Commit Graph

305 Commits

Author SHA1 Message Date
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
Guy Harris
b6e38e7c52 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:12:49 -07:00
Francois-Xavier Le Bail
46efa1bc47 Fix spaces 2018-09-03 15:18:19 +02:00
Denis Ovsienko
415b70b6ce Remove a useless warning about the SMB decoder.
In the last couple years it had been proved that any decoder can
potentially have buffer overflows, hence let's not emphasize one of them
more than the others.
2018-07-28 20:48:16 +01:00
Denis Ovsienko
b14d690f6d Fix a typo in a comment. 2018-07-28 20:48:16 +01:00
Denis Ovsienko
9b1c2ba51b Try the pcap_dump_ftell() check after pcap-config.
Apparently, the test for pcap_dump_ftell() cannot succeed if the test
program isn't linked with libpcap, this depending on the output of
pcap-config. That's why all pcap_* function checks come after the
pcap-config check.

This explains why in my working copy a ./configure build of the previous
commit tree with the master branch of libpcap found that the function
was "missing" and tried to substitute it with the local implementation
and eventually failed trying to link with libpcap that actually had the
function.

However, this does not explain why all 32 Travis CI builds of the same
tree passed, including the builds that used autotools.
2018-07-28 20:48:16 +01:00
Denis Ovsienko
40e217a816 Stick with one version of pcap_dump_ftell.c.
It looks like CMake after commit 3e9e2b6 started to use the newly added
missing/pcap_dump_ftell.c to make pcap_dump_ftell() available in tcpdump
if libpcap does not have it. However, autotools continued to use the
previously existing ./pcap_dump_ftell.c for the same purpose. Remove the
previously existing file and amend autotools files to cover
pcap_dump_ftell() the same way as the other functions in the missing/
directory files.

Amend missing/pcap_dump_ftell.c not to use pcap_dump_file(), as it may be
unavailable.

This has been tested to work with libpcap 0.6.1.
2018-07-28 13:36:17 +01: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
abe1aa5a29 Compile with '-Wunreachable-code-return' in devel mode if supported 2018-07-17 22:22:49 +02:00
Francois-Xavier Le Bail
bcb77e9f99 Sort the tested compiler warning options 2018-07-07 22:01:00 +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
e325894a35 If we have a local libpcap, add it to the dependencies for tcpdump.
We weren't doing so if we found a local pcap-config script.
2018-01-22 21:33:21 -08:00
Guy Harris
27f68cf1a8 Regenerate configure script. 2018-01-22 20:53:09 -08:00
Guy Harris
0c21656150 Configure for ether_ntohost() as libpcap does it for ether_hostton().
Check for the same header files that declare it, and handle the results
of those checks in a similar fashion.
2018-01-22 02:34:31 -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
2a3509a466 Clean up comments to reflect reality. 2018-01-21 19:33:54 -08:00
Guy Harris
a7f76515c4 Again, we don't replace vfprintf(). 2018-01-21 18:42:09 -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
fe225c5518 Use nd_ types, add host-endian extract routines, clean up signed vs. unsigned.
We now define the structures for Linux USB headers in print-usb.c, so it
doesn't need to include <pcap/usb.h>; don't check for it.
2018-01-11 11:10:21 -08:00
Guy Harris
3bc62cd35f Use pcapng as the name of the file format.
At one point, I remember a discussion resulting in the official name of
the next-generation replacement for pcap format being changed to
"pcapng", with no hyphen.

Make tcpdump reflect that.

While we're at it, uppdate to use "macOS" as the name of Apple's
UNIX-for-Macs, as appropriate (don't use it for versions that were still
called Mac OS X or OS X).
2018-01-08 18:50:06 -08:00
Guy Harris
8ab5c3a4e7 C99 - ask for it by name!
Use AC_PROG_CC_C99, to try to get the appropriate flags to make C99 the
C version for which we compile.  (XXX - should we fail if we don't get
support for C99?)
2018-01-07 01:12:52 -08:00
Guy Harris
ebf3f19426 Clean up handling of libdnet headers.
If we don't have dnet_htoa(), we don't need any of the headers.  Check
for them only if we have dnet_htoa().

Use AC_CHECK_DECL to see if netdnet/dnetdb.h declares dnet_htoa().

Check for netdnet/dn.h and, if we have it, check whether it declares
struct dn_naddr; if so, include it, rather than defining the structure
ourselves.

Don't define union etheraddr ourselves; we only need to define an
etheraddr typedef.  That avoids colliding with a libdnet header
definition of union etheraddr.  (When we use etheraddr, we care about
what's on the wire, and we don't rely on system headers to tell us
what's on the wire.)
2017-12-30 14:16:15 -08:00
Guy Harris
bfdad0f58f Fix typo, and request additional libraries for *static* linking. 2017-11-30 12:59:54 -08:00
Guy Harris
cfc4c750a2 Fix the handling of libpcap.
We have four possibilities:

  1) local library, with a pcap-config;
  2) local library, without a pcap-config;
  3) installed library, with a pcap-config;
  4) installed library, without a pcap-config.

