Commit Graph

62 Commits

Author SHA1 Message Date
Guy Harris
4cc892cbff Use "-H", not "-h", for the 802.11s option, and improve error reporting.
I was rudely surprised to find that "tcpdump -h" wasn't printing a usage
message, and I'm the person who *added* the "-h" option.  Make it "-H",
and add an explicit "-h" option to print a usage message, so nobody else
makes the same mistake.  Also, don't clear opterr, so that if you give
an illegal command-line option, you get an explanatory error message.
2011-06-21 18:15:50 -07:00
Guy Harris
6bfcf8d87e Try to handle radiotap Rate values > 127 better.
Use the same heuristic Wireshark uses, i.e. assume that FreeBSD only
reports MCS indices between 0 and 15, and that any other values with the
0x80 bit set are rate values.  (Yes, those do exist.)

Also note, as I did in Wireshark, that it might be possible to extract
from the XChannel and Flags field the additional information to convert
an MCS index from the Rate field into a rate.  (Whether that's possible
depends on what platforms using the FreeBSD convention do with the
channel width and guard interval information.)
2011-04-27 15:15:09 -07:00
Guy Harris
54db122321 Support RX flags, MCS and the vendor namespace, and fix Rate.
Based on patches from an anonymous donor, support the radiotap RX flags and
MCS fields, and the vendor namespace, and, if Channel and XChannel are
both present, use XChannel, not Channel.

Do not try to look up a rate for an MCS value from the Rate field; you
cannot map an MCS value to a rate without also knowing the channel width
and guard interval length.
2011-04-27 12:08:27 -07:00
Guy Harris
5b665ba92f Fix the handling of unknown tagged parameters in management frames.
Fetch the element length early in the process, rather than fetching it
each time we need it - even after we've advanced the pointer we are
using to fetch it (doing the latter means we fetch the wrong value when
we subtract it from the remaining length).
2011-04-05 09:53:57 -07:00
Guy Harris
dee11b5b10 Process the flags even if parsing the full radiotap header fails.
If we were able to get the flags, we should process them, so we know
whether there's Atheros padding after the 802.11 header or if there's an
FCS at the end of the packet, and properly process them; if we weren't
able to get the flags, they're 0, so we're not doing anything
differently, and that's the best we can do.
2011-04-04 21:32:58 -07:00
Guy Harris
5b08a20f21 Don't return value from a filed cpack_uint8() call.
If the cpack_uint8() call to fetch the flags for
IEEE80211_RADIOTAP_FLAGS fails, don't return u.u8, as we didn't fetch
anything into it.
2011-04-04 21:30:22 -07:00
Guy Harris
fe209f3b17 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).
2010-05-27 23:58:01 -07:00
Guy Harris
aeae58e079 Print bit numbers in decimal, not hex - it's not the presence bit field,
its the index of a bit from that field.
2010-02-06 19:21:30 -08:00
Guy Harris
7923f06110 When parsing IEs in a management frame, save the *first* IE of a given
type we see, not the *last*, so the first one gets printed.  If,
however, a rates IE has a zero-length list of rates, don't save that
one; some devices send out frames with two rates IEs, one zero-length
and a later one containing the actual rates.

Have parse_elements() return an indication of whether truncation
occurred - and pass it the frame length, so it doesn't just keep parsing
until an end-of-captured-data test fails, as that would make *every*
frame look truncated.
2009-11-04 14:55:05 -08:00
Guy Harris
aae14f93d9 Merge in stuff from the current top-of-tree FreeBSD tcpdump; this picks
up changes from Sam Leffler for 802.11n and 802.11s.

