Guy Harris [Sun, 19 Oct 2014 20:42:00 +0000 (13:42 -0700)]
Use the length field in the UDP header.
If it's less than the length of the IP payload, use it as the size of
the UDP packet. If it's greater than the length of the IP payload,
and we're not dissecting the payload, report the length as bad.
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 [Tue, 8 Mar 2011 17:11:25 +0000 (09:11 -0800)]
Fix plurals in packet count messages.
Based on a patch from [email protected], but with a macro
PLURAL_SUFFIX() defined to return either "s" or "" (rather than possibly
printing a NUL character with %c), and with that macro used in a couple
of cases where the equivalent had been done by hand, and with one case
the patch missed fixed as well.
Guy Harris [Tue, 1 Feb 2011 10:08:41 +0000 (02:08 -0800)]
Get rid of unnecessary configure script tests and missing/XXX.h headers.
This also fixes configure-script problems on OSes that have IPv6 support
but don't have <netinet6/in6.h> - no standard I could find requires that
header for IPv6 support (the Single UNIX Specification speaks of
<netinet/in.h> for both IPv4 and IPv6, and RFCs 2292 and 3542 don't
mention <netinet6/in6.h>, just <netinet/in.h> and <netinet6/ip6.h>).
Guy Harris [Wed, 1 Dec 2010 00:18:32 +0000 (16:18 -0800)]
Add support for nommu systems.
Rather than hardcode the WIN32 define, add proper fork checks to the
configure script and check those. This fixes building for nommu systems
which lack the fork function.
While we're here though, add support for this functionality via vfork
so that it does work on nommu systems. And fix an old bug where we
exit properly in the forked child when the exec failed instead of just
returning to the calling code (which isn't expecting it).
Mike Frysinger [Wed, 1 Dec 2010 00:13:05 +0000 (16:13 -0800)]
Use AC_PATH_TOOL, not AC_PATH_PROG, to find pcap-config.
The PROG variant does not take into consideration cross-compilation, so
it always looks for "pcap-config" which finds the host script. So use
the TOOL variant instead which first searches for the cross-prefixed
pcap-config before falling back to the bare "pcap-config".
Guy Harris [Sun, 14 Nov 2010 20:23:40 +0000 (12:23 -0800)]
Make sure we can link with libpcap.
After finding libpcap and getting a list of other flags needed when
linking, we check for "pcap_loop()", to make sure we found a working
libpcap and have all the right other libraries with which dnl to link.
(Otherwise, for example, the check for pcap_list_datalinks() will fail,
not because the routines are missing from the library, but because we
aren't linking properly with libpcap, and that will cause confusing
errors at build time.)
Paul Ferrell [Sun, 7 Nov 2010 02:28:10 +0000 (19:28 -0700)]
Switch user ID/root directory with -Z before opening savefiles for output.
In addition to Paul's change, I added a comment explaining why we do
this, and explaining that doing so after opening the first savefile
doesn't help with subsequent savefiles, so you'll have to come up with a
better fix if you want the savefiles opened by the original UID or
outside the chroot.
Guy Harris [Tue, 31 Aug 2010 17:03:47 +0000 (10:03 -0700)]
Mark various IPv4 and IPv6 headers as unaligned.
This prevents GCC on SPARC from generating code that assumes those
structures are aligned naturally, which they are not guaranteed to be.
Move some #defines from interface.h to tcpdump-stdinc.h to make them
available to code that doesn't include interface.h.
Move the declaration of nextproto6_cksum() to ip6.h, so that only files
that use it get it declared, and thus so that you don't need to define
"struct ip6_hdr" in everything that includes interface.h. Don't include
ip6.h in tcpdump-stdinc.h.
Guy Harris [Mon, 23 Aug 2010 10:30:54 +0000 (03:30 -0700)]
Get rid of some more include files we no longer need.
We have our own copies of those include files, which we use; we haven't
used the system versions for a long time, so we don't need to drag them
along for compiling WinDump.
Guy Harris [Mon, 23 Aug 2010 10:22:25 +0000 (03:22 -0700)]
Clean up handling of tftp.h.
Don't include the win32/Include/Arpa copy in print-udp.c; don't put that
copy into the release tarball; and don't talk about <arpa/tftp.h>, or
work around its deficiencies in some OSes, as we no longer include it,
we include our own tftp.h, which has a th_stuff array in its structure
definition.
Guy Harris [Mon, 16 Aug 2010 22:02:12 +0000 (15:02 -0700)]
Print AppleTalk layer-3 network numbers as 16-bit unsigned decimal numbers.
Pick up from FreeBSD:
revision 1.3
date: 1996/09/11 06:18:26; author: pst; state: Exp; lines: +9 -12
branches: 1.3.2;
Print appletalk layer 3 addresses as 16 bit unsigned decimal numbers,
not two 8 bit values. This conforms to industry standard.
These changes have been sent back to LBL.
Inside AppleTalk(R), Second Edition speaks of node numbers as 16-bit.
Guy Harris [Mon, 16 Aug 2010 17:43:28 +0000 (10:43 -0700)]
Get rid of no-longer-valid comment.
We no longer guarantee alignment in any printer routine; all printers
must use the EXTRACT_ macros to extract integral quantities - and the
Appletalk printers now do so.
where bp is a pointer to a struct bootp, that loads the first 4-byte
word in that structure, masks out the field in that structure that's not
being compared, and compares against a word with the appropriate values
in the other fields. That won't work, because there's no guarantee that
bp points to a value aligned on a 4-byte boundary.
Declaring "struct bootp" to be packed appears to keep at least GCC 4.2.4
from performing that optimization; we define an "UNALIGNED" tag to apply
to structures to prevent that optimization, and apply that tag to the
structures in bootp.h. (We'll apply it to other structures as we
discover the need for it.)
Romain Francoise [Sat, 5 Jun 2010 07:37:27 +0000 (00:37 -0700)]
If -U is specified, flush the file after creating it, so it's not zero-length.
Reading from a capture file that has not yet received any packets fails
with "truncated dump file"; to avoid this, flush the file (forcing the
pcap header out) immediately after opening it.
Romain Francoise [Sat, 5 Jun 2010 03:10:07 +0000 (20:10 -0700)]
Merge back changes from the Debian package:
- fix TCP flags output description, by Christophe Rhodes <[email protected]>
Original patch submitted in http://bugs.debian.org/575724
- two remaining typo fixes, by A Costa <[email protected]>
Original patch submitted in http://bugs.debian.org/342310
Guy Harris [Fri, 28 May 2010 06:58:01 +0000 (23:58 -0700)]
Add a -h flag, and only attempt to recognize 802.11s mesh headers if it's set.
I give up. I have no access to the 802.11s drafts, I can't find
anything that suggests whether a heuristic check for an 802.11s header
should check for To DS and From DS both being set or either being set or
unset, or whether it should check for a QoS frame type (the examples in
all the documentation I can find have To DS and From DS set, and have a
QoS field, in the 802.11 header, but that might just be an example
802.11 header showing all the fields), so I'm just adding a -h
command-line flag; you need to specify it to get tcpdump to try to guess
whether a frame has a mesh header or not. I'll leave it up to somebody
else to figure out what the best heuristic for detecting the presence of
mesh headers is (note that tcpdump and Wireshark have different
heuristics, both of which can probably get false positives, especially
with encrypted frames where the first payload byte just *happens* not to
have any of the reserved bits in the mesh header flags set).
Guy Harris [Sun, 21 Feb 2010 20:44:53 +0000 (12:44 -0800)]
Process VLAN frames and Alteon jumbo frames in the Ethernet printer.
Instead of having the Ethernet-type handler process the VLAN and Alteon
jumbo frame Ethernet type values, process them in the Ethernet (and
Linux cooked-mode) dissectors. This makes it easier for the right MAC
addresses to be printed for those packets.
As part of that, rename ether_encap_print() to ethertype_print() - it
doesn't print encapsulated Ethernet frames, it prints payloads whose
packet type is indicated by an Ethernet type field value - and remove
the no-longer-needed "extracted Ethernet type" argument. That also lets
us eliminate it from the SNAP print routine.
Make ether_print() take a function, and an argument to pass to that
function, as parameters, so that, for example, the ATM LANE printer can
use it and put the LEC ID into the link-layer headeer printout.
Guy Harris [Sun, 21 Feb 2010 19:27:41 +0000 (11:27 -0800)]
Don't directly fetch multi-byte integers from packets.
Use the EXTRACT_ macros to extract multi-byte integral values from
packets, rather than just dereferencing pointers into the packet; there
is no guarantee that the packet data will be aligned on the right
boundary, and there is no guarantee that, if they're not, a direct
access will work correctly.
Guy Harris [Sun, 21 Feb 2010 08:27:00 +0000 (00:27 -0800)]
Don't directly fetch multi-byte integers from packets.
Use the EXTRACT_ macros to extract multi-byte integral values from
packets, rather than just dereferencing pointers into the packet; there
is no guarantee that the packet data will be aligned on the right
boundary, and there is no guarantee that, if they're not, a direct
access will work correctly.