If we have a local library, i.e. one in ../libpcap{whatever}, we:

    add -I flags to the C compiler flags to point it at whatever
    directories in ../libpcap{whatever};

    add ../libpcap{whatever}/libpcap.a to $LIBS and:

        if it has a pcap-config, we use it, with --additional-libraries,
        to find the additional libraries with which we need to link;

        otherwise, we do the usual OS-dependent hacks to try to figure
        out with what additional flags we need to link;

    and add them to $LIBS after libpcap.a.

If we have an installed library:

    if it has a pcap-config we use it, with --cflags, to find what flags
    to add to the C compiler flags, and use it, with --libs, to see what
    flags to add to $LIBS;

    if it doesn't have a pcap-config, we search for -lpcap and, if that
    succeeds, we assume the headers are under /usr/local/include or
    /usr/include, search for them there, and, if we don't find pcap.h
    there, we look for it in a pcap subdirectory under there, and add
    the appropriate -I flag to the C compiler flags, and then do the
    usual OS-dependent hacks to try to figure out with what additional
    flags we need to link.

While we're at it, we do the libdlpi check only on Solaris, as part of
"the usual OS-dependent hacks".
2017-11-29 18:18:18 -08:00
Guy Harris
768d80e11f Regenerate configure script. 2017-11-13 19:27:37 -08:00
Guy Harris
20af93776d Use alarm() iff we're not on Windows.
We assume "not on Windows" means "on UN*X", which means we have alarm()
(we don't care about V6 and earlier; 1978 called, they want their UNIX
back).  If somebody wants to support something that's neither UN*X nor
Windows, they'll need to contribute support, properly checking for that
other OS.
2017-11-12 13:31:57 -08:00
Ali Abdulkadir
9b939ac5a3 improved check for ipv6 support on windows (autotools) 2017-11-06 01:42:13 +03:00
Ali Abdulkadir
260ad4d1bd regenerate 2017-10-24 08:17:52 +03:00
Guy Harris
f151a6d655 Add support for remote capture if libpcap supports it. 2017-10-20 11:27:12 -07:00
Guy Harris
4943adfb5f Do the version number the way it's now done for libpcap.
Use the two-argument version of AC_INIT() - which requires autoconf 2.64
or later, so require that as a minimum - and get the version string from
the VERSION file.  Use AC_CONFIG_SRCDIR() to say that the source
directory needs tcpdump.c; the two-argument version of AC_INIT() doesn't
do that.

This means that we no longer have a version.c file.
2017-10-16 14:31:14 -07:00
Guy Harris
d230f8b687 Get rid of obsolescent configure test.
All UN*Xes, these days, let you include both <time.h> and <sys/time.h>.
2017-10-16 13:48:40 -07:00
Guy Harris
2b9bfa05b6 Check for unaligned memory access support at compile time.
Don't test at configure time; that doesn't work when cross-compiling and
may be a pain to do with CMake.
2017-10-16 01:39:10 -07:00
Guy Harris
fdd0467bcd On UN*X, always use sigaction(), and always have signal handlers return void.
Some time between the mid 1980's and 1990 called; they want their
old-fashioned UNIX signal handling back.  ANSI C has had signal handlers
returning void sincer, well, 1989, and POSIX has had sigaction() since
close to forever.  No need to worry about really old UN*Xes here.

On Windows, it's also void (as per ANSI C); use signal().
2017-10-15 22:36:07 -07:00
Guy Harris
88d1467627 Get rid of an unnecessary test.
We don't care whether struct sockaddr has an sa_len field or not.
2017-10-15 22:16:01 -07:00
Guy Harris
62f2725b57 Use pcap_dump_ftell64() if we have it.
That way, even if a file offset doesn't fit in a long, we can still
handle a -C flag specifying a maximum file size >=2GB.
2017-09-30 01:10:29 -07:00
Francois-Xavier Le Bail
7871b86d08 Compile with '-Wassign-enum' in devel mode if supported 2017-09-20 20:41:25 +02:00
Guy Harris
14c81f0a4a Clean up the stuff we do to get <inttypes.h> stuff defined.
If we have a libpcap with <pcap/pcap-inttypes.h>, include it, so that we
don't have to worry about definitions colliding if we later include a
pcap header file that includes pcap/pcap-inttypes.h.

Otherwise, do the same stuff pcap-inttypes.h does.  This means that, on
UN*X, we require that there be an <inttypes.h> that defines everything
we need.

