Commit Graph

180 Commits

Author SHA1 Message Date
Michael Richardson
35a1310799 Merge branch 'master' of https://github.com/kivinen/tcpdump into kivinen-master 2019-03-24 09:05:06 +01:00
Florian Fainelli
6eaebfe992 Add support for decoding Broadcom Ethernet switches tags
This adds support for decoding the Broadcom Ethernet switches tags which
are are 4byte in length and are located between the Ethernet MAC SA and
the Type/Length field (DSA_TAG_BRCM) as well as the pre-pended Broadcom
tag (DSA_TAG_BRCM_PREPEND) which are located in front of the standard
Ethernet header.

This makes use of the recently introduced ether_print_hdr_len() to allow
specifying the non-standard Ethernet header length of 12 + 4 + 2 bytes.
2019-01-28 10:56:18 -08:00
Guy Harris
1af79d4adf Try to squelch another annoying repeated warning. 2018-12-10 19:57:54 -08:00
Tero Kivinen
8030a66cdc Fixed some warnings, added print-zep.c to CMakeLists 2018-11-18 00:34:33 +02:00
Guy Harris
65f3770fd7 Require sys/capsicum.h to use Capsicum.
My PC-BSD 9.1 VM, at least, has sys/capability.h but not sys/capsicum.h;
we now use sys/capsicum.h, so require it to be present (which it is in
FreeBSD 10 and later).
2018-11-09 12:00:59 -08:00
Francois-Xavier Le Bail
cb36ac604e Compile with -Wsign-compare in devel mode if supported (cmake) 2018-10-30 21:33:51 +01:00
Guy Harris
9008c09c88 Don't warn about declarations after statements.
We now allow them, and require a compiler that supports them, so there's
no need to warn about them.
2018-09-15 13:16:02 -07:00
Francois-Xavier Le Bail
009bd798b5 Add '-Wunreachable-code-return' warning option in devel mode for cmake 2018-08-07 23:46:16 +02:00
Francois-Xavier Le Bail
7920225334 Sort the tested compiler warning options for cmake 2018-08-07 23:36:44 +02:00
Francois-Xavier Le Bail
34b59a8011 Remove the no more used gmt2local() function 2018-08-07 20:27:46 +02:00
Petr Vorel
152acc2ece Display interface and index and name on DLT_LINUX_SLL2
Index is displayed always, name only if available.

Warn about possible wrong interfaces when in reading mode
(pcap file can be displayed on a different host then where
was captured) [1].

See: GH the-tcpdump-group/libpcap#127

[1] https://lists.sandelman.ca/pipermail/tcpdump-workers/2018-July/001019.html

Signed-off-by: Petr Vorel <pvorel@suse.cz>
Suggested-by: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Denis Ovsienko <denis@ovsienko.info>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-07-19 07:15:11 +01:00
Francois-Xavier Le Bail
38e32cdf14 Remove trailing spaces/tabs 2018-05-25 09:56:04 +02:00
Guy Harris
e7011808da Declare the NFLOG pseudo-header ourselves.
It's not specified by a libpcap header that might have a different
layout in different pcap releases, it's specified on the list of
link-layer header types and must remain the same forever (except for
getting additional bits defined), so we don't need to pick it up from
libpcap.

This means we get to use tcpdump's nd_ types; do so.
2018-05-23 14:43:47 -07:00
Guy Harris
e02efb5044 Declare the Bluetooth pseudo-header ourselves.
It's not specified by a libpcap header that might have a different
layout in different pcap releases, it's specified on the list of
link-layer header types and must remain the same forever (except for
getting additional bits defined), so we don't need to pick it up from
libpcap.

