From 74e9dc92b229a3f9fc2d34a0b9c982573f75d315 Mon Sep 17 00:00:00 2001 From: christos Date: Wed, 19 Nov 2014 18:04:51 +0000 Subject: [PATCH] import newest libpcap --- external/bsd/libpcap/dist/CHANGES | 79 ++- external/bsd/libpcap/dist/CREDITS | 2 +- external/bsd/libpcap/dist/INSTALL.txt | 13 +- external/bsd/libpcap/dist/Makefile.in | 22 +- external/bsd/libpcap/dist/README | 2 - external/bsd/libpcap/dist/README.aix | 5 + .../libpcap/dist/SUNOS4/nit_if.o.sun4c.4.0.3c | Bin 5289 -> 5290 bytes external/bsd/libpcap/dist/VERSION | 2 +- .../bsd/libpcap/dist/Win32/Include/Gnuc.h | 4 - .../bsd/libpcap/dist/Win32/Include/addrinfo.h | 4 - .../libpcap/dist/Win32/Include/arpa/nameser.h | 2 - .../bsd/libpcap/dist/Win32/Include/bittypes.h | 2 - .../libpcap/dist/Win32/Include/cdecl_ext.h | 2 - .../libpcap/dist/Win32/Include/inetprivate.h | 2 - .../bsd/libpcap/dist/Win32/Include/ip6_misc.h | 4 - .../bsd/libpcap/dist/Win32/Include/net/if.h | 2 - .../libpcap/dist/Win32/Include/net/netdb.h | 2 - .../libpcap/dist/Win32/Include/net/paths.h | 2 - .../libpcap/dist/Win32/Include/sockstorage.h | 2 - external/bsd/libpcap/dist/Win32/Src/ffs.c | 2 - .../bsd/libpcap/dist/Win32/Src/gai_strerror.c | 2 - .../bsd/libpcap/dist/Win32/Src/getaddrinfo.c | 7 - .../bsd/libpcap/dist/Win32/Src/getnetbynm.c | 2 - .../bsd/libpcap/dist/Win32/Src/getnetent.c | 2 - external/bsd/libpcap/dist/Win32/Src/getopt.c | 2 - .../bsd/libpcap/dist/Win32/Src/getservent.c | 2 - .../bsd/libpcap/dist/Win32/Src/inet_aton.c | 9 - .../bsd/libpcap/dist/Win32/Src/inet_net.c | 2 - .../bsd/libpcap/dist/Win32/Src/inet_pton.c | 9 - external/bsd/libpcap/dist/aclocal.m4 | 2 - external/bsd/libpcap/dist/arcnet.h | 4 - external/bsd/libpcap/dist/atmuni31.h | 4 - external/bsd/libpcap/dist/bpf_dump.c | 6 - external/bsd/libpcap/dist/bpf_image.c | 27 +- external/bsd/libpcap/dist/config.guess | 258 ++++---- external/bsd/libpcap/dist/config.h.in | 3 + external/bsd/libpcap/dist/config.sub | 211 ++++-- external/bsd/libpcap/dist/configure | 239 +++++-- external/bsd/libpcap/dist/configure.in | 191 ++++-- external/bsd/libpcap/dist/dlpisubs.c | 8 +- external/bsd/libpcap/dist/dlpisubs.h | 6 - external/bsd/libpcap/dist/etherent.c | 7 - external/bsd/libpcap/dist/ethertype.h | 4 - external/bsd/libpcap/dist/fad-getad.c | 64 +- external/bsd/libpcap/dist/fad-gifc.c | 12 +- external/bsd/libpcap/dist/fad-glifc.c | 12 +- external/bsd/libpcap/dist/fad-null.c | 7 - external/bsd/libpcap/dist/fad-sita.c | 4 - external/bsd/libpcap/dist/fad-win32.c | 111 +--- external/bsd/libpcap/dist/gencode.h | 11 +- external/bsd/libpcap/dist/ieee80211.h | 2 - external/bsd/libpcap/dist/inet.c | 309 ++++++--- external/bsd/libpcap/dist/lbl/os-aix4.h | 4 - external/bsd/libpcap/dist/lbl/os-hpux11.h | 4 - external/bsd/libpcap/dist/lbl/os-osf4.h | 4 - external/bsd/libpcap/dist/lbl/os-osf5.h | 4 - external/bsd/libpcap/dist/lbl/os-solaris2.h | 4 - external/bsd/libpcap/dist/lbl/os-sunos4.h | 4 - external/bsd/libpcap/dist/lbl/os-ultrix4.h | 4 - external/bsd/libpcap/dist/llc.h | 39 +- external/bsd/libpcap/dist/missing/snprintf.c | 9 - external/bsd/libpcap/dist/msdos/bin2c.c | 2 - external/bsd/libpcap/dist/msdos/common.dj | 1 - external/bsd/libpcap/dist/msdos/makefile.dj | 1 - external/bsd/libpcap/dist/msdos/ndis2.c | 2 - external/bsd/libpcap/dist/msdos/ndis2.h | 2 - external/bsd/libpcap/dist/msdos/pktdrvr.c | 2 - external/bsd/libpcap/dist/msdos/pktdrvr.h | 2 - external/bsd/libpcap/dist/msdos/readme.dos | 2 - external/bsd/libpcap/dist/nametoaddr.c | 7 - external/bsd/libpcap/dist/nlpid.h | 4 - external/bsd/libpcap/dist/pcap-bpf.h | 4 - external/bsd/libpcap/dist/pcap-bt-linux.c | 6 - external/bsd/libpcap/dist/pcap-bt-linux.h | 4 - .../bsd/libpcap/dist/pcap-bt-monitor-linux.c | 241 +++++++ .../bsd/libpcap/dist/pcap-bt-monitor-linux.h | 32 + external/bsd/libpcap/dist/pcap-can-linux.c | 4 +- external/bsd/libpcap/dist/pcap-can-linux.h | 2 - external/bsd/libpcap/dist/pcap-canusb-linux.c | 2 - external/bsd/libpcap/dist/pcap-canusb-linux.h | 2 - external/bsd/libpcap/dist/pcap-common.c | 196 +++++- external/bsd/libpcap/dist/pcap-common.h | 6 +- external/bsd/libpcap/dist/pcap-dag.c | 9 +- external/bsd/libpcap/dist/pcap-dag.h | 4 - external/bsd/libpcap/dist/pcap-dbus.c | 2 - external/bsd/libpcap/dist/pcap-dbus.h | 2 - external/bsd/libpcap/dist/pcap-dlpi.c | 115 ++-- external/bsd/libpcap/dist/pcap-dos.c | 6 +- external/bsd/libpcap/dist/pcap-dos.h | 4 - external/bsd/libpcap/dist/pcap-enet.c | 6 - .../bsd/libpcap/dist/pcap-filter.manmisc.in | 89 ++- external/bsd/libpcap/dist/pcap-int.h | 36 +- external/bsd/libpcap/dist/pcap-libdlpi.c | 64 +- .../bsd/libpcap/dist/pcap-linktype.manmisc.in | 4 +- external/bsd/libpcap/dist/pcap-linux.c | 624 +++++++++++------- .../bsd/libpcap/dist/pcap-netfilter-linux.c | 13 +- .../bsd/libpcap/dist/pcap-netfilter-linux.h | 2 - external/bsd/libpcap/dist/pcap-nit.c | 8 +- external/bsd/libpcap/dist/pcap-null.c | 6 - external/bsd/libpcap/dist/pcap-pf.c | 9 +- .../bsd/libpcap/dist/pcap-savefile.manfile.in | 5 +- external/bsd/libpcap/dist/pcap-septel.c | 16 +- external/bsd/libpcap/dist/pcap-septel.h | 4 - external/bsd/libpcap/dist/pcap-sita.c | 4 - external/bsd/libpcap/dist/pcap-sita.h | 4 - external/bsd/libpcap/dist/pcap-snf.c | 4 +- external/bsd/libpcap/dist/pcap-snf.h | 2 - external/bsd/libpcap/dist/pcap-snit.c | 9 +- external/bsd/libpcap/dist/pcap-snoop.c | 6 - external/bsd/libpcap/dist/pcap-stdinc.h | 60 +- .../bsd/libpcap/dist/pcap-tstamp.manmisc.in | 6 +- external/bsd/libpcap/dist/pcap-usb-linux.c | 17 +- external/bsd/libpcap/dist/pcap-usb-linux.h | 4 - external/bsd/libpcap/dist/pcap-win32.c | 133 +++- external/bsd/libpcap/dist/pcap/bluetooth.h | 15 +- external/bsd/libpcap/dist/pcap/ipnet.h | 2 - external/bsd/libpcap/dist/pcap/namedb.h | 4 - external/bsd/libpcap/dist/pcap/nflog.h | 92 +++ external/bsd/libpcap/dist/pcap/sll.h | 4 - external/bsd/libpcap/dist/pcap/usb.h | 4 - external/bsd/libpcap/dist/pcap/vlan.h | 4 - external/bsd/libpcap/dist/pcap_activate.3pcap | 4 +- .../bsd/libpcap/dist/pcap_breakloop.3pcap | 2 - .../bsd/libpcap/dist/pcap_can_set_rfmon.3pcap | 2 - external/bsd/libpcap/dist/pcap_close.3pcap | 2 - .../bsd/libpcap/dist/pcap_compile.3pcap.in | 4 +- external/bsd/libpcap/dist/pcap_create.3pcap | 2 - .../bsd/libpcap/dist/pcap_datalink.3pcap.in | 4 +- .../dist/pcap_datalink_name_to_val.3pcap | 2 - .../dist/pcap_datalink_val_to_name.3pcap | 10 +- external/bsd/libpcap/dist/pcap_dump.3pcap | 2 - .../bsd/libpcap/dist/pcap_dump_close.3pcap | 2 - .../bsd/libpcap/dist/pcap_dump_file.3pcap | 2 - .../bsd/libpcap/dist/pcap_dump_flush.3pcap | 2 - .../bsd/libpcap/dist/pcap_dump_ftell.3pcap | 2 - external/bsd/libpcap/dist/pcap_file.3pcap | 2 - external/bsd/libpcap/dist/pcap_fileno.3pcap | 4 +- .../bsd/libpcap/dist/pcap_findalldevs.3pcap | 12 +- external/bsd/libpcap/dist/pcap_freecode.3pcap | 2 - .../libpcap/dist/pcap_get_selectable_fd.3pcap | 4 +- .../dist/pcap_get_tstamp_precision.3pcap.in | 9 +- external/bsd/libpcap/dist/pcap_geterr.3pcap | 2 - external/bsd/libpcap/dist/pcap_inject.3pcap | 2 - .../bsd/libpcap/dist/pcap_is_swapped.3pcap | 4 +- .../bsd/libpcap/dist/pcap_lib_version.3pcap | 2 - .../libpcap/dist/pcap_list_datalinks.3pcap.in | 4 +- .../bsd/libpcap/dist/pcap_lookupdev.3pcap | 2 - .../bsd/libpcap/dist/pcap_lookupnet.3pcap | 2 - external/bsd/libpcap/dist/pcap_loop.3pcap | 4 +- .../bsd/libpcap/dist/pcap_major_version.3pcap | 4 +- external/bsd/libpcap/dist/pcap_next_ex.3pcap | 8 +- .../libpcap/dist/pcap_offline_filter.3pcap | 4 +- .../bsd/libpcap/dist/pcap_open_dead.3pcap.in | 2 - .../bsd/libpcap/dist/pcap_open_live.3pcap | 2 - .../libpcap/dist/pcap_set_buffer_size.3pcap | 2 - .../bsd/libpcap/dist/pcap_set_datalink.3pcap | 2 - .../dist/pcap_set_immediate_mode.3pcap | 2 +- .../bsd/libpcap/dist/pcap_set_promisc.3pcap | 2 - .../bsd/libpcap/dist/pcap_set_rfmon.3pcap | 2 - .../bsd/libpcap/dist/pcap_set_snaplen.3pcap | 2 - .../bsd/libpcap/dist/pcap_set_timeout.3pcap | 4 +- .../bsd/libpcap/dist/pcap_setdirection.3pcap | 2 - .../bsd/libpcap/dist/pcap_setfilter.3pcap | 4 +- .../bsd/libpcap/dist/pcap_setnonblock.3pcap | 2 - external/bsd/libpcap/dist/pcap_snapshot.3pcap | 4 +- external/bsd/libpcap/dist/pcap_stats.3pcap | 2 - .../bsd/libpcap/dist/pcap_statustostr.3pcap | 2 - external/bsd/libpcap/dist/pcap_strerror.3pcap | 2 - .../dist/pcap_tstamp_type_val_to_name.3pcap | 8 +- external/bsd/libpcap/dist/ppp.h | 3 - external/bsd/libpcap/dist/runlex.sh | 2 - external/bsd/libpcap/dist/savefile.c | 7 - external/bsd/libpcap/dist/sf-pcap-ng.h | 2 - external/bsd/libpcap/dist/sf-pcap.h | 2 - external/bsd/libpcap/dist/sunatmpos.h | 4 - external/bsd/libpcap/dist/tests/capturetest.c | 287 ++++++++ external/bsd/libpcap/dist/tests/filtertest.c | 25 +- .../bsd/libpcap/dist/tests/findalldevstest.c | 2 - external/bsd/libpcap/dist/tests/opentest.c | 2 - .../bsd/libpcap/dist/tests/reactivatetest.c | 2 - external/bsd/libpcap/dist/tests/selpolltest.c | 2 - .../bsd/libpcap/dist/tests/valgrindtest.c | 4 - 182 files changed, 2685 insertions(+), 1514 deletions(-) create mode 100644 external/bsd/libpcap/dist/pcap-bt-monitor-linux.c create mode 100644 external/bsd/libpcap/dist/pcap-bt-monitor-linux.h create mode 100644 external/bsd/libpcap/dist/pcap/nflog.h create mode 100644 external/bsd/libpcap/dist/tests/capturetest.c diff --git a/external/bsd/libpcap/dist/CHANGES b/external/bsd/libpcap/dist/CHANGES index 75decb78900e..eb73e28d77f0 100644 --- a/external/bsd/libpcap/dist/CHANGES +++ b/external/bsd/libpcap/dist/CHANGES @@ -1,3 +1,47 @@ +Monday Aug. 12, 2014 guy@alum.mit.edu + Summary for 1.6.2 tcpdump release + Don't crash on filters testing a non-existent link-layer type + field. + Fix sending in non-blocking mode on Linux with memory-mapped + capture. + Fix timestamps when reading pcap-ng files on big-endian + machines. + +Saturday Jul. 19, 2014 mcr@sandelman.ca + Summary for 1.6.1 tcpdump release + some fixes for the any device + changes for how --enable-XXX works + +Wednesday Jul. 2, 2014 mcr@sandelman.ca + Summary for 1.6.0 tcpdump release + Don't support D-Bus sniffing on OS X + fixes for byte order issues with NFLOG captures + Handle using cooked mode for DLT_NETLINK in activate_new(). + on platforms where you can not capture on down interfaces, do not list them + but: do list interfaces which are down, if you can capture on them! + +Wednesday December 18, 2013 guy@alum.mit.edu +Summary for 1.5.3 libpcap release + Don't let packets that don't match the current filter get to the + application when TPACKET_V3 is used. (GitHub issue #331) + Fix handling of pcap_loop()/pcap_dispatch() with a packet count + of 0 on some platforms (including Linux with TPACKET_V3). + (GitHub issue #333) + Work around TPACKET_V3 deficiency that causes packets to be lost + when a timeout of 0 is specified. (GitHub issue #335) + Man page formatting fixes. + +Wednesday December 4, 2013 guy@alum.mit.edu +Summary for 1.5.2 libpcap release + Fix libpcap to work when compiled with TPACKET_V3 support and + running on a kernel without TPACKET_V3 support. (GitHub + issue #329) + +Wednesday November 20, 2013 guy@alum.mit.edu +Summary for 1.5.1 libpcap release + Report an error, rather than crashing, if an IPv6 address is + used for link-layer filtering. (Wireshark bug 9376) + Wednesday October 30, 2013 guy@alum.mit.edu Summary for 1.5.0 libpcap release TPACKET_V3 support added for Linux @@ -7,7 +51,8 @@ Summary for 1.5.0 libpcap release Fixed build on Solaris 11 Support filtering filtering E1 SS7 traffic on MTP2 layer Annex A Use "ln -s" to link man pages by default - Added pcap_open_dead_with_tstamp_precision API interface. + Add support for getting nanosecond-resolution time stamps when + capturing and reading capture files Many changes to autoconf to deal better with non-GCC compilers added many new DLT types @@ -221,7 +266,7 @@ Mon. October 27, 2008. ken@netfunctional.ca. Summary for 1.0.0 libpcap rele DLT: Add JUNIPER_ST 802.15.4 support Variable length 802.11 header support - X2E data type 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 @@ -233,7 +278,7 @@ Mon. October 27, 2008. ken@netfunctional.ca. Summary for 1.0.0 libpcap rele can print better diagnostic information Return PCAP_ERROR_PERM_DENIED if we don't have permission to open a device, so applications can tell the user they need to go play with permissions - On Linux, ignore ENETDOWN so we can continue to capture packets if the + 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/bpf* and launchd plist @@ -246,14 +291,14 @@ Mon. September 10, 2007. ken@xelerance.com. Summary for 0.9.8 libpcap relea Change build process to put public libpcap headers into pcap subir DLT: Add value for IPMI IPMB packets DLT: Add value for u10 Networks boards - Require for pf definitions - allows reading of pflog formatted + Require for pf definitions - allows reading of pflog formatted libpcap files on an OS other than where the file was generated Wed. April 25, 2007. ken@xelerance.com. Summary for 0.9.6 libpcap release Put the public libpcap headers into a pcap subdirectory in both the source directory and the target include directory, and have include - files at the top-level directory to include those headers, for + files at the top-level directory to include those headers, for backwards compatibility. Add Bluetooth support Add USB capturing support on Linux @@ -261,30 +306,30 @@ Wed. April 25, 2007. ken@xelerance.com. Summary for 0.9.6 libpcap release Add support for new FreeBSD BIOCSDIRECTION ioctl Add additional filter operations for 802.11 frame types Add support for filtering on MTP2 frame types - Propagate some changes from the main branch, so the x.9 branch has + Propagate some changes from the main branch, so the x.9 branch has all the DLT_ and LINKTYPE_ values that the main branch does - Reserved a DLT_ and SAVEFILE_ value for PPI (Per Packet Info) + Reserved a DLT_ and SAVEFILE_ value for PPI (Per Packet Info) encapsulated packets - Add LINKTYPE_ for IEEE 802.15.4, with address fields padded as done + Add LINKTYPE_ for IEEE 802.15.4, with address fields padded as done by Linux drivers Add LINKTYPE_ value corresponding to DLT_IEEE802_16_MAC_CPS. Add DLT for IEEE 802.16 (WiMAX) MAC Common Part Sublayer Add DLT for Bluetooth HCI UART transport layer When building a shared library, build with "-fPIC" on Linux to support x86_64 - Link with "$(CC) -shared" rather than "ld -shared" when building a + Link with "$(CC) -shared" rather than "ld -shared" when building a ".so" shared library Add support for autoconf 2.60 Fixes to discard unread packets when changing filters - Changes to handle name changes in the DAG library resulting from + Changes to handle name changes in the DAG library resulting from switching to libtool. Add support for new DAG ERF types. - Add an explicit "-ldag" when building the shared library, so the DAG + Add an explicit "-ldag" when building the shared library, so the DAG library dependency is explicit. Mac OSX fixes for dealing with "wlt" devices Fixes in add_or_find_if() & pcap_findalldevs() to optimize generating device lists Fixed a bug in pcap_open_live(). The return value of PacketSetHwFilter - was not checked. + was not checked. Tue. September 19, 2006. ken@xelerance.com. Summary for 0.9.5 libpcap release @@ -296,19 +341,19 @@ Tue. September 19, 2006. ken@xelerance.com. Summary for 0.9.5 libpcap release OP_PACKET now matches the beginning of the packet, instead of beginning+link-layer Add DLT/LINKTYPE for carrying FRF.16 Multi-link Frame Relay - Fix allocation of buffer for list of link-layer types + Fix allocation of buffer for list of link-layer types Added a new DLT and LINKTYPE value for ARINC 653 Interpartition Communcation Messages Fixed a typo in a DLT value: it should start with DLT_ and not LINKTYPE_ Redefined DLT_CAN20B and LINKTYPE_CAN20B as #190 (as this is the right value for CAN). Added definition for DLT_A429 and LINKTYPE_A429 as #184. Added a new DLT and LINKTYPE value for CAN v2.0B frames. Add support for DLT_JUNIPER_VP. - Don't double-count received packets on Linux systems that - support the PACKET_STATISTICS getsockopt() argument on + Don't double-count received packets on Linux systems that + support the PACKET_STATISTICS getsockopt() argument on PF_PACKET sockets. - Add support for DLT_IEEE802_11 and DLT_IEEE802_11_RADIO link + Add support for DLT_IEEE802_11 and DLT_IEEE802_11_RADIO link layers in Windows - Add support to build libpcap.lib and wpcap.dll under Cygnus and + Add support to build libpcap.lib and wpcap.dll under Cygnus and MingW32. Mon. September 5, 2005. ken@xelerance.com. Summary for 0.9.4 libpcap release diff --git a/external/bsd/libpcap/dist/CREDITS b/external/bsd/libpcap/dist/CREDITS index 69cbbf0444e2..dfc4e411036d 100644 --- a/external/bsd/libpcap/dist/CREDITS +++ b/external/bsd/libpcap/dist/CREDITS @@ -111,7 +111,7 @@ Additional people who have contributed patches: Márton Németh Matthew Luckie Max Laier - Michal Labedzki + Michal Labedzki Michal Sekletar Mike Frysinger Mike Kershaw diff --git a/external/bsd/libpcap/dist/INSTALL.txt b/external/bsd/libpcap/dist/INSTALL.txt index ffb69b981d3b..7bbbf0cb8e1c 100644 --- a/external/bsd/libpcap/dist/INSTALL.txt +++ b/external/bsd/libpcap/dist/INSTALL.txt @@ -1,5 +1,3 @@ -@(#) 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 appropriate Makefile from Makefile.in. Next run "make". If everything @@ -31,19 +29,14 @@ where the configure scripts fails to detect it. You will need an ANSI C compiler to build libpcap. The configure script will abort if your compiler is not ANSI compliant. If this happens, use -the GNU C compiler, available via anonymous ftp: - - ftp://ftp.gnu.org/pub/gnu/gcc/ +the generally available GNU C compiler (GCC). If you use flex, you must use version 2.4.6 or higher. The configure script automatically detects the version of flex and will not use it unless it is new enough. You can use "flex -V" to see what version you have (unless it's really old). The current version of flex is available -via anonymous ftp: - - ftp://ftp.ee.lbl.gov/flex-*.tar.Z - -As of this writing, the current version is 2.5.4. +at flex.sourceforge.net and often comes packaged by means of the OS. +As of this writing, the current version is 2.5.37. If you use bison, you must use flex (and visa versa). The configure script automatically falls back to lex and yacc if both flex and bison diff --git a/external/bsd/libpcap/dist/Makefile.in b/external/bsd/libpcap/dist/Makefile.in index 0b0e69c06709..1c2d7459943f 100644 --- a/external/bsd/libpcap/dist/Makefile.in +++ b/external/bsd/libpcap/dist/Makefile.in @@ -16,8 +16,6 @@ # 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. -# -# @(#) 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) @@ -85,7 +83,7 @@ YACC = @V_YACC@ @rm -f $@ $(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c -PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @CAN_SRC@ @NETFILTER_SRC@ @CANUSB_SRC@ @DBUS_SRC@ +PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @CAN_SRC@ @NETFILTER_SRC@ @CANUSB_SRC@ @DBUS_SRC@ FSRC = fad-@V_FINDALLDEVS@.c SSRC = @SSRC@ CSRC = pcap.c inet.c gencode.c optimize.c nametoaddr.c etherent.c \ @@ -107,6 +105,7 @@ PUBHDR = \ pcap/bluetooth.h \ pcap/ipnet.h \ pcap/namedb.h \ + pcap/nflog.h \ pcap/pcap.h \ pcap/sll.h \ pcap/vlan.h \ @@ -129,17 +128,17 @@ HDR = $(PUBHDR) \ sunatmpos.h TESTS = \ + capturetest \ filtertest \ findalldevstest \ - nonblocktest \ opentest \ selpolltest \ valgrindtest TESTS_SRC = \ + tests/capturetest.c \ tests/filtertest.c \ tests/findalldevstest.c \ - tests/nonblocktest.c \ tests/opentest.c \ tests/reactivatetest.c \ tests/selpolltest.c \ @@ -296,6 +295,8 @@ EXTRA_DIST = \ pcap-bpf.c \ pcap-bt-linux.c \ pcap-bt-linux.h \ + pcap-bt-monitor-linux.c \ + pcap-bt-monitor-linux.h \ pcap-can-linux.c \ pcap-can-linux.h \ pcap-canusb-linux.c \ @@ -526,15 +527,15 @@ pcap-config: $(srcdir)/pcap-config.in ./config.status # tests: $(TESTS) +capturetest: tests/capturetest.c libpcap.a + $(CC) $(FULL_CFLAGS) -I. -L. -o capturetest $(srcdir)/tests/capturetest.c libpcap.a $(LIBS) + filtertest: tests/filtertest.c libpcap.a $(CC) $(FULL_CFLAGS) -I. -L. -o filtertest $(srcdir)/tests/filtertest.c libpcap.a $(LIBS) findalldevstest: tests/findalldevstest.c libpcap.a $(CC) $(FULL_CFLAGS) -I. -L. -o findalldevstest $(srcdir)/tests/findalldevstest.c libpcap.a $(LIBS) -nonblocktest: tests/nonblocktest.c libpcap.a - $(CC) $(FULL_CFLAGS) -I. -L. -o nonblocktest $(srcdir)/tests/nonblocktest.c libpcap.a $(LIBS) - opentest: tests/opentest.c libpcap.a $(CC) $(FULL_CFLAGS) -I. -L. -o opentest $(srcdir)/tests/opentest.c libpcap.a $(LIBS) @@ -605,6 +606,8 @@ install: install-shared install-archive pcap-config $(LN_S) pcap_open_offline.3pcap pcap_fopen_offline.3pcap && \ rm -f pcap_fopen_offline_with_tstamp_precision.3pcap && \ $(LN_S) pcap_open_offline.3pcap pcap_fopen_offline_with_tstamp_precision.3pcap && \ + rm -f pcap_tstamp_type_val_to_description.3pcap && \ + $(LN_S) pcap_tstamp_type_val_to_name.3pcap pcap_tstamp_type_val_to_description.3pcap && \ rm -f pcap_getnonblock.3pcap && \ $(LN_S) pcap_setnonblock.3pcap pcap_getnonblock.3pcap) for i in $(MANFILE); do \ @@ -688,6 +691,7 @@ uninstall: uninstall-shared rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline_with_tstamp_precision.3pcap rm -f $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap + rm -f $(DESTDIR)$(mandir)/man3/pcap_tstamp_type_val_to_description.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 \ @@ -741,4 +745,4 @@ releasetar: rm -rf $$name depend: $(GENSRC) $(GENHDR) bpf_filter.c - $(MKDEP) -c $(CC) -m $(DEPENDENCY_CFLAG) $(DEFS) $(INCLS) $(SRC) + $(MKDEP) -c $(CC) -m $(CFLAGS) $(DEPENDENCY_CFLAG) $(DEFS) $(INCLS) $(SRC) diff --git a/external/bsd/libpcap/dist/README b/external/bsd/libpcap/dist/README index 3f4a26f39b26..46fcc5689e70 100644 --- a/external/bsd/libpcap/dist/README +++ b/external/bsd/libpcap/dist/README @@ -1,5 +1,3 @@ -@(#) Header: /tcpdump/master/libpcap/README,v 1.34 2008-12-14 19:44:14 guy Exp (LBL) - LIBPCAP 1.x.y www.tcpdump.org diff --git a/external/bsd/libpcap/dist/README.aix b/external/bsd/libpcap/dist/README.aix index 74cd9af65146..f457df321702 100644 --- a/external/bsd/libpcap/dist/README.aix +++ b/external/bsd/libpcap/dist/README.aix @@ -11,6 +11,11 @@ Using BPF: same, and the configure script should detect that it's on an AIX system and choose BPF even if the devices aren't there. + Also note that tcpdump _binary_ compiled on AIX 4 may have a problem + doing the initial loading of the BPF driver if copied to AIX 5 and + run there (GH #52). tcpdump binary natively compiled on AIX 5 should + not have this issue. + (2) If libpcap doesn't compile on your machine when configured to use BPF, or if the workarounds fail to make it work correctly, you should send to tcpdump-workers@lists.tcpdump.org a detailed bug diff --git a/external/bsd/libpcap/dist/SUNOS4/nit_if.o.sun4c.4.0.3c b/external/bsd/libpcap/dist/SUNOS4/nit_if.o.sun4c.4.0.3c index 3ae25d7546cb8f9e3aa8717d0eb7400c4fbdd6be..cb2a4fe232a1ac7c9cefd35c595e040364a908d4 100644 GIT binary patch delta 9 QcmZ3fxk_`xN)bjb024X`9smFU delta 7 OcmZ3bxl(h(N)Z4J3Ih`W diff --git a/external/bsd/libpcap/dist/VERSION b/external/bsd/libpcap/dist/VERSION index 4cda8f19edc7..fdd3be6df54a 100644 --- a/external/bsd/libpcap/dist/VERSION +++ b/external/bsd/libpcap/dist/VERSION @@ -1 +1 @@ -1.5.2 +1.6.2 diff --git a/external/bsd/libpcap/dist/Win32/Include/Gnuc.h b/external/bsd/libpcap/dist/Win32/Include/Gnuc.h index b891a7bcdf9f..aa4959873796 100644 --- a/external/bsd/libpcap/dist/Win32/Include/Gnuc.h +++ b/external/bsd/libpcap/dist/Win32/Include/Gnuc.h @@ -1,7 +1,3 @@ -/* $NetBSD: Gnuc.h,v 1.1.1.3 2013/04/06 15:57:51 christos Exp $ */ - -/* @(#) Header: /tcpdump/master/libpcap/Win32/Include/Gnuc.h,v 1.1 2002-08-01 08:33:05 risso Exp (LBL) */ - /* Define __P() macro, if necessary */ #ifndef __P diff --git a/external/bsd/libpcap/dist/Win32/Include/addrinfo.h b/external/bsd/libpcap/dist/Win32/Include/addrinfo.h index 1dcf74950274..4db7384af205 100644 --- a/external/bsd/libpcap/dist/Win32/Include/addrinfo.h +++ b/external/bsd/libpcap/dist/Win32/Include/addrinfo.h @@ -1,5 +1,3 @@ -/* $NetBSD: addrinfo.h,v 1.1.1.3 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. * All rights reserved. @@ -29,8 +27,6 @@ * SUCH DAMAGE. */ -/* Id: addrinfo.h,v 1.1 2002-08-01 08:33:05 risso Exp */ - #ifndef HAVE_ADDRINFO /* diff --git a/external/bsd/libpcap/dist/Win32/Include/arpa/nameser.h b/external/bsd/libpcap/dist/Win32/Include/arpa/nameser.h index b1baf4f3c3d6..18f185cf5b34 100644 --- a/external/bsd/libpcap/dist/Win32/Include/arpa/nameser.h +++ b/external/bsd/libpcap/dist/Win32/Include/arpa/nameser.h @@ -1,5 +1,3 @@ -/* $NetBSD: nameser.h,v 1.1.1.2 2013/04/06 15:57:51 christos Exp $ */ - /* * ++Copyright++ 1983, 1989, 1993 * - diff --git a/external/bsd/libpcap/dist/Win32/Include/bittypes.h b/external/bsd/libpcap/dist/Win32/Include/bittypes.h index 1d77174840b9..7c0cbdeb5f3b 100644 --- a/external/bsd/libpcap/dist/Win32/Include/bittypes.h +++ b/external/bsd/libpcap/dist/Win32/Include/bittypes.h @@ -1,5 +1,3 @@ -/* $NetBSD: bittypes.h,v 1.1.1.2 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (C) 1999 WIDE Project. * All rights reserved. diff --git a/external/bsd/libpcap/dist/Win32/Include/cdecl_ext.h b/external/bsd/libpcap/dist/Win32/Include/cdecl_ext.h index 7912c72594f9..9591db264574 100644 --- a/external/bsd/libpcap/dist/Win32/Include/cdecl_ext.h +++ b/external/bsd/libpcap/dist/Win32/Include/cdecl_ext.h @@ -1,5 +1,3 @@ -/* $NetBSD: cdecl_ext.h,v 1.1.1.2 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (C) 1999 WIDE Project. * All rights reserved. diff --git a/external/bsd/libpcap/dist/Win32/Include/inetprivate.h b/external/bsd/libpcap/dist/Win32/Include/inetprivate.h index 0e1e5b474676..e25ed3d6c9bc 100644 --- a/external/bsd/libpcap/dist/Win32/Include/inetprivate.h +++ b/external/bsd/libpcap/dist/Win32/Include/inetprivate.h @@ -1,5 +1,3 @@ -/* $NetBSD: inetprivate.h,v 1.1.1.2 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (c) 1999 - 2003 * NetGroup, Politecnico di Torino (Italy) diff --git a/external/bsd/libpcap/dist/Win32/Include/ip6_misc.h b/external/bsd/libpcap/dist/Win32/Include/ip6_misc.h index 7ed553b5d8c4..0b578c33c11d 100644 --- a/external/bsd/libpcap/dist/Win32/Include/ip6_misc.h +++ b/external/bsd/libpcap/dist/Win32/Include/ip6_misc.h @@ -1,5 +1,3 @@ -/* $NetBSD: ip6_misc.h,v 1.1.1.3 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (c) 1993, 1994, 1997 * The Regents of the University of California. All rights reserved. @@ -19,8 +17,6 @@ * 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. - * - * @(#) Header: /tcpdump/master/libpcap/Win32/Include/ip6_misc.h,v 1.5 2006-01-22 18:02:18 gianluca Exp (LBL) */ /* diff --git a/external/bsd/libpcap/dist/Win32/Include/net/if.h b/external/bsd/libpcap/dist/Win32/Include/net/if.h index 26153e2471e5..bf926b6ef517 100644 --- a/external/bsd/libpcap/dist/Win32/Include/net/if.h +++ b/external/bsd/libpcap/dist/Win32/Include/net/if.h @@ -1,5 +1,3 @@ -/* $NetBSD: if.h,v 1.1.1.2 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (c) 1982, 1986, 1989, 1993 * The Regents of the University of California. All rights reserved. diff --git a/external/bsd/libpcap/dist/Win32/Include/net/netdb.h b/external/bsd/libpcap/dist/Win32/Include/net/netdb.h index 489edec94532..b9d45acf6d02 100644 --- a/external/bsd/libpcap/dist/Win32/Include/net/netdb.h +++ b/external/bsd/libpcap/dist/Win32/Include/net/netdb.h @@ -1,5 +1,3 @@ -/* $NetBSD: netdb.h,v 1.1.1.2 2013/04/06 15:57:51 christos Exp $ */ - /*- * Copyright (c) 1980, 1983, 1988, 1993 * The Regents of the University of California. All rights reserved. diff --git a/external/bsd/libpcap/dist/Win32/Include/net/paths.h b/external/bsd/libpcap/dist/Win32/Include/net/paths.h index 281269fddb34..987de4f0dcef 100644 --- a/external/bsd/libpcap/dist/Win32/Include/net/paths.h +++ b/external/bsd/libpcap/dist/Win32/Include/net/paths.h @@ -1,5 +1,3 @@ -/* $NetBSD: paths.h,v 1.1.1.2 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (c) 1989 The Regents of the University of California. * All rights reserved. diff --git a/external/bsd/libpcap/dist/Win32/Include/sockstorage.h b/external/bsd/libpcap/dist/Win32/Include/sockstorage.h index 6c854003e593..557eb4df0aff 100644 --- a/external/bsd/libpcap/dist/Win32/Include/sockstorage.h +++ b/external/bsd/libpcap/dist/Win32/Include/sockstorage.h @@ -1,5 +1,3 @@ -/* $NetBSD: sockstorage.h,v 1.1.1.2 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (C) 1999 WIDE Project. * All rights reserved. diff --git a/external/bsd/libpcap/dist/Win32/Src/ffs.c b/external/bsd/libpcap/dist/Win32/Src/ffs.c index 57adc8bfe08b..099ff8e4c911 100644 --- a/external/bsd/libpcap/dist/Win32/Src/ffs.c +++ b/external/bsd/libpcap/dist/Win32/Src/ffs.c @@ -1,5 +1,3 @@ -/* $NetBSD: ffs.c,v 1.1.1.2 2013/04/06 15:57:51 christos Exp $ */ - /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. diff --git a/external/bsd/libpcap/dist/Win32/Src/gai_strerror.c b/external/bsd/libpcap/dist/Win32/Src/gai_strerror.c index a5eb3984e790..edd970b927c7 100644 --- a/external/bsd/libpcap/dist/Win32/Src/gai_strerror.c +++ b/external/bsd/libpcap/dist/Win32/Src/gai_strerror.c @@ -1,5 +1,3 @@ -/* $NetBSD: gai_strerror.c,v 1.1.1.2 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. diff --git a/external/bsd/libpcap/dist/Win32/Src/getaddrinfo.c b/external/bsd/libpcap/dist/Win32/Src/getaddrinfo.c index 5278ec36c0d5..19ffa68a8a8a 100644 --- a/external/bsd/libpcap/dist/Win32/Src/getaddrinfo.c +++ b/external/bsd/libpcap/dist/Win32/Src/getaddrinfo.c @@ -1,5 +1,3 @@ -/* $NetBSD: getaddrinfo.c,v 1.1.1.3 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. @@ -57,11 +55,6 @@ #include #endif -#ifndef lint -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/Win32/Src/getaddrinfo.c,v 1.3 2008-09-15 23:37:51 guy Exp "; -#endif - #include #if 0 #include diff --git a/external/bsd/libpcap/dist/Win32/Src/getnetbynm.c b/external/bsd/libpcap/dist/Win32/Src/getnetbynm.c index 102d0284bd01..fa4d398e54eb 100644 --- a/external/bsd/libpcap/dist/Win32/Src/getnetbynm.c +++ b/external/bsd/libpcap/dist/Win32/Src/getnetbynm.c @@ -1,5 +1,3 @@ -/* $NetBSD: getnetbynm.c,v 1.1.1.2 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. diff --git a/external/bsd/libpcap/dist/Win32/Src/getnetent.c b/external/bsd/libpcap/dist/Win32/Src/getnetent.c index 55f37850c035..d4cceb334380 100644 --- a/external/bsd/libpcap/dist/Win32/Src/getnetent.c +++ b/external/bsd/libpcap/dist/Win32/Src/getnetent.c @@ -1,5 +1,3 @@ -/* $NetBSD: getnetent.c,v 1.1.1.2 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. diff --git a/external/bsd/libpcap/dist/Win32/Src/getopt.c b/external/bsd/libpcap/dist/Win32/Src/getopt.c index 33ecffb4afc5..03c2086efdcb 100644 --- a/external/bsd/libpcap/dist/Win32/Src/getopt.c +++ b/external/bsd/libpcap/dist/Win32/Src/getopt.c @@ -1,5 +1,3 @@ -/* $NetBSD: getopt.c,v 1.1.1.2 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (c) 1987, 1993, 1994 * The Regents of the University of California. All rights reserved. diff --git a/external/bsd/libpcap/dist/Win32/Src/getservent.c b/external/bsd/libpcap/dist/Win32/Src/getservent.c index b75b498ac0d0..61b8cb04b7fe 100644 --- a/external/bsd/libpcap/dist/Win32/Src/getservent.c +++ b/external/bsd/libpcap/dist/Win32/Src/getservent.c @@ -1,5 +1,3 @@ -/* $NetBSD: getservent.c,v 1.1.1.2 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. diff --git a/external/bsd/libpcap/dist/Win32/Src/inet_aton.c b/external/bsd/libpcap/dist/Win32/Src/inet_aton.c index 3ef6e837c90b..cbd43619164b 100644 --- a/external/bsd/libpcap/dist/Win32/Src/inet_aton.c +++ b/external/bsd/libpcap/dist/Win32/Src/inet_aton.c @@ -1,5 +1,3 @@ -/* $NetBSD: inet_aton.c,v 1.1.1.3 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). @@ -38,13 +36,6 @@ * SUCH DAMAGE. */ -/* Id: inet_aton.c,v 1.2 2003-11-15 23:24:06 guy Exp */ - -#ifndef lint -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/Win32/Src/inet_aton.c,v 1.2 2003-11-15 23:24:06 guy Exp "; -#endif - #include #include diff --git a/external/bsd/libpcap/dist/Win32/Src/inet_net.c b/external/bsd/libpcap/dist/Win32/Src/inet_net.c index 02f3922f650e..5bbe3914ef9b 100644 --- a/external/bsd/libpcap/dist/Win32/Src/inet_net.c +++ b/external/bsd/libpcap/dist/Win32/Src/inet_net.c @@ -1,5 +1,3 @@ -/* $NetBSD: inet_net.c,v 1.1.1.2 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. diff --git a/external/bsd/libpcap/dist/Win32/Src/inet_pton.c b/external/bsd/libpcap/dist/Win32/Src/inet_pton.c index d94c89f2d532..fe89bb59f3c3 100644 --- a/external/bsd/libpcap/dist/Win32/Src/inet_pton.c +++ b/external/bsd/libpcap/dist/Win32/Src/inet_pton.c @@ -1,5 +1,3 @@ -/* $NetBSD: inet_pton.c,v 1.1.1.3 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (c) 1999 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). @@ -38,13 +36,6 @@ * SUCH DAMAGE. */ -/* Id: inet_pton.c,v 1.3 2007-09-27 18:02:20 gianluca Exp */ - -#ifndef lint -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/Win32/Src/inet_pton.c,v 1.3 2007-09-27 18:02:20 gianluca Exp "; -#endif - #include #ifdef WIN32 diff --git a/external/bsd/libpcap/dist/aclocal.m4 b/external/bsd/libpcap/dist/aclocal.m4 index 5a11a1274861..31a18e10fc47 100644 --- a/external/bsd/libpcap/dist/aclocal.m4 +++ b/external/bsd/libpcap/dist/aclocal.m4 @@ -1,5 +1,3 @@ -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. dnl diff --git a/external/bsd/libpcap/dist/arcnet.h b/external/bsd/libpcap/dist/arcnet.h index dff180e98905..58690985cbde 100644 --- a/external/bsd/libpcap/dist/arcnet.h +++ b/external/bsd/libpcap/dist/arcnet.h @@ -1,5 +1,3 @@ -/* $NetBSD: arcnet.h,v 1.1.1.3 2013/04/06 15:57:48 christos Exp $ */ - /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. @@ -32,8 +30,6 @@ * 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) - * * from: NetBSD: if_arc.h,v 1.13 1999/11/19 20:41:19 thorpej Exp */ diff --git a/external/bsd/libpcap/dist/atmuni31.h b/external/bsd/libpcap/dist/atmuni31.h index ecc2d6f86c95..0f85430098ce 100644 --- a/external/bsd/libpcap/dist/atmuni31.h +++ b/external/bsd/libpcap/dist/atmuni31.h @@ -1,5 +1,3 @@ -/* $NetBSD: atmuni31.h,v 1.1.1.3 2013/04/06 15:57:49 christos Exp $ */ - /* * Copyright (c) 1997 Yen Yen Lim and North Dakota State University * All rights reserved. @@ -30,8 +28,6 @@ * 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. - * - * @(#) 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/external/bsd/libpcap/dist/bpf_dump.c b/external/bsd/libpcap/dist/bpf_dump.c index 515e1947aebd..5eaadc08aad2 100644 --- a/external/bsd/libpcap/dist/bpf_dump.c +++ b/external/bsd/libpcap/dist/bpf_dump.c @@ -1,5 +1,3 @@ -/* $NetBSD: bpf_dump.c,v 1.1.1.3 2013/04/06 15:57:46 christos Exp $ */ - /* * Copyright (c) 1992, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. @@ -20,10 +18,6 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/bpf_dump.c,v 1.15 2008-01-02 04:16:46 guy Exp (LBL)"; -#endif #ifdef HAVE_CONFIG_H #include "config.h" diff --git a/external/bsd/libpcap/dist/bpf_image.c b/external/bsd/libpcap/dist/bpf_image.c index d76642f9e812..3e9a23f51b4c 100644 --- a/external/bsd/libpcap/dist/bpf_image.c +++ b/external/bsd/libpcap/dist/bpf_image.c @@ -1,5 +1,3 @@ -/* $NetBSD: bpf_image.c,v 1.1.1.4 2013/12/31 16:57:24 christos Exp $ */ - /* * Copyright (c) 1990, 1991, 1992, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. @@ -21,11 +19,6 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) 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 @@ -218,6 +211,11 @@ bpf_image(p, n) fmt = "x"; break; + case BPF_ALU|BPF_MOD|BPF_X: + op = "mod"; + fmt = "x"; + break; + case BPF_ALU|BPF_AND|BPF_X: op = "and"; fmt = "x"; @@ -228,6 +226,11 @@ bpf_image(p, n) fmt = "x"; break; + case BPF_ALU|BPF_XOR|BPF_X: + op = "xor"; + fmt = "x"; + break; + case BPF_ALU|BPF_LSH|BPF_X: op = "lsh"; fmt = "x"; @@ -258,6 +261,11 @@ bpf_image(p, n) fmt = "#%d"; break; + case BPF_ALU|BPF_MOD|BPF_K: + op = "mod"; + fmt = "#%d"; + break; + case BPF_ALU|BPF_AND|BPF_K: op = "and"; fmt = "#0x%x"; @@ -268,6 +276,11 @@ bpf_image(p, n) fmt = "#0x%x"; break; + case BPF_ALU|BPF_XOR|BPF_K: + op = "xor"; + fmt = "#0x%x"; + break; + case BPF_ALU|BPF_LSH|BPF_K: op = "lsh"; fmt = "#%d"; diff --git a/external/bsd/libpcap/dist/config.guess b/external/bsd/libpcap/dist/config.guess index c2246a4f7f4c..d622a44e551f 100755 --- a/external/bsd/libpcap/dist/config.guess +++ b/external/bsd/libpcap/dist/config.guess @@ -1,10 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 -# Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +# 2011, 2012 Free Software Foundation, Inc. -timestamp='2009-12-30' +timestamp='2012-02-10' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -17,9 +17,7 @@ timestamp='2009-12-30' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -57,8 +55,8 @@ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free -Software Foundation, Inc. +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 +Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -145,7 +143,7 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward @@ -181,7 +179,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in fi ;; *) - os=netbsd + os=netbsd ;; esac # The OS release @@ -224,7 +222,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on @@ -270,7 +268,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit ;; + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead @@ -296,7 +297,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo s390-ibm-zvmoe exit ;; *:OS400:*:*) - echo powerpc-ibm-os400 + echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} @@ -395,23 +396,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; @@ -481,8 +482,8 @@ EOF echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ @@ -495,7 +496,7 @@ EOF else echo i586-dg-dgux${UNAME_RELEASE} fi - exit ;; + exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; @@ -552,7 +553,7 @@ EOF echo rs6000-ibm-aix3.2 fi exit ;; - *:AIX:*:[456]) + *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 @@ -595,52 +596,52 @@ EOF 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac + esac ;; + esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + sed 's/^ //' << EOF >$dummy.c - #define _HPUX_SOURCE - #include - #include + #define _HPUX_SOURCE + #include + #include - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa @@ -731,22 +732,22 @@ EOF exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd - exit ;; + exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit ;; + exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd - exit ;; + exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd - exit ;; + exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd - exit ;; + exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; @@ -770,14 +771,14 @@ EOF exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} @@ -789,13 +790,12 @@ EOF echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) - case ${UNAME_MACHINE} in - pc98) - echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=`/usr/bin/uname -p` + case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) @@ -804,15 +804,18 @@ EOF *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; + i*:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) - case ${UNAME_MACHINE} in + case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; @@ -858,6 +861,13 @@ EOF i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; @@ -867,7 +877,7 @@ EOF EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; - esac + esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} @@ -879,20 +889,29 @@ EOF then echo ${UNAME_MACHINE}-unknown-linux-gnu else - echo ${UNAME_MACHINE}-unknown-linux-gnueabi + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo ${UNAME_MACHINE}-unknown-linux-gnueabi + else + echo ${UNAME_MACHINE}-unknown-linux-gnueabihf + fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) - echo cris-axis-linux-gnu + echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; crisv32:Linux:*:*) - echo crisv32-axis-linux-gnu + echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; frv:Linux:*:*) - echo frv-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + hexagon:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu @@ -934,7 +953,7 @@ EOF test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) - echo or32-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu @@ -960,7 +979,7 @@ EOF echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu @@ -968,14 +987,17 @@ EOF sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. @@ -984,11 +1006,11 @@ EOF echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. + # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) @@ -1020,7 +1042,7 @@ EOF fi exit ;; i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. + # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; @@ -1048,13 +1070,13 @@ EOF exit ;; pc:*:*:*) # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i586. + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp - exit ;; + exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; @@ -1089,8 +1111,8 @@ EOF /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ @@ -1133,10 +1155,10 @@ EOF echo ns32k-sni-sysv fi exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm @@ -1162,11 +1184,11 @@ EOF exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv${UNAME_RELEASE} else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv${UNAME_RELEASE} fi - exit ;; + exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; @@ -1231,6 +1253,9 @@ EOF *:QNX:*:4*) echo i386-pc-qnx exit ;; + NEO-?:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk${UNAME_RELEASE} + exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; @@ -1276,13 +1301,13 @@ EOF echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` + UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; @@ -1300,6 +1325,9 @@ EOF i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-unknown-esx + exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 @@ -1322,11 +1350,11 @@ main () #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 - "4" + "4" #else - "" + "" #endif - ); exit (0); + ); exit (0); #endif #endif diff --git a/external/bsd/libpcap/dist/config.h.in b/external/bsd/libpcap/dist/config.h.in index c6bc68eb2a6f..4bbb491ec168 100644 --- a/external/bsd/libpcap/dist/config.h.in +++ b/external/bsd/libpcap/dist/config.h.in @@ -256,6 +256,9 @@ /* target host supports Bluetooth sniffing */ #undef PCAP_SUPPORT_BT +/* target host supports Bluetooth Monitor */ +#undef PCAP_SUPPORT_BT_MONITOR + /* target host supports CAN sniffing */ #undef PCAP_SUPPORT_CAN diff --git a/external/bsd/libpcap/dist/config.sub b/external/bsd/libpcap/dist/config.sub index 85186096a9e1..59bb593f109c 100755 --- a/external/bsd/libpcap/dist/config.sub +++ b/external/bsd/libpcap/dist/config.sub @@ -1,10 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 -# Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +# 2011, 2012 Free Software Foundation, Inc. -timestamp='2009-12-31' +timestamp='2012-04-18' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -21,9 +21,7 @@ timestamp='2009-12-31' # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -76,8 +74,8 @@ version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free -Software Foundation, Inc. +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 +Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -124,13 +122,18 @@ esac # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ - uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] @@ -157,8 +160,8 @@ case $os in os= basic_machine=$1 ;; - -bluegene*) - os=-cnk + -bluegene*) + os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= @@ -174,10 +177,10 @@ case $os in os=-chorusos basic_machine=$1 ;; - -chorusrdb) - os=-chorusrdb + -chorusrdb) + os=-chorusrdb basic_machine=$1 - ;; + ;; -hiux*) os=-hiuxwe2 ;; @@ -222,6 +225,12 @@ case $os in -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; -lynx*) os=-lynxos ;; @@ -246,17 +255,22 @@ case $basic_machine in # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ + | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | be32 | be64 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ + | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ + | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | mcore | mep | metag \ @@ -282,29 +296,39 @@ case $basic_machine in | moxie \ | mt \ | msp430 \ + | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ + | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ - | rx \ + | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ - | v850 | v850e \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ - | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ + | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; - m6811 | m68hc11 | m6812 | m68hc12 | picochip) - # Motorola 68HC11/12. + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) basic_machine=$basic_machine-unknown os=-none ;; @@ -314,6 +338,21 @@ case $basic_machine in basic_machine=mt-unknown ;; + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. @@ -328,21 +367,25 @@ case $basic_machine in # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ + | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ + | be32-* | be64-* \ | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ + | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ @@ -368,25 +411,29 @@ case $basic_machine in | mmix-* \ | mt-* \ | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ - | romp-* | rs6000-* | rx-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | tahoe-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ | tron-* \ | ubicom32-* \ - | v850-* | v850e-* | vax-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) @@ -411,7 +458,7 @@ case $basic_machine in basic_machine=a29k-amd os=-udi ;; - abacus) + abacus) basic_machine=abacus-unknown ;; adobe68k) @@ -481,11 +528,20 @@ case $basic_machine in basic_machine=powerpc-ibm os=-cnk ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; c90) basic_machine=c90-cray os=-unicos ;; - cegcc) + cegcc) basic_machine=arm-unknown os=-cegcc ;; @@ -517,7 +573,7 @@ case $basic_machine in basic_machine=craynv-cray os=-unicosmp ;; - cr16) + cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; @@ -675,7 +731,6 @@ case $basic_machine in i370-ibm* | ibm*) basic_machine=i370-ibm ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 @@ -733,7 +788,7 @@ case $basic_machine in basic_machine=ns32k-utek os=-sysv ;; - microblaze) + microblaze) basic_machine=microblaze-xilinx ;; mingw32) @@ -772,10 +827,18 @@ case $basic_machine in ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; + msys) + basic_machine=i386-pc + os=-msys + ;; mvs) basic_machine=i370-ibm os=-mvs ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; ncr3000) basic_machine=i486-ncr os=-sysv4 @@ -840,6 +903,12 @@ case $basic_machine in np1) basic_machine=np1-gould ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; nsr-tandem) basic_machine=nsr-tandem ;; @@ -922,9 +991,10 @@ case $basic_machine in ;; power) basic_machine=power-ibm ;; - ppc) basic_machine=powerpc-unknown + ppc | ppcbe) basic_machine=powerpc-unknown ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown @@ -1018,6 +1088,9 @@ case $basic_machine in basic_machine=i860-stratus os=-sysv4 ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; sun2) basic_machine=m68000-sun ;; @@ -1074,20 +1147,8 @@ case $basic_machine in basic_machine=t90-cray os=-unicos ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff - ;; tile*) - basic_machine=tile-unknown + basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) @@ -1157,6 +1218,9 @@ case $basic_machine in xps | xps100) basic_machine=xps100-honeywell ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ;; ymp) basic_machine=ymp-cray os=-unicos @@ -1254,11 +1318,11 @@ esac if [ x"$os" != x"" ] then case $os in - # First match some system type aliases - # that might get confused with valid system types. + # First match some system type aliases + # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux + -auroraux) + os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` @@ -1294,8 +1358,9 @@ case $os in | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ @@ -1342,7 +1407,7 @@ case $os in -opened*) os=-openedition ;; - -os400*) + -os400*) os=-os400 ;; -wince*) @@ -1391,7 +1456,7 @@ case $os in -sinix*) os=-sysv4 ;; - -tpf*) + -tpf*) os=-tpf ;; -triton*) @@ -1436,8 +1501,8 @@ case $os in -dicos*) os=-dicos ;; - -nacl*) - ;; + -nacl*) + ;; -none) ;; *) @@ -1460,10 +1525,10 @@ else # system, and we'll never get to this point. case $basic_machine in - score-*) + score-*) os=-elf ;; - spu-*) + spu-*) os=-elf ;; *-acorn) @@ -1475,8 +1540,17 @@ case $basic_machine in arm*-semi) os=-aout ;; - c4x-* | tic4x-*) - os=-coff + c4x-* | tic4x-*) + os=-coff + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff ;; # This must come before the *-dec entry. pdp10-*) @@ -1496,14 +1570,11 @@ case $basic_machine in ;; m68000-sun) os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 ;; m68*-cisco) os=-aout ;; - mep-*) + mep-*) os=-elf ;; mips*-cisco) @@ -1530,7 +1601,7 @@ case $basic_machine in *-ibm) os=-aix ;; - *-knuth) + *-knuth) os=-mmixware ;; *-wec) diff --git a/external/bsd/libpcap/dist/configure b/external/bsd/libpcap/dist/configure index be87668692f7..e665cb9bbc0c 100755 --- a/external/bsd/libpcap/dist/configure +++ b/external/bsd/libpcap/dist/configure @@ -630,6 +630,7 @@ CAN_SRC PCAP_SUPPORT_CAN CANUSB_SRC PCAP_SUPPORT_CANUSB +BT_MONITOR_SRC BT_SRC PCAP_SUPPORT_BT NETFILTER_SRC @@ -7999,7 +8000,7 @@ esac if test "${enable_bluetooth+set}" = set; then : enableval=$enable_bluetooth; else - enable_bluetooth=yes + enable_bluetooth=ifsupportavailable fi @@ -8053,30 +8054,82 @@ $as_echo "$ac_cv_lbl_sockaddr_hci_has_hci_channel" >&6; } $as_echo "#define SOCKADDR_HCI_HAS_HCI_CHANNEL /**/" >>confdefs.h + + # + # OK, is HCI_CHANNEL_MONITOR defined? + # + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if HCI_CHANNEL_MONITOR is defined" >&5 +$as_echo_n "checking if HCI_CHANNEL_MONITOR is defined... " >&6; } + if ${ac_cv_lbl_hci_channel_monitor_is_defined+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include + +int +main () +{ +u_int i = HCI_CHANNEL_MONITOR + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_lbl_hci_channel_monitor_is_defined=yes +else + ac_cv_lbl_hci_channel_monitor_is_defined=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_hci_channel_monitor_is_defined" >&5 +$as_echo "$ac_cv_lbl_hci_channel_monitor_is_defined" >&6; } + if test $ac_cv_lbl_hci_channel_monitor_is_defined = yes ; then + +$as_echo "#define PCAP_SUPPORT_BT_MONITOR /**/" >>confdefs.h + + BT_MONITOR_SRC=pcap-bt-monitor-linux.c + fi fi + ac_lbl_bluetooth_available=yes else - { $as_echo "$as_me:${as_lineno-$LINENO}: Bluetooth sniffing is not supported; install bluez-lib devel to enable it" >&5 -$as_echo "$as_me: Bluetooth sniffing is not supported; install bluez-lib devel to enable it" >&6;} + ac_lbl_bluetooth_available=no fi + if test "x$ac_lbl_bluetooth_available" == "xno" ; then + if test "x$enable_bluetooth" = "xyes" ; then + as_fn_error $? "Bluetooth sniffing is not supported; install bluez-lib devel to enable it" "$LINENO" 5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: Bluetooth sniffing is not supported; install bluez-lib devel to enable it" >&5 +$as_echo "$as_me: Bluetooth sniffing is not supported; install bluez-lib devel to enable it" >&6;} + fi + fi ;; *) - { $as_echo "$as_me:${as_lineno-$LINENO}: no Bluetooth sniffing support implemented for $host_os" >&5 + if test "x$enable_bluetooth" = "xyes" ; then + as_fn_error $? "no Bluetooth sniffing support implemented for $host_os" "$LINENO" 5 + else + { $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;} + fi ;; esac + fi # Check whether --enable-canusb was given. if test "${enable_canusb+set}" = set; then : enableval=$enable_canusb; else - enable_canusb=yes + enable_canusb=ifsupportavailable fi @@ -8086,25 +8139,82 @@ if test "x$enable_canusb" != "xno" ; then ac_fn_c_check_header_mongrel "$LINENO" "libusb-1.0/libusb.h" "ac_cv_header_libusb_1_0_libusb_h" "$ac_includes_default" if test "x$ac_cv_header_libusb_1_0_libusb_h" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libusb_init in -lusb-1.0" >&5 +$as_echo_n "checking for libusb_init in -lusb-1.0... " >&6; } +if ${ac_cv_lib_usb_1_0_libusb_init+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lusb-1.0 $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 libusb_init (); +int +main () +{ +return libusb_init (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_usb_1_0_libusb_init=yes +else + ac_cv_lib_usb_1_0_libusb_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_usb_1_0_libusb_init" >&5 +$as_echo "$ac_cv_lib_usb_1_0_libusb_init" >&6; } +if test "x$ac_cv_lib_usb_1_0_libusb_init" = xyes; then : + $as_echo "#define PCAP_SUPPORT_CANUSB 1" >>confdefs.h - CANUSB_SRC=pcap-canusb-linux.c - LIBS="-lusb-1.0 -lpthread $LIBS" - { $as_echo "$as_me:${as_lineno-$LINENO}: canusb sniffing is supported" >&5 -$as_echo "$as_me: canusb sniffing is supported" >&6;} + CANUSB_SRC=pcap-canusb-linux.c + LIBS="-lusb-1.0 -lpthread $LIBS" + ac_lbl_has_libusb=yes else - { $as_echo "$as_me:${as_lineno-$LINENO}: canusb sniffing is not supported; install libusb1.0 lib devel to enable it" >&5 -$as_echo "$as_me: canusb sniffing is not supported; install libusb1.0 lib devel to enable it" >&6;} + ac_lbl_has_libusb=no fi +else + ac_lbl_has_libusb=no + +fi + + + if test "x$ac_lbl_has_libusb" = "xyes" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: canusb sniffing is supported" >&5 +$as_echo "$as_me: canusb sniffing is supported" >&6;} + else + if test "x$enable_canusb" = "xyes" ; then + as_fn_error $? "canusb sniffing is not supported; install libusb1.0 lib devel to enable it" "$LINENO" 5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: canusb sniffing is not supported; install libusb1.0 lib devel to enable it" >&5 +$as_echo "$as_me: canusb sniffing is not supported; install libusb1.0 lib devel to enable it" >&6;} + fi + fi ;; *) - { $as_echo "$as_me:${as_lineno-$LINENO}: no canusb support implemented for $host_os" >&5 + if test "x$enable_canusb" = "xyes" ; then + as_fn_error $? "no canusb support implemented for $host_os" "$LINENO" 5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: no canusb support implemented for $host_os" >&5 $as_echo "$as_me: no canusb support implemented for $host_os" >&6;} + fi ;; esac @@ -8115,7 +8225,7 @@ fi if test "${enable_can+set}" = set; then : enableval=$enable_can; else - enable_can=yes + enable_can=ifsupportavailable fi @@ -8127,21 +8237,33 @@ if test "x$enable_can" != "xno" ; then " if test "x$ac_cv_header_linux_can_h" = xyes; 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 + 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 + + if test "x$enable_can" = "xyes" ; then + as_fn_error $? "CAN sniffing is not supported" "$LINENO" 5 + 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 + fi ;; *) - { $as_echo "$as_me:${as_lineno-$LINENO}: no CAN sniffing support implemented for $host_os" >&5 + if test "x$enable_can" = "xyes" ; then + as_fn_error $? "no CAN sniffing support implemented for $host_os" "$LINENO" 5 + else + { $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;} + fi ;; esac @@ -8157,7 +8279,27 @@ fi if test "x$enable_dbus" != "xno"; then - # Extract the first word of "pkg-config", so it can be a program name with args. + if test "x$enable_dbus" = "xyes"; then + case "$host_os" in + + darwin*) + # + # https://bugs.freedesktop.org/show_bug.cgi?id=74029 + # + as_fn_error $? "Due to freedesktop.org bug 74029, D-Bus capture support is not available on OS X" "$LINENO" 5 + ;; + esac + else + case "$host_os" in + + darwin*) + # + # https://bugs.freedesktop.org/show_bug.cgi?id=74029 + # + ;; + + *) + # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } @@ -8195,28 +8337,28 @@ $as_echo "no" >&6; } fi - if test "x$PKGCONFIG" != "xno"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for D-Bus" >&5 + if test "x$PKGCONFIG" != "xno"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for D-Bus" >&5 $as_echo_n "checking for D-Bus... " >&6; } - if "$PKGCONFIG" dbus-1; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + if "$PKGCONFIG" dbus-1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1` - DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1` - save_CFLAGS="$CFLAGS" - save_LIBS="$LIBS" - CFLAGS="$CFLAGS $DBUS_CFLAGS" - LIBS="$LIBS $DBUS_LIBS" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the D-Bus library defines dbus_connection_read_write" >&5 + DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1` + DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1` + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + CFLAGS="$CFLAGS $DBUS_CFLAGS" + LIBS="$LIBS $DBUS_LIBS" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the D-Bus library defines dbus_connection_read_write" >&5 $as_echo_n "checking whether the D-Bus library defines dbus_connection_read_write... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include - #include - #include + #include + #include - #include + #include int main () { @@ -8227,34 +8369,37 @@ return dbus_connection_read_write(NULL, 0); _ACEOF if ac_fn_c_try_link "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define PCAP_SUPPORT_DBUS 1" >>confdefs.h - DBUS_SRC=pcap-dbus.c - V_INCLS="$V_INCLS $DBUS_CFLAGS" + DBUS_SRC=pcap-dbus.c + V_INCLS="$V_INCLS $DBUS_CFLAGS" else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - if test "x$enable_dbus" = "xyes"; then - as_fn_error $? "--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()" "$LINENO" 5 - fi - LIBS="$save_LIBS" + if test "x$enable_dbus" = "xyes"; then + as_fn_error $? "--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()" "$LINENO" 5 + fi + LIBS="$save_LIBS" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - CFLAGS="$save_CFLAGS" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + CFLAGS="$save_CFLAGS" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - if test "x$enable_dbus" = "xyes"; then - as_fn_error $? "--enable-dbus was given, but the dbus-1 package is not installed" "$LINENO" 5 + if test "x$enable_dbus" = "xyes"; then + as_fn_error $? "--enable-dbus was given, but the dbus-1 package is not installed" "$LINENO" 5 + fi + fi fi - fi + ;; + esac fi diff --git a/external/bsd/libpcap/dist/configure.in b/external/bsd/libpcap/dist/configure.in index 1cacf2b2fd02..4530aed3a7d0 100644 --- a/external/bsd/libpcap/dist/configure.in +++ b/external/bsd/libpcap/dist/configure.in @@ -1,4 +1,3 @@ -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. @@ -1456,7 +1455,7 @@ AC_SUBST(NETFILTER_SRC) AC_ARG_ENABLE([bluetooth], [AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])], [], - [enable_bluetooth=yes]) + [enable_bluetooth=ifsupportavailable]) if test "x$enable_bluetooth" != "xno" ; then dnl check for Bluetooth sniffing support @@ -1486,23 +1485,56 @@ if test "x$enable_bluetooth" != "xno" ; then if test $ac_cv_lbl_sockaddr_hci_has_hci_channel = yes ; then AC_DEFINE(SOCKADDR_HCI_HAS_HCI_CHANNEL,, [if struct sockaddr_hci has hci_channel member]) + + # + # OK, is HCI_CHANNEL_MONITOR defined? + # + AC_MSG_CHECKING(if HCI_CHANNEL_MONITOR is defined) + AC_CACHE_VAL(ac_cv_lbl_hci_channel_monitor_is_defined, + AC_TRY_COMPILE( +[ +#include +#include +], + [u_int i = HCI_CHANNEL_MONITOR], + ac_cv_lbl_hci_channel_monitor_is_defined=yes, + ac_cv_lbl_hci_channel_monitor_is_defined=no)) + AC_MSG_RESULT($ac_cv_lbl_hci_channel_monitor_is_defined) + if test $ac_cv_lbl_hci_channel_monitor_is_defined = yes ; then + AC_DEFINE(PCAP_SUPPORT_BT_MONITOR,, + [target host supports Bluetooth Monitor]) + BT_MONITOR_SRC=pcap-bt-monitor-linux.c + fi fi + ac_lbl_bluetooth_available=yes ], - AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it) + ac_lbl_bluetooth_available=no ) + if test "x$ac_lbl_bluetooth_available" == "xno" ; then + if test "x$enable_bluetooth" = "xyes" ; then + AC_MSG_ERROR(Bluetooth sniffing is not supported; install bluez-lib devel to enable it) + else + AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it) + fi + fi ;; *) - AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os) + if test "x$enable_bluetooth" = "xyes" ; then + AC_MSG_ERROR(no Bluetooth sniffing support implemented for $host_os) + else + AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os) + fi ;; esac AC_SUBST(PCAP_SUPPORT_BT) AC_SUBST(BT_SRC) + AC_SUBST(BT_MONITOR_SRC) fi AC_ARG_ENABLE([canusb], [AC_HELP_STRING([--enable-canusb],[enable canusb support @<:@default=yes, if support available@:>@])], [], - [enable_canusb=yes]) + [enable_canusb=ifsupportavailable]) if test "x$enable_canusb" != "xno" ; then dnl check for canusb support @@ -1510,16 +1542,34 @@ if test "x$enable_canusb" != "xno" ; then linux*) AC_CHECK_HEADER(libusb-1.0/libusb.h, [ - AC_DEFINE(PCAP_SUPPORT_CANUSB, 1, [target host supports canusb]) - CANUSB_SRC=pcap-canusb-linux.c - LIBS="-lusb-1.0 -lpthread $LIBS" - AC_MSG_NOTICE(canusb sniffing is supported) + AC_CHECK_LIB(usb-1.0, libusb_init, + [ + AC_DEFINE(PCAP_SUPPORT_CANUSB, 1, [target host supports canusb]) + CANUSB_SRC=pcap-canusb-linux.c + LIBS="-lusb-1.0 -lpthread $LIBS" + ac_lbl_has_libusb=yes + ], + ac_lbl_has_libusb=no + ) ], - AC_MSG_NOTICE(canusb sniffing is not supported; install libusb1.0 lib devel to enable it) + ac_lbl_has_libusb=no ) + if test "x$ac_lbl_has_libusb" = "xyes" ; then + AC_MSG_NOTICE(canusb sniffing is supported) + else + if test "x$enable_canusb" = "xyes" ; then + AC_MSG_ERROR(canusb sniffing is not supported; install libusb1.0 lib devel to enable it) + else + AC_MSG_NOTICE(canusb sniffing is not supported; install libusb1.0 lib devel to enable it) + fi + fi ;; *) - AC_MSG_NOTICE(no canusb support implemented for $host_os) + if test "x$enable_canusb" = "xyes" ; then + AC_MSG_ERROR(no canusb support implemented for $host_os) + else + AC_MSG_NOTICE(no canusb support implemented for $host_os) + fi ;; esac AC_SUBST(PCAP_SUPPORT_CANUSB) @@ -1529,22 +1579,34 @@ fi AC_ARG_ENABLE([can], [AC_HELP_STRING([--enable-can],[enable CAN support @<:@default=yes, if support available@:>@])], [], - [enable_can=yes]) + [enable_can=ifsupportavailable]) 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), + [ + AC_DEFINE(PCAP_SUPPORT_CAN, 1, [target host supports CAN sniffing]) + CAN_SRC=pcap-can-linux.c + AC_MSG_NOTICE(CAN sniffing is supported) + ], + [ + if test "x$enable_can" = "xyes" ; then + AC_MSG_ERROR(CAN sniffing is not supported) + else + AC_MSG_NOTICE(CAN sniffing is not supported) + fi + ], [#include ] ) ;; *) - AC_MSG_NOTICE(no CAN sniffing support implemented for $host_os) + if test "x$enable_can" = "xyes" ; then + AC_MSG_ERROR(no CAN sniffing support implemented for $host_os) + else + AC_MSG_NOTICE(no CAN sniffing support implemented for $host_os) + fi ;; esac AC_SUBST(PCAP_SUPPORT_CAN) @@ -1557,46 +1619,69 @@ AC_ARG_ENABLE([dbus], [enable_dbus=ifavailable]) if test "x$enable_dbus" != "xno"; then - AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no]) - if test "x$PKGCONFIG" != "xno"; then - AC_MSG_CHECKING([for D-Bus]) - if "$PKGCONFIG" dbus-1; then - AC_MSG_RESULT([yes]) - DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1` - DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1` - save_CFLAGS="$CFLAGS" - save_LIBS="$LIBS" - CFLAGS="$CFLAGS $DBUS_CFLAGS" - LIBS="$LIBS $DBUS_LIBS" - AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write) - AC_TRY_LINK( - [#include + if test "x$enable_dbus" = "xyes"; then + case "$host_os" in - #include - #include + darwin*) + # + # https://bugs.freedesktop.org/show_bug.cgi?id=74029 + # + AC_MSG_ERROR([Due to freedesktop.org bug 74029, D-Bus capture support is not available on OS X]) + ;; + esac + else + case "$host_os" in - #include ], - [return dbus_connection_read_write(NULL, 0);], - [ - AC_MSG_RESULT([yes]) - AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing]) - DBUS_SRC=pcap-dbus.c - V_INCLS="$V_INCLS $DBUS_CFLAGS" - ], - [ - AC_MSG_RESULT([no]) - if test "x$enable_dbus" = "xyes"; then - AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()]) + darwin*) + # + # https://bugs.freedesktop.org/show_bug.cgi?id=74029 + # + ;; + + *) + AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no]) + if test "x$PKGCONFIG" != "xno"; then + AC_MSG_CHECKING([for D-Bus]) + if "$PKGCONFIG" dbus-1; then + AC_MSG_RESULT([yes]) + DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1` + DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1` + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + CFLAGS="$CFLAGS $DBUS_CFLAGS" + LIBS="$LIBS $DBUS_LIBS" + AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write) + AC_TRY_LINK( + [#include + + #include + #include + + #include ], + [return dbus_connection_read_write(NULL, 0);], + [ + AC_MSG_RESULT([yes]) + AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing]) + DBUS_SRC=pcap-dbus.c + V_INCLS="$V_INCLS $DBUS_CFLAGS" + ], + [ + AC_MSG_RESULT([no]) + if test "x$enable_dbus" = "xyes"; then + AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()]) + fi + LIBS="$save_LIBS" + ]) + CFLAGS="$save_CFLAGS" + else + AC_MSG_RESULT([no]) + if test "x$enable_dbus" = "xyes"; then + AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed]) + fi fi - LIBS="$save_LIBS" - ]) - CFLAGS="$save_CFLAGS" - else - AC_MSG_RESULT([no]) - if test "x$enable_dbus" = "xyes"; then - AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed]) fi - fi + ;; + esac fi AC_SUBST(PCAP_SUPPORT_DBUS) AC_SUBST(DBUS_SRC) diff --git a/external/bsd/libpcap/dist/dlpisubs.c b/external/bsd/libpcap/dist/dlpisubs.c index 024a80e1e883..131fa279d843 100644 --- a/external/bsd/libpcap/dist/dlpisubs.c +++ b/external/bsd/libpcap/dist/dlpisubs.c @@ -1,5 +1,3 @@ -/* $NetBSD: dlpisubs.c,v 1.1.1.4 2013/12/31 16:57:23 christos Exp $ */ - /* * This code is derived from code formerly in pcap-dlpi.c, originally * contributed by Atanu Ghosh (atanu@cs.ucl.ac.uk), University College @@ -12,10 +10,6 @@ * This file contains dlpi/libdlpi related common functions used * by pcap-[dlpi,libdlpi].c. */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) 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" @@ -195,7 +189,7 @@ pcap_process_pkts(pcap_t *p, pcap_handler callback, u_char *user, if (pkthdr.caplen > p->snapshot) pkthdr.caplen = p->snapshot; (*callback)(user, &pkthdr, pk); - if (++n >= count && count >= 0) { + if (++n >= count && !PACKET_COUNT_IS_UNLIMITED(count)) { p->cc = ep - bufp; p->bp = bufp; return (n); diff --git a/external/bsd/libpcap/dist/dlpisubs.h b/external/bsd/libpcap/dist/dlpisubs.h index 63ffab9c861f..cdc531c1f651 100644 --- a/external/bsd/libpcap/dist/dlpisubs.h +++ b/external/bsd/libpcap/dist/dlpisubs.h @@ -1,9 +1,3 @@ -/* $NetBSD: dlpisubs.h,v 1.1.1.4 2013/12/31 16:57:25 christos Exp $ */ - -/* - * @(#) Header: /tcpdump/master/libpcap/dlpisubs.h,v 1.2 2008-04-04 19:37:45 guy Exp - */ - #ifndef dlpisubs_h #define dlpisubs_h diff --git a/external/bsd/libpcap/dist/etherent.c b/external/bsd/libpcap/dist/etherent.c index 31bbe3d3516c..707fd9d148b7 100644 --- a/external/bsd/libpcap/dist/etherent.c +++ b/external/bsd/libpcap/dist/etherent.c @@ -1,5 +1,3 @@ -/* $NetBSD: etherent.c,v 1.1.1.3 2013/04/06 15:57:49 christos Exp $ */ - /* * Copyright (c) 1990, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. @@ -21,11 +19,6 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#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)"; -#endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/external/bsd/libpcap/dist/ethertype.h b/external/bsd/libpcap/dist/ethertype.h index 1f94a3c4281b..8bab881634d6 100644 --- a/external/bsd/libpcap/dist/ethertype.h +++ b/external/bsd/libpcap/dist/ethertype.h @@ -1,5 +1,3 @@ -/* $NetBSD: ethertype.h,v 1.1.1.3 2013/04/06 15:57:48 christos Exp $ */ - /* * Copyright (c) 1993, 1994, 1996 * The Regents of the University of California. All rights reserved. @@ -19,8 +17,6 @@ * 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. - * - * @(#) Header: /tcpdump/master/libpcap/ethertype.h,v 1.14 2005-09-05 09:06:58 guy Exp (LBL) */ /* diff --git a/external/bsd/libpcap/dist/fad-getad.c b/external/bsd/libpcap/dist/fad-getad.c index 7d680e47c674..6fd3360f788f 100644 --- a/external/bsd/libpcap/dist/fad-getad.c +++ b/external/bsd/libpcap/dist/fad-getad.c @@ -1,5 +1,3 @@ -/* $NetBSD: fad-getad.c,v 1.1.1.4 2013/12/31 16:57:24 christos Exp $ */ - /* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ /* * Copyright (c) 1994, 1995, 1996, 1997, 1998 @@ -34,11 +32,6 @@ * SUCH DAMAGE. */ -#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)"; -#endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -148,7 +141,7 @@ get_sa_len(struct sockaddr *addr) * Get a list of all interfaces that are up and that we can open. * Returns -1 on error, 0 otherwise. * The list, as returned through "alldevsp", may be null if no interfaces - * were up and could be opened. + * could be opened. */ int pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf) @@ -164,10 +157,10 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf) * Get the list of interface addresses. * * Note: this won't return information about interfaces - * with no addresses; are there any such interfaces - * that would be capable of receiving packets? - * (Interfaces incapable of receiving packets aren't - * very interesting from libpcap's point of view.) + * with no addresses, so, if a platform has interfaces + * with no interfaces on which traffic can be captured, + * we must check for those interfaces as well (see, for + * example, what's done on Linux). * * LAN interfaces will probably have link-layer * addresses; I don't know whether all implementations @@ -180,35 +173,12 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf) return (-1); } for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) { - /* - * Is this interface up? - */ - if (!(ifa->ifa_flags & IFF_UP)) { - /* - * No, so don't add it to the list. - */ - continue; - } - /* * "ifa_addr" was apparently null on at least one - * interface on some system. - * - * "ifa_broadaddr" may be non-null even on - * non-broadcast interfaces, and was null on - * at least one OpenBSD 3.4 system on at least - * one interface with IFF_BROADCAST set. - * - * "ifa_dstaddr" was, on at least one FreeBSD 4.1 - * system, non-null on a non-point-to-point - * interface. - * - * Therefore, we supply the address and netmask only - * if "ifa_addr" is non-null (if there's no address, - * there's obviously no netmask), and supply the - * broadcast and destination addresses if the appropriate - * flag is set *and* the appropriate "ifa_" entry doesn't - * evaluate to a null pointer. + * interface on some system. Therefore, we supply + * the address and netmask only if "ifa_addr" is + * non-null (if there's no address, there's obviously + * no netmask). */ if (ifa->ifa_addr != NULL) { addr = ifa->ifa_addr; @@ -219,6 +189,22 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf) addr_size = 0; netmask = NULL; } + + /* + * Note that, on some platforms, ifa_broadaddr and + * ifa_dstaddr could be the same field (true on at + * least some versions of *BSD and OS X), so we + * can't just check whether the broadcast address + * is null and add it if so and check whether the + * destination address is null and add it if so. + * + * Therefore, we must also check the IFF_BROADCAST + * flag, and only add a broadcast address if it's + * set, and check the IFF_POINTTOPOINT flag, and + * only add a destination address if it's set (as + * per man page recommendations on some of those + * platforms). + */ if (ifa->ifa_flags & IFF_BROADCAST && ifa->ifa_broadaddr != NULL) { broadaddr = ifa->ifa_broadaddr; diff --git a/external/bsd/libpcap/dist/fad-gifc.c b/external/bsd/libpcap/dist/fad-gifc.c index b13fd4eb6f32..5c3357c7cea0 100644 --- a/external/bsd/libpcap/dist/fad-gifc.c +++ b/external/bsd/libpcap/dist/fad-gifc.c @@ -1,5 +1,3 @@ -/* $NetBSD: fad-gifc.c,v 1.1.1.4 2013/12/31 16:57:26 christos Exp $ */ - /* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ /* * Copyright (c) 1994, 1995, 1996, 1997, 1998 @@ -34,11 +32,6 @@ * SUCH DAMAGE. */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/fad-gifc.c,v 1.12 2008-08-06 07:34:09 guy Exp (LBL)"; -#endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -244,8 +237,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf) continue; /* - * Get the flags for this interface, and skip it if it's - * not up. + * Get the flags for this interface. */ strncpy(ifrflags.ifr_name, ifrp->ifr_name, sizeof(ifrflags.ifr_name)); @@ -260,8 +252,6 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf) ret = -1; break; } - if (!(ifrflags.ifr_flags & IFF_UP)) - continue; /* * Get the netmask for this address on this interface. diff --git a/external/bsd/libpcap/dist/fad-glifc.c b/external/bsd/libpcap/dist/fad-glifc.c index dca7f062a391..1a820ad90c61 100644 --- a/external/bsd/libpcap/dist/fad-glifc.c +++ b/external/bsd/libpcap/dist/fad-glifc.c @@ -1,5 +1,3 @@ -/* $NetBSD: fad-glifc.c,v 1.1.1.4 2013/12/31 16:57:18 christos Exp $ */ - /* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ /* * Copyright (c) 1994, 1995, 1996, 1997, 1998 @@ -34,11 +32,6 @@ * SUCH DAMAGE. */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/fad-glifc.c,v 1.7 2008-01-30 09:35:48 guy Exp (LBL)"; -#endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -210,8 +203,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf) #endif /* - * Get the flags for this interface, and skip it if it's - * not up. + * Get the flags for this interface. */ strncpy(ifrflags.lifr_name, ifrp->lifr_name, sizeof(ifrflags.lifr_name)); @@ -226,8 +218,6 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf) ret = -1; break; } - if (!(ifrflags.lifr_flags & IFF_UP)) - continue; /* * Get the netmask for this address on this interface. diff --git a/external/bsd/libpcap/dist/fad-null.c b/external/bsd/libpcap/dist/fad-null.c index f5447f6225e1..cecfbcb46052 100644 --- a/external/bsd/libpcap/dist/fad-null.c +++ b/external/bsd/libpcap/dist/fad-null.c @@ -1,5 +1,3 @@ -/* $NetBSD: fad-null.c,v 1.1.1.4 2013/12/31 16:57:24 christos Exp $ */ - /* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ /* * Copyright (c) 1994, 1995, 1996, 1997, 1998 @@ -34,11 +32,6 @@ * SUCH DAMAGE. */ -#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)"; -#endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/external/bsd/libpcap/dist/fad-sita.c b/external/bsd/libpcap/dist/fad-sita.c index c7500d9ba174..34ddf1d85186 100644 --- a/external/bsd/libpcap/dist/fad-sita.c +++ b/external/bsd/libpcap/dist/fad-sita.c @@ -1,5 +1,3 @@ -/* $NetBSD: fad-sita.c,v 1.1.1.3 2013/12/31 16:57:24 christos Exp $ */ - /* * fad-sita.c: Packet capture interface additions for SITA ACN devices * @@ -26,8 +24,6 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ - /* $Id: fad-sita.c */ - #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/external/bsd/libpcap/dist/fad-win32.c b/external/bsd/libpcap/dist/fad-win32.c index 6b2424c4860d..0de893ef5487 100644 --- a/external/bsd/libpcap/dist/fad-win32.c +++ b/external/bsd/libpcap/dist/fad-win32.c @@ -1,5 +1,3 @@ -/* $NetBSD: fad-win32.c,v 1.1.1.4 2013/12/31 16:57:21 christos Exp $ */ - /* * Copyright (c) 2002 - 2005 NetGroup, Politecnico di Torino (Italy) * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) @@ -33,11 +31,6 @@ * */ -#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)"; -#endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -47,102 +40,6 @@ static const char rcsid[] _U_ = #include #include - -/* - * Add an entry to the list of addresses for an interface. - * "curdev" is the entry for that interface. - */ -static int -add_addr_to_list(pcap_if_t *curdev, struct sockaddr *addr, - struct sockaddr *netmask, struct sockaddr *broadaddr, - struct sockaddr *dstaddr, char *errbuf) -{ - pcap_addr_t *curaddr, *prevaddr, *nextaddr; - - /* - * Allocate the new entry and fill it in. - */ - curaddr = (pcap_addr_t*)malloc(sizeof(pcap_addr_t)); - if (curaddr == NULL) { - (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - return (-1); - } - - curaddr->next = NULL; - if (addr != NULL) { - curaddr->addr = (struct sockaddr*)dup_sockaddr(addr, sizeof(struct sockaddr_storage)); - if (curaddr->addr == NULL) { - (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - free(curaddr); - return (-1); - } - } else - curaddr->addr = NULL; - - if (netmask != NULL) { - curaddr->netmask = (struct sockaddr*)dup_sockaddr(netmask, sizeof(struct sockaddr_storage)); - if (curaddr->netmask == NULL) { - (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - free(curaddr); - return (-1); - } - } else - curaddr->netmask = NULL; - - if (broadaddr != NULL) { - curaddr->broadaddr = (struct sockaddr*)dup_sockaddr(broadaddr, sizeof(struct sockaddr_storage)); - if (curaddr->broadaddr == NULL) { - (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - free(curaddr); - return (-1); - } - } else - curaddr->broadaddr = NULL; - - if (dstaddr != NULL) { - curaddr->dstaddr = (struct sockaddr*)dup_sockaddr(dstaddr, sizeof(struct sockaddr_storage)); - if (curaddr->dstaddr == NULL) { - (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - free(curaddr); - return (-1); - } - } else - curaddr->dstaddr = NULL; - - /* - * Find the end of the list of addresses. - */ - for (prevaddr = curdev->addresses; prevaddr != NULL; prevaddr = nextaddr) { - nextaddr = prevaddr->next; - if (nextaddr == NULL) { - /* - * This is the end of the list. - */ - break; - } - } - - if (prevaddr == NULL) { - /* - * The list was empty; this is the first member. - */ - curdev->addresses = curaddr; - } else { - /* - * "prevaddr" is the last member of the list; append - * this member to it. - */ - prevaddr->next = curaddr; - } - - return (0); -} - static int pcap_add_if_win32(pcap_if_t **devlist, char *name, const char *desc, @@ -191,12 +88,16 @@ pcap_add_if_win32(pcap_if_t **devlist, char *name, const char *desc, */ if(curdev == NULL) break; - res = add_addr_to_list(curdev, + res = add_addr_to_dev(curdev, (struct sockaddr *)&if_addrs[if_addr_size].IPAddress, + sizeof (struct sockaddr_storage), (struct sockaddr *)&if_addrs[if_addr_size].SubnetMask, + sizeof (struct sockaddr_storage), (struct sockaddr *)&if_addrs[if_addr_size].Broadcast, + sizeof (struct sockaddr_storage), NULL, - errbuf); + 0, + errbuf); if (res == -1) { /* * Failure. diff --git a/external/bsd/libpcap/dist/gencode.h b/external/bsd/libpcap/dist/gencode.h index 5fd439f34a3d..e6b3a71ea0db 100644 --- a/external/bsd/libpcap/dist/gencode.h +++ b/external/bsd/libpcap/dist/gencode.h @@ -1,5 +1,3 @@ -/* $NetBSD: gencode.h,v 1.1.1.4 2013/12/31 16:57:26 christos Exp $ */ - /* * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. @@ -19,8 +17,6 @@ * 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. - * - * @(#) Header: /tcpdump/master/libpcap/gencode.h,v 1.71 2007-11-18 02:03:52 guy Exp (LBL) */ /* @@ -312,6 +308,13 @@ struct block *gen_broadcast(int); struct block *gen_multicast(int); struct block *gen_inbound(int); +struct block *gen_llc(void); +struct block *gen_llc_i(void); +struct block *gen_llc_s(void); +struct block *gen_llc_u(void); +struct block *gen_llc_s_subtype(bpf_u_int32); +struct block *gen_llc_u_subtype(bpf_u_int32); + struct block *gen_vlan(int); struct block *gen_mpls(int); diff --git a/external/bsd/libpcap/dist/ieee80211.h b/external/bsd/libpcap/dist/ieee80211.h index e5a630fcdf12..473803d8a242 100644 --- a/external/bsd/libpcap/dist/ieee80211.h +++ b/external/bsd/libpcap/dist/ieee80211.h @@ -1,5 +1,3 @@ -/* $NetBSD: ieee80211.h,v 1.1.1.2 2013/04/06 15:57:48 christos Exp $ */ - /*- * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting diff --git a/external/bsd/libpcap/dist/inet.c b/external/bsd/libpcap/dist/inet.c index ff72c775fbee..036b2db316d6 100644 --- a/external/bsd/libpcap/dist/inet.c +++ b/external/bsd/libpcap/dist/inet.c @@ -1,5 +1,3 @@ -/* $NetBSD: inet.c,v 1.1.1.3 2013/04/06 15:57:47 christos Exp $ */ - /* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ /* * Copyright (c) 1994, 1995, 1996, 1997, 1998 @@ -34,11 +32,6 @@ * SUCH DAMAGE. */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/inet.c,v 1.79 2008-04-20 18:19:02 guy Exp (LBL)"; -#endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -92,6 +85,18 @@ struct rtentry; /* declarations in */ (isdigit((unsigned char)((name)[2])) || (name)[2] == '\0')) #endif +#ifdef IFF_UP +#define ISUP(flags) ((flags) & IFF_UP) +#else +#define ISUP(flags) 0 +#endif + +#ifdef IFF_RUNNING +#define ISRUNNING(flags) ((flags) & IFF_RUNNING) +#else +#define ISRUNNING(flags) 0 +#endif + struct sockaddr * dup_sockaddr(struct sockaddr *sa, size_t sa_length) { @@ -102,40 +107,85 @@ dup_sockaddr(struct sockaddr *sa, size_t sa_length) return (memcpy(newsa, sa, sa_length)); } -static int -get_instance(const char *name) +/* + * Construct a "figure of merit" for an interface, for use when sorting + * the list of interfaces, in which interfaces that are up are superior + * to interfaces that aren't up, interfaces that are up and running are + * superior to interfaces that are up but not running, and non-loopback + * interfaces that are up and running are superior to loopback interfaces, + * and interfaces with the same flags have a figure of merit that's higher + * the lower the instance number. + * + * The goal is to try to put the interfaces most likely to be useful for + * capture at the beginning of the list. + * + * The figure of merit, which is lower the "better" the interface is, + * has the uppermost bit set if the interface isn't running, the bit + * below that set if the interface isn't up, the bit below that set + * if the interface is a loopback interface, and the interface index + * in the 29 bits below that. (Yes, we assume u_int is 32 bits.) + */ +static u_int +get_figure_of_merit(pcap_if_t *dev) { - const char *cp, *endcp; - int n; + const char *cp; + u_int n; - if (strcmp(name, "any") == 0) { + if (strcmp(dev->name, "any") == 0) { /* * Give the "any" device an artificially high instance * number, so it shows up after all other non-loopback * interfaces. */ - return INT_MAX; + n = 0x1FFFFFFF; /* 29 all-1 bits */ + } else { + /* + * A number at the end of the device name string is + * assumed to be a unit number. + */ + cp = dev->name + strlen(dev->name) - 1; + while (cp-1 >= dev->name && *(cp-1) >= '0' && *(cp-1) <= '9') + cp--; + if (*cp >= '0' && *cp <= '9') + n = atoi(cp); + else + n = 0; } - - endcp = name + strlen(name); - for (cp = name; cp < endcp && !isdigit((unsigned char)*cp); ++cp) - continue; - - if (isdigit((unsigned char)*cp)) - n = atoi(cp); - else - n = 0; + if (!(dev->flags & PCAP_IF_RUNNING)) + n |= 0x80000000; + if (!(dev->flags & PCAP_IF_UP)) + n |= 0x40000000; + if (dev->flags & PCAP_IF_LOOPBACK) + n |= 0x20000000; return (n); } +/* + * Look for a given device in the specified list of devices. + * + * If we find it, return 0 and set *curdev_ret to point to it. + * + * If we don't find it, check whether we can open it: + * + * If that fails with PCAP_ERROR_NO_SUCH_DEVICE or + * PCAP_ERROR_IFACE_NOT_UP, don't attempt to add an entry for + * it, as that probably means it exists but doesn't support + * packet capture. + * + * Otherwise, attempt to add an entry for it, with the specified + * ifnet flags and description, and, if that succeeds, return 0 + * and set *curdev_ret to point to the new entry, otherwise + * return PCAP_ERROR and set errbuf to an error message. + */ int add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name, u_int flags, const char *description, char *errbuf) { pcap_t *p; pcap_if_t *curdev, *prevdev, *nextdev; - int this_instance; + u_int this_figure_of_merit, nextdev_figure_of_merit; char open_errbuf[PCAP_ERRBUF_SIZE]; + int ret; /* * Is there already an entry in the list for this interface? @@ -195,23 +245,72 @@ add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name, } strcpy(en_name, "en"); strcat(en_name, name + 3); - p = pcap_open_live(en_name, 68, 0, 0, open_errbuf); + p = pcap_create(en_name, open_errbuf); free(en_name); } else #endif /* __APPLE */ - p = pcap_open_live(name, 68, 0, 0, open_errbuf); + p = pcap_create(name, open_errbuf); if (p == NULL) { /* - * No. Don't bother including it. - * Don't treat this as an error, though. + * The attempt to create the pcap_t failed; + * that's probably an indication that we're + * out of memory. + * + * Don't bother including this interface, + * but don't treat it as an error. */ *curdev_ret = NULL; return (0); } + /* Small snaplen, so we don't try to allocate much memory. */ + pcap_set_snaplen(p, 68); + ret = pcap_activate(p); pcap_close(p); + switch (ret) { + + case PCAP_ERROR_NO_SUCH_DEVICE: + case PCAP_ERROR_IFACE_NOT_UP: + /* + * We expect these two errors - they're the + * reason we try to open the device. + * + * PCAP_ERROR_NO_SUCH_DEVICE typically means + * "there's no such device *known to the + * OS's capture mechanism*", so, even though + * it might be a valid network interface, you + * can't capture on it (e.g., the loopback + * device in Solaris up to Solaris 10, or + * the vmnet devices in OS X with VMware + * Fusion). We don't include those devices + * in our list of devices, as there's no + * point in doing so - they're not available + * for capture. + * + * PCAP_ERROR_IFACE_NOT_UP means that the + * OS's capture mechanism doesn't work on + * interfaces not marked as up; some capture + * mechanisms *do* support that, so we no + * longer reject those interfaces out of hand, + * but we *do* want to reject them if they + * can't be opened for capture. + */ + *curdev_ret = NULL; + return (0); + } /* - * Yes, we can open it. + * Yes, we can open it, or we can't, for some other + * reason. + * + * If we can open it, we want to offer it for + * capture, as you can capture on it. If we can't, + * we want to offer it for capture, so that, if + * the user tries to capture on it, they'll get + * an error and they'll know why they can't + * capture on it (e.g., insufficient permissions) + * or they'll report it as a problem (and then + * have the error message to provide as information). + * * Allocate a new entry. */ curdev = malloc(sizeof(pcap_if_t)); @@ -254,20 +353,22 @@ add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name, curdev->flags = 0; if (ISLOOPBACK(name, flags)) curdev->flags |= PCAP_IF_LOOPBACK; + if (ISUP(flags)) + curdev->flags |= PCAP_IF_UP; + if (ISRUNNING(flags)) + curdev->flags |= PCAP_IF_RUNNING; /* * Add it to the list, in the appropriate location. - * First, get the instance number of this interface. + * First, get the "figure of merit" for this + * interface. */ - this_instance = get_instance(name); + this_figure_of_merit = get_figure_of_merit(curdev); /* - * Now look for the last interface with an instance number - * less than or equal to the new interface's instance - * number - except that non-loopback interfaces are - * arbitrarily treated as having interface numbers less - * than those of loopback interfaces, so the loopback - * interfaces are put at the end of the list. + * Now look for the last interface with an figure of merit + * less than or equal to the new interface's figure of + * merit. * * We start with "prevdev" being NULL, meaning we're before * the first element in the list. @@ -297,34 +398,13 @@ add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name, } /* - * Is the new interface a non-loopback interface - * and the next interface a loopback interface? + * Is the new interface's figure of merit less + * than the next interface's figure of merit, + * meaning that the new interface is better + * than the next interface? */ - if (!(curdev->flags & PCAP_IF_LOOPBACK) && - (nextdev->flags & PCAP_IF_LOOPBACK)) { - /* - * Yes, we should put the new entry - * before "nextdev", i.e. after "prevdev". - */ - break; - } - - /* - * Is the new interface's instance number less - * than the next interface's instance number, - * and is it the case that the new interface is a - * non-loopback interface or the next interface is - * a loopback interface? - * - * (The goal of both loopback tests is to make - * sure that we never put a loopback interface - * before any non-loopback interface and that we - * always put a non-loopback interface before all - * loopback interfaces.) - */ - if (this_instance < get_instance(nextdev->name) && - (!(curdev->flags & PCAP_IF_LOOPBACK) || - (nextdev->flags & PCAP_IF_LOOPBACK))) { + nextdev_figure_of_merit = get_figure_of_merit(nextdev); + if (this_figure_of_merit < nextdev_figure_of_merit) { /* * Yes - we should put the new entry * before "nextdev", i.e. after "prevdev". @@ -360,6 +440,9 @@ add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name, } /* + * Try to get a description for a given device. + * Returns a mallocated description if it could and NULL if it couldn't. + * * XXX - on FreeBSDs that support it, should it get the sysctl named * "dev.{adapter family name}.{adapter unit}.%desc" to get a description * of the adapter? Note that "dev.an.0.%desc" is "Aironet PC4500/PC4800" @@ -405,18 +488,11 @@ add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name, * Do any other UN*Xes, or desktop environments support getting a * description? */ -int -add_addr_to_iflist(pcap_if_t **alldevs, const char *name, u_int flags, - struct sockaddr *addr, size_t addr_size, - struct sockaddr *netmask, size_t netmask_size, - struct sockaddr *broadaddr, size_t broadaddr_size, - struct sockaddr *dstaddr, size_t dstaddr_size, - char *errbuf) +static char * +get_if_description(const char *name) { - pcap_if_t *curdev; - char *description = NULL; - pcap_addr_t *curaddr, *prevaddr, *nextaddr; #ifdef SIOCGIFDESCR + char *description = NULL; int s; struct ifreq ifrdesc; #ifndef IFDESCRSIZE @@ -424,9 +500,7 @@ add_addr_to_iflist(pcap_if_t **alldevs, const char *name, u_int flags, #else size_t descrlen = IFDESCRSIZE; #endif /* IFDESCRSIZE */ -#endif /* SIOCGIFDESCR */ -#ifdef SIOCGIFDESCR /* * Get the description for the interface. */ @@ -487,8 +561,44 @@ add_addr_to_iflist(pcap_if_t **alldevs, const char *name, u_int flags, description = NULL; } } -#endif /* SIOCGIFDESCR */ + return (description); +#else /* SIOCGIFDESCR */ + return (NULL); +#endif /* SIOCGIFDESCR */ +} + +/* + * Try to get a description for a given device, and then look for that + * device in the specified list of devices. + * + * If we find it, add the specified address to it and return 0. + * + * If we don't find it, check whether we can open it: + * + * If that fails with PCAP_ERROR_NO_SUCH_DEVICE or + * PCAP_ERROR_IFACE_NOT_UP, don't attempt to add an entry for + * it, as that probably means it exists but doesn't support + * packet capture. + * + * Otherwise, attempt to add an entry for it, with the specified + * ifnet flags and description, and, if that succeeds, add the + * specified address to it, set *curdev_ret to point to the new + * entry, and return 0, otherwise return PCAP_ERROR and set errbuf + * to an error message. + */ +int +add_addr_to_iflist(pcap_if_t **alldevs, const char *name, u_int flags, + struct sockaddr *addr, size_t addr_size, + struct sockaddr *netmask, size_t netmask_size, + struct sockaddr *broadaddr, size_t broadaddr_size, + struct sockaddr *dstaddr, size_t dstaddr_size, + char *errbuf) +{ + char *description; + pcap_if_t *curdev; + + description = get_if_description(name); if (add_or_find_if(&curdev, alldevs, name, flags, description, errbuf) == -1) { free(description); @@ -512,6 +622,26 @@ add_addr_to_iflist(pcap_if_t **alldevs, const char *name, u_int flags, * * Allocate the new entry and fill it in. */ + return (add_addr_to_dev(curdev, addr, addr_size, netmask, netmask_size, + broadaddr, broadaddr_size, dstaddr, dstaddr_size, errbuf)); +} + +/* + * Add an entry to the list of addresses for an interface. + * "curdev" is the entry for that interface. + * If this is the first IP address added to the interface, move it + * in the list as appropriate. + */ +int +add_addr_to_dev(pcap_if_t *curdev, + struct sockaddr *addr, size_t addr_size, + struct sockaddr *netmask, size_t netmask_size, + struct sockaddr *broadaddr, size_t broadaddr_size, + struct sockaddr *dstaddr, size_t dstaddr_size, + char *errbuf) +{ + pcap_addr_t *curaddr, *prevaddr, *nextaddr; + curaddr = malloc(sizeof(pcap_addr_t)); if (curaddr == NULL) { (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, @@ -605,6 +735,23 @@ add_addr_to_iflist(pcap_if_t **alldevs, const char *name, u_int flags, return (0); } +/* + * Look for a given device in the specified list of devices. + * + * If we find it, return 0. + * + * If we don't find it, check whether we can open it: + * + * If that fails with PCAP_ERROR_NO_SUCH_DEVICE or + * PCAP_ERROR_IFACE_NOT_UP, don't attempt to add an entry for + * it, as that probably means it exists but doesn't support + * packet capture. + * + * Otherwise, attempt to add an entry for it, with the specified + * ifnet flags and description, and, if that succeeds, return 0 + * and set *curdev_ret to point to the new entry, otherwise + * return PCAP_ERROR and set errbuf to an error message. + */ int pcap_add_if(pcap_if_t **devlist, const char *name, u_int flags, const char *description, char *errbuf) @@ -819,14 +966,14 @@ pcap_lookupdev(errbuf) DWORD dwWindowsMajorVersion; dwVersion = GetVersion(); /* get the OS version */ dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); - + if (dwVersion >= 0x80000000 && dwWindowsMajorVersion >= 4) { /* * Windows 95, 98, ME. */ ULONG NameLength = 8192; static char AdaptersName[8192]; - + if (PacketGetAdapterNames(AdaptersName,&NameLength) ) return (AdaptersName); else @@ -889,7 +1036,7 @@ pcap_lookupdev(errbuf) free(TAdaptersName); return (char *)(AdaptersName); - } + } } @@ -899,7 +1046,7 @@ pcap_lookupnet(device, netp, maskp, errbuf) register bpf_u_int32 *netp, *maskp; register char *errbuf; { - /* + /* * We need only the first IPv4 address, so we must scan the array returned by PacketGetNetInfo() * in order to skip non IPv4 (i.e. IPv6 addresses) */ @@ -925,7 +1072,7 @@ pcap_lookupnet(device, netp, maskp, errbuf) *netp &= *maskp; return (0); } - + } *netp = *maskp = 0; diff --git a/external/bsd/libpcap/dist/lbl/os-aix4.h b/external/bsd/libpcap/dist/lbl/os-aix4.h index ec7887e2e278..5cf458627eb2 100644 --- a/external/bsd/libpcap/dist/lbl/os-aix4.h +++ b/external/bsd/libpcap/dist/lbl/os-aix4.h @@ -1,5 +1,3 @@ -/* $NetBSD: os-aix4.h,v 1.1.1.3 2013/04/06 15:57:52 christos Exp $ */ - /* * Copyright (c) 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -19,8 +17,6 @@ * 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. - * - * @(#) 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/external/bsd/libpcap/dist/lbl/os-hpux11.h b/external/bsd/libpcap/dist/lbl/os-hpux11.h index 8b50534d94ad..42c6b60d493a 100644 --- a/external/bsd/libpcap/dist/lbl/os-hpux11.h +++ b/external/bsd/libpcap/dist/lbl/os-hpux11.h @@ -1,5 +1,3 @@ -/* $NetBSD: os-hpux11.h,v 1.1.1.3 2013/04/06 15:57:52 christos Exp $ */ - /* * Copyright (c) 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -19,8 +17,6 @@ * 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. - * - * @(#) 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/external/bsd/libpcap/dist/lbl/os-osf4.h b/external/bsd/libpcap/dist/lbl/os-osf4.h index 14c0dad90f6f..6b87bc055c29 100644 --- a/external/bsd/libpcap/dist/lbl/os-osf4.h +++ b/external/bsd/libpcap/dist/lbl/os-osf4.h @@ -1,5 +1,3 @@ -/* $NetBSD: os-osf4.h,v 1.1.1.3 2013/04/06 15:57:52 christos Exp $ */ - /* * Copyright (c) 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -19,8 +17,6 @@ * 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. - * - * @(#) 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/external/bsd/libpcap/dist/lbl/os-osf5.h b/external/bsd/libpcap/dist/lbl/os-osf5.h index 6174a416e2b6..4c73c69f4a71 100644 --- a/external/bsd/libpcap/dist/lbl/os-osf5.h +++ b/external/bsd/libpcap/dist/lbl/os-osf5.h @@ -1,5 +1,3 @@ -/* $NetBSD: os-osf5.h,v 1.1.1.3 2013/04/06 15:57:52 christos Exp $ */ - /* * Copyright (c) 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -19,8 +17,6 @@ * 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. - * - * @(#) Header: /tcpdump/master/libpcap/lbl/os-osf5.h,v 1.2 2002-08-02 03:24:15 guy Exp (LBL) */ /* diff --git a/external/bsd/libpcap/dist/lbl/os-solaris2.h b/external/bsd/libpcap/dist/lbl/os-solaris2.h index 7893d9b12e84..22948b4a2695 100644 --- a/external/bsd/libpcap/dist/lbl/os-solaris2.h +++ b/external/bsd/libpcap/dist/lbl/os-solaris2.h @@ -1,5 +1,3 @@ -/* $NetBSD: os-solaris2.h,v 1.1.1.3 2013/04/06 15:57:52 christos Exp $ */ - /* * Copyright (c) 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -19,8 +17,6 @@ * 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. - * - * @(#) 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/external/bsd/libpcap/dist/lbl/os-sunos4.h b/external/bsd/libpcap/dist/lbl/os-sunos4.h index 1ba344ad6325..b73585706cd5 100644 --- a/external/bsd/libpcap/dist/lbl/os-sunos4.h +++ b/external/bsd/libpcap/dist/lbl/os-sunos4.h @@ -1,5 +1,3 @@ -/* $NetBSD: os-sunos4.h,v 1.1.1.3 2013/04/06 15:57:52 christos Exp $ */ - /* * Copyright (c) 1989, 1990, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. @@ -19,8 +17,6 @@ * 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. - * - * @(#) 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/external/bsd/libpcap/dist/lbl/os-ultrix4.h b/external/bsd/libpcap/dist/lbl/os-ultrix4.h index 9b44813be33f..fa1f770f8d44 100644 --- a/external/bsd/libpcap/dist/lbl/os-ultrix4.h +++ b/external/bsd/libpcap/dist/lbl/os-ultrix4.h @@ -1,5 +1,3 @@ -/* $NetBSD: os-ultrix4.h,v 1.1.1.3 2013/04/06 15:57:52 christos Exp $ */ - /* * Copyright (c) 1990, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. @@ -19,8 +17,6 @@ * 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. - * - * @(#) 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/external/bsd/libpcap/dist/llc.h b/external/bsd/libpcap/dist/llc.h index 84e331e1cc8d..b0cf881ca1dd 100644 --- a/external/bsd/libpcap/dist/llc.h +++ b/external/bsd/libpcap/dist/llc.h @@ -1,5 +1,3 @@ -/* $NetBSD: llc.h,v 1.1.1.3 2013/04/06 15:57:46 christos Exp $ */ - /* * Copyright (c) 1993, 1994, 1997 * The Regents of the University of California. All rights reserved. @@ -19,10 +17,39 @@ * 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. - * - * @(#) Header: /tcpdump/master/libpcap/llc.h,v 1.2 2001-01-28 09:44:50 guy Exp (LBL) */ +/* + * Definitions for information in the LLC header. + */ + +#define LLC_U_FMT 3 +#define LLC_GSAP 1 +#define LLC_IG 1 /* Individual / Group */ +#define LLC_S_FMT 1 + +#define LLC_U_POLL 0x10 +#define LLC_IS_POLL 0x0100 +#define LLC_XID_FI 0x81 + +#define LLC_U_CMD_MASK 0xef +#define LLC_UI 0x03 +#define LLC_UA 0x63 +#define LLC_DISC 0x43 +#define LLC_DM 0x0f +#define LLC_SABME 0x6f +#define LLC_TEST 0xe3 +#define LLC_XID 0xaf +#define LLC_FRMR 0x87 + +#define LLC_S_CMD_MASK 0x0f +#define LLC_RR 0x0001 +#define LLC_RNR 0x0005 +#define LLC_REJ 0x0009 + +#define LLC_IS_NR(is) (((is) >> 9) & 0x7f) +#define LLC_I_NS(is) (((is) >> 1) & 0x7f) + /* * 802.2 LLC SAP values. */ @@ -33,10 +60,10 @@ #ifndef LLCSAP_GLOBAL #define LLCSAP_GLOBAL 0xff #endif -#ifndef LLCSAP_8021B +#ifndef LLCSAP_8021B_I #define LLCSAP_8021B_I 0x02 #endif -#ifndef LLCSAP_8021B +#ifndef LLCSAP_8021B_G #define LLCSAP_8021B_G 0x03 #endif #ifndef LLCSAP_IP diff --git a/external/bsd/libpcap/dist/missing/snprintf.c b/external/bsd/libpcap/dist/missing/snprintf.c index 73399bf948d6..9b63f8b1dcd0 100644 --- a/external/bsd/libpcap/dist/missing/snprintf.c +++ b/external/bsd/libpcap/dist/missing/snprintf.c @@ -1,5 +1,3 @@ -/* $NetBSD: snprintf.c,v 1.1.1.3 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (c) 1995-1999 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). @@ -33,17 +31,10 @@ * SUCH DAMAGE. */ -/* Id: snprintf.c,v 1.1 2004-04-05 22:43:51 guy Exp */ - #ifdef HAVE_CONFIG_H #include #endif -#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 "; -#endif - #include #include #include diff --git a/external/bsd/libpcap/dist/msdos/bin2c.c b/external/bsd/libpcap/dist/msdos/bin2c.c index 8e3b97293d2f..d82056e17a94 100644 --- a/external/bsd/libpcap/dist/msdos/bin2c.c +++ b/external/bsd/libpcap/dist/msdos/bin2c.c @@ -1,5 +1,3 @@ -/* $NetBSD: bin2c.c,v 1.1.1.2 2013/04/06 15:57:52 christos Exp $ */ - #include #include #include diff --git a/external/bsd/libpcap/dist/msdos/common.dj b/external/bsd/libpcap/dist/msdos/common.dj index c2693c33ef02..ec0ce02b2449 100644 --- a/external/bsd/libpcap/dist/msdos/common.dj +++ b/external/bsd/libpcap/dist/msdos/common.dj @@ -1,7 +1,6 @@ # # Common defines for libpcap and 16/32-bit network drivers (djgpp) # -# @(#) Header: /tcpdump/master/libpcap/msdos/common.dj,v 1.2 2004-12-19 19:36:33 guy Exp (LBL) .SUFFIXES: .exe .wlm .dxe .l .y .PHONY: check_gcclib diff --git a/external/bsd/libpcap/dist/msdos/makefile.dj b/external/bsd/libpcap/dist/msdos/makefile.dj index 748bec5b95e7..28e3f2d71120 100644 --- a/external/bsd/libpcap/dist/msdos/makefile.dj +++ b/external/bsd/libpcap/dist/msdos/makefile.dj @@ -6,7 +6,6 @@ # # c:\net\pcap> make -f msdos/makefile.dj # -# @(#) Header: /tcpdump/master/libpcap/msdos/makefile.dj,v 1.2 2004-12-19 19:41:06 guy Exp (LBL) VPATH = missing msdos diff --git a/external/bsd/libpcap/dist/msdos/ndis2.c b/external/bsd/libpcap/dist/msdos/ndis2.c index 27e7d761a42a..0a5ea2a7b89e 100644 --- a/external/bsd/libpcap/dist/msdos/ndis2.c +++ b/external/bsd/libpcap/dist/msdos/ndis2.c @@ -1,5 +1,3 @@ -/* $NetBSD: ndis2.c,v 1.1.1.2 2013/04/06 15:57:52 christos Exp $ */ - /* * Copyright (c) 1993,1994 * Texas A&M University. All rights reserved. diff --git a/external/bsd/libpcap/dist/msdos/ndis2.h b/external/bsd/libpcap/dist/msdos/ndis2.h index 06e7482dafd7..dc72f4c6a80b 100644 --- a/external/bsd/libpcap/dist/msdos/ndis2.h +++ b/external/bsd/libpcap/dist/msdos/ndis2.h @@ -1,5 +1,3 @@ -/* $NetBSD: ndis2.h,v 1.1.1.2 2013/04/06 15:57:52 christos Exp $ */ - /* * Copyright (c) 1993,1994 * Texas A&M University. All rights reserved. diff --git a/external/bsd/libpcap/dist/msdos/pktdrvr.c b/external/bsd/libpcap/dist/msdos/pktdrvr.c index b82daaa51fa6..cd22ee645900 100644 --- a/external/bsd/libpcap/dist/msdos/pktdrvr.c +++ b/external/bsd/libpcap/dist/msdos/pktdrvr.c @@ -1,5 +1,3 @@ -/* $NetBSD: pktdrvr.c,v 1.1.1.2 2013/04/06 15:57:52 christos Exp $ */ - /* * File.........: pktdrvr.c * diff --git a/external/bsd/libpcap/dist/msdos/pktdrvr.h b/external/bsd/libpcap/dist/msdos/pktdrvr.h index 4a58d0de410f..08898ae8685f 100644 --- a/external/bsd/libpcap/dist/msdos/pktdrvr.h +++ b/external/bsd/libpcap/dist/msdos/pktdrvr.h @@ -1,5 +1,3 @@ -/* $NetBSD: pktdrvr.h,v 1.1.1.2 2013/04/06 15:57:52 christos Exp $ */ - #ifndef __PKTDRVR_H #define __PKTDRVR_H diff --git a/external/bsd/libpcap/dist/msdos/readme.dos b/external/bsd/libpcap/dist/msdos/readme.dos index 37ecd1e6158c..913c4e697042 100644 --- a/external/bsd/libpcap/dist/msdos/readme.dos +++ b/external/bsd/libpcap/dist/msdos/readme.dos @@ -1,5 +1,3 @@ -@(#) Header: /tcpdump/master/libpcap/msdos/readme.dos,v 1.3 2004-12-19 19:47:01 guy Exp (LBL) - libpcap for DOS --------------- diff --git a/external/bsd/libpcap/dist/nametoaddr.c b/external/bsd/libpcap/dist/nametoaddr.c index ef759a642489..e6483a358d09 100644 --- a/external/bsd/libpcap/dist/nametoaddr.c +++ b/external/bsd/libpcap/dist/nametoaddr.c @@ -1,5 +1,3 @@ -/* $NetBSD: nametoaddr.c,v 1.1.1.4 2013/12/31 16:57:25 christos Exp $ */ - /* * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998 * The Regents of the University of California. All rights reserved. @@ -24,11 +22,6 @@ * These functions are not time critical. */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) 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 diff --git a/external/bsd/libpcap/dist/nlpid.h b/external/bsd/libpcap/dist/nlpid.h index b49b7192e112..9dfa752b8575 100644 --- a/external/bsd/libpcap/dist/nlpid.h +++ b/external/bsd/libpcap/dist/nlpid.h @@ -1,5 +1,3 @@ -/* $NetBSD: nlpid.h,v 1.1.1.3 2013/04/06 15:57:48 christos Exp $ */ - /* * Copyright (c) 1996 * Juniper Networks, Inc. All rights reserved. @@ -16,8 +14,6 @@ * 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. - * - * @(#) 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/external/bsd/libpcap/dist/pcap-bpf.h b/external/bsd/libpcap/dist/pcap-bpf.h index 19190e2137ee..937452293362 100644 --- a/external/bsd/libpcap/dist/pcap-bpf.h +++ b/external/bsd/libpcap/dist/pcap-bpf.h @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-bpf.h,v 1.1.1.3 2013/04/06 15:57:48 christos Exp $ */ - /*- * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -36,8 +34,6 @@ * 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. - * - * @(#) Header: /tcpdump/master/libpcap/pcap-bpf.h,v 1.50 2007-04-01 21:43:55 guy Exp (LBL) */ /* diff --git a/external/bsd/libpcap/dist/pcap-bt-linux.c b/external/bsd/libpcap/dist/pcap-bt-linux.c index 55c91b0bf66d..a32691d348c3 100644 --- a/external/bsd/libpcap/dist/pcap-bt-linux.c +++ b/external/bsd/libpcap/dist/pcap-bt-linux.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-bt-linux.c,v 1.1.1.4 2013/12/31 16:57:28 christos Exp $ */ - /* * Copyright (c) 2006 Paolo Abeni (Italy) * All rights reserved. @@ -33,10 +31,6 @@ * By Paolo Abeni * */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) 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 #include "config.h" diff --git a/external/bsd/libpcap/dist/pcap-bt-linux.h b/external/bsd/libpcap/dist/pcap-bt-linux.h index 283959ef3a8b..cacbd2f10dbd 100644 --- a/external/bsd/libpcap/dist/pcap-bt-linux.h +++ b/external/bsd/libpcap/dist/pcap-bt-linux.h @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-bt-linux.h,v 1.1.1.4 2013/12/31 16:57:18 christos Exp $ */ - /* * Copyright (c) 2006 Paolo Abeni (Italy) * All rights reserved. @@ -31,8 +29,6 @@ * * Bluetooth sniffing API implementation for Linux platform * By Paolo Abeni - * - * @(#) Header: /tcpdump/master/libpcap/pcap-bt-linux.h,v 1.5 2008-04-04 19:37:45 guy Exp (LBL) */ /* diff --git a/external/bsd/libpcap/dist/pcap-bt-monitor-linux.c b/external/bsd/libpcap/dist/pcap-bt-monitor-linux.c new file mode 100644 index 000000000000..76c9ee34a4e1 --- /dev/null +++ b/external/bsd/libpcap/dist/pcap-bt-monitor-linux.c @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2014 Michal Labedzki for Tieto Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include +#include +#include + +#include "pcap/bluetooth.h" +#include "pcap-int.h" + +#define BT_CONTROL_SIZE 32 +#define INTERFACE_NAME "bluetooth-monitor" + +int +bt_monitor_findalldevs(pcap_if_t **alldevsp, char *err_str) +{ + int ret = 0; + + if (pcap_add_if(alldevsp, INTERFACE_NAME, 0, + "Bluetooth Linux Monitor", err_str) < 0) + { + ret = -1; + } + + return ret; +} + +static int +bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_char *user) +{ + struct cmsghdr *cmsg; + struct msghdr msg; + struct iovec iv[2]; + ssize_t ret; + struct pcap_pkthdr pkth; + pcap_bluetooth_linux_monitor_header *bthdr; + struct mgmt_hdr hdr; + int in = 0; + + bthdr = (pcap_bluetooth_linux_monitor_header*) &handle->buffer[handle->offset]; + + iv[0].iov_base = &hdr; + iv[0].iov_len = MGMT_HDR_SIZE; + iv[1].iov_base = &handle->buffer[handle->offset + sizeof(pcap_bluetooth_linux_monitor_header)]; + iv[1].iov_len = handle->snapshot; + + memset(&pkth.ts, 0, sizeof(pkth.ts)); + memset(&msg, 0, sizeof(msg)); + msg.msg_iov = iv; + msg.msg_iovlen = 2; + msg.msg_control = handle->buffer; + msg.msg_controllen = handle->offset; + + do { + ret = recvmsg(handle->fd, &msg, 0); + if (handle->break_loop) + { + handle->break_loop = 0; + return -2; + } + } while ((ret == -1) && (errno == EINTR)); + + if (ret < 0) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "Can't receive packet: %s", strerror(errno)); + return -1; + } + + pkth.caplen = ret - MGMT_HDR_SIZE + sizeof(pcap_bluetooth_linux_monitor_header); + pkth.len = pkth.caplen; + + for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) { + if (cmsg->cmsg_level != SOL_SOCKET) continue; + + if (cmsg->cmsg_type == SCM_TIMESTAMP) { + memcpy(&pkth.ts, CMSG_DATA(cmsg), sizeof(pkth.ts)); + } + } + + bthdr->adapter_id = htons(hdr.index); + bthdr->opcode = htons(hdr.opcode); + + if (handle->fcode.bf_insns == NULL || + bpf_filter(handle->fcode.bf_insns, &handle->buffer[handle->offset], + pkth.len, pkth.caplen)) { + callback(user, &pkth, &handle->buffer[handle->offset]); + return 1; + } + return 0; /* didn't pass filter */ +} + +static int +bt_monitor_inject(pcap_t *handle, const void *buf _U_, size_t size _U_) +{ + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "inject not supported yet"); + return -1; +} + +static int +bt_monitor_setdirection(pcap_t *p, pcap_direction_t d) +{ + p->direction = d; + return 0; +} + +static int +bt_monitor_stats(pcap_t *handle _U_, struct pcap_stat *stats) +{ + stats->ps_recv = 0; + stats->ps_drop = 0; + stats->ps_ifdrop = 0; + + return 0; +} + +static int +bt_monitor_activate(pcap_t* handle) +{ + struct sockaddr_hci addr; + int err = PCAP_ERROR; + int opt; + + if (handle->opt.rfmon) { + /* monitor mode doesn't apply here */ + return PCAP_ERROR_RFMON_NOTSUP; + } + + handle->bufsize = handle->snapshot + BT_CONTROL_SIZE + sizeof(pcap_bluetooth_linux_monitor_header); + handle->offset = BT_CONTROL_SIZE; + handle->linktype = DLT_BLUETOOTH_LINUX_MONITOR; + + handle->read_op = bt_monitor_read; + handle->inject_op = bt_monitor_inject; + handle->setfilter_op = install_bpf_program; /* no kernel filtering */ + handle->setdirection_op = bt_monitor_setdirection; + handle->set_datalink_op = NULL; /* can't change data link type */ + handle->getnonblock_op = pcap_getnonblock_fd; + handle->setnonblock_op = pcap_setnonblock_fd; + handle->stats_op = bt_monitor_stats; + + handle->fd = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); + if (handle->fd < 0) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "Can't create raw socket: %s", strerror(errno)); + return PCAP_ERROR; + } + + handle->buffer = malloc(handle->bufsize); + if (!handle->buffer) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't allocate dump buffer: %s", + pcap_strerror(errno)); + goto close_fail; + } + + /* Bind socket to the HCI device */ + addr.hci_family = AF_BLUETOOTH; + addr.hci_dev = HCI_DEV_NONE; + addr.hci_channel = HCI_CHANNEL_MONITOR; + + if (bind(handle->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "Can't attach to interface: %s", strerror(errno)); + goto close_fail; + } + + opt = 1; + if (setsockopt(handle->fd, SOL_SOCKET, SO_TIMESTAMP, &opt, sizeof(opt)) < 0) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "Can't enable time stamp: %s", strerror(errno)); + goto close_fail; + } + + handle->selectable_fd = handle->fd; + + return 0; + +close_fail: + pcap_cleanup_live_common(handle); + return err; +} + +pcap_t * +bt_monitor_create(const char *device, char *ebuf, int *is_ours) +{ + pcap_t *p; + const char *cp; + + cp = strrchr(device, '/'); + if (cp == NULL) + cp = device; + + if (strcmp(cp, INTERFACE_NAME) != 0) { + *is_ours = 0; + return NULL; + } + + *is_ours = 1; + p = pcap_create_common(device, ebuf, 0); + if (p == NULL) + return NULL; + + p->activate_op = bt_monitor_activate; + + return p; +} diff --git a/external/bsd/libpcap/dist/pcap-bt-monitor-linux.h b/external/bsd/libpcap/dist/pcap-bt-monitor-linux.h new file mode 100644 index 000000000000..aada2bc77bfb --- /dev/null +++ b/external/bsd/libpcap/dist/pcap-bt-monitor-linux.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2014 Michal Labedzki for Tieto Corporation + * 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. + */ + +int bt_monitor_findalldevs(pcap_if_t **alldevsp, char *err_str); +pcap_t *bt_monitor_create(const char *device, char *ebuf, int *is_ours); diff --git a/external/bsd/libpcap/dist/pcap-can-linux.c b/external/bsd/libpcap/dist/pcap-can-linux.c index bcefc92a805d..3a9e8cbeef21 100644 --- a/external/bsd/libpcap/dist/pcap-can-linux.c +++ b/external/bsd/libpcap/dist/pcap-can-linux.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-can-linux.c,v 1.1.1.3 2013/12/31 16:57:20 christos Exp $ */ - /* * Copyright (c) 2009 Felix Obenhuber * All rights reserved. @@ -245,7 +243,7 @@ can_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *u } } while ((pkth.caplen == -1) && (errno == EINTR)); - if (pkth.caplen < 0) + if (pkth.caplen == -1) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't receive packet %d:%s", errno, strerror(errno)); diff --git a/external/bsd/libpcap/dist/pcap-can-linux.h b/external/bsd/libpcap/dist/pcap-can-linux.h index 9e48c81bf211..fe806ff93578 100644 --- a/external/bsd/libpcap/dist/pcap-can-linux.h +++ b/external/bsd/libpcap/dist/pcap-can-linux.h @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-can-linux.h,v 1.1.1.3 2013/12/31 16:57:20 christos Exp $ */ - /* * Copyright (c) 2009 Felix Obenhuber * All rights reserved. diff --git a/external/bsd/libpcap/dist/pcap-canusb-linux.c b/external/bsd/libpcap/dist/pcap-canusb-linux.c index ab29ede8c091..a72f4697fa4d 100644 --- a/external/bsd/libpcap/dist/pcap-canusb-linux.c +++ b/external/bsd/libpcap/dist/pcap-canusb-linux.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-canusb-linux.c,v 1.1.1.2 2013/12/31 16:57:24 christos Exp $ */ - /* * Copyright (c) 2009 Felix Obenhuber * All rights reserved. diff --git a/external/bsd/libpcap/dist/pcap-canusb-linux.h b/external/bsd/libpcap/dist/pcap-canusb-linux.h index aa7950eddffd..c8f3be1d9c65 100644 --- a/external/bsd/libpcap/dist/pcap-canusb-linux.h +++ b/external/bsd/libpcap/dist/pcap-canusb-linux.h @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-canusb-linux.h,v 1.1.1.2 2013/12/31 16:57:21 christos Exp $ */ - /* * Copyright (c) 2009 Felix Obenhuber * All rights reserved. diff --git a/external/bsd/libpcap/dist/pcap-common.c b/external/bsd/libpcap/dist/pcap-common.c index f8abcfc6ecf8..a68e03221528 100644 --- a/external/bsd/libpcap/dist/pcap-common.c +++ b/external/bsd/libpcap/dist/pcap-common.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-common.c,v 1.1.1.4 2013/12/31 16:57:28 christos Exp $ */ - /* * Copyright (c) 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -43,6 +41,7 @@ #include "pcap-int.h" #include "pcap/usb.h" +#include "pcap/nflog.h" #include "pcap-common.h" @@ -934,7 +933,68 @@ */ #define LINKTYPE_WIRESHARK_UPPER_PDU 252 -#define LINKTYPE_MATCHING_MAX 252 /* highest value in the "matching" range */ +/* + * Link-layer header type for the netlink protocol (nlmon devices). + */ +#define LINKTYPE_NETLINK 253 + +/* + * Bluetooth Linux Monitor headers for the BlueZ stack. + */ +#define LINKTYPE_BLUETOOTH_LINUX_MONITOR 254 + +/* + * Bluetooth Basic Rate/Enhanced Data Rate baseband packets, as + * captured by Ubertooth. + */ +#define LINKTYPE_BLUETOOTH_BREDR_BB 255 + +/* + * Bluetooth Low Energy link layer packets, as captured by Ubertooth. + */ +#define LINKTYPE_BLUETOOTH_LE_LL_WITH_PHDR 256 + +/* + * PROFIBUS data link layer. + */ +#define LINKTYPE_PROFIBUS_DL 257 + + +/* + * Apple's DLT_PKTAP headers. + * + * Sadly, the folks at Apple either had no clue that the DLT_USERn values + * are for internal use within an organization and partners only, and + * didn't know that the right way to get a link-layer header type is to + * ask tcpdump.org for one, or knew and didn't care, so they just + * used DLT_USER2, which causes problems for everything except for + * their version of tcpdump. + * + * So I'll just give them one; hopefully this will show up in a + * libpcap release in time for them to get this into 10.10 Big Sur + * or whatever Mavericks' successor is called. LINKTYPE_PKTAP + * will be 258 *even on OS X*; that is *intentional*, so that + * PKTAP files look the same on *all* OSes (different OSes can have + * different numerical values for a given DLT_, but *MUST NOT* have + * different values for what goes in a file, as files can be moved + * between OSes!). + */ +#define LINKTYPE_PKTAP 258 + +/* + * Ethernet packets preceded by a header giving the last 6 octets + * of the preamble specified by 802.3-2012 Clause 65, section + * 65.1.3.2 "Transmit". + */ +#define LINKTYPE_EPON 259 + +/* + * IPMI trace packets, as specified by Table 3-20 "Trace Data Block Format" + * in the PICMG HPM.2 specification. + */ +#define LINKTYPE_IPMI_HPM_2 260 + +#define LINKTYPE_MATCHING_MAX 260 /* highest value in the "matching" range */ static struct linktype_map { int dlt; @@ -1007,13 +1067,20 @@ dlt_to_linktype(int dlt) int i; /* - * Map DLT_PFSYNC, whatever it might be, to LINKTYPE_PFSYNC. + * DLTs that, on some platforms, have values in the matching range + * but that *don't* have the same value as the corresponding + * LINKTYPE because, for some reason, not all OSes have the + * same value for that DLT (note that the DLT's value might be + * outside the matching range on some of those OSes). */ if (dlt == DLT_PFSYNC) return (LINKTYPE_PFSYNC); + if (dlt == DLT_PKTAP) + return (LINKTYPE_PKTAP); /* - * Map the values in the matching range. + * For all other values in the matching range, the DLT + * value is the same as the LINKTYPE value. */ if (dlt >= DLT_MATCHING_MIN && dlt <= DLT_MATCHING_MAX) return (dlt); @@ -1027,9 +1094,9 @@ dlt_to_linktype(int dlt) } /* - * If we don't have a mapping for this DLT_ code, return an + * If we don't have a mapping for this DLT, return an * error; that means that this is a value with no corresponding - * LINKTYPE_ code, and we need to assign one. + * LINKTYPE, and we need to assign one. */ return (-1); } @@ -1040,16 +1107,19 @@ linktype_to_dlt(int linktype) int i; /* - * Map LINKTYPE_PFSYNC to DLT_PFSYNC, whatever it might be. - * LINKTYPE_PFSYNC is in the matching range, to make sure - * it's as safe from reuse as we can arrange, so we do - * this test first. + * LINKTYPEs in the matching range that *don't* + * have the same value as the corresponding DLTs + * because, for some reason, not all OSes have the + * same value for that DLT. */ if (linktype == LINKTYPE_PFSYNC) return (DLT_PFSYNC); + if (linktype == LINKTYPE_PKTAP) + return (DLT_PKTAP); /* - * Map the values in the matching range. + * For all other values in the matching range, the LINKTYPE + * value is the same as the DLT value. */ if (linktype >= LINKTYPE_MATCHING_MIN && linktype <= LINKTYPE_MATCHING_MAX) @@ -1064,9 +1134,9 @@ linktype_to_dlt(int linktype) } /* - * 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. + * If we don't have an entry for this LINKTYPE, return + * the link type value; it may be a DLT from an older + * version of libpcap. */ return linktype; } @@ -1077,10 +1147,10 @@ linktype_to_dlt(int linktype) * 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. + * we need to convert it from the byte order of the host that wrote + * the file to this host's byte order. */ -void +static void swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf, int header_len_64_bytes) { @@ -1207,3 +1277,93 @@ swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf, } } } + +/* + * The DLT_NFLOG "packets" have a mixture of big-endian and host-byte-order + * data. They begin with a fixed-length header with big-endian fields, + * followed by a set of TLVs, where the type and length are in host + * byte order but the values are either big-endian or are a raw byte + * sequence that's the same regardless of the host's byte order. + * + * When reading a DLT_NFLOG capture file, we need to convert the type + * and length values from the byte order of the host that wrote the + * file to the byte order of this host. + */ +static void +swap_nflog_header(const struct pcap_pkthdr *hdr, u_char *buf) +{ + u_char *p = buf; + nflog_hdr_t *nfhdr = (nflog_hdr_t *)buf; + nflog_tlv_t *tlv; + u_int caplen = hdr->caplen; + u_int length = hdr->len; + u_int16_t size; + + if (caplen < (int) sizeof(nflog_hdr_t) || length < (int) sizeof(nflog_hdr_t)) { + /* Not enough data to have any TLVs. */ + return; + } + + if (!(nfhdr->nflog_version) == 0) { + /* Unknown NFLOG version */ + return; + } + + length -= sizeof(nflog_hdr_t); + caplen -= sizeof(nflog_hdr_t); + p += sizeof(nflog_hdr_t); + + while (caplen >= sizeof(nflog_tlv_t)) { + tlv = (nflog_tlv_t *) p; + + /* Swap the type and length. */ + tlv->tlv_type = SWAPSHORT(tlv->tlv_type); + tlv->tlv_length = SWAPSHORT(tlv->tlv_length); + + /* Get the length of the TLV. */ + size = tlv->tlv_length; + if (size % 4 != 0) + size += 4 - size % 4; + + /* Is the TLV's length less than the minimum? */ + if (size < sizeof(nflog_tlv_t)) { + /* Yes. Give up now. */ + return; + } + + /* Do we have enough data for the full TLV? */ + if (caplen < size || length < size) { + /* No. */ + return; + } + + /* Skip over the TLV. */ + length -= size; + caplen -= size; + p += size; + } +} + +void +swap_pseudo_headers(int linktype, struct pcap_pkthdr *hdr, u_char *data) +{ + /* + * Convert pseudo-headers from the byte order of + * the host on which the file was saved to our + * byte order, as necessary. + */ + switch (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; + + case DLT_NFLOG: + swap_nflog_header(hdr, data); + break; + } +} diff --git a/external/bsd/libpcap/dist/pcap-common.h b/external/bsd/libpcap/dist/pcap-common.h index 894ef5e0e65c..6ac5bcd264f9 100644 --- a/external/bsd/libpcap/dist/pcap-common.h +++ b/external/bsd/libpcap/dist/pcap-common.h @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-common.h,v 1.1.1.2 2013/04/06 15:57:46 christos Exp $ */ - /* * We use the "receiver-makes-right" approach to byte order, @@ -23,5 +21,5 @@ 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); +extern void swap_pseudo_headers(int linktype, struct pcap_pkthdr *hdr, + u_char *data); diff --git a/external/bsd/libpcap/dist/pcap-dag.c b/external/bsd/libpcap/dist/pcap-dag.c index 307980987277..aaa3fae3dd3c 100644 --- a/external/bsd/libpcap/dist/pcap-dag.c +++ b/external/bsd/libpcap/dist/pcap-dag.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-dag.c,v 1.1.1.4 2013/12/31 16:57:24 christos Exp $ */ - /* * pcap-dag.c: Packet capture interface for Endace DAG card. * @@ -17,11 +15,6 @@ * Stephen Donnelly */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/pcap-dag.c,v 1.39 2008-04-14 20:40:58 guy Exp (LBL)"; -#endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -581,7 +574,7 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user) /* Only count packets that pass the filter, for consistency with standard Linux behaviour. */ processed++; - if (processed == cnt && cnt > 0) + if (processed == cnt && !PACKET_COUNT_IS_UNLIMITED(cnt)) { /* Reached the user-specified limit. */ return cnt; diff --git a/external/bsd/libpcap/dist/pcap-dag.h b/external/bsd/libpcap/dist/pcap-dag.h index 18568899d29a..68520dc8214d 100644 --- a/external/bsd/libpcap/dist/pcap-dag.h +++ b/external/bsd/libpcap/dist/pcap-dag.h @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-dag.h,v 1.1.1.4 2013/12/31 16:57:22 christos Exp $ */ - /* * pcap-dag.c: Packet capture interface for Endace DAG card. * @@ -8,8 +6,6 @@ * at the same time as another type of device. * * Author: Richard Littin, Sean Irvine ({richard,sean}@reeltwo.com) - * - * @(#) Header: /tcpdump/master/libpcap/pcap-dag.h,v 1.7 2008-04-04 19:37:45 guy Exp (LBL) */ pcap_t *dag_create(const char *, char *, int *); diff --git a/external/bsd/libpcap/dist/pcap-dbus.c b/external/bsd/libpcap/dist/pcap-dbus.c index e5e9fa2d43c9..c878353b9f4b 100644 --- a/external/bsd/libpcap/dist/pcap-dbus.c +++ b/external/bsd/libpcap/dist/pcap-dbus.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-dbus.c,v 1.1.1.1 2013/12/31 16:57:18 christos Exp $ */ - /* * Copyright (c) 2012 Jakub Zawadzki * All rights reserved. diff --git a/external/bsd/libpcap/dist/pcap-dbus.h b/external/bsd/libpcap/dist/pcap-dbus.h index ad14f58c6e87..67493cce93cf 100644 --- a/external/bsd/libpcap/dist/pcap-dbus.h +++ b/external/bsd/libpcap/dist/pcap-dbus.h @@ -1,4 +1,2 @@ -/* $NetBSD: pcap-dbus.h,v 1.1.1.1 2013/12/31 16:57:20 christos Exp $ */ - pcap_t *dbus_create(const char *, char *, int *); int dbus_findalldevs(pcap_if_t **devlistp, char *errbuf); diff --git a/external/bsd/libpcap/dist/pcap-dlpi.c b/external/bsd/libpcap/dist/pcap-dlpi.c index b06e25f807ca..459860066eb6 100644 --- a/external/bsd/libpcap/dist/pcap-dlpi.c +++ b/external/bsd/libpcap/dist/pcap-dlpi.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-dlpi.c,v 1.1.1.4 2013/12/31 16:57:26 christos Exp $ */ - /* * Copyright (c) 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -70,11 +68,6 @@ * DL_HP_RAWDLS? */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/pcap-dlpi.c,v 1.128 2008-12-02 16:20:23 guy Exp (LBL)"; -#endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -343,6 +336,8 @@ pcap_activate_dlpi(pcap_t *p) #ifdef DL_HP_RAWDLS struct pcap_dlpi *pd = p->priv; #endif + int status = 0; + int retv; register char *cp; int ppa; #ifdef HAVE_SOLARIS @@ -361,7 +356,6 @@ pcap_activate_dlpi(pcap_t *p) #ifndef HAVE_DEV_DLPI char dname2[100]; #endif - int status = PCAP_ERROR; #ifdef HAVE_DEV_DLPI /* @@ -399,6 +393,8 @@ pcap_activate_dlpi(pcap_t *p) if ((p->fd = open(cp, O_RDWR)) < 0) { if (errno == EPERM || errno == EACCES) status = PCAP_ERROR_PERM_DENIED; + else + status = PCAP_ERROR; snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s", cp, pcap_strerror(errno)); goto bad; @@ -463,6 +459,8 @@ pcap_activate_dlpi(pcap_t *p) if (errno != ENOENT) { if (errno == EPERM || errno == EACCES) status = PCAP_ERROR_PERM_DENIED; + else + status = PCAP_ERROR; snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s", dname, pcap_strerror(errno)); goto bad; @@ -499,6 +497,8 @@ pcap_activate_dlpi(pcap_t *p) } else { if (errno == EPERM || errno == EACCES) status = PCAP_ERROR_PERM_DENIED; + else + status = PCAP_ERROR; snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s", dname2, pcap_strerror(errno)); } @@ -513,21 +513,28 @@ pcap_activate_dlpi(pcap_t *p) ** Attach if "style 2" provider */ if (dlinforeq(p->fd, p->errbuf) < 0 || - dlinfoack(p->fd, (char *)buf, p->errbuf) < 0) + dlinfoack(p->fd, (char *)buf, p->errbuf) < 0) { + status = PCAP_ERROR; goto bad; + } infop = &(MAKE_DL_PRIMITIVES(buf))->info_ack; #ifdef HAVE_SOLARIS if (infop->dl_mac_type == DL_IPATM) isatm = 1; #endif if (infop->dl_provider_style == DL_STYLE2) { - status = dl_doattach(p->fd, ppa, p->errbuf); - if (status < 0) + retv = dl_doattach(p->fd, ppa, p->errbuf); + if (retv < 0) { + status = retv; goto bad; + } #ifdef DL_HP_RAWDLS if (pd->send_fd >= 0) { - if (dl_doattach(pd->send_fd, ppa, p->errbuf) < 0) + retv = dl_doattach(pd->send_fd, ppa, p->errbuf); + if (retv < 0) { + status = retv; goto bad; + } } #endif } @@ -574,22 +581,28 @@ pcap_activate_dlpi(pcap_t *p) */ if ((dlbindreq(p->fd, 1537, p->errbuf) < 0 && dlbindreq(p->fd, 2, p->errbuf) < 0) || - dlbindack(p->fd, (char *)buf, p->errbuf, NULL) < 0) + dlbindack(p->fd, (char *)buf, p->errbuf, NULL) < 0) { + status = PCAP_ERROR; goto bad; + } #elif defined(DL_HP_RAWDLS) /* ** HP-UX 10.0x and 10.1x. */ - if (dl_dohpuxbind(p->fd, p->errbuf) < 0) + if (dl_dohpuxbind(p->fd, p->errbuf) < 0) { + status = PCAP_ERROR; goto bad; + } if (pd->send_fd >= 0) { /* ** XXX - if this fails, just close send_fd and ** set it to -1, so that you can't send but can ** still receive? */ - if (dl_dohpuxbind(pd->send_fd, p->errbuf) < 0) + if (dl_dohpuxbind(pd->send_fd, p->errbuf) < 0) { + status = PCAP_ERROR; goto bad; + } } #else /* neither AIX nor HP-UX */ /* @@ -597,8 +610,10 @@ pcap_activate_dlpi(pcap_t *p) ** OS using DLPI. **/ if (dlbindreq(p->fd, 0, p->errbuf) < 0 || - dlbindack(p->fd, (char *)buf, p->errbuf, NULL) < 0) + dlbindack(p->fd, (char *)buf, p->errbuf, NULL) < 0) { + status = PCAP_ERROR; goto bad; + } #endif /* AIX vs. HP-UX vs. other */ #endif /* !HP-UX 9 and !HP-UX 10.20 or later and !SINIX */ @@ -611,6 +626,7 @@ pcap_activate_dlpi(pcap_t *p) ** help, and may break things. */ if (strioctl(p->fd, A_PROMISCON_REQ, 0, NULL) < 0) { + status = PCAP_ERROR; snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "A_PROMISCON_REQ: %s", pcap_strerror(errno)); goto bad; @@ -621,10 +637,12 @@ pcap_activate_dlpi(pcap_t *p) /* ** Enable promiscuous (not necessary on send FD) */ - status = dlpromiscon(p, DL_PROMISC_PHYS); - if (status < 0) { - if (status == PCAP_ERROR_PERM_DENIED) + retv = dlpromiscon(p, DL_PROMISC_PHYS); + if (retv < 0) { + if (retv == PCAP_ERROR_PERM_DENIED) status = PCAP_ERROR_PROMISC_PERM_DENIED; + else + status = retv; goto bad; } @@ -634,8 +652,8 @@ pcap_activate_dlpi(pcap_t *p) ** HP-UX or SINIX) (Not necessary on send FD) */ #if !defined(__hpux) && !defined(sinix) - status = dlpromiscon(p, DL_PROMISC_MULTI); - if (status < 0) + retv = dlpromiscon(p, DL_PROMISC_MULTI); + if (retv < 0) status = PCAP_WARNING; #endif } @@ -655,16 +673,23 @@ pcap_activate_dlpi(pcap_t *p) /* Everything else (except for SINIX) - always do this */ { #endif - status = dlpromiscon(p, DL_PROMISC_SAP); - if (status < 0) { - /* - * Not fatal, since the DL_PROMISC_PHYS mode worked. - * Report it as a warning, however. - */ - if (p->opt.promisc) + retv = dlpromiscon(p, DL_PROMISC_SAP); + if (retv < 0) { + if (p->opt.promisc) { + /* + * Not fatal, since the DL_PROMISC_PHYS mode + * worked. + * + * Report it as a warning, however. + */ status = PCAP_WARNING; - else + } else { + /* + * Fatal. + */ + status = retv; goto bad; + } } } #endif /* sinix */ @@ -674,8 +699,10 @@ pcap_activate_dlpi(pcap_t *p) ** promiscuous options. */ #if defined(HAVE_HPUX9) || defined(HAVE_HPUX10_20_OR_LATER) - if (dl_dohpuxbind(p->fd, p->errbuf) < 0) + if (dl_dohpuxbind(p->fd, p->errbuf) < 0) { + status = PCAP_ERROR; goto bad; + } /* ** We don't set promiscuous mode on the send FD, but we'll defer ** binding it anyway, just to keep the HP-UX 9/10.20 or later @@ -687,8 +714,10 @@ pcap_activate_dlpi(pcap_t *p) ** set it to -1, so that you can't send but can ** still receive? */ - if (dl_dohpuxbind(pd->send_fd, p->errbuf) < 0) + if (dl_dohpuxbind(pd->send_fd, p->errbuf) < 0) { + status = PCAP_ERROR; goto bad; + } } #endif @@ -698,12 +727,16 @@ pcap_activate_dlpi(pcap_t *p) ** when sending packets. */ if (dlinforeq(p->fd, p->errbuf) < 0 || - dlinfoack(p->fd, (char *)buf, p->errbuf) < 0) + dlinfoack(p->fd, (char *)buf, p->errbuf) < 0) { + status = PCAP_ERROR; goto bad; + } infop = &(MAKE_DL_PRIMITIVES(buf))->info_ack; - if (pcap_process_mactype(p, infop->dl_mac_type) != 0) + if (pcap_process_mactype(p, infop->dl_mac_type) != 0) { + status = PCAP_ERROR; goto bad; + } #ifdef DLIOCRAW /* @@ -711,6 +744,7 @@ pcap_activate_dlpi(pcap_t *p) ** header. */ if (strioctl(p->fd, DLIOCRAW, 0, NULL) < 0) { + status = PCAP_ERROR; snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "DLIOCRAW: %s", pcap_strerror(errno)); goto bad; @@ -741,28 +775,31 @@ pcap_activate_dlpi(pcap_t *p) #endif /* Push and configure bufmod. */ - if (pcap_conf_bufmod(p, ss) != 0) + if (pcap_conf_bufmod(p, ss) != 0) { + status = PCAP_ERROR; goto bad; + } #endif /* ** As the last operation flush the read side. */ if (ioctl(p->fd, I_FLUSH, FLUSHR) != 0) { + status = PCAP_ERROR; snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "FLUSHR: %s", pcap_strerror(errno)); goto bad; } /* Allocate data buffer. */ - if (pcap_alloc_databuf(p) != 0) + if (pcap_alloc_databuf(p) != 0) { + status = PCAP_ERROR; goto bad; - - /* Success - but perhaps with a warning */ - if (status < 0) - status = 0; + } /* + * Success. + * * "p->fd" is an FD for a STREAMS device, so "select()" and * "poll()" should work on it. */ diff --git a/external/bsd/libpcap/dist/pcap-dos.c b/external/bsd/libpcap/dist/pcap-dos.c index d993fe2b76f0..43f50c7f13b2 100644 --- a/external/bsd/libpcap/dist/pcap-dos.c +++ b/external/bsd/libpcap/dist/pcap-dos.c @@ -1,13 +1,9 @@ -/* $NetBSD: pcap-dos.c,v 1.1.1.4 2013/12/31 16:57:23 christos Exp $ */ - /* * This file is part of DOS-libpcap * Ported to DOS/DOSX by G. Vanem * * pcap-dos.c: Interface to PKTDRVR, NDIS2 and 32-bit pmode * network drivers. - * - * @(#) Header: /tcpdump/master/libpcap/pcap-dos.c,v 1.7 2008-04-22 17:16:30 guy Exp (LBL) */ #include @@ -337,7 +333,7 @@ pcap_read_dos (pcap_t *p, int cnt, pcap_handler callback, u_char *data) struct pcap_dos *pd = p->priv; int rc, num = 0; - while (num <= cnt || (cnt < 0)) + while (num <= cnt || PACKET_COUNT_IS_UNLIMITED(cnt)) { if (p->fd <= 0) return (-1); diff --git a/external/bsd/libpcap/dist/pcap-dos.h b/external/bsd/libpcap/dist/pcap-dos.h index 53e1dfe34ce4..8f92252ba268 100644 --- a/external/bsd/libpcap/dist/pcap-dos.h +++ b/external/bsd/libpcap/dist/pcap-dos.h @@ -1,10 +1,6 @@ -/* $NetBSD: pcap-dos.h,v 1.1.1.3 2013/04/06 15:57:50 christos Exp $ */ - /* * 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) */ #ifndef __PCAP_DOS_H diff --git a/external/bsd/libpcap/dist/pcap-enet.c b/external/bsd/libpcap/dist/pcap-enet.c index 0b4cda0913f6..777d3e3a8134 100644 --- a/external/bsd/libpcap/dist/pcap-enet.c +++ b/external/bsd/libpcap/dist/pcap-enet.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-enet.c,v 1.1.1.3 2013/04/06 15:57:49 christos Exp $ */ - /* * Stanford Enetfilter subroutines for tcpdump * @@ -8,10 +6,6 @@ * * Rayan Zachariassen, CA*Net */ -#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 "; -#endif #ifdef HAVE_CONFIG_H #include "config.h" diff --git a/external/bsd/libpcap/dist/pcap-filter.manmisc.in b/external/bsd/libpcap/dist/pcap-filter.manmisc.in index 5595e6645260..f65a6a95f75f 100644 --- a/external/bsd/libpcap/dist/pcap-filter.manmisc.in +++ b/external/bsd/libpcap/dist/pcap-filter.manmisc.in @@ -1,5 +1,3 @@ -.\" @(#) 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. .\" All rights reserved. @@ -20,7 +18,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP-FILTER @MAN_MISC_INFO@ "6 January 2008" +.TH PCAP-FILTER @MAN_MISC_INFO@ "17 May 2013" .SH NAME pcap-filter \- packet filter syntax .br @@ -332,8 +330,9 @@ The packet may contain, for example, authentication header, routing header, or hop-by-hop option header, between IPv6 header and TCP header. The BPF code emitted by this primitive is complex and -cannot be optimized by the BPF optimizer code, so this can be somewhat -slow. +cannot be optimized by the BPF optimizer code, and is not supported by +filter engines in the kernel, so this can be somewhat slow, and may +cause more packets to be dropped. .IP "\fBip protochain \fIprotocol\fR" Equivalent to \fBip6 protochain \fIprotocol\fR, but this is for IPv4. .IP "\fBprotochain \fIprotocol\fR" @@ -453,6 +452,67 @@ True if the DECNET destination address is .IP "\fBdecnet host \fIhost\fR" True if either the DECNET source or destination address is .IR host . +.IP \fBllc\fP +True if the packet has an 802.2 LLC header. This includes: +.IP +Ethernet packets with a length field rather than a type field that +aren't raw NetWare-over-802.3 packets; +.IP +IEEE 802.11 data packets; +.IP +Token Ring packets (no check is done for LLC frames); +.IP +FDDI packets (no check is done for LLC frames); +.IP +LLC-encapsulated ATM packets, for SunATM on Solaris. +.IP + +.IP "\fBllc\fP \Fitype\fR" +True if the packet has an 802.2 LLC header and has the specified +.IR type . +.I type +can be one of: +.RS +.TP +\fBi\fR +Information (I) PDUs +.TP +\fBs\fR +Supervisory (S) PDUs +.TP +\fBu\fR +Unnumbered (U) PDUs +.TP +\fBrr\fR +Receiver Ready (RR) S PDUs +.TP +\fBrnr\fR +Receiver Not Ready (RNR) S PDUs +.TP +\fBrej\fR +Reject (REJ) S PDUs +.TP +\fBui\fR +Unnumbered Information (UI) U PDUs +.TP +\fBua\fR +Unnumbered Acknowledgment (UA) U PDUs +.TP +\fBdisc\fR +Disconnect (DISC) U PDUs +.TP +\fBsabme\fR +Set Asynchronous Balanced Mode Extended (SABME) U PDUs +.TP +\fBtest\fR +Test (TEST) U PDUs +.TP +\fBxid\fR +Exchange Identification (XID) U PDUs +.TP +\fBfrmr\fR +Frame Reject (FRMR) U PDUs +.RE .IP "\fBifname \fIinterface\fR" True if the packet was logged as coming from the specified interface (applies only to packets logged by OpenBSD's or FreeBSD's @@ -487,7 +547,7 @@ name of an anchored ruleset (applies only to packets logged by OpenBSD's or FreeBSD's .BR pf (4)). .IP "\fBruleset \fIname\fR" -Synonomous with the +Synonymous with the .B rset modifier. .IP "\fBsrnr \fInum\fR" @@ -496,7 +556,7 @@ of an anchored ruleset (applies only to packets logged by OpenBSD's or FreeBSD's .BR pf (4)). .IP "\fBsubrulenum \fInum\fR" -Synonomous with the +Synonymous with the .B srnr modifier. .IP "\fBaction \fIact\fR" @@ -704,9 +764,6 @@ on the assumption that the packet is either a LANE emulated Ethernet packet or a LANE LE Control packet. If \fBlane\fR isn't specified, the tests are done under the assumption that the packet is an LLC-encapsulated packet. -.IP \fBllc\fP -True if the packet is an ATM packet, for SunATM on Solaris, and is -an LLC-encapsulated packet. .IP \fBoamf4s\fP True if the packet is an ATM packet, for SunATM on Solaris, and is a segment OAM F4 flow cell (VPI=0 & VCI=3). @@ -743,11 +800,17 @@ Release, or Release Done message. True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =, !=, and \fIexpr\fR is an arithmetic expression composed of integer constants (expressed in standard C syntax), the normal binary operators -[+, -, *, /, &, |, <<, >>], a length operator, and special packet data +[+, -, *, /, %, &, |, ^, <<, >>], a length operator, and special packet data accessors. Note that all comparisons are unsigned, so that, for example, 0x80000000 and 0xffffffff are > 0. -To access -data inside the packet, use the following syntax: +.IP +The % and ^ operators are currently only supported for filtering in the +kernel on Linux with 3.7 and later kernels; on all other systems, if +those operators are used, filtering will be done in user mode, which +will increase the overhead of capturing packets and may cause more +packets to be dropped. +.IP +To access data inside the packet, use the following syntax: .in +.5i .nf \fIproto\fB [ \fIexpr\fB : \fIsize\fB ]\fR diff --git a/external/bsd/libpcap/dist/pcap-int.h b/external/bsd/libpcap/dist/pcap-int.h index 36e4a89b2c6d..5a20444617a9 100644 --- a/external/bsd/libpcap/dist/pcap-int.h +++ b/external/bsd/libpcap/dist/pcap-int.h @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-int.h,v 1.1.1.4 2013/12/31 16:57:24 christos Exp $ */ - /* * Copyright (c) 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. @@ -31,8 +29,6 @@ * 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. - * - * @(#) Header: /tcpdump/master/libpcap/pcap-int.h,v 1.94 2008-09-16 00:20:23 guy Exp (LBL) */ #ifndef pcap_int_h @@ -86,6 +82,29 @@ extern CRITICAL_SECTION g_PcapCompileCriticalSection; #endif /* _MSC_VER */ +/* + * Maximum snapshot length. + * + * Somewhat arbitrary, but chosen to be: + * + * 1) big enough for maximum-size Linux loopback packets (65549) + * and some USB packets captured with USBPcap: + * + * http://desowin.org/usbpcap/ + * + * (> 131072, < 262144) + * + * and + * + * 2) small enough not to cause attempts to allocate huge amounts of + * memory; some applications might use the snapshot length in a + * savefile header to control the size of the buffer they allocate, + * so a size of, say, 2^31-1 might not work well. + * + * We don't enforce this in pcap_set_snaplen(), but we use it internally. + */ +#define MAXIMUM_SNAPLEN 262144 + struct pcap_opt { char *source; int timeout; /* timeout for buffering */ @@ -338,6 +357,12 @@ extern int snprintf (char *, size_t, const char *, ...); extern int vsnprintf (char *, size_t, const char *, va_list ap); #endif +/* + * Does the packet count argument to a module's read routine say + * "supply packets until you run out of packets"? + */ +#define PACKET_COUNT_IS_UNLIMITED(count) ((count) <= 0) + /* * Routines that most pcap implementations can use for non-blocking mode. */ @@ -383,6 +408,9 @@ int pcap_platform_finddevs(pcap_if_t **, char *); int add_addr_to_iflist(pcap_if_t **, const char *, u_int, struct sockaddr *, size_t, struct sockaddr *, size_t, struct sockaddr *, size_t, struct sockaddr *, size_t, char *); +int add_addr_to_dev(pcap_if_t *, struct sockaddr *, size_t, + struct sockaddr *, size_t, struct sockaddr *, size_t, + struct sockaddr *dstaddr, size_t, char *errbuf); int pcap_add_if(pcap_if_t **, const char *, u_int, const char *, char *); struct sockaddr *dup_sockaddr(struct sockaddr *, size_t); int add_or_find_if(pcap_if_t **, pcap_if_t **, const char *, u_int, diff --git a/external/bsd/libpcap/dist/pcap-libdlpi.c b/external/bsd/libpcap/dist/pcap-libdlpi.c index 661ca9123335..333e532b765a 100644 --- a/external/bsd/libpcap/dist/pcap-libdlpi.c +++ b/external/bsd/libpcap/dist/pcap-libdlpi.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-libdlpi.c,v 1.1.1.4 2013/12/31 16:57:20 christos Exp $ */ - /* * Copyright (c) 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -26,11 +24,6 @@ * Packet capture routines for DLPI using libdlpi under SunOS 5.11. */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/pcap-libdlpi.c,v 1.6 2008-04-14 20:40:58 guy Exp (LBL)"; -#endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -103,10 +96,10 @@ static int pcap_activate_libdlpi(pcap_t *p) { struct pcap_dlpi *pd = p->priv; + int status = 0; int retv; dlpi_handle_t dh; dlpi_info_t dlinfo; - int err = PCAP_ERROR; /* * Enable Solaris raw and passive DLPI extensions; @@ -116,13 +109,15 @@ pcap_activate_libdlpi(pcap_t *p) retv = dlpi_open(p->opt.source, &dh, DLPI_RAW|DLPI_PASSIVE); if (retv != DLPI_SUCCESS) { if (retv == DLPI_ELINKNAMEINVAL || retv == DLPI_ENOLINK) - err = PCAP_ERROR_NO_SUCH_DEVICE; + status = PCAP_ERROR_NO_SUCH_DEVICE; else if (retv == DL_SYSERR && (errno == EPERM || errno == EACCES)) - err = PCAP_ERROR_PERM_DENIED; + status = PCAP_ERROR_PERM_DENIED; + else + status = PCAP_ERROR; pcap_libdlpi_err(p->opt.source, "dlpi_open", retv, p->errbuf); - return (err); + return (status); } pd->dlpi_hd = dh; @@ -131,20 +126,21 @@ pcap_activate_libdlpi(pcap_t *p) * This device exists, but we don't support monitor mode * any platforms that support DLPI. */ - err = PCAP_ERROR_RFMON_NOTSUP; + status = PCAP_ERROR_RFMON_NOTSUP; goto bad; } /* Bind with DLPI_ANY_SAP. */ if ((retv = dlpi_bind(pd->dlpi_hd, DLPI_ANY_SAP, 0)) != DLPI_SUCCESS) { + status = PCAP_ERROR; pcap_libdlpi_err(p->opt.source, "dlpi_bind", retv, p->errbuf); goto bad; } /* Enable promiscuous mode. */ if (p->opt.promisc) { - err = dlpromiscon(p, DL_PROMISC_PHYS); - if (err < 0) { + retv = dlpromiscon(p, DL_PROMISC_PHYS); + if (retv < 0) { /* * "You don't have permission to capture on * this device" and "you don't have permission @@ -158,57 +154,71 @@ pcap_activate_libdlpi(pcap_t *p) * XXX - you might have to capture in * promiscuous mode to see outgoing packets. */ - if (err == PCAP_ERROR_PERM_DENIED) - err = PCAP_ERROR_PROMISC_PERM_DENIED; + if (retv == PCAP_ERROR_PERM_DENIED) + status = PCAP_ERROR_PROMISC_PERM_DENIED; + else + status = retv; goto bad; } } else { /* Try to enable multicast. */ - err = dlpromiscon(p, DL_PROMISC_MULTI); - if (err < 0) + retv = dlpromiscon(p, DL_PROMISC_MULTI); + if (retv < 0) { + status = retv; goto bad; + } } /* Try to enable SAP promiscuity. */ - err = dlpromiscon(p, DL_PROMISC_SAP); - if (err < 0) { + retv = dlpromiscon(p, DL_PROMISC_SAP); + if (retv < 0) { /* * Not fatal, since the DL_PROMISC_PHYS mode worked. * Report it as a warning, however. */ if (p->opt.promisc) - err = PCAP_WARNING; - else + status = PCAP_WARNING; + else { + status = retv; goto bad; + } } /* Determine link type. */ if ((retv = dlpi_info(pd->dlpi_hd, &dlinfo, 0)) != DLPI_SUCCESS) { + status = PCAP_ERROR; pcap_libdlpi_err(p->opt.source, "dlpi_info", retv, p->errbuf); goto bad; } - if (pcap_process_mactype(p, dlinfo.di_mactype) != 0) + if (pcap_process_mactype(p, dlinfo.di_mactype) != 0) { + status = PCAP_ERROR; goto bad; + } p->fd = dlpi_fd(pd->dlpi_hd); /* Push and configure bufmod. */ - if (pcap_conf_bufmod(p, p->snapshot) != 0) + if (pcap_conf_bufmod(p, p->snapshot) != 0) { + status = PCAP_ERROR; goto bad; + } /* * Flush the read side. */ if (ioctl(p->fd, I_FLUSH, FLUSHR) != 0) { + status = PCAP_ERROR; snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "FLUSHR: %s", pcap_strerror(errno)); goto bad; } /* Allocate data buffer. */ - if (pcap_alloc_databuf(p) != 0) + if (pcap_alloc_databuf(p) != 0) { + status = PCAP_ERROR; goto bad; + } /* * "p->fd" is a FD for a STREAMS device, so "select()" and @@ -226,10 +236,10 @@ pcap_activate_libdlpi(pcap_t *p) p->stats_op = pcap_stats_dlpi; p->cleanup_op = pcap_cleanup_libdlpi; - return (0); + return (status); bad: pcap_cleanup_libdlpi(p); - return (err); + return (status); } #define STRINGIFY(n) #n diff --git a/external/bsd/libpcap/dist/pcap-linktype.manmisc.in b/external/bsd/libpcap/dist/pcap-linktype.manmisc.in index 0fb6b527dad4..e42c5b367f3b 100644 --- a/external/bsd/libpcap/dist/pcap-linktype.manmisc.in +++ b/external/bsd/libpcap/dist/pcap-linktype.manmisc.in @@ -1,5 +1,3 @@ -.\" @(#) 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. .\" All rights reserved. @@ -20,7 +18,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP-LINKTYPE @MAN_MISC_INFO@ "23 October 2008" +.TH PCAP-LINKTYPE @MAN_MISC_INFO@ "12 March 2011" .SH NAME pcap-linktype \- link-layer header types supported by libpcap .SH DESCRIPTION diff --git a/external/bsd/libpcap/dist/pcap-linux.c b/external/bsd/libpcap/dist/pcap-linux.c index d6eaa3786836..900ebbc0dd56 100644 --- a/external/bsd/libpcap/dist/pcap-linux.c +++ b/external/bsd/libpcap/dist/pcap-linux.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-linux.c,v 1.1.1.4 2013/12/31 16:57:20 christos Exp $ */ - /* * pcap-linux.c: Packet capture interface to the Linux kernel * @@ -69,11 +67,6 @@ * SUCH DAMAGE. */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.164 2008-12-14 22:00:57 guy Exp (LBL)"; -#endif - /* * Known problems with 2.0[.x] kernels: * @@ -291,7 +284,8 @@ struct pcap_linux { struct pcap_stat stat; char *device; /* device name */ - int filtering_in_kernel; /* using kernel filter */ + int filter_in_userland; /* must filter in userland */ + int blocks_to_filter_in_userland; int must_do_on_close; /* stuff we must do when we close */ int timeout; /* timeout for buffering */ int sock_packet; /* using Linux 2.0 compatible interface */ @@ -322,7 +316,7 @@ struct pcap_linux { /* * Prototypes for internal functions and methods. */ -static void map_arphrd_to_dlt(pcap_t *, int, int); +static void map_arphrd_to_dlt(pcap_t *, int, const char *, int); #ifdef HAVE_PF_PACKET_SOCKETS static short int map_packet_type_to_sll_type(short int); #endif @@ -429,6 +423,8 @@ pcap_create_interface(const char *device, char *ebuf) handle->tstamp_type_count = 3; handle->tstamp_type_list = malloc(3 * sizeof(u_int)); if (handle->tstamp_type_list == NULL) { + snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s", + pcap_strerror(errno)); free(handle); return NULL; } @@ -449,6 +445,8 @@ pcap_create_interface(const char *device, char *ebuf) handle->tstamp_precision_count = 2; handle->tstamp_precision_list = malloc(2 * sizeof(u_int)); if (handle->tstamp_precision_list == NULL) { + snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s", + pcap_strerror(errno)); if (handle->tstamp_type_list != NULL) free(handle->tstamp_type_list); free(handle); @@ -872,7 +870,7 @@ added: * Now configure the monitor interface up. */ memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, handlep->mondevice, sizeof(ifr.ifr_name)); + strlcpy(ifr.ifr_name, handlep->mondevice, sizeof(ifr.ifr_name)); if (ioctl(sock_fd, SIOCGIFFLAGS, &ifr) == -1) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "%s: Can't get flags for %s: %s", device, @@ -974,9 +972,8 @@ pcap_can_set_rfmon_linux(pcap_t *handle) /* * Attempt to get the current mode. */ - strncpy(ireq.ifr_ifrn.ifrn_name, handle->opt.source, + strlcpy(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) { /* * Well, we got the mode; assume we can set it. @@ -1098,7 +1095,7 @@ static void pcap_cleanup_linux( pcap_t *handle ) * in 2.0[.x] kernels. */ memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, handlep->device, + strlcpy(ifr.ifr_name, handlep->device, sizeof(ifr.ifr_name)); if (ioctl(handle->fd, SIOCGIFFLAGS, &ifr) == -1) { fprintf(stderr, @@ -1162,7 +1159,7 @@ static void pcap_cleanup_linux( pcap_t *handle ) */ oldflags = 0; memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, handlep->device, + strlcpy(ifr.ifr_name, handlep->device, sizeof(ifr.ifr_name)); if (ioctl(handle->fd, SIOCGIFFLAGS, &ifr) != -1) { if (ifr.ifr_flags & IFF_UP) { @@ -1176,10 +1173,8 @@ static void pcap_cleanup_linux( pcap_t *handle ) /* * Now restore the mode. */ - strncpy(ireq.ifr_ifrn.ifrn_name, handlep->device, + strlcpy(ireq.ifr_ifrn.ifrn_name, handlep->device, sizeof ireq.ifr_ifrn.ifrn_name); - ireq.ifr_ifrn.ifrn_name[sizeof ireq.ifr_ifrn.ifrn_name - 1] - = 0; ireq.u.mode = handlep->oldmode; if (ioctl(handle->fd, SIOCSIWMODE, &ireq) == -1) { /* @@ -1238,10 +1233,28 @@ pcap_activate_linux(pcap_t *handle) { struct pcap_linux *handlep = handle->priv; const char *device; + struct ifreq ifr; int status = 0; + int ret; device = handle->opt.source; + /* + * Make sure the name we were handed will fit into the ioctls we + * might perform on the device; if not, return a "No such device" + * indication, as the Linux kernel shouldn't support creating + * a device whose name won't fit into those ioctls. + * + * "Will fit" means "will fit, complete with a null terminator", + * so if the length, which does *not* include the null terminator, + * is greater than *or equal to* the size of the field into which + * we'll be copying it, that won't fit. + */ + if (strlen(device) >= sizeof(ifr.ifr_name)) { + status = PCAP_ERROR_NO_SUCH_DEVICE; + goto fail; + } + handle->inject_op = pcap_inject_linux; handle->setfilter_op = pcap_setfilter_linux; handle->setdirection_op = pcap_setdirection_linux; @@ -1294,16 +1307,17 @@ pcap_activate_linux(pcap_t *handle) * to be compatible with older kernels for a while so we are * trying both methods with the newer method preferred. */ - status = activate_new(handle); - if (status < 0) { + ret = activate_new(handle); + if (ret < 0) { /* * Fatal error with the new way; just fail. - * status has the error return; if it's PCAP_ERROR, + * ret has the error return; if it's PCAP_ERROR, * handle->errbuf has been set appropriately. */ + status = ret; goto fail; } - if (status == 1) { + if (ret == 1) { /* * Success. * Try to use memory-mapped access. @@ -1330,21 +1344,23 @@ pcap_activate_linux(pcap_t *handle) /* * We failed to set up to use it, or the kernel * supports it, but we failed to enable it. - * status has been set to the error status to + * ret has been set to the error status to * return and, if it's PCAP_ERROR, handle->errbuf * contains the error message. */ + status = ret; goto fail; } } - else if (status == 0) { + else if (ret == 0) { /* Non-fatal error; try old way */ - if ((status = activate_old(handle)) != 1) { + if ((ret = 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). */ + status = ret; goto fail; } } @@ -1352,7 +1368,6 @@ pcap_activate_linux(pcap_t *handle) /* * We set up the socket, but not with memory-mapped access. */ - status = 0; if (handle->opt.buffer_size != 0) { /* * Set the socket buffer size to the specified value. @@ -1695,8 +1710,8 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata) * * We currently handle this by making a copy of the filter * program, fixing all "ret" instructions with non-zero - * operands to have an operand of 65535 so that the filter - * doesn't truncate the packet, and supplying that modified + * operands to have an operand of MAXIMUM_SNAPLEN so that the + * filter doesn't truncate the packet, and supplying that modified * filter to the kernel. */ @@ -1705,7 +1720,7 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata) caplen = handle->snapshot; /* Run the packet filter if not using kernel filter */ - if (!handlep->filtering_in_kernel && handle->fcode.bf_insns) { + if (handlep->filter_in_userland && handle->fcode.bf_insns) { if (bpf_filter(handle->fcode.bf_insns, bp, packet_len, caplen) == 0) { @@ -1985,6 +2000,77 @@ pcap_stats_linux(pcap_t *handle, struct pcap_stat *stats) return 0; } +static int +add_linux_if(pcap_if_t **devlistp, const char *ifname, int fd, char *errbuf) +{ + const char *p; + char name[512]; /* XXX - pick a size */ + char *q, *saveq; + struct ifreq ifrflags; + + /* + * Get the interface name. + */ + p = ifname; + 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. + */ + strlcpy(ifrflags.ifr_name, name, sizeof(ifrflags.ifr_name)); + if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifrflags) < 0) { + if (errno == ENXIO || errno == ENODEV) + return (0); /* device doesn't actually exist - ignore it */ + (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, + "SIOCGIFFLAGS: %.*s: %s", + (int)sizeof(ifrflags.ifr_name), + ifrflags.ifr_name, + pcap_strerror(errno)); + return (-1); + } + + /* + * Add an entry for this interface, with no addresses. + */ + if (pcap_add_if(devlistp, name, ifrflags.ifr_flags, NULL, + errbuf) == -1) { + /* + * Failure. + */ + return (-1); + } + + 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 @@ -1998,6 +2084,8 @@ pcap_stats_linux(pcap_t *handle, struct pcap_stat *stats) * 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. + * + * Otherwise, we return 1 if we don't get an error and -1 if we do. */ static int scan_sys_class_net(pcap_if_t **devlistp, char *errbuf) @@ -2007,10 +2095,6 @@ scan_sys_class_net(pcap_if_t **devlistp, char *errbuf) struct dirent *ent; char subsystem_path[PATH_MAX+1]; struct stat statb; - 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"); @@ -2088,66 +2172,10 @@ scan_sys_class_net(pcap_if_t **devlistp, char *errbuf) } /* - * Get the interface name. + * Attempt to add the interface. */ - 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 || errno == ENODEV) - 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. - */ + if (add_linux_if(devlistp, &ent->d_name[0], fd, errbuf) == -1) { + /* Fail. */ ret = -1; break; } @@ -2185,9 +2213,6 @@ scan_proc_net_dev(pcap_if_t **devlistp, char *errbuf) 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"); @@ -2236,65 +2261,10 @@ scan_proc_net_dev(pcap_if_t **devlistp, char *errbuf) continue; /* blank line */ /* - * Get the interface name. + * Attempt to add the interface. */ - 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. - */ + if (add_linux_if(devlistp, p, fd, errbuf) == -1) { + /* Fail. */ ret = -1; break; } @@ -2349,7 +2319,8 @@ pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf) /* * Add the "any" device. */ - if (pcap_add_if(alldevsp, "any", 0, any_descr, errbuf) < 0) + if (pcap_add_if(alldevsp, "any", IFF_UP|IFF_RUNNING, + any_descr, errbuf) < 0) return (-1); return (0); @@ -2372,7 +2343,7 @@ pcap_setfilter_linux_common(pcap_t *handle, struct bpf_program *filter, if (!handle) return -1; if (!filter) { - strncpy(handle->errbuf, "setfilter: No filter specified", + strlcpy(handle->errbuf, "setfilter: No filter specified", PCAP_ERRBUF_SIZE); return -1; } @@ -2389,7 +2360,7 @@ pcap_setfilter_linux_common(pcap_t *handle, struct bpf_program *filter, * Run user level packet filter by default. Will be overriden if * installing a kernel filter succeeds. */ - handlep->filtering_in_kernel = 0; + handlep->filter_in_userland = 1; /* Install kernel level filter if possible */ @@ -2415,12 +2386,13 @@ pcap_setfilter_linux_common(pcap_t *handle, struct bpf_program *filter, * of different size. Pointed out by Sebastian * * Oh, and we also need to fix it up so that all "ret" - * instructions with non-zero operands have 65535 as the - * 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. + * instructions with non-zero operands have MAXIMUM_SNAPLEN + * as the operand if we're not capturing in memory-mapped + * mode, 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, is_mmapped)) { @@ -2477,8 +2449,11 @@ pcap_setfilter_linux_common(pcap_t *handle, struct bpf_program *filter, if (can_filter_in_kernel) { if ((err = set_kernel_filter(handle, &fcode)) == 0) { - /* Installation succeded - using kernel filter. */ - handlep->filtering_in_kernel = 1; + /* + * Installation succeded - using kernel filter, + * so userland filtering not needed. + */ + handlep->filter_in_userland = 0; } else if (err == -1) /* Non-fatal error */ { @@ -2503,7 +2478,7 @@ pcap_setfilter_linux_common(pcap_t *handle, struct bpf_program *filter, * calling "pcap_setfilter()". Otherwise, the kernel filter may * filter out packets that would pass the new userland filter. */ - if (!handlep->filtering_in_kernel) + if (handlep->filter_in_userland) reset_kernel_filter(handle); /* @@ -2604,11 +2579,31 @@ map_packet_type_to_sll_type(short int sll_pkttype) * * Sets the link type to -1 if unable to map the type. */ -static void map_arphrd_to_dlt(pcap_t *handle, int arptype, int cooked_ok) +static void map_arphrd_to_dlt(pcap_t *handle, int arptype, const char *device, + int cooked_ok) { + static const char cdma_rmnet[] = "cdma_rmnet"; + switch (arptype) { case ARPHRD_ETHER: + /* + * For various annoying reasons having to do with DHCP + * software, some versions of Android give the mobile- + * phone-network interface an ARPHRD_ value of + * ARPHRD_ETHER, even though the packet supplied by + * that interface have no link-layer header, and begin + * with an IP header, so that the ARPHRD_ value should + * be ARPHRD_NONE. + * + * Detect those devices by checking the device name, and + * use DLT_RAW for them. + */ + if (strncmp(device, cdma_rmnet, sizeof cdma_rmnet - 1) == 0) { + handle->linktype = DLT_RAW; + return; + } + /* * This is (presumably) a real Ethernet capture; give it a * link-layer-type list with DLT_EN10MB and DLT_DOCSIS, so @@ -2942,7 +2937,9 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, int cooked_ok) /* Don't expect IP packet out of this interfaces... */ handle->linktype = DLT_LINUX_IRDA; /* We need to save packet direction for IrDA decoding, - * so let's use "Linux-cooked" mode. Jean II */ + * so let's use "Linux-cooked" mode. Jean II + * + * XXX - this is handled in activate_new(). */ //handlep->cooked = 1; break; @@ -2974,6 +2971,21 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, int cooked_ok) handle->linktype = DLT_IEEE802_15_4_NOFCS; break; +#ifndef ARPHRD_NETLINK +#define ARPHRD_NETLINK 824 +#endif + case ARPHRD_NETLINK: + handle->linktype = DLT_NETLINK; + /* + * We need to use cooked mode, so that in sll_protocol we + * pick up the netlink protocol type such as NETLINK_ROUTE, + * NETLINK_GENERIC, NETLINK_FIB_LOOKUP, etc. + * + * XXX - this is handled in activate_new(). + */ + //handlep->cooked = 1; + break; + default: handle->linktype = -1; break; @@ -3105,11 +3117,12 @@ activate_new(pcap_t *handle) close(sock_fd); return arptype; } - map_arphrd_to_dlt(handle, arptype, 1); + map_arphrd_to_dlt(handle, arptype, device, 1); if (handle->linktype == -1 || handle->linktype == DLT_LINUX_SLL || handle->linktype == DLT_LINUX_IRDA || handle->linktype == DLT_LINUX_LAPD || + handle->linktype == DLT_NETLINK || (handle->linktype == DLT_EN10MB && (strncmp("isdn", device, 4) == 0 || strncmp("isdY", device, 4) == 0))) { @@ -3179,7 +3192,8 @@ activate_new(pcap_t *handle) * same applies to LAPD capture. */ if (handle->linktype != DLT_LINUX_IRDA && - handle->linktype != DLT_LINUX_LAPD) + handle->linktype != DLT_LINUX_LAPD && + handle->linktype != DLT_NETLINK) handle->linktype = DLT_LINUX_SLL; } @@ -3206,6 +3220,7 @@ activate_new(pcap_t *handle) /* * It doesn't support monitor mode. */ + close(sock_fd); return PCAP_ERROR_RFMON_NOTSUP; } @@ -3312,23 +3327,26 @@ activate_new(pcap_t *handle) break; } - /* Save the socket FD in the pcap structure */ - handle->fd = sock_fd; - #if defined(SIOCGSTAMPNS) && defined(SO_TIMESTAMPNS) if (handle->opt.tstamp_precision == PCAP_TSTAMP_PRECISION_NANO) { int nsec_tstamps = 1; - if (setsockopt(handle->fd, SOL_SOCKET, SO_TIMESTAMPNS, &nsec_tstamps, sizeof(nsec_tstamps)) < 0) { + if (setsockopt(sock_fd, SOL_SOCKET, SO_TIMESTAMPNS, &nsec_tstamps, sizeof(nsec_tstamps)) < 0) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "setsockopt: unable to set SO_TIMESTAMPNS"); + close(sock_fd); return PCAP_ERROR; } } #endif /* defined(SIOCGSTAMPNS) && defined(SO_TIMESTAMPNS) */ + /* + * We've succeeded. Save the socket FD in the pcap structure. + */ + handle->fd = sock_fd; + return 1; #else /* HAVE_PF_PACKET_SOCKETS */ - strncpy(ebuf, + strlcpy(ebuf, "New packet capturing interface not supported by build " "environment", PCAP_ERRBUF_SIZE); return 0; @@ -3513,7 +3531,19 @@ prepare_tpacket_socket(pcap_t *handle) handlep->tp_hdrlen = sizeof(struct tpacket_hdr); #ifdef HAVE_TPACKET3 - ret = init_tpacket(handle, TPACKET_V3, "TPACKET_V3"); + /* + * The only mode in which buffering is done on PF_PACKET + * sockets, so that packets might not be delivered + * immediately, is TPACKET_V3 mode. + * + * The buffering cannot be disabled in that mode, so + * if the user has requested immediate mode, we don't + * use TPACKET_V3. + */ + if (handle->opt.immediate) + ret = 1; /* pretend TPACKET_V3 couldn't be set */ + else + ret = init_tpacket(handle, TPACKET_V3, "TPACKET_V3"); if (-1 == ret) { /* Error during setting up TPACKET_V3. */ return -1; @@ -3702,7 +3732,7 @@ create_ring(pcap_t *handle, int *status) * We pick a "frame" size of 128K to leave enough * room for at least one reasonably-sized packet * in the "frame". */ - req.tp_frame_size = 131072; + req.tp_frame_size = MAXIMUM_SNAPLEN; req.tp_frame_nr = handle->opt.buffer_size/req.tp_frame_size; break; #endif @@ -3754,7 +3784,7 @@ create_ring(pcap_t *handle, int *status) hwconfig.rx_filter = HWTSTAMP_FILTER_ALL; memset(&ifr, 0, sizeof(ifr)); - strcpy(ifr.ifr_name, handle->opt.source); + strlcpy(ifr.ifr_name, handle->opt.source, sizeof(ifr.ifr_name)); ifr.ifr_data = (void *)&hwconfig; if (ioctl(handle->fd, SIOCSHWTSTAMP, &ifr) < 0) { @@ -3988,6 +4018,13 @@ pcap_setnonblock_mmap(pcap_t *p, int nonblock, char *errbuf) { struct pcap_linux *handlep = p->priv; + /* + * Set the file descriptor to non-blocking mode, as we use + * it for sending packets. + */ + if (pcap_setnonblock_fd(p, nonblock, errbuf) == -1) + return -1; + /* * Map each value to their corresponding negation to * preserve the timeout value provided with pcap_set_timeout. @@ -4056,9 +4093,31 @@ static int pcap_wait_for_frames_mmap(pcap_t *handle) pollinfo.fd = handle->fd; pollinfo.events = POLLIN; - if (handlep->timeout == 0) - timeout = -1; /* block forever */ - else if (handlep->timeout > 0) + if (handlep->timeout == 0) { +#ifdef HAVE_TPACKET3 + /* + * XXX - due to a set of (mis)features in the + * TPACKET_V3 kernel code, blocking forever with + * a TPACKET_V3 socket can, if few packets + * are arriving and passing the socket filter, + * cause most packets to be dropped. See + * libpcap issue #335 for the full painful + * story. The workaround is to have poll() + * time out very quickly, so we grab the + * frames handed to us, and return them to + * the kernel, ASAP. + * + * If those issues are ever fixed, we might + * want to check the kernel version and block + * forever with TPACKET_V3 if we're running + * with a kernel that has the fix. + */ + if (handlep->tp_version == TPACKET_V3) + timeout = 1; /* don't block for very long */ + else +#endif + timeout = -1; /* block forever */ + } else if (handlep->timeout > 0) timeout = handlep->timeout; /* block for that amount of time */ else timeout = 0; /* non-blocking mode - poll to pick up errors */ @@ -4147,7 +4206,6 @@ static int pcap_handle_packet_mmap( { struct pcap_linux *handlep = handle->priv; unsigned char *bp; - int run_bpf; struct sockaddr_ll *sll; struct pcap_pkthdr pcaphdr; @@ -4164,15 +4222,13 @@ static int pcap_handle_packet_mmap( * If the kernel filtering is enabled we need to run the * filter until all the frames present into the ring * at filter creation time are processed. - * In such case filtering_in_kernel is used as a counter for the - * packet we need to filter. + * In this case, blocks_to_filter_in_userland is used + * as a counter for the packet we need to filter. * Note: alternatively it could be possible to stop applying * the filter when the ring became empty, but it can possibly * happen a lot later... */ bp = frame + tp_mac; - run_bpf = (!handlep->filtering_in_kernel) || - ((handlep->filtering_in_kernel>1) && handlep->filtering_in_kernel--); - if (run_bpf && handle->fcode.bf_insns && + if (handlep->filter_in_userland && handle->fcode.bf_insns && (bpf_filter(handle->fcode.bf_insns, bp, tp_len, tp_snaplen) == 0)) return 0; @@ -4284,7 +4340,7 @@ pcap_read_linux_mmap_v1(pcap_t *handle, int max_packets, pcap_handler callback, /* non-positive values of max_packets are used to require all * packets currently available in the ring */ - while ((pkts < max_packets) || (max_packets <= 0)) { + while ((pkts < max_packets) || PACKET_COUNT_IS_UNLIMITED(max_packets)) { union thdr h; h.raw = pcap_get_ring_frame(handle, TP_STATUS_USER); @@ -4310,9 +4366,25 @@ pcap_read_linux_mmap_v1(pcap_t *handle, int max_packets, pcap_handler callback, return ret; } - /* next packet */ + /* + * Hand this block back to the kernel, and, if we're + * counting blocks that need to be filtered in userland + * after having been filtered by the kernel, count + * the one we've just processed. + */ h.h1->tp_status = TP_STATUS_KERNEL; + if (handlep->blocks_to_filter_in_userland > 0) { + handlep->blocks_to_filter_in_userland--; + if (handlep->blocks_to_filter_in_userland == 0) { + /* + * No more blocks need to be filtered + * in userland. + */ + handlep->filter_in_userland = 0; + } + } + /* next block */ if (++handle->offset >= handle->cc) handle->offset = 0; @@ -4342,7 +4414,7 @@ pcap_read_linux_mmap_v2(pcap_t *handle, int max_packets, pcap_handler callback, /* non-positive values of max_packets are used to require all * packets currently available in the ring */ - while ((pkts < max_packets) || (max_packets <= 0)) { + while ((pkts < max_packets) || PACKET_COUNT_IS_UNLIMITED(max_packets)) { union thdr h; h.raw = pcap_get_ring_frame(handle, TP_STATUS_USER); @@ -4372,9 +4444,25 @@ pcap_read_linux_mmap_v2(pcap_t *handle, int max_packets, pcap_handler callback, return ret; } - /* next packet */ + /* + * Hand this block back to the kernel, and, if we're + * counting blocks that need to be filtered in userland + * after having been filtered by the kernel, count + * the one we've just processed. + */ h.h2->tp_status = TP_STATUS_KERNEL; + if (handlep->blocks_to_filter_in_userland > 0) { + handlep->blocks_to_filter_in_userland--; + if (handlep->blocks_to_filter_in_userland == 0) { + /* + * No more blocks need to be filtered + * in userland. + */ + handlep->filter_in_userland = 0; + } + } + /* next block */ if (++handle->offset >= handle->cc) handle->offset = 0; @@ -4398,6 +4486,7 @@ pcap_read_linux_mmap_v3(pcap_t *handle, int max_packets, pcap_handler callback, int pkts = 0; int ret; +again: if (handlep->current_packet == NULL) { /* wait for frames availability.*/ ret = pcap_wait_for_frames_mmap(handle); @@ -4406,12 +4495,17 @@ pcap_read_linux_mmap_v3(pcap_t *handle, int max_packets, pcap_handler callback, } } h.raw = pcap_get_ring_frame(handle, TP_STATUS_USER); - if (!h.raw) + if (!h.raw) { + if (pkts == 0 && handlep->timeout == 0) { + /* Block until we see a packet. */ + goto again; + } return pkts; + } /* non-positive values of max_packets are used to require all * packets currently available in the ring */ - while ((pkts < max_packets) || (max_packets <= 0)) { + while ((pkts < max_packets) || PACKET_COUNT_IS_UNLIMITED(max_packets)) { if (handlep->current_packet == NULL) { h.raw = pcap_get_ring_frame(handle, TP_STATUS_USER); if (!h.raw) @@ -4422,7 +4516,7 @@ pcap_read_linux_mmap_v3(pcap_t *handle, int max_packets, pcap_handler callback, } int packets_to_read = handlep->packets_left; - if (max_packets >= 0 && packets_to_read > max_packets) { + if (!PACKET_COUNT_IS_UNLIMITED(max_packets) && packets_to_read > max_packets) { packets_to_read = max_packets; } @@ -4456,9 +4550,26 @@ pcap_read_linux_mmap_v3(pcap_t *handle, int max_packets, pcap_handler callback, } if (handlep->packets_left <= 0) { - /* next block */ + /* + * Hand this block back to the kernel, and, if + * we're counting blocks that need to be + * filtered in userland after having been + * filtered by the kernel, count the one we've + * just processed. + */ h.h3->hdr.bh1.block_status = TP_STATUS_KERNEL; + if (handlep->blocks_to_filter_in_userland > 0) { + handlep->blocks_to_filter_in_userland--; + if (handlep->blocks_to_filter_in_userland == 0) { + /* + * No more blocks need to be filtered + * in userland. + */ + handlep->filter_in_userland = 0; + } + } + /* next block */ if (++handle->offset >= handle->cc) handle->offset = 0; @@ -4471,6 +4582,10 @@ pcap_read_linux_mmap_v3(pcap_t *handle, int max_packets, pcap_handler callback, return PCAP_ERROR_BREAK; } } + if (pkts == 0 && handlep->timeout == 0) { + /* Block until we see a packet. */ + goto again; + } return pkts; } #endif /* HAVE_TPACKET3 */ @@ -4492,13 +4607,22 @@ pcap_setfilter_linux_mmap(pcap_t *handle, struct bpf_program *filter) if (ret < 0) return ret; - /* if the kernel filter is enabled, we need to apply the filter on - * all packets present into the ring. Get an upper bound of their number + /* + * If we're filtering in userland, there's nothing to do; + * the new filter will be used for the next packet. */ - if (!handlep->filtering_in_kernel) + if (handlep->filter_in_userland) return ret; - /* walk the ring backward and count the free slot */ + /* + * We're filtering in the kernel; the packets present in + * all blocks currently in the ring were already filtered + * by the old filter, and so will need to be filtered in + * userland by the new filter. + * + * Get an upper bound for the number of such blocks; first, + * walk the ring backward and count the free blocks. + */ offset = handle->offset; if (--handle->offset < 0) handle->offset = handle->cc - 1; @@ -4509,11 +4633,39 @@ pcap_setfilter_linux_mmap(pcap_t *handle, struct bpf_program *filter) break; } + /* + * If we found free blocks, decrement the count of free + * blocks by 1, just in case we lost a race with another + * thread of control that was adding a packet while + * we were counting and that had run the filter before + * we changed it. + * + * XXX - could there be more than one block added in + * this fashion? + * + * XXX - is there a way to avoid that race, e.g. somehow + * wait for all packets that passed the old filter to + * be added to the ring? + */ + if (n != 0) + n--; + /* be careful to not change current ring position */ handle->offset = offset; - /* store the number of packets currently present in the ring */ - handlep->filtering_in_kernel = 1 + (handle->cc - n); + /* + * Set the count of blocks worth of packets to filter + * in userland to the total number of blocks in the + * ring minus the number of free blocks we found, and + * turn on userland filtering. (The count of blocks + * worth of packets to filter in userland is guaranteed + * not to be zero - n, above, couldn't be set to a + * value > handle->cc, and if it were equal to + * handle->cc, it wouldn't be zero, and thus would + * be decremented to handle->cc - 1.) + */ + handlep->blocks_to_filter_in_userland = handle->cc - n; + handlep->filter_in_userland = 1; return ret; } @@ -4531,7 +4683,7 @@ iface_get_id(int fd, const char *device, char *ebuf) struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); + strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFINDEX, &ifr) == -1) { snprintf(ebuf, PCAP_ERRBUF_SIZE, @@ -4613,9 +4765,8 @@ has_wext(int sock_fd, const char *device, char *ebuf) { struct iwreq ireq; - strncpy(ireq.ifr_ifrn.ifrn_name, device, + strlcpy(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; if (ioctl(sock_fd, SIOCGIWNAME, &ireq) >= 0) return 1; /* yes */ snprintf(ebuf, PCAP_ERRBUF_SIZE, @@ -4751,9 +4902,8 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) * return EOPNOTSUPP. */ memset(&ireq, 0, sizeof ireq); - strncpy(ireq.ifr_ifrn.ifrn_name, device, + strlcpy(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 = (void *)args; ireq.u.data.length = 0; ireq.u.data.flags = 0; @@ -4954,9 +5104,8 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) /* * Get the old mode. */ - strncpy(ireq.ifr_ifrn.ifrn_name, device, + strlcpy(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; if (ioctl(sock_fd, SIOCGIWMODE, &ireq) == -1) { /* * We probably won't be able to set the mode, either. @@ -5011,12 +5160,11 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) * If it fails, just fall back on SIOCSIWMODE. */ memset(&ireq, 0, sizeof ireq); - strncpy(ireq.ifr_ifrn.ifrn_name, device, + strlcpy(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.length = 1; /* 1 argument */ args[0] = 3; /* request Prism header */ - memcpy(ireq.u.name, args, IFNAMSIZ); + memcpy(ireq.u.name, args, sizeof (int)); if (ioctl(sock_fd, cmd, &ireq) != -1) { /* * Success. @@ -5044,7 +5192,7 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) * might get EBUSY. */ memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); + strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); if (ioctl(sock_fd, SIOCGIFFLAGS, &ifr) == -1) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "%s: Can't get flags: %s", device, strerror(errno)); @@ -5064,9 +5212,8 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) /* * Then turn monitor mode on. */ - strncpy(ireq.ifr_ifrn.ifrn_name, device, + strlcpy(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.mode = IW_MODE_MONITOR; if (ioctl(sock_fd, SIOCSIWMODE, &ireq) == -1) { /* @@ -5104,9 +5251,8 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) * Try to select the radiotap header. */ memset(&ireq, 0, sizeof ireq); - strncpy(ireq.ifr_ifrn.ifrn_name, device, + strlcpy(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) @@ -5116,9 +5262,8 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) * That failed. Try to select the AVS header. */ memset(&ireq, 0, sizeof ireq); - strncpy(ireq.ifr_ifrn.ifrn_name, device, + strlcpy(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] = 2; /* request AVS header */ memcpy(ireq.u.name, args, sizeof (int)); if (ioctl(sock_fd, cmd, &ireq) != -1) @@ -5128,9 +5273,8 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) * That failed. Try to select the Prism header. */ memset(&ireq, 0, sizeof ireq); - strncpy(ireq.ifr_ifrn.ifrn_name, device, + strlcpy(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); @@ -5147,9 +5291,8 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) * Select the Prism header. */ memset(&ireq, 0, sizeof ireq); - strncpy(ireq.ifr_ifrn.ifrn_name, device, + strlcpy(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 Prism header */ memcpy(ireq.u.name, args, sizeof (int)); ioctl(sock_fd, cmd, &ireq); @@ -5160,9 +5303,8 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) * Get the current channel. */ memset(&ireq, 0, sizeof ireq); - strncpy(ireq.ifr_ifrn.ifrn_name, device, + strlcpy(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; if (ioctl(sock_fd, SIOCGIWFREQ, &ireq) == -1) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "%s: SIOCGIWFREQ: %s", device, @@ -5176,9 +5318,8 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) * current value. */ memset(&ireq, 0, sizeof ireq); - strncpy(ireq.ifr_ifrn.ifrn_name, device, + strlcpy(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 */ args[1] = channel; /* set channel */ memcpy(ireq.u.name, args, 2*sizeof (int)); @@ -5191,9 +5332,8 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) * Prism header. */ memset(&ireq, 0, sizeof ireq); - strncpy(ireq.ifr_ifrn.ifrn_name, device, + strlcpy(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] = 0; /* disallow transmitting */ memcpy(ireq.u.name, args, sizeof (int)); ioctl(sock_fd, cmd, &ireq); @@ -5204,9 +5344,8 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) * Force the Prism header. */ memset(&ireq, 0, sizeof ireq); - strncpy(ireq.ifr_ifrn.ifrn_name, device, + strlcpy(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); @@ -5217,9 +5356,8 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) * Force the Prism header. */ memset(&ireq, 0, sizeof ireq); - strncpy(ireq.ifr_ifrn.ifrn_name, device, + strlcpy(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.length = 1; /* 1 argument */ ireq.u.data.pointer = "1"; ireq.u.data.flags = 0; @@ -5231,9 +5369,8 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device) * Force the Prism header. */ memset(&ireq, 0, sizeof ireq); - strncpy(ireq.ifr_ifrn.ifrn_name, device, + strlcpy(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); @@ -5331,7 +5468,7 @@ iface_ethtool_ioctl(pcap_t *handle, int cmd, const char *cmdname) struct ethtool_value eval; memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, handle->opt.source, sizeof(ifr.ifr_name)); + strlcpy(ifr.ifr_name, handle->opt.source, sizeof(ifr.ifr_name)); eval.cmd = cmd; eval.data = 0; ifr.ifr_data = (caddr_t)&eval; @@ -5469,7 +5606,7 @@ activate_old(pcap_t *handle) /* Bind to the given device */ if (strcmp(device, "any") == 0) { - strncpy(handle->errbuf, "pcap_activate: The \"any\" device isn't supported on 2.0[.x]-kernel systems", + strlcpy(handle->errbuf, "pcap_activate: The \"any\" device isn't supported on 2.0[.x]-kernel systems", PCAP_ERRBUF_SIZE); return PCAP_ERROR; } @@ -5487,7 +5624,7 @@ activate_old(pcap_t *handle) * Try to find the DLT_ type corresponding to that * link-layer type. */ - map_arphrd_to_dlt(handle, arptype, 0); + map_arphrd_to_dlt(handle, arptype, device, 0); if (handle->linktype == -1) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "unknown arptype %d", arptype); @@ -5498,7 +5635,7 @@ activate_old(pcap_t *handle) if (handle->opt.promisc) { memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); + strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); if (ioctl(handle->fd, SIOCGIFFLAGS, &ifr) == -1) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "SIOCGIFFLAGS: %s", pcap_strerror(errno)); @@ -5636,7 +5773,7 @@ iface_bind_old(int fd, const char *device, char *ebuf) socklen_t errlen = sizeof(err); memset(&saddr, 0, sizeof(saddr)); - strncpy(saddr.sa_data, device, sizeof(saddr.sa_data)); + strlcpy(saddr.sa_data, device, sizeof(saddr.sa_data)); if (bind(fd, &saddr, sizeof(saddr)) == -1) { snprintf(ebuf, PCAP_ERRBUF_SIZE, "bind: %s", pcap_strerror(errno)); @@ -5675,7 +5812,7 @@ iface_get_mtu(int fd, const char *device, char *ebuf) return BIGGER_THAN_ALL_MTUS; memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); + strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFMTU, &ifr) == -1) { snprintf(ebuf, PCAP_ERRBUF_SIZE, @@ -5695,7 +5832,7 @@ iface_get_arptype(int fd, const char *device, char *ebuf) struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); + strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFHWADDR, &ifr) == -1) { snprintf(ebuf, PCAP_ERRBUF_SIZE, @@ -5762,18 +5899,19 @@ fix_program(pcap_t *handle, struct sock_fprog *fcode, int 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()", + * MAXIMUM_SNAPLEN, 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. + * non-zero values to be + * MAXIMUM_SNAPLEN. */ if (p->k != 0) - p->k = 65535; + p->k = MAXIMUM_SNAPLEN; } } break; diff --git a/external/bsd/libpcap/dist/pcap-netfilter-linux.c b/external/bsd/libpcap/dist/pcap-netfilter-linux.c index 76f250db2076..2a5812b273af 100644 --- a/external/bsd/libpcap/dist/pcap-netfilter-linux.c +++ b/external/bsd/libpcap/dist/pcap-netfilter-linux.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-netfilter-linux.c,v 1.1.1.2 2013/12/31 16:57:19 christos Exp $ */ - /* * Copyright (c) 2011 Jakub Zawadzki * All rights reserved. @@ -119,12 +117,11 @@ netfilter_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_c } if (NFNL_SUBSYS_ID(nlh->nlmsg_type) == NFNL_SUBSYS_ULOG && - NFNL_MSG_TYPE(nlh->nlmsg_type) == NFULNL_MSG_PACKET) - type = NFLOG; - - if (NFNL_SUBSYS_ID(nlh->nlmsg_type) == NFNL_SUBSYS_QUEUE && - NFNL_MSG_TYPE(nlh->nlmsg_type) == NFQNL_MSG_PACKET) - type = NFQUEUE; + NFNL_MSG_TYPE(nlh->nlmsg_type) == NFULNL_MSG_PACKET) + type = NFLOG; + else if (NFNL_SUBSYS_ID(nlh->nlmsg_type) == NFNL_SUBSYS_QUEUE && + NFNL_MSG_TYPE(nlh->nlmsg_type) == NFQNL_MSG_PACKET) + type = NFQUEUE; if (type != OTHER) { const unsigned char *payload = NULL; diff --git a/external/bsd/libpcap/dist/pcap-netfilter-linux.h b/external/bsd/libpcap/dist/pcap-netfilter-linux.h index 1834bbcd82cd..882a40219172 100644 --- a/external/bsd/libpcap/dist/pcap-netfilter-linux.h +++ b/external/bsd/libpcap/dist/pcap-netfilter-linux.h @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-netfilter-linux.h,v 1.1.1.2 2013/12/31 16:57:28 christos Exp $ */ - /* * Copyright (c) 2011 Jakub Zawadzki * All rights reserved. diff --git a/external/bsd/libpcap/dist/pcap-nit.c b/external/bsd/libpcap/dist/pcap-nit.c index 08482d353e2e..ea81eb579f58 100644 --- a/external/bsd/libpcap/dist/pcap-nit.c +++ b/external/bsd/libpcap/dist/pcap-nit.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-nit.c,v 1.1.1.4 2013/12/31 16:57:19 christos Exp $ */ - /* * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. @@ -20,10 +18,6 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.62 2008-04-14 20:40:58 guy Exp (LBL)"; -#endif #ifdef HAVE_CONFIG_H #include "config.h" @@ -191,7 +185,7 @@ pcap_read_nit(pcap_t *p, int cnt, pcap_handler callback, u_char *user) h.len = nh->nh_wirelen; h.caplen = caplen; (*callback)(user, &h, cp); - if (++n >= cnt && cnt > 0) { + if (++n >= cnt && !PACKET_COUNT_IS_UNLIMITED(cnt)) { p->cc = ep - bp; p->bp = bp; return (n); diff --git a/external/bsd/libpcap/dist/pcap-null.c b/external/bsd/libpcap/dist/pcap-null.c index c027f41e411f..934fb2cc061c 100644 --- a/external/bsd/libpcap/dist/pcap-null.c +++ b/external/bsd/libpcap/dist/pcap-null.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-null.c,v 1.1.1.4 2013/12/31 16:57:24 christos Exp $ */ - /* * Copyright (c) 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. @@ -20,10 +18,6 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/pcap-null.c,v 1.22 2008-04-04 19:37:45 guy Exp (LBL)"; -#endif #ifdef HAVE_CONFIG_H #include "config.h" diff --git a/external/bsd/libpcap/dist/pcap-pf.c b/external/bsd/libpcap/dist/pcap-pf.c index 5fbd3b6590f8..96a4a50979b4 100644 --- a/external/bsd/libpcap/dist/pcap-pf.c +++ b/external/bsd/libpcap/dist/pcap-pf.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-pf.c,v 1.1.1.4 2013/12/31 16:57:24 christos Exp $ */ - /* * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. @@ -24,11 +22,6 @@ * Extraction/creation by Jeffrey Mogul, DECWRL */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.97 2008-04-14 20:40:58 guy Exp (LBL)"; -#endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -221,7 +214,7 @@ pcap_read_pf(pcap_t *pc, int cnt, pcap_handler callback, u_char *user) buflen -= pad; h.caplen = buflen; (*callback)(user, &h, p); - if (++n >= cnt && cnt > 0) { + if (++n >= cnt && !PACKET_COUNT_IS_UNLIMITED(cnt)) { pc->cc = cc; pc->bp = bp; return (n); diff --git a/external/bsd/libpcap/dist/pcap-savefile.manfile.in b/external/bsd/libpcap/dist/pcap-savefile.manfile.in index 60bf7bcf198d..2b93c143781d 100644 --- a/external/bsd/libpcap/dist/pcap-savefile.manfile.in +++ b/external/bsd/libpcap/dist/pcap-savefile.manfile.in @@ -1,6 +1,3 @@ -'\" t -.\" @(#) 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. .\" @@ -20,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP-SAVEFILE @MAN_FILE_FORMATS@ "21 October 2008" +.TH PCAP-SAVEFILE @MAN_FILE_FORMATS@ "29 July 2013" .SH NAME pcap-savefile \- libpcap savefile format .SH DESCRIPTION diff --git a/external/bsd/libpcap/dist/pcap-septel.c b/external/bsd/libpcap/dist/pcap-septel.c index 74ee24c15caf..2f0ff33beb7e 100644 --- a/external/bsd/libpcap/dist/pcap-septel.c +++ b/external/bsd/libpcap/dist/pcap-septel.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-septel.c,v 1.1.1.4 2013/12/31 16:57:25 christos Exp $ */ - /* * pcap-septel.c: Packet capture interface for Intel/Septel card. * @@ -16,11 +14,6 @@ * (+961 3 485243) */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/pcap-septel.c,v 1.4 2008-04-14 20:40:58 guy Exp "; -#endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -261,13 +254,8 @@ static int septel_stats(pcap_t *p, struct pcap_stat *ps) { int septel_findalldevs(pcap_if_t **devlistp, char *errbuf) { -unsigned char *p; - const char description[512]= "Intel/Septel device"; - char name[512]="septel" ; - int ret = 0; - pcap_add_if(devlistp,name,0,description,errbuf); - - return (ret); + return (pcap_add_if(devlistp,"septel",0, + "Intel/Septel device",errbuf)); } diff --git a/external/bsd/libpcap/dist/pcap-septel.h b/external/bsd/libpcap/dist/pcap-septel.h index fe80117c7952..b6e1168b0ef8 100644 --- a/external/bsd/libpcap/dist/pcap-septel.h +++ b/external/bsd/libpcap/dist/pcap-septel.h @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-septel.h,v 1.1.1.4 2013/12/31 16:57:20 christos Exp $ */ - /* * pcap-septel.c: Packet capture interface for Intel Septel card * @@ -9,8 +7,6 @@ * * Authors: Gilbert HOYEK (gil_hoyek@hotmail.com), Elias M. KHOURY * (+961 3 485343); - * - * @(#) 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, int *is_ours); diff --git a/external/bsd/libpcap/dist/pcap-sita.c b/external/bsd/libpcap/dist/pcap-sita.c index 0ea1c864e692..d507e1eecd8a 100644 --- a/external/bsd/libpcap/dist/pcap-sita.c +++ b/external/bsd/libpcap/dist/pcap-sita.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-sita.c,v 1.1.1.3 2013/12/31 16:57:26 christos Exp $ */ - /* * pcap-sita.c: Packet capture interface additions for SITA ACN devices * @@ -26,8 +24,6 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ - /* $Id: pcap-sita.c */ - #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/external/bsd/libpcap/dist/pcap-sita.h b/external/bsd/libpcap/dist/pcap-sita.h index 8d00c8b5147c..9c35c6ac1d27 100644 --- a/external/bsd/libpcap/dist/pcap-sita.h +++ b/external/bsd/libpcap/dist/pcap-sita.h @@ -1,11 +1,7 @@ -/* $NetBSD: pcap-sita.h,v 1.1.1.2 2013/04/06 15:57:49 christos Exp $ */ - /* * pcap-sita.h: Packet capture interface for SITA WAN devices * * Authors: Fulko Hew (fulko.hew@sita.aero) (+1 905 6815570); - * - * @(#) $Header: /tcpdump/master/libpcap/pcap-sita.h */ extern int acn_parse_hosts_file(char *errbuf); diff --git a/external/bsd/libpcap/dist/pcap-snf.c b/external/bsd/libpcap/dist/pcap-snf.c index b1b524676b1e..ee6ffa4dcc6e 100644 --- a/external/bsd/libpcap/dist/pcap-snf.c +++ b/external/bsd/libpcap/dist/pcap-snf.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-snf.c,v 1.1.1.3 2013/12/31 16:57:23 christos Exp $ */ - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -120,7 +118,7 @@ snf_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user) return -1; n = 0; - while (n < cnt || cnt < 0) { + while (n < cnt || PACKET_COUNT_IS_UNLIMITED(cnt)) { /* * Has "pcap_breakloop()" been called? */ diff --git a/external/bsd/libpcap/dist/pcap-snf.h b/external/bsd/libpcap/dist/pcap-snf.h index 4e9fb0a66e4f..c9d7722bf4fc 100644 --- a/external/bsd/libpcap/dist/pcap-snf.h +++ b/external/bsd/libpcap/dist/pcap-snf.h @@ -1,4 +1,2 @@ -/* $NetBSD: pcap-snf.h,v 1.1.1.3 2013/12/31 16:57:20 christos Exp $ */ - pcap_t *snf_create(const char *, char *, int *); int snf_findalldevs(pcap_if_t **devlistp, char *errbuf); diff --git a/external/bsd/libpcap/dist/pcap-snit.c b/external/bsd/libpcap/dist/pcap-snit.c index a8548061503b..e6232c2e8420 100644 --- a/external/bsd/libpcap/dist/pcap-snit.c +++ b/external/bsd/libpcap/dist/pcap-snit.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-snit.c,v 1.1.1.4 2013/12/31 16:57:24 christos Exp $ */ - /* * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. @@ -25,11 +23,6 @@ * This module now handles the STREAMS based NIT. */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/pcap-snit.c,v 1.77 2008-04-14 20:40:58 guy Exp (LBL)"; -#endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -203,7 +196,7 @@ pcap_read_snit(pcap_t *p, int cnt, pcap_handler callback, u_char *user) h.len = nlp->nh_pktlen; h.caplen = caplen; (*callback)(user, &h, cp); - if (++n >= cnt && cnt > 0) { + if (++n >= cnt && !PACKET_COUNT_IS_UNLIMITED(cnt)) { p->cc = ep - bp; p->bp = bp; return (n); diff --git a/external/bsd/libpcap/dist/pcap-snoop.c b/external/bsd/libpcap/dist/pcap-snoop.c index f1822454eecc..7993e70edeba 100644 --- a/external/bsd/libpcap/dist/pcap-snoop.c +++ b/external/bsd/libpcap/dist/pcap-snoop.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-snoop.c,v 1.1.1.4 2013/12/31 16:57:20 christos Exp $ */ - /* * Copyright (c) 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -20,10 +18,6 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.59 2008-12-02 16:25:14 guy Exp (LBL)"; -#endif #ifdef HAVE_CONFIG_H #include "config.h" diff --git a/external/bsd/libpcap/dist/pcap-stdinc.h b/external/bsd/libpcap/dist/pcap-stdinc.h index c1e96461ea15..f70dcce86bed 100644 --- a/external/bsd/libpcap/dist/pcap-stdinc.h +++ b/external/bsd/libpcap/dist/pcap-stdinc.h @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-stdinc.h,v 1.1.1.3 2013/04/06 15:57:46 christos Exp $ */ - /* * Copyright (c) 2002 - 2005 NetGroup, Politecnico di Torino (Italy) * Copyright (c) 2005 - 2009 CACE Technologies, Inc. Davis (California) @@ -29,63 +27,57 @@ * 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. - * - * @(#) 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 /* - * Avoids a compiler warning in case this was already defined + * Avoids a compiler warning in case this was already defined * (someone defined _WINSOCKAPI_ when including 'windows.h', in order * to prevent it from including 'winsock.h') */ #ifdef _WINSOCKAPI_ #undef _WINSOCKAPI_ #endif + #include - #include - -#include "bittypes.h" #include #include -#ifndef __MINGW32__ +#include "bittypes.h" #include "IP6_misc.h" -#endif #define caddr_t char* -#if _MSC_VER < 1500 -#define snprintf _snprintf -#define vsnprintf _vsnprintf -#define strdup _strdup +#if defined(_MSC_VER) + #define snprintf _snprintf + #define vsnprintf _vsnprintf + #define strdup _strdup #endif -#define inline __inline +#define inline __inline #ifdef __MINGW32__ -#include -#else /*__MINGW32__*/ -/* MSVC compiler */ -#ifndef _UINTPTR_T_DEFINED -#ifdef _WIN64 -typedef unsigned __int64 uintptr_t; + #include #else -typedef _W64 unsigned int uintptr_t; -#endif -#define _UINTPTR_T_DEFINED -#endif - -#ifndef _INTPTR_T_DEFINED -#ifdef _WIN64 -typedef __int64 intptr_t; -#else -typedef _W64 int intptr_t; -#endif -#define _INTPTR_T_DEFINED -#endif + #ifndef _UINTPTR_T_DEFINED + #ifdef _WIN64 + typedef unsigned __int64 uintptr_t; + #else + typedef _W64 unsigned int uintptr_t; + #endif + #define _UINTPTR_T_DEFINED + #endif + #ifndef _INTPTR_T_DEFINED + #ifdef _WIN64 + typedef __int64 intptr_t; + #else + typedef _W64 int intptr_t; + #endif + #define _INTPTR_T_DEFINED + #endif #endif /*__MINGW32__*/ + #endif /* pcap_stdinc_h */ diff --git a/external/bsd/libpcap/dist/pcap-tstamp.manmisc.in b/external/bsd/libpcap/dist/pcap-tstamp.manmisc.in index 2cd32c621362..f86f83324a57 100644 --- a/external/bsd/libpcap/dist/pcap-tstamp.manmisc.in +++ b/external/bsd/libpcap/dist/pcap-tstamp.manmisc.in @@ -19,7 +19,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP-TSTAMP @MAN_MISC_INFO@ "22 August 2010" +.TH PCAP-TSTAMP @MAN_MISC_INFO@ "21 December 2013" .SH NAME pcap-tstamp \- packet time stamps in libpcap .SH DESCRIPTION @@ -95,7 +95,7 @@ The time stamp types are listed here; the first value is the #define to use in code, the second value is the value returned by .B pcap_tstamp_type_val_to_name() and accepted by -.BR pcap_tstamp_name_to_val() . +.BR pcap_tstamp_type_name_to_val() . .RS 5 .TP 5 .BR PCAP_TSTAMP_HOST " - " host @@ -129,4 +129,4 @@ the host operating system's clock. pcap_set_tstamp_type(3PCAP), pcap_list_tstamp_types(3PCAP), pcap_tstamp_type_val_to_name(3PCAP), -pcap_tstamp_name_to_val(3PCAP) +pcap_tstamp_type_name_to_val(3PCAP) diff --git a/external/bsd/libpcap/dist/pcap-usb-linux.c b/external/bsd/libpcap/dist/pcap-usb-linux.c index fe2a470f258e..bdabf005ccae 100644 --- a/external/bsd/libpcap/dist/pcap-usb-linux.c +++ b/external/bsd/libpcap/dist/pcap-usb-linux.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-usb-linux.c,v 1.1.1.4 2013/12/31 16:57:24 christos Exp $ */ - /* * Copyright (c) 2006 Paolo Abeni (Italy) * All rights reserved. @@ -34,10 +32,6 @@ * Modifications: Kris Katterjohn * */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) 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 #include "config.h" @@ -227,6 +221,8 @@ int usb_mmap(pcap_t* handle) return handlep->mmapbuf != MAP_FAILED; } +#ifdef HAVE_LINUX_USBDEVICE_FS_H + #define CTRL_TIMEOUT (5*1000) /* milliseconds */ #define USB_DIR_IN 0x80 @@ -295,6 +291,7 @@ probe_devices(int bus) } closedir(dir); } +#endif /* HAVE_LINUX_USBDEVICE_FS_H */ pcap_t * usb_create(const char *device, char *ebuf, int *is_ours) @@ -384,7 +381,9 @@ usb_activate(pcap_t* handle) handle->stats_op = usb_stats_linux_bin; handle->read_op = usb_read_linux_mmap; handle->cleanup_op = usb_cleanup_linux_mmap; +#ifdef HAVE_LINUX_USBDEVICE_FS_H probe_devices(handlep->bus_index); +#endif /* * "handle->fd" is a real file, so "select()" and @@ -397,7 +396,9 @@ 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; +#ifdef HAVE_LINUX_USBDEVICE_FS_H probe_devices(handlep->bus_index); +#endif } else { /*Binary interface not available, try open text interface */ @@ -910,8 +911,8 @@ usb_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_ch } } - /* with max_packets <= 0 we stop afer the first chunk*/ - if ((max_packets <= 0) || (packets == max_packets)) + /* with max_packets specifying "unlimited" we stop afer the first chunk*/ + if (PACKET_COUNT_IS_UNLIMITED(max_packets) || (packets == max_packets)) break; } diff --git a/external/bsd/libpcap/dist/pcap-usb-linux.h b/external/bsd/libpcap/dist/pcap-usb-linux.h index d1f95745276c..06dee01339a5 100644 --- a/external/bsd/libpcap/dist/pcap-usb-linux.h +++ b/external/bsd/libpcap/dist/pcap-usb-linux.h @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-usb-linux.h,v 1.1.1.4 2013/12/31 16:57:25 christos Exp $ */ - /* * Copyright (c) 2006 Paolo Abeni (Italy) * All rights reserved. @@ -31,8 +29,6 @@ * * USB sniffing API implementation for Linux platform * By Paolo Abeni - * - * @(#) Header: /tcpdump/master/libpcap/pcap-usb-linux.h,v 1.5 2008-04-04 19:37:45 guy Exp (LBL) */ /* diff --git a/external/bsd/libpcap/dist/pcap-win32.c b/external/bsd/libpcap/dist/pcap-win32.c index 6470cec3496a..f63b5c472b93 100644 --- a/external/bsd/libpcap/dist/pcap-win32.c +++ b/external/bsd/libpcap/dist/pcap-win32.c @@ -1,5 +1,3 @@ -/* $NetBSD: pcap-win32.c,v 1.1.1.4 2013/12/31 16:57:21 christos Exp $ */ - /* * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) * Copyright (c) 2005 - 2008 CACE Technologies, Davis (California) @@ -33,11 +31,6 @@ * */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.42 2008-05-21 22:15:25 gianluca Exp (LBL)"; -#endif - #include #include #ifdef __MINGW32__ @@ -79,6 +72,8 @@ static int pcap_setnonblock_win32(pcap_t *, int, char *); struct pcap_win { int nonblock; + int filtering_in_kernel; /* using kernel filter */ + #ifdef HAVE_DAG_API int dag_fcs_bits; /* Number of checksum bits from link layer */ #endif @@ -118,16 +113,27 @@ wsockinit() { WORD wVersionRequested; WSADATA wsaData; - int err; + static int err = -1; + static int done = 0; + + if (done) + return err; + wVersionRequested = MAKEWORD( 1, 1); err = WSAStartup( wVersionRequested, &wsaData ); + atexit ((void(*)(void))WSACleanup); + InitializeCriticalSection(&g_PcapCompileCriticalSection); + done = 1; + if ( err != 0 ) - { - return -1; - } - return 0; + err = -1; + return err; } +int pcap_wsockinit() +{ + return wsockinit(); +} static int pcap_stats_win32(pcap_t *p, struct pcap_stat *ps) @@ -191,6 +197,8 @@ pcap_read_win32_npf(pcap_t *p, int cnt, pcap_handler callback, u_char *user) int cc; int n = 0; register u_char *bp, *ep; + u_char *datap; + struct pcap_win *pw = p->priv; cc = p->cc; if (p->cc == 0) { @@ -200,17 +208,17 @@ pcap_read_win32_npf(pcap_t *p, int cnt, pcap_handler callback, u_char *user) if (p->break_loop) { /* * Yes - clear the flag that indicates that it - * has, and return -2 to indicate that we were - * told to break out of the loop. + * has, and return PCAP_ERROR_BREAK to indicate + * that we were told to break out of the loop. */ p->break_loop = 0; - return (-2); + return (PCAP_ERROR_BREAK); } /* capture the packets */ if(PacketReceivePacket(p->adapter,p->Packet,TRUE)==FALSE){ snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "read error: PacketReceivePacket failed"); - return (-1); + return (PCAP_ERROR); } cc = p->Packet->ulBytesReceived; @@ -231,16 +239,17 @@ pcap_read_win32_npf(pcap_t *p, int cnt, pcap_handler callback, u_char *user) /* * Has "pcap_breakloop()" been called? * If so, return immediately - if we haven't read any - * packets, clear the flag and return -2 to indicate - * that we were told to break out of the loop, otherwise - * leave the flag set, so that the *next* call will break - * out of the loop without having read any packets, and - * return the number of packets we've processed so far. + * packets, clear the flag and return PCAP_ERROR_BREAK + * to indicate that we were told to break out of the loop, + * otherwise leave the flag set, so that the *next* call + * will break out of the loop without having read any + * packets, and return the number of packets we've + * processed so far. */ if (p->break_loop) { if (n == 0) { p->break_loop = 0; - return (-2); + return (PCAP_ERROR_BREAK); } else { p->bp = bp; p->cc = ep - bp; @@ -252,16 +261,35 @@ pcap_read_win32_npf(pcap_t *p, int cnt, pcap_handler callback, u_char *user) caplen = bhp->bh_caplen; hdrlen = bhp->bh_hdrlen; + datap = bp + hdrlen; /* - * XXX A bpf_hdr matches a pcap_pkthdr. + * Short-circuit evaluation: if using BPF filter + * in kernel, no need to do it now - we already know + * the packet passed the filter. + * + * XXX - bpf_filter() should always return TRUE if + * handed a null pointer for the program, but it might + * just try to "run" the filter, so we check here. */ - (*callback)(user, (struct pcap_pkthdr*)bp, bp + hdrlen); - bp += Packet_WORDALIGN(caplen + hdrlen); - if (++n >= cnt && cnt > 0) { - p->bp = bp; - p->cc = ep - bp; - return (n); + if (pw->filtering_in_kernel || + p->fcode.bf_insns == NULL || + bpf_filter(p->fcode.bf_insns, datap, bhp->bh_datalen, caplen)) { + /* + * XXX A bpf_hdr matches a pcap_pkthdr. + */ + (*callback)(user, (struct pcap_pkthdr*)bp, datap); + bp += Packet_WORDALIGN(caplen + hdrlen); + if (++n >= cnt && !PACKET_COUNT_IS_UNLIMITED(cnt)) { + p->bp = bp; + p->cc = ep - bp; + return (n); + } + } else { + /* + * Skip this packet. + */ + bp += Packet_WORDALIGN(caplen + hdrlen); } } #undef bhp @@ -418,7 +446,7 @@ pcap_read_win32_dag(pcap_t *p, int cnt, pcap_handler callback, u_char *user) header = (dag_record_t*)((char*)header + erf_record_len); /* Stop if the number of packets requested by user has been reached*/ - if (++n >= cnt && cnt > 0) + if (++n >= cnt && !PACKET_COUNT_IS_UNLIMITED(cnt)) { p->bp = (char*)header; p->cc = endofbuf - (char*)header; @@ -644,7 +672,7 @@ pcap_activate_win32(pcap_t *p) PacketInitPacket(p->Packet,(BYTE*)p->buffer,p->bufsize); - if (p-opt.immediate) + if (p->opt.immediate) { /* tell the driver to copy the buffer as soon as data arrives */ if(PacketSetMinToCopy(p->adapter,0)==FALSE) @@ -796,16 +824,51 @@ pcap_create_interface(const char *device, char *ebuf) static int pcap_setfilter_win32_npf(pcap_t *p, struct bpf_program *fp) { + struct pcap_win *pw = p->priv; + if(PacketSetBpf(p->adapter,fp)==FALSE){ /* * Kernel filter not installed. - * XXX - fall back on userland filtering, as is done - * on other platforms? + * + * XXX - we don't know whether this failed because: + * + * the kernel rejected the filter program as invalid, + * in which case we should fall back on userland + * filtering; + * + * the kernel rejected the filter program as too big, + * in which case we should again fall back on + * userland filtering; + * + * there was some other problem, in which case we + * should probably report an error. + * + * For NPF devices, the Win32 status will be + * STATUS_INVALID_DEVICE_REQUEST for invalid + * filters, but I don't know what it'd be for + * other problems, and for some other devices + * it might not be set at all. + * + * So we just fall back on userland filtering in + * all cases. */ - snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Driver error: cannot set bpf filter: %s", pcap_win32strerror()); - return (-1); + + /* + * install_bpf_program() validates the program. + * + * XXX - what if we already have a filter in the kernel? + */ + if (install_bpf_program(p, fp) < 0) + return (-1); + pw->filtering_in_kernel = 0; /* filtering in userland */ + return (0); } + /* + * It worked. + */ + pw->filtering_in_kernel = 1; /* filtering in the kernel */ + /* * Discard any previously-received packets, as they might have * passed whatever filter was formerly in effect, but might diff --git a/external/bsd/libpcap/dist/pcap/bluetooth.h b/external/bsd/libpcap/dist/pcap/bluetooth.h index ebcd4f41e290..7cb0a8e8c05a 100644 --- a/external/bsd/libpcap/dist/pcap/bluetooth.h +++ b/external/bsd/libpcap/dist/pcap/bluetooth.h @@ -1,5 +1,3 @@ -/* $NetBSD: bluetooth.h,v 1.1.1.3 2013/04/06 15:57:50 christos Exp $ */ - /* * Copyright (c) 2006 Paolo Abeni (Italy) * All rights reserved. @@ -31,20 +29,27 @@ * * bluetooth data struct * By Paolo Abeni - * - * @(#) Header: /tcpdump/master/libpcap/pcap/bluetooth.h,v 1.1 2007-09-22 02:10:17 guy Exp */ #ifndef _PCAP_BLUETOOTH_STRUCTS_H__ #define _PCAP_BLUETOOTH_STRUCTS_H__ /* - * Header prepended libpcap to each bluetooth h:4 frame. + * Header prepended libpcap to each bluetooth h4 frame, * fields are in network byte order */ typedef struct _pcap_bluetooth_h4_header { u_int32_t direction; /* if first bit is set direction is incoming */ } pcap_bluetooth_h4_header; +/* + * Header prepended libpcap to each bluetooth linux monitor frame, + * fields are in network byte order + */ +typedef struct _pcap_bluetooth_linux_monitor_header { + u_int16_t adapter_id; + u_int16_t opcode; +} pcap_bluetooth_linux_monitor_header; + #endif diff --git a/external/bsd/libpcap/dist/pcap/ipnet.h b/external/bsd/libpcap/dist/pcap/ipnet.h index e6ca79f30408..53308470991e 100644 --- a/external/bsd/libpcap/dist/pcap/ipnet.h +++ b/external/bsd/libpcap/dist/pcap/ipnet.h @@ -1,5 +1,3 @@ -/* $NetBSD: ipnet.h,v 1.1.1.2 2013/04/06 15:57:51 christos Exp $ */ - /*- * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. diff --git a/external/bsd/libpcap/dist/pcap/namedb.h b/external/bsd/libpcap/dist/pcap/namedb.h index 59443ecfc450..d3a343225f04 100644 --- a/external/bsd/libpcap/dist/pcap/namedb.h +++ b/external/bsd/libpcap/dist/pcap/namedb.h @@ -1,5 +1,3 @@ -/* $NetBSD: namedb.h,v 1.1.1.3 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (c) 1994, 1996 * The Regents of the University of California. All rights reserved. @@ -31,8 +29,6 @@ * 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. - * - * @(#) 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/external/bsd/libpcap/dist/pcap/nflog.h b/external/bsd/libpcap/dist/pcap/nflog.h new file mode 100644 index 000000000000..388dd0c55d08 --- /dev/null +++ b/external/bsd/libpcap/dist/pcap/nflog.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2013, Petar Alilovic, + * Faculty of Electrical Engineering and Computing, University of Zagreb + * All rights reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + */ + +#ifndef _PCAP_NFLOG_H__ +#define _PCAP_NFLOG_H__ + +/* + * Structure of an NFLOG header and TLV parts, as described at + * http://www.tcpdump.org/linktypes/LINKTYPE_NFLOG.html + * + * The NFLOG header is big-endian. + * + * The TLV length and type are in host byte order. The value is either + * big-endian or is an array of bytes in some externally-specified byte + * order (text string, link-layer address, link-layer header, packet + * data, etc.). + */ +typedef struct nflog_hdr { + u_int8_t nflog_family; /* address family */ + u_int8_t nflog_version; /* version */ + u_int16_t nflog_rid; /* resource ID */ +} nflog_hdr_t; + +typedef struct nflog_tlv { + u_int16_t tlv_length; /* tlv length */ + u_int16_t tlv_type; /* tlv type */ + /* value follows this */ +} nflog_tlv_t; + +typedef struct nflog_packet_hdr { + u_int16_t hw_protocol; /* hw protocol */ + u_int8_t hook; /* netfilter hook */ + u_int8_t pad; /* padding to 32 bits */ +} nflog_packet_hdr_t; + +typedef struct nflog_hwaddr { + u_int16_t hw_addrlen; /* address length */ + u_int16_t pad; /* padding to 32-bit boundary */ + u_int8_t hw_addr[8]; /* address, up to 8 bytes */ +} nflog_hwaddr_t; + +typedef struct nflog_timestamp { + u_int64_t sec; + u_int64_t usec; +} nflog_timestamp_t; + +/* + * TLV types. + */ +#define NFULA_PACKET_HDR 1 /* nflog_packet_hdr_t */ +#define NFULA_MARK 2 /* packet mark from skbuff */ +#define NFULA_TIMESTAMP 3 /* nflog_timestamp_t for skbuff's time stamp */ +#define NFULA_IFINDEX_INDEV 4 /* ifindex of device on which packet received (possibly bridge group) */ +#define NFULA_IFINDEX_OUTDEV 5 /* ifindex of device on which packet transmitted (possibly bridge group) */ +#define NFULA_IFINDEX_PHYSINDEV 6 /* ifindex of physical device on which packet received (not bridge group) */ +#define NFULA_IFINDEX_PHYSOUTDEV 7 /* ifindex of physical device on which packet transmitted (not bridge group) */ +#define NFULA_HWADDR 8 /* nflog_hwaddr_t for hardware address */ +#define NFULA_PAYLOAD 9 /* packet payload */ +#define NFULA_PREFIX 10 /* text string - null-terminated, count includes NUL */ +#define NFULA_UID 11 /* UID owning socket on which packet was sent/received */ +#define NFULA_SEQ 12 /* sequence number of packets on this NFLOG socket */ +#define NFULA_SEQ_GLOBAL 13 /* sequence number of pakets on all NFLOG sockets */ +#define NFULA_GID 14 /* GID owning socket on which packet was sent/received */ +#define NFULA_HWTYPE 15 /* ARPHRD_ type of skbuff's device */ +#define NFULA_HWHEADER 16 /* skbuff's MAC-layer header */ +#define NFULA_HWLEN 17 /* length of skbuff's MAC-layer header */ + +#endif diff --git a/external/bsd/libpcap/dist/pcap/sll.h b/external/bsd/libpcap/dist/pcap/sll.h index e9c56753de07..38da29f5090e 100644 --- a/external/bsd/libpcap/dist/pcap/sll.h +++ b/external/bsd/libpcap/dist/pcap/sll.h @@ -1,5 +1,3 @@ -/* $NetBSD: sll.h,v 1.1.1.3 2013/04/06 15:57:50 christos Exp $ */ - /*- * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -36,8 +34,6 @@ * 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. - * - * @(#) Header: /tcpdump/master/libpcap/pcap/sll.h,v 1.3 2008-05-30 01:35:33 guy Exp (LBL) */ /* diff --git a/external/bsd/libpcap/dist/pcap/usb.h b/external/bsd/libpcap/dist/pcap/usb.h index 46496fce05cc..52cb5a322a5e 100644 --- a/external/bsd/libpcap/dist/pcap/usb.h +++ b/external/bsd/libpcap/dist/pcap/usb.h @@ -1,5 +1,3 @@ -/* $NetBSD: usb.h,v 1.1.1.3 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (c) 2006 Paolo Abeni (Italy) * All rights reserved. @@ -31,8 +29,6 @@ * * Basic USB data struct * By Paolo Abeni - * - * @(#) Header: /tcpdump/master/libpcap/pcap/usb.h,v 1.9 2008-12-23 20:13:29 guy Exp */ #ifndef _PCAP_USB_STRUCTS_H__ diff --git a/external/bsd/libpcap/dist/pcap/vlan.h b/external/bsd/libpcap/dist/pcap/vlan.h index ab71b9aee9d7..021f612907f8 100644 --- a/external/bsd/libpcap/dist/pcap/vlan.h +++ b/external/bsd/libpcap/dist/pcap/vlan.h @@ -1,5 +1,3 @@ -/* $NetBSD: vlan.h,v 1.1.1.3 2013/04/06 15:57:51 christos Exp $ */ - /*- * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -31,8 +29,6 @@ * 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. - * - * @(#) 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/external/bsd/libpcap/dist/pcap_activate.3pcap b/external/bsd/libpcap/dist/pcap_activate.3pcap index 45c05ade4508..61887a7bead3 100644 --- a/external/bsd/libpcap/dist/pcap_activate.3pcap +++ b/external/bsd/libpcap/dist/pcap_activate.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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. .\" @@ -19,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_ACTIVATE 3PCAP "5 April 2008" +.TH PCAP_ACTIVATE 3PCAP "21 September 2010" .SH NAME pcap_activate \- activate a capture handle .SH SYNOPSIS diff --git a/external/bsd/libpcap/dist/pcap_breakloop.3pcap b/external/bsd/libpcap/dist/pcap_breakloop.3pcap index 83203b50abf8..a39582069b69 100644 --- a/external/bsd/libpcap/dist/pcap_breakloop.3pcap +++ b/external/bsd/libpcap/dist/pcap_breakloop.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_can_set_rfmon.3pcap b/external/bsd/libpcap/dist/pcap_can_set_rfmon.3pcap index 43d36b960193..b5798046db33 100644 --- a/external/bsd/libpcap/dist/pcap_can_set_rfmon.3pcap +++ b/external/bsd/libpcap/dist/pcap_can_set_rfmon.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_close.3pcap b/external/bsd/libpcap/dist/pcap_close.3pcap index d6a6fad96685..91eb677ef3b8 100644 --- a/external/bsd/libpcap/dist/pcap_close.3pcap +++ b/external/bsd/libpcap/dist/pcap_close.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_compile.3pcap.in b/external/bsd/libpcap/dist/pcap_compile.3pcap.in index 0a681c9004fb..0e5276a165c7 100644 --- a/external/bsd/libpcap/dist/pcap_compile.3pcap.in +++ b/external/bsd/libpcap/dist/pcap_compile.3pcap.in @@ -1,5 +1,3 @@ -.\" @(#) 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. .\" @@ -19,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_COMPILE 3PCAP "5 April 2008" +.TH PCAP_COMPILE 3PCAP "1 December 2009" .SH NAME pcap_compile \- compile a filter expression .SH SYNOPSIS diff --git a/external/bsd/libpcap/dist/pcap_create.3pcap b/external/bsd/libpcap/dist/pcap_create.3pcap index 7242913fdf29..5c537fc55421 100644 --- a/external/bsd/libpcap/dist/pcap_create.3pcap +++ b/external/bsd/libpcap/dist/pcap_create.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_datalink.3pcap.in b/external/bsd/libpcap/dist/pcap_datalink.3pcap.in index c37fa83daec7..b07fc28f0982 100644 --- a/external/bsd/libpcap/dist/pcap_datalink.3pcap.in +++ b/external/bsd/libpcap/dist/pcap_datalink.3pcap.in @@ -1,5 +1,3 @@ -.\" @(#) 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. .\" @@ -19,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_DATALINK 3PCAP "22 August 2010" +.TH PCAP_DATALINK 3PCAP "13 October 2013" .SH NAME pcap_datalink \- get the link-layer header type .SH SYNOPSIS diff --git a/external/bsd/libpcap/dist/pcap_datalink_name_to_val.3pcap b/external/bsd/libpcap/dist/pcap_datalink_name_to_val.3pcap index 546c503edcc9..c61e91e3f91e 100644 --- a/external/bsd/libpcap/dist/pcap_datalink_name_to_val.3pcap +++ b/external/bsd/libpcap/dist/pcap_datalink_name_to_val.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_datalink_val_to_name.3pcap b/external/bsd/libpcap/dist/pcap_datalink_val_to_name.3pcap index 276b4d1fd61f..0b178253d3ac 100644 --- a/external/bsd/libpcap/dist/pcap_datalink_val_to_name.3pcap +++ b/external/bsd/libpcap/dist/pcap_datalink_val_to_name.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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. .\" @@ -37,8 +35,12 @@ const char *pcap_datalink_val_to_description(int dlt); .SH DESCRIPTION .B pcap_datalink_val_to_name() translates a link-layer header type value to the corresponding -link-layer header type name. NULL is returned on failure. +link-layer header type name. +.B NULL +is returned on failure. .PP .B pcap_datalink_val_to_description() translates a link-layer header type value to a short description of that -link-layer header type. NULL is returned on failure. +link-layer header type. +.B NULL +is returned on failure. diff --git a/external/bsd/libpcap/dist/pcap_dump.3pcap b/external/bsd/libpcap/dist/pcap_dump.3pcap index 884c6b9002c8..c7d29f5140e4 100644 --- a/external/bsd/libpcap/dist/pcap_dump.3pcap +++ b/external/bsd/libpcap/dist/pcap_dump.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_dump_close.3pcap b/external/bsd/libpcap/dist/pcap_dump_close.3pcap index a18a29f74ae5..afd00cb498eb 100644 --- a/external/bsd/libpcap/dist/pcap_dump_close.3pcap +++ b/external/bsd/libpcap/dist/pcap_dump_close.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_dump_file.3pcap b/external/bsd/libpcap/dist/pcap_dump_file.3pcap index f17591ca6d71..982b0dc9df65 100644 --- a/external/bsd/libpcap/dist/pcap_dump_file.3pcap +++ b/external/bsd/libpcap/dist/pcap_dump_file.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_dump_flush.3pcap b/external/bsd/libpcap/dist/pcap_dump_flush.3pcap index 7e4bb3a3afcf..ba98dee1dd23 100644 --- a/external/bsd/libpcap/dist/pcap_dump_flush.3pcap +++ b/external/bsd/libpcap/dist/pcap_dump_flush.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_dump_ftell.3pcap b/external/bsd/libpcap/dist/pcap_dump_ftell.3pcap index 0aaebe890cde..6d5c8280589f 100644 --- a/external/bsd/libpcap/dist/pcap_dump_ftell.3pcap +++ b/external/bsd/libpcap/dist/pcap_dump_ftell.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_file.3pcap b/external/bsd/libpcap/dist/pcap_file.3pcap index 6268b98ddc5d..7b18c81dc252 100644 --- a/external/bsd/libpcap/dist/pcap_file.3pcap +++ b/external/bsd/libpcap/dist/pcap_file.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_fileno.3pcap b/external/bsd/libpcap/dist/pcap_fileno.3pcap index 3d02887296b6..39d068b44ece 100644 --- a/external/bsd/libpcap/dist/pcap_fileno.3pcap +++ b/external/bsd/libpcap/dist/pcap_fileno.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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. .\" @@ -19,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_FILENO 3PCAP "5 April 2008" +.TH PCAP_FILENO 3PCAP "3 November 2009" .SH NAME pcap_fileno \- get the file descriptor for a live capture .SH SYNOPSIS diff --git a/external/bsd/libpcap/dist/pcap_findalldevs.3pcap b/external/bsd/libpcap/dist/pcap_findalldevs.3pcap index 46e09dd7efb3..00bb911f9132 100644 --- a/external/bsd/libpcap/dist/pcap_findalldevs.3pcap +++ b/external/bsd/libpcap/dist/pcap_findalldevs.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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. .\" @@ -19,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_FINDALLDEVS 3PCAP "22 August 2010" +.TH PCAP_FINDALLDEVS 3PCAP "10 January 2014" .SH NAME pcap_findalldevs, pcap_freealldevs \- get a list of capture devices, and free that list @@ -94,6 +92,12 @@ device flags: .TP .B PCAP_IF_LOOPBACK set if the device is a loopback interface +.TP +.B PCAP_IF_UP +set if the device is up +.TP +.B PCAP_IF_RUNNING +set if the device is running .RE .RE .PP @@ -167,7 +171,7 @@ for IPv6 addresses, it can be interpreted as if it pointed to a .PP The list of devices must be freed with .BR pcap_freealldevs() , -whch frees the list pointed to by +which frees the list pointed to by .IR alldevs . .SH RETURN VALUE .B pcap_findalldevs() diff --git a/external/bsd/libpcap/dist/pcap_freecode.3pcap b/external/bsd/libpcap/dist/pcap_freecode.3pcap index d72e1f54b8d2..c3c3ea6e0c96 100644 --- a/external/bsd/libpcap/dist/pcap_freecode.3pcap +++ b/external/bsd/libpcap/dist/pcap_freecode.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_get_selectable_fd.3pcap b/external/bsd/libpcap/dist/pcap_get_selectable_fd.3pcap index dd7a1757e297..6ae06a1bc429 100644 --- a/external/bsd/libpcap/dist/pcap_get_selectable_fd.3pcap +++ b/external/bsd/libpcap/dist/pcap_get_selectable_fd.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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. .\" @@ -19,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_GET_SELECTABLE_FD 3PCAP "5 April 2008" +.TH PCAP_GET_SELECTABLE_FD 3PCAP "22 July 2011" .SH NAME pcap_get_selectable_fd \- get a file descriptor on which a select() can be done for a live capture diff --git a/external/bsd/libpcap/dist/pcap_get_tstamp_precision.3pcap.in b/external/bsd/libpcap/dist/pcap_get_tstamp_precision.3pcap.in index 7633a36ed98b..656c14291ff0 100644 --- a/external/bsd/libpcap/dist/pcap_get_tstamp_precision.3pcap.in +++ b/external/bsd/libpcap/dist/pcap_get_tstamp_precision.3pcap.in @@ -39,8 +39,13 @@ returns the precision of the time stamp returned in packet captures on the pcap descriptor. .SH RETURN VALUE .B pcap_get_tstamp_precision() -returns PCAP_TSTAMP_PRECISION_MICRO or PCAP_TSTAMP_PRECISION_NANO, which indicates -that pcap captures contains time stamps in microseconds or nanoseconds respectively. +returns +.B PCAP_TSTAMP_PRECISION_MICRO +or +.BR PCAP_TSTAMP_PRECISION_NANO , +which indicates +that pcap captures contains time stamps in microseconds or nanoseconds +respectively. .SH SEE ALSO pcap(3PCAP), pcap_set_tstamp_precision(3PCAP), diff --git a/external/bsd/libpcap/dist/pcap_geterr.3pcap b/external/bsd/libpcap/dist/pcap_geterr.3pcap index 9ee3f357ec23..fcabec3b5bed 100644 --- a/external/bsd/libpcap/dist/pcap_geterr.3pcap +++ b/external/bsd/libpcap/dist/pcap_geterr.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_inject.3pcap b/external/bsd/libpcap/dist/pcap_inject.3pcap index be6e4d8d2bad..7ccdf2c506c9 100644 --- a/external/bsd/libpcap/dist/pcap_inject.3pcap +++ b/external/bsd/libpcap/dist/pcap_inject.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_is_swapped.3pcap b/external/bsd/libpcap/dist/pcap_is_swapped.3pcap index 0c1bf45108b9..a120616d3291 100644 --- a/external/bsd/libpcap/dist/pcap_is_swapped.3pcap +++ b/external/bsd/libpcap/dist/pcap_is_swapped.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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. .\" @@ -19,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_IS_SWAPPED 3PCAP "5 April 2008" +.TH PCAP_IS_SWAPPED 3PCAP "17 September 2013" .SH NAME pcap_is_swapped \- find out whether a savefile has the native byte order .SH SYNOPSIS diff --git a/external/bsd/libpcap/dist/pcap_lib_version.3pcap b/external/bsd/libpcap/dist/pcap_lib_version.3pcap index 4e9ba7d4b661..3ec2e32d5f56 100644 --- a/external/bsd/libpcap/dist/pcap_lib_version.3pcap +++ b/external/bsd/libpcap/dist/pcap_lib_version.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_list_datalinks.3pcap.in b/external/bsd/libpcap/dist/pcap_list_datalinks.3pcap.in index 67cd241dae2a..607efdecafc0 100644 --- a/external/bsd/libpcap/dist/pcap_list_datalinks.3pcap.in +++ b/external/bsd/libpcap/dist/pcap_list_datalinks.3pcap.in @@ -1,5 +1,3 @@ -.\" @(#) 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. .\" @@ -19,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_LIST_DATALINKS 3PCAP "22 August 2010" +.TH PCAP_LIST_DATALINKS 3PCAP "17 September 2013" .SH NAME pcap_list_datalinks, pcap_free_datalinks \- get a list of link-layer header types supported by a capture device, and free that list diff --git a/external/bsd/libpcap/dist/pcap_lookupdev.3pcap b/external/bsd/libpcap/dist/pcap_lookupdev.3pcap index 3734a048e645..79dda429e437 100644 --- a/external/bsd/libpcap/dist/pcap_lookupdev.3pcap +++ b/external/bsd/libpcap/dist/pcap_lookupdev.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_lookupnet.3pcap b/external/bsd/libpcap/dist/pcap_lookupnet.3pcap index 29e1ae518160..a3d14ae7f477 100644 --- a/external/bsd/libpcap/dist/pcap_lookupnet.3pcap +++ b/external/bsd/libpcap/dist/pcap_lookupnet.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_loop.3pcap b/external/bsd/libpcap/dist/pcap_loop.3pcap index 180bb0ef0ab4..d18dc06c28b8 100644 --- a/external/bsd/libpcap/dist/pcap_loop.3pcap +++ b/external/bsd/libpcap/dist/pcap_loop.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_LOOP 3PCAP "24 December 2008" +.TH PCAP_LOOP 3PCAP "13 October 2013" .SH NAME pcap_loop, pcap_dispatch \- process packets from a live capture or savefile .SH SYNOPSIS diff --git a/external/bsd/libpcap/dist/pcap_major_version.3pcap b/external/bsd/libpcap/dist/pcap_major_version.3pcap index 91a75ea810aa..a0858380cb14 100644 --- a/external/bsd/libpcap/dist/pcap_major_version.3pcap +++ b/external/bsd/libpcap/dist/pcap_major_version.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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. .\" @@ -19,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_MAJOR_VERSION 3PCAP "5 April 2008" +.TH PCAP_MAJOR_VERSION 3PCAP "21 December 2011" .SH NAME pcap_major_version, pcap_minor_version \- get the version number of a savefile .SH SYNOPSIS diff --git a/external/bsd/libpcap/dist/pcap_next_ex.3pcap b/external/bsd/libpcap/dist/pcap_next_ex.3pcap index 89870bc5d072..c310c2f004b5 100644 --- a/external/bsd/libpcap/dist/pcap_next_ex.3pcap +++ b/external/bsd/libpcap/dist/pcap_next_ex.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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. .\" @@ -19,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_NEXT_EX 3PCAP "5 April 2008" +.TH PCAP_NEXT_EX 3PCAP "13 October 2013" .SH NAME pcap_next_ex, pcap_next \- read the next packet from a pcap_t .SH SYNOPSIS @@ -115,9 +113,9 @@ for Ethernet. .SH RETURN VALUE .B pcap_next_ex() returns 1 if the packet was read without problems, 0 -if packets are being read from a live capture, and the timeout expired, +if packets are being read from a live capture and the timeout expired, \-1 if an error occurred while reading the packet, and \-2 if -packets are being read from a ``savefile'', and there are no more +packets are being read from a ``savefile'' and there are no more packets to read from the savefile. If \-1 is returned, .B pcap_geterr() diff --git a/external/bsd/libpcap/dist/pcap_offline_filter.3pcap b/external/bsd/libpcap/dist/pcap_offline_filter.3pcap index 84aa191924a6..b471c6a7403e 100644 --- a/external/bsd/libpcap/dist/pcap_offline_filter.3pcap +++ b/external/bsd/libpcap/dist/pcap_offline_filter.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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. .\" @@ -19,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_OFFLINE_FILTER 3PCAP "13 May 2008" +.TH PCAP_OFFLINE_FILTER 3PCAP "25 November 2012" .SH NAME pcap_offline_filter \- check whether a filter matches a packet .SH SYNOPSIS diff --git a/external/bsd/libpcap/dist/pcap_open_dead.3pcap.in b/external/bsd/libpcap/dist/pcap_open_dead.3pcap.in index 340789894560..2d1b48cca75d 100644 --- a/external/bsd/libpcap/dist/pcap_open_dead.3pcap.in +++ b/external/bsd/libpcap/dist/pcap_open_dead.3pcap.in @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_open_live.3pcap b/external/bsd/libpcap/dist/pcap_open_live.3pcap index cee35fc8bc3b..715994b0fd0c 100644 --- a/external/bsd/libpcap/dist/pcap_open_live.3pcap +++ b/external/bsd/libpcap/dist/pcap_open_live.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_set_buffer_size.3pcap b/external/bsd/libpcap/dist/pcap_set_buffer_size.3pcap index f2997a7de34c..fea1df74a9a5 100644 --- a/external/bsd/libpcap/dist/pcap_set_buffer_size.3pcap +++ b/external/bsd/libpcap/dist/pcap_set_buffer_size.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_set_datalink.3pcap b/external/bsd/libpcap/dist/pcap_set_datalink.3pcap index 75e4b92eac92..60a7bfc81c80 100644 --- a/external/bsd/libpcap/dist/pcap_set_datalink.3pcap +++ b/external/bsd/libpcap/dist/pcap_set_datalink.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_set_immediate_mode.3pcap b/external/bsd/libpcap/dist/pcap_set_immediate_mode.3pcap index fef5dcdf9977..87ec98bb146b 100644 --- a/external/bsd/libpcap/dist/pcap_set_immediate_mode.3pcap +++ b/external/bsd/libpcap/dist/pcap_set_immediate_mode.3pcap @@ -18,7 +18,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_SET_IMMEDIATE_MODE 3PCAP "8 May 20013" +.TH PCAP_SET_IMMEDIATE_MODE 3PCAP "8 May 2013" .SH NAME pcap_set_immediate_mode \- set immediate mode for a not-yet-activated capture handle diff --git a/external/bsd/libpcap/dist/pcap_set_promisc.3pcap b/external/bsd/libpcap/dist/pcap_set_promisc.3pcap index 15cb80b67305..5d1757275a76 100644 --- a/external/bsd/libpcap/dist/pcap_set_promisc.3pcap +++ b/external/bsd/libpcap/dist/pcap_set_promisc.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_set_rfmon.3pcap b/external/bsd/libpcap/dist/pcap_set_rfmon.3pcap index 06e636d340e4..a386e8b1f2a3 100644 --- a/external/bsd/libpcap/dist/pcap_set_rfmon.3pcap +++ b/external/bsd/libpcap/dist/pcap_set_rfmon.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_set_snaplen.3pcap b/external/bsd/libpcap/dist/pcap_set_snaplen.3pcap index 34e6f13c0681..8080ea12940d 100644 --- a/external/bsd/libpcap/dist/pcap_set_snaplen.3pcap +++ b/external/bsd/libpcap/dist/pcap_set_snaplen.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_set_timeout.3pcap b/external/bsd/libpcap/dist/pcap_set_timeout.3pcap index d9f7871bbd31..b7282037b3e7 100644 --- a/external/bsd/libpcap/dist/pcap_set_timeout.3pcap +++ b/external/bsd/libpcap/dist/pcap_set_timeout.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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. .\" @@ -19,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_SET_TIMEOUT 3PCAP "5 April 2008" +.TH PCAP_SET_TIMEOUT 3PCAP "16 April 2014" .SH NAME pcap_set_timeout \- set the read timeout for a not-yet-activated capture handle diff --git a/external/bsd/libpcap/dist/pcap_setdirection.3pcap b/external/bsd/libpcap/dist/pcap_setdirection.3pcap index 3ffd6eb4e1bf..70920b174aba 100644 --- a/external/bsd/libpcap/dist/pcap_setdirection.3pcap +++ b/external/bsd/libpcap/dist/pcap_setdirection.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_setfilter.3pcap b/external/bsd/libpcap/dist/pcap_setfilter.3pcap index 7a1f7d190c7d..c737797f3108 100644 --- a/external/bsd/libpcap/dist/pcap_setfilter.3pcap +++ b/external/bsd/libpcap/dist/pcap_setfilter.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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. .\" @@ -19,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_SETFILTER 3PCAP "5 April 2008" +.TH PCAP_SETFILTER 3PCAP "13 May 2008" .SH NAME pcap_setfilter \- set the filter .SH SYNOPSIS diff --git a/external/bsd/libpcap/dist/pcap_setnonblock.3pcap b/external/bsd/libpcap/dist/pcap_setnonblock.3pcap index 8feec879a5f3..37b22031d451 100644 --- a/external/bsd/libpcap/dist/pcap_setnonblock.3pcap +++ b/external/bsd/libpcap/dist/pcap_setnonblock.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_snapshot.3pcap b/external/bsd/libpcap/dist/pcap_snapshot.3pcap index e5ea6f99b84b..47eb42a3843f 100644 --- a/external/bsd/libpcap/dist/pcap_snapshot.3pcap +++ b/external/bsd/libpcap/dist/pcap_snapshot.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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. .\" @@ -19,7 +17,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_SNAPSHOT 3PCAP "17 September 2013" .SH NAME pcap_snapshot \- get the snapshot length .SH SYNOPSIS diff --git a/external/bsd/libpcap/dist/pcap_stats.3pcap b/external/bsd/libpcap/dist/pcap_stats.3pcap index 1d5f85872064..159054e74485 100644 --- a/external/bsd/libpcap/dist/pcap_stats.3pcap +++ b/external/bsd/libpcap/dist/pcap_stats.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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. .\" diff --git a/external/bsd/libpcap/dist/pcap_statustostr.3pcap b/external/bsd/libpcap/dist/pcap_statustostr.3pcap index 56c83172ccca..77b8c5f1079c 100644 --- a/external/bsd/libpcap/dist/pcap_statustostr.3pcap +++ b/external/bsd/libpcap/dist/pcap_statustostr.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_strerror.3pcap b/external/bsd/libpcap/dist/pcap_strerror.3pcap index 79dc16b2a5ab..71851623ddd0 100644 --- a/external/bsd/libpcap/dist/pcap_strerror.3pcap +++ b/external/bsd/libpcap/dist/pcap_strerror.3pcap @@ -1,5 +1,3 @@ -.\" @(#) 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/external/bsd/libpcap/dist/pcap_tstamp_type_val_to_name.3pcap b/external/bsd/libpcap/dist/pcap_tstamp_type_val_to_name.3pcap index 5d8d75405c17..903cea7b11a2 100644 --- a/external/bsd/libpcap/dist/pcap_tstamp_type_val_to_name.3pcap +++ b/external/bsd/libpcap/dist/pcap_tstamp_type_val_to_name.3pcap @@ -36,10 +36,14 @@ const char *pcap_tstamp_type_val_to_description(int tstamp_type); .SH DESCRIPTION .B pcap_tstamp_type_val_to_name() translates a time stamp type value to the corresponding time stamp type -name. NULL is returned on failure. +name. +.B NULL +is returned on failure. .PP .B pcap_tstamp_type_val_to_description() translates a time stamp type value to a short description of that time -stamp type. NULL is returned on failure. +stamp type. +.B NULL +is returned on failure. .SH SEE ALSO pcap(3PCAP), pcap_tstamp_type_name_to_val(3PCAP) diff --git a/external/bsd/libpcap/dist/ppp.h b/external/bsd/libpcap/dist/ppp.h index e6eb37ebefe2..d6e70c151d96 100644 --- a/external/bsd/libpcap/dist/ppp.h +++ b/external/bsd/libpcap/dist/ppp.h @@ -1,6 +1,3 @@ -/* $NetBSD: ppp.h,v 1.1.1.3 2013/04/06 15:57:45 christos Exp $ */ - -/* @(#) 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/external/bsd/libpcap/dist/runlex.sh b/external/bsd/libpcap/dist/runlex.sh index c989a90c7722..24c3c2e1344a 100755 --- a/external/bsd/libpcap/dist/runlex.sh +++ b/external/bsd/libpcap/dist/runlex.sh @@ -7,8 +7,6 @@ # means that neither Flex nor Lex was found, so we report an error and # quit. # -# @(#) Header: /tcpdump/master/libpcap/runlex.sh,v 1.4 2007-12-31 03:38:39 guy Exp -# # # Get the name of the command to run, and then shift to get the arguments. diff --git a/external/bsd/libpcap/dist/savefile.c b/external/bsd/libpcap/dist/savefile.c index 1766675b06fe..0ab2fdefb201 100644 --- a/external/bsd/libpcap/dist/savefile.c +++ b/external/bsd/libpcap/dist/savefile.c @@ -1,5 +1,3 @@ -/* $NetBSD: savefile.c,v 1.1.1.4 2013/12/31 16:57:18 christos Exp $ */ - /* * Copyright (c) 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -30,11 +28,6 @@ * 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 diff --git a/external/bsd/libpcap/dist/sf-pcap-ng.h b/external/bsd/libpcap/dist/sf-pcap-ng.h index ca8740a27ee2..3c93498fb569 100644 --- a/external/bsd/libpcap/dist/sf-pcap-ng.h +++ b/external/bsd/libpcap/dist/sf-pcap-ng.h @@ -1,5 +1,3 @@ -/* $NetBSD: sf-pcap-ng.h,v 1.1.1.3 2013/12/31 16:57:21 christos Exp $ */ - /* * Copyright (c) 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. diff --git a/external/bsd/libpcap/dist/sf-pcap.h b/external/bsd/libpcap/dist/sf-pcap.h index ccbc21c0417c..e9c7eafa655d 100644 --- a/external/bsd/libpcap/dist/sf-pcap.h +++ b/external/bsd/libpcap/dist/sf-pcap.h @@ -1,5 +1,3 @@ -/* $NetBSD: sf-pcap.h,v 1.1.1.3 2013/12/31 16:57:25 christos Exp $ */ - /* * Copyright (c) 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. diff --git a/external/bsd/libpcap/dist/sunatmpos.h b/external/bsd/libpcap/dist/sunatmpos.h index e30d3eb2d1e1..787de8574328 100644 --- a/external/bsd/libpcap/dist/sunatmpos.h +++ b/external/bsd/libpcap/dist/sunatmpos.h @@ -1,5 +1,3 @@ -/* $NetBSD: sunatmpos.h,v 1.1.1.3 2013/04/06 15:57:46 christos Exp $ */ - /* * Copyright (c) 1997 Yen Yen Lim and North Dakota State University * All rights reserved. @@ -30,8 +28,6 @@ * 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. - * - * @(#) 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/external/bsd/libpcap/dist/tests/capturetest.c b/external/bsd/libpcap/dist/tests/capturetest.c new file mode 100644 index 000000000000..e70e69a514c1 --- /dev/null +++ b/external/bsd/libpcap/dist/tests/capturetest.c @@ -0,0 +1,287 @@ +/* + * 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 + +#include + +static 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; + register char *cp, *cmdbuf, *device; + long longarg; + char *p; + int timeout = 1000; + int immediate = 0; + int nonblock = 0; + bpf_u_int32 localnet, netmask; + struct bpf_program fcode; + char ebuf[PCAP_ERRBUF_SIZE]; + int status; + int packet_count; + + device = NULL; + if ((cp = strrchr(argv[0], '/')) != NULL) + program_name = cp + 1; + else + program_name = argv[0]; + + opterr = 0; + while ((op = getopt(argc, argv, "i:mnt:")) != -1) { + switch (op) { + + case 'i': + device = optarg; + break; + + case 'm': + immediate = 1; + break; + + case 'n': + nonblock = 1; + break; + + case 't': + longarg = strtol(optarg, &p, 10); + if (p == optarg || *p != '\0') { + error("Timeout value \"%s\" is not a number", + optarg); + /* NOTREACHED */ + } + if (longarg < 0) { + error("Timeout value %ld is negative", longarg); + /* NOTREACHED */ + } + if (longarg > INT_MAX) { + error("Timeout value %ld is too large (> %d)", + longarg, INT_MAX); + /* NOTREACHED */ + } + timeout = (int)longarg; + break; + + default: + usage(); + /* NOTREACHED */ + } + } + + if (device == NULL) { + device = pcap_lookupdev(ebuf); + if (device == NULL) + error("%s", ebuf); + } + *ebuf = '\0'; + pd = pcap_create(device, ebuf); + if (pd == NULL) + error("%s", ebuf); + status = pcap_set_snaplen(pd, 65535); + if (status != 0) + error("%s: pcap_set_snaplen failed: %s", + device, pcap_statustostr(status)); + if (immediate) { + status = pcap_set_immediate_mode(pd, 1); + if (status != 0) + error("%s: pcap_set_immediate_mode failed: %s", + device, pcap_statustostr(status)); + } + status = pcap_set_timeout(pd, timeout); + if (status != 0) + error("%s: pcap_set_timeout failed: %s", + device, pcap_statustostr(status)); + status = pcap_activate(pd); + if (status < 0) { + /* + * pcap_activate() failed. + */ + error("%s: %s\n(%s)", device, + pcap_statustostr(status), pcap_geterr(pd)); + } else if (status > 0) { + /* + * pcap_activate() succeeded, but it's warning us + * of a problem it had. + */ + warning("%s: %s\n(%s)", device, + pcap_statustostr(status), pcap_geterr(pd)); + } + 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_setnonblock(pd, nonblock, ebuf) == -1) + error("pcap_setnonblock failed: %s", ebuf); + printf("Listening on %s\n", device); + for (;;) { + packet_count = 0; + status = pcap_dispatch(pd, -1, countme, + (u_char *)&packet_count); + if (status < 0) + break; + if (status != 0) { + 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 [ -mn ] [ -i interface ] [ -t timeout] [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/external/bsd/libpcap/dist/tests/filtertest.c b/external/bsd/libpcap/dist/tests/filtertest.c index 01e7e4d37784..d603376da64e 100644 --- a/external/bsd/libpcap/dist/tests/filtertest.c +++ b/external/bsd/libpcap/dist/tests/filtertest.c @@ -1,5 +1,3 @@ -/* $NetBSD: filtertest.c,v 1.1.1.1 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000 * The Regents of the University of California. All rights reserved. @@ -25,8 +23,6 @@ static const char copyright[] _U_ = "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\ The Regents of the University of California. All rights reserved.\n"; -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/filtertest.c,v 1.2 2005-08-08 17:50:13 guy Exp (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -55,6 +51,8 @@ static char *program_name; static void usage(void) __attribute__((noreturn)); static void error(const char *, ...) __attribute__((noreturn, format (printf, 1, 2))); +static void warn(const char *, ...) + __attribute__((format (printf, 1, 2))); extern int optind; extern int opterr; @@ -124,6 +122,23 @@ error(const char *fmt, ...) /* NOTREACHED */ } +/* VARARGS */ +static void +warn(const char *fmt, ...) +{ + va_list ap; + + (void)fprintf(stderr, "%s: WARNING: ", program_name); + va_start(ap, fmt); + (void)vfprintf(stderr, fmt, ap); + va_end(ap); + if (*fmt) { + fmt += strlen(fmt); + if (fmt[-1] != '\n') + (void)fputc('\n', stderr); + } +} + /* * Copy arg vector into a new buffer, concatenating arguments with spaces. */ @@ -251,6 +266,8 @@ main(int argc, char **argv) if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0) error("%s", pcap_geterr(pd)); + if (!bpf_validate(fcode.bf_insns, fcode.bf_len)) + warn("Filter doesn't pass validation"); bpf_dump(&fcode, dflag); pcap_close(pd); exit(0); diff --git a/external/bsd/libpcap/dist/tests/findalldevstest.c b/external/bsd/libpcap/dist/tests/findalldevstest.c index aaf0a90a5cb4..ec7c95015c9e 100644 --- a/external/bsd/libpcap/dist/tests/findalldevstest.c +++ b/external/bsd/libpcap/dist/tests/findalldevstest.c @@ -1,5 +1,3 @@ -/* $NetBSD: findalldevstest.c,v 1.1.1.1 2013/04/06 15:57:51 christos Exp $ */ - #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/external/bsd/libpcap/dist/tests/opentest.c b/external/bsd/libpcap/dist/tests/opentest.c index a7e3da97d3c8..0c91531018db 100644 --- a/external/bsd/libpcap/dist/tests/opentest.c +++ b/external/bsd/libpcap/dist/tests/opentest.c @@ -1,5 +1,3 @@ -/* $NetBSD: opentest.c,v 1.1.1.1 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000 * The Regents of the University of California. All rights reserved. diff --git a/external/bsd/libpcap/dist/tests/reactivatetest.c b/external/bsd/libpcap/dist/tests/reactivatetest.c index ac800ced0f2c..9031a64a619e 100644 --- a/external/bsd/libpcap/dist/tests/reactivatetest.c +++ b/external/bsd/libpcap/dist/tests/reactivatetest.c @@ -1,5 +1,3 @@ -/* $NetBSD: reactivatetest.c,v 1.1.1.1 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000 * The Regents of the University of California. All rights reserved. diff --git a/external/bsd/libpcap/dist/tests/selpolltest.c b/external/bsd/libpcap/dist/tests/selpolltest.c index 6e1e5c2c2ac2..d94fb567fb20 100644 --- a/external/bsd/libpcap/dist/tests/selpolltest.c +++ b/external/bsd/libpcap/dist/tests/selpolltest.c @@ -1,5 +1,3 @@ -/* $NetBSD: selpolltest.c,v 1.1.1.1 2013/04/06 15:57:51 christos Exp $ */ - /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000 * The Regents of the University of California. All rights reserved. diff --git a/external/bsd/libpcap/dist/tests/valgrindtest.c b/external/bsd/libpcap/dist/tests/valgrindtest.c index 1d749cd6aa17..1d883776b04e 100644 --- a/external/bsd/libpcap/dist/tests/valgrindtest.c +++ b/external/bsd/libpcap/dist/tests/valgrindtest.c @@ -1,5 +1,3 @@ -/* $NetBSD: valgrindtest.c,v 1.1.1.1 2013/12/31 16:57:29 christos Exp $ */ - /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000 * The Regents of the University of California. All rights reserved. @@ -25,8 +23,6 @@ static const char copyright[] _U_ = "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\ The Regents of the University of California. All rights reserved.\n"; -static const char rcsid[] _U_ = - "@(#) Header: /tcpdump/master/libpcap/filtertest.c,v 1.2 2005-08-08 17:50:13 guy Exp (LBL)"; #endif #ifdef HAVE_CONFIG_H