Commit Graph

171 Commits

Author SHA1 Message Date
Denis Ovsienko
a0ffbfba6c CMake: Get the comment about EXTRA_CFLAGS right. [skip ci]
The "testprogs" sentence applies to libpcap only.
2024-04-05 15:17:08 +01:00
Denis Ovsienko
0e04b9da80 SLL2: Translate interface indices to names on Linux only.
print-sll.c uses HAVE_NET_IF_H, which does not always work right: the
header is in POSIX.1-2001, but the result of if_indextoname() is
irrelevant if the current OS is not Linux, in which case the packet was
captured on a different host because libpcap produces DLT_LINUX_SLL2 on
Linux only.  The result can be irrelevant on Linux too, but this does
not have an easy solution.

To reduce the problem space, switch print-sll.c to check for __linux__
instead.  In tcpdump.c print the warning about interface names only if
sll2_if_print() would print interface names.  Since HAVE_NET_IF_H has no
purpose now, remove the checks for <net/if.h>.
2024-04-02 11:36:13 +01:00
Francois-Xavier Le Bail
f81ffd1754 Include <fcntl.h> unconditionally
It is used for open() which is in POSIX.1-2001, POSIX.1-2008.

libpcap has included <fcntl.h> unconditionally since at least 1999.
2024-03-29 06:11:55 +00:00
Francois-Xavier Le Bail
94a3708f00 Include <config.h> unconditionally
Builds using Autotools or CMake generate config.h, thus remove the
'#ifdef HAVE_CONFIG_H'/'#endif'.

Remove also the 'add_definitions(-DHAVE_CONFIG_H)' in CMakeLists.txt.
2024-03-28 05:34:34 +00:00
Denis Ovsienko
e1bcb7941d Simplify the checks for snprintf().
Do not check that the function is just available: first, it is in C99,
so the check almost certainly is a waste of time; second, the source
requires the function unconditionally; third, the subsequent "snprintf()
is suitable" check implies the "snprintf() is available" part anyway.
2024-03-27 23:46:15 +00:00
Denis Ovsienko
3d215c6db5 Do not define _SUN on AIX. [skip ci]
Setting the macro makes no difference on AIX 7.1, see also libpcap
commit be724d5.
2024-03-26 20:59:44 +00:00
Denis Ovsienko
a9c7cf8848 Disregard setlinebuf(3), always use setvbuf(3).
As most setlinebuf(3) man pages mention, setlinebuf() is a shorthand for
setvbuf().  The latter is in C99, but the former is not, so it is most
logical to use setvbuf() in all cases and to lose another build-time
check.
2024-03-25 15:09:00 +00:00
Denis Ovsienko
b29858253c Fix Sun C invocation from CMake.
cc: Can not use -xc99 with -pedantic
2024-03-15 00:08:55 -07:00
Francois-Xavier Le Bail
170cbc8c6d Autoconf, CMake: Get the size of a void * and a time_t
With this change we know:
whether this is a 32-bit or 64-bit build ;
whether the time_t size is 32-bit or 64-bit.

At least with CMake, the SIZEOF values could be 0, if somebody's
doing a fat build on macOS and that includes both 32-bit and 64-bit
instruction sets.
2024-03-14 16:19:01 +01:00
Francois-Xavier Le Bail
656bd18c72 Autoconf, CMake: Add a warning flag (-Wundef) 2024-03-07 06:39:23 +00:00
Denis Ovsienko
f32255ba13 Fix propagation of cc_werr_cflags() output. [skip ci]
Same as in libpcap.  It is not the propagation that tcpdump needs from
this change, but the proper application of compiler options.
2024-03-04 11:43:20 +00:00
Denis Ovsienko
569372be9e Retire most of IRIX support.
In parsenfsfh.c keep IRIX-specific code that is not specific to
*compiling* on IRIX.  Do not touch AC_LBL_LIBRARY_NET yet.
2024-01-28 16:48:31 +00:00
Denis Ovsienko
630f9bcaa8 Retire Tru64 UNIX support.
See also commit 6008cb8.
2024-01-28 11:35:15 +00:00
Francois-Xavier Le Bail
5ee91ef4b6 Replace some command name 'Tcpdump' with 'tcpdump'
[skip ci]
2023-12-20 21:03:50 +01:00
Guy Harris
6193b88600 CMake: attempt to suppress deprecation errors.
Yes, we should probably fix them at some point, but not Right This
Instant.

