Commit Graph

7685 Commits

Author SHA1 Message Date
Bill Fenner
498f33b5eb ICMP: print RFC8335 PROBE extended echo/reply messages
Add interface name, ifindex and IP address printing for Interface
Information Object, and use the newly-refactored object printing
to print the single object included in an RFC8335 PROBE message.

Include a test with several well-formed packets, and one test
with a truncated packet (truncated packet supplied by fuzzer).
2024-07-11 15:14:47 +00:00
Guy Harris
605654a1d8 autoconf: fix buggy ether_ntohost() test.
First, find out where, if anywhere, ether_ntohost() is declare, *then*
test whether it's buggy - using code taken from addrtoname.c to figure
out what to include and, if there's nothing that works, how to work
around it.

(This means that a bunch of platforms will start using ether_ntohost().)
2024-07-10 23:01:01 -07:00
Guy Harris
97d13d3344 CMake: fixes to cmakeconfig.h.in.
Chagne the comment for HAVE_LIBCRYPTO to match the autoconf version.

Remove HAVE_OPENSSL_EVP_H - we don't set it, and we don't test it.
2024-07-10 13:25:17 -07:00
Guy Harris
fc8465a50d CMake: use pkg-config and Homebrew when looking for libcrypto.
Do the same sort of stuff that configure does, but CMake-style.
2024-07-10 12:10:42 -07:00
Guy Harris
749988b236 autotools: use pkg-config and Homebrew when looking for libcrypto.
Grab the stuff from libpcap's configure script that looks for libssl
(and libcrypto) and adapt it to look for libcrypto.

his includes some macros to check using pkg-config (and other macros,
such as macros to save and restore CFLAGS, LIBS, and LDFLAGS; any
resemblance between their names and the cmake_push_check_state() and
cmake_pop_check_state() commands is *entirely* coincidental :-)).

Instead of checking for DES_cbc_encrypt(), which we don't use, to
determine whether the libcrypto we found is usable, check for
EVP_CIPHER_CTX_block_size(), which we *do* use.  (We also check whether
the openssl/evp.h header exists; if it doesn't, we might have found the
libcrypto that Apple bundles with macOS, for which they do *NOT* provide
the header in newer versions of Xcode.)  See also #1174.

This means that we don't need to check whether we have openssl/evp.h at
compile time - now, if we don't, we don't even set HAVE_LIBCRYPTO, so
there's no need to check HAVE_OPENSSL_EVP_H.
2024-07-09 23:04:41 -07:00
Guy Harris
ae83a79e03 CMake: fix a comment. [skip ci]
We're checking for both pcap_open() and pcap_findalldevs_ex().
2024-07-09 18:15:13 -07:00
Guy Harris
9ee0608e63 CMake: check for pcap_findalldevs_ex.
We do so for autotools, and we currently have separate ifdefs for
pcap_open and pcap_findalldevs_ex, rather than treating the presence of
pcap_open as an indication that we have the entire remote capture API
(the latter is what Wireshark does).
2024-07-09 17:58:39 -07:00
Guy Harris
c02b47db92 autotools, cmake: work around an Xcode 15+ issue.
There appears to be no way to build tcpdump on macOS Ventura with Xcode
15 with the system libpcap and have the resulting program run without
getting an error due to failing to find pcap_open() or
pcap_findalldevs_ex() at startup.

In particular, there appears to be no way to use __builtin_available()
to protect accesses to the routines that showed up in Sonoma, so that
the run-time linker doesn't fail if the routine in question isn't
present.  Perhaps it requires more compiler command-line arguments.

So, instead, only check for pcap_open() and pcap_findalldevs_ex() if 1)
this isn't macOS or 2) we're not building with the system libpcap.
2024-07-09 16:09:12 -07:00
Guy Harris
8e12b7ff03 autotools: don't put anything before -I and -L flags for local libpcap.
Those might point to a directory with headers and libraries for an
installed version of libpcap; if we've already decided to use a local
version in the source tree next to us, don't put -I and -L flags from
--with-crypto in front of them, put those flags *after* what's already
in V_INCLS and LIBS.
2024-07-09 04:31:39 -07:00
Francois-Xavier Le Bail
3dc8bebab7 Autoconf: Use V_INCLS to update the list of include search paths
This is the one used in the Makefile depend target via INCLS.
2024-07-07 17:26:04 +00:00
Guy Harris
d1ae6788c3 Update to the 1.13 SDK for Npcap. 2024-05-29 11:28:48 -07:00
Guy Harris
4b6535c921 erspan: handle the Type III frame type field.
Show its value and only dissect the payload as an Ethernet frame if it's
type 0, for Ethernet.