This means we get to use tcpdump's nd_ types; do so.
2018-05-23 14:12:45 -07:00
Guy Harris
9373df8aa3 Don't set COMPILE_FLAGS if there aren't any flags to set.
Otherwise, you get a complaint about there being too few arguments to
set_target_properties().
2018-03-27 14:38:29 -07:00
Guy Harris
2846055e96 Add -W options. 2018-03-27 14:18:14 -07:00
Guy Harris
af51efcd6a The COMPILE_FLAGS property is a string, not a list.
Make C_ADDITIONAL_FLAGS a string as well, and use it appropriately.
2018-03-27 14:11:25 -07:00
Guy Harris
092ae6ddf7 Add C_ADDITIONAL_FLAGS to the compiler flags for targets. 2018-03-27 13:34:09 -07:00
Guy Harris
32f8ededb0 Initialize C_ADDITIONAL_FLAGS where we start setting it. 2018-03-27 13:16:17 -07:00
Guy Harris
111e17e87d Don't use CMAKE_C_STANDARD, it doesn't work on all versions of CMake.
It doesn't work at all prior to CMake 3.1 and, even in newer versions of
CMake, it doesn't support all the vendor compilers out there for various
UNIXes.
2018-03-27 13:13:30 -07:00
Francois-Xavier Le Bail
a53605c61b Add a malloc/free process with garbage collector
Use it in the PPP printer.
2018-03-14 13:59:26 +01:00
Guy Harris
800d27dd0d Add "make check".
This assumes you can run tests/TESTrun.sh as a script, which means it
assumes your command interpreter will either recognize it as a shell
script and run it in a Bourne-compatible shell or will just try and
execute it and the #! header will cause it to be run by /bin/sh.

This probably won't work on Windows.
2018-03-05 19:11:09 -08:00
Guy Harris
ace2828188 Add ws2_32, not socket and nsl, if ws2_32 has gethostbyaddr().
Also, fail if we don't have gethostbyaddr(), either on Windows or on
UN*X.

Suppress some UN*X-only tests on Windows while we're at it.
2018-01-30 02:41:43 -08:00
Guy Harris
0f0600c901 Get rid of tests whose results we don't use.
(Crud left over from using libpcap's CMakeLists.txt as a basis for this
one.)
2018-01-30 02:18:31 -08:00
Guy Harris
c499612a7f Add nd_{v}snprintf() routines/wrappers.
Some versions of the MSVC runtime library have a non-C99-compliant
vsnprintf(), which we want to avoid.  On Windows, use snprintf() and
vsnprintf() for VS 2015 and later, where they both exist in
C99-compliant forms, and wrap _{v}snprintf_s() otherwise (they're
guaranteed to do the null termination that we want).
2018-01-29 15:48:55 -08:00
Guy Harris
0fb509808c Not all Windows pcaps have pcap_wsockinit().
WinPcap 4.1.3 has only wsockinit(); check for both, on Windows.
2018-01-29 02:16:13 -08:00
Guy Harris
ffe074feba Work around a WinPcap botch. 2018-01-29 02:04:12 -08:00
Guy Harris
a13e29249b Extra libraries needed on Windows. 2018-01-29 01:54:48 -08:00
Guy Harris
c7dfcd6aaf When checking pcap.h, make sure we look in ${PCAP_INCLUDE_DIRS}.
It's not necessarily in one of the default include directories, so look
in the directory where we're supposed to look for pcap header files.
2018-01-29 01:30:20 -08:00
Guy Harris
494c8096e0 Use check_symbol_exists for {v}snprintf().
With MSVC 2015, stdio.h defines snprintf() and vsnprintf() as inline
functions, so you need to include stdio.h when testing for them -
check_function_exists() won't do it, you need check_symbol_exists().
2018-01-29 00:57:02 -08:00
Guy Harris
b3703ed9cf Pick up Windows snprintf and strdup replacements from libpcap. 2018-01-28 20:57:15 -08:00
Guy Harris
bf8cae24c0 If you need multiple headers, use check_include_files(), plural. 2018-01-28 19:01:10 -08:00
Guy Harris
4ef8d63149 Do libdnet checks the same way autotools does. 2018-01-28 18:58:00 -08:00
Guy Harris
c2a480c367 Don't check for libxnet.
We don't need it for tcpdump; libpcap will pick it up if necessary if
it's dynamically-linked, we'll link with it ourselves if it's
statically-linked, and libpcap will bind to the libxnet version of
recvmsg() even if we link with libsocket (as it's compiled to refer to
it with a decorated name).

