Guy Harris [Wed, 12 Nov 2014 03:05:48 +0000 (19:05 -0800)]
Further cleanups.
Use ND_TCHECK() rather than home-brew bounds checks. Do simpler length
checks.
Let i be the length of the actual remaining packet data; use ND_TCHECK()
inside loops that iterate over the remaining data.
Let the printers for particular message types cast the raw data pointer
to a pointer of the appropriate type, rather than passing two pointers,
with different types, to the same data.
Guy Harris [Wed, 12 Nov 2014 01:24:12 +0000 (17:24 -0800)]
Add initial bounds check, get rid of union aodv.
Fetch the type field without using a structure, and check to make sure
it's not past the end of the packet.
Pass to each dissection routine a pointer to the appropriate message
type structure, rather than a pointer to a union of all the message type
structures.
Guy Harris [Sun, 31 Aug 2014 18:57:04 +0000 (11:57 -0700)]
Clean up configure check for libsmi.
First, check for smi.h. If we don't have it, don't check for anything
else.
If we do have it, check for libsmi containing smiInit. If we don't have
it, don't check for anything else.
If we do have it, check, with our test program, whether we can use it.
If that succeeds, prepend -lsmi to LIBS, and set USE_LIBSMI. Otherwise,
don't do either of those.
Check, in source, *only* for USE_LIBSMI. If it's set, use libsmi,
otherwise don't - don't even include smi.h, even if we happened to have
found it, and don't print the libsmi version string.
Guy Harris [Tue, 8 Jul 2014 10:23:09 +0000 (03:23 -0700)]
Squelch a Coverity warning.
If you pass in a value of oidlen and oidsize such that we can't store
*anything* into OID, this would be a problem; that *shouldn't* ever
happen, but this makes the code a bit more obviously correct.
Guy Harris [Mon, 7 Jul 2014 20:44:12 +0000 (13:44 -0700)]
Shorten a status text description.
Instead of just copying-and-pasting from 802.11, edit the description a
bit; this squelches a Coverity warning (it thought we might have
forgotten a comma in the list), and also means we don't quite print out
as much.
(If Table 8-37 "Status codes" in 802.11-2012 had names for *all* the
status codes, we could use the names instead of the explanatory text,
but, for some unknown reason, it doesn't.)
Guy Harris [Wed, 25 Jun 2014 20:18:18 +0000 (13:18 -0700)]
Don't treat 65535 as the maximum snapshot length.
Make it 131072, instead; the MTU on the Linux loopback interface, in at
least some versions of the kernel, is 65536, and that doesn't count the
fake Ethernet header, so we need a value bigger than 65536. We don't
want a value that's *too* large, so that it causes attempts to allocate
huge amounts of memory, however.
This (plus the corresponding change to libpcap) should fix GitHub issue
Guy Harris [Wed, 25 Jun 2014 19:06:35 +0000 (12:06 -0700)]
Allow builds if libpcap doesn't have pcap_set_tstamp_precision().
Check for pcap_set_tstamp_precision() in the configure script and, if
it's not there, don't include the code that allows time stamp precisions
to be set.
Wesley Shields [Fri, 16 May 2014 14:32:55 +0000 (10:32 -0400)]
Make droproot say something when successful.
I've seen people run into situations where they were using a command like this:
tcpdump -i eth0 -G 500 -w /root/%H%M%S.pcap
The first file would be created successfully but the second file would not
because their version of tcpdump was dropping privs. It was unclear to them
that this was going on and was causing confusion.
At least with this message in there it should become more evident that
privs are being altered and aid in debugging these kinds of problems.
Denis Ovsienko [Thu, 5 Jun 2014 20:56:05 +0000 (00:56 +0400)]
fix bittok2str_internal() w/o separator (GH #391)
Simplify separator string handling in bittok2str_internal(): use empty
value for the first snprintf() call and set new value after each use.
This makes the terminating null char management unnecessary, especially
that it missed the case where there was no separator and no match (it
would return the previous content of the static buffer unchanged).
This change may affect the output of tcpdump in that before it could
print either "[]" or "[none]" or a string like "[S.]" for TCP flags
value 0. Now it prints "[none]" as that is exactly the value passed to
bittok2str_nosep() in tcp_print().
Michal Sekletar [Wed, 19 Mar 2014 13:14:25 +0000 (14:14 +0100)]
Introduce --time-stamp-precision
A while ago we introduced new API in libpcap which made possible to
request time stamps with higher precision (nanoseconds). This commit
aims to move things forward and implement missing bits. It introduces
new long option --time-stamp-precision. Note that there is no equivalent
short option.
When used for a live capture tcpdump will ask the kernel for time stamp
with desired precision and tcpdump will print fraction part of the time
stamp using respective format. We currently support only microsecond and
nanosecond precision. In the future we might support even more granular
time stamp precision, but we should be fine to support only
microseconds and nanoseconds for now. libpcap doesn't provide anything
else at the moment anyway.
When used in combination with -r/-w options then we obtain time stamps
appropriately scaled up or down from libpcap. Also note that distinct
magic number is used for savefiles containing nanosecond time stamps.
Guy Harris [Tue, 6 May 2014 21:25:43 +0000 (14:25 -0700)]
Add a --version option, to print just version information.
Also, use #defines starting at 128 (outside the ASCII range) for long
options having no short-option equivalent, and have -h/--help exit with
an exit status of 0 (you just asked for usage information, and you got
it - no fault, no error).
Francois-Xavier Le Bail [Mon, 5 May 2014 09:02:52 +0000 (11:02 +0200)]
print-ether: print 'ethertype IEEE1905.1' instead of 'ethertype Unknown'
not a full decoder, uses default print
reference: http://standards.ieee.org/develop/regauth/ethertype/eth.txt
Denis Ovsienko [Sun, 4 May 2014 16:48:03 +0000 (20:48 +0400)]
AoE: add version 1 decoder (GH #298)
The sample capture was produced with two Linux hosts (aoetools version
36, kernel module version 85, vblade version 21). One of the hosts
exported a 1MB block device containing a freshly created filesystem and
the other mounted it, wrote a small file and then unmounted.
Guy Harris [Sat, 3 May 2014 19:36:06 +0000 (12:36 -0700)]
Clean up protocol ID printing.
If getprotobynumber() doesn't return a valid protocol name, just print
the protocol number.
Don't bother with setprotoent() and endprotoent() - none of the other
dissectors using getprotobynumber() use them and, if it's a useful
optimization, we should do the optimization in a common routine for all
callers (or do some other optimization, e.g. reading the entire protocol
list and building a table in which we can do a quick lookup).
Guy Harris [Sat, 3 May 2014 18:10:54 +0000 (11:10 -0700)]
Don't care about the Linux kernel version number.
What OS-specific and OS-version-specific features tcpdump uses
*directly* should be checked for specifically; if it *requires* features
not available with systems using a 1.x kernel, the configure should fail
because of *that*, and if it doesn't require any such features, we
should allow building on/for systems with a 1.x kernel.
If there are issues with *libpcap* on systems with a 1.x kernel, then
that should be handled in the libpcap configure script - and, even if
it's impossible to capture traffic on such a system, you can build a
version of libpcap that can read files but not capture, which would give
you a tcpdump that could, at least, read files from other machines.
Guy Harris [Fri, 2 May 2014 18:49:30 +0000 (11:49 -0700)]
Add some long options.
Currently, they're all aliases for existing short options, but we're out
of letters, so we'll be adding some that won't have short options.
This means we can't have entries in the options table corresponding to
short options with no long options, as an entry in the long options
table with a null option name terminates the table.
Gisle Vanem [Fri, 2 May 2014 11:30:57 +0000 (04:30 -0700)]
Update tcpdump-stdinc.h
Put WinPcap's header "bittypes.h" before potentially defining basic types like "uint8_t". Define EAFNOSUPPORT unless defined in system's <errno.h>. The local Win32/Include/errno.h is gone.
Guy Harris [Fri, 2 May 2014 06:20:21 +0000 (23:20 -0700)]
Sort options and put in notes for unusable option letters.
Sort the options alphabetically, and put in comments for the options
we're *currently* not using, to note that other versions of tcpdump use
them and that we should only use them for the same purposes.
Guy Harris [Fri, 2 May 2014 02:50:19 +0000 (19:50 -0700)]
Don't assume the Perl interpreter is in /usr/bin/perl.
It's not necessarily there on all platforms. Explicitly invoke the
interpreter to run the TESTonce script; that requires that, when you run
"make check", your path includes the directory in which the Perl
interpreter resides.
Guy Harris [Fri, 2 May 2014 02:48:10 +0000 (19:48 -0700)]
Split the OSPFv3 header and bodies into separate structures.
Some compilers appear to put some padding before the ospf6_un union, so
the OSPFv3 packets aren't dissected correctly. Pull the members of
that union into separate structures, and find the pointer to the OSPFv6
body by adding the header length to the pointer to the beginning of the
header.