Clean up ieee802_11_radio.h a bit.
2009-07-14 18:23:06 -07:00
Guy Harris
ab73c1d5d9 Make the presence bit unsigned; some compilers might warn about 1<<31
overflowing, as, with 32-bit signed numbers, the 1 becomes the sign bit.
2009-06-28 10:58:16 -07:00
Guy Harris
68fcda9beb Make the FCS length unsigned; this squelches a signed vs. unsigned
comparison warning.
2009-05-21 10:50:08 -07:00
Guy Harris
f2aee3ed6d Handle frames with an FCS (at least with a radiotap header).
Handle (to some degree) 802.11n Control Wrapper, Block Ack Req, and
Block Ack frames.
2009-01-15 02:35:19 -08:00
guy
9f7024c8c6 Handle version 2 of the AVS header. 2007-12-29 23:25:02 +00:00
guy
efb80785aa Support DLT_IEEE802_11_RADIO_AVS.
Update a comment (we now parse the radiotap header).
2007-12-20 08:13:35 +00:00
guy
4bef1cedce Handle the padding that Atheros adapters helpfully introduce between the
802.2 header and the body.
2007-07-22 23:13:41 +00:00
guy
45b4f19d76 Handle 802.11 frames with QoS data. 2007-07-22 22:00:40 +00:00
guy
7bfcc5ebc5 Don't attempt to dissect the payload of a no-data frame. 2007-07-22 19:59:06 +00:00
hannes
ee1afebee8 squelch compiler warnings 2007-03-23 08:17:57 +00:00
guy
8a905570c7 Fix a potential buffer overflow in the 802.11 printer; reported by
Moritz Jodeit.
2007-02-01 02:18:18 +00:00
guy
801c193b35 Pick up check for bad FCS from NetBSD version. 2006-06-13 22:25:30 +00:00
guy
1306b4434f Use sizeof to get sizes of various structure members, rather than
hardwiring the sizes (which runs the risk that the hardwired size in the
structure definition and code could get out of sync).
2005-11-13 20:13:58 +00:00
guy
269f9685a5 Fix the sense of a test. 2005-11-13 20:03:21 +00:00
guy
4e487b0b8b Get rid of a return value in a void function. 2005-11-13 19:59:19 +00:00
guy
86f96f8a7b Have parse_elements() flag each item as "present (and not truncated)",
"present but truncated", and "not present", and don't have it return an
indication of whether we ran past the end of a packet - instead, have
the routines that handle particular management frame types use macros
that check what the status of a particular tagged parameter is and:

	print it if present and not truncated;

	skip it if not present;

	return a "packet truncated" indication if present but truncated.

This means we handle tagged parameters that aren't present, and print
parameters that are present and not truncated even if there's a
present-but-truncated field after them.

Add some additional bounds checks.

Make the table of rates bigger - there can be more than 8 rates in a
rates tagged parameter.
2005-11-13 12:07:25 +00:00
guy
c589777d74 Uniformly use IEEE802_11_TSTAMP_LEN as the 802.11 timestamp length and
IEEE802_11_AP_LEN as the length of the previous AP in reassociation
frame.

Before copying variable-length fields from a management frame IE, make
sure the length isn't too large.
2005-10-17 07:58:56 +00:00
guy
6eb94437cb Put calls to print the management frame type in the switch statement,
rather than having a separate table; this makes it clearer that unknown
manaagement frame types already have a message printed, and that you
have to add a call to print that if a new management frame type is
created.
2005-07-30 21:37:20 +00:00
guy
4518dd7214 We already print "Unhandled Management subtype(N)" for management frames
we don't handle; there's no need to print "Unknown subtype N" as well.

Revert to using null strings for the unknown management frame types -
that way we don't have to check for a null pointer.
2005-07-30 18:48:35 +00:00
guy
d9441bbffc Make "subtype_text[]" have 16 elements, for all 16 possible subtypes,
and make all unknown subtypes have null pointers and, if the pointer for
a subtype is null, print the subtype as "Unknown subtype".

Compute the sizes of the tables of authentication algorithm names,
status code strings, and reason code strings at compile time, and use
those values to check whether the value is in the table or not.  Get rid
of trailing NULL pointers in those tables.

Fix a typo in one reason code string.
2005-07-30 00:05:32 +00:00
guy
d953299b94 Add a flag to suppress the "default_print()" call made in various
link-layer print routines if no other print routine claimed the packet.
Test whether that flag is set rather than testing whether neither of -x
or -q were specified, and have -x, -q, *and* -X set that flag, so that
-X suppresses it just as -x does.  That way you don't get those pckets
dumped twice if -X was specified.
2005-07-07 01:22:15 +00:00
guy
1bd9d74460 Attempt to squelch a warning from the SGI C compiler. 2005-04-20 19:32:16 +00:00
guy
83827bee81 From Gisle Vanem: the Digital Mars C compiler doesn't allow converstion
between unsigned and signed (and pointers to same) without a case - the
IEEE80211_RADIOTAP_DBM_TX_POWER item is signed, so use "cpack_int8()" to
fetch it.
2004-11-04 07:35:53 +00:00
dyoung
00511ce1cf Add the radiotap capture format to tcpdump. radiotap is an extensible
capture format for 802.11 radio statistics such as signal strength,
rx/tx bit rate, and rx/tx channel.
2004-09-23 21:57:24 +00:00
guy
fb1b6d808f Fix up a bunch of comments - the on-the-wire length field in a
pcap_pkthdr is "len", not "length".
2004-03-17 23:24:35 +00:00
guy
b8c884ee9c Get rid of the no-longer-used frame control argument to various
management frame print routines.
2003-12-10 09:51:03 +00:00
guy
419347a8e3 Don't stick an extra "RESERVED" in the printout for unknown management
frame subtypes.
2003-11-27 02:51:04 +00:00
guy
cc0ea017e1 Print the subtype of management frames *before* parsing the body, so
that if there's an error parsing the body, we at least see the type (and
so that the code to print the subtype isn't duplicated in every
body-printing routine).
2003-11-27 02:18:53 +00:00
guy
d69adedc59 Fix a typo (as per NetBSD). 2003-11-19 02:01:40 +00:00
guy
bbc1cfa669 Have the configure script arrange that the Makefile define _U_
appropriately, and that GNUmakefile and the MSVC++ project file define
it apppriately, as we do with libpcap, rather than defining it in
"interface.h".