Also, we don't check for it with autotools.
2018-01-28 14:01:17 -08:00
Guy Harris
6c13379a72 Check for ether_ntohost() after finding additional networking libraries.
It might be in one of those libraries.
2018-01-28 13:54:22 -08:00
Guy Harris
25360d9e22 Search TCPDUMP_LINK_LIBRARIES when looking for ether_ntohost(). 2018-01-28 13:50:09 -08:00
Guy Harris
88007d634c Shuffle include(CheckLibraryExists) up with the other includes.
We'll be using it later; might as well include it there.
2018-01-27 11:42:08 -08:00
Guy Harris
757ffb7ab9 Check for pcap_debug and yydebug if we don't have pcap_set_parser_debug(). 2018-01-27 11:34:39 -08:00
Guy Harris
f5c2aca06b Look for pcap header files in the appropriate directory.
Include the directory in which the pcap find module found the main pcap
header file in the list of directories in which to search for other pcap
header files; otherwise, it won't find them unless they're system header
files.
2018-01-27 10:40:15 -08:00
Guy Harris
253ef5db82 Don't do "here's the directories in which to look for libraries".
CMake *hates* that.  -L considered harmful, I guess (and I don't know
how that's done with tools other than UN*X linkers - do all of them
support an equivalent to -L?).

This should fix the checks for pcap functions to look in the library we
found.
2018-01-26 20:02:32 -08:00
Guy Harris
2a286c71f3 Add ${PCAP_LIBRARY_DIRS} to the list of directories with libraries.
Also, use ${PCAP_INCLUDE_DIRS} rather than ${PCAP_INCLUDE_DIR} for the
list of directories with header files (it should be a one-element list,
but do this for consistency), and search for pcap headers *after* we've
found libpcap, so we look in the appropriate directory.
2018-01-26 09:26:30 -08:00
Guy Harris
107e3f1888 Fix typo. 2018-01-24 13:34:36 -08:00
Guy Harris
8c6ffa5124 OK, even with -lxnet, we may need -lnsl.
You are in a twisty little maze of Solaris libraries, all different.
2018-01-24 13:33:14 -08:00
Guy Harris
1d96b4ecf1 Clean up checks for -lsocket/-lnsl/-lxnet.
Do the checks for -lnsl/-lxnet in the same way that we do them for
libpcap, before checking for functions that might require those
libraries.  Include the results of those checks when checking for
routines that require them.

For getservent(), check for -lsocket as well.

Clean up ${XXX_LIBRARY} vs. ${XXX_LIBRARIES} usage while we're at it.
2018-01-24 13:00:36 -08:00
Guy Harris
96877078a1 Fix check for getrpcbynumber().
Multiple checks for a function, in different libraries, need different
variables, as, if only one variable is used, the first test checks, and
subsequent tests are skipped because the variable is already set.
2018-01-24 12:04:07 -08:00
Guy Harris
a5a0a64361 Pop check state after pushing it in libcrypto tests. 2018-01-23 12:27:28 -08:00
Guy Harris
587a15c126 -lcap_dns requires -lcasper. 2018-01-23 10:56:17 -08:00
Guy Harris
bd455d07af Fix conditional addition of source files.
Conditionally add everything to LOCALSRC and include LOCALSRC in
NETDISSECT_SOURCE_LIST_C.
2018-01-22 19:43:26 -08:00
Guy Harris
2ff5f25b7f Fix name for variable containing libpcap library path. 2018-01-22 19:38:34 -08:00
Guy Harris
a6c362fe7b Fix path for rpc.h. 2018-01-22 19:30:55 -08:00
Guy Harris
90ce77da29 Fix check for rpc/rpcent.h.
Autotools' check in AC_CHECK_HEADERS() apparently either doesn't
actually try to include it or somehow arranges to define stuff that it
requires on FreeBSD.  CMake's check in check_include_file() just tries
to include it, which fails on FreeBSD because __BEGIN_DECLS isn't
defined.

The man page for getrpcbynumber() says we just need to include
<rpc/rpc.h>; perhaps there are platforms on which we require both, and
that's what we do, so test it with rpc/rpc.h if we have rpc/rpc.h.
2018-01-22 19:29:32 -08:00
Guy Harris
1d2cbb914a net/pfvar.h and net/if_pflog.h require other headers to be included first. 2018-01-22 19:19:50 -08:00
Guy Harris
ec7e42194f Fix endif() argument to match if() argument. 2018-01-22 19:13:51 -08:00
Guy Harris
d08662ca14 Do our best to try to get C99 support from the compiler. 2018-01-22 18:57:40 -08:00
Guy Harris
f1f3bfc031 Set up WITH_CHROOT and WITH_USER as user-settable string parameters.
No, I have no idea why CMake has option() to create user-settable
documented Boolean parameters but uses a special variant of set() to
create user-settable documented non-Boolean parameters.
2018-01-22 18:50:51 -08:00
Guy Harris
636bbd91c3 Add cap-ng support.
Fix check_library_exists() calls while we're at it.
2018-01-22 18:23:00 -08:00
Guy Harris
56e15dfd8d Add Capsium sandboxing support. 2018-01-22 18:02:25 -08:00
Guy Harris
69d358c964 Clean up handling of libraries.
If a library is found:

	add the include directories for it as a SYSTEM include
	directory;

	add the library for it to a list of libraries with which to link
	tcpdump;

