diff --git a/CHANGELOG b/CHANGELOG index 7135db9ea..d69068bd7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/libpcap/CHANGES b/libpcap/CHANGES index dc4e00699..de3ac954f 100644 --- a/libpcap/CHANGES +++ b/libpcap/CHANGES @@ -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 diff --git a/libpcap/CREDITS b/libpcap/CREDITS index 2cd7207d4..2d7c09e9d 100644 --- a/libpcap/CREDITS +++ b/libpcap/CREDITS @@ -10,9 +10,10 @@ The current maintainers: Additional people who have contributed patches: Alan Bawden + Albert Chin Alexander 'Leo' Bergolth Alexey Kuznetsov - Albert Chin + Alon Bar-Lev Andrew Brown Antti Kantee Arien Vijn @@ -23,24 +24,28 @@ Additional people who have contributed patches: Charles M. Hannum Chris G. Demetriou Chris Lightfoot + Chris Maynard Chris Pepper + Christian Bell Christian Peron Daniele Orlandi - Darren Reed + Darren Reed David Kaelbling David Young Dean Gaudet Don Ebright Dug Song + Dustin Spicuzza Eric Anderson Erik de Castro Lopo + Felix Obenhuber Florent Drouin Franz Schaefer Fulko Hew + Fumiyuki Shimizu Gianluca Varenni Gilbert Hoyek Gisle Vanem - Gisle Vanem Graeme Hewson Greg Stark Greg Troxel @@ -53,11 +58,13 @@ Additional people who have contributed patches: Jason R. Thorpe Javier Achirica Jean Tourrilhes + Jean-Louis Charton Jefferson Ogata Jesper Peterson Joerg Mayer John Bankier Jon Lindgren + Jon Smirl Juergen Schoenwaelder Jung-uk Kim Kazushi Sugyo @@ -67,19 +74,22 @@ Additional people who have contributed patches: Krzysztof Halasa Lorenzo Cavallaro Loris Degioanni - Love Hörnquist-Åstrand + Love Hörnquist-Ã…strand Luis Martin Garcia Maciej W. Rozycki Marcus Felipe Pereira Mark C. Brown Mark Pizzolato + Markus Mayer Martin Husemann + Márton Németh Matthew Luckie Max Laier Mike Frysinger Mike Kershaw Mike Wiacek Monroe Williams + N. Leiten Nicolas Dade Octavian Cerna Olaf Kirch @@ -93,15 +103,20 @@ Additional people who have contributed patches: Pawel Pokrywka Peter Fales Peter Jeremy + Peter Volkov Phil Wood Rafal Maszkowski Richard Stearn Rick Jones + Robert Edmonds + Roberto Mariani + Romain Francoise Sagun Shakya Scott Barron Scott Gifford Sebastian Krahmer + Sebastien Roy Sepherosa Ziehau Shaun Clowes Solomon Peachy @@ -109,12 +124,16 @@ Additional people who have contributed patches: Stephen Donnelly Takashi Yamamoto Tanaka Shin-ya + Tobias Poschwatta Tony Li Torsten Landschoff Uns Lider Uwe Girlich + Wesley Shields Xianjie Zhang + Xin Li Yen Yen Lim + Yvan Vanhullebus Yoann Vandoorselaere The original LBL crew: diff --git a/libpcap/ChmodBPF/StartupParameters.plist b/libpcap/ChmodBPF/StartupParameters.plist index 545e2a683..cba21664f 100644 --- a/libpcap/ChmodBPF/StartupParameters.plist +++ b/libpcap/ChmodBPF/StartupParameters.plist @@ -1,4 +1,4 @@ { Description = "Change BPF permissions"; - Provides = ("Non-root permission to capture or send raw packets"); + Provides = ("ChmodBPF"); } diff --git a/libpcap/INSTALL.txt b/libpcap/INSTALL.txt index c7cfd2261..58d8e3c65 100644 --- a/libpcap/INSTALL.txt +++ b/libpcap/INSTALL.txt @@ -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 diff --git a/libpcap/Makefile.in b/libpcap/Makefile.in index 470696440..e7ac6a95c 100644 --- a/libpcap/Makefile.in +++ b/libpcap/Makefile.in @@ -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) \ diff --git a/libpcap/NMAP_MODIFICATIONS b/libpcap/NMAP_MODIFICATIONS index 31c5cbdbb..7357073f1 100644 --- a/libpcap/NMAP_MODIFICATIONS +++ b/libpcap/NMAP_MODIFICATIONS @@ -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 - #include - ]) -- 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 -+#include -+#ifdef HAVE_SYS_IOCCOM_H -+#include -+#endif -+#include -+ ]) - ;; - - 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. diff --git a/libpcap/README b/libpcap/README index ee1a14186..47944d7a7 100644 --- a/libpcap/README +++ b/libpcap/README @@ -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 diff --git a/libpcap/README.Win32 b/libpcap/README.Win32 index 3116d5ed2..503836e34 100644 --- a/libpcap/README.Win32 +++ b/libpcap/README.Win32 @@ -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. diff --git a/libpcap/README.linux b/libpcap/README.linux index dd959139d..226b2438b 100644 --- a/libpcap/README.linux +++ b/libpcap/README.linux @@ -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 diff --git a/libpcap/README.macosx b/libpcap/README.macosx index cfda4b867..3dc921171 100644 --- a/libpcap/README.macosx +++ b/libpcap/README.macosx @@ -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.) diff --git a/libpcap/TODO b/libpcap/TODO index 3de4530ed..73325e196 100644 --- a/libpcap/TODO +++ b/libpcap/TODO @@ -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. diff --git a/libpcap/VERSION b/libpcap/VERSION index 3eefcb9dd..524cb5524 100644 --- a/libpcap/VERSION +++ b/libpcap/VERSION @@ -1 +1 @@ -1.0.0 +1.1.1 diff --git a/libpcap/acconfig.h b/libpcap/acconfig.h deleted file mode 100644 index a23f320c2..000000000 --- a/libpcap/acconfig.h +++ /dev/null @@ -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 diff --git a/libpcap/aclocal.m4 b/libpcap/aclocal.m4 index 5ceb076c9..e5841edf0 100644 --- a/libpcap/aclocal.m4 +++ b/libpcap/aclocal.m4 @@ -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 ], + [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 @@ -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 -# if STDC_HEADERS -# include -# include -# 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]) diff --git a/libpcap/arcnet.h b/libpcap/arcnet.h index dce73353e..4f86043e6 100644 --- a/libpcap/arcnet.h +++ b/libpcap/arcnet.h @@ -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 */ diff --git a/libpcap/atmuni31.h b/libpcap/atmuni31.h index 11242b8bf..880cc1a8a 100644 --- a/libpcap/atmuni31.h +++ b/libpcap/atmuni31.h @@ -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 */ diff --git a/libpcap/bpf/net/bpf_filter.c b/libpcap/bpf/net/bpf_filter.c index a2733d1b1..a51ed7875 100644 --- a/libpcap/bpf/net/bpf_filter.c +++ b/libpcap/bpf/net/bpf_filter.c @@ -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 +#elif HAVE_STDINT_H +#include +#endif +#ifdef HAVE_SYS_BITYPES_H +#include +#endif + #include #include #include @@ -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 */ diff --git a/libpcap/bpf_dump.c b/libpcap/bpf_dump.c index 5c0033dc5..e4ff4a239 100644 --- a/libpcap/bpf_dump.c +++ b/libpcap/bpf_dump.c @@ -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 diff --git a/libpcap/bpf_image.c b/libpcap/bpf_image.c index 91f7cef43..e2f1a774a 100644 --- a/libpcap/bpf_image.c +++ b/libpcap/bpf_image.c @@ -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 +#else /* WIN32 */ +#if HAVE_INTTYPES_H +#include +#elif HAVE_STDINT_H +#include +#endif +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +#include +#endif /* WIN32 */ + #include #include diff --git a/libpcap/config.h.in b/libpcap/config.h.in index 3e3c6ad24..55e13dad7 100644 --- a/libpcap/config.h.in +++ b/libpcap/config.h.in @@ -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 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 header file. */ +#undef HAVE_LINUX_USBDEVICE_FS_H + /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_WIRELESS_H @@ -80,7 +79,7 @@ /* Define to 1 if you have the 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 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 header file. */ +#undef HAVE_SYS_BITYPES_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_BUFMOD_H @@ -158,6 +160,9 @@ /* Define to 1 if you have the 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 diff --git a/libpcap/configure b/libpcap/configure index 3727767a0..daf0be828 100755 --- a/libpcap/configure +++ b/libpcap/configure @@ -1,19 +1,23 @@ #! /bin/sh -# From configure.in Revision: 1.138.2.22 . +# From configure.in Revision: 1.168 . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.63. +# Generated by GNU Autoconf 2.65. +# # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# +# # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which @@ -21,23 +25,15 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; esac - fi - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - as_nl=' ' export as_nl @@ -45,7 +41,13 @@ export as_nl as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else @@ -56,7 +58,7 @@ else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; - case $arg in + case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; @@ -79,13 +81,6 @@ if test "${PATH_SEPARATOR+set}" != set; then } fi -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - # IFS # We need space, tab and new line, in precisely that order. Quoting is @@ -95,15 +90,15 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -case $0 in +case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done IFS=$as_save_IFS ;; @@ -115,12 +110,16 @@ if test "x$as_myself" = x; then fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } + exit 1 fi -# Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' @@ -132,7 +131,248 @@ export LC_ALL LANGUAGE=C export LANGUAGE -# Required to use basename. +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + # We cannot yet assume a decent shell, so we have to provide a + # neutralization value for shells without unset; and this also + # works around shells that cannot unset nonexistent variables. + BASH_ENV=/dev/null + ENV=/dev/null + (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, +$0: including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error ERROR [LINENO LOG_FD] +# --------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with status $?, using 1 if that was 0. +as_fn_error () +{ + as_status=$?; test $as_status -eq 0 && as_status=1 + if test "$3"; then + as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + fi + $as_echo "$as_me: error: $1" >&2 + as_fn_exit $as_status +} # as_fn_error + if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr @@ -146,8 +386,12 @@ else as_basename=false fi +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi -# Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ @@ -167,295 +411,19 @@ $as_echo X/"$0" | } s/.*/./; q'` -# CDPATH. -$as_unset CDPATH +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits -if test "x$CONFIG_SHELL" = x; then - if (eval ":") 2>/dev/null; then - as_have_required=yes -else - as_have_required=no -fi - - if test $as_have_required = yes && (eval ": -(as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test \$exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=\$LINENO - as_lineno_2=\$LINENO - test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && - test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } -") 2> /dev/null; then - : -else - as_candidate_shells= - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - case $as_dir in - /*) - for as_base in sh bash ksh sh5; do - as_candidate_shells="$as_candidate_shells $as_dir/$as_base" - done;; - esac -done -IFS=$as_save_IFS - - - for as_shell in $as_candidate_shells $SHELL; do - # Try only shells that exist, to save several forks. - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { ("$as_shell") 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - -: -_ASEOF -}; then - CONFIG_SHELL=$as_shell - as_have_required=yes - if { "$as_shell" 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - -: -(as_func_return () { - (exit $1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = "$1" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test $exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } - -_ASEOF -}; then - break -fi - -fi - - done - - if test "x$CONFIG_SHELL" != x; then - for as_var in BASH_ENV ENV - do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - done - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} -fi - - - if test $as_have_required = no; then - echo This script requires a shell more modern than all the - echo shells that I found on your system. Please install a - echo modern shell, or manually run the script under such a - echo shell if you do have one. - { (exit 1); exit 1; } -fi - - -fi - -fi - - - -(eval "as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test \$exitcode = 0") || { - echo No shell found that supports shell functions. - echo Please tell bug-autoconf@gnu.org about your system, - echo including any error possibly output before this message. - echo This can help us improve future autoconf versions. - echo Configuration will now proceed without shell functions. -} - - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= @@ -472,8 +440,7 @@ test \$exitcode = 0") || { s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the @@ -483,29 +450,18 @@ test \$exitcode = 0") || { exit } - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in +case `echo -n x` in #((((( -n*) - case `echo 'x\c'` in + case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then @@ -535,7 +491,7 @@ rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then - as_mkdir_p=: + as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false @@ -554,10 +510,10 @@ else if test -d "$1"; then test -d "$1/."; else - case $1 in + case $1 in #( -*)set "./$1";; esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' @@ -571,8 +527,8 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - -exec 7<&0 &1 +test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, @@ -590,7 +546,6 @@ cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME= @@ -598,6 +553,7 @@ PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= +PACKAGE_URL= ac_unique_file="pcap.c" # Factoring default headers for most tests. @@ -640,23 +596,29 @@ ac_subst_vars='LTLIBOBJS INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM +CAN_SRC +PCAP_SUPPORT_CAN BT_SRC PCAP_SUPPORT_BT USB_SRC PCAP_SUPPORT_USB MAN_MISC_INFO MAN_FILE_FORMATS -DEPLIBS -DAGLIBS DYEXT SSRC -V_FINDALLDEVS +ADDLARCHIVEOBJS +ADDLOBJS +V_RPATH_OPT +V_SONAME_OPT +V_SHLIB_OPT +V_SHLIB_CMD V_PCAP -V_LIBS V_INCLS +V_FINDALLDEVS V_DEFS V_CCOPT RANLIB +HAVE_LINUX_TPACKET_AUXDATA LIBOBJS EGREP GREP @@ -711,6 +673,7 @@ bindir program_transform_name prefix exec_prefix +PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION @@ -726,6 +689,7 @@ enable_largefile enable_protochain with_sita with_pcap +with_libnl enable_ipv6 enable_optimizer_dbg enable_yydebug @@ -733,6 +697,11 @@ with_dag with_dag_includes with_dag_libraries with_septel +with_snf +with_snf_includes +with_snf_libraries +enable_bluetooth +enable_can ' ac_precious_vars='build_alias host_alias @@ -851,8 +820,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -878,8 +846,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1083,8 +1050,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1100,8 +1066,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1131,17 +1096,17 @@ do | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) { $as_echo "$as_me: error: unrecognized option: $ac_option -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } + -*) as_fn_error "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information." ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. - expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2 - { (exit 1); exit 1; }; } + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error "invalid variable name: \`$ac_envvar'" ;; + esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; @@ -1158,15 +1123,13 @@ done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - { $as_echo "$as_me: error: missing argument to $ac_option" >&2 - { (exit 1); exit 1; }; } + as_fn_error "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; - fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2 - { (exit 1); exit 1; }; } ;; + fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi @@ -1189,8 +1152,7 @@ do [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac - { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; } + as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' @@ -1220,11 +1182,9 @@ test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - { $as_echo "$as_me: error: working directory cannot be determined" >&2 - { (exit 1); exit 1; }; } + as_fn_error "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - { $as_echo "$as_me: error: pwd does not report name of working directory" >&2 - { (exit 1); exit 1; }; } + as_fn_error "pwd does not report name of working directory" # Find the source files, if location was not specified. @@ -1263,13 +1223,11 @@ else fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 - { (exit 1); exit 1; }; } + as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2 - { (exit 1); exit 1; }; } + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then @@ -1369,9 +1327,14 @@ Optional Features: --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-largefile omit support for large files --disable-protochain disable \"protochain\" insn - --enable-ipv6 build IPv6-capable version [default=yes, if getaddrinfo available] + --enable-ipv6 build IPv6-capable version [default=yes, if + getaddrinfo available] --enable-optimizer-dbg build optimizer debugging code --enable-yydebug build parser debugging code + --enable-bluetooth enable Bluetooth support [default=yes, if support + available] + --enable-can enable CAN support [default=yes, if support + available] Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -1379,10 +1342,20 @@ Optional Packages: --without-gcc don't use gcc --with-sita include SITA support --with-pcap=TYPE use packet capture TYPE - --with-dag[=DIR] include Endace DAG support ("yes", "no" or DIR; default="yes" on BSD and Linux if present) - --with-dag-includes=DIR Endace DAG include directory - --with-dag-libraries=DIR Endace DAG library directory - --with-septel[=DIR] include Septel support (located in directory DIR, if supplied). default=yes, on Linux, if present + --without-libnl disable libnl support [default=yes, on Linux, if + present] + --with-dag[=DIR] include Endace DAG support ["yes", "no" or DIR; + default="yes" on BSD and Linux if present] + --with-dag-includes=DIR Endace DAG include directory + --with-dag-libraries=DIR + Endace DAG library directory + --with-septel[=DIR] include Septel support (located in directory DIR, if + supplied). [default=yes, on Linux, if present] + --with-snf[=DIR] include Myricom SNF support ["yes", "no" or DIR; + default="yes" on BSD and Linux if present] + --with-snf-includes=DIR Myricom SNF include directory + --with-snf-libraries=DIR + Myricom SNF library directory Some influential environment variables: CC C compiler command @@ -1390,13 +1363,14 @@ Some influential environment variables: LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. +Report bugs to the package provider. _ACEOF ac_status=$? fi @@ -1460,21 +1434,465 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF configure -generated by GNU Autoconf 2.63 +generated by GNU Autoconf 2.65 -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 2009 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_header_compile + +# ac_fn_c_check_type LINENO TYPE VAR INCLUDES +# ------------------------------------------- +# Tests whether TYPE exists after having included INCLUDES, setting cache +# variable VAR accordingly. +ac_fn_c_check_type () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof ($2)) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof (($2))) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + eval "$3=yes" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_type + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_check_func LINENO FUNC VAR +# ---------------------------------- +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_c_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_func + +# ac_fn_c_check_decl LINENO SYMBOL VAR +# ------------------------------------ +# Tests whether SYMBOL is declared, setting cache variable VAR accordingly. +ac_fn_c_check_decl () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5 +$as_echo_n "checking whether $2 is declared... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +#ifndef $2 + (void) $2; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_decl cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was -generated by GNU Autoconf 2.63. Invocation command line was +generated by GNU Autoconf 2.65. Invocation command line was $ $0 $@ @@ -1510,8 +1928,8 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" -done + $as_echo "PATH: $as_dir" + done IFS=$as_save_IFS } >&5 @@ -1548,9 +1966,9 @@ do ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in - 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) - ac_configure_args1="$ac_configure_args1 '$ac_arg'" + as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else @@ -1566,13 +1984,13 @@ do -* ) ac_must_keep_next=true ;; esac fi - ac_configure_args="$ac_configure_args '$ac_arg'" + as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done -$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } -$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there @@ -1597,13 +2015,13 @@ _ASBOX case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) $as_unset $ac_var ;; + *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done @@ -1675,39 +2093,41 @@ _ASBOX exit $exit_status ' 0 for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h +$as_echo "/* confdefs.h */" > confdefs.h + # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. @@ -1725,8 +2145,8 @@ fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue - if test -r "$ac_site_file"; then - { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" @@ -1734,10 +2154,10 @@ $as_echo "$as_me: loading site script $ac_site_file" >&6;} done if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special - # files actually), so we avoid doing that. - if test -f "$cache_file"; then - { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5 + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; @@ -1745,7 +2165,7 @@ $as_echo "$as_me: loading cache $cache_file" >&6;} esac fi else - { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi @@ -1760,11 +2180,11 @@ for ac_var in $ac_precious_vars; do eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) - { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) - { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; @@ -1774,17 +2194,17 @@ $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else - { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi - { $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac @@ -1796,35 +2216,20 @@ $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then - { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 -$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi - - - - - - - - - - - - - - - - +## -------------------- ## +## Main body of script. ## +## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -1836,24 +2241,16 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do - if test -f "$ac_dir/install-sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f "$ac_dir/install.sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f "$ac_dir/shtool"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi + for ac_t in install-sh install.sh shtool; do + if test -f "$ac_dir/$ac_t"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/$ac_t -c" + break 2 + fi + done done if test -z "$ac_aux_dir"; then - { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 -$as_echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, @@ -1867,35 +2264,27 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - { { $as_echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 -$as_echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 -{ $as_echo "$as_me:$LINENO: checking build system type" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } -if test "${ac_cv_build+set}" = set; then +if test "${ac_cv_build+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && - { { $as_echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 -$as_echo "$as_me: error: cannot guess build type; you must specify one" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 -$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; -*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 -$as_echo "$as_me: error: invalid value of canonical build" >&2;} - { (exit 1); exit 1; }; };; +*) as_fn_error "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' @@ -1911,28 +2300,24 @@ IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac -{ $as_echo "$as_me:$LINENO: checking host system type" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } -if test "${ac_cv_host+set}" = set; then +if test "${ac_cv_host+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 -$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; -*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 -$as_echo "$as_me: error: invalid value of canonical host" >&2;} - { (exit 1); exit 1; }; };; +*) as_fn_error "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' @@ -1948,28 +2333,24 @@ IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac -{ $as_echo "$as_me:$LINENO: checking target system type" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 $as_echo_n "checking target system type... " >&6; } -if test "${ac_cv_target+set}" = set; then +if test "${ac_cv_target+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$target_alias" = x; then ac_cv_target=$ac_cv_host else ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || - { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&5 -$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_target" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 $as_echo "$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; -*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical target" >&5 -$as_echo "$as_me: error: invalid value of canonical target" >&2;} - { (exit 1); exit 1; }; };; +*) as_fn_error "invalid value of canonical target" "$LINENO" 5;; esac target=$ac_cv_target ac_save_IFS=$IFS; IFS='-' @@ -1997,8 +2378,10 @@ test -n "$target_alias" && + + # Check whether --with-gcc was given. -if test "${with_gcc+set}" = set; then +if test "${with_gcc+set}" = set; then : withval=$with_gcc; fi @@ -2016,9 +2399,9 @@ fi bsdi*) # Extract the first word of "shlicc2", so it can be a program name with args. set dummy shlicc2; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_SHLICC2+set}" = set; then +if test "${ac_cv_prog_SHLICC2+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$SHLICC2"; then @@ -2029,14 +2412,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_SHLICC2="yes" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS test -z "$ac_cv_prog_SHLICC2" && ac_cv_prog_SHLICC2="no" @@ -2044,10 +2427,10 @@ fi fi SHLICC2=$ac_cv_prog_SHLICC2 if test -n "$SHLICC2"; then - { $as_echo "$as_me:$LINENO: result: $SHLICC2" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SHLICC2" >&5 $as_echo "$SHLICC2" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2063,7 +2446,8 @@ fi CC=cc export CC fi - ac_ext=c + +ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' @@ -2071,9 +2455,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2084,24 +2468,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2111,9 +2495,9 @@ if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -2124,24 +2508,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2150,7 +2534,7 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -2164,9 +2548,9 @@ if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2177,24 +2561,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2204,9 +2588,9 @@ fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2218,18 +2602,18 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then @@ -2248,10 +2632,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2263,9 +2647,9 @@ if test -z "$CC"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2276,24 +2660,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2307,9 +2691,9 @@ if test -z "$CC"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -2320,24 +2704,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2350,7 +2734,7 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -2361,57 +2745,37 @@ fi fi -test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error "no acceptable C compiler found in \$PATH +See \`config.log' for more details." "$LINENO" 5; } # Provide some information about the compiler. -$as_echo "$as_me:$LINENO: checking for C compiler version" >&5 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 -{ (ac_try="$ac_compiler --version >&5" +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler --version >&5") 2>&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -v >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -v >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -V >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -V >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2427,8 +2791,8 @@ ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -{ $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: @@ -2444,17 +2808,17 @@ do done rm -f $ac_rmfiles -if { (ac_try="$ac_link_default" +if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, @@ -2471,7 +2835,7 @@ do # certainly right. break;; *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi @@ -2490,84 +2854,42 @@ test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi - -{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -if test -z "$ac_file"; then - $as_echo "$as_me: failed program was:" >&5 +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: C compiler cannot create executables -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; }; } -fi - -ac_exeext=$ac_cv_exeext - -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 -# If not cross compiling, check that we can run a simple program. -if test "$cross_compiling" != yes; then - if { ac_try='./$ac_file' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } - fi - fi -fi -{ $as_echo "$as_me:$LINENO: result: yes" >&5 +{ as_fn_set_status 77 +as_fn_error "C compiler cannot create executables +See \`config.log' for more details." "$LINENO" 5; }; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } -if { (ac_try="$ac_link" +if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with @@ -2582,32 +2904,83 @@ for ac_file in conftest.exe conftest conftest.*; do esac done else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." "$LINENO" 5; } fi - -rm -f conftest$ac_cv_exeext -{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT -{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then +if test "${ac_cv_objext+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2619,17 +2992,17 @@ main () } _ACEOF rm -f conftest.o conftest.obj -if { (ac_try="$ac_compile" +if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in @@ -2642,31 +3015,23 @@ else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error "cannot compute suffix of object files: cannot compile +See \`config.log' for more details." "$LINENO" 5; } fi - rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then +if test "${ac_cv_c_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2680,37 +3045,16 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_compiler_gnu=no + ac_compiler_gnu=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes @@ -2719,20 +3063,16 @@ else fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then +if test "${ac_cv_prog_cc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2743,35 +3083,11 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - CFLAGS="" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2782,36 +3098,12 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_compile "$LINENO"; then : - ac_c_werror_flag=$ac_save_c_werror_flag +else + ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2822,42 +3114,17 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS @@ -2874,18 +3141,14 @@ else CFLAGS= fi fi -{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then +if test "${ac_cv_prog_cc_c89+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -2942,32 +3205,9 @@ for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" - rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done @@ -2978,17 +3218,19 @@ fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) - { $as_echo "$as_me:$LINENO: result: none needed" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) - { $as_echo "$as_me:$LINENO: result: unsupported" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac +if test "x$ac_cv_prog_cc_c89" != xno; then : +fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -2996,14 +3238,18 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + if test "$GCC" = yes ; then if test "$SHLICC2" = yes ; then ac_cv_lbl_gcc_vers=2 V_CCOPT="-O2" else - { $as_echo "$as_me:$LINENO: checking gcc version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking gcc version" >&5 $as_echo_n "checking gcc version... " >&6; } - if test "${ac_cv_lbl_gcc_vers+set}" = set; then + if test "${ac_cv_lbl_gcc_vers+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_lbl_gcc_vers=`$CC -v 2>&1 | \ @@ -3013,24 +3259,20 @@ else -e 's/\..*//'` fi - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_gcc_vers" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_gcc_vers" >&5 $as_echo "$ac_cv_lbl_gcc_vers" >&6; } if test $ac_cv_lbl_gcc_vers -gt 1 ; then V_CCOPT="-O2" fi fi else - { $as_echo "$as_me:$LINENO: checking that $CC handles ansi prototypes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking that $CC handles ansi prototypes" >&5 $as_echo_n "checking that $CC handles ansi prototypes... " >&6; } - if test "${ac_cv_lbl_cc_ansi_prototypes+set}" = set; then + if test "${ac_cv_lbl_cc_ansi_prototypes+set}" = set; then : $as_echo_n "(cached) " >&6 else -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -3041,53 +3283,28 @@ int frob(int, char *) return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_lbl_cc_ansi_prototypes=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lbl_cc_ansi_prototypes=no + ac_cv_lbl_cc_ansi_prototypes=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_cc_ansi_prototypes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_cc_ansi_prototypes" >&5 $as_echo "$ac_cv_lbl_cc_ansi_prototypes" >&6; } if test $ac_cv_lbl_cc_ansi_prototypes = no ; then case "$host_os" in hpux*) - { $as_echo "$as_me:$LINENO: checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)" >&5 $as_echo_n "checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)... " >&6; } savedcflags="$CFLAGS" CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS" - if test "${ac_cv_lbl_cc_hpux_cc_aa+set}" = set; then + if test "${ac_cv_lbl_cc_hpux_cc_aa+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -3098,55 +3315,64 @@ int frob(int, char *) return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_lbl_cc_hpux_cc_aa=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lbl_cc_hpux_cc_aa=no + ac_cv_lbl_cc_hpux_cc_aa=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_cc_hpux_cc_aa" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_cc_hpux_cc_aa" >&5 $as_echo "$ac_cv_lbl_cc_hpux_cc_aa" >&6; } if test $ac_cv_lbl_cc_hpux_cc_aa = no ; then - { { $as_echo "$as_me:$LINENO: error: see the INSTALL doc for more info" >&5 -$as_echo "$as_me: error: see the INSTALL doc for more info" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "see the INSTALL doc for more info" "$LINENO" 5 fi CFLAGS="$savedcflags" V_CCOPT="-Aa $V_CCOPT" -cat >>confdefs.h <<\_ACEOF -#define _HPUX_SOURCE 1 -_ACEOF +$as_echo "#define _HPUX_SOURCE 1" >>confdefs.h ;; + osf*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ansi mode in DEC compiler ($CC -std1)" >&5 +$as_echo_n "checking for ansi mode in DEC compiler ($CC -std1)... " >&6; } + savedcflags="$CFLAGS" + CFLAGS="-std1" + if test "${ac_cv_lbl_cc_osf1_cc_std1+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +int frob(int, char *) + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_lbl_cc_osf1_cc_std1=yes +else + ac_cv_lbl_cc_osf1_cc_std1=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_cc_osf1_cc_std1" >&5 +$as_echo "$ac_cv_lbl_cc_osf1_cc_std1" >&6; } + if test $ac_cv_lbl_cc_osf1_cc_std1 = no ; then + as_fn_error "see the INSTALL doc for more info" "$LINENO" 5 + fi + CFLAGS="$savedcflags" + V_CCOPT="-std1 $V_CCOPT" + ;; + *) - { { $as_echo "$as_me:$LINENO: error: see the INSTALL doc for more info" >&5 -$as_echo "$as_me: error: see the INSTALL doc for more info" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "see the INSTALL doc for more info" "$LINENO" 5 ;; esac fi @@ -3160,20 +3386,20 @@ $as_echo "$as_me: error: see the INSTALL doc for more info" >&2;} ;; osf*) - V_CCOPT="$V_CCOPT -std1 -g3" + # + # Presumed to be DEC OSF/1, Digital UNIX, or + # Tru64 UNIX. + # + V_CCOPT="$V_CCOPT -g3" ;; ultrix*) - { $as_echo "$as_me:$LINENO: checking that Ultrix $CC hacks const in prototypes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking that Ultrix $CC hacks const in prototypes" >&5 $as_echo_n "checking that Ultrix $CC hacks const in prototypes... " >&6; } - if test "${ac_cv_lbl_cc_const_proto+set}" = set; then + if test "${ac_cv_lbl_cc_const_proto+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -3185,52 +3411,160 @@ struct a { int b; }; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_lbl_cc_const_proto=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lbl_cc_const_proto=no + ac_cv_lbl_cc_const_proto=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_cc_const_proto" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_cc_const_proto" >&5 $as_echo "$ac_cv_lbl_cc_const_proto" >&6; } if test $ac_cv_lbl_cc_const_proto = no ; then - cat >>confdefs.h <<\_ACEOF -#define const /**/ -_ACEOF + +$as_echo "#define const /**/" >>confdefs.h fi ;; esac fi -{ $as_echo "$as_me:$LINENO: checking for inline" >&5 + + 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 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } save_CFLAGS="$CFLAGS" CFLAGS="$V_CCOPT" - if test "${ac_cv_lbl_inline+set}" = set; then + if test "${ac_cv_lbl_inline+set}" = set; then : $as_echo_n "(cached) " >&6 else @@ -3238,11 +3572,7 @@ else ac_lbl_cc_inline=no for ac_lbl_inline in inline __inline__ __inline do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define inline $ac_lbl_inline static inline struct iltest *foo(void); @@ -3266,32 +3596,9 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_lbl_cc_inline=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "$ac_lbl_cc_inline" = yes ; then break; @@ -3304,10 +3611,10 @@ fi CFLAGS="$save_CFLAGS" if test ! -z "$ac_cv_lbl_inline" ; then - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_inline" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_inline" >&5 $as_echo "$ac_cv_lbl_inline" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3316,17 +3623,13 @@ cat >>confdefs.h <<_ACEOF _ACEOF -{ $as_echo "$as_me:$LINENO: checking for __attribute__" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__" >&5 $as_echo_n "checking for __attribute__... " >&6; } -if test "${ac_cv___attribute__+set}" = set; then +if test "${ac_cv___attribute__+set}" = set; then : $as_echo_n "(cached) " >&6 else -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -3346,811 +3649,39 @@ main(int argc, char **argv) } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv___attribute__=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv___attribute__=no + ac_cv___attribute__=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test "$ac_cv___attribute__" = "yes"; then -cat >>confdefs.h <<\_ACEOF -#define HAVE___ATTRIBUTE__ 1 -_ACEOF +$as_echo "#define HAVE___ATTRIBUTE__ 1" >>confdefs.h V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\"" else V_DEFS="$V_DEFS -D_U_=\"\"" fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv___attribute__" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute__" >&5 $as_echo "$ac_cv___attribute__" >&6; } -{ $as_echo "$as_me:$LINENO: checking for u_int8_t using $CC" >&5 -$as_echo_n "checking for u_int8_t using $CC... " >&6; } - if test "${ac_cv_lbl_have_u_int8_t+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -# include "confdefs.h" -# include -# if STDC_HEADERS -# include -# include -# endif -int -main () -{ -u_int8_t i - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_lbl_have_u_int8_t=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lbl_have_u_int8_t=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_have_u_int8_t" >&5 -$as_echo "$ac_cv_lbl_have_u_int8_t" >&6; } - if test $ac_cv_lbl_have_u_int8_t = no ; then - -cat >>confdefs.h <<\_ACEOF -#define u_int8_t u_char -_ACEOF - - fi -{ $as_echo "$as_me:$LINENO: checking for u_int16_t using $CC" >&5 -$as_echo_n "checking for u_int16_t using $CC... " >&6; } - if test "${ac_cv_lbl_have_u_int16_t+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -# include "confdefs.h" -# include -# if STDC_HEADERS -# include -# include -# endif -int -main () -{ -u_int16_t i - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_lbl_have_u_int16_t=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lbl_have_u_int16_t=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_have_u_int16_t" >&5 -$as_echo "$ac_cv_lbl_have_u_int16_t" >&6; } - if test $ac_cv_lbl_have_u_int16_t = no ; then - -cat >>confdefs.h <<\_ACEOF -#define u_int16_t u_short -_ACEOF - - fi -{ $as_echo "$as_me:$LINENO: checking for u_int32_t using $CC" >&5 -$as_echo_n "checking for u_int32_t using $CC... " >&6; } - if test "${ac_cv_lbl_have_u_int32_t+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -# include "confdefs.h" -# include -# if STDC_HEADERS -# include -# include -# endif -int -main () -{ -u_int32_t i - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_lbl_have_u_int32_t=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lbl_have_u_int32_t=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_have_u_int32_t" >&5 -$as_echo "$ac_cv_lbl_have_u_int32_t" >&6; } - if test $ac_cv_lbl_have_u_int32_t = no ; then - -cat >>confdefs.h <<\_ACEOF -#define u_int32_t u_int -_ACEOF - - fi -{ $as_echo "$as_me:$LINENO: checking for u_int64_t using $CC" >&5 -$as_echo_n "checking for u_int64_t using $CC... " >&6; } - if test "${ac_cv_lbl_have_u_int64_t+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -# include "confdefs.h" -# include -# if STDC_HEADERS -# include -# include -# endif -int -main () -{ -u_int64_t i - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_lbl_have_u_int64_t=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lbl_have_u_int64_t=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_have_u_int64_t" >&5 -$as_echo "$ac_cv_lbl_have_u_int64_t" >&6; } - if test $ac_cv_lbl_have_u_int64_t = no ; then - -cat >>confdefs.h <<\_ACEOF -#define u_int64_t unsigned long long -_ACEOF - - fi - -# -# Try to arrange for large file support. -# -# Check whether --enable-largefile was given. -if test "${enable_largefile+set}" = set; then - enableval=$enable_largefile; -fi - -if test "$enable_largefile" != no; then - - { $as_echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5 -$as_echo_n "checking for special C compiler options needed for large files... " >&6; } -if test "${ac_cv_sys_largefile_CC+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_sys_largefile_CC=no - if test "$GCC" != yes; then - ac_save_CC=$CC - while :; do - # IRIX 6.2 and later do not support large files by default, - # so use the C compiler's -n32 option if that helps. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF - rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext - CC="$CC -n32" - rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_sys_largefile_CC=' -n32'; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext - break - done - CC=$ac_save_CC - rm -f conftest.$ac_ext - fi -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5 -$as_echo "$ac_cv_sys_largefile_CC" >&6; } - if test "$ac_cv_sys_largefile_CC" != no; then - CC=$CC$ac_cv_sys_largefile_CC - fi - - { $as_echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5 -$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } -if test "${ac_cv_sys_file_offset_bits+set}" = set; then - $as_echo_n "(cached) " >&6 -else - while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_sys_file_offset_bits=no; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#define _FILE_OFFSET_BITS 64 -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_sys_file_offset_bits=64; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_cv_sys_file_offset_bits=unknown - break -done -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5 -$as_echo "$ac_cv_sys_file_offset_bits" >&6; } -case $ac_cv_sys_file_offset_bits in #( - no | unknown) ;; - *) -cat >>confdefs.h <<_ACEOF -#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits -_ACEOF -;; -esac -rm -rf conftest* - if test $ac_cv_sys_file_offset_bits = unknown; then - { $as_echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5 -$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } -if test "${ac_cv_sys_large_files+set}" = set; then - $as_echo_n "(cached) " >&6 -else - while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_sys_large_files=no; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#define _LARGE_FILES 1 -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_sys_large_files=1; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_cv_sys_large_files=unknown - break -done -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5 -$as_echo "$ac_cv_sys_large_files" >&6; } -case $ac_cv_sys_large_files in #( - no | unknown) ;; - *) -cat >>confdefs.h <<_ACEOF -#define _LARGE_FILES $ac_cv_sys_large_files -_ACEOF -;; -esac -rm -rf conftest* - fi -fi - -{ $as_echo "$as_me:$LINENO: checking for _LARGEFILE_SOURCE value needed for large files" >&5 -$as_echo_n "checking for _LARGEFILE_SOURCE value needed for large files... " >&6; } -if test "${ac_cv_sys_largefile_source+set}" = set; then - $as_echo_n "(cached) " >&6 -else - while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include /* for off_t */ - #include -int -main () -{ -int (*fp) (FILE *, off_t, int) = fseeko; - return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_sys_largefile_source=no; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#define _LARGEFILE_SOURCE 1 -#include /* for off_t */ - #include -int -main () -{ -int (*fp) (FILE *, off_t, int) = fseeko; - return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_sys_largefile_source=1; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext - ac_cv_sys_largefile_source=unknown - break -done -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_source" >&5 -$as_echo "$ac_cv_sys_largefile_source" >&6; } -case $ac_cv_sys_largefile_source in #( - no | unknown) ;; - *) -cat >>confdefs.h <<_ACEOF -#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source -_ACEOF -;; -esac -rm -rf conftest* - -# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug -# in glibc 2.1.3, but that breaks too many other things. -# If you want fseeko and ftello with glibc, upgrade to a fixed glibc. -if test $ac_cv_sys_largefile_source != unknown; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_FSEEKO 1 -_ACEOF - -fi - - ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then + if test "${ac_cv_prog_CPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -4165,11 +3696,7 @@ do # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include @@ -4178,78 +3705,34 @@ cat >>conftest.$ac_ext <<_ACEOF #endif Syntax error _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_cpp "$LINENO"; then : +else # Broken: fails on valid input. continue fi - rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then +if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - # Passes both tests. ac_preproc_ok=: break fi - rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then +if $ac_preproc_ok; then : break fi @@ -4261,7 +3744,7 @@ fi else ac_cv_prog_CPP=$CPP fi -{ $as_echo "$as_me:$LINENO: result: $CPP" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes @@ -4272,11 +3755,7 @@ do # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include @@ -4285,87 +3764,40 @@ cat >>conftest.$ac_ext <<_ACEOF #endif Syntax error _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_cpp "$LINENO"; then : +else # Broken: fails on valid input. continue fi - rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then +if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - # Passes both tests. ac_preproc_ok=: break fi - rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - : +if $ac_preproc_ok; then : + else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." "$LINENO" 5; } fi ac_ext=c @@ -4375,9 +3807,9 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then +if test "${ac_cv_path_GREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then @@ -4388,7 +3820,7 @@ for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do + for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue @@ -4408,7 +3840,7 @@ case `"$ac_path_GREP" --version 2>&1` in $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` + as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" @@ -4423,26 +3855,24 @@ esac $ac_path_GREP_found && break 3 done done -done + done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" -{ $as_echo "$as_me:$LINENO: checking for egrep" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then +if test "${ac_cv_path_EGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 @@ -4456,7 +3886,7 @@ for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do + for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue @@ -4476,7 +3906,7 @@ case `"$ac_path_EGREP" --version 2>&1` in $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` + as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" @@ -4491,12 +3921,10 @@ esac $ac_path_EGREP_found && break 3 done done -done + done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP @@ -4504,21 +3932,17 @@ fi fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" -{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then +if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -4533,48 +3957,23 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_header_stdc=no + ac_cv_header_stdc=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then - : + $EGREP "memchr" >/dev/null 2>&1; then : + else ac_cv_header_stdc=no fi @@ -4584,18 +3983,14 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then - : + $EGREP "free" >/dev/null 2>&1; then : + else ac_cv_header_stdc=no fi @@ -4605,14 +4000,10 @@ fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then + if test "$cross_compiling" = yes; then : : else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -4639,118 +4030,34 @@ main () return 0; } _ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : +if ac_fn_c_try_run "$LINENO"; then : + else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_header_stdc=no + ac_cv_header_stdc=no fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi - fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then -cat >>confdefs.h <<\_ACEOF -#define STDC_HEADERS 1 -_ACEOF +$as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. - - - - - - - - - for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - eval "$as_ac_Header=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_Header=no" -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -4760,147 +4067,400 @@ fi done +for ac_header in sys/bitypes.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "sys/bitypes.h" "ac_cv_header_sys_bitypes_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_bitypes_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_BITYPES_H 1 +_ACEOF + +fi + +done +ac_fn_c_check_type "$LINENO" "int8_t" "ac_cv_type_int8_t" "$ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +" +if test "x$ac_cv_type_int8_t" = x""yes; then : + +else + +$as_echo "#define int8_t signed char" >>confdefs.h + +fi + +ac_fn_c_check_type "$LINENO" "u_int8_t" "ac_cv_type_u_int8_t" "$ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +" +if test "x$ac_cv_type_u_int8_t" = x""yes; then : + +else + +$as_echo "#define u_int8_t unsigned char" >>confdefs.h + +fi + +ac_fn_c_check_type "$LINENO" "int16_t" "ac_cv_type_int16_t" "$ac_includes_default" +if test "x$ac_cv_type_int16_t" = x""yes; then : + +else + +$as_echo "#define int16_t short" >>confdefs.h + + $ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +fi + +ac_fn_c_check_type "$LINENO" "u_int16_t" "ac_cv_type_u_int16_t" "$ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +" +if test "x$ac_cv_type_u_int16_t" = x""yes; then : + +else + +$as_echo "#define u_int16_t unsigned short" >>confdefs.h + +fi + +ac_fn_c_check_type "$LINENO" "int32_t" "ac_cv_type_int32_t" "$ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +" +if test "x$ac_cv_type_int32_t" = x""yes; then : + +else + +$as_echo "#define int32_t int" >>confdefs.h + +fi + +ac_fn_c_check_type "$LINENO" "u_int32_t" "ac_cv_type_u_int32_t" "$ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +" +if test "x$ac_cv_type_u_int32_t" = x""yes; then : + +else + +$as_echo "#define u_int32_t unsigned int" >>confdefs.h + +fi + +ac_fn_c_check_type "$LINENO" "int64_t" "ac_cv_type_int64_t" "$ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +" +if test "x$ac_cv_type_int64_t" = x""yes; then : + +else + +$as_echo "#define int64_t long long" >>confdefs.h + +fi + +ac_fn_c_check_type "$LINENO" "u_int64_t" "ac_cv_type_u_int64_t" "$ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +" +if test "x$ac_cv_type_u_int64_t" = x""yes; then : + +else + +$as_echo "#define u_int64_t unsigned long long" >>confdefs.h + +fi + + +# +# Try to arrange for large file support. +# +# Check whether --enable-largefile was given. +if test "${enable_largefile+set}" = set; then : + enableval=$enable_largefile; +fi + +if test "$enable_largefile" != no; then + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 +$as_echo_n "checking for special C compiler options needed for large files... " >&6; } +if test "${ac_cv_sys_largefile_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_sys_largefile_CC=no + if test "$GCC" != yes; then + ac_save_CC=$CC + while :; do + # IRIX 6.2 and later do not support large files by default, + # so use the C compiler's -n32 option if that helps. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF + if ac_fn_c_try_compile "$LINENO"; then : + break +fi +rm -f core conftest.err conftest.$ac_objext + CC="$CC -n32" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_largefile_CC=' -n32'; break +fi +rm -f core conftest.err conftest.$ac_objext + break + done + CC=$ac_save_CC + rm -f conftest.$ac_ext + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 +$as_echo "$ac_cv_sys_largefile_CC" >&6; } + if test "$ac_cv_sys_largefile_CC" != no; then + CC=$CC$ac_cv_sys_largefile_CC + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 +$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } +if test "${ac_cv_sys_file_offset_bits+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_file_offset_bits=no; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _FILE_OFFSET_BITS 64 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_file_offset_bits=64; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cv_sys_file_offset_bits=unknown + break +done +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 +$as_echo "$ac_cv_sys_file_offset_bits" >&6; } +case $ac_cv_sys_file_offset_bits in #( + no | unknown) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits +_ACEOF +;; +esac +rm -rf conftest* + if test $ac_cv_sys_file_offset_bits = unknown; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 +$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } +if test "${ac_cv_sys_large_files+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_large_files=no; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _LARGE_FILES 1 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_large_files=1; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cv_sys_large_files=unknown + break +done +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 +$as_echo "$ac_cv_sys_large_files" >&6; } +case $ac_cv_sys_large_files in #( + no | unknown) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _LARGE_FILES $ac_cv_sys_large_files +_ACEOF +;; +esac +rm -rf conftest* + fi +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGEFILE_SOURCE value needed for large files" >&5 +$as_echo_n "checking for _LARGEFILE_SOURCE value needed for large files... " >&6; } +if test "${ac_cv_sys_largefile_source+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include /* for off_t */ + #include +int +main () +{ +int (*fp) (FILE *, off_t, int) = fseeko; + return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_sys_largefile_source=no; break +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _LARGEFILE_SOURCE 1 +#include /* for off_t */ + #include +int +main () +{ +int (*fp) (FILE *, off_t, int) = fseeko; + return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_sys_largefile_source=1; break +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + ac_cv_sys_largefile_source=unknown + break +done +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_source" >&5 +$as_echo "$ac_cv_sys_largefile_source" >&6; } +case $ac_cv_sys_largefile_source in #( + no | unknown) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source +_ACEOF +;; +esac +rm -rf conftest* + +# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug +# in glibc 2.1.3, but that breaks too many other things. +# If you want fseeko and ftello with glibc, upgrade to a fixed glibc. +if test $ac_cv_sys_largefile_source != unknown; then + +$as_echo "#define HAVE_FSEEKO 1" >>confdefs.h + +fi for ac_header in sys/ioccom.h sys/sockio.h limits.h paths.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -4909,64 +4469,15 @@ fi done - for ac_header in net/pfvar.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include +do : + ac_fn_c_check_header_compile "$LINENO" "net/pfvar.h" "ac_cv_header_net_pfvar_h" "#include #include #include - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - eval "$as_ac_Header=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_Header=no" -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +" +if test "x$ac_cv_header_net_pfvar_h" = x""yes; then : cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define HAVE_NET_PFVAR_H 1 _ACEOF fi @@ -4977,13 +4488,9 @@ if test "$ac_cv_header_net_pfvar_h" = yes; then # # Check for various PF actions. # - { $as_echo "$as_me:$LINENO: checking whether net/pfvar.h defines PF_NAT through PF_NORDR" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether net/pfvar.h defines PF_NAT through PF_NORDR" >&5 $as_echo_n "checking whether net/pfvar.h defines PF_NAT through PF_NORDR... " >&6; } - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -4997,100 +4504,28 @@ return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } -cat >>confdefs.h <<\_ACEOF -#define HAVE_PF_NAT_THROUGH_PF_NORDR 1 -_ACEOF +$as_echo "#define HAVE_PF_NAT_THROUGH_PF_NORDR 1" >>confdefs.h else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - for ac_header in netinet/if_ether.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include +do : + ac_fn_c_check_header_compile "$LINENO" "netinet/if_ether.h" "ac_cv_header_netinet_if_ether_h" "#include #include - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - eval "$as_ac_Header=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_Header=no" -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +" +if test "x$ac_cv_header_netinet_if_ether_h" = x""yes; then : cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define HAVE_NETINET_IF_ETHER_H 1 _ACEOF fi @@ -5105,70 +4540,21 @@ if test "$ac_cv_header_netinet_if_ether_h" != yes; then # treat the previous failure as a cached value and # suppress the next test. # - { $as_echo "$as_me:$LINENO: Rechecking with some additional includes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rechecking with some additional includes" >&5 $as_echo "$as_me: Rechecking with some additional includes" >&6;} unset ac_cv_header_netinet_if_ether_h - -for ac_header in netinet/if_ether.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include + for ac_header in netinet/if_ether.h +do : + ac_fn_c_check_header_compile "$LINENO" "netinet/if_ether.h" "ac_cv_header_netinet_if_ether_h" "#include #include #include struct mbuf; struct rtentry; #include - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - eval "$as_ac_Header=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_Header=no" -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +" +if test "x$ac_cv_header_netinet_if_ether_h" = x""yes; then : cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define HAVE_NETINET_IF_ETHER_H 1 _ACEOF fi @@ -5178,16 +4564,12 @@ done fi if test "$GCC" = yes ; then - { $as_echo "$as_me:$LINENO: checking for ANSI ioctl definitions" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI ioctl definitions" >&5 $as_echo_n "checking for ANSI ioctl definitions... " >&6; } - if test "${ac_cv_lbl_gcc_fixincludes+set}" = set; then + if test "${ac_cv_lbl_gcc_fixincludes+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* * This generates a "duplicate case value" when fixincludes @@ -5210,141 +4592,29 @@ switch (0) { return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_lbl_gcc_fixincludes=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lbl_gcc_fixincludes=no + ac_cv_lbl_gcc_fixincludes=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_gcc_fixincludes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_gcc_fixincludes" >&5 $as_echo "$ac_cv_lbl_gcc_fixincludes" >&6; } if test $ac_cv_lbl_gcc_fixincludes = no ; then # Don't cache failure unset ac_cv_lbl_gcc_fixincludes - { { $as_echo "$as_me:$LINENO: error: see the INSTALL for more info" >&5 -$as_echo "$as_me: error: see the INSTALL for more info" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "see the INSTALL for more info" "$LINENO" 5 fi fi - - for ac_func in strerror strlcpy -do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - eval "$as_ac_var=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +eval as_val=\$$as_ac_var + if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -5354,101 +4624,12 @@ done needsnprintf=no - - for ac_func in vsnprintf snprintf -do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - eval "$as_ac_var=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +eval as_val=\$$as_ac_var + if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -5476,17 +4657,13 @@ fi # libraries (i.e. libc): # Some OSes (eg. Solaris) place it in libnsl # Some strange OSes (SINIX) have it in libsocket: - { $as_echo "$as_me:$LINENO: checking for library containing gethostbyname" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5 $as_echo_n "checking for library containing gethostbyname... " >&6; } -if test "${ac_cv_search_gethostbyname+set}" = set; then +if test "${ac_cv_search_gethostbyname+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -5511,54 +4688,27 @@ for ac_lib in '' nsl socket resolv; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_gethostbyname=$ac_res -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext - if test "${ac_cv_search_gethostbyname+set}" = set; then +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if test "${ac_cv_search_gethostbyname+set}" = set; then : break fi done -if test "${ac_cv_search_gethostbyname+set}" = set; then - : +if test "${ac_cv_search_gethostbyname+set}" = set; then : + else ac_cv_search_gethostbyname=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_gethostbyname" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5 $as_echo "$ac_cv_search_gethostbyname" >&6; } ac_res=$ac_cv_search_gethostbyname -if test "$ac_res" != no; then +if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi @@ -5567,18 +4717,14 @@ fi # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this. if test "$ac_cv_search_gethostbyname" = "no" then - { $as_echo "$as_me:$LINENO: checking for gethostbyname in -lsocket" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lsocket" >&5 $as_echo_n "checking for gethostbyname in -lsocket... " >&6; } -if test "${ac_cv_lib_socket_gethostbyname+set}" = set; then +if test "${ac_cv_lib_socket_gethostbyname+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket -lnsl $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -5596,58 +4742,29 @@ return gethostbyname (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_gethostbyname=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_socket_gethostbyname=no + ac_cv_lib_socket_gethostbyname=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_socket_gethostbyname" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_gethostbyname" >&5 $as_echo "$ac_cv_lib_socket_gethostbyname" >&6; } -if test "x$ac_cv_lib_socket_gethostbyname" = x""yes; then +if test "x$ac_cv_lib_socket_gethostbyname" = x""yes; then : LIBS="-lsocket -lnsl $LIBS" fi fi - { $as_echo "$as_me:$LINENO: checking for library containing socket" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing socket" >&5 $as_echo_n "checking for library containing socket... " >&6; } -if test "${ac_cv_search_socket+set}" = set; then +if test "${ac_cv_search_socket+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -5672,69 +4789,38 @@ for ac_lib in '' socket; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_socket=$ac_res -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext - if test "${ac_cv_search_socket+set}" = set; then +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if test "${ac_cv_search_socket+set}" = set; then : break fi done -if test "${ac_cv_search_socket+set}" = set; then - : +if test "${ac_cv_search_socket+set}" = set; then : + else ac_cv_search_socket=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_socket" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_socket" >&5 $as_echo "$ac_cv_search_socket" >&6; } ac_res=$ac_cv_search_socket -if test "$ac_res" != no; then +if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" else - { $as_echo "$as_me:$LINENO: checking for socket in -lsocket" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5 $as_echo_n "checking for socket in -lsocket... " >&6; } -if test "${ac_cv_lib_socket_socket+set}" = set; then +if test "${ac_cv_lib_socket_socket+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket -lnsl $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -5752,60 +4838,31 @@ return socket (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_socket=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_socket_socket=no + ac_cv_lib_socket_socket=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_socket_socket" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5 $as_echo "$ac_cv_lib_socket_socket" >&6; } -if test "x$ac_cv_lib_socket_socket" = x""yes; then +if test "x$ac_cv_lib_socket_socket" = x""yes; then : LIBS="-lsocket -lnsl $LIBS" fi fi # DLPI needs putmsg under HPUX so test for -lstr while we're at it - { $as_echo "$as_me:$LINENO: checking for library containing putmsg" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing putmsg" >&5 $as_echo_n "checking for library containing putmsg... " >&6; } -if test "${ac_cv_search_putmsg+set}" = set; then +if test "${ac_cv_search_putmsg+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -5830,54 +4887,27 @@ for ac_lib in '' str; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_putmsg=$ac_res -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext - if test "${ac_cv_search_putmsg+set}" = set; then +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if test "${ac_cv_search_putmsg+set}" = set; then : break fi done -if test "${ac_cv_search_putmsg+set}" = set; then - : +if test "${ac_cv_search_putmsg+set}" = set; then : + else ac_cv_search_putmsg=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_putmsg" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_putmsg" >&5 $as_echo "$ac_cv_search_putmsg" >&6; } ac_res=$ac_cv_search_putmsg -if test "$ac_res" != no; then +if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi @@ -5895,102 +4925,12 @@ fi # # Before you is a C compiler. # - for ac_func in ether_hostton -do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - eval "$as_ac_var=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +do : + ac_fn_c_check_func "$LINENO" "ether_hostton" "ac_cv_func_ether_hostton" +if test "x$ac_cv_func_ether_hostton" = x""yes; then : cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define HAVE_ETHER_HOSTTON 1 _ACEOF fi @@ -6004,18 +4944,7 @@ if test "$ac_cv_func_ether_hostton" = yes; then # # Yes. Does it declare ether_hostton()? # - { $as_echo "$as_me:$LINENO: checking whether ether_hostton is declared" >&5 -$as_echo_n "checking whether ether_hostton is declared... " >&6; } -if test "${ac_cv_have_decl_ether_hostton+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - + ac_fn_c_check_decl "$LINENO" "ether_hostton" "ac_cv_have_decl_ether_hostton" " #include #include #include @@ -6025,54 +4954,11 @@ struct rtentry; #include #include - -int -main () -{ -#ifndef ether_hostton - (void) ether_hostton; -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_have_decl_ether_hostton=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_have_decl_ether_hostton=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_ether_hostton" >&5 -$as_echo "$ac_cv_have_decl_ether_hostton" >&6; } -if test "x$ac_cv_have_decl_ether_hostton" = x""yes; then +" +if test "x$ac_cv_have_decl_ether_hostton" = x""yes; then : -cat >>confdefs.h <<\_ACEOF -#define NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON /**/ -_ACEOF +$as_echo "#define NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON /**/" >>confdefs.h fi @@ -6085,146 +4971,12 @@ fi # # No, how about , as on Linux? # - -for ac_header in netinet/ether.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then + for ac_header in netinet/ether.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "netinet/ether.h" "ac_cv_header_netinet_ether_h" "$ac_includes_default" +if test "x$ac_cv_header_netinet_ether_h" = x""yes; then : cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define HAVE_NETINET_ETHER_H 1 _ACEOF fi @@ -6239,68 +4991,14 @@ done # suppress the next test. # unset ac_cv_have_decl_ether_hostton - { $as_echo "$as_me:$LINENO: checking whether ether_hostton is declared" >&5 -$as_echo_n "checking whether ether_hostton is declared... " >&6; } -if test "${ac_cv_have_decl_ether_hostton+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - + ac_fn_c_check_decl "$LINENO" "ether_hostton" "ac_cv_have_decl_ether_hostton" " #include - -int -main () -{ -#ifndef ether_hostton - (void) ether_hostton; -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_have_decl_ether_hostton=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_have_decl_ether_hostton=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_ether_hostton" >&5 -$as_echo "$ac_cv_have_decl_ether_hostton" >&6; } -if test "x$ac_cv_have_decl_ether_hostton" = x""yes; then +" +if test "x$ac_cv_have_decl_ether_hostton" = x""yes; then : -cat >>confdefs.h <<\_ACEOF -#define NETINET_ETHER_H_DECLARES_ETHER_HOSTTON /**/ -_ACEOF +$as_echo "#define NETINET_ETHER_H_DECLARES_ETHER_HOSTTON /**/" >>confdefs.h fi @@ -6315,19 +5013,7 @@ fi # No, we'll have to declare it ourselves. # Do we have "struct ether_addr"? # - { $as_echo "$as_me:$LINENO: checking for struct ether_addr" >&5 -$as_echo_n "checking for struct ether_addr... " >&6; } -if test "${ac_cv_type_struct_ether_addr+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_type_struct_ether_addr=no -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - + ac_fn_c_check_type "$LINENO" "struct ether_addr" "ac_cv_type_struct_ether_addr" " #include #include #include @@ -6337,99 +5023,8 @@ struct rtentry; #include #include - -int -main () -{ -if (sizeof (struct ether_addr)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -#include -#include -#include -#include -struct mbuf; -struct rtentry; -#include -#include - - -int -main () -{ -if (sizeof ((struct ether_addr))) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_type_struct_ether_addr=yes -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_struct_ether_addr" >&5 -$as_echo "$ac_cv_type_struct_ether_addr" >&6; } -if test "x$ac_cv_type_struct_ether_addr" = x""yes; then +" +if test "x$ac_cv_type_struct_ether_addr" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_ETHER_ADDR 1 @@ -6439,23 +5034,19 @@ _ACEOF fi -cat >>confdefs.h <<\_ACEOF -#define HAVE_DECL_ETHER_HOSTTON 0 -_ACEOF +$as_echo "#define HAVE_DECL_ETHER_HOSTTON 0" >>confdefs.h else -cat >>confdefs.h <<\_ACEOF -#define HAVE_DECL_ETHER_HOSTTON 1 -_ACEOF +$as_echo "#define HAVE_DECL_ETHER_HOSTTON 1" >>confdefs.h fi fi -{ $as_echo "$as_me:$LINENO: checking if --disable-protochain option is specified" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if --disable-protochain option is specified" >&5 $as_echo_n "checking if --disable-protochain option is specified... " >&6; } # Check whether --enable-protochain was given. -if test "${enable_protochain+set}" = set; then +if test "${enable_protochain+set}" = set; then : enableval=$enable_protochain; fi @@ -6467,12 +5058,10 @@ esac if test "$enable_protochain" = "disabled"; then -cat >>confdefs.h <<\_ACEOF -#define NO_PROTOCHAIN 1 -_ACEOF +$as_echo "#define NO_PROTOCHAIN 1" >>confdefs.h fi -{ $as_echo "$as_me:$LINENO: result: ${enable_protochain}" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${enable_protochain}" >&5 $as_echo "${enable_protochain}" >&6; } # @@ -6481,44 +5070,40 @@ $as_echo "${enable_protochain}" >&6; } # # Check whether --with-sita was given. -if test "${with_sita+set}" = set; then +if test "${with_sita+set}" = set; then : withval=$with_sita; + if test ! "x$withval" = "xno" ; then -cat >>confdefs.h <<\_ACEOF -#define SITA 1 -_ACEOF +$as_echo "#define SITA 1" >>confdefs.h - { $as_echo "$as_me:$LINENO: Enabling SITA ACN support" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Enabling SITA ACN support" >&5 $as_echo "$as_me: Enabling SITA ACN support" >&6;} - V_PCAP=sita - V_FINDALLDEVS=sita + V_PCAP=sita + V_FINDALLDEVS=sita + fi else if test -z "$with_pcap" && test "$cross_compiling" = yes; then - { { $as_echo "$as_me:$LINENO: error: pcap type not determined when cross-compiling; use --with-pcap=..." >&5 -$as_echo "$as_me: error: pcap type not determined when cross-compiling; use --with-pcap=..." >&2;} - { (exit 1); exit 1; }; } + as_fn_error "pcap type not determined when cross-compiling; use --with-pcap=..." "$LINENO" 5 fi # Check whether --with-pcap was given. -if test "${with_pcap+set}" = set; then +if test "${with_pcap+set}" = set; then : withval=$with_pcap; fi -{ $as_echo "$as_me:$LINENO: checking packet capture type" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking packet capture type" >&5 $as_echo_n "checking packet capture type... " >&6; } 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. # V_PCAP=bpf -cat >>confdefs.h <<\_ACEOF -#define HAVE_CLONING_BPF 1 -_ACEOF +$as_echo "#define HAVE_CLONING_BPF 1" >>confdefs.h elif test -r /dev/bpf0 ; then V_PCAP=bpf @@ -6541,10 +5126,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 @@ -6552,7 +5137,7 @@ elif test -c /dev/nit ; then # check again in case not readable else V_PCAP=null fi -{ $as_echo "$as_me:$LINENO: result: $V_PCAP" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $V_PCAP" >&5 $as_echo "$V_PCAP" >&6; } # @@ -6573,18 +5158,14 @@ dlpi) # saved_ldflags=$LDFLAGS LDFLAGS="$LIBS -L/lib" - { $as_echo "$as_me:$LINENO: checking for dlpi_walk in -ldlpi" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlpi_walk in -ldlpi" >&5 $as_echo_n "checking for dlpi_walk in -ldlpi... " >&6; } -if test "${ac_cv_lib_dlpi_dlpi_walk+set}" = set; then +if test "${ac_cv_lib_dlpi_dlpi_walk+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldlpi $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -6602,49 +5183,22 @@ return dlpi_walk (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dlpi_dlpi_walk=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_dlpi_dlpi_walk=no + ac_cv_lib_dlpi_dlpi_walk=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dlpi_dlpi_walk" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dlpi_dlpi_walk" >&5 $as_echo "$ac_cv_lib_dlpi_dlpi_walk" >&6; } -if test "x$ac_cv_lib_dlpi_dlpi_walk" = x""yes; then +if test "x$ac_cv_lib_dlpi_dlpi_walk" = x""yes; then : LIBS="-ldlpi $LIBS" V_PCAP=libdlpi -cat >>confdefs.h <<\_ACEOF -#define HAVE_LIBDLPI 1 -_ACEOF +$as_echo "#define HAVE_LIBDLPI 1" >>confdefs.h else V_PCAP=dlpi @@ -6656,16 +5210,12 @@ fi # Checks whether is usable, to catch weird SCO # versions of DLPI. # - { $as_echo "$as_me:$LINENO: checking whether is usable" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether is usable" >&5 $as_echo_n "checking whether is usable... " >&6; } - if test "${ac_cv_sys_dlpi_usable+set}" = set; then + if test "${ac_cv_sys_dlpi_usable+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -6680,64 +5230,39 @@ int i = DL_PROMISC_PHYS; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_dlpi_usable=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_sys_dlpi_usable=no + ac_cv_sys_dlpi_usable=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { $as_echo "$as_me:$LINENO: result: $ac_cv_sys_dlpi_usable" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_dlpi_usable" >&5 $as_echo "$ac_cv_sys_dlpi_usable" >&6; } if test $ac_cv_sys_dlpi_usable = no ; then - { { $as_echo "$as_me:$LINENO: error: is not usable on this system; it probably has a non-standard DLPI" >&5 -$as_echo "$as_me: error: is not usable on this system; it probably has a non-standard DLPI" >&2;} - { (exit 1); exit 1; }; } + as_fn_error " is not usable on this system; it probably has a non-standard DLPI" "$LINENO" 5 fi # # Check whether we have a /dev/dlpi device or have multiple devices. # - { $as_echo "$as_me:$LINENO: checking for /dev/dlpi device" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /dev/dlpi device" >&5 $as_echo_n "checking for /dev/dlpi device... " >&6; } if test -c /dev/dlpi ; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } -cat >>confdefs.h <<\_ACEOF -#define HAVE_DEV_DLPI 1 -_ACEOF +$as_echo "#define HAVE_DEV_DLPI 1" >>confdefs.h else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } dir="/dev/dlpi" - { $as_echo "$as_me:$LINENO: checking for $dir directory" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $dir directory" >&5 $as_echo_n "checking for $dir directory... " >&6; } if test -d $dir ; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF @@ -6745,7 +5270,7 @@ cat >>confdefs.h <<_ACEOF _ACEOF else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi @@ -6754,16 +5279,12 @@ $as_echo "no" >&6; } # This check is for Solaris with DLPI support for passive modes. # See dlpi(7P) for more details. # - { $as_echo "$as_me:$LINENO: checking if dl_passive_req_t struct exists" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if dl_passive_req_t struct exists" >&5 $as_echo_n "checking if dl_passive_req_t struct exists... " >&6; } - if test "${ac_cv_lbl_has_dl_passive_req_t+set}" = set; then + if test "${ac_cv_lbl_has_dl_passive_req_t+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include @@ -6776,58 +5297,35 @@ u_int i = sizeof(dl_passive_req_t) return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_lbl_has_dl_passive_req_t=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lbl_has_dl_passive_req_t=no + ac_cv_lbl_has_dl_passive_req_t=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_has_dl_passive_req_t" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_has_dl_passive_req_t" >&5 $as_echo "$ac_cv_lbl_has_dl_passive_req_t" >&6; } if test $ac_cv_lbl_has_dl_passive_req_t = yes ; then -cat >>confdefs.h <<\_ACEOF -#define HAVE_DLPI_PASSIVE 1 -_ACEOF +$as_echo "#define HAVE_DLPI_PASSIVE 1" >>confdefs.h fi ;; linux) - { $as_echo "$as_me:$LINENO: checking Linux kernel version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Linux kernel version" >&5 $as_echo_n "checking Linux kernel version... " >&6; } if test "$cross_compiling" = yes; then - if test "${ac_cv_linux_vers+set}" = set; then + if test "${ac_cv_linux_vers+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_linux_vers=unknown fi else - if test "${ac_cv_linux_vers+set}" = set; then + if test "${ac_cv_linux_vers+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_linux_vers=`uname -r 2>&1 | \ @@ -6835,94 +5333,103 @@ else fi fi - { $as_echo "$as_me:$LINENO: result: $ac_cv_linux_vers" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_linux_vers" >&5 $as_echo "$ac_cv_linux_vers" >&6; } if test $ac_cv_linux_vers = unknown ; then - { { $as_echo "$as_me:$LINENO: error: cannot determine linux version when cross-compiling" >&5 -$as_echo "$as_me: error: cannot determine linux version when cross-compiling" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "cannot determine linux version when cross-compiling" "$LINENO" 5 fi if test $ac_cv_linux_vers -lt 2 ; then - { { $as_echo "$as_me:$LINENO: error: version 2 or higher required; see the INSTALL doc for more info" >&5 -$as_echo "$as_me: error: version 2 or higher required; see the INSTALL doc for more info" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "version 2 or higher required; see the INSTALL doc for more info" "$LINENO" 5 fi -for ac_header in linux/wireless.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - + # + # Do we have the wireless extensions? + # + for ac_header in linux/wireless.h +do : + ac_fn_c_check_header_compile "$LINENO" "linux/wireless.h" "ac_cv_header_linux_wireless_h" " #include -#include +#include #include - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - eval "$as_ac_Header=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_Header=no" -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +" +if test "x$ac_cv_header_linux_wireless_h" = x""yes; then : cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define HAVE_LINUX_WIRELESS_H 1 _ACEOF fi done - { $as_echo "$as_me:$LINENO: checking if if_packet.h has tpacket_stats defined" >&5 -$as_echo_n "checking if if_packet.h has tpacket_stats defined... " >&6; } - if test "${ac_cv_lbl_tpacket_stats+set}" = set; then + + # + # Do we have libnl? + # + +# Check whether --with-libnl was given. +if test "${with_libnl+set}" = set; then : + withval=$with_libnl; with_libnl=$withval +fi + + + if test x$with_libnl != xno ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_handle_alloc in -lnl" >&5 +$as_echo_n "checking for nl_handle_alloc in -lnl... " >&6; } +if test "${ac_cv_lib_nl_nl_handle_alloc+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ + ac_check_lib_save_LIBS=$LIBS +LIBS="-lnl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char nl_handle_alloc (); +int +main () +{ +return nl_handle_alloc (); + ; + return 0; +} _ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_nl_nl_handle_alloc=yes +else + ac_cv_lib_nl_nl_handle_alloc=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nl_nl_handle_alloc" >&5 +$as_echo "$ac_cv_lib_nl_nl_handle_alloc" >&6; } +if test "x$ac_cv_lib_nl_nl_handle_alloc" = x""yes; then : + LIBS="-lnl $LIBS" + +$as_echo "#define HAVE_LIBNL 1" >>confdefs.h + +else + if test x$with_libnl = xyes ; then + as_fn_error "libnl support requested but libnl not found" "$LINENO" 5 + fi + +fi + + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if if_packet.h has tpacket_stats defined" >&5 +$as_echo_n "checking if if_packet.h has tpacket_stats defined... " >&6; } + if test "${ac_cv_lbl_tpacket_stats+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include @@ -6934,54 +5441,27 @@ struct tpacket_stats stats return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_lbl_tpacket_stats=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lbl_tpacket_stats=no + ac_cv_lbl_tpacket_stats=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_tpacket_stats" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_tpacket_stats" >&5 $as_echo "$ac_cv_lbl_tpacket_stats" >&6; } if test $ac_cv_lbl_tpacket_stats = yes; then -cat >>confdefs.h <<\_ACEOF -#define HAVE_TPACKET_STATS 1 -_ACEOF +$as_echo "#define HAVE_TPACKET_STATS 1" >>confdefs.h fi - { $as_echo "$as_me:$LINENO: checking if tpacket_auxdata struct has tp_vlan_tci member" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if tpacket_auxdata struct has tp_vlan_tci member" >&5 $as_echo_n "checking if tpacket_auxdata struct has tp_vlan_tci member... " >&6; } - if test "${ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1+set}" = set; then + if test "${ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include @@ -6993,42 +5473,21 @@ u_int i = sizeof(((struct tpacket_auxdata *)0)->tp_vlan_tci) return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=no + ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci" >&5 $as_echo "$ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci" >&6; } if test $ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci = yes ; then + HAVE_LINUX_TPACKET_AUXDATA=tp_vlan_tci -cat >>confdefs.h <<\_ACEOF -#define HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI 1 -_ACEOF + +$as_echo "#define HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI 1" >>confdefs.h fi ;; @@ -7037,146 +5496,12 @@ bpf) # # Check whether we have the *BSD-style ioctls. # - -for ac_header in net/if_media.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then + for ac_header in net/if_media.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "net/if_media.h" "ac_cv_header_net_if_media_h" "$ac_includes_default" +if test "x$ac_cv_header_net_if_media_h" = x""yes; then : cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define HAVE_NET_IF_MEDIA_H 1 _ACEOF fi @@ -7184,13 +5509,9 @@ fi done - { $as_echo "$as_me:$LINENO: checking whether the system supports zerocopy BPF" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the system supports zerocopy BPF" >&5 $as_echo_n "checking whether the system supports zerocopy BPF... " >&6; } - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -7204,59 +5525,24 @@ return (BIOCROTZBUF + BPF_BUFMODE_ZBUF); return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } -cat >>confdefs.h <<\_ACEOF -#define HAVE_ZEROCOPY_BPF 1 -_ACEOF +$as_echo "#define HAVE_ZEROCOPY_BPF 1" >>confdefs.h else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # # Check whether we have struct BPF_TIMEVAL. # - { $as_echo "$as_me:$LINENO: checking for struct BPF_TIMEVAL" >&5 -$as_echo_n "checking for struct BPF_TIMEVAL... " >&6; } -if test "${ac_cv_type_struct_BPF_TIMEVAL+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_type_struct_BPF_TIMEVAL=no -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - + ac_fn_c_check_type "$LINENO" "struct BPF_TIMEVAL" "ac_cv_type_struct_BPF_TIMEVAL" " #include #include #ifdef HAVE_SYS_IOCCOM_H @@ -7264,97 +5550,8 @@ cat >>conftest.$ac_ext <<_ACEOF #endif #include - -int -main () -{ -if (sizeof (struct BPF_TIMEVAL)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -#include -#include -#ifdef HAVE_SYS_IOCCOM_H -#include -#endif -#include - - -int -main () -{ -if (sizeof ((struct BPF_TIMEVAL))) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_type_struct_BPF_TIMEVAL=yes -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_struct_BPF_TIMEVAL" >&5 -$as_echo "$ac_cv_type_struct_BPF_TIMEVAL" >&6; } -if test "x$ac_cv_type_struct_BPF_TIMEVAL" = x""yes; then +" +if test "x$ac_cv_type_struct_BPF_TIMEVAL" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_BPF_TIMEVAL 1 @@ -7373,10 +5570,14 @@ septel) V_DEFS="$V_DEFS -DSEPTEL_ONLY" ;; +snf) + V_DEFS="$V_DEFS -DSNF_ONLY" + ;; + null) - { $as_echo "$as_me:$LINENO: WARNING: cannot determine packet capture interface" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot determine packet capture interface" >&5 $as_echo "$as_me: WARNING: cannot determine packet capture interface" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: (see the INSTALL doc for more info)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: (see the INSTALL doc for more info)" >&5 $as_echo "$as_me: WARNING: (see the INSTALL doc for more info)" >&2;} ;; esac @@ -7389,225 +5590,15 @@ then # V_FINDALLDEVS=null else - { $as_echo "$as_me:$LINENO: checking for getifaddrs" >&5 -$as_echo_n "checking for getifaddrs... " >&6; } -if test "${ac_cv_func_getifaddrs+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define getifaddrs to an innocuous variant, in case declares getifaddrs. - For example, HP-UX 11i declares gettimeofday. */ -#define getifaddrs innocuous_getifaddrs - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char getifaddrs (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef getifaddrs - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char getifaddrs (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_getifaddrs || defined __stub___getifaddrs -choke me -#endif - -int -main () -{ -return getifaddrs (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_func_getifaddrs=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_getifaddrs=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_getifaddrs" >&5 -$as_echo "$ac_cv_func_getifaddrs" >&6; } -if test "x$ac_cv_func_getifaddrs" = x""yes; then + ac_fn_c_check_func "$LINENO" "getifaddrs" "ac_cv_func_getifaddrs" +if test "x$ac_cv_func_getifaddrs" = x""yes; then : # # We have "getifaddrs()"; make sure we have # as well, just in case some platform is really weird. # - if test "${ac_cv_header_ifaddrs_h+set}" = set; then - { $as_echo "$as_me:$LINENO: checking for ifaddrs.h" >&5 -$as_echo_n "checking for ifaddrs.h... " >&6; } -if test "${ac_cv_header_ifaddrs_h+set}" = set; then - $as_echo_n "(cached) " >&6 -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_ifaddrs_h" >&5 -$as_echo "$ac_cv_header_ifaddrs_h" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking ifaddrs.h usability" >&5 -$as_echo_n "checking ifaddrs.h usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking ifaddrs.h presence" >&5 -$as_echo_n "checking ifaddrs.h presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: ifaddrs.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: ifaddrs.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: ifaddrs.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: ifaddrs.h: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: ifaddrs.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: ifaddrs.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: ifaddrs.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: ifaddrs.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: ifaddrs.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: ifaddrs.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: ifaddrs.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: ifaddrs.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: ifaddrs.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: ifaddrs.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: ifaddrs.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: ifaddrs.h: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for ifaddrs.h" >&5 -$as_echo_n "checking for ifaddrs.h... " >&6; } -if test "${ac_cv_header_ifaddrs_h+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_header_ifaddrs_h=$ac_header_preproc -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_ifaddrs_h" >&5 -$as_echo "$ac_cv_header_ifaddrs_h" >&6; } - -fi -if test "x$ac_cv_header_ifaddrs_h" = x""yes; then + ac_fn_c_check_header_mongrel "$LINENO" "ifaddrs.h" "ac_cv_header_ifaddrs_h" "$ac_includes_default" +if test "x$ac_cv_header_ifaddrs_h" = x""yes; then : # # We have the header, so we use "getifaddrs()" to @@ -7626,9 +5617,7 @@ else # but without "ifaddrs.h", if there is something # we can do on those systems. # - { { $as_echo "$as_me:$LINENO: error: Your system has getifaddrs() but doesn't have a usable ." >&5 -$as_echo "$as_me: error: Your system has getifaddrs() but doesn't have a usable ." >&2;} - { (exit 1); exit 1; }; } + as_fn_error "Your system has getifaddrs() but doesn't have a usable ." "$LINENO" 5 fi @@ -7646,145 +5635,12 @@ else case "$V_PCAP" in dlpi|libdlpi) - - -for ac_header in sys/bufmod.h sys/dlpi_ext.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then + for ac_header in sys/bufmod.h sys/dlpi_ext.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -7799,16 +5655,12 @@ done # or some older version of Solaris, with # just SIOCGIFCONF. # - { $as_echo "$as_me:$LINENO: checking whether we have SIOCGLIFCONF" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have SIOCGLIFCONF" >&5 $as_echo_n "checking whether we have SIOCGLIFCONF... " >&6; } - if test "${ac_cv_lbl_have_siocglifconf+set}" = set; then + if test "${ac_cv_lbl_have_siocglifconf+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -7823,36 +5675,15 @@ ioctl(0, SIOCGLIFCONF, (char *)0); return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_lbl_have_siocglifconf=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lbl_have_siocglifconf=no + ac_cv_lbl_have_siocglifconf=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_have_siocglifconf" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_have_siocglifconf" >&5 $as_echo "$ac_cv_lbl_have_siocglifconf" >&6; } if test $ac_cv_lbl_have_siocglifconf = yes ; then V_FINDALLDEVS=glifc @@ -7882,13 +5713,9 @@ fi fi -{ $as_echo "$as_me:$LINENO: checking for socklen_t" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for socklen_t" >&5 $as_echo_n "checking for socklen_t... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -7902,215 +5729,82 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : have_socklen_t=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - have_socklen_t=no + have_socklen_t=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "x$have_socklen_t" = "xyes"; then -cat >>confdefs.h <<\_ACEOF -#define HAVE_SOCKLEN_T 1 -_ACEOF +$as_echo "#define HAVE_SOCKLEN_T 1" >>confdefs.h fi -{ $as_echo "$as_me:$LINENO: result: $have_socklen_t" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_socklen_t" >&5 $as_echo "$have_socklen_t" >&6; } # Check whether --enable-ipv6 was given. -if test "${enable_ipv6+set}" = set; then +if test "${enable_ipv6+set}" = set; then : enableval=$enable_ipv6; else enable_ipv6=ifavailable fi if test "$enable_ipv6" != "no"; then - { $as_echo "$as_me:$LINENO: checking for getaddrinfo" >&5 -$as_echo_n "checking for getaddrinfo... " >&6; } -if test "${ac_cv_func_getaddrinfo+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define getaddrinfo to an innocuous variant, in case declares getaddrinfo. - For example, HP-UX 11i declares gettimeofday. */ -#define getaddrinfo innocuous_getaddrinfo - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char getaddrinfo (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef getaddrinfo - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char getaddrinfo (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_getaddrinfo || defined __stub___getaddrinfo -choke me -#endif - -int -main () -{ -return getaddrinfo (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_func_getaddrinfo=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_getaddrinfo=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_getaddrinfo" >&5 -$as_echo "$ac_cv_func_getaddrinfo" >&6; } -if test "x$ac_cv_func_getaddrinfo" = x""yes; then + ac_fn_c_check_func "$LINENO" "getaddrinfo" "ac_cv_func_getaddrinfo" +if test "x$ac_cv_func_getaddrinfo" = x""yes; then : -cat >>confdefs.h <<\_ACEOF -#define INET6 1 -_ACEOF +$as_echo "#define INET6 1" >>confdefs.h else if test "$enable_ipv6" != "ifavailable"; then - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: --enable-ipv6 was given, but getaddrinfo isn't available -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: --enable-ipv6 was given, but getaddrinfo isn't available -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error "--enable-ipv6 was given, but getaddrinfo isn't available +See \`config.log' for more details." "$LINENO" 5; } fi fi fi -{ $as_echo "$as_me:$LINENO: checking whether to build optimizer debugging code" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build optimizer debugging code" >&5 $as_echo_n "checking whether to build optimizer debugging code... " >&6; } # Check whether --enable-optimizer-dbg was given. -if test "${enable_optimizer_dbg+set}" = set; then +if test "${enable_optimizer_dbg+set}" = set; then : enableval=$enable_optimizer_dbg; fi if test "$enable_optimizer_dbg" = "yes"; then -cat >>confdefs.h <<\_ACEOF -#define BDEBUG 1 -_ACEOF +$as_echo "#define BDEBUG 1" >>confdefs.h fi -{ $as_echo "$as_me:$LINENO: result: ${enable_optimizer_dbg-no}" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${enable_optimizer_dbg-no}" >&5 $as_echo "${enable_optimizer_dbg-no}" >&6; } -{ $as_echo "$as_me:$LINENO: checking whether to build parser debugging code" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build parser debugging code" >&5 $as_echo_n "checking whether to build parser debugging code... " >&6; } # Check whether --enable-yydebug was given. -if test "${enable_yydebug+set}" = set; then +if test "${enable_yydebug+set}" = set; then : enableval=$enable_yydebug; fi if test "$enable_yydebug" = "yes"; then -cat >>confdefs.h <<\_ACEOF -#define YYDEBUG 1 -_ACEOF +$as_echo "#define YYDEBUG 1" >>confdefs.h fi -{ $as_echo "$as_me:$LINENO: result: ${enable_yydebug-no}" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${enable_yydebug-no}" >&5 $as_echo "${enable_yydebug-no}" >&6; } -{ $as_echo "$as_me:$LINENO: checking whether we have /proc/net/dev" >&5 -$as_echo_n "checking whether we have /proc/net/dev... " >&6; } -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 - -cat >>confdefs.h <<\_ACEOF -#define HAVE_PROC_NET_DEV 1 -_ACEOF - -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_proc_net_dev" >&5 -$as_echo "$ac_cv_lbl_proc_net_dev" >&6; } - # Check for Endace DAG card support. # Check whether --with-dag was given. -if test "${with_dag+set}" = set; then +if test "${with_dag+set}" = set; then : withval=$with_dag; if test "$withval" = no then @@ -8138,7 +5832,7 @@ fi # Check whether --with-dag-includes was given. -if test "${with_dag_includes+set}" = set; then +if test "${with_dag_includes+set}" = set; then : withval=$with_dag_includes; # User wants DAG support and has specified a header directory, so use the provided value. want_dag=yes @@ -8149,7 +5843,7 @@ fi # Check whether --with-dag-libraries was given. -if test "${with_dag_libraries+set}" = set; then +if test "${with_dag_libraries+set}" = set; then : withval=$with_dag_libraries; # User wants DAG support and has specified a library directory, so use the provided value. want_dag=yes @@ -8173,9 +5867,7 @@ linux|bpf|dag) # If they expressed no preference, don't include it. # if test $want_dag = yes; then - { { $as_echo "$as_me:$LINENO: error: DAG support is only available with 'linux' 'bpf' and 'dag' packet capture types" >&5 -$as_echo "$as_me: error: DAG support is only available with 'linux' 'bpf' and 'dag' packet capture types" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "DAG support is only available with 'linux' 'bpf' and 'dag' packet capture types" "$LINENO" 5 elif test $want_dag = yes; then want_dag=no fi @@ -8185,7 +5877,7 @@ esac ac_cv_lbl_dag_api=no if test "$want_dag" != no; then - { $as_echo "$as_me:$LINENO: checking whether we have DAG API headers" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have DAG API headers" >&5 $as_echo_n "checking whether we have DAG API headers... " >&6; } # If necessary, set default paths for DAG API headers and libraries. @@ -8208,13 +5900,13 @@ $as_echo_n "checking whether we have DAG API headers... " >&6; } if test -r $dag_include_dir/dagapi.h; then ac_cv_lbl_dag_api=yes fi - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_dag_api ($dag_include_dir)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_dag_api ($dag_include_dir)" >&5 $as_echo "$ac_cv_lbl_dag_api ($dag_include_dir)" >&6; } fi if test $ac_cv_lbl_dag_api = yes; then - { $as_echo "$as_me:$LINENO: checking dagapi.o" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking dagapi.o" >&5 $as_echo_n "checking dagapi.o... " >&6; } dagapi_obj=no if test -r $dag_tools_dir/dagapi.o; then @@ -8237,18 +5929,18 @@ $as_echo_n "checking dagapi.o... " >&6; } fi if test $dagapi_obj = no; then - { $as_echo "$as_me:$LINENO: result: no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)" >&5 $as_echo "no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)" >&6; } ac_cv_lbl_dag_api=no else - { $as_echo "$as_me:$LINENO: result: yes ($dagapi_obj)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes ($dagapi_obj)" >&5 $as_echo "yes ($dagapi_obj)" >&6; } fi fi if test $ac_cv_lbl_dag_api = yes; then - { $as_echo "$as_me:$LINENO: checking dagopts.o" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking dagopts.o" >&5 $as_echo_n "checking dagopts.o... " >&6; } dagopts_obj=no if test -r $dag_tools_dir/dagopts.o; then @@ -8271,11 +5963,11 @@ $as_echo_n "checking dagopts.o... " >&6; } fi if test $dagopts_obj = no; then - { $as_echo "$as_me:$LINENO: result: no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)" >&5 $as_echo "no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)" >&6; } ac_cv_lbl_dag_api=no else - { $as_echo "$as_me:$LINENO: result: yes ($dagopts_obj)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes ($dagopts_obj)" >&5 $as_echo "yes ($dagopts_obj)" >&6; } fi fi @@ -8283,7 +5975,7 @@ fi if test $ac_cv_lbl_dag_api = yes; then # Under 2.5.x only we need to add dagreg.o. if test -r $dag_include_dir/dagreg.h; then - { $as_echo "$as_me:$LINENO: checking dagreg.o" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking dagreg.o" >&5 $as_echo_n "checking dagreg.o... " >&6; } dagreg_obj=no if test -r $dag_lib_dir/dagreg.o; then @@ -8303,19 +5995,52 @@ $as_echo_n "checking dagreg.o... " >&6; } fi if test $dagreg_obj = no; then - { $as_echo "$as_me:$LINENO: result: no (checked $dag_lib_dir $dag_lib_dir/libdag.a)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no (checked $dag_lib_dir $dag_lib_dir/libdag.a)" >&5 $as_echo "no (checked $dag_lib_dir $dag_lib_dir/libdag.a)" >&6; } ac_cv_lbl_dag_api=no else - { $as_echo "$as_me:$LINENO: result: yes ($dagreg_obj)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes ($dagreg_obj)" >&5 $as_echo "yes ($dagreg_obj)" >&6; } fi 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 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking dagutil.o" >&5 +$as_echo_n "checking dagutil.o... " >&6; } + 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 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no (checked $dag_lib_dir $dag_lib_dir/libdag.a)" >&5 +$as_echo "no (checked $dag_lib_dir $dag_lib_dir/libdag.a)" >&6; } + ac_cv_lbl_dag_api=no + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes ($dagutil_obj)" >&5 +$as_echo "yes ($dagutil_obj)" >&6; } + 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 @@ -8325,18 +6050,14 @@ if test $ac_cv_lbl_dag_api = yes; then # included if there's a found-action (arg 3). saved_ldflags=$LDFLAGS LDFLAGS="-L$dag_lib_dir" - { $as_echo "$as_me:$LINENO: checking for dag_attach_stream in -ldag" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dag_attach_stream in -ldag" >&5 $as_echo_n "checking for dag_attach_stream in -ldag... " >&6; } -if test "${ac_cv_lib_dag_dag_attach_stream+set}" = set; then +if test "${ac_cv_lib_dag_dag_attach_stream+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldag $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -8354,60 +6075,31 @@ return dag_attach_stream (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dag_dag_attach_stream=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_dag_dag_attach_stream=no + ac_cv_lib_dag_dag_attach_stream=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dag_dag_attach_stream" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dag_dag_attach_stream" >&5 $as_echo "$ac_cv_lib_dag_dag_attach_stream" >&6; } -if test "x$ac_cv_lib_dag_dag_attach_stream" = x""yes; then +if test "x$ac_cv_lib_dag_dag_attach_stream" = x""yes; then : dag_streams="1" else dag_streams="0" fi - { $as_echo "$as_me:$LINENO: checking for dag_get_erf_types in -ldag" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dag_get_erf_types in -ldag" >&5 $as_echo_n "checking for dag_get_erf_types in -ldag... " >&6; } -if test "${ac_cv_lib_dag_dag_get_erf_types+set}" = set; then +if test "${ac_cv_lib_dag_dag_get_erf_types+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldag $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -8425,63 +6117,32 @@ return dag_get_erf_types (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dag_dag_get_erf_types=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_dag_dag_get_erf_types=no + ac_cv_lib_dag_dag_get_erf_types=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dag_dag_get_erf_types" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dag_dag_get_erf_types" >&5 $as_echo "$ac_cv_lib_dag_dag_get_erf_types" >&6; } -if test "x$ac_cv_lib_dag_dag_get_erf_types" = x""yes; then +if test "x$ac_cv_lib_dag_dag_get_erf_types" = x""yes; then : -cat >>confdefs.h <<\_ACEOF -#define HAVE_DAG_GET_ERF_TYPES 1 -_ACEOF +$as_echo "#define HAVE_DAG_GET_ERF_TYPES 1" >>confdefs.h fi - { $as_echo "$as_me:$LINENO: checking for dag_get_stream_erf_types in -ldag" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dag_get_stream_erf_types in -ldag" >&5 $as_echo_n "checking for dag_get_stream_erf_types in -ldag... " >&6; } -if test "${ac_cv_lib_dag_dag_get_stream_erf_types+set}" = set; then +if test "${ac_cv_lib_dag_dag_get_stream_erf_types+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldag $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -8499,48 +6160,21 @@ return dag_get_stream_erf_types (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dag_dag_get_stream_erf_types=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_dag_dag_get_stream_erf_types=no + ac_cv_lib_dag_dag_get_stream_erf_types=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dag_dag_get_stream_erf_types" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dag_dag_get_stream_erf_types" >&5 $as_echo "$ac_cv_lib_dag_dag_get_stream_erf_types" >&6; } -if test "x$ac_cv_lib_dag_dag_get_stream_erf_types" = x""yes; then +if test "x$ac_cv_lib_dag_dag_get_stream_erf_types" = x""yes; then : -cat >>confdefs.h <<\_ACEOF -#define HAVE_DAG_GET_STREAM_ERF_TYPES 1 -_ACEOF +$as_echo "#define HAVE_DAG_GET_STREAM_ERF_TYPES 1" >>confdefs.h fi @@ -8548,48 +6182,40 @@ fi if test "$dag_streams" = 1; then -cat >>confdefs.h <<\_ACEOF -#define HAVE_DAG_STREAMS_API 1 -_ACEOF +$as_echo "#define HAVE_DAG_STREAMS_API 1" >>confdefs.h - DAGLIBS="-ldag" + LIBS="$LIBS -ldag" fi -cat >>confdefs.h <<\_ACEOF -#define HAVE_DAG_API 1 -_ACEOF +$as_echo "#define HAVE_DAG_API 1" >>confdefs.h fi -{ $as_echo "$as_me:$LINENO: checking whether we have the DAG API" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have the DAG API" >&5 $as_echo_n "checking whether we have the DAG API... " >&6; } if test $ac_cv_lbl_dag_api = no; then - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if test "$want_dag" = yes; then # User wanted DAG support but we couldn't find it. - { { $as_echo "$as_me:$LINENO: error: DAG API requested, but not found at $dag_root: use --without-dag" >&5 -$as_echo "$as_me: error: DAG API requested, but not found at $dag_root: use --without-dag" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "DAG API requested, but not found at $dag_root: use --without-dag" "$LINENO" 5 fi if test "$V_PCAP" = dag; then # User requested "dag" capture type but the DAG API wasn't # found. - { { $as_echo "$as_me:$LINENO: error: Specifying the capture type as \"dag\" requires the DAG API to be present; use the --with-dag options to specify the location. (Try \"./configure --help\" for more information.)" >&5 -$as_echo "$as_me: error: Specifying the capture type as \"dag\" requires the DAG API to be present; use the --with-dag options to specify the location. (Try \"./configure --help\" for more information.)" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "Specifying the capture type as \"dag\" requires the DAG API to be present; use the --with-dag options to specify the location. (Try \"./configure --help\" for more information.)" "$LINENO" 5 fi else - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi # Check whether --with-septel was given. -if test "${with_septel+set}" = set; then +if test "${with_septel+set}" = set; then : withval=$with_septel; if test "$withval" = no then @@ -8629,9 +6255,7 @@ linux|septel) # If they expressed no preference, don't include it. # if test $want_septel = yes; then - { { $as_echo "$as_me:$LINENO: error: Septel support only available with 'linux' and 'septel' packet capture types" >&5 -$as_echo "$as_me: error: Septel support only available with 'linux' and 'septel' packet capture types" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "Septel support only available with 'linux' and 'septel' packet capture types" "$LINENO" 5 elif test $want_septel = yes; then want_septel=no fi @@ -8639,75 +6263,268 @@ $as_echo "$as_me: error: Septel support only available with 'linux' and 'septel' esac if test "$with_septel" != no; then - { $as_echo "$as_me:$LINENO: checking whether we have Septel API" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have Septel API" >&5 $as_echo_n "checking whether we have Septel API... " >&6; } 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 - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_septel_api" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_septel_api" >&5 $as_echo "$ac_cv_lbl_septel_api" >&6; } if test $ac_cv_lbl_septel_api = no; then if test "$want_septel" = yes; then - { { $as_echo "$as_me:$LINENO: error: Septel API not found under directory $septel_root; use --without-septel" >&5 -$as_echo "$as_me: error: Septel API not found under directory $septel_root; use --without-septel" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "Septel API not found under directory $septel_root; use --without-septel" "$LINENO" 5 fi else -cat >>confdefs.h <<\_ACEOF -#define HAVE_SEPTEL_API 1 -_ACEOF +$as_echo "#define HAVE_SEPTEL_API 1" >>confdefs.h fi fi if test "$V_PCAP" = septel -a "$ac_cv_lbl_septel_api" = no; then - { { $as_echo "$as_me:$LINENO: error: Specifying the capture type as 'septel' requires the Septel API to be present; use --with-septel=DIR" >&5 -$as_echo "$as_me: error: Specifying the capture type as 'septel' requires the Septel API to be present; use --with-septel=DIR" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "Specifying the capture type as 'septel' requires the Septel API to be present; use --with-septel=DIR" "$LINENO" 5 +fi + +# Check for Myricom SNF support. + +# Check whether --with-snf was given. +if test "${with_snf+set}" = set; then : + withval=$with_snf; + 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 + +else + + # + # Use Sniffer API if present, otherwise don't + # + want_snf=ifpresent + fi + +# Check whether --with-snf-includes was given. +if test "${with_snf_includes+set}" = set; then : + withval=$with_snf_includes; + # User wants SNF with specific header directory + want_snf=yes + snf_include_dir=$withval + +fi + + + +# Check whether --with-snf-libraries was given. +if test "${with_snf_libraries+set}" = set; then : + withval=$with_snf_libraries; + # User wants SNF with specific lib directory + want_snf=yes + snf_lib_dir=$withval + +fi + + +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 + as_fn_error "Myricom SNF support only available with 'bpf' 'linux' and 'snf' packet capture types" "$LINENO" 5 + elif test $want_snf = yes; then + want_snf=no + fi + ;; +esac + +ac_cv_lbl_snf_api=no +if test "$with_snf" != no; then + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have Myricom Sniffer API" >&5 +$as_echo_n "checking whether we have Myricom Sniffer API... " >&6; } + + 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 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_snf_api ($snf_root)" >&5 +$as_echo "$ac_cv_lbl_snf_api ($snf_root)" >&6; } + + if test $ac_cv_lbl_snf_api = no; then + if test "$want_snf" = yes; then + as_fn_error "SNF API headers not found under $snf_include_dir; use --without-snf" "$LINENO" 5 + fi + else + saved_ldflags=$LDFLAGS + LDFLAGS="$LDFLAGS -L$snf_lib_dir" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for snf_init in -lsnf" >&5 +$as_echo_n "checking for snf_init in -lsnf... " >&6; } +if test "${ac_cv_lib_snf_snf_init+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsnf $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char snf_init (); +int +main () +{ +return snf_init (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_snf_snf_init=yes +else + ac_cv_lib_snf_snf_init=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_snf_snf_init" >&5 +$as_echo "$ac_cv_lib_snf_snf_init" >&6; } +if test "x$ac_cv_lib_snf_snf_init" = x""yes; then : + ac_cv_lbl_snf_api="yes" +else + ac_cv_lbl_snf_api="no" +fi + + LDFLAGS="$saved_ldflags" + + if test $ac_cv_lbl_snf_api = no; then + if test "$want_snf" = yes; then + as_fn_error "SNF API cannot correctly be linked check config.log; use --without-snf" "$LINENO" 5 + 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 + +$as_echo "#define HAVE_SNF_API 1" >>confdefs.h + + fi + fi +fi + +if test "$V_PCAP" = snf -a "$ac_cv_lbl_snf_api" = no; then + as_fn_error "Specifying the capture type as 'snf' requires the Myricom Sniffer API to be present; use --with-snf=DIR" "$LINENO" 5 +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 aix*) -cat >>confdefs.h <<\_ACEOF -#define _SUN 1 -_ACEOF +$as_echo "#define _SUN 1" >>confdefs.h - # 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" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $pseexe" >&5 +$as_echo_n "checking for $pseexe... " >&6; } + if test -f $pseexe ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + 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*) @@ -8717,9 +6534,7 @@ darwin*) hpux9*) -cat >>confdefs.h <<\_ACEOF -#define HAVE_HPUX9 1 -_ACEOF +$as_echo "#define HAVE_HPUX9 1" >>confdefs.h # @@ -8749,10 +6564,19 @@ hpux10.1*) hpux*) -cat >>confdefs.h <<\_ACEOF -#define HAVE_HPUX10_20_OR_LATER 1 -_ACEOF +$as_echo "#define HAVE_HPUX10_20_OR_LATER 1" >>confdefs.h + 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. @@ -8769,11 +6593,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. # @@ -8782,16 +6616,12 @@ osf*) ;; sinix*) - { $as_echo "$as_me:$LINENO: checking if SINIX compiler defines sinix" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if SINIX compiler defines sinix" >&5 $as_echo_n "checking if SINIX compiler defines sinix... " >&6; } - if test "${ac_cv_cc_sinix_defined+set}" = set; then + if test "${ac_cv_cc_sinix_defined+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -8802,53 +6632,29 @@ int i = sinix; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_cc_sinix_defined=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_cc_sinix_defined=no + ac_cv_cc_sinix_defined=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { $as_echo "$as_me:$LINENO: result: $ac_cv_cc_sinix_defined" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cc_sinix_defined" >&5 $as_echo "$ac_cv_cc_sinix_defined" >&6; } if test $ac_cv_cc_sinix_defined = no ; then -cat >>confdefs.h <<\_ACEOF -#define sinix 1 -_ACEOF +$as_echo "#define sinix 1" >>confdefs.h fi ;; solaris*) -cat >>confdefs.h <<\_ACEOF -#define HAVE_SOLARIS 1 -_ACEOF +$as_echo "#define HAVE_SOLARIS 1" >>confdefs.h + DYEXT="so" # # Use System V conventions for man pages. # @@ -8860,9 +6666,9 @@ esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_RANLIB+set}" = set; then +if test "${ac_cv_prog_RANLIB+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then @@ -8873,24 +6679,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then - { $as_echo "$as_me:$LINENO: result: $RANLIB" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -8900,9 +6706,9 @@ if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then @@ -8913,24 +6719,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -8939,7 +6745,7 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -8981,26 +6787,20 @@ rm -f os-proto.h if test -f $name ; then ln -s $name os-proto.h -cat >>confdefs.h <<\_ACEOF -#define HAVE_OS_PROTO_H 1 -_ACEOF +$as_echo "#define HAVE_OS_PROTO_H 1" >>confdefs.h else - { $as_echo "$as_me:$LINENO: WARNING: can't find $name" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: can't find $name" >&5 $as_echo "$as_me: WARNING: can't find $name" >&2;} fi fi -{ $as_echo "$as_me:$LINENO: checking if sockaddr struct has sa_len member" >&5 -$as_echo_n "checking if sockaddr struct has sa_len member... " >&6; } - if test "${ac_cv_lbl_sockaddr_has_sa_len+set}" = set; then +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if sockaddr struct has the sa_len member" >&5 +$as_echo_n "checking if sockaddr struct has the sa_len member... " >&6; } + if test "${ac_cv_lbl_sockaddr_has_sa_len+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include @@ -9013,55 +6813,28 @@ u_int i = sizeof(((struct sockaddr *)0)->sa_len) return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_lbl_sockaddr_has_sa_len=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lbl_sockaddr_has_sa_len=no + ac_cv_lbl_sockaddr_has_sa_len=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_sockaddr_has_sa_len" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_sockaddr_has_sa_len" >&5 $as_echo "$ac_cv_lbl_sockaddr_has_sa_len" >&6; } if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then -cat >>confdefs.h <<\_ACEOF -#define HAVE_SOCKADDR_SA_LEN 1 -_ACEOF +$as_echo "#define HAVE_SOCKADDR_SA_LEN 1" >>confdefs.h fi -{ $as_echo "$as_me:$LINENO: checking if sockaddr_storage struct exists" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if sockaddr_storage struct exists" >&5 $as_echo_n "checking if sockaddr_storage struct exists... " >&6; } - if test "${ac_cv_lbl_has_sockaddr_storage+set}" = set; then + if test "${ac_cv_lbl_has_sockaddr_storage+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include @@ -9074,55 +6847,28 @@ u_int i = sizeof (struct sockaddr_storage) return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_lbl_has_sockaddr_storage=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lbl_has_sockaddr_storage=no + ac_cv_lbl_has_sockaddr_storage=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_has_sockaddr_storage" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_has_sockaddr_storage" >&5 $as_echo "$ac_cv_lbl_has_sockaddr_storage" >&6; } if test $ac_cv_lbl_has_sockaddr_storage = yes ; then -cat >>confdefs.h <<\_ACEOF -#define HAVE_SOCKADDR_STORAGE 1 -_ACEOF +$as_echo "#define HAVE_SOCKADDR_STORAGE 1" >>confdefs.h fi -{ $as_echo "$as_me:$LINENO: checking if dl_hp_ppa_info_t struct has dl_module_id_1 member" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if dl_hp_ppa_info_t struct has dl_module_id_1 member" >&5 $as_echo_n "checking if dl_hp_ppa_info_t struct has dl_module_id_1 member... " >&6; } - if test "${ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1+set}" = set; then + if test "${ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include @@ -9136,48 +6882,25 @@ u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1) return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=no + ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1" >&5 $as_echo "$ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1" >&6; } if test $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1 = yes ; then -cat >>confdefs.h <<\_ACEOF -#define HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 1 -_ACEOF +$as_echo "#define HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 1" >>confdefs.h fi -{ $as_echo "$as_me:$LINENO: checking if unaligned accesses fail" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if unaligned accesses fail" >&5 $as_echo_n "checking if unaligned accesses fail... " >&6; } - if test "${ac_cv_lbl_unaligned_fail+set}" = set; then + if test "${ac_cv_lbl_unaligned_fail+set}" = set; then : $as_echo_n "(cached) " >&6 else case "$host_cpu" in @@ -9257,18 +6980,16 @@ EOF ac_cv_lbl_unaligned_fail=no fi fi - rm -f conftest* core core.conftest + rm -f -r conftest* core core.conftest ;; esac fi - { $as_echo "$as_me:$LINENO: result: $ac_cv_lbl_unaligned_fail" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_unaligned_fail" >&5 $as_echo "$ac_cv_lbl_unaligned_fail" >&6; } if test $ac_cv_lbl_unaligned_fail = yes ; then -cat >>confdefs.h <<\_ACEOF -#define LBL_ALIGN 1 -_ACEOF +$as_echo "#define LBL_ALIGN 1" >>confdefs.h fi @@ -9277,9 +6998,7 @@ _ACEOF # that it will be generated if autoconf is used. # -cat >>confdefs.h <<\_ACEOF -#define HAVE_VERSION_H 1 -_ACEOF +$as_echo "#define HAVE_VERSION_H 1" >>confdefs.h rm -f net @@ -9298,17 +7017,18 @@ ln -s ${srcdir}/bpf/net net -{ $as_echo "$as_me:$LINENO: checking for USB sniffing support" >&5 + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for USB sniffing support" >&5 $as_echo_n "checking for USB sniffing support... " >&6; } case "$host_os" in linux*) -cat >>confdefs.h <<\_ACEOF -#define PCAP_SUPPORT_USB 1 -_ACEOF +$as_echo "#define PCAP_SUPPORT_USB 1" >>confdefs.h USB_SRC=pcap-usb-linux.c - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } ac_usb_dev_name=`udevinfo -q name -p /sys/class/usb_device/usbmon 2>/dev/null` if test $? -ne 0 ; then @@ -9319,172 +7039,147 @@ cat >>confdefs.h <<_ACEOF #define LINUX_USB_MON_DEV "/dev/$ac_usb_dev_name" _ACEOF - { $as_echo "$as_me:$LINENO: Device for USB sniffing is /dev/$ac_usb_dev_name" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Device for USB sniffing is /dev/$ac_usb_dev_name" >&5 $as_echo "$as_me: Device for USB sniffing is /dev/$ac_usb_dev_name" >&6;} + for ac_header in linux/usbdevice_fs.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "linux/usbdevice_fs.h" "ac_cv_header_linux_usbdevice_fs_h" "$ac_includes_default" +if test "x$ac_cv_header_linux_usbdevice_fs_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LINUX_USBDEVICE_FS_H 1 +_ACEOF + +fi + +done + + 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". + # + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if usbdevfs_ctrltransfer struct has bRequestType member" >&5 +$as_echo_n "checking if usbdevfs_ctrltransfer struct has bRequestType member... " >&6; } + if test "${ac_cv_usbdevfs_ctrltransfer_has_bRequestType+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +$ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +# include +int +main () +{ +u_int i = sizeof(((struct usbdevfs_ctrltransfer *)0)->bRequestType) + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_usbdevfs_ctrltransfer_has_bRequestType=yes +else + ac_cv_usbdevfs_ctrltransfer_has_bRequestType=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_usbdevfs_ctrltransfer_has_bRequestType" >&5 +$as_echo "$ac_cv_usbdevfs_ctrltransfer_has_bRequestType" >&6; } + if test $ac_cv_usbdevfs_ctrltransfer_has_bRequestType = yes ; then + +$as_echo "#define HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE 1" >>confdefs.h + + fi + fi ;; *) - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac -case "$host_os" in -linux*) - if test "${ac_cv_header_bluetooth_bluetooth_h+set}" = set; then - { $as_echo "$as_me:$LINENO: checking for bluetooth/bluetooth.h" >&5 -$as_echo_n "checking for bluetooth/bluetooth.h... " >&6; } -if test "${ac_cv_header_bluetooth_bluetooth_h+set}" = set; then - $as_echo_n "(cached) " >&6 -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_bluetooth_bluetooth_h" >&5 -$as_echo "$ac_cv_header_bluetooth_bluetooth_h" >&6; } +# Check whether --enable-bluetooth was given. +if test "${enable_bluetooth+set}" = set; then : + enableval=$enable_bluetooth; else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking bluetooth/bluetooth.h usability" >&5 -$as_echo_n "checking bluetooth/bluetooth.h usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no + enable_bluetooth=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking bluetooth/bluetooth.h presence" >&5 -$as_echo_n "checking bluetooth/bluetooth.h presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: bluetooth/bluetooth.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: bluetooth/bluetooth.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: bluetooth/bluetooth.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: bluetooth/bluetooth.h: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: bluetooth/bluetooth.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: bluetooth/bluetooth.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: bluetooth/bluetooth.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: bluetooth/bluetooth.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: bluetooth/bluetooth.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: bluetooth/bluetooth.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: bluetooth/bluetooth.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: bluetooth/bluetooth.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: bluetooth/bluetooth.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: bluetooth/bluetooth.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: bluetooth/bluetooth.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: bluetooth/bluetooth.h: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for bluetooth/bluetooth.h" >&5 -$as_echo_n "checking for bluetooth/bluetooth.h... " >&6; } -if test "${ac_cv_header_bluetooth_bluetooth_h+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_header_bluetooth_bluetooth_h=$ac_header_preproc -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_bluetooth_bluetooth_h" >&5 -$as_echo "$ac_cv_header_bluetooth_bluetooth_h" >&6; } - -fi -if test "x$ac_cv_header_bluetooth_bluetooth_h" = x""yes; then +if test "x$enable_bluetooth" != "xno" ; then + case "$host_os" in + linux*) + ac_fn_c_check_header_mongrel "$LINENO" "bluetooth/bluetooth.h" "ac_cv_header_bluetooth_bluetooth_h" "$ac_includes_default" +if test "x$ac_cv_header_bluetooth_bluetooth_h" = x""yes; then : -cat >>confdefs.h <<\_ACEOF -#define PCAP_SUPPORT_BT 1 -_ACEOF +$as_echo "#define PCAP_SUPPORT_BT 1" >>confdefs.h - BT_SRC=pcap-bt-linux.c - { $as_echo "$as_me:$LINENO: Bluetooth sniffing is supported" >&5 + BT_SRC=pcap-bt-linux.c + { $as_echo "$as_me:${as_lineno-$LINENO}: Bluetooth sniffing is supported" >&5 $as_echo "$as_me: Bluetooth sniffing is supported" >&6;} else - { $as_echo "$as_me:$LINENO: Bluetooth sniffing is not supported; install bluez-lib devel to enable it" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Bluetooth sniffing is not supported; install bluez-lib devel to enable it" >&5 $as_echo "$as_me: Bluetooth sniffing is not supported; install bluez-lib devel to enable it" >&6;} fi - ;; -*) - { $as_echo "$as_me:$LINENO: no Bluetooth sniffing support" >&5 -$as_echo "$as_me: no Bluetooth sniffing support" >&6;} - ;; -esac + ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: no Bluetooth sniffing support implemented for $host_os" >&5 +$as_echo "$as_me: no Bluetooth sniffing support implemented for $host_os" >&6;} + ;; + esac +fi + +# Check whether --enable-can was given. +if test "${enable_can+set}" = set; then : + enableval=$enable_can; +else + enable_can=yes +fi + + +if test "x$enable_can" != "xno" ; then + case "$host_os" in + linux*) + ac_fn_c_check_header_compile "$LINENO" "linux/can.h" "ac_cv_header_linux_can_h" "#include + +" +if test "x$ac_cv_header_linux_can_h" = x""yes; then : + +$as_echo "#define PCAP_SUPPORT_CAN 1" >>confdefs.h + + CAN_SRC=pcap-can-linux.c + { $as_echo "$as_me:${as_lineno-$LINENO}: CAN sniffing is supported" >&5 +$as_echo "$as_me: CAN sniffing is supported" >&6;} +else + { $as_echo "$as_me:${as_lineno-$LINENO}: CAN sniffing is not supported" >&5 +$as_echo "$as_me: CAN sniffing is not supported" >&6;} +fi + + + ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: no CAN sniffing support implemented for $host_os" >&5 +$as_echo "$as_me: no CAN sniffing support implemented for $host_os" >&6;} + ;; + esac + + +fi # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or @@ -9500,10 +7195,10 @@ esac # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. -{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then +if test "${ac_cv_path_install+set}" = set; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -9511,11 +7206,11 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in - ./ | .// | /cC/* | \ + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. @@ -9552,7 +7247,7 @@ case $as_dir/ in ;; esac -done + done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir @@ -9568,7 +7263,7 @@ fi INSTALL=$ac_install_sh fi fi -{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. @@ -9612,13 +7307,13 @@ _ACEOF case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) $as_unset $ac_var ;; + *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done @@ -9626,8 +7321,8 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \). + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" @@ -9650,11 +7345,11 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && - { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else - { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi @@ -9674,8 +7369,8 @@ for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. - ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs @@ -9687,9 +7382,10 @@ LTLIBOBJS=$ac_ltlibobjs ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. @@ -9699,17 +7395,18 @@ cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 debug=false ac_cs_recheck=false ac_cs_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which @@ -9717,23 +7414,15 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; esac - fi - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - as_nl=' ' export as_nl @@ -9741,7 +7430,13 @@ export as_nl as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else @@ -9752,7 +7447,7 @@ else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; - case $arg in + case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; @@ -9775,13 +7470,6 @@ if test "${PATH_SEPARATOR+set}" != set; then } fi -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - # IFS # We need space, tab and new line, in precisely that order. Quoting is @@ -9791,15 +7479,15 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -case $0 in +case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done IFS=$as_save_IFS ;; @@ -9811,12 +7499,16 @@ if test "x$as_myself" = x; then fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } + exit 1 fi -# Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' @@ -9828,7 +7520,89 @@ export LC_ALL LANGUAGE=C export LANGUAGE -# Required to use basename. +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error ERROR [LINENO LOG_FD] +# --------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with status $?, using 1 if that was 0. +as_fn_error () +{ + as_status=$?; test $as_status -eq 0 && as_status=1 + if test "$3"; then + as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + fi + $as_echo "$as_me: error: $1" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr @@ -9842,8 +7616,12 @@ else as_basename=false fi +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi -# Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ @@ -9863,76 +7641,25 @@ $as_echo X/"$0" | } s/.*/./; q'` -# CDPATH. -$as_unset CDPATH - - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in +case `echo -n x` in #((((( -n*) - case `echo 'x\c'` in + case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then @@ -9961,8 +7688,56 @@ fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + + +} # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then - as_mkdir_p=: + as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false @@ -9981,10 +7756,10 @@ else if test -d "$1"; then test -d "$1/."; else - case $1 in + case $1 in #( -*)set "./$1";; esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' @@ -9999,13 +7774,19 @@ as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 -# Save the log message, to keep $[0] and so on meaningful, and to +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by $as_me, which was -generated by GNU Autoconf 2.63. Invocation command line was +generated by GNU Autoconf 2.65. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -10036,13 +7817,15 @@ _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ -\`$as_me' instantiates files from templates according to the -current configuration. +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. -Usage: $0 [OPTION]... [FILE]... +Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit + --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files @@ -10058,16 +7841,17 @@ $config_files Configuration headers: $config_headers -Report bugs to ." +Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ config.status -configured by $0, generated by GNU Autoconf 2.63, - with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" +configured by $0, generated by GNU Autoconf 2.65, + with options \\"\$ac_cs_config\\" -Copyright (C) 2008 Free Software Foundation, Inc. +Copyright (C) 2009 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -10101,6 +7885,8 @@ do ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) @@ -10108,20 +7894,19 @@ do case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac - CONFIG_FILES="$CONFIG_FILES '$ac_optarg'" + as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac - CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'" + as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header - { $as_echo "$as_me: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; };; + as_fn_error "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ @@ -10129,11 +7914,10 @@ Try \`$0 --help' for more information." >&2 ac_cs_silent=: ;; # This is an error. - -*) { $as_echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } ;; + -*) as_fn_error "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; - *) ac_config_targets="$ac_config_targets $1" + *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac @@ -10192,9 +7976,7 @@ do "pcap_open_dead.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_open_dead.3pcap" ;; "pcap_open_offline.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_open_offline.3pcap" ;; - *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;} - { (exit 1); exit 1; }; };; + *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done @@ -10220,7 +8002,7 @@ $debug || trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 - trap '{ (exit 1); exit 1; }' 1 2 13 15 + trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. @@ -10231,11 +8013,7 @@ $debug || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") -} || -{ - $as_echo "$as_me: cannot create a temporary directory in ." >&2 - { (exit 1); exit 1; } -} +} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -10243,10 +8021,16 @@ $debug || if test -n "$CONFIG_FILES"; then -ac_cr=' ' +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\\r' + ac_cs_awk_cr='\r' else ac_cs_awk_cr=$ac_cr fi @@ -10260,24 +8044,18 @@ _ACEOF echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -10299,7 +8077,7 @@ s/'"$ac_delim"'$// t delim :nl h -s/\(.\{148\}\).*/\1/ +s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p @@ -10313,7 +8091,7 @@ s/.\{148\}// t nl :delim h -s/\(.\{148\}\).*/\1/ +s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p @@ -10366,9 +8144,7 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then else cat fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5 -$as_echo "$as_me: error: could not setup config files machinery" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove $(srcdir), @@ -10409,9 +8185,7 @@ for ac_last_try in false false :; do if test -z "$ac_t"; then break elif $ac_last_try; then - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -10496,9 +8270,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - { { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5 -$as_echo "$as_me: error: could not setup config headers machinery" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" @@ -10511,9 +8283,7 @@ do esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5 -$as_echo "$as_me: error: invalid tag $ac_tag" >&2;} - { (exit 1); exit 1; }; };; + :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -10541,12 +8311,10 @@ $as_echo "$as_me: error: invalid tag $ac_tag" >&2;} [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 -$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} - { (exit 1); exit 1; }; };; + as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - ac_file_inputs="$ac_file_inputs '$ac_f'" + as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't @@ -10557,7 +8325,7 @@ $as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:$LINENO: creating $ac_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. @@ -10570,9 +8338,7 @@ $as_echo "$as_me: creating $ac_file" >&6;} case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } ;; + || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -10600,47 +8366,7 @@ $as_echo X"$ac_file" | q } s/.*/./; q'` - { as_dir="$ac_dir" - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} - { (exit 1); exit 1; }; }; } + as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in @@ -10692,7 +8418,6 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= - ac_sed_dataroot=' /datarootdir/ { p @@ -10702,12 +8427,11 @@ ac_sed_dataroot=' /@docdir@/p /@infodir@/p /@localedir@/p -/@mandir@/p -' +/@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 @@ -10717,7 +8441,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; + s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF @@ -10745,14 +8469,12 @@ s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&2;} @@ -10762,9 +8484,7 @@ which seems to be undefined. Please make sure it is defined." >&2;} -) cat "$tmp/out" && rm -f "$tmp/out";; *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; :H) # @@ -10775,25 +8495,19 @@ $as_echo "$as_me: error: could not create $ac_file" >&2;} $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" } >"$tmp/config.h" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then - { $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$tmp/config.h" "$ac_file" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ - || { { $as_echo "$as_me:$LINENO: error: could not create -" >&5 -$as_echo "$as_me: error: could not create -" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error "could not create -" "$LINENO" 5 fi ;; @@ -10803,15 +8517,12 @@ $as_echo "$as_me: error: could not create -" >&2;} done # for ac_tag -{ (exit 0); exit 0; } +as_fn_exit 0 _ACEOF -chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || - { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. @@ -10832,10 +8543,10 @@ if test "$no_create" != yes; then exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. - $ac_cs_success || { (exit 1); exit 1; } + $ac_cs_success || as_fn_exit $? fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi diff --git a/libpcap/configure.in b/libpcap/configure.in index b177e132d..58996b11a 100644 --- a/libpcap/configure.in +++ b/libpcap/configure.in @@ -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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 ; 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 were, on all OSes that support BPF, fixed to +dnl include , and we were to drop support for older +dnl releases without that fix, so that pcap-bpf.c doesn't need to +dnl include , 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 @@ -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 -#include +#include #include ]) + + # + # 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 +#endif +# include ], + [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 ] + ) + ;; + *) + 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 diff --git a/libpcap/dlpisubs.c b/libpcap/dlpisubs.c index 05ea4dd95..23c78ced2 100644 --- a/libpcap/dlpisubs.c +++ b/libpcap/dlpisubs.c @@ -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 diff --git a/libpcap/dlpisubs.h b/libpcap/dlpisubs.h index 67acd292f..1b57d4d2e 100644 --- a/libpcap/dlpisubs.h +++ b/libpcap/dlpisubs.h @@ -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 diff --git a/libpcap/etherent.c b/libpcap/etherent.c index 27e55024e..d9de11467 100644 --- a/libpcap/etherent.c +++ b/libpcap/etherent.c @@ -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 +#else /* WIN32 */ +#if HAVE_INTTYPES_H +#include +#elif HAVE_STDINT_H +#include +#endif +#ifdef HAVE_SYS_BITYPES_H +#include +#endif #include +#endif /* WIN32 */ #include #include diff --git a/libpcap/ethertype.h b/libpcap/ethertype.h index 867d33eae..d22b92778 100644 --- a/libpcap/ethertype.h +++ b/libpcap/ethertype.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) */ /* diff --git a/libpcap/fad-getad.c b/libpcap/fad-getad.c index 2ce6d7009..831ddae7a 100644 --- a/libpcap/fad-getad.c +++ b/libpcap/fad-getad.c @@ -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 /* LynxOS */ +/* LynxOS */ +# include # else -# include /* Linux */ +/* Linux */ +# include +# include # endif #endif diff --git a/libpcap/fad-gifc.c b/libpcap/fad-gifc.c index ef04bd903..d0a2e99e0 100644 --- a/libpcap/fad-gifc.c +++ b/libpcap/fad-gifc.c @@ -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 */ */ #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) { diff --git a/libpcap/fad-glifc.c b/libpcap/fad-glifc.c index 9e92bc359..664bb78ae 100644 --- a/libpcap/fad-glifc.c +++ b/libpcap/fad-glifc.c @@ -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 diff --git a/libpcap/fad-null.c b/libpcap/fad-null.c index 676ff71e4..26d791d0d 100644 --- a/libpcap/fad-null.c +++ b/libpcap/fad-null.c @@ -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 diff --git a/libpcap/fad-win32.c b/libpcap/fad-win32.c index 19839c869..241a92690 100644 --- a/libpcap/fad-win32.c +++ b/libpcap/fad-win32.c @@ -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 diff --git a/libpcap/filtertest.c b/libpcap/filtertest.c index cfa69eab4..a56d1e49e 100644 --- a/libpcap/filtertest.c +++ b/libpcap/filtertest.c @@ -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 #include #include +#include #include #include @@ -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); } diff --git a/libpcap/gencode.c b/libpcap/gencode.c index 41057ba8c..14f4b7509 100644 --- a/libpcap/gencode.c +++ b/libpcap/gencode.c @@ -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 #else /* WIN32 */ +#if HAVE_INTTYPES_H +#include +#elif HAVE_STDINT_H +#include +#endif +#ifdef HAVE_SYS_BITYPES_H +#include +#endif #include #include #endif /* WIN32 */ @@ -49,6 +57,7 @@ static const char rcsid[] _U_ = #endif #include +#include #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 @@ -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) { /* diff --git a/libpcap/gencode.h b/libpcap/gencode.h index 39b1eea54..e2388b78c 100644 --- a/libpcap/gencode.h +++ b/libpcap/gencode.h @@ -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) */ /* diff --git a/libpcap/grammar.c b/libpcap/grammar.c index 1d5745239..38d93fe36 100644 --- a/libpcap/grammar.c +++ b/libpcap/grammar.c @@ -101,7 +101,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 @@ -124,6 +124,7 @@ struct rtentry; #endif #include +#include #endif /* WIN32 */ #include @@ -318,7 +319,7 @@ pfaction_to_num(const char *action) /* Line 189 of yacc.c */ -#line 322 "y.tab.c" +#line 323 "y.tab.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -573,7 +574,7 @@ typedef union YYSTYPE { /* Line 214 of yacc.c */ -#line 241 "grammar.y" +#line 242 "grammar.y" int i; bpf_u_int32 h; @@ -592,7 +593,7 @@ typedef union YYSTYPE /* Line 214 of yacc.c */ -#line 596 "y.tab.c" +#line 597 "y.tab.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -604,7 +605,7 @@ typedef union YYSTYPE /* Line 264 of yacc.c */ -#line 608 "y.tab.c" +#line 609 "y.tab.c" #ifdef short # undef short @@ -967,27 +968,27 @@ static const yytype_int16 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 314, 314, 318, 320, 322, 323, 324, 325, 326, - 328, 330, 332, 333, 335, 337, 338, 340, 342, 355, - 364, 373, 382, 391, 393, 395, 397, 398, 399, 401, - 403, 405, 406, 408, 409, 410, 411, 412, 413, 415, - 416, 417, 418, 420, 422, 423, 424, 425, 426, 427, - 430, 431, 434, 435, 436, 437, 438, 439, 440, 441, - 442, 443, 446, 447, 448, 449, 452, 454, 455, 456, - 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, - 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, - 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, - 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, - 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, - 510, 511, 512, 513, 514, 515, 518, 523, 526, 530, - 533, 534, 540, 541, 561, 577, 578, 591, 592, 595, - 598, 599, 600, 602, 603, 604, 606, 607, 609, 610, - 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, - 621, 623, 624, 625, 626, 627, 629, 630, 632, 633, - 634, 635, 636, 637, 638, 639, 641, 642, 643, 644, - 647, 648, 650, 651, 652, 653, 655, 662, 663, 666, - 667, 668, 671, 672, 673, 674, 676, 677, 678, 679, - 681, 690, 691 + 0, 315, 315, 319, 321, 323, 324, 325, 326, 327, + 329, 331, 333, 334, 336, 338, 339, 341, 343, 356, + 365, 374, 383, 392, 394, 396, 398, 399, 400, 402, + 404, 406, 407, 409, 410, 411, 412, 413, 414, 416, + 417, 418, 419, 421, 423, 424, 425, 426, 427, 428, + 431, 432, 435, 436, 437, 438, 439, 440, 441, 442, + 443, 444, 447, 448, 449, 450, 453, 455, 456, 457, + 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, + 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, + 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, + 488, 489, 490, 491, 492, 494, 495, 496, 497, 498, + 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, + 511, 512, 513, 514, 515, 516, 519, 524, 527, 531, + 534, 535, 541, 542, 562, 578, 579, 592, 593, 596, + 599, 600, 601, 603, 604, 605, 607, 608, 610, 611, + 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, + 622, 624, 625, 626, 627, 628, 630, 631, 633, 634, + 635, 636, 637, 638, 639, 640, 642, 643, 644, 645, + 648, 649, 651, 652, 653, 654, 656, 663, 664, 667, + 668, 669, 672, 673, 674, 675, 677, 678, 679, 680, + 682, 691, 692 }; #endif @@ -2176,7 +2177,7 @@ yyreduce: case 2: /* Line 1455 of yacc.c */ -#line 315 "grammar.y" +#line 316 "grammar.y" { finish_parse((yyvsp[(2) - (2)].blk).b); } @@ -2185,56 +2186,56 @@ yyreduce: case 4: /* Line 1455 of yacc.c */ -#line 320 "grammar.y" +#line 321 "grammar.y" { (yyval.blk).q = qerr; } break; case 6: /* Line 1455 of yacc.c */ -#line 323 "grammar.y" +#line 324 "grammar.y" { gen_and((yyvsp[(1) - (3)].blk).b, (yyvsp[(3) - (3)].blk).b); (yyval.blk) = (yyvsp[(3) - (3)].blk); } break; case 7: /* Line 1455 of yacc.c */ -#line 324 "grammar.y" +#line 325 "grammar.y" { gen_and((yyvsp[(1) - (3)].blk).b, (yyvsp[(3) - (3)].blk).b); (yyval.blk) = (yyvsp[(3) - (3)].blk); } break; case 8: /* Line 1455 of yacc.c */ -#line 325 "grammar.y" +#line 326 "grammar.y" { gen_or((yyvsp[(1) - (3)].blk).b, (yyvsp[(3) - (3)].blk).b); (yyval.blk) = (yyvsp[(3) - (3)].blk); } break; case 9: /* Line 1455 of yacc.c */ -#line 326 "grammar.y" +#line 327 "grammar.y" { gen_or((yyvsp[(1) - (3)].blk).b, (yyvsp[(3) - (3)].blk).b); (yyval.blk) = (yyvsp[(3) - (3)].blk); } break; case 10: /* Line 1455 of yacc.c */ -#line 328 "grammar.y" +#line 329 "grammar.y" { (yyval.blk) = (yyvsp[(0) - (1)].blk); } break; case 11: /* Line 1455 of yacc.c */ -#line 330 "grammar.y" +#line 331 "grammar.y" { (yyval.blk) = (yyvsp[(0) - (1)].blk); } break; case 13: /* Line 1455 of yacc.c */ -#line 333 "grammar.y" +#line 334 "grammar.y" { (yyval.blk).b = gen_ncode(NULL, (bpf_u_int32)(yyvsp[(1) - (1)].i), (yyval.blk).q = (yyvsp[(0) - (1)].blk).q); } break; @@ -2242,21 +2243,21 @@ yyreduce: case 14: /* Line 1455 of yacc.c */ -#line 335 "grammar.y" +#line 336 "grammar.y" { (yyval.blk) = (yyvsp[(2) - (3)].blk); } break; case 15: /* Line 1455 of yacc.c */ -#line 337 "grammar.y" +#line 338 "grammar.y" { (yyval.blk).b = gen_scode((yyvsp[(1) - (1)].s), (yyval.blk).q = (yyvsp[(0) - (1)].blk).q); } break; case 16: /* Line 1455 of yacc.c */ -#line 338 "grammar.y" +#line 339 "grammar.y" { (yyval.blk).b = gen_mcode((yyvsp[(1) - (3)].s), NULL, (yyvsp[(3) - (3)].i), (yyval.blk).q = (yyvsp[(0) - (3)].blk).q); } break; @@ -2264,7 +2265,7 @@ yyreduce: case 17: /* Line 1455 of yacc.c */ -#line 340 "grammar.y" +#line 341 "grammar.y" { (yyval.blk).b = gen_mcode((yyvsp[(1) - (3)].s), (yyvsp[(3) - (3)].s), 0, (yyval.blk).q = (yyvsp[(0) - (3)].blk).q); } break; @@ -2272,7 +2273,7 @@ yyreduce: case 18: /* Line 1455 of yacc.c */ -#line 342 "grammar.y" +#line 343 "grammar.y" { /* Decide how to parse HID based on proto */ (yyval.blk).q = (yyvsp[(0) - (1)].blk).q; @@ -2291,7 +2292,7 @@ yyreduce: case 19: /* Line 1455 of yacc.c */ -#line 355 "grammar.y" +#line 356 "grammar.y" { #ifdef INET6 (yyval.blk).b = gen_mcode6((yyvsp[(1) - (3)].s), NULL, (yyvsp[(3) - (3)].i), @@ -2306,7 +2307,7 @@ yyreduce: case 20: /* Line 1455 of yacc.c */ -#line 364 "grammar.y" +#line 365 "grammar.y" { #ifdef INET6 (yyval.blk).b = gen_mcode6((yyvsp[(1) - (1)].s), 0, 128, @@ -2321,7 +2322,7 @@ yyreduce: case 21: /* Line 1455 of yacc.c */ -#line 373 "grammar.y" +#line 374 "grammar.y" { (yyval.blk).b = gen_ecode((yyvsp[(1) - (1)].e), (yyval.blk).q = (yyvsp[(0) - (1)].blk).q); /* @@ -2336,7 +2337,7 @@ yyreduce: case 22: /* Line 1455 of yacc.c */ -#line 382 "grammar.y" +#line 383 "grammar.y" { (yyval.blk).b = gen_acode((yyvsp[(1) - (1)].e), (yyval.blk).q = (yyvsp[(0) - (1)].blk).q); /* @@ -2351,42 +2352,42 @@ yyreduce: case 23: /* Line 1455 of yacc.c */ -#line 391 "grammar.y" +#line 392 "grammar.y" { gen_not((yyvsp[(2) - (2)].blk).b); (yyval.blk) = (yyvsp[(2) - (2)].blk); } break; case 24: /* Line 1455 of yacc.c */ -#line 393 "grammar.y" +#line 394 "grammar.y" { (yyval.blk) = (yyvsp[(0) - (1)].blk); } break; case 25: /* Line 1455 of yacc.c */ -#line 395 "grammar.y" +#line 396 "grammar.y" { (yyval.blk) = (yyvsp[(0) - (1)].blk); } break; case 27: /* Line 1455 of yacc.c */ -#line 398 "grammar.y" +#line 399 "grammar.y" { gen_and((yyvsp[(1) - (3)].blk).b, (yyvsp[(3) - (3)].blk).b); (yyval.blk) = (yyvsp[(3) - (3)].blk); } break; case 28: /* Line 1455 of yacc.c */ -#line 399 "grammar.y" +#line 400 "grammar.y" { gen_or((yyvsp[(1) - (3)].blk).b, (yyvsp[(3) - (3)].blk).b); (yyval.blk) = (yyvsp[(3) - (3)].blk); } break; case 29: /* Line 1455 of yacc.c */ -#line 401 "grammar.y" +#line 402 "grammar.y" { (yyval.blk).b = gen_ncode(NULL, (bpf_u_int32)(yyvsp[(1) - (1)].i), (yyval.blk).q = (yyvsp[(0) - (1)].blk).q); } break; @@ -2394,77 +2395,77 @@ yyreduce: case 32: /* Line 1455 of yacc.c */ -#line 406 "grammar.y" +#line 407 "grammar.y" { gen_not((yyvsp[(2) - (2)].blk).b); (yyval.blk) = (yyvsp[(2) - (2)].blk); } break; case 33: /* Line 1455 of yacc.c */ -#line 408 "grammar.y" +#line 409 "grammar.y" { QSET((yyval.blk).q, (yyvsp[(1) - (3)].i), (yyvsp[(2) - (3)].i), (yyvsp[(3) - (3)].i)); } break; case 34: /* Line 1455 of yacc.c */ -#line 409 "grammar.y" +#line 410 "grammar.y" { QSET((yyval.blk).q, (yyvsp[(1) - (2)].i), (yyvsp[(2) - (2)].i), Q_DEFAULT); } break; case 35: /* Line 1455 of yacc.c */ -#line 410 "grammar.y" +#line 411 "grammar.y" { QSET((yyval.blk).q, (yyvsp[(1) - (2)].i), Q_DEFAULT, (yyvsp[(2) - (2)].i)); } break; case 36: /* Line 1455 of yacc.c */ -#line 411 "grammar.y" +#line 412 "grammar.y" { QSET((yyval.blk).q, (yyvsp[(1) - (2)].i), Q_DEFAULT, Q_PROTO); } break; case 37: /* Line 1455 of yacc.c */ -#line 412 "grammar.y" +#line 413 "grammar.y" { QSET((yyval.blk).q, (yyvsp[(1) - (2)].i), Q_DEFAULT, Q_PROTOCHAIN); } break; case 38: /* Line 1455 of yacc.c */ -#line 413 "grammar.y" +#line 414 "grammar.y" { QSET((yyval.blk).q, (yyvsp[(1) - (2)].i), Q_DEFAULT, (yyvsp[(2) - (2)].i)); } break; case 39: /* Line 1455 of yacc.c */ -#line 415 "grammar.y" +#line 416 "grammar.y" { (yyval.blk) = (yyvsp[(2) - (2)].blk); } break; case 40: /* Line 1455 of yacc.c */ -#line 416 "grammar.y" +#line 417 "grammar.y" { (yyval.blk).b = (yyvsp[(2) - (3)].blk).b; (yyval.blk).q = (yyvsp[(1) - (3)].blk).q; } break; case 41: /* Line 1455 of yacc.c */ -#line 417 "grammar.y" +#line 418 "grammar.y" { (yyval.blk).b = gen_proto_abbrev((yyvsp[(1) - (1)].i)); (yyval.blk).q = qerr; } break; case 42: /* Line 1455 of yacc.c */ -#line 418 "grammar.y" +#line 419 "grammar.y" { (yyval.blk).b = gen_relation((yyvsp[(2) - (3)].i), (yyvsp[(1) - (3)].a), (yyvsp[(3) - (3)].a), 0); (yyval.blk).q = qerr; } break; @@ -2472,7 +2473,7 @@ yyreduce: case 43: /* Line 1455 of yacc.c */ -#line 420 "grammar.y" +#line 421 "grammar.y" { (yyval.blk).b = gen_relation((yyvsp[(2) - (3)].i), (yyvsp[(1) - (3)].a), (yyvsp[(3) - (3)].a), 1); (yyval.blk).q = qerr; } break; @@ -2480,574 +2481,574 @@ yyreduce: case 44: /* Line 1455 of yacc.c */ -#line 422 "grammar.y" +#line 423 "grammar.y" { (yyval.blk).b = (yyvsp[(1) - (1)].rblk); (yyval.blk).q = qerr; } break; case 45: /* Line 1455 of yacc.c */ -#line 423 "grammar.y" +#line 424 "grammar.y" { (yyval.blk).b = gen_atmtype_abbrev((yyvsp[(1) - (1)].i)); (yyval.blk).q = qerr; } break; case 46: /* Line 1455 of yacc.c */ -#line 424 "grammar.y" +#line 425 "grammar.y" { (yyval.blk).b = gen_atmmulti_abbrev((yyvsp[(1) - (1)].i)); (yyval.blk).q = qerr; } break; case 47: /* Line 1455 of yacc.c */ -#line 425 "grammar.y" +#line 426 "grammar.y" { (yyval.blk).b = (yyvsp[(2) - (2)].blk).b; (yyval.blk).q = qerr; } break; case 48: /* Line 1455 of yacc.c */ -#line 426 "grammar.y" +#line 427 "grammar.y" { (yyval.blk).b = gen_mtp2type_abbrev((yyvsp[(1) - (1)].i)); (yyval.blk).q = qerr; } break; case 49: /* Line 1455 of yacc.c */ -#line 427 "grammar.y" +#line 428 "grammar.y" { (yyval.blk).b = (yyvsp[(2) - (2)].blk).b; (yyval.blk).q = qerr; } break; case 51: /* Line 1455 of yacc.c */ -#line 431 "grammar.y" +#line 432 "grammar.y" { (yyval.i) = Q_DEFAULT; } break; case 52: /* Line 1455 of yacc.c */ -#line 434 "grammar.y" +#line 435 "grammar.y" { (yyval.i) = Q_SRC; } break; case 53: /* Line 1455 of yacc.c */ -#line 435 "grammar.y" +#line 436 "grammar.y" { (yyval.i) = Q_DST; } break; case 54: /* Line 1455 of yacc.c */ -#line 436 "grammar.y" +#line 437 "grammar.y" { (yyval.i) = Q_OR; } break; case 55: /* Line 1455 of yacc.c */ -#line 437 "grammar.y" +#line 438 "grammar.y" { (yyval.i) = Q_OR; } break; case 56: /* Line 1455 of yacc.c */ -#line 438 "grammar.y" +#line 439 "grammar.y" { (yyval.i) = Q_AND; } break; case 57: /* Line 1455 of yacc.c */ -#line 439 "grammar.y" +#line 440 "grammar.y" { (yyval.i) = Q_AND; } break; case 58: /* Line 1455 of yacc.c */ -#line 440 "grammar.y" +#line 441 "grammar.y" { (yyval.i) = Q_ADDR1; } break; case 59: /* Line 1455 of yacc.c */ -#line 441 "grammar.y" +#line 442 "grammar.y" { (yyval.i) = Q_ADDR2; } break; case 60: /* Line 1455 of yacc.c */ -#line 442 "grammar.y" +#line 443 "grammar.y" { (yyval.i) = Q_ADDR3; } break; case 61: /* Line 1455 of yacc.c */ -#line 443 "grammar.y" +#line 444 "grammar.y" { (yyval.i) = Q_ADDR4; } break; case 62: /* Line 1455 of yacc.c */ -#line 446 "grammar.y" +#line 447 "grammar.y" { (yyval.i) = Q_HOST; } break; case 63: /* Line 1455 of yacc.c */ -#line 447 "grammar.y" +#line 448 "grammar.y" { (yyval.i) = Q_NET; } break; case 64: /* Line 1455 of yacc.c */ -#line 448 "grammar.y" +#line 449 "grammar.y" { (yyval.i) = Q_PORT; } break; case 65: /* Line 1455 of yacc.c */ -#line 449 "grammar.y" +#line 450 "grammar.y" { (yyval.i) = Q_PORTRANGE; } break; case 66: /* Line 1455 of yacc.c */ -#line 452 "grammar.y" +#line 453 "grammar.y" { (yyval.i) = Q_GATEWAY; } break; case 67: /* Line 1455 of yacc.c */ -#line 454 "grammar.y" +#line 455 "grammar.y" { (yyval.i) = Q_LINK; } break; case 68: /* Line 1455 of yacc.c */ -#line 455 "grammar.y" +#line 456 "grammar.y" { (yyval.i) = Q_IP; } break; case 69: /* Line 1455 of yacc.c */ -#line 456 "grammar.y" +#line 457 "grammar.y" { (yyval.i) = Q_ARP; } break; case 70: /* Line 1455 of yacc.c */ -#line 457 "grammar.y" +#line 458 "grammar.y" { (yyval.i) = Q_RARP; } break; case 71: /* Line 1455 of yacc.c */ -#line 458 "grammar.y" +#line 459 "grammar.y" { (yyval.i) = Q_SCTP; } break; case 72: /* Line 1455 of yacc.c */ -#line 459 "grammar.y" +#line 460 "grammar.y" { (yyval.i) = Q_TCP; } break; case 73: /* Line 1455 of yacc.c */ -#line 460 "grammar.y" +#line 461 "grammar.y" { (yyval.i) = Q_UDP; } break; case 74: /* Line 1455 of yacc.c */ -#line 461 "grammar.y" +#line 462 "grammar.y" { (yyval.i) = Q_ICMP; } break; case 75: /* Line 1455 of yacc.c */ -#line 462 "grammar.y" +#line 463 "grammar.y" { (yyval.i) = Q_IGMP; } break; case 76: /* Line 1455 of yacc.c */ -#line 463 "grammar.y" +#line 464 "grammar.y" { (yyval.i) = Q_IGRP; } break; case 77: /* Line 1455 of yacc.c */ -#line 464 "grammar.y" +#line 465 "grammar.y" { (yyval.i) = Q_PIM; } break; case 78: /* Line 1455 of yacc.c */ -#line 465 "grammar.y" +#line 466 "grammar.y" { (yyval.i) = Q_VRRP; } break; case 79: /* Line 1455 of yacc.c */ -#line 466 "grammar.y" +#line 467 "grammar.y" { (yyval.i) = Q_ATALK; } break; case 80: /* Line 1455 of yacc.c */ -#line 467 "grammar.y" +#line 468 "grammar.y" { (yyval.i) = Q_AARP; } break; case 81: /* Line 1455 of yacc.c */ -#line 468 "grammar.y" +#line 469 "grammar.y" { (yyval.i) = Q_DECNET; } break; case 82: /* Line 1455 of yacc.c */ -#line 469 "grammar.y" +#line 470 "grammar.y" { (yyval.i) = Q_LAT; } break; case 83: /* Line 1455 of yacc.c */ -#line 470 "grammar.y" +#line 471 "grammar.y" { (yyval.i) = Q_SCA; } break; case 84: /* Line 1455 of yacc.c */ -#line 471 "grammar.y" +#line 472 "grammar.y" { (yyval.i) = Q_MOPDL; } break; case 85: /* Line 1455 of yacc.c */ -#line 472 "grammar.y" +#line 473 "grammar.y" { (yyval.i) = Q_MOPRC; } break; case 86: /* Line 1455 of yacc.c */ -#line 473 "grammar.y" +#line 474 "grammar.y" { (yyval.i) = Q_IPV6; } break; case 87: /* Line 1455 of yacc.c */ -#line 474 "grammar.y" +#line 475 "grammar.y" { (yyval.i) = Q_ICMPV6; } break; case 88: /* Line 1455 of yacc.c */ -#line 475 "grammar.y" +#line 476 "grammar.y" { (yyval.i) = Q_AH; } break; case 89: /* Line 1455 of yacc.c */ -#line 476 "grammar.y" +#line 477 "grammar.y" { (yyval.i) = Q_ESP; } break; case 90: /* Line 1455 of yacc.c */ -#line 477 "grammar.y" +#line 478 "grammar.y" { (yyval.i) = Q_ISO; } break; case 91: /* Line 1455 of yacc.c */ -#line 478 "grammar.y" +#line 479 "grammar.y" { (yyval.i) = Q_ESIS; } break; case 92: /* Line 1455 of yacc.c */ -#line 479 "grammar.y" +#line 480 "grammar.y" { (yyval.i) = Q_ISIS; } break; case 93: /* Line 1455 of yacc.c */ -#line 480 "grammar.y" +#line 481 "grammar.y" { (yyval.i) = Q_ISIS_L1; } break; case 94: /* Line 1455 of yacc.c */ -#line 481 "grammar.y" +#line 482 "grammar.y" { (yyval.i) = Q_ISIS_L2; } break; case 95: /* Line 1455 of yacc.c */ -#line 482 "grammar.y" +#line 483 "grammar.y" { (yyval.i) = Q_ISIS_IIH; } break; case 96: /* Line 1455 of yacc.c */ -#line 483 "grammar.y" +#line 484 "grammar.y" { (yyval.i) = Q_ISIS_LSP; } break; case 97: /* Line 1455 of yacc.c */ -#line 484 "grammar.y" +#line 485 "grammar.y" { (yyval.i) = Q_ISIS_SNP; } break; case 98: /* Line 1455 of yacc.c */ -#line 485 "grammar.y" +#line 486 "grammar.y" { (yyval.i) = Q_ISIS_PSNP; } break; case 99: /* Line 1455 of yacc.c */ -#line 486 "grammar.y" +#line 487 "grammar.y" { (yyval.i) = Q_ISIS_CSNP; } break; case 100: /* Line 1455 of yacc.c */ -#line 487 "grammar.y" +#line 488 "grammar.y" { (yyval.i) = Q_CLNP; } break; case 101: /* Line 1455 of yacc.c */ -#line 488 "grammar.y" +#line 489 "grammar.y" { (yyval.i) = Q_STP; } break; case 102: /* Line 1455 of yacc.c */ -#line 489 "grammar.y" +#line 490 "grammar.y" { (yyval.i) = Q_IPX; } break; case 103: /* Line 1455 of yacc.c */ -#line 490 "grammar.y" +#line 491 "grammar.y" { (yyval.i) = Q_NETBEUI; } break; case 104: /* Line 1455 of yacc.c */ -#line 491 "grammar.y" +#line 492 "grammar.y" { (yyval.i) = Q_RADIO; } break; case 105: /* Line 1455 of yacc.c */ -#line 493 "grammar.y" +#line 494 "grammar.y" { (yyval.rblk) = gen_broadcast((yyvsp[(1) - (2)].i)); } break; case 106: /* Line 1455 of yacc.c */ -#line 494 "grammar.y" +#line 495 "grammar.y" { (yyval.rblk) = gen_multicast((yyvsp[(1) - (2)].i)); } break; case 107: /* Line 1455 of yacc.c */ -#line 495 "grammar.y" +#line 496 "grammar.y" { (yyval.rblk) = gen_less((yyvsp[(2) - (2)].i)); } break; case 108: /* Line 1455 of yacc.c */ -#line 496 "grammar.y" +#line 497 "grammar.y" { (yyval.rblk) = gen_greater((yyvsp[(2) - (2)].i)); } break; case 109: /* Line 1455 of yacc.c */ -#line 497 "grammar.y" +#line 498 "grammar.y" { (yyval.rblk) = gen_byteop((yyvsp[(3) - (4)].i), (yyvsp[(2) - (4)].i), (yyvsp[(4) - (4)].i)); } break; case 110: /* Line 1455 of yacc.c */ -#line 498 "grammar.y" +#line 499 "grammar.y" { (yyval.rblk) = gen_inbound(0); } break; case 111: /* Line 1455 of yacc.c */ -#line 499 "grammar.y" +#line 500 "grammar.y" { (yyval.rblk) = gen_inbound(1); } break; case 112: /* Line 1455 of yacc.c */ -#line 500 "grammar.y" +#line 501 "grammar.y" { (yyval.rblk) = gen_vlan((yyvsp[(2) - (2)].i)); } break; case 113: /* Line 1455 of yacc.c */ -#line 501 "grammar.y" +#line 502 "grammar.y" { (yyval.rblk) = gen_vlan(-1); } break; case 114: /* Line 1455 of yacc.c */ -#line 502 "grammar.y" +#line 503 "grammar.y" { (yyval.rblk) = gen_mpls((yyvsp[(2) - (2)].i)); } break; case 115: /* Line 1455 of yacc.c */ -#line 503 "grammar.y" +#line 504 "grammar.y" { (yyval.rblk) = gen_mpls(-1); } break; case 116: /* Line 1455 of yacc.c */ -#line 504 "grammar.y" +#line 505 "grammar.y" { (yyval.rblk) = gen_pppoed(); } break; case 117: /* Line 1455 of yacc.c */ -#line 505 "grammar.y" +#line 506 "grammar.y" { (yyval.rblk) = gen_pppoes(); } break; case 118: /* Line 1455 of yacc.c */ -#line 506 "grammar.y" +#line 507 "grammar.y" { (yyval.rblk) = (yyvsp[(1) - (1)].rblk); } break; case 119: /* Line 1455 of yacc.c */ -#line 507 "grammar.y" +#line 508 "grammar.y" { (yyval.rblk) = (yyvsp[(2) - (2)].rblk); } break; case 120: /* Line 1455 of yacc.c */ -#line 510 "grammar.y" +#line 511 "grammar.y" { (yyval.rblk) = gen_pf_ifname((yyvsp[(2) - (2)].s)); } break; case 121: /* Line 1455 of yacc.c */ -#line 511 "grammar.y" +#line 512 "grammar.y" { (yyval.rblk) = gen_pf_ruleset((yyvsp[(2) - (2)].s)); } break; case 122: /* Line 1455 of yacc.c */ -#line 512 "grammar.y" +#line 513 "grammar.y" { (yyval.rblk) = gen_pf_rnr((yyvsp[(2) - (2)].i)); } break; case 123: /* Line 1455 of yacc.c */ -#line 513 "grammar.y" +#line 514 "grammar.y" { (yyval.rblk) = gen_pf_srnr((yyvsp[(2) - (2)].i)); } break; case 124: /* Line 1455 of yacc.c */ -#line 514 "grammar.y" +#line 515 "grammar.y" { (yyval.rblk) = gen_pf_reason((yyvsp[(2) - (2)].i)); } break; case 125: /* Line 1455 of yacc.c */ -#line 515 "grammar.y" +#line 516 "grammar.y" { (yyval.rblk) = gen_pf_action((yyvsp[(2) - (2)].i)); } break; case 126: /* Line 1455 of yacc.c */ -#line 519 "grammar.y" +#line 520 "grammar.y" { (yyval.rblk) = gen_p80211_type((yyvsp[(2) - (4)].i) | (yyvsp[(4) - (4)].i), IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK); @@ -3057,7 +3058,7 @@ yyreduce: case 127: /* Line 1455 of yacc.c */ -#line 523 "grammar.y" +#line 524 "grammar.y" { (yyval.rblk) = gen_p80211_type((yyvsp[(2) - (2)].i), IEEE80211_FC0_TYPE_MASK); } @@ -3066,7 +3067,7 @@ yyreduce: case 128: /* Line 1455 of yacc.c */ -#line 526 "grammar.y" +#line 527 "grammar.y" { (yyval.rblk) = gen_p80211_type((yyvsp[(2) - (2)].i), IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK); @@ -3076,14 +3077,14 @@ yyreduce: case 129: /* Line 1455 of yacc.c */ -#line 530 "grammar.y" +#line 531 "grammar.y" { (yyval.rblk) = gen_p80211_fcdir((yyvsp[(2) - (2)].i)); } break; case 131: /* Line 1455 of yacc.c */ -#line 534 "grammar.y" +#line 535 "grammar.y" { (yyval.i) = str2tok((yyvsp[(1) - (1)].s), ieee80211_types); if ((yyval.i) == -1) bpf_error("unknown 802.11 type name"); @@ -3093,7 +3094,7 @@ yyreduce: case 133: /* Line 1455 of yacc.c */ -#line 541 "grammar.y" +#line 542 "grammar.y" { const struct tok *types = NULL; int i; for (i = 0;; i++) { @@ -3117,7 +3118,7 @@ yyreduce: case 134: /* Line 1455 of yacc.c */ -#line 561 "grammar.y" +#line 562 "grammar.y" { int i; for (i = 0;; i++) { if (ieee80211_type_subtypes[i].tok == NULL) { @@ -3137,7 +3138,7 @@ yyreduce: case 136: /* Line 1455 of yacc.c */ -#line 578 "grammar.y" +#line 579 "grammar.y" { if (pcap_strcasecmp((yyvsp[(1) - (1)].s), "nods") == 0) (yyval.i) = IEEE80211_FC1_DIR_NODS; else if (pcap_strcasecmp((yyvsp[(1) - (1)].s), "tods") == 0) @@ -3154,329 +3155,329 @@ yyreduce: case 137: /* Line 1455 of yacc.c */ -#line 591 "grammar.y" +#line 592 "grammar.y" { (yyval.i) = (yyvsp[(1) - (1)].i); } break; case 138: /* Line 1455 of yacc.c */ -#line 592 "grammar.y" +#line 593 "grammar.y" { (yyval.i) = pfreason_to_num((yyvsp[(1) - (1)].s)); } break; case 139: /* Line 1455 of yacc.c */ -#line 595 "grammar.y" +#line 596 "grammar.y" { (yyval.i) = pfaction_to_num((yyvsp[(1) - (1)].s)); } break; case 140: /* Line 1455 of yacc.c */ -#line 598 "grammar.y" +#line 599 "grammar.y" { (yyval.i) = BPF_JGT; } break; case 141: /* Line 1455 of yacc.c */ -#line 599 "grammar.y" +#line 600 "grammar.y" { (yyval.i) = BPF_JGE; } break; case 142: /* Line 1455 of yacc.c */ -#line 600 "grammar.y" +#line 601 "grammar.y" { (yyval.i) = BPF_JEQ; } break; case 143: /* Line 1455 of yacc.c */ -#line 602 "grammar.y" +#line 603 "grammar.y" { (yyval.i) = BPF_JGT; } break; case 144: /* Line 1455 of yacc.c */ -#line 603 "grammar.y" +#line 604 "grammar.y" { (yyval.i) = BPF_JGE; } break; case 145: /* Line 1455 of yacc.c */ -#line 604 "grammar.y" +#line 605 "grammar.y" { (yyval.i) = BPF_JEQ; } break; case 146: /* Line 1455 of yacc.c */ -#line 606 "grammar.y" +#line 607 "grammar.y" { (yyval.a) = gen_loadi((yyvsp[(1) - (1)].i)); } break; case 148: /* Line 1455 of yacc.c */ -#line 609 "grammar.y" +#line 610 "grammar.y" { (yyval.a) = gen_load((yyvsp[(1) - (4)].i), (yyvsp[(3) - (4)].a), 1); } break; case 149: /* Line 1455 of yacc.c */ -#line 610 "grammar.y" +#line 611 "grammar.y" { (yyval.a) = gen_load((yyvsp[(1) - (6)].i), (yyvsp[(3) - (6)].a), (yyvsp[(5) - (6)].i)); } break; case 150: /* Line 1455 of yacc.c */ -#line 611 "grammar.y" +#line 612 "grammar.y" { (yyval.a) = gen_arth(BPF_ADD, (yyvsp[(1) - (3)].a), (yyvsp[(3) - (3)].a)); } break; case 151: /* Line 1455 of yacc.c */ -#line 612 "grammar.y" +#line 613 "grammar.y" { (yyval.a) = gen_arth(BPF_SUB, (yyvsp[(1) - (3)].a), (yyvsp[(3) - (3)].a)); } break; case 152: /* Line 1455 of yacc.c */ -#line 613 "grammar.y" +#line 614 "grammar.y" { (yyval.a) = gen_arth(BPF_MUL, (yyvsp[(1) - (3)].a), (yyvsp[(3) - (3)].a)); } break; case 153: /* Line 1455 of yacc.c */ -#line 614 "grammar.y" +#line 615 "grammar.y" { (yyval.a) = gen_arth(BPF_DIV, (yyvsp[(1) - (3)].a), (yyvsp[(3) - (3)].a)); } break; case 154: /* Line 1455 of yacc.c */ -#line 615 "grammar.y" +#line 616 "grammar.y" { (yyval.a) = gen_arth(BPF_AND, (yyvsp[(1) - (3)].a), (yyvsp[(3) - (3)].a)); } break; case 155: /* Line 1455 of yacc.c */ -#line 616 "grammar.y" +#line 617 "grammar.y" { (yyval.a) = gen_arth(BPF_OR, (yyvsp[(1) - (3)].a), (yyvsp[(3) - (3)].a)); } break; case 156: /* Line 1455 of yacc.c */ -#line 617 "grammar.y" +#line 618 "grammar.y" { (yyval.a) = gen_arth(BPF_LSH, (yyvsp[(1) - (3)].a), (yyvsp[(3) - (3)].a)); } break; case 157: /* Line 1455 of yacc.c */ -#line 618 "grammar.y" +#line 619 "grammar.y" { (yyval.a) = gen_arth(BPF_RSH, (yyvsp[(1) - (3)].a), (yyvsp[(3) - (3)].a)); } break; case 158: /* Line 1455 of yacc.c */ -#line 619 "grammar.y" +#line 620 "grammar.y" { (yyval.a) = gen_neg((yyvsp[(2) - (2)].a)); } break; case 159: /* Line 1455 of yacc.c */ -#line 620 "grammar.y" +#line 621 "grammar.y" { (yyval.a) = (yyvsp[(2) - (3)].a); } break; case 160: /* Line 1455 of yacc.c */ -#line 621 "grammar.y" +#line 622 "grammar.y" { (yyval.a) = gen_loadlen(); } break; case 161: /* Line 1455 of yacc.c */ -#line 623 "grammar.y" +#line 624 "grammar.y" { (yyval.i) = '&'; } break; case 162: /* Line 1455 of yacc.c */ -#line 624 "grammar.y" +#line 625 "grammar.y" { (yyval.i) = '|'; } break; case 163: /* Line 1455 of yacc.c */ -#line 625 "grammar.y" +#line 626 "grammar.y" { (yyval.i) = '<'; } break; case 164: /* Line 1455 of yacc.c */ -#line 626 "grammar.y" +#line 627 "grammar.y" { (yyval.i) = '>'; } break; case 165: /* Line 1455 of yacc.c */ -#line 627 "grammar.y" +#line 628 "grammar.y" { (yyval.i) = '='; } break; case 167: /* Line 1455 of yacc.c */ -#line 630 "grammar.y" +#line 631 "grammar.y" { (yyval.i) = (yyvsp[(2) - (3)].i); } break; case 168: /* Line 1455 of yacc.c */ -#line 632 "grammar.y" +#line 633 "grammar.y" { (yyval.i) = A_LANE; } break; case 169: /* Line 1455 of yacc.c */ -#line 633 "grammar.y" +#line 634 "grammar.y" { (yyval.i) = A_LLC; } break; case 170: /* Line 1455 of yacc.c */ -#line 634 "grammar.y" +#line 635 "grammar.y" { (yyval.i) = A_METAC; } break; case 171: /* Line 1455 of yacc.c */ -#line 635 "grammar.y" +#line 636 "grammar.y" { (yyval.i) = A_BCC; } break; case 172: /* Line 1455 of yacc.c */ -#line 636 "grammar.y" +#line 637 "grammar.y" { (yyval.i) = A_OAMF4EC; } break; case 173: /* Line 1455 of yacc.c */ -#line 637 "grammar.y" +#line 638 "grammar.y" { (yyval.i) = A_OAMF4SC; } break; case 174: /* Line 1455 of yacc.c */ -#line 638 "grammar.y" +#line 639 "grammar.y" { (yyval.i) = A_SC; } break; case 175: /* Line 1455 of yacc.c */ -#line 639 "grammar.y" +#line 640 "grammar.y" { (yyval.i) = A_ILMIC; } break; case 176: /* Line 1455 of yacc.c */ -#line 641 "grammar.y" +#line 642 "grammar.y" { (yyval.i) = A_OAM; } break; case 177: /* Line 1455 of yacc.c */ -#line 642 "grammar.y" +#line 643 "grammar.y" { (yyval.i) = A_OAMF4; } break; case 178: /* Line 1455 of yacc.c */ -#line 643 "grammar.y" +#line 644 "grammar.y" { (yyval.i) = A_CONNECTMSG; } break; case 179: /* Line 1455 of yacc.c */ -#line 644 "grammar.y" +#line 645 "grammar.y" { (yyval.i) = A_METACONNECT; } break; case 180: /* Line 1455 of yacc.c */ -#line 647 "grammar.y" +#line 648 "grammar.y" { (yyval.blk).atmfieldtype = A_VPI; } break; case 181: /* Line 1455 of yacc.c */ -#line 648 "grammar.y" +#line 649 "grammar.y" { (yyval.blk).atmfieldtype = A_VCI; } break; case 183: /* Line 1455 of yacc.c */ -#line 651 "grammar.y" +#line 652 "grammar.y" { (yyval.blk).b = gen_atmfield_code((yyvsp[(0) - (2)].blk).atmfieldtype, (bpf_int32)(yyvsp[(2) - (2)].i), (bpf_u_int32)(yyvsp[(1) - (2)].i), 0); } break; case 184: /* Line 1455 of yacc.c */ -#line 652 "grammar.y" +#line 653 "grammar.y" { (yyval.blk).b = gen_atmfield_code((yyvsp[(0) - (2)].blk).atmfieldtype, (bpf_int32)(yyvsp[(2) - (2)].i), (bpf_u_int32)(yyvsp[(1) - (2)].i), 1); } break; case 185: /* Line 1455 of yacc.c */ -#line 653 "grammar.y" +#line 654 "grammar.y" { (yyval.blk).b = (yyvsp[(2) - (3)].blk).b; (yyval.blk).q = qerr; } break; case 186: /* Line 1455 of yacc.c */ -#line 655 "grammar.y" +#line 656 "grammar.y" { (yyval.blk).atmfieldtype = (yyvsp[(0) - (1)].blk).atmfieldtype; if ((yyval.blk).atmfieldtype == A_VPI || @@ -3488,84 +3489,84 @@ yyreduce: case 188: /* Line 1455 of yacc.c */ -#line 663 "grammar.y" +#line 664 "grammar.y" { gen_or((yyvsp[(1) - (3)].blk).b, (yyvsp[(3) - (3)].blk).b); (yyval.blk) = (yyvsp[(3) - (3)].blk); } break; case 189: /* Line 1455 of yacc.c */ -#line 666 "grammar.y" +#line 667 "grammar.y" { (yyval.i) = M_FISU; } break; case 190: /* Line 1455 of yacc.c */ -#line 667 "grammar.y" +#line 668 "grammar.y" { (yyval.i) = M_LSSU; } break; case 191: /* Line 1455 of yacc.c */ -#line 668 "grammar.y" +#line 669 "grammar.y" { (yyval.i) = M_MSU; } break; case 192: /* Line 1455 of yacc.c */ -#line 671 "grammar.y" +#line 672 "grammar.y" { (yyval.blk).mtp3fieldtype = M_SIO; } break; case 193: /* Line 1455 of yacc.c */ -#line 672 "grammar.y" +#line 673 "grammar.y" { (yyval.blk).mtp3fieldtype = M_OPC; } break; case 194: /* Line 1455 of yacc.c */ -#line 673 "grammar.y" +#line 674 "grammar.y" { (yyval.blk).mtp3fieldtype = M_DPC; } break; case 195: /* Line 1455 of yacc.c */ -#line 674 "grammar.y" +#line 675 "grammar.y" { (yyval.blk).mtp3fieldtype = M_SLS; } break; case 197: /* Line 1455 of yacc.c */ -#line 677 "grammar.y" +#line 678 "grammar.y" { (yyval.blk).b = gen_mtp3field_code((yyvsp[(0) - (2)].blk).mtp3fieldtype, (u_int)(yyvsp[(2) - (2)].i), (u_int)(yyvsp[(1) - (2)].i), 0); } break; case 198: /* Line 1455 of yacc.c */ -#line 678 "grammar.y" +#line 679 "grammar.y" { (yyval.blk).b = gen_mtp3field_code((yyvsp[(0) - (2)].blk).mtp3fieldtype, (u_int)(yyvsp[(2) - (2)].i), (u_int)(yyvsp[(1) - (2)].i), 1); } break; case 199: /* Line 1455 of yacc.c */ -#line 679 "grammar.y" +#line 680 "grammar.y" { (yyval.blk).b = (yyvsp[(2) - (3)].blk).b; (yyval.blk).q = qerr; } break; case 200: /* Line 1455 of yacc.c */ -#line 681 "grammar.y" +#line 682 "grammar.y" { (yyval.blk).mtp3fieldtype = (yyvsp[(0) - (1)].blk).mtp3fieldtype; if ((yyval.blk).mtp3fieldtype == M_SIO || @@ -3579,14 +3580,14 @@ yyreduce: case 202: /* Line 1455 of yacc.c */ -#line 691 "grammar.y" +#line 692 "grammar.y" { gen_or((yyvsp[(1) - (3)].blk).b, (yyvsp[(3) - (3)].blk).b); (yyval.blk) = (yyvsp[(3) - (3)].blk); } break; /* Line 1455 of yacc.c */ -#line 3590 "y.tab.c" +#line 3591 "y.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -3798,6 +3799,6 @@ yyreturn: /* Line 1675 of yacc.c */ -#line 693 "grammar.y" +#line 694 "grammar.y" diff --git a/libpcap/grammar.y b/libpcap/grammar.y index 7076c87bc..4c52579ba 100644 --- a/libpcap/grammar.y +++ b/libpcap/grammar.y @@ -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 +#include #endif /* WIN32 */ #include diff --git a/libpcap/inet.c b/libpcap/inet.c index aad87963e..0b16a6590 100644 --- a/libpcap/inet.c +++ b/libpcap/inet.c @@ -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)); diff --git a/libpcap/lbl/os-aix4.h b/libpcap/lbl/os-aix4.h index f7edb62df..c5dfce251 100644 --- a/libpcap/lbl/os-aix4.h +++ b/libpcap/lbl/os-aix4.h @@ -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 */ diff --git a/libpcap/lbl/os-hpux11.h b/libpcap/lbl/os-hpux11.h index 55a79e56a..5e325a9d1 100644 --- a/libpcap/lbl/os-hpux11.h +++ b/libpcap/lbl/os-hpux11.h @@ -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 */ diff --git a/libpcap/lbl/os-osf4.h b/libpcap/lbl/os-osf4.h index abb207e4c..60abcd915 100644 --- a/libpcap/lbl/os-osf4.h +++ b/libpcap/lbl/os-osf4.h @@ -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 */ diff --git a/libpcap/lbl/os-osf5.h b/libpcap/lbl/os-osf5.h index 338caa8bf..1ebcac62b 100644 --- a/libpcap/lbl/os-osf5.h +++ b/libpcap/lbl/os-osf5.h @@ -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) */ /* diff --git a/libpcap/lbl/os-solaris2.h b/libpcap/lbl/os-solaris2.h index 5de2c6ec2..fae2aa3a2 100644 --- a/libpcap/lbl/os-solaris2.h +++ b/libpcap/lbl/os-solaris2.h @@ -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 */ diff --git a/libpcap/lbl/os-sunos4.h b/libpcap/lbl/os-sunos4.h index fd8f5087d..cfd4b0468 100644 --- a/libpcap/lbl/os-sunos4.h +++ b/libpcap/lbl/os-sunos4.h @@ -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 */ diff --git a/libpcap/lbl/os-ultrix4.h b/libpcap/lbl/os-ultrix4.h index bd931b389..9f2a155e9 100644 --- a/libpcap/lbl/os-ultrix4.h +++ b/libpcap/lbl/os-ultrix4.h @@ -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 */ diff --git a/libpcap/llc.h b/libpcap/llc.h index ffd3a6014..b8c221fa0 100644 --- a/libpcap/llc.h +++ b/libpcap/llc.h @@ -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) */ /* diff --git a/libpcap/missing/snprintf.c b/libpcap/missing/snprintf.c index 9c0a6ee1a..8991f2496 100644 --- a/libpcap/missing/snprintf.c +++ b/libpcap/missing/snprintf.c @@ -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 @@ -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 diff --git a/libpcap/nametoaddr.c b/libpcap/nametoaddr.c index c21e7849c..5835e4d1f 100644 --- a/libpcap/nametoaddr.c +++ b/libpcap/nametoaddr.c @@ -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 +#include +#endif + #ifdef WIN32 #include @@ -44,13 +49,6 @@ static const char rcsid[] _U_ = #include #endif /* WIN32 */ -/* - * XXX - why was this included even on UNIX? - */ -#ifdef __MINGW32__ -#include "IP6_misc.h" -#endif - #ifndef WIN32 #ifdef HAVE_ETHER_HOSTTON /* diff --git a/libpcap/nlpid.h b/libpcap/nlpid.h index c3ab8c2cb..5327a362b 100644 --- a/libpcap/nlpid.h +++ b/libpcap/nlpid.h @@ -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 */ diff --git a/libpcap/opentest.c b/libpcap/opentest.c new file mode 100644 index 000000000..0c9153101 --- /dev/null +++ b/libpcap/opentest.c @@ -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 +#include +#include +#include +#include +#include +#include + +#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); + } +} diff --git a/libpcap/optimize.c b/libpcap/optimize.c index 475313f26..46dffec8a 100644 --- a/libpcap/optimize.c +++ b/libpcap/optimize.c @@ -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 +#else /* WIN32 */ +#if HAVE_INTTYPES_H +#include +#elif HAVE_STDINT_H +#include +#endif +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +#include +#endif /* WIN32 */ + #include #include #include diff --git a/libpcap/pcap-bpf.c b/libpcap/pcap-bpf.c index ce3327f8f..b4482e9f1 100644 --- a/libpcap/pcap-bpf.c +++ b/libpcap/pcap-bpf.c @@ -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 #endif #include -#include #include -#include +/* + * defines ioctls, but doesn't include . + * + * We include 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 , but if we're already including + * , which includes on those platforms, + * there's not much point in doing so. + * + * If we have , we include it as well, to handle systems + * such as Solaris which don't arrange to include if you + * include + */ #include +#ifdef HAVE_SYS_IOCCOM_H +#include +#endif #include #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 @@ -92,6 +108,7 @@ static int odmlockid = 0; #endif /* _AIX */ #include +#include #include #include #include @@ -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) diff --git a/libpcap/pcap-bpf.h b/libpcap/pcap-bpf.h index 5fe129dbb..7b7e90a53 100644 --- a/libpcap/pcap-bpf.h +++ b/libpcap/pcap-bpf.h @@ -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) */ /* diff --git a/libpcap/pcap-bt-linux.c b/libpcap/pcap-bt-linux.c index 2c619ff9f..a36c144d8 100644 --- a/libpcap/pcap-bt-linux.c +++ b/libpcap/pcap-bt-linux.c @@ -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 diff --git a/libpcap/pcap-bt-linux.h b/libpcap/pcap-bt-linux.h index 87d22a6e1..ed01190f8 100644 --- a/libpcap/pcap-bt-linux.h +++ b/libpcap/pcap-bt-linux.h @@ -30,7 +30,7 @@ * Bluetooth sniffing API implementation for Linux platform * By Paolo Abeni * - * @(#) $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) */ /* diff --git a/libpcap/pcap-can-linux.c b/libpcap/pcap-can-linux.c new file mode 100644 index 000000000..fb8e232c8 --- /dev/null +++ b/libpcap/pcap-can-linux.c @@ -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 + * + */ + +#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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/* 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 */ diff --git a/libpcap/pcap-can-linux.h b/libpcap/pcap-can-linux.h new file mode 100644 index 000000000..0c8f3b551 --- /dev/null +++ b/libpcap/pcap-can-linux.h @@ -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); diff --git a/libpcap/pcap-common.c b/libpcap/pcap-common.c new file mode 100644 index 000000000..979b5e364 --- /dev/null +++ b/libpcap/pcap-common.c @@ -0,0 +1,1179 @@ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * savefile.c - supports offline use of tcpdump + * Extraction/creation by Jeffrey Mogul, DECWRL + * Modified by Steve McCanne, LBL. + * + * Used to save the received packet headers, after filtering, to + * a file, and then read them later. + * The first record in the file contains saved values for the machine + * dependent values so we can print the dump file on any architecture. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.183 2008-12-23 20:13:29 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef WIN32 +#include +#else /* WIN32 */ +#if HAVE_INTTYPES_H +#include +#elif HAVE_STDINT_H +#include +#endif +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +#include +#endif /* WIN32 */ + +#include "pcap-int.h" +#include "pcap/usb.h" + +#include "pcap-common.h" + +/* + * We don't write DLT_* values to capture files, because they're not the + * same on all platforms. + * + * Unfortunately, the various flavors of BSD have not always used the same + * numerical values for the same data types, and various patches to + * libpcap for non-BSD OSes have added their own DLT_* codes for link + * layer encapsulation types seen on those OSes, and those codes have had, + * in some cases, values that were also used, on other platforms, for other + * link layer encapsulation types. + * + * This means that capture files of a type whose numerical DLT_* code + * means different things on different BSDs, or with different versions + * of libpcap, can't always be read on systems other than those like + * the one running on the machine on which the capture was made. + * + * Instead, we define here a set of LINKTYPE_* codes, and map DLT_* codes + * to LINKTYPE_* codes when writing a savefile header, and map LINKTYPE_* + * codes to DLT_* codes when reading a savefile header. + * + * For those DLT_* codes that have, as far as we know, the same values on + * all platforms (DLT_NULL through DLT_FDDI), we define LINKTYPE_xxx as + * DLT_xxx; that way, captures of those types can still be read by + * versions of libpcap that map LINKTYPE_* values to DLT_* values, and + * captures of those types written by versions of libpcap that map DLT_ + * values to LINKTYPE_ values can still be read by older versions + * of libpcap. + * + * The other LINKTYPE_* codes are given values starting at 100, in the + * hopes that no DLT_* code will be given one of those values. + * + * In order to ensure that a given LINKTYPE_* code's value will refer to + * the same encapsulation type on all platforms, you should not allocate + * a new LINKTYPE_* value without consulting + * "tcpdump-workers@lists.tcpdump.org". The tcpdump developers will + * allocate a value for you, and will not subsequently allocate it to + * anybody else; that value will be added to the "pcap.h" in the + * tcpdump.org Git repository, so that a future libpcap release will + * include it. + * + * You should, if possible, also contribute patches to libpcap and tcpdump + * to handle the new encapsulation type, so that they can also be checked + * into the tcpdump.org Git repository and so that they will appear in + * future libpcap and tcpdump releases. + * + * Do *NOT* assume that any values after the largest value in this file + * are available; you might not have the most up-to-date version of this + * file, and new values after that one might have been assigned. Also, + * do *NOT* use any values below 100 - those might already have been + * taken by one (or more!) organizations. + */ +#define LINKTYPE_NULL DLT_NULL +#define LINKTYPE_ETHERNET DLT_EN10MB /* also for 100Mb and up */ +#define LINKTYPE_EXP_ETHERNET DLT_EN3MB /* 3Mb experimental Ethernet */ +#define LINKTYPE_AX25 DLT_AX25 +#define LINKTYPE_PRONET DLT_PRONET +#define LINKTYPE_CHAOS DLT_CHAOS +#define LINKTYPE_TOKEN_RING DLT_IEEE802 /* DLT_IEEE802 is used for Token Ring */ +#define LINKTYPE_ARCNET DLT_ARCNET /* BSD-style headers */ +#define LINKTYPE_SLIP DLT_SLIP +#define LINKTYPE_PPP DLT_PPP +#define LINKTYPE_FDDI DLT_FDDI + +/* + * LINKTYPE_PPP is for use when there might, or might not, be an RFC 1662 + * PPP in HDLC-like framing header (with 0xff 0x03 before the PPP protocol + * field) at the beginning of the packet. + * + * This is for use when there is always such a header; the address field + * might be 0xff, for regular PPP, or it might be an address field for Cisco + * point-to-point with HDLC framing as per section 4.3.1 of RFC 1547 ("Cisco + * HDLC"). This is, for example, what you get with NetBSD's DLT_PPP_SERIAL. + * + * We give it the same value as NetBSD's DLT_PPP_SERIAL, in the hopes that + * nobody else will choose a DLT_ value of 50, and so that DLT_PPP_SERIAL + * captures will be written out with a link type that NetBSD's tcpdump + * can read. + */ +#define LINKTYPE_PPP_HDLC 50 /* PPP in HDLC-like framing */ + +#define LINKTYPE_PPP_ETHER 51 /* NetBSD PPP-over-Ethernet */ + +#define LINKTYPE_SYMANTEC_FIREWALL 99 /* Symantec Enterprise Firewall */ + +#define LINKTYPE_ATM_RFC1483 100 /* LLC/SNAP-encapsulated ATM */ +#define LINKTYPE_RAW 101 /* raw IP */ +#define LINKTYPE_SLIP_BSDOS 102 /* BSD/OS SLIP BPF header */ +#define LINKTYPE_PPP_BSDOS 103 /* BSD/OS PPP BPF header */ +#define LINKTYPE_C_HDLC 104 /* Cisco HDLC */ +#define LINKTYPE_IEEE802_11 105 /* IEEE 802.11 (wireless) */ +#define LINKTYPE_ATM_CLIP 106 /* Linux Classical IP over ATM */ +#define LINKTYPE_FRELAY 107 /* Frame Relay */ +#define LINKTYPE_LOOP 108 /* OpenBSD loopback */ +#define LINKTYPE_ENC 109 /* OpenBSD IPSEC enc */ + +/* + * These three types are reserved for future use. + */ +#define LINKTYPE_LANE8023 110 /* ATM LANE + 802.3 */ +#define LINKTYPE_HIPPI 111 /* NetBSD HIPPI */ +#define LINKTYPE_HDLC 112 /* NetBSD HDLC framing */ + +#define LINKTYPE_LINUX_SLL 113 /* Linux cooked socket capture */ +#define LINKTYPE_LTALK 114 /* Apple LocalTalk hardware */ +#define LINKTYPE_ECONET 115 /* Acorn Econet */ + +/* + * Reserved for use with OpenBSD ipfilter. + */ +#define LINKTYPE_IPFILTER 116 + +#define LINKTYPE_PFLOG 117 /* OpenBSD DLT_PFLOG */ +#define LINKTYPE_CISCO_IOS 118 /* For Cisco-internal use */ +#define LINKTYPE_PRISM_HEADER 119 /* 802.11+Prism II monitor mode */ +#define LINKTYPE_AIRONET_HEADER 120 /* FreeBSD Aironet driver stuff */ + +/* + * Reserved for Siemens HiPath HDLC. + */ +#define LINKTYPE_HHDLC 121 + +#define LINKTYPE_IP_OVER_FC 122 /* RFC 2625 IP-over-Fibre Channel */ +#define LINKTYPE_SUNATM 123 /* Solaris+SunATM */ + +/* + * Reserved as per request from Kent Dahlgren + * for private use. + */ +#define LINKTYPE_RIO 124 /* RapidIO */ +#define LINKTYPE_PCI_EXP 125 /* PCI Express */ +#define LINKTYPE_AURORA 126 /* Xilinx Aurora link layer */ + +#define LINKTYPE_IEEE802_11_RADIO 127 /* 802.11 plus BSD radio header */ + +/* + * Reserved for the TZSP encapsulation, as per request from + * Chris Waters + * TZSP is a generic encapsulation for any other link type, + * which includes a means to include meta-information + * with the packet, e.g. signal strength and channel + * for 802.11 packets. + */ +#define LINKTYPE_TZSP 128 /* Tazmen Sniffer Protocol */ + +#define LINKTYPE_ARCNET_LINUX 129 /* Linux-style headers */ + +/* + * Juniper-private data link types, as per request from + * Hannes Gredler . The corresponding + * DLT_s are used for passing on chassis-internal + * metainformation such as QOS profiles, etc.. + */ +#define LINKTYPE_JUNIPER_MLPPP 130 +#define LINKTYPE_JUNIPER_MLFR 131 +#define LINKTYPE_JUNIPER_ES 132 +#define LINKTYPE_JUNIPER_GGSN 133 +#define LINKTYPE_JUNIPER_MFR 134 +#define LINKTYPE_JUNIPER_ATM2 135 +#define LINKTYPE_JUNIPER_SERVICES 136 +#define LINKTYPE_JUNIPER_ATM1 137 + +#define LINKTYPE_APPLE_IP_OVER_IEEE1394 138 /* Apple IP-over-IEEE 1394 cooked header */ + +#define LINKTYPE_MTP2_WITH_PHDR 139 +#define LINKTYPE_MTP2 140 +#define LINKTYPE_MTP3 141 +#define LINKTYPE_SCCP 142 + +#define LINKTYPE_DOCSIS 143 /* DOCSIS MAC frames */ + +#define LINKTYPE_LINUX_IRDA 144 /* Linux-IrDA */ + +/* + * Reserved for IBM SP switch and IBM Next Federation switch. + */ +#define LINKTYPE_IBM_SP 145 +#define LINKTYPE_IBM_SN 146 + +/* + * Reserved for private use. If you have some link-layer header type + * that you want to use within your organization, with the capture files + * using that link-layer header type not ever be sent outside your + * organization, you can use these values. + * + * No libpcap release will use these for any purpose, nor will any + * tcpdump release use them, either. + * + * Do *NOT* use these in capture files that you expect anybody not using + * your private versions of capture-file-reading tools to read; in + * particular, do *NOT* use them in products, otherwise you may find that + * people won't be able to use tcpdump, or snort, or Ethereal, or... to + * read capture files from your firewall/intrusion detection/traffic + * monitoring/etc. appliance, or whatever product uses that LINKTYPE_ value, + * and you may also find that the developers of those applications will + * not accept patches to let them read those files. + * + * Also, do not use them if somebody might send you a capture using them + * for *their* private type and tools using them for *your* private type + * would have to read them. + * + * Instead, in those cases, ask "tcpdump-workers@lists.tcpdump.org" for a + * new DLT_ and LINKTYPE_ value, as per the comment in pcap/bpf.h, and use + * the type you're given. + */ +#define LINKTYPE_USER0 147 +#define LINKTYPE_USER1 148 +#define LINKTYPE_USER2 149 +#define LINKTYPE_USER3 150 +#define LINKTYPE_USER4 151 +#define LINKTYPE_USER5 152 +#define LINKTYPE_USER6 153 +#define LINKTYPE_USER7 154 +#define LINKTYPE_USER8 155 +#define LINKTYPE_USER9 156 +#define LINKTYPE_USER10 157 +#define LINKTYPE_USER11 158 +#define LINKTYPE_USER12 159 +#define LINKTYPE_USER13 160 +#define LINKTYPE_USER14 161 +#define LINKTYPE_USER15 162 + +/* + * For future use with 802.11 captures - defined by AbsoluteValue + * Systems to store a number of bits of link-layer information + * including radio information: + * + * http://www.shaftnet.org/~pizza/software/capturefrm.txt + * + * but could and arguably should also be used by non-AVS Linux + * 802.11 drivers; that may happen in the future. + */ +#define LINKTYPE_IEEE802_11_RADIO_AVS 163 /* 802.11 plus AVS radio header */ + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . The corresponding + * DLT_s are used for passing on chassis-internal + * metainformation such as QOS profiles, etc.. + */ +#define LINKTYPE_JUNIPER_MONITOR 164 + +/* + * Reserved for BACnet MS/TP. + */ +#define LINKTYPE_BACNET_MS_TP 165 + +/* + * Another PPP variant as per request from Karsten Keil . + * + * This is used in some OSes to allow a kernel socket filter to distinguish + * between incoming and outgoing packets, on a socket intended to + * supply pppd with outgoing packets so it can do dial-on-demand and + * hangup-on-lack-of-demand; incoming packets are filtered out so they + * don't cause pppd to hold the connection up (you don't want random + * input packets such as port scans, packets from old lost connections, + * etc. to force the connection to stay up). + * + * The first byte of the PPP header (0xff03) is modified to accomodate + * the direction - 0x00 = IN, 0x01 = OUT. + */ +#define LINKTYPE_PPP_PPPD 166 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . The DLT_s are used + * for passing on chassis-internal metainformation such as + * QOS profiles, cookies, etc.. + */ +#define LINKTYPE_JUNIPER_PPPOE 167 +#define LINKTYPE_JUNIPER_PPPOE_ATM 168 + +#define LINKTYPE_GPRS_LLC 169 /* GPRS LLC */ +#define LINKTYPE_GPF_T 170 /* GPF-T (ITU-T G.7041/Y.1303) */ +#define LINKTYPE_GPF_F 171 /* GPF-T (ITU-T G.7041/Y.1303) */ + +/* + * Requested by Oolan Zimmer for use in Gcom's T1/E1 line + * monitoring equipment. + */ +#define LINKTYPE_GCOM_T1E1 172 +#define LINKTYPE_GCOM_SERIAL 173 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . The DLT_ is used + * for internal communication to Physical Interface Cards (PIC) + */ +#define LINKTYPE_JUNIPER_PIC_PEER 174 + +/* + * Link types requested by Gregor Maier of Endace + * Measurement Systems. They add an ERF header (see + * http://www.endace.com/support/EndaceRecordFormat.pdf) in front of + * the link-layer header. + */ +#define LINKTYPE_ERF_ETH 175 /* Ethernet */ +#define LINKTYPE_ERF_POS 176 /* Packet-over-SONET */ + +/* + * Requested by Daniele Orlandi for raw LAPD + * for vISDN (http://www.orlandi.com/visdn/). Its link-layer header + * includes additional information before the LAPD header, so it's + * not necessarily a generic LAPD header. + */ +#define LINKTYPE_LINUX_LAPD 177 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . + * The Link Types are used for prepending meta-information + * like interface index, interface name + * before standard Ethernet, PPP, Frelay & C-HDLC Frames + */ +#define LINKTYPE_JUNIPER_ETHER 178 +#define LINKTYPE_JUNIPER_PPP 179 +#define LINKTYPE_JUNIPER_FRELAY 180 +#define LINKTYPE_JUNIPER_CHDLC 181 + +/* + * Multi Link Frame Relay (FRF.16) + */ +#define LINKTYPE_MFR 182 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . + * The DLT_ is used for internal communication with a + * voice Adapter Card (PIC) + */ +#define LINKTYPE_JUNIPER_VP 183 + +/* + * Arinc 429 frames. + * DLT_ requested by Gianluca Varenni . + * Every frame contains a 32bit A429 label. + * More documentation on Arinc 429 can be found at + * http://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf + */ +#define LINKTYPE_A429 184 + +/* + * Arinc 653 Interpartition Communication messages. + * DLT_ requested by Gianluca Varenni . + * Please refer to the A653-1 standard for more information. + */ +#define LINKTYPE_A653_ICM 185 + +/* + * USB packets, beginning with a USB setup header; requested by + * Paolo Abeni . + */ +#define LINKTYPE_USB 186 + +/* + * Bluetooth HCI UART transport layer (part H:4); requested by + * Paolo Abeni. + */ +#define LINKTYPE_BLUETOOTH_HCI_H4 187 + +/* + * IEEE 802.16 MAC Common Part Sublayer; requested by Maria Cruz + * . + */ +#define LINKTYPE_IEEE802_16_MAC_CPS 188 + +/* + * USB packets, beginning with a Linux USB header; requested by + * Paolo Abeni . + */ +#define LINKTYPE_USB_LINUX 189 + +/* + * Controller Area Network (CAN) v. 2.0B packets. + * DLT_ requested by Gianluca Varenni . + * Used to dump CAN packets coming from a CAN Vector board. + * More documentation on the CAN v2.0B frames can be found at + * http://www.can-cia.org/downloads/?269 + */ +#define LINKTYPE_CAN20B 190 + +/* + * IEEE 802.15.4, with address fields padded, as is done by Linux + * drivers; requested by Juergen Schimmer. + */ +#define LINKTYPE_IEEE802_15_4_LINUX 191 + +/* + * Per Packet Information encapsulated packets. + * LINKTYPE_ requested by Gianluca Varenni . + */ +#define LINKTYPE_PPI 192 + +/* + * Header for 802.16 MAC Common Part Sublayer plus a radiotap radio header; + * requested by Charles Clancy. + */ +#define LINKTYPE_IEEE802_16_MAC_CPS_RADIO 193 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . + * The DLT_ is used for internal communication with a + * integrated service module (ISM). + */ +#define LINKTYPE_JUNIPER_ISM 194 + +/* + * IEEE 802.15.4, exactly as it appears in the spec (no padding, no + * nothing); requested by Mikko Saarnivala . + */ +#define LINKTYPE_IEEE802_15_4 195 + +/* + * Various link-layer types, with a pseudo-header, for SITA + * (http://www.sita.aero/); requested by Fulko Hew (fulko.hew@gmail.com). + */ +#define LINKTYPE_SITA 196 + +/* + * Various link-layer types, with a pseudo-header, for Endace DAG cards; + * encapsulates Endace ERF records. Requested by Stephen Donnelly + * . + */ +#define LINKTYPE_ERF 197 + +/* + * Special header prepended to Ethernet packets when capturing from a + * u10 Networks board. Requested by Phil Mulholland + * . + */ +#define LINKTYPE_RAIF1 198 + +/* + * IPMB packet for IPMI, beginning with the I2C slave address, followed + * by the netFn and LUN, etc.. Requested by Chanthy Toeung + * . + */ +#define LINKTYPE_IPMB 199 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . + * The DLT_ is used for capturing data on a secure tunnel interface. + */ +#define LINKTYPE_JUNIPER_ST 200 + +/* + * Bluetooth HCI UART transport layer (part H:4), with pseudo-header + * that includes direction information; requested by Paolo Abeni. + */ +#define LINKTYPE_BLUETOOTH_HCI_H4_WITH_PHDR 201 + +/* + * AX.25 packet with a 1-byte KISS header; see + * + * http://www.ax25.net/kiss.htm + * + * as per Richard Stearn . + */ +#define LINKTYPE_AX25_KISS 202 + +/* + * LAPD packets from an ISDN channel, starting with the address field, + * with no pseudo-header. + * Requested by Varuna De Silva . + */ +#define LINKTYPE_LAPD 203 + +/* + * Variants of various link-layer headers, with a one-byte direction + * pseudo-header prepended - zero means "received by this host", + * non-zero (any non-zero value) means "sent by this host" - as per + * Will Barker . + */ +#define LINKTYPE_PPP_WITH_DIR 204 /* PPP */ +#define LINKTYPE_C_HDLC_WITH_DIR 205 /* Cisco HDLC */ +#define LINKTYPE_FRELAY_WITH_DIR 206 /* Frame Relay */ +#define LINKTYPE_LAPB_WITH_DIR 207 /* LAPB */ + +/* + * 208 is reserved for an as-yet-unspecified proprietary link-layer + * type, as requested by Will Barker. + */ + +/* + * IPMB with a Linux-specific pseudo-header; as requested by Alexey Neyman + * . + */ +#define LINKTYPE_IPMB_LINUX 209 + +/* + * FlexRay automotive bus - http://www.flexray.com/ - as requested + * by Hannes Kaelber . + */ +#define LINKTYPE_FLEXRAY 210 + +/* + * Media Oriented Systems Transport (MOST) bus for multimedia + * transport - http://www.mostcooperation.com/ - as requested + * by Hannes Kaelber . + */ +#define LINKTYPE_MOST 211 + +/* + * Local Interconnect Network (LIN) bus for vehicle networks - + * http://www.lin-subbus.org/ - as requested by Hannes Kaelber + * . + */ +#define LINKTYPE_LIN 212 + +/* + * X2E-private data link type used for serial line capture, + * as requested by Hannes Kaelber . + */ +#define LINKTYPE_X2E_SERIAL 213 + +/* + * X2E-private data link type used for the Xoraya data logger + * family, as requested by Hannes Kaelber . + */ +#define LINKTYPE_X2E_XORAYA 214 + +/* + * IEEE 802.15.4, exactly as it appears in the spec (no padding, no + * nothing), but with the PHY-level data for non-ASK PHYs (4 octets + * of 0 as preamble, one octet of SFD, one octet of frame length+ + * reserved bit, and then the MAC-layer data, starting with the + * frame control field). + * + * Requested by Max Filippov . + */ +#define LINKTYPE_IEEE802_15_4_NONASK_PHY 215 + +/* + * David Gibson 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 LINKTYPE_LINUX_EVDEV 216 + +/* + * GSM Um and Abis interfaces, preceded by a "gsmtap" header. + * + * Requested by Harald Welte . + */ +#define LINKTYPE_GSMTAP_UM 217 +#define LINKTYPE_GSMTAP_ABIS 218 + +/* + * MPLS, with an MPLS label as the link-layer header. + * Requested by Michele Marchetto on behalf + * of OpenBSD. + */ +#define LINKTYPE_MPLS 219 + +/* + * USB packets, beginning with a Linux USB header, with the USB header + * padded to 64 bytes; required for memory-mapped access. + */ +#define LINKTYPE_USB_LINUX_MMAPPED 220 + +/* + * DECT packets, with a pseudo-header; requested by + * Matthias Wenzel . + */ +#define LINKTYPE_DECT 221 + +/* + * From: "Lidwa, Eric (GSFC-582.0)[SGT INC]" + * 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 LINKTYPE_AOS 222 + +/* + * Wireless HART (Highway Addressable Remote Transducer) + * From the HART Communication Foundation + * IES/PAS 62591 + * + * Requested by Sam Roberts . + */ +#define LINKTYPE_WIHART 223 + +/* + * Fibre Channel FC-2 frames, beginning with a Frame_Header. + * Requested by Kahou Lei . + */ +#define LINKTYPE_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 . + */ +#define LINKTYPE_FC_2_WITH_FRAME_DELIMS 225 + +/* + * Solaris ipnet pseudo-header; requested by Darren Reed . + * + * 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 LINKTYPE_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 . + */ +#define LINKTYPE_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 . + */ +#define LINKTYPE_IPV4 228 +#define LINKTYPE_IPV6 229 + + +static struct linktype_map { + int dlt; + int linktype; +} map[] = { + /* + * These DLT_* codes have LINKTYPE_* codes with values identical + * to the values of the corresponding DLT_* code. + */ + { DLT_NULL, LINKTYPE_NULL }, + { DLT_EN10MB, LINKTYPE_ETHERNET }, + { DLT_EN3MB, LINKTYPE_EXP_ETHERNET }, + { DLT_AX25, LINKTYPE_AX25 }, + { DLT_PRONET, LINKTYPE_PRONET }, + { DLT_CHAOS, LINKTYPE_CHAOS }, + { DLT_IEEE802, LINKTYPE_TOKEN_RING }, + { DLT_ARCNET, LINKTYPE_ARCNET }, + { DLT_SLIP, LINKTYPE_SLIP }, + { DLT_PPP, LINKTYPE_PPP }, + { DLT_FDDI, LINKTYPE_FDDI }, + + /* + * These DLT_* codes have different values on different + * platforms; we map them to LINKTYPE_* codes that + * have values that should never be equal to any DLT_* + * code. + */ +#ifdef DLT_FR + /* BSD/OS Frame Relay */ + { DLT_FR, LINKTYPE_FRELAY }, +#endif + + { DLT_SYMANTEC_FIREWALL, LINKTYPE_SYMANTEC_FIREWALL }, + { DLT_ATM_RFC1483, LINKTYPE_ATM_RFC1483 }, + { DLT_RAW, LINKTYPE_RAW }, + { DLT_SLIP_BSDOS, LINKTYPE_SLIP_BSDOS }, + { DLT_PPP_BSDOS, LINKTYPE_PPP_BSDOS }, + + /* BSD/OS Cisco HDLC */ + { DLT_C_HDLC, LINKTYPE_C_HDLC }, + + /* + * These DLT_* codes are not on all platforms, but, so far, + * there don't appear to be any platforms that define + * other codes with those values; we map them to + * different LINKTYPE_* values anyway, just in case. + */ + + /* Linux ATM Classical IP */ + { DLT_ATM_CLIP, LINKTYPE_ATM_CLIP }, + + /* NetBSD sync/async serial PPP (or Cisco HDLC) */ + { DLT_PPP_SERIAL, LINKTYPE_PPP_HDLC }, + + /* NetBSD PPP over Ethernet */ + { DLT_PPP_ETHER, LINKTYPE_PPP_ETHER }, + + /* IEEE 802.11 wireless */ + { DLT_IEEE802_11, LINKTYPE_IEEE802_11 }, + + /* Frame Relay */ + { DLT_FRELAY, LINKTYPE_FRELAY }, + + /* OpenBSD loopback */ + { DLT_LOOP, LINKTYPE_LOOP }, + + /* OpenBSD IPSEC enc */ + { DLT_ENC, LINKTYPE_ENC }, + + /* Linux cooked socket capture */ + { DLT_LINUX_SLL, LINKTYPE_LINUX_SLL }, + + /* Apple LocalTalk hardware */ + { DLT_LTALK, LINKTYPE_LTALK }, + + /* Acorn Econet */ + { DLT_ECONET, LINKTYPE_ECONET }, + + /* OpenBSD DLT_PFLOG */ + { DLT_PFLOG, LINKTYPE_PFLOG }, + + /* For Cisco-internal use */ + { DLT_CISCO_IOS, LINKTYPE_CISCO_IOS }, + + /* Prism II monitor-mode header plus 802.11 header */ + { DLT_PRISM_HEADER, LINKTYPE_PRISM_HEADER }, + + /* FreeBSD Aironet driver stuff */ + { DLT_AIRONET_HEADER, LINKTYPE_AIRONET_HEADER }, + + /* Siemens HiPath HDLC */ + { DLT_HHDLC, LINKTYPE_HHDLC }, + + /* RFC 2625 IP-over-Fibre Channel */ + { DLT_IP_OVER_FC, LINKTYPE_IP_OVER_FC }, + + /* Solaris+SunATM */ + { DLT_SUNATM, LINKTYPE_SUNATM }, + + /* RapidIO */ + { DLT_RIO, LINKTYPE_RIO }, + + /* PCI Express */ + { DLT_PCI_EXP, LINKTYPE_PCI_EXP }, + + /* Xilinx Aurora link layer */ + { DLT_AURORA, LINKTYPE_AURORA }, + + /* 802.11 plus BSD radio header */ + { DLT_IEEE802_11_RADIO, LINKTYPE_IEEE802_11_RADIO }, + + /* Tazmen Sniffer Protocol */ + { DLT_TZSP, LINKTYPE_TZSP }, + + /* Arcnet with Linux-style link-layer headers */ + { DLT_ARCNET_LINUX, LINKTYPE_ARCNET_LINUX }, + + /* Juniper-internal chassis encapsulation */ + { DLT_JUNIPER_MLPPP, LINKTYPE_JUNIPER_MLPPP }, + { DLT_JUNIPER_MLFR, LINKTYPE_JUNIPER_MLFR }, + { DLT_JUNIPER_ES, LINKTYPE_JUNIPER_ES }, + { DLT_JUNIPER_GGSN, LINKTYPE_JUNIPER_GGSN }, + { DLT_JUNIPER_MFR, LINKTYPE_JUNIPER_MFR }, + { DLT_JUNIPER_ATM2, LINKTYPE_JUNIPER_ATM2 }, + { DLT_JUNIPER_SERVICES, LINKTYPE_JUNIPER_SERVICES }, + { DLT_JUNIPER_ATM1, LINKTYPE_JUNIPER_ATM1 }, + + /* Apple IP-over-IEEE 1394 cooked header */ + { DLT_APPLE_IP_OVER_IEEE1394, LINKTYPE_APPLE_IP_OVER_IEEE1394 }, + + /* SS7 */ + { DLT_MTP2_WITH_PHDR, LINKTYPE_MTP2_WITH_PHDR }, + { DLT_MTP2, LINKTYPE_MTP2 }, + { DLT_MTP3, LINKTYPE_MTP3 }, + { DLT_SCCP, LINKTYPE_SCCP }, + + /* DOCSIS MAC frames */ + { DLT_DOCSIS, LINKTYPE_DOCSIS }, + + /* IrDA IrLAP packets + Linux-cooked header */ + { DLT_LINUX_IRDA, LINKTYPE_LINUX_IRDA }, + + /* IBM SP and Next Federation switches */ + { DLT_IBM_SP, LINKTYPE_IBM_SP }, + { DLT_IBM_SN, LINKTYPE_IBM_SN }, + + /* 802.11 plus AVS radio header */ + { DLT_IEEE802_11_RADIO_AVS, LINKTYPE_IEEE802_11_RADIO_AVS }, + + /* + * Any platform that defines additional DLT_* codes should: + * + * request a LINKTYPE_* code and value from tcpdump.org, + * as per the above; + * + * add, in their version of libpcap, an entry to map + * those DLT_* codes to the corresponding LINKTYPE_* + * code; + * + * redefine, in their "net/bpf.h", any DLT_* values + * that collide with the values used by their additional + * DLT_* codes, to remove those collisions (but without + * making them collide with any of the LINKTYPE_* + * values equal to 50 or above; they should also avoid + * defining DLT_* values that collide with those + * LINKTYPE_* values, either). + */ + + /* Juniper-internal chassis encapsulation */ + { DLT_JUNIPER_MONITOR, LINKTYPE_JUNIPER_MONITOR }, + + /* BACnet MS/TP */ + { DLT_BACNET_MS_TP, LINKTYPE_BACNET_MS_TP }, + + /* PPP for pppd, with direction flag in the PPP header */ + { DLT_PPP_PPPD, LINKTYPE_PPP_PPPD}, + + /* Juniper-internal chassis encapsulation */ + { DLT_JUNIPER_PPPOE, LINKTYPE_JUNIPER_PPPOE }, + { DLT_JUNIPER_PPPOE_ATM,LINKTYPE_JUNIPER_PPPOE_ATM }, + + /* GPRS LLC */ + { DLT_GPRS_LLC, LINKTYPE_GPRS_LLC }, + + /* Transparent Generic Framing Procedure (ITU-T G.7041/Y.1303) */ + { DLT_GPF_T, LINKTYPE_GPF_T }, + + /* Framed Generic Framing Procedure (ITU-T G.7041/Y.1303) */ + { DLT_GPF_F, LINKTYPE_GPF_F }, + + { DLT_GCOM_T1E1, LINKTYPE_GCOM_T1E1 }, + { DLT_GCOM_SERIAL, LINKTYPE_GCOM_SERIAL }, + + /* Juniper-internal chassis encapsulation */ + { DLT_JUNIPER_PIC_PEER, LINKTYPE_JUNIPER_PIC_PEER }, + + /* Endace types */ + { DLT_ERF_ETH, LINKTYPE_ERF_ETH }, + { DLT_ERF_POS, LINKTYPE_ERF_POS }, + + /* viSDN LAPD */ + { DLT_LINUX_LAPD, LINKTYPE_LINUX_LAPD }, + + /* Juniper meta-information before Ether, PPP, Frame Relay, C-HDLC Frames */ + { DLT_JUNIPER_ETHER, LINKTYPE_JUNIPER_ETHER }, + { DLT_JUNIPER_PPP, LINKTYPE_JUNIPER_PPP }, + { DLT_JUNIPER_FRELAY, LINKTYPE_JUNIPER_FRELAY }, + { DLT_JUNIPER_CHDLC, LINKTYPE_JUNIPER_CHDLC }, + + /* Multi Link Frame Relay (FRF.16) */ + { DLT_MFR, LINKTYPE_MFR }, + + /* Juniper Voice PIC */ + { DLT_JUNIPER_VP, LINKTYPE_JUNIPER_VP }, + + /* Controller Area Network (CAN) v2.0B */ + { DLT_A429, LINKTYPE_A429 }, + + /* Arinc 653 Interpartition Communication messages */ + { DLT_A653_ICM, LINKTYPE_A653_ICM }, + + /* USB */ + { DLT_USB, LINKTYPE_USB }, + + /* Bluetooth HCI UART transport layer */ + { DLT_BLUETOOTH_HCI_H4, LINKTYPE_BLUETOOTH_HCI_H4 }, + + /* IEEE 802.16 MAC Common Part Sublayer */ + { DLT_IEEE802_16_MAC_CPS, LINKTYPE_IEEE802_16_MAC_CPS }, + + /* USB with Linux header */ + { DLT_USB_LINUX, LINKTYPE_USB_LINUX }, + + /* Controller Area Network (CAN) v2.0B */ + { DLT_CAN20B, LINKTYPE_CAN20B }, + + /* IEEE 802.15.4 with address fields padded */ + { DLT_IEEE802_15_4_LINUX, LINKTYPE_IEEE802_15_4_LINUX }, + + /* Per Packet Information encapsulated packets */ + { DLT_PPI, LINKTYPE_PPI }, + + /* IEEE 802.16 MAC Common Part Sublayer plus radiotap header */ + { DLT_IEEE802_16_MAC_CPS_RADIO, LINKTYPE_IEEE802_16_MAC_CPS_RADIO }, + + /* Juniper Voice ISM */ + { DLT_JUNIPER_ISM, LINKTYPE_JUNIPER_ISM }, + + /* IEEE 802.15.4 exactly as it appears in the spec */ + { DLT_IEEE802_15_4, LINKTYPE_IEEE802_15_4 }, + + /* Various link-layer types for SITA */ + { DLT_SITA, LINKTYPE_SITA }, + + /* Various link-layer types for Endace */ + { DLT_ERF, LINKTYPE_ERF }, + + /* Special header for u10 Networks boards */ + { DLT_RAIF1, LINKTYPE_RAIF1 }, + + /* IPMB */ + { DLT_IPMB, LINKTYPE_IPMB }, + + /* Juniper Secure Tunnel */ + { DLT_JUNIPER_ST, LINKTYPE_JUNIPER_ST }, + + /* Bluetooth HCI UART transport layer, with pseudo-header */ + { DLT_BLUETOOTH_HCI_H4_WITH_PHDR, LINKTYPE_BLUETOOTH_HCI_H4_WITH_PHDR }, + + /* AX.25 with KISS header */ + { DLT_AX25_KISS, LINKTYPE_AX25_KISS }, + + /* Raw LAPD, with no pseudo-header */ + { DLT_LAPD, LINKTYPE_LAPD }, + + /* PPP with one-byte pseudo-header giving direction */ + { DLT_PPP_WITH_DIR, LINKTYPE_PPP_WITH_DIR }, + + /* Cisco HDLC with one-byte pseudo-header giving direction */ + { DLT_C_HDLC_WITH_DIR, LINKTYPE_C_HDLC_WITH_DIR }, + + /* Frame Relay with one-byte pseudo-header giving direction */ + { DLT_FRELAY_WITH_DIR, LINKTYPE_FRELAY_WITH_DIR }, + + /* LAPB with one-byte pseudo-header giving direction */ + { DLT_LAPB_WITH_DIR, LINKTYPE_LAPB_WITH_DIR }, + + /* IPMB with Linux pseudo-header */ + { DLT_IPMB_LINUX, LINKTYPE_IPMB_LINUX }, + + /* FlexRay */ + { DLT_FLEXRAY, LINKTYPE_FLEXRAY }, + + /* MOST */ + { DLT_MOST, LINKTYPE_MOST }, + + /* LIN */ + { DLT_LIN, LINKTYPE_LIN }, + + /* X2E-private serial line capture */ + { DLT_X2E_SERIAL, LINKTYPE_X2E_SERIAL }, + + /* X2E-private for Xoraya data logger family */ + { DLT_X2E_XORAYA, LINKTYPE_X2E_XORAYA }, + + /* IEEE 802.15.4 with PHY data for non-ASK PHYs */ + { DLT_IEEE802_15_4_NONASK_PHY, LINKTYPE_IEEE802_15_4_NONASK_PHY }, + + /* Input device events from Linux /dev/input/eventN devices */ + { DLT_LINUX_EVDEV, LINKTYPE_LINUX_EVDEV }, + + /* GSM types */ + { DLT_GSMTAP_UM, LINKTYPE_GSMTAP_UM }, + { DLT_GSMTAP_ABIS, LINKTYPE_GSMTAP_ABIS }, + + /* MPLS, with an MPLS label as the link-layer header */ + { DLT_MPLS, LINKTYPE_MPLS }, + + /* USB with padded Linux header */ + { DLT_USB_LINUX_MMAPPED, LINKTYPE_USB_LINUX_MMAPPED }, + + /* DECT packets with a pseudo-header */ + { DLT_DECT, LINKTYPE_DECT }, + + /* AOS Space Data Link Protocol */ + { DLT_AOS, LINKTYPE_AOS }, + + /* Wireless HART */ + { DLT_WIHART, LINKTYPE_WIHART }, + + /* Fibre Channel FC-2 frames without SOF or EOF */ + { DLT_FC_2, LINKTYPE_FC_2 }, + + /* Fibre Channel FC-2 frames with SOF and EOF */ + { DLT_FC_2_WITH_FRAME_DELIMS, LINKTYPE_FC_2_WITH_FRAME_DELIMS }, + + /* Solaris IPNET */ + { DLT_IPNET, LINKTYPE_IPNET }, + + /* CAN frames with SocketCAN headers */ + { DLT_CAN_SOCKETCAN, LINKTYPE_CAN_SOCKETCAN }, + + /* Raw IPv4/IPv6 */ + { DLT_IPV4, LINKTYPE_IPV4 }, + { DLT_IPV6, LINKTYPE_IPV6 }, + + { -1, -1 } +}; + +int +dlt_to_linktype(int dlt) +{ + int i; + + for (i = 0; map[i].dlt != -1; i++) { + if (map[i].dlt == dlt) + return (map[i].linktype); + } + + /* + * If we don't have a mapping for this DLT_ code, return an + * error; that means that the table above needs to have an + * entry added. + */ + return (-1); +} + +int +linktype_to_dlt(int linktype) +{ + int i; + + for (i = 0; map[i].linktype != -1; i++) { + if (map[i].linktype == linktype) + return (map[i].dlt); + } + + /* + * If we don't have an entry for this link type, return + * the link type value; it may be a DLT_ value from an + * older version of libpcap. + */ + return linktype; +} + +/* + * The DLT_USB_LINUX and DLT_USB_LINUX_MMAPPED headers are in host + * byte order when capturing (it's supplied directly from a + * memory-mapped buffer shared by the kernel). + * + * When reading a DLT_USB_LINUX or DLT_USB_LINUX_MMAPPED capture file, + * we need to convert it from the capturing host's byte order to + * the reading host's byte order. + */ +void +swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf, + int header_len_64_bytes) +{ + pcap_usb_header_mmapped *uhdr = (pcap_usb_header_mmapped *)buf; + + /* + * The URB id is a totally opaque value; do we really need to + * convert it to the reading host's byte order??? + */ + if (hdr->caplen < 8) + return; + uhdr->id = SWAPLL(uhdr->id); + if (hdr->caplen < 14) + return; + uhdr->bus_id = SWAPSHORT(uhdr->bus_id); + if (hdr->caplen < 24) + return; + uhdr->ts_sec = SWAPLL(uhdr->ts_sec); + if (hdr->caplen < 28) + return; + uhdr->ts_usec = SWAPLONG(uhdr->ts_usec); + if (hdr->caplen < 32) + return; + uhdr->status = SWAPLONG(uhdr->status); + if (hdr->caplen < 36) + return; + uhdr->urb_len = SWAPLONG(uhdr->urb_len); + if (hdr->caplen < 40) + return; + uhdr->data_len = SWAPLONG(uhdr->data_len); + + if (header_len_64_bytes) { + /* + * This is either the "version 1" header, with + * 16 bytes of additional fields at the end, or + * a "version 0" header from a memory-mapped + * capture, with 16 bytes of zeroed-out padding + * at the end. Byte swap them as if this were + * a "version 1" header. + */ + if (hdr->caplen < 52) + return; + uhdr->interval = SWAPLONG(uhdr->interval); + if (hdr->caplen < 56) + return; + uhdr->start_frame = SWAPLONG(uhdr->start_frame); + if (hdr->caplen < 60) + return; + uhdr->xfer_flags = SWAPLONG(uhdr->xfer_flags); + if (hdr->caplen < 64) + return; + uhdr->ndesc = SWAPLONG(uhdr->ndesc); + } +} diff --git a/libpcap/pcap-common.h b/libpcap/pcap-common.h new file mode 100644 index 000000000..0c80ba326 --- /dev/null +++ b/libpcap/pcap-common.h @@ -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); diff --git a/libpcap/pcap-config.1 b/libpcap/pcap-config.1 index a99b37912..021f4504c 100644 --- a/libpcap/pcap-config.1 +++ b/libpcap/pcap-config.1 @@ -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) diff --git a/libpcap/pcap-config.in b/libpcap/pcap-config.in index 19f21141d..37526d7fe 100644 --- a/libpcap/pcap-config.in +++ b/libpcap/pcap-config.in @@ -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 diff --git a/libpcap/pcap-dag.c b/libpcap/pcap-dag.c index 039d92601..938ec26dc 100644 --- a/libpcap/pcap-dag.c +++ b/libpcap/pcap-dag.c @@ -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 */ diff --git a/libpcap/pcap-dag.h b/libpcap/pcap-dag.h index 7ba272bec..fcdef7bda 100644 --- a/libpcap/pcap-dag.h +++ b/libpcap/pcap-dag.h @@ -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 diff --git a/libpcap/pcap-dlpi.c b/libpcap/pcap-dlpi.c index 695e48ad3..8f938fe16 100644 --- a/libpcap/pcap-dlpi.c +++ b/libpcap/pcap-dlpi.c @@ -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); } diff --git a/libpcap/pcap-dos.c b/libpcap/pcap-dos.c index 7b3c4bda7..bcd277fa1 100644 --- a/libpcap/pcap-dos.c +++ b/libpcap/pcap-dos.c @@ -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 diff --git a/libpcap/pcap-dos.h b/libpcap/pcap-dos.h index c9737baec..f4744378c 100644 --- a/libpcap/pcap-dos.h +++ b/libpcap/pcap-dos.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 diff --git a/libpcap/pcap-enet.c b/libpcap/pcap-enet.c index e5ea9aa17..5ad921c25 100644 --- a/libpcap/pcap-enet.c +++ b/libpcap/pcap-enet.c @@ -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 diff --git a/libpcap/pcap-filter.manmisc.in b/libpcap/pcap-filter.manmisc.in index 3beec5802..6b826e3cc 100644 --- a/libpcap/pcap-filter.manmisc.in +++ b/libpcap/pcap-filter.manmisc.in @@ -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. diff --git a/libpcap/pcap-int.h b/libpcap/pcap-int.h index 080470e93..c3afbade5 100644 --- a/libpcap/pcap-int.h +++ b/libpcap/pcap-int.h @@ -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 +extern CRITICAL_SECTION g_PcapCompileCriticalSection; #endif /* WIN32 */ #ifdef MSDOS @@ -55,6 +56,10 @@ extern "C" { #include #endif +#ifdef HAVE_SNF_API +#include +#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 diff --git a/libpcap/pcap-libdlpi.c b/libpcap/pcap-libdlpi.c index b61e8ecd4..87cd08b7d 100644 --- a/libpcap/pcap-libdlpi.c +++ b/libpcap/pcap-libdlpi.c @@ -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; /* diff --git a/libpcap/pcap-linktype.manmisc.in b/libpcap/pcap-linktype.manmisc.in index 7d33b7f88..fa156120f 100644 --- a/libpcap/pcap-linktype.manmisc.in +++ b/libpcap/pcap-linktype.manmisc.in @@ -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, diff --git a/libpcap/pcap-linux.c b/libpcap/pcap-linux.c index 8161af019..af125433f 100644 --- a/libpcap/pcap-linux.c +++ b/libpcap/pcap-linux.c @@ -30,11 +30,44 @@ * based on previous works of: * Simon Patarin * Phil Wood + * + * Monitor-mode support for mac80211 includes code taken from the iw + * command; the copyright notice for that code is + * + * Copyright (c) 2007, 2008 Johannes Berg + * Copyright (c) 2007 Andy Lutomirski + * Copyright (c) 2007 Mike Kershaw + * Copyright (c) 2008 Gábor Stefanik + * + * 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 AUTHOR ``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 AUTHOR 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. */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.129.2.29 2008-10-28 00:50:39 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.164 2008-12-14 22:00:57 guy Exp $ (LBL)"; #endif /* @@ -80,31 +113,50 @@ static const char rcsid[] _U_ = */ +#define _GNU_SOURCE + #ifdef HAVE_CONFIG_H #include "config.h" #endif #include +#include #include +#include #include #include #include +#include #include #include #include #include -#include +#include #include #include #include #include +#include /* * Got Wireless Extensions? */ #ifdef HAVE_LINUX_WIRELESS_H #include -#endif +#endif /* HAVE_LINUX_WIRELESS_H */ + +/* + * Got libnl? + */ +#ifdef HAVE_LIBNL +#include + +#include +#include +#include +#include +#include +#endif /* HAVE_LIBNL */ #include "pcap-int.h" #include "pcap/sll.h" @@ -118,6 +170,10 @@ static const char rcsid[] _U_ = #include "pcap-septel.h" #endif /* HAVE_SEPTEL_API */ +#ifdef HAVE_SNF_API +#include "pcap-snf.h" +#endif /* HAVE_SNF_API */ + #ifdef PCAP_SUPPORT_USB #include "pcap-usb-linux.h" #endif @@ -126,6 +182,10 @@ static const char rcsid[] _U_ = #include "pcap-bt-linux.h" #endif +#ifdef PCAP_SUPPORT_CAN +#include "pcap-can-linux.h" +#endif + /* * If PF_PACKET is defined, we can use {SOCK_RAW,SOCK_DGRAM}/PF_PACKET * sockets rather than SOCK_PACKET sockets. @@ -262,6 +322,8 @@ static int pcap_read_linux_mmap(pcap_t *, int, pcap_handler , u_char *); static int pcap_setfilter_linux_mmap(pcap_t *, struct bpf_program *); static int pcap_setnonblock_mmap(pcap_t *p, int nonblock, char *errbuf); static int pcap_getnonblock_mmap(pcap_t *p, char *errbuf); +static void pcap_oneshot_mmap(u_char *user, const struct pcap_pkthdr *h, + const u_char *bytes); #endif /* @@ -274,14 +336,17 @@ static int iface_get_mtu(int fd, const char *device, char *ebuf); static int iface_get_arptype(int fd, const char *device, char *ebuf); #ifdef HAVE_PF_PACKET_SOCKETS static int iface_bind(int fd, int ifindex, char *ebuf); +#ifdef IW_MODE_MONITOR static int has_wext(int sock_fd, const char *device, char *ebuf); -static int enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, +#endif /* IW_MODE_MONITOR */ +static int enter_rfmon_mode(pcap_t *handle, int sock_fd, const char *device); -#endif +#endif /* HAVE_PF_PACKET_SOCKETS */ static int iface_bind_old(int fd, const char *device, char *ebuf); #ifdef SO_ATTACH_FILTER -static int fix_program(pcap_t *handle, struct sock_fprog *fcode); +static int fix_program(pcap_t *handle, struct sock_fprog *fcode, + int is_mapped); static int fix_offset(struct bpf_insn *p); static int set_kernel_filter(pcap_t *handle, struct sock_fprog *fcode); static int reset_kernel_filter(pcap_t *handle); @@ -297,6 +362,12 @@ pcap_create(const char *device, char *ebuf) { pcap_t *handle; + /* + * A null device name is equivalent to the "any" device. + */ + if (device == NULL) + device = "any"; + #ifdef HAVE_DAG_API if (strstr(device, "dag")) { return dag_create(device, ebuf); @@ -309,14 +380,27 @@ pcap_create(const char *device, char *ebuf) } #endif /* HAVE_SEPTEL_API */ +#ifdef HAVE_SNF_API + handle = snf_create(device, ebuf); + if (strstr(device, "snf") || handle != NULL) + return handle; + +#endif /* HAVE_SNF_API */ + #ifdef PCAP_SUPPORT_BT if (strstr(device, "bluetooth")) { return bt_create(device, ebuf); } #endif +#ifdef PCAP_SUPPORT_CAN + if (strstr(device, "can") || strstr(device, "vcan")) { + return can_create(device, ebuf); + } +#endif + #ifdef PCAP_SUPPORT_USB - if (strstr(device, "usb")) { + if (strstr(device, "usbmon")) { return usb_create(device, ebuf); } #endif @@ -330,22 +414,462 @@ pcap_create(const char *device, char *ebuf) return handle; } +#ifdef HAVE_LIBNL +/* + * + * If interface {if} is a mac80211 driver, the file + * /sys/class/net/{if}/phy80211 is a symlink to + * /sys/class/ieee80211/{phydev}, for some {phydev}. + * + * On Fedora 9, with a 2.6.26.3-29 kernel, my Zydas stick, at + * least, has a "wmaster0" device and a "wlan0" device; the + * latter is the one with the IP address. Both show up in + * "tcpdump -D" output. Capturing on the wmaster0 device + * captures with 802.11 headers. + * + * airmon-ng searches through /sys/class/net for devices named + * monN, starting with mon0; as soon as one *doesn't* exist, + * it chooses that as the monitor device name. If the "iw" + * command exists, it does "iw dev {if} interface add {monif} + * type monitor", where {monif} is the monitor device. It + * then (sigh) sleeps .1 second, and then configures the + * device up. Otherwise, if /sys/class/ieee80211/{phydev}/add_iface + * is a file, it writes {mondev}, without a newline, to that file, + * and again (sigh) sleeps .1 second, and then iwconfig's that + * device into monitor mode and configures it up. Otherwise, + * you can't do monitor mode. + * + * All these devices are "glued" together by having the + * /sys/class/net/{device}/phy80211 links pointing to the same + * place, so, given a wmaster, wlan, or mon device, you can + * find the other devices by looking for devices with + * the same phy80211 link. + * + * To turn monitor mode off, delete the monitor interface, + * either with "iw dev {monif} interface del" or by sending + * {monif}, with no NL, down /sys/class/ieee80211/{phydev}/remove_iface + * + * Note: if you try to create a monitor device named "monN", and + * there's already a "monN" device, it fails, as least with + * the netlink interface (which is what iw uses), with a return + * value of -ENFILE. (Return values are negative errnos.) We + * could probably use that to find an unused device. + * + * Yes, you can have multiple monitor devices for a given + * physical device. +*/ + +/* + * Is this a mac80211 device? If so, fill in the physical device path and + * return 1; if not, return 0. On an error, fill in handle->errbuf and + * return PCAP_ERROR. + */ static int -pcap_can_set_rfmon_linux(pcap_t *p) +get_mac80211_phydev(pcap_t *handle, const char *device, char *phydev_path, + size_t phydev_max_pathlen) { + char *pathstr; + ssize_t bytes_read; + + /* + * Generate the path string for the symlink to the physical device. + */ + if (asprintf(&pathstr, "/sys/class/net/%s/phy80211", device) == -1) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "%s: Can't generate path name string for /sys/class/net device", + device); + return PCAP_ERROR; + } + bytes_read = readlink(pathstr, phydev_path, phydev_max_pathlen); + if (bytes_read == -1) { + if (errno == ENOENT || errno == EINVAL) { + /* + * Doesn't exist, or not a symlink; assume that + * means it's not a mac80211 device. + */ + free(pathstr); + return 0; + } + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "%s: Can't readlink %s: %s", device, pathstr, + strerror(errno)); + free(pathstr); + return PCAP_ERROR; + } + free(pathstr); + phydev_path[bytes_read] = '\0'; + return 1; +} + +struct nl80211_state { + struct nl_handle *nl_handle; + struct nl_cache *nl_cache; + struct genl_family *nl80211; +}; + +static int +nl80211_init(pcap_t *handle, struct nl80211_state *state, const char *device) +{ + state->nl_handle = nl_handle_alloc(); + if (!state->nl_handle) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "%s: failed to allocate netlink handle", device); + return PCAP_ERROR; + } + + if (genl_connect(state->nl_handle)) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "%s: failed to connect to generic netlink", device); + goto out_handle_destroy; + } + + state->nl_cache = genl_ctrl_alloc_cache(state->nl_handle); + if (!state->nl_cache) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "%s: failed to allocate generic netlink cache", device); + goto out_handle_destroy; + } + + state->nl80211 = genl_ctrl_search_by_name(state->nl_cache, "nl80211"); + if (!state->nl80211) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "%s: nl80211 not found", device); + goto out_cache_free; + } + + return 0; + +out_cache_free: + nl_cache_free(state->nl_cache); +out_handle_destroy: + nl_handle_destroy(state->nl_handle); + return PCAP_ERROR; +} + +static void +nl80211_cleanup(struct nl80211_state *state) +{ + genl_family_put(state->nl80211); + nl_cache_free(state->nl_cache); + nl_handle_destroy(state->nl_handle); +} + +static int +add_mon_if(pcap_t *handle, int sock_fd, struct nl80211_state *state, + const char *device, const char *mondevice) +{ + int ifindex; + struct nl_msg *msg; + int err; + + ifindex = iface_get_id(sock_fd, device, handle->errbuf); + if (ifindex == -1) + return PCAP_ERROR; + + msg = nlmsg_alloc(); + if (!msg) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "%s: failed to allocate netlink msg", device); + return PCAP_ERROR; + } + + genlmsg_put(msg, 0, 0, genl_family_get_id(state->nl80211), 0, + 0, NL80211_CMD_NEW_INTERFACE, 0); + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex); + NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, mondevice); + NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, NL80211_IFTYPE_MONITOR); + + err = nl_send_auto_complete(state->nl_handle, msg); + if (err < 0) { + if (err == -ENFILE) { + /* + * Device not available; our caller should just + * keep trying. + */ + nlmsg_free(msg); + return 0; + } else { + /* + * Real failure, not just "that device is not + * available. + */ + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "%s: nl_send_auto_complete failed adding %s interface: %s", + device, mondevice, strerror(-err)); + nlmsg_free(msg); + return PCAP_ERROR; + } + } + err = nl_wait_for_ack(state->nl_handle); + if (err < 0) { + if (err == -ENFILE) { + /* + * Device not available; our caller should just + * keep trying. + */ + nlmsg_free(msg); + return 0; + } else { + /* + * Real failure, not just "that device is not + * available. + */ + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "%s: nl_wait_for_ack failed adding %s interface: %s", + device, mondevice, strerror(-err)); + nlmsg_free(msg); + return PCAP_ERROR; + } + } + + /* + * Success. + */ + nlmsg_free(msg); + return 1; + +nla_put_failure: + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "%s: nl_put failed adding %s interface", + device, mondevice); + nlmsg_free(msg); + return PCAP_ERROR; +} + +static int +del_mon_if(pcap_t *handle, int sock_fd, struct nl80211_state *state, + const char *device, const char *mondevice) +{ + int ifindex; + struct nl_msg *msg; + int err; + + ifindex = iface_get_id(sock_fd, mondevice, handle->errbuf); + if (ifindex == -1) + return PCAP_ERROR; + + msg = nlmsg_alloc(); + if (!msg) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "%s: failed to allocate netlink msg", device); + return PCAP_ERROR; + } + + genlmsg_put(msg, 0, 0, genl_family_get_id(state->nl80211), 0, + 0, NL80211_CMD_DEL_INTERFACE, 0); + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex); + + err = nl_send_auto_complete(state->nl_handle, msg); + if (err < 0) { + if (err == -ENFILE) { + /* + * Device not available; our caller should just + * keep trying. + */ + nlmsg_free(msg); + return 0; + } else { + /* + * Real failure, not just "that device is not + * available. + */ + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "%s: nl_send_auto_complete failed deleting %s interface: %s", + device, mondevice, strerror(-err)); + nlmsg_free(msg); + return PCAP_ERROR; + } + } + err = nl_wait_for_ack(state->nl_handle); + if (err < 0) { + if (err == -ENFILE) { + /* + * Device not available; our caller should just + * keep trying. + */ + nlmsg_free(msg); + return 0; + } else { + /* + * Real failure, not just "that device is not + * available. + */ + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "%s: nl_wait_for_ack failed adding %s interface: %s", + device, mondevice, strerror(-err)); + nlmsg_free(msg); + return PCAP_ERROR; + } + } + + /* + * Success. + */ + nlmsg_free(msg); + return 1; + +nla_put_failure: + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "%s: nl_put failed deleting %s interface", + device, mondevice); + nlmsg_free(msg); + return PCAP_ERROR; +} + +static int +enter_rfmon_mode_mac80211(pcap_t *handle, int sock_fd, const char *device) +{ + int ret; + char phydev_path[PATH_MAX+1]; + struct nl80211_state nlstate; + struct ifreq ifr; + u_int n; + + /* + * Is this a mac80211 device? + */ + ret = get_mac80211_phydev(handle, device, phydev_path, PATH_MAX); + if (ret < 0) + return ret; /* error */ + if (ret == 0) + return 0; /* no error, but not mac80211 device */ + + /* + * XXX - is this already a monN device? + * If so, we're done. + * Is that determined by old Wireless Extensions ioctls? + */ + + /* + * OK, it's apparently a mac80211 device. + * Try to find an unused monN device for it. + */ + ret = nl80211_init(handle, &nlstate, device); + if (ret != 0) + return ret; + for (n = 0; n < UINT_MAX; n++) { + /* + * Try mon{n}. + */ + char mondevice[3+10+1]; /* mon{UINT_MAX}\0 */ + + snprintf(mondevice, sizeof mondevice, "mon%u", n); + ret = add_mon_if(handle, sock_fd, &nlstate, device, mondevice); + if (ret == 1) { + handle->md.mondevice = strdup(mondevice); + goto added; + } + if (ret < 0) { + /* + * Hard failure. Just return ret; handle->errbuf + * has already been set. + */ + nl80211_cleanup(&nlstate); + return ret; + } + } + + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "%s: No free monN interfaces", device); + nl80211_cleanup(&nlstate); + return PCAP_ERROR; + +added: + +#if 0 + /* + * Sleep for .1 seconds. + */ + delay.tv_sec = 0; + delay.tv_nsec = 500000000; + nanosleep(&delay, NULL); +#endif + + /* + * Now configure the monitor interface up. + */ + memset(&ifr, 0, sizeof(ifr)); + strncpy(ifr.ifr_name, handle->md.mondevice, sizeof(ifr.ifr_name)); + if (ioctl(sock_fd, SIOCGIFFLAGS, &ifr) == -1) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "%s: Can't get flags for %s: %s", device, + handle->md.mondevice, strerror(errno)); + del_mon_if(handle, sock_fd, &nlstate, device, + handle->md.mondevice); + nl80211_cleanup(&nlstate); + return PCAP_ERROR; + } + ifr.ifr_flags |= IFF_UP|IFF_RUNNING; + if (ioctl(sock_fd, SIOCSIFFLAGS, &ifr) == -1) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "%s: Can't set flags for %s: %s", device, + handle->md.mondevice, strerror(errno)); + del_mon_if(handle, sock_fd, &nlstate, device, + handle->md.mondevice); + nl80211_cleanup(&nlstate); + return PCAP_ERROR; + } + + /* + * Success. Clean up the libnl state. + */ + nl80211_cleanup(&nlstate); + + /* + * Note that we have to delete the monitor device when we close + * the handle. + */ + handle->md.must_do_on_close |= MUST_DELETE_MONIF; + + /* + * Add this to the list of pcaps to close when we exit. + */ + pcap_add_to_pcaps_to_close(handle); + + return 1; +} +#endif /* HAVE_LIBNL */ + +static int +pcap_can_set_rfmon_linux(pcap_t *handle) +{ +#ifdef HAVE_LIBNL + char phydev_path[PATH_MAX+1]; + int ret; +#endif #ifdef IW_MODE_MONITOR int sock_fd; struct iwreq ireq; #endif - if (p->opt.source == NULL) { + if (strcmp(handle->opt.source, "any") == 0) { /* - * This is equivalent to the "any" device, and we don't - * support monitor mode on it. + * Monitor mode makes no sense on the "any" device. */ return 0; } +#ifdef HAVE_LIBNL + /* + * Bleah. There doesn't seem to be a way to ask a mac80211 + * device, through libnl, whether it supports monitor mode; + * we'll just check whether the device appears to be a + * mac80211 device and, if so, assume the device supports + * monitor mode. + * + * wmaster devices don't appear to support the Wireless + * Extensions, but we can create a mon device for a + * wmaster device, so we don't bother checking whether + * a mac80211 device supports the Wireless Extensions. + */ + ret = get_mac80211_phydev(handle, handle->opt.source, phydev_path, + PATH_MAX); + if (ret < 0) + return ret; /* error */ + if (ret == 1) + return 1; /* mac80211 device */ +#endif + #ifdef IW_MODE_MONITOR /* * Bleah. There doesn't appear to be an ioctl to use to ask @@ -359,7 +883,7 @@ pcap_can_set_rfmon_linux(pcap_t *p) */ sock_fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (sock_fd == -1) { - (void)snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + (void)snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "socket: %s", pcap_strerror(errno)); return PCAP_ERROR; } @@ -367,7 +891,7 @@ pcap_can_set_rfmon_linux(pcap_t *p) /* * Attempt to get the current mode. */ - strncpy(ireq.ifr_ifrn.ifrn_name, p->opt.source, + strncpy(ireq.ifr_ifrn.ifrn_name, handle->opt.source, sizeof ireq.ifr_ifrn.ifrn_name); ireq.ifr_ifrn.ifrn_name[sizeof ireq.ifr_ifrn.ifrn_name - 1] = 0; if (ioctl(sock_fd, SIOCGIWMODE, &ireq) != -1) { @@ -379,6 +903,8 @@ pcap_can_set_rfmon_linux(pcap_t *p) } if (errno == ENODEV) { /* The device doesn't even exist. */ + (void)snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "SIOCGIWMODE failed: %s", pcap_strerror(errno)); close(sock_fd); return PCAP_ERROR_NO_SUCH_DEVICE; } @@ -387,6 +913,67 @@ pcap_can_set_rfmon_linux(pcap_t *p) return 0; } +/* + * Grabs the number of dropped packets by the interface from /proc/net/dev. + * + * XXX - what about /sys/class/net/{interface name}/rx_*? There are + * individual devices giving, in ASCII, various rx_ and tx_ statistics. + * + * Or can we get them in binary form from netlink? + */ +static long int +linux_if_drops(const char * if_name) +{ + char buffer[512]; + char * bufptr; + FILE * file; + int field_to_convert = 3, if_name_sz = strlen(if_name); + long int dropped_pkts = 0; + + file = fopen("/proc/net/dev", "r"); + if (!file) + return 0; + + while (!dropped_pkts && fgets( buffer, sizeof(buffer), file )) + { + /* search for 'bytes' -- if its in there, then + that means we need to grab the fourth field. otherwise + grab the third field. */ + if (field_to_convert != 4 && strstr(buffer, "bytes")) + { + field_to_convert = 4; + continue; + } + + /* find iface and make sure it actually matches -- space before the name and : after it */ + if ((bufptr = strstr(buffer, if_name)) && + (bufptr == buffer || *(bufptr-1) == ' ') && + *(bufptr + if_name_sz) == ':') + { + bufptr = bufptr + if_name_sz + 1; + + /* grab the nth field from it */ + while( --field_to_convert && *bufptr != '\0') + { + while (*bufptr != '\0' && *(bufptr++) == ' '); + while (*bufptr != '\0' && *(bufptr++) != ' '); + } + + /* get rid of any final spaces */ + while (*bufptr != '\0' && *bufptr == ' ') bufptr++; + + if (*bufptr != '\0') + dropped_pkts = strtol(bufptr, NULL, 10); + + break; + } + } + + fclose(file); + return dropped_pkts; +} + + /* * With older kernels promiscuous mode is kind of interesting because we * have to reset the interface before exiting. The problem can't really @@ -402,16 +989,20 @@ pcap_can_set_rfmon_linux(pcap_t *p) static void pcap_cleanup_linux( pcap_t *handle ) { struct ifreq ifr; +#ifdef HAVE_LIBNL + struct nl80211_state nlstate; + int ret; +#endif /* HAVE_LIBNL */ #ifdef IW_MODE_MONITOR struct iwreq ireq; -#endif +#endif /* IW_MODE_MONITOR */ - if (handle->md.must_clear != 0) { + if (handle->md.must_do_on_close != 0) { /* * There's something we have to do when closing this * pcap_t. */ - if (handle->md.must_clear & MUST_CLEAR_PROMISC) { + if (handle->md.must_do_on_close & MUST_CLEAR_PROMISC) { /* * We put the interface into promiscuous mode; * take it out of promiscuous mode. @@ -449,8 +1040,25 @@ static void pcap_cleanup_linux( pcap_t *handle ) } } +#ifdef HAVE_LIBNL + if (handle->md.must_do_on_close & MUST_DELETE_MONIF) { + ret = nl80211_init(handle, &nlstate, handle->md.device); + if (ret >= 0) { + ret = del_mon_if(handle, handle->fd, &nlstate, + handle->md.device, handle->md.mondevice); + nl80211_cleanup(&nlstate); + } + if (ret < 0) { + fprintf(stderr, + "Can't delete monitor interface %s (%s).\n" + "Please delete manually.\n", + handle->md.mondevice, handle->errbuf); + } + } +#endif /* HAVE_LIBNL */ + #ifdef IW_MODE_MONITOR - if (handle->md.must_clear & MUST_CLEAR_RFMON) { + if (handle->md.must_do_on_close & MUST_CLEAR_RFMON) { /* * We put the interface into rfmon mode; * take it out of rfmon mode. @@ -474,7 +1082,7 @@ static void pcap_cleanup_linux( pcap_t *handle ) strerror(errno)); } } -#endif +#endif /* IW_MODE_MONITOR */ /* * Take this pcap out of the list of pcaps for which we @@ -483,6 +1091,10 @@ static void pcap_cleanup_linux( pcap_t *handle ) pcap_remove_from_pcaps_to_close(handle); } + if (handle->md.mondevice != NULL) { + free(handle->md.mondevice); + handle->md.mondevice = NULL; + } if (handle->md.device != NULL) { free(handle->md.device); handle->md.device = NULL; @@ -503,7 +1115,6 @@ pcap_activate_linux(pcap_t *handle) { const char *device; int status = 0; - int activate_ok = 0; device = handle->opt.source; @@ -518,12 +1129,11 @@ pcap_activate_linux(pcap_t *handle) handle->stats_op = pcap_stats_linux; /* - * NULL and "any" are special devices which give us the hint to - * monitor all devices. + * The "any" device is a special device which causes us not + * to bind to a particular device and thus to look at all + * devices. */ - if (!device || strcmp(device, "any") == 0) { - device = NULL; - handle->md.device = strdup("any"); + if (strcmp(device, "any") == 0) { if (handle->opt.promisc) { handle->opt.promisc = 0; /* Just a warning. */ @@ -531,15 +1141,22 @@ pcap_activate_linux(pcap_t *handle) "Promiscuous mode not supported on the \"any\" device"); status = PCAP_WARNING_PROMISC_NOTSUP; } + } - } else - handle->md.device = strdup(device); - + handle->md.device = strdup(device); if (handle->md.device == NULL) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "strdup: %s", pcap_strerror(errno) ); return PCAP_ERROR; } + + /* + * If we're in promiscuous mode, then we probably want + * to see when the interface drops packets too, so get an + * initial count from /proc/net/dev + */ + if (handle->opt.promisc) + handle->md.proc_dropped = linux_if_drops(handle->md.device); /* * Current Linux kernels use the protocol family PF_PACKET to @@ -552,27 +1169,57 @@ pcap_activate_linux(pcap_t *handle) */ if ((status = activate_new(handle)) == 1) { - activate_ok = 1; /* + * Success. * Try to use memory-mapped access. */ - if (activate_mmap(handle) == 1) - return 0; /* we succeeded; nothing more to do */ + switch (activate_mmap(handle)) { + + case 1: + /* we succeeded; nothing more to do */ + return 0; + + case 0: + /* + * Kernel doesn't support it - just continue + * with non-memory-mapped access. + */ + status = 0; + break; + + case -1: + /* + * We failed to set up to use it, or kernel + * supports it, but we failed to enable it; + * return an error. handle->errbuf contains + * an error message. + */ + status = PCAP_ERROR; + goto fail; + } } else if (status == 0) { /* Non-fatal error; try old way */ - if ((status = activate_old(handle)) == 1) - activate_ok = 1; - } - if (!activate_ok) { + if ((status = activate_old(handle)) != 1) { + /* + * Both methods to open the packet socket failed. + * Tidy up and report our failure (handle->errbuf + * is expected to be set by the functions above). + */ + goto fail; + } + } else { /* - * Both methods to open the packet socket failed. Tidy - * up and report our failure (ebuf is expected to be - * set by the functions above). + * Fatal error with the new way; just fail. + * status has the error return; if it's PCAP_ERROR, + * handle->errbuf has been set appropriately. */ goto fail; } + /* + * We set up the socket, but not with memory-mapped access. + */ if (handle->opt.buffer_size != 0) { /* * Set the socket buffer size to the specified value. @@ -708,12 +1355,12 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata) */ if (handle->break_loop) { /* - * Yes - clear the flag that indicates that it - * has, and return -2 as an indication that we - * were told to break out of the loop. + * Yes - clear the flag that indicates that it has, + * and return PCAP_ERROR_BREAK as an indication that + * we were told to break out of the loop. */ handle->break_loop = 0; - return -2; + return PCAP_ERROR_BREAK; } #if defined(HAVE_PACKET_AUXDATA) && defined(HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI) @@ -725,17 +1372,32 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata) handle->bufsize - offset, MSG_TRUNC, (struct sockaddr *) &from, &fromlen); #endif /* defined(HAVE_PACKET_AUXDATA) && defined(HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI) */ - } while (packet_len == -1 && (errno == EINTR || errno == ENETDOWN)); + } while (packet_len == -1 && errno == EINTR); /* Check if an error occured */ if (packet_len == -1) { - if (errno == EAGAIN) + switch (errno) { + + case EAGAIN: return 0; /* no packet there */ - else { + + case ENETDOWN: + /* + * 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 return that. + */ + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "The interface went down"); + return PCAP_ERROR; + + default: snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "recvfrom: %s", pcap_strerror(errno)); - return -1; + return PCAP_ERROR; } } @@ -893,7 +1555,7 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata) if (ioctl(handle->fd, SIOCGSTAMP, &pcap_header.ts) == -1) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "SIOCGSTAMP: %s", pcap_strerror(errno)); - return -1; + return PCAP_ERROR; } pcap_header.caplen = caplen; pcap_header.len = packet_len; @@ -1008,6 +1670,18 @@ pcap_stats_linux(pcap_t *handle, struct pcap_stat *stats) socklen_t len = sizeof (struct tpacket_stats); #endif + long if_dropped = 0; + + /* + * To fill in ps_ifdrop, we parse /proc/net/dev for the number + */ + if (handle->opt.promisc) + { + if_dropped = handle->md.proc_dropped; + handle->md.proc_dropped = linux_if_drops(handle->md.device); + handle->md.stat.ps_ifdrop += (handle->md.proc_dropped - if_dropped); + } + #ifdef HAVE_TPACKET_STATS /* * Try to get the packet counts from the kernel. @@ -1028,6 +1702,8 @@ pcap_stats_linux(pcap_t *handle, struct pcap_stat *stats) * dropped by the interface driver. It counts only * packets that passed the filter. * + * See above for ps_ifdrop. + * * Both statistics include packets not yet read from * the kernel by libpcap, and thus not yet seen by * the application. @@ -1091,19 +1767,299 @@ pcap_stats_linux(pcap_t *handle, struct pcap_stat *stats) * * "ps_drop" is not supported. * + * "ps_ifdrop" is supported. It will return the number + * of drops the interface reports in /proc/net/dev, + * if that is available. + * * "ps_recv" doesn't include packets not yet read from * the kernel by libpcap. * * We maintain the count of packets processed by libpcap in * "md.packets_read", for reasons described in the comment * at the end of pcap_read_packet(). We have no idea how many - * packets were dropped. + * packets were dropped by the kernel buffers -- but we know + * how many the interface dropped, so we can return that. */ + stats->ps_recv = handle->md.packets_read; stats->ps_drop = 0; + stats->ps_ifdrop = handle->md.stat.ps_ifdrop; return 0; } +/* + * Get from "/sys/class/net" 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 "/sys/class/net"; we just leave + * the list of interfaces as is, and return 0, so that we can try + * scanning /proc/net/dev. + */ +static int +scan_sys_class_net(pcap_if_t **devlistp, char *errbuf) +{ + DIR *sys_class_net_d; + int fd; + struct dirent *ent; + char *p; + char name[512]; /* XXX - pick a size */ + char *q, *saveq; + struct ifreq ifrflags; + int ret = 1; + + sys_class_net_d = opendir("/sys/class/net"); + if (sys_class_net_d == NULL && errno == ENOENT) + return (0); + + /* + * Create a socket from which to fetch interface information. + */ + fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd < 0) { + (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, + "socket: %s", pcap_strerror(errno)); + return (-1); + } + + for (;;) { + errno = 0; + ent = readdir(sys_class_net_d); + if (ent == NULL) { + /* + * Error or EOF; if errno != 0, it's an error. + */ + break; + } + + /* + * Ignore directories (".", "..", and any subdirectories). + */ + if (ent->d_type == DT_DIR) + continue; + + /* + * Get the interface name. + */ + p = &ent->d_name[0]; + q = &name[0]; + while (*p != '\0' && isascii(*p) && !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 (isascii(*p) && 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 directory? + */ + if (errno != 0) { + (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, + "Error reading /sys/class/net: %s", + pcap_strerror(errno)); + ret = -1; + } + } + + (void)close(fd); + (void)closedir(sys_class_net_d); + return (ret); +} + +/* + * 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. + * + * See comments from scan_sys_class_net(). + */ +static int +scan_proc_net_dev(pcap_if_t **devlistp, char *errbuf) +{ + FILE *proc_net_f; + int fd; + char linebuf[512]; + int linenum; + 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 && errno == ENOENT) + return (0); + + /* + * Create a socket from which to fetch interface information. + */ + fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd < 0) { + (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, + "socket: %s", pcap_strerror(errno)); + return (-1); + } + + 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' && isascii(*p) && isspace(*p)) + p++; + if (*p == '\0' || *p == '\n') + continue; /* blank line */ + + /* + * Get the interface name. + */ + q = &name[0]; + while (*p != '\0' && isascii(*p) && !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 (isascii(*p) && 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)close(fd); + (void)fclose(proc_net_f); + return (ret); +} + /* * Description string for the "any" device. */ @@ -1112,25 +2068,66 @@ static const char any_descr[] = "Pseudo-device that captures on all interfaces"; int pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf) { + int ret; + + /* + * Read "/sys/class/net", 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, + * and even getifaddrs() won't return information about + * interfaces with no addresses, so you need to read "/sys/class/net" + * to get the names of the rest of the interfaces. + */ + ret = scan_sys_class_net(alldevsp, errbuf); + if (ret == -1) + return (-1); /* failed */ + if (ret == 0) { + /* + * No /sys/class/net; try reading /proc/net/dev instead. + */ + if (scan_proc_net_dev(alldevsp, errbuf) == -1) + return (-1); + } + + /* + * Add the "any" device. + */ if (pcap_add_if(alldevsp, "any", 0, any_descr, errbuf) < 0) return (-1); #ifdef HAVE_DAG_API + /* + * Add DAG devices. + */ if (dag_platform_finddevs(alldevsp, errbuf) < 0) return (-1); #endif /* HAVE_DAG_API */ #ifdef HAVE_SEPTEL_API + /* + * Add Septel devices. + */ if (septel_platform_finddevs(alldevsp, errbuf) < 0) return (-1); #endif /* HAVE_SEPTEL_API */ +#ifdef HAVE_SNF_API + if (snf_platform_finddevs(alldevsp, errbuf) < 0) + return (-1); +#endif /* HAVE_SNF_API */ + #ifdef PCAP_SUPPORT_BT + /* + * Add Bluetooth devices. + */ if (bt_platform_finddevs(alldevsp, errbuf) < 0) return (-1); #endif #ifdef PCAP_SUPPORT_USB + /* + * Add USB devices. + */ if (usb_platform_finddevs(alldevsp, errbuf) < 0) return (-1); #endif @@ -1142,7 +2139,8 @@ pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf) * Attach the given BPF code to the packet capture device. */ static int -pcap_setfilter_linux(pcap_t *handle, struct bpf_program *filter) +pcap_setfilter_linux_common(pcap_t *handle, struct bpf_program *filter, + int is_mmapped) { #ifdef SO_ATTACH_FILTER struct sock_fprog fcode; @@ -1195,13 +2193,13 @@ pcap_setfilter_linux(pcap_t *handle, struct bpf_program *filter) * * Oh, and we also need to fix it up so that all "ret" * instructions with non-zero operands have 65535 as the - * operand, and so that, if we're in cooked mode, all - * memory-reference instructions use special magic offsets - * in references to the link-layer header and assume that - * the link-layer payload begins at 0; "fix_program()" - * will do that. + * operand if we're not capturing in memory-mapped modee, + * and so that, if we're in cooked mode, all memory-reference + * instructions use special magic offsets in references to + * the link-layer header and assume that the link-layer + * payload begins at 0; "fix_program()" will do that. */ - switch (fix_program(handle, &fcode)) { + switch (fix_program(handle, &fcode, is_mmapped)) { case -1: default: @@ -1275,6 +2273,13 @@ pcap_setfilter_linux(pcap_t *handle, struct bpf_program *filter) return 0; } +static int +pcap_setfilter_linux(pcap_t *handle, struct bpf_program *filter) +{ + return pcap_setfilter_linux_common(handle, filter, 0); +} + + /* * Set direction flag: Which packets do we accept on a forwarding * single device? IN, OUT or both? @@ -1405,6 +2410,12 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, int cooked_ok) case ARPHRD_CHAOS: handle->linktype = DLT_CHAOS; break; +#ifndef ARPHRD_CAN +#define ARPHRD_CAN 280 +#endif + case ARPHRD_CAN: + handle->linktype = DLT_CAN_SOCKETCAN; + break; #ifndef ARPHRD_IEEE802_TR #define ARPHRD_IEEE802_TR 800 /* From Linux 2.4 */ @@ -1657,19 +2668,24 @@ static int activate_new(pcap_t *handle) { #ifdef HAVE_PF_PACKET_SOCKETS - int sock_fd = -1, arptype, val; + const char *device = handle->opt.source; + int is_any_device = (strcmp(device, "any") == 0); + int sock_fd = -1, arptype; +#ifdef HAVE_PACKET_AUXDATA + int val; +#endif int err = 0; struct packet_mreq mr; - const char* device = handle->opt.source; /* - * Open a socket with protocol family packet. If a device is - * given we try to open it in raw mode otherwise we use - * the cooked interface. + * Open a socket with protocol family packet. If the + * "any" device was specified, we open a SOCK_DGRAM + * socket for the cooked interface, otherwise we first + * try a SOCK_RAW socket for the raw interface. */ - sock_fd = device ? - socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)) - : socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL)); + sock_fd = is_any_device ? + socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL)) : + socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (sock_fd == -1) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "socket: %s", @@ -1704,7 +2720,7 @@ activate_new(pcap_t *handle) * to cooked mode if we have an unknown interface type * or a type we know doesn't work well in raw mode. */ - if (device) { + if (!is_any_device) { /* Assume for now we don't need cooked mode. */ handle->md.cooked = 0; @@ -1715,7 +2731,7 @@ activate_new(pcap_t *handle) * because entering monitor mode could change * the link-layer type. */ - err = enter_rfmon_mode_wext(handle, sock_fd, device); + err = enter_rfmon_mode(handle, sock_fd, device); if (err < 0) { /* Hard failure */ close(sock_fd); @@ -1729,6 +2745,15 @@ activate_new(pcap_t *handle) close(sock_fd); return PCAP_ERROR_RFMON_NOTSUP; } + + /* + * Either monitor mode has been turned on for + * the device, or we've been given a different + * device to open for monitor mode. If we've + * been given a different device, use it. + */ + if (handle->md.mondevice != NULL) + device = handle->md.mondevice; } arptype = iface_get_arptype(sock_fd, device, handle->errbuf); if (arptype < 0) { @@ -1819,15 +2844,23 @@ activate_new(pcap_t *handle) } } else { /* - * This is cooked mode. + * The "any" device. + */ + if (handle->opt.rfmon) { + /* + * It doesn't support monitor mode. + */ + return PCAP_ERROR_RFMON_NOTSUP; + } + + /* + * It uses cooked mode. */ handle->md.cooked = 1; handle->linktype = DLT_LINUX_SLL; /* * We're not bound to a device. - * XXX - true? Or true only if we're using - * the "any" device? * For now, we're using this as an indication * that we can't transmit; stop doing that only * if we figure out how to transmit in cooked @@ -1852,10 +2885,13 @@ activate_new(pcap_t *handle) /* * Hmm, how can we set promiscuous mode on all interfaces? - * I am not sure if that is possible at all. + * I am not sure if that is possible at all. For now, we + * silently ignore attempts to turn promiscuous mode on + * for the "any" device (so you don't have to explicitly + * disable it in programs such as tcpdump). */ - if (device && handle->opt.promisc) { + if (!is_any_device && handle->opt.promisc) { memset(&mr, 0, sizeof(mr)); mr.mr_ifindex = handle->md.ifindex; mr.mr_type = PACKET_MR_PROMISC; @@ -1920,16 +2956,32 @@ activate_mmap(pcap_t *handle) #ifdef HAVE_PACKET_RING int ret; + /* + * Attempt to allocate a buffer to hold the contents of one + * packet, for use by the oneshot callback. + */ + handle->md.oneshot_buffer = malloc(handle->snapshot); + if (handle->md.oneshot_buffer == NULL) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "can't allocate oneshot buffer: %s", + pcap_strerror(errno)); + return PCAP_ERROR; + } + if (handle->opt.buffer_size == 0) { /* by default request 2M for the ring buffer */ handle->opt.buffer_size = 2*1024*1024; } ret = prepare_tpacket_socket(handle); - if (ret == 0) + if (ret != 1) { + free(handle->md.oneshot_buffer); return ret; + } ret = create_ring(handle); - if (ret == 0) + if (ret != 1) { + free(handle->md.oneshot_buffer); return ret; + } /* override some defaults and inherit the other fields from * activate_new @@ -1940,6 +2992,7 @@ activate_mmap(pcap_t *handle) handle->setfilter_op = pcap_setfilter_linux_mmap; handle->setnonblock_op = pcap_setnonblock_mmap; handle->getnonblock_op = pcap_getnonblock_mmap; + handle->oneshot_callback = pcap_oneshot_mmap; handle->selectable_fd = handle->fd; return 1; #else /* HAVE_PACKET_RING */ @@ -1965,11 +3018,13 @@ prepare_tpacket_socket(pcap_t *handle) len = sizeof(val); if (getsockopt(handle->fd, SOL_PACKET, PACKET_HDRLEN, &val, &len) < 0) { if (errno == ENOPROTOOPT) - return 1; + return 1; /* no - just drive on */ + + /* Yes - treat as a failure. */ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, - "can't get TPACKET_V2 header len on socket %d: %d-%s", - handle->fd, errno, pcap_strerror(errno)); - return 0; + "can't get TPACKET_V2 header len on packet socket: %s", + pcap_strerror(errno)); + return -1; } handle->md.tp_hdrlen = val; @@ -1977,9 +3032,9 @@ prepare_tpacket_socket(pcap_t *handle) if (setsockopt(handle->fd, SOL_PACKET, PACKET_VERSION, &val, sizeof(val)) < 0) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, - "can't activate TPACKET_V2 on socket %d: %d-%s", - handle->fd, errno, pcap_strerror(errno)); - return 0; + "can't activate TPACKET_V2 on packet socket: %s", + pcap_strerror(errno)); + return -1; } handle->md.tp_version = TPACKET_V2; @@ -1988,33 +3043,19 @@ prepare_tpacket_socket(pcap_t *handle) if (setsockopt(handle->fd, SOL_PACKET, PACKET_RESERVE, &val, sizeof(val)) < 0) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, - "can't set up reserve on socket %d: %d-%s", - handle->fd, errno, pcap_strerror(errno)); - return 0; + "can't set up reserve on packet socket: %s", + pcap_strerror(errno)); + return -1; } #endif /* HAVE_TPACKET2 */ return 1; } -static void -compute_ring_block(int frame_size, unsigned *block_size, unsigned *frames_per_block) -{ - /* compute the minumum block size that will handle this frame. - * The block has to be page size aligned. - * The max block size allowed by the kernel is arch-dependent and - * it's not explicitly checked here. */ - *block_size = getpagesize(); - while (*block_size < frame_size) - *block_size <<= 1; - - *frames_per_block = *block_size/frame_size; -} - static int create_ring(pcap_t *handle) { - unsigned i, j, ringsize, frames_per_block; + unsigned i, j, frames_per_block; struct tpacket_req req; /* Note that with large snapshot (say 64K) only a few frames @@ -2026,53 +3067,83 @@ create_ring(pcap_t *handle) TPACKET_ALIGN(handle->md.tp_hdrlen) + sizeof(struct sockaddr_ll)); req.tp_frame_nr = handle->opt.buffer_size/req.tp_frame_size; - compute_ring_block(req.tp_frame_size, &req.tp_block_size, &frames_per_block); + + /* compute the minumum block size that will handle this frame. + * The block has to be page size aligned. + * The max block size allowed by the kernel is arch-dependent and + * it's not explicitly checked here. */ + req.tp_block_size = getpagesize(); + while (req.tp_block_size < req.tp_frame_size) + req.tp_block_size <<= 1; + + frames_per_block = req.tp_block_size/req.tp_frame_size; + + /* ask the kernel to create the ring */ +retry: req.tp_block_nr = req.tp_frame_nr / frames_per_block; /* req.tp_frame_nr is requested to match frames_per_block*req.tp_block_nr */ req.tp_frame_nr = req.tp_block_nr * frames_per_block; - - /* ask the kernel to create the ring */ -retry: + if (setsockopt(handle->fd, SOL_PACKET, PACKET_RX_RING, (void *) &req, sizeof(req))) { - /* try to reduce requested ring size to prevent memory failure */ if ((errno == ENOMEM) && (req.tp_block_nr > 1)) { - req.tp_frame_nr >>= 1; - req.tp_block_nr = req.tp_frame_nr/frames_per_block; + /* + * Memory failure; try to reduce the requested ring + * size. + * + * We used to reduce this by half -- do 5% instead. + * That may result in more iterations and a longer + * startup, but the user will be much happier with + * the resulting buffer size. + */ + if (req.tp_frame_nr < 20) + req.tp_frame_nr -= 1; + else + req.tp_frame_nr -= req.tp_frame_nr/20; goto retry; } - snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "can't create rx ring on " - "packet socket %d: %d-%s", handle->fd, errno, - pcap_strerror(errno)); - return 0; + if (errno == ENOPROTOOPT) { + /* + * We don't have ring buffer support in this kernel. + */ + return 0; + } + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "can't create rx ring on packet socket: %s", + pcap_strerror(errno)); + return -1; } /* memory map the rx ring */ - ringsize = req.tp_block_nr * req.tp_block_size; - handle->bp = mmap(0, ringsize, PROT_READ| PROT_WRITE, MAP_SHARED, - handle->fd, 0); - if (handle->bp == MAP_FAILED) { - snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "can't mmap rx ring: %d-%s", - errno, pcap_strerror(errno)); + handle->md.mmapbuflen = req.tp_block_nr * req.tp_block_size; + handle->md.mmapbuf = mmap(0, handle->md.mmapbuflen, + PROT_READ|PROT_WRITE, MAP_SHARED, handle->fd, 0); + if (handle->md.mmapbuf == MAP_FAILED) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "can't mmap rx ring: %s", pcap_strerror(errno)); /* clear the allocated ring on error*/ destroy_ring(handle); - return 0; + return -1; } /* allocate a ring for each frame header pointer*/ handle->cc = req.tp_frame_nr; handle->buffer = malloc(handle->cc * sizeof(union thdr *)); if (!handle->buffer) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "can't allocate ring of frame headers: %s", + pcap_strerror(errno)); + destroy_ring(handle); - return 0; + return -1; } /* fill the header ring with proper frame ptr*/ handle->offset = 0; for (i=0; ibp[i*req.tp_block_size]; + void *base = &handle->md.mmapbuf[i*req.tp_block_size]; for (j=0; joffset) { RING_GET_FRAME(handle) = base; base += req.tp_frame_size; @@ -2095,21 +3166,49 @@ destroy_ring(pcap_t *handle) (void *) &req, sizeof(req)); /* if ring is mapped, unmap it*/ - if (handle->bp) { - /* need to re-compute the ring size */ - unsigned frames_per_block, block_size; - compute_ring_block(handle->bufsize, &block_size, &frames_per_block); - - /* do not perform sanity check here: we can't recover any error */ - munmap(handle->bp, block_size * handle->cc / frames_per_block); - handle->bp = 0; + if (handle->md.mmapbuf) { + /* do not test for mmap failure, as we can't recover from any error */ + munmap(handle->md.mmapbuf, handle->md.mmapbuflen); + handle->md.mmapbuf = NULL; } } +/* + * Special one-shot callback, used for pcap_next() and pcap_next_ex(), + * for Linux mmapped capture. + * + * The problem is that pcap_next() and pcap_next_ex() expect the packet + * data handed to the callback to be valid after the callback returns, + * but pcap_read_linux_mmap() has to release that packet as soon as + * the callback returns (otherwise, the kernel thinks there's still + * at least one unprocessed packet available in the ring, so a select() + * will immediately return indicating that there's data to process), so, + * in the callback, we have to make a copy of the packet. + * + * Yes, this means that, if the capture is using the ring buffer, using + * pcap_next() or pcap_next_ex() requires more copies than using + * pcap_loop() or pcap_dispatch(). If that bothers you, don't use + * pcap_next() or pcap_next_ex(). + */ +static void +pcap_oneshot_mmap(u_char *user, const struct pcap_pkthdr *h, + const u_char *bytes) +{ + struct oneshot_userdata *sp = (struct oneshot_userdata *)user; + + *sp->hdr = *h; + memcpy(sp->pd->md.oneshot_buffer, bytes, h->caplen); + *sp->pkt = sp->pd->md.oneshot_buffer; +} + static void pcap_cleanup_linux_mmap( pcap_t *handle ) { destroy_ring(handle); + if (handle->md.oneshot_buffer != NULL) { + free(handle->md.oneshot_buffer); + handle->md.oneshot_buffer = NULL; + } pcap_cleanup_linux(handle); } @@ -2127,11 +3226,26 @@ pcap_setnonblock_mmap(pcap_t *p, int nonblock, char *errbuf) /* map each value to the corresponding 2's complement, to * preserve the timeout value provided with pcap_set_timeout */ 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; } @@ -2158,35 +3272,95 @@ pcap_get_ring_frame(pcap_t *handle, int status) return h.raw; } +#ifndef POLLRDHUP +#define POLLRDHUP 0 +#endif + static int pcap_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user) { + int timeout; int pkts = 0; + char c; /* wait for frames availability.*/ - if ((handle->md.timeout >= 0) && - !pcap_get_ring_frame(handle, TP_STATUS_USER)) { + if (!pcap_get_ring_frame(handle, TP_STATUS_USER)) { struct pollfd pollinfo; int ret; pollinfo.fd = handle->fd; pollinfo.events = POLLIN; + if (handle->md.timeout == 0) + timeout = -1; /* block forever */ + else if (handle->md.timeout > 0) + timeout = handle->md.timeout; /* block for that amount of time */ + else + timeout = 0; /* non-blocking mode - poll to pick up errors */ do { - /* poll() requires a negative timeout to wait forever */ - ret = poll(&pollinfo, 1, (handle->md.timeout > 0)? - handle->md.timeout: -1); - if ((ret < 0) && (errno != EINTR)) { + ret = poll(&pollinfo, 1, timeout); + if (ret < 0 && errno != EINTR) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, - "can't poll on packet socket fd %d: %d-%s", - handle->fd, errno, pcap_strerror(errno)); - return -1; - } + "can't poll on packet socket: %s", + pcap_strerror(errno)); + return PCAP_ERROR; + } else if (ret > 0 && + (pollinfo.revents & (POLLHUP|POLLRDHUP|POLLERR|POLLNVAL))) { + /* + * There's some indication other than + * "you can read on this descriptor" on + * the descriptor. + */ + if (pollinfo.revents & (POLLHUP | POLLRDHUP)) { + snprintf(handle->errbuf, + PCAP_ERRBUF_SIZE, + "Hangup on packet socket"); + return PCAP_ERROR; + } + if (pollinfo.revents & POLLERR) { + /* + * A recv() will give us the + * actual error code. + * + * XXX - make the socket non-blocking? + */ + if (recv(handle->fd, &c, sizeof c, + MSG_PEEK) != -1) + continue; /* what, no error? */ + if (errno == ENETDOWN) { + /* + * 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 return + * that. + */ + snprintf(handle->errbuf, + PCAP_ERRBUF_SIZE, + "The interface went down"); + } else { + snprintf(handle->errbuf, + PCAP_ERRBUF_SIZE, + "Error condition on packet socket: %s", + strerror(errno)); + } + return PCAP_ERROR; + } + if (pollinfo.revents & POLLNVAL) { + snprintf(handle->errbuf, + PCAP_ERRBUF_SIZE, + "Invalid polling request on packet socket"); + return PCAP_ERROR; + } + } /* check for break loop condition on interrupted syscall*/ if (handle->break_loop) { handle->break_loop = 0; - return -2; + return PCAP_ERROR_BREAK; } } while (ret < 0); } @@ -2258,11 +3432,33 @@ pcap_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, tp_len, tp_snaplen) == 0)) goto skip; - /* check direction and interface index */ + /* + * Do checks based on packet direction. + */ sll = (void *)h.raw + TPACKET_ALIGN(handle->md.tp_hdrlen); - if ((sll->sll_ifindex == handle->md.lo_ifindex) && - (sll->sll_pkttype == PACKET_OUTGOING)) - goto skip; + if (sll->sll_pkttype == PACKET_OUTGOING) { + /* + * Outgoing packet. + * If this is from the loopback device, reject it; + * we'll see the packet as an incoming packet as well, + * and we don't want to see it twice. + */ + if (sll->sll_ifindex == handle->md.lo_ifindex) + goto skip; + + /* + * If the user only wants incoming packets, reject it. + */ + if (handle->direction == PCAP_D_IN) + goto skip; + } else { + /* + * Incoming packet. + * If the user only wants outgoing packets, reject it. + */ + if (handle->direction == PCAP_D_OUT) + goto skip; + } /* get required packet info from ring header */ pcaphdr.ts.tv_sec = tp_sec; @@ -2331,6 +3527,18 @@ pcap_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, } #endif + /* + * The only way to tell the kernel to cut off the + * packet at a snapshot length is with a filter program; + * if there's no filter program, the kernel won't cut + * the packet off. + * + * Trim the snapshot length to be no longer than the + * specified snapshot length. + */ + if (pcaphdr.caplen > handle->snapshot) + pcaphdr.caplen = handle->snapshot; + /* pass the packet to the user */ pkts++; callback(user, &pcaphdr, bp); @@ -2354,7 +3562,7 @@ skip: /* check for break loop condition*/ if (handle->break_loop) { handle->break_loop = 0; - return -2; + return PCAP_ERROR_BREAK; } } return pkts; @@ -2364,7 +3572,15 @@ static int pcap_setfilter_linux_mmap(pcap_t *handle, struct bpf_program *filter) { int n, offset; - int ret = pcap_setfilter_linux(handle, filter); + int ret; + + /* + * Don't rewrite "ret" instructions; we don't need to, as + * we're not reading packets with recvmsg(), and we don't + * want to, as, by not rewriting them, the kernel can avoid + * copying extra data. + */ + ret = pcap_setfilter_linux_common(handle, filter, 1); if (ret < 0) return ret; @@ -2478,6 +3694,7 @@ iface_bind(int fd, int ifindex, char *ebuf) return 1; } +#ifdef IW_MODE_MONITOR /* * Check whether the device supports the Wireless Extensions. * Returns 1 if it does, 0 if it doesn't, PCAP_ERROR_NO_SUCH_DEVICE @@ -2486,7 +3703,6 @@ iface_bind(int fd, int ifindex, char *ebuf) static int has_wext(int sock_fd, const char *device, char *ebuf) { -#ifdef IW_MODE_MONITOR struct iwreq ireq; strncpy(ireq.ifr_ifrn.ifrn_name, device, @@ -2498,7 +3714,6 @@ has_wext(int sock_fd, const char *device, char *ebuf) "%s: SIOCGIWPRIV: %s", device, pcap_strerror(errno)); if (errno == ENODEV) return PCAP_ERROR_NO_SUCH_DEVICE; -#endif return 0; } @@ -2534,7 +3749,6 @@ typedef enum { static int enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) { -#ifdef IW_MODE_MONITOR /* * XXX - at least some adapters require non-Wireless Extensions * mechanisms to turn monitor mode on. @@ -2622,7 +3836,7 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) strncpy(ireq.ifr_ifrn.ifrn_name, device, sizeof ireq.ifr_ifrn.ifrn_name); ireq.ifr_ifrn.ifrn_name[sizeof ireq.ifr_ifrn.ifrn_name - 1] = 0; - ireq.u.data.pointer = args; + ireq.u.data.pointer = (void *)args; ireq.u.data.length = 0; ireq.u.data.flags = 0; if (ioctl(sock_fd, SIOCGIWPRIV, &ireq) != -1) { @@ -2652,7 +3866,7 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) "malloc: %s", pcap_strerror(errno)); return PCAP_ERROR; } - ireq.u.data.pointer = priv; + ireq.u.data.pointer = (void *)priv; if (ioctl(sock_fd, SIOCGIWPRIV, &ireq) == -1) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "%s: SIOCGIWPRIV: %s", device, pcap_strerror(errno)); @@ -2672,8 +3886,10 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) * Hostap driver, use this one. * Set monitor mode first. * You can set it to 0 to get DLT_IEEE80211, - * 1 to get DLT_PRISM, or 2 to get - * DLT_IEEE80211_RADIO_AVS. + * 1 to get DLT_PRISM, 2 to get + * DLT_IEEE80211_RADIO_AVS, and, with more + * recent versions of the driver, 3 to get + * DLT_IEEE80211_RADIO. */ if ((priv[i].set_args & IW_PRIV_TYPE_MASK) != IW_PRIV_TYPE_INT) break; @@ -2887,7 +4103,7 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) * Note that we have to put the old mode back * when we close the device. */ - handle->md.must_clear |= MUST_CLEAR_RFMON; + handle->md.must_do_on_close |= MUST_CLEAR_RFMON; /* * Add this to the list of pcaps to close @@ -2936,8 +4152,19 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) case MONITOR_HOSTAP: /* - * Select the AVS header if we can, otherwise - * select the Prism header. + * Try to select the radiotap header. + */ + memset(&ireq, 0, sizeof ireq); + strncpy(ireq.ifr_ifrn.ifrn_name, device, + sizeof ireq.ifr_ifrn.ifrn_name); + ireq.ifr_ifrn.ifrn_name[sizeof ireq.ifr_ifrn.ifrn_name - 1] = 0; + args[0] = 3; /* request radiotap header */ + memcpy(ireq.u.name, args, sizeof (int)); + if (ioctl(sock_fd, cmd, &ireq) != -1) + break; /* success */ + + /* + * That failed. Try to select the AVS header. */ memset(&ireq, 0, sizeof ireq); strncpy(ireq.ifr_ifrn.ifrn_name, device, @@ -2945,18 +4172,19 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) ireq.ifr_ifrn.ifrn_name[sizeof ireq.ifr_ifrn.ifrn_name - 1] = 0; args[0] = 2; /* request AVS header */ memcpy(ireq.u.name, args, sizeof (int)); - if (ioctl(sock_fd, cmd, &ireq) == -1) { - /* - * Failure - try the Prism header. - */ - memset(&ireq, 0, sizeof ireq); - strncpy(ireq.ifr_ifrn.ifrn_name, device, - sizeof ireq.ifr_ifrn.ifrn_name); - ireq.ifr_ifrn.ifrn_name[sizeof ireq.ifr_ifrn.ifrn_name - 1] = 0; - args[0] = 1; /* request Prism header */ - memcpy(ireq.u.name, args, sizeof (int)); - ioctl(sock_fd, cmd, &ireq); - } + if (ioctl(sock_fd, cmd, &ireq) != -1) + break; /* success */ + + /* + * That failed. Try to select the Prism header. + */ + memset(&ireq, 0, sizeof ireq); + strncpy(ireq.ifr_ifrn.ifrn_name, device, + sizeof ireq.ifr_ifrn.ifrn_name); + ireq.ifr_ifrn.ifrn_name[sizeof ireq.ifr_ifrn.ifrn_name - 1] = 0; + args[0] = 1; /* request Prism header */ + memcpy(ireq.u.name, args, sizeof (int)); + ioctl(sock_fd, cmd, &ireq); break; case MONITOR_PRISM: @@ -3067,7 +4295,7 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) * Note that we have to put the old mode back when we * close the device. */ - handle->md.must_clear |= MUST_CLEAR_RFMON; + handle->md.must_do_on_close |= MUST_CLEAR_RFMON; /* * Add this to the list of pcaps to close when we exit. @@ -3075,13 +4303,41 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) pcap_add_to_pcaps_to_close(handle); return 1; -#else +} +#endif /* IW_MODE_MONITOR */ + +/* + * Try various mechanisms to enter monitor mode. + */ +static int +enter_rfmon_mode(pcap_t *handle, int sock_fd, const char *device) +{ +#if defined(HAVE_LIBNL) || defined(IW_MODE_MONITOR) + int ret; +#endif + +#ifdef HAVE_LIBNL + ret = enter_rfmon_mode_mac80211(handle, sock_fd, device); + if (ret < 0) + return ret; /* error attempting to do so */ + if (ret == 1) + return 1; /* success */ +#endif /* HAVE_LIBNL */ + +#ifdef IW_MODE_MONITOR + ret = enter_rfmon_mode_wext(handle, sock_fd, device); + if (ret < 0) + return ret; /* error attempting to do so */ + if (ret == 1) + return 1; /* success */ +#endif /* IW_MODE_MONITOR */ + /* - * We don't have the Wireless Extensions available, so we can't - * do monitor mode. + * Either none of the mechanisms we know about work or none + * of those mechanisms are available, so we can't do monitor + * mode. */ return 0; -#endif } #endif /* HAVE_PF_PACKET_SOCKETS */ @@ -3118,7 +4374,7 @@ activate_old(pcap_t *handle) /* Bind to the given device */ - if (!device) { + if (strcmp(device, "any") == 0) { strncpy(handle->errbuf, "pcap_activate: The \"any\" device isn't supported on 2.0[.x]-kernel systems", PCAP_ERRBUF_SIZE); return PCAP_ERROR; @@ -3183,7 +4439,7 @@ activate_old(pcap_t *handle) pcap_strerror(errno)); return PCAP_ERROR; } - handle->md.must_clear |= MUST_CLEAR_PROMISC; + handle->md.must_do_on_close |= MUST_CLEAR_PROMISC; /* * Add this to the list of pcaps @@ -3358,7 +4614,7 @@ iface_get_arptype(int fd, const char *device, char *ebuf) #ifdef SO_ATTACH_FILTER static int -fix_program(pcap_t *handle, struct sock_fprog *fcode) +fix_program(pcap_t *handle, struct sock_fprog *fcode, int is_mmapped) { size_t prog_size; register int i; @@ -3391,26 +4647,33 @@ fix_program(pcap_t *handle, struct sock_fprog *fcode) case BPF_RET: /* - * It's a return instruction; is the snapshot - * length a constant, rather than the contents - * of the accumulator? + * It's a return instruction; are we capturing + * in memory-mapped mode? */ - if (BPF_MODE(p->code) == BPF_K) { + if (!is_mmapped) { /* - * Yes - if the value to be returned, - * i.e. the snapshot length, is anything - * other than 0, make it 65535, so that - * the packet is truncated by "recvfrom()", - * not by the filter. - * - * XXX - there's nothing we can easily do - * if it's getting the value from the - * accumulator; we'd have to insert - * code to force non-zero values to be - * 65535. + * No; is the snapshot length a constant, + * rather than the contents of the + * accumulator? */ - if (p->k != 0) - p->k = 65535; + if (BPF_MODE(p->code) == BPF_K) { + /* + * Yes - if the value to be returned, + * i.e. the snapshot length, is + * anything other than 0, make it + * 65535, so that the packet is + * truncated by "recvfrom()", + * not by the filter. + * + * XXX - there's nothing we can + * easily do if it's getting the + * value from the accumulator; we'd + * have to insert code to force + * non-zero values to be 65535. + */ + if (p->k != 0) + p->k = 65535; + } } break; diff --git a/libpcap/pcap-namedb.h b/libpcap/pcap-namedb.h index 80a2f0040..d0b223108 100644 --- a/libpcap/pcap-namedb.h +++ b/libpcap/pcap-namedb.h @@ -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) */ /* diff --git a/libpcap/pcap-nit.c b/libpcap/pcap-nit.c index ed042089a..b799549e4 100644 --- a/libpcap/pcap-nit.c +++ b/libpcap/pcap-nit.c @@ -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); } diff --git a/libpcap/pcap-null.c b/libpcap/pcap-null.c index f72a0c3c4..2d271eb42 100644 --- a/libpcap/pcap-null.c +++ b/libpcap/pcap-null.c @@ -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); } diff --git a/libpcap/pcap-pf.c b/libpcap/pcap-pf.c index be9381440..d8326df9a 100644 --- a/libpcap/pcap-pf.c +++ b/libpcap/pcap-pf.c @@ -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); } diff --git a/libpcap/pcap-savefile.manfile.in b/libpcap/pcap-savefile.manfile.in index 3b9503fd2..907559ccb 100644 --- a/libpcap/pcap-savefile.manfile.in +++ b/libpcap/pcap-savefile.manfile.in @@ -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. diff --git a/libpcap/pcap-septel.c b/libpcap/pcap-septel.c index c0473bbb9..8cc2403ac 100644 --- a/libpcap/pcap-septel.c +++ b/libpcap/pcap-septel.c @@ -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 diff --git a/libpcap/pcap-septel.h b/libpcap/pcap-septel.h index c91679768..227d05685 100644 --- a/libpcap/pcap-septel.h +++ b/libpcap/pcap-septel.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); diff --git a/libpcap/pcap-sita.html b/libpcap/pcap-sita.html index 5f7884f99..97408d850 100644 --- a/libpcap/pcap-sita.html +++ b/libpcap/pcap-sita.html @@ -20,7 +20,7 @@ A { text-decoration:none }

SUMMARY

    - Note: This document is part of the libpcap CVS and was derived from 'pcap.3' (circa Aug/07). + Note: This document is part of the libpcap Git and was derived from 'pcap.3' (circa Aug/07).

    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 diff --git a/libpcap/pcap-snf.c b/libpcap/pcap-snf.c new file mode 100644 index 000000000..96781bd71 --- /dev/null +++ b/libpcap/pcap-snf.c @@ -0,0 +1,306 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#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; +} diff --git a/libpcap/pcap-snf.h b/libpcap/pcap-snf.h new file mode 100644 index 000000000..8c197551a --- /dev/null +++ b/libpcap/pcap-snf.h @@ -0,0 +1,2 @@ +pcap_t *snf_create(const char *, char *); +int snf_platform_finddevs(pcap_if_t **devlistp, char *errbuf); diff --git a/libpcap/pcap-snit.c b/libpcap/pcap-snit.c index 8f937be32..fa0c4ef25 100644 --- a/libpcap/pcap-snit.c +++ b/libpcap/pcap-snit.c @@ -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); } diff --git a/libpcap/pcap-snoop.c b/libpcap/pcap-snoop.c index a8034341c..330e01d3a 100644 --- a/libpcap/pcap-snoop.c +++ b/libpcap/pcap-snoop.c @@ -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); } diff --git a/libpcap/pcap-stdinc.h b/libpcap/pcap-stdinc.h index 870e33494..f025013ce 100644 --- a/libpcap/pcap-stdinc.h +++ b/libpcap/pcap-stdinc.h @@ -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 */ diff --git a/libpcap/pcap-usb-linux.c b/libpcap/pcap-usb-linux.c index 830abc775..fea527f4f 100644 --- a/libpcap/pcap-usb-linux.c +++ b/libpcap/pcap-usb-linux.c @@ -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 #include #include +#ifdef HAVE_LINUX_USBDEVICE_FS_H +#include +#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; ibuffer[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); } diff --git a/libpcap/pcap-usb-linux.h b/libpcap/pcap-usb-linux.h index a15790743..2d9638c54 100644 --- a/libpcap/pcap-usb-linux.h +++ b/libpcap/pcap-usb-linux.h @@ -30,7 +30,7 @@ * USB sniffing API implementation for Linux platform * By Paolo Abeni * - * @(#) $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) */ /* diff --git a/libpcap/pcap-win32.c b/libpcap/pcap-win32.c index 4fea62122..0e2201e36 100644 --- a/libpcap/pcap-win32.c +++ b/libpcap/pcap-win32.c @@ -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 @@ -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() diff --git a/libpcap/pcap.3pcap.in b/libpcap/pcap.3pcap.in index 1c6650837..c2f912663 100644 --- a/libpcap/pcap.3pcap.in +++ b/libpcap/pcap.3pcap.in @@ -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. diff --git a/libpcap/pcap.c b/libpcap/pcap.c index 010ef74cd..8c5959fee 100644 --- a/libpcap/pcap.c +++ b/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 #else /* WIN32 */ +#if HAVE_INTTYPES_H +#include +#elif HAVE_STDINT_H +#include +#endif +#ifdef HAVE_SYS_BITYPES_H +#include +#endif #include #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 diff --git a/libpcap/pcap.h b/libpcap/pcap.h index 935f9494c..490a4bfb4 100644 --- a/libpcap/pcap.h +++ b/libpcap/pcap.h @@ -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) */ /* diff --git a/libpcap/pcap/bluetooth.h b/libpcap/pcap/bluetooth.h index 7bf65df03..813bea347 100644 --- a/libpcap/pcap/bluetooth.h +++ b/libpcap/pcap/bluetooth.h @@ -30,7 +30,7 @@ * bluetooth data struct * By Paolo Abeni * - * @(#) $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__ diff --git a/libpcap/pcap/bpf.h b/libpcap/pcap/bpf.h index 9f4ca33e3..eff892c42 100644 --- a/libpcap/pcap/bpf.h +++ b/libpcap/pcap/bpf.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 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 . + */ +#define DLT_GSMTAP_UM 217 +#define DLT_GSMTAP_ABIS 218 + +/* + * MPLS, with an MPLS label as the link-layer header. + * Requested by Michele Marchetto 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 . + */ +#define DLT_DECT 221 + +/* + * From: "Lidwa, Eric (GSFC-582.0)[SGT INC]" + * 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 . + */ +#define DLT_WIHART 223 + +/* + * Fibre Channel FC-2 frames, beginning with a Frame_Header. + * Requested by Kahou Lei . + */ +#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 . + */ +#define DLT_FC_2_WITH_FRAME_DELIMS 225 + +/* + * Solaris ipnet pseudo-header; requested by Darren Reed . + * + * 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 . + */ +#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 . + */ +#define DLT_IPV4 228 +#define DLT_IPV6 229 /* * DLT and savefile link type values are split into a class and diff --git a/libpcap/pcap/ipnet.h b/libpcap/pcap/ipnet.h new file mode 100644 index 000000000..533084709 --- /dev/null +++ b/libpcap/pcap/ipnet.h @@ -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 diff --git a/libpcap/pcap/namedb.h b/libpcap/pcap/namedb.h index 9002c7509..e31455791 100644 --- a/libpcap/pcap/namedb.h +++ b/libpcap/pcap/namedb.h @@ -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 diff --git a/libpcap/pcap/pcap.h b/libpcap/pcap/pcap.h index ea18edcff..05ba31f35 100644 --- a/libpcap/pcap/pcap.h +++ b/libpcap/pcap/pcap.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 *); diff --git a/libpcap/pcap/sll.h b/libpcap/pcap/sll.h index e9d5452af..7ad811d7c 100644 --- a/libpcap/pcap/sll.h +++ b/libpcap/pcap/sll.h @@ -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) */ /* diff --git a/libpcap/pcap/usb.h b/libpcap/pcap/usb.h index adcd19c05..aa3512258 100644 --- a/libpcap/pcap/usb.h +++ b/libpcap/pcap/usb.h @@ -30,7 +30,7 @@ * Basic USB data struct * By Paolo Abeni * - * @(#) $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 diff --git a/libpcap/pcap/vlan.h b/libpcap/pcap/vlan.h index b0cb7949b..41aa8c786 100644 --- a/libpcap/pcap/vlan.h +++ b/libpcap/pcap/vlan.h @@ -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 diff --git a/libpcap/pcap_activate.3pcap b/libpcap/pcap_activate.3pcap index 5b1913604..b33fa530f 100644 --- a/libpcap/pcap_activate.3pcap +++ b/libpcap/pcap_activate.3pcap @@ -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. diff --git a/libpcap/pcap_breakloop.3pcap b/libpcap/pcap_breakloop.3pcap index cf7886032..2372348be 100644 --- a/libpcap/pcap_breakloop.3pcap +++ b/libpcap/pcap_breakloop.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_breakloop.3pcap,v 1.1.2.3 2008-04-06 03:21:55 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_breakloop.3pcap,v 1.3 2008-04-06 02:53:21 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_can_set_rfmon.3pcap b/libpcap/pcap_can_set_rfmon.3pcap index 992d2c8c4..4c85e238b 100644 --- a/libpcap/pcap_can_set_rfmon.3pcap +++ b/libpcap/pcap_can_set_rfmon.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_can_set_rfmon.3pcap,v 1.1.2.1 2008-04-06 03:21:55 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_can_set_rfmon.3pcap,v 1.1 2008-04-06 02:53:21 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_close.3pcap b/libpcap/pcap_close.3pcap index 3d92f0306..810664dbd 100644 --- a/libpcap/pcap_close.3pcap +++ b/libpcap/pcap_close.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_close.3pcap,v 1.1.2.3 2008-04-06 03:21:55 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_close.3pcap,v 1.3 2008-04-06 02:53:21 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_compile.3pcap.in b/libpcap/pcap_compile.3pcap.in index 87e277869..e557fdb43 100644 --- a/libpcap/pcap_compile.3pcap.in +++ b/libpcap/pcap_compile.3pcap.in @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_compile.3pcap.in,v 1.1.2.2 2008-10-21 07:44:57 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_compile.3pcap.in,v 1.1 2008-10-21 07:33:02 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. @@ -54,9 +54,9 @@ captured; it is used only when checking for IPv4 broadcast addresses in the filter program. If the netmask of the network on which packets are being captured isn't known to the program, or if packets are being captured on the Linux "any" pseudo-interface that can capture on more -than one network, a value of 0 can be supplied; tests for IPv4 broadcast -addreses won't be done correctly, but all other tests in the filter -program will be OK. +than one network, a value of PCAP_NETMASK_UNKNOWN can be supplied; tests +for IPv4 broadcast addreses will fail to compile, but all other tests in +the filter program will be OK. .SH RETURN VALUE .B pcap_compile() returns 0 on success and \-1 on failure. diff --git a/libpcap/pcap_create.3pcap b/libpcap/pcap_create.3pcap index 32071b335..153f9fd69 100644 --- a/libpcap/pcap_create.3pcap +++ b/libpcap/pcap_create.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_create.3pcap,v 1.1.2.1 2008-04-06 03:21:55 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_create.3pcap,v 1.1 2008-04-06 02:53:21 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_datalink.3pcap.in b/libpcap/pcap_datalink.3pcap.in index 83426f05c..cdc7c2456 100644 --- a/libpcap/pcap_datalink.3pcap.in +++ b/libpcap/pcap_datalink.3pcap.in @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_datalink.3pcap.in,v 1.1.2.2 2008-10-21 07:44:57 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_datalink.3pcap.in,v 1.1 2008-10-21 07:33:02 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_datalink_name_to_val.3pcap b/libpcap/pcap_datalink_name_to_val.3pcap index f51b933e3..93daafdfb 100644 --- a/libpcap/pcap_datalink_name_to_val.3pcap +++ b/libpcap/pcap_datalink_name_to_val.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_datalink_name_to_val.3pcap,v 1.1.2.3 2008-04-06 03:21:55 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_datalink_name_to_val.3pcap,v 1.3 2008-04-06 02:53:21 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_datalink_val_to_name.3pcap b/libpcap/pcap_datalink_val_to_name.3pcap index 476bf1036..5e4f6bced 100644 --- a/libpcap/pcap_datalink_val_to_name.3pcap +++ b/libpcap/pcap_datalink_val_to_name.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_datalink_val_to_name.3pcap,v 1.1.2.2 2008-05-30 01:32:55 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_datalink_val_to_name.3pcap,v 1.3 2008-12-24 21:45:25 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. @@ -19,7 +19,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_DATALINK_VAL_TO_NAME 3 "4 April 2008" +.TH PCAP_DATALINK_VAL_TO_NAME 3PCAP "24 December 2008" .SH NAME pcap_datalink_val_to_name, pcap_datalink_val_to_description \- get a name or description for a link-layer header type value diff --git a/libpcap/pcap_dump.3pcap b/libpcap/pcap_dump.3pcap index 1808869b7..1ccd82a6f 100644 --- a/libpcap/pcap_dump.3pcap +++ b/libpcap/pcap_dump.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_dump.3pcap,v 1.1.2.3 2008-04-06 03:21:55 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_dump.3pcap,v 1.3 2008-04-06 02:53:21 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_dump_close.3pcap b/libpcap/pcap_dump_close.3pcap index 07b690a86..4ed820b03 100644 --- a/libpcap/pcap_dump_close.3pcap +++ b/libpcap/pcap_dump_close.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_dump_close.3pcap,v 1.1.2.3 2008-04-06 03:21:55 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_dump_close.3pcap,v 1.3 2008-04-06 02:53:21 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_dump_file.3pcap b/libpcap/pcap_dump_file.3pcap index 5cf0de65a..9e51a2a98 100644 --- a/libpcap/pcap_dump_file.3pcap +++ b/libpcap/pcap_dump_file.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_dump_file.3pcap,v 1.1.2.3 2008-04-06 03:21:55 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_dump_file.3pcap,v 1.3 2008-04-06 02:53:21 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_dump_flush.3pcap b/libpcap/pcap_dump_flush.3pcap index e83e2a074..b553883aa 100644 --- a/libpcap/pcap_dump_flush.3pcap +++ b/libpcap/pcap_dump_flush.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_dump_flush.3pcap,v 1.1.2.3 2008-04-06 03:21:55 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_dump_flush.3pcap,v 1.3 2008-04-06 02:53:21 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_dump_ftell.3pcap b/libpcap/pcap_dump_ftell.3pcap index d9c3600ce..1d0f96f35 100644 --- a/libpcap/pcap_dump_ftell.3pcap +++ b/libpcap/pcap_dump_ftell.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_dump_ftell.3pcap,v 1.1.2.3 2008-04-06 03:21:55 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_dump_ftell.3pcap,v 1.3 2008-04-06 02:53:21 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_dump_open.3pcap.in b/libpcap/pcap_dump_open.3pcap.in index 9fe116bb7..2a5dc9de1 100644 --- a/libpcap/pcap_dump_open.3pcap.in +++ b/libpcap/pcap_dump_open.3pcap.in @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_dump_open.3pcap.in,v 1.1.2.2 2008-10-23 05:59:43 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_dump_open.3pcap.in,v 1.1 2008-10-23 05:56:59 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_file.3pcap b/libpcap/pcap_file.3pcap index b74e50216..1471ab63c 100644 --- a/libpcap/pcap_file.3pcap +++ b/libpcap/pcap_file.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_file.3pcap,v 1.1.2.3 2008-04-06 03:21:55 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_file.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_fileno.3pcap b/libpcap/pcap_fileno.3pcap index 9c05be0d0..02d24b532 100644 --- a/libpcap/pcap_fileno.3pcap +++ b/libpcap/pcap_fileno.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_fileno.3pcap,v 1.1.2.3 2008-04-06 03:21:55 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_fileno.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. @@ -33,15 +33,36 @@ int pcap_fileno(pcap_t *p); .ft .fi .SH DESCRIPTION -.B pcap_fileno() -returns the file descriptor number from which captured packets are read, -if a network device was opened with +If +.I p +refers to a network device that was opened for a live capture using +a combination of .B pcap_create() and -.B pcap_activate() -or with +.BR pcap_activate() , +or using .BR pcap_open_live() , -or \-1, if a ``savefile'' was opened with -.BR pcap_open_offline() . +.B pcap_fileno() +returns the file descriptor from which captured packets are read. +.LP +If +.I p +refers to a ``savefile'' that was opened using fuctions such as +.BR pcap_open_offline() +or +.BR pcap_fopen_offline() , +a ``dead'' +.B pcap_t +opened using +.BR pcap_open_dead() , +or a +.B pcap_t +that was created with +.B pcap_create() +but that has not yet been activated with +.BR pcap_activate() , +it returns \-1. .SH SEE ALSO -pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP) +pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP), +pcap_open_live(3PCAP), pcap_open_offline(3PCAP), +pcap_fopen_offline(3PCAP), pcap_open_dead(3PCAP) diff --git a/libpcap/pcap_findalldevs.3pcap b/libpcap/pcap_findalldevs.3pcap index 93c0455f8..3bf152059 100644 --- a/libpcap/pcap_findalldevs.3pcap +++ b/libpcap/pcap_findalldevs.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_findalldevs.3pcap,v 1.1.2.3 2008-04-06 03:21:55 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_findalldevs.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_free_datalinks.3pcap b/libpcap/pcap_free_datalinks.3pcap index 8bb7899c7..b7355bdf8 100644 --- a/libpcap/pcap_free_datalinks.3pcap +++ b/libpcap/pcap_free_datalinks.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_free_datalinks.3pcap,v 1.1.2.1 2008-05-26 19:58:59 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_free_datalinks.3pcap,v 1.1 2008-05-26 19:58:06 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_freealldevs.3pcap b/libpcap/pcap_freealldevs.3pcap index 09d4706df..d3f234fc6 100644 --- a/libpcap/pcap_freealldevs.3pcap +++ b/libpcap/pcap_freealldevs.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_freealldevs.3pcap,v 1.1.2.3 2008-04-06 03:21:55 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_freealldevs.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_freecode.3pcap b/libpcap/pcap_freecode.3pcap index 061b50641..31b4f8971 100644 --- a/libpcap/pcap_freecode.3pcap +++ b/libpcap/pcap_freecode.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_freecode.3pcap,v 1.1.2.3 2008-04-06 03:21:55 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_freecode.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_get_selectable_fd.3pcap b/libpcap/pcap_get_selectable_fd.3pcap index 9026f451b..61be3d32e 100644 --- a/libpcap/pcap_get_selectable_fd.3pcap +++ b/libpcap/pcap_get_selectable_fd.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_get_selectable_fd.3pcap,v 1.1.2.3 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_get_selectable_fd.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. @@ -104,6 +104,11 @@ can be used on the descriptor returned by .B poll() cannot be used on it those versions of Mac OS X. Kqueues also don't work on that descriptor. +.BR poll() , +but not kqueues, work on that descriptor in Mac OS X releases prior to +10.4; +.B poll() +and kqueues work on that descriptor in Mac OS X 10.6 and later. .PP .B pcap_get_selectable_fd() is not available on Windows. diff --git a/libpcap/pcap_geterr.3pcap b/libpcap/pcap_geterr.3pcap index 9a46a830c..1a4ea3476 100644 --- a/libpcap/pcap_geterr.3pcap +++ b/libpcap/pcap_geterr.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_geterr.3pcap,v 1.1.2.3 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_geterr.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_inject.3pcap b/libpcap/pcap_inject.3pcap index 954984c7f..79a3eea6d 100644 --- a/libpcap/pcap_inject.3pcap +++ b/libpcap/pcap_inject.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_inject.3pcap,v 1.1.2.3 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_inject.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_is_swapped.3pcap b/libpcap/pcap_is_swapped.3pcap index 6cc70896f..4d26b3be9 100644 --- a/libpcap/pcap_is_swapped.3pcap +++ b/libpcap/pcap_is_swapped.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_is_swapped.3pcap,v 1.1.2.3 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_is_swapped.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_lib_version.3pcap b/libpcap/pcap_lib_version.3pcap index fff914971..7b39be181 100644 --- a/libpcap/pcap_lib_version.3pcap +++ b/libpcap/pcap_lib_version.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_lib_version.3pcap,v 1.1.2.3 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_lib_version.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_list_datalinks.3pcap.in b/libpcap/pcap_list_datalinks.3pcap.in index 822c70c51..490e8dde7 100644 --- a/libpcap/pcap_list_datalinks.3pcap.in +++ b/libpcap/pcap_list_datalinks.3pcap.in @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_list_datalinks.3pcap.in,v 1.1.2.2 2008-10-21 07:44:57 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_list_datalinks.3pcap.in,v 1.1 2008-10-21 07:33:02 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_lookupdev.3pcap b/libpcap/pcap_lookupdev.3pcap index 2d80bf5b6..8b23cb870 100644 --- a/libpcap/pcap_lookupdev.3pcap +++ b/libpcap/pcap_lookupdev.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_lookupdev.3pcap,v 1.1.2.3 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_lookupdev.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_lookupnet.3pcap b/libpcap/pcap_lookupnet.3pcap index 031acb781..75c82cfc7 100644 --- a/libpcap/pcap_lookupnet.3pcap +++ b/libpcap/pcap_lookupnet.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_lookupnet.3pcap,v 1.1.2.3 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_lookupnet.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_loop.3pcap b/libpcap/pcap_loop.3pcap index 8e491d4c1..70cfaa029 100644 --- a/libpcap/pcap_loop.3pcap +++ b/libpcap/pcap_loop.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_loop.3pcap,v 1.1.2.3 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_loop.3pcap,v 1.4 2008-12-25 02:01:32 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. @@ -19,7 +19,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_LOOP 3PCAP "5 April 2008" +.TH PCAP_LOOP 3PCAP "24 December 2008" .SH NAME pcap_loop, pcap_dispatch \- process packets from a live capture or savefile .SH SYNOPSIS @@ -89,7 +89,9 @@ should use \-1, nor 0, as the value of .ft R .PP .I callback -specifies a routine to be called with three arguments: +specifies a +.I pcap_handler +routine to be called with three arguments: a .I u_char pointer which is passed in the diff --git a/libpcap/pcap_major_version.3pcap b/libpcap/pcap_major_version.3pcap index 1eabcf00f..6f9c8ae70 100644 --- a/libpcap/pcap_major_version.3pcap +++ b/libpcap/pcap_major_version.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_major_version.3pcap,v 1.1.2.3 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_major_version.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_next_ex.3pcap b/libpcap/pcap_next_ex.3pcap index d472a2b6e..50ad198aa 100644 --- a/libpcap/pcap_next_ex.3pcap +++ b/libpcap/pcap_next_ex.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_next_ex.3pcap,v 1.1.2.3 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_next_ex.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_offline_filter.3pcap b/libpcap/pcap_offline_filter.3pcap index 0ec697788..596c5e44c 100644 --- a/libpcap/pcap_offline_filter.3pcap +++ b/libpcap/pcap_offline_filter.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_offline_filter.3pcap,v 1.1.2.1 2008-05-13 15:20:44 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_offline_filter.3pcap,v 1.1 2008-05-13 15:19:56 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_open_dead.3pcap.in b/libpcap/pcap_open_dead.3pcap.in index 18c98ffca..00df78668 100644 --- a/libpcap/pcap_open_dead.3pcap.in +++ b/libpcap/pcap_open_dead.3pcap.in @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_open_dead.3pcap.in,v 1.1.2.2 2008-10-21 07:44:57 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_open_dead.3pcap.in,v 1.1 2008-10-21 07:33:02 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_open_live.3pcap b/libpcap/pcap_open_live.3pcap index 6ef1d5fbd..623f0986e 100644 --- a/libpcap/pcap_open_live.3pcap +++ b/libpcap/pcap_open_live.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_open_live.3pcap,v 1.1.2.3 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_open_live.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_open_offline.3pcap.in b/libpcap/pcap_open_offline.3pcap.in index ce350ddf7..3f9f5a271 100644 --- a/libpcap/pcap_open_offline.3pcap.in +++ b/libpcap/pcap_open_offline.3pcap.in @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_open_offline.3pcap.in,v 1.1.2.2 2008-10-23 05:59:43 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_open_offline.3pcap.in,v 1.1 2008-10-23 05:56:59 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. @@ -43,11 +43,15 @@ pcap_t *pcap_fopen_offline(FILE *fp, char *errbuf); is called to open a ``savefile'' for reading. .PP .I fname -specifies the name of the file to open. The file has -the same format as those used by +specifies the name of the file to open. The file can have the pcap file +format as described in +.BR pcap-savefile (@MAN_FILE_FORMATS@), +which is the file format used by, among other programs, .BR tcpdump (1) and -.BR tcpslice (1). +.BR tcpslice (1), +or can have the pcap-ng file format, although not all pcap-ng files can +be read. The name "-" in a synonym for .BR stdin . .PP diff --git a/libpcap/pcap_set_buffer_size.3pcap b/libpcap/pcap_set_buffer_size.3pcap index d26a7a5d0..060e923e8 100644 --- a/libpcap/pcap_set_buffer_size.3pcap +++ b/libpcap/pcap_set_buffer_size.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_set_buffer_size.3pcap,v 1.1.2.1 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_set_buffer_size.3pcap,v 1.1 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_set_datalink.3pcap b/libpcap/pcap_set_datalink.3pcap index 5754d764d..bad39e4c8 100644 --- a/libpcap/pcap_set_datalink.3pcap +++ b/libpcap/pcap_set_datalink.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_set_datalink.3pcap,v 1.1.2.3 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_set_datalink.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_set_promisc.3pcap b/libpcap/pcap_set_promisc.3pcap index 27c071455..382260c74 100644 --- a/libpcap/pcap_set_promisc.3pcap +++ b/libpcap/pcap_set_promisc.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_set_promisc.3pcap,v 1.1.2.1 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_set_promisc.3pcap,v 1.1 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_set_rfmon.3pcap b/libpcap/pcap_set_rfmon.3pcap index ceb62a676..ee7355686 100644 --- a/libpcap/pcap_set_rfmon.3pcap +++ b/libpcap/pcap_set_rfmon.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_set_rfmon.3pcap,v 1.1.2.1 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_set_rfmon.3pcap,v 1.1 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_set_snaplen.3pcap b/libpcap/pcap_set_snaplen.3pcap index 10093e482..74195d936 100644 --- a/libpcap/pcap_set_snaplen.3pcap +++ b/libpcap/pcap_set_snaplen.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_set_snaplen.3pcap,v 1.1.2.1 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_set_snaplen.3pcap,v 1.1 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_set_timeout.3pcap b/libpcap/pcap_set_timeout.3pcap index 17f2c31e4..c361b7da6 100644 --- a/libpcap/pcap_set_timeout.3pcap +++ b/libpcap/pcap_set_timeout.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_set_timeout.3pcap,v 1.1.2.1 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_set_timeout.3pcap,v 1.1 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_setdirection.3pcap b/libpcap/pcap_setdirection.3pcap index 70891a258..bd0fb253e 100644 --- a/libpcap/pcap_setdirection.3pcap +++ b/libpcap/pcap_setdirection.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_setdirection.3pcap,v 1.1.2.3 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_setdirection.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_setfilter.3pcap b/libpcap/pcap_setfilter.3pcap index 67c1214fa..89d5da7f7 100644 --- a/libpcap/pcap_setfilter.3pcap +++ b/libpcap/pcap_setfilter.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_setfilter.3pcap,v 1.1.2.4 2008-05-13 15:20:44 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_setfilter.3pcap,v 1.4 2008-05-13 15:19:56 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_setnonblock.3pcap b/libpcap/pcap_setnonblock.3pcap index 07d962938..b00fce100 100644 --- a/libpcap/pcap_setnonblock.3pcap +++ b/libpcap/pcap_setnonblock.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_setnonblock.3pcap,v 1.1.2.3 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_setnonblock.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_snapshot.3pcap b/libpcap/pcap_snapshot.3pcap index 19bb9dec6..3025312fb 100644 --- a/libpcap/pcap_snapshot.3pcap +++ b/libpcap/pcap_snapshot.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_snapshot.3pcap,v 1.1.2.3 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_snapshot.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_stats.3pcap b/libpcap/pcap_stats.3pcap index 0a68c1ec2..a953e211d 100644 --- a/libpcap/pcap_stats.3pcap +++ b/libpcap/pcap_stats.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_stats.3pcap,v 1.1.2.3 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_stats.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. @@ -19,7 +19,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_SNAPSHOT 3PCAP "5 April 2008" +.TH PCAP_STATS 3PCAP "7 September 2009" .SH NAME pcap_stats \- get capture statistics .SH SYNOPSIS @@ -35,17 +35,57 @@ int pcap_stats(pcap_t *p, struct pcap_stat *ps); .SH DESCRIPTION .B pcap_stats() fills in the -.I pcap_stat -structure pointed to by its second argument. The values represent +.B struct pcap_stat +pointed to by its second argument. The values represent packet statistics from the start of the run to the time of the call. .PP .B pcap_stats() is supported only on live captures, not on ``savefiles''; no statistics are stored in ``savefiles'', so no statistics are available when reading from a ``savefile''. +.PP +A +.B struct pcap_stat +has the following members: +.RS +.TP +.B ps_recv +number of packets received; +.TP +.B ps_drop +number of packets dropped because there was no room in the operating +system's buffer when they arrived, because packets weren't being read +fast enough; +.TP +.B ps_ifdrop +number of packets dropped by the network interface or its driver. +.RE +.PP +The statistics do not behave the same way on all platforms. +.B ps_recv +might count packets whether they passed any filter set with +.BR pcap_setfilter (3PCAP) +or not, or it might count only packets that pass the filter. +It also might, or might not, count packets dropped because there was no +room in the operating system's buffer when they arrived. +.B ps_drop +is not available on all platforms; it is zero on platforms where it's +not available. If packet filtering is done in libpcap, rather than in +the operating system, it would count packets that don't pass the filter. +Both +.B ps_recv +and +.B ps_drop +might, or might not, count packets not yet read from the operating +system and thus not yet seen by the application. +.B ps_ifdrop +might, or might not, be implemented; if it's zero, that might mean that +no packets were dropped by the interface, or it might mean that the +statistic is unavailable, so it should not be treated as an indication +that the interface did not drop any packets. .SH RETURN VALUE .B pcap_stats() -returns 0 on success and returns \-1 if there is an error or the +returns 0 on success and returns \-1 if there is an error or if .I p doesn't support packet statistics. If \-1 is returned, diff --git a/libpcap/pcap_statustostr.3pcap b/libpcap/pcap_statustostr.3pcap index 5e8942c15..da18f6912 100644 --- a/libpcap/pcap_statustostr.3pcap +++ b/libpcap/pcap_statustostr.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_statustostr.3pcap,v 1.1.2.1 2008-04-09 21:41:53 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_statustostr.3pcap,v 1.1 2008-04-09 21:39:21 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/pcap_strerror.3pcap b/libpcap/pcap_strerror.3pcap index eacdce492..8e6319bbf 100644 --- a/libpcap/pcap_strerror.3pcap +++ b/libpcap/pcap_strerror.3pcap @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/libpcap/pcap_strerror.3pcap,v 1.1.2.3 2008-04-06 03:21:56 guy Exp $ +.\" @(#) $Header: /tcpdump/master/libpcap/pcap_strerror.3pcap,v 1.2 2008-04-05 20:26:56 guy Exp $ .\" .\" Copyright (c) 1994, 1996, 1997 .\" The Regents of the University of California. All rights reserved. diff --git a/libpcap/ppp.h b/libpcap/ppp.h index 80a685169..4e1d08de1 100644 --- a/libpcap/ppp.h +++ b/libpcap/ppp.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/libpcap/ppp.h,v 1.12 2005/02/08 19:52:19 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/libpcap/ppp.h,v 1.12 2005-02-08 19:52:19 guy Exp $ (LBL) */ /* * Point to Point Protocol (PPP) RFC1331 * diff --git a/libpcap/runlex.sh b/libpcap/runlex.sh index 497a6186f..74f216171 100755 --- a/libpcap/runlex.sh +++ b/libpcap/runlex.sh @@ -7,7 +7,7 @@ # means that neither Flex nor Lex was found, so we report an error and # quit. # -# @(#) $Header: /tcpdump/master/libpcap/runlex.sh,v 1.1.2.4 2007/12/31 03:39:06 guy Exp $ +# @(#) $Header: /tcpdump/master/libpcap/runlex.sh,v 1.4 2007-12-31 03:38:39 guy Exp $ # # diff --git a/libpcap/savefile.c b/libpcap/savefile.c index 65416f64d..56e571937 100644 --- a/libpcap/savefile.c +++ b/libpcap/savefile.c @@ -30,13 +30,27 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.168.2.10 2008-10-06 15:38:39 gianluca Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.183 2008-12-23 20:13:29 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif +#ifdef WIN32 +#include +#else /* WIN32 */ +#if HAVE_INTTYPES_H +#include +#elif HAVE_STDINT_H +#include +#endif +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +#include +#endif /* WIN32 */ + #include #include #include @@ -50,56 +64,8 @@ static const char rcsid[] _U_ = #include "os-proto.h" #endif -/* - * Standard libpcap format. - */ -#define TCPDUMP_MAGIC 0xa1b2c3d4 - -/* - * Alexey Kuznetzov's modified libpcap format. - */ -#define KUZNETZOV_TCPDUMP_MAGIC 0xa1b2cd34 - -/* - * Reserved for Francisco Mesquita - * for another modified format. - */ -#define FMESQUITA_TCPDUMP_MAGIC 0xa1b234cd - -/* - * Navtel Communcations' format, with nanosecond timestamps, - * as per a request from Dumas Hwang . - */ -#define NAVTEL_TCPDUMP_MAGIC 0xa12b3c4d - -/* - * Normal libpcap format, except for seconds/nanoseconds timestamps, - * as per a request by Ulf Lamping - */ -#define NSEC_TCPDUMP_MAGIC 0xa1b23c4d - -/* - * 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) ) - -#define SFERR_TRUNC 1 -#define SFERR_BADVERSION 2 -#define SFERR_BADF 3 -#define SFERR_EOF 4 /* not really an error, just a status */ +#include "sf-pcap.h" +#include "sf-pcap-ng.h" /* * Setting O_BINARY on DOS/Windows is a bit tricky @@ -114,926 +80,6 @@ static const char rcsid[] _U_ = #endif #endif -/* - * We don't write DLT_* values to the capture file header, because - * they're not the same on all platforms. - * - * Unfortunately, the various flavors of BSD have not always used the same - * numerical values for the same data types, and various patches to - * libpcap for non-BSD OSes have added their own DLT_* codes for link - * layer encapsulation types seen on those OSes, and those codes have had, - * in some cases, values that were also used, on other platforms, for other - * link layer encapsulation types. - * - * This means that capture files of a type whose numerical DLT_* code - * means different things on different BSDs, or with different versions - * of libpcap, can't always be read on systems other than those like - * the one running on the machine on which the capture was made. - * - * Instead, we define here a set of LINKTYPE_* codes, and map DLT_* codes - * to LINKTYPE_* codes when writing a savefile header, and map LINKTYPE_* - * codes to DLT_* codes when reading a savefile header. - * - * For those DLT_* codes that have, as far as we know, the same values on - * all platforms (DLT_NULL through DLT_FDDI), we define LINKTYPE_xxx as - * DLT_xxx; that way, captures of those types can still be read by - * versions of libpcap that map LINKTYPE_* values to DLT_* values, and - * captures of those types written by versions of libpcap that map DLT_ - * values to LINKTYPE_ values can still be read by older versions - * of libpcap. - * - * The other LINKTYPE_* codes are given values starting at 100, in the - * hopes that no DLT_* code will be given one of those values. - * - * In order to ensure that a given LINKTYPE_* code's value will refer to - * the same encapsulation type on all platforms, you should not allocate - * a new LINKTYPE_* value without consulting - * "tcpdump-workers@lists.tcpdump.org". The tcpdump developers will - * allocate a value for you, and will not subsequently allocate it to - * anybody else; that value will be added to the "pcap.h" in the - * tcpdump.org CVS repository, so that a future libpcap release will - * include it. - * - * You should, if possible, also contribute patches to libpcap and tcpdump - * to handle the new encapsulation type, so that they can also be checked - * into the tcpdump.org CVS repository and so that they will appear in - * future libpcap and tcpdump releases. - * - * Do *NOT* assume that any values after the largest value in this file - * are available; you might not have the most up-to-date version of this - * file, and new values after that one might have been assigned. Also, - * do *NOT* use any values below 100 - those might already have been - * taken by one (or more!) organizations. - */ -#define LINKTYPE_NULL DLT_NULL -#define LINKTYPE_ETHERNET DLT_EN10MB /* also for 100Mb and up */ -#define LINKTYPE_EXP_ETHERNET DLT_EN3MB /* 3Mb experimental Ethernet */ -#define LINKTYPE_AX25 DLT_AX25 -#define LINKTYPE_PRONET DLT_PRONET -#define LINKTYPE_CHAOS DLT_CHAOS -#define LINKTYPE_TOKEN_RING DLT_IEEE802 /* DLT_IEEE802 is used for Token Ring */ -#define LINKTYPE_ARCNET DLT_ARCNET /* BSD-style headers */ -#define LINKTYPE_SLIP DLT_SLIP -#define LINKTYPE_PPP DLT_PPP -#define LINKTYPE_FDDI DLT_FDDI - -/* - * LINKTYPE_PPP is for use when there might, or might not, be an RFC 1662 - * PPP in HDLC-like framing header (with 0xff 0x03 before the PPP protocol - * field) at the beginning of the packet. - * - * This is for use when there is always such a header; the address field - * might be 0xff, for regular PPP, or it might be an address field for Cisco - * point-to-point with HDLC framing as per section 4.3.1 of RFC 1547 ("Cisco - * HDLC"). This is, for example, what you get with NetBSD's DLT_PPP_SERIAL. - * - * We give it the same value as NetBSD's DLT_PPP_SERIAL, in the hopes that - * nobody else will choose a DLT_ value of 50, and so that DLT_PPP_SERIAL - * captures will be written out with a link type that NetBSD's tcpdump - * can read. - */ -#define LINKTYPE_PPP_HDLC 50 /* PPP in HDLC-like framing */ - -#define LINKTYPE_PPP_ETHER 51 /* NetBSD PPP-over-Ethernet */ - -#define LINKTYPE_SYMANTEC_FIREWALL 99 /* Symantec Enterprise Firewall */ - -#define LINKTYPE_ATM_RFC1483 100 /* LLC/SNAP-encapsulated ATM */ -#define LINKTYPE_RAW 101 /* raw IP */ -#define LINKTYPE_SLIP_BSDOS 102 /* BSD/OS SLIP BPF header */ -#define LINKTYPE_PPP_BSDOS 103 /* BSD/OS PPP BPF header */ -#define LINKTYPE_C_HDLC 104 /* Cisco HDLC */ -#define LINKTYPE_IEEE802_11 105 /* IEEE 802.11 (wireless) */ -#define LINKTYPE_ATM_CLIP 106 /* Linux Classical IP over ATM */ -#define LINKTYPE_FRELAY 107 /* Frame Relay */ -#define LINKTYPE_LOOP 108 /* OpenBSD loopback */ -#define LINKTYPE_ENC 109 /* OpenBSD IPSEC enc */ - -/* - * These three types are reserved for future use. - */ -#define LINKTYPE_LANE8023 110 /* ATM LANE + 802.3 */ -#define LINKTYPE_HIPPI 111 /* NetBSD HIPPI */ -#define LINKTYPE_HDLC 112 /* NetBSD HDLC framing */ - -#define LINKTYPE_LINUX_SLL 113 /* Linux cooked socket capture */ -#define LINKTYPE_LTALK 114 /* Apple LocalTalk hardware */ -#define LINKTYPE_ECONET 115 /* Acorn Econet */ - -/* - * Reserved for use with OpenBSD ipfilter. - */ -#define LINKTYPE_IPFILTER 116 - -#define LINKTYPE_PFLOG 117 /* OpenBSD DLT_PFLOG */ -#define LINKTYPE_CISCO_IOS 118 /* For Cisco-internal use */ -#define LINKTYPE_PRISM_HEADER 119 /* 802.11+Prism II monitor mode */ -#define LINKTYPE_AIRONET_HEADER 120 /* FreeBSD Aironet driver stuff */ - -/* - * Reserved for Siemens HiPath HDLC. - */ -#define LINKTYPE_HHDLC 121 - -#define LINKTYPE_IP_OVER_FC 122 /* RFC 2625 IP-over-Fibre Channel */ -#define LINKTYPE_SUNATM 123 /* Solaris+SunATM */ - -/* - * Reserved as per request from Kent Dahlgren - * for private use. - */ -#define LINKTYPE_RIO 124 /* RapidIO */ -#define LINKTYPE_PCI_EXP 125 /* PCI Express */ -#define LINKTYPE_AURORA 126 /* Xilinx Aurora link layer */ - -#define LINKTYPE_IEEE802_11_RADIO 127 /* 802.11 plus BSD radio header */ - -/* - * Reserved for the TZSP encapsulation, as per request from - * Chris Waters - * TZSP is a generic encapsulation for any other link type, - * which includes a means to include meta-information - * with the packet, e.g. signal strength and channel - * for 802.11 packets. - */ -#define LINKTYPE_TZSP 128 /* Tazmen Sniffer Protocol */ - -#define LINKTYPE_ARCNET_LINUX 129 /* Linux-style headers */ - -/* - * Juniper-private data link types, as per request from - * Hannes Gredler . The corresponding - * DLT_s are used for passing on chassis-internal - * metainformation such as QOS profiles, etc.. - */ -#define LINKTYPE_JUNIPER_MLPPP 130 -#define LINKTYPE_JUNIPER_MLFR 131 -#define LINKTYPE_JUNIPER_ES 132 -#define LINKTYPE_JUNIPER_GGSN 133 -#define LINKTYPE_JUNIPER_MFR 134 -#define LINKTYPE_JUNIPER_ATM2 135 -#define LINKTYPE_JUNIPER_SERVICES 136 -#define LINKTYPE_JUNIPER_ATM1 137 - -#define LINKTYPE_APPLE_IP_OVER_IEEE1394 138 /* Apple IP-over-IEEE 1394 cooked header */ - -#define LINKTYPE_MTP2_WITH_PHDR 139 -#define LINKTYPE_MTP2 140 -#define LINKTYPE_MTP3 141 -#define LINKTYPE_SCCP 142 - -#define LINKTYPE_DOCSIS 143 /* DOCSIS MAC frames */ - -#define LINKTYPE_LINUX_IRDA 144 /* Linux-IrDA */ - -/* - * Reserved for IBM SP switch and IBM Next Federation switch. - */ -#define LINKTYPE_IBM_SP 145 -#define LINKTYPE_IBM_SN 146 - -/* - * Reserved for private use. If you have some link-layer header type - * that you want to use within your organization, with the capture files - * using that link-layer header type not ever be sent outside your - * organization, you can use these values. - * - * No libpcap release will use these for any purpose, nor will any - * tcpdump release use them, either. - * - * Do *NOT* use these in capture files that you expect anybody not using - * your private versions of capture-file-reading tools to read; in - * particular, do *NOT* use them in products, otherwise you may find that - * people won't be able to use tcpdump, or snort, or Ethereal, or... to - * read capture files from your firewall/intrusion detection/traffic - * monitoring/etc. appliance, or whatever product uses that LINKTYPE_ value, - * and you may also find that the developers of those applications will - * not accept patches to let them read those files. - * - * Also, do not use them if somebody might send you a capture using them - * for *their* private type and tools using them for *your* private type - * would have to read them. - * - * Instead, in those cases, ask "tcpdump-workers@lists.tcpdump.org" for a - * new DLT_ and LINKTYPE_ value, as per the comment in pcap/bpf.h, and use - * the type you're given. - */ -#define LINKTYPE_USER0 147 -#define LINKTYPE_USER1 148 -#define LINKTYPE_USER2 149 -#define LINKTYPE_USER3 150 -#define LINKTYPE_USER4 151 -#define LINKTYPE_USER5 152 -#define LINKTYPE_USER6 153 -#define LINKTYPE_USER7 154 -#define LINKTYPE_USER8 155 -#define LINKTYPE_USER9 156 -#define LINKTYPE_USER10 157 -#define LINKTYPE_USER11 158 -#define LINKTYPE_USER12 159 -#define LINKTYPE_USER13 160 -#define LINKTYPE_USER14 161 -#define LINKTYPE_USER15 162 - -/* - * For future use with 802.11 captures - defined by AbsoluteValue - * Systems to store a number of bits of link-layer information - * including radio information: - * - * http://www.shaftnet.org/~pizza/software/capturefrm.txt - * - * but could and arguably should also be used by non-AVS Linux - * 802.11 drivers; that may happen in the future. - */ -#define LINKTYPE_IEEE802_11_RADIO_AVS 163 /* 802.11 plus AVS radio header */ - -/* - * Juniper-private data link type, as per request from - * Hannes Gredler . The corresponding - * DLT_s are used for passing on chassis-internal - * metainformation such as QOS profiles, etc.. - */ -#define LINKTYPE_JUNIPER_MONITOR 164 - -/* - * Reserved for BACnet MS/TP. - */ -#define LINKTYPE_BACNET_MS_TP 165 - -/* - * Another PPP variant as per request from Karsten Keil . - * - * This is used in some OSes to allow a kernel socket filter to distinguish - * between incoming and outgoing packets, on a socket intended to - * supply pppd with outgoing packets so it can do dial-on-demand and - * hangup-on-lack-of-demand; incoming packets are filtered out so they - * don't cause pppd to hold the connection up (you don't want random - * input packets such as port scans, packets from old lost connections, - * etc. to force the connection to stay up). - * - * The first byte of the PPP header (0xff03) is modified to accomodate - * the direction - 0x00 = IN, 0x01 = OUT. - */ -#define LINKTYPE_PPP_PPPD 166 - -/* - * Juniper-private data link type, as per request from - * Hannes Gredler . The DLT_s are used - * for passing on chassis-internal metainformation such as - * QOS profiles, cookies, etc.. - */ -#define LINKTYPE_JUNIPER_PPPOE 167 -#define LINKTYPE_JUNIPER_PPPOE_ATM 168 - -#define LINKTYPE_GPRS_LLC 169 /* GPRS LLC */ -#define LINKTYPE_GPF_T 170 /* GPF-T (ITU-T G.7041/Y.1303) */ -#define LINKTYPE_GPF_F 171 /* GPF-T (ITU-T G.7041/Y.1303) */ - -/* - * Requested by Oolan Zimmer for use in Gcom's T1/E1 line - * monitoring equipment. - */ -#define LINKTYPE_GCOM_T1E1 172 -#define LINKTYPE_GCOM_SERIAL 173 - -/* - * Juniper-private data link type, as per request from - * Hannes Gredler . The DLT_ is used - * for internal communication to Physical Interface Cards (PIC) - */ -#define LINKTYPE_JUNIPER_PIC_PEER 174 - -/* - * Link types requested by Gregor Maier of Endace - * Measurement Systems. They add an ERF header (see - * http://www.endace.com/support/EndaceRecordFormat.pdf) in front of - * the link-layer header. - */ -#define LINKTYPE_ERF_ETH 175 /* Ethernet */ -#define LINKTYPE_ERF_POS 176 /* Packet-over-SONET */ - -/* - * Requested by Daniele Orlandi for raw LAPD - * for vISDN (http://www.orlandi.com/visdn/). Its link-layer header - * includes additional information before the LAPD header, so it's - * not necessarily a generic LAPD header. - */ -#define LINKTYPE_LINUX_LAPD 177 - -/* - * Juniper-private data link type, as per request from - * Hannes Gredler . - * The Link Types are used for prepending meta-information - * like interface index, interface name - * before standard Ethernet, PPP, Frelay & C-HDLC Frames - */ -#define LINKTYPE_JUNIPER_ETHER 178 -#define LINKTYPE_JUNIPER_PPP 179 -#define LINKTYPE_JUNIPER_FRELAY 180 -#define LINKTYPE_JUNIPER_CHDLC 181 - -/* - * Multi Link Frame Relay (FRF.16) - */ -#define LINKTYPE_MFR 182 - -/* - * Juniper-private data link type, as per request from - * Hannes Gredler . - * The DLT_ is used for internal communication with a - * voice Adapter Card (PIC) - */ -#define LINKTYPE_JUNIPER_VP 183 - -/* - * Arinc 429 frames. - * DLT_ requested by Gianluca Varenni . - * Every frame contains a 32bit A429 label. - * More documentation on Arinc 429 can be found at - * http://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf - */ -#define LINKTYPE_A429 184 - -/* - * Arinc 653 Interpartition Communication messages. - * DLT_ requested by Gianluca Varenni . - * Please refer to the A653-1 standard for more information. - */ -#define LINKTYPE_A653_ICM 185 - -/* - * USB packets, beginning with a USB setup header; requested by - * Paolo Abeni . - */ -#define LINKTYPE_USB 186 - -/* - * Bluetooth HCI UART transport layer (part H:4); requested by - * Paolo Abeni. - */ -#define LINKTYPE_BLUETOOTH_HCI_H4 187 - -/* - * IEEE 802.16 MAC Common Part Sublayer; requested by Maria Cruz - * . - */ -#define LINKTYPE_IEEE802_16_MAC_CPS 188 - -/* - * USB packets, beginning with a Linux USB header; requested by - * Paolo Abeni . - */ -#define LINKTYPE_USB_LINUX 189 - -/* - * Controller Area Network (CAN) v. 2.0B packets. - * DLT_ requested by Gianluca Varenni . - * Used to dump CAN packets coming from a CAN Vector board. - * More documentation on the CAN v2.0B frames can be found at - * http://www.can-cia.org/downloads/?269 - */ -#define LINKTYPE_CAN20B 190 - -/* - * IEEE 802.15.4, with address fields padded, as is done by Linux - * drivers; requested by Juergen Schimmer. - */ -#define LINKTYPE_IEEE802_15_4_LINUX 191 - -/* - * Per Packet Information encapsulated packets. - * LINKTYPE_ requested by Gianluca Varenni . - */ -#define LINKTYPE_PPI 192 - -/* - * Header for 802.16 MAC Common Part Sublayer plus a radiotap radio header; - * requested by Charles Clancy. - */ -#define LINKTYPE_IEEE802_16_MAC_CPS_RADIO 193 - -/* - * Juniper-private data link type, as per request from - * Hannes Gredler . - * The DLT_ is used for internal communication with a - * integrated service module (ISM). - */ -#define LINKTYPE_JUNIPER_ISM 194 - -/* - * IEEE 802.15.4, exactly as it appears in the spec (no padding, no - * nothing); requested by Mikko Saarnivala . - */ -#define LINKTYPE_IEEE802_15_4 195 - -/* - * Various link-layer types, with a pseudo-header, for SITA - * (http://www.sita.aero/); requested by Fulko Hew (fulko.hew@gmail.com). - */ -#define LINKTYPE_SITA 196 - -/* - * Various link-layer types, with a pseudo-header, for Endace DAG cards; - * encapsulates Endace ERF records. Requested by Stephen Donnelly - * . - */ -#define LINKTYPE_ERF 197 - -/* - * Special header prepended to Ethernet packets when capturing from a - * u10 Networks board. Requested by Phil Mulholland - * . - */ -#define LINKTYPE_RAIF1 198 - -/* - * IPMB packet for IPMI, beginning with the I2C slave address, followed - * by the netFn and LUN, etc.. Requested by Chanthy Toeung - * . - */ -#define LINKTYPE_IPMB 199 - -/* - * Juniper-private data link type, as per request from - * Hannes Gredler . - * The DLT_ is used for capturing data on a secure tunnel interface. - */ -#define LINKTYPE_JUNIPER_ST 200 - -/* - * Bluetooth HCI UART transport layer (part H:4), with pseudo-header - * that includes direction information; requested by Paolo Abeni. - */ -#define LINKTYPE_BLUETOOTH_HCI_H4_WITH_PHDR 201 - -/* - * AX.25 packet with a 1-byte KISS header; see - * - * http://www.ax25.net/kiss.htm - * - * as per Richard Stearn . - */ -#define LINKTYPE_AX25_KISS 202 - -/* - * LAPD packets from an ISDN channel, starting with the address field, - * with no pseudo-header. - * Requested by Varuna De Silva . - */ -#define LINKTYPE_LAPD 203 - -/* - * Variants of various link-layer headers, with a one-byte direction - * pseudo-header prepended - zero means "received by this host", - * non-zero (any non-zero value) means "sent by this host" - as per - * Will Barker . - */ -#define LINKTYPE_PPP_WITH_DIR 204 /* PPP */ -#define LINKTYPE_C_HDLC_WITH_DIR 205 /* Cisco HDLC */ -#define LINKTYPE_FRELAY_WITH_DIR 206 /* Frame Relay */ -#define LINKTYPE_LAPB_WITH_DIR 207 /* LAPB */ - -/* - * 208 is reserved for an as-yet-unspecified proprietary link-layer - * type, as requested by Will Barker. - */ - -/* - * IPMB with a Linux-specific pseudo-header; as requested by Alexey Neyman - * . - */ -#define LINKTYPE_IPMB_LINUX 209 - -/* - * FlexRay automotive bus - http://www.flexray.com/ - as requested - * by Hannes Kaelber . - */ -#define LINKTYPE_FLEXRAY 210 - -/* - * Media Oriented Systems Transport (MOST) bus for multimedia - * transport - http://www.mostcooperation.com/ - as requested - * by Hannes Kaelber . - */ -#define LINKTYPE_MOST 211 - -/* - * Local Interconnect Network (LIN) bus for vehicle networks - - * http://www.lin-subbus.org/ - as requested by Hannes Kaelber - * . - */ -#define LINKTYPE_LIN 212 - -/* - * X2E-private data link type used for serial line capture, - * as requested by Hannes Kaelber . - */ -#define LINKTYPE_X2E_SERIAL 213 - -/* - * X2E-private data link type used for the Xoraya data logger - * family, as requested by Hannes Kaelber . - */ -#define LINKTYPE_X2E_XORAYA 214 - -/* - * IEEE 802.15.4, exactly as it appears in the spec (no padding, no - * nothing), but with the PHY-level data for non-ASK PHYs (4 octets - * of 0 as preamble, one octet of SFD, one octet of frame length+ - * reserved bit, and then the MAC-layer data, starting with the - * frame control field). - * - * Requested by Max Filippov . - */ -#define LINKTYPE_IEEE802_15_4_NONASK_PHY 215 - - -static struct linktype_map { - int dlt; - int linktype; -} map[] = { - /* - * These DLT_* codes have LINKTYPE_* codes with values identical - * to the values of the corresponding DLT_* code. - */ - { DLT_NULL, LINKTYPE_NULL }, - { DLT_EN10MB, LINKTYPE_ETHERNET }, - { DLT_EN3MB, LINKTYPE_EXP_ETHERNET }, - { DLT_AX25, LINKTYPE_AX25 }, - { DLT_PRONET, LINKTYPE_PRONET }, - { DLT_CHAOS, LINKTYPE_CHAOS }, - { DLT_IEEE802, LINKTYPE_TOKEN_RING }, - { DLT_ARCNET, LINKTYPE_ARCNET }, - { DLT_SLIP, LINKTYPE_SLIP }, - { DLT_PPP, LINKTYPE_PPP }, - { DLT_FDDI, LINKTYPE_FDDI }, - - /* - * These DLT_* codes have different values on different - * platforms; we map them to LINKTYPE_* codes that - * have values that should never be equal to any DLT_* - * code. - */ -#ifdef DLT_FR - /* BSD/OS Frame Relay */ - { DLT_FR, LINKTYPE_FRELAY }, -#endif - - { DLT_SYMANTEC_FIREWALL, LINKTYPE_SYMANTEC_FIREWALL }, - { DLT_ATM_RFC1483, LINKTYPE_ATM_RFC1483 }, - { DLT_RAW, LINKTYPE_RAW }, - { DLT_SLIP_BSDOS, LINKTYPE_SLIP_BSDOS }, - { DLT_PPP_BSDOS, LINKTYPE_PPP_BSDOS }, - - /* BSD/OS Cisco HDLC */ - { DLT_C_HDLC, LINKTYPE_C_HDLC }, - - /* - * These DLT_* codes are not on all platforms, but, so far, - * there don't appear to be any platforms that define - * other codes with those values; we map them to - * different LINKTYPE_* values anyway, just in case. - */ - - /* Linux ATM Classical IP */ - { DLT_ATM_CLIP, LINKTYPE_ATM_CLIP }, - - /* NetBSD sync/async serial PPP (or Cisco HDLC) */ - { DLT_PPP_SERIAL, LINKTYPE_PPP_HDLC }, - - /* NetBSD PPP over Ethernet */ - { DLT_PPP_ETHER, LINKTYPE_PPP_ETHER }, - - /* IEEE 802.11 wireless */ - { DLT_IEEE802_11, LINKTYPE_IEEE802_11 }, - - /* Frame Relay */ - { DLT_FRELAY, LINKTYPE_FRELAY }, - - /* OpenBSD loopback */ - { DLT_LOOP, LINKTYPE_LOOP }, - - /* Linux cooked socket capture */ - { DLT_LINUX_SLL, LINKTYPE_LINUX_SLL }, - - /* Apple LocalTalk hardware */ - { DLT_LTALK, LINKTYPE_LTALK }, - - /* Acorn Econet */ - { DLT_ECONET, LINKTYPE_ECONET }, - - /* OpenBSD DLT_PFLOG */ - { DLT_PFLOG, LINKTYPE_PFLOG }, - - /* For Cisco-internal use */ - { DLT_CISCO_IOS, LINKTYPE_CISCO_IOS }, - - /* Prism II monitor-mode header plus 802.11 header */ - { DLT_PRISM_HEADER, LINKTYPE_PRISM_HEADER }, - - /* FreeBSD Aironet driver stuff */ - { DLT_AIRONET_HEADER, LINKTYPE_AIRONET_HEADER }, - - /* Siemens HiPath HDLC */ - { DLT_HHDLC, LINKTYPE_HHDLC }, - - /* RFC 2625 IP-over-Fibre Channel */ - { DLT_IP_OVER_FC, LINKTYPE_IP_OVER_FC }, - - /* Solaris+SunATM */ - { DLT_SUNATM, LINKTYPE_SUNATM }, - - /* RapidIO */ - { DLT_RIO, LINKTYPE_RIO }, - - /* PCI Express */ - { DLT_PCI_EXP, LINKTYPE_PCI_EXP }, - - /* Xilinx Aurora link layer */ - { DLT_AURORA, LINKTYPE_AURORA }, - - /* 802.11 plus BSD radio header */ - { DLT_IEEE802_11_RADIO, LINKTYPE_IEEE802_11_RADIO }, - - /* Tazmen Sniffer Protocol */ - { DLT_TZSP, LINKTYPE_TZSP }, - - /* Arcnet with Linux-style link-layer headers */ - { DLT_ARCNET_LINUX, LINKTYPE_ARCNET_LINUX }, - - /* Juniper-internal chassis encapsulation */ - { DLT_JUNIPER_MLPPP, LINKTYPE_JUNIPER_MLPPP }, - { DLT_JUNIPER_MLFR, LINKTYPE_JUNIPER_MLFR }, - { DLT_JUNIPER_ES, LINKTYPE_JUNIPER_ES }, - { DLT_JUNIPER_GGSN, LINKTYPE_JUNIPER_GGSN }, - { DLT_JUNIPER_MFR, LINKTYPE_JUNIPER_MFR }, - { DLT_JUNIPER_ATM2, LINKTYPE_JUNIPER_ATM2 }, - { DLT_JUNIPER_SERVICES, LINKTYPE_JUNIPER_SERVICES }, - { DLT_JUNIPER_ATM1, LINKTYPE_JUNIPER_ATM1 }, - - /* Apple IP-over-IEEE 1394 cooked header */ - { DLT_APPLE_IP_OVER_IEEE1394, LINKTYPE_APPLE_IP_OVER_IEEE1394 }, - - /* SS7 */ - { DLT_MTP2_WITH_PHDR, LINKTYPE_MTP2_WITH_PHDR }, - { DLT_MTP2, LINKTYPE_MTP2 }, - { DLT_MTP3, LINKTYPE_MTP3 }, - { DLT_SCCP, LINKTYPE_SCCP }, - - /* DOCSIS MAC frames */ - { DLT_DOCSIS, LINKTYPE_DOCSIS }, - - /* IrDA IrLAP packets + Linux-cooked header */ - { DLT_LINUX_IRDA, LINKTYPE_LINUX_IRDA }, - - /* IBM SP and Next Federation switches */ - { DLT_IBM_SP, LINKTYPE_IBM_SP }, - { DLT_IBM_SN, LINKTYPE_IBM_SN }, - - /* 802.11 plus AVS radio header */ - { DLT_IEEE802_11_RADIO_AVS, LINKTYPE_IEEE802_11_RADIO_AVS }, - - /* - * Any platform that defines additional DLT_* codes should: - * - * request a LINKTYPE_* code and value from tcpdump.org, - * as per the above; - * - * add, in their version of libpcap, an entry to map - * those DLT_* codes to the corresponding LINKTYPE_* - * code; - * - * redefine, in their "net/bpf.h", any DLT_* values - * that collide with the values used by their additional - * DLT_* codes, to remove those collisions (but without - * making them collide with any of the LINKTYPE_* - * values equal to 50 or above; they should also avoid - * defining DLT_* values that collide with those - * LINKTYPE_* values, either). - */ - - /* Juniper-internal chassis encapsulation */ - { DLT_JUNIPER_MONITOR, LINKTYPE_JUNIPER_MONITOR }, - - /* BACnet MS/TP */ - { DLT_BACNET_MS_TP, LINKTYPE_BACNET_MS_TP }, - - /* PPP for pppd, with direction flag in the PPP header */ - { DLT_PPP_PPPD, LINKTYPE_PPP_PPPD}, - - /* Juniper-internal chassis encapsulation */ - { DLT_JUNIPER_PPPOE, LINKTYPE_JUNIPER_PPPOE }, - { DLT_JUNIPER_PPPOE_ATM,LINKTYPE_JUNIPER_PPPOE_ATM }, - - /* GPRS LLC */ - { DLT_GPRS_LLC, LINKTYPE_GPRS_LLC }, - - /* Transparent Generic Framing Procedure (ITU-T G.7041/Y.1303) */ - { DLT_GPF_T, LINKTYPE_GPF_T }, - - /* Framed Generic Framing Procedure (ITU-T G.7041/Y.1303) */ - { DLT_GPF_F, LINKTYPE_GPF_F }, - - { DLT_GCOM_T1E1, LINKTYPE_GCOM_T1E1 }, - { DLT_GCOM_SERIAL, LINKTYPE_GCOM_SERIAL }, - - /* Juniper-internal chassis encapsulation */ - { DLT_JUNIPER_PIC_PEER, LINKTYPE_JUNIPER_PIC_PEER }, - - /* Endace types */ - { DLT_ERF_ETH, LINKTYPE_ERF_ETH }, - { DLT_ERF_POS, LINKTYPE_ERF_POS }, - - /* viSDN LAPD */ - { DLT_LINUX_LAPD, LINKTYPE_LINUX_LAPD }, - - /* Juniper meta-information before Ether, PPP, Frame Relay, C-HDLC Frames */ - { DLT_JUNIPER_ETHER, LINKTYPE_JUNIPER_ETHER }, - { DLT_JUNIPER_PPP, LINKTYPE_JUNIPER_PPP }, - { DLT_JUNIPER_FRELAY, LINKTYPE_JUNIPER_FRELAY }, - { DLT_JUNIPER_CHDLC, LINKTYPE_JUNIPER_CHDLC }, - - /* Multi Link Frame Relay (FRF.16) */ - { DLT_MFR, LINKTYPE_MFR }, - - /* Juniper Voice PIC */ - { DLT_JUNIPER_VP, LINKTYPE_JUNIPER_VP }, - - /* Controller Area Network (CAN) v2.0B */ - { DLT_A429, LINKTYPE_A429 }, - - /* Arinc 653 Interpartition Communication messages */ - { DLT_A653_ICM, LINKTYPE_A653_ICM }, - - /* USB */ - { DLT_USB, LINKTYPE_USB }, - - /* Bluetooth HCI UART transport layer */ - { DLT_BLUETOOTH_HCI_H4, LINKTYPE_BLUETOOTH_HCI_H4 }, - - /* IEEE 802.16 MAC Common Part Sublayer */ - { DLT_IEEE802_16_MAC_CPS, LINKTYPE_IEEE802_16_MAC_CPS }, - - /* USB with Linux header */ - { DLT_USB_LINUX, LINKTYPE_USB_LINUX }, - - /* Controller Area Network (CAN) v2.0B */ - { DLT_CAN20B, LINKTYPE_CAN20B }, - - /* IEEE 802.15.4 with address fields padded */ - { DLT_IEEE802_15_4_LINUX, LINKTYPE_IEEE802_15_4_LINUX }, - - /* Per Packet Information encapsulated packets */ - { DLT_PPI, LINKTYPE_PPI }, - - /* IEEE 802.16 MAC Common Part Sublayer plus radiotap header */ - { DLT_IEEE802_16_MAC_CPS_RADIO, LINKTYPE_IEEE802_16_MAC_CPS_RADIO }, - - /* Juniper Voice ISM */ - { DLT_JUNIPER_ISM, LINKTYPE_JUNIPER_ISM }, - - /* IEEE 802.15.4 exactly as it appears in the spec */ - { DLT_IEEE802_15_4, LINKTYPE_IEEE802_15_4 }, - - /* Various link-layer types for SITA */ - { DLT_SITA, LINKTYPE_SITA }, - - /* Various link-layer types for Endace */ - { DLT_ERF, LINKTYPE_ERF }, - - /* Special header for u10 Networks boards */ - { DLT_RAIF1, LINKTYPE_RAIF1 }, - - /* IPMB */ - { DLT_IPMB, LINKTYPE_IPMB }, - - /* Juniper Secure Tunnel */ - { DLT_JUNIPER_ST, LINKTYPE_JUNIPER_ST }, - - /* Bluetooth HCI UART transport layer, with pseudo-header */ - { DLT_BLUETOOTH_HCI_H4_WITH_PHDR, LINKTYPE_BLUETOOTH_HCI_H4_WITH_PHDR }, - - /* AX.25 with KISS header */ - { DLT_AX25_KISS, LINKTYPE_AX25_KISS }, - - /* Raw LAPD, with no pseudo-header */ - { DLT_LAPD, LINKTYPE_LAPD }, - - /* PPP with one-byte pseudo-header giving direction */ - { DLT_PPP_WITH_DIR, LINKTYPE_PPP_WITH_DIR }, - - /* Cisco HDLC with one-byte pseudo-header giving direction */ - { DLT_C_HDLC_WITH_DIR, LINKTYPE_C_HDLC_WITH_DIR }, - - /* Frame Relay with one-byte pseudo-header giving direction */ - { DLT_FRELAY_WITH_DIR, LINKTYPE_FRELAY_WITH_DIR }, - - /* LAPB with one-byte pseudo-header giving direction */ - { DLT_LAPB_WITH_DIR, LINKTYPE_LAPB_WITH_DIR }, - - /* IPMB with Linux pseudo-header */ - { DLT_IPMB_LINUX, LINKTYPE_IPMB_LINUX }, - - /* FlexRay */ - { DLT_FLEXRAY, LINKTYPE_FLEXRAY }, - - /* MOST */ - { DLT_MOST, LINKTYPE_MOST }, - - /* LIN */ - { DLT_LIN, LINKTYPE_LIN }, - - /* X2E-private serial line capture */ - { DLT_X2E_SERIAL, LINKTYPE_X2E_SERIAL }, - - /* X2E-private for Xoraya data logger family */ - { DLT_X2E_XORAYA, LINKTYPE_X2E_XORAYA }, - - /* IEEE 802.15.4 with PHY data for non-ASK PHYs */ - { DLT_IEEE802_15_4_NONASK_PHY, LINKTYPE_IEEE802_15_4_NONASK_PHY }, - - { -1, -1 } -}; - -/* - * Mechanism for storing information about a capture in the upper - * 6 bits of a linktype value in a capture file. - * - * LT_LINKTYPE_EXT(x) extracts the additional information. - * - * The rest of the bits are for a value describing the link-layer - * value. LT_LINKTYPE(x) extracts that value. - */ -#define LT_LINKTYPE(x) ((x) & 0x03FFFFFF) -#define LT_LINKTYPE_EXT(x) ((x) & 0xFC000000) - -static int -dlt_to_linktype(int dlt) -{ - int i; - - for (i = 0; map[i].dlt != -1; i++) { - if (map[i].dlt == dlt) - return (map[i].linktype); - } - - /* - * If we don't have a mapping for this DLT_ code, return an - * error; that means that the table above needs to have an - * entry added. - */ - return (-1); -} - -static int -linktype_to_dlt(int linktype) -{ - int i; - - for (i = 0; map[i].linktype != -1; i++) { - if (map[i].linktype == linktype) - return (map[i].dlt); - } - - /* - * If we don't have an entry for this link type, return - * the link type value; it may be a DLT_ value from an - * older version of libpcap. - */ - return linktype; -} - -static int -sf_write_header(FILE *fp, int linktype, int thiszone, int snaplen) -{ - struct pcap_file_header hdr; - - hdr.magic = TCPDUMP_MAGIC; - hdr.version_major = PCAP_VERSION_MAJOR; - hdr.version_minor = PCAP_VERSION_MINOR; - - hdr.thiszone = thiszone; - hdr.snaplen = snaplen; - hdr.sigfigs = 0; - hdr.linktype = linktype; - - if (fwrite((char *)&hdr, sizeof(hdr), 1, fp) != 1) - return (-1); - - return (0); -} - -static void -swap_hdr(struct pcap_file_header *hp) -{ - hp->version_major = SWAPSHORT(hp->version_major); - hp->version_minor = SWAPSHORT(hp->version_minor); - hp->thiszone = SWAPLONG(hp->thiszone); - hp->sigfigs = SWAPLONG(hp->sigfigs); - hp->snaplen = SWAPLONG(hp->snaplen); - hp->linktype = SWAPLONG(hp->linktype); -} - static int sf_getnonblock(pcap_t *p, char *errbuf) { @@ -1113,8 +159,8 @@ sf_cleanup(pcap_t *p) { if (p->sf.rfile != stdin) (void)fclose(p->sf.rfile); - if (p->sf.base != NULL) - free(p->sf.base); + if (p->buffer != NULL) + free(p->buffer); } pcap_t * @@ -1178,6 +224,13 @@ pcap_t* pcap_hopen_offline(intptr_t osfd, char *errbuf) } #endif +static int (*check_headers[])(pcap_t *, bpf_u_int32, FILE *, char *) = { + pcap_check_header, + pcap_ng_check_header +}; + +#define N_FILE_TYPES (sizeof check_headers / sizeof check_headers[0]) + #ifdef WIN32 static #endif @@ -1185,21 +238,23 @@ pcap_t * pcap_fopen_offline(FILE *fp, char *errbuf) { register pcap_t *p; - struct pcap_file_header hdr; - size_t amt_read; bpf_u_int32 magic; - int linklen; + size_t amt_read; + u_int i; - p = (pcap_t *)malloc(sizeof(*p)); - if (p == NULL) { - strlcpy(errbuf, "out of swap", PCAP_ERRBUF_SIZE); + p = pcap_create_common("(savefile)", errbuf); + if (p == NULL) return (NULL); - } - memset((char *)p, 0, sizeof(*p)); - - amt_read = fread((char *)&hdr, 1, sizeof(hdr), fp); - if (amt_read != sizeof(hdr)) { + /* + * Read the first 4 bytes of the file; the network analyzer dump + * file formats we support (pcap and pcap-ng), and several other + * formats we might support in the future (such as snoop, DOS and + * Windows Sniffer, and Microsoft Network Monitor) all have magic + * numbers that are unique in their first 4 bytes. + */ + amt_read = fread((char *)&magic, 1, sizeof(magic), fp); + if (amt_read != sizeof(magic)) { if (ferror(fp)) { snprintf(errbuf, PCAP_ERRBUF_SIZE, "error reading dump file: %s", @@ -1207,144 +262,46 @@ pcap_fopen_offline(FILE *fp, char *errbuf) } else { snprintf(errbuf, PCAP_ERRBUF_SIZE, "truncated dump file; tried to read %lu file header bytes, only got %lu", - (unsigned long)sizeof(hdr), + (unsigned long)sizeof(magic), (unsigned long)amt_read); } goto bad; } - magic = hdr.magic; - if (magic != TCPDUMP_MAGIC && magic != KUZNETZOV_TCPDUMP_MAGIC) { - magic = SWAPLONG(magic); - if (magic != TCPDUMP_MAGIC && magic != KUZNETZOV_TCPDUMP_MAGIC) { - snprintf(errbuf, PCAP_ERRBUF_SIZE, - "bad dump file format"); + + /* + * Try all file types. + */ + for (i = 0; i < N_FILE_TYPES; i++) { + switch ((*check_headers[i])(p, magic, fp, errbuf)) { + + case -1: + /* + * Error trying to read the header. + */ goto bad; + + case 1: + /* + * Yup, that's it. + */ + goto found; } - p->sf.swapped = 1; - swap_hdr(&hdr); - } - if (magic == KUZNETZOV_TCPDUMP_MAGIC) { - /* - * XXX - the patch that's in some versions of libpcap - * changes the packet header but not the magic number, - * and some other versions with this magic number have - * some extra debugging information in the packet header; - * we'd have to use some hacks^H^H^H^H^Hheuristics to - * detect those variants. - * - * Ethereal does that, but it does so by trying to read - * the first two packets of the file with each of the - * record header formats. That currently means it seeks - * backwards and retries the reads, which doesn't work - * on pipes. We want to be able to read from a pipe, so - * that strategy won't work; we'd have to buffer some - * data ourselves and read from that buffer in order to - * make that work. - */ - p->sf.hdrsize = sizeof(struct pcap_sf_patched_pkthdr); - } else - p->sf.hdrsize = sizeof(struct pcap_sf_pkthdr); - if (hdr.version_major < PCAP_VERSION_MAJOR) { - snprintf(errbuf, PCAP_ERRBUF_SIZE, "archaic file format"); - goto bad; - } - p->tzoff = hdr.thiszone; - p->snapshot = hdr.snaplen; - p->linktype = linktype_to_dlt(LT_LINKTYPE(hdr.linktype)); - p->linktype_ext = LT_LINKTYPE_EXT(hdr.linktype); - if (magic == KUZNETZOV_TCPDUMP_MAGIC && p->linktype == DLT_EN10MB) { - /* - * This capture might have been done in raw mode or cooked - * mode. - * - * If it was done in cooked mode, p->snapshot was passed - * to recvfrom() as the buffer size, meaning that the - * most packet data that would be copied would be - * p->snapshot. However, a faked Ethernet header would - * then have been added to it, so the most data that would - * be in a packet in the file would be p->snapshot + 14. - * - * We can't easily tell whether the capture was done in - * raw mode or cooked mode, so we'll assume it was - * cooked mode, and add 14 to the snapshot length. That - * means that, for a raw capture, the snapshot length will - * be misleading if you use it to figure out why a capture - * doesn't have all the packet data, but there's not much - * we can do to avoid that. - */ - p->snapshot += 14; } + + /* + * Well, who knows what this mess is.... + */ + snprintf(errbuf, PCAP_ERRBUF_SIZE, "unknown file format"); + goto bad; + +found: p->sf.rfile = fp; -#ifndef WIN32 - p->bufsize = hdr.snaplen; -#else - /* Allocate the space for pcap_pkthdr as well. It will be used by pcap_read_ex */ - p->bufsize = hdr.snaplen+sizeof(struct pcap_pkthdr); -#endif - /* Align link header as required for proper data alignment */ - /* XXX should handle all types */ - switch (p->linktype) { - - case DLT_EN10MB: - linklen = 14; - break; - - case DLT_FDDI: - linklen = 13 + 8; /* fddi_header + llc */ - break; - - case DLT_NULL: - default: - linklen = 0; - break; - } - - if (p->bufsize < 0) - p->bufsize = BPF_MAXBUFSIZE; - p->sf.base = (u_char *)malloc(p->bufsize + BPF_ALIGNMENT); - if (p->sf.base == NULL) { - strlcpy(errbuf, "out of swap", PCAP_ERRBUF_SIZE); - goto bad; - } - p->buffer = p->sf.base + BPF_ALIGNMENT - (linklen % BPF_ALIGNMENT); - p->sf.version_major = hdr.version_major; - p->sf.version_minor = hdr.version_minor; #ifdef PCAP_FDDIPAD /* Padding only needed for live capture fcode */ p->fddipad = 0; #endif - /* - * We interchanged the caplen and len fields at version 2.3, - * in order to match the bpf header layout. But unfortunately - * some files were written with version 2.3 in their headers - * but without the interchanged fields. - * - * In addition, DG/UX tcpdump writes out files with a version - * number of 543.0, and with the caplen and len fields in the - * pre-2.3 order. - */ - switch (hdr.version_major) { - - case 2: - if (hdr.version_minor < 3) - p->sf.lengths_swapped = SWAPPED; - else if (hdr.version_minor == 3) - p->sf.lengths_swapped = MAYBE_SWAPPED; - else - p->sf.lengths_swapped = NOT_SWAPPED; - break; - - case 543: - p->sf.lengths_swapped = SWAPPED; - break; - - default: - p->sf.lengths_swapped = NOT_SWAPPED; - break; - } - #if !defined(WIN32) && !defined(MSDOS) /* * You can do "select()" and "poll()" on plain files on most @@ -1379,190 +336,8 @@ pcap_fopen_offline(FILE *fp, char *errbuf) } /* - * Read sf_readfile and return the next packet. Return the header in hdr - * and the contents in buf. Return 0 on success, SFERR_EOF if there were - * no more packets, and SFERR_TRUNC if a partial packet was encountered. - */ -static int -sf_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char *buf, u_int buflen) -{ - struct pcap_sf_patched_pkthdr sf_hdr; - FILE *fp = p->sf.rfile; - size_t amt_read; - bpf_u_int32 t; - - /* - * Read the packet header; the structure we use as a buffer - * is the longer structure for files generated by the patched - * libpcap, but if the file has the magic number for an - * unpatched libpcap we only read as many bytes as the regular - * header has. - */ - amt_read = fread(&sf_hdr, 1, p->sf.hdrsize, fp); - if (amt_read != p->sf.hdrsize) { - if (ferror(fp)) { - snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "error reading dump file: %s", - pcap_strerror(errno)); - return (-1); - } else { - if (amt_read != 0) { - snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "truncated dump file; tried to read %lu header bytes, only got %lu", - (unsigned long)p->sf.hdrsize, - (unsigned long)amt_read); - return (-1); - } - /* EOF */ - return (1); - } - } - - if (p->sf.swapped) { - /* these were written in opposite byte order */ - hdr->caplen = SWAPLONG(sf_hdr.caplen); - hdr->len = SWAPLONG(sf_hdr.len); - hdr->ts.tv_sec = SWAPLONG(sf_hdr.ts.tv_sec); - hdr->ts.tv_usec = SWAPLONG(sf_hdr.ts.tv_usec); - } else { - hdr->caplen = sf_hdr.caplen; - hdr->len = sf_hdr.len; - hdr->ts.tv_sec = sf_hdr.ts.tv_sec; - hdr->ts.tv_usec = sf_hdr.ts.tv_usec; - } - /* Swap the caplen and len fields, if necessary. */ - switch (p->sf.lengths_swapped) { - - case NOT_SWAPPED: - break; - - case MAYBE_SWAPPED: - if (hdr->caplen <= hdr->len) { - /* - * The captured length is <= the actual length, - * so presumably they weren't swapped. - */ - break; - } - /* FALLTHROUGH */ - - case SWAPPED: - t = hdr->caplen; - hdr->caplen = hdr->len; - hdr->len = t; - break; - } - - if (hdr->caplen > buflen) { - /* - * This can happen due to Solaris 2.3 systems tripping - * over the BUFMOD problem and not setting the snapshot - * correctly in the savefile header. If the caplen isn't - * grossly wrong, try to salvage. - */ - static u_char *tp = NULL; - static size_t tsize = 0; - - if (hdr->caplen > 65535) { - snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "bogus savefile header"); - return (-1); - } - - if (tsize < hdr->caplen) { - tsize = ((hdr->caplen + 1023) / 1024) * 1024; - if (tp != NULL) - free((u_char *)tp); - tp = (u_char *)malloc(tsize); - if (tp == NULL) { - tsize = 0; - snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "BUFMOD hack malloc"); - return (-1); - } - } - amt_read = fread((char *)tp, 1, hdr->caplen, fp); - if (amt_read != hdr->caplen) { - if (ferror(fp)) { - snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "error reading dump file: %s", - pcap_strerror(errno)); - } else { - snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "truncated dump file; tried to read %u captured bytes, only got %lu", - hdr->caplen, (unsigned long)amt_read); - } - return (-1); - } - /* - * We can only keep up to buflen bytes. Since caplen > buflen - * is exactly how we got here, we know we can only keep the - * first buflen bytes and must drop the remainder. Adjust - * caplen accordingly, so we don't get confused later as - * to how many bytes we have to play with. - */ - hdr->caplen = buflen; - memcpy((char *)buf, (char *)tp, buflen); - - } else { - /* read the packet itself */ - amt_read = fread((char *)buf, 1, hdr->caplen, fp); - if (amt_read != hdr->caplen) { - if (ferror(fp)) { - snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "error reading dump file: %s", - pcap_strerror(errno)); - } else { - snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "truncated dump file; tried to read %u captured bytes, only got %lu", - hdr->caplen, (unsigned long)amt_read); - } - return (-1); - } - } - - /* - * The DLT_USB_LINUX header is in host byte order when capturing - * (it's supplied directly from a memory-mapped buffer shared - * by the kernel). - * - * When reading a DLT_USB_LINUX capture file, we need to convert - * it from the capturing host's byte order to the reading host's - * byte order. - */ - if (p->sf.swapped && p->linktype == DLT_USB_LINUX) { - pcap_usb_header* uhdr = (pcap_usb_header*) buf; - /* - * The URB id is a totally opaque value; do we really need to - * converte it to the reading host's byte order??? - */ - if (hdr->caplen < 8) - return 0; - uhdr->id = SWAPLL(uhdr->id); - if (hdr->caplen < 14) - return 0; - uhdr->bus_id = SWAPSHORT(uhdr->bus_id); - if (hdr->caplen < 24) - return 0; - uhdr->ts_sec = SWAPLL(uhdr->ts_sec); - if (hdr->caplen < 28) - return 0; - uhdr->ts_usec = SWAPLONG(uhdr->ts_usec); - if (hdr->caplen < 32) - return 0; - uhdr->status = SWAPLONG(uhdr->status); - if (hdr->caplen < 36) - return 0; - uhdr->urb_len = SWAPLONG(uhdr->urb_len); - if (hdr->caplen < 40) - return 0; - uhdr->data_len = SWAPLONG(uhdr->data_len); - } - return (0); -} - -/* - * Print out packets stored in the file initialized by sf_read_init(). + * Read packets from a capture file, and call the callback for each + * packet. * If cnt > 0, return after 'cnt' packets, otherwise continue until eof. */ int @@ -1571,6 +346,7 @@ pcap_offline_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user) struct bpf_insn *fcode; int status = 0; int n = 0; + u_char *data; while (status == 0) { struct pcap_pkthdr h; @@ -1592,7 +368,7 @@ pcap_offline_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user) return (n); } - status = sf_next_packet(p, &h, p->buffer, p->bufsize); + status = p->sf.next_packet_op(p, &h, &data); if (status) { if (status == 1) return (0); @@ -1601,7 +377,7 @@ pcap_offline_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user) if ((fcode = p->fcode.bf_insns) == NULL || bpf_filter(fcode, p->buffer, h.len, h.caplen)) { - (*callback)(user, &h, p->buffer); + (*callback)(user, &h, data); if (++n >= cnt && cnt > 0) break; } @@ -1609,139 +385,3 @@ pcap_offline_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user) /*XXX this breaks semantics tcpslice expects */ return (n); } - -/* - * Output a packet to the initialized dump file. - */ -void -pcap_dump(u_char *user, const struct pcap_pkthdr *h, const u_char *sp) -{ - register FILE *f; - struct pcap_sf_pkthdr sf_hdr; - - f = (FILE *)user; - sf_hdr.ts.tv_sec = h->ts.tv_sec; - sf_hdr.ts.tv_usec = h->ts.tv_usec; - sf_hdr.caplen = h->caplen; - sf_hdr.len = h->len; - /* XXX we should check the return status */ - (void)fwrite(&sf_hdr, sizeof(sf_hdr), 1, f); - (void)fwrite(sp, h->caplen, 1, f); -} - -static pcap_dumper_t * -pcap_setup_dump(pcap_t *p, int linktype, FILE *f, const char *fname) -{ - -#if defined(WIN32) || defined(MSDOS) - /* - * If we're writing to the standard output, put it in binary - * mode, as savefiles are binary files. - * - * Otherwise, we turn off buffering. - * XXX - why? And why not on the standard output? - */ - if (f == stdout) - SET_BINMODE(f); - else - setbuf(f, NULL); -#endif - if (sf_write_header(f, linktype, p->tzoff, p->snapshot) == -1) { - snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Can't write to %s: %s", - fname, pcap_strerror(errno)); - if (f != stdout) - (void)fclose(f); - return (NULL); - } - return ((pcap_dumper_t *)f); -} - -/* - * Initialize so that sf_write() will output to the file named 'fname'. - */ -pcap_dumper_t * -pcap_dump_open(pcap_t *p, const char *fname) -{ - FILE *f; - int linktype; - - linktype = dlt_to_linktype(p->linktype); - if (linktype == -1) { - snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "%s: link-layer type %d isn't supported in savefiles", - fname, linktype); - return (NULL); - } - linktype |= p->linktype_ext; - - if (fname[0] == '-' && fname[1] == '\0') { - f = stdout; - fname = "standard output"; - } else { -#if !defined(WIN32) && !defined(MSDOS) - f = fopen(fname, "w"); -#else - f = fopen(fname, "wb"); -#endif - if (f == NULL) { - snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s", - fname, pcap_strerror(errno)); - return (NULL); - } - } - return (pcap_setup_dump(p, linktype, f, fname)); -} - -/* - * Initialize so that sf_write() will output to the given stream. - */ -pcap_dumper_t * -pcap_dump_fopen(pcap_t *p, FILE *f) -{ - int linktype; - - linktype = dlt_to_linktype(p->linktype); - if (linktype == -1) { - snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "stream: link-layer type %d isn't supported in savefiles", - linktype); - return (NULL); - } - linktype |= p->linktype_ext; - - return (pcap_setup_dump(p, linktype, f, "stream")); -} - -FILE * -pcap_dump_file(pcap_dumper_t *p) -{ - return ((FILE *)p); -} - -long -pcap_dump_ftell(pcap_dumper_t *p) -{ - return (ftell((FILE *)p)); -} - -int -pcap_dump_flush(pcap_dumper_t *p) -{ - - if (fflush((FILE *)p) == EOF) - return (-1); - else - return (0); -} - -void -pcap_dump_close(pcap_dumper_t *p) -{ - -#ifdef notyet - if (ferror((FILE *)p)) - return-an-error; - /* XXX should check return from fclose() too */ -#endif - (void)fclose((FILE *)p); -} diff --git a/libpcap/scanner.c b/libpcap/scanner.c index 98eaa8557..740032c12 100644 --- a/libpcap/scanner.c +++ b/libpcap/scanner.c @@ -2705,13 +2705,27 @@ char *pcap_text; #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.110.2.2 2008/02/06 10:21:47 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.112 2008-02-06 10:21:30 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif +#ifdef WIN32 +#include +#else /* WIN32 */ +#if HAVE_INTTYPES_H +#include +#elif HAVE_STDINT_H +#include +#endif +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +#include +#endif /* WIN32 */ + #include #include @@ -2749,7 +2763,7 @@ static inline int xdtoi(int); #define YY_NO_UNPUT static YY_BUFFER_STATE in_buffer; #else -static char *in_buffer; +static const char *in_buffer; #undef getc #define getc(fp) (*in_buffer == 0 ? EOF : *in_buffer++) @@ -2758,7 +2772,7 @@ static char *in_buffer; #define yylval pcap_lval extern YYSTYPE yylval; -#line 2762 "scanner.c" +#line 2776 "scanner.c" #define INITIAL 0 @@ -2922,9 +2936,9 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 174 "scanner.l" +#line 188 "scanner.l" -#line 2928 "scanner.c" +#line 2942 "scanner.c" if ( !(yy_init) ) { @@ -3009,87 +3023,87 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 175 "scanner.l" +#line 189 "scanner.l" return DST; YY_BREAK case 2: YY_RULE_SETUP -#line 176 "scanner.l" +#line 190 "scanner.l" return SRC; YY_BREAK case 3: YY_RULE_SETUP -#line 178 "scanner.l" +#line 192 "scanner.l" return LINK; YY_BREAK case 4: YY_RULE_SETUP -#line 179 "scanner.l" +#line 193 "scanner.l" return LINK; YY_BREAK case 5: YY_RULE_SETUP -#line 180 "scanner.l" +#line 194 "scanner.l" return ARP; YY_BREAK case 6: YY_RULE_SETUP -#line 181 "scanner.l" +#line 195 "scanner.l" return RARP; YY_BREAK case 7: YY_RULE_SETUP -#line 182 "scanner.l" +#line 196 "scanner.l" return IP; YY_BREAK case 8: YY_RULE_SETUP -#line 183 "scanner.l" +#line 197 "scanner.l" return SCTP; YY_BREAK case 9: YY_RULE_SETUP -#line 184 "scanner.l" +#line 198 "scanner.l" return TCP; YY_BREAK case 10: YY_RULE_SETUP -#line 185 "scanner.l" +#line 199 "scanner.l" return UDP; YY_BREAK case 11: YY_RULE_SETUP -#line 186 "scanner.l" +#line 200 "scanner.l" return ICMP; YY_BREAK case 12: YY_RULE_SETUP -#line 187 "scanner.l" +#line 201 "scanner.l" return IGMP; YY_BREAK case 13: YY_RULE_SETUP -#line 188 "scanner.l" +#line 202 "scanner.l" return IGRP; YY_BREAK case 14: YY_RULE_SETUP -#line 189 "scanner.l" +#line 203 "scanner.l" return PIM; YY_BREAK case 15: YY_RULE_SETUP -#line 190 "scanner.l" +#line 204 "scanner.l" return VRRP; YY_BREAK case 16: YY_RULE_SETUP -#line 191 "scanner.l" +#line 205 "scanner.l" return RADIO; YY_BREAK case 17: YY_RULE_SETUP -#line 193 "scanner.l" +#line 207 "scanner.l" { #ifdef INET6 return IPV6; @@ -3100,7 +3114,7 @@ YY_RULE_SETUP YY_BREAK case 18: YY_RULE_SETUP -#line 200 "scanner.l" +#line 214 "scanner.l" { #ifdef INET6 return ICMPV6; @@ -3111,162 +3125,162 @@ YY_RULE_SETUP YY_BREAK case 19: YY_RULE_SETUP -#line 207 "scanner.l" +#line 221 "scanner.l" return AH; YY_BREAK case 20: YY_RULE_SETUP -#line 208 "scanner.l" +#line 222 "scanner.l" return ESP; YY_BREAK case 21: YY_RULE_SETUP -#line 210 "scanner.l" +#line 224 "scanner.l" return ATALK; YY_BREAK case 22: YY_RULE_SETUP -#line 211 "scanner.l" +#line 225 "scanner.l" return AARP; YY_BREAK case 23: YY_RULE_SETUP -#line 212 "scanner.l" +#line 226 "scanner.l" return DECNET; YY_BREAK case 24: YY_RULE_SETUP -#line 213 "scanner.l" +#line 227 "scanner.l" return LAT; YY_BREAK case 25: YY_RULE_SETUP -#line 214 "scanner.l" +#line 228 "scanner.l" return SCA; YY_BREAK case 26: YY_RULE_SETUP -#line 215 "scanner.l" +#line 229 "scanner.l" return MOPRC; YY_BREAK case 27: YY_RULE_SETUP -#line 216 "scanner.l" +#line 230 "scanner.l" return MOPDL; YY_BREAK case 28: YY_RULE_SETUP -#line 218 "scanner.l" +#line 232 "scanner.l" return ISO; YY_BREAK case 29: YY_RULE_SETUP -#line 219 "scanner.l" +#line 233 "scanner.l" return ESIS; YY_BREAK case 30: YY_RULE_SETUP -#line 220 "scanner.l" +#line 234 "scanner.l" return ESIS; YY_BREAK case 31: YY_RULE_SETUP -#line 221 "scanner.l" +#line 235 "scanner.l" return ISIS; YY_BREAK case 32: YY_RULE_SETUP -#line 222 "scanner.l" +#line 236 "scanner.l" return ISIS; YY_BREAK case 33: YY_RULE_SETUP -#line 223 "scanner.l" +#line 237 "scanner.l" return L1; YY_BREAK case 34: YY_RULE_SETUP -#line 224 "scanner.l" +#line 238 "scanner.l" return L2; YY_BREAK case 35: YY_RULE_SETUP -#line 225 "scanner.l" +#line 239 "scanner.l" return IIH; YY_BREAK case 36: YY_RULE_SETUP -#line 226 "scanner.l" +#line 240 "scanner.l" return LSP; YY_BREAK case 37: YY_RULE_SETUP -#line 227 "scanner.l" +#line 241 "scanner.l" return SNP; YY_BREAK case 38: YY_RULE_SETUP -#line 228 "scanner.l" +#line 242 "scanner.l" return CSNP; YY_BREAK case 39: YY_RULE_SETUP -#line 229 "scanner.l" +#line 243 "scanner.l" return PSNP; YY_BREAK case 40: YY_RULE_SETUP -#line 231 "scanner.l" +#line 245 "scanner.l" return CLNP; YY_BREAK case 41: YY_RULE_SETUP -#line 233 "scanner.l" +#line 247 "scanner.l" return STP; YY_BREAK case 42: YY_RULE_SETUP -#line 235 "scanner.l" +#line 249 "scanner.l" return IPX; YY_BREAK case 43: YY_RULE_SETUP -#line 237 "scanner.l" +#line 251 "scanner.l" return NETBEUI; YY_BREAK case 44: YY_RULE_SETUP -#line 239 "scanner.l" +#line 253 "scanner.l" return HOST; YY_BREAK case 45: YY_RULE_SETUP -#line 240 "scanner.l" +#line 254 "scanner.l" return NET; YY_BREAK case 46: YY_RULE_SETUP -#line 241 "scanner.l" +#line 255 "scanner.l" return NETMASK; YY_BREAK case 47: YY_RULE_SETUP -#line 242 "scanner.l" +#line 256 "scanner.l" return PORT; YY_BREAK case 48: YY_RULE_SETUP -#line 243 "scanner.l" +#line 257 "scanner.l" return PORTRANGE; YY_BREAK case 49: YY_RULE_SETUP -#line 244 "scanner.l" +#line 258 "scanner.l" return PROTO; YY_BREAK case 50: YY_RULE_SETUP -#line 245 "scanner.l" +#line 259 "scanner.l" { #ifdef NO_PROTOCHAIN bpf_error("%s not supported", pcap_text); @@ -3277,326 +3291,326 @@ YY_RULE_SETUP YY_BREAK case 51: YY_RULE_SETUP -#line 253 "scanner.l" +#line 267 "scanner.l" return GATEWAY; YY_BREAK case 52: YY_RULE_SETUP -#line 255 "scanner.l" +#line 269 "scanner.l" return TYPE; YY_BREAK case 53: YY_RULE_SETUP -#line 256 "scanner.l" +#line 270 "scanner.l" return SUBTYPE; YY_BREAK case 54: YY_RULE_SETUP -#line 257 "scanner.l" +#line 271 "scanner.l" return DIR; YY_BREAK case 55: YY_RULE_SETUP -#line 258 "scanner.l" +#line 272 "scanner.l" return ADDR1; YY_BREAK case 56: YY_RULE_SETUP -#line 259 "scanner.l" +#line 273 "scanner.l" return ADDR2; YY_BREAK case 57: YY_RULE_SETUP -#line 260 "scanner.l" +#line 274 "scanner.l" return ADDR3; YY_BREAK case 58: YY_RULE_SETUP -#line 261 "scanner.l" +#line 275 "scanner.l" return ADDR4; YY_BREAK case 59: YY_RULE_SETUP -#line 263 "scanner.l" +#line 277 "scanner.l" return LESS; YY_BREAK case 60: YY_RULE_SETUP -#line 264 "scanner.l" +#line 278 "scanner.l" return GREATER; YY_BREAK case 61: YY_RULE_SETUP -#line 265 "scanner.l" +#line 279 "scanner.l" return CBYTE; YY_BREAK case 62: YY_RULE_SETUP -#line 266 "scanner.l" +#line 280 "scanner.l" return TK_BROADCAST; YY_BREAK case 63: YY_RULE_SETUP -#line 267 "scanner.l" +#line 281 "scanner.l" return TK_MULTICAST; YY_BREAK case 64: YY_RULE_SETUP -#line 269 "scanner.l" +#line 283 "scanner.l" return AND; YY_BREAK case 65: YY_RULE_SETUP -#line 270 "scanner.l" +#line 284 "scanner.l" return OR; YY_BREAK case 66: YY_RULE_SETUP -#line 271 "scanner.l" +#line 285 "scanner.l" return '!'; YY_BREAK case 67: YY_RULE_SETUP -#line 273 "scanner.l" +#line 287 "scanner.l" return LEN; YY_BREAK case 68: YY_RULE_SETUP -#line 274 "scanner.l" +#line 288 "scanner.l" return INBOUND; YY_BREAK case 69: YY_RULE_SETUP -#line 275 "scanner.l" +#line 289 "scanner.l" return OUTBOUND; YY_BREAK case 70: YY_RULE_SETUP -#line 277 "scanner.l" +#line 291 "scanner.l" return VLAN; YY_BREAK case 71: YY_RULE_SETUP -#line 278 "scanner.l" +#line 292 "scanner.l" return MPLS; YY_BREAK case 72: YY_RULE_SETUP -#line 279 "scanner.l" +#line 293 "scanner.l" return PPPOED; YY_BREAK case 73: YY_RULE_SETUP -#line 280 "scanner.l" +#line 294 "scanner.l" return PPPOES; YY_BREAK case 74: YY_RULE_SETUP -#line 282 "scanner.l" +#line 296 "scanner.l" return LANE; YY_BREAK case 75: YY_RULE_SETUP -#line 283 "scanner.l" +#line 297 "scanner.l" return LLC; YY_BREAK case 76: YY_RULE_SETUP -#line 284 "scanner.l" +#line 298 "scanner.l" return METAC; YY_BREAK case 77: YY_RULE_SETUP -#line 285 "scanner.l" +#line 299 "scanner.l" return BCC; YY_BREAK case 78: YY_RULE_SETUP -#line 286 "scanner.l" +#line 300 "scanner.l" return OAM; YY_BREAK case 79: YY_RULE_SETUP -#line 287 "scanner.l" +#line 301 "scanner.l" return OAMF4; YY_BREAK case 80: YY_RULE_SETUP -#line 288 "scanner.l" +#line 302 "scanner.l" return OAMF4EC; YY_BREAK case 81: YY_RULE_SETUP -#line 289 "scanner.l" +#line 303 "scanner.l" return OAMF4SC; YY_BREAK case 82: YY_RULE_SETUP -#line 290 "scanner.l" +#line 304 "scanner.l" return SC; YY_BREAK case 83: YY_RULE_SETUP -#line 291 "scanner.l" +#line 305 "scanner.l" return ILMIC; YY_BREAK case 84: YY_RULE_SETUP -#line 292 "scanner.l" +#line 306 "scanner.l" return VPI; YY_BREAK case 85: YY_RULE_SETUP -#line 293 "scanner.l" +#line 307 "scanner.l" return VCI; YY_BREAK case 86: YY_RULE_SETUP -#line 294 "scanner.l" +#line 308 "scanner.l" return CONNECTMSG; YY_BREAK case 87: YY_RULE_SETUP -#line 295 "scanner.l" +#line 309 "scanner.l" return METACONNECT; YY_BREAK case 88: YY_RULE_SETUP -#line 297 "scanner.l" +#line 311 "scanner.l" return PF_IFNAME; YY_BREAK case 89: YY_RULE_SETUP -#line 298 "scanner.l" +#line 312 "scanner.l" return PF_RSET; YY_BREAK case 90: YY_RULE_SETUP -#line 299 "scanner.l" +#line 313 "scanner.l" return PF_RNR; YY_BREAK case 91: YY_RULE_SETUP -#line 300 "scanner.l" +#line 314 "scanner.l" return PF_SRNR; YY_BREAK case 92: YY_RULE_SETUP -#line 301 "scanner.l" +#line 315 "scanner.l" return PF_REASON; YY_BREAK case 93: YY_RULE_SETUP -#line 302 "scanner.l" +#line 316 "scanner.l" return PF_ACTION; YY_BREAK case 94: YY_RULE_SETUP -#line 304 "scanner.l" +#line 318 "scanner.l" return FISU; YY_BREAK case 95: YY_RULE_SETUP -#line 305 "scanner.l" +#line 319 "scanner.l" return LSSU; YY_BREAK case 96: YY_RULE_SETUP -#line 306 "scanner.l" +#line 320 "scanner.l" return LSSU; YY_BREAK case 97: YY_RULE_SETUP -#line 307 "scanner.l" +#line 321 "scanner.l" return MSU; YY_BREAK case 98: YY_RULE_SETUP -#line 308 "scanner.l" +#line 322 "scanner.l" return SIO; YY_BREAK case 99: YY_RULE_SETUP -#line 309 "scanner.l" +#line 323 "scanner.l" return OPC; YY_BREAK case 100: YY_RULE_SETUP -#line 310 "scanner.l" +#line 324 "scanner.l" return DPC; YY_BREAK case 101: YY_RULE_SETUP -#line 311 "scanner.l" +#line 325 "scanner.l" return SLS; YY_BREAK case 102: /* rule 102 can match eol */ YY_RULE_SETUP -#line 313 "scanner.l" +#line 327 "scanner.l" ; YY_BREAK case 103: YY_RULE_SETUP -#line 314 "scanner.l" +#line 328 "scanner.l" return pcap_text[0]; YY_BREAK case 104: YY_RULE_SETUP -#line 315 "scanner.l" +#line 329 "scanner.l" return GEQ; YY_BREAK case 105: YY_RULE_SETUP -#line 316 "scanner.l" +#line 330 "scanner.l" return LEQ; YY_BREAK case 106: YY_RULE_SETUP -#line 317 "scanner.l" +#line 331 "scanner.l" return NEQ; YY_BREAK case 107: YY_RULE_SETUP -#line 318 "scanner.l" +#line 332 "scanner.l" return '='; YY_BREAK case 108: YY_RULE_SETUP -#line 319 "scanner.l" +#line 333 "scanner.l" return LSH; YY_BREAK case 109: YY_RULE_SETUP -#line 320 "scanner.l" +#line 334 "scanner.l" return RSH; YY_BREAK case 110: YY_RULE_SETUP -#line 321 "scanner.l" +#line 335 "scanner.l" { yylval.e = pcap_ether_aton(((char *)pcap_text)+1); return AID; } YY_BREAK case 111: YY_RULE_SETUP -#line 323 "scanner.l" +#line 337 "scanner.l" { yylval.e = pcap_ether_aton((char *)pcap_text); return EID; } YY_BREAK case 112: YY_RULE_SETUP -#line 325 "scanner.l" +#line 339 "scanner.l" { yylval.i = stoi((char *)pcap_text); return NUM; } YY_BREAK case 113: YY_RULE_SETUP -#line 326 "scanner.l" +#line 340 "scanner.l" { yylval.s = sdup((char *)pcap_text); return HID; } YY_BREAK case 114: YY_RULE_SETUP -#line 328 "scanner.l" +#line 342 "scanner.l" { #ifdef INET6 struct addrinfo hints, *res; @@ -3606,6 +3620,7 @@ YY_RULE_SETUP if (getaddrinfo(pcap_text, NULL, &hints, &res)) bpf_error("bogus IPv6 address %s", pcap_text); else { + freeaddrinfo(res); yylval.s = sdup((char *)pcap_text); return HID6; } #else @@ -3615,157 +3630,157 @@ YY_RULE_SETUP YY_BREAK case 115: YY_RULE_SETUP -#line 343 "scanner.l" +#line 358 "scanner.l" { bpf_error("bogus ethernet address %s", pcap_text); } YY_BREAK case 116: YY_RULE_SETUP -#line 344 "scanner.l" +#line 359 "scanner.l" { yylval.i = 0; return NUM; } YY_BREAK case 117: YY_RULE_SETUP -#line 345 "scanner.l" +#line 360 "scanner.l" { yylval.i = 1; return NUM; } YY_BREAK case 118: YY_RULE_SETUP -#line 346 "scanner.l" +#line 361 "scanner.l" { yylval.i = 0; return NUM; } YY_BREAK case 119: YY_RULE_SETUP -#line 347 "scanner.l" +#line 362 "scanner.l" { yylval.i = 3; return NUM; } YY_BREAK case 120: YY_RULE_SETUP -#line 348 "scanner.l" +#line 363 "scanner.l" { yylval.i = 4; return NUM; } YY_BREAK case 121: YY_RULE_SETUP -#line 349 "scanner.l" +#line 364 "scanner.l" { yylval.i = 5; return NUM; } YY_BREAK case 122: YY_RULE_SETUP -#line 350 "scanner.l" +#line 365 "scanner.l" { yylval.i = 8; return NUM; } YY_BREAK case 123: YY_RULE_SETUP -#line 351 "scanner.l" +#line 366 "scanner.l" { yylval.i = 9; return NUM; } YY_BREAK case 124: YY_RULE_SETUP -#line 352 "scanner.l" +#line 367 "scanner.l" { yylval.i = 10; return NUM; } YY_BREAK case 125: YY_RULE_SETUP -#line 353 "scanner.l" +#line 368 "scanner.l" { yylval.i = 11; return NUM; } YY_BREAK case 126: YY_RULE_SETUP -#line 354 "scanner.l" +#line 369 "scanner.l" { yylval.i = 12; return NUM; } YY_BREAK case 127: YY_RULE_SETUP -#line 355 "scanner.l" +#line 370 "scanner.l" { yylval.i = 13; return NUM; } YY_BREAK case 128: YY_RULE_SETUP -#line 356 "scanner.l" +#line 371 "scanner.l" { yylval.i = 14; return NUM; } YY_BREAK case 129: YY_RULE_SETUP -#line 357 "scanner.l" +#line 372 "scanner.l" { yylval.i = 15; return NUM; } YY_BREAK case 130: YY_RULE_SETUP -#line 358 "scanner.l" +#line 373 "scanner.l" { yylval.i = 16; return NUM; } YY_BREAK case 131: YY_RULE_SETUP -#line 359 "scanner.l" +#line 374 "scanner.l" { yylval.i = 17; return NUM; } YY_BREAK case 132: YY_RULE_SETUP -#line 360 "scanner.l" +#line 375 "scanner.l" { yylval.i = 18; return NUM; } YY_BREAK case 133: YY_RULE_SETUP -#line 361 "scanner.l" +#line 376 "scanner.l" { yylval.i = 13; return NUM; } YY_BREAK case 134: YY_RULE_SETUP -#line 362 "scanner.l" +#line 377 "scanner.l" { yylval.i = 0x01; return NUM; } YY_BREAK case 135: YY_RULE_SETUP -#line 363 "scanner.l" +#line 378 "scanner.l" { yylval.i = 0x02; return NUM; } YY_BREAK case 136: YY_RULE_SETUP -#line 364 "scanner.l" +#line 379 "scanner.l" { yylval.i = 0x04; return NUM; } YY_BREAK case 137: YY_RULE_SETUP -#line 365 "scanner.l" +#line 380 "scanner.l" { yylval.i = 0x08; return NUM; } YY_BREAK case 138: YY_RULE_SETUP -#line 366 "scanner.l" +#line 381 "scanner.l" { yylval.i = 0x10; return NUM; } YY_BREAK case 139: YY_RULE_SETUP -#line 367 "scanner.l" +#line 382 "scanner.l" { yylval.i = 0x20; return NUM; } YY_BREAK case 140: YY_RULE_SETUP -#line 368 "scanner.l" +#line 383 "scanner.l" { yylval.s = sdup((char *)pcap_text); return ID; } YY_BREAK case 141: YY_RULE_SETUP -#line 370 "scanner.l" +#line 385 "scanner.l" { yylval.s = sdup((char *)pcap_text + 1); return ID; } YY_BREAK case 142: YY_RULE_SETUP -#line 371 "scanner.l" +#line 386 "scanner.l" { bpf_error("illegal token: %s", pcap_text); } YY_BREAK case 143: YY_RULE_SETUP -#line 373 "scanner.l" +#line 388 "scanner.l" { bpf_error("illegal char '%c'", *pcap_text); } YY_BREAK case 144: YY_RULE_SETUP -#line 374 "scanner.l" +#line 389 "scanner.l" ECHO; YY_BREAK -#line 3769 "scanner.c" +#line 3784 "scanner.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -4662,7 +4677,7 @@ void pcap_free (void * ptr ) #define YYTABLES_NAME "yytables" -#line 374 "scanner.l" +#line 389 "scanner.l" void diff --git a/libpcap/scanner.l b/libpcap/scanner.l index c477684e1..9b3e139f6 100644 --- a/libpcap/scanner.l +++ b/libpcap/scanner.l @@ -22,13 +22,27 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.110.2.2 2008/02/06 10:21:47 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.112 2008-02-06 10:21:30 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif +#ifdef WIN32 +#include +#else /* WIN32 */ +#if HAVE_INTTYPES_H +#include +#elif HAVE_STDINT_H +#include +#endif +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +#include +#endif /* WIN32 */ + #include #include @@ -66,7 +80,7 @@ static inline int xdtoi(int); #define YY_NO_UNPUT static YY_BUFFER_STATE in_buffer; #else -static char *in_buffer; +static const char *in_buffer; #undef getc #define getc(fp) (*in_buffer == 0 ? EOF : *in_buffer++) @@ -334,6 +348,7 @@ ${B} { yylval.e = pcap_ether_aton(((char *)yytext)+1); if (getaddrinfo(yytext, NULL, &hints, &res)) bpf_error("bogus IPv6 address %s", yytext); else { + freeaddrinfo(res); yylval.s = sdup((char *)yytext); return HID6; } #else diff --git a/libpcap/selpolltest.c b/libpcap/selpolltest.c new file mode 100644 index 000000000..d94fb567f --- /dev/null +++ b/libpcap/selpolltest.c @@ -0,0 +1,350 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +char *program_name; + +/* Forwards */ +static void countme(u_char *, const struct pcap_pkthdr *, const u_char *); +static void usage(void) __attribute__((noreturn)); +static void error(const char *, ...); +static void warning(const char *, ...); +static char *copy_argv(char **); + +static pcap_t *pd; + +extern int optind; +extern int opterr; +extern char *optarg; + +int +main(int argc, char **argv) +{ + register int op; + bpf_u_int32 localnet, netmask; + register char *cp, *cmdbuf, *device; + int doselect, dopoll, dotimeout, dononblock; + struct bpf_program fcode; + char ebuf[PCAP_ERRBUF_SIZE]; + int selectable_fd; + int status; + int packet_count; + + device = NULL; + doselect = 0; + dopoll = 0; + dotimeout = 0; + dononblock = 0; + if ((cp = strrchr(argv[0], '/')) != NULL) + program_name = cp + 1; + else + program_name = argv[0]; + + opterr = 0; + while ((op = getopt(argc, argv, "i:sptn")) != -1) { + switch (op) { + + case 'i': + device = optarg; + break; + + case 's': + doselect = 1; + break; + + case 'p': + dopoll = 1; + break; + + case 't': + dotimeout = 1; + break; + + case 'n': + dononblock = 1; + break; + + default: + usage(); + /* NOTREACHED */ + } + } + + if (doselect && dopoll) { + fprintf(stderr, "selpolltest: choose select (-s) or poll (-p), but not both\n"); + return 1; + } + if (dotimeout && !doselect && !dopoll) { + fprintf(stderr, "selpolltest: timeout (-t) requires select (-s) or poll (-p)\n"); + return 1; + } + if (device == NULL) { + device = pcap_lookupdev(ebuf); + if (device == NULL) + error("%s", ebuf); + } + *ebuf = '\0'; + pd = pcap_open_live(device, 65535, 0, 1000, ebuf); + if (pd == NULL) + error("%s", ebuf); + else if (*ebuf) + warning("%s", ebuf); + if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) { + localnet = 0; + netmask = 0; + warning("%s", ebuf); + } + cmdbuf = copy_argv(&argv[optind]); + + if (pcap_compile(pd, &fcode, cmdbuf, 1, netmask) < 0) + error("%s", pcap_geterr(pd)); + + if (pcap_setfilter(pd, &fcode) < 0) + error("%s", pcap_geterr(pd)); + if (pcap_get_selectable_fd(pd) == -1) + error("pcap_get_selectable_fd() fails"); + if (dononblock) { + if (pcap_setnonblock(pd, 1, ebuf) == -1) + error("pcap_setnonblock failed: %s", ebuf); + } + selectable_fd = pcap_get_selectable_fd(pd); + printf("Listening on %s\n", device); + if (doselect) { + for (;;) { + fd_set setread, setexcept; + struct timeval seltimeout; + + FD_ZERO(&setread); + FD_SET(selectable_fd, &setread); + FD_ZERO(&setexcept); + FD_SET(selectable_fd, &setexcept); + if (dotimeout) { + seltimeout.tv_sec = 0; + seltimeout.tv_usec = 1000; + status = select(selectable_fd + 1, &setread, + NULL, &setexcept, &seltimeout); + } else { + status = select(selectable_fd + 1, &setread, + NULL, &setexcept, NULL); + } + if (status == -1) { + printf("Select returns error (%s)\n", + strerror(errno)); + } else { + if (status == 0) + printf("Select timed out: "); + else + printf("Select returned a descriptor: "); + if (FD_ISSET(selectable_fd, &setread)) + printf("readable, "); + else + printf("not readable, "); + if (FD_ISSET(selectable_fd, &setexcept)) + printf("exceptional condition\n"); + else + printf("no exceptional condition\n"); + packet_count = 0; + status = pcap_dispatch(pd, -1, countme, + (u_char *)&packet_count); + if (status < 0) + break; + printf("%d packets seen, %d packets counted after select returns\n", + status, packet_count); + } + } + } else if (dopoll) { + for (;;) { + struct pollfd fd; + int polltimeout; + + fd.fd = selectable_fd; + fd.events = POLLIN; + if (dotimeout) + polltimeout = 1; + else + polltimeout = -1; + status = poll(&fd, 1, polltimeout); + if (status == -1) { + printf("Poll returns error (%s)\n", + strerror(errno)); + } else { + if (status == 0) + printf("Poll timed out\n"); + else { + printf("Poll returned a descriptor: "); + if (fd.revents & POLLIN) + printf("readable, "); + else + printf("not readable, "); + if (fd.revents & POLLERR) + printf("exceptional condition, "); + else + printf("no exceptional condition, "); + if (fd.revents & POLLHUP) + printf("disconnect, "); + else + printf("no disconnect, "); + if (fd.revents & POLLNVAL) + printf("invalid\n"); + else + printf("not invalid\n"); + } + packet_count = 0; + status = pcap_dispatch(pd, -1, countme, + (u_char *)&packet_count); + if (status < 0) + break; + printf("%d packets seen, %d packets counted after poll returns\n", + status, packet_count); + } + } + } else { + for (;;) { + packet_count = 0; + status = pcap_dispatch(pd, -1, countme, + (u_char *)&packet_count); + if (status < 0) + break; + printf("%d packets seen, %d packets counted after pcap_dispatch returns\n", + status, packet_count); + } + } + if (status == -2) { + /* + * We got interrupted, so perhaps we didn't + * manage to finish a line we were printing. + * Print an extra newline, just in case. + */ + putchar('\n'); + } + (void)fflush(stdout); + if (status == -1) { + /* + * Error. Report it. + */ + (void)fprintf(stderr, "%s: pcap_loop: %s\n", + program_name, pcap_geterr(pd)); + } + pcap_close(pd); + exit(status == -1 ? 1 : 0); +} + +static void +countme(u_char *user, const struct pcap_pkthdr *h, const u_char *sp) +{ + int *counterp = (int *)user; + + (*counterp)++; +} + +static void +usage(void) +{ + (void)fprintf(stderr, "Usage: %s [ -sptn ] [ -i interface ] [expression]\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); + } +} + +/* + * Copy arg vector into a new buffer, concatenating arguments with spaces. + */ +static char * +copy_argv(register char **argv) +{ + register char **p; + register u_int len = 0; + char *buf; + char *src, *dst; + + p = argv; + if (*p == 0) + return 0; + + while (*p) + len += strlen(*p++) + 1; + + buf = (char *)malloc(len); + if (buf == NULL) + error("copy_argv: malloc"); + + p = argv; + dst = buf; + while ((src = *p++) != NULL) { + while ((*dst++ = *src++) != '\0') + ; + dst[-1] = ' '; + } + dst[-1] = '\0'; + + return buf; +} diff --git a/libpcap/sf-pcap-ng.c b/libpcap/sf-pcap-ng.c new file mode 100644 index 000000000..3535777ce --- /dev/null +++ b/libpcap/sf-pcap-ng.c @@ -0,0 +1,1113 @@ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * sf-pcap-ng.c - pcap-ng-file-format-specific code from savefile.c + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header$ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef WIN32 +#include +#else /* WIN32 */ +#if HAVE_INTTYPES_H +#include +#elif HAVE_STDINT_H +#include +#endif +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +#include +#endif /* WIN32 */ + +#include +#include +#include +#include +#include + +#include "pcap-int.h" + +#include "pcap-common.h" + +#ifdef HAVE_OS_PROTO_H +#include "os-proto.h" +#endif + +#include "sf-pcap-ng.h" + +/* + * Block types. + */ + +/* + * Common part at the beginning of all blocks. + */ +struct block_header { + bpf_u_int32 block_type; + bpf_u_int32 total_length; +}; + +/* + * Common trailer at the end of all blocks. + */ +struct block_trailer { + bpf_u_int32 total_length; +}; + +/* + * Common options. + */ +#define OPT_ENDOFOPT 0 /* end of options */ +#define OPT_COMMENT 1 /* comment string */ + +/* + * Option header. + */ +struct option_header { + u_short option_code; + u_short option_length; +}; + +/* + * Structures for the part of each block type following the common + * part. + */ + +/* + * Section Header Block. + */ +#define BT_SHB 0x0A0D0D0A + +struct section_header_block { + bpf_u_int32 byte_order_magic; + u_short major_version; + u_short minor_version; + u_int64_t section_length; + /* followed by options and trailer */ +}; + +/* + * Byte-order magic value. + */ +#define BYTE_ORDER_MAGIC 0x1A2B3C4D + +/* + * Current version number. If major_version isn't PCAP_NG_VERSION_MAJOR, + * that means that this code can't read the file. + */ +#define PCAP_NG_VERSION_MAJOR 1 + +/* + * Interface Description Block. + */ +#define BT_IDB 0x00000001 + +struct interface_description_block { + u_short linktype; + u_short reserved; + bpf_u_int32 snaplen; + /* followed by options and trailer */ +}; + +/* + * Options in the IDB. + */ +#define IF_NAME 2 /* interface name string */ +#define IF_DESCRIPTION 3 /* interface description string */ +#define IF_IPV4ADDR 4 /* interface's IPv4 address and netmask */ +#define IF_IPV6ADDR 5 /* interface's IPv6 address and prefix length */ +#define IF_MACADDR 6 /* interface's MAC address */ +#define IF_EUIADDR 7 /* interface's EUI address */ +#define IF_SPEED 8 /* interface's speed, in bits/s */ +#define IF_TSRESOL 9 /* interface's time stamp resolution */ +#define IF_TZONE 10 /* interface's time zone */ +#define IF_FILTER 11 /* filter used when capturing on interface */ +#define IF_OS 12 /* string OS on which capture on this interface was done */ +#define IF_FCSLEN 13 /* FCS length for this interface */ +#define IF_TSOFFSET 14 /* time stamp offset for this interface */ + +/* + * Enhanced Packet Block. + */ +#define BT_EPB 0x00000006 + +struct enhanced_packet_block { + bpf_u_int32 interface_id; + bpf_u_int32 timestamp_high; + bpf_u_int32 timestamp_low; + bpf_u_int32 caplen; + bpf_u_int32 len; + /* followed by packet data, options, and trailer */ +}; + +/* + * Simple Packet Block. + */ +#define BT_SPB 0x00000003 + +struct simple_packet_block { + bpf_u_int32 len; + /* followed by packet data and trailer */ +}; + +/* + * Packet Block. + */ +#define BT_PB 0x00000002 + +struct packet_block { + u_short interface_id; + u_short drops_count; + bpf_u_int32 timestamp_high; + bpf_u_int32 timestamp_low; + bpf_u_int32 caplen; + bpf_u_int32 len; + /* followed by packet data, options, and trailer */ +}; + +/* + * Block cursor - used when processing the contents of a block. + * Contains a pointer into the data being processed and a count + * of bytes remaining in the block. + */ +struct block_cursor { + u_char *data; + size_t data_remaining; + bpf_u_int32 block_type; +}; + +static int pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, + u_char **data); + +static int +read_bytes(FILE *fp, void *buf, size_t bytes_to_read, int fail_on_eof, + char *errbuf) +{ + size_t amt_read; + + amt_read = fread(buf, 1, bytes_to_read, fp); + if (amt_read != bytes_to_read) { + if (ferror(fp)) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "error reading dump file: %s", + pcap_strerror(errno)); + } else { + if (amt_read == 0 && !fail_on_eof) + return (0); /* EOF */ + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "truncated dump file; tried to read %lu bytes, only got %lu", + (unsigned long)bytes_to_read, + (unsigned long)amt_read); + } + return (-1); + } + return (1); +} + +static int +read_block(FILE *fp, pcap_t *p, struct block_cursor *cursor, char *errbuf) +{ + int status; + struct block_header bhdr; + + status = read_bytes(fp, &bhdr, sizeof(bhdr), 0, errbuf); + if (status <= 0) + return (status); /* error or EOF */ + + if (p->sf.swapped) { + bhdr.block_type = SWAPLONG(bhdr.block_type); + bhdr.total_length = SWAPLONG(bhdr.total_length); + } + + /* + * Is this block "too big"? + * + * We choose 16MB as "too big", for now, so that we handle + * "reasonably" large buffers but don't chew up all the + * memory if we read a malformed file. + */ + if (bhdr.total_length > 16*1024*1024) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "pcap-ng block size %u > maximum %u", + bhdr.total_length, 16*1024*1024); + return (-1); + } + + /* + * Is this block "too small" - i.e., is it shorter than a block + * header plus a block trailer? + */ + if (bhdr.total_length < sizeof(struct block_header) + + sizeof(struct block_trailer)) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "block in pcap-ng dump file has a length of %u < %lu", + bhdr.total_length, + (unsigned long)(sizeof(struct block_header) + sizeof(struct block_trailer))); + return (-1); + } + + /* + * Is the buffer big enough? + */ + if (p->bufsize < bhdr.total_length) { + /* + * No - make it big enough. + */ + p->buffer = realloc(p->buffer, bhdr.total_length); + if (p->buffer == NULL) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, "out of memory"); + return (-1); + } + } + + /* + * Copy the stuff we've read to the buffer, and read the rest + * of the block. + */ + memcpy(p->buffer, &bhdr, sizeof(bhdr)); + if (read_bytes(fp, p->buffer + sizeof(bhdr), + bhdr.total_length - sizeof(bhdr), 1, errbuf) == -1) + return (-1); + + /* + * Initialize the cursor. + */ + cursor->data = p->buffer + sizeof(bhdr); + cursor->data_remaining = bhdr.total_length - sizeof(bhdr) - + sizeof(struct block_trailer); + cursor->block_type = bhdr.block_type; + return (1); +} + +static void * +get_from_block_data(struct block_cursor *cursor, size_t chunk_size, + char *errbuf) +{ + void *data; + + /* + * Make sure we have the specified amount of data remaining in + * the block data. + */ + if (cursor->data_remaining < chunk_size) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "block of type %u in pcap-ng dump file is too short", + cursor->block_type); + return (NULL); + } + + /* + * Return the current pointer, and skip past the chunk. + */ + data = cursor->data; + cursor->data += chunk_size; + cursor->data_remaining -= chunk_size; + return (data); +} + +static struct option_header * +get_opthdr_from_block_data(pcap_t *p, struct block_cursor *cursor, char *errbuf) +{ + struct option_header *opthdr; + + opthdr = get_from_block_data(cursor, sizeof(*opthdr), errbuf); + if (opthdr == NULL) { + /* + * Option header is cut short. + */ + return (NULL); + } + + /* + * Byte-swap it if necessary. + */ + if (p->sf.swapped) { + opthdr->option_code = SWAPSHORT(opthdr->option_code); + opthdr->option_length = SWAPSHORT(opthdr->option_length); + } + + return (opthdr); +} + +static void * +get_optvalue_from_block_data(struct block_cursor *cursor, + struct option_header *opthdr, char *errbuf) +{ + size_t padded_option_len; + void *optvalue; + + /* Pad option length to 4-byte boundary */ + padded_option_len = opthdr->option_length; + padded_option_len = ((padded_option_len + 3)/4)*4; + + optvalue = get_from_block_data(cursor, padded_option_len, errbuf); + if (optvalue == NULL) { + /* + * Option value is cut short. + */ + return (NULL); + } + + return (optvalue); +} + +static int +process_idb_options(pcap_t *p, struct block_cursor *cursor, u_int *tsresol, + u_int64_t *tsoffset, char *errbuf) +{ + struct option_header *opthdr; + void *optvalue; + int saw_tsresol, saw_tsoffset; + u_char tsresol_opt; + u_int i; + + saw_tsresol = 0; + saw_tsoffset = 0; + while (cursor->data_remaining != 0) { + /* + * Get the option header. + */ + opthdr = get_opthdr_from_block_data(p, cursor, errbuf); + if (opthdr == NULL) { + /* + * Option header is cut short. + */ + return (-1); + } + + /* + * Get option value. + */ + optvalue = get_optvalue_from_block_data(cursor, opthdr, + errbuf); + if (optvalue == NULL) { + /* + * Option value is cut short. + */ + return (-1); + } + + switch (opthdr->option_code) { + + case OPT_ENDOFOPT: + if (opthdr->option_length != 0) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "Interface Description Block has opt_endofopt option with length %u != 0", + opthdr->option_length); + return (-1); + } + goto done; + + case IF_TSRESOL: + if (opthdr->option_length != 1) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "Interface Description Block has if_tsresol option with length %u != 1", + opthdr->option_length); + return (-1); + } + if (saw_tsresol) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "Interface Description Block has more than one if_tsresol option"); + return (-1); + } + saw_tsresol = 1; + tsresol_opt = *(u_int *)optvalue; + if (tsresol_opt & 0x80) { + /* + * Resolution is negative power of 2. + */ + *tsresol = 1 << (tsresol_opt & 0x7F); + } else { + /* + * Resolution is negative power of 10. + */ + *tsresol = 1; + for (i = 0; i < tsresol_opt; i++) + *tsresol *= 10; + } + if (*tsresol == 0) { + /* + * Resolution is too high. + */ + if (tsresol_opt & 0x80) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "Interface Description Block if_tsresol option resolution 2^-%u is too high", + tsresol_opt & 0x7F); + } else { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "Interface Description Block if_tsresol option resolution 10^-%u is too high", + tsresol_opt); + } + return (-1); + } + break; + + case IF_TSOFFSET: + if (opthdr->option_length != 8) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "Interface Description Block has if_tsoffset option with length %u != 8", + opthdr->option_length); + return (-1); + } + if (saw_tsoffset) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "Interface Description Block has more than one if_tsoffset option"); + return (-1); + } + saw_tsoffset = 1; + memcpy(tsoffset, optvalue, sizeof(*tsoffset)); + if (p->sf.swapped) + *tsoffset = SWAPLL(*tsoffset); + break; + + default: + break; + } + } + +done: + return (0); +} + +/* + * Check whether this is a pcap-ng savefile and, if it is, extract the + * relevant information from the header. + */ +int +pcap_ng_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf) +{ + size_t amt_read; + bpf_u_int32 total_length; + bpf_u_int32 byte_order_magic; + struct block_header *bhdrp; + struct section_header_block *shbp; + int status; + struct block_cursor cursor; + struct interface_description_block *idbp; + + /* + * Check whether the first 4 bytes of the file are the block + * type for a pcap-ng savefile. + */ + if (magic != BT_SHB) { + /* + * XXX - check whether this looks like what the block + * type would be after being munged by mapping between + * UN*X and DOS/Windows text file format and, if it + * does, look for the byte-order magic number in + * the appropriate place and, if we find it, report + * this as possibly being a pcap-ng file transferred + * between UN*X and Windows in text file format? + */ + return (0); /* nope */ + } + + /* + * OK, they are. However, that's just \n\r\r\n, so it could, + * conceivably, be an ordinary text file. + * + * It could not, however, conceivably be any other type of + * capture file, so we can read the rest of the putative + * Section Header Block; put the block type in the common + * header, read the rest of the common header and the + * fixed-length portion of the SHB, and look for the byte-order + * magic value. + */ + amt_read = fread(&total_length, 1, sizeof(total_length), fp); + if (amt_read < sizeof(total_length)) { + if (ferror(fp)) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "error reading dump file: %s", + pcap_strerror(errno)); + return (-1); /* fail */ + } + + /* + * Possibly a weird short text file, so just say + * "not pcap-ng". + */ + return (0); + } + amt_read = fread(&byte_order_magic, 1, sizeof(byte_order_magic), fp); + if (amt_read < sizeof(byte_order_magic)) { + if (ferror(fp)) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "error reading dump file: %s", + pcap_strerror(errno)); + return (-1); /* fail */ + } + + /* + * Possibly a weird short text file, so just say + * "not pcap-ng". + */ + return (0); + } + if (byte_order_magic != BYTE_ORDER_MAGIC) { + byte_order_magic = SWAPLONG(byte_order_magic); + if (byte_order_magic != BYTE_ORDER_MAGIC) { + /* + * Not a pcap-ng file. + */ + return (0); + } + p->sf.swapped = 1; + total_length = SWAPLONG(total_length); + } + + /* + * Check the sanity of the total length. + */ + if (total_length < sizeof(*bhdrp) + sizeof(*shbp) + sizeof(struct block_trailer)) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "Section Header Block in pcap-ng dump file has a length of %u < %lu", + total_length, + (unsigned long)(sizeof(*bhdrp) + sizeof(*shbp) + sizeof(struct block_trailer))); + return (-1); + } + + /* + * Allocate a buffer into which to read blocks. We default to + * the maximum of: + * + * the total length of the SHB for which we read the header; + * + * 2K, which should be more than large enough for an Enhanced + * Packet Block containing a full-size Ethernet frame, and + * leaving room for some options. + * + * If we find a bigger block, we reallocate the buffer. + */ + p->bufsize = 2048; + if (p->bufsize < total_length) + p->bufsize = total_length; + p->buffer = malloc(p->bufsize); + if (p->buffer == NULL) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, "out of memory"); + return (-1); + } + + /* + * Copy the stuff we've read to the buffer, and read the rest + * of the SHB. + */ + bhdrp = (struct block_header *)p->buffer; + shbp = (struct section_header_block *)(p->buffer + sizeof(struct block_header)); + bhdrp->block_type = magic; + bhdrp->total_length = total_length; + shbp->byte_order_magic = byte_order_magic; + if (read_bytes(fp, + p->buffer + (sizeof(magic) + sizeof(total_length) + sizeof(byte_order_magic)), + total_length - (sizeof(magic) + sizeof(total_length) + sizeof(byte_order_magic)), + 1, errbuf) == -1) + goto fail; + + if (p->sf.swapped) { + /* + * Byte-swap the fields we've read. + */ + shbp->major_version = SWAPSHORT(shbp->major_version); + shbp->minor_version = SWAPSHORT(shbp->minor_version); + + /* + * XXX - we don't care about the section length. + */ + } + if (shbp->major_version != PCAP_NG_VERSION_MAJOR) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "unknown pcap-ng savefile major version number %u", + shbp->major_version); + goto fail; + } + p->sf.version_major = shbp->major_version; + p->sf.version_minor = shbp->minor_version; + + /* + * Set the default time stamp resolution and offset. + */ + p->sf.tsresol = 1000000; /* microsecond resolution */ + p->sf.tsscale = 1; /* multiply by 1 to scale to microseconds */ + p->sf.tsoffset = 0; /* absolute timestamps */ + + /* + * Now start looking for an Interface Description Block. + */ + for (;;) { + /* + * Read the next block. + */ + status = read_block(fp, p, &cursor, errbuf); + if (status == 0) { + /* EOF - no IDB in this file */ + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "the capture file has no Interface Description Blocks"); + goto fail; + } + if (status == -1) + goto fail; /* error */ + switch (cursor.block_type) { + + case BT_IDB: + /* + * Get a pointer to the fixed-length portion of the + * IDB. + */ + idbp = get_from_block_data(&cursor, sizeof(*idbp), + errbuf); + if (idbp == NULL) + goto fail; /* error */ + + /* + * Byte-swap it if necessary. + */ + if (p->sf.swapped) { + idbp->linktype = SWAPSHORT(idbp->linktype); + idbp->snaplen = SWAPLONG(idbp->snaplen); + } + + /* + * Count this interface. + */ + p->sf.ifcount++; + + /* + * Now look for various time stamp options, so + * we know how to interpret the time stamps. + */ + if (process_idb_options(p, &cursor, &p->sf.tsresol, + &p->sf.tsoffset, errbuf) == -1) + goto fail; + + /* + * Compute the scaling factor to convert the + * sub-second part of the time stamp to + * microseconds. + */ + if (p->sf.tsresol > 1000000) { + /* + * Higher than microsecond resolution; + * scale down to microseconds. + */ + p->sf.tsscale = (p->sf.tsresol / 1000000); + } else { + /* + * Lower than microsecond resolution; + * scale up to microseconds. + */ + p->sf.tsscale = (1000000 / p->sf.tsresol); + } + goto done; + + case BT_EPB: + case BT_SPB: + case BT_PB: + /* + * Saw a packet before we saw any IDBs. That's + * not valid, as we don't know what link-layer + * encapsulation the packet has. + */ + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "the capture file has a packet block before any Interface Description Blocks"); + goto fail; + + default: + /* + * Just ignore it. + */ + break; + } + } + +done: + p->tzoff = 0; /* XXX - not used in pcap */ + p->snapshot = idbp->snaplen; + p->linktype = idbp->linktype; + p->linktype_ext = 0; + + p->sf.next_packet_op = pcap_ng_next_packet; + + return (1); + +fail: + free(p->buffer); + return (-1); +} + +/* + * Read and return the next packet from the savefile. Return the header + * in hdr and a pointer to the contents in data. Return 0 on success, 1 + * if there were no more packets, and -1 on an error. + */ +static int +pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) +{ + struct block_cursor cursor; + int status; + struct enhanced_packet_block *epbp; + struct simple_packet_block *spbp; + struct packet_block *pbp; + bpf_u_int32 interface_id = 0xFFFFFFFF; + size_t pblock_len; + struct interface_description_block *idbp; + struct section_header_block *shbp; + FILE *fp = p->sf.rfile; + u_int tsresol; + u_int64_t tsoffset; + u_int64_t t, sec, frac; + + /* + * Look for an Enhanced Packet Block, a Simple Packet Block, + * or a Packet Block. + */ + for (;;) { + /* + * Read the block type and length; those are common + * to all blocks. + */ + status = read_block(fp, p, &cursor, p->errbuf); + if (status == 0) + return (1); /* EOF */ + if (status == -1) + return (-1); /* error */ + switch (cursor.block_type) { + + case BT_EPB: + /* + * Get a pointer to the fixed-length portion of the + * EPB. + */ + epbp = get_from_block_data(&cursor, sizeof(*epbp), + p->errbuf); + if (epbp == NULL) + return (-1); /* error */ + + /* + * Byte-swap it if necessary. + */ + if (p->sf.swapped) { + /* these were written in opposite byte order */ + interface_id = SWAPLONG(epbp->interface_id); + hdr->caplen = SWAPLONG(epbp->caplen); + hdr->len = SWAPLONG(epbp->len); + t = ((u_int64_t)SWAPLONG(epbp->timestamp_high)) << 32 | + SWAPLONG(epbp->timestamp_low); + } else { + interface_id = epbp->interface_id; + hdr->caplen = epbp->caplen; + hdr->len = epbp->len; + t = ((u_int64_t)epbp->timestamp_high) << 32 | + epbp->timestamp_low; + } + pblock_len = sizeof(*epbp); + goto found; + + case BT_SPB: + /* + * Get a pointer to the fixed-length portion of the + * SPB. + */ + spbp = get_from_block_data(&cursor, sizeof(*spbp), + p->errbuf); + if (spbp == NULL) + return (-1); /* error */ + + /* + * SPB packets are assumed to have arrived on + * the first interface. + */ + interface_id = 0; + + /* + * Byte-swap it if necessary. + */ + if (p->sf.swapped) { + /* these were written in opposite byte order */ + hdr->len = SWAPLONG(spbp->len); + } else + hdr->len = spbp->len; + + /* + * The SPB doesn't give the captured length; + * it's the minimum of the snapshot length + * and the packet length. + */ + hdr->caplen = hdr->len; + if (hdr->caplen > p->snapshot) + hdr->caplen = p->snapshot; + t = 0; /* no time stamps */ + pblock_len = sizeof(*spbp); + goto found; + + case BT_PB: + /* + * Get a pointer to the fixed-length portion of the + * PB. + */ + pbp = get_from_block_data(&cursor, sizeof(*pbp), + p->errbuf); + if (pbp == NULL) + return (-1); /* error */ + + /* + * Byte-swap it if necessary. + */ + if (p->sf.swapped) { + /* these were written in opposite byte order */ + interface_id = SWAPSHORT(pbp->interface_id); + hdr->caplen = SWAPLONG(pbp->caplen); + hdr->len = SWAPLONG(pbp->len); + t = ((u_int64_t)SWAPLONG(pbp->timestamp_high)) << 32 | + SWAPLONG(pbp->timestamp_low); + } else { + interface_id = pbp->interface_id; + hdr->caplen = pbp->caplen; + hdr->len = pbp->len; + t = ((u_int64_t)pbp->timestamp_high) << 32 | + pbp->timestamp_low; + } + pblock_len = sizeof(*pbp); + goto found; + + case BT_IDB: + /* + * Interface Description Block. Get a pointer + * to its fixed-length portion. + */ + idbp = get_from_block_data(&cursor, sizeof(*idbp), + p->errbuf); + if (idbp == NULL) + return (-1); /* error */ + + /* + * Byte-swap it if necessary. + */ + if (p->sf.swapped) { + idbp->linktype = SWAPSHORT(idbp->linktype); + idbp->snaplen = SWAPLONG(idbp->snaplen); + } + + /* + * If the link-layer type or snapshot length + * differ from the ones for the first IDB we + * saw, quit. + * + * XXX - just discard packets from those + * interfaces? + */ + if (p->linktype != idbp->linktype) { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "an interface has a type %u different from the type of the first interface", + idbp->linktype); + return (-1); + } + if (p->snapshot != idbp->snaplen) { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "an interface has a snapshot length %u different from the type of the first interface", + idbp->snaplen); + return (-1); + } + + /* + * Count this interface. + */ + p->sf.ifcount++; + + /* + * Set the default time stamp resolution and offset. + */ + tsresol = 1000000; /* microsecond resolution */ + tsoffset = 0; /* absolute timestamps */ + + /* + * Now look for various time stamp options, to + * make sure they're the same. + * + * XXX - we could, in theory, handle multiple + * different resolutions and offsets, but we + * don't do so for now. + */ + if (process_idb_options(p, &cursor, &tsresol, &tsoffset, + p->errbuf) == -1) + return (-1); + if (tsresol != p->sf.tsresol) { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "an interface has a time stamp resolution different from the time stamp resolution of the first interface"); + return (-1); + } + if (tsoffset != p->sf.tsoffset) { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "an interface has a time stamp offset different from the time stamp offset of the first interface"); + return (-1); + } + break; + + case BT_SHB: + /* + * Section Header Block. Get a pointer + * to its fixed-length portion. + */ + shbp = get_from_block_data(&cursor, sizeof(*shbp), + p->errbuf); + if (shbp == NULL) + return (-1); /* error */ + + /* + * Assume the byte order of this section is + * the same as that of the previous section. + * We'll check for that later. + */ + if (p->sf.swapped) { + shbp->byte_order_magic = + SWAPLONG(shbp->byte_order_magic); + shbp->major_version = + SWAPSHORT(shbp->major_version); + } + + /* + * Make sure the byte order doesn't change; + * pcap_is_swapped() shouldn't change its + * return value in the middle of reading a capture. + */ + switch (shbp->byte_order_magic) { + + case BYTE_ORDER_MAGIC: + /* + * OK. + */ + break; + + case SWAPLONG(BYTE_ORDER_MAGIC): + /* + * Byte order changes. + */ + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "the file has sections with different byte orders"); + return (-1); + + default: + /* + * Not a valid SHB. + */ + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "the file has a section with a bad byte order magic field"); + return (-1); + } + + /* + * Make sure the major version is the version + * we handle. + */ + if (shbp->major_version != PCAP_NG_VERSION_MAJOR) { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "unknown pcap-ng savefile major version number %u", + shbp->major_version); + return (-1); + } + + /* + * Reset the interface count; this section should + * have its own set of IDBs. If any of them + * don't have the same interface type, snapshot + * length, or resolution as the first interface + * we saw, we'll fail. (And if we don't see + * any IDBs, we'll fail when we see a packet + * block.) + */ + p->sf.ifcount = 0; + break; + + default: + /* + * Not a packet block, IDB, or SHB; ignore it. + */ + break; + } + } + +found: + /* + * Is the interface ID an interface we know? + */ + if (interface_id > p->sf.ifcount) { + /* + * Yes. Fail. + */ + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "a packet arrived on interface %u, but there's no Interface Description Block for that interface", + interface_id); + return (-1); + } + + /* + * Convert the time stamp to a struct timeval. + */ + sec = t / p->sf.tsresol + p->sf.tsoffset; + frac = t % p->sf.tsresol; + if (p->sf.tsresol > 1000000) { + /* + * Higher than microsecond resolution; scale down to + * microseconds. + */ + frac /= p->sf.tsscale; + } else { + /* + * Lower than microsecond resolution; scale up to + * microseconds. + */ + frac *= p->sf.tsscale; + } + hdr->ts.tv_sec = sec; + hdr->ts.tv_usec = frac; + + /* + * Get a pointer to the packet data. + */ + *data = get_from_block_data(&cursor, hdr->caplen, p->errbuf); + if (*data == NULL) + return (-1); + + if (p->sf.swapped) { + /* + * Convert pseudo-headers from the byte order of + * the host on which the file was saved to our + * byte order, as necessary. + */ + switch (p->linktype) { + + case DLT_USB_LINUX: + swap_linux_usb_header(hdr, *data, 0); + break; + + case DLT_USB_LINUX_MMAPPED: + swap_linux_usb_header(hdr, *data, 1); + break; + } + } + + return (0); +} diff --git a/libpcap/sf-pcap-ng.h b/libpcap/sf-pcap-ng.h new file mode 100644 index 000000000..cc5518241 --- /dev/null +++ b/libpcap/sf-pcap-ng.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * sf-pcap-ng.h - pcap-ng-file-format-specific routines + * + * Used to read pcap-ng savefiles. + */ + +#ifndef sf_pcap_ng_h +#define sf_pcap_ng_h + +extern int pcap_ng_check_header(pcap_t *, bpf_u_int32, FILE *, char *); + +#endif diff --git a/libpcap/sf-pcap.c b/libpcap/sf-pcap.c new file mode 100644 index 000000000..9d55dae5f --- /dev/null +++ b/libpcap/sf-pcap.c @@ -0,0 +1,614 @@ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * sf-pcap.c - libpcap-file-format-specific code from savefile.c + * Extraction/creation by Jeffrey Mogul, DECWRL + * Modified by Steve McCanne, LBL. + * + * Used to save the received packet headers, after filtering, to + * a file, and then read them later. + * The first record in the file contains saved values for the machine + * dependent values so we can print the dump file on any architecture. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header$ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef WIN32 +#include +#else /* WIN32 */ +#if HAVE_INTTYPES_H +#include +#elif HAVE_STDINT_H +#include +#endif +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +#include +#endif /* WIN32 */ + +#include +#include +#include +#include +#include + +#include "pcap-int.h" + +#include "pcap-common.h" + +#ifdef HAVE_OS_PROTO_H +#include "os-proto.h" +#endif + +#include "sf-pcap.h" + +/* + * Setting O_BINARY on DOS/Windows is a bit tricky + */ +#if defined(WIN32) + #define SET_BINMODE(f) _setmode(_fileno(f), _O_BINARY) +#elif defined(MSDOS) + #if defined(__HIGHC__) + #define SET_BINMODE(f) setmode(f, O_BINARY) + #else + #define SET_BINMODE(f) setmode(fileno(f), O_BINARY) + #endif +#endif + +/* + * Standard libpcap format. + */ +#define TCPDUMP_MAGIC 0xa1b2c3d4 + +/* + * Alexey Kuznetzov's modified libpcap format. + */ +#define KUZNETZOV_TCPDUMP_MAGIC 0xa1b2cd34 + +/* + * Reserved for Francisco Mesquita + * for another modified format. + */ +#define FMESQUITA_TCPDUMP_MAGIC 0xa1b234cd + +/* + * Navtel Communcations' format, with nanosecond timestamps, + * as per a request from Dumas Hwang . + */ +#define NAVTEL_TCPDUMP_MAGIC 0xa12b3c4d + +/* + * Normal libpcap format, except for seconds/nanoseconds timestamps, + * as per a request by Ulf Lamping + */ +#define NSEC_TCPDUMP_MAGIC 0xa1b23c4d + +/* + * Mechanism for storing information about a capture in the upper + * 6 bits of a linktype value in a capture file. + * + * LT_LINKTYPE_EXT(x) extracts the additional information. + * + * The rest of the bits are for a value describing the link-layer + * value. LT_LINKTYPE(x) extracts that value. + */ +#define LT_LINKTYPE(x) ((x) & 0x03FFFFFF) +#define LT_LINKTYPE_EXT(x) ((x) & 0xFC000000) + +static int pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **datap); + +/* + * Check whether this is a pcap savefile and, if it is, extract the + * relevant information from the header. + */ +int +pcap_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf) +{ + struct pcap_file_header hdr; + size_t amt_read; + + /* + * Check whether the first 4 bytes of the file are the magic + * number for a pcap savefile, or for a byte-swapped pcap + * savefile. + */ + if (magic != TCPDUMP_MAGIC && magic != KUZNETZOV_TCPDUMP_MAGIC) { + magic = SWAPLONG(magic); + if (magic != TCPDUMP_MAGIC && magic != KUZNETZOV_TCPDUMP_MAGIC) + return (0); /* nope */ + p->sf.swapped = 1; + } + + /* + * They are. Put the magic number in the header, and read + * the rest of the header. + */ + hdr.magic = magic; + amt_read = fread(((char *)&hdr) + sizeof hdr.magic, 1, + sizeof(hdr) - sizeof(hdr.magic), fp); + if (amt_read != sizeof(hdr) - sizeof(hdr.magic)) { + if (ferror(fp)) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "error reading dump file: %s", + pcap_strerror(errno)); + } else { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "truncated dump file; tried to read %lu file header bytes, only got %lu", + (unsigned long)sizeof(hdr), + (unsigned long)amt_read); + } + return (-1); + } + + /* + * If it's a byte-swapped capture file, byte-swap the header. + */ + if (p->sf.swapped) { + hdr.version_major = SWAPSHORT(hdr.version_major); + hdr.version_minor = SWAPSHORT(hdr.version_minor); + hdr.thiszone = SWAPLONG(hdr.thiszone); + hdr.sigfigs = SWAPLONG(hdr.sigfigs); + hdr.snaplen = SWAPLONG(hdr.snaplen); + hdr.linktype = SWAPLONG(hdr.linktype); + } + + if (hdr.version_major < PCAP_VERSION_MAJOR) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "archaic pcap savefile format"); + return (-1); + } + p->sf.version_major = hdr.version_major; + p->sf.version_minor = hdr.version_minor; + p->tzoff = hdr.thiszone; + p->snapshot = hdr.snaplen; + p->linktype = linktype_to_dlt(LT_LINKTYPE(hdr.linktype)); + p->linktype_ext = LT_LINKTYPE_EXT(hdr.linktype); + + p->sf.next_packet_op = pcap_next_packet; + + /* + * We interchanged the caplen and len fields at version 2.3, + * in order to match the bpf header layout. But unfortunately + * some files were written with version 2.3 in their headers + * but without the interchanged fields. + * + * In addition, DG/UX tcpdump writes out files with a version + * number of 543.0, and with the caplen and len fields in the + * pre-2.3 order. + */ + switch (hdr.version_major) { + + case 2: + if (hdr.version_minor < 3) + p->sf.lengths_swapped = SWAPPED; + else if (hdr.version_minor == 3) + p->sf.lengths_swapped = MAYBE_SWAPPED; + else + p->sf.lengths_swapped = NOT_SWAPPED; + break; + + case 543: + p->sf.lengths_swapped = SWAPPED; + break; + + default: + p->sf.lengths_swapped = NOT_SWAPPED; + break; + } + + if (magic == KUZNETZOV_TCPDUMP_MAGIC) { + /* + * XXX - the patch that's in some versions of libpcap + * changes the packet header but not the magic number, + * and some other versions with this magic number have + * some extra debugging information in the packet header; + * we'd have to use some hacks^H^H^H^H^Hheuristics to + * detect those variants. + * + * Ethereal does that, but it does so by trying to read + * the first two packets of the file with each of the + * record header formats. That currently means it seeks + * backwards and retries the reads, which doesn't work + * on pipes. We want to be able to read from a pipe, so + * that strategy won't work; we'd have to buffer some + * data ourselves and read from that buffer in order to + * make that work. + */ + p->sf.hdrsize = sizeof(struct pcap_sf_patched_pkthdr); + + if (p->linktype == DLT_EN10MB) { + /* + * This capture might have been done in raw mode + * or cooked mode. + * + * If it was done in cooked mode, p->snapshot was + * passed to recvfrom() as the buffer size, meaning + * that the most packet data that would be copied + * would be p->snapshot. However, a faked Ethernet + * header would then have been added to it, so the + * most data that would be in a packet in the file + * would be p->snapshot + 14. + * + * We can't easily tell whether the capture was done + * in raw mode or cooked mode, so we'll assume it was + * cooked mode, and add 14 to the snapshot length. + * That means that, for a raw capture, the snapshot + * length will be misleading if you use it to figure + * out why a capture doesn't have all the packet data, + * but there's not much we can do to avoid that. + */ + p->snapshot += 14; + } + } else + p->sf.hdrsize = sizeof(struct pcap_sf_pkthdr); + + /* + * Allocate a buffer for the packet data. + */ + p->bufsize = p->snapshot; + if (p->bufsize <= 0) + p->bufsize = BPF_MAXBUFSIZE; + p->buffer = malloc(p->bufsize); + if (p->buffer == NULL) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, "out of memory"); + return (-1); + } + + return (1); +} + +/* + * Read and return the next packet from the savefile. Return the header + * in hdr and a pointer to the contents in data. Return 0 on success, 1 + * if there were no more packets, and -1 on an error. + */ +static int +pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) +{ + struct pcap_sf_patched_pkthdr sf_hdr; + FILE *fp = p->sf.rfile; + size_t amt_read; + bpf_u_int32 t; + + /* + * Read the packet header; the structure we use as a buffer + * is the longer structure for files generated by the patched + * libpcap, but if the file has the magic number for an + * unpatched libpcap we only read as many bytes as the regular + * header has. + */ + amt_read = fread(&sf_hdr, 1, p->sf.hdrsize, fp); + if (amt_read != p->sf.hdrsize) { + if (ferror(fp)) { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "error reading dump file: %s", + pcap_strerror(errno)); + return (-1); + } else { + if (amt_read != 0) { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "truncated dump file; tried to read %lu header bytes, only got %lu", + (unsigned long)p->sf.hdrsize, + (unsigned long)amt_read); + return (-1); + } + /* EOF */ + return (1); + } + } + + if (p->sf.swapped) { + /* these were written in opposite byte order */ + hdr->caplen = SWAPLONG(sf_hdr.caplen); + hdr->len = SWAPLONG(sf_hdr.len); + hdr->ts.tv_sec = SWAPLONG(sf_hdr.ts.tv_sec); + hdr->ts.tv_usec = SWAPLONG(sf_hdr.ts.tv_usec); + } else { + hdr->caplen = sf_hdr.caplen; + hdr->len = sf_hdr.len; + hdr->ts.tv_sec = sf_hdr.ts.tv_sec; + hdr->ts.tv_usec = sf_hdr.ts.tv_usec; + } + /* Swap the caplen and len fields, if necessary. */ + switch (p->sf.lengths_swapped) { + + case NOT_SWAPPED: + break; + + case MAYBE_SWAPPED: + if (hdr->caplen <= hdr->len) { + /* + * The captured length is <= the actual length, + * so presumably they weren't swapped. + */ + break; + } + /* FALLTHROUGH */ + + case SWAPPED: + t = hdr->caplen; + hdr->caplen = hdr->len; + hdr->len = t; + break; + } + + if (hdr->caplen > p->bufsize) { + /* + * This can happen due to Solaris 2.3 systems tripping + * over the BUFMOD problem and not setting the snapshot + * correctly in the savefile header. If the caplen isn't + * grossly wrong, try to salvage. + */ + static u_char *tp = NULL; + static size_t tsize = 0; + + if (hdr->caplen > 65535) { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "bogus savefile header"); + return (-1); + } + + if (tsize < hdr->caplen) { + tsize = ((hdr->caplen + 1023) / 1024) * 1024; + if (tp != NULL) + free((u_char *)tp); + tp = (u_char *)malloc(tsize); + if (tp == NULL) { + tsize = 0; + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "BUFMOD hack malloc"); + return (-1); + } + } + amt_read = fread((char *)tp, 1, hdr->caplen, fp); + if (amt_read != hdr->caplen) { + if (ferror(fp)) { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "error reading dump file: %s", + pcap_strerror(errno)); + } else { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "truncated dump file; tried to read %u captured bytes, only got %lu", + hdr->caplen, (unsigned long)amt_read); + } + return (-1); + } + /* + * We can only keep up to p->bufsize bytes. Since + * caplen > p->bufsize is exactly how we got here, + * we know we can only keep the first p->bufsize bytes + * and must drop the remainder. Adjust caplen accordingly, + * so we don't get confused later as to how many bytes we + * have to play with. + */ + hdr->caplen = p->bufsize; + memcpy(p->buffer, (char *)tp, p->bufsize); + } else { + /* read the packet itself */ + amt_read = fread(p->buffer, 1, hdr->caplen, fp); + if (amt_read != hdr->caplen) { + if (ferror(fp)) { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "error reading dump file: %s", + pcap_strerror(errno)); + } else { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "truncated dump file; tried to read %u captured bytes, only got %lu", + hdr->caplen, (unsigned long)amt_read); + } + return (-1); + } + } + *data = p->buffer; + + if (p->sf.swapped) { + /* + * Convert pseudo-headers from the byte order of + * the host on which the file was saved to our + * byte order, as necessary. + */ + switch (p->linktype) { + + case DLT_USB_LINUX: + swap_linux_usb_header(hdr, *data, 0); + break; + + case DLT_USB_LINUX_MMAPPED: + swap_linux_usb_header(hdr, *data, 1); + break; + } + } + + return (0); +} + +static int +sf_write_header(FILE *fp, int linktype, int thiszone, int snaplen) +{ + struct pcap_file_header hdr; + + hdr.magic = TCPDUMP_MAGIC; + hdr.version_major = PCAP_VERSION_MAJOR; + hdr.version_minor = PCAP_VERSION_MINOR; + + hdr.thiszone = thiszone; + hdr.snaplen = snaplen; + hdr.sigfigs = 0; + hdr.linktype = linktype; + + if (fwrite((char *)&hdr, sizeof(hdr), 1, fp) != 1) + return (-1); + + return (0); +} + +/* + * Output a packet to the initialized dump file. + */ +void +pcap_dump(u_char *user, const struct pcap_pkthdr *h, const u_char *sp) +{ + register FILE *f; + struct pcap_sf_pkthdr sf_hdr; + + f = (FILE *)user; + sf_hdr.ts.tv_sec = h->ts.tv_sec; + sf_hdr.ts.tv_usec = h->ts.tv_usec; + sf_hdr.caplen = h->caplen; + sf_hdr.len = h->len; + /* XXX we should check the return status */ + (void)fwrite(&sf_hdr, sizeof(sf_hdr), 1, f); + (void)fwrite(sp, h->caplen, 1, f); +} + +static pcap_dumper_t * +pcap_setup_dump(pcap_t *p, int linktype, FILE *f, const char *fname) +{ + +#if defined(WIN32) || defined(MSDOS) + /* + * If we're writing to the standard output, put it in binary + * mode, as savefiles are binary files. + * + * Otherwise, we turn off buffering. + * XXX - why? And why not on the standard output? + */ + if (f == stdout) + SET_BINMODE(f); + else + setbuf(f, NULL); +#endif + if (sf_write_header(f, linktype, p->tzoff, p->snapshot) == -1) { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Can't write to %s: %s", + fname, pcap_strerror(errno)); + if (f != stdout) + (void)fclose(f); + return (NULL); + } + return ((pcap_dumper_t *)f); +} + +/* + * Initialize so that sf_write() will output to the file named 'fname'. + */ +pcap_dumper_t * +pcap_dump_open(pcap_t *p, const char *fname) +{ + FILE *f; + int linktype; + + /* + * If this pcap_t hasn't been activated, it doesn't have a + * link-layer type, so we can't use it. + */ + if (!p->activated) { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "%s: not-yet-activated pcap_t passed to pcap_dump_open", + fname); + return (NULL); + } + linktype = dlt_to_linktype(p->linktype); + if (linktype == -1) { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "%s: link-layer type %d isn't supported in savefiles", + fname, p->linktype); + return (NULL); + } + linktype |= p->linktype_ext; + + if (fname[0] == '-' && fname[1] == '\0') { + f = stdout; + fname = "standard output"; + } else { +#if !defined(WIN32) && !defined(MSDOS) + f = fopen(fname, "w"); +#else + f = fopen(fname, "wb"); +#endif + if (f == NULL) { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s", + fname, pcap_strerror(errno)); + return (NULL); + } + } + return (pcap_setup_dump(p, linktype, f, fname)); +} + +/* + * Initialize so that sf_write() will output to the given stream. + */ +pcap_dumper_t * +pcap_dump_fopen(pcap_t *p, FILE *f) +{ + int linktype; + + linktype = dlt_to_linktype(p->linktype); + if (linktype == -1) { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "stream: link-layer type %d isn't supported in savefiles", + p->linktype); + return (NULL); + } + linktype |= p->linktype_ext; + + return (pcap_setup_dump(p, linktype, f, "stream")); +} + +FILE * +pcap_dump_file(pcap_dumper_t *p) +{ + return ((FILE *)p); +} + +long +pcap_dump_ftell(pcap_dumper_t *p) +{ + return (ftell((FILE *)p)); +} + +int +pcap_dump_flush(pcap_dumper_t *p) +{ + + if (fflush((FILE *)p) == EOF) + return (-1); + else + return (0); +} + +void +pcap_dump_close(pcap_dumper_t *p) +{ + +#ifdef notyet + if (ferror((FILE *)p)) + return-an-error; + /* XXX should check return from fclose() too */ +#endif + (void)fclose((FILE *)p); +} diff --git a/libpcap/sf-pcap.h b/libpcap/sf-pcap.h new file mode 100644 index 000000000..3b3fbe893 --- /dev/null +++ b/libpcap/sf-pcap.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * sf-pcap.h - libpcap-file-format-specific routines + * Extraction/creation by Jeffrey Mogul, DECWRL + * Modified by Steve McCanne, LBL. + * + * Used to save the received packet headers, after filtering, to + * a file, and then read them later. + * The first record in the file contains saved values for the machine + * dependent values so we can print the dump file on any architecture. + */ + +#ifndef sf_pcap_h +#define sf_pcap_h + +extern int pcap_check_header(pcap_t *, bpf_u_int32, FILE *, char *); + +#endif diff --git a/libpcap/sunatmpos.h b/libpcap/sunatmpos.h index 7538b2a9b..916017fa9 100644 --- a/libpcap/sunatmpos.h +++ b/libpcap/sunatmpos.h @@ -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/sunatmpos.h,v 1.1 2002/07/11 09:06:47 guy Exp $ (LBL) + * @(#) $Header: /tcpdump/master/libpcap/sunatmpos.h,v 1.1 2002-07-11 09:06:47 guy Exp $ (LBL) */ /* SunATM header for ATM packet */ diff --git a/libpcap/tokdefs.h b/libpcap/tokdefs.h index bf67e9ddd..1a60ea666 100644 --- a/libpcap/tokdefs.h +++ b/libpcap/tokdefs.h @@ -267,7 +267,7 @@ typedef union YYSTYPE { /* Line 1676 of yacc.c */ -#line 241 "grammar.y" +#line 242 "grammar.y" int i; bpf_u_int32 h;