]> The Tcpdump Group git mirrors - tcpdump/log
tcpdump
23 months agogre: add support for MikroTik Ethernet-over-IP hack.
Guy Harris [Sat, 10 Jun 2023 21:24:32 +0000 (14:24 -0700)] 
gre: add support for MikroTik Ethernet-over-IP hack.

More from OpenBSD's tcpdump.

23 months agogre: clean up GRE "version 1" (PPTP) parsing of "key" field.
Guy Harris [Sat, 10 Jun 2023 07:52:23 +0000 (00:52 -0700)] 
gre: clean up GRE "version 1" (PPTP) parsing of "key" field.

In the PPTP (RFC 2637) version of the PPTP header, the "key" field,
which must be present, consists of a 2-byte big-endian payload length
followed by a 2-byte big-endian call ID.  Dissect it as such, and report
an error if the K bit *isn't* set.

23 months agoVXLAN: pick up some stuff from the OpenBSD tcpdump.
Guy Harris [Wed, 7 Jun 2023 23:59:43 +0000 (16:59 -0700)] 
VXLAN: pick up some stuff from the OpenBSD tcpdump.

23 months agogre, erspan: add an ERSPAN dissector and have the GRE dissector call it.
Guy Harris [Wed, 7 Jun 2023 22:20:16 +0000 (15:20 -0700)] 
gre, erspan: add an ERSPAN dissector and have the GRE dissector call it.

This is from the OpenBSD tcpdump.

Fixes #1040.

Sort the .c list in CMakeLists.txt while we're at it.

23 months agoIgnore failures when setting the default "any" device DLL to LINUX_SLL2.
Guy Harris [Wed, 7 Jun 2023 02:56:17 +0000 (19:56 -0700)] 
Ignore failures when setting the default "any" device DLL to LINUX_SLL2.

If the user didn't explicitly request DLT_LINUX_SLL2 with -y, attempt to
set the link-layer type on the "any" device to DLT_LINUX_SLL2, but, if
that fails, just drive on - it could be the Solaris or macOS "any"
device, neither of which support the Linux-style headers, or it could be
a tcpdump built with a newer libpcap but dynamically-linked, and running
on a system with an older libpcap that doesn't support DLT_LINUX_SLL2.

Fixes #1057.

23 months agoMoved source port equal BCM_LI_PORT to bottom of long if else chain
Jonas Chianu [Fri, 31 Mar 2023 16:24:22 +0000 (12:24 -0400)] 
Moved source port equal BCM_LI_PORT to bottom of long if else chain

BCM_LI_SHIM (BCM_LI_PORT) value is set to 49152, therefore when the
source port is 49152, it does not matter what the true destination is,
it defaults to Broadcom. So tcpdump interprets any packet with source
UDP port of 49152 as BCM_LI_SHIM (Broadcom). Ports 49152+, by
definition are ephemeral ports so it's totally reasonable that, for
example, BFD is using that source port for their packets. To prevent,
for example, BFD packets from being wrongly identified as BCM_LI_SHIM
packets, the "else if" statement has been moved to bottom of long chain.

Add a test file.

23 months agoMakefile.in: Update the whitespacecheck target
Francois-Xavier Le Bail [Thu, 1 Jun 2023 12:59:02 +0000 (14:59 +0200)] 
Makefile.in: Update the whitespacecheck target

install-sh has no longer a tab at the end of one line.

This is a follow-up to b5a4b9338ca5d063914b7bacbbdda5faf0b27ce4.

23 months agoUpdate install-sh script to the latest available version
Rose [Wed, 31 May 2023 16:07:48 +0000 (12:07 -0400)] 
Update install-sh script to the latest available version

The version of install-sh we have was made over 2 decades ago,
and last edited 9 years ago.

I updated the script by running autoreconf -fiv on autoconf 2.71,
and autoreconf automatically updated the script.

23 months agoRename the suffix of a pcapng test file to .pcapng
Francois-Xavier Le Bail [Tue, 30 May 2023 08:33:35 +0000 (10:33 +0200)] 
Rename the suffix of a pcapng test file to .pcapng

[skip ci]

23 months agoOSPF6: Fix an undefined behavior
Bill Fenner [Tue, 11 Oct 2022 20:16:20 +0000 (13:16 -0700)] 
OSPF6: Fix an undefined behavior

Handle ls_length shorter than sizeof(lsa_hdr) in the same way as OSPF.

Use a u_int32 to hold a loop variable initialized with GET_BE_U_4.

print-ospf6.c:815:46: runtime error: signed integer overflow:
-2147483648 - 1 cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior print-ospf6.c:817:46

