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.)
Francois-Xavier Le Bail [Sat, 21 Feb 2015 13:25:35 +0000 (14:25 +0100)]
gitattributes: Update the attributes for tests/*.out
The actual status for good conditions of tests in Windows are:
Sources from autocrlf *.out ending sed stuff
git true CRLF no
git input LF yes
git false LF yes
archive N/A LF yes
We need to have the sed stuff for sources archives.
Thus we need that the endings of tests/*.out files be always LF only.
We don't want to depend on user config.
Thus this changes.
Advantage: This config is under version control, it applies to all users.
Denis Ovsienko [Sun, 1 Feb 2015 21:34:38 +0000 (21:34 +0000)]
OpenFlow 1.0: improve BSN extensions support
Improve decoding of BSN vendor commands: update printing of commands
that set/get mirror port reporting flag, add decoding of shell exec
commands. Introduce decoding of vendor-specific actions with BSN as the
first such vendor and "mirror" as the first such BSN action.
Add a new test case based on a packet capture produced using Trema
controller and an Arista 7050SX-64 switch in Arista Networks' test lab.
Besides the structures above the capture contains the following items:
* OFPT_QUEUE_GET_CONFIG_REPLY with 0 queues (a valid edge case)
* OFPT_FEATURES_REPLY with ports 21 and 23 having bogus "config" field
(a violation of the protocol, which required temporary patching of the
controller to avoid the session shutdown)
* a set of IP mask manipulation BSN-specific commands
Tommy Beadle [Wed, 18 Feb 2015 16:38:56 +0000 (11:38 -0500)]
Fix issues with the setting of libcap-ng capabilities.
- Only set the SETUID/SETGID capabilities if required (i.e. we'll be changing
the effective UID).
- Only set the CAP_DAC_OVERRIDE capability if writing out to a file (i.e. the -w
flag was provided).
- Fix the calls to capng_clear to pass CAPNG_SELECT_BOTH so that the traditional
and bounding capabilities are set.
- Only remove CAP_DAC_OVERRIDE from the permitted set after opening the write
file if neither -G nor -C flag was provided. We always drop it from the
effective set immediately after opening the write file. During file rotation,
we reacquire it immediately before and drop it immediately after opening the
file.
Guy Harris [Tue, 10 Feb 2015 22:55:43 +0000 (14:55 -0800)]
Use immediate mode if available.
If libpcap has pcap_set_immediate_mode(), then default to immediate mode
if we're printing packets to a terminal, and use immediate mode if
--immediate-mode is specified.
Guy Harris [Tue, 10 Feb 2015 21:52:51 +0000 (13:52 -0800)]
Move pcap function checks to configure.in.
It was doing some of the function checks; move the remaining ones out of
AC_LBL_LIBPCAP(), which is now solely responsible for finding libpcap,
making sure it'll work, and setting compiler and linker flags
appropriately. Checks for functions that were introduced in later
versions of libpcap, which we use if available, are all done in
configure.in.
mkirkhart [Wed, 4 Feb 2015 23:55:58 +0000 (18:55 -0500)]
Fixed bug in arp_print() in handling of inverse arp responses - the target's hardware and protocol address were being printed instead of the sender's hardware and protocol address
Guy Harris [Tue, 27 Jan 2015 19:38:31 +0000 (11:38 -0800)]
Merge pull request #422 from tbeadle/capng_changes
Make sure to init capng before dropping root.
capng_clear needs to be called before capng_change_id can be called within
droproot. Otherwise, an (unusable) error message is output: "error : ret -1" and it fails to drop root privileges.
This also fixes the dropping of the CAP_SETGID capability. Previously,
CAP_SETUID was being dropped twice.
Tommy Beadle [Tue, 27 Jan 2015 18:32:14 +0000 (13:32 -0500)]
Make sure to init capng before dropping root.
capng_clear needs to be called before capng_change_id can be called within
droproot. Otherwise, an (unusable) error message is output: "error : ret -1".
This also fixes the dropping of the CAP_SETGID capability. Previously,
CAP_SETUID was being dropped twice.
Guy Harris [Thu, 8 Jan 2015 21:22:13 +0000 (13:22 -0800)]
No OPER-TLV are "empty TLVs".
As section 7 of RFC 5810 says, an OPER-TLV is 1*PATH-DATA-TLV, so it
always has at least one PATH-DATA-TLV. Remove the ZERO_TTLV check - the
old one was bogus ((!ops->flags & ZERO_TTLV) means ((!ops->flags) &
ZERO_TTLV), and if ops->flags is non-zero, !ops->flags is zero, and the
test fails), and the new one causes tests to fail, revealing that the
whole "empty TLVs like COMMIT and TRCOMMIT are empty, we stop here"
think is wrong, so we remove it.