This should squelch the warnings in #1087, but leave that open, pending
a decision on which release of CMake to require on non-Windows
platforms.
2023-11-25 22:12:59 -08:00
Josh Soref
38050da48e Fix spelling
* account
* address
* adjacency
* alignment
* anymore
* ascii
* assumption
* blithely
* canonical
* compound
* consecutive
* control
* diagnostics
* disassociation
* fairly
* fallthrough
* greatest
* identification
* multihop
* multiplexed
* nonexistent
* notifiable
* notwithstanding
* number
* polynomial
* preexisting
* proprietary
* quenches
* reassociation
* redefinition
* refresh
* solicitation
* specifying
* support
* the
* unacceptable

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-08-20 07:19:40 +00:00
Francois-Xavier Le Bail
d6734adaa3 Fix a typo in a comment
[skip ci]
2023-08-13 09:59:12 +02:00
Francois-Xavier Le Bail
7cba9309f3 Fix a typo in a comment
[skip ci]
2023-06-25 19:22:16 +02:00
Guy Harris
e0787e5d8c 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.
2023-06-07 15:20:16 -07:00
Guy Harris
6c8a3facc7 Add support for dissecting RFC 2332 NHRP.
This is from the OpenBSD tcpdump.
2023-04-11 04:11:49 -07:00
Denis Ovsienko
161c18fa34 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.
2023-02-25 18:02:18 +00:00
Guy Harris
008b90f611 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.
2023-02-22 22:38:19 -08:00
Denis Ovsienko
10b807441e 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.
2023-02-22 20:05:58 +00:00
Denis Ovsienko
afe133ecef Do not substitute strdup().
libpcap has been using strdup() for a long time too, but never
substituted it under the assumption the function is available in all
supported OSes, see libpcap commit cb71eef from 2006.  The only
exception to that is Windows, which can have a different name for the
function, but both libpcap and tcpdump for that already use a separate
workaround, which does not involve the substitution.

Let's take this as a proof that strdup() substitution in tcpdump is dead
code, and remove it.
2023-02-19 11:33:13 +00:00
Denis Ovsienko
a69de5a4d9 Do not require vsnprintf().
The check for vsnprintf() has been in the configure script since commit
8cb054c in 2000, and the only actual use of the function was in the
"#ifndef HAVE_SNPRINTF" block in missing/snprintf.c until commit 1ed63b5
in 2019.  Since then tcpdump does not require vsnprintf() in any way.
2023-02-17 08:56:15 +00:00
Denis Ovsienko
e03799cb9f Require a proof of suitable snprintf(3) implementation.
My earlier commit fbd4415 did a wrong thing because it caused a failure
to fail in "make check" on Solaris 9, whereas the right thing to do when
printf() does not work as expected would be to fail the build with a
useful error message.   Implement that by testing snprintf() in Autoconf
and CMake (assume that in a given libc implementation all functions in
the printf() family have the same level of support for conversion
specifications).  Return 18 tests from the conditional space back into
TESTLIST.
2023-02-16 20:55:56 +00:00
Guy Harris
31762a4eb3 CMake: improve the comment before project(tcpdump C). [skip ci]
Note that, even if there weren't horrible consequences to either 1)
having no C++ compiler, 2) setting an instruction set bit width in
CFLAGS but not in CXXFLAGS, or 3) having C and C++ compilers with
different default instruction set bit-widths, specifying that we're
C-only avoids wasting time looking for a C++ compiler.
2023-02-15 15:10:35 -08:00
Guy Harris
6eb61d130b configure, CMake: remove -fPIC hacks for Haiku.
As of llvm12_clang-12.0.1-5, Clang defaults to generating PIC, just as
GCC does, and the entire matrix now works.
2023-02-14 16:07:22 -08:00
Guy Harris
93a3b993be CMake: try to fix the Haiku build.
If we set CMAKE_C_FLAGS_INIT to "-fPIC" before setting the project, that
initializes CMAKE_C_FLAGS to "-fPIC" *before* prepending the contents of
the CFLAGS environment variable, and *before* doing any tests that
depend on linking, in the project() command, so it 1) adds -fPIC before
doing those tests, so they don't fail due to the object files being
unfit to link into an executable, and 2) adds the contents of CFLAGS to
CMAKE_C_FLAGS, so the user can set CFLAGS and have it affect the build.

This requires CMake 3.7 or later, so we set 3.7 as the minimum required
on Haiku.

