Luiz Otavio O Souza [Wed, 14 Oct 2015 15:05:24 +0000 (10:05 -0500)]
Fix capsicum support to work with zerocopy buffers in bpf.
Zerocopcy buffers in bpf was broken until recently in FreeBSD and now that
it is fixed, tcpdump is failing with insuficient capabilities when trying to
use the BIOCROTZBUF ioctl.
This commit adds BIOCROTZBUF to the list of allowed ioctls.
Guy Harris [Wed, 7 Oct 2015 07:14:20 +0000 (00:14 -0700)]
Use the nd_uintN_t types more.
Define them in netdissect.h.
Use them in ip.h, and *don't* mark the structures as UNALIGNED; that
should no longer be necessary.
Add a new nd_ipv4 type to use as an IPv4 address; it represents the 4
bytes of IPv4 address as an array of unsigned chars, so that its natural
alignment is only on a byte boundary.
Those changes found some places where we weren't using
UNALIGNED_MEMCPY() to extract IPv4 addresses from packets; use it.
Guy Harris [Tue, 6 Oct 2015 16:41:01 +0000 (09:41 -0700)]
Introduce data types to use for integral values in packet structures.
They are defined as arrays of bytes, so
1) no padding is inserted before them to put them on natural
boundaries, so they can be used if the values *aren't* so
aligned;
2) you have to use EXTRACT_ macros with them - which you should
be doing *anyway*, to avoid explicitly or implicitly making
assumptions about byte order or alignment safety on the
platform for which your code is being built (it'd better work
when built for little-endian x86 or for big-endian *and*
strict-alignment-requiring SPARC).
Use them in the LISP (no, not the programming language!) dissector;
UNALIGNED means "this structure is not guaranteed to be aligned as a
whole, so don't generate code that assumes it is", not "this structure's
individual members shouldn't have padding to put them on natural
boundaries", so it's not sufficient to do that. (Using these types
*might* suffice to ensure that code that assumes alignment not be
generated, but never underestimate SPARC compilers' eagerness to use
single load and store instructions to fetch big-endian 16-bit, 32-bit,
and 64-bit values from packets that really aren't guaranteed to be
aligned.)
Francois-Xavier Le Bail [Mon, 5 Oct 2015 09:03:15 +0000 (11:03 +0200)]
LISP: Fix a Clang warning
The warning was:
./print-lisp.c:401:11: warning: variable 'xtr_present' is used uninitialized
whenever 'if' condition is false [-Wsometimes-uninitialized]
else if (type == LISP_MAP_NOTIFY)
^~~~~~~~~~~~~~~~~~~~~~~
./print-lisp.c:404:9: note: uninitialized use occurs here
return xtr_present;
^~~~~~~~~~~
Guy Harris [Tue, 29 Sep 2015 08:15:53 +0000 (01:15 -0700)]
We need -Werror when testing whether -f or -m flags work.
Thank you, clang, for treating unknown -f flags as warnings, only
failing with them if run with -Werror, and spewing out warning messages
whenever they're used.
Guy Harris [Tue, 29 Sep 2015 01:19:31 +0000 (18:19 -0700)]
If we have the MCS field, it's 11n.
Pass print_chaninfo() the presence flags, and, if IEEE80211_RADIOTAP_MCS
is set, report it as 11n, rather than looking at the channel flags to
figure out whether it's FHSS or 11b/11a/11g.
Fix typo while we're at it ("long GI", not "lon GI").
Simon Nicolussi [Mon, 21 Sep 2015 20:12:20 +0000 (22:12 +0200)]
Default to first interface from pcap_findalldevs()
Only call (deprecated) pcap_lookupdev() as a last resort, as it doesn't
necessarily agree with pcap_findalldevs() on the order of interfaces and
the -D and -i options already rely upon the latter function's behaviour.
Adjust the TLV infinite loop check to require the right amount of bytes
for T and L; do it after printing the TLV header so it is easier to
understand what was wrong. Check if the TLV V is within the capture. Use
the new "invalid" exit label to indicate a packet anomaly and add more
checks for the length value into the type-specific case blocks. Print
the domain string with fn_printzp().
Guy Harris [Sat, 19 Sep 2015 00:24:23 +0000 (17:24 -0700)]
Additional Windows cleanups.
Don't import stuff from WinPcap that it really shouldn't be exporting.
Define HAVE_U_INT{N}_T,to suppress definition of intN_t in bittypes.h, as
included by <pcap/pcap.h> on Windows.
Define HAVE_OS_IPV6_SUPPORT if AF_INET6 is defined, so that if we're
building with a VC+SDK combination that defines it and struct in6_addr,
we don't define them ourselves.
Guy Harris [Fri, 18 Sep 2015 19:39:05 +0000 (12:39 -0700)]
Update Visual Studio files.
Update the list of source files, and the command-line flags (for
example, don't define INET6, as we no longer check it, or WIN32, as we
no longer check it - we check the standard _WIN32 instead).
Guy Harris [Thu, 17 Sep 2015 21:56:44 +0000 (14:56 -0700)]
Don't require IPv6 library support in order to support IPv6 addresses.
Have our own routines to convert between IPv4/IPv6 addresses and
strings; that helps if, for example, we want to build binary versions of
tcpdump for Windows that can run both on NT 5 (W2K/WXP), which doesn't
have inet_ntop() or inet_pton(), and NT 6 (Vista/7/8/10), which do. It
also means that we don't require IPv6 library support on UN*X to print
addresses (if somebody wants to build tcpdump for older UN*Xes lacking
IPv6 support in the system library or in add-on libraries).
Get rid of files in the missing directory that we don't need, and
various no-longer-necessary autoconf tests.
The problem shows itself because 'configure' displays
"checking whether the compiler supports the -Wstrict-prototypes option... no"
even if '-Wstrict-prototypes' option is supported.
Moreover:
Update configure accordingly.
Fix a trailing space.
Even if frontend/backend separation is ongoing, keep coherence between
option name and flag name at the moment.
Option name is 'm', thus s/ndo_sflag/ndo_mflag/.
When I needed to print a string and didn't remember which of the three
functions fn_print(), fn_printn() and fn_printzp() was the right one
for the data, every time it would end up in reading through all of them
and forgetting the difference shortly after the commit.
Just having it explained in the comments should work better.
Guy Harris [Tue, 1 Sep 2015 00:16:07 +0000 (17:16 -0700)]
Keep the two line numbers in esp_print_decode_onesecret() separate.
Have the line number for the file we're opening for "file" be separate
from the line number we're passed. That avoids warnings, and makes it
clearer *which* line number we're using.
Guy Harris [Mon, 31 Aug 2015 23:57:07 +0000 (16:57 -0700)]
Avoid collison with error(), clean up code a bit.
Rename the variable to "error_status", as that's what it represents, and
as that doesn't collide with the error() function. Don't set it and
then not use the resulting value.
Guy Harris [Mon, 31 Aug 2015 23:12:43 +0000 (16:12 -0700)]
Get rid of warnings on systems that provide index().
Rename the variable "index" to "idx", so that if the environment in
which we're compiling tcpdump happens to declare the index() function
(the old V7 name for the function called strchr() in S3/S5 and ANSI C),
we don't get compiler warnings.