mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-22 02:37:15 +00:00
libpcap: Update to 1.10.3
Local changes: - In contrib/libpcap/pcap/bpf.h, do not include pcap/dlt.h. Our system net/dlt.h is pulled in from net/bpf.h. - sys/net/dlt.h: Incorporate changes from libpcap 1.10.3. - lib/libpcap/Makefile: Update for libpcap 1.10.3. Changelog: https://git.tcpdump.org/libpcap/blob/95691ebe7564afa3faa5c6ba0dbd17e351be455a:/CHANGES Reviewed by: emaste Obtained from: https://www.tcpdump.org/release/libpcap-1.10.3.tar.gz Sponsored by: The FreeBSD Foundation
This commit is contained in:
commit
6f9cba8f8b
|
@ -1,3 +1,432 @@
|
|||
Thursday, January 12, 2023 / The Tcpdump Group
|
||||
Summary for 1.10.3 libpcap release
|
||||
Source code:
|
||||
Sort the PUBHDR variable in Makefile.in in "ls" order.
|
||||
Fix typo in comment in pflog.h.
|
||||
Remove two no-longer-present files from .gitignore.
|
||||
Update code and comments for handling failure to set promiscuous
|
||||
mode based on new information.
|
||||
Building and testing:
|
||||
install: Fixed not to install the non-public pcap-util.h header.
|
||||
pcap-config: add a --version flag.
|
||||
Makefile.in: Add some missing files in the distclean target.
|
||||
|
||||
Saturday, December 31, 2022 / The Tcpdump Group
|
||||
Summary for 1.10.2 libpcap release
|
||||
Source code:
|
||||
Use __builtin_unreachable() in PCAP_UNREACHABLE.
|
||||
Use AS_HELP_STRING macro instead of AC_HELP_STRING in the
|
||||
configure scripts, to avoid deprecation warnings.
|
||||
Change availability tags in pcap.h to make it easier to
|
||||
arrange for it to be used in Darwin releases.
|
||||
Use AS_HELP_STRING for --enable-remote.
|
||||
Fix some formatting string issues found by cppcheck.
|
||||
Various small code and comment cleanups.
|
||||
Use PCAP_ERROR (defined as -1) rather than explicit -1 for
|
||||
functions the documentation says return PCAP_ERROR.
|
||||
Remove unused code from the filter compiler.
|
||||
Use _declspec(deprecated(msg)) rather than __pragma(deprecated)
|
||||
for Windows deprecation warnings, so the message that was
|
||||
specified shows up.
|
||||
diag-control.h: define PCAP_DO_PRAGMA() iff we're going to use it.
|
||||
Use "%d" to print some signed ints.
|
||||
Use the Wayback Machine for a removed document in a comment.
|
||||
Add some const qualifiers.
|
||||
RDMA: Use PRIu64 to print a uint64_t.
|
||||
"Dead" pcap_ts from pcap_open_dead() and ..._with_tstamp_precision():
|
||||
Don't crash if pcap_breakloop() is called.
|
||||
Savefiles:
|
||||
Fix pcap_dispatch() to return number of packets processed, rather
|
||||
than 0, even at EOF.
|
||||
If we get an error writing the packet header, don't write the
|
||||
packet data.
|
||||
Put PFLOG UID and PID values in the header into host byte order
|
||||
when reading a LINKTYPE_PFLOG file.
|
||||
Put CAN ID field in CAN pseudo-headers for LINUX_SLL2, as we do
|
||||
for LINUX_SLL.
|
||||
Fix inorrectly-computed "real" length for isochronous USB
|
||||
transfers when reading savefiles.
|
||||
Don't crash if pcap_can_set_rfmon() is called.
|
||||
Fix pcap_offline_read() loop.
|
||||
Capture:
|
||||
Never process more than INT_MAX packets in a pcap_dispatch() call,
|
||||
to avoid integer overflow (issue #1087).
|
||||
Improve error messages for "no such device" and "permission
|
||||
denied" errors.
|
||||
SITA: Fix a typo in a variable name.
|
||||
Packet filtering:
|
||||
Get PFLOG header length from the length value in the header.
|
||||
Support all the direction, reason, and action types supported by
|
||||
all systems that support PFLOG.
|
||||
Don't require PFLOG support on the target machine in order to
|
||||
support PFLOG filtering (also fixes issue #1076).
|
||||
Expand abbreviations into "proto X" properly.
|
||||
gencode.c: Update a comment about the VLAN TPID test.
|
||||
Add the minimum and maximum matching DLTs to an error message.
|
||||
Linux:
|
||||
Fix memory leak in capture device open (pull request #1038).
|
||||
Fix detection of CAN/CAN FD packets in direction check (issue
|
||||
#1051).
|
||||
Fix double-free crashes on errors such as running on a kernel with
|
||||
CONFIG_PACKET_MMAP not configured (issue #1054).
|
||||
Use DLT_CAN_SOCKETCAN for CANbus interfaces (issue #1052; includes
|
||||
changes from pull request #1035).
|
||||
Make sure the CANFD_FDF can be relied on to indicate whether a
|
||||
CANbus packet is a CAN frame or a CAN FD frame
|
||||
Improve error message for "out of memory" errors for kernel
|
||||
filters (see issue #1089).
|
||||
Fix pcap_findalldevs() to find usbmon devices.
|
||||
Fix handling of VLAN tagged packets if the link-layer type is
|
||||
changed from DLT_LINUX_SLL to DLT_LINUX_SLL2 (see issue #1105).
|
||||
Always turn on PACKET_AUXDATA (see issue #1105).
|
||||
We require 2.6.27 or later, so PACKET_RESERVE is available.
|
||||
Make sure there's reserved space for a DLT_LINUX_SLL2 header
|
||||
when capturing.
|
||||
Correctly compute the "real" length for isochronous USB transfers.
|
||||
Don't have an eventfd descriptor open in non-blocking mode, so as
|
||||
not to waste descriptors.
|
||||
netfilter: Squelch a narrowing warning (To be look at before 2038).
|
||||
BPF capture (*BSD, macOS, AIX, Solaris 11):
|
||||
Fix case where a device open might fail, rather than falling back
|
||||
to a smaller buffer size, when the initial buffer size is too
|
||||
big.
|
||||
Use an unsigned device number to iterate over BPF devices, to
|
||||
squelch a compiler warning.
|
||||
NetBSD:
|
||||
Fix handling of LINKTYPE_HDLC/DLT_HDLC.
|
||||
rpcap:
|
||||
Fix unaligned accesses in rpcapd (pull request #1037).
|
||||
Fix code to process port number.
|
||||
Clean up findalldevs code in rpcapd.
|
||||
Clean up bufferizing code.
|
||||
Fix a file descriptor/handle leak in pcap_findalldevs_ex()
|
||||
(Coverity CID 1507240).
|
||||
Improve error messages for host and port resolution errors.
|
||||
Fix connect code not to fail if both IPv4 and IPv6 addresses are
|
||||
tried.
|
||||
Improve connect failure error message.
|
||||
Provide an error message for a bad authentication reply size.
|
||||
For link-layer types with host-endian fields in the header, fix
|
||||
those fields if capturing from a server with a different byte
|
||||
order.
|
||||
Suppress temporarily the warnings with "enable remote packet capture".
|
||||
Windows:
|
||||
Add support for NdisMediumIP (pull request #1027).
|
||||
Don't require applications using pcap to be built with VS 2015 or
|
||||
later.
|
||||
Use the correct string for the DLL VersionInfo.
|
||||
Remove unnecessary DllMain() function.
|
||||
Correctly handle ERROR_INVALID_FUNCTION from
|
||||
PacketGetTimestampModes() (indicate that WinPcap or an older
|
||||
version of Npcap is probably installed).
|
||||
Fix use-after-free in some cases when a pcap_t is closed.
|
||||
Make sure an error is returned by pcap_create_interface() if
|
||||
PacketOpenAdapter() fails.
|
||||
Return an error if the driver reports 0 timestamp modes supported.
|
||||
Close the ADAPTER handle for some errors in
|
||||
pcap_create_interface().
|
||||
Get rid of old umaintained VS project files.
|
||||
Fix deprecation warning for pcap_handle().
|
||||
Npcap is now at npcap.com, not npcap.org.
|
||||
Make sure "no such device" and "no permission to open device"
|
||||
errors show up in pcap_activate(), not pcap_create() (fixes,
|
||||
among other things, tcpdump -i <interface-number>).
|
||||
npcap: squelch deprecation warnings for kernel dump mode.
|
||||
Haiku:
|
||||
Implement pcap_lib_version(), as now required.
|
||||
Handle negative or too-large snaplen values.
|
||||
Fix various build issues and warnings.
|
||||
Building and testing:
|
||||
Update configure-time universal build checks for macOS.
|
||||
Update config.guess and config.sub.
|
||||
If we look for an SSL library with pkg-config in configure script,
|
||||
try pkg-config first.
|
||||
If we have pkg-config and Homebrew, try to set pkg-config up to
|
||||
find Homebrew packages.
|
||||
Handle some Autoconf/make errors better.
|
||||
Use "git archive" for the "make releasetar" process.
|
||||
Remove the release candidate rcX targets.
|
||||
Fix compiling on Solaris 9/SPARC and 11/AMD64.
|
||||
Address assorted compiler warnings.
|
||||
Fix cross-building on Linux for Windows with mingw32 for Win64
|
||||
(pull request #1031).
|
||||
Properly set installation directory on Windows when not compiling
|
||||
with MSVC.
|
||||
Fix configure script checks for compiler flags.
|
||||
Give more details if check for usable (F)Lex fails.
|
||||
Fix compiling with GCC 4.6.4.
|
||||
Don't use add_compile_options() with CMake, as we currently don't
|
||||
require 2.8.12, where it first appeared.
|
||||
Don't provide -L/usr/lib for pkg-config --libs in pkg-config.
|
||||
Fix error message for inadequate Bison/Berkeley YACC.
|
||||
configure: correctly do some DPDK checks.
|
||||
Only use pkg-config when checking for DPDK.
|
||||
Allow the path in which DPDK is installed to be specified.
|
||||
Use pkg-config first when checking for libibverbs.
|
||||
CMake: fix check for libibverbs with Sun's C compiler.
|
||||
Have CMake warn if no capture mechanism can be found.
|
||||
Don't do stuff requiring 3.19 or later on earlier CMakes.
|
||||
Squelch some CMake warnings.
|
||||
Fix diag-control.h to handle compiling with clang-cl (issues
|
||||
#1101 and #1115).
|
||||
Cleanup various leftover cruft in the configure script.
|
||||
Fix building without protochain support. (GH #852)
|
||||
Check for a usable YACC (or Bison) and {F}lex in CMake, as we do
|
||||
in autotools.
|
||||
Only check for a C++ compiler on Haiku, as that's the only
|
||||
platform with C++ code, and make sure they generate code for
|
||||
the same instruction set bit-width (both 32-bit or both 64-bit)
|
||||
(issue #1112).
|
||||
On Solaris, check the target bit-width and set PKG_CONFIG_PATH
|
||||
appropriately, to handle the mess that is the D-Bus library
|
||||
package (issue #1112).
|
||||
Fix generation of pcap-config and libpcap.pc files (issue #1062).
|
||||
pcap-config: don't assume the system library directory is /usr/lib.
|
||||
pcap-config: add a --static-pcap-only flag.
|
||||
Cirrus CI: Use the same configuration as for the main branch.
|
||||
Add four libpcap test files.
|
||||
Update Npcap SDK to 1.13.
|
||||
Makefile.in: Use TEST_DIST, like for tcpdump.
|
||||
Remove awk code from mkdep.
|
||||
Cirrus CI: Add the libssl-dev package in the Linux task.
|
||||
Cirrus CI: Add the openssl@3 brew package in the macOS task.
|
||||
Get "make shellcheck" to pass again.
|
||||
CMake: Build valgrindtest only if Autoconf would.
|
||||
CMake: use ${CMAKE_INSTALL_SBINDIR} rather than just sbin.
|
||||
CMake: use NUL: as the null device on Windows.
|
||||
autoconf: fix typo in test of macOS version.
|
||||
Makefile.in: Add two missing files in EXTRA_DIST.
|
||||
autotools, cmake: provide an rpath option if necessary.
|
||||
configure: get rid of the attempt to auto-run PKG_PROG_PKG_CONFIG.
|
||||
configure: use PKG_CHECK_MODULES to run pkg-config.
|
||||
Documentation:
|
||||
Add README.solaris.md.
|
||||
Add SCTP to pcap-filter(7).
|
||||
Note that = and == are the same operator in filters (issue #1044).
|
||||
Update INSTALL.md, README.md, and README.solaris.md.
|
||||
Update and clean up CONTRIBUTING.md.
|
||||
Trim documentation of support for now-dead UN*Xe and older
|
||||
versions of other UN*Xes.
|
||||
Move the "how to allocate a LINKTYPE_/DLT_ value" documentation to
|
||||
the web site.
|
||||
Clean up man pages.
|
||||
Move README.capture-module to the web site.
|
||||
Improve some protocol details in pcap-filter(7).
|
||||
Refine "relop" notes in pcap-filter(7).
|
||||
In pcap-filter(7) "domain" is an id.
|
||||
Discuss backward compatibility in pcap-filter(7).
|
||||
Other improvements to pcap-filter(7).
|
||||
Document pcap_breakloop(3PCAP) interaction with threads better.
|
||||
Document PCAP_ERROR_NOT_ACTIVATED for more routines.
|
||||
|
||||
Wednesday, June 9, 2021:
|
||||
Summary for 1.10.1 libpcap release:
|
||||
Packet filtering:
|
||||
Fix "type XXX subtype YYY" giving a parse error
|
||||
Source code:
|
||||
Add PCAP_AVAILABLE_1_11.
|
||||
Building and testing:
|
||||
Rename struct bpf_aux_data to avoid NetBSD compile errors
|
||||
Squelch some compiler warnings
|
||||
Squelch some Bison warnings
|
||||
Fix cross-builds with older kernels lacking BPF_MOD and BPF_XOR
|
||||
Fix Bison detection for minor version 0.
|
||||
Fix parallel build with FreeBSD make.
|
||||
Get DLT_MATCHING_MAX right in gencode.c on NetBSD.
|
||||
Define timeradd() and timersub() if necessary.
|
||||
Fix Cygwin/MSYS target directories.
|
||||
Fix symlinking with DESTDIR.
|
||||
Fix generation of libpcap.pc with CMake when not building a shared
|
||||
library.
|
||||
Check for Arm64 as well as x86-64 when looking for packet.lib on
|
||||
Windows.
|
||||
Documentation:
|
||||
Refine Markdown in README.md.
|
||||
Improve the description of portrange in filters.
|
||||
README.linux.md isn't Markdown, rename it just README.linux.
|
||||
pcapng:
|
||||
Support reading version 1.2, which some writers produce, and which
|
||||
is the same as 1.0 (some new block types were added, but
|
||||
that's not sufficient reason to bump the minor version number,
|
||||
as code that understands those new block types can handle them
|
||||
in a 1.0 file)
|
||||
Linux:
|
||||
Drop support for text-mode USB captures, as we require a 2.6.27
|
||||
or later kernel (credit to Chaoyuan Peng for noting the
|
||||
sscanf vulnerabilities in the text-mode code that got me to
|
||||
realize that we didn't need this code any more)
|
||||
Bluetooth: fix non-blocking mode.
|
||||
Don't assume that all compilers used to build for Linux support
|
||||
the __atomic builtins
|
||||
Windows:
|
||||
Add more information in "interface disappeared" error messages, in
|
||||
the hopes of trying to figure out the cause.
|
||||
Treat ERROR_DEVICE_REMOVED as "device was removed".
|
||||
Indicate in the error message which "device was removed" error
|
||||
occurred.
|
||||
Report the Windows error status if PacketSendPacket() fails.
|
||||
Use %lu for ULONGs in error message formats.
|
||||
Don't treat the inability to find airpcap.dll as an error.
|
||||
Ignore spurious error reports by Microsoft Surface mobile
|
||||
telephony modem driver
|
||||
rpcap:
|
||||
Clean up error checking and error messages for server address
|
||||
lookup.
|
||||
|
||||
Tuesday, December 29, 2020
|
||||
Summary for 1.10.0 libpcap release
|
||||
Add support for capturing on DPDK devices
|
||||
Label most APIs by the first release in which they're available
|
||||
Fix some memory leaks, including in pcap_compile()
|
||||
Add pcap_datalink_val_to_description_or_dlt()
|
||||
Handle the pcap private data in a fashion that makes fewer
|
||||
assumptions about memory layouts (might fix GitHub issue #940
|
||||
on ARM)
|
||||
Fix some thread safety issues
|
||||
pcap_findalldevs(): don't sort interfaces by unit number
|
||||
Always return a list of supported time-stamp types, even if only
|
||||
host time stamps are supported
|
||||
Increase the maximum snaplen for LINKTYPE_USBPCAP/DLT_USBPCAP
|
||||
Report the DLT description in error messages
|
||||
Add pcap_init() for first-time initialization and global option
|
||||
setting; it's not required, but may be used
|
||||
Remove (unused) SITA support
|
||||
Capture file reading:
|
||||
Correctly handle pcapng captures with more than one IDB with a
|
||||
snspshot length greater than the supported maximum
|
||||
Capture file writing:
|
||||
Create the file in pcap_dump_open_append() if it doesn't exist
|
||||
Packet filtering:
|
||||
Fix "unknown ether proto 'aarp'"
|
||||
Add a new filter "ifindex" for DLT_LINUX_SLL2 files on all
|
||||
platforms and live Linux captures
|
||||
Add a hack to the optimizer to try to catch certain optimizer
|
||||
loops (should prevent GitHub issue #112)
|
||||
Show special Linux BPF offsets symbolically in bpf_image() and
|
||||
bpf_dump()
|
||||
Added support for ICMPv6 types 1-4 as tokens with names
|
||||
Remove undocumented and rather old "ether proto" protocols
|
||||
Catch invalid IPv4 addresses in filters
|
||||
Don't assume ARM supports unaligned accesses
|
||||
Security and other issues found by analysis:
|
||||
Fix various security issues reported by Charles Smith at Tangible
|
||||
Security
|
||||
Fix various security issues reported by Include Security
|
||||
Fix some issues found by cppcheck.
|
||||
Add some overflow checks in the optimizer
|
||||
rpcap:
|
||||
Support rpcap-over-TLS
|
||||
Redo protocol version negotiation to avoid problems with old
|
||||
servers (it still works with servers using the old negotiation,
|
||||
as well as servers not supporting negotiation)
|
||||
Error handling cleanups
|
||||
Add some new authentication libpcap error codes for specific
|
||||
errors
|
||||
Fix some inetd issues in rpcapd
|
||||
Fix rpcapd core dumps with invalid configuration file
|
||||
On UN*X, don't have rpcapd tell the client why authentication
|
||||
failed, so a brute-force attacker can't distinguish between
|
||||
"unknown user name" and "known user name, wrong password"
|
||||
Allow rpcapd to rebind more rapidly (GitHub issue #765)
|
||||
Documentation:
|
||||
Improve man pages, including adding backward compatibility notes
|
||||
Building and testing:
|
||||
Require, and assume, some level of C99 support in the C compiler
|
||||
Require Visual Studio 2015 or later if using Visual Studio
|
||||
Fix configure script issues, including with libnl on Linux
|
||||
Fix CMake issues
|
||||
Squelch complaints from Bison about "%define api.pure" being
|
||||
deprecated
|
||||
Fix compilation of pcap-tc.c
|
||||
Linux:
|
||||
Require PF_PACKET support, and kernel 2.6.27 or later
|
||||
Handle systems without AF_INET or AF_UNIX socket support
|
||||
Get rid of Wireless Extensions for turning monitor mode on
|
||||
Proper memory sync for PACKET_MMAP (may prevent GitHub issue
|
||||
#898)
|
||||
Drop support for libnl 1 and 2.
|
||||
Return error on interface going away, but not if it just went
|
||||
down but is still present
|
||||
Set socket protocol only after packet ring configured,
|
||||
reducing bogus packet drop reports
|
||||
Get ifdrop stats from sysfs.
|
||||
When adjusting BPF programs, do not subtract the
|
||||
SLL[2]_HDR_LEN if the location is negative (special metadata
|
||||
offset), to preserve references to metadata; see
|
||||
https://github.com/the-tcpdump-group/tcpdump/issues/480#issuecomment-486827278
|
||||
Report a warning for unknown ARPHRD types
|
||||
Have pcap_breakloop() forcibly break out of a sleeping
|
||||
capture loop
|
||||
Add support for DSA data link types
|
||||
For raw USB bus capture, use the snapshot length to set the
|
||||
buffer size, and set the len field to reflect the length
|
||||
in the URB (GitHub issue #808)
|
||||
With a timeout of zero, wait indefinitely
|
||||
Clean up support for some non-GNU libc C libraries
|
||||
Add DLT_LINUX_SLL2 for cooked-mode captures
|
||||
Probe CONFIGURATION descriptor of connected USB devices
|
||||
Treat EPERM on ethtool ioctls as meaning "not supported", as
|
||||
permissions checks are done before checking whether the
|
||||
ioctl is supported at all
|
||||
macOS:
|
||||
Cope with getting EPWROFF from SIOCGIFMEDIA
|
||||
Treat EPERM on SIOCGIFMEDIA as meaning "not supported", as
|
||||
permissions checks are done before checking whether the
|
||||
ioctl is supported at all
|
||||
Treat ENXIO when reading packets as meaning "the interface
|
||||
was removed"
|
||||
Report "the interface disappeared", not "the interface went
|
||||
down", if the interface was removed during a capture
|
||||
FreeBSD:
|
||||
Treat ENXIO as meaning "the interface was removed"
|
||||
Report "the interface disappeared", not "the interface went
|
||||
down", if the interface was removed during a capture
|
||||
NetBSD:
|
||||
Treat ENXIO as meaning "the interface was removed"
|
||||
Report "the interface disappeared", not "the interface went
|
||||
down", if the interface was removed during a capture
|
||||
OpenBSD:
|
||||
Treat EIO as meaning "the interface was removed"
|
||||
Report "the interface disappeared", not "the interface went
|
||||
down", if the interface was removed during a capture
|
||||
DragonFly BSD:
|
||||
Treat ENXIO as meaning "the interface was removed"
|
||||
Report "the interface disappeared", not "the interface went
|
||||
down", if the interface was removed during a capture
|
||||
Solaris:
|
||||
Treat ENXIO as meaning "the interface was removed"
|
||||
Report "the interface disappeared", not "the interface went
|
||||
down", if the interface was removed during a capture
|
||||
AIX:
|
||||
Fix loading of BPF kernel extension
|
||||
Treat ENXIO as meaning "the interface was removed"
|
||||
Report "the interface disappeared", not "the interface went
|
||||
down", if the interface was removed during a capture
|
||||
Windows:
|
||||
Make the snapshot length work even if pcap_setfilter()
|
||||
isn't called
|
||||
Fix compilation on Cygwin/MSYS
|
||||
Add pcap_handle(), and deprecate pcap_fileno()
|
||||
Report PCAP_ERROR_NO_SUCH_DEVICE for a non-existent device
|
||||
Return an appropriate error message for device removed or
|
||||
device unusable due to a suspend/resume
|
||||
Report a warning for unknown NdisMedium types
|
||||
Have pcap_breakloop() forcibly break out of a sleeping
|
||||
capture loop
|
||||
Clean up building DLL
|
||||
Handle CRT mismatch for pcap_dump_fopen()
|
||||
Map NdisMediumWirelessWan to DLT_RAW
|
||||
Add AirPcap support in a module, rather than using
|
||||
WinPcap/Npcap's support for it
|
||||
Report the system error for PacketSetHwFilter() failures
|
||||
Add support for getting and setting packet time stamp types
|
||||
with Npcap
|
||||
Have pcap_init() allow selecting whether the API should use
|
||||
local code page strings or UTF-8 strings (including error
|
||||
messages)
|
||||
Haiku:
|
||||
Add capture support
|
||||
|
||||
Sunday, July 22, 2018
|
||||
Summary for 1.9.1 libpcap release
|
||||
Mention pcap_get_required_select_timeout() in the main pcap man page
|
||||
|
@ -26,7 +455,7 @@ Sunday, July 22, 2018
|
|||
need to be
|
||||
Fix reading of capture statistics for Linux USB
|
||||
Fix packet size values for Linux USB packets (GitHub issue #808)
|
||||
Check only VID in VLAN test in filterss (GitHub issue #461)
|
||||
Check only VID in VLAN test in filters (GitHub issue #461)
|
||||
Fix pcap_list_datalinks on 802.11 devices on macOS
|
||||
Fix overflows with very large snapshot length in pcap file
|
||||
Improve parsing of rpcapd configuration file (GitHub issue #767)
|
||||
|
@ -67,7 +496,6 @@ Sunday, July 22, 2018
|
|||
Boost the TPACKET_V3 timeout to the maximum if a timeout of 0 was
|
||||
specified
|
||||
Five CVE-2019-15161, CVE-2019-15162, CVE-2019-15163, CVE-2019-15164, CVE-2019-15165
|
||||
Fixes for CVE-2018-16301, errors in pcapng reading.
|
||||
PCAPNG reader applies some sanity checks before doing malloc().
|
||||
|
||||
Sunday, June 24, 2018, by mcr@sandelman.ca
|
||||
|
@ -75,7 +503,7 @@ Sunday, June 24, 2018, by mcr@sandelman.ca
|
|||
Added testing system to libpcap, independent of tcpdump
|
||||
Changes to how pcap_t is activated
|
||||
Adding support for Large stream buffers on Endace DAG cards
|
||||
Changes to BSD 3-clause license to 2-clause licence
|
||||
Changes to BSD 3-clause license to 2-clause license
|
||||
Additions to TCP header parsing, per RFC3168
|
||||
Add CMake build process (extensive number of changes)
|
||||
Assign a value for OpenBSD DLT_OPENFLOW.
|
||||
|
@ -93,7 +521,7 @@ Sunday, June 24, 2018, by mcr@sandelman.ca
|
|||
Make VLAN filter handle both metadata and inline tags
|
||||
D-Bus captures can now be up to 128MB in size
|
||||
Added LORATAP DLT value
|
||||
Added DLT_VSOCK for http://qemu-project.org/Features/VirtioVsock
|
||||
Added DLT_VSOCK for https://qemu-project.org/Features/VirtioVsock
|
||||
probe_devices() fixes not to overrun buffer for name of device
|
||||
Add linux-specific pcap_set_protocol_linux() to allow specifying a specific capture protocol.
|
||||
RDMA sniffing support for pcap
|
||||
|
@ -275,7 +703,7 @@ Summary for 1.5.0 libpcap release
|
|||
than the mcr repository
|
||||
Checks added for malloc()/realloc()/etc. failures
|
||||
Fixed build on Solaris 11
|
||||
Support filtering filtering E1 SS7 traffic on MTP2 layer Annex A
|
||||
Support filtering E1 SS7 traffic on MTP2 layer Annex A
|
||||
Use "ln -s" to link man pages by default
|
||||
Add support for getting nanosecond-resolution time stamps when
|
||||
capturing and reading capture files
|
||||
|
@ -336,7 +764,7 @@ Summary for 1.3.0 libpcap release
|
|||
Friday December 9, 2011. guy@alum.mit.edu.
|
||||
Summary for 1.2.1 libpcap release
|
||||
Update README file.
|
||||
Fix typoes in README.linux file.
|
||||
Fix typos in README.linux file.
|
||||
Clean up some compiler warnings.
|
||||
Fix Linux compile problems and tests for ethtool.h.
|
||||
Treat Debian/kFreeBSD and GNU/Hurd as systems with GNU
|
||||
|
@ -369,7 +797,7 @@ Summary for 1.2 libpcap release
|
|||
Noted real nature of LINKTYPE_ARCNET.
|
||||
Add a link-layer type for DVB-CI.
|
||||
Fix configure-script discovery of VLAN acceleration support.
|
||||
see http://netoptimizer.blogspot.com/2010/09/tcpdump-vs-vlan-tags.html
|
||||
see https://netoptimizer.blogspot.com/2010/09/tcpdump-vs-vlan-tags.html
|
||||
Linux, HP-UX, AIX, NetBSD and OpenBSD compilation/conflict fixes.
|
||||
Protect against including AIX 5.x's <net/bpf.h> having been included.
|
||||
Add DLT_DBUS, for raw D-Bus messages.
|
||||
|
@ -568,7 +996,7 @@ Tue. September 19, 2006. ken@xelerance.com. Summary for 0.9.5 libpcap release
|
|||
beginning+link-layer
|
||||
Add DLT/LINKTYPE for carrying FRF.16 Multi-link Frame Relay
|
||||
Fix allocation of buffer for list of link-layer types
|
||||
Added a new DLT and LINKTYPE value for ARINC 653 Interpartition Communcation Messages
|
||||
Added a new DLT and LINKTYPE value for ARINC 653 Interpartition Communication 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.
|
||||
|
@ -682,7 +1110,7 @@ Tuesday January 9, 2001. guy@alum.mit.edu. Summary for 0.6 release
|
|||
|
||||
Header files fixed to allow use in C++ programs.
|
||||
|
||||
Removed dependancy on native headers for packet layout.
|
||||
Removed dependency on native headers for packet layout.
|
||||
Removed Linux specific headers that were shipped.
|
||||
|
||||
Security fixes: Strcpy replaced with strlcpy, sprintf replaced
|
||||
|
@ -820,7 +1248,7 @@ v0.3 Sat Nov 30 20:56:27 PST 1996
|
|||
|
||||
v0.2.1 Sun Jul 14 03:02:26 PDT 1996
|
||||
|
||||
- Fixes for HP-UX 10. Thanks in part to to Thomas Wolfram
|
||||
- Fixes for HP-UX 10. Thanks in part to Thomas Wolfram
|
||||
(wolf@prz.tu-berlin.de) and Rick Jones (raj@hpisrdq.cup.hp.com)
|
||||
|
||||
- Added support for SINIX. Thanks to Andrej Borsenkow
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -14,10 +14,10 @@ above), please navigate to https://github.com/the-tcpdump-group/libpcap/issues
|
|||
and check if the problem has already been reported. If it has not, please open
|
||||
a new issue and provide the following details:
|
||||
|
||||
* libpcap version (e.g. from tcpdump --version)
|
||||
* libpcap version (e.g. from `tcpdump --version`)
|
||||
* operating system name and version and any other details that may be relevant
|
||||
(uname -a, compiler name and version, CPU type etc.)
|
||||
* configure flags if any were used
|
||||
(`uname -a`, compiler name and version, CPU type etc.)
|
||||
* `configure` or `cmake` flags if any were used
|
||||
* statement of the problem
|
||||
* steps to reproduce
|
||||
|
||||
|
|
|
@ -3,29 +3,43 @@ This file lists people who have contributed to libpcap.
|
|||
The current maintainers (in alphabetical order):
|
||||
Denis Ovsienko <denis at ovsienko dot info>
|
||||
Francois-Xavier Le Bail <devel dot fx dot lebail at orange dot fr>
|
||||
Guy Harris <guy at alum dot mit dot edu>
|
||||
Guy Harris <gharris at sonic dot net>
|
||||
Michael Richardson <mcr at sandelman dot ottawa dot on dot ca>
|
||||
|
||||
Additional people who have contributed patches (in alphabetical order):
|
||||
Adrian Budau <adbudau at bitdefender dot com>
|
||||
Akos Vandra <axos88 at gmail dot com>
|
||||
Alan Bawden <Alan at LCS dot MIT dot EDU>
|
||||
Albert Chin <china at thewrittenword dot com>
|
||||
Alexander Galanin <al at galanin dot nnov dot ru>
|
||||
Alexander 'Leo' Bergolth <Leo dot Bergolth at wu-wien dot ac dot at>
|
||||
Alexey Kuznetsov <kuznet at ms2 dot inr dot ac dot ru>
|
||||
Alex Smith <44322503+MadAlexUK at users dot noreply dot github dot com>
|
||||
Alfredo Alvarez Fernandez <alfredoalvarezernandez at gmail dot com>
|
||||
Ali Abdulkadir <autostart dot ini at gmail dot com>
|
||||
Alon Bar-Lev <alonbl at sourceforge dot net>
|
||||
Anders Broman <anders dot broman at ericsson dot com>
|
||||
Andres Perera <andres dot p at zoho dot com>
|
||||
Andrew Brown <atatat at atatdot dot net>
|
||||
<andy-1 at sourceforge dot net>
|
||||
Ani Sinha <ani at aristanetworks dot com>
|
||||
Anthony Kirby <Anthony dot Kirby at nominet dot uk>
|
||||
Antti Kantee <pooka at netbsd dot org>
|
||||
Arien Vijn <arienvijn at sourceforge dot net>
|
||||
Arkadiusz Miskiewicz <misiek at pld dot org dot pl>
|
||||
Armando L. Caro Jr. <acaro at mail dot eecis dot udel dot edu>
|
||||
Assar Westerlund <assar at sics dot se>
|
||||
Atzm Watanabe <atzm at atzm dot org>
|
||||
Baptiste Peugnez <baptiste dot peugnez at cea dot fr>
|
||||
Baruch Siach <baruch at tkos dot co dot il>
|
||||
Bill Parker <wp02855 at gmail dot com>
|
||||
Biswapriyo Nath <nathbappai at gmail dot com>
|
||||
blazeable <blazeable at blazeable dot eu>
|
||||
bleader <bleader at ratonland dot org>
|
||||
Brent Cook <brent at boundary dot com>
|
||||
Brian Ginsbach <ginsbach at cray dot com>
|
||||
B. Scott Michel <scooter dot phd at gmail dot com>
|
||||
Cedric Cellier <rixed at happyleptic dot org>
|
||||
Charles M. Hannum <mycroft at netbsd dot org>
|
||||
Chris G. Demetriou <cgd at netbsd dot org>
|
||||
Chris Lightfoot <cwrl at users dot sourceforge dot net>
|
||||
|
@ -34,24 +48,38 @@ Additional people who have contributed patches (in alphabetical order):
|
|||
Christian Bell <csbell at myri dot com>
|
||||
Christian Peron <csjp at freebsd dot org>
|
||||
Christian Svensson <blue at cmd dot nu>
|
||||
Christopher K Lee <christopher dot lee at cspi dot com>
|
||||
Daniel Borkmann <dborkman at redhat dot com>
|
||||
Daniele Orlandi <daniele at orlandi dot com>
|
||||
Daniel Lublin <daniel at lublin dot se>
|
||||
Daniel Miller <dmiller at nmap dot org>
|
||||
Dario Lombardo <lomato at gmail dot com>
|
||||
Darren Lim <darren dot lim at endace dot com>
|
||||
Darren Reed <darrenr at sun dot com>
|
||||
Dave Barach <dave at barachs dot net>
|
||||
David Clark <david dot clark at datasoft dot com>
|
||||
David Kaelbling <drk at sgi dot com>
|
||||
David Karoly <david dot karoly at outlook dot com>
|
||||
David Ward <david dot ward at ll dot mit dot edu>
|
||||
David Young <dyoung at ojctech dot com>
|
||||
Dean Gaudet <dean at arctic dot org>
|
||||
dhruv <rsrivat at sourceforge dot net>
|
||||
Dmytro Ovdiienko <dmitriy dot ovdienko at gmail dot com>
|
||||
Don Ebright <Don dot Ebright at compuware dot com>
|
||||
Dug Song <dugsong at monkey dot org>
|
||||
Dustin Spicuzza <dustin at virtualroadside dot com>
|
||||
dzejarczech <dzejarczech at sourceforge dot net>
|
||||
Edward Sheldrake <ejs1920 at sourceforge dot net>
|
||||
Eli Schwartz <eschwartz93 at gmail dot com>
|
||||
Eric Anderson <anderse at hpl dot hp dot com>
|
||||
Erik de Castro Lopo <erik dot de dot castro dot lopo at sensorynetworks dot com>
|
||||
Fedor Sakharov <fedor dot sakharov at gmail dot com>
|
||||
Felix Janda <felix dot janda at posteo dot de>
|
||||
Felix Obenhuber <felix at obenhuber dot de>
|
||||
fghzxm <fghzxm at outlook dot com>
|
||||
Florent Drouin <Florent dot Drouin at alcatel-lucent dot fr>
|
||||
Florian Fainelli <f dot fainelli at gmail dot com>
|
||||
François Revol <revol at free dot fr>
|
||||
Franz Schaefer <schaefer at mond dot at>
|
||||
frederich <frederich at sourceforge dot net>
|
||||
Fulko Hew <fulko dot hew at gmail dot com>
|
||||
|
@ -59,6 +87,7 @@ Additional people who have contributed patches (in alphabetical order):
|
|||
Gabor Tatarka <gabor dot tatarka at ericsson dot com>
|
||||
Garrett Cooper <yaberauneya at sourceforge dot net>
|
||||
George Neville-Neil <gnn at freebsd dot org>
|
||||
Gerald Combs <gerald at zing dot org>
|
||||
Gerard Garcia <nouboh at gmail dot com>
|
||||
Gianluca Varenni <gianluca dot varenni at gmail dot com>
|
||||
Gilbert Hoyek <gil_hoyek at hotmail dot com>
|
||||
|
@ -71,83 +100,115 @@ Additional people who have contributed patches (in alphabetical order):
|
|||
Gustavo Zacarias <gustavo at zacarias dot com dot ar>
|
||||
Hagen Paul Pfeifer <hagen at jauu dot net>
|
||||
Henri Doreau <hdoreau at sourceforge dot net>
|
||||
Hiroaki KAWAI <kawai at stratosphere dot co dot jp>
|
||||
Hyung Sik Yoon <hsyn at kr dot ibm dot com>
|
||||
Igor Khristophorov <igor at atdot dot org>
|
||||
Jakub Sitnicki <jsitnicki at gmail dot com>
|
||||
Jakub Zawadzki <darkjames at darkjames dot pl>
|
||||
James Ko <jck at exegin dot com>
|
||||
Jan-Philip Velders <jpv at veldersjes dot net>
|
||||
Jason R. Thorpe <thorpej at netbsd dot org>
|
||||
Javier Achirica <achirica at ttd dot net>
|
||||
Jean-Louis Charton <Jean-Louis dot CHARTON at oikialog dot com>
|
||||
Jean Tourrilhes <jt at hpl dot hp dot com>
|
||||
Jefferson Ogata <jogata at nodc dot noaa dot gov>
|
||||
Jerome Duval <jerome dot duval at gmail dot com>
|
||||
Jesper Dangaard Brouer <hawk at comx dot dk>
|
||||
Jesper Peterson <jesper at endace dot com>
|
||||
Jesse Gross <jesse at nicira dot com>
|
||||
JHA <jon dot anderson at oracle dot com>
|
||||
jingyu yang <jingleyang at users dot noreply dot github dot com>
|
||||
Jiri Slaby <jirislaby at gmail dot com>
|
||||
João Valverde <joao dot valverde at tecnico dot ulisboa dot pt>
|
||||
Joerg Mayer <jmayer at loplof dot de>
|
||||
John Bankier <jbankier at rainfinity dot com>
|
||||
Jon Lindgren <jonl at yubyub dot net>
|
||||
Jon Smirl <jonsmirl at gmail dot com>
|
||||
Jorge Boncompte [DTI2] <jorge at dti2 dot net>
|
||||
jromanr <jromanr at hotmail dot com>
|
||||
Juergen Schoenwaelder <schoenw at ibr dot cs dot tu-bs dot de>
|
||||
Julien Moutinho <julm at savines dot alpes dot fr dot eu dot org>
|
||||
Jung-uk Kim <jkim at FreeBSD dot org>
|
||||
Kazushi Sugyo <sugyo at pb dot jp dot nec dot com>
|
||||
Kevin Boulain <kevin dot boulain at securactive dot net>
|
||||
Klaus Klein <kleink at netbsd dot org>
|
||||
Koryn Grant <koryn at endace dot com>
|
||||
Kris Katterjohn <katterjohn at gmail dot com>
|
||||
Krzysztof Halasa <khc at pm dot waw dot pl>
|
||||
Lennert Buytenhek <buytenh at wantstofly dot org>
|
||||
Li kunyu <kunyu at nfschina dot com>
|
||||
lixiaoyan <lixiaoyan at google dot com>
|
||||
Lorenzo Cavallaro <sullivan at sikurezza dot org>
|
||||
Loris Degioanni <loris at netgroup-serv dot polito dot it>
|
||||
Love Hörnquist-Åstrand <lha at stacken dot kth dot se>
|
||||
Luis MartinGarcia <luis dot mgarc at gmail dot com>
|
||||
lxy <391861737 at qq dot com>
|
||||
Maciej W. Rozycki <macro at ds2 dot pg dot gda dot pl>
|
||||
Mansour Behabadi <mansour at oxplot dot com>
|
||||
Marcus Felipe Pereira <marcus at task dot com dot br>
|
||||
Mario J. Rugiero <mrugiero at gmail dot com>
|
||||
Mark C. Brown <mbrown at hp dot com>
|
||||
Mark Johnston <markjdb at gmail dot com>
|
||||
Mark Marshall <mark dot marshall at omicronenergy dot com>
|
||||
Mark Pizzolato <List-tcpdump-workers at subscriptions dot pizzolato dot net>
|
||||
Markus Mayer <markus_mayer at sourceforge dot net>
|
||||
Martin Husemann <martin at netbsd dot org>
|
||||
Márton Németh <nm127 at freemail dot hu>
|
||||
Matt Eaton <agnosticdev at gmail dot com>
|
||||
Matthew Luckie <mjl at luckie dot org dot nz>
|
||||
Matthias Hannig <matthias at hannig dot cc>
|
||||
Matwey V. Kornilov <matwey dot kornilov at gmail dot com>
|
||||
maxice8 <thinkabit dot ukim at gmail dot com>
|
||||
Max Laier <max at love2party dot net>
|
||||
Michal Kubecek <mkubecek at suse dot cz>
|
||||
Michal Labedzki <michal dot labedzki at tieto dot com>
|
||||
Michal Ruprich <michalruprich at gmail dot com>
|
||||
Michal Sekletar <msekleta at redhat dot com>
|
||||
Mike Frysinger <vapier at gmail dot com>
|
||||
Mike Kershaw <dragorn at kismetwireless dot net>
|
||||
Mike Wiacek <mike at iroot dot net>
|
||||
Milosz Kaniewski <milosz dot kaniewski at gmail dot com>
|
||||
Miroslav Lichvar <mlichvar at redhat dot com>
|
||||
Monroe Williams <monroe at pobox dot com>
|
||||
Myricom Help <myri at users dot noreply dot github dot com>
|
||||
Nan Xiao <nan at chinadtrace dot org>
|
||||
nic-kaczinsky <68271784+nic-kaczinsky at users dot noreply dot github dot com>
|
||||
Nick Kelsey <nickk at silicondust dot com>
|
||||
Nicolas Dade <ndade at nsd dot dyndns dot org>
|
||||
Niko Delarich <niko dot delarich at gmail dot com>
|
||||
N. Leiten <nleiten at sourceforge dot net>
|
||||
nnposter <nnposter at users dot noreply dot github dot com>
|
||||
<nvercamm at sourceforge dot net>
|
||||
Octavian Cerna <tavy at ylabs dot com>
|
||||
Olaf Kirch <okir at caldera dot de>
|
||||
Ollie Wild <aaw at users dot sourceforge dot net>
|
||||
Ondřej Hošek <ondra dot hosek at gmail dot com>
|
||||
Onno van der Linden <onno at simplex dot nl>
|
||||
Orgad Shaneh <orgad dot shaneh at audiocodes dot com>
|
||||
Ørjan Malde <red at foxi dot me>
|
||||
Paolo Abeni <pabeni at redhat dot com>
|
||||
Patrick Marie <mycroft at virgaria dot org>
|
||||
Patrick McHardy <kaber at trash not net>
|
||||
Patrick McHardy <kaber at trash dot net>
|
||||
Paul Mundt <lethal at linux-sh dot org>
|
||||
Pavel Kankovsky <kan at dcit dot cz>
|
||||
Pawel Brzezinski <pawel dot brzezinski at harman dot com>
|
||||
Pawel Pokrywka <publicpp at gmail dot com>
|
||||
Peter Fales <peter at fales-lorenz dot net>
|
||||
Peter Jeremy <peter dot jeremy at alcatel dot com dot au>
|
||||
Peter Volkov <pva at gentoo dot org>
|
||||
Petr Vorel <pvorel at suse dot cz>
|
||||
Philippe Antoine <contact at catenacyber dot fr>
|
||||
Phil Wood <cpw at lanl dot gov>
|
||||
Rafal Maszkowski <rzm at icm dot edu dot pl>
|
||||
ramin <lordrasmus at gmail dot com>
|
||||
<rcb-isis at users dot sourceforge dot net>
|
||||
Richard Stearn <richard at rns-stearn dot demon dot co dot uk>
|
||||
Rick Jones <raj at cup dot hp dot com>
|
||||
Robert Edmonds <stu-42 at sourceforge dot net>
|
||||
Roberto Mariani <jelot-tcpdump at jelot dot it>
|
||||
Rongxi Li <rongxi dot li at chaitin dot com>
|
||||
Roland Dreier <roland at purestorage dot com>
|
||||
Romain Francoise <rfrancoise at debian dot org>
|
||||
Rongxi Li <rongxi dot li at chaitin dot com>
|
||||
Sagun Shakya <sagun dot shakya at sun dot com>
|
||||
Scott Barron <sb125499 at ohiou dot edu>
|
||||
Scott Gifford <sgifford at tir dot com>
|
||||
|
@ -155,23 +216,39 @@ Additional people who have contributed patches (in alphabetical order):
|
|||
Sebastian Krahmer <krahmer at cs dot uni-potsdam dot de>
|
||||
Sebastien Roy <Sebastien dot Roy at Sun dot COM>
|
||||
Sepherosa Ziehau <sepherosa at gmail dot com>
|
||||
Shane Kerr <shane at time-travellers dot org>
|
||||
Shaun Clowes <delius at progsoc dot uts dot edu dot au>
|
||||
solofox <wensg100 at sina dot com>
|
||||
Solomon Peachy <pizza at shaftnet dot org>
|
||||
Stefan Hudson <hudson at mbay dot net>
|
||||
Stephen Donnelly <stephen at endace dot com>
|
||||
Steve Karg <skarg at users dot sourceforge dot net>
|
||||
stubbfel <stubbfel at gmail dot com>
|
||||
Takashi Yamamoto <yamt at mwd dot biglobe dot ne dot jp>
|
||||
Tanaka Shin-ya <zstanaka at archer dot livedoor dot com>
|
||||
Thomas Habets <habets at google dot com>
|
||||
Thomas Petazzoni <thomas dot petazzoni at free-electrons dot com>
|
||||
Tobias Poschwatta <posch at sourceforge dot net>
|
||||
Tomasz Moń <desowin at gmail dot com>
|
||||
Tommy Beadle <tbeadle at arbor dot net>
|
||||
Tony Li <tli at procket dot com>
|
||||
Torsten Landschoff <torsten at debian dot org>
|
||||
Tymoteusz Blazejczyk <tymoteusz dot blazejczyk at intel dot com>
|
||||
Uns Lider <unslider at miranda dot org>
|
||||
Uwe Girlich <Uwe dot Girlich at philosys dot de>
|
||||
Vitaly Lavrov <vel21ripn at gmail dot com>
|
||||
Vivien Didelot <vivien dot didelot at gmail dot com>
|
||||
Vladimir Gladkov <vovkos at gmail dot com>
|
||||
Vladimir Marek <vlmarek at volny dot cz>
|
||||
Walter Schell <walterschell at users dot noreply dot github dot com>
|
||||
Wesley Shields <wxs at FreeBSD dot org>
|
||||
Xianjie Zhang <xzhang at cup dot hp dot com>
|
||||
Xin Li <delphij at FreeBSD dot org>
|
||||
Xue Jiang Qing <xuejianqing at star-net dot cn>
|
||||
Yang Luo <hsluoyz at qq dot com>
|
||||
Yen Yen Lim
|
||||
Yoann Vandoorselaere <yoann at prelude-ids dot org>
|
||||
Yogesh Prasad <yogesh dot prasad at rockwellcollins dot com>
|
||||
Yvan Vanhullebus <vanhu at sourceforge dot net>
|
||||
|
||||
The original LBL crew:
|
||||
|
|
|
@ -1,105 +1,120 @@
|
|||
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
|
||||
goes well you can su to root and run "make install". However, you need
|
||||
not install libpcap if you just want to build tcpdump; just make sure
|
||||
the tcpdump and libpcap directory trees have the same parent
|
||||
directory.
|
||||
# libpcap installation notes
|
||||
Libpcap can be built either with the configure script and `make`, or
|
||||
with CMake and any build system supported by CMake.
|
||||
|
||||
To build libpcap with the configure script and `make`:
|
||||
|
||||
* Run `./configure` (a shell script). The configure script will
|
||||
determine your system attributes and generate an appropriate `Makefile`
|
||||
from `Makefile.in`. The configure script has a number of options to
|
||||
control the configuration of libpcap; `./configure --help`` will show
|
||||
them.
|
||||
|
||||
* Next, run `make`. If everything goes well, you can
|
||||
`su` to root and run `make install`. However, you need not install
|
||||
libpcap if you just want to build tcpdump; just make sure the tcpdump
|
||||
and libpcap directory trees have the same parent directory.
|
||||
|
||||
To build libpcap with CMake and the build system of your choice, from
|
||||
the command line:
|
||||
|
||||
* Create a build directory into which CMake will put the build files it
|
||||
generates; CMake does not work as well with builds done in the source
|
||||
code directory as does the configure script. The build directory may be
|
||||
created as a subdirectory of the source directory or as a directory
|
||||
outside the source directory.
|
||||
|
||||
* Change to the build directory and run CMake with the path from the
|
||||
build directory to the source directory as an argument. The `-G` flag
|
||||
can be used to select the CMake "generator" appropriate for the build
|
||||
system you're using; various `-D` flags can be used to control the
|
||||
configuration of libpcap.
|
||||
|
||||
* Run the build tool. If everything goes well, you can `su` to root and
|
||||
run the build tool with the `install` target. Building tcpdump from a
|
||||
libpcap in a build directory is not supported.
|
||||
|
||||
An `uninstall` target is supported with both `./configure` and CMake.
|
||||
|
||||
***DO NOT*** run the build as root; there is no need to do so, running
|
||||
anything as root that doesn't need to be run as root increases the risk
|
||||
of damaging your system, and running the build as root will put files in
|
||||
the build directory that are owned by root and that probably cannot be
|
||||
overwritten, removed, or replaced except by root, which could cause
|
||||
permission errors in subsequent builds.
|
||||
|
||||
If configure says:
|
||||
|
||||
configure: warning: cannot determine packet capture interface
|
||||
configure: warning: (see INSTALL for more info)
|
||||
configure: warning: (see INSTALL.md file for more info)
|
||||
|
||||
or CMake says:
|
||||
|
||||
cannot determine packet capture interface
|
||||
|
||||
(see the INSTALL.md file for more info)
|
||||
|
||||
then your system either does not support packet capture or your system
|
||||
does support packet capture but libpcap does not support that
|
||||
particular type. (If you have HP-UX, see below.) If your system uses a
|
||||
packet capture not supported by libpcap, please send us patches; don't
|
||||
forget to include an autoconf fragment suitable for use in
|
||||
configure.ac.
|
||||
`configure.ac`.
|
||||
|
||||
It is possible to override the default packet capture type, although
|
||||
the circumstance where this works are limited. For example if you have
|
||||
installed bpf under SunOS 4 and wish to build a snit libpcap:
|
||||
It is possible to override the default packet capture type with the
|
||||
`--with-pcap`` option to `./configure` or the `-DPCAP_TYPE` option to
|
||||
CMake, although the circumstances where this works are limited. One
|
||||
possible reason to do that would be to force a supported packet capture
|
||||
type in the case where the configure or CMake scripts fails to detect
|
||||
it.
|
||||
|
||||
./configure --with-pcap=snit
|
||||
|
||||
Another example is to force a supported packet capture type in the case
|
||||
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 generally available GNU C compiler (GCC).
|
||||
You will need a C99 compiler to build libpcap. The configure script
|
||||
will abort if your compiler is not C99 compliant. If this happens, use
|
||||
the generally available GNU C compiler (GCC) or Clang.
|
||||
|
||||
You will need either Flex 2.5.31 or later, or a version of Lex
|
||||
compatible with it (if any exist), to build libpcap. The configure
|
||||
script will abort if there isn't any such program. If you have an older
|
||||
version of Flex, or don't have a compatible version of Lex, the current
|
||||
version of flex is available at flex.sourceforge.net.
|
||||
script will abort if there isn't any such program; CMake fails if Flex
|
||||
or Lex cannot be found, but doesn't ensure that it's compatible with
|
||||
Flex 2.5.31 or later. If you have an older version of Flex, or don't
|
||||
have a compatible version of Lex, the current version of Flex is
|
||||
available [here](https://github.com/westes/flex).
|
||||
|
||||
You will need either Bison, Berkeley YACC, or a version of YACC
|
||||
compatible with them (if any exist), to build libpcap. The configure
|
||||
script will abort if there isn't any such program. If you don't have
|
||||
any such program, the current version of Bison can be found at
|
||||
http://ftp.gnu.org/gnu/bison/ and the current version of Berkeley YACC
|
||||
can be found at http://invisible-island.net/byacc/.
|
||||
script will abort if there isn't any such program; CMake fails if Bison
|
||||
or some form of YACC cannot be found, but doesn't ensure that it's
|
||||
compatible with Bison or Berkeley YACC. If you don't have any such
|
||||
program, the current version of Bison can be found
|
||||
[here](https://ftp.gnu.org/gnu/bison/) and the current version of
|
||||
Berkeley YACC can be found [here](https://invisible-island.net/byacc/).
|
||||
|
||||
Sometimes the stock C compiler does not interact well with Flex and
|
||||
Bison. The list of problems includes undefined references for alloca.
|
||||
Bison. The list of problems includes undefined references for alloca(3).
|
||||
You can get around this by installing GCC.
|
||||
|
||||
If you use Solaris, there is a bug with bufmod(7) that is fixed in
|
||||
Solaris 2.3.2 (aka SunOS 5.3.2). Setting a snapshot length with the
|
||||
broken bufmod(7) results in data be truncated from the FRONT of the
|
||||
packet instead of the end. The work around is to not set a snapshot
|
||||
length but this results in performance problems since the entire packet
|
||||
is copied to user space. If you must run an older version of Solaris,
|
||||
there is a patch available from Sun; ask for bugid 1149065. After
|
||||
installing the patch, use "setenv BUFMOD_FIXED" to enable use of
|
||||
bufmod(7). However, we recommend you run a more current release of
|
||||
Solaris.
|
||||
## Linux specifics
|
||||
On Linux, libpcap will not work if the kernel does not have the packet
|
||||
socket option enabled; see [this file](doc/README.linux) for more
|
||||
information.
|
||||
|
||||
## Solaris specifics
|
||||
If you use the SPARCompiler, you must be careful to not use the
|
||||
/usr/ucb/cc interface. If you do, you will get bogus warnings and
|
||||
perhaps errors. Either make sure your path has /opt/SUNWspro/bin
|
||||
before /usr/ucb or else:
|
||||
`/usr/ucb/cc` interface. If you do, you will get bogus warnings and
|
||||
perhaps errors. Either make sure your path has `/opt/SUNWspro/bin`
|
||||
before `/usr/ucb` or else:
|
||||
|
||||
setenv CC /opt/SUNWspro/bin/cc
|
||||
|
||||
before running configure. (You might have to do a "make distclean"
|
||||
if you already ran configure once).
|
||||
before running configure. (You might have to do a `make distclean`
|
||||
if you already ran `configure` once).
|
||||
|
||||
If you are trying to do packet capture with a FORE ATM card, you may or
|
||||
may not be able to. They usually only release their driver in object
|
||||
code so unless their driver supports packet capture, there's not much
|
||||
libpcap can do.
|
||||
|
||||
If you get an error like:
|
||||
|
||||
tcpdump: recv_ack: bind error 0x???
|
||||
|
||||
when using DLPI, look for the DL_ERROR_ACK error return values, usually
|
||||
in /usr/include/sys/dlpi.h, and find the corresponding value.
|
||||
|
||||
Under {DEC OSF/1, Digital UNIX, Tru64 UNIX}, packet capture must be
|
||||
enabled before it can be used. For instructions on how to enable packet
|
||||
filter support, see:
|
||||
|
||||
ftp://ftp.digital.com/pub/Digital/dec-faq/Digital-UNIX
|
||||
|
||||
Look for the "How do I configure the Berkeley Packet Filter and capture
|
||||
tcpdump traces?" item.
|
||||
|
||||
Once you enable packet filter support, your OSF system will support bpf
|
||||
natively.
|
||||
|
||||
Under Ultrix, packet capture must be enabled before it can be used. For
|
||||
instructions on how to enable packet filter support, see:
|
||||
|
||||
ftp://ftp.digital.com/pub/Digital/dec-faq/ultrix
|
||||
See [this file](doc/README.solaris.md) for more up to date
|
||||
Solaris-related information.
|
||||
|
||||
## HP-UX specifics
|
||||
If you use HP-UX, you must have at least version 9 and either the
|
||||
version of cc that supports ANSI C (cc -Aa) or else use the GNU C
|
||||
version of `cc` that supports C99 (`cc -AC99`) or else use the GNU C
|
||||
compiler. You must also buy the optional streams package. If you don't
|
||||
have:
|
||||
|
||||
|
@ -113,10 +128,10 @@ need to install the "9.X LAN and DLPI drivers cumulative" patch
|
|||
The DLPI streams package is standard starting with HP-UX 10.
|
||||
|
||||
The HP implementation of DLPI is a little bit eccentric. Unlike
|
||||
Solaris, you must attach /dev/dlpi instead of the specific /dev/*
|
||||
Solaris, you must attach `/dev/dlpi` instead of the specific `/dev/*`
|
||||
network pseudo device entry in order to capture packets. The PPA is
|
||||
based on the ifnet "index" number. Under HP-UX 9, it is necessary to
|
||||
read /dev/kmem and the kernel symbol file (/hp-ux). Under HP-UX 10,
|
||||
read `/dev/kmem` and the kernel symbol file (`/hp-ux`). Under HP-UX 10,
|
||||
DLPI can provide information for determining the PPA. It does not seem
|
||||
to be possible to trace the loopback interface. Unlike other DLPI
|
||||
implementations, PHYS implies MULTI and SAP and you get an error if you
|
||||
|
@ -137,216 +152,126 @@ doing
|
|||
|
||||
echo 'lanc_outbound_promisc_flag/W 1' | adb -w /stand/vmunix /dev/mem
|
||||
|
||||
You would have to arrange that this happen on reboots; the right way to
|
||||
You would have to arrange that this happens on reboots; the right way to
|
||||
do that would probably be to put it into an executable script file
|
||||
"/sbin/init.d/outbound_promisc" and making
|
||||
"/sbin/rc2.d/S350outbound_promisc" a symbolic link to that script.
|
||||
`/sbin/init.d/outbound_promisc` and making
|
||||
`/sbin/rc2.d/S350outbound_promisc` a symbolic link to that script.
|
||||
|
||||
Finally, testing shows that there can't be more than one simultaneous
|
||||
DLPI user per network interface.
|
||||
|
||||
If you use Linux, this version of libpcap is known to compile and run
|
||||
under Red Hat 4.0 with the 2.0.25 kernel. It may work with earlier 2.X
|
||||
versions but is guaranteed not to work with 1.X kernels. Running more
|
||||
than one libpcap program at a time, on a system with a 2.0.X kernel, can
|
||||
cause problems since promiscuous mode is implemented by twiddling the
|
||||
interface flags from the libpcap application; the packet capture
|
||||
mechanism in the 2.2 and later kernels doesn't have this problem. Also,
|
||||
packet timestamps aren't very good. This appears to be due to haphazard
|
||||
handling of the timestamp in the kernel.
|
||||
See [this file](doc/README.hpux) for more information specific to HP-UX.
|
||||
|
||||
Note well: there is rumoured to be a version of tcpdump floating around
|
||||
called 3.0.3 that includes libpcap and is supposed to support Linux.
|
||||
You should be advised that neither the Network Research Group at LBNL
|
||||
nor the Tcpdump Group ever generated a release with this version number.
|
||||
The LBNL Network Research Group notes with interest that a standard
|
||||
cracker trick to get people to install trojans is to distribute bogus
|
||||
packages that have a version number higher than the current release.
|
||||
They also noted with annoyance that 90% of the Linux related bug reports
|
||||
they got are due to changes made to unofficial versions of their page.
|
||||
If you are having trouble but aren't using a version that came from
|
||||
tcpdump.org, please try that before submitting a bug report!
|
||||
|
||||
On Linux, libpcap will not work if the kernel does not have the packet
|
||||
socket option enabled; see the README.linux file for information about
|
||||
this.
|
||||
|
||||
If you use AIX, you may not be able to build libpcap from this release.
|
||||
We do not have an AIX system in house so it's impossible for us to test
|
||||
AIX patches submitted to us. We are told that you must link against
|
||||
/lib/pse.exp, that you must use AIX cc or a GNU C compiler newer than
|
||||
2.7.2, and that you may need to run strload before running a libpcap
|
||||
application.
|
||||
|
||||
Read the README.aix file for information on installing libpcap and
|
||||
## AIX specifics
|
||||
See [this file](doc/README.aix) for information on installing libpcap and
|
||||
configuring your system to be able to support libpcap.
|
||||
|
||||
If you use NeXTSTEP, you will not be able to build libpcap from this
|
||||
release.
|
||||
## other specifics
|
||||
If you are trying to do packet capture with a FORE ATM card, you may or
|
||||
may not be able to. They usually only release their driver in object
|
||||
code so unless their driver supports packet capture, there's not much
|
||||
libpcap can do.
|
||||
|
||||
If you use SINIX, you should be able to build libpcap from this
|
||||
release. It is known to compile and run on SINIX-Y/N 5.42 with the C-DS
|
||||
V1.0 or V1.1 compiler. But note that in some releases of SINIX, yacc
|
||||
emits incorrect code; if grammar.y fails to compile, change every
|
||||
occurence of:
|
||||
If you get an error like:
|
||||
|
||||
#ifdef YYDEBUG
|
||||
tcpdump: recv_ack: bind error 0x???
|
||||
|
||||
to:
|
||||
#if YYDEBUG
|
||||
when using DLPI, look for the DL_ERROR_ACK error return values, usually
|
||||
in `/usr/include/sys/dlpi.h`, and find the corresponding value.
|
||||
|
||||
Another workaround is to use flex and bison.
|
||||
|
||||
If you use SCO, you might have trouble building libpcap from this
|
||||
release. We do not have a machine running SCO and have not had reports
|
||||
of anyone successfully building on it; the current release of libpcap
|
||||
does not compile on SCO OpenServer 5. Although SCO apparently supports
|
||||
DLPI to some extent, the DLPI in OpenServer 5 is very non-standard, and
|
||||
it appears that completely new code would need to be written to capture
|
||||
network traffic. SCO do not appear to provide tcpdump binaries for
|
||||
OpenServer 5 or OpenServer 6 as part of SCO Skunkware:
|
||||
|
||||
http://www.sco.com/skunkware/
|
||||
|
||||
If you use UnixWare, you might be able to build libpcap from this
|
||||
release, or you might not. We do not have a machine running UnixWare,
|
||||
so we have not tested it; however, SCO provide packages for libpcap
|
||||
0.6.2 and tcpdump 3.7.1 in the UnixWare 7/Open UNIX 8 part of SCO
|
||||
Skunkware, and the source package for libpcap 0.6.2 is not changed from
|
||||
the libpcap 0.6.2 source release, so this release of libpcap might also
|
||||
build without changes on UnixWare 7.
|
||||
|
||||
If linking tcpdump fails with "Undefined: _alloca" when using bison on
|
||||
a Sun4, your version of Bison is broken. In any case version 1.16 or
|
||||
higher is recommended (1.14 is known to cause problems 1.16 is known to
|
||||
work). Either pick up a current version from:
|
||||
|
||||
http://ftp.gnu.org/gnu/bison/
|
||||
|
||||
or hack around it by inserting the lines:
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define alloca __builtin_alloca
|
||||
#else
|
||||
#ifdef sparc
|
||||
#include <alloca.h>
|
||||
#else
|
||||
char *alloca ();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
right after the (100 line!) GNU license comment in bison.simple, remove
|
||||
grammar.[co] and fire up make again.
|
||||
|
||||
If you use SunOS 4, your kernel must support streams NIT. If you run a
|
||||
libpcap program and it dies with:
|
||||
|
||||
/dev/nit: No such device
|
||||
|
||||
You must add streams NIT support to your kernel configuration, run
|
||||
config and boot the new kernel.
|
||||
|
||||
FILES
|
||||
-----
|
||||
CHANGES - description of differences between releases
|
||||
ChmodBPF/* - macOS startup item to set ownership and permissions
|
||||
on /dev/bpf*
|
||||
CMakeLists.txt - CMake file
|
||||
CONTRIBUTING - guidelines for contributing
|
||||
CREDITS - people that have helped libpcap along
|
||||
INSTALL.md - this file
|
||||
LICENSE - the license under which tcpdump is distributed
|
||||
Makefile.in - compilation rules (input to the configure script)
|
||||
README.md - description of distribution
|
||||
doc/README.aix - notes on using libpcap on AIX
|
||||
doc/README.dag - notes on using libpcap to capture on Endace DAG devices
|
||||
doc/README.hpux - notes on using libpcap on HP-UX
|
||||
doc/README.linux.md - notes on using libpcap on Linux
|
||||
doc/README.macos - notes on using libpcap on macOS
|
||||
doc/README.septel - notes on using libpcap to capture on Intel/Septel devices
|
||||
doc/README.sita - notes on using libpcap to capture on SITA devices
|
||||
doc/README.tru64 - notes on using libpcap on Digital/Tru64 UNIX
|
||||
doc/README.Win32 - notes on using libpcap on Win32 systems (with Npcap)
|
||||
VERSION - version of this release
|
||||
acconfig.h - support for post-2.13 autoconf
|
||||
aclocal.m4 - autoconf macros
|
||||
arcnet.h - ARCNET definitions
|
||||
atmuni31.h - ATM Q.2931 definitions
|
||||
bpf_dump.c - BPF program printing routines
|
||||
bpf_filter.c - BPF filtering routines
|
||||
bpf_image.c - BPF disassembly routine
|
||||
config.guess - autoconf support
|
||||
config.h.in - autoconf input
|
||||
config.sub - autoconf support
|
||||
configure - configure script (run this first)
|
||||
configure.ac - configure script source
|
||||
dlpisubs.c - DLPI-related functions for pcap-dlpi.c and pcap-libdlpi.c
|
||||
dlpisubs.h - DLPI-related function declarations
|
||||
etherent.c - /etc/ethers support routines
|
||||
ethertype.h - Ethernet protocol types and names definitions
|
||||
fad-getad.c - pcap_findalldevs() for systems with getifaddrs()
|
||||
fad-gifc.c - pcap_findalldevs() for systems with only SIOCGIFLIST
|
||||
fad-glifc.c - pcap_findalldevs() for systems with SIOCGLIFCONF
|
||||
filtertest.c - test program for BPF compiler
|
||||
findalldevstest.c - test program for pcap_findalldevs()
|
||||
gencode.c - BPF code generation routines
|
||||
gencode.h - BPF code generation definitions
|
||||
grammar.y - filter string grammar
|
||||
ieee80211.h - 802.11 definitions
|
||||
install-sh - BSD style install script
|
||||
lbl/os-*.h - OS-dependent defines and prototypes
|
||||
llc.h - 802.2 LLC SAP definitions
|
||||
missing/* - replacements for missing library functions
|
||||
mkdep - construct Makefile dependency list
|
||||
msdos/* - drivers for MS-DOS capture support
|
||||
nametoaddr.c - hostname to address routines
|
||||
nlpid.h - OSI network layer protocol identifier definitions
|
||||
net - symlink to bpf/net
|
||||
optimize.c - BPF optimization routines
|
||||
pcap/bluetooth.h - public definition of DLT_BLUETOOTH_HCI_H4_WITH_PHDR header
|
||||
pcap/bpf.h - BPF definitions
|
||||
pcap/namedb.h - public libpcap name database definitions
|
||||
pcap/pcap.h - public libpcap definitions
|
||||
pcap/sll.h - public definition of DLT_LINUX_SLL header
|
||||
pcap/usb.h - public definition of DLT_USB header
|
||||
pcap-bpf.c - BSD Packet Filter support
|
||||
pcap-bpf.h - header for backwards compatibility
|
||||
pcap-bt-linux.c - Bluetooth capture support for Linux
|
||||
pcap-bt-linux.h - Bluetooth capture support for Linux
|
||||
pcap-dag.c - Endace DAG device capture support
|
||||
pcap-dag.h - Endace DAG device capture support
|
||||
pcap-dlpi.c - Data Link Provider Interface support
|
||||
pcap-dos.c - MS-DOS capture support
|
||||
pcap-dos.h - headers for MS-DOS capture support
|
||||
pcap-enet.c - enet support
|
||||
pcap-int.h - internal libpcap definitions
|
||||
pcap-libdlpi.c - Data Link Provider Interface support for systems with libdlpi
|
||||
pcap-linux.c - Linux packet socket support
|
||||
pcap-namedb.h - header for backwards compatibility
|
||||
pcap-nit.c - SunOS Network Interface Tap support
|
||||
pcap-nit.h - SunOS Network Interface Tap definitions
|
||||
pcap-npf.c - WinPcap capture support
|
||||
pcap-null.c - dummy monitor support (allows offline use of libpcap)
|
||||
pcap-pf.c - Ultrix and Digital/Tru64 UNIX Packet Filter support
|
||||
pcap-pf.h - Ultrix and Digital/Tru64 UNIX Packet Filter definitions
|
||||
pcap-septel.c - Intel/Septel device capture support
|
||||
pcap-septel.h - Intel/Septel device capture support
|
||||
pcap-sita.c - SITA device capture support
|
||||
pcap-sita.h - SITA device capture support
|
||||
pcap-sita.html - SITA device capture documentation
|
||||
pcap-stdinc.h - includes and #defines for compiling on Win32 systems
|
||||
pcap-snit.c - SunOS 4.x STREAMS-based Network Interface Tap support
|
||||
pcap-snoop.c - IRIX Snoop network monitoring support
|
||||
pcap-usb-linux.c - USB capture support for Linux
|
||||
pcap-usb-linux.h - USB capture support for Linux
|
||||
pcap.3pcap - manual entry for the library
|
||||
pcap.c - pcap utility routines
|
||||
pcap.h - header for backwards compatibility
|
||||
pcap_*.3pcap - manual entries for library functions
|
||||
pcap-filter.4 - manual entry for filter syntax
|
||||
pcap-linktype.4 - manual entry for link-layer header types
|
||||
ppp.h - Point to Point Protocol definitions
|
||||
savefile.c - offline support
|
||||
scanner.l - filter string scanner
|
||||
sunatmpos.h - definitions for SunATM capturing
|
||||
Win32 - headers and routines for building on Win32 systems
|
||||
## Description of files
|
||||
CHANGES - description of differences between releases
|
||||
ChmodBPF/* - macOS startup item to set ownership and permissions on /dev/bpf*
|
||||
CMakeLists.txt - CMake file
|
||||
CONTRIBUTING.md - guidelines for contributing
|
||||
CREDITS - people that have helped libpcap along
|
||||
INSTALL.md - this file
|
||||
LICENSE - the license under which tcpdump is distributed
|
||||
Makefile.in - compilation rules (input to the configure script)
|
||||
README.md - description of distribution
|
||||
doc/README.aix - notes on using libpcap on AIX
|
||||
doc/README.dag - notes on using libpcap to capture on Endace DAG devices
|
||||
doc/README.hpux - notes on using libpcap on HP-UX
|
||||
doc/README.linux - notes on using libpcap on Linux
|
||||
doc/README.macos - notes on using libpcap on macOS
|
||||
doc/README.septel - notes on using libpcap to capture on Intel/Septel devices
|
||||
doc/README.sita - notes on using libpcap to capture on SITA devices
|
||||
doc/README.solaris.md - notes on using libpcap on Solaris
|
||||
doc/README.Win32.md - notes on using libpcap on Win32 systems (with Npcap)
|
||||
VERSION - version of this release
|
||||
aclocal.m4 - autoconf macros
|
||||
arcnet.h - ARCNET definitions
|
||||
atmuni31.h - ATM Q.2931 definitions
|
||||
bpf_dump.c - BPF program printing routines
|
||||
bpf_filter.c - BPF filtering routines
|
||||
bpf_image.c - BPF disassembly routine
|
||||
config.guess - autoconf support
|
||||
config.h.in - autoconf input
|
||||
config.sub - autoconf support
|
||||
configure - configure script (run this first)
|
||||
configure.ac - configure script source
|
||||
dlpisubs.c - DLPI-related functions for pcap-dlpi.c and pcap-libdlpi.c
|
||||
dlpisubs.h - DLPI-related function declarations
|
||||
etherent.c - /etc/ethers support routines
|
||||
ethertype.h - Ethernet protocol types and names definitions
|
||||
fad-getad.c - pcap_findalldevs() for systems with getifaddrs()
|
||||
fad-gifc.c - pcap_findalldevs() for systems with only SIOCGIFLIST
|
||||
fad-glifc.c - pcap_findalldevs() for systems with SIOCGLIFCONF
|
||||
testprogs/filtertest.c - test program for BPF compiler
|
||||
testprogs/findalldevstest.c - test program for pcap_findalldevs()
|
||||
gencode.c - BPF code generation routines
|
||||
gencode.h - BPF code generation definitions
|
||||
grammar.y - filter string grammar
|
||||
ieee80211.h - 802.11 definitions
|
||||
install-sh - BSD style install script
|
||||
lbl/os-*.h - OS-dependent defines and prototypes
|
||||
llc.h - 802.2 LLC SAP definitions
|
||||
missing/* - replacements for missing library functions
|
||||
mkdep - construct Makefile dependency list
|
||||
msdos/* - drivers for MS-DOS capture support
|
||||
nametoaddr.c - hostname to address routines
|
||||
nlpid.h - OSI network layer protocol identifier definitions
|
||||
optimize.c - BPF optimization routines
|
||||
pcap/bluetooth.h - public definition of DLT_BLUETOOTH_HCI_H4_WITH_PHDR header
|
||||
pcap/bpf.h - BPF definitions
|
||||
pcap/namedb.h - public libpcap name database definitions
|
||||
pcap/pcap.h - public libpcap definitions
|
||||
pcap/sll.h - public definitions of DLT_LINUX_SLL and DLT_LINUX_SLL2 headers
|
||||
pcap/usb.h - public definition of DLT_USB header
|
||||
pcap-bpf.c - BSD Packet Filter support
|
||||
pcap-bpf.h - header for backwards compatibility
|
||||
pcap-bt-linux.c - Bluetooth capture support for Linux
|
||||
pcap-bt-linux.h - Bluetooth capture support for Linux
|
||||
pcap-dag.c - Endace DAG device capture support
|
||||
pcap-dag.h - Endace DAG device capture support
|
||||
pcap-dlpi.c - Data Link Provider Interface support
|
||||
pcap-dos.c - MS-DOS capture support
|
||||
pcap-dos.h - headers for MS-DOS capture support
|
||||
pcap-enet.c - enet support
|
||||
pcap-int.h - internal libpcap definitions
|
||||
pcap-libdlpi.c - Data Link Provider Interface support for systems with libdlpi
|
||||
pcap-linux.c - Linux packet socket support
|
||||
pcap-namedb.h - header for backwards compatibility
|
||||
pcap-nit.c - SunOS Network Interface Tap support
|
||||
pcap-npf.c - Npcap capture support
|
||||
pcap-null.c - dummy monitor support (allows offline use of libpcap)
|
||||
pcap-pf.c - Ultrix and Digital/Tru64 UNIX Packet Filter support
|
||||
pcap-septel.c - Intel/Septel device capture support
|
||||
pcap-septel.h - Intel/Septel device capture support
|
||||
pcap-sita.c - SITA device capture support
|
||||
pcap-sita.h - SITA device capture support
|
||||
pcap-sita.html - SITA device capture documentation
|
||||
pcap-snit.c - SunOS 4.x STREAMS-based Network Interface Tap support
|
||||
pcap-snoop.c - IRIX Snoop network monitoring support
|
||||
pcap-usb-linux.c - USB capture support for Linux
|
||||
pcap-usb-linux.h - USB capture support for Linux
|
||||
pcap.3pcap - manual entry for the library
|
||||
pcap.c - pcap utility routines
|
||||
pcap.h - header for backwards compatibility
|
||||
pcap_*.3pcap - manual entries for library functions
|
||||
pcap-filter.manmisc.in - manual entry for filter syntax
|
||||
pcap-linktype.manmisc.in - manual entry for link-layer header types
|
||||
ppp.h - Point to Point Protocol definitions
|
||||
savefile.c - offline support
|
||||
scanner.l - filter string scanner
|
||||
sunatmpos.h - definitions for SunATM capturing
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
# From autoconf.info . Works best with GNU Make.
|
||||
#
|
||||
${srcdir}/configure: configure.ac aclocal.m4
|
||||
cd ${srcdir} && autoconf
|
||||
(cd ${srcdir} && autoconf)
|
||||
|
||||
# autoheader might not change config.h.in, so touch a stamp file.
|
||||
${srcdir}/config.h.in: ${srcdir}/stamp-h.in
|
||||
${srcdir}/stamp-h.in: configure.ac aclocal.m4
|
||||
cd ${srcdir} && autoheader
|
||||
(cd ${srcdir} && autoheader)
|
||||
echo timestamp > ${srcdir}/stamp-h.in
|
||||
|
||||
config.h: stamp-h
|
||||
|
|
|
@ -38,6 +38,7 @@ mandir = @mandir@
|
|||
|
||||
# VPATH
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
#
|
||||
|
@ -60,16 +61,16 @@ CROSSFLAGS=
|
|||
CFLAGS = @CFLAGS@ ${CROSSFLAGS}
|
||||
LDFLAGS = @LDFLAGS@ ${CROSSFLAGS}
|
||||
DYEXT = @DYEXT@
|
||||
V_RPATH_OPT = @V_RPATH_OPT@
|
||||
RPATH = @RPATH@
|
||||
DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@
|
||||
PROG=libpcap
|
||||
PTHREAD_LIBS=@PTHREAD_LIBS@
|
||||
BUILD_RPCAPD=@BUILD_RPCAPD@
|
||||
INSTALL_RPCAPD=@INSTALL_RPCAPD@
|
||||
EXTRA_NETWORK_LIBS=@EXTRA_NETWORK_LIBS@
|
||||
|
||||
# Standard CFLAGS for building members of a shared library
|
||||
FULL_CFLAGS = $(CCOPT) @V_LIB_CCOPT_FAT@ $(SHLIB_CCOPT) $(INCLS) $(DEFS) $(CFLAGS)
|
||||
CXXFLAGS = $(CCOPT) @V_LIB_CCOPT_FAT@ $(SHLIB_CCOPT) $(INCLS) $(DEFS) $(CFLAGS)
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
|
@ -77,7 +78,7 @@ INSTALL_DATA = @INSTALL_DATA@
|
|||
RANLIB = @RANLIB@
|
||||
|
||||
LEX = @LEX@
|
||||
YACC = @YACC@
|
||||
BISON_BYACC = @BISON_BYACC@
|
||||
|
||||
# Explicitly define compilation rule since SunOS 4's make doesn't like gcc.
|
||||
# Also, gcc does not remove the .o before forking 'as', which can be a
|
||||
|
@ -86,40 +87,48 @@ YACC = @YACC@
|
|||
@rm -f $@
|
||||
$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
|
||||
|
||||
PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @NETFILTER_SRC@ @DBUS_SRC@ @NETMAP_SRC@ @RDMA_SRC@
|
||||
FSRC = @V_FINDALLDEVS@
|
||||
SSRC = @SSRC@
|
||||
CSRC = pcap.c gencode.c optimize.c nametoaddr.c etherent.c \
|
||||
fmtutils.c \
|
||||
savefile.c sf-pcap.c sf-pcapng.c pcap-common.c \
|
||||
bpf_image.c bpf_filter.c bpf_dump.c
|
||||
GENSRC = scanner.c grammar.c
|
||||
PLATFORM_C_SRC = @PLATFORM_C_SRC@
|
||||
PLATFORM_CXX_SRC = @PLATFORM_CXX_SRC@
|
||||
MODULE_C_SRC = @MODULE_C_SRC@
|
||||
REMOTE_C_SRC = @REMOTE_C_SRC@
|
||||
COMMON_C_SRC = pcap.c gencode.c optimize.c nametoaddr.c etherent.c \
|
||||
fmtutils.c pcap-util.c \
|
||||
savefile.c sf-pcap.c sf-pcapng.c pcap-common.c \
|
||||
pcap-usb-linux-common.c bpf_image.c bpf_filter.c bpf_dump.c
|
||||
GENERATED_C_SRC = scanner.c grammar.c
|
||||
LIBOBJS = @LIBOBJS@
|
||||
|
||||
SRC = $(PSRC) $(FSRC) $(CSRC) $(SSRC) $(GENSRC)
|
||||
SRC = $(PLATFORM_C_SRC) $(PLATFORM_CXX_SRC) \
|
||||
$(MODULE_C_SRC) $(REMOTE_C_SRC) $(COMMON_C_SRC) \
|
||||
$(GENERATED_C_SRC)
|
||||
|
||||
# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
|
||||
# hack the extra indirection
|
||||
OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
|
||||
# hack the extra indirection, and we have to handle PLATFORM_CXX_SRC
|
||||
# differently from the defines for C source
|
||||
OBJ = $(PLATFORM_C_SRC:.c=.o) $(PLATFORM_CXX_SRC:.cpp=.o) \
|
||||
$(MODULE_C_SRC:.c=.o) $(REMOTE_C_SRC:.c=.o) $(COMMON_C_SRC:.c=.o) \
|
||||
$(GENERATED_C_SRC:.c=.o) \
|
||||
$(LIBOBJS)
|
||||
|
||||
PUBHDR = \
|
||||
pcap.h \
|
||||
pcap-bpf.h \
|
||||
pcap-namedb.h \
|
||||
pcap/bpf.h \
|
||||
pcap/bluetooth.h \
|
||||
pcap/bpf.h \
|
||||
pcap/can_socketcan.h \
|
||||
pcap/compiler-tests.h \
|
||||
pcap/dlt.h \
|
||||
pcap/funcattrs.h \
|
||||
pcap/pcap-inttypes.h \
|
||||
pcap/ipnet.h \
|
||||
pcap/namedb.h \
|
||||
pcap/nflog.h \
|
||||
pcap/pcap-inttypes.h \
|
||||
pcap/pcap.h \
|
||||
pcap/sll.h \
|
||||
pcap/socket.h \
|
||||
pcap/vlan.h \
|
||||
pcap/usb.h
|
||||
pcap/usb.h \
|
||||
pcap/vlan.h
|
||||
|
||||
HDR = $(PUBHDR) \
|
||||
arcnet.h \
|
||||
|
@ -139,6 +148,9 @@ HDR = $(PUBHDR) \
|
|||
pcap-int.h \
|
||||
pcap-rpcap.h \
|
||||
pcap-types.h \
|
||||
pcap-usb-linux-common.h \
|
||||
pcap-util.h \
|
||||
pflog.h \
|
||||
portability.h \
|
||||
ppp.h \
|
||||
rpcap-protocol.h \
|
||||
|
@ -154,7 +166,7 @@ TAGFILES = \
|
|||
$(SRC) $(HDR)
|
||||
|
||||
CLEANFILES = $(OBJ) libpcap.a libpcap.so.`cat $(srcdir)/VERSION` \
|
||||
$(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \
|
||||
$(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENERATED_C_SRC) $(GENHDR) \
|
||||
lex.yy.c pcap-config libpcap.pc
|
||||
|
||||
MAN1 = pcap-config.1
|
||||
|
@ -193,6 +205,7 @@ MAN3PCAP_NOEXPAND = \
|
|||
pcap_get_required_select_timeout.3pcap \
|
||||
pcap_get_selectable_fd.3pcap \
|
||||
pcap_geterr.3pcap \
|
||||
pcap_init.3pcap \
|
||||
pcap_inject.3pcap \
|
||||
pcap_is_swapped.3pcap \
|
||||
pcap_lib_version.3pcap \
|
||||
|
@ -241,15 +254,27 @@ EXTRA_DIST = \
|
|||
Makefile.in \
|
||||
Makefile-devel-adds \
|
||||
README.md \
|
||||
doc \
|
||||
doc/README.Win32.md \
|
||||
doc/README.aix \
|
||||
doc/README.dag \
|
||||
doc/README.hpux \
|
||||
doc/README.linux \
|
||||
doc/README.macos \
|
||||
doc/README.septel \
|
||||
doc/README.sita \
|
||||
doc/README.solaris.md \
|
||||
CONTRIBUTING.md \
|
||||
TODO \
|
||||
VERSION \
|
||||
aclocal.m4 \
|
||||
charconv.c \
|
||||
charconv.h \
|
||||
chmod_bpf \
|
||||
cmake_uninstall.cmake.in \
|
||||
cmakeconfig.h.in \
|
||||
cmake/Modules/FindAirPcap.cmake \
|
||||
cmake/Modules/FindDAG.cmake \
|
||||
cmake/Modules/Finddpdk.cmake \
|
||||
cmake/Modules/FindFseeko.cmake \
|
||||
cmake/Modules/FindLFS.cmake \
|
||||
cmake/Modules/FindPacket.cmake \
|
||||
|
@ -266,7 +291,7 @@ EXTRA_DIST = \
|
|||
fad-getad.c \
|
||||
fad-gifc.c \
|
||||
fad-glifc.c \
|
||||
grammar.y \
|
||||
grammar.y.in \
|
||||
install-sh \
|
||||
lbl/os-aix4.h \
|
||||
lbl/os-aix7.h \
|
||||
|
@ -280,12 +305,10 @@ EXTRA_DIST = \
|
|||
missing/asprintf.c \
|
||||
missing/getopt.c \
|
||||
missing/getopt.h \
|
||||
missing/snprintf.c \
|
||||
missing/strlcat.c \
|
||||
missing/strlcpy.c \
|
||||
missing/strtok_r.c \
|
||||
missing/win_asprintf.c \
|
||||
missing/win_snprintf.c \
|
||||
mkdep \
|
||||
msdos/bin2c.c \
|
||||
msdos/makefile \
|
||||
|
@ -298,6 +321,8 @@ EXTRA_DIST = \
|
|||
msdos/readme.dos \
|
||||
nomkdep \
|
||||
org.tcpdump.chmod_bpf.plist \
|
||||
pcap-airpcap.c \
|
||||
pcap-airpcap.h \
|
||||
pcap-bpf.c \
|
||||
pcap-bt-linux.c \
|
||||
pcap-bt-linux.h \
|
||||
|
@ -312,7 +337,10 @@ EXTRA_DIST = \
|
|||
pcap-dlpi.c \
|
||||
pcap-dos.c \
|
||||
pcap-dos.h \
|
||||
pcap-dpdk.c \
|
||||
pcap-dpdk.h \
|
||||
pcap-enet.c \
|
||||
pcap-haiku.cpp \
|
||||
pcap-int.h \
|
||||
pcap-libdlpi.c \
|
||||
pcap-linux.c \
|
||||
|
@ -367,6 +395,8 @@ EXTRA_DIST = \
|
|||
rpcapd/win32-svc.h \
|
||||
sockutils.c \
|
||||
sockutils.h \
|
||||
sslutils.c \
|
||||
sslutils.h \
|
||||
scanner.l \
|
||||
testprogs/CMakeLists.txt \
|
||||
testprogs/Makefile.in \
|
||||
|
@ -374,16 +404,30 @@ EXTRA_DIST = \
|
|||
testprogs/capturetest.c \
|
||||
testprogs/filtertest.c \
|
||||
testprogs/findalldevstest.c \
|
||||
testprogs/findalldevstest-perf.c \
|
||||
testprogs/fuzz/CMakeLists.txt \
|
||||
testprogs/fuzz/fuzz_both.c \
|
||||
testprogs/fuzz/fuzz_both.options \
|
||||
testprogs/fuzz/fuzz_filter.c \
|
||||
testprogs/fuzz/fuzz_filter.options \
|
||||
testprogs/fuzz/fuzz_pcap.c \
|
||||
testprogs/fuzz/fuzz_pcap.options \
|
||||
testprogs/fuzz/onefile.c \
|
||||
testprogs/nonblocktest.c \
|
||||
testprogs/opentest.c \
|
||||
testprogs/reactivatetest.c \
|
||||
testprogs/selpolltest.c \
|
||||
testprogs/threadsignaltest.c \
|
||||
testprogs/unix.h \
|
||||
testprogs/valgrindtest.c \
|
||||
tests/shb-option-too-long.pcapng \
|
||||
Win32/Prj/wpcap.sln \
|
||||
Win32/Prj/wpcap.vcxproj \
|
||||
Win32/Prj/wpcap.vcxproj.filters
|
||||
testprogs/visopts.py \
|
||||
testprogs/writecaptest.c
|
||||
|
||||
TEST_DIST = `git ls-files tests | grep -v 'tests/\..*'`
|
||||
|
||||
RELEASE_FILES = $(COMMON_C_SRC) $(HDR) $(MAN1) $(MAN3PCAP_EXPAND) \
|
||||
$(MAN3PCAP_NOEXPAND) $(MANFILE) $(MANMISC) $(EXTRA_DIST) \
|
||||
$(TEST_DIST)
|
||||
|
||||
all: libpcap.a shared $(BUILD_RPCAPD) libpcap.pc pcap-config
|
||||
|
||||
|
@ -480,8 +524,27 @@ scanner.h: scanner.c
|
|||
scanner.o: scanner.c grammar.h
|
||||
$(CC) $(FULL_CFLAGS) -c scanner.c
|
||||
|
||||
grammar.c: $(srcdir)/grammar.y
|
||||
$(YACC) -p pcap_ -o grammar.c -d $<
|
||||
#
|
||||
# Generate the grammar.y file.
|
||||
#
|
||||
# Some Makes, e.g. AIX Make and Solaris Make, can't handle "--file=$@.tmp:$<";
|
||||
# for example, the Solaris 9 make man page says
|
||||
#
|
||||
# Because make assigns $< and $* as it would for implicit rules
|
||||
# (according to the suffixes list and the directory contents),
|
||||
# they may be unreliable when used within explicit target entries.
|
||||
#
|
||||
# and this is an explicit target entry.
|
||||
#
|
||||
# Therefore, instead of using $<, we explicitly put in $(srcdir)/libpcap.pc.in.
|
||||
#
|
||||
grammar.y: $(srcdir)/grammar.y.in ./config.status
|
||||
@rm -f $@ $@.tmp
|
||||
./config.status --file=$@.tmp:$(srcdir)/grammar.y.in
|
||||
mv $@.tmp $@
|
||||
|
||||
grammar.c: grammar.y
|
||||
$(BISON_BYACC) -p pcap_ -o grammar.c -d $<
|
||||
grammar.h: grammar.c
|
||||
## Recover from the removal of $@
|
||||
@if test -f $@; then :; else \
|
||||
|
@ -528,7 +591,6 @@ libpcap.pc: $(srcdir)/libpcap.pc.in ./config.status
|
|||
@rm -f $@ $@.tmp
|
||||
./config.status --file=$@.tmp:$(srcdir)/libpcap.pc.in
|
||||
mv $@.tmp $@
|
||||
chmod a+x $@
|
||||
|
||||
#
|
||||
# Generate the pcap-config script. See above.
|
||||
|
@ -543,13 +605,13 @@ pcap-config: $(srcdir)/pcap-config.in ./config.status
|
|||
# Remote pcap daemon.
|
||||
#
|
||||
build-rpcapd: libpcap.a
|
||||
cd rpcapd; $(MAKE)
|
||||
(cd rpcapd; $(MAKE))
|
||||
|
||||
#
|
||||
# Test programs - not built by default, and not installed.
|
||||
#
|
||||
testprogs: FORCE
|
||||
cd testprogs; $(MAKE)
|
||||
(cd testprogs; $(MAKE))
|
||||
|
||||
FORCE:
|
||||
|
||||
|
@ -681,7 +743,7 @@ install-archive-shareda:
|
|||
#
|
||||
|
||||
install-rpcapd:
|
||||
cd rpcapd; $(MAKE) DESTDIR=$(DESTDIR) install
|
||||
(cd rpcapd; $(MAKE) DESTDIR=$(DESTDIR) install)
|
||||
|
||||
uninstall: uninstall-shared uninstall-rpcapd
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.a
|
||||
|
@ -695,6 +757,7 @@ uninstall: uninstall-shared uninstall-rpcapd
|
|||
for i in $(MAN3PCAP); do \
|
||||
rm -f $(DESTDIR)$(mandir)/man3/$$i; done
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description_or_dlt.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_freealldevs.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
|
||||
|
@ -737,21 +800,21 @@ uninstall-shared-shareda:
|
|||
uninstall-shared-none:
|
||||
|
||||
uninstall-rpcapd:
|
||||
cd rpcapd; $(MAKE) DESTDIR=$(DESTDIR) uninstall
|
||||
(cd rpcapd; $(MAKE) DESTDIR=$(DESTDIR) uninstall)
|
||||
|
||||
clean:
|
||||
rm -f $(CLEANFILES)
|
||||
cd rpcapd; $(MAKE) clean
|
||||
cd testprogs; $(MAKE) clean
|
||||
(cd rpcapd; $(MAKE) clean)
|
||||
(cd testprogs; $(MAKE) clean)
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile config.cache config.log config.status \
|
||||
config.h gnuc.h net os-proto.h libpcap.pc \
|
||||
pcap-config stamp-h stamp-h.in
|
||||
rm -f Makefile grammar.y config.cache config.log config.status \
|
||||
config.h config.h.in~ configure~ configure.ac~ \
|
||||
gnuc.h net os-proto.h libpcap.pc pcap-config stamp-h stamp-h.in
|
||||
rm -f $(MAN3PCAP_EXPAND:.in=) $(MANFILE:.in=) $(MANMISC:.in=)
|
||||
rm -rf autom4te.cache
|
||||
cd rpcapd; $(MAKE) distclean
|
||||
cd testprogs; $(MAKE) distclean
|
||||
(cd rpcapd; $(MAKE) distclean)
|
||||
(cd testprogs; $(MAKE) distclean)
|
||||
|
||||
extags: $(TAGFILES)
|
||||
ctags $(TAGFILES)
|
||||
|
@ -760,15 +823,21 @@ tags: $(TAGFILES)
|
|||
ctags -wtd $(TAGFILES)
|
||||
|
||||
releasetar:
|
||||
@cwd=`pwd` ; dir=`basename $$cwd` ; name=$(PROG)-`cat VERSION` ; \
|
||||
mkdir $$name; \
|
||||
tar -c --exclude='*~' -f - $(CSRC) $(HDR) $(MAN1) $(MAN3PCAP_EXPAND) \
|
||||
$(MAN3PCAP_NOEXPAND) $(MANFILE) $(MANMISC) $(EXTRA_DIST) | \
|
||||
(cd $$name; tar xf -); \
|
||||
tar -c -z -f $$name.tar.gz $$name; \
|
||||
rm -rf $$name
|
||||
@TAG=$(PROG)-`cat VERSION` && \
|
||||
if git show-ref --tags --quiet --verify -- "refs/tags/$$TAG"; then \
|
||||
git archive --prefix="$$TAG"/ -o "$$TAG".tar.gz "$$TAG" \
|
||||
$(RELEASE_FILES) && \
|
||||
echo "Archive build from tag $$TAG."; \
|
||||
else \
|
||||
git archive --prefix="$$TAG"/ -o "$$TAG".tar.gz HEAD \
|
||||
$(RELEASE_FILES) && \
|
||||
echo "No $$TAG tag. Archive build from HEAD."; \
|
||||
fi
|
||||
|
||||
depend: $(GENSRC) $(GENHDR)
|
||||
$(MKDEP) -c "$(CC)" -m "$(DEPENDENCY_CFLAG)" $(CFLAGS) $(DEFS) $(INCLS) $(SRC)
|
||||
cd rpcapd; $(MAKE) depend
|
||||
cd testprogs; $(MAKE) depend
|
||||
depend: $(GENERATED_C_SRC) $(GENHDR)
|
||||
$(MKDEP) -c "$(CC)" -m "$(DEPENDENCY_CFLAG)" -s "$(srcdir)" $(CFLAGS) $(DEFS) $(INCLS) $(SRC)
|
||||
(cd rpcapd; $(MAKE) depend)
|
||||
(cd testprogs; $(MAKE) depend)
|
||||
|
||||
shellcheck:
|
||||
shellcheck -f gcc -e SC2006 build.sh build_matrix.sh build_common.sh
|
||||
|
|
|
@ -1,22 +1,17 @@
|
|||
To report a security issue please send an e-mail to security@tcpdump.org.
|
||||
# LIBPCAP 1.x.y by [The Tcpdump Group](https://www.tcpdump.org)
|
||||
|
||||
**To report a security issue please send an e-mail to security@tcpdump.org.**
|
||||
|
||||
To report bugs and other problems, contribute patches, request a
|
||||
feature, provide generic feedback etc please see the file
|
||||
[CONTRIBUTING](CONTRIBUTING.md) in the libpcap source tree root.
|
||||
feature, provide generic feedback etc please see the
|
||||
[guidelines for contributing](CONTRIBUTING.md).
|
||||
|
||||
The directory doc/ has README files about specific operating systems and
|
||||
options.
|
||||
|
||||
LIBPCAP 1.x.y
|
||||
Now maintained by "The Tcpdump Group"
|
||||
https://www.tcpdump.org
|
||||
The [documentation directory](doc/) has README files about specific
|
||||
operating systems and options.
|
||||
|
||||
Anonymous Git is available via:
|
||||
https://github.com/the-tcpdump-group/libpcap.git
|
||||
|
||||
formerly from Lawrence Berkeley National Laboratory
|
||||
Network Research Group <libpcap@ee.lbl.gov>
|
||||
ftp://ftp.ee.lbl.gov/old/libpcap-0.4a7.tar.Z
|
||||
https://github.com/the-tcpdump-group/libpcap.git
|
||||
|
||||
This directory contains source code for libpcap, a system-independent
|
||||
interface for user-level packet capture. libpcap provides a portable
|
||||
|
@ -28,7 +23,14 @@ require this functionality, we've created this system-independent API
|
|||
to ease in porting and to alleviate the need for several
|
||||
system-dependent packet capture modules in each application.
|
||||
|
||||
For some platforms there are README.{system} files that discuss issues
|
||||
```text
|
||||
formerly from Lawrence Berkeley National Laboratory
|
||||
Network Research Group <libpcap@ee.lbl.gov>
|
||||
ftp://ftp.ee.lbl.gov/old/libpcap-0.4a7.tar.Z
|
||||
```
|
||||
|
||||
### Support for particular platforms and BPF
|
||||
For some platforms there are `README.{system}` files that discuss issues
|
||||
with the OS's interface for packet capture on those platforms, such as
|
||||
how to enable support for that interface in the OS, if it's not built in
|
||||
by default.
|
||||
|
@ -36,22 +38,10 @@ by default.
|
|||
The libpcap interface supports a filtering mechanism based on the
|
||||
architecture in the BSD packet filter. BPF is described in the 1993
|
||||
Winter Usenix paper ``The BSD Packet Filter: A New Architecture for
|
||||
User-level Packet Capture''. A compressed PostScript version can be
|
||||
found at
|
||||
|
||||
ftp://ftp.ee.lbl.gov/papers/bpf-usenix93.ps.Z
|
||||
|
||||
or
|
||||
|
||||
https://www.tcpdump.org/papers/bpf-usenix93.ps.Z
|
||||
|
||||
and a gzipped version can be found at
|
||||
|
||||
https://www.tcpdump.org/papers/bpf-usenix93.ps.gz
|
||||
|
||||
A PDF version can be found at
|
||||
|
||||
https://www.tcpdump.org/papers/bpf-usenix93.pdf
|
||||
User-level Packet Capture''
|
||||
([compressed PostScript](https://www.tcpdump.org/papers/bpf-usenix93.ps.Z),
|
||||
[gzipped PostScript](https://www.tcpdump.org/papers/bpf-usenix93.ps.gz),
|
||||
[PDF](https://www.tcpdump.org/papers/bpf-usenix93.pdf)).
|
||||
|
||||
Although most packet capture interfaces support in-kernel filtering,
|
||||
libpcap utilizes in-kernel filtering only for the BPF interface.
|
||||
|
@ -62,32 +52,25 @@ would translate BPF filters into a filter program that is compatible
|
|||
with the underlying kernel subsystem, but this is not yet implemented.
|
||||
|
||||
BPF is standard in 4.4BSD, BSD/OS, NetBSD, FreeBSD, OpenBSD, DragonFly
|
||||
BSD, and macOS; an older, modified and undocumented version is standard
|
||||
in AIX. {DEC OSF/1, Digital UNIX, Tru64 UNIX} uses the packetfilter
|
||||
interface but has been extended to accept BPF filters (which libpcap
|
||||
utilizes). Also, you can add BPF filter support to Ultrix using the
|
||||
kernel source and/or object patches available in:
|
||||
|
||||
https://www.tcpdump.org/other/bpfext42.tar.Z
|
||||
BSD, macOS, and Solaris 11; an older, modified and undocumented version
|
||||
is standard in AIX. {DEC OSF/1, Digital UNIX, Tru64 UNIX} uses the
|
||||
packetfilter interface but has been extended to accept BPF filters
|
||||
(which libpcap utilizes).
|
||||
|
||||
Linux has a number of BPF based systems, and libpcap does not support
|
||||
any of the eBPF mechanisms as yet, although it supports many of the
|
||||
memory mapped receive mechanisms.
|
||||
See the [README.linux](doc/README.linux.md) file for more information.
|
||||
See the [Linux-specific README](doc/README.linux) for more information.
|
||||
|
||||
Note to Linux distributions and *BSD systems that include libpcap:
|
||||
### Note to Linux distributions and *BSD systems that include libpcap:
|
||||
|
||||
There's now a rule to make a shared library, which should work on Linux
|
||||
and *BSD, among other platforms.
|
||||
|
||||
It sets the soname of the library to "libpcap.so.1"; this is what it
|
||||
should be, *NOT* libpcap.so.1.x or libpcap.so.1.x.y or something such as
|
||||
It sets the soname of the library to `libpcap.so.1`; this is what it
|
||||
should be, **NOT** `libpcap.so.1.x` or `libpcap.so.1.x.y` or something such as
|
||||
that.
|
||||
|
||||
We've been maintaining binary compatibility between libpcap releases for
|
||||
quite a while; there's no reason to tie a binary linked with libpcap to
|
||||
a particular release of libpcap.
|
||||
|
||||
Current versions can be found at https://www.tcpdump.org.
|
||||
|
||||
- The TCPdump group
|
||||
|
|
|
@ -31,5 +31,3 @@ Less urgent items
|
|||
+ too many functions. There are a lot of functions for everything which
|
||||
violates the KISS principle. Why do we need pcap_strerror, pcap_perror
|
||||
and pcap_geterr?
|
||||
+ the manpage has a brief description of each function but where is the
|
||||
big picture? Seems like you need to buy UNP for that...
|
||||
|
|
|
@ -1 +1 @@
|
|||
1.9.1
|
||||
1.10.3
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.40629.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wpcap", "wpcap.vcxproj", "{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|x64.Build.0 = Debug|x64
|
||||
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|Win32.Build.0 = Release|Win32
|
||||
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|x64.ActiveCfg = Release|x64
|
||||
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -1,233 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<SccProjectName />
|
||||
<SccLocalPath />
|
||||
<ProjectGuid>{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>.\Release\</OutDir>
|
||||
<IntDir>.\Release\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>../../../;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>../../../;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>.\Debug\</OutDir>
|
||||
<IntDir>.\Debug\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>../../../;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>../../../;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<StringPooling>true</StringPooling>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;pcap_EXPORTS;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
|
||||
win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
|
||||
win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<StringPooling>true</StringPooling>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;pcap_EXPORTS;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\x64\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
|
||||
win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
|
||||
win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;_DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;pcap_EXPORTS;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
|
||||
win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
|
||||
win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;_DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;pcap_EXPORTS;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\x64\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
|
||||
win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
|
||||
win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\bpf\net\bpf_filter.c" />
|
||||
<ClCompile Include="..\..\bpf_dump.c" />
|
||||
<ClCompile Include="..\..\bpf_image.c" />
|
||||
<ClCompile Include="..\..\etherent.c" />
|
||||
<ClCompile Include="..\..\gencode.c" />
|
||||
<ClCompile Include="..\..\grammar.c" />
|
||||
<ClCompile Include="..\..\inet.c" />
|
||||
<ClCompile Include="..\..\missing\win_snprintf.c" />
|
||||
<ClCompile Include="..\..\nametoaddr.c" />
|
||||
<ClCompile Include="..\..\optimize.c" />
|
||||
<ClCompile Include="..\..\pcap-common.c" />
|
||||
<ClCompile Include="..\..\pcap-new.c" />
|
||||
<ClCompile Include="..\..\pcap-rpcap.c" />
|
||||
<ClCompile Include="..\..\pcap-win32.c" />
|
||||
<ClCompile Include="..\..\pcap.c" />
|
||||
<ClCompile Include="..\..\savefile.c" />
|
||||
<ClCompile Include="..\..\scanner.c" />
|
||||
<ClCompile Include="..\..\sf-pcapng.c" />
|
||||
<ClCompile Include="..\..\sf-pcap.c" />
|
||||
<ClCompile Include="..\..\sockutils.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\pcap-common.h" />
|
||||
<ClInclude Include="..\..\pcap-int.h" />
|
||||
<ClInclude Include="..\..\pcap-rpcap.h" />
|
||||
<ClInclude Include="..\..\pcap-stdinc.h" />
|
||||
<ClInclude Include="..\..\pcap.h" />
|
||||
<ClInclude Include="..\..\remote-ext.h" />
|
||||
<ClInclude Include="..\..\sockutils.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="..\..\..\Win32-Extensions\version.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -1,107 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\bpf_dump.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\bpf\net\bpf_filter.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\bpf_image.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\etherent.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\gencode.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\grammar.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\inet.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\nametoaddr.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\optimize.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\pcap.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\pcap-win32.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\savefile.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\scanner.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\sf-pcap.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\sf-pcapng.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\pcap-common.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\fad-helpers.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\missing\win_snprintf.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\pcap-new.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\pcap-rpcap.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\sockutils.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{c51dce5e-0da9-4e33-a235-d5c76c76485c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{5ec9fd4b-10b5-4527-b249-56b53d844fb1}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{c90886f0-8973-436b-a7a1-b9e881544f9a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\pcap-stdinc.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\pcap-common.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\pcap.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\pcap-int.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\pcap-rpcap.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\remote-ext.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\sockutils.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="..\..\..\Win32-Extensions\version.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
585
contrib/libpcap/aclocal.m4
vendored
585
contrib/libpcap/aclocal.m4
vendored
|
@ -232,34 +232,27 @@ AC_DEFUN(AC_LBL_C_INIT,
|
|||
])
|
||||
|
||||
dnl
|
||||
dnl Check whether, if you pass an unknown warning option to the
|
||||
dnl compiler, it fails or just prints a warning message and succeeds.
|
||||
dnl Set ac_lbl_unknown_warning_option_error to the appropriate flag
|
||||
dnl to force an error if it would otherwise just print a warning message
|
||||
dnl and succeed.
|
||||
dnl Save the values of various variables that affect compilation and
|
||||
dnl linking, and that we don't ourselves modify persistently; done
|
||||
dnl before a test involving compiling or linking is done, so that we
|
||||
dnl can restore those variables after the test is done.
|
||||
dnl
|
||||
AC_DEFUN(AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR,
|
||||
[
|
||||
AC_MSG_CHECKING([whether the compiler fails when given an unknown warning option])
|
||||
AC_DEFUN(AC_LBL_SAVE_CHECK_STATE,
|
||||
[
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
|
||||
AC_TRY_COMPILE(
|
||||
[],
|
||||
[return 0],
|
||||
[
|
||||
AC_MSG_RESULT([no])
|
||||
#
|
||||
# We're assuming this is clang, where
|
||||
# -Werror=unknown-warning-option is the appropriate
|
||||
# option to force the compiler to fail.
|
||||
#
|
||||
ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option"
|
||||
],
|
||||
[
|
||||
AC_MSG_RESULT([yes])
|
||||
])
|
||||
save_LIBS="$LIBS"
|
||||
save_LDFLAGS="$LDFLAGS"
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Restore the values of variables saved by AC_LBL_SAVE_CHECK_STATE.
|
||||
dnl
|
||||
AC_DEFUN(AC_LBL_RESTORE_CHECK_STATE,
|
||||
[
|
||||
CFLAGS="$save_CFLAGS"
|
||||
])
|
||||
LIBS="$save_LIBS"
|
||||
LDFLAGS="$save_LDFLAGS"
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Check whether the compiler option specified as the second argument
|
||||
|
@ -271,28 +264,42 @@ dnl with the flag in question, and the "treat warnings as errors" flag
|
|||
dnl set, and don't add the flag to the first argument if the compile
|
||||
dnl fails; this is for warning options cause problems that can't be
|
||||
dnl worked around. If a third argument is supplied, a fourth argument
|
||||
dnl should also be supplied; it's a message desribing what the test
|
||||
dnl should also be supplied; it's a message describing what the test
|
||||
dnl program is checking.
|
||||
dnl
|
||||
AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
|
||||
[
|
||||
AC_MSG_CHECKING([whether the compiler supports the $2 option])
|
||||
save_CFLAGS="$CFLAGS"
|
||||
if expr "x$2" : "x-W.*" >/dev/null
|
||||
then
|
||||
CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error $2"
|
||||
elif expr "x$2" : "x-f.*" >/dev/null
|
||||
then
|
||||
CFLAGS="$CFLAGS -Werror $2"
|
||||
elif expr "x$2" : "x-m.*" >/dev/null
|
||||
then
|
||||
CFLAGS="$CFLAGS -Werror $2"
|
||||
else
|
||||
CFLAGS="$CFLAGS $2"
|
||||
fi
|
||||
AC_TRY_COMPILE(
|
||||
[],
|
||||
[return 0],
|
||||
CFLAGS="$CFLAGS $2"
|
||||
#
|
||||
# XXX - yes, this depends on the way AC_LANG_WERROR works,
|
||||
# but no mechanism is provided to turn AC_LANG_WERROR on
|
||||
# *and then turn it back off*, so that we *only* do it when
|
||||
# testing compiler options - 15 years after somebody asked
|
||||
# for it:
|
||||
#
|
||||
# https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
|
||||
#
|
||||
save_ac_c_werror_flag="$ac_c_werror_flag"
|
||||
ac_c_werror_flag=yes
|
||||
#
|
||||
# We use AC_LANG_SOURCE() so that we can control the complete
|
||||
# content of the program being compiled. We do not, for example,
|
||||
# want the default "int main()" that AC_LANG_PROGRAM() generates,
|
||||
# as it will generate a warning with -Wold-style-definition, meaning
|
||||
# that we would treat it as not working, as the test will fail if
|
||||
# *any* error output, including a warning due to the flag we're
|
||||
# testing, is generated; see
|
||||
#
|
||||
# https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
|
||||
# https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
|
||||
#
|
||||
# This may, as per those two messages, be fixed in autoconf 2.70,
|
||||
# but we only require 2.64 or newer for now.
|
||||
#
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_SOURCE([[int main(void) { return 0; }]])],
|
||||
[
|
||||
AC_MSG_RESULT([yes])
|
||||
can_add_to_cflags=yes
|
||||
|
@ -332,6 +339,7 @@ AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
|
|||
AC_MSG_RESULT([no])
|
||||
CFLAGS="$save_CFLAGS"
|
||||
])
|
||||
ac_c_werror_flag="$save_ac_c_werror_flag"
|
||||
])
|
||||
|
||||
dnl
|
||||
|
@ -425,14 +433,14 @@ AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT,
|
|||
if AC_RUN_LOG([eval "$CC $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1"]); then
|
||||
AC_MSG_RESULT([yes, with $ac_lbl_dependency_flag])
|
||||
DEPENDENCY_CFLAG="$ac_lbl_dependency_flag"
|
||||
MKDEP='${srcdir}/mkdep'
|
||||
MKDEP='${top_srcdir}/mkdep'
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
#
|
||||
# We can't run mkdep, so have "make depend" do
|
||||
# nothing.
|
||||
#
|
||||
MKDEP='${srcdir}/nomkdep'
|
||||
MKDEP='${top_srcdir}/nomkdep'
|
||||
fi
|
||||
rm -rf conftest*
|
||||
else
|
||||
|
@ -441,7 +449,7 @@ AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT,
|
|||
# We can't run mkdep, so have "make depend" do
|
||||
# nothing.
|
||||
#
|
||||
MKDEP='${srcdir}/nomkdep'
|
||||
MKDEP='${top_srcdir}/nomkdep'
|
||||
fi
|
||||
AC_SUBST(DEPENDENCY_CFLAG)
|
||||
AC_SUBST(MKDEP)
|
||||
|
@ -460,7 +468,6 @@ dnl V_SHLIB_CCOPT (modified to build position-independent code)
|
|||
dnl V_SHLIB_CMD
|
||||
dnl V_SHLIB_OPT
|
||||
dnl V_SONAME_OPT
|
||||
dnl V_RPATH_OPT
|
||||
dnl
|
||||
AC_DEFUN(AC_LBL_SHLIBS_INIT,
|
||||
[AC_PREREQ(2.50)
|
||||
|
@ -484,11 +491,12 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT,
|
|||
aix*)
|
||||
;;
|
||||
|
||||
freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*|midipix*)
|
||||
#
|
||||
# Platforms where the linker is the GNU linker
|
||||
# or accepts command-line arguments like
|
||||
# those the GNU linker accepts.
|
||||
freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*|haiku*|midipix*)
|
||||
#
|
||||
# Platforms where the C compiler is GCC or accepts
|
||||
# compatible command-line arguments, and the linker
|
||||
# is the GNU linker or accepts compatible command-line
|
||||
# arguments.
|
||||
#
|
||||
# Some instruction sets require -fPIC on some
|
||||
# operating systems. Check for them. If you
|
||||
|
@ -509,12 +517,11 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT,
|
|||
esac
|
||||
V_SHLIB_CCOPT="$V_SHLIB_CCOPT $PIC_OPT"
|
||||
V_SONAME_OPT="-Wl,-soname,"
|
||||
V_RPATH_OPT="-Wl,-rpath,"
|
||||
;;
|
||||
|
||||
hpux*)
|
||||
V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
|
||||
#
|
||||
#
|
||||
# XXX - this assumes GCC is using the HP linker,
|
||||
# rather than the GNU linker, and that the "+h"
|
||||
# option is used on all HP-UX platforms, both .sl
|
||||
|
@ -522,7 +529,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT,
|
|||
#
|
||||
V_SONAME_OPT="-Wl,+h,"
|
||||
#
|
||||
# By default, directories specifed with -L
|
||||
# By default, directories specified with -L
|
||||
# are added to the run-time search path, so
|
||||
# we don't add them in pcap-config.
|
||||
#
|
||||
|
@ -531,11 +538,12 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT,
|
|||
solaris*)
|
||||
V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
|
||||
#
|
||||
# XXX - this assumes GCC is using the Sun linker,
|
||||
# rather than the GNU linker.
|
||||
# Sun/Oracle's C compiler, GCC, and GCC-compatible
|
||||
# compilers support -Wl,{comma-separated list of options},
|
||||
# and we use the C compiler, not ld, for all linking,
|
||||
# including linking to produce a shared library.
|
||||
#
|
||||
V_SONAME_OPT="-Wl,-h,"
|
||||
V_RPATH_OPT="-Wl,-R,"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
|
@ -557,7 +565,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT,
|
|||
# "-Wl,-soname,{soname}" option, with the soname part
|
||||
# of the option, while on other platforms the C compiler
|
||||
# driver takes it as a regular option with the soname
|
||||
# following the option. The same applies to V_RPATH_OPT.
|
||||
# following the option.
|
||||
#
|
||||
case "$host_os" in
|
||||
|
||||
|
@ -568,13 +576,17 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT,
|
|||
|
||||
freebsd*|netbsd*|openbsd*|dragonfly*|linux*)
|
||||
#
|
||||
# "cc" is GCC.
|
||||
# Platforms where the C compiler is GCC or accepts
|
||||
# compatible command-line arguments, and the linker
|
||||
# is the GNU linker or accepts compatible command-line
|
||||
# arguments.
|
||||
#
|
||||
# XXX - does 64-bit SPARC require -fPIC?
|
||||
#
|
||||
V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
|
||||
V_SHLIB_CMD="\$(CC)"
|
||||
V_SHLIB_OPT="-shared"
|
||||
V_SONAME_OPT="-Wl,-soname,"
|
||||
V_RPATH_OPT="-Wl,-rpath,"
|
||||
;;
|
||||
|
||||
hpux*)
|
||||
|
@ -583,29 +595,33 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT,
|
|||
V_SHLIB_OPT="-b"
|
||||
V_SONAME_OPT="+h "
|
||||
#
|
||||
# By default, directories specifed with -L
|
||||
# By default, directories specified with -L
|
||||
# are added to the run-time search path, so
|
||||
# we don't add them in pcap-config.
|
||||
#
|
||||
;;
|
||||
|
||||
osf*)
|
||||
#
|
||||
#
|
||||
# Presumed to be DEC OSF/1, Digital UNIX, or
|
||||
# Tru64 UNIX.
|
||||
#
|
||||
V_SHLIB_CMD="\$(CC)"
|
||||
V_SHLIB_OPT="-shared"
|
||||
V_SONAME_OPT="-soname "
|
||||
V_RPATH_OPT="-rpath "
|
||||
;;
|
||||
|
||||
solaris*)
|
||||
V_SHLIB_CCOPT="$V_SHLIB_CCOPT -Kpic"
|
||||
V_SHLIB_CMD="\$(CC)"
|
||||
V_SHLIB_OPT="-G"
|
||||
V_SONAME_OPT="-h "
|
||||
V_RPATH_OPT="-R"
|
||||
#
|
||||
# Sun/Oracle's C compiler, GCC, and GCC-compatible
|
||||
# compilers support -Wl,{comma-separated list of options},
|
||||
# and we use the C compiler, not ld, for all linking,
|
||||
# including linking to produce a shared library.
|
||||
#
|
||||
V_SONAME_OPT="-Wl,-h,"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
@ -662,6 +678,46 @@ AC_DEFUN(AC_LBL_C_INLINE,
|
|||
fi
|
||||
AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])])
|
||||
|
||||
#
|
||||
# Test whether we have __atomic_load_n() and __atomic_store_n().
|
||||
#
|
||||
# We use AC_TRY_LINK because AC_TRY_COMPILE will succeed, as the
|
||||
# compiler will just think that those functions are undefined,
|
||||
# and perhaps warn about that, but not fail to compile.
|
||||
#
|
||||
AC_DEFUN(AC_PCAP_C___ATOMICS,
|
||||
[
|
||||
AC_MSG_CHECKING(for __atomic_load_n)
|
||||
AC_CACHE_VAL(ac_cv_have___atomic_load_n,
|
||||
AC_TRY_LINK([],
|
||||
[
|
||||
int i = 17;
|
||||
int j;
|
||||
j = __atomic_load_n(&i, __ATOMIC_RELAXED);
|
||||
],
|
||||
ac_have___atomic_load_n=yes,
|
||||
ac_have___atomic_load_n=no))
|
||||
AC_MSG_RESULT($ac_have___atomic_load_n)
|
||||
if test $ac_have___atomic_load_n = yes ; then
|
||||
AC_DEFINE(HAVE___ATOMIC_LOAD_N, 1,
|
||||
[define if __atomic_load_n is supported by the compiler])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING(for __atomic_store_n)
|
||||
AC_CACHE_VAL(ac_cv_have___atomic_store_n,
|
||||
AC_TRY_LINK([],
|
||||
[
|
||||
int i;
|
||||
__atomic_store_n(&i, 17, __ATOMIC_RELAXED);
|
||||
],
|
||||
ac_have___atomic_store_n=yes,
|
||||
ac_have___atomic_store_n=no))
|
||||
AC_MSG_RESULT($ac_have___atomic_store_n)
|
||||
if test $ac_have___atomic_store_n = yes ; then
|
||||
AC_DEFINE(HAVE___ATOMIC_STORE_N, 1,
|
||||
[define if __atomic_store_n is supported by the compiler])
|
||||
fi])
|
||||
|
||||
dnl
|
||||
dnl If using gcc, make sure we have ANSI ioctl definitions
|
||||
dnl
|
||||
|
@ -752,106 +808,6 @@ AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
|
|||
AC_MSG_RESULT($ac_cv_lbl_have_run_path)
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Checks to see if unaligned memory accesses fail
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl
|
||||
dnl AC_LBL_UNALIGNED_ACCESS
|
||||
dnl
|
||||
dnl results:
|
||||
dnl
|
||||
dnl LBL_ALIGN (DEFINED)
|
||||
dnl
|
||||
AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
|
||||
[AC_MSG_CHECKING(if unaligned accesses fail)
|
||||
AC_CACHE_VAL(ac_cv_lbl_unaligned_fail,
|
||||
[case "$host_cpu" in
|
||||
|
||||
#
|
||||
# These are CPU types where:
|
||||
#
|
||||
# the CPU faults on an unaligned access, but at least some
|
||||
# OSes that support that CPU catch the fault and simulate
|
||||
# the unaligned access (e.g., Alpha/{Digital,Tru64} UNIX) -
|
||||
# the simulation is slow, so we don't want to use it;
|
||||
#
|
||||
# the CPU, I infer (from the old
|
||||
#
|
||||
# XXX: should also check that they don't do weird things (like on arm)
|
||||
#
|
||||
# comment) doesn't fault on unaligned accesses, but doesn't
|
||||
# do a normal unaligned fetch, either (e.g., presumably, ARM);
|
||||
#
|
||||
# for whatever reason, the test program doesn't work
|
||||
# (this has been claimed to be the case for several of those
|
||||
# CPUs - I don't know what the problem is; the problem
|
||||
# was reported as "the test program dumps core" for SuperH,
|
||||
# but that's what the test program is *supposed* to do -
|
||||
# it dumps core before it writes anything, so the test
|
||||
# for an empty output file should find an empty output
|
||||
# file and conclude that unaligned accesses don't work).
|
||||
#
|
||||
# This run-time test won't work if you're cross-compiling, so
|
||||
# in order to support cross-compiling for a particular CPU,
|
||||
# we have to wire in the list of CPU types anyway, as far as
|
||||
# I know, so perhaps we should just have a set of CPUs on
|
||||
# which we know it doesn't work, a set of CPUs on which we
|
||||
# know it does work, and have the script just fail on other
|
||||
# cpu types and update it when such a failure occurs.
|
||||
#
|
||||
alpha*|arm*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1)
|
||||
ac_cv_lbl_unaligned_fail=yes
|
||||
;;
|
||||
|
||||
*)
|
||||
cat >conftest.c <<EOF
|
||||
# include <sys/types.h>
|
||||
# include <sys/wait.h>
|
||||
# include <stdio.h>
|
||||
unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
|
||||
main() {
|
||||
unsigned int i;
|
||||
pid_t pid;
|
||||
int status;
|
||||
/* avoid "core dumped" message */
|
||||
pid = fork();
|
||||
if (pid < 0)
|
||||
exit(2);
|
||||
if (pid > 0) {
|
||||
/* parent */
|
||||
pid = waitpid(pid, &status, 0);
|
||||
if (pid < 0)
|
||||
exit(3);
|
||||
exit(!WIFEXITED(status));
|
||||
}
|
||||
/* child */
|
||||
i = *(unsigned int *)&a[[1]];
|
||||
printf("%d\n", i);
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
|
||||
conftest.c $LIBS >/dev/null 2>&1
|
||||
if test ! -x conftest ; then
|
||||
dnl failed to compile for some reason
|
||||
ac_cv_lbl_unaligned_fail=yes
|
||||
else
|
||||
./conftest >conftest.out
|
||||
if test ! -s conftest.out ; then
|
||||
ac_cv_lbl_unaligned_fail=yes
|
||||
else
|
||||
ac_cv_lbl_unaligned_fail=no
|
||||
fi
|
||||
fi
|
||||
rm -f -r conftest* core core.conftest
|
||||
;;
|
||||
esac])
|
||||
AC_MSG_RESULT($ac_cv_lbl_unaligned_fail)
|
||||
if test $ac_cv_lbl_unaligned_fail = yes ; then
|
||||
AC_DEFINE(LBL_ALIGN,1,[if unaligned access fails])
|
||||
fi])
|
||||
|
||||
dnl
|
||||
dnl If the file .devel exists:
|
||||
dnl Add some warning flags if the compiler supports them
|
||||
|
@ -877,16 +833,16 @@ AC_DEFUN(AC_LBL_DEVEL,
|
|||
# Skip all the warning option stuff on some compilers.
|
||||
#
|
||||
if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
|
||||
AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR()
|
||||
AC_LBL_CHECK_COMPILER_OPT($1, -W)
|
||||
AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
|
||||
AC_LBL_CHECK_COMPILER_OPT($1, -Wcomma)
|
||||
AC_LBL_CHECK_COMPILER_OPT($1, -Wdeclaration-after-statement)
|
||||
AC_LBL_CHECK_COMPILER_OPT($1, -Wdocumentation)
|
||||
AC_LBL_CHECK_COMPILER_OPT($1, -Wformat-nonliteral)
|
||||
AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-noreturn)
|
||||
AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
|
||||
AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-variable-declarations)
|
||||
AC_LBL_CHECK_COMPILER_OPT($1, -Wpointer-arith)
|
||||
AC_LBL_CHECK_COMPILER_OPT($1, -Wpointer-sign)
|
||||
AC_LBL_CHECK_COMPILER_OPT($1, -Wshadow)
|
||||
AC_LBL_CHECK_COMPILER_OPT($1, -Wsign-compare)
|
||||
AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
|
||||
|
@ -930,6 +886,7 @@ testme(unsigned short a)
|
|||
}
|
||||
],
|
||||
[generates warnings from ntohs()])
|
||||
AC_LBL_CHECK_COMPILER_OPT($1, -Wshorten-64-to-32)
|
||||
fi
|
||||
AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT()
|
||||
#
|
||||
|
@ -1057,9 +1014,22 @@ AC_DEFUN(AC_LBL_LIBRARY_NET, [
|
|||
],
|
||||
[
|
||||
#
|
||||
# We didn't find it.
|
||||
# Not found in libsocket; test for it in libnetwork, which
|
||||
# is where it is in Haiku.
|
||||
#
|
||||
AC_MSG_ERROR([getaddrinfo is required, but wasn't found])
|
||||
AC_CHECK_LIB(network, getaddrinfo,
|
||||
[
|
||||
#
|
||||
# OK, we found it in libnetwork.
|
||||
#
|
||||
LIBS="-lnetwork $LIBS"
|
||||
],
|
||||
[
|
||||
#
|
||||
# We didn't find it.
|
||||
#
|
||||
AC_MSG_ERROR([getaddrinfo is required, but wasn't found])
|
||||
])
|
||||
], -lnsl)
|
||||
|
||||
#
|
||||
|
@ -1077,3 +1047,282 @@ AC_DEFUN(AC_LBL_LIBRARY_NET, [
|
|||
# DLPI needs putmsg under HPUX so test for -lstr while we're at it
|
||||
AC_SEARCH_LIBS(putmsg, str)
|
||||
])
|
||||
|
||||
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
|
||||
dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
|
||||
dnl serial 11 (pkg-config-0.29)
|
||||
dnl
|
||||
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
|
||||
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
|
||||
dnl
|
||||
dnl This program is free software; you can redistribute it and/or modify
|
||||
dnl it under the terms of the GNU General Public License as published by
|
||||
dnl the Free Software Foundation; either version 2 of the License, or
|
||||
dnl (at your option) any later version.
|
||||
dnl
|
||||
dnl This program is distributed in the hope that it will be useful, but
|
||||
dnl WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
dnl General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU General Public License
|
||||
dnl along with this program; if not, write to the Free Software
|
||||
dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
dnl 02111-1307, USA.
|
||||
dnl
|
||||
dnl As a special exception to the GNU General Public License, if you
|
||||
dnl distribute this file as part of a program that contains a
|
||||
dnl configuration script generated by Autoconf, you may include it under
|
||||
dnl the same distribution terms that you use for the rest of that
|
||||
dnl program.
|
||||
|
||||
dnl PKG_PREREQ(MIN-VERSION)
|
||||
dnl -----------------------
|
||||
dnl Since: 0.29
|
||||
dnl
|
||||
dnl Verify that the version of the pkg-config macros are at least
|
||||
dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
|
||||
dnl installed version of pkg-config, this checks the developer's version
|
||||
dnl of pkg.m4 when generating configure.
|
||||
dnl
|
||||
dnl To ensure that this macro is defined, also add:
|
||||
dnl m4_ifndef([PKG_PREREQ],
|
||||
dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
|
||||
dnl
|
||||
dnl See the "Since" comment for each macro you use to see what version
|
||||
dnl of the macros you require.
|
||||
m4_defun([PKG_PREREQ],
|
||||
[m4_define([PKG_MACROS_VERSION], [0.29])
|
||||
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
|
||||
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
|
||||
])dnl PKG_PREREQ
|
||||
|
||||
dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
|
||||
dnl ----------------------------------
|
||||
dnl Since: 0.16
|
||||
dnl
|
||||
dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
|
||||
dnl first found in the path. Checks that the version of pkg-config found
|
||||
dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
|
||||
dnl used since that's the first version where most current features of
|
||||
dnl pkg-config existed.
|
||||
AC_DEFUN([PKG_PROG_PKG_CONFIG],
|
||||
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
|
||||
m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
|
||||
m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
|
||||
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
|
||||
AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
|
||||
AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
|
||||
|
||||
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
|
||||
AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
|
||||
fi
|
||||
if test -n "$PKG_CONFIG"; then
|
||||
_pkg_min_version=m4_default([$1], [0.9.0])
|
||||
AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
|
||||
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
PKG_CONFIG=""
|
||||
fi
|
||||
fi[]dnl
|
||||
])dnl PKG_PROG_PKG_CONFIG
|
||||
|
||||
dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
|
||||
dnl -------------------------------------------------------------------
|
||||
dnl Since: 0.18
|
||||
dnl
|
||||
dnl Check to see whether a particular set of modules exists. Similar to
|
||||
dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
|
||||
AC_DEFUN([PKG_CHECK_EXISTS],
|
||||
[
|
||||
if test -n "$PKG_CONFIG" && \
|
||||
AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
|
||||
m4_default([$2], [:])
|
||||
m4_ifvaln([$3], [else
|
||||
$3])dnl
|
||||
fi])
|
||||
|
||||
dnl _PKG_CONFIG([VARIABLE], [FLAGS], [MODULES])
|
||||
dnl ---------------------------------------------
|
||||
dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
|
||||
dnl pkg_failed based on the result.
|
||||
m4_define([_PKG_CONFIG],
|
||||
[if test -n "$$1"; then
|
||||
pkg_cv_[]$1="$$1"
|
||||
elif test -n "$PKG_CONFIG"; then
|
||||
PKG_CHECK_EXISTS([$3],
|
||||
[pkg_cv_[]$1=`$PKG_CONFIG $2 "$3" 2>/dev/null`
|
||||
test "x$?" != "x0" && pkg_failed=yes ],
|
||||
[pkg_failed=yes])
|
||||
else
|
||||
pkg_failed=untried
|
||||
fi[]dnl
|
||||
])dnl _PKG_CONFIG
|
||||
|
||||
dnl _PKG_SHORT_ERRORS_SUPPORTED
|
||||
dnl ---------------------------
|
||||
dnl Internal check to see if pkg-config supports short errors.
|
||||
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
|
||||
[
|
||||
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
|
||||
_pkg_short_errors_supported=yes
|
||||
else
|
||||
_pkg_short_errors_supported=no
|
||||
fi[]dnl
|
||||
])dnl _PKG_SHORT_ERRORS_SUPPORTED
|
||||
|
||||
|
||||
dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
|
||||
dnl [ACTION-IF-NOT-FOUND])
|
||||
dnl --------------------------------------------------------------
|
||||
dnl Since: 0.4.0
|
||||
AC_DEFUN([PKG_CHECK_MODULES],
|
||||
[
|
||||
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $2, overriding pkg-config])dnl
|
||||
AC_ARG_VAR([$1][_LIBS], [linker flags for $2, overriding pkg-config])dnl
|
||||
AC_ARG_VAR([$1][_LIBS_STATIC], [static-link linker flags for $2, overriding pkg-config])dnl
|
||||
|
||||
pkg_failed=no
|
||||
AC_MSG_CHECKING([for $2 with pkg-config])
|
||||
PKG_CHECK_EXISTS($2,
|
||||
[
|
||||
#
|
||||
# The package was found, so try to get its C flags and
|
||||
# libraries.
|
||||
#
|
||||
_PKG_CONFIG([$1][_CFLAGS], [--cflags], [$2])
|
||||
_PKG_CONFIG([$1][_LIBS], [--libs], [$2])
|
||||
_PKG_CONFIG([$1][_LIBS_STATIC], [--libs --static], [$2])
|
||||
|
||||
m4_define([_PKG_TEXT], [
|
||||
Alternatively, you may set the environment variables $1[]_CFLAGS
|
||||
and $1[]_LIBS to avoid the need to call pkg-config.
|
||||
See the pkg-config man page for more details.])
|
||||
|
||||
if test $pkg_failed = yes; then
|
||||
#
|
||||
# That failed - report an error.
|
||||
#
|
||||
AC_MSG_RESULT([error])
|
||||
_PKG_SHORT_ERRORS_SUPPORTED
|
||||
if test $_pkg_short_errors_supported = yes; then
|
||||
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
|
||||
else
|
||||
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
|
||||
fi
|
||||
# Put the nasty error message in config.log where it belongs
|
||||
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
|
||||
|
||||
m4_default([$4], [AC_MSG_ERROR(
|
||||
[Package requirements ($2) were not met:
|
||||
|
||||
$$1_PKG_ERRORS
|
||||
|
||||
Consider adjusting the PKG_CONFIG_PATH environment variable if you
|
||||
installed software in a non-standard prefix.
|
||||
|
||||
_PKG_TEXT])[]dnl
|
||||
])
|
||||
elif test $pkg_failed = untried; then
|
||||
#
|
||||
# We don't have pkg-config, so it didn't work.
|
||||
#
|
||||
AC_MSG_RESULT([not found (pkg-config not found)])
|
||||
else
|
||||
#
|
||||
# We found the package.
|
||||
#
|
||||
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
|
||||
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
|
||||
$1[]_LIBS_STATIC=$pkg_cv_[]$1[]_LIBS_STATIC
|
||||
AC_MSG_RESULT([found])
|
||||
$3
|
||||
fi[]dnl
|
||||
],
|
||||
[
|
||||
#
|
||||
# The package isn't present.
|
||||
#
|
||||
AC_MSG_RESULT([not found])
|
||||
])
|
||||
])dnl PKG_CHECK_MODULES
|
||||
|
||||
|
||||
dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
|
||||
dnl [ACTION-IF-NOT-FOUND])
|
||||
dnl ---------------------------------------------------------------------
|
||||
dnl Since: 0.29
|
||||
dnl
|
||||
dnl Checks for existence of MODULES and gathers its build flags with
|
||||
dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
|
||||
dnl and VARIABLE-PREFIX_LIBS from --libs.
|
||||
AC_DEFUN([PKG_CHECK_MODULES_STATIC],
|
||||
[
|
||||
_save_PKG_CONFIG=$PKG_CONFIG
|
||||
PKG_CONFIG="$PKG_CONFIG --static"
|
||||
PKG_CHECK_MODULES($@)
|
||||
PKG_CONFIG=$_save_PKG_CONFIG[]dnl
|
||||
])dnl PKG_CHECK_MODULES_STATIC
|
||||
|
||||
|
||||
dnl PKG_INSTALLDIR([DIRECTORY])
|
||||
dnl -------------------------
|
||||
dnl Since: 0.27
|
||||
dnl
|
||||
dnl Substitutes the variable pkgconfigdir as the location where a module
|
||||
dnl should install pkg-config .pc files. By default the directory is
|
||||
dnl $libdir/pkgconfig, but the default can be changed by passing
|
||||
dnl DIRECTORY. The user can override through the --with-pkgconfigdir
|
||||
dnl parameter.
|
||||
AC_DEFUN([PKG_INSTALLDIR],
|
||||
[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
|
||||
m4_pushdef([pkg_description],
|
||||
[pkg-config installation directory @<:@]pkg_default[@:>@])
|
||||
AC_ARG_WITH([pkgconfigdir],
|
||||
[AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
|
||||
[with_pkgconfigdir=]pkg_default)
|
||||
AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
|
||||
m4_popdef([pkg_default])
|
||||
m4_popdef([pkg_description])
|
||||
])dnl PKG_INSTALLDIR
|
||||
|
||||
|
||||
dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
|
||||
dnl --------------------------------
|
||||
dnl Since: 0.27
|
||||
dnl
|
||||
dnl Substitutes the variable noarch_pkgconfigdir as the location where a
|
||||
dnl module should install arch-independent pkg-config .pc files. By
|
||||
dnl default the directory is $datadir/pkgconfig, but the default can be
|
||||
dnl changed by passing DIRECTORY. The user can override through the
|
||||
dnl --with-noarch-pkgconfigdir parameter.
|
||||
AC_DEFUN([PKG_NOARCH_INSTALLDIR],
|
||||
[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
|
||||
m4_pushdef([pkg_description],
|
||||
[pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
|
||||
AC_ARG_WITH([noarch-pkgconfigdir],
|
||||
[AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
|
||||
[with_noarch_pkgconfigdir=]pkg_default)
|
||||
AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
|
||||
m4_popdef([pkg_default])
|
||||
m4_popdef([pkg_description])
|
||||
])dnl PKG_NOARCH_INSTALLDIR
|
||||
|
||||
|
||||
dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
|
||||
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
|
||||
dnl -------------------------------------------
|
||||
dnl Since: 0.28
|
||||
dnl
|
||||
dnl Retrieves the value of the pkg-config variable for the given module.
|
||||
AC_DEFUN([PKG_CHECK_VAR],
|
||||
[
|
||||
AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
|
||||
|
||||
_PKG_CONFIG([$1], [--variable="][$3]["], [$2])
|
||||
AS_VAR_COPY([$1], [pkg_cv_][$1])
|
||||
|
||||
AS_VAR_IF([$1], [""], [$5], [$4])dnl
|
||||
])dnl PKG_CHECK_VAR
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
#define PROTO_POS 0 /* offset of protocol discriminator */
|
||||
#define CALL_REF_POS 2 /* offset of call reference value */
|
||||
#define MSG_TYPE_POS 5 /* offset of message type */
|
||||
#define MSG_LEN_POS 7 /* offset of mesage length */
|
||||
#define MSG_LEN_POS 7 /* offset of message length */
|
||||
#define IE_BEGIN_POS 9 /* offset of first information element */
|
||||
|
||||
/* format of signalling messages */
|
||||
|
|
|
@ -44,6 +44,11 @@
|
|||
|
||||
#include <pcap/pcap-inttypes.h>
|
||||
#include "pcap-types.h"
|
||||
#include "extract.h"
|
||||
#include "diag-control.h"
|
||||
|
||||
#define EXTRACT_SHORT EXTRACT_BE_U_2
|
||||
#define EXTRACT_LONG EXTRACT_BE_U_4
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <sys/param.h>
|
||||
|
@ -55,42 +60,6 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define int32 bpf_int32
|
||||
#define u_int32 bpf_u_int32
|
||||
|
||||
#ifndef LBL_ALIGN
|
||||
/*
|
||||
* XXX - IA-64? If not, this probably won't work on Win64 IA-64
|
||||
* systems, unless LBL_ALIGN is defined elsewhere for them.
|
||||
* XXX - SuperH? If not, this probably won't work on WinCE SuperH
|
||||
* systems, unless LBL_ALIGN is defined elsewhere for them.
|
||||
*/
|
||||
#if defined(sparc) || defined(__sparc__) || defined(mips) || \
|
||||
defined(ibm032) || defined(__alpha) || defined(__hpux) || \
|
||||
defined(__arm__)
|
||||
#define LBL_ALIGN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LBL_ALIGN
|
||||
#ifndef _WIN32
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#define EXTRACT_SHORT(p) ((u_short)ntohs(*(u_short *)p))
|
||||
#define EXTRACT_LONG(p) (ntohl(*(u_int32 *)p))
|
||||
#else
|
||||
#define EXTRACT_SHORT(p)\
|
||||
((u_short)\
|
||||
((u_short)*((u_char *)p+0)<<8|\
|
||||
(u_short)*((u_char *)p+1)<<0))
|
||||
#define EXTRACT_LONG(p)\
|
||||
((u_int32)*((u_char *)p+0)<<24|\
|
||||
(u_int32)*((u_char *)p+1)<<16|\
|
||||
(u_int32)*((u_char *)p+2)<<8|\
|
||||
(u_int32)*((u_char *)p+3)<<0)
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#include <linux/types.h>
|
||||
#include <linux/if_packet.h>
|
||||
|
@ -115,13 +84,19 @@ enum {
|
|||
*
|
||||
* Thanks to Ani Sinha <ani@arista.com> for providing initial implementation
|
||||
*/
|
||||
#if defined(SKF_AD_VLAN_TAG_PRESENT)
|
||||
u_int
|
||||
bpf_filter_with_aux_data(const struct bpf_insn *pc, const u_char *p,
|
||||
u_int wirelen, u_int buflen, const struct bpf_aux_data *aux_data)
|
||||
pcap_filter_with_aux_data(const struct bpf_insn *pc, const u_char *p,
|
||||
u_int wirelen, u_int buflen, const struct pcap_bpf_aux_data *aux_data)
|
||||
#else
|
||||
u_int
|
||||
pcap_filter_with_aux_data(const struct bpf_insn *pc, const u_char *p,
|
||||
u_int wirelen, u_int buflen, const struct pcap_bpf_aux_data *aux_data _U_)
|
||||
#endif
|
||||
{
|
||||
register u_int32 A, X;
|
||||
register uint32_t A, X;
|
||||
register bpf_u_int32 k;
|
||||
u_int32 mem[BPF_MEMWORDS];
|
||||
uint32_t mem[BPF_MEMWORDS];
|
||||
|
||||
if (pc == 0)
|
||||
/*
|
||||
|
@ -160,6 +135,13 @@ bpf_filter_with_aux_data(const struct bpf_insn *pc, const u_char *p,
|
|||
continue;
|
||||
|
||||
case BPF_LD|BPF_B|BPF_ABS:
|
||||
/*
|
||||
* Yes, we know, this switch doesn't do
|
||||
* anything unless we're building for
|
||||
* a Linux kernel with removed VLAN
|
||||
* tags available as meta-data.
|
||||
*/
|
||||
DIAG_OFF_DEFAULT_ONLY_SWITCH
|
||||
switch (pc->k) {
|
||||
|
||||
#if defined(SKF_AD_VLAN_TAG_PRESENT)
|
||||
|
@ -183,6 +165,7 @@ bpf_filter_with_aux_data(const struct bpf_insn *pc, const u_char *p,
|
|||
A = p[k];
|
||||
break;
|
||||
}
|
||||
DIAG_ON_DEFAULT_ONLY_SWITCH
|
||||
continue;
|
||||
|
||||
case BPF_LD|BPF_W|BPF_LEN:
|
||||
|
@ -405,13 +388,12 @@ bpf_filter_with_aux_data(const struct bpf_insn *pc, const u_char *p,
|
|||
}
|
||||
|
||||
u_int
|
||||
bpf_filter(const struct bpf_insn *pc, const u_char *p, u_int wirelen,
|
||||
pcap_filter(const struct bpf_insn *pc, const u_char *p, u_int wirelen,
|
||||
u_int buflen)
|
||||
{
|
||||
return bpf_filter_with_aux_data(pc, p, wirelen, buflen, NULL);
|
||||
return pcap_filter_with_aux_data(pc, p, wirelen, buflen, NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Return true if the 'fcode' is a valid filter program.
|
||||
* The constraints are that each jump be forward and to a valid
|
||||
|
@ -424,7 +406,7 @@ bpf_filter(const struct bpf_insn *pc, const u_char *p, u_int wirelen,
|
|||
* Otherwise, a bogus program could easily crash the system.
|
||||
*/
|
||||
int
|
||||
bpf_validate(const struct bpf_insn *f, int len)
|
||||
pcap_validate_filter(const struct bpf_insn *f, int len)
|
||||
{
|
||||
u_int i, from;
|
||||
const struct bpf_insn *p;
|
||||
|
@ -546,3 +528,19 @@ bpf_validate(const struct bpf_insn *f, int len)
|
|||
}
|
||||
return BPF_CLASS(f[len - 1].code) == BPF_RET;
|
||||
}
|
||||
|
||||
/*
|
||||
* Exported because older versions of libpcap exported them.
|
||||
*/
|
||||
u_int
|
||||
bpf_filter(const struct bpf_insn *pc, const u_char *p, u_int wirelen,
|
||||
u_int buflen)
|
||||
{
|
||||
return pcap_filter(pc, p, wirelen, buflen);
|
||||
}
|
||||
|
||||
int
|
||||
bpf_validate(const struct bpf_insn *f, int len)
|
||||
{
|
||||
return pcap_validate_filter(f, len);
|
||||
}
|
||||
|
|
|
@ -28,12 +28,104 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <linux/types.h>
|
||||
#include <linux/if_packet.h>
|
||||
#include <linux/filter.h>
|
||||
|
||||
/*
|
||||
* We want our versions of these #defines, not Linux's version.
|
||||
* (The two should be the same; if not, we have a problem; all BPF
|
||||
* implementations *should* be source-compatible supersets of ours.)
|
||||
*/
|
||||
#undef BPF_STMT
|
||||
#undef BPF_JUMP
|
||||
#endif
|
||||
|
||||
#include "pcap-int.h"
|
||||
|
||||
#ifdef HAVE_OS_PROTO_H
|
||||
#include "os-proto.h"
|
||||
#endif
|
||||
|
||||
#ifdef SKF_AD_OFF
|
||||
/*
|
||||
* Symbolic names for offsets that refer to the special Linux BPF locations.
|
||||
*/
|
||||
static const char *offsets[SKF_AD_MAX] = {
|
||||
#ifdef SKF_AD_PROTOCOL
|
||||
[SKF_AD_PROTOCOL] = "proto",
|
||||
#endif
|
||||
#ifdef SKF_AD_PKTTYPE
|
||||
[SKF_AD_PKTTYPE] = "type",
|
||||
#endif
|
||||
#ifdef SKF_AD_IFINDEX
|
||||
[SKF_AD_IFINDEX] = "ifidx",
|
||||
#endif
|
||||
#ifdef SKF_AD_NLATTR
|
||||
[SKF_AD_NLATTR] = "nla",
|
||||
#endif
|
||||
#ifdef SKF_AD_NLATTR_NEST
|
||||
[SKF_AD_NLATTR_NEST] = "nlan",
|
||||
#endif
|
||||
#ifdef SKF_AD_MARK
|
||||
[SKF_AD_MARK] = "mark",
|
||||
#endif
|
||||
#ifdef SKF_AD_QUEUE
|
||||
[SKF_AD_QUEUE] = "queue",
|
||||
#endif
|
||||
#ifdef SKF_AD_HATYPE
|
||||
[SKF_AD_HATYPE] = "hatype",
|
||||
#endif
|
||||
#ifdef SKF_AD_RXHASH
|
||||
[SKF_AD_RXHASH] = "rxhash",
|
||||
#endif
|
||||
#ifdef SKF_AD_CPU
|
||||
[SKF_AD_CPU] = "cpu",
|
||||
#endif
|
||||
#ifdef SKF_AD_ALU_XOR_X
|
||||
[SKF_AD_ALU_XOR_X] = "xor_x",
|
||||
#endif
|
||||
#ifdef SKF_AD_VLAN_TAG
|
||||
[SKF_AD_VLAN_TAG] = "vlan_tci",
|
||||
#endif
|
||||
#ifdef SKF_AD_VLAN_TAG_PRESENT
|
||||
[SKF_AD_VLAN_TAG_PRESENT] = "vlanp",
|
||||
#endif
|
||||
#ifdef SKF_AD_PAY_OFFSET
|
||||
[SKF_AD_PAY_OFFSET] = "poff",
|
||||
#endif
|
||||
#ifdef SKF_AD_RANDOM
|
||||
[SKF_AD_RANDOM] = "random",
|
||||
#endif
|
||||
#ifdef SKF_AD_VLAN_TPID
|
||||
[SKF_AD_VLAN_TPID] = "vlan_tpid"
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
static void
|
||||
bpf_print_abs_load_operand(char *buf, size_t bufsize, const struct bpf_insn *p)
|
||||
{
|
||||
#ifdef SKF_AD_OFF
|
||||
const char *sym;
|
||||
|
||||
/*
|
||||
* It's an absolute load.
|
||||
* Is the offset a special Linux offset that we know about?
|
||||
*/
|
||||
if (p->k >= (bpf_u_int32)SKF_AD_OFF &&
|
||||
p->k < (bpf_u_int32)(SKF_AD_OFF + SKF_AD_MAX) &&
|
||||
(sym = offsets[p->k - (bpf_u_int32)SKF_AD_OFF]) != NULL) {
|
||||
/*
|
||||
* Yes. Print the offset symbolically.
|
||||
*/
|
||||
(void)snprintf(buf, bufsize, "[%s]", sym);
|
||||
} else
|
||||
#endif
|
||||
(void)snprintf(buf, bufsize, "[%d]", p->k);
|
||||
}
|
||||
|
||||
char *
|
||||
bpf_image(const struct bpf_insn *p, int n)
|
||||
{
|
||||
|
@ -46,13 +138,13 @@ bpf_image(const struct bpf_insn *p, int n)
|
|||
|
||||
default:
|
||||
op = "unimp";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "0x%x", p->code);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "0x%x", p->code);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_RET|BPF_K:
|
||||
op = "ret";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "#%d", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
|
@ -63,19 +155,19 @@ bpf_image(const struct bpf_insn *p, int n)
|
|||
|
||||
case BPF_LD|BPF_W|BPF_ABS:
|
||||
op = "ld";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "[%d]", p->k);
|
||||
bpf_print_abs_load_operand(operand_buf, sizeof operand_buf, p);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_LD|BPF_H|BPF_ABS:
|
||||
op = "ldh";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "[%d]", p->k);
|
||||
bpf_print_abs_load_operand(operand_buf, sizeof operand_buf, p);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_LD|BPF_B|BPF_ABS:
|
||||
op = "ldb";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "[%d]", p->k);
|
||||
bpf_print_abs_load_operand(operand_buf, sizeof operand_buf, p);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
|
@ -86,91 +178,91 @@ bpf_image(const struct bpf_insn *p, int n)
|
|||
|
||||
case BPF_LD|BPF_W|BPF_IND:
|
||||
op = "ld";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "[x + %d]", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "[x + %d]", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_LD|BPF_H|BPF_IND:
|
||||
op = "ldh";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "[x + %d]", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "[x + %d]", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_LD|BPF_B|BPF_IND:
|
||||
op = "ldb";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "[x + %d]", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "[x + %d]", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_LD|BPF_IMM:
|
||||
op = "ld";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_LDX|BPF_IMM:
|
||||
op = "ldx";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_LDX|BPF_MSH|BPF_B:
|
||||
op = "ldxb";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "4*([%d]&0xf)", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "4*([%d]&0xf)", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_LD|BPF_MEM:
|
||||
op = "ld";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_LDX|BPF_MEM:
|
||||
op = "ldx";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_ST:
|
||||
op = "st";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_STX:
|
||||
op = "stx";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_JMP|BPF_JA:
|
||||
op = "ja";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "%d", n + 1 + p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "%d", n + 1 + p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_JMP|BPF_JGT|BPF_K:
|
||||
op = "jgt";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_JMP|BPF_JGE|BPF_K:
|
||||
op = "jge";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_JMP|BPF_JEQ|BPF_K:
|
||||
op = "jeq";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_JMP|BPF_JSET|BPF_K:
|
||||
op = "jset";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
|
@ -246,61 +338,61 @@ bpf_image(const struct bpf_insn *p, int n)
|
|||
|
||||
case BPF_ALU|BPF_ADD|BPF_K:
|
||||
op = "add";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "#%d", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_SUB|BPF_K:
|
||||
op = "sub";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "#%d", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_MUL|BPF_K:
|
||||
op = "mul";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "#%d", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_DIV|BPF_K:
|
||||
op = "div";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "#%d", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_MOD|BPF_K:
|
||||
op = "mod";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "#%d", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_AND|BPF_K:
|
||||
op = "and";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_OR|BPF_K:
|
||||
op = "or";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_XOR|BPF_K:
|
||||
op = "xor";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_LSH|BPF_K:
|
||||
op = "lsh";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "#%d", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_RSH|BPF_K:
|
||||
op = "rsh";
|
||||
(void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k);
|
||||
(void)snprintf(operand_buf, sizeof operand_buf, "#%d", p->k);
|
||||
operand = operand_buf;
|
||||
break;
|
||||
|
||||
|
@ -320,11 +412,11 @@ bpf_image(const struct bpf_insn *p, int n)
|
|||
break;
|
||||
}
|
||||
if (BPF_CLASS(p->code) == BPF_JMP && BPF_OP(p->code) != BPF_JA) {
|
||||
(void)pcap_snprintf(image, sizeof image,
|
||||
(void)snprintf(image, sizeof image,
|
||||
"(%03d) %-8s %-16s jt %d\tjf %d",
|
||||
n, op, operand, n + 1 + p->jt, n + 1 + p->jf);
|
||||
} else {
|
||||
(void)pcap_snprintf(image, sizeof image,
|
||||
(void)snprintf(image, sizeof image,
|
||||
"(%03d) %-8s %s",
|
||||
n, op, operand);
|
||||
}
|
||||
|
|
217
contrib/libpcap/charconv.c
Normal file
217
contrib/libpcap/charconv.c
Normal file
|
@ -0,0 +1,217 @@
|
|||
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1995, 1996, 1997
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the Computer Systems
|
||||
* Engineering Group at Lawrence Berkeley Laboratory.
|
||||
* 4. Neither the name of the University nor of the Laboratory may be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <pcap/pcap.h> /* Needed for PCAP_ERRBUF_SIZE */
|
||||
|
||||
#include "charconv.h"
|
||||
|
||||
wchar_t *
|
||||
cp_to_utf_16le(UINT codepage, const char *cp_string, DWORD flags)
|
||||
{
|
||||
int utf16le_len;
|
||||
wchar_t *utf16le_string;
|
||||
|
||||
/*
|
||||
* Map from the specified code page to UTF-16LE.
|
||||
* First, find out how big a buffer we'll need.
|
||||
*/
|
||||
utf16le_len = MultiByteToWideChar(codepage, flags, cp_string, -1,
|
||||
NULL, 0);
|
||||
if (utf16le_len == 0) {
|
||||
/*
|
||||
* Error. Fail with EINVAL.
|
||||
*/
|
||||
errno = EINVAL;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Now attempt to allocate a buffer for that.
|
||||
*/
|
||||
utf16le_string = malloc(utf16le_len * sizeof (wchar_t));
|
||||
if (utf16le_string == NULL) {
|
||||
/*
|
||||
* Not enough memory; assume errno has been
|
||||
* set, and fail.
|
||||
*/
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Now convert.
|
||||
*/
|
||||
utf16le_len = MultiByteToWideChar(codepage, flags, cp_string, -1,
|
||||
utf16le_string, utf16le_len);
|
||||
if (utf16le_len == 0) {
|
||||
/*
|
||||
* Error. Fail with EINVAL.
|
||||
* XXX - should this ever happen, given that
|
||||
* we already ran the string through
|
||||
* MultiByteToWideChar() to find out how big
|
||||
* a buffer we needed?
|
||||
*/
|
||||
free(utf16le_string);
|
||||
errno = EINVAL;
|
||||
return (NULL);
|
||||
}
|
||||
return (utf16le_string);
|
||||
}
|
||||
|
||||
char *
|
||||
utf_16le_to_cp(UINT codepage, const wchar_t *utf16le_string)
|
||||
{
|
||||
int cp_len;
|
||||
char *cp_string;
|
||||
|
||||
/*
|
||||
* Map from UTF-16LE to the specified code page.
|
||||
* First, find out how big a buffer we'll need.
|
||||
* We convert composite characters to precomposed characters,
|
||||
* as that's what Windows expects.
|
||||
*/
|
||||
cp_len = WideCharToMultiByte(codepage, WC_COMPOSITECHECK,
|
||||
utf16le_string, -1, NULL, 0, NULL, NULL);
|
||||
if (cp_len == 0) {
|
||||
/*
|
||||
* Error. Fail with EINVAL.
|
||||
*/
|
||||
errno = EINVAL;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Now attempt to allocate a buffer for that.
|
||||
*/
|
||||
cp_string = malloc(cp_len * sizeof (char));
|
||||
if (cp_string == NULL) {
|
||||
/*
|
||||
* Not enough memory; assume errno has been
|
||||
* set, and fail.
|
||||
*/
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Now convert.
|
||||
*/
|
||||
cp_len = WideCharToMultiByte(codepage, WC_COMPOSITECHECK,
|
||||
utf16le_string, -1, cp_string, cp_len, NULL, NULL);
|
||||
if (cp_len == 0) {
|
||||
/*
|
||||
* Error. Fail with EINVAL.
|
||||
* XXX - should this ever happen, given that
|
||||
* we already ran the string through
|
||||
* WideCharToMultiByte() to find out how big
|
||||
* a buffer we needed?
|
||||
*/
|
||||
free(cp_string);
|
||||
errno = EINVAL;
|
||||
return (NULL);
|
||||
}
|
||||
return (cp_string);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an error message string from UTF-8 to the local code page, as
|
||||
* best we can.
|
||||
*
|
||||
* The buffer is assumed to be PCAP_ERRBUF_SIZE bytes long; we truncate
|
||||
* if it doesn't fit.
|
||||
*/
|
||||
void
|
||||
utf_8_to_acp_truncated(char *errbuf)
|
||||
{
|
||||
wchar_t *utf_16_errbuf;
|
||||
int retval;
|
||||
DWORD err;
|
||||
|
||||
/*
|
||||
* Do this by converting to UTF-16LE and then to the local
|
||||
* code page. That means we get to use Microsoft's
|
||||
* conversion routines, rather than having to understand
|
||||
* all the code pages ourselves, *and* that this routine
|
||||
* can convert in place.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Map from UTF-8 to UTF-16LE.
|
||||
* First, find out how big a buffer we'll need.
|
||||
* Convert any invalid characters to REPLACEMENT CHARACTER.
|
||||
*/
|
||||
utf_16_errbuf = cp_to_utf_16le(CP_UTF8, errbuf, 0);
|
||||
if (utf_16_errbuf == NULL) {
|
||||
/*
|
||||
* Error. Give up.
|
||||
*/
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Can't convert error string to the local code page");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now, convert that to the local code page.
|
||||
* Use the current thread's code page. For unconvertable
|
||||
* characters, let it pick the "best fit" character.
|
||||
*
|
||||
* XXX - we'd like some way to do what utf_16le_to_utf_8_truncated()
|
||||
* does if the buffer isn't big enough, but we don't want to have
|
||||
* to handle all local code pages ourselves; doing so requires
|
||||
* knowledge of all those code pages, including knowledge of how
|
||||
* characters are formed in thoe code pages so that we can avoid
|
||||
* cutting a multi-byte character into pieces.
|
||||
*
|
||||
* Converting to an un-truncated string using Windows APIs, and
|
||||
* then copying to the buffer, still requires knowledge of how
|
||||
* characters are formed in the target code page.
|
||||
*/
|
||||
retval = WideCharToMultiByte(CP_THREAD_ACP, 0, utf_16_errbuf, -1,
|
||||
errbuf, PCAP_ERRBUF_SIZE, NULL, NULL);
|
||||
if (retval == 0) {
|
||||
err = GetLastError();
|
||||
free(utf_16_errbuf);
|
||||
if (err == ERROR_INSUFFICIENT_BUFFER)
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"The error string, in the local code page, didn't fit in the buffer");
|
||||
else
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Can't convert error string to the local code page");
|
||||
return;
|
||||
}
|
||||
free(utf_16_errbuf);
|
||||
}
|
||||
#endif
|
44
contrib/libpcap/charconv.h
Normal file
44
contrib/libpcap/charconv.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1995, 1996, 1997
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the Computer Systems
|
||||
* Engineering Group at Lawrence Berkeley Laboratory.
|
||||
* 4. Neither the name of the University nor of the Laboratory may be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef charconv_h
|
||||
#define charconv_h
|
||||
|
||||
#ifdef _WIN32
|
||||
extern wchar_t *cp_to_utf_16le(UINT codepage, const char *cp_string, DWORD flags);
|
||||
extern char *utf_16le_to_cp(UINT codepage, const wchar_t *utf16le_string);
|
||||
extern void utf_8_to_acp_truncated(char *);
|
||||
#endif
|
||||
|
||||
#endif /* charconv_h */
|
69
contrib/libpcap/cmake/Modules/FindAirPcap.cmake
Normal file
69
contrib/libpcap/cmake/Modules/FindAirPcap.cmake
Normal file
|
@ -0,0 +1,69 @@
|
|||
#
|
||||
# FindAirPcap
|
||||
# ==========
|
||||
#
|
||||
# Find the AirPcap library and include files.
|
||||
#
|
||||
# This module defines the following variables:
|
||||
#
|
||||
# AirPcap_INCLUDE_DIR - absolute path to the directory containing airpcap.h.
|
||||
#
|
||||
# AirPcap_LIBRARY - relative or absolute path to the AirPcap library to
|
||||
# link with. An absolute path is will be used if the
|
||||
# AirPcap library is not located in the compiler's
|
||||
# default search path.
|
||||
|
||||
# AirPcap_FOUND - TRUE if the AirPcap library *and* header are found.
|
||||
#
|
||||
# Hints and Backward Compatibility
|
||||
# ================================
|
||||
#
|
||||
# To tell this module where to look, a user may set the environment variable
|
||||
# AirPcap_ROOT to point cmake to the *root* of a directory with include and
|
||||
# lib subdirectories for airpcap.dll (e.g Airpcap_Devpack).
|
||||
# Alternatively, AirPcap_ROOT may also be set from the CMake command
|
||||
# line or GUI (e.g cmake -DAirPcap_ROOT=C:\path\to\airpcap_sdk [...])
|
||||
#
|
||||
|
||||
# The 64-bit airpcap.lib is located under /x64
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
#
|
||||
# For the WinPcap and Npcap SDKs, the Lib subdirectory of the top-level
|
||||
# directory contains 32-bit libraries; the 64-bit libraries are in the
|
||||
# Lib/x64 directory.
|
||||
#
|
||||
# The only way to *FORCE* CMake to look in the Lib/x64 directory
|
||||
# without searching in the Lib directory first appears to be to set
|
||||
# CMAKE_LIBRARY_ARCHITECTURE to "x64".
|
||||
#
|
||||
# In newer versions of CMake, CMAKE_LIBRARY_ARCHITECTURE is set according to
|
||||
# the language, e.g., CMAKE_<LANG>_LIBRARY_ARCHITECTURE. So, set the new
|
||||
# variable, CMAKE_C_LIBRARY_ARCHITECTURE, so that CMAKE_LIBRARY_ARCHITECTURE
|
||||
# inherits the correct value.
|
||||
#
|
||||
set(CMAKE_C_LIBRARY_ARCHITECTURE "x64")
|
||||
set(CMAKE_LIBRARY_ARCHITECTURE "x64")
|
||||
endif()
|
||||
|
||||
# Find the header
|
||||
find_path(AirPcap_INCLUDE_DIR airpcap.h
|
||||
PATH_SUFFIXES include
|
||||
)
|
||||
|
||||
# Find the library
|
||||
find_library(AirPcap_LIBRARY
|
||||
NAMES airpcap
|
||||
)
|
||||
|
||||
# Set AirPcap_FOUND to TRUE if AirPcap_INCLUDE_DIR and AirPcap_LIBRARY are TRUE.
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(AirPcap
|
||||
DEFAULT_MSG
|
||||
AirPcap_INCLUDE_DIR
|
||||
AirPcap_LIBRARY
|
||||
)
|
||||
|
||||
mark_as_advanced(AirPcap_INCLUDE_DIR AirPcap_LIBRARY)
|
||||
|
||||
set(AirPcap_INCLUDE_DIRS ${AirPcap_INCLUDE_DIR})
|
||||
set(AirPcap_LIBRARIES ${AirPcap_LIBRARY})
|
|
@ -14,6 +14,12 @@ find_path(DAG_INCLUDE_DIR dagapi.h)
|
|||
find_library(DAG_LIBRARY dag)
|
||||
find_library(DAGCONF_LIBRARY dagconf)
|
||||
|
||||
#
|
||||
# Get link information from the _LIBRARY paths.
|
||||
#
|
||||
get_link_info_from_library_path(DAG dag)
|
||||
get_link_info_from_library_path(DAGCONF dagconf)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(DAG
|
||||
DEFAULT_MSG
|
||||
|
@ -30,3 +36,4 @@ mark_as_advanced(
|
|||
|
||||
set(DAG_INCLUDE_DIRS ${DAG_INCLUDE_DIR})
|
||||
set(DAG_LIBRARIES ${DAG_LIBRARY} ${DAGCONF_LIBRARY})
|
||||
set(DAG_STATIC_LIBRARIES ${DAG_LIBRARY} ${DAGCONF_LIBRARY})
|
||||
|
|
|
@ -28,24 +28,23 @@
|
|||
#
|
||||
# This module defines the following variables:
|
||||
#
|
||||
# PACKET_INCLUDE_DIR - absolute path to the directory containing Packet32.h.
|
||||
# Packet_INCLUDE_DIR - absolute path to the directory containing Packet32.h.
|
||||
#
|
||||
# PACKET_LIBRARY - relative or absolute path to the Packet library to
|
||||
# Packet_LIBRARY - relative or absolute path to the Packet library to
|
||||
# link with. An absolute path is will be used if the
|
||||
# Packet library is not located in the compiler's
|
||||
# default search path. See e.g. PACKET_DLL_DIR
|
||||
# variable below.
|
||||
# default search path.
|
||||
|
||||
# PACKET_FOUND - TRUE if the Packet library *and* header are found.
|
||||
# Packet_FOUND - TRUE if the Packet library *and* header are found.
|
||||
#
|
||||
# Hints and Backward Compatibility
|
||||
# ================================
|
||||
#
|
||||
# To tell this module where to look, a user may set the environment variable
|
||||
# PACKET_DLL_DIR to point cmake to the *root* of a directory with include and
|
||||
# lib subdirectories for packet.dll (e.g WpdPack/npcap-sdk).
|
||||
# Alternatively, PACKET_DLL_DIR may also be set from cmake command line or GUI
|
||||
# (e.g cmake -DPACKET_DLL_DIR=/path/to/packet [...])
|
||||
# Packet_ROOT to point cmake to the *root* of a directory with include and
|
||||
# lib subdirectories for packet.dll (e.g WpdPack or npcap-sdk).
|
||||
# Alternatively, Packet_ROOT may also be set from cmake command line or GUI
|
||||
# (e.g cmake -DPacket_ROOT=C:\path\to\packet [...])
|
||||
#
|
||||
|
||||
# The 64-bit Packet.lib is located under /x64
|
||||
|
@ -59,30 +58,52 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|||
# without searching in the Lib directory first appears to be to set
|
||||
# CMAKE_LIBRARY_ARCHITECTURE to "x64".
|
||||
#
|
||||
set(CMAKE_LIBRARY_ARCHITECTURE "x64")
|
||||
# In newer versions of CMake, CMAKE_LIBRARY_ARCHITECTURE is set according to
|
||||
# the language, e.g., CMAKE_<LANG>_LIBRARY_ARCHITECTURE. So, set the new
|
||||
# variable, CMAKE_C_LIBRARY_ARCHITECTURE, so that CMAKE_LIBRARY_ARCHITECTURE
|
||||
# inherits the correct value.
|
||||
#
|
||||
set(archdetect_c_code "
|
||||
#ifndef _M_ARM64
|
||||
#error Not ARM64
|
||||
#endif
|
||||
int main() { return 0; }
|
||||
")
|
||||
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/archdetect.c" "${archdetect_c_code}")
|
||||
try_compile(
|
||||
IsArm64
|
||||
"${CMAKE_BINARY_DIR}/archdetect"
|
||||
"${CMAKE_BINARY_DIR}/archdetect.c"
|
||||
)
|
||||
if(IsArm64)
|
||||
set(CMAKE_C_LIBRARY_ARCHITECTURE "ARM64")
|
||||
set(CMAKE_LIBRARY_ARCHITECTURE "ARM64")
|
||||
else()
|
||||
set(CMAKE_C_LIBRARY_ARCHITECTURE "x64")
|
||||
set(CMAKE_LIBRARY_ARCHITECTURE "x64")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Find the header
|
||||
find_path(PACKET_INCLUDE_DIR Packet32.h
|
||||
HINTS "${PACKET_DLL_DIR}" ENV PACKET_DLL_DIR
|
||||
find_path(Packet_INCLUDE_DIR Packet32.h
|
||||
PATH_SUFFIXES include Include
|
||||
)
|
||||
|
||||
# Find the library
|
||||
find_library(PACKET_LIBRARY
|
||||
find_library(Packet_LIBRARY
|
||||
NAMES Packet packet
|
||||
HINTS "${PACKET_DLL_DIR}" ENV PACKET_DLL_DIR
|
||||
)
|
||||
|
||||
# Set PACKET_FOUND to TRUE if PACKET_INCLUDE_DIR and PACKET_LIBRARY are TRUE.
|
||||
# Set Packet_FOUND to TRUE if Packet_INCLUDE_DIR and Packet_LIBRARY are TRUE.
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(PACKET
|
||||
find_package_handle_standard_args(Packet
|
||||
DEFAULT_MSG
|
||||
PACKET_INCLUDE_DIR
|
||||
PACKET_LIBRARY
|
||||
Packet_INCLUDE_DIR
|
||||
Packet_LIBRARY
|
||||
)
|
||||
|
||||
mark_as_advanced(PACKET_INCLUDE_DIR PACKET_LIBRARY)
|
||||
mark_as_advanced(Packet_INCLUDE_DIR Packet_LIBRARY)
|
||||
|
||||
set(PACKET_INCLUDE_DIRS ${PACKET_INCLUDE_DIR})
|
||||
set(PACKET_LIBRARIES ${PACKET_LIBRARY})
|
||||
set(Packet_INCLUDE_DIRS ${Packet_INCLUDE_DIR})
|
||||
set(Packet_LIBRARIES ${Packet_LIBRARY})
|
||||
|
|
|
@ -8,6 +8,11 @@ find_path(SNF_INCLUDE_DIR snf.h /opt/snf)
|
|||
# Try to find the library
|
||||
find_library(SNF_LIBRARY snf /opt/snf)
|
||||
|
||||
#
|
||||
# Get link information from the _LIBRARY paths.
|
||||
#
|
||||
get_link_info_from_library_path(SNF snf)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(SNF
|
||||
DEFAULT_MSG
|
||||
|
@ -22,3 +27,4 @@ mark_as_advanced(
|
|||
|
||||
set(SNF_INCLUDE_DIRS ${SNF_INCLUDE_DIR})
|
||||
set(SNF_LIBRARIES ${SNF_LIBRARY})
|
||||
set(SNF_STATIC_LIBRARIES ${SNF_LIBRARY})
|
||||
|
|
118
contrib/libpcap/cmake/Modules/Finddpdk.cmake
Normal file
118
contrib/libpcap/cmake/Modules/Finddpdk.cmake
Normal file
|
@ -0,0 +1,118 @@
|
|||
# Try to find dpdk
|
||||
#
|
||||
# Once done, this will define
|
||||
#
|
||||
# dpdk_FOUND
|
||||
# dpdk_INCLUDE_DIRS
|
||||
# dpdk_LIBRARIES
|
||||
# dpdk_STATIC_LIBRARIES
|
||||
# dpdk_LIBS_STATIC
|
||||
# dpdk_REQUIRES_PRIVATE
|
||||
# dpdk_PACKAGE_NAME
|
||||
|
||||
#
|
||||
# We only try to find DPDK using pkg-config; DPDK is *SO*
|
||||
# complicated - DPDK 19.02, for example, has about 117(!)
|
||||
# libraries, and the precise set of libraries required has
|
||||
# changed over time - so attempting to guess which libraries
|
||||
# you need, and hardcoding that in an attempt to find the
|
||||
# libraries without DPDK, rather than relying on DPDK to
|
||||
# tell you, with a .pc file, what libraries are needed,
|
||||
# is *EXTREMELY* fragile and has caused some bug reports,
|
||||
# so we're just not going to do it.
|
||||
#
|
||||
# If that causes a problem, the only thing we will do is
|
||||
# accept an alternative way of finding the appropriate
|
||||
# library set for the installed version of DPDK that is
|
||||
# as robust as pkg-config (i.e., it had better work as well
|
||||
# as pkg-config with *ALL* versions of DPDK that provide a
|
||||
# libdpdk.pc file).
|
||||
#
|
||||
# If dpdk_ROOT is set, add ${dpdk_ROOT}/pkgconfig
|
||||
# to PKG_CONFIG_PATH, so we look for the .pc file there,
|
||||
# first.
|
||||
#
|
||||
if(PKG_CONFIG_FOUND)
|
||||
set(save_PKG_CONFIG_PATH $ENV{PKG_CONFIG_PATH})
|
||||
if(dpdk_ROOT)
|
||||
set(ENV{PKG_CONFIG_PATH} "${dpdk_ROOT}/pkgconfig:$ENV{PKG_CONFIG_PATH}")
|
||||
endif()
|
||||
pkg_check_modules(dpdk QUIET libdpdk)
|
||||
if(dpdk_FOUND)
|
||||
#
|
||||
# Get link information for DPDK.
|
||||
#
|
||||
pkg_get_link_info(dpdk libdpdk)
|
||||
endif()
|
||||
set(ENV{PKG_CONFIG_PATH} "${save_PKG_CONFIG_PATH}")
|
||||
endif()
|
||||
|
||||
mark_as_advanced(dpdk_INCLUDE_DIRS dpdk_LIBRARIES dpdk_STATIC_LIBRARIES dpdk_REQUIRES_PRIVATE)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(dpdk DEFAULT_MSG
|
||||
dpdk_INCLUDE_DIRS
|
||||
dpdk_LIBRARIES)
|
||||
|
||||
if(dpdk_FOUND)
|
||||
#
|
||||
# This depends on CMake support for "imported targets",
|
||||
# which are not supported until CMake 3.19.
|
||||
#
|
||||
# Ubuntu 20.04 provides CMake 3.16.3, so we are *NOT*
|
||||
# going to require CMake 3.19. If you want to use
|
||||
# Shiny New Features(TM), wait until all the OSes on
|
||||
# which a build might conceivably be done, and that
|
||||
# provide CMake, provide 3.19 or later.
|
||||
#
|
||||
# Just don't do this stuff on earlier versions. If that
|
||||
# breaks something, figure out a way to do it *without*
|
||||
# "imported targets", and either do this that way, or,
|
||||
# at least, do it that way on older versions of CMake.
|
||||
#
|
||||
# (One good thing about autotools is that only the builders
|
||||
# of a package, and people doing configure-script development,
|
||||
# have to care about the autoconf etc. version; you don't
|
||||
# even need to have autotools installed in order to be able
|
||||
# to run an autotools-generated configure script, you just
|
||||
# need an environment UN*Xy enough, and modern enough, to
|
||||
# run the stuff in the script.
|
||||
#
|
||||
# This is *NOT* the case for CMake; not only do you need
|
||||
# CMake in order to build a package using CMake, you need
|
||||
# a version recent enough to run the stuff the package's
|
||||
# CMake files use.
|
||||
#
|
||||
# Please keep this in mind when changing any CMake files,
|
||||
# and keep in mind what versions of CMake come with, for
|
||||
# example, commonly-used versions of commonly-used
|
||||
# Linux distributiions.)
|
||||
#
|
||||
if(NOT CMAKE_VERSION VERSION_LESS 3.19)
|
||||
if(NOT TARGET dpdk::cflags)
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64")
|
||||
set(rte_cflags "-march=core2")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|ARM")
|
||||
set(rte_cflags "-march=armv7-a")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|AARCH64")
|
||||
set(rte_cflags "-march=armv8-a+crc")
|
||||
endif()
|
||||
add_library(dpdk::cflags INTERFACE IMPORTED)
|
||||
if (rte_cflags)
|
||||
set_target_properties(dpdk::cflags PROPERTIES
|
||||
INTERFACE_COMPILE_OPTIONS "${rte_cflags}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT TARGET dpdk::dpdk)
|
||||
add_library(dpdk::dpdk INTERFACE IMPORTED)
|
||||
find_package(Threads QUIET)
|
||||
list(APPEND dpdk_LIBRARIES
|
||||
Threads::Threads
|
||||
dpdk::cflags)
|
||||
set_target_properties(dpdk::dpdk PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "${dpdk_LIBRARIES}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${dpdk_INCLUDE_DIRS}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
|
@ -15,9 +15,15 @@
|
|||
/* define if we have the AIX getprotobyname_r() */
|
||||
#cmakedefine HAVE_AIX_GETPROTOBYNAME_R 1
|
||||
|
||||
/* define if you have the AirPcap API */
|
||||
#cmakedefine HAVE_AIRPCAP_API 1
|
||||
|
||||
/* Define to 1 if you have the `asprintf' function. */
|
||||
#cmakedefine HAVE_ASPRINTF 1
|
||||
|
||||
/* Define to 1 if you have the <config/HaikuConfig.h> header file. */
|
||||
#cmakedefine HAVE_CONFIG_HAIKUCONFIG_H 1
|
||||
|
||||
/* define if you have the DAG API */
|
||||
#cmakedefine HAVE_DAG_API 1
|
||||
|
||||
|
@ -69,45 +75,21 @@
|
|||
/* if libnl exists */
|
||||
#cmakedefine HAVE_LIBNL 1
|
||||
|
||||
/* if libnl exists and is version 2.x */
|
||||
#cmakedefine HAVE_LIBNL_2_x 1
|
||||
|
||||
/* if libnl exists and is version 3.x */
|
||||
#cmakedefine HAVE_LIBNL_3_x 1
|
||||
|
||||
/* libnl has NLE_FAILURE */
|
||||
#cmakedefine HAVE_LIBNL_NLE 1
|
||||
|
||||
/* libnl has new-style socket api */
|
||||
#cmakedefine HAVE_LIBNL_SOCKETS 1
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#cmakedefine HAVE_LIMITS_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/compiler.h> header file. */
|
||||
#cmakedefine HAVE_LINUX_COMPILER_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/ethtool.h> header file. */
|
||||
#cmakedefine HAVE_LINUX_ETHTOOL_H 1
|
||||
|
||||
/* define if we have the Linux getnetbyname_r() */
|
||||
#cmakedefine HAVE_LINUX_GETNETBYNAME_R 1
|
||||
|
||||
/* define if we have the Linux getprotobyname_r() */
|
||||
#cmakedefine HAVE_LINUX_GETPROTOBYNAME_R 1
|
||||
|
||||
/* Define to 1 if you have the <linux/if_bonding.h> header file. */
|
||||
#cmakedefine HAVE_LINUX_IF_BONDING_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/net_tstamp.h> header file. */
|
||||
#cmakedefine HAVE_LINUX_NET_TSTAMP_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/socket.h> header file. */
|
||||
#cmakedefine HAVE_LINUX_SOCKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/sockios.h> header file. */
|
||||
#cmakedefine HAVE_LINUX_SOCKIOS_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/usbdevice_fs.h> header file. */
|
||||
#cmakedefine HAVE_LINUX_USBDEVICE_FS_H 1
|
||||
|
||||
|
@ -135,12 +117,12 @@
|
|||
/* Define to 1 if you have the <net/pfilt.h> header file. */
|
||||
#cmakedefine HAVE_NET_PFILT_H 1
|
||||
|
||||
/* Define to 1 if you have the <net/pfvar.h> header file. */
|
||||
#cmakedefine HAVE_NET_PFVAR_H 1
|
||||
|
||||
/* Define to 1 if you have the <net/raw.h> header file. */
|
||||
#cmakedefine HAVE_NET_RAW_H 1
|
||||
|
||||
/* Use OpenSSL */
|
||||
#cmakedefine HAVE_OPENSSL 1
|
||||
|
||||
/* if there's an os_proto.h for this platform, to use additional prototypes */
|
||||
#cmakedefine HAVE_OS_PROTO_H 1
|
||||
|
||||
|
@ -153,9 +135,6 @@
|
|||
/* Define to 1 if you have a POSIX-style `strerror_r' function. */
|
||||
#cmakedefine HAVE_POSIX_STRERROR_R 1
|
||||
|
||||
/* define if net/pfvar.h defines PF_NAT through PF_NORDR */
|
||||
#cmakedefine HAVE_PF_NAT_THROUGH_PF_NORDR 1
|
||||
|
||||
/* define if you have the Septel API */
|
||||
#cmakedefine HAVE_SEPTEL_API 1
|
||||
|
||||
|
@ -186,9 +165,6 @@
|
|||
/* Define to 1 if you have the `strerror' function. */
|
||||
#cmakedefine HAVE_STRERROR 1
|
||||
|
||||
/* Define to 1 if you have the `strerror_s' function. */
|
||||
#cmakedefine HAVE_STRERROR_S 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#cmakedefine HAVE_STRINGS_H 1
|
||||
|
||||
|
@ -216,6 +192,9 @@
|
|||
/* Define to 1 if `msg_flags' is a member of `struct msghdr'. */
|
||||
#cmakedefine HAVE_STRUCT_MSGHDR_MSG_FLAGS 1
|
||||
|
||||
/* Define to 1 if the system has the type `struct rte_ether_addr'. */
|
||||
#cmakedefine HAVE_STRUCT_RTE_ETHER_ADDR 1
|
||||
|
||||
/* Define to 1 if `hci_channel' is a member of `struct sockaddr_hci'. */
|
||||
#cmakedefine HAVE_STRUCT_SOCKADDR_HCI_HCI_CHANNEL 1
|
||||
|
||||
|
@ -228,9 +207,6 @@
|
|||
/* Define to 1 if `tp_vlan_tci' is a member of `struct tpacket_auxdata'. */
|
||||
#cmakedefine HAVE_STRUCT_TPACKET_AUXDATA_TP_VLAN_TCI 1
|
||||
|
||||
/* Define to 1 if the system has the type `struct tpacket_stats'. */
|
||||
#cmakedefine HAVE_STRUCT_TPACKET_STATS 1
|
||||
|
||||
/* Define to 1 if `bRequestType' is a member of `struct
|
||||
usbdevfs_ctrltransfer'. */
|
||||
#cmakedefine HAVE_STRUCT_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE 1
|
||||
|
@ -272,7 +248,19 @@
|
|||
#cmakedefine HAVE_VSNPRINTF 1
|
||||
|
||||
/* Define to 1 if you have the `vsyslog' function. */
|
||||
#undef HAVE_VSYSLOG
|
||||
#cmakedefine HAVE_VSYSLOG 1
|
||||
|
||||
/* Define to 1 if you have the `_wcserror_s' function. */
|
||||
#cmakedefine HAVE__WCSERROR_S 1
|
||||
|
||||
/* define if __atomic_load_n is supported by the compiler */
|
||||
#cmakedefine HAVE___ATOMIC_LOAD_N 1
|
||||
|
||||
/* define if __atomic_store_n is supported by the compiler */
|
||||
#cmakedefine HAVE___ATOMIC_STORE_N 1
|
||||
|
||||
/* Define to 1 if you have the `PacketGetTimestampModes' function. */
|
||||
#cmakedefine HAVE_PACKET_GET_TIMESTAMP_MODES 1
|
||||
|
||||
/* Define to 1 if you have the `PacketIsLoopbackAdapter' function. */
|
||||
#cmakedefine HAVE_PACKET_IS_LOOPBACK_ADAPTER 1
|
||||
|
@ -280,12 +268,6 @@
|
|||
/* IPv6 */
|
||||
#cmakedefine INET6 1
|
||||
|
||||
/* if unaligned access fails */
|
||||
#cmakedefine LBL_ALIGN 1
|
||||
|
||||
/* path for device for USB sniffing */
|
||||
#cmakedefine LINUX_USB_MON_DEV "@LINUX_USB_MON_DEV@"
|
||||
|
||||
/* Define to 1 if netinet/ether.h declares `ether_hostton' */
|
||||
#cmakedefine NETINET_ETHER_H_DECLARES_ETHER_HOSTTON 1
|
||||
|
||||
|
@ -301,7 +283,7 @@
|
|||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#cmakedefine PACKAGE_BUGREPORT 1
|
||||
|
||||
/* Define to the DLL-preferred version string of of this package. */
|
||||
/* Define to the DLL-preferred version string of this package. */
|
||||
#cmakedefine PACKAGE_VERSION_DLL @PACKAGE_VERSION_DLL@
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
|
@ -328,24 +310,21 @@
|
|||
/* support D-Bus sniffing */
|
||||
#cmakedefine PCAP_SUPPORT_DBUS 1
|
||||
|
||||
/* target host supports DPDK */
|
||||
#cmakedefine PCAP_SUPPORT_DPDK 1
|
||||
|
||||
/* target host supports Linux usbmon for USB sniffing */
|
||||
#cmakedefine PCAP_SUPPORT_LINUX_USBMON 1
|
||||
|
||||
/* target host supports netfilter sniffing */
|
||||
#cmakedefine PCAP_SUPPORT_NETFILTER 1
|
||||
|
||||
/* target host supports netmap */
|
||||
#cmakedefine PCAP_SUPPORT_NETMAP 1
|
||||
|
||||
/* use packet ring capture support on Linux if available */
|
||||
#cmakedefine PCAP_SUPPORT_PACKET_RING 1
|
||||
|
||||
/* target host supports RDMA sniffing */
|
||||
#cmakedefine PCAP_SUPPORT_RDMASNIFF 1
|
||||
|
||||
/* target host supports USB sniffing */
|
||||
#cmakedefine PCAP_SUPPORT_USB 1
|
||||
|
||||
/* include ACN support */
|
||||
#cmakedefine SITA 1
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#cmakedefine STDC_HEADERS 1
|
||||
|
||||
|
|
1510
contrib/libpcap/config.guess
vendored
1510
contrib/libpcap/config.guess
vendored
File diff suppressed because it is too large
Load diff
|
@ -18,6 +18,9 @@
|
|||
/* Define to 1 if you have the `asprintf' function. */
|
||||
#undef HAVE_ASPRINTF
|
||||
|
||||
/* Define to 1 if you have the <config/HaikuConfig.h> header file. */
|
||||
#undef HAVE_CONFIG_HAIKUCONFIG_H
|
||||
|
||||
/* Define to 1 if you have the <dagapi.h> header file. */
|
||||
#undef HAVE_DAGAPI_H
|
||||
|
||||
|
@ -69,8 +72,8 @@
|
|||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `dag' library (-ldag). */
|
||||
#undef HAVE_LIBDAG
|
||||
/* Define to 1 if you have the `bsd' library (-lbsd). */
|
||||
#undef HAVE_LIBBSD
|
||||
|
||||
/* if libdlpi exists */
|
||||
#undef HAVE_LIBDLPI
|
||||
|
@ -78,45 +81,21 @@
|
|||
/* if libnl exists */
|
||||
#undef HAVE_LIBNL
|
||||
|
||||
/* if libnl exists and is version 2.x */
|
||||
#undef HAVE_LIBNL_2_x
|
||||
|
||||
/* if libnl exists and is version 3.x */
|
||||
#undef HAVE_LIBNL_3_x
|
||||
|
||||
/* libnl has NLE_FAILURE */
|
||||
#undef HAVE_LIBNL_NLE
|
||||
|
||||
/* libnl has new-style socket api */
|
||||
#undef HAVE_LIBNL_SOCKETS
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
/* Define to 1 if you have the <linux/compiler.h> header file. */
|
||||
#undef HAVE_LINUX_COMPILER_H
|
||||
|
||||
/* Define to 1 if you have the <linux/ethtool.h> header file. */
|
||||
#undef HAVE_LINUX_ETHTOOL_H
|
||||
|
||||
/* define if we have the Linux getnetbyname_r() */
|
||||
#undef HAVE_LINUX_GETNETBYNAME_R
|
||||
|
||||
/* define if we have the Linux getprotobyname_r() */
|
||||
#undef HAVE_LINUX_GETPROTOBYNAME_R
|
||||
|
||||
/* Define to 1 if you have the <linux/if_bonding.h> header file. */
|
||||
#undef HAVE_LINUX_IF_BONDING_H
|
||||
|
||||
/* Define to 1 if you have the <linux/net_tstamp.h> header file. */
|
||||
#undef HAVE_LINUX_NET_TSTAMP_H
|
||||
|
||||
/* Define to 1 if you have the <linux/socket.h> header file. */
|
||||
#undef HAVE_LINUX_SOCKET_H
|
||||
|
||||
/* Define to 1 if you have the <linux/sockios.h> header file. */
|
||||
#undef HAVE_LINUX_SOCKIOS_H
|
||||
|
||||
/* Define to 1 if you have the <linux/usbdevice_fs.h> header file. */
|
||||
#undef HAVE_LINUX_USBDEVICE_FS_H
|
||||
|
||||
|
@ -135,27 +114,33 @@
|
|||
/* Define to 1 if you have the <net/enet.h> header file. */
|
||||
#undef HAVE_NET_ENET_H
|
||||
|
||||
/* Define to 1 if you have the <net/if_dl.h> header file. */
|
||||
#undef HAVE_NET_IF_DL_H
|
||||
|
||||
/* Define to 1 if you have the <net/if.h> header file. */
|
||||
#undef HAVE_NET_IF_H
|
||||
|
||||
/* Define to 1 if you have the <net/if_media.h> header file. */
|
||||
#undef HAVE_NET_IF_MEDIA_H
|
||||
|
||||
/* Define to 1 if you have the <net/if_types.h> header file. */
|
||||
#undef HAVE_NET_IF_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <net/nit.h> header file. */
|
||||
#undef HAVE_NET_NIT_H
|
||||
|
||||
/* Define to 1 if you have the <net/pfilt.h> header file. */
|
||||
#undef HAVE_NET_PFILT_H
|
||||
|
||||
/* Define to 1 if you have the <net/pfvar.h> header file. */
|
||||
#undef HAVE_NET_PFVAR_H
|
||||
|
||||
/* Define to 1 if you have the <net/raw.h> header file. */
|
||||
#undef HAVE_NET_RAW_H
|
||||
|
||||
/* Use OpenSSL */
|
||||
#undef HAVE_OPENSSL
|
||||
|
||||
/* if there's an os_proto.h for this platform, to use additional prototypes */
|
||||
#undef HAVE_OS_PROTO_H
|
||||
|
||||
/* define if net/pfvar.h defines PF_NAT through PF_NORDR */
|
||||
#undef HAVE_PF_NAT_THROUGH_PF_NORDR
|
||||
|
||||
/* Define to 1 if you have a POSIX-style `strerror_r' function. */
|
||||
#undef HAVE_POSIX_STRERROR_R
|
||||
|
||||
|
@ -165,9 +150,6 @@
|
|||
/* define if you have the Myricom SNF API */
|
||||
#undef HAVE_SNF_API
|
||||
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#undef HAVE_SNPRINTF
|
||||
|
||||
/* Define to 1 if the system has the type `socklen_t'. */
|
||||
#undef HAVE_SOCKLEN_T
|
||||
|
||||
|
@ -189,9 +171,6 @@
|
|||
/* Define to 1 if you have the `strerror' function. */
|
||||
#undef HAVE_STRERROR
|
||||
|
||||
/* Define to 1 if you have the `strerror_s' function. */
|
||||
#undef HAVE_STRERROR_S
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
|
@ -219,6 +198,9 @@
|
|||
/* Define to 1 if `msg_flags' is a member of `struct msghdr'. */
|
||||
#undef HAVE_STRUCT_MSGHDR_MSG_FLAGS
|
||||
|
||||
/* Define to 1 if the system has the type `struct rte_ether_addr'. */
|
||||
#undef HAVE_STRUCT_RTE_ETHER_ADDR
|
||||
|
||||
/* Define to 1 if `hci_channel' is a member of `struct sockaddr_hci'. */
|
||||
#undef HAVE_STRUCT_SOCKADDR_HCI_HCI_CHANNEL
|
||||
|
||||
|
@ -231,9 +213,6 @@
|
|||
/* Define to 1 if `tp_vlan_tci' is a member of `struct tpacket_auxdata'. */
|
||||
#undef HAVE_STRUCT_TPACKET_AUXDATA_TP_VLAN_TCI
|
||||
|
||||
/* Define to 1 if the system has the type `struct tpacket_stats'. */
|
||||
#undef HAVE_STRUCT_TPACKET_STATS
|
||||
|
||||
/* Define to 1 if `bRequestType' is a member of `struct
|
||||
usbdevfs_ctrltransfer'. */
|
||||
#undef HAVE_STRUCT_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE
|
||||
|
@ -271,21 +250,21 @@
|
|||
/* Define to 1 if you have the `vasprintf' function. */
|
||||
#undef HAVE_VASPRINTF
|
||||
|
||||
/* Define to 1 if you have the `vsnprintf' function. */
|
||||
#undef HAVE_VSNPRINTF
|
||||
|
||||
/* Define to 1 if you have the `vsyslog' function. */
|
||||
#undef HAVE_VSYSLOG
|
||||
|
||||
/* Define to 1 if you have the `_wcserror_s' function. */
|
||||
#undef HAVE__WCSERROR_S
|
||||
|
||||
/* define if __atomic_load_n is supported by the compiler */
|
||||
#undef HAVE___ATOMIC_LOAD_N
|
||||
|
||||
/* define if __atomic_store_n is supported by the compiler */
|
||||
#undef HAVE___ATOMIC_STORE_N
|
||||
|
||||
/* IPv6 */
|
||||
#undef INET6
|
||||
|
||||
/* if unaligned access fails */
|
||||
#undef LBL_ALIGN
|
||||
|
||||
/* path for device for USB sniffing */
|
||||
#undef LINUX_USB_MON_DEV
|
||||
|
||||
/* Define to 1 if netinet/ether.h declares `ether_hostton' */
|
||||
#undef NETINET_ETHER_H_DECLARES_ETHER_HOSTTON
|
||||
|
||||
|
@ -325,23 +304,26 @@
|
|||
/* support D-Bus sniffing */
|
||||
#undef PCAP_SUPPORT_DBUS
|
||||
|
||||
/* target host supports DPDK */
|
||||
#undef PCAP_SUPPORT_DPDK
|
||||
|
||||
/* target host supports Linux usbmon for USB sniffing */
|
||||
#undef PCAP_SUPPORT_LINUX_USBMON
|
||||
|
||||
/* target host supports netfilter sniffing */
|
||||
#undef PCAP_SUPPORT_NETFILTER
|
||||
|
||||
/* target host supports netmap */
|
||||
#undef PCAP_SUPPORT_NETMAP
|
||||
|
||||
/* use packet ring capture support on Linux if available */
|
||||
#undef PCAP_SUPPORT_PACKET_RING
|
||||
|
||||
/* target host supports RDMA sniffing */
|
||||
#undef PCAP_SUPPORT_RDMASNIFF
|
||||
|
||||
/* target host supports USB sniffing */
|
||||
#undef PCAP_SUPPORT_USB
|
||||
/* The size of `const void *', as computed by sizeof. */
|
||||
#undef SIZEOF_CONST_VOID_P
|
||||
|
||||
/* include ACN support */
|
||||
#undef SITA
|
||||
/* The size of `void *', as computed by sizeof. */
|
||||
#undef SIZEOF_VOID_P
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
|
1862
contrib/libpcap/config.sub
vendored
1862
contrib/libpcap/config.sub
vendored
File diff suppressed because it is too large
Load diff
7178
contrib/libpcap/configure
vendored
7178
contrib/libpcap/configure
vendored
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -37,20 +37,100 @@
|
|||
|
||||
#include "pcap/compiler-tests.h"
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#if PCAP_IS_AT_LEAST_CLANG_VERSION(2,8) || PCAP_IS_AT_LEAST_GNUC_VERSION(4,6)
|
||||
/*
|
||||
* Clang and GCC both support this way of putting pragmas into #defines.
|
||||
* We don't use it unless we have a compiler that supports it; the
|
||||
* warning-suppressing pragmas differ between Clang and GCC, so we test
|
||||
* for both of those separately.
|
||||
* We use it only if we have a compiler that supports it; see below
|
||||
* for the code that uses it and the #defines that control whether
|
||||
* that code is used.
|
||||
*/
|
||||
#define PCAP_DO_PRAGMA(x) _Pragma (#x)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Suppress Flex warnings.
|
||||
* Suppress "enum value not explicitly handled in switch" warnings.
|
||||
* We may have to build on multiple different Windows SDKs, so we
|
||||
* may not be able to include all enum values in a switch, as they
|
||||
* won't necessarily be defined on all the SDKs, and, unlike
|
||||
* #defines, there's no easy way to test whether a given enum has
|
||||
* a given value. It *could* be done by the configure script or
|
||||
* CMake tests.
|
||||
*/
|
||||
#if defined(_MSC_VER)
|
||||
#define DIAG_OFF_ENUM_SWITCH \
|
||||
__pragma(warning(push)) \
|
||||
__pragma(warning(disable:4061))
|
||||
#define DIAG_ON_ENUM_SWITCH \
|
||||
__pragma(warning(pop))
|
||||
#else
|
||||
#define DIAG_OFF_ENUM_SWITCH
|
||||
#define DIAG_ON_ENUM_SWITCH
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Suppress "switch statement has only a default case" warnings.
|
||||
* There's a switch in bpf_filter.c that only has additional
|
||||
* cases on Linux.
|
||||
*/
|
||||
#if defined(_MSC_VER)
|
||||
#define DIAG_OFF_DEFAULT_ONLY_SWITCH \
|
||||
__pragma(warning(push)) \
|
||||
__pragma(warning(disable:4065))
|
||||
#define DIAG_ON_DEFAULT_ONLY_SWITCH \
|
||||
__pragma(warning(pop))
|
||||
#else
|
||||
#define DIAG_OFF_DEFAULT_ONLY_SWITCH
|
||||
#define DIAG_ON_DEFAULT_ONLY_SWITCH
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Suppress Flex, narrowing, and deprecation warnings.
|
||||
*/
|
||||
#if PCAP_IS_AT_LEAST_CLANG_VERSION(2,8)
|
||||
/*
|
||||
* This is Clang 2.8 or later; we can use "clang diagnostic
|
||||
* ignored -Wxxx" and "clang diagnostic push/pop".
|
||||
*
|
||||
* Suppress -Wdocumentation warnings; GCC doesn't support -Wdocumentation,
|
||||
* at least according to the GCC 7.3 documentation. Apparently, Flex
|
||||
* generates code that upsets at least some versions of Clang's
|
||||
* -Wdocumentation.
|
||||
*
|
||||
* (This could be clang-cl, which defines _MSC_VER, so test this
|
||||
* before testing _MSC_VER.)
|
||||
*/
|
||||
#define DIAG_OFF_FLEX \
|
||||
PCAP_DO_PRAGMA(clang diagnostic push) \
|
||||
PCAP_DO_PRAGMA(clang diagnostic ignored "-Wsign-compare") \
|
||||
PCAP_DO_PRAGMA(clang diagnostic ignored "-Wdocumentation") \
|
||||
PCAP_DO_PRAGMA(clang diagnostic ignored "-Wshorten-64-to-32") \
|
||||
PCAP_DO_PRAGMA(clang diagnostic ignored "-Wmissing-noreturn") \
|
||||
PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunused-parameter") \
|
||||
PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code")
|
||||
#define DIAG_ON_FLEX \
|
||||
PCAP_DO_PRAGMA(clang diagnostic pop)
|
||||
|
||||
/*
|
||||
* Suppress the only narrowing warnings you get from Clang.
|
||||
*/
|
||||
#define DIAG_OFF_NARROWING \
|
||||
PCAP_DO_PRAGMA(clang diagnostic push) \
|
||||
PCAP_DO_PRAGMA(clang diagnostic ignored "-Wshorten-64-to-32")
|
||||
|
||||
#define DIAG_ON_NARROWING \
|
||||
PCAP_DO_PRAGMA(clang diagnostic pop)
|
||||
|
||||
/*
|
||||
* Suppress deprecation warnings.
|
||||
*/
|
||||
#define DIAG_OFF_DEPRECATION \
|
||||
PCAP_DO_PRAGMA(clang diagnostic push) \
|
||||
PCAP_DO_PRAGMA(clang diagnostic ignored "-Wdeprecated-declarations")
|
||||
#define DIAG_ON_DEPRECATION \
|
||||
PCAP_DO_PRAGMA(clang diagnostic pop)
|
||||
#define DIAG_OFF_FORMAT_TRUNCATION
|
||||
#define DIAG_ON_FORMAT_TRUNCATION
|
||||
#elif defined(_MSC_VER)
|
||||
/*
|
||||
* This is Microsoft Visual Studio; we can use __pragma(warning(disable:XXXX))
|
||||
* and __pragma(warning(push/pop)).
|
||||
|
@ -64,26 +144,29 @@
|
|||
__pragma(warning(disable:4242)) \
|
||||
__pragma(warning(disable:4244)) \
|
||||
__pragma(warning(disable:4702))
|
||||
#define DIAG_ON_FLEX __pragma(warning(pop))
|
||||
#elif PCAP_IS_AT_LEAST_CLANG_VERSION(2,8)
|
||||
/*
|
||||
* This is Clang 2.8 or later; we can use "clang diagnostic
|
||||
* ignored -Wxxx" and "clang diagnostic push/pop".
|
||||
*
|
||||
* Suppress -Wdocumentation warnings; GCC doesn't support -Wdocumentation,
|
||||
* at least according to the GCC 7.3 documentation. Apparently, Flex
|
||||
* generates code that upsets at least some versions of Clang's
|
||||
* -Wdocumentation.
|
||||
*/
|
||||
#define DIAG_OFF_FLEX \
|
||||
PCAP_DO_PRAGMA(clang diagnostic push) \
|
||||
PCAP_DO_PRAGMA(clang diagnostic ignored "-Wsign-compare") \
|
||||
PCAP_DO_PRAGMA(clang diagnostic ignored "-Wdocumentation") \
|
||||
PCAP_DO_PRAGMA(clang diagnostic ignored "-Wmissing-noreturn") \
|
||||
PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunused-parameter") \
|
||||
PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code")
|
||||
#define DIAG_ON_FLEX \
|
||||
PCAP_DO_PRAGMA(clang diagnostic pop)
|
||||
__pragma(warning(pop))
|
||||
|
||||
/*
|
||||
* Suppress narrowing warnings.
|
||||
*/
|
||||
#define DIAG_OFF_NARROWING \
|
||||
__pragma(warning(push)) \
|
||||
__pragma(warning(disable:4242)) \
|
||||
__pragma(warning(disable:4311))
|
||||
#define DIAG_ON_NARROWING \
|
||||
__pragma(warning(pop))
|
||||
|
||||
/*
|
||||
* Suppress deprecation warnings.
|
||||
*/
|
||||
#define DIAG_OFF_DEPRECATION \
|
||||
__pragma(warning(push)) \
|
||||
__pragma(warning(disable:4996))
|
||||
#define DIAG_ON_DEPRECATION \
|
||||
__pragma(warning(pop))
|
||||
#define DIAG_OFF_FORMAT_TRUNCATION
|
||||
#define DIAG_ON_FORMAT_TRUNCATION
|
||||
#elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6)
|
||||
/*
|
||||
* This is GCC 4.6 or later, or a compiler claiming to be that.
|
||||
|
@ -97,6 +180,37 @@
|
|||
PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wunreachable-code")
|
||||
#define DIAG_ON_FLEX \
|
||||
PCAP_DO_PRAGMA(GCC diagnostic pop)
|
||||
|
||||
/*
|
||||
* GCC currently doesn't issue any narrowing warnings.
|
||||
*/
|
||||
#define DIAG_OFF_NARROWING
|
||||
#define DIAG_ON_NARROWING
|
||||
|
||||
/*
|
||||
* Suppress deprecation warnings.
|
||||
*/
|
||||
#define DIAG_OFF_DEPRECATION \
|
||||
PCAP_DO_PRAGMA(GCC diagnostic push) \
|
||||
PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
|
||||
#define DIAG_ON_DEPRECATION \
|
||||
PCAP_DO_PRAGMA(GCC diagnostic pop)
|
||||
|
||||
/*
|
||||
* Suppress format-truncation= warnings.
|
||||
* GCC 7.1 had introduced this warning option. Earlier versions (at least
|
||||
* one particular copy of GCC 4.6.4) treat the request as a warning.
|
||||
*/
|
||||
#if PCAP_IS_AT_LEAST_GNUC_VERSION(7,1)
|
||||
#define DIAG_OFF_FORMAT_TRUNCATION \
|
||||
PCAP_DO_PRAGMA(GCC diagnostic push) \
|
||||
PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wformat-truncation=")
|
||||
#define DIAG_ON_FORMAT_TRUNCATION \
|
||||
PCAP_DO_PRAGMA(GCC diagnostic pop)
|
||||
#else
|
||||
#define DIAG_OFF_FORMAT_TRUNCATION
|
||||
#define DIAG_ON_FORMAT_TRUNCATION
|
||||
#endif
|
||||
#else
|
||||
/*
|
||||
* Neither Visual Studio, nor Clang 2.8 or later, nor GCC 4.6 or later
|
||||
|
@ -105,6 +219,12 @@
|
|||
*/
|
||||
#define DIAG_OFF_FLEX
|
||||
#define DIAG_ON_FLEX
|
||||
#define DIAG_OFF_NARROWING
|
||||
#define DIAG_ON_NARROWING
|
||||
#define DIAG_OFF_DEPRECATION
|
||||
#define DIAG_ON_DEPRECATION
|
||||
#define DIAG_OFF_FORMAT_TRUNCATION
|
||||
#define DIAG_ON_FORMAT_TRUNCATION
|
||||
#endif
|
||||
|
||||
#ifdef YYBYACC
|
||||
|
@ -124,96 +244,95 @@
|
|||
* In addition, the generated code may have functions with unreachable
|
||||
* code, so suppress warnings about those.
|
||||
*/
|
||||
#if defined(_MSC_VER)
|
||||
#if PCAP_IS_AT_LEAST_CLANG_VERSION(2,8)
|
||||
/*
|
||||
* This is Microsoft Visual Studio; we can use
|
||||
* __pragma(warning(disable:XXXX)) and __pragma(warning(push/pop)).
|
||||
* This is Clang 2.8 or later (including clang-cl, so test this
|
||||
* before _MSC_VER); we can use "clang diagnostic ignored -Wxxx".
|
||||
*/
|
||||
#define DIAG_OFF_BISON_BYACC \
|
||||
__pragma(warning(push)) \
|
||||
__pragma(warning(disable:4702))
|
||||
#define DIAG_ON_BISON_BYACC __pragma(warning(pop))
|
||||
#elif PCAP_IS_AT_LEAST_CLANG_VERSION(2,8)
|
||||
/*
|
||||
* This is Clang 2.8 or later; we can use "clang diagnostic
|
||||
* ignored -Wxxx" and "clang diagnostic push/pop".
|
||||
*/
|
||||
#define DIAG_OFF_BISON_BYACC \
|
||||
PCAP_DO_PRAGMA(clang diagnostic push) \
|
||||
PCAP_DO_PRAGMA(clang diagnostic ignored "-Wshadow") \
|
||||
PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code")
|
||||
#define DIAG_ON_BISON_BYACC \
|
||||
PCAP_DO_PRAGMA(clang diagnostic pop)
|
||||
#elif defined(_MSC_VER)
|
||||
/*
|
||||
* This is Microsoft Visual Studio; we can use
|
||||
* __pragma(warning(disable:XXXX)).
|
||||
*/
|
||||
#define DIAG_OFF_BISON_BYACC \
|
||||
__pragma(warning(disable:4702))
|
||||
#elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6)
|
||||
/*
|
||||
* This is GCC 4.6 or later, or a compiler claiming to be that.
|
||||
* We can use "GCC diagnostic ignored -Wxxx" (introduced in 4.2)
|
||||
* and "GCC diagnostic push/pop" (introduced in 4.6).
|
||||
* We can use "GCC diagnostic ignored -Wxxx" (introduced in 4.2,
|
||||
* but it may not actually work very well prior to 4.6).
|
||||
*/
|
||||
#define DIAG_OFF_BISON_BYACC \
|
||||
PCAP_DO_PRAGMA(GCC diagnostic push) \
|
||||
PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wshadow") \
|
||||
PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wunreachable-code")
|
||||
#define DIAG_ON_BISON_BYACC \
|
||||
PCAP_DO_PRAGMA(GCC diagnostic pop)
|
||||
#else
|
||||
/*
|
||||
* Neither Clang 2.8 or later nor GCC 4.6 or later or a compiler
|
||||
* claiming to be that; there's nothing we know of that we can do.
|
||||
*/
|
||||
#define DIAG_OFF_BISON_BYACC
|
||||
#define DIAG_ON_BISON_BYACC
|
||||
#endif
|
||||
#else
|
||||
/*
|
||||
* Bison.
|
||||
*
|
||||
* The generated code may have functions with unreachable code, so
|
||||
* suppress warnings about those.
|
||||
* The generated code may have functions with unreachable code and
|
||||
* switches with only a default case, so suppress warnings about those.
|
||||
*/
|
||||
#if defined(_MSC_VER)
|
||||
#if PCAP_IS_AT_LEAST_CLANG_VERSION(2,8)
|
||||
/*
|
||||
* This is Clang 2.8 or later (including clang-cl, so test this
|
||||
* before _MSC_VER); we can use "clang diagnostic ignored -Wxxx".
|
||||
*/
|
||||
#define DIAG_OFF_BISON_BYACC \
|
||||
PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code")
|
||||
#elif defined(_MSC_VER)
|
||||
/*
|
||||
* This is Microsoft Visual Studio; we can use
|
||||
* __pragma(warning(disable:XXXX)) and __pragma(warning(push/pop)).
|
||||
* __pragma(warning(disable:XXXX)).
|
||||
*
|
||||
* Suppress some /Wall warnings.
|
||||
*/
|
||||
#define DIAG_OFF_BISON_BYACC \
|
||||
__pragma(warning(push)) \
|
||||
__pragma(warning(disable:4065)) \
|
||||
__pragma(warning(disable:4127)) \
|
||||
__pragma(warning(disable:4242)) \
|
||||
__pragma(warning(disable:4244)) \
|
||||
__pragma(warning(disable:4702))
|
||||
#define DIAG_ON_BISON_BYACC __pragma(warning(pop))
|
||||
#elif PCAP_IS_AT_LEAST_CLANG_VERSION(2,8)
|
||||
/*
|
||||
* This is Clang 2.8 or later; we can use "clang diagnostic
|
||||
* ignored -Wxxx" and "clang diagnostic push/pop".
|
||||
*/
|
||||
#define DIAG_OFF_BISON_BYACC \
|
||||
PCAP_DO_PRAGMA(clang diagnostic push) \
|
||||
PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code")
|
||||
#define DIAG_ON_BISON_BYACC \
|
||||
PCAP_DO_PRAGMA(clang diagnostic pop)
|
||||
#elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6)
|
||||
/*
|
||||
* This is GCC 4.6 or later, or a compiler claiming to be that.
|
||||
* We can use "GCC diagnostic ignored -Wxxx" (introduced in 4.2)
|
||||
* and "GCC diagnostic push/pop" (introduced in 4.6).
|
||||
* We can use "GCC diagnostic ignored -Wxxx" (introduced in 4.2,
|
||||
* but it may not actually work very well prior to 4.6).
|
||||
*/
|
||||
#define DIAG_OFF_BISON_BYACC \
|
||||
PCAP_DO_PRAGMA(GCC diagnostic push) \
|
||||
PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wunreachable-code")
|
||||
#define DIAG_ON_BISON_BYACC \
|
||||
PCAP_DO_PRAGMA(GCC diagnostic pop)
|
||||
#else
|
||||
/*
|
||||
* Neither Clang 2.8 or later nor GCC 4.6 or later or a compiler
|
||||
* claiming to be that; there's nothing we know of that we can do.
|
||||
*/
|
||||
#define DIAG_OFF_BISON_BYACC
|
||||
#define DIAG_ON_BISON_BYACC
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* GCC needs this on AIX for longjmp().
|
||||
*/
|
||||
#if PCAP_IS_AT_LEAST_GNUC_VERSION(5,1)
|
||||
/*
|
||||
* Beware that the effect of this builtin is more than just squelching the
|
||||
* warning! GCC trusts it enough for the process to segfault if the control
|
||||
* flow reaches the builtin (an infinite empty loop in the same context would
|
||||
* squelch the warning and ruin the process too, albeit in a different way).
|
||||
* So please remember to use this very carefully.
|
||||
*/
|
||||
#define PCAP_UNREACHABLE __builtin_unreachable();
|
||||
#else
|
||||
#define PCAP_UNREACHABLE
|
||||
#endif
|
||||
|
||||
#endif /* _diag_control_h */
|
||||
|
|
|
@ -113,6 +113,20 @@ pcap_stats_dlpi(pcap_t *p, struct pcap_stat *ps)
|
|||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Does the processor for which we're compiling this support aligned loads?
|
||||
*/
|
||||
#if (defined(__i386__) || defined(_M_IX86) || defined(__X86__) || defined(__x86_64__) || defined(_M_X64)) || \
|
||||
(defined(__arm__) || defined(_M_ARM) || defined(__aarch64__)) || \
|
||||
(defined(__m68k__) && (!defined(__mc68000__) && !defined(__mc68010__))) || \
|
||||
(defined(__ppc__) || defined(__ppc64__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PPC64)) || \
|
||||
(defined(__s390__) || defined(__s390x__) || defined(__zarch__))
|
||||
/* Yes, it does. */
|
||||
#else
|
||||
/* No, it doesn't. */
|
||||
#define REQUIRE_ALIGNMENT
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Loop through the packets and call the callback for each packet.
|
||||
* Return the number of packets read.
|
||||
|
@ -127,12 +141,17 @@ pcap_process_pkts(pcap_t *p, pcap_handler callback, u_char *user,
|
|||
struct pcap_pkthdr pkthdr;
|
||||
#ifdef HAVE_SYS_BUFMOD_H
|
||||
struct sb_hdr *sbp;
|
||||
#ifdef LBL_ALIGN
|
||||
#ifdef REQUIRE_ALIGNMENT
|
||||
struct sb_hdr sbhdr;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Loop through packets */
|
||||
/*
|
||||
* Loop through packets.
|
||||
*
|
||||
* This assumes that a single buffer of packets will have
|
||||
* <= INT_MAX packets, so the packet count doesn't overflow.
|
||||
*/
|
||||
ep = bufp + len;
|
||||
n = 0;
|
||||
|
||||
|
@ -157,7 +176,7 @@ pcap_process_pkts(pcap_t *p, pcap_handler callback, u_char *user,
|
|||
return (n);
|
||||
}
|
||||
}
|
||||
#ifdef LBL_ALIGN
|
||||
#ifdef REQUIRE_ALIGNMENT
|
||||
if ((long)bufp & 3) {
|
||||
sbp = &sbhdr;
|
||||
memcpy(sbp, bufp, sizeof(*sbp));
|
||||
|
@ -176,7 +195,7 @@ pcap_process_pkts(pcap_t *p, pcap_handler callback, u_char *user,
|
|||
bufp += caplen;
|
||||
#endif
|
||||
++pd->stat.ps_recv;
|
||||
if (bpf_filter(p->fcode.bf_insns, pk, origlen, caplen)) {
|
||||
if (pcap_filter(p->fcode.bf_insns, pk, origlen, caplen)) {
|
||||
#ifdef HAVE_SYS_BUFMOD_H
|
||||
pkthdr.ts.tv_sec = sbp->sbh_timestamp.tv_sec;
|
||||
pkthdr.ts.tv_usec = sbp->sbh_timestamp.tv_usec;
|
||||
|
@ -275,7 +294,7 @@ pcap_process_mactype(pcap_t *p, u_int mactype)
|
|||
* XXX - DL_IPNET devices default to "raw IP" rather than
|
||||
* "IPNET header"; see
|
||||
*
|
||||
* http://seclists.org/tcpdump/2009/q1/202
|
||||
* https://seclists.org/tcpdump/2009/q1/202
|
||||
*
|
||||
* We'd have to do DL_IOC_IPNET_INFO to enable getting
|
||||
* the IPNET header.
|
||||
|
@ -286,7 +305,7 @@ pcap_process_mactype(pcap_t *p, u_int mactype)
|
|||
#endif
|
||||
|
||||
default:
|
||||
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "unknown mactype 0x%x",
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "unknown mactype 0x%x",
|
||||
mactype);
|
||||
retv = -1;
|
||||
}
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
DLT and LINKTYPE allocation
|
||||
===========================
|
||||
|
||||
DLT_ types live in pcap/dlt.h. They can be requested by the community on a
|
||||
First-Come First-Served basis [i.e. https://tools.ietf.org/html/rfc8126#section-4.4 ]
|
||||
(Although libpcap is not at this time an IETF specification, there have been
|
||||
some as yet-incomplete efforts to do this).
|
||||
|
||||
The Tcpdump Group prefers to link to an open specification on the new DLT_
|
||||
type, but they are available for closed, proprietary projects as well.
|
||||
In that case, a stable email address suffices so that someone who finds
|
||||
an unknown DLT_ type can investigate.
|
||||
We prefer to give out unambiguous numbers, and we try to do it as quickly
|
||||
as possible, but DLT_USERx is available while you wait.
|
||||
|
||||
Note that DLT_ types are, in theory, private to the capture mechanism and can
|
||||
in some cases be operating system specific, and so a second set of values,
|
||||
LINKTYPE_ is allocated for actually writing to pcap files. As much as
|
||||
possible going forward, the DLT_ and LINKTYPE_ value are identical, however,
|
||||
this was not always the case. See pcap-common.c.
|
||||
|
||||
The LINKTYPE_ values are not exported, but are in pcap-common.c only.
|
||||
|
||||
DEVELOPER NOTES
|
||||
---------------
|
||||
|
||||
When allocating a new DLT_ value, a corresponding value needs to be
|
||||
added to pcap-common.c.
|
||||
It is not necessary to copy the comments from dlt.h to pcap-common.c.
|
|
@ -1,3 +1,198 @@
|
|||
Win32 used to build with Visual Studio 6, but we now use cmake.
|
||||
Building libpcap on Windows with Visual Studio
|
||||
==============================================
|
||||
|
||||
This file needs to be adopted by a windows expert developer.
|
||||
Unlike the UN*Xes on which libpcap can capture network traffic, Windows
|
||||
has no network traffic capture mechanism that libpcap can use.
|
||||
Therefore, libpcap requires a driver, and a library to access the
|
||||
driver, provided by the Npcap or WinPcap projects.
|
||||
|
||||
Those projects include versions of libpcap built to use that driver and
|
||||
library; these instructions are for people who want to build libpcap
|
||||
source releases, or libpcap from the Git repository, as a replacement
|
||||
for the version provided with Npcap or WinPcap.
|
||||
|
||||
Npcap and WinPcap SDK
|
||||
---------------------
|
||||
|
||||
In order to build libpcap, you will need to download Npcap and its
|
||||
software development kit (SDK) or WinPcap and its software development
|
||||
kit.
|
||||
|
||||
Npcap is currently being developed and maintained, and offers many
|
||||
additional capabilities that WinPcap does not.
|
||||
|
||||
WinPcap is no longer being developed or maintained; it should be used
|
||||
only if there is some other requirement to use it rather than Npcap,
|
||||
such as a requirement to support versions of Windows earlier than
|
||||
Windows Vista, which is the earliest version supported by Npcap.
|
||||
|
||||
Npcap and its SDK can be downloaded from its home page:
|
||||
|
||||
https://npcap.com
|
||||
|
||||
The SDK is a ZIP archive; create a folder on your C: drive, e.g.
|
||||
C:\npcap-sdk, and put the contents of the ZIP archive into that folder.
|
||||
|
||||
The WinPcap installer can be downloaded from
|
||||
|
||||
https://www.winpcap.org/install/default.htm
|
||||
|
||||
and the WinPcap Developer's Kit can be downloaded from
|
||||
|
||||
https://www.winpcap.org/devel.htm
|
||||
|
||||
Required build tools
|
||||
--------------------
|
||||
|
||||
The Developer's Kit is a ZIP archive; it contains a folder named
|
||||
WpdPack, which you should place on your C: drive, e.g. C:\WpdPack.
|
||||
|
||||
Building libpcap on Windows requires Visual Studio 2015 or later. The
|
||||
Community Edition of Visual Studio can be downloaded at no cost from
|
||||
|
||||
https://visualstudio.microsoft.com
|
||||
|
||||
Additional tools are also required. Chocolatey is a package manager for
|
||||
Windows with which those tools, and other tools, can be installed; it
|
||||
can be downloaded from
|
||||
|
||||
https://chocolatey.org
|
||||
|
||||
It is a command-line tool; a GUI tool, Chocolatey GUI, is provided as a
|
||||
Chocolatey package, which can be installed from the command line:
|
||||
|
||||
choco install chocolateygui
|
||||
|
||||
For convenience, the "choco install" command can be run with the "-y"
|
||||
flag, forcing it to automatically answer all questions asked of the user
|
||||
with "yes":
|
||||
|
||||
choco install -y chocolateygui
|
||||
|
||||
The required tools are:
|
||||
|
||||
### CMake ###
|
||||
|
||||
libpcap does not provide supported project files for Visual Studio
|
||||
(there are currently unsupported project files provided, but we do not
|
||||
guarantee that they will work or that we will continue to provide them).
|
||||
It does provide files for CMake, which is a cross-platform tool that
|
||||
runs on UN*Xes and on Windows and that can generate project files for
|
||||
UN*X Make, the Ninja build system, and Visual Studio, among other build
|
||||
systems.
|
||||
|
||||
Visual Studio 2015 does not provide CMake; an installer can be
|
||||
downloaded from
|
||||
|
||||
https://cmake.org/download/
|
||||
|
||||
When you run the installer, you should choose to add CMake to the system
|
||||
PATH for all users and to create the desktop icon.
|
||||
|
||||
CMake can also be installed as the Chocolatey package "cmake":
|
||||
|
||||
choco install -y cmake
|
||||
|
||||
Visual Studio 2017 and later provide CMake, so you will not need to
|
||||
install CMake if you have installed Visual Studio 2017 or later. They
|
||||
include built-in support for CMake-based projects:
|
||||
|
||||
https://devblogs.microsoft.com/cppblog/cmake-support-in-visual-studio/
|
||||
|
||||
For Visual Studio 2017, make sure "Visual C++ tools for CMake" is
|
||||
installed; for Visual Studio 2019, make sure "C++ CMake tools for
|
||||
Windows" is installed.
|
||||
|
||||
### winflexbison ###
|
||||
|
||||
libpcap uses the Flex lexical-analyzer generator and the Bison or
|
||||
Berkeley YACC parser generators to generate the parser for filter
|
||||
expressions. Windows versions of Flex and Bison can be downloaded from
|
||||
|
||||
https://sourceforge.net/projects/winflexbison/
|
||||
|
||||
The downloaded file is a ZIP archive; create a folder on your C: drive,
|
||||
e.g. C:\Program Files\winflexbison, and put the contents of the ZIP
|
||||
archive into that folder. Then add that folder to the system PATH
|
||||
environment variable.
|
||||
|
||||
Git
|
||||
---
|
||||
|
||||
An optional tool, required only if you will be building from a Git
|
||||
repository rather than from a release source tarball, is Git. Git is
|
||||
provided as an optional installation component, "Git for Windows", with
|
||||
Visual Studio 2017 and later.
|
||||
|
||||
Building from the Visual Studio GUI
|
||||
-----------------------------------
|
||||
|
||||
### Visual Studio 2017 ###
|
||||
|
||||
Open the folder containing the libpcap source with Open > Folder.
|
||||
Visual Studio will run CMake; however, you will need to indicate where
|
||||
the Npcap or WinPcap SDK is installed.
|
||||
|
||||
To do this, go to Project > "Change CMake Settings" > pcap and:
|
||||
|
||||
Choose which configuration type to build, if you don't want the default
|
||||
Debug build.
|
||||
|
||||
In the CMakeSettings.json tab, change cmakeCommandArgs to include
|
||||
|
||||
-DPacket_ROOT={path-to-sdk}
|
||||
|
||||
where {path-to-sdk} is the path of the directory containing the Npcap or
|
||||
WinPcap SDK. Note that backslashes in the path must be specified as two
|
||||
backslashes.
|
||||
|
||||
Save the configuration changes with File > "Save CMakeSettings.json" or
|
||||
with control-S.
|
||||
|
||||
Visual Studio will then re-run CMake. If that completes without errors,
|
||||
you can build with CMake > "Build All".
|
||||
|
||||
### Visual Studio 2019 ###
|
||||
|
||||
Open the folder containing the libpcap source with Open > Folder.
|
||||
Visual Studio will run CMake; however, you will need to indicate where
|
||||
the Npcap or WinPcap SDK is installed.
|
||||
|
||||
To do this, go to Project > "CMake Settings for pcap" and:
|
||||
|
||||
Choose which configuration type to build, if you don't want the default
|
||||
Debug build.
|
||||
|
||||
Scroll down to "Cmake variables and cache", scroll through the list
|
||||
looking for the entry for Packet_ROOT, and either type in the path of
|
||||
the directory containing the Npcap or WinPcap SDK or use the "Browse..."
|
||||
button to browse for that directory.
|
||||
|
||||
Save the configuration changes with File > "Save CMakeSettings.json" or
|
||||
with control-S.
|
||||
|
||||
Visual Studio will then re-run CMake. If that completes without errors,
|
||||
you can build with Build > "Build All".
|
||||
|
||||
Building from the command line
|
||||
------------------------------
|
||||
|
||||
Start the appropriate Native Tools command line prompt.
|
||||
|
||||
Change to the directory into which you want to build libpcap, possibly
|
||||
after creating it first. One choice is to create it as a subdirectory
|
||||
of the libpcap source directory.
|
||||
|
||||
Run the command
|
||||
|
||||
cmake "-DPacket_ROOT={path-to-sdk}" {path-to-libpcap-source}
|
||||
|
||||
where {path-to-sdk} is the path of the directory containing the Npcap or
|
||||
WinPcap SDK and {path-to-libpcap-source} is the pathname of the
|
||||
top-level source directory for libpcap.
|
||||
|
||||
Run the command
|
||||
|
||||
msbuild/m pcap.sln
|
||||
|
||||
to compile libpcap.
|
||||
|
|
|
@ -1,3 +1,25 @@
|
|||
# Compiling libpcap on AIX
|
||||
|
||||
* Autoconf is expected to work everywhere.
|
||||
* Neither AIX lex nor AIX yacc nor AIX m4 are suitable.
|
||||
|
||||
## AIX 7.1
|
||||
|
||||
* libpcap build fails with rpcapd enabled.
|
||||
* GNU M4 1.4.17 works.
|
||||
* flex 2.6.4 and GNU Bison 3.5.1 work.
|
||||
* CMake 3.16.0 works.
|
||||
* GCC 8.3.0 works, XL C 12.1.0 works.
|
||||
|
||||
## AIX 7.2
|
||||
|
||||
* libpcap build fails with rpcapd enabled.
|
||||
* GNU M4 1.4.17 works.
|
||||
* flex 2.5.35 and GNU Bison 3.0.4 work.
|
||||
* GCC 7.2.0 works, XL C 13.1.3 works.
|
||||
|
||||
## Other AIX-related information
|
||||
|
||||
Using BPF:
|
||||
|
||||
(1) AIX 4.x's version of BPF is undocumented and somewhat unstandard; the
|
||||
|
@ -27,7 +49,7 @@ Using BPF:
|
|||
If you fix the problems yourself, please submit a patch by forking
|
||||
the branch at
|
||||
|
||||
https://github.com/the-tcpdump-group/libpcap/issues
|
||||
https://github.com/the-tcpdump-group/libpcap/tree/master
|
||||
|
||||
and issuing a pull request, so we can incorporate the fixes into the
|
||||
next release.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
The following instructions apply if you have a Linux or FreeBSD platform and
|
||||
want libpcap to support the DAG range of passive network monitoring cards from
|
||||
Endace (http://www.endace.com, see below for further contact details).
|
||||
Endace (https://www.endace.com, see below for further contact details).
|
||||
|
||||
1) Install and build the DAG software distribution by following the
|
||||
instructions supplied with that package. Current Endace customers can download
|
||||
|
@ -22,7 +22,7 @@ If 'configure' reports that there is no DAG API, the directory may have been
|
|||
incorrectly specified or the DAG software was not built before configuring
|
||||
libpcap.
|
||||
|
||||
See also the libpcap INSTALL.txt file for further libpcap configuration
|
||||
See also the libpcap INSTALL.md file for further libpcap configuration
|
||||
options.
|
||||
|
||||
Building libpcap at this stage will include support for both the native packet
|
||||
|
@ -117,6 +117,6 @@ Please submit bug reports via <support@endace.com>.
|
|||
|
||||
Please also visit our Web site at:
|
||||
|
||||
http://www.endace.com/
|
||||
https://www.endace.com/
|
||||
|
||||
For more information about Endace DAG cards contact <sales@endace.com>.
|
||||
|
|
|
@ -8,7 +8,7 @@ Note that packet-capture programs such as tcpdump may, on HP-UX, not be
|
|||
able to see packets sent from the machine on which they're running.
|
||||
Some articles on groups.google.com discussing this are:
|
||||
|
||||
http://groups.google.com/groups?selm=82ld3v%2480i%241%40mamenchi.zrz.TU-Berlin.DE
|
||||
https://groups.google.com/groups?selm=82ld3v%2480i%241%40mamenchi.zrz.TU-Berlin.DE
|
||||
|
||||
which says:
|
||||
|
||||
|
@ -69,7 +69,7 @@ which says:
|
|||
|
||||
and
|
||||
|
||||
http://groups.google.com/groups?selm=38AA973E.96BE7DF7%40cc.uit.no
|
||||
https://groups.google.com/groups?selm=38AA973E.96BE7DF7%40cc.uit.no
|
||||
|
||||
which says:
|
||||
|
||||
|
@ -118,7 +118,7 @@ And another message to tcpdump-workers@tcpdump.org, from Rick Jones:
|
|||
|
||||
Another posting:
|
||||
|
||||
http://groups.google.com/groups?selm=7d6gvn%24b3%241%40ocean.cup.hp.com
|
||||
https://groups.google.com/groups?selm=7d6gvn%24b3%241%40ocean.cup.hp.com
|
||||
|
||||
indicates that you need to install the optional STREAMS product to do
|
||||
captures on HP-UX 9.x:
|
||||
|
@ -159,7 +159,7 @@ An additional note, from Jost Martin, for HP-UX 10.20:
|
|||
of an interface
|
||||
A: You need to get PHNE_20892,PHNE_20725 and PHCO_10947 (or
|
||||
newer, this is as of 4.4.00) and its dependencies. Then you can
|
||||
enable the feature as descibed below:
|
||||
enable the feature as described below:
|
||||
|
||||
Patch Name: PHNE_20892
|
||||
Patch Description: s700 10.20 PCI 100Base-T cumulative patch
|
||||
|
@ -195,7 +195,7 @@ Here's the "hack_ip_stack" script:
|
|||
-----------------------------------Cut Here-------------------------------------
|
||||
#!/sbin/sh
|
||||
#
|
||||
# nettune: hack kernel parms for safety
|
||||
# nettune: hack kernel params for safety
|
||||
|
||||
OKAY=0
|
||||
ERROR=-1
|
||||
|
|
36
contrib/libpcap/doc/README.linux
Normal file
36
contrib/libpcap/doc/README.linux
Normal file
|
@ -0,0 +1,36 @@
|
|||
Currently, libpcap supports packet capturing on Linux 2.6.27 and later;
|
||||
earlier versions are not supported.
|
||||
|
||||
You must configure 2.6.x kernels with the CONFIG_PACKET_MMAP option for
|
||||
this protocol. 3.x and later kernels do not require that.
|
||||
|
||||
Note that, by default, libpcap will, if libnl is present, build with it;
|
||||
it uses libnl to support monitor mode on mac80211 devices. There is a
|
||||
configuration option to disable building with libnl, but, if that option
|
||||
is chosen, the monitor-mode APIs (as used by tcpdump's "-I" flag, and as
|
||||
will probably be used by other applications in the future) won't work
|
||||
properly on mac80211 devices.
|
||||
|
||||
Linux's run-time linker allows shared libraries to be linked with other
|
||||
shared libraries, which means that if an older version of a shared
|
||||
library doesn't require routines from some other shared library, and a
|
||||
later version of the shared library does require those routines, the
|
||||
later version of the shared library can be linked with that other shared
|
||||
library and, if it's otherwise binary-compatible with the older version,
|
||||
can replace that older version without breaking applications built with
|
||||
the older version, and without breaking configure scripts or the build
|
||||
procedure for applications whose configure script doesn't use the
|
||||
pcap-config script if they build with the shared library. (The build
|
||||
procedure for applications whose configure scripts use the pcap-config
|
||||
script if present will not break even if they build with the static
|
||||
library.)
|
||||
|
||||
Statistics:
|
||||
Statistics reported by pcap are platform specific. The statistics
|
||||
reported by pcap_stats on Linux are as follows:
|
||||
|
||||
ps_recv Number of packets that were accepted by the pcap filter
|
||||
ps_drop Number of packets that had passed filtering but were not
|
||||
passed on to pcap due to things like buffer shortage, etc.
|
||||
This is useful because these are packets you are interested in
|
||||
but won't be reported by, for example, tcpdump output.
|
|
@ -1,108 +0,0 @@
|
|||
In order for libpcap to be able to capture packets on a Linux system,
|
||||
the "packet" protocol must be supported by your kernel. If it is not,
|
||||
you may get error messages such as
|
||||
|
||||
modprobe: can't locate module net-pf-17
|
||||
|
||||
in "/var/adm/messages", or may get messages such as
|
||||
|
||||
socket: Address family not supported by protocol
|
||||
|
||||
from applications using libpcap.
|
||||
|
||||
You must configure the kernel with the CONFIG_PACKET option for this
|
||||
protocol; the following note is from the Linux "Configure.help" file for
|
||||
the 2.0[.x] kernel:
|
||||
|
||||
Packet socket
|
||||
CONFIG_PACKET
|
||||
The Packet protocol is used by applications which communicate
|
||||
directly with network devices without an intermediate network
|
||||
protocol implemented in the kernel, e.g. tcpdump. If you want them
|
||||
to work, choose Y.
|
||||
|
||||
This driver is also available as a module called af_packet.o ( =
|
||||
code which can be inserted in and removed from the running kernel
|
||||
whenever you want). If you want to compile it as a module, say M
|
||||
here and read Documentation/modules.txt; if you use modprobe or
|
||||
kmod, you may also want to add "alias net-pf-17 af_packet" to
|
||||
/etc/modules.conf.
|
||||
|
||||
and the note for the 2.2[.x] kernel says:
|
||||
|
||||
Packet socket
|
||||
CONFIG_PACKET
|
||||
The Packet protocol is used by applications which communicate
|
||||
directly with network devices without an intermediate network
|
||||
protocol implemented in the kernel, e.g. tcpdump. If you want them
|
||||
to work, choose Y. This driver is also available as a module called
|
||||
af_packet.o ( = code which can be inserted in and removed from the
|
||||
running kernel whenever you want). If you want to compile it as a
|
||||
module, say M here and read Documentation/modules.txt. You will
|
||||
need to add 'alias net-pf-17 af_packet' to your /etc/conf.modules
|
||||
file for the module version to function automatically. If unsure,
|
||||
say Y.
|
||||
|
||||
In addition, there is an option that, in 2.2 and later kernels, will
|
||||
allow packet capture filters specified to programs such as tcpdump to be
|
||||
executed in the kernel, so that packets that don't pass the filter won't
|
||||
be copied from the kernel to the program, rather than having all packets
|
||||
copied to the program and libpcap doing the filtering in user mode.
|
||||
|
||||
Copying packets from the kernel to the program consumes a significant
|
||||
amount of CPU, so filtering in the kernel can reduce the overhead of
|
||||
capturing packets if a filter has been specified that discards a
|
||||
significant number of packets. (If no filter is specified, it makes no
|
||||
difference whether the filtering isn't performed in the kernel or isn't
|
||||
performed in user mode. :-))
|
||||
|
||||
The option for this is the CONFIG_FILTER option; the "Configure.help"
|
||||
file says:
|
||||
|
||||
Socket filtering
|
||||
CONFIG_FILTER
|
||||
The Linux Socket Filter is derived from the Berkeley Packet Filter.
|
||||
If you say Y here, user-space programs can attach a filter to any
|
||||
socket and thereby tell the kernel that it should allow or disallow
|
||||
certain types of data to get through the socket. Linux Socket
|
||||
Filtering works on all socket types except TCP for now. See the text
|
||||
file linux/Documentation/networking/filter.txt for more information.
|
||||
If unsure, say N.
|
||||
|
||||
Note that, by default, libpcap will, if libnl is present, build with it;
|
||||
it uses libnl to support monitor mode on mac80211 devices. There is a
|
||||
configuration option to disable building with libnl, but, if that option
|
||||
is chosen, the monitor-mode APIs (as used by tcpdump's "-I" flag, and as
|
||||
will probably be used by other applications in the future) won't work
|
||||
properly on mac80211 devices.
|
||||
|
||||
Linux's run-time linker allows shared libraries to be linked with other
|
||||
shared libraries, which means that if an older version of a shared
|
||||
library doesn't require routines from some other shared library, and a
|
||||
later version of the shared library does require those routines, the
|
||||
later version of the shared library can be linked with that other shared
|
||||
library and, if it's otherwise binary-compatible with the older version,
|
||||
can replace that older version without breaking applications built with
|
||||
the older version, and without breaking configure scripts or the build
|
||||
procedure for applications whose configure script doesn't use the
|
||||
pcap-config script if they build with the shared library. (The build
|
||||
procedure for applications whose configure scripts use the pcap-config
|
||||
script if present will not break even if they build with the static
|
||||
library.)
|
||||
|
||||
Statistics:
|
||||
Statistics reported by pcap are platform specific. The statistics
|
||||
reported by pcap_stats on Linux are as follows:
|
||||
|
||||
2.2.x
|
||||
=====
|
||||
ps_recv Number of packets that were accepted by the pcap filter
|
||||
ps_drop Always 0, this statistic is not gathered on this platform
|
||||
|
||||
2.4.x and later
|
||||
=====
|
||||
ps_recv Number of packets that were accepted by the pcap filter
|
||||
ps_drop Number of packets that had passed filtering but were not
|
||||
passed on to pcap due to things like buffer shortage, etc.
|
||||
This is useful because these are packets you are interested in
|
||||
but won't be reported by, for example, tcpdump output.
|
|
@ -1,6 +1,6 @@
|
|||
The following instructions apply if you have a Linux platform and want
|
||||
libpcap to support the Septel range of passive network monitoring cards
|
||||
from Intel (http://www.intel.com)
|
||||
from Intel (https://www.intel.com)
|
||||
|
||||
1) Install and build the Septel software distribution by following the
|
||||
instructions supplied with that package.
|
||||
|
@ -25,7 +25,7 @@ If 'configure' reports that there is no Septel API, the directory may have been
|
|||
incorrectly specified or the Septel software was not built before configuring
|
||||
libpcap.
|
||||
|
||||
See also the libpcap INSTALL.txt file for further libpcap configuration
|
||||
See also the libpcap INSTALL.md file for further libpcap configuration
|
||||
options.
|
||||
|
||||
Building libpcap at this stage will include support for both the native
|
||||
|
|
|
@ -1,18 +1,25 @@
|
|||
NOTE: this is not currently supported; the configure script doesn't
|
||||
support --with-sita, and CMake doesn't support enabling SITA ACN
|
||||
support. The code currently does not compile; it should really be
|
||||
implemented as an additional remote capture mechanism, using a URL,
|
||||
rather than as a separate version of libpcap that supports only the ACN
|
||||
product, but the infrastructure for that isn't yet available.
|
||||
|
||||
The following instructions apply if you have a Linux platform and want
|
||||
libpcap to support the 'ACN' WAN/LAN router product from SITA
|
||||
(http://www.sita.aero)
|
||||
(https://www.sita.aero)
|
||||
|
||||
This might also work on non-Linux Unix-compatible platforms, but that
|
||||
has not been tested.
|
||||
|
||||
See also the libpcap INSTALL.txt file for further libpcap configuration
|
||||
See also the libpcap INSTALL.md file for further libpcap configuration
|
||||
options.
|
||||
|
||||
These additions/extensions have been made to PCAP to allow it to
|
||||
capture packets from a SITA ACN device (and potentially others).
|
||||
|
||||
To enable its support you need to ensure that the distribution has
|
||||
a correct configure.ac file; that can be created if neccessay by
|
||||
a correct configure.ac file; that can be created if necessary by
|
||||
using the normal autoconf procedure of:
|
||||
|
||||
aclocal
|
||||
|
|
58
contrib/libpcap/doc/README.solaris.md
Normal file
58
contrib/libpcap/doc/README.solaris.md
Normal file
|
@ -0,0 +1,58 @@
|
|||
# Compiling libpcap on Solaris and related OSes
|
||||
|
||||
* Autoconf works everywhere.
|
||||
* Neither Solaris lex nor Solaris yacc are suitable.
|
||||
* Neither illumos lex nor illumos yacc are suitable.
|
||||
* Solaris m4 and illumos m4 are suitable.
|
||||
|
||||
## OmniOS r151042/AMD64
|
||||
|
||||
* flex 2.6.4 and GNU Bison 3.8.2 work.
|
||||
* CMake 3.23.1 works.
|
||||
* GCC 11.2.0 and Clang 14.0.3 work.
|
||||
|
||||
## OpenIndiana 2021.04/AMD64
|
||||
|
||||
* flex 2.6.4 and GNU Bison 3.7.6 work.
|
||||
* CMake 3.21.1 works.
|
||||
* GCC 7.5.0 and GCC 10.3.0 work, Clang 9.0.1 works.
|
||||
|
||||
For reference, the tests were done using a system installed from
|
||||
`OI-hipster-text-20210430.iso` plus the following packages:
|
||||
```shell
|
||||
xargs -L1 pkg install <<ENDOFTEXT
|
||||
developer/build/autoconf
|
||||
developer/parser/bison
|
||||
developer/lexer/flex
|
||||
developer/build/cmake
|
||||
developer/gcc-10
|
||||
developer/clang-90
|
||||
ENDOFTEXT
|
||||
```
|
||||
|
||||
## Solaris 11/AMD64
|
||||
|
||||
* flex 2.6.4 and GNU Bison 3.7.3 work.
|
||||
* CMake 3.21.0 works.
|
||||
* Clang 11.0 works, GCC 11.2 works.
|
||||
|
||||
For reference, the tests were done using Oracle Solaris 11.4.42.111.0.
|
||||
|
||||
## Solaris 11/SPARC
|
||||
|
||||
* flex 2.6.4 and GNU Bison 3.7.1 work.
|
||||
* CMake 3.14.3 works.
|
||||
* Sun C 5.13, Sun C 5.14 and Sun C 5.15 work; GCC 5.5.0 and GCC 7.3.0 work.
|
||||
|
||||
## Solaris 10/SPARC
|
||||
|
||||
* libpcap build fails with rpcapd enabled.
|
||||
* flex 2.6.4 and GNU Bison 3.7.1 work.
|
||||
* CMake 3.14.3 works.
|
||||
* Sun C 5.13 works, GCC 5.5.0 works.
|
||||
|
||||
## Solaris 9/SPARC
|
||||
|
||||
* flex 2.5.35 and GNU Bison 3.0.2 work.
|
||||
* CMake 2.8.9 does not work.
|
||||
* Neither Sun C 5.8 nor Sun C 5.9 work, GCC 4.6.4 works.
|
|
@ -1,49 +0,0 @@
|
|||
The following instructions are applicable to Tru64 UNIX
|
||||
(formerly Digital UNIX (formerly DEC OSF/1)) version 4.0, and
|
||||
probably to later versions as well; at least some options apply to
|
||||
Digital UNIX 3.2 - perhaps all do.
|
||||
|
||||
In order to use kernel packet filtering on this system, you have
|
||||
to configure it in such a way:
|
||||
|
||||
Kernel configuration
|
||||
--------------------
|
||||
|
||||
The packet filtering kernel option must be enabled at kernel
|
||||
installation. If it was not the case, you can rebuild the kernel with
|
||||
"doconfig -c" after adding the following line in the kernel
|
||||
configuration file (/sys/conf/<HOSTNAME>):
|
||||
|
||||
option PACKETFILTER
|
||||
|
||||
or use "doconfig" without any arguments to add the packet filter driver
|
||||
option via the kernel option menu (see the system administration
|
||||
documentation for information on how to do this).
|
||||
|
||||
Device configuration
|
||||
--------------------
|
||||
|
||||
Devices used for packet filtering must be created thanks to
|
||||
the following command (executed in the /dev directory):
|
||||
|
||||
./MAKEDEV pfilt
|
||||
|
||||
Interface configuration
|
||||
-----------------------
|
||||
|
||||
In order to capture all packets on a network, you may want to allow
|
||||
applications to put the interface on that network into "local copy"
|
||||
mode, so that tcpdump can see packets sent by the host on which it's
|
||||
running as well as packets received by that host, and to put the
|
||||
interface into "promiscuous" mode, so that tcpdump can see packets on
|
||||
the network segment not sent to the host on which it's running, by using
|
||||
the pfconfig(1) command:
|
||||
|
||||
pfconfig +c +p <network_device>
|
||||
|
||||
or allow application to put any interface into "local copy" or
|
||||
"promiscuous" mode by using the command:
|
||||
|
||||
pfconfig +c +p -a
|
||||
|
||||
Note: all instructions given require root privileges.
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include <pcap-types.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <memory.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -45,14 +44,18 @@ static inline int skip_line(FILE *);
|
|||
static inline u_char
|
||||
xdtoi(u_char c)
|
||||
{
|
||||
if (isdigit(c))
|
||||
if (c >= '0' && c <= '9')
|
||||
return (u_char)(c - '0');
|
||||
else if (islower(c))
|
||||
else if (c >= 'a' && c <= 'f')
|
||||
return (u_char)(c - 'a' + 10);
|
||||
else
|
||||
return (u_char)(c - 'A' + 10);
|
||||
}
|
||||
|
||||
/*
|
||||
* Skip linear white space (space and tab) and any CRs before LF.
|
||||
* Stop when we hit a non-white-space character or an end-of-line LF.
|
||||
*/
|
||||
static inline int
|
||||
skip_space(FILE *f)
|
||||
{
|
||||
|
@ -60,7 +63,7 @@ skip_space(FILE *f)
|
|||
|
||||
do {
|
||||
c = getc(f);
|
||||
} while (isspace(c) && c != '\n');
|
||||
} while (c == ' ' || c == '\t' || c == '\r');
|
||||
|
||||
return c;
|
||||
}
|
||||
|
@ -97,7 +100,7 @@ pcap_next_etherent(FILE *fp)
|
|||
|
||||
/* If this is a comment, or first thing on line
|
||||
cannot be Ethernet address, skip the line. */
|
||||
if (!isxdigit(c)) {
|
||||
if (!PCAP_ISXDIGIT(c)) {
|
||||
c = skip_line(fp);
|
||||
if (c == EOF)
|
||||
return (NULL);
|
||||
|
@ -110,7 +113,7 @@ pcap_next_etherent(FILE *fp)
|
|||
c = getc(fp);
|
||||
if (c == EOF)
|
||||
return (NULL);
|
||||
if (isxdigit(c)) {
|
||||
if (PCAP_ISXDIGIT(c)) {
|
||||
d <<= 4;
|
||||
d |= xdtoi((u_char)c);
|
||||
c = getc(fp);
|
||||
|
@ -126,7 +129,7 @@ pcap_next_etherent(FILE *fp)
|
|||
}
|
||||
|
||||
/* Must be whitespace */
|
||||
if (!isspace(c)) {
|
||||
if (c != ' ' && c != '\t' && c != '\r' && c != '\n') {
|
||||
c = skip_line(fp);
|
||||
if (c == EOF)
|
||||
return (NULL);
|
||||
|
@ -156,7 +159,8 @@ pcap_next_etherent(FILE *fp)
|
|||
c = getc(fp);
|
||||
if (c == EOF)
|
||||
return (NULL);
|
||||
} while (!isspace(c) && --namesize != 0);
|
||||
} while (c != ' ' && c != '\t' && c != '\r' && c != '\n'
|
||||
&& --namesize != 0);
|
||||
*bp = '\0';
|
||||
|
||||
/* Eat trailing junk */
|
||||
|
|
|
@ -32,58 +32,58 @@
|
|||
*/
|
||||
|
||||
#ifndef ETHERTYPE_PUP
|
||||
#define ETHERTYPE_PUP 0x0200 /* PUP protocol */
|
||||
#define ETHERTYPE_PUP 0x0200 /* PUP protocol */
|
||||
#endif
|
||||
#ifndef ETHERTYPE_IP
|
||||
#define ETHERTYPE_IP 0x0800 /* IP protocol */
|
||||
#define ETHERTYPE_IP 0x0800 /* IP protocol */
|
||||
#endif
|
||||
#ifndef ETHERTYPE_ARP
|
||||
#define ETHERTYPE_ARP 0x0806 /* Addr. resolution protocol */
|
||||
#endif
|
||||
#ifndef ETHERTYPE_REVARP
|
||||
#define ETHERTYPE_REVARP 0x8035 /* reverse Addr. resolution protocol */
|
||||
#endif
|
||||
#ifndef ETHERTYPE_NS
|
||||
#define ETHERTYPE_NS 0x0600
|
||||
#endif
|
||||
#ifndef ETHERTYPE_SPRITE
|
||||
#define ETHERTYPE_SPRITE 0x0500
|
||||
#define ETHERTYPE_SPRITE 0x0500
|
||||
#endif
|
||||
#ifndef ETHERTYPE_TRAIL
|
||||
#define ETHERTYPE_TRAIL 0x1000
|
||||
#endif
|
||||
#ifndef ETHERTYPE_MOPDL
|
||||
#define ETHERTYPE_MOPDL 0x6001
|
||||
#define ETHERTYPE_MOPDL 0x6001
|
||||
#endif
|
||||
#ifndef ETHERTYPE_MOPRC
|
||||
#define ETHERTYPE_MOPRC 0x6002
|
||||
#define ETHERTYPE_MOPRC 0x6002
|
||||
#endif
|
||||
#ifndef ETHERTYPE_DN
|
||||
#define ETHERTYPE_DN 0x6003
|
||||
#define ETHERTYPE_DN 0x6003
|
||||
#endif
|
||||
#ifndef ETHERTYPE_LAT
|
||||
#define ETHERTYPE_LAT 0x6004
|
||||
#define ETHERTYPE_LAT 0x6004
|
||||
#endif
|
||||
#ifndef ETHERTYPE_SCA
|
||||
#define ETHERTYPE_SCA 0x6007
|
||||
#endif
|
||||
#ifndef ETHERTYPE_TEB
|
||||
#define ETHERTYPE_TEB 0x6558
|
||||
#endif
|
||||
#ifndef ETHERTYPE_REVARP
|
||||
#define ETHERTYPE_REVARP 0x8035
|
||||
#define ETHERTYPE_REVARP 0x8035 /* reverse Addr. resolution protocol */
|
||||
#endif
|
||||
#ifndef ETHERTYPE_LANBRIDGE
|
||||
#define ETHERTYPE_LANBRIDGE 0x8038
|
||||
#define ETHERTYPE_LANBRIDGE 0x8038
|
||||
#endif
|
||||
#ifndef ETHERTYPE_DECDNS
|
||||
#define ETHERTYPE_DECDNS 0x803c
|
||||
#define ETHERTYPE_DECDNS 0x803c
|
||||
#endif
|
||||
#ifndef ETHERTYPE_DECDTS
|
||||
#define ETHERTYPE_DECDTS 0x803e
|
||||
#define ETHERTYPE_DECDTS 0x803e
|
||||
#endif
|
||||
#ifndef ETHERTYPE_VEXP
|
||||
#define ETHERTYPE_VEXP 0x805b
|
||||
#define ETHERTYPE_VEXP 0x805b
|
||||
#endif
|
||||
#ifndef ETHERTYPE_VPROD
|
||||
#define ETHERTYPE_VPROD 0x805c
|
||||
#define ETHERTYPE_VPROD 0x805c
|
||||
#endif
|
||||
#ifndef ETHERTYPE_ATALK
|
||||
#define ETHERTYPE_ATALK 0x809b
|
||||
|
@ -101,10 +101,10 @@
|
|||
#define ETHERTYPE_IPV6 0x86dd
|
||||
#endif
|
||||
#ifndef ETHERTYPE_MPLS
|
||||
#define ETHERTYPE_MPLS 0x8847
|
||||
#define ETHERTYPE_MPLS 0x8847
|
||||
#endif
|
||||
#ifndef ETHERTYPE_MPLS_MULTI
|
||||
#define ETHERTYPE_MPLS_MULTI 0x8848
|
||||
#define ETHERTYPE_MPLS_MULTI 0x8848
|
||||
#endif
|
||||
#ifndef ETHERTYPE_PPPOED
|
||||
#define ETHERTYPE_PPPOED 0x8863
|
||||
|
@ -116,7 +116,7 @@
|
|||
#define ETHERTYPE_8021AD 0x88a8
|
||||
#endif
|
||||
#ifndef ETHERTYPE_LOOPBACK
|
||||
#define ETHERTYPE_LOOPBACK 0x9000
|
||||
#define ETHERTYPE_LOOPBACK 0x9000
|
||||
#endif
|
||||
#ifndef ETHERTYPE_8021QINQ
|
||||
#define ETHERTYPE_8021QINQ 0x9100
|
||||
|
|
|
@ -25,15 +25,94 @@
|
|||
|
||||
#include <pcap/pcap-inttypes.h>
|
||||
#include <pcap/compiler-tests.h>
|
||||
#include "portability.h"
|
||||
|
||||
/*
|
||||
* Macros to extract possibly-unaligned big-endian integral values.
|
||||
* If we have versions of GCC or Clang that support an __attribute__
|
||||
* to say "if we're building with unsigned behavior sanitization,
|
||||
* don't complain about undefined behavior in this function", we
|
||||
* label these functions with that attribute - we *know* it's undefined
|
||||
* in the C standard, but we *also* know it does what we want with
|
||||
* the ISA we're targeting and the compiler we're using.
|
||||
*
|
||||
* For GCC 4.9.0 and later, we use __attribute__((no_sanitize_undefined));
|
||||
* pre-5.0 GCC doesn't have __has_attribute, and I'm not sure whether
|
||||
* GCC or Clang first had __attribute__((no_sanitize(XXX)).
|
||||
*
|
||||
* For Clang, we check for __attribute__((no_sanitize(XXX)) with
|
||||
* __has_attribute, as there are versions of Clang that support
|
||||
* __attribute__((no_sanitize("undefined")) but don't support
|
||||
* __attribute__((no_sanitize_undefined)).
|
||||
*
|
||||
* We define this here, rather than in funcattrs.h, because we
|
||||
* only want it used here, we don't want it to be broadly used.
|
||||
* (Any printer will get this defined, but this should at least
|
||||
* make it harder for people to find.)
|
||||
*/
|
||||
#ifdef LBL_ALIGN
|
||||
#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 409)
|
||||
#define UNALIGNED_OK __attribute__((no_sanitize_undefined))
|
||||
#elif __has_attribute(no_sanitize)
|
||||
#define UNALIGNED_OK __attribute__((no_sanitize("undefined")))
|
||||
#else
|
||||
#define UNALIGNED_OK
|
||||
#endif
|
||||
|
||||
#if (defined(__i386__) || defined(_M_IX86) || defined(__X86__) || defined(__x86_64__) || defined(_M_X64)) || \
|
||||
(defined(__m68k__) && (!defined(__mc68000__) && !defined(__mc68010__))) || \
|
||||
(defined(__ppc__) || defined(__ppc64__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PPC64)) || \
|
||||
(defined(__s390__) || defined(__s390x__) || defined(__zarch__))
|
||||
/*
|
||||
* The processor doesn't natively handle unaligned loads.
|
||||
* The processor natively handles unaligned loads, so we can just
|
||||
* cast the pointer and fetch through it.
|
||||
*
|
||||
* XXX - are those all the x86 tests we need?
|
||||
* XXX - are those the only 68k tests we need not to generated
|
||||
* unaligned accesses if the target is the 68000 or 68010?
|
||||
* XXX - are there any tests we don't need, because some definitions are for
|
||||
* compilers that also predefine the GCC symbols?
|
||||
* XXX - do we need to test for both 32-bit and 64-bit versions of those
|
||||
* architectures in all cases?
|
||||
*/
|
||||
#if PCAP_IS_AT_LEAST_GNUC_VERSION(2,0) && \
|
||||
UNALIGNED_OK static inline uint16_t
|
||||
EXTRACT_BE_U_2(const void *p)
|
||||
{
|
||||
return ((uint16_t)ntohs(*(const uint16_t *)(p)));
|
||||
}
|
||||
|
||||
UNALIGNED_OK static inline int16_t
|
||||
EXTRACT_BE_S_2(const void *p)
|
||||
{
|
||||
return ((int16_t)ntohs(*(const int16_t *)(p)));
|
||||
}
|
||||
|
||||
UNALIGNED_OK static inline uint32_t
|
||||
EXTRACT_BE_U_4(const void *p)
|
||||
{
|
||||
return ((uint32_t)ntohl(*(const uint32_t *)(p)));
|
||||
}
|
||||
|
||||
UNALIGNED_OK static inline int32_t
|
||||
EXTRACT_BE_S_4(const void *p)
|
||||
{
|
||||
return ((int32_t)ntohl(*(const int32_t *)(p)));
|
||||
}
|
||||
|
||||
UNALIGNED_OK static inline uint64_t
|
||||
EXTRACT_BE_U_8(const void *p)
|
||||
{
|
||||
return ((uint64_t)(((uint64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 |
|
||||
((uint64_t)ntohl(*((const uint32_t *)(p) + 1))) << 0));
|
||||
|
||||
}
|
||||
|
||||
UNALIGNED_OK static inline int64_t
|
||||
EXTRACT_BE_S_8(const void *p)
|
||||
{
|
||||
return ((int64_t)(((int64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 |
|
||||
((uint64_t)ntohl(*((const uint32_t *)(p) + 1))) << 0));
|
||||
|
||||
}
|
||||
#elif PCAP_IS_AT_LEAST_GNUC_VERSION(2,0) && \
|
||||
(defined(__alpha) || defined(__alpha__) || \
|
||||
defined(__mips) || defined(__mips__))
|
||||
/*
|
||||
|
@ -48,11 +127,11 @@
|
|||
* cast the pointer to point to one of those, and fetch through it;
|
||||
* the GCC manual doesn't appear to explicitly say that
|
||||
* __attribute__((packed)) causes the compiler to generate unaligned-safe
|
||||
* code, but it apppears to do so.
|
||||
* code, but it appears to do so.
|
||||
*
|
||||
* We do this in case the compiler can generate code using those
|
||||
* instructions to do an unaligned load and pass stuff to "ntohs()" or
|
||||
* "ntohl()", which might be better than than the code to fetch the
|
||||
* "ntohl()", which might be better than the code to fetch the
|
||||
* bytes one at a time and assemble them. (That might not be the
|
||||
* case on a little-endian platform, such as DEC's MIPS machines and
|
||||
* Alpha machines, where "ntohs()" and "ntohl()" might not be done
|
||||
|
@ -92,46 +171,91 @@ typedef struct {
|
|||
uint16_t val;
|
||||
} __attribute__((packed)) unaligned_uint16_t;
|
||||
|
||||
typedef struct {
|
||||
int16_t val;
|
||||
} __attribute__((packed)) unaligned_int16_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t val;
|
||||
} __attribute__((packed)) unaligned_uint32_t;
|
||||
|
||||
static inline uint16_t
|
||||
EXTRACT_16BITS(const void *p)
|
||||
typedef struct {
|
||||
int32_t val;
|
||||
} __attribute__((packed)) unaligned_int32_t;
|
||||
|
||||
UNALIGNED_OK static inline uint16_t
|
||||
EXTRACT_BE_U_2(const void *p)
|
||||
{
|
||||
return ((uint16_t)ntohs(((const unaligned_uint16_t *)(p))->val));
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
EXTRACT_32BITS(const void *p)
|
||||
UNALIGNED_OK static inline int16_t
|
||||
EXTRACT_BE_S_2(const void *p)
|
||||
{
|
||||
return ((int16_t)ntohs(((const unaligned_int16_t *)(p))->val));
|
||||
}
|
||||
|
||||
UNALIGNED_OK static inline uint32_t
|
||||
EXTRACT_BE_U_4(const void *p)
|
||||
{
|
||||
return ((uint32_t)ntohl(((const unaligned_uint32_t *)(p))->val));
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
EXTRACT_64BITS(const void *p)
|
||||
UNALIGNED_OK static inline int32_t
|
||||
EXTRACT_BE_S_4(const void *p)
|
||||
{
|
||||
return ((uint64_t)(((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 0)->val)) << 32 | \
|
||||
return ((int32_t)ntohl(((const unaligned_int32_t *)(p))->val));
|
||||
}
|
||||
|
||||
UNALIGNED_OK static inline uint64_t
|
||||
EXTRACT_BE_U_8(const void *p)
|
||||
{
|
||||
return ((uint64_t)(((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 0)->val)) << 32 |
|
||||
((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 1)->val)) << 0));
|
||||
}
|
||||
|
||||
#else /* have to do it a byte at a time */
|
||||
UNALIGNED_OK static inline int64_t
|
||||
EXTRACT_BE_S_8(const void *p)
|
||||
{
|
||||
return ((int64_t)(((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 0)->val)) << 32 |
|
||||
((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 1)->val)) << 0));
|
||||
}
|
||||
#else
|
||||
/*
|
||||
* This isn't a GCC-compatible compiler, we don't have __attribute__,
|
||||
* This architecture doesn't natively support unaligned loads, and either
|
||||
* this isn't a GCC-compatible compiler, we don't have __attribute__,
|
||||
* or we do but we don't know of any better way with this instruction
|
||||
* set to do unaligned loads, so do unaligned loads of big-endian
|
||||
* quantities the hard way - fetch the bytes one at a time and
|
||||
* assemble them.
|
||||
*
|
||||
* XXX - ARM is a special case. ARMv1 through ARMv5 didn't suppory
|
||||
* unaligned loads; ARMv6 and later support it *but* have a bit in
|
||||
* the system control register that the OS can set and that causes
|
||||
* unaligned loads to fault rather than succeeding.
|
||||
*
|
||||
* At least some OSes may set that flag, so we do *not* treat ARM
|
||||
* as supporting unaligned loads. If your OS supports them on ARM,
|
||||
* and you want to use them, please update the tests in the #if above
|
||||
* to check for ARM *and* for your OS.
|
||||
*/
|
||||
#define EXTRACT_16BITS(p) \
|
||||
#define EXTRACT_BE_U_2(p) \
|
||||
((uint16_t)(((uint16_t)(*((const uint8_t *)(p) + 0)) << 8) | \
|
||||
((uint16_t)(*((const uint8_t *)(p) + 1)) << 0)))
|
||||
#define EXTRACT_32BITS(p) \
|
||||
#define EXTRACT_BE_S_2(p) \
|
||||
((int16_t)(((uint16_t)(*((const uint8_t *)(p) + 0)) << 8) | \
|
||||
((uint16_t)(*((const uint8_t *)(p) + 1)) << 0)))
|
||||
#define EXTRACT_BE_U_4(p) \
|
||||
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 24) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 1)) << 16) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 2)) << 8) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 3)) << 0)))
|
||||
#define EXTRACT_64BITS(p) \
|
||||
#define EXTRACT_BE_S_4(p) \
|
||||
((int32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 24) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 1)) << 16) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 2)) << 8) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 3)) << 0)))
|
||||
#define EXTRACT_BE_U_8(p) \
|
||||
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 56) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 48) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 40) | \
|
||||
|
@ -140,47 +264,67 @@ EXTRACT_64BITS(const void *p)
|
|||
((uint64_t)(*((const uint8_t *)(p) + 5)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 6)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 7)) << 0)))
|
||||
#endif /* must special-case unaligned accesses */
|
||||
#else /* LBL_ALIGN */
|
||||
#define EXTRACT_BE_S_8(p) \
|
||||
((int64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 56) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 48) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 40) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 3)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 24) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 5)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 6)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 7)) << 0)))
|
||||
|
||||
/*
|
||||
* The processor natively handles unaligned loads, so we can just
|
||||
* cast the pointer and fetch through it.
|
||||
* Extract an IPv4 address, which is in network byte order, and not
|
||||
* necessarily aligned, and provide the result in host byte order.
|
||||
*/
|
||||
static inline uint16_t
|
||||
EXTRACT_16BITS(const void *p)
|
||||
{
|
||||
return ((uint16_t)ntohs(*(const uint16_t *)(p)));
|
||||
}
|
||||
#define EXTRACT_IPV4_TO_HOST_ORDER(p) \
|
||||
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 24) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 1)) << 16) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 2)) << 8) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 3)) << 0)))
|
||||
#endif /* unaligned access checks */
|
||||
|
||||
static inline uint32_t
|
||||
EXTRACT_32BITS(const void *p)
|
||||
{
|
||||
return ((uint32_t)ntohl(*(const uint32_t *)(p)));
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
EXTRACT_64BITS(const void *p)
|
||||
{
|
||||
return ((uint64_t)(((uint64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 | \
|
||||
((uint64_t)ntohl(*((const uint32_t *)(p) + 1))) << 0));
|
||||
|
||||
}
|
||||
|
||||
#endif /* LBL_ALIGN */
|
||||
|
||||
#define EXTRACT_24BITS(p) \
|
||||
/*
|
||||
* Non-power-of-2 sizes.
|
||||
*/
|
||||
#define EXTRACT_BE_U_3(p) \
|
||||
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 16) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 2)) << 0)))
|
||||
|
||||
#define EXTRACT_40BITS(p) \
|
||||
#define EXTRACT_BE_S_3(p) \
|
||||
(((*((const uint8_t *)(p) + 0)) & 0x80) ? \
|
||||
((int32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 16) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 2)) << 0))) : \
|
||||
((int32_t)(0xFF000000U | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 0)) << 16) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 2)) << 0))))
|
||||
|
||||
#define EXTRACT_BE_U_5(p) \
|
||||
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 24) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 3)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 0)))
|
||||
|
||||
#define EXTRACT_48BITS(p) \
|
||||
#define EXTRACT_BE_S_5(p) \
|
||||
(((*((const uint8_t *)(p) + 0)) & 0x80) ? \
|
||||
((int64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 24) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 3)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 0))) : \
|
||||
((int64_t)(INT64_T_CONSTANT(0xFFFFFF0000000000U) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 0)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 24) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 3)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 0))))
|
||||
|
||||
#define EXTRACT_BE_U_6(p) \
|
||||
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 40) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 24) | \
|
||||
|
@ -188,7 +332,23 @@ EXTRACT_64BITS(const void *p)
|
|||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 5)) << 0)))
|
||||
|
||||
#define EXTRACT_56BITS(p) \
|
||||
#define EXTRACT_BE_S_6(p) \
|
||||
(((*((const uint8_t *)(p) + 0)) & 0x80) ? \
|
||||
((int64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 40) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 24) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 3)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 5)) << 0))) : \
|
||||
((int64_t)(INT64_T_CONSTANT(0xFFFFFFFF00000000U) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 0)) << 40) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 24) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 3)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 5)) << 0))))
|
||||
|
||||
#define EXTRACT_BE_U_7(p) \
|
||||
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 48) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 40) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 32) | \
|
||||
|
@ -197,24 +357,53 @@ EXTRACT_64BITS(const void *p)
|
|||
((uint64_t)(*((const uint8_t *)(p) + 5)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 6)) << 0)))
|
||||
|
||||
#define EXTRACT_BE_S_7(p) \
|
||||
(((*((const uint8_t *)(p) + 0)) & 0x80) ? \
|
||||
((int64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 48) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 40) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 5)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 6)) << 0))) : \
|
||||
((int64_t)(INT64_T_CONSTANT(0xFFFFFFFFFF000000U) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 0)) << 48) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 40) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 5)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 6)) << 0))))
|
||||
|
||||
/*
|
||||
* Macros to extract possibly-unaligned little-endian integral values.
|
||||
* XXX - do loads on little-endian machines that support unaligned loads?
|
||||
*/
|
||||
#define EXTRACT_LE_8BITS(p) (*(p))
|
||||
#define EXTRACT_LE_16BITS(p) \
|
||||
#define EXTRACT_LE_U_2(p) \
|
||||
((uint16_t)(((uint16_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint16_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
||||
#define EXTRACT_LE_32BITS(p) \
|
||||
#define EXTRACT_LE_S_2(p) \
|
||||
((int16_t)(((uint16_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint16_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
||||
#define EXTRACT_LE_U_4(p) \
|
||||
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 3)) << 24) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
||||
#define EXTRACT_LE_24BITS(p) \
|
||||
#define EXTRACT_LE_S_4(p) \
|
||||
((int32_t)(((uint32_t)(*((const uint8_t *)(p) + 3)) << 24) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
||||
#define EXTRACT_LE_U_3(p) \
|
||||
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
||||
#define EXTRACT_LE_64BITS(p) \
|
||||
#define EXTRACT_LE_S_3(p) \
|
||||
((int32_t)(((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
||||
#define EXTRACT_LE_U_8(p) \
|
||||
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 7)) << 56) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 6)) << 48) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 5)) << 40) | \
|
||||
|
@ -223,3 +412,12 @@ EXTRACT_64BITS(const void *p)
|
|||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
||||
#define EXTRACT_LE_S_8(p) \
|
||||
((int64_t)(((uint64_t)(*((const uint8_t *)(p) + 7)) << 56) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 6)) << 48) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 5)) << 40) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
|
||||
#include <net/if.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -190,7 +189,7 @@ pcap_findalldevs_interfaces(pcap_if_list_t *devlistp, char *errbuf,
|
|||
* We have a ":"; is it followed by a number?
|
||||
*/
|
||||
q = p + 1;
|
||||
while (isdigit((unsigned char)*q))
|
||||
while (PCAP_ISDIGIT(*q))
|
||||
q++;
|
||||
if (*q == '\0') {
|
||||
/*
|
||||
|
|
|
@ -49,19 +49,13 @@ struct rtentry; /* declarations in <net/if.h> */
|
|||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <memory.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#else
|
||||
#define INT_MAX 2147483647
|
||||
#endif
|
||||
|
||||
#include "pcap-int.h"
|
||||
|
||||
|
@ -178,7 +172,7 @@ pcap_findalldevs_interfaces(pcap_if_list_t *devlistp, char *errbuf,
|
|||
* Don't let the buffer size get bigger than INT_MAX.
|
||||
*/
|
||||
if (buf_size > INT_MAX) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"interface information requires more than %u bytes",
|
||||
INT_MAX);
|
||||
(void)close(fd);
|
||||
|
@ -399,7 +393,7 @@ pcap_findalldevs_interfaces(pcap_if_list_t *devlistp, char *errbuf,
|
|||
* We have a ":"; is it followed by a number?
|
||||
*/
|
||||
q = p + 1;
|
||||
while (isdigit((unsigned char)*q))
|
||||
while (PCAP_ISDIGIT(*q))
|
||||
q++;
|
||||
if (*q == '\0') {
|
||||
/*
|
||||
|
|
|
@ -50,7 +50,6 @@ struct rtentry; /* declarations in <net/if.h> */
|
|||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <memory.h>
|
||||
#include <stdio.h>
|
||||
|
@ -311,7 +310,7 @@ pcap_findalldevs_interfaces(pcap_if_list_t *devlistp, char *errbuf,
|
|||
* We have a ":"; is it followed by a number?
|
||||
*/
|
||||
q = p + 1;
|
||||
while (isdigit((unsigned char)*q))
|
||||
while (PCAP_ISDIGIT(*q))
|
||||
q++;
|
||||
if (*q == '\0') {
|
||||
/*
|
||||
|
|
|
@ -47,12 +47,220 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <pcap/pcap.h>
|
||||
#include "pcap-int.h"
|
||||
|
||||
#include "portability.h"
|
||||
|
||||
#include "fmtutils.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "charconv.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set the encoding.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
* True if we shouold use UTF-8.
|
||||
*/
|
||||
static int use_utf_8;
|
||||
|
||||
void
|
||||
pcap_fmt_set_encoding(unsigned int opts)
|
||||
{
|
||||
if (opts == PCAP_CHAR_ENC_UTF_8)
|
||||
use_utf_8 = 1;
|
||||
}
|
||||
#else
|
||||
void
|
||||
pcap_fmt_set_encoding(unsigned int opts _U_)
|
||||
{
|
||||
/*
|
||||
* Nothing to do here.
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
* Convert a null-terminated UTF-16LE string to UTF-8, putting it into
|
||||
* a buffer starting at the specified location and stopping if we go
|
||||
* past the specified size. This will only put out complete UTF-8
|
||||
* sequences.
|
||||
*
|
||||
* We do this ourselves because Microsoft doesn't offer a "convert and
|
||||
* stop at a UTF-8 character boundary if we run out of space" routine.
|
||||
*/
|
||||
#define IS_LEADING_SURROGATE(c) \
|
||||
((c) >= 0xd800 && (c) < 0xdc00)
|
||||
#define IS_TRAILING_SURROGATE(c) \
|
||||
((c) >= 0xdc00 && (c) < 0xe000)
|
||||
#define SURROGATE_VALUE(leading, trailing) \
|
||||
(((((leading) - 0xd800) << 10) | ((trailing) - 0xdc00)) + 0x10000)
|
||||
#define REPLACEMENT_CHARACTER 0x0FFFD
|
||||
|
||||
static char *
|
||||
utf_16le_to_utf_8_truncated(const wchar_t *utf_16, char *utf_8,
|
||||
size_t utf_8_len)
|
||||
{
|
||||
wchar_t c, c2;
|
||||
uint32_t uc;
|
||||
|
||||
if (utf_8_len == 0) {
|
||||
/*
|
||||
* Not even enough room for a trailing '\0'.
|
||||
* Don't put anything into the buffer.
|
||||
*/
|
||||
return (utf_8);
|
||||
}
|
||||
|
||||
while ((c = *utf_16++) != '\0') {
|
||||
if (IS_LEADING_SURROGATE(c)) {
|
||||
/*
|
||||
* Leading surrogate. Must be followed by
|
||||
* a trailing surrogate.
|
||||
*/
|
||||
c2 = *utf_16;
|
||||
if (c2 == '\0') {
|
||||
/*
|
||||
* Oops, string ends with a lead
|
||||
* surrogate. Try to drop in
|
||||
* a REPLACEMENT CHARACTER, and
|
||||
* don't move the string pointer,
|
||||
* so on the next trip through
|
||||
* the loop we grab the terminating
|
||||
* '\0' and quit.
|
||||
*/
|
||||
uc = REPLACEMENT_CHARACTER;
|
||||
} else {
|
||||
/*
|
||||
* OK, we can consume this 2-octet
|
||||
* value.
|
||||
*/
|
||||
utf_16++;
|
||||
if (IS_TRAILING_SURROGATE(c2)) {
|
||||
/*
|
||||
* Trailing surrogate.
|
||||
* This calculation will,
|
||||
* for c being a leading
|
||||
* surrogate and c2 being
|
||||
* a trailing surrogate,
|
||||
* produce a value between
|
||||
* 0x100000 and 0x10ffff,
|
||||
* so it's always going to be
|
||||
* a valid Unicode code point.
|
||||
*/
|
||||
uc = SURROGATE_VALUE(c, c2);
|
||||
} else {
|
||||
/*
|
||||
* Not a trailing surroage;
|
||||
* try to drop in a
|
||||
* REPLACEMENT CHARACTER.
|
||||
*/
|
||||
uc = REPLACEMENT_CHARACTER;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Not a leading surrogate.
|
||||
*/
|
||||
if (IS_TRAILING_SURROGATE(c)) {
|
||||
/*
|
||||
* Trailing surrogate without
|
||||
* a preceding leading surrogate.
|
||||
* Try to drop in a REPLACEMENT
|
||||
* CHARACTER.
|
||||
*/
|
||||
uc = REPLACEMENT_CHARACTER;
|
||||
} else {
|
||||
/*
|
||||
* This is a valid BMP character;
|
||||
* drop it in.
|
||||
*/
|
||||
uc = c;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* OK, uc is a valid Unicode character; how
|
||||
* many bytes worth of UTF-8 does it require?
|
||||
*/
|
||||
if (uc < 0x0080) {
|
||||
/* 1 byte. */
|
||||
if (utf_8_len < 2) {
|
||||
/*
|
||||
* Not enough room for that byte
|
||||
* plus a trailing '\0'.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
*utf_8++ = (char)uc;
|
||||
utf_8_len--;
|
||||
} else if (uc < 0x0800) {
|
||||
/* 2 bytes. */
|
||||
if (utf_8_len < 3) {
|
||||
/*
|
||||
* Not enough room for those bytes
|
||||
* plus a trailing '\0'.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
*utf_8++ = ((uc >> 6) & 0x3F) | 0xC0;
|
||||
*utf_8++ = ((uc >> 0) & 0x3F) | 0x80;
|
||||
utf_8_len -= 2;
|
||||
} else if (uc < 0x010000) {
|
||||
/* 3 bytes. */
|
||||
if (utf_8_len < 4) {
|
||||
/*
|
||||
* Not enough room for those bytes
|
||||
* plus a trailing '\0'.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
*utf_8++ = ((uc >> 12) & 0x0F) | 0xE0;
|
||||
*utf_8++ = ((uc >> 6) & 0x3F) | 0x80;
|
||||
*utf_8++ = ((uc >> 0) & 0x3F) | 0x80;
|
||||
utf_8_len -= 3;
|
||||
} else {
|
||||
/* 4 bytes. */
|
||||
if (utf_8_len < 5) {
|
||||
/*
|
||||
* Not enough room for those bytes
|
||||
* plus a trailing '\0'.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
*utf_8++ = ((uc >> 18) & 0x03) | 0xF0;
|
||||
*utf_8++ = ((uc >> 12) & 0x3F) | 0x80;
|
||||
*utf_8++ = ((uc >> 6) & 0x3F) | 0x80;
|
||||
*utf_8++ = ((uc >> 0) & 0x3F) | 0x80;
|
||||
utf_8_len -= 3;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* OK, we have enough room for (at least) a trailing '\0'.
|
||||
* (We started out with enough room, thanks to the test
|
||||
* for a zero-length buffer at the beginning, and if
|
||||
* there wasn't enough room for any character we wanted
|
||||
* to put into the buffer *plus* a trailing '\0',
|
||||
* we'd have quit before putting it into the buffer,
|
||||
* and thus would have left enough room for the trailing
|
||||
* '\0'.)
|
||||
*
|
||||
* Drop it in.
|
||||
*/
|
||||
*utf_8 = '\0';
|
||||
|
||||
/*
|
||||
* Return a pointer to the terminating '\0', in case we
|
||||
* want to drop something in after that.
|
||||
*/
|
||||
return (utf_8);
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/*
|
||||
* Generate an error message based on a format, arguments, and an
|
||||
* errno, with a message for the errno after the formatted output.
|
||||
|
@ -62,13 +270,21 @@ pcap_fmt_errmsg_for_errno(char *errbuf, size_t errbuflen, int errnum,
|
|||
const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
pcap_vfmt_errmsg_for_errno(errbuf, errbuflen, errnum, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
pcap_vfmt_errmsg_for_errno(char *errbuf, size_t errbuflen, int errnum,
|
||||
const char *fmt, va_list ap)
|
||||
{
|
||||
size_t msglen;
|
||||
char *p;
|
||||
size_t errbuflen_remaining;
|
||||
|
||||
va_start(ap, fmt);
|
||||
pcap_vsnprintf(errbuf, errbuflen, fmt, ap);
|
||||
va_end(ap);
|
||||
(void)vsnprintf(errbuf, errbuflen, fmt, ap);
|
||||
msglen = strlen(errbuf);
|
||||
|
||||
/*
|
||||
|
@ -84,24 +300,40 @@ pcap_fmt_errmsg_for_errno(char *errbuf, size_t errbuflen, int errnum,
|
|||
*p++ = ':';
|
||||
*p++ = ' ';
|
||||
*p = '\0';
|
||||
msglen += 2;
|
||||
errbuflen_remaining -= 2;
|
||||
|
||||
/*
|
||||
* Now append the string for the error code.
|
||||
*/
|
||||
#if defined(HAVE_STRERROR_S)
|
||||
#if defined(HAVE__WCSERROR_S)
|
||||
/*
|
||||
* We have a Windows-style strerror_s().
|
||||
* We have a Windows-style _wcserror_s().
|
||||
* Generate a UTF-16LE error message.
|
||||
*/
|
||||
errno_t err = strerror_s(p, errbuflen_remaining, errnum);
|
||||
wchar_t utf_16_errbuf[PCAP_ERRBUF_SIZE];
|
||||
errno_t err = _wcserror_s(utf_16_errbuf, PCAP_ERRBUF_SIZE, errnum);
|
||||
if (err != 0) {
|
||||
/*
|
||||
* It doesn't appear to be documented anywhere obvious
|
||||
* what the error returns from strerror_s().
|
||||
* what the error returns from _wcserror_s().
|
||||
*/
|
||||
pcap_snprintf(p, errbuflen_remaining, "Error %d", errnum);
|
||||
snprintf(p, errbuflen_remaining, "Error %d", errnum);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now convert it from UTF-16LE to UTF-8, dropping it in the
|
||||
* remaining space in the buffer, and truncating it - cleanly,
|
||||
* on a UTF-8 character boundary - if it doesn't fit.
|
||||
*/
|
||||
utf_16le_to_utf_8_truncated(utf_16_errbuf, p, errbuflen_remaining);
|
||||
|
||||
/*
|
||||
* Now, if we're not in UTF-8 mode, convert errbuf to the
|
||||
* local code page.
|
||||
*/
|
||||
if (!use_utf_8)
|
||||
utf_8_to_acp_truncated(errbuf);
|
||||
#elif defined(HAVE_GNU_STRERROR_R)
|
||||
/*
|
||||
* We have a GNU-style strerror_r(), which is *not* guaranteed to
|
||||
|
@ -113,7 +345,7 @@ pcap_fmt_errmsg_for_errno(char *errbuf, size_t errbuflen, int errnum,
|
|||
*/
|
||||
char strerror_buf[PCAP_ERRBUF_SIZE];
|
||||
char *errstring = strerror_r(errnum, strerror_buf, PCAP_ERRBUF_SIZE);
|
||||
pcap_snprintf(p, errbuflen_remaining, "%s", errstring);
|
||||
snprintf(p, errbuflen_remaining, "%s", errstring);
|
||||
#elif defined(HAVE_POSIX_STRERROR_R)
|
||||
/*
|
||||
* We have a POSIX-style strerror_r(), which is guaranteed to fill
|
||||
|
@ -125,22 +357,22 @@ pcap_fmt_errmsg_for_errno(char *errbuf, size_t errbuflen, int errnum,
|
|||
* UNIX 03 says this isn't guaranteed to produce a
|
||||
* fallback error message.
|
||||
*/
|
||||
pcap_snprintf(p, errbuflen_remaining, "Unknown error: %d",
|
||||
snprintf(p, errbuflen_remaining, "Unknown error: %d",
|
||||
errnum);
|
||||
} else if (err == ERANGE) {
|
||||
/*
|
||||
* UNIX 03 says this isn't guaranteed to produce a
|
||||
* fallback error message.
|
||||
*/
|
||||
pcap_snprintf(p, errbuflen_remaining,
|
||||
snprintf(p, errbuflen_remaining,
|
||||
"Message for error %d is too long", errnum);
|
||||
}
|
||||
#else
|
||||
/*
|
||||
* We have neither strerror_s() nor strerror_r(), so we're
|
||||
* We have neither _wcserror_s() nor strerror_r(), so we're
|
||||
* stuck with using pcap_strerror().
|
||||
*/
|
||||
pcap_snprintf(p, errbuflen_remaining, "%s", pcap_strerror(errnum));
|
||||
snprintf(p, errbuflen_remaining, "%s", pcap_strerror(errnum));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -154,15 +386,24 @@ pcap_fmt_errmsg_for_win32_err(char *errbuf, size_t errbuflen, DWORD errnum,
|
|||
const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
pcap_vfmt_errmsg_for_win32_err(errbuf, errbuflen, errnum, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
pcap_vfmt_errmsg_for_win32_err(char *errbuf, size_t errbuflen, DWORD errnum,
|
||||
const char *fmt, va_list ap)
|
||||
{
|
||||
size_t msglen;
|
||||
char *p;
|
||||
size_t errbuflen_remaining;
|
||||
DWORD retval;
|
||||
char win32_errbuf[PCAP_ERRBUF_SIZE+1];
|
||||
wchar_t utf_16_errbuf[PCAP_ERRBUF_SIZE];
|
||||
size_t utf_8_len;
|
||||
|
||||
va_start(ap, fmt);
|
||||
pcap_vsnprintf(errbuf, errbuflen, fmt, ap);
|
||||
va_end(ap);
|
||||
vsnprintf(errbuf, errbuflen, fmt, ap);
|
||||
msglen = strlen(errbuf);
|
||||
|
||||
/*
|
||||
|
@ -197,18 +438,39 @@ pcap_fmt_errmsg_for_win32_err(char *errbuf, size_t errbuflen, DWORD errnum,
|
|||
* get the message translated if it's in a language they don't
|
||||
* happen to understand.
|
||||
*/
|
||||
retval = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_MAX_WIDTH_MASK,
|
||||
retval = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_MAX_WIDTH_MASK,
|
||||
NULL, errnum, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
win32_errbuf, PCAP_ERRBUF_SIZE, NULL);
|
||||
utf_16_errbuf, PCAP_ERRBUF_SIZE, NULL);
|
||||
if (retval == 0) {
|
||||
/*
|
||||
* Failed.
|
||||
*/
|
||||
pcap_snprintf(p, errbuflen_remaining,
|
||||
snprintf(p, errbuflen_remaining,
|
||||
"Couldn't get error message for error (%lu)", errnum);
|
||||
return;
|
||||
}
|
||||
|
||||
pcap_snprintf(p, errbuflen_remaining, "%s (%lu)", win32_errbuf, errnum);
|
||||
/*
|
||||
* Now convert it from UTF-16LE to UTF-8.
|
||||
*/
|
||||
p = utf_16le_to_utf_8_truncated(utf_16_errbuf, p, errbuflen_remaining);
|
||||
|
||||
/*
|
||||
* Now append the error number, if it fits.
|
||||
*/
|
||||
utf_8_len = p - errbuf;
|
||||
errbuflen_remaining -= utf_8_len;
|
||||
if (utf_8_len == 0) {
|
||||
/* The message was empty. */
|
||||
snprintf(p, errbuflen_remaining, "(%lu)", errnum);
|
||||
} else
|
||||
snprintf(p, errbuflen_remaining, " (%lu)", errnum);
|
||||
|
||||
/*
|
||||
* Now, if we're not in UTF-8 mode, convert errbuf to the
|
||||
* local code page.
|
||||
*/
|
||||
if (!use_utf_8)
|
||||
utf_8_to_acp_truncated(errbuf);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -34,18 +34,26 @@
|
|||
#ifndef fmtutils_h
|
||||
#define fmtutils_h
|
||||
|
||||
#include <stdarg.h> /* we declare varargs functions */
|
||||
|
||||
#include "pcap/funcattrs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void pcap_fmt_set_encoding(unsigned int);
|
||||
|
||||
void pcap_fmt_errmsg_for_errno(char *, size_t, int,
|
||||
PCAP_FORMAT_STRING(const char *), ...) PCAP_PRINTFLIKE(4, 5);
|
||||
void pcap_vfmt_errmsg_for_errno(char *, size_t, int,
|
||||
PCAP_FORMAT_STRING(const char *), va_list) PCAP_PRINTFLIKE(4, 0);
|
||||
|
||||
#ifdef _WIN32
|
||||
void pcap_fmt_errmsg_for_win32_err(char *, size_t, DWORD,
|
||||
PCAP_FORMAT_STRING(const char *), ...) PCAP_PRINTFLIKE(4, 5);
|
||||
void pcap_vfmt_errmsg_for_win32_err(char *, size_t, DWORD,
|
||||
PCAP_FORMAT_STRING(const char *), va_list) PCAP_PRINTFLIKE(4, 0);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -45,7 +45,12 @@
|
|||
* namespace to the maximum extent possible"?
|
||||
*/
|
||||
#if defined(sun) || defined(__sun)
|
||||
#define __EXTENSIONS__
|
||||
/*
|
||||
* On Solaris Clang defines __EXTENSIONS__ automatically.
|
||||
*/
|
||||
#ifndef __EXTENSIONS__
|
||||
#define __EXTENSIONS__
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We also need to define _XPG4_2 in order to get
|
||||
|
@ -83,14 +88,18 @@
|
|||
* least with HP's C compiler; hopefully doing so won't make it
|
||||
* *not* work with *un*-threaded code.
|
||||
*/
|
||||
#elif defined(__linux__) || defined(linux) || defined(__linux)
|
||||
#else
|
||||
/*
|
||||
* Turn on _GNU_SOURCE to get everything GNU libc has to offer,
|
||||
* including asprintf().
|
||||
* including asprintf(), if we're using GNU libc.
|
||||
*
|
||||
* Unfortunately, one thing it has to offer is a strerror_r()
|
||||
* that's not POSIX-compliant, but we deal with that in
|
||||
* pcap_fmt_errmsg_for_errno().
|
||||
*
|
||||
* We don't limit this to, for example, Linux and Cygwin, because
|
||||
* this might, for example, be GNU/HURD or one of Debian's kFreeBSD
|
||||
* OSes ("GNU/FreeBSD").
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
|
||||
|
@ -101,9 +110,18 @@
|
|||
* don't whine about _BSD_SOURCE being deprecated; we still have
|
||||
* to define _BSD_SOURCE to handle older versions of GNU libc that
|
||||
* don't support _DEFAULT_SOURCE.
|
||||
*
|
||||
* But, if it's already defined, don't define it, so that we don't
|
||||
* get a warning of it being redefined if it's defined as, for
|
||||
* example, 1.
|
||||
*/
|
||||
#define _DEFAULT_SOURCE
|
||||
#define _BSD_SOURCE
|
||||
#ifndef _DEFAULT_SOURCE
|
||||
#define _DEFAULT_SOURCE
|
||||
#endif
|
||||
/* Avoid redefining _BSD_SOURCE if it's already defined as for ex. 1 */
|
||||
#ifndef _BSD_SOURCE
|
||||
#define _BSD_SOURCE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -19,7 +19,19 @@
|
|||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef gencode_h
|
||||
#define gencode_h
|
||||
|
||||
#include "pcap/funcattrs.h"
|
||||
/*
|
||||
* pcap/bpf.h (a public header) needs u_char, u_short and u_int, which can be
|
||||
* made available via either pcap-types.h (a private header) or pcap/pcap.h
|
||||
* (a public header), none of which pcap/bpf.h includes. Include the private
|
||||
* header to keep things simple, this way this private header should compile
|
||||
* even if included early from another file.
|
||||
*/
|
||||
#include "pcap-types.h"
|
||||
#include "pcap/bpf.h" /* bpf_u_int32 and BPF_MEMWORDS */
|
||||
|
||||
/*
|
||||
* ATM support:
|
||||
|
@ -200,11 +212,14 @@
|
|||
|
||||
struct slist;
|
||||
|
||||
/*
|
||||
* A single statement, corresponding to an instruction in a block.
|
||||
*/
|
||||
struct stmt {
|
||||
int code;
|
||||
struct slist *jt; /*only for relative jump in block*/
|
||||
struct slist *jf; /*only for relative jump in block*/
|
||||
bpf_int32 k;
|
||||
int code; /* opcode */
|
||||
struct slist *jt; /* only for relative jump in block */
|
||||
struct slist *jf; /* only for relative jump in block */
|
||||
bpf_u_int32 k; /* k field */
|
||||
};
|
||||
|
||||
struct slist {
|
||||
|
@ -231,17 +246,27 @@ typedef bpf_u_int32 *uset;
|
|||
*/
|
||||
#define N_ATOMS (BPF_MEMWORDS+2)
|
||||
|
||||
/*
|
||||
* Control flow graph of a program.
|
||||
* This corresponds to an edge in the CFG.
|
||||
* It's a directed graph, so an edge has a predecessor and a successor.
|
||||
*/
|
||||
struct edge {
|
||||
int id;
|
||||
int code;
|
||||
u_int id;
|
||||
int code; /* opcode for branch corresponding to this edge */
|
||||
uset edom;
|
||||
struct block *succ;
|
||||
struct block *pred;
|
||||
struct block *succ; /* successor vertex */
|
||||
struct block *pred; /* predecessor vertex */
|
||||
struct edge *next; /* link list of incoming edges for a node */
|
||||
};
|
||||
|
||||
/*
|
||||
* A block is a vertex in the CFG.
|
||||
* It has a list of statements, with the final statement being a
|
||||
* branch to successor blocks.
|
||||
*/
|
||||
struct block {
|
||||
int id;
|
||||
u_int id;
|
||||
struct slist *stmts; /* side effect stmts */
|
||||
struct stmt s; /* branch stmt */
|
||||
int mark;
|
||||
|
@ -250,18 +275,18 @@ struct block {
|
|||
int level;
|
||||
int offset;
|
||||
int sense;
|
||||
struct edge et;
|
||||
struct edge ef;
|
||||
struct edge et; /* edge corresponding to the jt branch */
|
||||
struct edge ef; /* edge corresponding to the jf branch */
|
||||
struct block *head;
|
||||
struct block *link; /* link field used by optimizer */
|
||||
uset dom;
|
||||
uset closure;
|
||||
struct edge *in_edges;
|
||||
struct edge *in_edges; /* first edge in the set (linked list) of edges with this as a successor */
|
||||
atomset def, kill;
|
||||
atomset in_use;
|
||||
atomset out_use;
|
||||
int oval;
|
||||
int val[N_ATOMS];
|
||||
int oval; /* value ID for value tested in branch stmt */
|
||||
bpf_u_int32 val[N_ATOMS];
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -286,8 +311,8 @@ struct _compiler_state;
|
|||
|
||||
typedef struct _compiler_state compiler_state_t;
|
||||
|
||||
struct arth *gen_loadi(compiler_state_t *, int);
|
||||
struct arth *gen_load(compiler_state_t *, int, struct arth *, int);
|
||||
struct arth *gen_loadi(compiler_state_t *, bpf_u_int32);
|
||||
struct arth *gen_load(compiler_state_t *, int, struct arth *, bpf_u_int32);
|
||||
struct arth *gen_loadlen(compiler_state_t *);
|
||||
struct arth *gen_neg(compiler_state_t *, struct arth *);
|
||||
struct arth *gen_arth(compiler_state_t *, int, struct arth *, struct arth *);
|
||||
|
@ -300,10 +325,10 @@ struct block *gen_scode(compiler_state_t *, const char *, struct qual);
|
|||
struct block *gen_ecode(compiler_state_t *, const char *, struct qual);
|
||||
struct block *gen_acode(compiler_state_t *, const char *, struct qual);
|
||||
struct block *gen_mcode(compiler_state_t *, const char *, const char *,
|
||||
unsigned int, struct qual);
|
||||
bpf_u_int32, struct qual);
|
||||
#ifdef INET6
|
||||
struct block *gen_mcode6(compiler_state_t *, const char *, const char *,
|
||||
unsigned int, struct qual);
|
||||
bpf_u_int32, struct qual);
|
||||
#endif
|
||||
struct block *gen_ncode(compiler_state_t *, const char *, bpf_u_int32,
|
||||
struct qual);
|
||||
|
@ -312,9 +337,10 @@ struct block *gen_relation(compiler_state_t *, int, struct arth *,
|
|||
struct arth *, int);
|
||||
struct block *gen_less(compiler_state_t *, int);
|
||||
struct block *gen_greater(compiler_state_t *, int);
|
||||
struct block *gen_byteop(compiler_state_t *, int, int, int);
|
||||
struct block *gen_byteop(compiler_state_t *, int, int, bpf_u_int32);
|
||||
struct block *gen_broadcast(compiler_state_t *, int);
|
||||
struct block *gen_multicast(compiler_state_t *, int);
|
||||
struct block *gen_ifindex(compiler_state_t *, int);
|
||||
struct block *gen_inbound(compiler_state_t *, int);
|
||||
|
||||
struct block *gen_llc(compiler_state_t *);
|
||||
|
@ -332,14 +358,14 @@ struct block *gen_pppoes(compiler_state_t *, bpf_u_int32, int);
|
|||
|
||||
struct block *gen_geneve(compiler_state_t *, bpf_u_int32, int);
|
||||
|
||||
struct block *gen_atmfield_code(compiler_state_t *, int, bpf_int32,
|
||||
bpf_u_int32, int);
|
||||
struct block *gen_atmtype_abbrev(compiler_state_t *, int type);
|
||||
struct block *gen_atmmulti_abbrev(compiler_state_t *, int type);
|
||||
struct block *gen_atmfield_code(compiler_state_t *, int, bpf_u_int32,
|
||||
int, int);
|
||||
struct block *gen_atmtype_abbrev(compiler_state_t *, int);
|
||||
struct block *gen_atmmulti_abbrev(compiler_state_t *, int);
|
||||
|
||||
struct block *gen_mtp2type_abbrev(compiler_state_t *, int type);
|
||||
struct block *gen_mtp2type_abbrev(compiler_state_t *, int);
|
||||
struct block *gen_mtp3field_code(compiler_state_t *, int, bpf_u_int32,
|
||||
bpf_u_int32, int);
|
||||
int, int);
|
||||
|
||||
struct block *gen_pf_ifname(compiler_state_t *, const char *);
|
||||
struct block *gen_pf_rnr(compiler_state_t *, int);
|
||||
|
@ -348,8 +374,8 @@ struct block *gen_pf_ruleset(compiler_state_t *, char *);
|
|||
struct block *gen_pf_reason(compiler_state_t *, int);
|
||||
struct block *gen_pf_action(compiler_state_t *, int);
|
||||
|
||||
struct block *gen_p80211_type(compiler_state_t *, int, int);
|
||||
struct block *gen_p80211_fcdir(compiler_state_t *, int);
|
||||
struct block *gen_p80211_type(compiler_state_t *, bpf_u_int32, bpf_u_int32);
|
||||
struct block *gen_p80211_fcdir(compiler_state_t *, bpf_u_int32);
|
||||
|
||||
/*
|
||||
* Representation of a program as a tree of blocks, plus current mark.
|
||||
|
@ -386,3 +412,5 @@ int pcap_parse(void *, compiler_state_t *);
|
|||
/* XXX */
|
||||
#define JT(b) ((b)->et.succ)
|
||||
#define JF(b) ((b)->ef.succ)
|
||||
|
||||
#endif /* gencode_h */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* We want a reentrant parser.
|
||||
*/
|
||||
%pure-parser
|
||||
@REENTRANT_PARSER@
|
||||
|
||||
/*
|
||||
* We also want a reentrant scanner, so we have to pass the
|
||||
|
@ -18,6 +18,27 @@
|
|||
%parse-param {void *yyscanner}
|
||||
%lex-param {void *yyscanner}
|
||||
|
||||
/*
|
||||
* According to bison documentation, shift/reduce conflicts are not an issue
|
||||
* in most parsers as long as the number does not evolve over time:
|
||||
* https://www.gnu.org/software/bison/manual/html_node/Expect-Decl.html
|
||||
* So, following the advice use %expect to check the amount of shift/reduce
|
||||
* warnings.
|
||||
*
|
||||
* This doesn't appear to work in Berkeley YACC - 1.9 20170709; it still
|
||||
* warns of 38 shift/reduce conflicts.
|
||||
*
|
||||
* The Berkeley YACC documentation:
|
||||
*
|
||||
* https://invisible-island.net/byacc/manpage/yacc.html
|
||||
*
|
||||
* claims that "Bison's support for "%expect" is broken in more than one
|
||||
* release.", but doesn't give details. Hopefully, that only means that
|
||||
* you get warnings even if you have the expected number of shift/reduce
|
||||
* conflicts, not that anything else fails.
|
||||
*/
|
||||
%expect 38
|
||||
|
||||
/*
|
||||
* And we need to pass the compiler state to the scanner.
|
||||
*/
|
||||
|
@ -50,6 +71,13 @@
|
|||
#include <config.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* grammar.h requires gencode.h and sometimes breaks in a polluted namespace
|
||||
* (see ftmacros.h), so include it early.
|
||||
*/
|
||||
#include "gencode.h"
|
||||
#include "grammar.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
@ -71,17 +99,11 @@ struct rtentry;
|
|||
|
||||
#include "pcap-int.h"
|
||||
|
||||
#include "gencode.h"
|
||||
#include "grammar.h"
|
||||
#include "scanner.h"
|
||||
|
||||
#ifdef HAVE_NET_PFVAR_H
|
||||
#include <net/if.h>
|
||||
#include <net/pfvar.h>
|
||||
#include <net/if_pflog.h>
|
||||
#endif
|
||||
#include "llc.h"
|
||||
#include "ieee80211.h"
|
||||
#include "pflog.h"
|
||||
#include <pcap/namedb.h>
|
||||
|
||||
#ifdef HAVE_OS_PROTO_H
|
||||
|
@ -210,8 +232,17 @@ str2tok(const char *str, const struct tok *toks)
|
|||
int i;
|
||||
|
||||
for (i = 0; toks[i].s != NULL; i++) {
|
||||
if (pcap_strcasecmp(toks[i].s, str) == 0)
|
||||
if (pcap_strcasecmp(toks[i].s, str) == 0) {
|
||||
/*
|
||||
* Just in case somebody is using this to
|
||||
* generate values of -1/0xFFFFFFFF.
|
||||
* That won't work, as it's indistinguishable
|
||||
* from an error.
|
||||
*/
|
||||
if (toks[i].v == -1)
|
||||
abort();
|
||||
return (toks[i].v);
|
||||
}
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
@ -224,60 +255,87 @@ yyerror(void *yyscanner _U_, compiler_state_t *cstate, const char *msg)
|
|||
bpf_set_error(cstate, "can't parse filter expression: %s", msg);
|
||||
}
|
||||
|
||||
#ifdef HAVE_NET_PFVAR_H
|
||||
static const struct tok pflog_reasons[] = {
|
||||
{ PFRES_MATCH, "match" },
|
||||
{ PFRES_BADOFF, "bad-offset" },
|
||||
{ PFRES_FRAG, "fragment" },
|
||||
{ PFRES_SHORT, "short" },
|
||||
{ PFRES_NORM, "normalize" },
|
||||
{ PFRES_MEMORY, "memory" },
|
||||
{ PFRES_TS, "bad-timestamp" },
|
||||
{ PFRES_CONGEST, "congestion" },
|
||||
{ PFRES_IPOPTIONS, "ip-option" },
|
||||
{ PFRES_PROTCKSUM, "proto-cksum" },
|
||||
{ PFRES_BADSTATE, "state-mismatch" },
|
||||
{ PFRES_STATEINS, "state-insert" },
|
||||
{ PFRES_MAXSTATES, "state-limit" },
|
||||
{ PFRES_SRCLIMIT, "src-limit" },
|
||||
{ PFRES_SYNPROXY, "synproxy" },
|
||||
#if defined(__FreeBSD__)
|
||||
{ PFRES_MAPFAILED, "map-failed" },
|
||||
#elif defined(__NetBSD__)
|
||||
{ PFRES_STATELOCKED, "state-locked" },
|
||||
#elif defined(__OpenBSD__)
|
||||
{ PFRES_TRANSLATE, "translate" },
|
||||
{ PFRES_NOROUTE, "no-route" },
|
||||
#elif defined(__APPLE__)
|
||||
{ PFRES_DUMMYNET, "dummynet" },
|
||||
#endif
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static int
|
||||
pfreason_to_num(compiler_state_t *cstate, const char *reason)
|
||||
{
|
||||
const char *reasons[] = PFRES_NAMES;
|
||||
int i;
|
||||
|
||||
for (i = 0; reasons[i]; i++) {
|
||||
if (pcap_strcasecmp(reason, reasons[i]) == 0)
|
||||
return (i);
|
||||
}
|
||||
bpf_set_error(cstate, "unknown PF reason");
|
||||
return (-1);
|
||||
i = str2tok(reason, pflog_reasons);
|
||||
if (i == -1)
|
||||
bpf_set_error(cstate, "unknown PF reason \"%s\"", reason);
|
||||
return (i);
|
||||
}
|
||||
|
||||
static const struct tok pflog_actions[] = {
|
||||
{ PF_PASS, "pass" },
|
||||
{ PF_PASS, "accept" }, /* alias for "pass" */
|
||||
{ PF_DROP, "drop" },
|
||||
{ PF_DROP, "block" }, /* alias for "drop" */
|
||||
{ PF_SCRUB, "scrub" },
|
||||
{ PF_NOSCRUB, "noscrub" },
|
||||
{ PF_NAT, "nat" },
|
||||
{ PF_NONAT, "nonat" },
|
||||
{ PF_BINAT, "binat" },
|
||||
{ PF_NOBINAT, "nobinat" },
|
||||
{ PF_RDR, "rdr" },
|
||||
{ PF_NORDR, "nordr" },
|
||||
{ PF_SYNPROXY_DROP, "synproxy-drop" },
|
||||
#if defined(__FreeBSD__)
|
||||
{ PF_DEFER, "defer" },
|
||||
#elif defined(__OpenBSD__)
|
||||
{ PF_DEFER, "defer" },
|
||||
{ PF_MATCH, "match" },
|
||||
{ PF_DIVERT, "divert" },
|
||||
{ PF_RT, "rt" },
|
||||
{ PF_AFRT, "afrt" },
|
||||
#elif defined(__APPLE__)
|
||||
{ PF_DUMMYNET, "dummynet" },
|
||||
{ PF_NODUMMYNET, "nodummynet" },
|
||||
{ PF_NAT64, "nat64" },
|
||||
{ PF_NONAT64, "nonat64" },
|
||||
#endif
|
||||
{ 0, NULL },
|
||||
};
|
||||
|
||||
static int
|
||||
pfaction_to_num(compiler_state_t *cstate, const char *action)
|
||||
{
|
||||
if (pcap_strcasecmp(action, "pass") == 0 ||
|
||||
pcap_strcasecmp(action, "accept") == 0)
|
||||
return (PF_PASS);
|
||||
else if (pcap_strcasecmp(action, "drop") == 0 ||
|
||||
pcap_strcasecmp(action, "block") == 0)
|
||||
return (PF_DROP);
|
||||
#if HAVE_PF_NAT_THROUGH_PF_NORDR
|
||||
else if (pcap_strcasecmp(action, "rdr") == 0)
|
||||
return (PF_RDR);
|
||||
else if (pcap_strcasecmp(action, "nat") == 0)
|
||||
return (PF_NAT);
|
||||
else if (pcap_strcasecmp(action, "binat") == 0)
|
||||
return (PF_BINAT);
|
||||
else if (pcap_strcasecmp(action, "nordr") == 0)
|
||||
return (PF_NORDR);
|
||||
#endif
|
||||
else {
|
||||
bpf_set_error(cstate, "unknown PF action");
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
#else /* !HAVE_NET_PFVAR_H */
|
||||
static int
|
||||
pfreason_to_num(compiler_state_t *cstate, const char *reason _U_)
|
||||
{
|
||||
bpf_set_error(cstate, "libpcap was compiled on a machine without pf support");
|
||||
return (-1);
|
||||
}
|
||||
int i;
|
||||
|
||||
static int
|
||||
pfaction_to_num(compiler_state_t *cstate, const char *action _U_)
|
||||
{
|
||||
bpf_set_error(cstate, "libpcap was compiled on a machine without pf support");
|
||||
return (-1);
|
||||
i = str2tok(action, pflog_actions);
|
||||
if (i == -1)
|
||||
bpf_set_error(cstate, "unknown PF action \"%s\"", action);
|
||||
return (i);
|
||||
}
|
||||
#endif /* HAVE_NET_PFVAR_H */
|
||||
|
||||
/*
|
||||
* For calls that might return an "an error occurred" value.
|
||||
|
@ -307,7 +365,8 @@ DIAG_OFF_BISON_BYACC
|
|||
%type <blk> head
|
||||
%type <i> pqual dqual aqual ndaqual
|
||||
%type <a> arth narth
|
||||
%type <i> byteop pname pnum relop irelop
|
||||
%type <i> byteop pname relop irelop
|
||||
%type <h> pnum
|
||||
%type <blk> and or paren not null prog
|
||||
%type <rblk> other pfvar p80211 pllc
|
||||
%type <i> atmtype atmmultitype
|
||||
|
@ -324,6 +383,7 @@ DIAG_OFF_BISON_BYACC
|
|||
%token ATALK AARP DECNET LAT SCA MOPRC MOPDL
|
||||
%token TK_BROADCAST TK_MULTICAST
|
||||
%token NUM INBOUND OUTBOUND
|
||||
%token IFINDEX
|
||||
%token PF_IFNAME PF_RSET PF_RNR PF_SRNR PF_REASON PF_ACTION
|
||||
%token TYPE SUBTYPE DIR ADDR1 ADDR2 ADDR3 ADDR4 RA TA
|
||||
%token LINK
|
||||
|
@ -348,7 +408,8 @@ DIAG_OFF_BISON_BYACC
|
|||
|
||||
%type <s> ID EID AID
|
||||
%type <s> HID HID6
|
||||
%type <i> NUM action reason type subtype type_subtype dir
|
||||
%type <h> NUM
|
||||
%type <i> action reason type subtype type_subtype dir
|
||||
|
||||
%left OR AND
|
||||
%nonassoc '!'
|
||||
|
@ -378,7 +439,7 @@ and: AND { $$ = $<blk>0; }
|
|||
or: OR { $$ = $<blk>0; }
|
||||
;
|
||||
id: nid
|
||||
| pnum { CHECK_PTR_VAL(($$.b = gen_ncode(cstate, NULL, (bpf_u_int32)$1,
|
||||
| pnum { CHECK_PTR_VAL(($$.b = gen_ncode(cstate, NULL, $1,
|
||||
$$.q = $<blk>0.q))); }
|
||||
| paren pid ')' { $$ = $2; }
|
||||
;
|
||||
|
@ -392,17 +453,17 @@ nid: ID { CHECK_PTR_VAL($1); CHECK_PTR_VAL(($$.b = gen_scode(cstate, $1, $$.
|
|||
/* Decide how to parse HID based on proto */
|
||||
$$.q = $<blk>0.q;
|
||||
if ($$.q.addr == Q_PORT) {
|
||||
bpf_set_error(cstate, "'port' modifier applied to ip host");
|
||||
YYABORT;
|
||||
bpf_set_error(cstate, "'port' modifier applied to ip host");
|
||||
YYABORT;
|
||||
} else if ($$.q.addr == Q_PORTRANGE) {
|
||||
bpf_set_error(cstate, "'portrange' modifier applied to ip host");
|
||||
YYABORT;
|
||||
bpf_set_error(cstate, "'portrange' modifier applied to ip host");
|
||||
YYABORT;
|
||||
} else if ($$.q.addr == Q_PROTO) {
|
||||
bpf_set_error(cstate, "'proto' modifier applied to ip host");
|
||||
YYABORT;
|
||||
bpf_set_error(cstate, "'proto' modifier applied to ip host");
|
||||
YYABORT;
|
||||
} else if ($$.q.addr == Q_PROTOCHAIN) {
|
||||
bpf_set_error(cstate, "'protochain' modifier applied to ip host");
|
||||
YYABORT;
|
||||
bpf_set_error(cstate, "'protochain' modifier applied to ip host");
|
||||
YYABORT;
|
||||
}
|
||||
CHECK_PTR_VAL(($$.b = gen_ncode(cstate, $1, 0, $$.q)));
|
||||
}
|
||||
|
@ -440,7 +501,7 @@ pid: nid
|
|||
| qid and id { gen_and($1.b, $3.b); $$ = $3; }
|
||||
| qid or id { gen_or($1.b, $3.b); $$ = $3; }
|
||||
;
|
||||
qid: pnum { CHECK_PTR_VAL(($$.b = gen_ncode(cstate, NULL, (bpf_u_int32)$1,
|
||||
qid: pnum { CHECK_PTR_VAL(($$.b = gen_ncode(cstate, NULL, $1,
|
||||
$$.q = $<blk>0.q))); }
|
||||
| pid
|
||||
;
|
||||
|
@ -514,7 +575,7 @@ pname: LINK { $$ = Q_LINK; }
|
|||
| IGRP { $$ = Q_IGRP; }
|
||||
| PIM { $$ = Q_PIM; }
|
||||
| VRRP { $$ = Q_VRRP; }
|
||||
| CARP { $$ = Q_CARP; }
|
||||
| CARP { $$ = Q_CARP; }
|
||||
| ATALK { $$ = Q_ATALK; }
|
||||
| AARP { $$ = Q_AARP; }
|
||||
| DECNET { $$ = Q_DECNET; }
|
||||
|
@ -549,14 +610,15 @@ other: pqual TK_BROADCAST { CHECK_PTR_VAL(($$ = gen_broadcast(cstate, $1))); }
|
|||
| CBYTE NUM byteop NUM { CHECK_PTR_VAL(($$ = gen_byteop(cstate, $3, $2, $4))); }
|
||||
| INBOUND { CHECK_PTR_VAL(($$ = gen_inbound(cstate, 0))); }
|
||||
| OUTBOUND { CHECK_PTR_VAL(($$ = gen_inbound(cstate, 1))); }
|
||||
| VLAN pnum { CHECK_PTR_VAL(($$ = gen_vlan(cstate, (bpf_u_int32)$2, 1))); }
|
||||
| IFINDEX NUM { CHECK_PTR_VAL(($$ = gen_ifindex(cstate, $2))); }
|
||||
| VLAN pnum { CHECK_PTR_VAL(($$ = gen_vlan(cstate, $2, 1))); }
|
||||
| VLAN { CHECK_PTR_VAL(($$ = gen_vlan(cstate, 0, 0))); }
|
||||
| MPLS pnum { CHECK_PTR_VAL(($$ = gen_mpls(cstate, (bpf_u_int32)$2, 1))); }
|
||||
| MPLS pnum { CHECK_PTR_VAL(($$ = gen_mpls(cstate, $2, 1))); }
|
||||
| MPLS { CHECK_PTR_VAL(($$ = gen_mpls(cstate, 0, 0))); }
|
||||
| PPPOED { CHECK_PTR_VAL(($$ = gen_pppoed(cstate))); }
|
||||
| PPPOES pnum { CHECK_PTR_VAL(($$ = gen_pppoes(cstate, (bpf_u_int32)$2, 1))); }
|
||||
| PPPOES pnum { CHECK_PTR_VAL(($$ = gen_pppoes(cstate, $2, 1))); }
|
||||
| PPPOES { CHECK_PTR_VAL(($$ = gen_pppoes(cstate, 0, 0))); }
|
||||
| GENEVE pnum { CHECK_PTR_VAL(($$ = gen_geneve(cstate, (bpf_u_int32)$2, 1))); }
|
||||
| GENEVE pnum { CHECK_PTR_VAL(($$ = gen_geneve(cstate, $2, 1))); }
|
||||
| GENEVE { CHECK_PTR_VAL(($$ = gen_geneve(cstate, 0, 0))); }
|
||||
| pfvar { $$ = $1; }
|
||||
| pqual p80211 { $$ = $2; }
|
||||
|
@ -586,23 +648,33 @@ p80211: TYPE type SUBTYPE subtype
|
|||
| DIR dir { CHECK_PTR_VAL(($$ = gen_p80211_fcdir(cstate, $2))); }
|
||||
;
|
||||
|
||||
type: NUM
|
||||
type: NUM { if (($1 & (~IEEE80211_FC0_TYPE_MASK)) != 0) {
|
||||
bpf_set_error(cstate, "invalid 802.11 type value 0x%02x", $1);
|
||||
YYABORT;
|
||||
}
|
||||
$$ = (int)$1;
|
||||
}
|
||||
| ID { CHECK_PTR_VAL($1);
|
||||
$$ = str2tok($1, ieee80211_types);
|
||||
if ($$ == -1) {
|
||||
bpf_set_error(cstate, "unknown 802.11 type name");
|
||||
YYABORT;
|
||||
bpf_set_error(cstate, "unknown 802.11 type name \"%s\"", $1);
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
subtype: NUM
|
||||
subtype: NUM { if (($1 & (~IEEE80211_FC0_SUBTYPE_MASK)) != 0) {
|
||||
bpf_set_error(cstate, "invalid 802.11 subtype value 0x%02x", $1);
|
||||
YYABORT;
|
||||
}
|
||||
$$ = (int)$1;
|
||||
}
|
||||
| ID { const struct tok *types = NULL;
|
||||
int i;
|
||||
CHECK_PTR_VAL($1);
|
||||
for (i = 0;; i++) {
|
||||
if (ieee80211_type_subtypes[i].tok == NULL) {
|
||||
/* Ran out of types */
|
||||
if (ieee80211_type_subtypes[i].tok == NULL) {
|
||||
/* Ran out of types */
|
||||
bpf_set_error(cstate, "unknown 802.11 type");
|
||||
YYABORT;
|
||||
}
|
||||
|
@ -614,7 +686,7 @@ subtype: NUM
|
|||
|
||||
$$ = str2tok($1, types);
|
||||
if ($$ == -1) {
|
||||
bpf_set_error(cstate, "unknown 802.11 subtype name");
|
||||
bpf_set_error(cstate, "unknown 802.11 subtype name \"%s\"", $1);
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
|
@ -623,8 +695,8 @@ subtype: NUM
|
|||
type_subtype: ID { int i;
|
||||
CHECK_PTR_VAL($1);
|
||||
for (i = 0;; i++) {
|
||||
if (ieee80211_type_subtypes[i].tok == NULL) {
|
||||
/* Ran out of types */
|
||||
if (ieee80211_type_subtypes[i].tok == NULL) {
|
||||
/* Ran out of types */
|
||||
bpf_set_error(cstate, "unknown 802.11 type name");
|
||||
YYABORT;
|
||||
}
|
||||
|
@ -654,9 +726,9 @@ pllc: LLC { CHECK_PTR_VAL(($$ = gen_llc(cstate))); }
|
|||
} else {
|
||||
subtype = str2tok($2, llc_u_subtypes);
|
||||
if (subtype == -1) {
|
||||
bpf_set_error(cstate, "unknown LLC type name \"%s\"", $2);
|
||||
YYABORT;
|
||||
}
|
||||
bpf_set_error(cstate, "unknown LLC type name \"%s\"", $2);
|
||||
YYABORT;
|
||||
}
|
||||
CHECK_PTR_VAL(($$ = gen_llc_u_subtype(cstate, subtype)));
|
||||
}
|
||||
}
|
||||
|
@ -665,7 +737,7 @@ pllc: LLC { CHECK_PTR_VAL(($$ = gen_llc(cstate))); }
|
|||
| LLC PF_RNR { CHECK_PTR_VAL(($$ = gen_llc_s_subtype(cstate, LLC_RNR))); }
|
||||
;
|
||||
|
||||
dir: NUM
|
||||
dir: NUM { $$ = (int)$1; }
|
||||
| ID { CHECK_PTR_VAL($1);
|
||||
if (pcap_strcasecmp($1, "nods") == 0)
|
||||
$$ = IEEE80211_FC1_DIR_NODS;
|
||||
|
@ -743,15 +815,15 @@ atmfield: VPI { $$.atmfieldtype = A_VPI; }
|
|||
| VCI { $$.atmfieldtype = A_VCI; }
|
||||
;
|
||||
atmvalue: atmfieldvalue
|
||||
| relop NUM { CHECK_PTR_VAL(($$.b = gen_atmfield_code(cstate, $<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 0))); }
|
||||
| irelop NUM { CHECK_PTR_VAL(($$.b = gen_atmfield_code(cstate, $<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 1))); }
|
||||
| relop NUM { CHECK_PTR_VAL(($$.b = gen_atmfield_code(cstate, $<blk>0.atmfieldtype, $2, $1, 0))); }
|
||||
| irelop NUM { CHECK_PTR_VAL(($$.b = gen_atmfield_code(cstate, $<blk>0.atmfieldtype, $2, $1, 1))); }
|
||||
| paren atmlistvalue ')' { $$.b = $2.b; $$.q = qerr; }
|
||||
;
|
||||
atmfieldvalue: NUM {
|
||||
$$.atmfieldtype = $<blk>0.atmfieldtype;
|
||||
if ($$.atmfieldtype == A_VPI ||
|
||||
$$.atmfieldtype == A_VCI)
|
||||
CHECK_PTR_VAL(($$.b = gen_atmfield_code(cstate, $$.atmfieldtype, (bpf_int32) $1, BPF_JEQ, 0)));
|
||||
CHECK_PTR_VAL(($$.b = gen_atmfield_code(cstate, $$.atmfieldtype, $1, BPF_JEQ, 0)));
|
||||
}
|
||||
;
|
||||
atmlistvalue: atmfieldvalue
|
||||
|
@ -776,8 +848,8 @@ mtp3field: SIO { $$.mtp3fieldtype = M_SIO; }
|
|||
| HSLS { $$.mtp3fieldtype = MH_SLS; }
|
||||
;
|
||||
mtp3value: mtp3fieldvalue
|
||||
| relop NUM { CHECK_PTR_VAL(($$.b = gen_mtp3field_code(cstate, $<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 0))); }
|
||||
| irelop NUM { CHECK_PTR_VAL(($$.b = gen_mtp3field_code(cstate, $<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 1))); }
|
||||
| relop NUM { CHECK_PTR_VAL(($$.b = gen_mtp3field_code(cstate, $<blk>0.mtp3fieldtype, $2, $1, 0))); }
|
||||
| irelop NUM { CHECK_PTR_VAL(($$.b = gen_mtp3field_code(cstate, $<blk>0.mtp3fieldtype, $2, $1, 1))); }
|
||||
| paren mtp3listvalue ')' { $$.b = $2.b; $$.q = qerr; }
|
||||
;
|
||||
mtp3fieldvalue: NUM {
|
||||
|
@ -790,7 +862,7 @@ mtp3fieldvalue: NUM {
|
|||
$$.mtp3fieldtype == MH_OPC ||
|
||||
$$.mtp3fieldtype == MH_DPC ||
|
||||
$$.mtp3fieldtype == MH_SLS)
|
||||
CHECK_PTR_VAL(($$.b = gen_mtp3field_code(cstate, $$.mtp3fieldtype, (u_int) $1, BPF_JEQ, 0)));
|
||||
CHECK_PTR_VAL(($$.b = gen_mtp3field_code(cstate, $$.mtp3fieldtype, $1, BPF_JEQ, 0)));
|
||||
}
|
||||
;
|
||||
mtp3listvalue: mtp3fieldvalue
|
|
@ -29,7 +29,7 @@
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
* $FreeBSD: src/sys/net80211/ieee80211.h,v 1.10 2005/07/22 16:55:27 sam Exp $
|
||||
*/
|
||||
#ifndef _NET80211_IEEE80211_H_
|
||||
#define _NET80211_IEEE80211_H_
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
|
||||
/* Prototypes missing in Digital UNIX 4.x */
|
||||
int pcap_snprintf(char *, size_t, const char *, ...);
|
||||
int pcap_vsnprintf(char *, size_t, const char *, va_list);
|
||||
int snprintf(char *, size_t, const char *, ...);
|
||||
int vsnprintf(char *, size_t, const char *, va_list);
|
||||
int pfopen(char *, int);
|
||||
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
|
||||
/*
|
||||
* Prototypes missing in Tru64 UNIX 5.x
|
||||
* XXX - "pcap_snprintf()" and "pcap_vsnprintf()" aren't missing, but you have to
|
||||
* XXX - "snprintf()" and "vsnprintf()" aren't missing, but you have to
|
||||
* #define the right value to get them defined by <stdio.h>.
|
||||
*/
|
||||
int pcap_snprintf(char *, size_t, const char *, ...);
|
||||
int pcap_vsnprintf(char *, size_t, const char *, va_list);
|
||||
int snprintf(char *, size_t, const char *, ...);
|
||||
int vsnprintf(char *, size_t, const char *, va_list);
|
||||
int pfopen(char *, int);
|
||||
|
||||
|
|
|
@ -21,4 +21,4 @@
|
|||
|
||||
/* Prototypes missing in SunOS 5 */
|
||||
char *strerror(int);
|
||||
int pcap_snprintf(char *, size_t, const char *, ...);
|
||||
int snprintf(char *, size_t, const char *, ...);
|
||||
|
|
|
@ -155,7 +155,7 @@ int sigsetmask(int);
|
|||
struct sigvec;
|
||||
#endif
|
||||
int sigvec(int, struct sigvec *, struct sigvec*);
|
||||
int pcap_snprintf(char *, size_t, const char *, ...);
|
||||
int snprintf(char *, size_t, const char *, ...);
|
||||
int socket(int, int, int);
|
||||
int socketpair(int, int, int, int *);
|
||||
int symlink(const char *, const char *);
|
||||
|
|
|
@ -13,6 +13,7 @@ libdir="@libdir@"
|
|||
Name: libpcap
|
||||
Description: Platform-independent network traffic capture library
|
||||
Version: @PACKAGE_VERSION@
|
||||
Libs: -L${libdir} -l@PACKAGE_NAME@
|
||||
Libs.private: @LIBS@
|
||||
Requires.private: @REQUIRES_PRIVATE@
|
||||
Libs: -L${libdir} @RPATH@ -l@PACKAGE_NAME@
|
||||
Libs.private: @LIBS_PRIVATE@
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -20,7 +20,7 @@ pcap_vasprintf(char **strp, const char *format, va_list args)
|
|||
int ret;
|
||||
|
||||
/*
|
||||
* XXX - the C99 standard says, in section 7.19.6.5 "Thes
|
||||
* XXX - the C99 standard says, in section 7.19.6.5 "The
|
||||
* nprintf function":
|
||||
*
|
||||
* The snprintf function is equivalent to fprintf, except that
|
||||
|
|
|
@ -80,9 +80,18 @@ getopt(int nargc, char * const *nargv, const char *ostr)
|
|||
place = EMSG;
|
||||
return (-1);
|
||||
}
|
||||
} /* option letter okay? */
|
||||
if ((optopt = (int)*place++) == (int)':' ||
|
||||
!(oli = strchr(ostr, optopt))) {
|
||||
}
|
||||
optopt = (int)*place++;
|
||||
if (optopt == (int)':') { /* option letter okay? */
|
||||
if (!*place)
|
||||
++optind;
|
||||
if (opterr && *ostr != ':')
|
||||
(void)fprintf(stderr,
|
||||
"%s: illegal option -- %c\n", __progname, optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
oli = strchr(ostr, optopt);
|
||||
if (!oli) {
|
||||
/*
|
||||
* if the user didn't specify '-' as an option,
|
||||
* assume it means -1.
|
||||
|
@ -114,7 +123,7 @@ getopt(int nargc, char * const *nargv, const char *ostr)
|
|||
__progname, optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
else /* white space */
|
||||
else /* white space */
|
||||
optarg = nargv[optind];
|
||||
place = EMSG;
|
||||
++optind;
|
||||
|
|
|
@ -1,631 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1995-1999 Kungliga Tekniska Högskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* 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. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* We use this for platforms that don't have snprintf() at all.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "portability.h"
|
||||
|
||||
enum format_flags {
|
||||
minus_flag = 1,
|
||||
plus_flag = 2,
|
||||
space_flag = 4,
|
||||
alternate_flag = 8,
|
||||
zero_flag = 16
|
||||
};
|
||||
|
||||
/*
|
||||
* Common state
|
||||
*/
|
||||
|
||||
struct state {
|
||||
unsigned char *str;
|
||||
unsigned char *s;
|
||||
unsigned char *theend;
|
||||
size_t sz;
|
||||
size_t max_sz;
|
||||
int (*append_char)(struct state *, unsigned char);
|
||||
int (*reserve)(struct state *, size_t);
|
||||
/* XXX - methods */
|
||||
};
|
||||
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
static int
|
||||
sn_reserve (struct state *state, size_t n)
|
||||
{
|
||||
return state->s + n > state->theend;
|
||||
}
|
||||
|
||||
static int
|
||||
sn_append_char (struct state *state, unsigned char c)
|
||||
{
|
||||
if (sn_reserve (state, 1)) {
|
||||
return 1;
|
||||
} else {
|
||||
*state->s++ = c;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static int
|
||||
as_reserve (struct state *state, size_t n)
|
||||
{
|
||||
if (state->s + n > state->theend) {
|
||||
int off = state->s - state->str;
|
||||
unsigned char *tmp;
|
||||
|
||||
if (state->max_sz && state->sz >= state->max_sz)
|
||||
return 1;
|
||||
|
||||
state->sz = max(state->sz * 2, state->sz + n);
|
||||
if (state->max_sz)
|
||||
state->sz = min(state->sz, state->max_sz);
|
||||
tmp = realloc (state->str, state->sz);
|
||||
if (tmp == NULL)
|
||||
return 1;
|
||||
state->str = tmp;
|
||||
state->s = state->str + off;
|
||||
state->theend = state->str + state->sz - 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
as_append_char (struct state *state, unsigned char c)
|
||||
{
|
||||
if(as_reserve (state, 1))
|
||||
return 1;
|
||||
else {
|
||||
*state->s++ = c;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
append_number(struct state *state,
|
||||
unsigned long num, unsigned base, char *rep,
|
||||
int width, int prec, int flags, int minusp)
|
||||
{
|
||||
int len = 0;
|
||||
int i;
|
||||
|
||||
/* given precision, ignore zero flag */
|
||||
if(prec != -1)
|
||||
flags &= ~zero_flag;
|
||||
else
|
||||
prec = 1;
|
||||
/* zero value with zero precision -> "" */
|
||||
if(prec == 0 && num == 0)
|
||||
return 0;
|
||||
do{
|
||||
if((*state->append_char)(state, rep[num % base]))
|
||||
return 1;
|
||||
len++;
|
||||
num /= base;
|
||||
}while(num);
|
||||
prec -= len;
|
||||
/* pad with prec zeros */
|
||||
while(prec-- > 0){
|
||||
if((*state->append_char)(state, '0'))
|
||||
return 1;
|
||||
len++;
|
||||
}
|
||||
/* add length of alternate prefix (added later) to len */
|
||||
if(flags & alternate_flag && (base == 16 || base == 8))
|
||||
len += base / 8;
|
||||
/* pad with zeros */
|
||||
if(flags & zero_flag){
|
||||
width -= len;
|
||||
if(minusp || (flags & space_flag) || (flags & plus_flag))
|
||||
width--;
|
||||
while(width-- > 0){
|
||||
if((*state->append_char)(state, '0'))
|
||||
return 1;
|
||||
len++;
|
||||
}
|
||||
}
|
||||
/* add alternate prefix */
|
||||
if(flags & alternate_flag && (base == 16 || base == 8)){
|
||||
if(base == 16)
|
||||
if((*state->append_char)(state, rep[10] + 23)) /* XXX */
|
||||
return 1;
|
||||
if((*state->append_char)(state, '0'))
|
||||
return 1;
|
||||
}
|
||||
/* add sign */
|
||||
if(minusp){
|
||||
if((*state->append_char)(state, '-'))
|
||||
return 1;
|
||||
len++;
|
||||
} else if(flags & plus_flag) {
|
||||
if((*state->append_char)(state, '+'))
|
||||
return 1;
|
||||
len++;
|
||||
} else if(flags & space_flag) {
|
||||
if((*state->append_char)(state, ' '))
|
||||
return 1;
|
||||
len++;
|
||||
}
|
||||
if(flags & minus_flag)
|
||||
/* swap before padding with spaces */
|
||||
for(i = 0; i < len / 2; i++){
|
||||
char c = state->s[-i-1];
|
||||
state->s[-i-1] = state->s[-len+i];
|
||||
state->s[-len+i] = c;
|
||||
}
|
||||
width -= len;
|
||||
while(width-- > 0){
|
||||
if((*state->append_char)(state, ' '))
|
||||
return 1;
|
||||
len++;
|
||||
}
|
||||
if(!(flags & minus_flag))
|
||||
/* swap after padding with spaces */
|
||||
for(i = 0; i < len / 2; i++){
|
||||
char c = state->s[-i-1];
|
||||
state->s[-i-1] = state->s[-len+i];
|
||||
state->s[-len+i] = c;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
append_string (struct state *state,
|
||||
unsigned char *arg,
|
||||
int width,
|
||||
int prec,
|
||||
int flags)
|
||||
{
|
||||
if(prec != -1)
|
||||
width -= prec;
|
||||
else
|
||||
width -= strlen((char *)arg);
|
||||
if(!(flags & minus_flag))
|
||||
while(width-- > 0)
|
||||
if((*state->append_char) (state, ' '))
|
||||
return 1;
|
||||
if (prec != -1) {
|
||||
while (*arg && prec--)
|
||||
if ((*state->append_char) (state, *arg++))
|
||||
return 1;
|
||||
} else {
|
||||
while (*arg)
|
||||
if ((*state->append_char) (state, *arg++))
|
||||
return 1;
|
||||
}
|
||||
if(flags & minus_flag)
|
||||
while(width-- > 0)
|
||||
if((*state->append_char) (state, ' '))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
append_char(struct state *state,
|
||||
unsigned char arg,
|
||||
int width,
|
||||
int flags)
|
||||
{
|
||||
while(!(flags & minus_flag) && --width > 0)
|
||||
if((*state->append_char) (state, ' '))
|
||||
return 1;
|
||||
|
||||
if((*state->append_char) (state, arg))
|
||||
return 1;
|
||||
while((flags & minus_flag) && --width > 0)
|
||||
if((*state->append_char) (state, ' '))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* This can't be made into a function...
|
||||
*/
|
||||
|
||||
#define PARSE_INT_FORMAT(res, arg, unsig) \
|
||||
if (long_flag) \
|
||||
res = (unsig long)va_arg(arg, unsig long); \
|
||||
else if (short_flag) \
|
||||
res = (unsig short)va_arg(arg, unsig int); \
|
||||
else \
|
||||
res = (unsig int)va_arg(arg, unsig int)
|
||||
|
||||
/*
|
||||
* zyxprintf - return 0 or -1
|
||||
*/
|
||||
|
||||
static int
|
||||
xyzprintf (struct state *state, const char *char_format, va_list ap)
|
||||
{
|
||||
const unsigned char *format = (const unsigned char *)char_format;
|
||||
unsigned char c;
|
||||
|
||||
while((c = *format++)) {
|
||||
if (c == '%') {
|
||||
int flags = 0;
|
||||
int width = 0;
|
||||
int prec = -1;
|
||||
int long_flag = 0;
|
||||
int short_flag = 0;
|
||||
|
||||
/* flags */
|
||||
while((c = *format++)){
|
||||
if(c == '-')
|
||||
flags |= minus_flag;
|
||||
else if(c == '+')
|
||||
flags |= plus_flag;
|
||||
else if(c == ' ')
|
||||
flags |= space_flag;
|
||||
else if(c == '#')
|
||||
flags |= alternate_flag;
|
||||
else if(c == '0')
|
||||
flags |= zero_flag;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if((flags & space_flag) && (flags & plus_flag))
|
||||
flags ^= space_flag;
|
||||
|
||||
if((flags & minus_flag) && (flags & zero_flag))
|
||||
flags ^= zero_flag;
|
||||
|
||||
/* width */
|
||||
if (isdigit(c))
|
||||
do {
|
||||
width = width * 10 + c - '0';
|
||||
c = *format++;
|
||||
} while(isdigit(c));
|
||||
else if(c == '*') {
|
||||
width = va_arg(ap, int);
|
||||
c = *format++;
|
||||
}
|
||||
|
||||
/* precision */
|
||||
if (c == '.') {
|
||||
prec = 0;
|
||||
c = *format++;
|
||||
if (isdigit(c))
|
||||
do {
|
||||
prec = prec * 10 + c - '0';
|
||||
c = *format++;
|
||||
} while(isdigit(c));
|
||||
else if (c == '*') {
|
||||
prec = va_arg(ap, int);
|
||||
c = *format++;
|
||||
}
|
||||
}
|
||||
|
||||
/* size */
|
||||
|
||||
if (c == 'h') {
|
||||
short_flag = 1;
|
||||
c = *format++;
|
||||
} else if (c == 'l') {
|
||||
long_flag = 1;
|
||||
c = *format++;
|
||||
}
|
||||
|
||||
switch (c) {
|
||||
case 'c' :
|
||||
if(append_char(state, va_arg(ap, int), width, flags))
|
||||
return -1;
|
||||
break;
|
||||
case 's' :
|
||||
if (append_string(state,
|
||||
va_arg(ap, unsigned char*),
|
||||
width,
|
||||
prec,
|
||||
flags))
|
||||
return -1;
|
||||
break;
|
||||
case 'd' :
|
||||
case 'i' : {
|
||||
long arg;
|
||||
unsigned long num;
|
||||
int minusp = 0;
|
||||
|
||||
PARSE_INT_FORMAT(arg, ap, signed);
|
||||
|
||||
if (arg < 0) {
|
||||
minusp = 1;
|
||||
num = -arg;
|
||||
} else
|
||||
num = arg;
|
||||
|
||||
if (append_number (state, num, 10, "0123456789",
|
||||
width, prec, flags, minusp))
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
case 'u' : {
|
||||
unsigned long arg;
|
||||
|
||||
PARSE_INT_FORMAT(arg, ap, unsigned);
|
||||
|
||||
if (append_number (state, arg, 10, "0123456789",
|
||||
width, prec, flags, 0))
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
case 'o' : {
|
||||
unsigned long arg;
|
||||
|
||||
PARSE_INT_FORMAT(arg, ap, unsigned);
|
||||
|
||||
if (append_number (state, arg, 010, "01234567",
|
||||
width, prec, flags, 0))
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
case 'x' : {
|
||||
unsigned long arg;
|
||||
|
||||
PARSE_INT_FORMAT(arg, ap, unsigned);
|
||||
|
||||
if (append_number (state, arg, 0x10, "0123456789abcdef",
|
||||
width, prec, flags, 0))
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
case 'X' :{
|
||||
unsigned long arg;
|
||||
|
||||
PARSE_INT_FORMAT(arg, ap, unsigned);
|
||||
|
||||
if (append_number (state, arg, 0x10, "0123456789ABCDEF",
|
||||
width, prec, flags, 0))
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
case 'p' : {
|
||||
unsigned long arg = (unsigned long)va_arg(ap, void*);
|
||||
|
||||
if (append_number (state, arg, 0x10, "0123456789ABCDEF",
|
||||
width, prec, flags, 0))
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
case 'n' : {
|
||||
int *arg = va_arg(ap, int*);
|
||||
*arg = state->s - state->str;
|
||||
break;
|
||||
}
|
||||
case '\0' :
|
||||
--format;
|
||||
/* FALLTHROUGH */
|
||||
case '%' :
|
||||
if ((*state->append_char)(state, c))
|
||||
return -1;
|
||||
break;
|
||||
default :
|
||||
if ( (*state->append_char)(state, '%')
|
||||
|| (*state->append_char)(state, c))
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
if ((*state->append_char) (state, c))
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef HAVE_SNPRINTF
|
||||
int
|
||||
pcap_snprintf (char *str, size_t sz, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int ret;
|
||||
|
||||
va_start(args, format);
|
||||
ret = pcap_vsnprintf (str, sz, format, args);
|
||||
|
||||
#ifdef PARANOIA
|
||||
{
|
||||
int ret2;
|
||||
char *tmp;
|
||||
|
||||
tmp = malloc (sz);
|
||||
if (tmp == NULL)
|
||||
abort ();
|
||||
|
||||
ret2 = pcap_vsprintf (tmp, format, args);
|
||||
if (ret != ret2 || strcmp(str, tmp))
|
||||
abort ();
|
||||
free (tmp);
|
||||
}
|
||||
#endif
|
||||
|
||||
va_end(args);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#ifndef HAVE_ASPRINTF
|
||||
int
|
||||
asprintf (char **ret, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int val;
|
||||
|
||||
va_start(args, format);
|
||||
val = vasprintf (ret, format, args);
|
||||
|
||||
#ifdef PARANOIA
|
||||
{
|
||||
int ret2;
|
||||
char *tmp;
|
||||
tmp = malloc (val + 1);
|
||||
if (tmp == NULL)
|
||||
abort ();
|
||||
|
||||
ret2 = vsprintf (tmp, format, args);
|
||||
if (val != ret2 || strcmp(*ret, tmp))
|
||||
abort ();
|
||||
free (tmp);
|
||||
}
|
||||
#endif
|
||||
|
||||
va_end(args);
|
||||
return val;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ASNPRINTF
|
||||
int
|
||||
pcap_asnprintf (char **ret, size_t max_sz, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int val;
|
||||
|
||||
va_start(args, format);
|
||||
val = pcap_vasnprintf (ret, max_sz, format, args);
|
||||
va_end(args);
|
||||
|
||||
#ifdef PARANOIA
|
||||
{
|
||||
int ret2;
|
||||
char *tmp;
|
||||
tmp = malloc (val + 1);
|
||||
if (tmp == NULL)
|
||||
abort ();
|
||||
|
||||
va_start(args, format);
|
||||
ret2 = pcap_vsprintf (tmp, format, args);
|
||||
va_end(args);
|
||||
if (val != ret2 || strcmp(*ret, tmp))
|
||||
abort ();
|
||||
free (tmp);
|
||||
}
|
||||
#endif
|
||||
|
||||
return val;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_VASPRINTF
|
||||
int
|
||||
pcap_vasprintf (char **ret, const char *format, va_list args)
|
||||
{
|
||||
return pcap_vasnprintf (ret, 0, format, args);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAVE_VASNPRINTF
|
||||
int
|
||||
pcap_vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
|
||||
{
|
||||
int st;
|
||||
size_t len;
|
||||
struct state state;
|
||||
|
||||
state.max_sz = max_sz;
|
||||
state.sz = 1;
|
||||
state.str = malloc(state.sz);
|
||||
if (state.str == NULL) {
|
||||
*ret = NULL;
|
||||
return -1;
|
||||
}
|
||||
state.s = state.str;
|
||||
state.theend = state.s + state.sz - 1;
|
||||
state.append_char = as_append_char;
|
||||
state.reserve = as_reserve;
|
||||
|
||||
st = xyzprintf (&state, format, args);
|
||||
if (st) {
|
||||
free (state.str);
|
||||
*ret = NULL;
|
||||
return -1;
|
||||
} else {
|
||||
char *tmp;
|
||||
|
||||
*state.s = '\0';
|
||||
len = state.s - state.str;
|
||||
tmp = realloc (state.str, len+1);
|
||||
if (tmp == NULL) {
|
||||
free (state.str);
|
||||
*ret = NULL;
|
||||
return -1;
|
||||
}
|
||||
*ret = tmp;
|
||||
return len;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
int
|
||||
pcap_vsnprintf (char *str, size_t sz, const char *format, va_list args)
|
||||
{
|
||||
struct state state;
|
||||
int ret;
|
||||
unsigned char *ustr = (unsigned char *)str;
|
||||
|
||||
state.max_sz = 0;
|
||||
state.sz = sz;
|
||||
state.str = ustr;
|
||||
state.s = ustr;
|
||||
state.theend = ustr + sz - 1;
|
||||
state.append_char = sn_append_char;
|
||||
state.reserve = sn_reserve;
|
||||
|
||||
ret = xyzprintf (&state, format, args);
|
||||
*state.s = '\0';
|
||||
if (ret)
|
||||
return sz;
|
||||
else
|
||||
return state.s - state.str;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -23,7 +23,7 @@ pcap_vasprintf(char **strp, const char *format, va_list args)
|
|||
*strp = NULL;
|
||||
return (-1);
|
||||
}
|
||||
ret = pcap_vsnprintf(str, str_size, format, args);
|
||||
ret = vsnprintf(str, str_size, format, args);
|
||||
if (ret == -1) {
|
||||
free(str);
|
||||
*strp = NULL;
|
||||
|
@ -31,7 +31,7 @@ pcap_vasprintf(char **strp, const char *format, va_list args)
|
|||
}
|
||||
*strp = str;
|
||||
/*
|
||||
* pcap_vsnprintf() shouldn't truncate the string, as we have
|
||||
* vsnprintf() shouldn't truncate the string, as we have
|
||||
* allocated a buffer large enough to hold the string, so its
|
||||
* return value should be the number of characters printed.
|
||||
*/
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "portability.h"
|
||||
|
||||
int
|
||||
pcap_vsnprintf(char *str, size_t str_size, const char *format, va_list args)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = _vsnprintf_s(str, str_size, _TRUNCATE, format, args);
|
||||
|
||||
/*
|
||||
* XXX - _vsnprintf() and _snprintf() do *not* guarantee
|
||||
* that str is null-terminated, but C99's vsnprintf()
|
||||
* and snprintf() do, and we want to offer C99 behavior,
|
||||
* so forcibly null-terminate the string.
|
||||
*
|
||||
* We don't, however, offer C99 behavior for the return
|
||||
* value; _vsnprintf_s() returns -1, not the number of
|
||||
* characters that would have been put into the buffer
|
||||
* had it been large enough, if the string is truncated.
|
||||
* The only way to get that value is to use _vscprintf();
|
||||
* getting that count isn't worth the re-formatting.
|
||||
*
|
||||
* XXX - does _vsnprintf_s() return -1 on a formatting
|
||||
* error?
|
||||
*/
|
||||
str[str_size - 1] = '\0';
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int
|
||||
pcap_snprintf(char *str, size_t str_size, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int ret;
|
||||
|
||||
va_start(args, format);
|
||||
ret = pcap_vsnprintf(str, str_size, format, args);
|
||||
va_end(args);
|
||||
return (ret);
|
||||
}
|
|
@ -16,7 +16,10 @@
|
|||
MAKE=Makefile # default makefile name is "Makefile"
|
||||
CC=cc # default C compiler is "cc"
|
||||
DEPENDENCY_CFLAG=-M # default dependency-generation flag is -M
|
||||
SOURCE_DIRECTORY=. # default source directory is the current directory
|
||||
|
||||
# No command-line flags seen yet.
|
||||
flags=""
|
||||
while :
|
||||
do case "$1" in
|
||||
# -c allows you to specify the C compiler
|
||||
|
@ -39,13 +42,29 @@ while :
|
|||
-p)
|
||||
SED='s;\.o;;'
|
||||
shift ;;
|
||||
|
||||
# -s allows you to specify the source directory
|
||||
-s)
|
||||
SOURCE_DIRECTORY=$2
|
||||
shift; shift ;;
|
||||
|
||||
# -include takes an argument
|
||||
-include)
|
||||
flags="$flags $1 $2"
|
||||
shift; shift ;;
|
||||
|
||||
# other command-line flag
|
||||
-*)
|
||||
flags="$flags $1"
|
||||
shift ;;
|
||||
|
||||
*)
|
||||
break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ $# = 0 ] ; then
|
||||
echo 'usage: mkdep [-p] [-c cc] [-f makefile] [-m dependency-cflag] [flags] file ...'
|
||||
echo 'usage: mkdep [-p] [-c cc] [-f makefile] [-m dependency-cflag] [-s source-directory] [flags] file ...'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -76,30 +95,20 @@ _EOF_
|
|||
# egrep '^#include[ ]*".*"' /dev/null $* |
|
||||
# sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' |
|
||||
|
||||
#
|
||||
# Construct a list of source files with paths relative to the source directory.
|
||||
#
|
||||
sources=""
|
||||
for srcfile in $*
|
||||
do
|
||||
sources="$sources $SOURCE_DIRECTORY/$srcfile"
|
||||
done
|
||||
|
||||
# XXX this doesn't work with things like "-DDECLWAITSTATUS=union\ wait"
|
||||
$CC $DEPENDENCY_CFLAG $* |
|
||||
$CC $DEPENDENCY_CFLAG $flags $sources |
|
||||
sed "
|
||||
s; \./; ;g
|
||||
$SED" |
|
||||
awk '{
|
||||
if ($1 != prev) {
|
||||
if (rec != "")
|
||||
print rec;
|
||||
rec = $0;
|
||||
prev = $1;
|
||||
}
|
||||
else {
|
||||
if (length(rec $2) > 78) {
|
||||
print rec;
|
||||
rec = $0;
|
||||
}
|
||||
else
|
||||
rec = rec " " $2
|
||||
}
|
||||
}
|
||||
END {
|
||||
print rec
|
||||
}' >> $TMP
|
||||
$SED" >> $TMP
|
||||
|
||||
cat << _EOF_ >> $TMP
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ Note for djgpp users:
|
|||
If you got the libpcap from the official site www.tcpdump, then that
|
||||
distribution does NOT contain any sources for building 32-bit drivers.
|
||||
Instead get the full version at
|
||||
http://www.watt-32.net/pcap/libpcap.zip
|
||||
https://www.watt-32.net/pcap/libpcap.zip
|
||||
|
||||
and set "USE_32BIT_DRIVERS = 1" in msdos\common.dj.
|
||||
|
||||
|
@ -51,12 +51,12 @@ The following packages and tools must be present for all targets.
|
|||
receive network data. It's mostly used to access the 'hosts'
|
||||
file and other <netdb.h> features. Get 'watt32s*.zip' at:
|
||||
|
||||
http://www.watt-32.net
|
||||
https://www.watt-32.net
|
||||
|
||||
2. Exception handler and disassember library (libexc.a) is needed if
|
||||
"USE_EXCEPT = 1" in common.dj. Available at:
|
||||
|
||||
http://www.watt-32.net/misc/exc_dx07.zip
|
||||
https://www.watt-32.net/misc/exc_dx07.zip
|
||||
|
||||
3. Flex & Bison is used to generate parser for the filter handler
|
||||
pcap_compile:
|
||||
|
@ -65,7 +65,7 @@ The following packages and tools must be present for all targets.
|
|||
|
||||
4. NASM assembler v 0.98 or later is required when building djgpp and
|
||||
Watcom targets:
|
||||
http://www.nasm.us/
|
||||
https://www.nasm.us/
|
||||
|
||||
5. sed (Stream Editor) is required for doing `make depend'.
|
||||
It's available at:
|
||||
|
|
|
@ -127,7 +127,6 @@
|
|||
#include <netdb.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -135,6 +134,8 @@
|
|||
|
||||
#include "pcap-int.h"
|
||||
|
||||
#include "diag-control.h"
|
||||
|
||||
#include "gencode.h"
|
||||
#include <pcap/namedb.h>
|
||||
#include "nametoaddr.h"
|
||||
|
@ -162,7 +163,23 @@ pcap_nametoaddr(const char *name)
|
|||
bpf_u_int32 **p;
|
||||
struct hostent *hp;
|
||||
|
||||
/*
|
||||
* gethostbyname() is deprecated on Windows, perhaps because
|
||||
* it's not thread-safe, or because it doesn't support IPv6,
|
||||
* or both.
|
||||
*
|
||||
* We deprecate pcap_nametoaddr() on all platforms because
|
||||
* it's not thread-safe; we supply it for backwards compatibility,
|
||||
* so suppress the deprecation warning. We could, I guess,
|
||||
* use getaddrinfo() and construct the array ourselves, but
|
||||
* that's probably not worth the effort, as that wouldn't make
|
||||
* this thread-safe - we can't change the API to require that
|
||||
* our caller free the address array, so we still have to reuse
|
||||
* a local array.
|
||||
*/
|
||||
DIAG_OFF_DEPRECATION
|
||||
if ((hp = gethostbyname(name)) != NULL) {
|
||||
DIAG_ON_DEPRECATION
|
||||
#ifndef h_addr
|
||||
hlist[0] = (bpf_u_int32 *)hp->h_addr;
|
||||
NTOHL(hp->h_addr);
|
||||
|
@ -200,10 +217,10 @@ pcap_nametoaddrinfo(const char *name)
|
|||
* XXX - not guaranteed to be thread-safe! See below for platforms
|
||||
* on which it is thread-safe and on which it isn't.
|
||||
*/
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
bpf_u_int32
|
||||
pcap_nametonetaddr(const char *name)
|
||||
pcap_nametonetaddr(const char *name _U_)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
* There's no "getnetbyname()" on Windows.
|
||||
*
|
||||
|
@ -217,7 +234,11 @@ pcap_nametonetaddr(const char *name)
|
|||
* of *UN*X* machines.)
|
||||
*/
|
||||
return 0;
|
||||
#else
|
||||
}
|
||||
#else /* _WIN32 */
|
||||
bpf_u_int32
|
||||
pcap_nametonetaddr(const char *name)
|
||||
{
|
||||
/*
|
||||
* UN*X.
|
||||
*/
|
||||
|
@ -291,8 +312,8 @@ pcap_nametonetaddr(const char *name)
|
|||
return np->n_net;
|
||||
else
|
||||
return 0;
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/*
|
||||
* Convert a port name to its port and protocol numbers.
|
||||
|
@ -569,28 +590,20 @@ struct eproto {
|
|||
*/
|
||||
PCAP_API struct eproto eproto_db[];
|
||||
PCAP_API_DEF struct eproto eproto_db[] = {
|
||||
{ "pup", ETHERTYPE_PUP },
|
||||
{ "xns", ETHERTYPE_NS },
|
||||
{ "aarp", ETHERTYPE_AARP },
|
||||
{ "arp", ETHERTYPE_ARP },
|
||||
{ "atalk", ETHERTYPE_ATALK },
|
||||
{ "decnet", ETHERTYPE_DN },
|
||||
{ "ip", ETHERTYPE_IP },
|
||||
#ifdef INET6
|
||||
{ "ip6", ETHERTYPE_IPV6 },
|
||||
#endif
|
||||
{ "arp", ETHERTYPE_ARP },
|
||||
{ "rarp", ETHERTYPE_REVARP },
|
||||
{ "sprite", ETHERTYPE_SPRITE },
|
||||
{ "lat", ETHERTYPE_LAT },
|
||||
{ "loopback", ETHERTYPE_LOOPBACK },
|
||||
{ "mopdl", ETHERTYPE_MOPDL },
|
||||
{ "moprc", ETHERTYPE_MOPRC },
|
||||
{ "decnet", ETHERTYPE_DN },
|
||||
{ "lat", ETHERTYPE_LAT },
|
||||
{ "rarp", ETHERTYPE_REVARP },
|
||||
{ "sca", ETHERTYPE_SCA },
|
||||
{ "lanbridge", ETHERTYPE_LANBRIDGE },
|
||||
{ "vexp", ETHERTYPE_VEXP },
|
||||
{ "vprod", ETHERTYPE_VPROD },
|
||||
{ "atalk", ETHERTYPE_ATALK },
|
||||
{ "atalkarp", ETHERTYPE_AARP },
|
||||
{ "loopback", ETHERTYPE_LOOPBACK },
|
||||
{ "decdts", ETHERTYPE_DECDTS },
|
||||
{ "decdns", ETHERTYPE_DECDNS },
|
||||
{ (char *)0, 0 }
|
||||
};
|
||||
|
||||
|
@ -635,9 +648,9 @@ pcap_nametollc(const char *s)
|
|||
static inline u_char
|
||||
xdtoi(u_char c)
|
||||
{
|
||||
if (isdigit(c))
|
||||
if (c >= '0' && c <= '9')
|
||||
return (u_char)(c - '0');
|
||||
else if (islower(c))
|
||||
else if (c >= 'a' && c <= 'f')
|
||||
return (u_char)(c - 'a' + 10);
|
||||
else
|
||||
return (u_char)(c - 'A' + 10);
|
||||
|
@ -716,7 +729,7 @@ pcap_ether_aton(const char *s)
|
|||
if (*s == ':' || *s == '.' || *s == '-')
|
||||
s += 1;
|
||||
d = xdtoi(*s++);
|
||||
if (isxdigit((unsigned char)*s)) {
|
||||
if (PCAP_ISXDIGIT(*s)) {
|
||||
d <<= 4;
|
||||
d |= xdtoi(*s++);
|
||||
}
|
||||
|
@ -772,9 +785,14 @@ pcap_ether_hostton(const char *name)
|
|||
{
|
||||
register u_char *ap;
|
||||
u_char a[6];
|
||||
char namebuf[1024];
|
||||
|
||||
/*
|
||||
* In AIX 7.1 and 7.2: int ether_hostton(char *, struct ether_addr *);
|
||||
*/
|
||||
pcap_strlcpy(namebuf, name, sizeof(namebuf));
|
||||
ap = NULL;
|
||||
if (ether_hostton(name, (struct ether_addr *)a) == 0) {
|
||||
if (ether_hostton(namebuf, (struct ether_addr *)a) == 0) {
|
||||
ap = (u_char *)malloc(6);
|
||||
if (ap != NULL)
|
||||
memcpy((char *)ap, (char *)a, 6);
|
||||
|
|
0
contrib/libpcap/nomkdep
Normal file → Executable file
0
contrib/libpcap/nomkdep
Normal file → Executable file
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
|
|
1054
contrib/libpcap/pcap-airpcap.c
Normal file
1054
contrib/libpcap/pcap-airpcap.c
Normal file
File diff suppressed because it is too large
Load diff
36
contrib/libpcap/pcap-airpcap.h
Normal file
36
contrib/libpcap/pcap-airpcap.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy)
|
||||
* Copyright (c) 2005 - 2010 CACE Technologies, Davis (California)
|
||||
* 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. Neither the name of the Politecnico di Torino, CACE Technologies
|
||||
* nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE 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.
|
||||
*
|
||||
*/
|
||||
|
||||
pcap_t *airpcap_create(const char *, char *, int *);
|
||||
int airpcap_findalldevs(pcap_if_list_t *devlistp, char *errbuf);
|
||||
int device_is_airpcap(const char *device, char *ebuf);
|
File diff suppressed because it is too large
Load diff
|
@ -58,7 +58,7 @@
|
|||
/* forward declaration */
|
||||
static int bt_activate(pcap_t *);
|
||||
static int bt_read_linux(pcap_t *, int , pcap_handler , u_char *);
|
||||
static int bt_inject_linux(pcap_t *, const void *, size_t);
|
||||
static int bt_inject_linux(pcap_t *, const void *, int);
|
||||
static int bt_setdirection_linux(pcap_t *, pcap_direction_t);
|
||||
static int bt_stats_linux(pcap_t *, struct pcap_stat *);
|
||||
|
||||
|
@ -92,12 +92,20 @@ bt_findalldevs(pcap_if_list_t *devlistp, char *err_str)
|
|||
dev_list = malloc(HCI_MAX_DEV * sizeof(*dev_req) + sizeof(*dev_list));
|
||||
if (!dev_list)
|
||||
{
|
||||
pcap_snprintf(err_str, PCAP_ERRBUF_SIZE, "Can't allocate %zu bytes for Bluetooth device list",
|
||||
snprintf(err_str, PCAP_ERRBUF_SIZE, "Can't allocate %zu bytes for Bluetooth device list",
|
||||
HCI_MAX_DEV * sizeof(*dev_req) + sizeof(*dev_list));
|
||||
ret = -1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* Zero the complete header, which is larger than dev_num because of tail
|
||||
* padding, to silence Valgrind, which overshoots validating that dev_num
|
||||
* has been set.
|
||||
* https://github.com/the-tcpdump-group/libpcap/issues/1083
|
||||
* https://bugs.kde.org/show_bug.cgi?id=448464
|
||||
*/
|
||||
memset(dev_list, 0, sizeof(*dev_list));
|
||||
dev_list->dev_num = HCI_MAX_DEV;
|
||||
|
||||
if (ioctl(sock, HCIGETDEVLIST, (void *) dev_list) < 0)
|
||||
|
@ -112,8 +120,8 @@ bt_findalldevs(pcap_if_list_t *devlistp, char *err_str)
|
|||
for (i = 0; i < dev_list->dev_num; i++, dev_req++) {
|
||||
char dev_name[20], dev_descr[40];
|
||||
|
||||
pcap_snprintf(dev_name, sizeof(dev_name), BT_IFACE"%u", dev_req->dev_id);
|
||||
pcap_snprintf(dev_descr, sizeof(dev_descr), "Bluetooth adapter number %u", i);
|
||||
snprintf(dev_name, sizeof(dev_name), BT_IFACE"%u", dev_req->dev_id);
|
||||
snprintf(dev_descr, sizeof(dev_descr), "Bluetooth adapter number %u", i);
|
||||
|
||||
/*
|
||||
* Bluetooth is a wireless technology.
|
||||
|
@ -173,7 +181,7 @@ bt_create(const char *device, char *ebuf, int *is_ours)
|
|||
/* OK, it's probably ours. */
|
||||
*is_ours = 1;
|
||||
|
||||
p = pcap_create_common(ebuf, sizeof (struct pcap_bt));
|
||||
p = PCAP_CREATE_COMMON(ebuf, struct pcap_bt);
|
||||
if (p == NULL)
|
||||
return (NULL);
|
||||
|
||||
|
@ -194,7 +202,7 @@ bt_activate(pcap_t* handle)
|
|||
/* get bt interface id */
|
||||
if (sscanf(handle->opt.device, BT_IFACE"%d", &dev_id) != 1)
|
||||
{
|
||||
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Can't get Bluetooth device index from %s",
|
||||
handle->opt.device);
|
||||
return PCAP_ERROR;
|
||||
|
@ -341,12 +349,16 @@ bt_read_linux(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_char
|
|||
} while ((ret == -1) && (errno == EINTR));
|
||||
|
||||
if (ret < 0) {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
/* Nonblocking mode, no data */
|
||||
return 0;
|
||||
}
|
||||
pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "Can't receive packet");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pkth.caplen = ret;
|
||||
pkth.caplen = (bpf_u_int32)ret;
|
||||
|
||||
/* get direction and timestamp*/
|
||||
cmsg = CMSG_FIRSTHDR(&msg);
|
||||
|
@ -362,15 +374,27 @@ bt_read_linux(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_char
|
|||
}
|
||||
cmsg = CMSG_NXTHDR(&msg, cmsg);
|
||||
}
|
||||
if ((in && (handle->direction == PCAP_D_OUT)) ||
|
||||
((!in) && (handle->direction == PCAP_D_IN)))
|
||||
return 0;
|
||||
switch (handle->direction) {
|
||||
|
||||
case PCAP_D_IN:
|
||||
if (!in)
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case PCAP_D_OUT:
|
||||
if (in)
|
||||
return 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
bthdr->direction = htonl(in != 0);
|
||||
pkth.caplen+=sizeof(pcap_bluetooth_h4_header);
|
||||
pkth.len = pkth.caplen;
|
||||
if (handle->fcode.bf_insns == NULL ||
|
||||
bpf_filter(handle->fcode.bf_insns, pktd, pkth.len, pkth.caplen)) {
|
||||
pcap_filter(handle->fcode.bf_insns, pktd, pkth.len, pkth.caplen)) {
|
||||
callback(user, &pkth, pktd);
|
||||
return 1;
|
||||
}
|
||||
|
@ -378,9 +402,9 @@ bt_read_linux(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_char
|
|||
}
|
||||
|
||||
static int
|
||||
bt_inject_linux(pcap_t *handle, const void *buf _U_, size_t size _U_)
|
||||
bt_inject_linux(pcap_t *handle, const void *buf _U_, int size _U_)
|
||||
{
|
||||
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Packet injection is not supported on Bluetooth devices");
|
||||
return (-1);
|
||||
}
|
||||
|
@ -418,6 +442,10 @@ bt_stats_linux(pcap_t *handle, struct pcap_stat *stats)
|
|||
static int
|
||||
bt_setdirection_linux(pcap_t *p, pcap_direction_t d)
|
||||
{
|
||||
/*
|
||||
* It's guaranteed, at this point, that d is a valid
|
||||
* direction value.
|
||||
*/
|
||||
p->direction = d;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -49,6 +49,14 @@
|
|||
#define BT_CONTROL_SIZE 32
|
||||
#define INTERFACE_NAME "bluetooth-monitor"
|
||||
|
||||
/*
|
||||
* Private data.
|
||||
* Currently contains nothing.
|
||||
*/
|
||||
struct pcap_bt_monitor {
|
||||
int dummy;
|
||||
};
|
||||
|
||||
/*
|
||||
* Fields and alignment must match the declaration in the Linux kernel 3.4+.
|
||||
* See struct hci_mon_hdr in include/net/bluetooth/hci_mon.h.
|
||||
|
@ -119,12 +127,16 @@ bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_ch
|
|||
} while ((ret == -1) && (errno == EINTR));
|
||||
|
||||
if (ret < 0) {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
/* Nonblocking mode, no data */
|
||||
return 0;
|
||||
}
|
||||
pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "Can't receive packet");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pkth.caplen = ret - sizeof(hdr) + sizeof(pcap_bluetooth_linux_monitor_header);
|
||||
pkth.caplen = (bpf_u_int32)(ret - sizeof(hdr) + sizeof(pcap_bluetooth_linux_monitor_header));
|
||||
pkth.len = pkth.caplen;
|
||||
|
||||
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
|
||||
|
@ -139,7 +151,7 @@ bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_ch
|
|||
bthdr->opcode = htons(hdr.opcode);
|
||||
|
||||
if (handle->fcode.bf_insns == NULL ||
|
||||
bpf_filter(handle->fcode.bf_insns, pktd, pkth.len, pkth.caplen)) {
|
||||
pcap_filter(handle->fcode.bf_insns, pktd, pkth.len, pkth.caplen)) {
|
||||
callback(user, &pkth, pktd);
|
||||
return 1;
|
||||
}
|
||||
|
@ -147,20 +159,13 @@ bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_ch
|
|||
}
|
||||
|
||||
static int
|
||||
bt_monitor_inject(pcap_t *handle, const void *buf _U_, size_t size _U_)
|
||||
bt_monitor_inject(pcap_t *handle, const void *buf _U_, int size _U_)
|
||||
{
|
||||
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Packet injection is not supported yet on Bluetooth monitor devices");
|
||||
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)
|
||||
{
|
||||
|
@ -200,7 +205,7 @@ bt_monitor_activate(pcap_t* handle)
|
|||
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->setdirection_op = NULL; /* Not implemented */
|
||||
handle->set_datalink_op = NULL; /* can't change data link type */
|
||||
handle->getnonblock_op = pcap_getnonblock_fd;
|
||||
handle->setnonblock_op = pcap_setnonblock_fd;
|
||||
|
@ -263,7 +268,7 @@ bt_monitor_create(const char *device, char *ebuf, int *is_ours)
|
|||
}
|
||||
|
||||
*is_ours = 1;
|
||||
p = pcap_create_common(ebuf, 0);
|
||||
p = PCAP_CREATE_COMMON(ebuf, struct pcap_bt_monitor);
|
||||
if (p == NULL)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -28,11 +28,6 @@
|
|||
#include <pcap-types.h>
|
||||
|
||||
#include "pcap-int.h"
|
||||
#include "extract.h"
|
||||
#include "pcap/sll.h"
|
||||
#include "pcap/usb.h"
|
||||
#include "pcap/nflog.h"
|
||||
#include "pcap/can_socketcan.h"
|
||||
|
||||
#include "pcap-common.h"
|
||||
|
||||
|
@ -168,11 +163,20 @@
|
|||
#define LINKTYPE_ENC 109 /* OpenBSD IPSEC enc */
|
||||
|
||||
/*
|
||||
* These three types are reserved for future use.
|
||||
* These two types are reserved for future use.
|
||||
*/
|
||||
#define LINKTYPE_LANE8023 110 /* ATM LANE + 802.3 */
|
||||
#define LINKTYPE_HIPPI 111 /* NetBSD HIPPI */
|
||||
#define LINKTYPE_HDLC 112 /* NetBSD HDLC framing */
|
||||
|
||||
/*
|
||||
* Used for NetBSD DLT_HDLC; from looking at the one driver in NetBSD
|
||||
* that uses it, it's Cisco HDLC, so it's the same as DLT_C_HDLC/
|
||||
* LINKTYPE_C_HDLC, but we define a separate value to avoid some
|
||||
* compatibility issues with programs on NetBSD.
|
||||
*
|
||||
* All code should treat LINKTYPE_NETBSD_HDLC and LINKTYPE_C_HDLC the same.
|
||||
*/
|
||||
#define LINKTYPE_NETBSD_HDLC 112 /* NetBSD HDLC framing */
|
||||
|
||||
#define LINKTYPE_LINUX_SLL 113 /* Linux cooked socket capture */
|
||||
#define LINKTYPE_LTALK 114 /* Apple LocalTalk hardware */
|
||||
|
@ -326,7 +330,7 @@
|
|||
* input packets such as port scans, packets from old lost connections,
|
||||
* etc. to force the connection to stay up).
|
||||
*
|
||||
* The first byte of the PPP header (0xff03) is modified to accomodate
|
||||
* The first byte of the PPP header (0xff03) is modified to accommodate
|
||||
* the direction - 0x00 = IN, 0x01 = OUT.
|
||||
*/
|
||||
#define LINKTYPE_PPP_PPPD 166
|
||||
|
@ -361,7 +365,7 @@
|
|||
/*
|
||||
* Link types requested by Gregor Maier <gregor@endace.com> of Endace
|
||||
* Measurement Systems. They add an ERF header (see
|
||||
* http://www.endace.com/support/EndaceRecordFormat.pdf) in front of
|
||||
* https://www.endace.com/support/EndaceRecordFormat.pdf) in front of
|
||||
* the link-layer header.
|
||||
*/
|
||||
#define LINKTYPE_ERF_ETH 175 /* Ethernet */
|
||||
|
@ -405,7 +409,7 @@
|
|||
* DLT_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
|
||||
* Every frame contains a 32bit A429 label.
|
||||
* More documentation on Arinc 429 can be found at
|
||||
* http://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf
|
||||
* https://web.archive.org/web/20040616233302/https://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf
|
||||
*/
|
||||
#define LINKTYPE_A429 184
|
||||
|
||||
|
@ -495,7 +499,7 @@
|
|||
|
||||
/*
|
||||
* Various link-layer types, with a pseudo-header, for SITA
|
||||
* (http://www.sita.aero/); requested by Fulko Hew (fulko.hew@gmail.com).
|
||||
* (https://www.sita.aero/); requested by Fulko Hew (fulko.hew@gmail.com).
|
||||
*/
|
||||
#define LINKTYPE_SITA 196
|
||||
|
||||
|
@ -558,7 +562,6 @@
|
|||
*/
|
||||
#define LINKTYPE_LAPD 203
|
||||
|
||||
|
||||
/*
|
||||
* PPP, with a one-byte direction pseudo-header prepended - zero means
|
||||
* "received by this host", non-zero (any non-zero value) means "sent by
|
||||
|
@ -608,7 +611,7 @@
|
|||
|
||||
/*
|
||||
* Media Oriented Systems Transport (MOST) bus for multimedia
|
||||
* transport - http://www.mostcooperation.com/ - as requested
|
||||
* transport - https://www.mostcooperation.com/ - as requested
|
||||
* by Hannes Kaelber <hannes.kaelber@x2e.de>.
|
||||
*/
|
||||
#define LINKTYPE_MOST 211
|
||||
|
@ -794,16 +797,16 @@
|
|||
/*
|
||||
* Raw D-Bus:
|
||||
*
|
||||
* http://www.freedesktop.org/wiki/Software/dbus
|
||||
* https://www.freedesktop.org/wiki/Software/dbus
|
||||
*
|
||||
* messages:
|
||||
*
|
||||
* http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages
|
||||
* https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages
|
||||
*
|
||||
* starting with the endianness flag, followed by the message type, etc.,
|
||||
* but without the authentication handshake before the message sequence:
|
||||
*
|
||||
* http://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol
|
||||
* https://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol
|
||||
*
|
||||
* Requested by Martin Vidner <martin@vidner.net>.
|
||||
*/
|
||||
|
@ -821,7 +824,7 @@
|
|||
* DVB-CI (DVB Common Interface for communication between a PC Card
|
||||
* module and a DVB receiver). See
|
||||
*
|
||||
* http://www.kaiser.cx/pcap-dvbci.html
|
||||
* https://www.kaiser.cx/pcap-dvbci.html
|
||||
*
|
||||
* for the specification.
|
||||
*
|
||||
|
@ -945,7 +948,7 @@
|
|||
*
|
||||
* Requested by Chris Bontje <chris_bontje@selinc.com>.
|
||||
*/
|
||||
#define DLT_RTAC_SERIAL 250
|
||||
#define LINKTYPE_RTAC_SERIAL 250
|
||||
|
||||
/*
|
||||
* Bluetooth Low Energy air interface link-layer packets.
|
||||
|
@ -957,13 +960,15 @@
|
|||
/*
|
||||
* Link-layer header type for upper-protocol layer PDU saves from wireshark.
|
||||
*
|
||||
* the actual contents are determined by two TAGs stored with each
|
||||
* packet:
|
||||
* EXP_PDU_TAG_LINKTYPE the link type (LINKTYPE_ value) of the
|
||||
* original packet.
|
||||
* the actual contents are determined by two TAGs, one or more of
|
||||
* which is stored with each packet:
|
||||
*
|
||||
* EXP_PDU_TAG_PROTO_NAME the name of the wireshark dissector
|
||||
* that can make sense of the data stored.
|
||||
* EXP_PDU_TAG_DISSECTOR_NAME the name of the Wireshark dissector
|
||||
* that can make sense of the data stored.
|
||||
*
|
||||
* EXP_PDU_TAG_HEUR_DISSECTOR_NAME the name of the Wireshark heuristic
|
||||
* dissector that can make sense of the
|
||||
* data stored.
|
||||
*/
|
||||
#define LINKTYPE_WIRESHARK_UPPER_PDU 252
|
||||
|
||||
|
@ -1079,9 +1084,9 @@
|
|||
|
||||
/*
|
||||
* per: Stefanha at gmail.com for
|
||||
* http://lists.sandelman.ca/pipermail/tcpdump-workers/2017-May/000772.html
|
||||
* https://lists.sandelman.ca/pipermail/tcpdump-workers/2017-May/000772.html
|
||||
* and: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/vsockmon.h
|
||||
* for: http://qemu-project.org/Features/VirtioVsock
|
||||
* for: https://qemu-project.org/Features/VirtioVsock
|
||||
*/
|
||||
#define LINKTYPE_VSOCK 271
|
||||
|
||||
|
@ -1093,7 +1098,7 @@
|
|||
/*
|
||||
* Excentis DOCSIS 3.1 RF sniffer (XRA-31)
|
||||
* per: bruno.verstuyft at excentis.com
|
||||
* http://www.xra31.com/xra-header
|
||||
* https://www.xra31.com/xra-header
|
||||
*/
|
||||
#define LINKTYPE_DOCSIS31_XRA31 273
|
||||
|
||||
|
@ -1105,7 +1110,7 @@
|
|||
|
||||
/*
|
||||
* DisplayPort AUX channel monitoring data as specified by VESA
|
||||
* DisplayPort(DP) Standard preceeded by a pseudo-header.
|
||||
* DisplayPort(DP) Standard preceded by a pseudo-header.
|
||||
* per dirk.eibach at gdsys.cc
|
||||
*/
|
||||
#define LINKTYPE_DISPLAYPORT_AUX 275
|
||||
|
@ -1115,7 +1120,84 @@
|
|||
*/
|
||||
#define LINKTYPE_LINUX_SLL2 276
|
||||
|
||||
#define LINKTYPE_MATCHING_MAX 276 /* highest value in the "matching" range */
|
||||
/*
|
||||
* Sercos Monitor, per Manuel Jacob <manuel.jacob at steinbeis-stg.de>
|
||||
*/
|
||||
#define LINKTYPE_SERCOS_MONITOR 277
|
||||
|
||||
/*
|
||||
* OpenVizsla http://openvizsla.org is open source USB analyzer hardware.
|
||||
* It consists of FPGA with attached USB phy and FTDI chip for streaming
|
||||
* the data to the host PC.
|
||||
*
|
||||
* Current OpenVizsla data encapsulation format is described here:
|
||||
* https://github.com/matwey/libopenvizsla/wiki/OpenVizsla-protocol-description
|
||||
*
|
||||
*/
|
||||
#define LINKTYPE_OPENVIZSLA 278
|
||||
|
||||
/*
|
||||
* The Elektrobit High Speed Capture and Replay (EBHSCR) protocol is produced
|
||||
* by a PCIe Card for interfacing high speed automotive interfaces.
|
||||
*
|
||||
* The specification for this frame format can be found at:
|
||||
* https://www.elektrobit.com/ebhscr
|
||||
*
|
||||
* for Guenter.Ebermann at elektrobit.com
|
||||
*
|
||||
*/
|
||||
#define LINKTYPE_EBHSCR 279
|
||||
|
||||
/*
|
||||
* The https://fd.io vpp graph dispatch tracer produces pcap trace files
|
||||
* in the format documented here:
|
||||
* https://fdio-vpp.readthedocs.io/en/latest/gettingstarted/developers/vnet.html#graph-dispatcher-pcap-tracing
|
||||
*/
|
||||
#define LINKTYPE_VPP_DISPATCH 280
|
||||
|
||||
/*
|
||||
* Broadcom Ethernet switches (ROBO switch) 4 bytes proprietary tagging format.
|
||||
*/
|
||||
#define LINKTYPE_DSA_TAG_BRCM 281
|
||||
#define LINKTYPE_DSA_TAG_BRCM_PREPEND 282
|
||||
|
||||
/*
|
||||
* IEEE 802.15.4 with pseudo-header and optional meta-data TLVs, PHY payload
|
||||
* exactly as it appears in the spec (no padding, no nothing), and FCS if
|
||||
* specified by FCS Type TLV; requested by James Ko <jck@exegin.com>.
|
||||
* Specification at https://github.com/jkcko/ieee802.15.4-tap
|
||||
*/
|
||||
#define LINKTYPE_IEEE802_15_4_TAP 283
|
||||
|
||||
/*
|
||||
* Marvell (Ethertype) Distributed Switch Architecture proprietary tagging format.
|
||||
*/
|
||||
#define LINKTYPE_DSA_TAG_DSA 284
|
||||
#define LINKTYPE_DSA_TAG_EDSA 285
|
||||
|
||||
/*
|
||||
* Payload of lawful intercept packets using the ELEE protocol;
|
||||
* https://socket.hr/draft-dfranusic-opsawg-elee-00.xml
|
||||
* https://xml2rfc.tools.ietf.org/cgi-bin/xml2rfc.cgi?url=https://socket.hr/draft-dfranusic-opsawg-elee-00.xml&modeAsFormat=html/ascii
|
||||
*/
|
||||
#define LINKTYPE_ELEE 286
|
||||
|
||||
/*
|
||||
* Serial frames transmitted between a host and a Z-Wave chip.
|
||||
*/
|
||||
#define LINKTYPE_Z_WAVE_SERIAL 287
|
||||
|
||||
/*
|
||||
* USB 2.0, 1.1, and 1.0 packets as transmitted over the cable.
|
||||
*/
|
||||
#define LINKTYPE_USB_2_0 288
|
||||
|
||||
/*
|
||||
* ATSC Link-Layer Protocol (A/330) packets.
|
||||
*/
|
||||
#define LINKTYPE_ATSC_ALP 289
|
||||
|
||||
#define LINKTYPE_MATCHING_MAX 289 /* highest value in the "matching" range */
|
||||
|
||||
/*
|
||||
* The DLT_ and LINKTYPE_ values in the "matching" range should be the
|
||||
|
@ -1144,7 +1226,7 @@ static struct linktype_map {
|
|||
{ DLT_ARCNET, LINKTYPE_ARCNET_BSD },
|
||||
{ DLT_SLIP, LINKTYPE_SLIP },
|
||||
{ DLT_PPP, LINKTYPE_PPP },
|
||||
{ DLT_FDDI, LINKTYPE_FDDI },
|
||||
{ DLT_FDDI, LINKTYPE_FDDI },
|
||||
{ DLT_SYMANTEC_FIREWALL, LINKTYPE_SYMANTEC_FIREWALL },
|
||||
|
||||
/*
|
||||
|
@ -1162,6 +1244,7 @@ static struct linktype_map {
|
|||
{ DLT_RAW, LINKTYPE_RAW },
|
||||
{ DLT_SLIP_BSDOS, LINKTYPE_SLIP_BSDOS },
|
||||
{ DLT_PPP_BSDOS, LINKTYPE_PPP_BSDOS },
|
||||
{ DLT_HDLC, LINKTYPE_NETBSD_HDLC },
|
||||
|
||||
/* BSD/OS Cisco HDLC */
|
||||
{ DLT_C_HDLC, LINKTYPE_C_HDLC },
|
||||
|
@ -1248,11 +1331,20 @@ linktype_to_dlt(int linktype)
|
|||
return (DLT_PKTAP);
|
||||
|
||||
/*
|
||||
* For all other values in the matching range, the LINKTYPE
|
||||
* value is the same as the DLT value.
|
||||
* For all other values in the matching range, except for
|
||||
* LINKTYPE_ATM_CLIP, the LINKTYPE value is the same as
|
||||
* the DLT value.
|
||||
*
|
||||
* LINKTYPE_ATM_CLIP is a special case. DLT_ATM_CLIP is
|
||||
* not on all platforms, but, so far, there don't appear
|
||||
* to be any platforms that define it as anything other
|
||||
* than 19; we define LINKTYPE_ATM_CLIP as something
|
||||
* other than 19, just in case. That value is in the
|
||||
* matching range, so we have to check for it.
|
||||
*/
|
||||
if (linktype >= LINKTYPE_MATCHING_MIN &&
|
||||
linktype <= LINKTYPE_MATCHING_MAX)
|
||||
linktype <= LINKTYPE_MATCHING_MAX &&
|
||||
linktype != LINKTYPE_ATM_CLIP)
|
||||
return (linktype);
|
||||
|
||||
/*
|
||||
|
@ -1265,7 +1357,7 @@ linktype_to_dlt(int linktype)
|
|||
|
||||
/*
|
||||
* If we don't have an entry for this LINKTYPE, return
|
||||
* the link type value; it may be a DLT from an older
|
||||
* the link type value; it may be a DLT from an newer
|
||||
* version of libpcap.
|
||||
*/
|
||||
return linktype;
|
||||
|
@ -1280,6 +1372,10 @@ linktype_to_dlt(int linktype)
|
|||
*
|
||||
* https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages
|
||||
*
|
||||
* For DLT_EBHSCR, the maximum is 8MiB, as per
|
||||
*
|
||||
* https://www.elektrobit.com/ebhscr
|
||||
*
|
||||
* For DLT_USBPCAP, the maximum is 1MiB, as per
|
||||
*
|
||||
* https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=15985
|
||||
|
@ -1292,6 +1388,9 @@ max_snaplen_for_dlt(int dlt)
|
|||
case DLT_DBUS:
|
||||
return 128*1024*1024;
|
||||
|
||||
case DLT_EBHSCR:
|
||||
return 8*1024*1024;
|
||||
|
||||
case DLT_USBPCAP:
|
||||
return 1024*1024;
|
||||
|
||||
|
@ -1299,286 +1398,3 @@ max_snaplen_for_dlt(int dlt)
|
|||
return MAXIMUM_SNAPLEN;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* DLT_LINUX_SLL packets with a protocol type of LINUX_SLL_P_CAN or
|
||||
* LINUX_SLL_P_CANFD have SocketCAN headers in front of the payload,
|
||||
* with the CAN ID being in host byte order.
|
||||
*
|
||||
* When reading a DLT_LINUX_SLL capture file, we need to check for those
|
||||
* packets and convert the CAN ID from the byte order of the host that
|
||||
* wrote the file to this host's byte order.
|
||||
*/
|
||||
static void
|
||||
swap_linux_sll_header(const struct pcap_pkthdr *hdr, u_char *buf)
|
||||
{
|
||||
u_int caplen = hdr->caplen;
|
||||
u_int length = hdr->len;
|
||||
struct sll_header *shdr = (struct sll_header *)buf;
|
||||
uint16_t protocol;
|
||||
pcap_can_socketcan_hdr *chdr;
|
||||
|
||||
if (caplen < (u_int) sizeof(struct sll_header) ||
|
||||
length < (u_int) sizeof(struct sll_header)) {
|
||||
/* Not enough data to have the protocol field */
|
||||
return;
|
||||
}
|
||||
|
||||
protocol = EXTRACT_16BITS(&shdr->sll_protocol);
|
||||
if (protocol != LINUX_SLL_P_CAN && protocol != LINUX_SLL_P_CANFD)
|
||||
return;
|
||||
|
||||
/*
|
||||
* SocketCAN packet; fix up the packet's header.
|
||||
*/
|
||||
chdr = (pcap_can_socketcan_hdr *)(buf + sizeof(struct sll_header));
|
||||
if (caplen < (u_int) sizeof(struct sll_header) + sizeof(chdr->can_id) ||
|
||||
length < (u_int) sizeof(struct sll_header) + sizeof(chdr->can_id)) {
|
||||
/* Not enough data to have the CAN ID */
|
||||
return;
|
||||
}
|
||||
chdr->can_id = SWAPLONG(chdr->can_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* The DLT_USB_LINUX and DLT_USB_LINUX_MMAPPED headers are in host
|
||||
* byte order when capturing (it's supplied directly from a
|
||||
* memory-mapped buffer shared by the kernel).
|
||||
*
|
||||
* When reading a DLT_USB_LINUX or DLT_USB_LINUX_MMAPPED capture file,
|
||||
* we need to convert it from the byte order of the host that wrote
|
||||
* the file to this host's byte order.
|
||||
*/
|
||||
static void
|
||||
swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf,
|
||||
int header_len_64_bytes)
|
||||
{
|
||||
pcap_usb_header_mmapped *uhdr = (pcap_usb_header_mmapped *)buf;
|
||||
bpf_u_int32 offset = 0;
|
||||
|
||||
/*
|
||||
* "offset" is the offset *past* the field we're swapping;
|
||||
* we skip the field *before* checking to make sure
|
||||
* the captured data length includes the entire field.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The URB id is a totally opaque value; do we really need to
|
||||
* convert it to the reading host's byte order???
|
||||
*/
|
||||
offset += 8; /* skip past id */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->id = SWAPLL(uhdr->id);
|
||||
|
||||
offset += 4; /* skip past various 1-byte fields */
|
||||
|
||||
offset += 2; /* skip past bus_id */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->bus_id = SWAPSHORT(uhdr->bus_id);
|
||||
|
||||
offset += 2; /* skip past various 1-byte fields */
|
||||
|
||||
offset += 8; /* skip past ts_sec */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->ts_sec = SWAPLL(uhdr->ts_sec);
|
||||
|
||||
offset += 4; /* skip past ts_usec */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->ts_usec = SWAPLONG(uhdr->ts_usec);
|
||||
|
||||
offset += 4; /* skip past status */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->status = SWAPLONG(uhdr->status);
|
||||
|
||||
offset += 4; /* skip past urb_len */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->urb_len = SWAPLONG(uhdr->urb_len);
|
||||
|
||||
offset += 4; /* skip past data_len */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->data_len = SWAPLONG(uhdr->data_len);
|
||||
|
||||
if (uhdr->transfer_type == URB_ISOCHRONOUS) {
|
||||
offset += 4; /* skip past s.iso.error_count */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->s.iso.error_count = SWAPLONG(uhdr->s.iso.error_count);
|
||||
|
||||
offset += 4; /* skip past s.iso.numdesc */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->s.iso.numdesc = SWAPLONG(uhdr->s.iso.numdesc);
|
||||
} else
|
||||
offset += 8; /* skip USB setup header */
|
||||
|
||||
/*
|
||||
* With the old header, there are no isochronous descriptors
|
||||
* after the header.
|
||||
*
|
||||
* With the new header, the actual number of descriptors in
|
||||
* the header is not s.iso.numdesc, it's ndesc - only the
|
||||
* first N descriptors, for some value of N, are put into
|
||||
* the header, and ndesc is set to the actual number copied.
|
||||
* In addition, if s.iso.numdesc is negative, no descriptors
|
||||
* are captured, and ndesc is set to 0.
|
||||
*/
|
||||
if (header_len_64_bytes) {
|
||||
/*
|
||||
* This is either the "version 1" header, with
|
||||
* 16 bytes of additional fields at the end, or
|
||||
* a "version 0" header from a memory-mapped
|
||||
* capture, with 16 bytes of zeroed-out padding
|
||||
* at the end. Byte swap them as if this were
|
||||
* a "version 1" header.
|
||||
*/
|
||||
offset += 4; /* skip past interval */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->interval = SWAPLONG(uhdr->interval);
|
||||
|
||||
offset += 4; /* skip past start_frame */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->start_frame = SWAPLONG(uhdr->start_frame);
|
||||
|
||||
offset += 4; /* skip past xfer_flags */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->xfer_flags = SWAPLONG(uhdr->xfer_flags);
|
||||
|
||||
offset += 4; /* skip past ndesc */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->ndesc = SWAPLONG(uhdr->ndesc);
|
||||
|
||||
if (uhdr->transfer_type == URB_ISOCHRONOUS) {
|
||||
/* swap the values in struct linux_usb_isodesc */
|
||||
usb_isodesc *pisodesc;
|
||||
uint32_t i;
|
||||
|
||||
pisodesc = (usb_isodesc *)(void *)(buf+offset);
|
||||
for (i = 0; i < uhdr->ndesc; i++) {
|
||||
offset += 4; /* skip past status */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
pisodesc->status = SWAPLONG(pisodesc->status);
|
||||
|
||||
offset += 4; /* skip past offset */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
pisodesc->offset = SWAPLONG(pisodesc->offset);
|
||||
|
||||
offset += 4; /* skip past len */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
pisodesc->len = SWAPLONG(pisodesc->len);
|
||||
|
||||
offset += 4; /* skip past padding */
|
||||
|
||||
pisodesc++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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;
|
||||
uint16_t size;
|
||||
|
||||
if (caplen < (u_int) sizeof(nflog_hdr_t) ||
|
||||
length < (u_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_LINUX_SLL:
|
||||
swap_linux_sll_header(hdr, data);
|
||||
break;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,33 +21,8 @@
|
|||
* pcap-common.h - common code for pcap and pcapng files
|
||||
*/
|
||||
|
||||
/*
|
||||
* We use the "receiver-makes-right" approach to byte order,
|
||||
* because time is at a premium when we are writing the file.
|
||||
* In other words, the pcap_file_header and pcap_pkthdr,
|
||||
* records are written in host byte order.
|
||||
* Note that the bytes of packet data are written out in the order in
|
||||
* which they were received, so multi-byte fields in packets are not
|
||||
* written in host byte order, they're written in whatever order the
|
||||
* sending machine put them in.
|
||||
*
|
||||
* ntoh[ls] aren't sufficient because we might need to swap on a big-endian
|
||||
* machine (if the file was written in little-end order).
|
||||
*/
|
||||
#define SWAPLONG(y) \
|
||||
(((((u_int)(y))&0xff)<<24) | \
|
||||
((((u_int)(y))&0xff00)<<8) | \
|
||||
((((u_int)(y))&0xff0000)>>8) | \
|
||||
((((u_int)(y))>>24)&0xff))
|
||||
#define SWAPSHORT(y) \
|
||||
((u_short)(((((u_int)(y))&0xff)<<8) | \
|
||||
((((u_int)(y))&0xff00)>>8)))
|
||||
|
||||
extern int dlt_to_linktype(int dlt);
|
||||
|
||||
extern int linktype_to_dlt(int linktype);
|
||||
|
||||
extern void swap_pseudo_headers(int linktype, struct pcap_pkthdr *hdr,
|
||||
u_char *data);
|
||||
|
||||
extern u_int max_snaplen_for_dlt(int dlt);
|
||||
|
|
|
@ -68,5 +68,5 @@ dynamically-linked version of libpcap; the
|
|||
.B \-\-static
|
||||
flag causes it to write flags appropriate for compiling with a
|
||||
statically-linked version of libpcap.
|
||||
.SH "SEE ALSO"
|
||||
pcap(3PCAP)
|
||||
.SH SEE ALSO
|
||||
.BR pcap (3PCAP)
|
||||
|
|
|
@ -12,13 +12,15 @@ prefix="@prefix@"
|
|||
exec_prefix="@exec_prefix@"
|
||||
includedir="@includedir@"
|
||||
libdir="@libdir@"
|
||||
V_RPATH_OPT="@V_RPATH_OPT@"
|
||||
LIBS="@LIBS@"
|
||||
PACKAGE_NAME="@PACKAGE_NAME@"
|
||||
LIBS_STATIC="@LIBS_STATIC@"
|
||||
VERSION="@PACKAGE_VERSION@"
|
||||
|
||||
static=0
|
||||
static_pcap_only=0
|
||||
show_cflags=0
|
||||
show_libs=0
|
||||
show_additional_libs=0
|
||||
while [ "$#" != 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
|
@ -27,6 +29,10 @@ do
|
|||
static=1
|
||||
;;
|
||||
|
||||
--static-pcap-only)
|
||||
static_pcap_only=1
|
||||
;;
|
||||
|
||||
--cflags)
|
||||
show_cflags=1
|
||||
;;
|
||||
|
@ -38,49 +44,107 @@ do
|
|||
--additional-libs)
|
||||
show_additional_libs=1
|
||||
;;
|
||||
|
||||
-h|--help)
|
||||
echo "Usage: pcap-config [ --help ] [--version] [ --static | --static-pcap-only ] [ --libs | --additional-libs ]"
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--version)
|
||||
echo "$VERSION"
|
||||
exit 0
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "pcap-config: Invalid command-line option $1 specified" 1>&2
|
||||
echo "Usage: pcap-config [ --help ] [ --static | --static-pcap-only ] [ --libs | --additional-libs ]" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
if [ "$V_RPATH_OPT" != "" ]
|
||||
|
||||
#
|
||||
# If we aren't installing in /usr, then provide a -L flag to let build
|
||||
# processes find our library.
|
||||
#
|
||||
# (We must check $prefix, as $libdir isn't necessarily /usr/lib in this
|
||||
# case - for example, Linux distributions for 64-bit platforms that
|
||||
# also provide support for binaries for a 32-bit version of the
|
||||
# platform may put the 64-bit libraries, the 32-bit libraries, or both
|
||||
# in directories other than /usr/lib.)
|
||||
#
|
||||
if [ "$prefix" != "/usr" ]
|
||||
then
|
||||
#
|
||||
# If libdir isn't /usr/lib, add it to the run-time linker path.
|
||||
#
|
||||
if [ "$libdir" != "/usr/lib" ]
|
||||
then
|
||||
RPATH=$V_RPATH_OPT$libdir
|
||||
fi
|
||||
LPATH=-L$libdir
|
||||
fi
|
||||
if [ "$static" = 1 ]
|
||||
then
|
||||
#
|
||||
# Include LIBS so that the flags include libraries containing
|
||||
# routines that libpcap uses.
|
||||
# Include LIBS_STATIC so that the flags include libraries
|
||||
# containing routines that libpcap uses, and libraries
|
||||
# containing routines those libraries use, etc., so that a
|
||||
# completely statically linked program - i.e., linked only with
|
||||
# static libraries - will be linked with all necessary
|
||||
# libraries.
|
||||
#
|
||||
if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
|
||||
then
|
||||
echo "-I$includedir -L$libdir -lpcap $LIBS"
|
||||
echo "-I$includedir $LPATH -l@PACKAGE_NAME@ $LIBS_STATIC"
|
||||
elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
|
||||
then
|
||||
echo "-I$includedir -L$libdir $LIBS"
|
||||
echo "-I$includedir $LPATH $LIBS_STATIC"
|
||||
elif [ "$show_cflags" = 1 ]
|
||||
then
|
||||
echo "-I$includedir"
|
||||
elif [ "$show_libs" = 1 ]
|
||||
then
|
||||
echo "-L$libdir -lpcap $LIBS"
|
||||
echo "$LPATH -l@PACKAGE_NAME@ $LIBS_STATIC"
|
||||
elif [ "$show_additional_libs" = 1 ]
|
||||
then
|
||||
echo "$LIBS_STATIC"
|
||||
fi
|
||||
elif [ "$static_pcap_only" = 1 ]
|
||||
then
|
||||
#
|
||||
# Include LIBS so that the flags include libraries
|
||||
# containing routines that libpcap uses, but not the libraries
|
||||
# on which libpcap depends, so that an otherwise
|
||||
# dynamically-linked program, linked statically only with
|
||||
# libpcap - i.e., linked with a static libpcap and dynamic
|
||||
# versions of other libraries - will be linked with all
|
||||
# necessary libraries.
|
||||
#
|
||||
if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
|
||||
then
|
||||
echo "-I$includedir $LPATH -l@PACKAGE_NAME@ $LIBS"
|
||||
elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
|
||||
then
|
||||
echo "-I$includedir $LPATH $LIBS"
|
||||
elif [ "$show_cflags" = 1 ]
|
||||
then
|
||||
echo "-I$includedir"
|
||||
elif [ "$show_libs" = 1 ]
|
||||
then
|
||||
echo "$LPATH -l@PACKAGE_NAME@ $LIBS"
|
||||
elif [ "$show_additional_libs" = 1 ]
|
||||
then
|
||||
echo "$LIBS"
|
||||
fi
|
||||
else
|
||||
#
|
||||
# Omit LIBS - libpcap is assumed to be linked with those
|
||||
# libraries, so there's no need to do so explicitly.
|
||||
# Don't included LIBS or LIBS_STATIC, for building a program
|
||||
# with a dynamic libpcap; libpcap, being a dynamic library, will
|
||||
# cause all of its dynamic-library dependencies to be pulled in
|
||||
# at run time.
|
||||
#
|
||||
# Do, however, include RPATH, to make sure that, on platforms
|
||||
# that require this, programs built with this version of
|
||||
# libpcap can find it at run time.
|
||||
#
|
||||
if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
|
||||
then
|
||||
echo "-I$includedir -L$libdir $RPATH -l$PACKAGE_NAME"
|
||||
echo "-I$includedir $LPATH @RPATH@ -l@PACKAGE_NAME@"
|
||||
elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
|
||||
then
|
||||
echo "-I$includedir"
|
||||
|
@ -89,6 +153,6 @@ else
|
|||
echo "-I$includedir"
|
||||
elif [ "$show_libs" = 1 ]
|
||||
then
|
||||
echo "-L$libdir $RPATH -l$PACKAGE_NAME"
|
||||
echo "$LPATH @RPATH@ -l@PACKAGE_NAME@"
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "pcap-int.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/socket.h>
|
||||
|
@ -208,14 +207,13 @@ static unsigned char TempPkt[MAX_DAG_PACKET];
|
|||
#define dag_size_t uint32_t
|
||||
#endif
|
||||
|
||||
static int dag_setfilter(pcap_t *p, struct bpf_program *fp);
|
||||
static int dag_stats(pcap_t *p, struct pcap_stat *ps);
|
||||
static int dag_set_datalink(pcap_t *p, int dlt);
|
||||
static int dag_get_datalink(pcap_t *p);
|
||||
static int dag_setnonblock(pcap_t *p, int nonblock);
|
||||
|
||||
static void
|
||||
delete_pcap_dag(pcap_t *p)
|
||||
delete_pcap_dag(const pcap_t *p)
|
||||
{
|
||||
pcap_dag_node_t *curr = NULL, *prev = NULL;
|
||||
|
||||
|
@ -301,7 +299,7 @@ new_pcap_dag(pcap_t *p)
|
|||
}
|
||||
|
||||
static unsigned int
|
||||
dag_erf_ext_header_count(uint8_t * erf, size_t len)
|
||||
dag_erf_ext_header_count(const uint8_t *erf, size_t len)
|
||||
{
|
||||
uint32_t hdr_num = 0;
|
||||
uint8_t hdr_type;
|
||||
|
@ -335,7 +333,7 @@ dag_erf_ext_header_count(uint8_t * erf, size_t len)
|
|||
/*
|
||||
* Read at most max_packets from the capture stream and call the callback
|
||||
* for each of them. Returns the number of packets handled, -1 if an
|
||||
* error occured, or -2 if we were told to break out of the loop.
|
||||
* error occurred, or -2 if we were told to break out of the loop.
|
||||
*/
|
||||
static int
|
||||
dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||
|
@ -393,7 +391,12 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
|||
|
||||
}
|
||||
|
||||
/* Process the packets. */
|
||||
/*
|
||||
* Process the packets.
|
||||
*
|
||||
* This assumes that a single buffer of packets will have
|
||||
* <= INT_MAX packets, so the packet count doesn't overflow.
|
||||
*/
|
||||
while (pd->dag_mem_top - pd->dag_mem_bottom >= dag_record_size) {
|
||||
|
||||
unsigned short packet_len = 0;
|
||||
|
@ -421,7 +424,8 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
|||
rlen = ntohs(header->rlen);
|
||||
if (rlen < dag_record_size)
|
||||
{
|
||||
strncpy(p->errbuf, "dag_read: record too small", PCAP_ERRBUF_SIZE);
|
||||
pcap_strlcpy(p->errbuf, "dag_read: record too small",
|
||||
PCAP_ERRBUF_SIZE);
|
||||
return -1;
|
||||
}
|
||||
pd->dag_mem_bottom += rlen;
|
||||
|
@ -664,7 +668,7 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
|||
caplen = p->snapshot;
|
||||
|
||||
/* Run the packet filter if there is one. */
|
||||
if ((p->fcode.bf_insns == NULL) || bpf_filter(p->fcode.bf_insns, dp, packet_len, caplen)) {
|
||||
if ((p->fcode.bf_insns == NULL) || pcap_filter(p->fcode.bf_insns, dp, packet_len, caplen)) {
|
||||
|
||||
/* convert between timestamp formats */
|
||||
register unsigned long long ts;
|
||||
|
@ -718,7 +722,7 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
|||
}
|
||||
|
||||
static int
|
||||
dag_inject(pcap_t *p, const void *buf _U_, size_t size _U_)
|
||||
dag_inject(pcap_t *p, const void *buf _U_, int size _U_)
|
||||
{
|
||||
pcap_strlcpy(p->errbuf, "Sending packets isn't supported on DAG cards",
|
||||
PCAP_ERRBUF_SIZE);
|
||||
|
@ -732,7 +736,7 @@ dag_inject(pcap_t *p, const void *buf _U_, size_t size _U_)
|
|||
* API polling parameters.
|
||||
*
|
||||
* snaplen is now also ignored, until we get per-stream slen support. Set
|
||||
* slen with approprite DAG tool BEFORE pcap_activate().
|
||||
* slen with appropriate DAG tool BEFORE pcap_activate().
|
||||
*
|
||||
* See also pcap(3).
|
||||
*/
|
||||
|
@ -750,7 +754,7 @@ static int dag_activate(pcap_t* p)
|
|||
struct timeval poll;
|
||||
|
||||
if (device == NULL) {
|
||||
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "device is NULL");
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "device is NULL");
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
|
||||
|
@ -780,7 +784,7 @@ static int dag_activate(pcap_t* p)
|
|||
|
||||
if (pd->dag_stream%2) {
|
||||
ret = PCAP_ERROR;
|
||||
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "dag_parse_name: tx (even numbered) streams not supported for capture");
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "dag_parse_name: tx (even numbered) streams not supported for capture");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -789,14 +793,23 @@ static int dag_activate(pcap_t* p)
|
|||
/*
|
||||
* XXX - does this reliably set errno?
|
||||
*/
|
||||
if (errno == ENOENT)
|
||||
if (errno == ENOENT) {
|
||||
/*
|
||||
* There's nothing more to say, so clear
|
||||
* the error message.
|
||||
*/
|
||||
ret = PCAP_ERROR_NO_SUCH_DEVICE;
|
||||
else if (errno == EPERM || errno == EACCES)
|
||||
p->errbuf[0] = '\0';
|
||||
} else if (errno == EPERM || errno == EACCES) {
|
||||
ret = PCAP_ERROR_PERM_DENIED;
|
||||
else
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Attempt to open %s failed with %s - additional privileges may be required",
|
||||
device, (errno == EPERM) ? "EPERM" : "EACCES");
|
||||
} else {
|
||||
ret = PCAP_ERROR;
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "dag_config_init %s", device);
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "dag_config_init %s", device);
|
||||
}
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -936,7 +949,7 @@ static int dag_activate(pcap_t* p)
|
|||
pd->dag_fcs_bits = n;
|
||||
} else {
|
||||
ret = PCAP_ERROR;
|
||||
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"pcap_activate %s: bad ERF_FCS_BITS value (%d) in environment", device, n);
|
||||
goto failstop;
|
||||
}
|
||||
|
@ -946,7 +959,7 @@ static int dag_activate(pcap_t* p)
|
|||
* Did the user request that they not be stripped?
|
||||
*/
|
||||
if ((s = getenv("ERF_DONT_STRIP_FCS")) != NULL) {
|
||||
/* Yes. Note the number of bytes that will be
|
||||
/* Yes. Note the number of 16-bit words that will be
|
||||
supplied. */
|
||||
p->linktype_ext = LT_FCS_DATALINK_EXT(pd->dag_fcs_bits/16);
|
||||
|
||||
|
@ -983,7 +996,7 @@ static int dag_activate(pcap_t* p)
|
|||
|
||||
p->read_op = dag_read;
|
||||
p->inject_op = dag_inject;
|
||||
p->setfilter_op = dag_setfilter;
|
||||
p->setfilter_op = install_bpf_program;
|
||||
p->setdirection_op = NULL; /* Not implemented.*/
|
||||
p->set_datalink_op = dag_set_datalink;
|
||||
p->getnonblock_op = pcap_getnonblock_fd;
|
||||
|
@ -1072,7 +1085,7 @@ pcap_t *dag_create(const char *device, char *ebuf, int *is_ours)
|
|||
/* OK, it's probably ours. */
|
||||
*is_ours = 1;
|
||||
|
||||
p = pcap_create_common(ebuf, sizeof (struct pcap_dag));
|
||||
p = PCAP_CREATE_COMMON(ebuf, struct pcap_dag);
|
||||
if (p == NULL)
|
||||
return NULL;
|
||||
|
||||
|
@ -1085,7 +1098,6 @@ pcap_t *dag_create(const char *device, char *ebuf, int *is_ours)
|
|||
* XXX Our native precision is 2^-32s, but libpcap doesn't support
|
||||
* power of two precisions yet. We can convert to either MICRO or NANO.
|
||||
*/
|
||||
p->tstamp_precision_count = 2;
|
||||
p->tstamp_precision_list = malloc(2 * sizeof(u_int));
|
||||
if (p->tstamp_precision_list == NULL) {
|
||||
pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
|
||||
|
@ -1095,6 +1107,7 @@ pcap_t *dag_create(const char *device, char *ebuf, int *is_ours)
|
|||
}
|
||||
p->tstamp_precision_list[0] = PCAP_TSTAMP_PRECISION_MICRO;
|
||||
p->tstamp_precision_list[1] = PCAP_TSTAMP_PRECISION_NANO;
|
||||
p->tstamp_precision_count = 2;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -1115,10 +1128,10 @@ dag_stats(pcap_t *p, struct pcap_stat *ps) {
|
|||
/* Note this counter is cleared at start of capture and will wrap at UINT_MAX.
|
||||
* The application is responsible for polling ps_drop frequently enough
|
||||
* to detect each wrap and integrate total drop with a wider counter */
|
||||
if ((dag_error = dag_config_get_uint32_attribute_ex(pd->dag_ref, pd->drop_attr, &stream_drop) == kDagErrNone)) {
|
||||
if ((dag_error = dag_config_get_uint32_attribute_ex(pd->dag_ref, pd->drop_attr, &stream_drop)) == kDagErrNone) {
|
||||
pd->stat.ps_drop = stream_drop;
|
||||
} else {
|
||||
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "reading stream drop attribute: %s",
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "reading stream drop attribute: %s",
|
||||
dag_config_strerror(dag_error));
|
||||
return -1;
|
||||
}
|
||||
|
@ -1146,10 +1159,10 @@ dag_findalldevs(pcap_if_list_t *devlistp, char *errbuf)
|
|||
|
||||
/* Try all the DAGs 0-DAG_MAX_BOARDS */
|
||||
for (c = 0; c < DAG_MAX_BOARDS; c++) {
|
||||
pcap_snprintf(name, 12, "dag%d", c);
|
||||
snprintf(name, 12, "dag%d", c);
|
||||
if (-1 == dag_parse_name(name, dagname, DAGNAME_BUFSIZE, &dagstream))
|
||||
{
|
||||
(void) pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
(void) snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"dag: device name %s can't be parsed", name);
|
||||
return (-1);
|
||||
}
|
||||
|
@ -1177,7 +1190,7 @@ dag_findalldevs(pcap_if_list_t *devlistp, char *errbuf)
|
|||
if (0 == dag_attach_stream64(dagfd, stream, 0, 0)) {
|
||||
dag_detach_stream(dagfd, stream);
|
||||
|
||||
pcap_snprintf(name, 10, "dag%d:%d", c, stream);
|
||||
snprintf(name, 10, "dag%d:%d", c, stream);
|
||||
if (add_dev(devlistp, name, 0, description, errbuf) == NULL) {
|
||||
/*
|
||||
* Failure.
|
||||
|
@ -1198,30 +1211,6 @@ dag_findalldevs(pcap_if_list_t *devlistp, char *errbuf)
|
|||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Installs the given bpf filter program in the given pcap structure. There is
|
||||
* no attempt to store the filter in kernel memory as that is not supported
|
||||
* with DAG cards.
|
||||
*/
|
||||
static int
|
||||
dag_setfilter(pcap_t *p, struct bpf_program *fp)
|
||||
{
|
||||
if (!p)
|
||||
return -1;
|
||||
if (!fp) {
|
||||
strncpy(p->errbuf, "setfilter: No filter specified",
|
||||
sizeof(p->errbuf));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Make our private copy of the filter */
|
||||
|
||||
if (install_bpf_program(p, fp) < 0)
|
||||
return -1;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
dag_set_datalink(pcap_t *p, int dlt)
|
||||
{
|
||||
|
@ -1451,7 +1440,7 @@ pcap_platform_finddevs(pcap_if_list_t *devlistp _U_, char *errbuf)
|
|||
pcap_t *
|
||||
pcap_create_interface(const char *device, char *errbuf)
|
||||
{
|
||||
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"This version of libpcap only supports DAG cards");
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ dbus_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_char *us
|
|||
while (!message) {
|
||||
/* XXX handle->opt.timeout = timeout_ms; */
|
||||
if (!dbus_connection_read_write(handlep->conn, 100)) {
|
||||
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Connection closed");
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Connection closed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ dbus_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_char *us
|
|||
}
|
||||
|
||||
if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, "Disconnected")) {
|
||||
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Disconnected");
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Disconnected");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ dbus_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_char *us
|
|||
|
||||
gettimeofday(&pkth.ts, NULL);
|
||||
if (handle->fcode.bf_insns == NULL ||
|
||||
bpf_filter(handle->fcode.bf_insns, (u_char *)raw_msg, pkth.len, pkth.caplen)) {
|
||||
pcap_filter(handle->fcode.bf_insns, (u_char *)raw_msg, pkth.len, pkth.caplen)) {
|
||||
handlep->packets_read++;
|
||||
callback(user, &pkth, (u_char *)raw_msg);
|
||||
count++;
|
||||
|
@ -103,7 +103,7 @@ dbus_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_char *us
|
|||
}
|
||||
|
||||
static int
|
||||
dbus_write(pcap_t *handle, const void *buf, size_t size)
|
||||
dbus_write(pcap_t *handle, const void *buf, int size)
|
||||
{
|
||||
/* XXX, not tested */
|
||||
struct pcap_dbus *handlep = handle->priv;
|
||||
|
@ -112,7 +112,7 @@ dbus_write(pcap_t *handle, const void *buf, size_t size)
|
|||
DBusMessage *msg;
|
||||
|
||||
if (!(msg = dbus_message_demarshal(buf, size, &error))) {
|
||||
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dbus_message_demarshal() failed: %s", error.message);
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dbus_message_demarshal() failed: %s", error.message);
|
||||
dbus_error_free(&error);
|
||||
return -1;
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ dbus_cleanup(pcap_t *handle)
|
|||
static int
|
||||
dbus_getnonblock(pcap_t *p)
|
||||
{
|
||||
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Non-blocking mode isn't supported for capturing on D-Bus");
|
||||
return (-1);
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ dbus_getnonblock(pcap_t *p)
|
|||
static int
|
||||
dbus_setnonblock(pcap_t *p, int nonblock _U_)
|
||||
{
|
||||
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Non-blocking mode isn't supported for capturing on D-Bus");
|
||||
return (-1);
|
||||
}
|
||||
|
@ -189,14 +189,14 @@ dbus_activate(pcap_t *handle)
|
|||
|
||||
if (strcmp(dev, "dbus-system") == 0) {
|
||||
if (!(handlep->conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error))) {
|
||||
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to get system bus: %s", error.message);
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to get system bus: %s", error.message);
|
||||
dbus_error_free(&error);
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
|
||||
} else if (strcmp(dev, "dbus-session") == 0) {
|
||||
if (!(handlep->conn = dbus_bus_get(DBUS_BUS_SESSION, &error))) {
|
||||
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to get session bus: %s", error.message);
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to get session bus: %s", error.message);
|
||||
dbus_error_free(&error);
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
|
@ -205,19 +205,19 @@ dbus_activate(pcap_t *handle)
|
|||
const char *addr = dev + 7;
|
||||
|
||||
if (!(handlep->conn = dbus_connection_open(addr, &error))) {
|
||||
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to open connection to: %s: %s", addr, error.message);
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to open connection to: %s: %s", addr, error.message);
|
||||
dbus_error_free(&error);
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
|
||||
if (!dbus_bus_register(handlep->conn, &error)) {
|
||||
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to register bus %s: %s\n", addr, error.message);
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to register bus %s: %s\n", addr, error.message);
|
||||
dbus_error_free(&error);
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
|
||||
} else {
|
||||
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't get bus address from %s", handle->opt.device);
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't get bus address from %s", handle->opt.device);
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
|
||||
|
@ -289,7 +289,7 @@ dbus_activate(pcap_t *handle)
|
|||
/* try without eavesdrop */
|
||||
dbus_bus_add_match(handlep->conn, rules[i] + strlen(EAVESDROPPING_RULE), &error);
|
||||
if (dbus_error_is_set(&error)) {
|
||||
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to add bus match: %s\n", error.message);
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to add bus match: %s\n", error.message);
|
||||
dbus_error_free(&error);
|
||||
dbus_cleanup(handle);
|
||||
return PCAP_ERROR;
|
||||
|
@ -314,7 +314,7 @@ dbus_create(const char *device, char *ebuf, int *is_ours)
|
|||
}
|
||||
|
||||
*is_ours = 1;
|
||||
p = pcap_create_common(ebuf, sizeof (struct pcap_dbus));
|
||||
p = PCAP_CREATE_COMMON(ebuf, struct pcap_dbus);
|
||||
if (p == NULL)
|
||||
return (NULL);
|
||||
|
||||
|
|
|
@ -20,12 +20,12 @@
|
|||
VALUE "Comments", "https://github.com/the-tcpdump-group/libpcap/"
|
||||
VALUE "CompanyName", "The TCPdump Group"
|
||||
VALUE "FileDescription", "System-Independent Interface for User-Level Packet Capture"
|
||||
VALUE "FileVersion", "PACKAGE_VERSION_DLL"
|
||||
VALUE "FileVersion", PACKAGE_VERSION
|
||||
VALUE "InternalName", PACKAGE_NAME
|
||||
VALUE "LegalCopyright", "Copyright (c) The TCPdump Group"
|
||||
VALUE "LegalTrademarks", ""
|
||||
VALUE "OriginalFilename", "wpcap.dll"
|
||||
VALUE "ProductName", PACKAGE_NAME
|
||||
VALUE "OriginalFilename", PACKAGE_NAME ".dll"
|
||||
VALUE "ProductName", "libpcap"
|
||||
VALUE "ProductVersion", PACKAGE_VERSION
|
||||
END
|
||||
END
|
||||
|
|
|
@ -96,7 +96,6 @@
|
|||
#include <net/if.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#ifdef HAVE_HPUX9
|
||||
#include <nlist.h>
|
||||
#endif
|
||||
|
@ -108,12 +107,7 @@
|
|||
#include <string.h>
|
||||
#include <stropts.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#else
|
||||
#define INT_MAX 2147483647
|
||||
#endif
|
||||
|
||||
#include "pcap-int.h"
|
||||
#include "dlpisubs.h"
|
||||
|
@ -152,7 +146,7 @@ static int dl_dohpuxbind(int, char *);
|
|||
static int dlpromiscon(pcap_t *, bpf_u_int32);
|
||||
static int dlbindreq(int, bpf_u_int32, char *);
|
||||
static int dlbindack(int, char *, char *, int *);
|
||||
static int dlokack(int, const char *, char *, char *);
|
||||
static int dlokack(int, const char *, char *, char *, int *);
|
||||
static int dlinforeq(int, char *);
|
||||
static int dlinfoack(int, char *, char *);
|
||||
|
||||
|
@ -252,7 +246,7 @@ pcap_read_dlpi(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
|||
}
|
||||
|
||||
static int
|
||||
pcap_inject_dlpi(pcap_t *p, const void *buf, size_t size)
|
||||
pcap_inject_dlpi(pcap_t *p, const void *buf, int size)
|
||||
{
|
||||
#ifdef DL_HP_RAWDLS
|
||||
struct pcap_dlpi *pd = p->priv;
|
||||
|
@ -268,7 +262,7 @@ pcap_inject_dlpi(pcap_t *p, const void *buf, size_t size)
|
|||
}
|
||||
#elif defined(DL_HP_RAWDLS)
|
||||
if (pd->send_fd < 0) {
|
||||
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"send: Output FD couldn't be opened");
|
||||
return (-1);
|
||||
}
|
||||
|
@ -372,8 +366,12 @@ open_dlpi_device(const char *name, u_int *ppa, char *errbuf)
|
|||
* chop off the unit number, so "dname" is just a device type name.
|
||||
*/
|
||||
cp = split_dname(dname, &unit, errbuf);
|
||||
if (cp == NULL)
|
||||
if (cp == NULL) {
|
||||
/*
|
||||
* split_dname() has filled in the error message.
|
||||
*/
|
||||
return (PCAP_ERROR_NO_SUCH_DEVICE);
|
||||
}
|
||||
*cp = '\0';
|
||||
|
||||
/*
|
||||
|
@ -389,12 +387,16 @@ open_dlpi_device(const char *name, u_int *ppa, char *errbuf)
|
|||
*/
|
||||
cp = "/dev/dlpi";
|
||||
if ((fd = open(cp, O_RDWR)) < 0) {
|
||||
if (errno == EPERM || errno == EACCES)
|
||||
if (errno == EPERM || errno == EACCES) {
|
||||
status = PCAP_ERROR_PERM_DENIED;
|
||||
else
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Attempt to open %s failed with %s - root privilege may be required",
|
||||
cp, (errno == EPERM) ? "EPERM" : "EACCES");
|
||||
} else {
|
||||
status = PCAP_ERROR;
|
||||
pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "%s", cp);
|
||||
pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "Attempt to open %s failed", cp);
|
||||
}
|
||||
return (status);
|
||||
}
|
||||
|
||||
|
@ -417,7 +419,7 @@ open_dlpi_device(const char *name, u_int *ppa, char *errbuf)
|
|||
if (*name == '/')
|
||||
pcap_strlcpy(dname, name, sizeof(dname));
|
||||
else
|
||||
pcap_snprintf(dname, sizeof(dname), "%s/%s", PCAP_DEV_PREFIX,
|
||||
snprintf(dname, sizeof(dname), "%s/%s", PCAP_DEV_PREFIX,
|
||||
name);
|
||||
|
||||
/*
|
||||
|
@ -425,8 +427,12 @@ open_dlpi_device(const char *name, u_int *ppa, char *errbuf)
|
|||
* type name.
|
||||
*/
|
||||
cp = split_dname(dname, ppa, errbuf);
|
||||
if (cp == NULL)
|
||||
if (cp == NULL) {
|
||||
/*
|
||||
* split_dname() has filled in the error message.
|
||||
*/
|
||||
return (PCAP_ERROR_NO_SUCH_DEVICE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a copy of the device pathname, and then remove the unit
|
||||
|
@ -438,12 +444,18 @@ open_dlpi_device(const char *name, u_int *ppa, char *errbuf)
|
|||
/* Try device without unit number */
|
||||
if ((fd = open(dname, O_RDWR)) < 0) {
|
||||
if (errno != ENOENT) {
|
||||
if (errno == EPERM || errno == EACCES)
|
||||
if (errno == EPERM || errno == EACCES) {
|
||||
status = PCAP_ERROR_PERM_DENIED;
|
||||
else
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Attempt to open %s failed with %s - root privilege may be required",
|
||||
dname,
|
||||
(errno == EPERM) ? "EPERM" : "EACCES");
|
||||
} else {
|
||||
status = PCAP_ERROR;
|
||||
pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "%s", dname);
|
||||
pcap_fmt_errmsg_for_errno(errbuf,
|
||||
PCAP_ERRBUF_SIZE, errno,
|
||||
"Attempt to open %s failed", dname);
|
||||
}
|
||||
return (status);
|
||||
}
|
||||
|
||||
|
@ -475,15 +487,22 @@ open_dlpi_device(const char *name, u_int *ppa, char *errbuf)
|
|||
* interface is just a symptom of that
|
||||
* inability.
|
||||
*/
|
||||
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"%s: No DLPI device found", name);
|
||||
} else {
|
||||
if (errno == EPERM || errno == EACCES)
|
||||
if (errno == EPERM || errno == EACCES) {
|
||||
status = PCAP_ERROR_PERM_DENIED;
|
||||
else
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Attempt to open %s failed with %s - root privilege may be required",
|
||||
dname2,
|
||||
(errno == EPERM) ? "EPERM" : "EACCES");
|
||||
} else {
|
||||
status = PCAP_ERROR;
|
||||
pcap_fmt_errmsg_for_errno(errbuf,
|
||||
PCAP_ERRBUF_SIZE, errno, "%s", dname2);
|
||||
pcap_fmt_errmsg_for_errno(errbuf,
|
||||
PCAP_ERRBUF_SIZE, errno,
|
||||
"Attempt to open %s failed",
|
||||
dname2);
|
||||
}
|
||||
}
|
||||
return (status);
|
||||
}
|
||||
|
@ -639,7 +658,7 @@ pcap_activate_dlpi(pcap_t *p)
|
|||
**/
|
||||
if (dlbindreq(p->fd, 0, p->errbuf) < 0 ||
|
||||
dlbindack(p->fd, (char *)buf, p->errbuf, NULL) < 0) {
|
||||
status = PCAP_ERROR;
|
||||
status = PCAP_ERROR;
|
||||
goto bad;
|
||||
}
|
||||
#endif /* AIX vs. HP-UX vs. other */
|
||||
|
@ -767,7 +786,7 @@ pcap_activate_dlpi(pcap_t *p)
|
|||
*/
|
||||
if (dlinforeq(p->fd, p->errbuf) < 0 ||
|
||||
dlinfoack(p->fd, (char *)buf, p->errbuf) < 0) {
|
||||
status = PCAP_ERROR;
|
||||
status = PCAP_ERROR;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
|
@ -805,7 +824,7 @@ pcap_activate_dlpi(pcap_t *p)
|
|||
get_release(release, sizeof (release), &osmajor, &osminor, &osmicro);
|
||||
if (osmajor == 5 && (osminor <= 2 || (osminor == 3 && osmicro < 2)) &&
|
||||
getenv("BUFMOD_FIXED") == NULL) {
|
||||
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"WARNING: bufmod is broken in SunOS %s; ignoring snaplen.",
|
||||
release);
|
||||
ss = 0;
|
||||
|
@ -880,7 +899,7 @@ split_dname(char *device, u_int *unitp, char *ebuf)
|
|||
*/
|
||||
cp = device + strlen(device) - 1;
|
||||
if (*cp < '0' || *cp > '9') {
|
||||
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s missing unit number",
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s missing unit number",
|
||||
device);
|
||||
return (NULL);
|
||||
}
|
||||
|
@ -892,16 +911,16 @@ split_dname(char *device, u_int *unitp, char *ebuf)
|
|||
errno = 0;
|
||||
unit = strtol(cp, &eos, 10);
|
||||
if (*eos != '\0') {
|
||||
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s bad unit number", device);
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s bad unit number", device);
|
||||
return (NULL);
|
||||
}
|
||||
if (errno == ERANGE || unit > INT_MAX) {
|
||||
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s unit number too large",
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s unit number too large",
|
||||
device);
|
||||
return (NULL);
|
||||
}
|
||||
if (unit < 0) {
|
||||
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s unit number is negative",
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s unit number is negative",
|
||||
device);
|
||||
return (NULL);
|
||||
}
|
||||
|
@ -921,7 +940,7 @@ dl_doattach(int fd, int ppa, char *ebuf)
|
|||
if (send_request(fd, (char *)&req, sizeof(req), "attach", ebuf) < 0)
|
||||
return (PCAP_ERROR);
|
||||
|
||||
err = dlokack(fd, "attach", (char *)buf, ebuf);
|
||||
err = dlokack(fd, "attach", (char *)buf, ebuf, NULL);
|
||||
if (err < 0)
|
||||
return (err);
|
||||
return (0);
|
||||
|
@ -986,6 +1005,7 @@ dlpromiscon(pcap_t *p, bpf_u_int32 level)
|
|||
dl_promiscon_req_t req;
|
||||
bpf_u_int32 buf[MAXDLBUF];
|
||||
int err;
|
||||
int uerror;
|
||||
|
||||
req.dl_primitive = DL_PROMISCON_REQ;
|
||||
req.dl_level = level;
|
||||
|
@ -993,9 +1013,16 @@ dlpromiscon(pcap_t *p, bpf_u_int32 level)
|
|||
p->errbuf) < 0)
|
||||
return (PCAP_ERROR);
|
||||
err = dlokack(p->fd, "promiscon" STRINGIFY(level), (char *)buf,
|
||||
p->errbuf);
|
||||
if (err < 0)
|
||||
p->errbuf, &uerror);
|
||||
if (err < 0) {
|
||||
if (err == PCAP_ERROR_PERM_DENIED) {
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Attempt to set promiscuous mode failed with %s - root privilege may be required",
|
||||
(uerror == EPERM) ? "EPERM" : "EACCES");
|
||||
err = PCAP_ERROR_PROMISC_PERM_DENIED;
|
||||
}
|
||||
return (err);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -1115,7 +1142,7 @@ pcap_platform_finddevs(pcap_if_list_t *devlistp, char *errbuf)
|
|||
return (-1);
|
||||
}
|
||||
for (i = 0; i < buf.nunits; i++) {
|
||||
pcap_snprintf(baname, sizeof baname, "ba%u", i);
|
||||
snprintf(baname, sizeof baname, "ba%u", i);
|
||||
/*
|
||||
* XXX - is there a notion of "up" and "running"?
|
||||
* And is there a way to determine whether the
|
||||
|
@ -1202,7 +1229,10 @@ recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf, int *uerror
|
|||
break;
|
||||
|
||||
default:
|
||||
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
/*
|
||||
* Neither EPERM nor EACCES.
|
||||
*/
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
"recv_ack: %s: %s", what,
|
||||
dlstrerror(errmsgbuf, sizeof (errmsgbuf), dlp->error_ack.dl_errno));
|
||||
if (dlp->error_ack.dl_errno == DL_BADPPA)
|
||||
|
@ -1214,14 +1244,14 @@ recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf, int *uerror
|
|||
return (PCAP_ERROR);
|
||||
|
||||
default:
|
||||
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
"recv_ack: %s: Unexpected primitive ack %s",
|
||||
what, dlprim(dlprimbuf, sizeof (dlprimbuf), dlp->dl_primitive));
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
|
||||
if (ctl.len < size) {
|
||||
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
"recv_ack: %s: Ack too small (%d < %d)",
|
||||
what, ctl.len, size);
|
||||
return (PCAP_ERROR);
|
||||
|
@ -1332,7 +1362,7 @@ dlstrerror(char *errbuf, size_t errbufsize, bpf_u_int32 dl_errno)
|
|||
return ("Pending outstanding connect indications");
|
||||
|
||||
default:
|
||||
pcap_snprintf(errbuf, errbufsize, "Error %02x", dl_errno);
|
||||
snprintf(errbuf, errbufsize, "Error %02x", dl_errno);
|
||||
return (errbuf);
|
||||
}
|
||||
}
|
||||
|
@ -1424,7 +1454,7 @@ dlprim(char *primbuf, size_t primbufsize, bpf_u_int32 prim)
|
|||
return ("DL_RESET_CON");
|
||||
|
||||
default:
|
||||
pcap_snprintf(primbuf, primbufsize, "unknown primitive 0x%x",
|
||||
snprintf(primbuf, primbufsize, "unknown primitive 0x%x",
|
||||
prim);
|
||||
return (primbuf);
|
||||
}
|
||||
|
@ -1458,10 +1488,10 @@ dlbindack(int fd, char *bufp, char *ebuf, int *uerror)
|
|||
}
|
||||
|
||||
static int
|
||||
dlokack(int fd, const char *what, char *bufp, char *ebuf)
|
||||
dlokack(int fd, const char *what, char *bufp, char *ebuf, int *uerror)
|
||||
{
|
||||
|
||||
return (recv_ack(fd, DL_OK_ACK_SIZE, what, bufp, ebuf, NULL));
|
||||
return (recv_ack(fd, DL_OK_ACK_SIZE, what, bufp, ebuf, uerror));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1496,7 +1526,7 @@ dlpassive(int fd, char *ebuf)
|
|||
req.dl_primitive = DL_PASSIVE_REQ;
|
||||
|
||||
if (send_request(fd, (char *)&req, sizeof(req), "dlpassive", ebuf) == 0)
|
||||
(void) dlokack(fd, "dlpassive", (char *)buf, ebuf);
|
||||
(void) dlokack(fd, "dlpassive", (char *)buf, ebuf, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1551,7 +1581,7 @@ get_release(char *buf, size_t bufsize, bpf_u_int32 *majorp,
|
|||
return;
|
||||
}
|
||||
cp = buf;
|
||||
if (!isdigit((unsigned char)*cp))
|
||||
if (!PCAP_ISDIGIT((unsigned char)*cp))
|
||||
return;
|
||||
*majorp = strtol(cp, &cp, 10);
|
||||
if (*cp++ != '.')
|
||||
|
@ -1651,21 +1681,21 @@ get_dlpi_ppa(register int fd, register const char *device, register u_int unit,
|
|||
return (PCAP_ERROR);
|
||||
}
|
||||
if (ctl.len == -1) {
|
||||
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
"get_dlpi_ppa: hpppa getmsg: control buffer has no data");
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
|
||||
dlp = (dl_hp_ppa_ack_t *)ctl.buf;
|
||||
if (dlp->dl_primitive != DL_HP_PPA_ACK) {
|
||||
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
"get_dlpi_ppa: hpppa unexpected primitive ack 0x%x",
|
||||
(bpf_u_int32)dlp->dl_primitive);
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
|
||||
if ((size_t)ctl.len < DL_HP_PPA_ACK_SIZE) {
|
||||
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
"get_dlpi_ppa: hpppa ack too small (%d < %lu)",
|
||||
ctl.len, (unsigned long)DL_HP_PPA_ACK_SIZE);
|
||||
return (PCAP_ERROR);
|
||||
|
@ -1688,12 +1718,12 @@ get_dlpi_ppa(register int fd, register const char *device, register u_int unit,
|
|||
return (PCAP_ERROR);
|
||||
}
|
||||
if (ctl.len == -1) {
|
||||
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
"get_dlpi_ppa: hpppa getmsg: control buffer has no data");
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
if ((u_int)ctl.len < dlp->dl_length) {
|
||||
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
"get_dlpi_ppa: hpppa ack too small (%d < %lu)",
|
||||
ctl.len, (unsigned long)dlp->dl_length);
|
||||
free(ppa_data_buf);
|
||||
|
@ -1750,7 +1780,7 @@ get_dlpi_ppa(register int fd, register const char *device, register u_int unit,
|
|||
* device number of a device with the name "/dev/<dev><unit>",
|
||||
* if such a device exists, as the old code did.
|
||||
*/
|
||||
pcap_snprintf(dname, sizeof(dname), "/dev/%s%u", device, unit);
|
||||
snprintf(dname, sizeof(dname), "/dev/%s%u", device, unit);
|
||||
if (stat(dname, &statbuf) < 0) {
|
||||
pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "stat: %s", dname);
|
||||
|
@ -1769,12 +1799,12 @@ get_dlpi_ppa(register int fd, register const char *device, register u_int unit,
|
|||
}
|
||||
}
|
||||
if (i == ap->dl_count) {
|
||||
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
"can't find /dev/dlpi PPA for %s%u", device, unit);
|
||||
return (PCAP_ERROR_NO_SUCH_DEVICE);
|
||||
}
|
||||
if (ip->dl_hdw_state == HDW_DEAD) {
|
||||
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
"%s%d: hardware state: DOWN\n", device, unit);
|
||||
free(ppa_data_buf);
|
||||
return (PCAP_ERROR);
|
||||
|
@ -1813,13 +1843,13 @@ get_dlpi_ppa(register int fd, register const char *ifname, register u_int unit,
|
|||
if (cp != NULL)
|
||||
ifname = cp + 1;
|
||||
if (nlist(path_vmunix, &nl) < 0) {
|
||||
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "nlist %s failed",
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "nlist %s failed",
|
||||
path_vmunix);
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
if (nl[NL_IFNET].n_value == 0) {
|
||||
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
"could't find %s kernel symbol",
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
"couldn't find %s kernel symbol",
|
||||
nl[NL_IFNET].n_name);
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
|
@ -1849,7 +1879,7 @@ get_dlpi_ppa(register int fd, register const char *ifname, register u_int unit,
|
|||
}
|
||||
}
|
||||
|
||||
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "Can't find %s", ifname);
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "Can't find %s", ifname);
|
||||
return (PCAP_ERROR_NO_SUCH_DEVICE);
|
||||
}
|
||||
|
||||
|
@ -1870,7 +1900,7 @@ dlpi_kread(register int fd, register off_t addr,
|
|||
errno, "read");
|
||||
return (-1);
|
||||
} else if (cc != len) {
|
||||
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "short read (%d != %d)", cc,
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "short read (%d != %d)", cc,
|
||||
len);
|
||||
return (-1);
|
||||
}
|
||||
|
@ -1886,7 +1916,7 @@ pcap_create_interface(const char *device _U_, char *ebuf)
|
|||
struct pcap_dlpi *pd;
|
||||
#endif
|
||||
|
||||
p = pcap_create_common(ebuf, sizeof (struct pcap_dlpi));
|
||||
p = PCAP_CREATE_COMMON(ebuf, struct pcap_dlpi);
|
||||
if (p == NULL)
|
||||
return (NULL);
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <signal.h>
|
||||
#include <float.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h> /* for INT_MAX */
|
||||
#include <io.h>
|
||||
|
||||
#if defined(USE_32BIT_DRIVERS)
|
||||
|
@ -153,7 +154,7 @@ pcap_t *pcap_create_interface (const char *device _U_, char *ebuf)
|
|||
{
|
||||
pcap_t *p;
|
||||
|
||||
p = pcap_create_common(ebuf, sizeof (struct pcap_dos));
|
||||
p = PCAP_CREATE_COMMON(ebuf, struct pcap_dos);
|
||||
if (p == NULL)
|
||||
return (NULL);
|
||||
|
||||
|
@ -215,7 +216,7 @@ static int pcap_activate_dos (pcap_t *pcap)
|
|||
}
|
||||
else if (stricmp(active_dev->name,pcap->opt.device))
|
||||
{
|
||||
pcap_snprintf (pcap->errbuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf (pcap->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Cannot use different devices simultaneously "
|
||||
"(`%s' vs. `%s')", active_dev->name, pcap->opt.device);
|
||||
/* XXX - free pcap->buffer? */
|
||||
|
@ -283,7 +284,7 @@ pcap_read_one (pcap_t *p, pcap_handler callback, u_char *data)
|
|||
pcap.len = rx_len;
|
||||
|
||||
if (callback &&
|
||||
(!p->fcode.bf_insns || bpf_filter(p->fcode.bf_insns, p->buffer, pcap.len, pcap.caplen)))
|
||||
(!p->fcode.bf_insns || pcap_filter(p->fcode.bf_insns, p->buffer, pcap.len, pcap.caplen)))
|
||||
{
|
||||
filter_count++;
|
||||
|
||||
|
@ -355,7 +356,22 @@ pcap_read_dos (pcap_t *p, int cnt, pcap_handler callback, u_char *data)
|
|||
{
|
||||
int rc, num = 0;
|
||||
|
||||
while (num <= cnt || PACKET_COUNT_IS_UNLIMITED(cnt))
|
||||
/*
|
||||
* This can conceivably process more than INT_MAX packets,
|
||||
* which would overflow the packet count, causing it either
|
||||
* to look like a negative number, and thus cause us to
|
||||
* return a value that looks like an error, or overflow
|
||||
* back into positive territory, and thus cause us to
|
||||
* return a too-low count.
|
||||
*
|
||||
* Therefore, if the packet count is unlimited, we clip
|
||||
* it at INT_MAX; this routine is not expected to
|
||||
* process packets indefinitely, so that's not an issue.
|
||||
*/
|
||||
if (PACKET_COUNT_IS_UNLIMITED(cnt))
|
||||
cnt = INT_MAX;
|
||||
|
||||
while (num <= cnt)
|
||||
{
|
||||
if (p->fd <= 0)
|
||||
return (-1);
|
||||
|
@ -539,7 +555,7 @@ int pcap_lookupnet (const char *device, bpf_u_int32 *localnet,
|
|||
net = IN_CLASSC_NET;
|
||||
else
|
||||
{
|
||||
pcap_snprintf (errbuf, PCAP_ERRBUF_SIZE, "inet class for 0x%lx unknown", mask);
|
||||
snprintf (errbuf, PCAP_ERRBUF_SIZE, "inet class for 0x%lx unknown", mask);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
@ -553,7 +569,7 @@ int pcap_lookupnet (const char *device, bpf_u_int32 *localnet,
|
|||
/*
|
||||
* Get a list of all interfaces that are present and that we probe okay.
|
||||
* Returns -1 on error, 0 otherwise.
|
||||
* The list may be NULL epty if no interfaces were up and could be opened.
|
||||
* The list may be NULL empty if no interfaces were up and could be opened.
|
||||
*/
|
||||
int pcap_platform_finddevs (pcap_if_list_t *devlistp, char *errbuf)
|
||||
{
|
||||
|
@ -667,7 +683,7 @@ open_driver (const char *dev_name, char *ebuf, int promisc)
|
|||
|
||||
if (!(*dev->probe)(dev)) /* call the xx_probe() function */
|
||||
{
|
||||
pcap_snprintf (ebuf, PCAP_ERRBUF_SIZE, "failed to detect device `%s'", dev_name);
|
||||
snprintf (ebuf, PCAP_ERRBUF_SIZE, "failed to detect device `%s'", dev_name);
|
||||
return (NULL);
|
||||
}
|
||||
probed_dev = dev; /* device is probed okay and may be used */
|
||||
|
@ -689,7 +705,7 @@ open_driver (const char *dev_name, char *ebuf, int promisc)
|
|||
|
||||
if (!(*dev->open)(dev))
|
||||
{
|
||||
pcap_snprintf (ebuf, PCAP_ERRBUF_SIZE, "failed to activate device `%s'", dev_name);
|
||||
snprintf (ebuf, PCAP_ERRBUF_SIZE, "failed to activate device `%s'", dev_name);
|
||||
if (pktInfo.error && !strncmp(dev->name,"pkt",3))
|
||||
{
|
||||
strcat (ebuf, ": ");
|
||||
|
@ -698,7 +714,7 @@ open_driver (const char *dev_name, char *ebuf, int promisc)
|
|||
return (NULL);
|
||||
}
|
||||
|
||||
/* Some devices need this to operate in promiscous mode
|
||||
/* Some devices need this to operate in promiscuous mode
|
||||
*/
|
||||
if (promisc && dev->set_multicast_list)
|
||||
(*dev->set_multicast_list) (dev);
|
||||
|
@ -711,14 +727,14 @@ open_driver (const char *dev_name, char *ebuf, int promisc)
|
|||
*/
|
||||
if (!dev)
|
||||
{
|
||||
pcap_snprintf (ebuf, PCAP_ERRBUF_SIZE, "device `%s' not supported", dev_name);
|
||||
snprintf (ebuf, PCAP_ERRBUF_SIZE, "device `%s' not supported", dev_name);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
not_probed:
|
||||
if (!probed_dev)
|
||||
{
|
||||
pcap_snprintf (ebuf, PCAP_ERRBUF_SIZE, "device `%s' not probed", dev_name);
|
||||
snprintf (ebuf, PCAP_ERRBUF_SIZE, "device `%s' not probed", dev_name);
|
||||
return (NULL);
|
||||
}
|
||||
return (dev);
|
||||
|
@ -943,7 +959,7 @@ static void pcap_init_hook (void)
|
|||
}
|
||||
|
||||
/*
|
||||
* Supress PRINT message from Watt-32's sock_init()
|
||||
* Suppress PRINT message from Watt-32's sock_init()
|
||||
*/
|
||||
static void null_print (void) {}
|
||||
|
||||
|
@ -1005,7 +1021,7 @@ static int init_watt32 (struct pcap *pcap, const char *dev_name, char *err_buf)
|
|||
}
|
||||
else if (rc && using_pktdrv)
|
||||
{
|
||||
pcap_snprintf (err_buf, PCAP_ERRBUF_SIZE, "sock_init() failed, code %d", rc);
|
||||
snprintf (err_buf, PCAP_ERRBUF_SIZE, "sock_init() failed, code %d", rc);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -1031,11 +1047,9 @@ static int init_watt32 (struct pcap *pcap, const char *dev_name, char *err_buf)
|
|||
pcap_save.linktype = _eth_get_hwtype (NULL, NULL);
|
||||
pcap_save.snapshot = MTU > 0 ? MTU : ETH_MAX; /* assume 1514 */
|
||||
|
||||
#if 1
|
||||
/* prevent use of resolve() and resolve_ip()
|
||||
*/
|
||||
last_nameserver = 0;
|
||||
#endif
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
@ -1190,14 +1204,14 @@ static void ndis_close (struct device *dev)
|
|||
|
||||
static int ndis_open (struct device *dev)
|
||||
{
|
||||
int promis = (dev->flags & IFF_PROMISC);
|
||||
int promisc = (dev->flags & IFF_PROMISC);
|
||||
|
||||
#ifdef USE_NDIS2
|
||||
if (!NdisInit(promis))
|
||||
if (!NdisInit(promisc))
|
||||
return (0);
|
||||
return (1);
|
||||
#else
|
||||
ARGSUSED (promis);
|
||||
ARGSUSED (promisc);
|
||||
return (0);
|
||||
#endif
|
||||
}
|
||||
|
|
1086
contrib/libpcap/pcap-dpdk.c
Normal file
1086
contrib/libpcap/pcap-dpdk.c
Normal file
File diff suppressed because it is too large
Load diff
28
contrib/libpcap/pcap-dpdk.h
Normal file
28
contrib/libpcap/pcap-dpdk.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (C) 2018 jingle YANG. 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
pcap_t *pcap_dpdk_create(const char *, char *, int *);
|
||||
int pcap_dpdk_findalldevs(pcap_if_list_t *devlistp, char *errbuf);
|
|
@ -75,7 +75,7 @@ readloop(int cnt, int if_fd, struct bpf_program *fp, printfunc printit)
|
|||
ph = (struct packet_header *)bp;
|
||||
caplen = ph->tap.th_wirelen > snaplen ? snaplen : ph->tap
|
||||
.th_wirelen ;
|
||||
if (bpf_filter(fcode, (char *)ph->packet,
|
||||
if (pcap_filter(fcode, (char *)ph->packet,
|
||||
ph->tap.th_wirelen, caplen)) {
|
||||
if (cnt >= 0 && --cnt < 0)
|
||||
goto out;
|
||||
|
@ -89,7 +89,7 @@ readloop(int cnt, int if_fd, struct bpf_program *fp, printfunc printit)
|
|||
}
|
||||
#else /* !IBMRTPC */
|
||||
caplen = cc > snaplen ? snaplen : cc ;
|
||||
if (bpf_filter(fcode, buf.hdr.packet, cc, caplen)) {
|
||||
if (pcap_filter(fcode, buf.hdr.packet, cc, caplen)) {
|
||||
if (cnt >= 0 && --cnt < 0)
|
||||
goto out;
|
||||
(*printit)(buf.hdr.packet, &tv, cc, caplen);
|
||||
|
|
File diff suppressed because it is too large
Load diff
305
contrib/libpcap/pcap-haiku.cpp
Normal file
305
contrib/libpcap/pcap-haiku.cpp
Normal file
|
@ -0,0 +1,305 @@
|
|||
/*
|
||||
* Copyright 2006-2010, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Axel Dörfler, axeld@pinc-software.de
|
||||
* James Woodcock
|
||||
*/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "pcap-int.h"
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sockio.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_types.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/*
|
||||
* Private data for capturing on Haiku sockets.
|
||||
*/
|
||||
struct pcap_haiku {
|
||||
struct pcap_stat stat;
|
||||
char *device; /* device name */
|
||||
};
|
||||
|
||||
|
||||
bool
|
||||
prepare_request(struct ifreq& request, const char* name)
|
||||
{
|
||||
if (strlen(name) >= IF_NAMESIZE)
|
||||
return false;
|
||||
|
||||
strcpy(request.ifr_name, name);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
pcap_read_haiku(pcap_t* handle, int maxPackets _U_, pcap_handler callback,
|
||||
u_char* userdata)
|
||||
{
|
||||
// Receive a single packet
|
||||
|
||||
u_char* buffer = (u_char*)handle->buffer + handle->offset;
|
||||
struct sockaddr_dl from;
|
||||
ssize_t bytesReceived;
|
||||
do {
|
||||
if (handle->break_loop) {
|
||||
// Clear the break loop flag, and return -2 to indicate our
|
||||
// reasoning
|
||||
handle->break_loop = 0;
|
||||
return -2;
|
||||
}
|
||||
|
||||
socklen_t fromLength = sizeof(from);
|
||||
bytesReceived = recvfrom(handle->fd, buffer, handle->bufsize, MSG_TRUNC,
|
||||
(struct sockaddr*)&from, &fromLength);
|
||||
} while (bytesReceived < 0 && errno == B_INTERRUPTED);
|
||||
|
||||
if (bytesReceived < 0) {
|
||||
if (errno == B_WOULD_BLOCK) {
|
||||
// there is no packet for us
|
||||
return 0;
|
||||
}
|
||||
|
||||
snprintf(handle->errbuf, sizeof(handle->errbuf),
|
||||
"recvfrom: %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32 captureLength = bytesReceived;
|
||||
if (captureLength > handle->snapshot)
|
||||
captureLength = handle->snapshot;
|
||||
|
||||
// run the packet filter
|
||||
if (handle->fcode.bf_insns) {
|
||||
if (pcap_filter(handle->fcode.bf_insns, buffer, bytesReceived,
|
||||
captureLength) == 0) {
|
||||
// packet got rejected
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// fill in pcap_header
|
||||
pcap_pkthdr header;
|
||||
header.caplen = captureLength;
|
||||
header.len = bytesReceived;
|
||||
header.ts.tv_usec = system_time() % 1000000;
|
||||
header.ts.tv_sec = system_time() / 1000000;
|
||||
// TODO: get timing from packet!!!
|
||||
|
||||
/* Call the user supplied callback function */
|
||||
callback(userdata, &header, buffer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
pcap_inject_haiku(pcap_t *handle, const void *buffer, int size)
|
||||
{
|
||||
// we don't support injecting packets yet
|
||||
// TODO: use the AF_LINK protocol (we need another socket for this) to
|
||||
// inject the packets
|
||||
strlcpy(handle->errbuf, "Sending packets isn't supported yet",
|
||||
PCAP_ERRBUF_SIZE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
pcap_stats_haiku(pcap_t *handle, struct pcap_stat *stats)
|
||||
{
|
||||
struct pcap_haiku* handlep = (struct pcap_haiku*)handle->priv;
|
||||
ifreq request;
|
||||
int socket = ::socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (socket < 0) {
|
||||
return -1;
|
||||
}
|
||||
prepare_request(request, handlep->device);
|
||||
if (ioctl(socket, SIOCGIFSTATS, &request, sizeof(struct ifreq)) < 0) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "pcap_stats: %s",
|
||||
strerror(errno));
|
||||
close(socket);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(socket);
|
||||
handlep->stat.ps_recv += request.ifr_stats.receive.packets;
|
||||
handlep->stat.ps_drop += request.ifr_stats.receive.dropped;
|
||||
*stats = handlep->stat;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
pcap_activate_haiku(pcap_t *handle)
|
||||
{
|
||||
struct pcap_haiku* handlep = (struct pcap_haiku*)handle->priv;
|
||||
|
||||
const char* device = handle->opt.device;
|
||||
|
||||
handle->read_op = pcap_read_haiku;
|
||||
handle->setfilter_op = install_bpf_program; /* no kernel filtering */
|
||||
handle->inject_op = pcap_inject_haiku;
|
||||
handle->stats_op = pcap_stats_haiku;
|
||||
|
||||
// use default hooks where possible
|
||||
handle->getnonblock_op = pcap_getnonblock_fd;
|
||||
handle->setnonblock_op = pcap_setnonblock_fd;
|
||||
|
||||
/*
|
||||
* Turn a negative snapshot value (invalid), a snapshot value of
|
||||
* 0 (unspecified), or a value bigger than the normal maximum
|
||||
* value, into the maximum allowed value.
|
||||
*
|
||||
* If some application really *needs* a bigger snapshot
|
||||
* length, we should just increase MAXIMUM_SNAPLEN.
|
||||
*/
|
||||
if (handle->snapshot <= 0 || handle->snapshot > MAXIMUM_SNAPLEN)
|
||||
handle->snapshot = MAXIMUM_SNAPLEN;
|
||||
|
||||
handlep->device = strdup(device);
|
||||
if (handlep->device == NULL) {
|
||||
pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "strdup");
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
|
||||
handle->bufsize = 65536;
|
||||
// TODO: should be determined by interface MTU
|
||||
|
||||
// allocate buffer for monitoring the device
|
||||
handle->buffer = (u_char*)malloc(handle->bufsize);
|
||||
if (handle->buffer == NULL) {
|
||||
pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "buffer malloc");
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
|
||||
handle->offset = 0;
|
||||
handle->linktype = DLT_EN10MB;
|
||||
// TODO: check interface type!
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - pcap API
|
||||
|
||||
|
||||
extern "C" pcap_t *
|
||||
pcap_create_interface(const char *device, char *errorBuffer)
|
||||
{
|
||||
// TODO: handle promiscuous mode!
|
||||
|
||||
// we need a socket to talk to the networking stack
|
||||
int socket = ::socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (socket < 0) {
|
||||
snprintf(errorBuffer, PCAP_ERRBUF_SIZE,
|
||||
"The networking stack doesn't seem to be available.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct ifreq request;
|
||||
if (!prepare_request(request, device)) {
|
||||
snprintf(errorBuffer, PCAP_ERRBUF_SIZE,
|
||||
"Interface name \"%s\" is too long.", device);
|
||||
close(socket);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// check if the interface exist
|
||||
if (ioctl(socket, SIOCGIFINDEX, &request, sizeof(request)) < 0) {
|
||||
snprintf(errorBuffer, PCAP_ERRBUF_SIZE,
|
||||
"Interface \"%s\" does not exist.\n", device);
|
||||
close(socket);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
close(socket);
|
||||
// no longer needed after this point
|
||||
|
||||
// get link level interface for this interface
|
||||
|
||||
socket = ::socket(AF_LINK, SOCK_DGRAM, 0);
|
||||
if (socket < 0) {
|
||||
snprintf(errorBuffer, PCAP_ERRBUF_SIZE, "No link level: %s\n",
|
||||
strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// start monitoring
|
||||
if (ioctl(socket, SIOCSPACKETCAP, &request, sizeof(struct ifreq)) < 0) {
|
||||
snprintf(errorBuffer, PCAP_ERRBUF_SIZE, "Cannot start monitoring: %s\n",
|
||||
strerror(errno));
|
||||
close(socket);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct wrapper_struct { pcap_t __common; struct pcap_haiku __private; };
|
||||
pcap_t* handle = pcap_create_common(errorBuffer,
|
||||
sizeof (struct wrapper_struct),
|
||||
offsetof (struct wrapper_struct, __private));
|
||||
|
||||
if (handle == NULL) {
|
||||
snprintf(errorBuffer, PCAP_ERRBUF_SIZE, "malloc: %s", strerror(errno));
|
||||
close(socket);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
handle->selectable_fd = socket;
|
||||
handle->fd = socket;
|
||||
|
||||
handle->activate_op = pcap_activate_haiku;
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
static int
|
||||
can_be_bound(const char *name _U_)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf)
|
||||
{
|
||||
/* TODO */
|
||||
if (*flags & PCAP_IF_LOOPBACK) {
|
||||
/*
|
||||
* Loopback devices aren't wireless, and "connected"/
|
||||
* "disconnected" doesn't apply to them.
|
||||
*/
|
||||
*flags |= PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE;
|
||||
return (0);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
pcap_platform_finddevs(pcap_if_list_t* _allDevices, char* errorBuffer)
|
||||
{
|
||||
return pcap_findalldevs_interfaces(_allDevices, errorBuffer, can_be_bound,
|
||||
get_if_flags);
|
||||
}
|
||||
|
||||
/*
|
||||
* Libpcap version string.
|
||||
*/
|
||||
extern "C" const char *
|
||||
pcap_lib_version(void)
|
||||
{
|
||||
return (PCAP_VERSION_STRING);
|
||||
}
|
|
@ -34,13 +34,42 @@
|
|||
#ifndef pcap_int_h
|
||||
#define pcap_int_h
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include <pcap/pcap.h>
|
||||
|
||||
#ifdef MSDOS
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#include "varattrs.h"
|
||||
#include "fmtutils.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "portability.h"
|
||||
|
||||
/*
|
||||
* If we're compiling with Visual Studio, make sure we have at least
|
||||
* VS 2015 or later, so we have sufficient C99 support.
|
||||
*
|
||||
* XXX - verify that we have at least C99 support on UN*Xes?
|
||||
*
|
||||
* What about MinGW or various DOS toolchains? We're currently assuming
|
||||
* sufficient C99 support there.
|
||||
*/
|
||||
#if defined(_MSC_VER)
|
||||
/*
|
||||
* Compiler is MSVC. Make sure we have VS 2015 or later.
|
||||
*/
|
||||
#if _MSC_VER < 1900
|
||||
#error "Building libpcap requires VS 2015 or later"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Version string.
|
||||
* Uses PACKAGE_VERSION from config.h.
|
||||
|
@ -51,10 +80,32 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef MSDOS
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#endif
|
||||
/*
|
||||
* If pcap_new_api is set, we disable pcap_lookupdev(), because:
|
||||
*
|
||||
* it's not thread-safe, and is marked as deprecated, on all
|
||||
* platforms;
|
||||
*
|
||||
* on Windows, it may return UTF-16LE strings, which the program
|
||||
* might then pass to pcap_create() (or to pcap_open_live(), which
|
||||
* then passes them to pcap_create()), requiring pcap_create() to
|
||||
* check for UTF-16LE strings using a hack, and that hack 1)
|
||||
* *cannot* be 100% reliable and 2) runs the risk of going past the
|
||||
* end of the string.
|
||||
*
|
||||
* We keep it around in legacy mode for compatibility.
|
||||
*
|
||||
* We also disable the aforementioned hack in pcap_create().
|
||||
*/
|
||||
extern int pcap_new_api;
|
||||
|
||||
/*
|
||||
* If pcap_utf_8_mode is set, on Windows we treat strings as UTF-8.
|
||||
*
|
||||
* On UN*Xes, we assume all strings are and should be in UTF-8, regardless
|
||||
* of the setting of this flag.
|
||||
*/
|
||||
extern int pcap_utf_8_mode;
|
||||
|
||||
/*
|
||||
* Swap byte ordering of unsigned long long timestamp on a big endian
|
||||
|
@ -77,7 +128,7 @@ extern "C" {
|
|||
* 1) big enough for maximum-size Linux loopback packets (65549)
|
||||
* and some USB packets captured with USBPcap:
|
||||
*
|
||||
* http://desowin.org/usbpcap/
|
||||
* https://desowin.org/usbpcap/
|
||||
*
|
||||
* (> 131072, < 262144)
|
||||
*
|
||||
|
@ -97,6 +148,18 @@ extern "C" {
|
|||
*/
|
||||
#define MAXIMUM_SNAPLEN 262144
|
||||
|
||||
/*
|
||||
* Locale-independent macros for testing character types.
|
||||
* These can be passed any integral value, without worrying about, for
|
||||
* example, sign-extending char values, unlike the C macros.
|
||||
*/
|
||||
#define PCAP_ISDIGIT(c) \
|
||||
((c) >= '0' && (c) <= '9')
|
||||
#define PCAP_ISXDIGIT(c) \
|
||||
(((c) >= '0' && (c) <= '9') || \
|
||||
((c) >= 'A' && (c) <= 'F') || \
|
||||
((c) >= 'a' && (c) <= 'f'))
|
||||
|
||||
struct pcap_opt {
|
||||
char *device;
|
||||
int timeout; /* timeout for buffering */
|
||||
|
@ -123,7 +186,7 @@ typedef int (*activate_op_t)(pcap_t *);
|
|||
typedef int (*can_set_rfmon_op_t)(pcap_t *);
|
||||
typedef int (*read_op_t)(pcap_t *, int cnt, pcap_handler, u_char *);
|
||||
typedef int (*next_packet_op_t)(pcap_t *, struct pcap_pkthdr *, u_char **);
|
||||
typedef int (*inject_op_t)(pcap_t *, const void *, size_t);
|
||||
typedef int (*inject_op_t)(pcap_t *, const void *, int);
|
||||
typedef void (*save_current_filter_op_t)(pcap_t *, const char *);
|
||||
typedef int (*setfilter_op_t)(pcap_t *, struct bpf_program *);
|
||||
typedef int (*setdirection_op_t)(pcap_t *, pcap_direction_t);
|
||||
|
@ -131,6 +194,7 @@ typedef int (*set_datalink_op_t)(pcap_t *, int);
|
|||
typedef int (*getnonblock_op_t)(pcap_t *);
|
||||
typedef int (*setnonblock_op_t)(pcap_t *, int);
|
||||
typedef int (*stats_op_t)(pcap_t *, struct pcap_stat *);
|
||||
typedef void (*breakloop_op_t)(pcap_t *);
|
||||
#ifdef _WIN32
|
||||
typedef struct pcap_stat *(*stats_ex_op_t)(pcap_t *, int *);
|
||||
typedef int (*setbuff_op_t)(pcap_t *, int);
|
||||
|
@ -200,8 +264,7 @@ struct pcap {
|
|||
|
||||
int snapshot;
|
||||
int linktype; /* Network linktype */
|
||||
int linktype_ext; /* Extended information stored in the linktype field of a file */
|
||||
int tzoff; /* timezone offset */
|
||||
int linktype_ext; /* Extended information stored in the linktype field of a file */
|
||||
int offset; /* offset for proper alignment */
|
||||
int activated; /* true if the capture is really started */
|
||||
int oldstyle; /* if we're opening with pcap_open_live() */
|
||||
|
@ -239,7 +302,7 @@ struct pcap {
|
|||
* pcap_t's with a required timeout, and the code must be
|
||||
* prepared not to see any packets from the attempt.
|
||||
*/
|
||||
struct timeval *required_select_timeout;
|
||||
const struct timeval *required_select_timeout;
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -248,6 +311,9 @@ struct pcap {
|
|||
struct bpf_program fcode;
|
||||
|
||||
char errbuf[PCAP_ERRBUF_SIZE + 1];
|
||||
#ifdef _WIN32
|
||||
char acp_errbuf[PCAP_ERRBUF_SIZE + 1]; /* buffer for local code page error strings */
|
||||
#endif
|
||||
int dlt_count;
|
||||
u_int *dlt_list;
|
||||
int tstamp_type_count;
|
||||
|
@ -270,6 +336,7 @@ struct pcap {
|
|||
getnonblock_op_t getnonblock_op;
|
||||
setnonblock_op_t setnonblock_op;
|
||||
stats_op_t stats_op;
|
||||
breakloop_op_t breakloop_op;
|
||||
|
||||
/*
|
||||
* Routine to use as callback for pcap_next()/pcap_next_ex().
|
||||
|
@ -340,7 +407,7 @@ struct pcap_timeval {
|
|||
*
|
||||
* Then supply the changes by forking the branch at
|
||||
*
|
||||
* https://github.com/the-tcpdump-group/libpcap/issues
|
||||
* https://github.com/the-tcpdump-group/libpcap/tree/master
|
||||
*
|
||||
* and issuing a pull request, so that future versions of libpcap and
|
||||
* programs that use it (such as tcpdump) will be able to read your new
|
||||
|
@ -350,7 +417,7 @@ struct pcap_timeval {
|
|||
struct pcap_sf_pkthdr {
|
||||
struct pcap_timeval ts; /* time stamp */
|
||||
bpf_u_int32 caplen; /* length of portion present */
|
||||
bpf_u_int32 len; /* length this packet (off wire) */
|
||||
bpf_u_int32 len; /* length of this packet (off wire) */
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -366,7 +433,7 @@ struct pcap_sf_pkthdr {
|
|||
struct pcap_sf_patched_pkthdr {
|
||||
struct pcap_timeval ts; /* time stamp */
|
||||
bpf_u_int32 caplen; /* length of portion present */
|
||||
bpf_u_int32 len; /* length this packet (off wire) */
|
||||
bpf_u_int32 len; /* length of this packet (off wire) */
|
||||
int index;
|
||||
unsigned short protocol;
|
||||
unsigned char pkt_type;
|
||||
|
@ -388,10 +455,6 @@ struct oneshot_userdata {
|
|||
|
||||
int pcap_offline_read(pcap_t *, int, pcap_handler, u_char *);
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "portability.h"
|
||||
|
||||
/*
|
||||
* Does the packet count argument to a module's read routine say
|
||||
* "supply packets until you run out of packets"?
|
||||
|
@ -418,12 +481,25 @@ int pcap_setnonblock_fd(pcap_t *p, int);
|
|||
* by pcap_create routines.
|
||||
*/
|
||||
pcap_t *pcap_create_interface(const char *, char *);
|
||||
pcap_t *pcap_create_common(char *, size_t);
|
||||
|
||||
/*
|
||||
* This wrapper takes an error buffer pointer and a type to use for the
|
||||
* private data, and calls pcap_create_common(), passing it the error
|
||||
* buffer pointer, the size for the private data type, in bytes, and the
|
||||
* offset of the private data from the beginning of the structure, in
|
||||
* bytes.
|
||||
*/
|
||||
#define PCAP_CREATE_COMMON(ebuf, type) \
|
||||
pcap_create_common(ebuf, \
|
||||
sizeof (struct { pcap_t __common; type __private; }), \
|
||||
offsetof (struct { pcap_t __common; type __private; }, __private))
|
||||
pcap_t *pcap_create_common(char *, size_t, size_t);
|
||||
int pcap_do_addexit(pcap_t *);
|
||||
void pcap_add_to_pcaps_to_close(pcap_t *);
|
||||
void pcap_remove_from_pcaps_to_close(pcap_t *);
|
||||
void pcap_cleanup_live_common(pcap_t *);
|
||||
int pcap_check_activated(pcap_t *);
|
||||
void pcap_breakloop_common(pcap_t *);
|
||||
|
||||
/*
|
||||
* Internal interfaces for "pcap_findalldevs()".
|
||||
|
@ -472,7 +548,8 @@ int add_addr_to_if(pcap_if_list_t *, const char *, bpf_u_int32,
|
|||
#endif
|
||||
|
||||
/*
|
||||
* Internal interfaces for "pcap_open_offline()".
|
||||
* Internal interfaces for "pcap_open_offline()" and other savefile
|
||||
* I/O routines.
|
||||
*
|
||||
* "pcap_open_offline_common()" allocates and fills in a pcap_t, for use
|
||||
* by pcap_open_offline routines.
|
||||
|
@ -483,10 +560,46 @@ int add_addr_to_if(pcap_if_list_t *, const char *, bpf_u_int32,
|
|||
* "sf_cleanup()" closes the file handle associated with a pcap_t, if
|
||||
* appropriate, and frees all data common to all modules for handling
|
||||
* savefile types.
|
||||
*
|
||||
* "charset_fopen()", in UTF-8 mode on Windows, does an fopen() that
|
||||
* treats the pathname as being in UTF-8, rather than the local
|
||||
* code page, on Windows.
|
||||
*/
|
||||
pcap_t *pcap_open_offline_common(char *ebuf, size_t size);
|
||||
|
||||
/*
|
||||
* This wrapper takes an error buffer pointer and a type to use for the
|
||||
* private data, and calls pcap_create_common(), passing it the error
|
||||
* buffer pointer, the size for the private data type, in bytes, and the
|
||||
* offset of the private data from the beginning of the structure, in
|
||||
* bytes.
|
||||
*/
|
||||
#define PCAP_OPEN_OFFLINE_COMMON(ebuf, type) \
|
||||
pcap_open_offline_common(ebuf, \
|
||||
sizeof (struct { pcap_t __common; type __private; }), \
|
||||
offsetof (struct { pcap_t __common; type __private; }, __private))
|
||||
pcap_t *pcap_open_offline_common(char *ebuf, size_t total_size,
|
||||
size_t private_data);
|
||||
bpf_u_int32 pcap_adjust_snapshot(bpf_u_int32 linktype, bpf_u_int32 snaplen);
|
||||
void sf_cleanup(pcap_t *p);
|
||||
#ifdef _WIN32
|
||||
FILE *charset_fopen(const char *path, const char *mode);
|
||||
#else
|
||||
/*
|
||||
* On other OSes, just use Boring Old fopen().
|
||||
*/
|
||||
#define charset_fopen(path, mode) fopen((path), (mode))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Internal interfaces for loading code at run time.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#define pcap_code_handle_t HMODULE
|
||||
#define pcap_funcptr_t FARPROC
|
||||
|
||||
pcap_code_handle_t pcap_load_code(const char *);
|
||||
pcap_funcptr_t pcap_find_function(pcap_code_handle_t, const char *);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Internal interfaces for doing user-mode filtering of packets and
|
||||
|
@ -497,7 +610,7 @@ void sf_cleanup(pcap_t *p);
|
|||
* Linux kernel when the kernel rejects the filter (requiring us to
|
||||
* run it in userland). It contains VLAN tag information.
|
||||
*/
|
||||
struct bpf_aux_data {
|
||||
struct pcap_bpf_aux_data {
|
||||
u_short vlan_tag_present;
|
||||
u_short vlan_tag;
|
||||
};
|
||||
|
@ -506,8 +619,18 @@ struct bpf_aux_data {
|
|||
* Filtering routine that takes the auxiliary data as an additional
|
||||
* argument.
|
||||
*/
|
||||
u_int bpf_filter_with_aux_data(const struct bpf_insn *,
|
||||
const u_char *, u_int, u_int, const struct bpf_aux_data *);
|
||||
u_int pcap_filter_with_aux_data(const struct bpf_insn *,
|
||||
const u_char *, u_int, u_int, const struct pcap_bpf_aux_data *);
|
||||
|
||||
/*
|
||||
* Filtering routine that doesn't.
|
||||
*/
|
||||
u_int pcap_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
|
||||
|
||||
/*
|
||||
* Routine to validate a BPF program.
|
||||
*/
|
||||
int pcap_validate_filter(const struct bpf_insn *, int);
|
||||
|
||||
/*
|
||||
* Internal interfaces for both "pcap_create()" and routines that
|
||||
|
@ -522,6 +645,16 @@ int install_bpf_program(pcap_t *, struct bpf_program *);
|
|||
|
||||
int pcap_strcasecmp(const char *, const char *);
|
||||
|
||||
/*
|
||||
* Internal interfaces for pcap_createsrcstr and pcap_parsesrcstr with
|
||||
* the additional bit of information regarding SSL support (rpcap:// vs.
|
||||
* rpcaps://).
|
||||
*/
|
||||
int pcap_createsrcstr_ex(char *, int, const char *, const char *,
|
||||
const char *, unsigned char, char *);
|
||||
int pcap_parsesrcstr_ex(const char *, int *, char *, char *,
|
||||
char *, unsigned char *, char *);
|
||||
|
||||
#ifdef YYDEBUG
|
||||
extern int pcap_debug;
|
||||
#endif
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
/* Forwards. */
|
||||
static int dlpromiscon(pcap_t *, bpf_u_int32);
|
||||
static int pcap_read_libdlpi(pcap_t *, int, pcap_handler, u_char *);
|
||||
static int pcap_inject_libdlpi(pcap_t *, const void *, size_t);
|
||||
static int pcap_inject_libdlpi(pcap_t *, const void *, int);
|
||||
static void pcap_libdlpi_err(const char *, const char *, int, char *);
|
||||
static void pcap_cleanup_libdlpi(pcap_t *);
|
||||
|
||||
|
@ -108,15 +108,24 @@ pcap_activate_libdlpi(pcap_t *p)
|
|||
*/
|
||||
retv = dlpi_open(p->opt.device, &dh, DLPI_RAW|DLPI_PASSIVE);
|
||||
if (retv != DLPI_SUCCESS) {
|
||||
if (retv == DLPI_ELINKNAMEINVAL || retv == DLPI_ENOLINK)
|
||||
if (retv == DLPI_ELINKNAMEINVAL || retv == DLPI_ENOLINK) {
|
||||
/*
|
||||
* There's nothing more to say, so clear the
|
||||
* error message.
|
||||
*/
|
||||
status = PCAP_ERROR_NO_SUCH_DEVICE;
|
||||
else if (retv == DL_SYSERR &&
|
||||
(errno == EPERM || errno == EACCES))
|
||||
p->errbuf[0] = '\0';
|
||||
} else if (retv == DL_SYSERR &&
|
||||
(errno == EPERM || errno == EACCES)) {
|
||||
status = PCAP_ERROR_PERM_DENIED;
|
||||
else
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Attempt to open DLPI device failed with %s - root privilege may be required",
|
||||
(errno == EPERM) ? "EPERM" : "EACCES");
|
||||
} else {
|
||||
status = PCAP_ERROR;
|
||||
pcap_libdlpi_err(p->opt.device, "dlpi_open", retv,
|
||||
p->errbuf);
|
||||
pcap_libdlpi_err(p->opt.device, "dlpi_open", retv,
|
||||
p->errbuf);
|
||||
}
|
||||
return (status);
|
||||
}
|
||||
pd->dlpi_hd = dh;
|
||||
|
@ -265,12 +274,25 @@ dlpromiscon(pcap_t *p, bpf_u_int32 level)
|
|||
retv = dlpi_promiscon(pd->dlpi_hd, level);
|
||||
if (retv != DLPI_SUCCESS) {
|
||||
if (retv == DL_SYSERR &&
|
||||
(errno == EPERM || errno == EACCES))
|
||||
err = PCAP_ERROR_PERM_DENIED;
|
||||
else
|
||||
(errno == EPERM || errno == EACCES)) {
|
||||
if (level == DL_PROMISC_PHYS) {
|
||||
err = PCAP_ERROR_PROMISC_PERM_DENIED;
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Attempt to set promiscuous mode failed with %s - root privilege may be required",
|
||||
(errno == EPERM) ? "EPERM" : "EACCES");
|
||||
} else {
|
||||
err = PCAP_ERROR_PERM_DENIED;
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Attempt to set %s mode failed with %s - root privilege may be required",
|
||||
(level == DL_PROMISC_MULTI) ? "multicast" : "SAP promiscuous",
|
||||
(errno == EPERM) ? "EPERM" : "EACCES");
|
||||
}
|
||||
} else {
|
||||
err = PCAP_ERROR;
|
||||
pcap_libdlpi_err(p->opt.device, "dlpi_promiscon" STRINGIFY(level),
|
||||
retv, p->errbuf);
|
||||
pcap_libdlpi_err(p->opt.device,
|
||||
"dlpi_promiscon" STRINGIFY(level),
|
||||
retv, p->errbuf);
|
||||
}
|
||||
return (err);
|
||||
}
|
||||
return (0);
|
||||
|
@ -427,7 +449,7 @@ pcap_read_libdlpi(pcap_t *p, int count, pcap_handler callback, u_char *user)
|
|||
}
|
||||
|
||||
static int
|
||||
pcap_inject_libdlpi(pcap_t *p, const void *buf, size_t size)
|
||||
pcap_inject_libdlpi(pcap_t *p, const void *buf, int size)
|
||||
{
|
||||
struct pcap_dlpi *pd = p->priv;
|
||||
int retv;
|
||||
|
@ -468,7 +490,7 @@ pcap_cleanup_libdlpi(pcap_t *p)
|
|||
static void
|
||||
pcap_libdlpi_err(const char *linkname, const char *func, int err, char *errbuf)
|
||||
{
|
||||
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "libpcap: %s failed on %s: %s",
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "libpcap: %s failed on %s: %s",
|
||||
func, linkname, dlpi_strerror(err));
|
||||
}
|
||||
|
||||
|
@ -477,7 +499,7 @@ pcap_create_interface(const char *device _U_, char *ebuf)
|
|||
{
|
||||
pcap_t *p;
|
||||
|
||||
p = pcap_create_common(ebuf, sizeof (struct pcap_dlpi));
|
||||
p = PCAP_CREATE_COMMON(ebuf, struct pcap_dlpi);
|
||||
if (p == NULL)
|
||||
return (NULL);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.\"
|
||||
.TH PCAP-LINKTYPE @MAN_MISC_INFO@ "7 April 2014"
|
||||
.TH PCAP-LINKTYPE @MAN_MISC_INFO@ "6 April 2020"
|
||||
.SH NAME
|
||||
pcap-linktype \- link-layer header types supported by libpcap
|
||||
.SH DESCRIPTION
|
||||
|
@ -38,11 +38,11 @@ so they are sometimes called "DLT_ values".
|
|||
The values stored in the link-layer header type field in the savefile
|
||||
header are, in most but not all cases, the same as the values returned
|
||||
by
|
||||
.BR pcap_datalink() .
|
||||
.BR pcap_datalink ().
|
||||
The names for those values begin with
|
||||
.BR LINKTYPE_ .
|
||||
.PP
|
||||
The link-layer header types supported by libpcap are described at
|
||||
https://www.tcpdump.org/linktypes.html.
|
||||
https://www.tcpdump.org/linktypes.html .
|
||||
.SH SEE ALSO
|
||||
pcap(3PCAP)
|
||||
.BR pcap (3PCAP)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -33,6 +33,7 @@
|
|||
#endif
|
||||
|
||||
#include "pcap-int.h"
|
||||
#include "diag-control.h"
|
||||
|
||||
#ifdef NEED_STRERROR_H
|
||||
#include "strerror.h"
|
||||
|
@ -56,13 +57,13 @@
|
|||
#include <linux/netfilter/nfnetlink_log.h>
|
||||
#include <linux/netfilter/nfnetlink_queue.h>
|
||||
|
||||
/* NOTE: if your program drops privilages after pcap_activate() it WON'T work with nfqueue.
|
||||
/* NOTE: if your program drops privileges after pcap_activate() it WON'T work with nfqueue.
|
||||
* It took me quite some time to debug ;/
|
||||
*
|
||||
* Sending any data to nfnetlink socket requires CAP_NET_ADMIN privilages,
|
||||
* Sending any data to nfnetlink socket requires CAP_NET_ADMIN privileges,
|
||||
* and in nfqueue we need to send verdict reply after recving packet.
|
||||
*
|
||||
* In tcpdump you can disable dropping privilages with -Z root
|
||||
* In tcpdump you can disable dropping privileges with -Z root
|
||||
*/
|
||||
|
||||
#include "pcap-netfilter-linux.h"
|
||||
|
@ -91,7 +92,7 @@ netfilter_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_c
|
|||
struct pcap_netfilter *handlep = handle->priv;
|
||||
register u_char *bp, *ep;
|
||||
int count = 0;
|
||||
int len;
|
||||
ssize_t len;
|
||||
|
||||
/*
|
||||
* Has "pcap_breakloop()" been called?
|
||||
|
@ -135,6 +136,13 @@ netfilter_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_c
|
|||
bp = (unsigned char *)handle->buffer;
|
||||
} else
|
||||
bp = handle->bp;
|
||||
|
||||
/*
|
||||
* Loop through each message.
|
||||
*
|
||||
* This assumes that a single buffer of message will have
|
||||
* <= INT_MAX packets, so the message count doesn't overflow.
|
||||
*/
|
||||
ep = bp + len;
|
||||
while (bp < ep) {
|
||||
const struct nlmsghdr *nlh = (const struct nlmsghdr *) bp;
|
||||
|
@ -152,14 +160,25 @@ netfilter_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_c
|
|||
*/
|
||||
if (handle->break_loop) {
|
||||
handle->bp = bp;
|
||||
handle->cc = ep - bp;
|
||||
handle->cc = (int)(ep - bp);
|
||||
if (count == 0) {
|
||||
handle->break_loop = 0;
|
||||
return PCAP_ERROR_BREAK;
|
||||
} else
|
||||
return count;
|
||||
}
|
||||
if (ep - bp < NLMSG_SPACE(0)) {
|
||||
/*
|
||||
* NLMSG_SPACE(0) might be signed or might be unsigned,
|
||||
* depending on whether the kernel defines NLMSG_ALIGNTO
|
||||
* as 4, which older kernels do, or as 4U, which newer
|
||||
* kernels do.
|
||||
*
|
||||
* ep - bp is of type ptrdiff_t, which is signed.
|
||||
*
|
||||
* To squelch warnings, we cast both to size_t, which
|
||||
* is unsigned; ep >= bp, so the cast is safe.
|
||||
*/
|
||||
if ((size_t)(ep - bp) < (size_t)NLMSG_SPACE(0)) {
|
||||
/*
|
||||
* There's less than one netlink message left
|
||||
* in the buffer. Give up.
|
||||
|
@ -168,7 +187,7 @@ netfilter_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_c
|
|||
}
|
||||
|
||||
if (nlh->nlmsg_len < sizeof(struct nlmsghdr) || (u_int)len < nlh->nlmsg_len) {
|
||||
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Message truncated: (got: %d) (nlmsg_len: %u)", len, nlh->nlmsg_len);
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Message truncated: (got: %zd) (nlmsg_len: %u)", len, nlh->nlmsg_len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -190,7 +209,7 @@ netfilter_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_c
|
|||
const struct nfattr *payload_attr = NULL;
|
||||
|
||||
if (nlh->nlmsg_len < HDR_LENGTH) {
|
||||
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Malformed message: (nlmsg_len: %u)", nlh->nlmsg_len);
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Malformed message: (nlmsg_len: %u)", nlh->nlmsg_len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -240,7 +259,7 @@ netfilter_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_c
|
|||
|
||||
gettimeofday(&pkth.ts, NULL);
|
||||
if (handle->fcode.bf_insns == NULL ||
|
||||
bpf_filter(handle->fcode.bf_insns, payload, pkth.len, pkth.caplen))
|
||||
pcap_filter(handle->fcode.bf_insns, payload, pkth.len, pkth.caplen))
|
||||
{
|
||||
handlep->packets_read++;
|
||||
callback(user, &pkth, payload);
|
||||
|
@ -262,14 +281,21 @@ netfilter_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_c
|
|||
* If the message length would run past the end of the
|
||||
* buffer, truncate it to the remaining space in the
|
||||
* buffer.
|
||||
*
|
||||
* To squelch warnings, we cast ep - bp to uint32_t, which
|
||||
* is unsigned and is the type of msg_len; ep >= bp, and
|
||||
* len should fit in 32 bits (either it's set from an int
|
||||
* or it's set from a recv() call with a buffer size that's
|
||||
* an int, and we're assuming either ILP32 or LP64), so
|
||||
* the cast is safe.
|
||||
*/
|
||||
if (msg_len > ep - bp)
|
||||
msg_len = ep - bp;
|
||||
if (msg_len > (uint32_t)(ep - bp))
|
||||
msg_len = (uint32_t)(ep - bp);
|
||||
|
||||
bp += msg_len;
|
||||
if (count >= max_packets && !PACKET_COUNT_IS_UNLIMITED(max_packets)) {
|
||||
handle->bp = bp;
|
||||
handle->cc = ep - bp;
|
||||
handle->cc = (int)(ep - bp);
|
||||
if (handle->cc < 0)
|
||||
handle->cc = 0;
|
||||
return count;
|
||||
|
@ -299,9 +325,9 @@ netfilter_stats_linux(pcap_t *handle, struct pcap_stat *stats)
|
|||
}
|
||||
|
||||
static int
|
||||
netfilter_inject_linux(pcap_t *handle, const void *buf _U_, size_t size _U_)
|
||||
netfilter_inject_linux(pcap_t *handle, const void *buf _U_, int size _U_)
|
||||
{
|
||||
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Packet injection is not supported on netfilter devices");
|
||||
return (-1);
|
||||
}
|
||||
|
@ -325,7 +351,9 @@ netfilter_send_config_msg(const pcap_t *handle, uint16_t msg_type, int ack, u_in
|
|||
static unsigned int seq_id;
|
||||
|
||||
if (!seq_id)
|
||||
DIAG_OFF_NARROWING
|
||||
seq_id = time(NULL);
|
||||
DIAG_ON_NARROWING
|
||||
++seq_id;
|
||||
|
||||
nlh->nlmsg_len = NLMSG_LENGTH(sizeof(struct nfgenmsg));
|
||||
|
@ -363,7 +391,11 @@ netfilter_send_config_msg(const pcap_t *handle, uint16_t msg_type, int ack, u_in
|
|||
|
||||
/* ignore interrupt system call error */
|
||||
do {
|
||||
len = recvfrom(handle->fd, buf, sizeof(buf), 0, (struct sockaddr *) &snl, &addrlen);
|
||||
/*
|
||||
* The buffer is not so big that its size won't
|
||||
* fit into an int.
|
||||
*/
|
||||
len = (int)recvfrom(handle->fd, buf, sizeof(buf), 0, (struct sockaddr *) &snl, &addrlen);
|
||||
} while ((len == -1) && (errno == EINTR));
|
||||
|
||||
if (len <= 0)
|
||||
|
@ -510,7 +542,7 @@ netfilter_activate(pcap_t* handle)
|
|||
char *end_dev;
|
||||
|
||||
if (group_count == 32) {
|
||||
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Maximum 32 netfilter groups! dev: %s",
|
||||
handle->opt.device);
|
||||
return PCAP_ERROR;
|
||||
|
@ -519,7 +551,7 @@ netfilter_activate(pcap_t* handle)
|
|||
group_id = strtol(dev, &end_dev, 0);
|
||||
if (end_dev != dev) {
|
||||
if (group_id < 0 || group_id > 65535) {
|
||||
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Netfilter group range from 0 to 65535 (got %ld)",
|
||||
group_id);
|
||||
return PCAP_ERROR;
|
||||
|
@ -535,7 +567,7 @@ netfilter_activate(pcap_t* handle)
|
|||
}
|
||||
|
||||
if (type == OTHER || *dev) {
|
||||
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Can't get netfilter group(s) index from %s",
|
||||
handle->opt.device);
|
||||
return PCAP_ERROR;
|
||||
|
@ -616,7 +648,7 @@ netfilter_activate(pcap_t* handle)
|
|||
if (nflog_send_config_cmd(handle, groups[i], NFULNL_CFG_CMD_BIND, AF_UNSPEC) < 0) {
|
||||
pcap_fmt_errmsg_for_errno(handle->errbuf,
|
||||
PCAP_ERRBUF_SIZE, errno,
|
||||
"Can't listen on group group index");
|
||||
"Can't listen on group index");
|
||||
goto close_fail;
|
||||
}
|
||||
|
||||
|
@ -646,7 +678,7 @@ netfilter_activate(pcap_t* handle)
|
|||
if (nfqueue_send_config_cmd(handle, groups[i], NFQNL_CFG_CMD_BIND, AF_UNSPEC) < 0) {
|
||||
pcap_fmt_errmsg_for_errno(handle->errbuf,
|
||||
PCAP_ERRBUF_SIZE, errno,
|
||||
"Can't listen on group group index");
|
||||
"Can't listen on group index");
|
||||
goto close_fail;
|
||||
}
|
||||
|
||||
|
@ -721,7 +753,7 @@ netfilter_create(const char *device, char *ebuf, int *is_ours)
|
|||
/* OK, it's probably ours. */
|
||||
*is_ours = 1;
|
||||
|
||||
p = pcap_create_common(ebuf, sizeof (struct pcap_netfilter));
|
||||
p = PCAP_CREATE_COMMON(ebuf, struct pcap_netfilter);
|
||||
if (p == NULL)
|
||||
return (NULL);
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#endif
|
||||
|
||||
#include <poll.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
|
@ -82,7 +81,7 @@ pcap_netmap_filter(u_char *arg, struct pcap_pkthdr *h, const u_char *buf)
|
|||
const struct bpf_insn *pc = p->fcode.bf_insns;
|
||||
|
||||
++pn->rx_pkts;
|
||||
if (pc == NULL || bpf_filter(pc, buf, h->len, h->caplen))
|
||||
if (pc == NULL || pcap_filter(pc, buf, h->len, h->caplen))
|
||||
pn->cb(pn->cb_arg, h, buf);
|
||||
}
|
||||
|
||||
|
@ -117,7 +116,7 @@ pcap_netmap_dispatch(pcap_t *p, int cnt, pcap_handler cb, u_char *user)
|
|||
|
||||
/* XXX need to check the NIOCTXSYNC/poll */
|
||||
static int
|
||||
pcap_netmap_inject(pcap_t *p, const void *buf, size_t size)
|
||||
pcap_netmap_inject(pcap_t *p, const void *buf, int size)
|
||||
{
|
||||
struct pcap_netmap *pn = p->priv;
|
||||
struct nm_desc *d = pn->d;
|
||||
|
@ -287,7 +286,7 @@ pcap_netmap_create(const char *device, char *ebuf, int *is_ours)
|
|||
*is_ours = (!strncmp(device, "netmap:", 7) || !strncmp(device, "vale", 4));
|
||||
if (! *is_ours)
|
||||
return NULL;
|
||||
p = pcap_create_common(ebuf, sizeof (struct pcap_netmap));
|
||||
p = PCAP_CREATE_COMMON(ebuf, struct pcap_netmap);
|
||||
if (p == NULL)
|
||||
return (NULL);
|
||||
p->activate_op = pcap_netmap_activate;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#endif
|
||||
|
||||
#include "ftmacros.h"
|
||||
#include "diag-control.h"
|
||||
|
||||
/*
|
||||
* sockutils.h may include <crtdbg.h> on Windows, and pcap-int.h will
|
||||
|
@ -88,7 +89,7 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t
|
|||
|
||||
if (strlen(source) > PCAP_BUF_SIZE)
|
||||
{
|
||||
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "The source string is too long. Cannot handle it correctly.");
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "The source string is too long. Cannot handle it correctly.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -119,7 +120,7 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t
|
|||
|
||||
if (*alldevs == NULL)
|
||||
{
|
||||
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"No interfaces found! Make sure libpcap/Npcap is properly installed"
|
||||
" on the local machine.");
|
||||
return -1;
|
||||
|
@ -209,7 +210,7 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t
|
|||
}
|
||||
|
||||
/* Save the path for future reference */
|
||||
pcap_snprintf(path, sizeof(path), "%s", name);
|
||||
snprintf(path, sizeof(path), "%s", name);
|
||||
pathlen = strlen(path);
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -224,7 +225,7 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t
|
|||
|
||||
if (filehandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Error when listing files: does folder '%s' exist?", path);
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "Error when listing files: does folder '%s' exist?", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -237,7 +238,10 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t
|
|||
|
||||
if (filedata == NULL)
|
||||
{
|
||||
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Error when listing files: does folder '%s' exist?", path);
|
||||
DIAG_OFF_FORMAT_TRUNCATION
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "Error when listing files: does folder '%s' exist?", path);
|
||||
DIAG_ON_FORMAT_TRUNCATION
|
||||
closedir(unixdir);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
@ -249,11 +253,13 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t
|
|||
/* Skip the file if the pathname won't fit in the buffer */
|
||||
if (pathlen + strlen(filedata.cFileName) >= sizeof(filename))
|
||||
continue;
|
||||
pcap_snprintf(filename, sizeof(filename), "%s%s", path, filedata.cFileName);
|
||||
snprintf(filename, sizeof(filename), "%s%s", path, filedata.cFileName);
|
||||
#else
|
||||
if (pathlen + strlen(filedata->d_name) >= sizeof(filename))
|
||||
continue;
|
||||
pcap_snprintf(filename, sizeof(filename), "%s%s", path, filedata->d_name);
|
||||
DIAG_OFF_FORMAT_TRUNCATION
|
||||
snprintf(filename, sizeof(filename), "%s%s", path, filedata->d_name);
|
||||
DIAG_ON_FORMAT_TRUNCATION
|
||||
#endif
|
||||
|
||||
fp = pcap_open_offline(filename, errbuf);
|
||||
|
@ -268,6 +274,11 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t
|
|||
PCAP_ERRBUF_SIZE, errno,
|
||||
"malloc() failed");
|
||||
pcap_freealldevs(*alldevs);
|
||||
#ifdef _WIN32
|
||||
FindClose(filehandle);
|
||||
#else
|
||||
closedir(unixdir);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -297,6 +308,11 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t
|
|||
if (pcap_createsrcstr(tmpstring, PCAP_SRC_FILE, NULL, NULL, filename, errbuf) == -1)
|
||||
{
|
||||
pcap_freealldevs(*alldevs);
|
||||
#ifdef _WIN32
|
||||
FindClose(filehandle);
|
||||
#else
|
||||
closedir(unixdir);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -307,6 +323,11 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t
|
|||
PCAP_ERRBUF_SIZE, errno,
|
||||
"malloc() failed");
|
||||
pcap_freealldevs(*alldevs);
|
||||
#ifdef _WIN32
|
||||
FindClose(filehandle);
|
||||
#else
|
||||
closedir(unixdir);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -321,6 +342,11 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t
|
|||
PCAP_ERRBUF_SIZE, errno,
|
||||
"malloc() failed");
|
||||
pcap_freealldevs(*alldevs);
|
||||
#ifdef _WIN32
|
||||
FindClose(filehandle);
|
||||
#else
|
||||
closedir(unixdir);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -334,9 +360,11 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Close the search handle. */
|
||||
#ifdef _WIN32
|
||||
FindClose(filehandle);
|
||||
#else
|
||||
closedir(unixdir);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
@ -370,7 +398,7 @@ pcap_t *pcap_open(const char *source, int snaplen, int flags, int read_timeout,
|
|||
|
||||
if (strlen(source) > PCAP_BUF_SIZE)
|
||||
{
|
||||
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "The source string is too long. Cannot handle it correctly.");
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "The source string is too long. Cannot handle it correctly.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -444,17 +472,19 @@ pcap_t *pcap_open(const char *source, int snaplen, int flags, int read_timeout,
|
|||
return fp;
|
||||
|
||||
fail:
|
||||
DIAG_OFF_FORMAT_TRUNCATION
|
||||
if (status == PCAP_ERROR)
|
||||
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s",
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s",
|
||||
name, fp->errbuf);
|
||||
else if (status == PCAP_ERROR_NO_SUCH_DEVICE ||
|
||||
status == PCAP_ERROR_PERM_DENIED ||
|
||||
status == PCAP_ERROR_PROMISC_PERM_DENIED)
|
||||
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s (%s)",
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s (%s)",
|
||||
name, pcap_statustostr(status), fp->errbuf);
|
||||
else
|
||||
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s",
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s",
|
||||
name, pcap_statustostr(status));
|
||||
DIAG_ON_FORMAT_TRUNCATION
|
||||
pcap_close(fp);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#include <netinet/tcp.h>
|
||||
#include <netinet/tcpip.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -126,6 +125,9 @@ pcap_read_nit(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
|||
* Loop through each packet. The increment expression
|
||||
* rounds up to the next int boundary past the end of
|
||||
* the previous packet.
|
||||
*
|
||||
* This assumes that a single buffer of packets will have
|
||||
* <= INT_MAX packets, so the packet count doesn't overflow.
|
||||
*/
|
||||
n = 0;
|
||||
ep = bp + cc;
|
||||
|
@ -168,7 +170,7 @@ pcap_read_nit(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
|||
continue;
|
||||
|
||||
default:
|
||||
pcap_snprintf(p->errbuf, sizeof(p->errbuf),
|
||||
snprintf(p->errbuf, sizeof(p->errbuf),
|
||||
"bad nit state %d", nh->nh_state);
|
||||
return (-1);
|
||||
}
|
||||
|
@ -179,7 +181,7 @@ pcap_read_nit(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
|||
caplen = nh->nh_wirelen;
|
||||
if (caplen > p->snapshot)
|
||||
caplen = p->snapshot;
|
||||
if (bpf_filter(p->fcode.bf_insns, cp, nh->nh_wirelen, caplen)) {
|
||||
if (pcap_filter(p->fcode.bf_insns, cp, nh->nh_wirelen, caplen)) {
|
||||
struct pcap_pkthdr h;
|
||||
h.ts = nh->nh_timestamp;
|
||||
h.len = nh->nh_wirelen;
|
||||
|
@ -197,7 +199,7 @@ pcap_read_nit(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
|||
}
|
||||
|
||||
static int
|
||||
pcap_inject_nit(pcap_t *p, const void *buf, size_t size)
|
||||
pcap_inject_nit(pcap_t *p, const void *buf, int size)
|
||||
{
|
||||
struct sockaddr sa;
|
||||
int ret;
|
||||
|
@ -371,7 +373,7 @@ pcap_create_interface(const char *device _U_, char *ebuf)
|
|||
{
|
||||
pcap_t *p;
|
||||
|
||||
p = pcap_create_common(ebuf, sizeof (struct pcap_nit));
|
||||
p = PCAP_CREATE_COMMON(ebuf, struct pcap_nit);
|
||||
if (p == NULL)
|
||||
return (NULL);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue