]> The Tcpdump Group git mirrors - tcpdump/log
tcpdump
3 years agoJuniper: Rename a variable
Francois-Xavier Le Bail [Mon, 27 Dec 2021 14:31:47 +0000 (15:31 +0100)] 
Juniper: Rename a variable

This change allows to have a better error message at the next commit
with ND_LCHECK_U().

3 years agoGRE: Print the protocol name before any ND_LCHECK_U()/GET_()
Francois-Xavier Le Bail [Sun, 26 Dec 2021 10:46:22 +0000 (11:46 +0100)] 
GRE: Print the protocol name before any ND_LCHECK_U()/GET_()

This change will print the protocol name even if the length is invalid
or if the packet is truncated at the beginning.
Use nd_print_protocol_caps().

Moreover:
Remove an useless variable.

3 years agoGRE: Modernize packet parsing
Francois-Xavier Le Bail [Sat, 25 Dec 2021 15:01:11 +0000 (16:01 +0100)] 
GRE: Modernize packet parsing

Enable ND_LONGJMP_FROM_TCHECK.
Use ND_LCHECK_U() for length checks.
Add and use many standard "invalid" sections.
Remove the redundant ND_TCHECK*() instances.
Add a bounds check before the addrtostr() call.
Remove two now useless comments.

3 years agoReword the current maintainer in README.md. [skip ci]
Denis Ovsienko [Sat, 25 Dec 2021 23:31:37 +0000 (23:31 +0000)] 
Reword the current maintainer in README.md. [skip ci]

Use the correct tense and subject (see tcpdump-htdocs commit feaf9ff).

3 years agoRemove an unused pcap file
Francois-Xavier Le Bail [Fri, 24 Dec 2021 15:34:22 +0000 (16:34 +0100)] 
Remove an unused pcap file

This is a follow-up to b51a0dafc7861eb31d21524ec067d7c529a664b8.

3 years agoFix OOB read while parsing QUIC SH packets.
Rui Paulo [Mon, 29 Nov 2021 19:46:01 +0000 (11:46 -0800)] 
Fix OOB read while parsing QUIC SH packets.

3 years agoForgot to update README.md as well. [skip ci]
Denis Ovsienko [Wed, 22 Dec 2021 14:41:39 +0000 (14:41 +0000)] 
Forgot to update README.md as well. [skip ci]

3 years agoReformat the installation notes in Markdown. [skip ci]
Denis Ovsienko [Wed, 22 Dec 2021 14:02:13 +0000 (14:02 +0000)] 
Reformat the installation notes in Markdown. [skip ci]

3 years agotests: Add a pcap test for BGP extended message capability
Donatas Abraitis [Sun, 31 Oct 2021 19:19:55 +0000 (21:19 +0200)] 
tests: Add a pcap test for BGP extended message capability

Signed-off-by: Donatas Abraitis <[email protected]>
3 years agobgp: Parse BGP extended message support capability
Donatas Abraitis [Sun, 31 Oct 2021 19:14:21 +0000 (21:14 +0200)] 
bgp: Parse BGP extended message support capability

Signed-off-by: Donatas Abraitis <[email protected]>
3 years agoKeep the link-layer dissectors names sorted
Francois-Xavier Le Bail [Wed, 15 Dec 2021 17:10:01 +0000 (18:10 +0100)] 
Keep the link-layer dissectors names sorted

3 years agodoc: Refine Markdown in README.Win32.md. [skip ci]
Denis Ovsienko [Sat, 11 Dec 2021 23:49:13 +0000 (23:49 +0000)] 
doc: Refine Markdown in README.Win32.md. [skip ci]

Simplify hyperlinks, make existing fencing blocks consistent and use
inline fencing for command line and path elements.

3 years agoRemove an unused script. [skip ci]
Denis Ovsienko [Tue, 7 Dec 2021 21:07:41 +0000 (21:07 +0000)] 
Remove an unused script. [skip ci]

There is a different solution in place, which is a superset of this.

3 years agoman: Punctuate "RFC" properly. [skip ci]
Denis Ovsienko [Mon, 6 Dec 2021 19:11:21 +0000 (19:11 +0000)] 
man: Punctuate "RFC" properly. [skip ci]

As far as I know, the nominal format is "RFC n", not "RFC-n" or "RFCn".

3 years agoTreat "msys" as Windows for test exit statuses. [skip ci]
Denis Ovsienko [Thu, 2 Dec 2021 20:31:34 +0000 (20:31 +0000)] 
Treat "msys" as Windows for test exit statuses. [skip ci]

As far as it was possible to tell in GH pull request #653, exit statuses
have the same semantics in "msys" as they do in "MSWin32".  Although
other OS-specific parts of TESTrun may require including or excluding
"msys" too, this would need to be established by running a current
revision of the script on the actual system.

3 years agoIPX: Add two length checks
Francois-Xavier Le Bail [Sat, 6 Nov 2021 15:58:42 +0000 (16:58 +0100)] 
IPX: Add two length checks

This change fixes some undefined behaviors at runtime.

The errors were like:
print-ipx.c:160:12: runtime error: unsigned integer overflow:
  1 - 2 cannot be represented in type 'unsigned int'
print-ipx.c:233:12: runtime error: unsigned integer overflow:
  1 - 2 cannot be represented in type 'unsigned int'

3 years agoman: Update the date
Francois-Xavier Le Bail [Mon, 29 Nov 2021 12:58:49 +0000 (13:58 +0100)] 
man: Update the date

3 years agoman: Update the print interface for the packet count to stdout
Francois-Xavier Le Bail [Mon, 29 Nov 2021 11:07:03 +0000 (12:07 +0100)] 
man: Update the print interface for the packet count to stdout

This is a follow-up to commit a0e19c0caef95fdcbace674de91e7c181d3bc866.

3 years agoZEP: Add three length checks
Francois-Xavier Le Bail [Sun, 28 Nov 2021 09:57:14 +0000 (10:57 +0100)] 
ZEP: Add three length checks

3 years agoUse a sizeof() in bgp_rt_prefix_print(). [skip ci]
Denis Ovsienko [Wed, 24 Nov 2021 15:08:00 +0000 (15:08 +0000)] 
Use a sizeof() in bgp_rt_prefix_print(). [skip ci]

This way it is easier to see how the buffer is spent.

3 years agoEthernet: Add a length check
Francois-Xavier Le Bail [Fri, 5 Nov 2021 20:48:31 +0000 (21:48 +0100)] 
Ethernet: Add a length check

This fix some undefined behaviors at runtime.

The errors were like:

print-ether.c:241:11: runtime error: unsigned integer overflow:
  1 - 2 cannot be represented in type 'unsigned int'
print-ether.c:242:11: runtime error: unsigned integer overflow:
  1 - 2 cannot be represented in type 'unsigned int'

Moreover:
Fix indentation.

3 years agoEthernet: Rework the length checks
Francois-Xavier Le Bail [Sun, 21 Nov 2021 14:33:24 +0000 (15:33 +0100)] 
Ethernet: Rework the length checks

Add a sanity check: packet length need to be >= capture length

(Like a sanity check in print.c, pretty_print_packet() function)

Remove a now useless test:
Because packet length (length) >= capture length (caplen), when
caplen >= ETHER_HDRLEN + switch_tag_len, length cannot
be < ETHER_HDRLEN + switch_tag_len.

3 years agoRefine INSTALL.txt. [skip ci]
Denis Ovsienko [Fri, 19 Nov 2021 14:33:22 +0000 (14:33 +0000)] 
Refine INSTALL.txt. [skip ci]

Say C99 instead of ANSI C and explain multiple versions better.

3 years ago802.15.4: fix some compiler warnings.
Guy Harris [Tue, 16 Nov 2021 07:52:08 +0000 (23:52 -0800)] 
802.15.4: fix some compiler warnings.

C's type conversion rules are a barrel of fun.  Did you know that if you
add "2" to an "unsigned short", the result has the type "int", even
though, at least on a machine where "unsigned int" is longer than
"unsigned short", the result is always >= 0?

Add "2U" instead, so that one of the operands is an "unsigned int",
making the result an "unsigned int".

3 years ago802.15.4: fix various length checks and other issues.
Guy Harris [Tue, 16 Nov 2021 07:42:04 +0000 (23:42 -0800)] 
802.15.4: fix various length checks and other issues.

Fix some length checks done before subtracting from a length value to
test whether the length value is < the full amount to be subtracted from
it, not just part of that amount.

Add some such checks where they were needed but not present.

Make some values unsigned if they're never negative.

This should fix some issues detected by undefined-behavior sanitizers.

3 years agoLISP: don't decrement count variables unless we know they're not zero.
Guy Harris [Tue, 16 Nov 2021 00:44:46 +0000 (16:44 -0800)] 
LISP: don't decrement count variables unless we know they're not zero.

This fixes some undefined behavior warnings.

3 years agoUpdate BGP tests for the new check we do.
Guy Harris [Tue, 16 Nov 2021 00:02:03 +0000 (16:02 -0800)] 
Update BGP tests for the new check we do.

3 years agoBGP: make sure the path attributes don't go past the end of the packet.
Guy Harris [Mon, 15 Nov 2021 22:33:10 +0000 (14:33 -0800)] 
BGP: make sure the path attributes don't go past the end of the packet.

This fixes some undefined behavior in which we subtract the remaining
length of the path attributes from the remaining length of the packet,
where the former is greater than the latter and they're both unsigned.

3 years agoUpdate eapon1-v.out to match the change to the EAP dissector.
Denis Ovsienko [Sun, 14 Nov 2021 13:25:47 +0000 (13:25 +0000)] 
Update eapon1-v.out to match the change to the EAP dissector.

The Buildbot workers build exactly what is in the tcpdump git repository
at the given revision, also every build (which consists of a single run
of build_matrix.sh) starts in a freshly cloned repository to keep any
effects of earlier builds out of the problem space.

So the only non-deterministic factors in a tcpdump build should be
libpcap revision, which is the latest master branch, and the host system
effects, such as network connectivity, disk space, RAM, compilers
randomly segfaulting for no reason, package updates and the likes.

