]> The Tcpdump Group git mirrors - tcpdump/log
tcpdump
3 months agoReimplement the tests similarly to libpcap. [skip appveyor] 1280/head
Denis Ovsienko [Fri, 7 Feb 2025 11:52:39 +0000 (11:52 +0000)] 
Reimplement the tests similarly to libpcap. [skip appveyor]

Import TESTlib.pm, TESTst.pm and TESTmt.pm from libpcap.  In TESTrun use
strict and warnings, also address all Perl issues that manifest because
of that, remove old code that the imported files make redundant and
clean the rest up.  Ibid., remove the core dump file before every test
and apply the "only this one test" mode even if the test does not come
from the TESTLIST file; focus on tcpdump specifics and have the imported
files handle all test/result logistics.

The latter among other things places all temporary test files in a
proper temporary directory rather than the source tree, which in turn
eliminates the tests/NEW and tests/DIFF temporary directories, which
also includes *.out.raw.stderr files; the .passed and .failed files have
been gone since commit b82970c in 2020.  This way, the tests/.gitignore
file no longer has a purpose, so remove it and the associated exemption
for TEST_DIST in Makefile.  Remove failure-outputs.txt from the
top-level .gitignore as well.  Prune "make distclean" as well.

Merge tests/*.tests into TESTrun: these are a part of the source tree
rather than volatile external data, so instead of implementing the
required run-time logistics just place the Perl data structures in the
only Perl script that uses them.  Convert "config_set" and
"config_unset" using "skip" and equivalent Perl expressions.

Since these changes rewrite most of TESTrun, reindent and reformat it to
match the code style of the new files.

3 months agoMake all test names unique in TESTLIST.
Denis Ovsienko [Fri, 7 Feb 2025 11:36:00 +0000 (11:36 +0000)] 
Make all test names unique in TESTLIST.

3 months agoPTP: Refine timestamp printing. 1277/head
Denis Ovsienko [Mon, 20 Jan 2025 14:01:45 +0000 (14:01 +0000)] 
PTP: Refine timestamp printing.

In ptp_print_timestamp_identity() and ptp_print_announce_msg() use
ptp_print_timestamp() to deduplicate code.  In ptp_print_timestamp()
change the format to SECONDS.NANOSECONDS and indicate an invalid
nanoseconds value.  Update the tests.  This resolves GH issue #1260.

3 months agoReport invalid microseconds as "us", not "ms".
Denis Ovsienko [Mon, 20 Jan 2025 13:59:44 +0000 (13:59 +0000)] 
Report invalid microseconds as "us", not "ms".

In timeval-operations.h for microseconds and nanoseconds define both the
maximum number of units per second and the string to use for reporting
an invalid value.  Use the new macros in ts_frac_print() and update a
test.

For consistency in print-arista.c instead of MAX_VALID_NS and
BOGUS_NS_STR use the macros from timeval-operations.h.

3 months agoUpdate the GitHub issue template for the new workflow
Francois-Xavier Le Bail [Fri, 17 Jan 2025 11:11:13 +0000 (12:11 +0100)] 
Update the GitHub issue template for the new workflow

Summary:
Create the .github/ISSUE_TEMPLATE directory
Rename the file ISSUE_TEMPLATE to .github/ISSUE_TEMPLATE/issue_template.md
Update this file with some keywords (name, about, ...)
Add a .github/ISSUE_TEMPLATE/config.yml file containing
"blank_issues_enabled: false".

[skip ci]

3 months agoLISP: Add a length check
Francois-Xavier Le Bail [Sun, 12 Jan 2025 21:05:02 +0000 (22:05 +0100)] 
LISP: Add a length check

Verify we have at least the header length.

Print the protocol name with nd_print_protocol_caps() before any check.
Update the lisp_type[] structure accordingly.

Add a test file with an invalid length.

4 months agoESP: Delete a useless custom bounds check
Francois-Xavier Le Bail [Thu, 9 Jan 2025 15:35:53 +0000 (16:35 +0100)] 
ESP: Delete a useless custom bounds check

The two GET_BE_U_4() perform the bounds checks.

Print the protocol name, with nd_print_protocol_caps(), before any
check.

Add a test file with a truncated ESP packet.

4 months agoCHANGES: Add changes backported to 4.99
Francois-Xavier Le Bail [Wed, 8 Jan 2025 20:12:09 +0000 (21:12 +0100)] 
CHANGES: Add changes backported to 4.99

[skip ci]

4 months agoISO: avoid undefined behavior and integer overflow in the fletcher checksum calculation
Bill Fenner [Tue, 11 Oct 2022 20:10:46 +0000 (13:10 -0700)] 
ISO: avoid undefined behavior and integer overflow in the fletcher checksum calculation

The fletcher checksum calculation would sometimes left-shift
a negative number, which is an undefined operation.  Rework the
code to avoid this.

checksum.c:186:20: runtime error: left shift of negative value -36
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior checksum.c:186:20

Unlike some checksum routines that use the defined semantics of
2's-complement unsigned overflow to their advantage, this one
gets the wrong value if it is allowed to overflow, due to the
use of mod-255.

Convert c1 to uint64_t to avoid overflow.

checksum.c:163:16: runtime error: unsigned integer overflow: NNN + NNN
  cannot be represented in type 'unsigned int'

Use integers during subtraction to avoid implicit conversion to unsigned
when calculating both x and y

checksum.c:172:18: runtime error: unsigned integer overflow: NNN - NNN
  cannot be represented in type 'unsigned int'
checksum.c:172:9: runtime error: implicit conversion from type
  'unsigned int' of value NNN (32-bit, unsigned) to type 'int' changed
  the value to -NNN (32-bit, signed)
checksum.c:173:12: runtime error: unsigned integer overflow: NNN - NNN
  cannot be represented in type 'unsigned int'
checksum.c:173:9: runtime error: implicit conversion from type
  'unsigned int' of value NNN (32-bit, unsigned) to type 'int' changed
  the value to -NNN (32-bit, signed)

4 months agoNFS: Delete dead code
Francois-Xavier Le Bail [Tue, 7 Jan 2025 19:21:12 +0000 (20:21 +0100)] 
NFS: Delete dead code

Since  commit f2eaaa35725c6cb52e9e3947769fc6e7f2579dee in year 2000
the typedef struct my_fsid has a field 'char Opaque_Handle[2 * 32 + 1];'

Thus sizeof(*fsidp) is > 14.
Delete the else block as dead code and the two useless if.

This should remove two Visual Studio warnings:
parsenfsfh.c(318,25): warning C4127: conditional expression is constant
parsenfsfh.c(319,22): warning C4127: conditional expression is constant

4 months agoBOOTP: Use an uint16_t variable to get the result of a GET_BE_U_2()
Francois-Xavier Le Bail [Tue, 7 Jan 2025 10:54:11 +0000 (11:54 +0100)] 
BOOTP: Use an uint16_t variable to get the result of a GET_BE_U_2()

This will fix this Visual Studio warning:
print-bootp.c(1009,18): warning C4242: =: conversion from uint16_t to
uint8_t, possible loss of data

4 months agoFix comments. [skip ci]
Guy Harris [Tue, 7 Jan 2025 20:02:17 +0000 (12:02 -0800)] 
Fix comments. [skip ci]

Yes, the offending set of *BSDs (FreeBSD, DragonFly BSD, and
CupertinoBSD) all do define IPPROTO_PIGP.  And the #defines are
IPPROTO_xxx, not IP_PROTO_xxx.

4 months agoAdd macOS to the list of OSes that define IPPROTO_IGRP as 88. [skip ci]
Guy Harris [Tue, 7 Jan 2025 12:00:14 +0000 (04:00 -0800)] 
Add macOS to the list of OSes that define IPPROTO_IGRP as 88. [skip ci]

4 months agoAdd comments about the IGRP/EIGRP protocol number and #define mess.
Guy Harris [Tue, 7 Jan 2025 07:23:21 +0000 (23:23 -0800)] 
Add comments about the IGRP/EIGRP protocol number and #define mess.

The current IANA protocol number assignments page lists 9 as "any
private interior gateway (used by Cisco for their IGRP)" and 88 as
"EIGRP" from Cisco.

Recent FreeBSD and DragonFly BSD <netinet/in.h> headers define
IP_PROTO_IGRP as 9 and IP_PROTO_IGRP as 88.  We define IP_PROTO_PIGP
("private interior gateway protocol") as 9 and IP_PROTO_EIGRP as 88;
those names* better match what the current protocol number assignments
say.

4 months agotcpdump: show error message for PCAP_ERROR_CAPTURE_NOTSUP.
Guy Harris [Sat, 4 Jan 2025 23:29:19 +0000 (15:29 -0800)] 
tcpdump: show error message for PCAP_ERROR_CAPTURE_NOTSUP.

If an attempt to open a capture device failed because capturing isn't
supported on that device, check whether an error message with a further
explanation was provided and, if so, report it.

4 months agoCHANGES: Add changes backported to 4.99
Francois-Xavier Le Bail [Sun, 5 Jan 2025 11:15:04 +0000 (12:15 +0100)] 
CHANGES: Add changes backported to 4.99

[skip ci]

4 months agofrag6: Add a bounds check in non-verbose mode
Francois-Xavier Le Bail [Sat, 4 Jan 2025 19:09:37 +0000 (20:09 +0100)] 
frag6: Add a bounds check in non-verbose mode

Define ND_LONGJMP_FROM_TCHECK.

Rename a test and its output, with "-v" in the names.
Add a test case (same pcap printed without "-v").

4 months agoIP: Use ND_TTEST_LEN() instead of a custom bounds check
Francois-Xavier Le Bail [Fri, 3 Jan 2025 15:08:32 +0000 (16:08 +0100)] 
IP: Use ND_TTEST_LEN() instead of a custom bounds check

This avoids an invalid-pointer-pair AddressSanitizer error with options
-fsanitize=address -fsanitize=pointer-compare
and
ASAN_OPTIONS=detect_invalid_pointer_pairs=1

The error was:
    ip_printroute_asan                      : TEST FAILED[...]

reading from file ip_printroute_asan.pcap, link-type EN10MB (Ethernet),
  snapshot length 60
=================================================================
==ERROR: AddressSanitizer: invalid-pointer-pair: 0x60600000006a
  0x60600000005c
    #0 0x558ce1cddb0b in ip_print
      /home/cpe/soft-origin/tcpdump/my-tcpdump/print-ip.c:429:55

0x60600000006a is located 14 bytes after 60-byte region
  [0x606000000020,0x60600000005c)
allocated by thread T0 here:
    #0 0x558ce1c5390e in malloc
      (/home/cpe/soft-origin/tcpdump/my-tcpdump/tcpdump+0x1fd90e)
    #1 0x558ce1efbba3 in pcap_check_header
      /home/cpe/soft-origin/tcpdump/my-libpcap/sf-pcap.c:480:14

0x60600000005c is located 0 bytes after 60-byte region
  [0x606000000020,0x60600000005c)
allocated by thread T0 here:
    #0 0x558ce1c5390e in malloc
      (/home/cpe/soft-origin/tcpdump/my-tcpdump/tcpdump+0x1fd90e)
    #1 0x558ce1efbba3 in pcap_check_header
      /home/cpe/soft-origin/tcpdump/my-libpcap/sf-pcap.c:480:14

SUMMARY: AddressSanitizer: invalid-pointer-pair
  /home/cpe/soft-origin/tcpdump/my-tcpdump/print-ip.c:429:55 in ip_print

4 months agoPoint to the correct documentation for installation on Windows. [skip ci]
anubhav [Mon, 30 Dec 2024 19:49:35 +0000 (01:19 +0530)] 
Point to the correct documentation for installation on Windows. [skip ci]

4 months agoCHANGES: Add a change backported to 4.99
Francois-Xavier Le Bail [Mon, 23 Dec 2024 22:02:28 +0000 (23:02 +0100)] 
CHANGES: Add a change backported to 4.99

[skip ci]

4 months agoAdd sub-second packet timestamp checks for invalid micro/nano
Francois-Xavier Le Bail [Sun, 22 Dec 2024 14:12:56 +0000 (15:12 +0100)] 
Add sub-second packet timestamp checks for invalid micro/nano

Now prints e.g.:
    2  17:16:10.1000000 (invalid ms) IP [...]
    3  17:16:10.2147483648 (invalid ms) IP [...]
or
    2  17:16:10.1000000000 (invalid ns) IP [...]
    3  17:16:10.2147483648 (invalid ns) IP [...]

Add two test files.

4 months agotests: Fix some tests with invalid microsecond packet timestamps
Francois-Xavier Le Bail [Fri, 20 Dec 2024 19:37:09 +0000 (20:37 +0100)] 
tests: Fix some tests with invalid microsecond packet timestamps

If the timestamp for packets are given in seconds and microseconds,
a microsecond value > 999999 is invalid. Set it to 999999.

4 months agoIKEv1: Fix a typo in a comment
Francois-Xavier Le Bail [Thu, 19 Dec 2024 20:23:17 +0000 (21:23 +0100)] 
IKEv1: Fix a typo in a comment

[skip ci]

4 months agoCirrus CI: Do not install coreutils on macOS. [skip appveyor]
Denis Ovsienko [Tue, 17 Dec 2024 19:33:40 +0000 (19:33 +0000)] 
Cirrus CI: Do not install coreutils on macOS. [skip appveyor]

libpcap build & test process now tolerates a missing timeout(1), so
let's keep the build environment as close to the original as possible.
This reverts commit 673a2fe.

4 months agoCHANGES: move some misplaced main branch changes. [skip ci]
Guy Harris [Tue, 17 Dec 2024 20:14:08 +0000 (12:14 -0800)] 
CHANGES: move some misplaced main branch changes. [skip ci]

They were mistakenly put in a section for a 1.10 branch change.

4 months agoCHANGES: additional pflog changes. [skip ci]
Guy Harris [Tue, 17 Dec 2024 20:10:46 +0000 (12:10 -0800)] 
CHANGES: additional pflog changes. [skip ci]

Switch to sentence case for some entries while we're at it.

4 months agopflog: handle OpenBSD's "rewriten" flag and addresses.
Guy Harris [Tue, 17 Dec 2024 19:46:50 +0000 (11:46 -0800)] 
pflog: handle OpenBSD's "rewriten" flag and addresses.

Derived from the OpenBSD tcpdump.

4 months agopflog: don't use PF_ as a prefix for #defines.
Guy Harris [Tue, 17 Dec 2024 09:52:52 +0000 (01:52 -0800)] 
pflog: don't use PF_ as a prefix for #defines.

PF_ is used as a prefix for packet family values, and that may cause a
collision between PF_ packet family values, such as PF_DIVERT, and PF_
action valus, such as... PF_DIVERT.

Use PFACT_ for action values and PFDIR_ for direction values.

4 months agopflog: print the ruleset if it's present.
Guy Harris [Tue, 17 Dec 2024 09:00:52 +0000 (01:00 -0800)] 
pflog: print the ruleset if it's present.

Do that regardless of whether the subrule is present.

Picked up from the OpenBSD tcpdump.

4 months agopflog: handle all types of pflog files, as best as can be done.
Guy Harris [Tue, 17 Dec 2024 08:22:06 +0000 (00:22 -0800)] 
pflog: handle all types of pflog files, as best as can be done.

We can distinguish between FreeBSD, OpenBSD, and everything else
(NetBSD, DragonFly BSD, and Darwin) based on the length field in the
header.

For NetBSD, DragonFly BSD, and Darwin, the differences are the meaning
of certain reason and action codes; we just mark those with the OSes and
meanings, so the user will have to figure out whether reason code 15 is
"state-locked' (NetBSD)" or "dummynet" (Darwin)". The other ones
shouldn't occur on OSes other than Darwin, but we mark it just in case
they do.

Fix the handling of "UID not present"; that's 0xFFFFFFFFU in FreeBSD,
OpenBSD, and DragonFly BSD, but it's 0x7FFFFFFFU in NetBSD and Darwin,
so for "neither NetBSD nor OpenBSD" we check for both of those values.

Do the checks for minimum and maximum header lengths before we round
the header length up.

4 months agoCHANGES: some additional changes not in 4.99. [skip ci]
Guy Harris [Tue, 17 Dec 2024 08:06:21 +0000 (00:06 -0800)] 
CHANGES: some additional changes not in 4.99. [skip ci]

4 months agoLISP: Fix a typo
Francois-Xavier Le Bail [Mon, 16 Dec 2024 10:32:24 +0000 (11:32 +0100)] 
LISP: Fix a typo

Update the outputs of two tests accordingly.

4 months agoCHANGES: changes backported to 4.99. [skip ci]
Guy Harris [Mon, 16 Dec 2024 03:27:14 +0000 (19:27 -0800)] 
CHANGES: changes backported to 4.99. [skip ci]

4 months agoCI: install coreutils with Homebrew on macOS. [skip appveyor]
Guy Harris [Sun, 15 Dec 2024 21:54:01 +0000 (13:54 -0800)] 
CI: install coreutils with Homebrew on macOS. [skip appveyor]

We need it because we do an install of libpcap, including "make check",
and "make check" requires Homebrew's coreutils in order to get the
timeout command.

5 months agoCI: Remove VS 2015 build. [skip ci]
Guy Harris [Wed, 11 Dec 2024 22:27:03 +0000 (14:27 -0800)] 
CI: Remove VS 2015 build. [skip ci]

VS 2015 is approximately 10 years old; get tid of the VS 2015 builds.

5 months agoCI: expand the matrix for AppVeyor and fix issues that finds.
Guy Harris [Wed, 11 Dec 2024 02:54:32 +0000 (18:54 -0800)] 
CI: expand the matrix for AppVeyor and fix issues that finds.

Add ARM64 builds for VS 2019 and VS 2022.

Fix cmake/Modules/FindPCAP.cmake to look in the right directory for pcap
libraries if the build isn't being done for 32-bit or 64-bit x86.

Use the -A flag for all generators; according to the CMake
documentation, they're supported for all generators in CMake 3.1 and
later and, on Windows, we require CMake 3.12 or later.  That ensures
that CMAKE_GENERATOR_PLATFORM will be set, so that we can use it to
determine the right directory in which to look for pcap libraries.

5 months agoautotools, CMake: fix issues with snprintf test and sanitizers.
Guy Harris [Tue, 10 Dec 2024 18:55:23 +0000 (10:55 -0800)] 
autotools, CMake: fix issues with snprintf test and sanitizers.

Avoid trying to cast negative values to unsigned types, or doing shifts
of signed types, in order not to have the test program fail if we're
building with undefined-behavior sanitizers enabled.

See the-tcpdump-group/libpcap#1396 for the equivalent libpcap issue.

5 months agoCMake: check whether check_c_source_runs() works.
Guy Harris [Tue, 10 Dec 2024 04:35:24 +0000 (20:35 -0800)] 
CMake: check whether check_c_source_runs() works.

That's the simplest way to check whether we can use
check_c_source_runs() to test for a suitable snprintf; it's easier than
trying to find out the target instruction set architecture and comparing
it with the host instruction set architecture, as CMake doesn't provide
any mechanism to provide the target instruction set architecture, on all
platforms, in a form that can be compared with the host instruction set
architecture, and even if the target is different, we may be able to run
code for that instruction set architecture if, for example, it's a
32-bit version of the instruction set architecture on which the build is
being done, or if there's a binary emulator.

5 months agoDECnet: Add comments about the specification. [skip ci]
Denis Ovsienko [Tue, 10 Dec 2024 12:07:15 +0000 (12:07 +0000)] 
DECnet: Add comments about the specification. [skip ci]

5 months agotests: Remove debugging leftovers from TESTrun.
Denis Ovsienko [Tue, 10 Dec 2024 12:03:34 +0000 (12:03 +0000)] 
tests: Remove debugging leftovers from TESTrun.

5 months agoRename the variable 'packets_skipped' to 'packets_to_skip'
Francois-Xavier Le Bail [Tue, 10 Dec 2024 04:10:26 +0000 (05:10 +0100)] 
Rename the variable 'packets_skipped' to 'packets_to_skip'

5 months agoFix two undefined behaviors for the pcap_loop() call
Francois-Xavier Le Bail [Sun, 8 Dec 2024 22:08:52 +0000 (23:08 +0100)] 
Fix two undefined behaviors for the pcap_loop() call

Limit the --skip argument to INT_MAX.
Limit the sum of -c and --skip arguments to INT_MAX.

Fix the regression in 3eab64d3: The '--skip 0' option is allowed to get
the first packet in some loop e.g. in a shell script.

The errors were:

tcpdump.c:2696:8: runtime error: implicit conversion from type 'int' of
  value -1 (32-bit, signed) to type 'u_int' (aka 'unsigned int')
  changed the value to 4294967295 (32-bit, unsigned)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior tcpdump.c:2696:8

tcpdump.c:2696:8: runtime error: implicit conversion from type 'u_int'
  (aka 'unsigned int') of value 4294967295 (32-bit, unsigned) to type
  'int' changed the value to -1 (32-bit, signed)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior tcpdump.c:2696:8

5 months agoautotools, CMake: add a comment.
Guy Harris [Mon, 9 Dec 2024 21:17:56 +0000 (13:17 -0800)] 
autotools, CMake: add a comment.

We should have our own copies of the ONC RPC headers, rather than
relying on the OS to supply them.  We've already done that for most if
not all other protocols.

5 months agoAdd routines to parse numeric command-line arguments, and use them.
Guy Harris [Sun, 8 Dec 2024 20:57:56 +0000 (12:57 -0800)] 
Add routines to parse numeric command-line arguments, and use them.

They do various error checks; use them instead of strto*() or atoi().

5 months agoUse C99 macros to define 64-bit constants and maximum 64-bit values.
Guy Harris [Sat, 7 Dec 2024 23:21:41 +0000 (15:21 -0800)] 
Use C99 macros to define 64-bit constants and maximum 64-bit values.

We require C99 support, so don't roll our own versions.

5 months agoLISP: Add two length checks for "invalid" cases
Francois-Xavier Le Bail [Fri, 6 Dec 2024 13:56:17 +0000 (14:56 +0100)] 
LISP: Add two length checks for "invalid" cases

Moreover:
Update a ND_ICHECK_U to ND_ICHECKMSG_U().
Add an "unsuported address family identifier" message.
Add two test cases (a pcap with two outputs, with/without -v).

5 months agoSOME/IP: Remove empty lines in output
Francois-Xavier Le Bail [Thu, 5 Dec 2024 12:00:08 +0000 (13:00 +0100)] 
SOME/IP: Remove empty lines in output

There is a newline in pretty_print_packet().

Update the output of some tests accordingly.

5 months agoUpdate the man page date. [skip ci]
Denis Ovsienko [Mon, 2 Dec 2024 11:14:20 +0000 (11:14 +0000)] 
Update the man page date. [skip ci]

5 months agoCHANGES: Add a change backported to 4.99
Francois-Xavier Le Bail [Mon, 2 Dec 2024 09:22:56 +0000 (10:22 +0100)] 
CHANGES: Add a change backported to 4.99

[skip ci]

5 months agoWarn that options -A, -x[x] and -X[X] are mutually exclusive
Francois-Xavier Le Bail [Sun, 1 Dec 2024 19:42:43 +0000 (20:42 +0100)] 
Warn that options -A, -x[x] and -X[X] are mutually exclusive

[skip ci]

5 months agoman: Add details on the relationships between -A, -X[X] and -x[x] options
Francois-Xavier Le Bail [Sat, 30 Nov 2024 18:22:02 +0000 (19:22 +0100)] 
man: Add details on the relationships between -A, -X[X] and -x[x] options

[skip ci]

5 months agoAdd the --skip option in print_usage()
Francois-Xavier Le Bail [Tue, 26 Nov 2024 11:03:27 +0000 (12:03 +0100)] 
Add the --skip option in print_usage()

This is a follow-up to d0c66a2c2aa40ee0289198086cf20e1f21b7bf9c.

[skip ci]

5 months agoBGP: Remove the UPDATE_BUF_BUFLEN() macro
Francois-Xavier Le Bail [Sun, 24 Nov 2024 21:05:53 +0000 (22:05 +0100)] 
BGP: Remove the UPDATE_BUF_BUFLEN() macro

This macro has been unused since commit 71045f95c.

5 months agoAdd comments to several #endif directives. [skip ci]
Denis Ovsienko [Sun, 24 Nov 2024 12:16:12 +0000 (12:16 +0000)] 
Add comments to several #endif directives. [skip ci]

5 months agoCHANGES: Add a change in the main section
Francois-Xavier Le Bail [Sat, 23 Nov 2024 17:27:41 +0000 (18:27 +0100)] 
CHANGES: Add a change in the main section

[skip ci]

5 months agoLISP: Modernize packet parsing
Francois-Xavier Le Bail [Thu, 21 Nov 2024 12:36:49 +0000 (13:36 +0100)] 
LISP: Modernize packet parsing

Define ND_LONGJMP_FROM_TCHECK and remove a 'trunc' label.
Make a bounds check conditional.
Use ND_ICHECK_U() for a length test.
Fix a bounds check, not invalid, but truncated.
(The bounds check is done by hex_print_with_offset() via hex_print().)
Use ND_TTEST_LEN() instead of testing ndo->ndo_snapend.
Remove an useless variable ('packet_iterator' same as 'bp').

Remove/update some comments.
Fix some indentations.
Remove some extra blank lines.

Update the outputs of two tests accordingly.

5 months agoLISP: Add three test cases (existing pcap printed without "-v")
Francois-Xavier Le Bail [Wed, 20 Nov 2024 19:46:02 +0000 (20:46 +0100)] 
LISP: Add three test cases (existing pcap printed without "-v")

Rename three test and three test outputs, with "-v" in the names.

5 months agodoc: Update OmniOS particulars. [skip ci]
Denis Ovsienko [Tue, 19 Nov 2024 12:21:18 +0000 (12:21 +0000)] 
doc: Update OmniOS particulars. [skip ci]

r151052 has been released, r151048 is now end-of-life.

5 months agoCMake: Fix the comment about versions. [skip ci]
Denis Ovsienko [Sun, 17 Nov 2024 10:58:13 +0000 (10:58 +0000)] 
CMake: Fix the comment about versions. [skip ci]

5 months agoCHANGES: Add a change in the main section
Francois-Xavier Le Bail [Fri, 15 Nov 2024 20:26:40 +0000 (21:26 +0100)] 
CHANGES: Add a change in the main section

[skip ci]

5 months agoRT6: Add a bounds check for the PadN TLV in Segment Routing Header
Francois-Xavier Le Bail [Fri, 15 Nov 2024 12:54:35 +0000 (13:54 +0100)] 
RT6: Add a bounds check for the PadN TLV in Segment Routing Header

Define ND_LONGJMP_FROM_TCHECK.

Add a test file.

5 months agoCHANGES: add changes backported to 4.99. [skip ci]
Guy Harris [Wed, 13 Nov 2024 22:16:16 +0000 (14:16 -0800)] 
CHANGES: add changes backported to 4.99. [skip ci]

5 months agoCMake: fix to support CMake 3.31.
Guy Harris [Wed, 13 Nov 2024 07:30:01 +0000 (23:30 -0800)] 
CMake: fix to support CMake 3.31.

Expand the "still support old versions of CMake, for the benefit of
people with older versions, but avoid deprecation warnings/errors"
section to handle the deprecation of pre-3.10 versions by 3.31.

5 months agoipv6: set the snapshot length for the payload correctly.
Guy Harris [Mon, 4 Nov 2024 17:36:12 +0000 (09:36 -0800)] 
ipv6: set the snapshot length for the payload correctly.

Cut off the snapshot length to the end of the IP payload or the end of
the data in which it's contained, whichever comes first.

6 months agoCirrus CI: Update the macOS task image
Francois-Xavier Le Bail [Fri, 8 Nov 2024 14:57:18 +0000 (15:57 +0100)] 
Cirrus CI: Update the macOS task image

Based on https://cirrus-ci.org/guide/macOS/.

This will avoid the warning:
Only ghcr.io/cirruslabs/macos-runner:sonoma is allowed. Automatically
upgraded.

6 months agoCHANGES: Add two changes backported to 4.99
Francois-Xavier Le Bail [Mon, 4 Nov 2024 14:11:22 +0000 (15:11 +0100)] 
CHANGES: Add two changes backported to 4.99

[skip ci]

6 months agoptp: Add test for management packets
Casper Andersson [Mon, 11 Mar 2024 17:49:47 +0000 (18:49 +0100)] 
ptp: Add test for management packets

Test setup:
ip link add link vethA type veth peer name vethB
ip link set dev vethA up
ip link set dev vethB up
ptp4l -2 -P -S -i vethA &
tcpdump -i vethA 'ether[14] = 0xD' -w ptp_management.pcap &

Tcpdump filtering on only management packets (0xD) to skip capturing
other traffic that is already covered by other tests.

Sending management requests (which ptp4l responds to):
pmc -b 3 -2 -i vethB 'get current_data_set'
pmc -b 3 -2 -i vethB 'get port_data_set'
pmc -b 3 -2 -i vethB 'get default_data_set'
pmc -b 3 -2 -i vethB 'get parent_data_set'
pmc -b 3 -2 -i vethB 'get clock_description'

Sidenote: the management packets contains a TLV at the end and I
included 5 of them (out of the total ~50 listed in the
standard). Tcpdump currently does not print the TLV.

Signed-off-by: Casper Andersson <[email protected]>
6 months agoptp: Fix management packet fields
Casper Andersson [Mon, 11 Mar 2024 17:06:11 +0000 (18:06 +0100)] 
ptp: Fix management packet fields

`bp` was modified inside the function but the change was not
reflected back outside, resulting in the fields afterwards accessing
the wrong part of the packet.

Signed-off-by: Casper Andersson <[email protected]>
6 months agoCHANGES: Add a change backported to 4.99
Francois-Xavier Le Bail [Sat, 2 Nov 2024 15:19:53 +0000 (16:19 +0100)] 
CHANGES: Add a change backported to 4.99

[skip ci]

6 months agoTCP: Fix Reset segment processing
Francois-Xavier Le Bail [Fri, 1 Nov 2024 21:20:24 +0000 (22:20 +0100)] 
TCP: Fix Reset segment processing

When a received RST segment contains data, this is diagnostic data that
explains the cause of the RST.

So we have to stop processing, even if we don't print the data (no "-v").

Rename two test outputs, with "-v" in the names.
Add two test cases (existing pcap printed without "-v").

6 months agoIPv6: Fix inconsistencies in the printing of some option names
Francois-Xavier Le Bail [Thu, 31 Oct 2024 10:50:08 +0000 (11:50 +0100)] 
IPv6: Fix inconsistencies in the printing of some option names

1) Hop-by-Hop Options Header

$ ./tcpdump --skip 1 -c1 -tnv -r tests/icmpv6.pcap
Before:
IP6 (hlim 1, next-header Options (0), payload length 36)
  fe80::215:17ff:fecc:e546 > ff02::16: HBH (rtalert: 0x0000) (padn)
  [icmp6 sum ok] ICMP6, [...]

There is "next-header Options" but the next header is printed "HBH".

After:
IP6 (hlim 1, next-header HBH (0), payload length 36)
  fe80::215:17ff:fecc:e546 > ff02::16: HBH (rtalert: 0x0000) (padn)
  [icmp6 sum ok] ICMP6, [...]

2) Destination Options Header

$ ./tcpdump  -tnv -r tests/erspan-type-iii-pb-1.pcap
Before:
IP6 (class 0x30, flowlabel 0x00001, hlim 1, next-header unknown (60),
  payload length 288) 4120:7467:1700:4200:143:100:7f01:400e >
  4591:bfd7:cd87:d7:68:38:101:e800: DSTOPT (padn) [...]

There is "next-header unknown" but next header is printed "DSTOPT".

After:
IP6 (class 0x30, flowlabel 0x00001, hlim 1, next-header DSTOPT (60),
  payload length 288) 4120:7467:1700:4200:143:100:7f01:400e >
  4591:bfd7:cd87:d7:68:38:101:e800: DSTOPT (padn) [...]

Moreover:
Update a ndo_protocol (s/hbhopt/hbh/).
Use nd_print_protocol_caps().

Update some test outputs accordingly.

6 months agoCHANGES: add a change backported to 4.99. [skip ci]
Guy Harris [Thu, 31 Oct 2024 19:04:55 +0000 (12:04 -0700)] 
CHANGES: add a change backported to 4.99. [skip ci]

6 months agoip: set the snapshot length for the payload correctly.
Guy Harris [Thu, 31 Oct 2024 05:26:34 +0000 (22:26 -0700)] 
ip: set the snapshot length for the payload correctly.

Cut off the snapshot length to the end of the IP payload or the end of
the data in which it's contained, whichever comes first.

6 months agoDon't hardwire the Windows system directory path.
Guy Harris [Tue, 29 Oct 2024 06:53:08 +0000 (23:53 -0700)] 
Don't hardwire the Windows system directory path.

Instead, fetch it with GetSystemDirectoryW() and append "\Npcap" to it.

6 months agoerspan: add checks for data we don't print.
Guy Harris [Mon, 28 Oct 2024 15:22:22 +0000 (08:22 -0700)] 
erspan: add checks for data we don't print.

Make sure we don't run past the end of the captured data for fields we
skip in ERSPAN type III packets.

Add a test file.

6 months agoAppveyor: Run "git show --oneline -s"
Francois-Xavier Le Bail [Sun, 27 Oct 2024 13:18:36 +0000 (14:18 +0100)] 
Appveyor: Run "git show --oneline -s"

It is used to identify the git HEAD.

[skip ci]

6 months agoerspan: Rename two printers
Francois-Xavier Le Bail [Sat, 26 Oct 2024 19:56:52 +0000 (21:56 +0200)] 
erspan: Rename two printers

Rename erspan_print_i_ii() to erspan_i_ii_print() and erspan_print_iii()
to erspan_iii_print(), with _print suffixes as in most similar cases.

6 months agobuild_matrix.sh: Add a "| cat" at the end of a git command
Francois-Xavier Le Bail [Fri, 25 Oct 2024 08:38:31 +0000 (10:38 +0200)] 
build_matrix.sh: Add a "| cat" at the end of a git command

This can avoid a display pause problem with "less -S" as a git pager.

This is a folow-up to 2f0fc907b4863d78e16528d1b9477e2fbc2d238b.

[skip ci]

6 months agobuild_matrix.sh: Run "git show --oneline -s"
Francois-Xavier Le Bail [Wed, 23 Oct 2024 12:00:40 +0000 (14:00 +0200)] 
build_matrix.sh: Run "git show --oneline -s"

It is used to identify the git HEAD.

6 months agoAdd vim swap files to .gitignore. [skip ci]
Denis Ovsienko [Wed, 23 Oct 2024 11:15:58 +0000 (12:15 +0100)] 
Add vim swap files to .gitignore. [skip ci]

6 months agoAdd --skip option to skip some packets before writing or printing
Francois-Xavier Le Bail [Mon, 21 Oct 2024 08:43:38 +0000 (10:43 +0200)] 
Add --skip option to skip some packets before writing or printing

With this change, we can write/print some contiguous packets from a file.
We can also skip some packets doing a live capture.

The '--skip 0' option is allowed to help some loop in a shell script.

Examples:

Skip 3 packets when printing:
tcpdump -#n --skip 3 -r in.pcap

Write the sixth packet, if any:
tcpdump --skip 5 -c 1 -r in.pcap -w out.pcap

Write up to 5 packets after skipping 3:
tcpdump --skip 3 -c 5 -r in.pcap -w out.pcap

6 months agoJuniper: Use the ND_ICHECKMSG_U() macro for a length check
Francois-Xavier Le Bail [Fri, 18 Oct 2024 10:07:36 +0000 (12:07 +0200)] 
Juniper: Use the ND_ICHECKMSG_U() macro for a length check

It displays the reason for the "invalid" case.

Before:
    1  2015-05-19 13:34:16.720640  (invalid)
After:
    1  2015-05-19 13:34:16.720640  [cookie length 10 > 8] (invalid)

This is a follow-up to 8c7221d39b44502999c78200d544665f13b4e331.

Add the poc test file from GitHub issue #783 (first packet).

Moreover:
Remove some extra blank lines.

6 months agoUpdate the ND_TCHECK_LEN macro definitions
Francois-Xavier Le Bail [Tue, 15 Oct 2024 19:08:57 +0000 (21:08 +0200)] 
Update the ND_TCHECK_LEN macro definitions

Avoid warnings such as in the following case:

        if (...)
                ND_TCHECK_LEN(...);
        else

With gcc:
source.c:X:12: warning: suggest explicit braces to avoid ambiguous
  'else' [-Wdangling-else]
    X |         if (...)
      |            ^

With clang:
source.c:Y:2: warning: add explicit braces to avoid dangling else
  [-Wdangling-else]
        else
        ^

6 months agoUpdate the ND_ICHECKMSG_U and ND_ICHECKMSG_ZU macro definitions
Francois-Xavier Le Bail [Tue, 15 Oct 2024 10:02:37 +0000 (12:02 +0200)] 
Update the ND_ICHECKMSG_U and ND_ICHECKMSG_ZU macro definitions

Avoid errors such as in the following case:

        if (...)
                ND_ICHECKMSG_U(...);
else

source.c:X:9: error: 'else' without a previous 'if'
    X |         else
      |         ^~~~

with gcc, or "error: expected expression" with clang.

This avoids the need to use explicit braces (dangling else).

Same for ND_ICHECK_U, ND_ICHECKMSG_ZU and ND_ICHECK_ZU.

6 months agoPTP: Remove spaces before colons in output
Francois-Xavier Le Bail [Sat, 12 Oct 2024 12:11:30 +0000 (14:11 +0200)] 
PTP: Remove spaces before colons in output

Update four test outputs accordingly.

6 months agoFix a few typos in comments
Francois-Xavier Le Bail [Sat, 12 Oct 2024 12:21:51 +0000 (14:21 +0200)] 
Fix a few typos in comments

[skip ci]

7 months agoCHANGES: Add a change backported to 4.99
Francois-Xavier Le Bail [Wed, 9 Oct 2024 11:35:13 +0000 (13:35 +0200)] 
CHANGES: Add a change backported to 4.99

[skip ci]

7 months agoCHANGES: add a change backported to 1.10. [skip ci]
Guy Harris [Wed, 9 Oct 2024 05:11:12 +0000 (22:11 -0700)] 
CHANGES: add a change backported to 1.10. [skip ci]

7 months agoMake tcpdump find wpcap.dll on Windows if it's not in the system library.
Guy Harris [Tue, 8 Oct 2024 19:40:21 +0000 (12:40 -0700)] 
Make tcpdump find wpcap.dll on Windows if it's not in the system library.

See https://npcap.com/guide/npcap-devguide.html#npcap-feature-native-dll-implicitly
for details on what's being done.

Fix #1226.

7 months agoAvoid some typo reports in comments
Francois-Xavier Le Bail [Tue, 8 Oct 2024 14:31:03 +0000 (16:31 +0200)] 
Avoid some typo reports in comments

[skip ci]

7 months agoREADME.windows.md: Add VS 2022. [skip ci]
Guy Harris [Tue, 8 Oct 2024 00:39:55 +0000 (17:39 -0700)] 
README.windows.md: Add VS 2022. [skip ci]

Also, put the "here's how to install CMake from Visual Studio" stuff
ahead of the "oh, and you can install it with Chocolatey" stuff.

7 months agoLWAPP: Fix indentation for some ND_PRINT()
Francois-Xavier Le Bail [Mon, 7 Oct 2024 12:39:12 +0000 (14:39 +0200)] 
LWAPP: Fix indentation for some ND_PRINT()

[skip ci]

7 months agoLWAPP: Fix indentation
Francois-Xavier Le Bail [Thu, 3 Oct 2024 12:09:05 +0000 (14:09 +0200)] 
LWAPP: Fix indentation

s/^<tab>/<8 spaces>/

[skip ci]

7 months agoLWAPP: Use flag bit names closer to those in the RFC
Francois-Xavier Le Bail [Wed, 2 Oct 2024 19:35:41 +0000 (21:35 +0200)] 
LWAPP: Use flag bit names closer to those in the RFC

L Bit: If set, it's not "Last Fragment", but "Not Last".

Add comments on flag bits.

Moreover:
Remove extra spaces in the output.

7 months agoCREDITS: Update Robert Edmonds entry. [skip ci]
Denis Ovsienko [Wed, 2 Oct 2024 17:15:35 +0000 (18:15 +0100)] 
CREDITS: Update Robert Edmonds entry. [skip ci]

Same as in libpcap.

7 months agoCHANGES: Add a change in the main section
Francois-Xavier Le Bail [Tue, 1 Oct 2024 18:04:31 +0000 (20:04 +0200)] 
CHANGES: Add a change in the main section

[skip ci]

7 months agoNTP: Use GET_U_1() to replace a direct dereference
Francois-Xavier Le Bail [Mon, 30 Sep 2024 18:03:40 +0000 (20:03 +0200)] 
NTP: Use GET_U_1() to replace a direct dereference

7 months agoCHANGES: Add a change backported to 4.99
Francois-Xavier Le Bail [Mon, 30 Sep 2024 16:06:55 +0000 (18:06 +0200)] 
CHANGES: Add a change backported to 4.99

[skip ci]

7 months agoFix a typo in a comment
Francois-Xavier Le Bail [Mon, 30 Sep 2024 11:59:00 +0000 (13:59 +0200)] 
Fix a typo in a comment

7 months agoFix '-tt' option printing when time > 2106-02-07T06:28:15Z
Francois-Xavier Le Bail [Fri, 27 Sep 2024 18:05:22 +0000 (20:05 +0200)] 
Fix '-tt' option printing when time > 2106-02-07T06:28:15Z

Currently the printing with '-tt' option (unix time) is incorrect.

Some examples:
1) test: time_2106_overflow-tt
0.000000 IP 192.168.1.11.43966 > 209.87.249.18.53: UDP, length 56
Should be:
4294967296.000000 IP 192.168.1.11.43966 > 209.87.249.18.53: UDP, length 56
2) test: time_2107-tt
28315904.000000 IP 192.168.1.11.43966 > 209.87.249.18.53: UDP, length 56
Should be:
4323283200.000000 IP 192.168.1.11.43966 > 209.87.249.18.53: UDP, length 56

Two build examples:
64-bit build: tv->tv_sec has type '__time_t' (aka 'long').
32-bit build with _TIME_BITS=64: tv->tv_sec has type '__time64_t'
  (aka 'long long').

Using 'unsigned' cast is incorrect for these 64-bit data.

Thus convert to 'int64_t' and print with '"%" PRId64'.

Add two test cases (existing pcapng printed with -tt).