Undo the rcsid-shuffling and addition of extra #includes, as we no
longer need to arrange that "interface.h" be included before using _U_
in an RCS ID or copyright.
2003-11-16 09:36:07 +00:00
guy
3824a6c041 From Neil Spring:
use "_U_" in the definitions of "rcsid[]", to eliminate
	complaints about those variables being unused;

	move the definitions after the include of "interface.h", or add
	an include of "interface.h", so that "_U_" is defined.

Include "config.h" before including "tcpdump-stdinc.h" in
"missing/datalinks.c".
2003-11-15 00:39:12 +00:00
guy
91f7cb2f57 From David Young:
[This patch] fixes some bugs and adds a new feature.  Control
	packets were showing as [|802.11] because tcpdump expected for
	there to be an FCS on each one (wrong assumption).  Also, even
	if pieces of a control packet are missing, I have made tcpdump
	print its type when it knows it.  The new features is that if
	you give -v, the 802.11 Duration field (for virtual carrier
	sense) is printed.  This is useful for detecting
	hardware/firmware bugs (!!) and for debugging the new crop of
	802.11 drivers.
2003-07-22 17:36:57 +00:00
guy
d8add7cacc Stylistic cleanups, from David Young. 2003-07-22 17:35:04 +00:00
guy
f72f67a5cf From David Young: print Ack/Poll information for data frames with
contention-free Ack or Poll indications, and print flag bits from the
Frame Control field if "-v" was specified.
2003-02-04 05:53:21 +00:00
guy
4bec97f457 Hoist a bunch of stuff that should be done by all if_print routines into
tcpdump.c.  Have if_print routines return the length of the link-layer
header, so that the common code knows how to skip the link-layer header
when printing the packet in hex/ASCII.
2002-12-19 09:39:10 +00:00
guy
cfabfb053b Add a new routine "default_print_packet()", which takes a pointer to the
beginning of the raw packet data, the captured length of the raw packet
data, and the length of the link-layer header, and:

	if "-e" was specified, prints all the raw packet data;

	if "-e" was not specified, prints all the raw packet data past
	the link-layer header, if there is any.

Use that routine in all the "xxx_if_print()" routines if "-x" was
specified.

Make "arcnet_encap_print()" static - it's not used outside
"print-arcnet.c".

Add missing info printing code to "atm_if_print()".

Print the packet data in "lane_if_print()", not in "lane_print()", as
"lane_print()" can be called from other "xxx_if_print()" routines, and
those routines will also print the packet data if "-x" was specified -
no need to print it twice.
2002-12-18 09:41:13 +00:00
guy
e070cf232f We no longer use "packetp" for anything, so eliminate it. (If any
dissector really needs source and destination MAC addresses, we should
make global pointers to them - which would be null for packets lacking
MAC addresses, so dissectors that need them will need to do something
sensible if those pointers are null.)

Don't fake up an Ethernet header if there aren't any MAC addresses to
use when faking it up.

"bp_chaddr" in "print-bootp.c" is an array, so "bp->bp_chaddr" cannot be
null, and there's no need to test for it not being null.
2002-12-18 08:53:18 +00:00
guy
46c77e78ff Handle DLT_PRISM_HEADER captures that are really DLT_IEEE802_11_RADIO
captures.
2002-12-17 09:13:45 +00:00
guy
f7a91421dd From Atsushi Onoe <onoe@netbsd.org>: NetBSD change to mark basic rate
with '*' in PRINT_RATES().
2002-12-12 07:47:38 +00:00
guy
5585ad8705 Don't hardwire in the length of the AVS capture header - extract it from
the header.

Do the check for the 802.11 header being large enough to include the
frame control byte in common code, not in each interface dissector.
2002-12-12 07:39:19 +00:00
guy
c52bf5af8c Add support for DLT_PRISM and DLT_IEEE802_11_RADIO. 2002-12-12 07:28:35 +00:00