In this case commit fd5f8f8 changed print-eap.c but not any tests, so
the build matrix failed at the first step that runs "make check", that
is, has BUILD_LIBPCAP=yes (for example, step 9 on linux-s390x and step 5
on openbsd-amd64).  That step had SMB=no, so the eapon1-v-nosmb test
failed. This was correctly addressed in commit 6841a40, so the
previously failed step passed, but the next step (step 10 on linux-s390x
and step 6 on openbsd-amd64) had SMB=yes and the eapon1-v test failed.
Update the latter and have the full matrix pass again.

A simple way not to make this feedback loop longer than it needs to be
is to run the full matrix locally before pushing the changes (the stdout
can be redirected to /dev/null to see the most important messages only):

./build_matrix.sh

3 years agoRevert "EAP: back out the two trailing-comma changes."
Denis Ovsienko [Sun, 14 Nov 2021 13:10:40 +0000 (13:10 +0000)] 
Revert "EAP: back out the two trailing-comma changes."

This reverts commit ab01750c1e454fdb9732c1a50671100b4f79070b.

3 years agoEAP: back out the two trailing-comma changes.
Guy Harris [Sun, 14 Nov 2021 06:20:08 +0000 (22:20 -0800)] 
EAP: back out the two trailing-comma changes.

Hopefully this provokes one more build on the buildbots, with a matching
print-eap.c and tests/eapon1-v-nosmb.out, so that "make check" succeeds.

Step 2 is to check the new versions back in, in one commit, in the hopes
that "make check" succeeds.

It appears that, on all the buildbots, print-esp.c is up to date but
tests/eapon1-v-nosmb.out isn't; I have *NO* idea how that happened, but
it again reminds me that I hate software.

3 years agoUpdate eapon1-v-nosmb.out to match the change to the EAP dissector.
Guy Harris [Sun, 14 Nov 2021 03:10:44 +0000 (19:10 -0800)] 
Update eapon1-v-nosmb.out to match the change to the EAP dissector.

3 years agoEAP: get rid of trailing commas in lists.
Guy Harris [Sun, 14 Nov 2021 03:08:26 +0000 (19:08 -0800)] 
EAP: get rid of trailing commas in lists.

Don't print a comma separator after items; print them before items if an
item has already been printed from which the new item needs to be
separated.

3 years agoEAP: clean up white space.
Guy Harris [Sun, 14 Nov 2021 02:50:53 +0000 (18:50 -0800)] 
EAP: clean up white space.

3 years agoEAP: add some more length checks.
Guy Harris [Sun, 14 Nov 2021 02:50:02 +0000 (18:50 -0800)] 
EAP: add some more length checks.

Check to make sure we don't go past the length value in the header.

Note that the string in an Identity message is optional (so we just
don't bother printing it if it's zero-length), but the string in a
notification message isn't (so report an error if it's zero-length).

3 years agoEAP: label length mismatch as a possible EAP fragment.
Guy Harris [Sun, 14 Nov 2021 02:44:57 +0000 (18:44 -0800)] 
EAP: label length mismatch as a possible EAP fragment.

In some cases, EAP fragmentation/reassembly is done at a layer above
EAP, e.g. when EAP messages are contained within a RADIUS message and
are broken up into multiple TLVs in the message.  In those cases, the
length handed to eap_print() will be different from the length in the
first fragment's header, and the remaining fragments won't *have* a
header, so the "length" will be garbage and thus unlikely to be equal to
the length handed to us.

3 years agoEAP: no need for the count variable to be signed.
Guy Harris [Sun, 14 Nov 2021 02:34:00 +0000 (18:34 -0800)] 
EAP: no need for the count variable to be signed.

Make it unsigned, and, while we're at it, make the loop a for loop.

3 years agoUpdate some comments with new RFC numbers.
Guy Harris [Sun, 14 Nov 2021 02:18:47 +0000 (18:18 -0800)] 
Update some comments with new RFC numbers.

3 years agoAdd a test case for QUIC retry packets.
Rui Paulo [Tue, 9 Nov 2021 21:06:18 +0000 (13:06 -0800)] 
Add a test case for QUIC retry packets.

3 years agoQUIC: Fix getting packet type in Long Header
Francois-Xavier Le Bail [Tue, 9 Nov 2021 19:13:01 +0000 (20:13 +0100)] 
QUIC: Fix getting packet type in Long Header

This change should fix the Coverity Scan issue CID 1493488:
178                             ND_PRINT(", handshake");
>>> CID 1493488:  Control flow issues  (DEADCODE)
>>> Execution cannot reach this statement: "if (packet_type == QUIC_LH_...".
179                     else if (packet_type == QUIC_LH_TYPE_RETRY)

3 years agoDocument "-T quic"
Francois-Xavier Le Bail [Tue, 9 Nov 2021 09:15:23 +0000 (10:15 +0100)] 
Document "-T quic"

3 years agoMerge pull request #943 from rpaulo/quic
fxlb [Tue, 9 Nov 2021 08:21:25 +0000 (08:21 +0000)] 
Merge pull request #943 from rpaulo/quic

Initial support to parse QUIC packets.

3 years agoInitial support to parse QUIC packets. 943/head
Rui Paulo [Fri, 1 Oct 2021 01:34:46 +0000 (18:34 -0700)] 
Initial support to parse QUIC packets.

3 years agoEAP: Fix some undefined behaviors at runtime
Francois-Xavier Le Bail [Thu, 4 Nov 2021 21:56:37 +0000 (22:56 +0100)] 
EAP: Fix some undefined behaviors at runtime

The errors were like:
print-eap.c:179:25: runtime error: unsigned integer overflow:
  2 - 5 cannot be represented in type 'unsigned int'
print-eap.c:181:50: runtime error: unsigned integer overflow:
  2 - 5 cannot be represented in type 'unsigned int'
print-eap.c:186:25: runtime error: unsigned integer overflow:
  2 - 5 cannot be represented in type 'unsigned int'
print-eap.c:188:50: runtime error: unsigned integer overflow:
  2 - 5 cannot be represented in type 'unsigned int'

3 years agoMerge pull request #954 from jiladahe1997/master
Denis Ovsienko [Thu, 4 Nov 2021 11:40:56 +0000 (11:40 +0000)] 
Merge pull request #954 from jiladahe1997/master

3 years ago[bugfix]configure: fix error when cross-compile 954/head
Mingrui [Thu, 4 Nov 2021 01:07:23 +0000 (09:07 +0800)] 
[bugfix]configure: fix error when cross-compile

While cross-compile, ./configure --host=xxx will output:
"checking whether printf(3) supports the z length modifier...
configure: error: in `/${path_to_tcpdump}/tcpdump':"

That is casued by AC_RUN_IFELSE, as describe in
"https://www.gnu.org/software/autoconf/manual/autoconf-2.63/html_node/Runtime.html"
, if AC_RUN_IFELSE do not have cross-compile option, configure prints an error message and exits.

Signed-off-by: Mingrui Ren [email protected]
3 years agosFlow: Add a length check
Francois-Xavier Le Bail [Wed, 3 Nov 2021 09:18:24 +0000 (10:18 +0100)] 
sFlow: Add a length check

3 years agoVRRP: Add support for IPv6
Quentin Armitage [Sun, 31 Oct 2021 16:52:54 +0000 (16:52 +0000)] 
VRRP: Add support for IPv6

Signed-off-by: Quentin Armitage <[email protected]>
3 years agolwres: Update a variable type
Francois-Xavier Le Bail [Tue, 2 Nov 2021 08:34:45 +0000 (09:34 +0100)] 
lwres: Update a variable type

This should address two AppVeyor/Visual Studio 2019/x64 warnings:
print-lwres.c(197,23): warning C4267: 'function': conversion from
 'size_t' to 'u_int', possible loss of data
print-lwres.c(201,14): warning C4267: 'return': conversion from
 'size_t' to 'unsigned int', possible loss of data

3 years agoAssign ndo->ndo_packetp in pretty_print_packet()
Francois-Xavier Le Bail [Mon, 1 Nov 2021 08:40:53 +0000 (09:40 +0100)] 
Assign ndo->ndo_packetp in pretty_print_packet()

Thus it can be used for debugging.

3 years agoUse __func__ from C99 in two function calls
Francois-Xavier Le Bail [Sun, 31 Oct 2021 12:27:20 +0000 (13:27 +0100)] 
Use __func__ from C99 in two function calls

3 years agoRename a pcapng test file to .pcapng
Francois-Xavier Le Bail [Wed, 27 Oct 2021 20:16:11 +0000 (22:16 +0200)] 
Rename a pcapng test file to .pcapng

3 years agoVRRP: Print the protocol name before any GET_()
Francois-Xavier Le Bail [Thu, 21 Oct 2021 14:25:57 +0000 (16:25 +0200)] 
VRRP: 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().

3 years agoman: Fixup some formatting. [skip ci]
Denis Ovsienko [Wed, 20 Oct 2021 12:44:23 +0000 (13:44 +0100)] 
man: Fixup some formatting. [skip ci]

Use BSD style references and protect some refs from hyphenation.

3 years agoMerge pull request #941.
Denis Ovsienko [Sat, 9 Oct 2021 20:34:30 +0000 (21:34 +0100)] 
Merge pull request #941.

3 years agotests: Add a pcap test for BGP link-bandwidth extended community 941/head
Donatas Abraitis [Thu, 23 Sep 2021 07:56:24 +0000 (10:56 +0300)] 
tests: Add a pcap test for BGP link-bandwidth extended community

Signed-off-by: Donatas Abraitis <[email protected]>
3 years agobgp: Decode BGP link-bandwidth extended community properly
Donatas Abraitis [Wed, 22 Sep 2021 08:30:06 +0000 (11:30 +0300)] 
bgp: Decode BGP link-bandwidth extended community properly

First two bytes are reserved for AS.

Before:
```
  Extended Community (16), length: 8, Flags [OT]:
    link-BW (0x4004), Flags [non-transitive]: bandwidth: -308754489798474897524123005616128.000 Mbps
    0x0000:  4004 fde8 47f4 2400
  Updated routes:
    192.168.10.0/23