[Part of the PR #1012]

23 months agomobile: Print the protocol name before any test
Francois-Xavier Le Bail [Wed, 24 May 2023 07:34:42 +0000 (09:34 +0200)] 
mobile: Print the protocol name before any test

23 months agoCONTRIBUTING.md: Update about 'struct tok' usage
Francois-Xavier Le Bail [Tue, 23 May 2023 14:43:22 +0000 (16:43 +0200)] 
CONTRIBUTING.md: Update about 'struct tok' usage

[skip ci]

2 years agoNFS: A pointer should not be compared to zero (improve code readability)
Francois-Xavier Le Bail [Sun, 21 May 2023 15:13:40 +0000 (17:13 +0200)] 
NFS: A pointer should not be compared to zero (improve code readability)

2 years agoCARP: Print the protocol name before any GET_()
Francois-Xavier Le Bail [Sun, 21 May 2023 14:32:46 +0000 (16:32 +0200)] 
CARP: Print the protocol name before any GET_()

This change will print the protocol name even if the first octet is
truncated.
Use nd_print_protocol_caps().

2 years agoFix spelling of PTP type SIGNALING 1051/head
Casper Andersson [Fri, 19 May 2023 19:31:25 +0000 (21:31 +0200)] 
Fix spelling of PTP type SIGNALING

The IEEE 1588 (PTP) standard uses the spelling SIGNALING, with one L.

2 years agoDVMRP: Update an error message
Francois-Xavier Le Bail [Mon, 15 May 2023 07:58:27 +0000 (09:58 +0200)] 
DVMRP: Update an error message

This change will avoid having the keyword "invalid" twice as:
[invalid ncount] (invalid)

2 years agoNSH: Update an error message
Francois-Xavier Le Bail [Mon, 15 May 2023 07:49:50 +0000 (09:49 +0200)] 
NSH: Update an error message

This change will avoid having the keyword "invalid" twice as:
(invalid length for the MD type) (invalid)

2 years agoRT6: Update an error message
Francois-Xavier Le Bail [Mon, 15 May 2023 07:44:27 +0000 (09:44 +0200)] 
RT6: Update an error message

This change will avoid having the keyword "invalid" twice as:
(invalid length nnn) (invalid)

2 years agoVTP: Update two error messages
Francois-Xavier Le Bail [Sun, 14 May 2023 12:01:57 +0000 (14:01 +0200)] 
VTP: Update two error messages

This change will avoid having the keyword "invalid" twice as:
[invalid MgmtD Len nnn] (invalid)
and
(invalid TLV length nnn != 1) (invalid)

2 years agoDTP: Update an error message
Francois-Xavier Le Bail [Sat, 13 May 2023 13:43:38 +0000 (15:43 +0200)] 
DTP: Update an error message

This change will avoid having the keyword "invalid" twice as :
[invalid TLV length nnn] (invalid)

2 years agomobile: Modernize packet parsing
Francois-Xavier Le Bail [Fri, 12 May 2023 16:29:25 +0000 (18:29 +0200)] 
mobile: Modernize packet parsing

Use ND_TCHECK_SIZE() and enable ND_LONGJMP_FROM_TCHECK.
Use ND_ICHECK_U() for length check and add standard "invalid" section.
Use nd_print_protocol().

2 years agoBabel,DHCPv6: Use nd_print_protocol()
Francois-Xavier Le Bail [Sat, 15 Apr 2023 09:05:35 +0000 (11:05 +0200)] 
Babel,DHCPv6: Use nd_print_protocol()

2 years agochecksum.c: Remove a now useless include
Francois-Xavier Le Bail [Wed, 10 May 2023 18:28:41 +0000 (20:28 +0200)] 
checksum.c: Remove a now useless include

It is a follow-up to 94f232c1ab0143c6da9fc00732b6b241b8abdf4c
where the assert() call was removed.

2 years agoNTP: Remove three redundant tests with -vv option
Francois-Xavier Le Bail [Wed, 10 May 2023 14:13:13 +0000 (16:13 +0200)] 
NTP: Remove three redundant tests with -vv option

-vv does not give more printed data than -v for the NTP protocol.
The only differences were about UDP checksums in IPv4 encapsulation.

2 years agoNTP: Remove three redundant tests with -vvv option
Francois-Xavier Le Bail [Wed, 10 May 2023 11:38:37 +0000 (13:38 +0200)] 
NTP: Remove three redundant tests with -vvv option

-vvv does not give more printed data than -vv.

2 years agoMakefile.in: Use the variable MAKE instead of the make command
Francois-Xavier Le Bail [Mon, 8 May 2023 08:41:28 +0000 (10:41 +0200)] 
Makefile.in: Use the variable MAKE instead of the make command

From https://www.gnu.org/software/make/manual/make.html#MAKE-Variable:
```
Recursive make commands should always use the variable MAKE, not the
explicit command name 'make', as shown here:

subsystem:
cd subdir && $(MAKE)
```

This should avoid the following warning when running 'make releasecheck'
in some cases:
make[1]: warning: jobserver unavailable: using -j1. Add '+' to parent
make rule.

2 years agoCirrus CI: Fix FreeBSD 13 and update Linux. [skip appveyor]
Denis Ovsienko [Sun, 7 May 2023 23:48:32 +0000 (00:48 +0100)] 
Cirrus CI: Fix FreeBSD 13 and update Linux. [skip appveyor]

Same as in tcpslice:

pkg: No packages available to install matching 'llvm14' have been
  found in the repositories

2 years agotcpdump.1.in: Delete Linux 2.0 references 1048/head
Jesse Rosenstock [Sun, 7 May 2023 15:21:23 +0000 (17:21 +0200)] 
tcpdump.1.in: Delete Linux 2.0 references

Delete Linux 2.0 bugs from bug list.

Linux 2.0.x releases are from 1996-2004. The man page recommended upgrading to Linux 2.2, released in 1999.

https://en.wikipedia.org/wiki/Linux_kernel_version_history#Releases_up_to_2.6.0

I'm assuming these >20 year old bug references aren't that useful now.

2 years agoinstrument functions: Reduce the scope of a variable
Francois-Xavier Le Bail [Wed, 3 May 2023 12:05:40 +0000 (14:05 +0200)] 
instrument functions: Reduce the scope of a variable

Fix the cppcheck warning:
instrument-functions.c:77:15: warning: The scope of the variable
'instrument_type' can be reduced. [variableScope]

2 years agolwres: Fix an undefined behavior in pointer arithmetic
Bill Fenner [Tue, 11 Oct 2022 20:05:55 +0000 (13:05 -0700)] 
lwres: Fix an undefined behavior in pointer arithmetic

Check for truncation before doing pointer arithmetic to point
to the end of the packet.

print-lwres.c:294:10: runtime error: addition of unsigned offset to
  0xf3b032be overflowed to 0x9652d560
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior print-lwres.c:294:10

[Part of the PR #1012]

2 years agoCI: Copy build_common.sh from tcpslice. [skip ci]
Denis Ovsienko [Mon, 1 May 2023 21:29:01 +0000 (22:29 +0100)] 
CI: Copy build_common.sh from tcpslice. [skip ci]

2 years agoCirrus CI: Avoid perl warnings about setting locale, Linux task
Francois-Xavier Le Bail [Sun, 30 Apr 2023 18:45:13 +0000 (20:45 +0200)] 
Cirrus CI: Avoid perl warnings about setting locale, Linux task

The warnings were like:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

2 years agoNHRP: Fix typos in a comment. [skip ci]
Denis Ovsienko [Fri, 28 Apr 2023 20:15:05 +0000 (21:15 +0100)] 
NHRP: Fix typos in a comment. [skip ci]

2 years agoPPP: Check if there is some data to hexdump
Francois-Xavier Le Bail [Thu, 27 Apr 2023 11:19:34 +0000 (13:19 +0200)] 
PPP: Check if there is some data to hexdump

This may avoid this error:
Dissector error: print_unknown_data() called with pointer past end of
packet

Add a test file showing the problem.

2 years agoRIP: Check if there is some data to hexdump
Francois-Xavier Le Bail [Thu, 27 Apr 2023 06:17:35 +0000 (08:17 +0200)] 
RIP: Check if there is some data to hexdump

This may avoid this error:
Dissector error: print_unknown_data() called with pointer past end of
packet

2 years agonhrp: fix infinite loop on malformed packets.
Guy Harris [Tue, 25 Apr 2023 20:37:56 +0000 (13:37 -0700)] 
nhrp: fix infinite loop on malformed packets.

If a CIE doesn't fit in the remainder of the mandatory part, return the
length of that remainder, so that the loop processing the CIE
terminates.

Add capture that produced the infinite loop.

2 years agoFix a typo
Francois-Xavier Le Bail [Sat, 22 Apr 2023 09:00:31 +0000 (11:00 +0200)] 
Fix a typo

[skip ci]

2 years agoPut "}" at beginning of line with "else" to keep a consistent style
Francois-Xavier Le Bail [Fri, 21 Apr 2023 12:44:55 +0000 (14:44 +0200)] 
Put "}" at beginning of line with "else" to keep a consistent style

[skip ci]

2 years agoPut "{" at end of line with "else" to keep a consistent style
Francois-Xavier Le Bail [Fri, 21 Apr 2023 12:24:23 +0000 (14:24 +0200)] 
Put "{" at end of line with "else" to keep a consistent style

[skip ci]

2 years agoPut "{" at end of line with "switch" to keep a consistent style
Francois-Xavier Le Bail [Wed, 19 Apr 2023 19:55:53 +0000 (21:55 +0200)] 
Put "{" at end of line with "switch" to keep a consistent style

[skip ci]

2 years agoPut "{" at end of line with "if" to keep a consistent style
Francois-Xavier Le Bail [Wed, 19 Apr 2023 19:19:44 +0000 (21:19 +0200)] 
Put "{" at end of line with "if" to keep a consistent style

[skip ci]

2 years agoPut "{" at end of line with "for" to keep a consistent style
Francois-Xavier Le Bail [Wed, 19 Apr 2023 19:06:12 +0000 (21:06 +0200)] 
Put "{" at end of line with "for" to keep a consistent style

[skip ci]

2 years agoPut "{" at end of line with "while" to keep a consistent style
Francois-Xavier Le Bail [Wed, 19 Apr 2023 19:03:49 +0000 (21:03 +0200)] 
Put "{" at end of line with "while" to keep a consistent style

[skip ci]

2 years agoSNMP: Fix two undefined behaviors
Bill Fenner [Tue, 11 Oct 2022 20:13:58 +0000 (13:13 -0700)] 
SNMP: Fix two undefined behaviors

When converting an integer from ASN.1, use an unsigned value
for the partial result and assign it to the integer part of
the union at the end, to avoid shifting a negative number left.

print-snmp.c:545:19: runtime error: left shift of negative value -1
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior print-snmp.c:545:19

OID elements are unsigned; a large-enough oid value could result
in the undefined behavior of shifting a signed integer left through
the sign bit, so simply store them as unsigned.

print-snmp.c:751:11: runtime error: left shift of 268435455 by 7 places
  cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior print-snmp.c:751:11

[Part of the PR #1012]

2 years agoMerge pull request #972 from martinetd/zombie
fxlb [Wed, 19 Apr 2023 09:52:25 +0000 (09:52 +0000)] 
Merge pull request #972 from martinetd/zombie

child_cleanup: reap as many child processes as possible

2 years agochild_cleanup: reap as many child processes as possible 972/head
Dominique Martinet [Fri, 21 Jan 2022 01:27:07 +0000 (10:27 +0900)] 
child_cleanup: reap as many child processes as possible

Under load it's possible multiple child processes have been killed before
we start processing the SIGCHILD signal, leaving zombie processes behind
everytime we miss a process.
Reap as many processes as possible instead of assuming one handler
call = one process like we currently did.

Can be reproduced by running the following commands in parallel:
 - tcpdump -i lo -w /tmp/test -C 1 -z /usr/bin/true
 - iperf3 -s
 - iperf3 -c localhost

2 years agoRT6: Print SRH TLV HMAC "reserved" field if non zero in verbose mode
Francois-Xavier Le Bail [Tue, 18 Apr 2023 15:50:30 +0000 (17:50 +0200)] 
RT6: Print SRH TLV HMAC "reserved" field if non zero in verbose mode

reserved: MUST be 0 (MBZ).

2 years agoRT6: Declare the struct tok srh_tlv_type "static"
Francois-Xavier Le Bail [Tue, 18 Apr 2023 16:00:36 +0000 (18:00 +0200)] 
RT6: Declare the struct tok srh_tlv_type "static"

This should avoid error like:
./print-rt6.c:36:18: error: no previous extern declaration for
non-static variable 'srh_tlv_type' [-Werror,-Wmissing-variable-declarations]
const struct tok srh_tlv_type[] = {
                 ^
./print-rt6.c:36:7: note: declare 'static' if the variable is not
intended to be used outside of this translation unit
const struct tok srh_tlv_type[] = {
      ^

2 years agoRT6: Use a "struct tok" for the SRH TLV type
Francois-Xavier Le Bail [Tue, 18 Apr 2023 15:41:49 +0000 (17:41 +0200)] 
RT6: Use a "struct tok" for the SRH TLV type

Moreover:
Factorise "ND_PRINT(", TLV-len=%u", tlv_len);"

2 years agoMerge pull request #949 from giulio-sido/tmp3
fxlb [Tue, 18 Apr 2023 12:43:49 +0000 (12:43 +0000)] 
Merge pull request #949 from giulio-sido/tmp3

rt6: parse TLV

2 years agort6: parse TLV 949/head
giulio-sido [Tue, 12 Oct 2021 15:17:58 +0000 (17:17 +0200)] 
rt6: parse TLV

Parse Type Length Values (TLV) in IPv6 Routing Header as specified by
RFC 8754 [1].

[1] https://datatracker.ietf.org/doc/html/rfc8754

Signed-off-by: Giulio Sidoretti <[email protected]>
2 years agoEAP: Assign ndo_protocol in the eap_print() function
Francois-Xavier Le Bail [Wed, 12 Apr 2023 07:52:04 +0000 (09:52 +0200)] 
EAP: Assign ndo_protocol in the eap_print() function

2 years agonhrp: handle draft-detienne-dmvpn-01, improve indication decoding.
Guy Harris [Wed, 12 Apr 2023 07:14:53 +0000 (00:14 -0700)] 
nhrp: handle draft-detienne-dmvpn-01, improve indication decoding.

Handle the I-D draft-detienne-dmvpn-01 traffic indication packet.

Print the error code in an error indication symbolically if it's a known
code.

Print the address fields in the mandatory part of the header for error
and traffic indication packets.

2 years agoGeneve: Add a bounds check
Francois-Xavier Le Bail [Tue, 11 Apr 2023 19:05:41 +0000 (21:05 +0200)] 
Geneve: Add a bounds check

2 years agonhrp: add casts to squelch narrowing warnings.
Guy Harris [Tue, 11 Apr 2023 11:21:10 +0000 (04:21 -0700)] 
nhrp: add casts to squelch narrowing warnings.

Get rid of some commented-out code while we're at it.

2 years agoAdd support for dissecting RFC 2332 NHRP.
Guy Harris [Tue, 11 Apr 2023 10:05:46 +0000 (03:05 -0700)] 
Add support for dissecting RFC 2332 NHRP.

This is from the OpenBSD tcpdump.

2 years agocdp: require that the Address TLV have at least 4 bytes of data.
Guy Harris [Tue, 11 Apr 2023 06:36:21 +0000 (23:36 -0700)] 
cdp: require that the Address TLV have at least 4 bytes of data.

Specify a minimum length of 4 in the cdptlvs table, rather than having
its printer do the length check itself.

2 years agocdp: show the TLV type as a 4-digit hex number.
Guy Harris [Tue, 11 Apr 2023 05:57:58 +0000 (22:57 -0700)] 
cdp: show the TLV type as a 4-digit hex number.

It's 2 bytes long.

2 years agocdp: support CDP TLV 0x001a.
Guy Harris [Tue, 11 Apr 2023 05:49:46 +0000 (22:49 -0700)] 
cdp: support CDP TLV 0x001a.

Based on the way it's dissected in Wireshark.

2 years agocdp: don't explicitly check for T_DEV_ID when printing.
Guy Harris [Tue, 11 Apr 2023 00:06:02 +0000 (17:06 -0700)] 
cdp: don't explicitly check for T_DEV_ID when printing.

Instead, have an additional element in a struct cdp_tlvinfo that
indicates whether to print the TLV in all modes or only in verbose mode;
that would allow other TLVs to printed in non-verbose mode.

Also, use the usual (sizeof x / sizeof x[0]) trick to determine how big
the table is, rather than having a defined size.

2 years agobootp/dhcp6: DHCPv4/v6 ZTP and SZTP option support
Eamon Doyle [Thu, 14 Apr 2022 07:53:54 +0000 (08:53 +0100)] 
bootp/dhcp6: DHCPv4/v6 ZTP and SZTP option support

DHCPv4: RFC8572 specifies the SZTP redirect tag.

DHCPv6: RFC5970 specifies the boot file URL, used for ZTP,
 and RFC8572 specifies the SZTP redirect tag
 The base DHCPv6 RFC3315 specifies the user class option.

2 years agogre: support CDP over GRE.
Guy Harris [Mon, 10 Apr 2023 19:18:41 +0000 (12:18 -0700)] 
gre: support CDP over GRE.

Taken from the OpenBSD version of tcpdump.

2 years agotests: wccp_redirect_gre.pcap contains SMB, so it needs two tests.
Guy Harris [Mon, 10 Apr 2023 07:46:57 +0000 (00:46 -0700)] 
tests: wccp_redirect_gre.pcap contains SMB, so it needs two tests.

Have separate .out files for dissection of wccp_redirect_gre.pcap with,
and without, SMB dissection enabled in tcpdump.

2 years agocdp: only hex-dump unknown TLVs in verbose mode.
Guy Harris [Mon, 10 Apr 2023 07:27:05 +0000 (00:27 -0700)] 
cdp: only hex-dump unknown TLVs in verbose mode.

If we're not in verbose mode, we only show the Device ID TLV, so there's
no good reason to show a hex dump of other TLVs if we don't happen to
have a printer for them - especially given that we don't show the type
value for the TLV, so it's not clear to what type value those hex bytes
correspond.  Furthermore, the hex dump causes the non-verbose output to
be multiple lines, and causes the ", length N" to show up at the end of
the hex dump rather than at the end of the first line.

I.e., it seems as if either 1) printing the hex dump in non-verbose mode
wasn't intended or 2) it was intended by whoever intended it didn't look
into what it would involve.

2 years agoGRE: Refine the WCCP header commit. [skip ci]
Denis Ovsienko [Sun, 9 Apr 2023 10:07:50 +0000 (11:07 +0100)] 
GRE: Refine the WCCP header commit. [skip ci]

Fixup the comment and have the case block actually fall through
consistently with the comment and the OpenBSD implementation.  Update
the test case, which now has the IPv4 packet after the WCCP header.  The
indentation does not represent the header nesting, but the same stands
for the OpenBSD implementation.

2 years agogre: handle Network Service Header (NSH), RFC 8300
Guy Harris [Sun, 9 Apr 2023 05:59:21 +0000 (22:59 -0700)] 
gre: handle Network Service Header (NSH), RFC 8300

This, and the previous multicast MPLS change, come from the OpenBSD
tcpdump.

2 years agogre: handle multicast MPLS.
Guy Harris [Sun, 9 Apr 2023 05:45:00 +0000 (22:45 -0700)] 
gre: handle multicast MPLS.

Pass ETHERTYPE_MPLS_MULTI packets to the MPLS dissector.

2 years agogre: add support for WCCP redirects over GRE.
Guy Harris [Sun, 9 Apr 2023 05:11:28 +0000 (22:11 -0700)] 
gre: add support for WCCP redirects over GRE.

Add a test capture for it - and for GRE keepalives.

Both this and the previous GRE keepalive changes are based on OpenBSD
code.

2 years agogre: recognize (Cisco?) GRE keepalives.
Guy Harris [Sun, 9 Apr 2023 03:01:34 +0000 (20:01 -0700)] 
gre: recognize (Cisco?) GRE keepalives.

The RFCs don't seem to mention this use, but Cisco, at least, uses
packets with a protocol value of 0x0000 as keepalives.

2 years agogre: expand a comment, mention NVGRE. [skip ci]
Guy Harris [Sun, 9 Apr 2023 02:57:00 +0000 (19:57 -0700)] 
gre: expand a comment, mention NVGRE. [skip ci]

When processing the key field, note that OpenBSD shows it both a a 32bit
key and an NVGRE VSID+FlowID.

2 years agoCHANGES: Synchronize the 4.99.x sections. [skip ci]
Denis Ovsienko [Fri, 7 Apr 2023 22:02:21 +0000 (23:02 +0100)] 
CHANGES: Synchronize the 4.99.x sections. [skip ci]

2 years agoCHANGES: Add a change backported to 4.99
Francois-Xavier Le Bail [Fri, 7 Apr 2023 12:31:18 +0000 (14:31 +0200)] 
CHANGES: Add a change backported to 4.99

2 years agoUpdate config.{guess,sub}, timestamps 2023-01-01,2023-01-21
Francois-Xavier Le Bail [Thu, 6 Apr 2023 15:50:27 +0000 (17:50 +0200)] 
Update config.{guess,sub}, timestamps 2023-01-01,2023-01-21

From repository git://git.savannah.gnu.org/config.git

2 years agoCHANGES: List more backported commits. [skip ci]
Denis Ovsienko [Sun, 2 Apr 2023 12:52:14 +0000 (13:52 +0100)] 
CHANGES: List more backported commits. [skip ci]

(cherry picked from commit af4b5f75370f521f96326f0d9469031a0a0a595d)

2 years agoMerge pull request #1039 from mspncp/ikev2-add-missing-notification-types
Michael Richardson [Sun, 2 Apr 2023 18:30:31 +0000 (14:30 -0400)] 
Merge pull request #1039 from mspncp/ikev2-add-missing-notification-types

IKEv2: add missing notification types

2 years agoAutoconf: Update a stale comment in aclocal.m4. [skip ci]
Denis Ovsienko [Sun, 26 Mar 2023 23:47:32 +0000 (00:47 +0100)] 
Autoconf: Update a stale comment in aclocal.m4. [skip ci]

2 years agoAutoconf: Fix --static-pcap-only test on Solaris 10. [skip appveyor]
Denis Ovsienko [Sun, 26 Mar 2023 20:37:25 +0000 (21:37 +0100)] 
Autoconf: Fix --static-pcap-only test on Solaris 10. [skip appveyor]

On Solaris 10 /usr/bin/grep does not implement the -q flag:

checking for pcap-config... ../libpcap/pcap-config
grep: illegal option -- q
Usage: grep -hblcnsviw pattern file . . .
checking for pcap_loop... yes

Follow recommendation of the "Limitations of Usual Tools" section of GNU
Autoconf manual and use output redirection to fix it:

checking for pcap-config... ../libpcap/pcap-config
checking for pcap_loop... yes

2 years agodoc: Add more Solaris-related particulars. [skip ci]
Denis Ovsienko [Sat, 18 Mar 2023 18:30:32 +0000 (18:30 +0000)] 
doc: Add more Solaris-related particulars. [skip ci]

2 years agoman: Format "output format" subsections properly. [skip ci]
Denis Ovsienko [Sat, 18 Mar 2023 16:24:26 +0000 (16:24 +0000)] 
man: Format "output format" subsections properly. [skip ci]

2 years agoCirrus CI: Configure with --enable-instrument-functions, Coverity task
Francois-Xavier Le Bail [Mon, 13 Mar 2023 09:38:26 +0000 (10:38 +0100)] 
Cirrus CI: Configure with --enable-instrument-functions, Coverity task

Add the required binutils-dev package.

[skip ci]

2 years agoinstrument functions: Use an environment variable instead of config files
Francois-Xavier Le Bail [Sun, 12 Mar 2023 17:57:56 +0000 (18:57 +0100)] 
instrument functions: Use an environment variable instead of config files

If the environment variable INSTRUMENT is
- unset or set to an empty string, print nothing, like with no
  instrumentation
- set to "all" or "a", print all the functions names
- set to "global" or "g", print only the global functions names

The configuration with --enable-instrument-functions remains.

Note that before this change, the default was to print all functions.
Now it is to print nothing. So by default 'make check' runs without errors.

This allows to run:
$ INSTRUMENT=a ./tcpdump ...
$ INSTRUMENT=g ./tcpdump ...
$ INSTRUMENT= ./tcpdump ...
or
$ export INSTRUMENT=global
$ ./tcpdump ...

This also allows to run the statically compiled binary on another host
after copying it.

It is no longer necessary to modify the configuration with:
$ make instrument_all
$ make instrument_global
$ make instrument_off
(Targets removed.)

Update .gitignore, CONTRIBUTING.md and Makefile.in accordingly.

Moreover:
Reduce the scope of a variable.
Rename a variable.
Remove '\n' in the perror() call.
Remove 2 spaces in function calls (style).

[skip ci]

2 years agoman: Spell TCP header flags names. [skip ci]
Denis Ovsienko [Sun, 12 Mar 2023 20:11:15 +0000 (20:11 +0000)] 
man: Spell TCP header flags names. [skip ci]

In the prose use the names from respective registry [1], which says:

* "PSH", not "PUSH",
* "CWR", not "ECN CWR", and
* "ECE", not "ECN-Echo".

This does not resolve all known inconsistencies related to TCP flags,
but at least makes the problem smaller.

1: https://www.iana.org/assignments/tcp-parameters/tcp-parameters.xhtml

2 years agoinstrument functions: Add a NULL check
Francois-Xavier Le Bail [Sat, 11 Mar 2023 08:47:07 +0000 (09:47 +0100)] 
instrument functions: Add a NULL check

Same as in tcpslice to fix a Coverity issue.

The issue was:
Null pointer dereferences  (FORWARD_NULL)
Passing null pointer "func" to "strncmp", which dereferences it.

2 years agoinstrument functions: Add a length check
Francois-Xavier Le Bail [Sat, 11 Mar 2023 08:46:09 +0000 (09:46 +0100)] 
instrument functions: Add a length check

We need space for the '\0'.

Same as in tcpslice to fix a Coverity issue.

Moreover:
Use '\0' for the null character.

2 years agoRefine the patterns in .gitignore. [skip ci]
Denis Ovsienko [Sun, 5 Mar 2023 19:14:25 +0000 (19:14 +0000)] 
Refine the patterns in .gitignore. [skip ci]

Spell patterns that are supposed to apply at the source tree root only
and remove two patterns that already appear in tests/.gitignore.

2 years agoIKEv2: add missing notification types 1039/head
Matthias St. Pierre [Sun, 5 Mar 2023 11:39:35 +0000 (12:39 +0100)] 
IKEv2: add missing notification types

The notification type entries were crafted from the CSV files
provided by IANA for the [error types] resp. [status types].

[error types]:  https://www.iana.org/assignments/ikev2-parameters/ikev2-parameters-14.csv
[status types]: https://www.iana.org/assignments/ikev2-parameters/ikev2-parameters-16.csv

2 years agoGet Markdown right in the previous change. [skip ci]
Denis Ovsienko [Sat, 4 Mar 2023 23:21:31 +0000 (23:21 +0000)] 
Get Markdown right in the previous change. [skip ci]

HTML 3 had problems, but confusing italic for bold was not one of them.

2 years agoFix minor issues in INSTALL.md. [skip ci]
Denis Ovsienko [Sat, 4 Mar 2023 23:06:13 +0000 (23:06 +0000)] 
Fix minor issues in INSTALL.md. [skip ci]

2 years agoMakefile.in: Add instrument-functions.o in CLEANFILES
Francois-Xavier Le Bail [Wed, 1 Mar 2023 13:54:20 +0000 (14:54 +0100)] 
Makefile.in: Add instrument-functions.o in CLEANFILES

It is not in LIBNETDISSECT_OBJ because it is optionally built.

[skip ci]

2 years agoMakefile.in: Add print-smb.o and smbutil.o in CLEANFILES
Francois-Xavier Le Bail [Wed, 1 Mar 2023 09:04:20 +0000 (10:04 +0100)] 
Makefile.in: Add print-smb.o and smbutil.o in CLEANFILES

They are not in LIBNETDISSECT_OBJ because they are optionally built.

[skip ci]

2 years agoCirrus CI: Configure with --enable-smb in the Coverity task
Francois-Xavier Le Bail [Mon, 27 Feb 2023 21:05:15 +0000 (22:05 +0100)] 
Cirrus CI: Configure with --enable-smb in the Coverity task

2 years agoRename a test. The protocol is IEEE 802.11
Francois-Xavier Le Bail [Mon, 27 Feb 2023 10:24:46 +0000 (11:24 +0100)] 
Rename a test. The protocol is IEEE 802.11

2 years agoman: Add the TCP flag names tcp-ece and tcp-cwr
Francois-Xavier Le Bail [Sun, 26 Feb 2023 14:03:40 +0000 (15:03 +0100)] 
man: Add the TCP flag names tcp-ece and tcp-cwr

State that these flag names became available when linking with libpcap
1.9.0 or later.

2 years agodoc: Update Haiku particulars. [skip ci]
Denis Ovsienko [Sun, 26 Feb 2023 00:04:39 +0000 (00:04 +0000)] 
doc: Update Haiku particulars. [skip ci]

Add a section for the 32-bit version.

2 years agoUntangle detection of pcap_findalldevs(). 1038/head
Denis Ovsienko [Fri, 24 Feb 2023 23:10:04 +0000 (23:10 +0000)] 
Untangle detection of pcap_findalldevs().

tcpdump.c requires both HAVE_PCAP_IF_T and HAVE_PCAP_FINDALLDEVS to
manage the code that depends on pcap_findalldevs().  Other than that,
the Autoconf and CMake checks that produce these two macros do not
relate directly, so having the check for pcap_if_t conditional on the
check for pcap_findalldevs() is an unnecessary complication.

More importantly, in the CMake case this places the check_type_size()
for pcap_if_t into a context with CMAKE_REQUIRED_LIBRARIES already set
to PCAP_LIBRARIES.  This works only if check_type_size() does not have
to check for <sys/types.h>, <stdint.h> or <stddef.h> implicitly.  This
was the case so long as another check_type_size() before the
CMAKE_REQUIRED_LIBRARIES change made the implicit checks and cached the
results, but removing that earlier instance resulted in a warning:

  Policy CMP0075 is not set: Include file check macros honor
  CMAKE_REQUIRED_LIBRARIES.  Run "cmake --help-policy CMP0075" for policy
  details.  Use the cmake_policy command to set the policy and suppress this
  warning.

  CMAKE_REQUIRED_LIBRARIES is set to:

    /usr/lib/x86_64-linux-gnu/libpcap.so

  For compatibility with CMake 3.11 and below this check is ignoring it.

To fix that, in both Autoconf and CMake make the two checks separate and
unconditional and place the check for pcap_if_t where it fits better.
In CMake remove the earlier workaround with in6_addr.

2 years agoCI: Introduce TEST_RELEASETAR. [skip ci]
Denis Ovsienko [Sat, 25 Feb 2023 17:52:18 +0000 (17:52 +0000)] 
CI: Introduce TEST_RELEASETAR. [skip ci]

Same as in tcpslice and libpcap.

2 years agotcpdump.c: fix a comment. [skip ci]
Guy Harris [Sat, 25 Feb 2023 09:51:45 +0000 (01:51 -0800)] 
tcpdump.c: fix a comment.  [skip ci]

Some versions of Mac OS X (as it was then called) *did*, in fact, ship
with a libpcap that had pcap_findalldevs() but a pcap.h that didn't
define pcap_if_t; it's not a question of "may ship", it's a fact of "did
ship".

2 years agoState there are currently no OS dependent defines and prototypes
Francois-Xavier Le Bail [Fri, 24 Feb 2023 08:45:27 +0000 (09:45 +0100)] 
State there are currently no OS dependent defines and prototypes

The last header was removed by commit
6008cb83b72a8fafe9c69f6955f4bdffbc049a09.

2 years agoCMake: balance cmake_push_check_state() and cmake_pop_check_state().
Guy Harris [Thu, 23 Feb 2023 03:10:37 +0000 (19:10 -0800)] 
CMake: balance cmake_push_check_state() and cmake_pop_check_state().

We didn't completely pop the check state after we finished the checks
for libpcap.

2 years agoDetect OS IPv6 support using AF_INET6 only. 1036/head
Denis Ovsienko [Tue, 21 Feb 2023 08:02:28 +0000 (08:02 +0000)] 
Detect OS IPv6 support using AF_INET6 only.

tcpdump source code has not been using struct in6_addr since commit
0c9cfdc in 2019, so lose the conditional structure declaration, which is
a no-op.

Since commit de7c619 in 2015 netdissect-stdinc.h on Windows defines
HAVE_OS_IPV6_SUPPORT if AF_INET6 if defined, which makes it equivalent
to AF_INET6.  On Unix-like systems taking struct in6_addr out of scope
would make HAVE_OS_IPV6_SUPPORT equivalent to AF_INET6, thus after
removing struct in6_addr remove HAVE_OS_IPV6_SUPPORT together with
Autoconf and CMake checks that define it.  Leave an unrelated CMake
workaround in place for later debugging.

On Windows do not define AF_INET6 if it is not defined, which makes
AF_INET6 a universal indicator of the OS IPv6 support on all supported
OSes.  The few remaining use cases that genuinely need AF_INET6 use it
to make OS API calls, so if the macro is not defined, it most likely
means such an API call in the best case would return just a well-formed
error status.  With this in mind, in win32_gethostbyaddr() and
ip6addr_string() guard all IPv6-specific code with #ifdef AF_INET6.  In
tcpdump.c add a comment to note why a guard is not required for
Casper-specific conditional code that uses AF_INET6.

This way when the OS does not support IPv6, IPv6 addresses will not
resolve to names, which is expected.  Other than that, tcpdump should be
able to process IPv6 addresses the usual way regardless if the OS would
be able to process the packets with these addresses.