Guy Harris [Sat, 2 May 2015 17:15:42 +0000 (10:15 -0700)]
Fix checksumming of PIMv2 Register messages.
The checksum only covers the header, not the encapsulated packet, so
only checksum that. However, if that checksum fails, try checksumming
the entire packet, as, according to RFC 4601, packets with the entire
packet checksummed should also be accepted, for interoperability.
Add IS_NOT_NEGATIVE macro.
Avoid these warnings:
- comparison of unsigned expression >= 0 is always true [-Wtype-limits],
- comparison is always true due to limited range of data type [-Wtype-limits].
Guy Harris [Mon, 27 Apr 2015 07:02:31 +0000 (00:02 -0700)]
Clean up To DS and From DS checks.
Rewrite get_data_src_dst_mac() to test To DS and From DS only once; that
also more clearly means that there's no way to escape from that function
without setting both pointers, so the compiler doesn't think there's a
way to do so.
and, hopefully, will prevent more from creeping in.
There are some remaining ones - and they represent attempts to overwrite
the packet bytes handed to tcpdump by libpcap, which could well *fail*
with, for example, memory-mapped capture mechanisms!
Guy Harris [Mon, 27 Apr 2015 01:42:23 +0000 (18:42 -0700)]
Don't cast away warnings for ether_ntohost().
We have a choice between "your OS's header files suck" warnings on HP-UX
and -Wcast-qual warnings on all platforms. I vote for the former, as
the latter let us find cases where we're casting constness away, and we
really don't want to cast constness away if we can possibly avoid it.
Guy Harris [Mon, 27 Apr 2015 00:09:16 +0000 (17:09 -0700)]
Fix heuristic not to be byte-order-dependent.
I'm *guessing* that the item being fetched is big-endian; the "vt"
protocol might be old enough that they developed it on (non-Sun386i) Sun
workstations, assuming they didn't just say "this is an Internet
protocol, hence fields are big-endian").
That also prevents problems on platforms that don't support unaligned
accesses.
Guy Harris [Mon, 27 Apr 2015 00:03:32 +0000 (17:03 -0700)]
Fetch a 32-bit big-endian quantity with EXTRACT_32BITS().
*Don't* fetch it with a pointer cast and dereference! That will fail on
little-endian machines and may fail on machines that don't handle
unaligned references.
Andrew Lunn [Sun, 19 Apr 2015 20:35:00 +0000 (15:35 -0500)]
Add support for the Marvell Extended Distributed Switch Architecture header
This header can be used with Marvell switches to direct packets in/out
of a specific port in a tree of interconnected switches. The header
uses its own Ethertype of 0xdada.
By default, only brief output is printed, showing the switch device,
port, and vlan the packet is to/from. However if -e is given, to print
the link-level header, all fields are printed.
Guy Harris [Sun, 19 Apr 2015 02:56:49 +0000 (19:56 -0700)]
Use unsigned values in tok2str and bittok2str routines.
This prevents the compiler issue mentioned in GitHub issue #451, and
also cleans up some other signed vs. unsigned stuff.
While we're at it, clean up bittok2str_internal() (just pass it the
separator string, not a Boolean value that's tested to choose the
separator string), and print unknown arguments to the bittok2str
routines in hex, not decimal.
Guy Harris [Sat, 18 Apr 2015 06:42:22 +0000 (23:42 -0700)]
Skip the LLC and SNAP headers with -x.
Have llc_print() return the length of the LLC header, plus the length of
the SNAP header, if available - or, if it couldn't dissect the payload,
return the *negative* of that sum. Use that return value in link-layer
printers.
Guy Harris [Sat, 18 Apr 2015 01:38:46 +0000 (18:38 -0700)]
Clean up printing of LLC packets.
Don't print LLC header information for SNAP packets; if we have a SNAP
header, just call snap_print() and return its return value, regardless
of whether it's 1 or 0, don't fall into the code to print raw LLC header
information - and don't print it with -e, either.
If llc_print() returns 0, just call the default packet printer, don't
print the MAC-layer header or the extracted ethertype - llc_print() will
print the source and destination MAC addresses and whatever type
information is in the LLC or SNAP headers.
If we don't know the DSAP/LSAP, and it's an information frame (numbered
or not) and not an XID frame, return 0, so that we give a hex dump of
the raw payload.
In addition, print the length when printing SNAP header information with
-e.
Guy Harris [Thu, 16 Apr 2015 03:11:41 +0000 (20:11 -0700)]
The FC flag is now "protected", not "WEP".
It's also used for WPA/WPA2, so it's a generic "protected by encryption"
flag. Update the name of the macro that checks it, and report it as
"Protected" rather than "WEP Encrypted".
Guy Harris [Thu, 16 Apr 2015 02:44:34 +0000 (19:44 -0700)]
Handle the link-layer header more like other 802.x dissectors.
Have ieee_802_11_hdr_print() unconditionally print the MAC header, call
it before any payload dissection if -e is specified, call it if
llc_print() fails and -e *isn't* specified, and print "WEP Encrypted"
for protected management and control frames if -e isn't specified.
Pull the extraction of source and destination addresses out of
ieee_802_11_hdr_print(), and do it only for data frames, as it's not
needed for management or control frames.
Guy Harris [Thu, 16 Apr 2015 01:13:53 +0000 (18:13 -0700)]
Only print unknown frame type or subtype messages once.
Check whether extract_header_length() returns 0; if it does, that means
that we don't have a known frame type or control frame subtype, so just
stop dissecting - extract_header_length() has already printed an
indication of the unknown frame type.
Remove other "unknown frame type" and "unknown control frame subtype"
printouts.
Guy Harris [Wed, 15 Apr 2015 19:51:34 +0000 (12:51 -0700)]
Get the header length for control wrapper and block ACK frames.
While we're at it, rename the "ctrl_XXX_t" structures to
"ctrl_XXX_hdr_t", and remove the FCS fields, as some control frames have
variable-length data in them and those structures only cover the
fixed-length portion of the frames.
Brooks Davis [Wed, 15 Apr 2015 16:39:05 +0000 (16:39 +0000)]
Disentangle packet dissection functionally in tcpdump from the internal
libnetdissect. This greatly narrows the public interface and allows
libnetdissect to be more easily sandboxed.
Denis Ovsienko [Sun, 22 Mar 2015 10:06:15 +0000 (10:06 +0000)]
dismiss NETDISSECT_REWORKED macro
The purpose of this macro was to enable the file-by-file switch to NDO,
after which only tcpdump.c had a use of it and the definitions guarded
by it. Update tcpdump.c not to require them any more and dismiss the
unused definitions.
Guy Harris [Tue, 10 Mar 2015 20:25:52 +0000 (13:25 -0700)]
Get rid of support for non-NDOified printers.
Remove the TTEST{2}/TCHECK{2} macros. Rename all "ndo_printer" routines,
structures, and structure members to just "printer", and get rid of the
old routines/structures/structure members with those names.
Guy Harris [Mon, 9 Mar 2015 22:34:03 +0000 (15:34 -0700)]
Clean up Capsicum rights setting a bit.
Rename set_dump_fd_capsicum_rights() to set_dumper_capsicum_rights() and
have it take a pcap_dumper_t * as an argument and extract the file
descriptor itself, rather than having the caller do so.
Guy Harris [Sun, 8 Mar 2015 22:55:47 +0000 (15:55 -0700)]
Add a #define for the short options and put it above the long options.
That puts all the option lists together; hopefully this encourages
developers who want to add a new flag to read the big "don't use these
options, other tcpdumps use them for their own purposes" command and
thus *dis*courages them from using one of those options.
Guy Harris [Thu, 5 Mar 2015 23:32:01 +0000 (15:32 -0800)]
Do the dump file Capsicum stuff in a common routine.
We were doing the same stuff in two places and *almost* the same stuff
in a third place, which should have been doing the same stuff. Put that
stuff into a common routine and just use that.
(What a mess. If you pour a bottle of Capsicum on your OS, it seeps all
throughout the system; might as well admit it and, at least, extend the
standard I/O library to handle it a bit better.)