Don't bother doing checks that are no longer necessary as a result of
those changes.
2017-09-14 18:53:34 -07:00
Guy Harris
6f0750ee0c Make the ESP decryption not crash with OpenSSL 1.1.
While we're at it, free the cipher context if we fail to allocate the
output buffer for decryption.
2017-09-01 04:00:38 -07:00
Guy Harris
3dc736d939 Handle attributes for function pointers by checking the compiler version.
Handle attributes for function pointers the same way we handle
attributes for functions, by explicitly checking for the compiler
version with #if rather than with a configure script check.  That's one
fewer thing that, if you're not using autoconf, has to be done in some
other fashion.

While we're at it, put NORETURN in the right place to have it work with
Microsoft Visual Studio as well as various UN*X compilers.
2017-08-19 11:25:24 -07:00
Denis Ovsienko
6df678ca31 Check for __attribute__ ((fallthrough)) (GCC 7).
The documentation claims that recent GCC is now better by default at
spotting cases of code flow falling through (which is true) and that it
avoids false positives by matching nearby source code comments with
regexps. However, the latter feature doesn't seem to work as reliably
as the manual describes it, so let's have a macro for this purpose.

Tested to work on:
* x86_64, Fedora 26, GCC 7.1.1 (w/__attribute__, w/fallthrough)
* x86_64, Ubuntu 16.04, GCC 5.4.0 (w/__attribute__, w/o fallthrough)
* x86_64, FreeBSD 11.0, CLang 3.8.0 (w/__attribute__, w/o fallthrough)
* SPARC, Solaris 10, SolStudio 12.4 (w/__attribute__, w/o fallthrough)
* SPARC, Solaris 10, SunStudio 11 (w/o __attribute__)
2017-07-22 19:33:49 +01:00
Guy Harris
b8c56aa092 Merge pull request #588 from glebius/casper
Add support for libcasper library available on FreeBSD 11.0 and newer.
2017-02-02 12:18:56 -08:00
Denis Ovsienko
be1e19f50c refine the feedback guidelines
Provide better detailed guidelines in CONTRIBUTING and update a number
of other files to refer to that file so that the directions are now
more uniform.
2017-02-02 11:38:05 +00:00
Gleb Smirnoff
cd3c5880b1 Add support for libcasper library available on FreeBSD 11.0 and newer.
The patch allows tcpdump to run sandboxed and still do name resolution.

The code is obtained from FreeBSD tree, where it was developed by

Pawel Jakub Dawidek <pjd@FreeBSD.org>
Mariusz Zaborski <oshogbo@FreeBSD.org>
2017-02-01 16:13:05 -08:00
Guy Harris
406b0e3e92 Stop processing IPPROTO_ values once we hit IPPROTO_IPCOMP.
It's not like, for example, AH or ESP, where, following the header for
that protocol, there's another protocol with its own payload.
2017-01-18 09:16:37 +01:00
fxlb
4abe27840d Compile with '-Wpedantic' in devel mode instead of '-pedantic'
Avoid 'Undefined symbol _mcount' with some Solaris compilers.

The '-pedantic' option is unknown to the comiler, but by coincidence
starts with a '-p' (gather performance data). When a file is compiled
with '-p' but is linked without '-p', 'Undefined symbol _mcount' occurs.
2016-11-01 20:33:19 +01:00
Francois-Xavier Le Bail
b7cbdfc92d Compile with '-Wused-but-marked-unused' in devel mode if supported
f.e. clang version 3.4 support this warning option.
2016-08-19 01:30:14 +02:00
Guy Harris
119ee49153 Allow building with libcrypto not in the default directory.
Add support for an argument to --with-crypto, so that if you have one
version of libcrypto installed under /usr and another version installed
under /usr/local, you can force tcpdump to be built with the /usr/local
version.

Also, refer both to OpenSSL and libressl in comments and messages.
2016-07-13 17:24:15 -07:00
Guy Harris
b1f305da3d Handle OpenSSL 1.1.x.
In 1.1.x, EVP_CIPHER_CTX is an opaque structure, so we can't declare it
on the stack.

Instead, if we don't have EVP_CIPHER_CTX_new() and EVP_CIPHER_CTX_free()
in libcrypto, define our own versions, with the same signatures as the
ones in OpenSSL 1.1.x's libcrypto, and have the code use
EVP_CIPHER_CTX_new() to allocate the structure and EVP_CIPHER_CTX_free()
to free it.
2016-06-22 21:14:40 -07:00
Guy Harris
817aadf8bb Use the new debugging routines in libpcap.
Newer versions of libpcap, when configured to provide debugging
printouts for the filter expression parser or optimizer, provide
routines to set the "debug the parser" and "debug the optimizer" flags;
use them if the library has them.  If the library doesn't have them, do
our best to try to use the older mechanisms for requesting debugging, if
present.
2015-12-30 18:49:37 -08:00