Commit Graph

147 Commits

Author SHA1 Message Date
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
Guy Harris
8ceef287ad CMake: add stuff from CMAKE_PREFIX_PATH to PKG_CONFIG_PATH.
Pull in some code from CMake 3.12.4's FindPkgConfig.cmake to arrange
that, when running pkg-config, directories from CMAKE_PREFIX_PATH are in
the PKG_CONFIG_PATH environment variable.

We do this because we want to make sure that, if CMAKE_PREFIX_PATH is
set, and it points to a directory that contains a libpcap that has a .pc
file installed, we get that .pc file, but we don't yet want to require a
minimum of CMake 3.1 or later (CMake 3.1 and later do that
automatically) because there might be some long-term support OS version
that comes with an older version of CMake.
2021-01-08 01:35:31 -08:00
Denis Ovsienko
bdac249ee0 OpenFlow 1.3: Add initial partial support.
This code processes only the simplest message types (9 out of the 30
defined).

Add a test from [1], which comes from [2], which comes from a
contributor in Ericsson (Zoltán Lajos Kis).

1: https://wiki.wireshark.org/SampleCaptures#OpenFlow
2: https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9283
2020-09-28 13:58:12 +01:00
Denis Ovsienko
95096be4f0 Install into bindir, not sbindir. [skip ci]
As discussed on GitHub and on the mailing list, install tcpdump into
bindir because it can be useful to non-root users too, in ways that do
not involve doing live packet captures. Original idea by Guy Harris.
2020-09-10 12:59:25 +01:00
Francois-Xavier Le Bail
0181656313 Compile with '-Wmissing-variable-declarations' if it's available
(In devel mode)
2020-05-30 00:05:22 +02:00
Guy Harris
d4c0251233 Add print-macsec.c to CMakeLists.txt. 2020-05-27 23:19:45 -07:00
Francois-Xavier Le Bail
25687e1a31 Print packets for unsupported link-layer protocols in hexadecimal/ASCII
This avoids to get only:
tcpdump: packet printing is not supported for link type XYZ: use -w

The default printing is like:
18:45:52.723872 UNSUPPORTED
        0x0000:  001f 0000 0540 6078 725d 586d 4d66 4671  .....@`xr]XmMfFq
        0x0010:  6d58 4d5c 7159 5f71 565c 556c 4e71 7171  mXM\qY_qV\UlNqqq
        0x0020:  7171 7171 7171 7171 7171 7171 7171 5180  qqqqqqqqqqqqqqQ.
        0x0030:  7f7f                                     ..
18:45:52.755995 UNSUPPORTED
        0x0000:  001f 0000 0540 6043 7851 807f 7f         .....@`CxQ...
        [...]
2020-05-10 11:05:59 +02:00
Herwin Weststrate
763bef5f53 Extract NTP printing
This method is required to dissect some RADIUS attributes
2020-04-21 23:50:03 +02:00
Francois-Xavier Le Bail
4f30fc8e14 CMakeLists.txt: Restore alphabetical order for printers 2020-04-07 11:05:59 +02:00
Hannes Gredler
a193f168bf add support for Broadcom LI header
(pull request #843)

fix build break for Broadcom LI printer on BSD platforms

incorporate review comments: make bcm_li_print() void, add a sample capture

incorporate review comments: remove trailing tabs

add BCM LI outputs to testset

incorporate review comment: return after printing

update verbose output for bcm-li
2020-04-02 18:44:26 +02:00
Francesco Fondelli
246ca110d1 Autosar SOME/IP protocol support 2020-02-19 10:05:32 +01:00
Guy Harris
74224d189c Don't assume a Perl script can be run directly as a command.
That's not the case on Windows - it doesn't support #!.  Look for the
perl interpreter and, if we find it, add a rule that runs tests/TESTrun
with the interpreter.
2020-02-05 01:07:52 -08:00
Guy Harris
52561ff053 Push the floating-point test into a separate file.
Hopefully, that will make sure we don't optimize away anything that
will, for example, cause us not to do things differently on 32-bit x86
using the x87 instructions.
2020-02-04 19:53:11 -08:00
Guy Harris
aa2650ec0e Do the floating-point tests closer to what we need.
It's All Very Complicated, so mirror what print-lmp.c does - just do a
calculation based on a particular input value and print the result using
the same format print-lmp.c does, and have tests/TESTrun see what that
result is.

Just do that inside tcpdump.c, so we don't need the fptype stuff.
2020-02-04 19:45:41 -08:00
Guy Harris
565131d8e7 Add fptype.c to CMake builds. 2020-02-04 19:24:34 -08:00
Guy Harris
422a74df58 Fix checks for libcrypto.
1) We don't need libcrypto to check for the header files, and if we say
we do, we get a lot of noise from CMake about policy CMP0075.