This should fix some of #996, although more needs to be done.
2023-02-13 12:34:42 -08:00
Guy Harris
21f46b9600 CMake: give up on Clang on Haiku.
Haiku bug 18258 makes it too painful to beat the configuration process
into submission.
2023-02-12 16:03:09 -08:00
Guy Harris
f37c5e5639 CMake: force -fPIC on Haiku, as we do with autotools.
This, and 64f81903ba, address some of the
issues in #996; in particular, they fix link errors.
2023-02-12 13:32:39 -08:00
Guy Harris
af51eea290 configure, CMakeLists.txt: don't check for snprintf().
It's specified by the C90 standard (and, as I remember, by the C89
standard, although I no longer have my paper copy); no need to worry
about ancient environments that lack it, and we have some cases where we
call it in code not protected by #ifdef HAVE_STRFTIME/#endif and haven't
seen any reports of problems.
2023-01-30 12:46:44 -08:00
Denis Ovsienko
d6e3ebf92c Fixup a comment in CMakeLists.txt. [skip ci] 2023-01-15 22:48:59 +00:00
David Karoly
bdece165ac CMake: search for gethostbyaddr() in libnetwork 2023-01-14 13:24:12 -08:00
Guy Harris
ed6d4f3054 CMake: set man page section numbers.
We use both MAN_FILE_FORMATS and MAN_MISC_INFO in tcpdump.1; set them

Also set _SUN on AIX, as we do with the configure script.
2023-01-09 03:57:42 -08:00
Denis Ovsienko
d74c65c5a7 CMake: Fix a typo in a comment. [skip ci] 2023-01-01 17:12:39 +00:00
Francois-Xavier Le Bail
9b05cc18ec cmake: Update the minimum required version to 2.8.12 (except Windows)
Windows minimum required is already 3.12.

This change avoids this warning:
CMake Deprecation Warning at CMakeLists.txt:7 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

(Same as in libpcap.)
2022-11-25 15:56:21 +01:00
Francois-Xavier Le Bail
e91ca695c3 Remove a trailing space
[skip ci]
2022-09-30 08:54:19 +02:00
Guy Harris
d58b413e83 cmake: expand a comment. [skip ci]
The requirement for setting the run-time path in an executable is not
unique to NetBSD; it also appears in the other BSDs, Linux, and Solaris.
2022-09-26 00:40:50 -07:00
Guy Harris
dcfed11c0b cmake: prevent stripping of the rpath on installation.
This should fix issue #1008.
2022-09-25 14:35:38 -07:00
Guy Harris
fe762c04a6 Handle DLT_PFLOG on all OSes.
Don't pad the pflog header with BPF_WORDALIGN(); round up to a multiple
of 4, instead, as that's what all but FreeBSD do, and FreeBSD used to do
that and should go back to doing so (kern/261566).

Don't rely on the OS's pflog include files to define direction types,
reason types, action types, or the layout of the header; instead, define
them ourselves in a header of our own, with #ifs to select the ones that
are only on some platforms.  That way, it'll handle some fields and
field values (the ones common to all OSes with pflog) on all OSes, even
ones without pflog.

That also expands the set of direction, reason, and action codes to what
various *BSDs and Darwin support.

Also, handle all the different AF_INET6 values in various *BSDs and
Darwin.
2022-01-29 22:30:33 -08:00
Guy Harris
a10ab62bf4 Rename print-rrcp.c to print-realtek.c.
It handles more than just RRCP, so rename it appropriately.
2022-01-23 01:46:20 -08:00
Francois-Xavier Le Bail
97e4fe30d8 WHOIS: Add its own printer source file and printer function
Like all other text protocols.

This is a follow-up to 185b7ce04b.
2022-01-14 13:34:49 +01:00
Rui Paulo
8ce37b54ed Initial support to parse QUIC packets. 2021-11-09 09:11:34 +01:00
Guy Harris
3834579486 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.
2021-08-08 11:54:17 -07:00
Guy Harris
c39d40a767 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.
2021-08-08 00:36:42 -07:00
Denis Ovsienko
bbeedf4f47 CMake: Fix EXTRA_CFLAGS after commit cae0c65. [skip appveyor]
Same as in libpcap.
2021-08-03 23:25:02 +01:00
Denis Ovsienko
cae0c65013 CMake: Handle EXTRA_CFLAGS w/o add_compile_options(). [skip ci]
Same as in libpcap commit 29d7856.
2021-07-31 21:40:04 +01:00
Denis Ovsienko
7880ad999f 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.
2021-07-30 10:44:45 +01:00
Francois-Xavier Le Bail
5cae5a274c SMB: Disable the printer by default with CMake build
This is a follow-up to commit 192db0a116.

[skip ci]
2021-02-05 18:25:35 +01:00