]> The Tcpdump Group git mirrors - tcpdump/commit
Detect OS IPv6 support using AF_INET6 only. 1036/head
authorDenis Ovsienko <[email protected]>
Tue, 21 Feb 2023 08:02:28 +0000 (08:02 +0000)
committerDenis Ovsienko <[email protected]>
Wed, 22 Feb 2023 20:05:58 +0000 (20:05 +0000)
commit10b807441e79f9c9e557bbb44ae0ecfe01ed5151
treed7da9a0f2ba7dad133266afd85c376d061fdb5e1
parent64a786abab1ede316c9b23b0ba6efb28bf51917e
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.
CHANGES
CMakeLists.txt
addrtoname.c
cmakeconfig.h.in
configure.ac
netdissect-stdinc.h
tcpdump.c