```

After:
```
  Extended Community (16), length: 8, Flags [OT]:
    link-BW (0x4004), Flags [non-transitive]: bandwidth: 1.000 Mbps
    0x0000:  4004 fde8 47f4 2400
  Updated routes:
    192.168.10.0/23
```

Signed-off-by: Donatas Abraitis <[email protected]>
3 years agoMerge pull request #889 from westermo/dsa-vid
Michael Richardson [Wed, 6 Oct 2021 18:38:09 +0000 (14:38 -0400)] 
Merge pull request #889 from westermo/dsa-vid

DSA: Correctly determine VID

3 years agoDSA: Correctly determine VID 889/head
Tobias Waldekranz [Tue, 5 Oct 2021 20:46:40 +0000 (22:46 +0200)] 
DSA: Correctly determine VID

The 4 MSBs of the VID is stored in the lower nibble of the tag's third
byte.

Previously the priority bits where folded into the VID space, e.g. a
packet with VID=1 and priority 6 was printed as having a VID of
1537 (0x601).

Add DSA test PCAPs with packets containing a high VID and non-zero
FPri values to make sure we catch any future regressions.

Signed-off-by: Tobias Waldekranz <[email protected]>
3 years agoMove the backported items to 4.99.2 in CHANGES. [skip ci]
Denis Ovsienko [Wed, 29 Sep 2021 14:26:15 +0000 (15:26 +0100)] 
Move the backported items to 4.99.2 in CHANGES. [skip ci]

3 years agolwres: Fix a length check
Francois-Xavier Le Bail [Mon, 27 Sep 2021 13:43:32 +0000 (15:43 +0200)] 
lwres: Fix a length check

This fix some inconsistent outputs clang versus gcc in 32 bits mode.

Add a test file.

3 years agoCI: Refine GCC identification. [skip appveyor]
Denis Ovsienko [Wed, 15 Sep 2021 08:54:11 +0000 (09:54 +0100)] 
CI: Refine GCC identification. [skip appveyor]

Same as in libpcap.

3 years agoMerge pull request #926 from gokulkumar792/print_Block_Ack_TA_field
Guy Harris [Mon, 13 Sep 2021 21:50:43 +0000 (14:50 -0700)] 
Merge pull request #926 from gokulkumar792/print_Block_Ack_TA_field

IEEE 802.11: include the "TA" field while printing Block Ack Control frame

3 years agoRemove last remaining trailing whitespace
a1346054 [Fri, 3 Sep 2021 21:18:14 +0000 (21:18 +0000)] 
Remove last remaining trailing whitespace

3 years agoMerge pull request #924 from gokulkumar792/print_meshid
Michael Richardson [Wed, 25 Aug 2021 15:44:08 +0000 (11:44 -0400)] 
Merge pull request #924 from gokulkumar792/print_meshid

IEEE 802.11: include the "Mesh ID" field while printing management frames

3 years agoIEEE 802.11: Add a test to check the 802.11s Mesh ID in management frames 924/head
Gokul Sivakumar [Sun, 4 Jul 2021 12:54:57 +0000 (18:24 +0530)] 
IEEE 802.11: Add a test to check the 802.11s Mesh ID in management frames

The newly added pcap file contains a Mesh Beacon frame, a Wildcard Probe
Request and a Mesh Probe Response. The test case checks if the "Mesh ID"
field is properly parsed by the IEEE 802.11 printer.

3 years agoIEEE 802.11: include the "Mesh ID" field while printing management frames
Gokul Sivakumar [Sun, 4 Jul 2021 12:54:19 +0000 (18:24 +0530)] 
IEEE 802.11: include the "Mesh ID" field while printing management frames

In an 802.11s mesh network, on detecting that the Beacon and Probe Response
frames transmitted has a non-zero length "Mesh ID", print it.

3 years agoMPTCP: Add missing MP_CAPABLE Flags 934/head
Rui [Mon, 16 Aug 2021 18:36:00 +0000 (19:36 +0100)] 
MPTCP: Add missing MP_CAPABLE Flags

Parse previous ignored flags from MP_CAPABLE option

3 years agoCI: Add MAKE_BIN to allow non-default makes. [skip ci]
Denis Ovsienko [Tue, 17 Aug 2021 19:35:21 +0000 (20:35 +0100)] 
CI: Add MAKE_BIN to allow non-default makes. [skip ci]

This way parallel builds are simpler on Solaris and OpenIndiana.

3 years agoDocument some OpenIndiana particulars. [skip ci]
Denis Ovsienko [Tue, 17 Aug 2021 16:39:47 +0000 (17:39 +0100)] 
Document some OpenIndiana particulars. [skip ci]

3 years agoCI: Clean in ../libpcap only if present. [skip ci]
Denis Ovsienko [Tue, 17 Aug 2021 16:20:32 +0000 (17:20 +0100)] 
CI: Clean in ../libpcap only if present. [skip ci]

./build_matrix.sh[89]: cd: /export/home/denis/libpcap: [No such file or
  directory]

3 years agoFixup commit 604cd4a for OpenIndiana.
Denis Ovsienko [Mon, 16 Aug 2021 22:47:07 +0000 (23:47 +0100)] 
Fixup commit 604cd4a for OpenIndiana.

SunOS openindiana 5.11 illumos-755ccbcfa2 i86pc i386 i86pc
gcc (OpenIndiana 10.3.0-oi-0) 10.3.0

As it turns out, in OpenIndiana 2021.04 ND_UNREACHABLE is one of the
neighbour discovery states in <net/if.h>:

In file included from ./extract.h:40,
                 from ./addrtoname.h:22,
                 from ./addrtoname.c:112:
./diag-control.h:181: warning: "ND_UNREACHABLE" redefined

In file included from ./addrtoname.c:87:
/usr/include/net/if.h:307: note: this is the location of the previous
  definition

In file included from ./extract.h:40,
                 from ./addrtoname.h:22,
                 from ./print-sll.c:36:
./diag-control.h:181: warning: "ND_UNREACHABLE" redefined

In file included from ./print-sll.c:29:
/usr/include/net/if.h:307: note: this is the location of the previous
  definition

3 years agoUse more the ND_TCHECK_1() macro
Francois-Xavier Le Bail [Sun, 15 Aug 2021 11:04:42 +0000 (13:04 +0200)] 
Use more the ND_TCHECK_1() macro

This is a follow-up to 7b7b84716e604abd8bd92cee75e6385cab6ce3dc.

3 years agoUse more the ND_TCHECK_1() macro
Francois-Xavier Le Bail [Sun, 15 Aug 2021 09:20:12 +0000 (11:20 +0200)] 
Use more the ND_TCHECK_1() macro

This is a follow-up to 880b867ee73ae757faebbab13213c7d4079222a5.

3 years agoUse __builtin_unreachable(). [skip ci]
Denis Ovsienko [Sun, 15 Aug 2021 09:54:50 +0000 (10:54 +0100)] 
Use __builtin_unreachable(). [skip ci]

Same as in libpcap.

3 years agoRemove the space I added to provoke a rebuild.
Guy Harris [Wed, 11 Aug 2021 23:37:34 +0000 (16:37 -0700)] 
Remove the space I added to provoke a rebuild.

(This should also provoke a rebuild; the NetBSD libpcap build should no
longer have the issue that caused tcpdump to fail when built with it.)

3 years agoAdd a space at the end of the first line, to provoke a build.
Guy Harris [Wed, 11 Aug 2021 10:18:54 +0000 (03:18 -0700)] 
Add a space at the end of the first line, to provoke a build.

(There doesn't appear to be an obvious way to force a rebuild, and a
change to libpcap doesn't force a rebuild of programs such as tcpdump
for which the CI build includes a build with the tip of the main branch
of libpcap.)

3 years agoConsistenly use "XYZZY compiler M.N and later". [skip ci]
Guy Harris [Wed, 11 Aug 2021 08:50:47 +0000 (01:50 -0700)] 
Consistenly use "XYZZY compiler M.N and later".  [skip ci]

Use that rather than "... or later".

3 years agoGet rid of duplicate definition of __has_attribute.
Guy Harris [Wed, 11 Aug 2021 08:44:51 +0000 (01:44 -0700)] 
Get rid of duplicate definition of __has_attribute.

compiler-tests.h already checks whether __has_attribute and, if not,
defines it as a macro that always returns 0 (so that we use the "what
version of the compiler is this?" fallback checks for a given
attribute).  We include compiler-tests.h before we define
__has_attribute ourselves, so we don't need to do it ourselves.

3 years agoFix a comment. [skip ci]
Guy Harris [Wed, 11 Aug 2021 08:28:42 +0000 (01:28 -0700)] 
Fix a comment.  [skip ci]

3 years agoMake the tests a bit easier to read.
Guy Harris [Wed, 11 Aug 2021 08:05:52 +0000 (01:05 -0700)] 
Make the tests a bit easier to read.

Add comments and indentation.

Handle XL C a bit more like the other compilers.  Make the first test be
"is this someting that's not XL C", as is the case for other compilers;
that test is done as "are both __xlC__ and __ibmxl__ undefined".  If
either of them are defined, use __ibmxl_version__ if __ibmxl__ is
defined, and use __xlC__ otherwise.

3 years agoDo not define __EXTENSIONS__ if already defined. [skip ci]
Denis Ovsienko [Tue, 10 Aug 2021 09:18:19 +0000 (10:18 +0100)] 
Do not define __EXTENSIONS__ if already defined. [skip ci]

SunOS solaris11-amd64 5.11 11.4.0.15.0 i86pc i386 i86pc
clang version 6.0.0 (tags/RELEASE_600/final)

Every .c file that included netdissect-stdinc.h generated a warning:

In file included from ./netdissect-stdinc.h:42:
./ftmacros.h:48:11: warning: '__EXTENSIONS__' macro redefined
      [-Wmacro-redefined]
<built-in>:345:9: note: previous definition is here

3 years agoTell CMake not to check for a C++ compiler.
Guy Harris [Sun, 8 Aug 2021 18:54:17 +0000 (11:54 -0700)] 
Tell CMake not to check for a C++ compiler.

We only need a C compiler, and if either

1) the C and C++ compilers don't match (e.g., a defaults-to-64-bit GCC
and a defaults-to-32-bit Oracle Studio C++)

or

2) you set CFLAGS in the environment to force a 64-bit build but don't
also set CXXFLAGS

CMake will get confused and think it's doing a 32-bit build even though
we'll be doing a 64-bit build, and all sorts of weirdness will occur.

Just say "C" in the project() command.

3 years agoOn Solaris, for 64-bit builds, use the 64-bit pcap-config.
Guy Harris [Sun, 8 Aug 2021 07:36:42 +0000 (00:36 -0700)] 
On Solaris, for 64-bit builds, use the 64-bit pcap-config.

There are two versions of pcap-config supplied on Solaris (or, at least,
on 64-bit Solaris) - a version that has the right --libs output to find
the 32-bit libraries and a version that has the right --libs output to
find the 64-bit libraries.

Try to figure out whether we're doing a 32-bit or 64-bit build (based on
the pointer size) and, for 64-bit builds, run the 64-bit version of
pcap-config.

3 years agoUse basename() and dirname() right on FreeBSD. [skip appveyor]
Denis Ovsienko [Thu, 5 Aug 2021 13:18:55 +0000 (14:18 +0100)] 
Use basename() and dirname() right on FreeBSD. [skip appveyor]

On FreeBSD CMake runs Clang with -std=gnu99, which used to emit three
warnings in a Capsicum-specific block along the following lines:

tcpdump.c:2432:32: warning: '_Generic' is a C11 extension
  [-Wc11-extensions]
/usr/include/libgen.h:61:21: note: expanded from macro 'basename'
  basename)(x)
/usr/include/sys/cdefs.h:325:2: note: expanded from macro '__generic'
        _Generic(expr, t: yes, default: no)

(In the same context Autoconf does not request a specific C standard
from Clang, so it happens to use C17 and there is no warning.)

Type-generic expressions support in C99 mode seems to be a quirk of
Clang that cannot be disabled and is harmless in this context, so
introduce and use another pair of diagnostic control macros (for Clang
only) to squelch the warnings.

While at it, study the reason for _Generic use in /usr/include/libgen.h
and realize that tcpdump.c still assumes the behaviour before FreeBSD
12.0.  Add two temporary buffers around basename() and dirname() calls
to get consistent results regardless of which FreeBSD version it is.

Remove the last remaining exemption rule.

3 years agoFix auto-enabling of Capsicum on FreeBSD with Autoconf. [skip appveyor]
Denis Ovsienko [Tue, 3 Aug 2021 23:20:36 +0000 (00:20 +0100)] 
Fix auto-enabling of Capsicum on FreeBSD with Autoconf. [skip appveyor]

Even after commit 6393bb6 --with-sandbox-capsicum didn't work entirely
as documented, as it defaulted to disabled:

checking whether to sandbox using capsicum... no
checking whether to sandbox using Casper library... no

Get the test condition right so it does what it says:

checking sys/capsicum.h usability... yes
checking sys/capsicum.h presence... yes
checking for sys/capsicum.h... yes
checking for cap_enter... yes
checking for cap_rights_limit... yes
checking for cap_ioctls_limit... yes
checking for openat... yes
checking for cap_init in -lcasper... yes
checking for cap_gethostbyaddr in -lcap_dns... yes
checking whether to sandbox using capsicum... yes
checking whether to sandbox using Casper library... yes

3 years agoSquelch a warning with Capsicum enabled. [skip appveyor]
Denis Ovsienko [Tue, 3 Aug 2021 22:38:48 +0000 (23:38 +0100)] 
Squelch a warning with Capsicum enabled. [skip appveyor]

The Capsicum workaround I added in commit 706c79e causes a side effect
on FreeBSD 11.4, 12.2 and 13.0 with local libpcap when Capsicum is
enabled, that is, in CMake builds (Capsicum detection is broken in
Autoconf builds, as it turns out).  Add a workaround for the side effect
as well and get rid of another warning and respective exemption:

tcpdump.c:2286:3: warning: implicit declaration of function 'bpf_dump'
  is invalid in C99 [-Wimplicit-function-declaration]

3 years agoCMake: Fix EXTRA_CFLAGS after commit cae0c65. [skip appveyor]
Denis Ovsienko [Tue, 3 Aug 2021 22:25:02 +0000 (23:25 +0100)] 
CMake: Fix EXTRA_CFLAGS after commit cae0c65. [skip appveyor]

Same as in libpcap.

3 years agoconfigure: special-case macOS /usr/bin/pcap-config as we do in CMake.
Guy Harris [Tue, 3 Aug 2021 19:58:34 +0000 (12:58 -0700)] 
configure: special-case macOS /usr/bin/pcap-config as we do in CMake.

macOS's /usr/bin/pcap-config is incorrectly generated - pcap-config
--cflags includes -I/usr/local/include and pcap-config --libs includes
-L/usr/local/lib, even though it's the pcap-config file for the libpcap
that comes with the OS and should omit those.

3 years agoDefine PRINTFLIKE_FUNCPTR() exactly for XL C. [skip appveyor]
Denis Ovsienko [Tue, 3 Aug 2021 17:23:13 +0000 (18:23 +0100)] 
Define PRINTFLIKE_FUNCPTR() exactly for XL C. [skip appveyor]

XL C full version consists of 4 numbers.  Introduce an additional macro
for testing the two least significant numbers.  Using the fix lists
published by IBM, tell XL C 16.1 that has the bug interpreting the
__format__ attribute of a function pointer from XL C 16.1 that has not.
Rejig the #if block to make it easier to follow.

3 years agoCI: Get randomness right in mktempdir_diy(). [skip ci]
Denis Ovsienko [Tue, 3 Aug 2021 14:36:31 +0000 (15:36 +0100)] 
CI: Get randomness right in mktempdir_diy(). [skip ci]

Same as in tcpslice.

3 years agoCI: Put a misplaced comment right in build.sh. [skip ci]
Denis Ovsienko [Tue, 3 Aug 2021 14:31:54 +0000 (15:31 +0100)] 
CI: Put a misplaced comment right in build.sh. [skip ci]

The script both assigns and uses TCPDUMP_BIN, so it is the export line
that is purposed for TESTrun rather than the variable assignment.

3 years agoMove capdns from tcpdump.c to addrtoname.c.
Denis Ovsienko [Sun, 1 Aug 2021 23:32:46 +0000 (00:32 +0100)] 
Move capdns from tcpdump.c to addrtoname.c.

Address the warning below (specific to a few versions of Clang, CMake
and FreeBSD) and update the exemption rule comment in build.sh.

tcpdump.c:244:16: warning: no previous extern declaration for non-static
  variable 'capdns' [-Wmissing-variable-declarations]

3 years agoCMake: Handle EXTRA_CFLAGS w/o add_compile_options(). [skip ci]
Denis Ovsienko [Sat, 31 Jul 2021 20:35:17 +0000 (21:35 +0100)] 
CMake: Handle EXTRA_CFLAGS w/o add_compile_options(). [skip ci]

Same as in libpcap commit 29d7856.

3 years agoLose two unused macros in diag-control.h. [skip ci]
Denis Ovsienko [Sat, 31 Jul 2021 20:04:11 +0000 (21:04 +0100)] 
Lose two unused macros in diag-control.h. [skip ci]

3 years agoCI: Explain useful side effects of "-D" and "-J". [skip ci]
Denis Ovsienko [Fri, 30 Jul 2021 15:20:34 +0000 (16:20 +0100)] 
CI: Explain useful side effects of "-D" and "-J". [skip ci]

3 years agoCMake: Add a way to request -Werror and equivalents.
Denis Ovsienko [Fri, 30 Jul 2021 09:12:59 +0000 (10:12 +0100)] 
CMake: Add a way to request -Werror and equivalents.

As it turns out, most FreeBSD/CMake tcpdump builds were emitting some
warnings.  This was difficult to notice because make returned success
regardless of the warnings because the compiler never received -Werror
because there was no way to tell CMake to append any compiler flags at
the build time, but not at the buildsystem generation time.  In other
words, the command "make CFLAGS=-Werror" had the same effect as just
"make".

Implement the desired behaviour with "cmake -DEXTRA_CFLAGS='xyz'" and
set the variable in build.sh when and as required.  Reword the comment
for clarity and define two known exemptions.

3 years agoCI: Port recent improvements from tcpslice. [skip appveyor]
Denis Ovsienko [Fri, 30 Jul 2021 08:44:04 +0000 (09:44 +0100)] 
CI: Port recent improvements from tcpslice. [skip appveyor]

Introduce TCPDUMP_TAINTED, improve OS and compiler identification, print
matrix progress to stderr.

3 years agoCirrus CI: Fixup the previous commit. [skip appveyor]
Denis Ovsienko [Thu, 29 Jul 2021 20:20:00 +0000 (21:20 +0100)] 
Cirrus CI: Fixup the previous commit. [skip appveyor]

Failed to start an instance: [...]
Number of vCPUs should be multiple of 2 if greater than 2, while 3.0 is
requested. Memory size for 3.0 vCPU instance should be between 2816MiB
and 19968MiB, while 2048MiB is requested.

3 years agonetdissect.h requires funcattrs.h
Denis Ovsienko [Thu, 29 Jul 2021 20:12:06 +0000 (21:12 +0100)] 
netdissect.h requires funcattrs.h

...because the former uses PRINTFLIKE_FUNCPTR().  However, it didn't
have the #include.  However, the problem was not visible because most
files that included netdissect.h also included (directly or through
another header) funcattrs.h beforehand.  The only exceptions were the
following two files, which apparently have not been compiled anywhere
for a long time:

In file included from missing/strdup.c:38:
./netdissect.h:254:8: error: expected ':', ',', ';', '}' or
'__attribute__' before 'PRINTFLIKE_FUNCPTR'

In file included from missing/snprintf.c:45:
./netdissect.h:254:8: error: expected ':', ',', ';', '}' or
'__attribute__' before 'PRINTFLIKE_FUNCPTR'

Add the missing #include to netdissect.h to eliminate this space for
failure.