and link with that list of libraries.
2018-01-22 17:45:49 -08:00
Guy Harris
54587515ef Add libcrypto checks.
Put the optional libraries after libpcap, which is *not* optional.
2018-01-22 17:20:02 -08:00
Guy Harris
72b5093bfb What has to be expanded is the template file, not the result file. 2018-01-22 16:51:02 -08:00
Guy Harris
59bf0fc9eb Expand the tcpdump man page from the template. 2018-01-22 16:46:46 -08:00
Guy Harris
6c8eeb6e6d Install man pages from the source directory. 2018-01-22 16:30:37 -08:00
Guy Harris
5632b98204 Add install and uninstall support for CMake. 2018-01-22 15:49:06 -08:00
Guy Harris
4d2d8809e4 Expand a comment. 2018-01-22 02:59:39 -08:00
Guy Harris
767a06a506 Use ether_ntohost() if we have it.
We don't bother checking to see whether it's buggy; we assume those bugs
are fixed by now.
2018-01-22 02:47:50 -08:00
Guy Harris
25d6d7e3ff Check for getrpcbynumber(). 2018-01-22 02:43:42 -08:00
Guy Harris
7094894ebc Don't check for netinet/if_ether.h unless we need it.
We only use it in addrtoname.c to declare ether_ntohost(), so there's no
need to check for it unless we have ether_ntohost() and there's no other
header that declares it.
2018-01-22 02:04:49 -08:00
Guy Harris
54ac92668e Fix checks for net/pfvar.h and net/if_pflog.h.
check_include_files() just checks whether the header file exists, so we
don't need to worry about adding other includes in the test.
2018-01-21 19:54:16 -08:00
Guy Harris
a7b0e673fe Do more substitution for missing libpcap functions.
Clean up some comments while we're at it.
2018-01-21 19:46:03 -08:00
Guy Harris
9765b18cc4 Use our mssing/pcap_dump_ftell.c if pcap doesn't have pcap_dump_ftell(). 2018-01-21 19:29:43 -08:00
Guy Harris
b90a22903d Check for pcap/pcap-inttypes.h. 2018-01-21 19:26:00 -08:00
Guy Harris
572e4f1eab Check for pcap/bluetooth.h and pcap/nflog.h. 2018-01-21 19:20:02 -08:00
Guy Harris
654739e1aa Add checks for AF_INET6 and struct in6_addr.
That lets us know whether the OS sufficiently supports IPv6 or whether
we have to define those ourselves.
2018-01-21 19:12:25 -08:00
Guy Harris
a3dbf9a460 Check for bpf_dump(), and build our own if it's missing. 2018-01-21 18:51:16 -08:00
Guy Harris
cc4797157d No need to replace vfprintf().
1988 called; it wants its pre-standard version of C back.  As the
comment in vfprintf.c said, "Stock 4.3 doesn't have vfprintf."; it's
been a while since 4.3BSD was the latest shiniest BSD-flavored OS.
2018-01-21 18:40:12 -08:00
Guy Harris
6ccce6f6cd getservent() is a replaceable function.
All the functions in that list are either now replaced or aren't
replaceable (we just do without), so remove the TODO comment.
2018-01-21 18:36:39 -08:00
Guy Harris
4547cb8839 Fix HAVE_ name for pcap_dump_ftell(). 2018-01-21 18:29:08 -08:00
Guy Harris
a06d0ca5c3 Build the SMB dissector by default, with an option to disable.
This matches what we offer for autotools.
2018-01-21 18:27:06 -08:00
Guy Harris
45fc519a2a Don't test for __attribute__ in the configure script.
Instead, use compiler test macros to check whether *particular*
attributes are supported, and set various #defines appropriately, in
header files.

Rename the UNALIGNED structure attribute to ND_UNALIGNED, and ask
whether we still need it.
2018-01-21 17:57:20 -08:00
Guy Harris
1807273b16 Initial CMake support.
Work in progress; there's more to be done.
2018-01-21 13:22:15 -08:00