2) We need libcrypto, with the full path specified, for library tests;
just linking with -lcrypto might not find it, or might find another
version (thanks, Apple!).
2020-02-04 14:42:22 -08:00
Guy Harris
dc59375166 TESTrun.sh is dead; long live TESTrun. 2020-01-24 14:28:34 -08:00
Guy Harris
bd22f1fd9a Clean up ESP and ISAKMP decryption.
At least as I read RFC 5996 section 3.14 and RFC 4303 section 2.4, if
the cipher has a block size of which the ciphertext's size must be a
multiple, the payload must be padded to make that happen, so the
ciphertext length must be a multiple of the block size.  Instead of
allocating a buffer, copying the ciphertext to it, and padding it to the
block size, fail if its size isn't a multiple of the block size.

(Note also that the old padding code added a block's worth of padding to
the end of a ciphertext block that *was* a multiple of the cipher block
size; this might have caused problems.)

Don't use the undocumented EVP_Cipher(); the lack of documentation means
a lack of information about whatever requirements it might impose.  Use
EVP_DecryptUpdate() instead.

Before calling it, use EVP_CIPHER_CTX_set_padding() to say "don't do
your own padding, this block is a multiple of the cipher block size".

Instead of using EVP_CipherInit() or EVP_CipherInit_ex(), use
EVP_DecryptInit() or EVP_DecryptInit_ex().  as we're always doing
decryption and never doing encryption - the extra parameter to
EVP_CipherInit() and EVP_CipherInit_ex() is always 0.

This may address GitHub issue #814.

It may also make it a bit easier to have the code use Common Crypto on
macOS (rather than requiring that OpenSSL be installed - macOS ships
with an OpenSSL shared library for binary compatibility with older
releases, but doesn't ship with the headers, because Apple wants you
using their crypto code) and use Cryptography API: Next Generation on
Windows (Vista/Server 2008 and later) (rather than requiring a Windows
build of OpenSSL).

(Hopefully this will all work with LibreSSL.)
2020-01-05 18:37:52 -08:00
Partha Ghosh
6f53130273 The ptp (precision time protocol) with UDP as the transport protocol.
- the print routines for ptp different ptp messages
- test completed for sync message, announce message, delay request message,
  delay response message and follow up message.
- integration of the ptp v2 code with the tcpdump code.

Signed-off-by: Partha S. Ghosh <psglinux@gmail.com>
2019-11-22 20:56:21 +01:00
Denis Ovsienko
c9e5ac541b libdnet has bugs, do not use it.
The only function tcpdump used in libdnet was dnet_htoa(), which tries
to translate a binary DECnet address to a nodename through a lookup in
/etc/decnet.conf. The translation is slow and has a bug, so stop using
the function and remove the dependency on libdnet.

This makes tcpdump always print DECnet addresses in numeric format, if
anybody needs the translation back they are welcome to fix libdnet or
(more realistically) add an implementation of dnet_htoa() to the tcpdump
source code and use it.

(This is a forward-port of commit 9a6eb27 from tcpdump-4.9 to master.
Sadly, together with libdnet this change removes the fine work that Guy
had done in the master branch in commits ebf3f19 and 4ef8d63 to put
libdnet usage right whilst my original "do not use libdnet" commit was
aging in the pipeline.)
2019-11-03 23:46:28 +00:00
Guy Harris
42ddfda12d Require CMake 3.12 or later on Windows.
We require it for policy CMP0074, so the user can tell CMake where the
Npcap or WinPcap SDK is hiding with -DPCAP_ROOT=.
2019-10-29 20:09:14 -07:00
Guy Harris
c05087101a Use PCAP_ROOT to tell CMake where to find Npcap or WinPcap. 2019-10-29 18:45:43 -07:00
Guy Harris
1fac78d737 Fix check target to work with the new versions of the test scripts. 2019-08-19 10:32:55 -07:00
Francois-Xavier Le Bail
ab450fb62d Remove trailing spaces 2019-08-16 13:52:46 +02:00
Guy Harris
a386f6baf2 Small cleanups.
Always initialize C_ADDITIONAL_FLAGS to empty.

Get rid of an extra empty line in a comment.
2019-08-09 14:51:07 -07:00