Add a test file for frame type 0, rename the existing file to
indicate that it uses the unknown frame type 7 (which ain't Ethernet),
and regenerate that file.
2024-05-22 11:52:56 -07:00
Guy Harris
36b6a5d70c erspan: add support for ERSPAN type III. 2024-05-21 10:48:19 -07:00
Guy Harris
852b62ab00 Remove missing/datalinks.c
That should have been removed in
d5b1a160a3.
2024-05-20 11:30:45 -07:00
Francois-Xavier Le Bail
ad42bfe536 CI: Remove a comment about a fixed warning
It is a follow-up to 5adcf64ae8.
2024-05-20 13:47:27 +02:00
Francois-Xavier Le Bail
5adcf64ae8 funcattrs: Update the NORETURN definition condition for TinyCC
Current TinyCC support __attribute((noreturn)).

[skip ci]
2024-05-20 11:17:09 +00:00
Francois-Xavier Le Bail
57f1c409a4 CI: Add TinyCC (aka TCC) support
Identification examples: tcc-0.9.27, tcc-0.9.28rc

There are currently warnings such as:
print-802_11.c:3317: warning: assignment discards qualifiers from pointer
  target type
print-esp.c:373: warning: function might return no value: 'ldp_pdu_print'
So use: TCPDUMP_TAINTED=yes

Works on linux-amd64.
Does not work on linux-armv7l with BUILD_LIBPCAP=yes / CMAKE=yes
(Segmentation fault, libpcap dynamically linked). Works with 0.9.28rc.

TinyCC can be found at https://bellard.org/tcc/,
https://repo.or.cz/r/tinycc.git or as package on some distros.
2024-05-20 11:17:09 +00:00
Guy Harris
83d7ac7aac esp: report a warning, not an error, for an invalid hex digit in a secret.
We already report a warning if the secret is too long; do so if there's
an invalid hex digit in the secret.

See

https://github.com/the-tcpdump-group/tcpdump/pull/1185#issuecomment-2119211162

While we're at it, put the length of the string, in hex-digit pairs,
into a size_t rather than an unsigned int, just in case (it's unlikely
that it will overflow a 32-bit unsigned integer, but...).
2024-05-19 23:03:32 -07:00
Guy Harris
d5b1a160a3 Get rid of support for libpcap prior to 1.0.
This lets us remove a bunch of configure-time and compile-time tests.

Update documentation to reflect this.

WinPcap 4.1.3 is based on libpcap 1.0, but doesn't export all of the new
APIs, so it won't work with code that uses any of the other APIs, which
tcpdump does, so don't test with WinPcap.
2024-05-19 12:43:23 -07:00
Guy Harris
074d10aa1a esp: mark unreached code as such.
Some compilers might not understand the declaration of the ndo_error
member of an netdissect_options as pointing to a function that never
returns; add a /* NOTREACHED */ comment in case they recognize that as a
hint.
2024-05-19 12:25:59 -07:00
Francois-Xavier Le Bail
47edb26bde NFS: Add two length checks
This change avoids adding a large number to the packet pointer and
overflow it.

It also avoids the differences between 32-bit and 64-bit printouts.

Example:
32-bit:
NFS request xid 1168185174 80 readdirplus fh / 1441792 bytes @ 1585267068834414592 [|nfs]
---
64-bit:
NFS request xid 1168185174 80 readdirplus [|nfs]

Add a test file.
Update a test output accordingly.
2024-05-08 19:12:19 +00:00
Francois-Xavier Le Bail
067f7dd17d frag6: Fix invalid 32-bit versus 64-bit printouts
Print "[length < 0] (invalid)" when fragment length is negative.

In this case, e.g. when IPv6 payload length is zero, the 32-bit and
64-bit printouts were different.

Example:
32-bit:
frag (0x80000074:1280|4294967288)
---
64-bit:
frag (0x80000074:1280|18446744073709551608)

Add a test file.
2024-05-06 19:10:03 +00:00
Francois-Xavier Le Bail
e5b1cab048 Autoconf: Update an AC_DEFINE()
Same result in config.h as with CMake.

Before:
#define NETINET_ETHER_H_DECLARES_ETHER_NTOHOST /**/

After:
#define NETINET_ETHER_H_DECLARES_ETHER_NTOHOST 1

[skip ci]
2024-05-03 09:15:51 +02:00
Francois-Xavier Le Bail
6d1136ac57 TESTrun: Print HAVE_FPTYPE1/HAVE_FPTYPE2 based on the --fp-type option 2024-04-29 11:59:57 +02:00
Francois-Xavier Le Bail
37745f6daa frag6: Refactor duplicate code
Update a test output accordingly.
2024-04-27 10:19:37 +02:00
Francois-Xavier Le Bail
429c68e33b IPv6: Update a comment
"advance" is used since commit 66df248b49.

[skip ci]
2024-04-27 08:42:55 +02:00
Denis Ovsienko
4822cd1f88 README.md: Add QNX to the formerly supported OS list. [skip ci]
There are various mentions of QNX implementing BPF and running tcpdump,
but finding an actual running OS and verifying it seems complicated.
2024-04-24 22:56:35 +01:00
Francois-Xavier Le Bail
bb704ed32d Rename the suffix of a pcap test file to .pcap 2024-04-17 10:57:19 +02:00
Guy Harris
baa6d9b864 SLL2: indicate why we only do interface lookup on Linux. [skip ci] 2024-04-15 13:57:29 -07:00
Francois-Xavier Le Bail
4ffb715478 CHANGES: Update an entry to avoid any misunderstanding
[skip ci]
2024-04-13 11:41:57 +02:00
Francois-Xavier Le Bail
1ed3921b6b CHANGES: Sync with the 4.99 branch
[skip ci]
2024-04-10 10:30:07 +02:00
Denis Ovsienko
cc0dc6a97c Fix deprecation macros for old Sun C. [skip ci]
As Francois-Xavier points it out, my recent commit 5265743 in certain
contexts adds rather than removes compiler warnings:

cc: Sun C 5.12 SunOS_i386 Patch 148918-11 2017/12/13
"tcpdump.c", line 3267: warning: bad message tag: E_DEPRECATED_ATT
"tcpdump.c", line 3307: warning: bad message tag: E_DEPRECATED_ATT

Get Sun C versions right to fix that.
2024-04-09 15:05:37 +01:00
Francois-Xavier Le Bail
7652b93066 CHANGES: Add two changes backported to the 4.99 branch
[skip ci]
2024-04-09 14:50:01 +02:00
Francois-Xavier Le Bail
420f9f215b mkdep: Exit with a non-zero status if a command fails
This could help detect errors such as in the previous commit.
2024-04-09 12:37:23 +00:00
Francois-Xavier Le Bail
db1e124f49 Makefile.in: Fix the depend target
Fix an error on Solaris 10 like:
./mkdep: /opt/solarisstudio12.3/bin/cc -D_STDC_C99=: not found

When configure get some compiler option like:
checking for /opt/solarisstudio12.3/bin/cc option to accept ISO C99...
-D_STDC_C99=
Makefile will contain:
CC = /opt/solarisstudio12.3/bin/cc -D_STDC_C99=

And if we use '-c "$(CC)"' mkdep will set and try to run:
CC="/opt/solarisstudio12.3/bin/cc -D_STDC_C99=", which is incorrect.

Remove the quotes to allow mkdep to set CC with the compiler name and
set flags with the option.
2024-04-09 12:37:23 +00:00
Guy Harris
7d48702a91 Extract common file rotation code into routines. 2024-04-07 22:24:24 -07:00
Francois-Xavier Le Bail
55b522a3ed CHANGES: Add a change in the main section
[skip ci]
2024-04-07 20:15:22 +02:00
Francois-Xavier Le Bail
1f583a44e1 Makefile.in: Update the .c.o build rule
Don't use the hacks for the rather old SunOS 4.

It's helps to do VPATH builds, e.g. 32-bit, 64-bit in two directories.
(https://www.gnu.org/software/automake/manual/html_node/VPATH-Builds.html)
2024-04-07 17:51:29 +00:00
Denis Ovsienko
a0ffbfba6c CMake: Get the comment about EXTRA_CFLAGS right. [skip ci]
The "testprogs" sentence applies to libpcap only.
2024-04-05 15:17:08 +01:00
Denis Ovsienko
af7e049e77 doc: Add recent OmniOS and OpenIndiana details. 2024-04-05 14:55:34 +01:00
Denis Ovsienko
4e99e07496 CHANGES: Move the cc_werr_cflags() entry to 4.99.5. 2024-04-05 12:01:59 +01:00
Francois-Xavier Le Bail
6eccce9a7c CHANGES: Move a backported change to the 4.99 branch
Use Autoconf with 'A', as this is the official name of the package.

[skip ci]
2024-04-03 13:30:33 +02:00
Francois-Xavier Le Bail
42116158c3 Update the error message when checking for pcap_loop()
Add a first error case when trying to build a 32-bit tcpdump with a
64-bit libpcap or vice versa.

[skip ci]
2024-04-03 04:43:09 +00:00
Denis Ovsienko
0e04b9da80 SLL2: Translate interface indices to names on Linux only.
print-sll.c uses HAVE_NET_IF_H, which does not always work right: the
header is in POSIX.1-2001, but the result of if_indextoname() is
irrelevant if the current OS is not Linux, in which case the packet was
captured on a different host because libpcap produces DLT_LINUX_SLL2 on
Linux only.  The result can be irrelevant on Linux too, but this does
not have an easy solution.

To reduce the problem space, switch print-sll.c to check for __linux__
instead.  In tcpdump.c print the warning about interface names only if
sll2_if_print() would print interface names.  Since HAVE_NET_IF_H has no
purpose now, remove the checks for <net/if.h>.
2024-04-02 11:36:13 +01:00
Denis Ovsienko
b779eda489 Include diag-control.h only where necessary.
Neither addrtoname.c nor extract.h nor netdissect.h nor print-sll.c
require the header anymore, so do not include it there.  Add a missing
conditional include to netdissect.c.
2024-04-02 11:36:13 +01:00
Rose
9b97f85e62 Prefer calloc over malloc
This makes the code cleaner anyway and avoids branching.
2024-04-02 11:19:15 +01:00
Francois-Xavier Le Bail
5a25aeddad Cirrus CI: Add the binutils-dev package, Linux task
It is needed to build with --enable-instrument-functions
(make releasecheck).
2024-04-02 12:01:43 +02:00
Denis Ovsienko
778e4bfd4e Cirrus CI: Reduce the footprint a little bit. [skip appveyor]
Same as in libpcap.
2024-04-01 17:48:42 +01:00
Denis Ovsienko
f80e2dcc0d Cirrus CI: Do not test on FreeBSD 14.0. [skip ci]
Buildbot does it now.
2024-03-31 10:32:59 +01:00
Francois-Xavier Le Bail
dab871e8be Fix incompatible pointer types with time functions calls on Windows
On Windows in a struct timestamp, tv_sec is a long not a 64-bit time_t.

The problem shows:
listening on \Device\NPF_Loopback, link-type NULL (BSD loopback),
snapshot length 262144 bytes
    1  [localtime() or gmtime() couldn't convert the date and time].052255
       IP 10.0.0.10 > 224.0.0.251: igmp v2 report 224.0.0.251
    2  [localtime() or gmtime() couldn't convert the date and time].792000
       IP 10.0.0.10.138 > 10.0.0.255.138: NBT UDP PACKET(138)

The warnings with clang-cl were:
util-print.c(253,18): warning: incompatible pointer types passing
  'const long *' to parameter of type 'const time_t *'
      (aka 'const long long *') [-Wincompatible-pointer-types]
  253 |                 tm = localtime(&tv->tv_sec);
      |                                ^~~~~~~~~~~

util-print.c(255,15): warning: incompatible pointer types passing
  'const long *' to parameter of type 'const time_t *'
      (aka 'const long long *') [-Wincompatible-pointer-types]
  255 |                 tm = gmtime(&tv->tv_sec);
      |                             ^~~~~~~~~~~
2024-03-29 13:24:27 -07:00