Loganaden Velvindron [Sat, 16 Mar 2019 11:31:26 +0000 (15:31 +0400)]
ICMPv6: Add the IPv6-Only flag
This flag in defined in a draft which is close to getting published as
an IETF RFC: https://tools.ietf.org/html/draft-ietf-6man-ipv6only-flag-05.
Florian Fainelli [Sat, 26 Jan 2019 00:58:42 +0000 (16:58 -0800)]
Add Broadcom tags tests
Add 3 tests to test that we can properly dissect Broadcom tags. Two are
for DSA_TAG_BRCM where the tag is between Ethernet MAC SA and
Type/Length and one for DSA_TAG_BRCM_PREPEND where the tag is
encapsulating the Ethernet frame (thus requires -e to be shown).
Florian Fainelli [Fri, 18 Jan 2019 23:24:33 +0000 (15:24 -0800)]
Add support for decoding Broadcom Ethernet switches tags
This adds support for decoding the Broadcom Ethernet switches tags which
are are 4byte in length and are located between the Ethernet MAC SA and
the Type/Length field (DSA_TAG_BRCM) as well as the pre-pended Broadcom
tag (DSA_TAG_BRCM_PREPEND) which are located in front of the standard
Ethernet header.
This makes use of the recently introduced ether_print_hdr_len() to allow
specifying the non-standard Ethernet header length of 12 + 4 + 2 bytes.
A fair number of proprietary Ethernet switch tagging protocols, such as
Broadcom tags for instance, will place their tag between the MAC SA and
the Type/Length field.
Move the body of ether_print() into ether_print_hdr_len() and specify
the Ethernet header length as an argument to that function.
ether_print() calls ether_print_hdr_len() with a standard Ethernet
header lenght of 14 bytes, while other callers could specify an
arbitrary length. We still assume that the first Length/Type field to
parse is located 2 bytes before the end of that Ethernet header length.
This will be used in a subsequent commit to parse Broadcom tags.
Andrea Ieri [Sun, 16 Dec 2018 12:13:58 +0000 (13:13 +0100)]
Amend the documentation about the use of the -C -G and -W switches.
When using all three switches (-C -G and -W), the behavior is
practically identical to only using -C and -G, as the -W flag will only
affect the filename suffix.
Guy Harris [Tue, 11 Dec 2018 07:16:45 +0000 (23:16 -0800)]
Add, and use, macros to do locale-independent case mapping.
This means we get the same behavior in Turkish locales (where, if we
aren't in the C locale, we might get lower-case "i" mapped to upper-case
"I with dot" and upper-case "I" mapped to lower-case "i without dot),
and may also suppress some shortening warnings from MSVC.
We may just want to suppress the warning, as in "trust us, we know what
we're doing", although it'd be nice if the format string passed to those
functions could be checked to make sure it is one that takes exactly one
integer argument.
Guy Harris [Tue, 11 Dec 2018 05:53:58 +0000 (21:53 -0800)]
Try to squelch a warning about non-constant format strings.
Declare the format-string argument to tok2strbuf(), tok2str(),
bittok2str(), and bittok2str_nosep() as such, to see whether that gets
MSVC not to complain - or if it just gets upset because there's no "..."
argument list for it.
Guy Harris [Tue, 11 Dec 2018 04:14:57 +0000 (20:14 -0800)]
Squelch a warning.
We're returning the calculated checksum result modulo 65536, given that
Internet checksums are 16-bit; throw in a cast to let MSVC know that
this is intended.
Guy Harris [Wed, 21 Nov 2018 23:09:39 +0000 (15:09 -0800)]
Change tests/hoobr_bfd_print.pcap to test the BFD printer again.
Clamp the on-the-wire length values of the packets at 262144, so that we
hand the packets to the BFD printer, rather than just bailing out before
we ever get there.
The sanity check in print.c/pretty_print_packet() function, packet length
(length) >= capture length (caplen), apply when the ether_print()
function is called by ether_if_print(), netanalyzer_if_print() or
netanalyzer_transparent_if_print().
But the ether_print() function is called in some other cases, thus not
sure length always >= caplen.
Guy Harris [Tue, 13 Nov 2018 06:03:49 +0000 (22:03 -0800)]
Fix printing of Linux cooked captures with monitor-mode packets.
Apparently, if you have an interface in monitor mode, capturing on the
"any" device can get packets that have a SLL hatype of 803, which is the
ARPHRD_ value for radiotap, and with the payload containing a radiotap
header, followed by an 802.11 header, followed by the 802.11 payload.
Handle that.
Francois-Xavier Le Bail [Sun, 11 Nov 2018 20:39:25 +0000 (21:39 +0100)]
DCCP: Fix some undefined behaviors at runtime
The errors were like:
print-dccp.c:448:4: runtime error: unsigned integer overflow: 20 - 24
cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior print-dccp.c:448:4
Guy Harris [Fri, 9 Nov 2018 20:00:59 +0000 (12:00 -0800)]
Require sys/capsicum.h to use Capsicum.
My PC-BSD 9.1 VM, at least, has sys/capability.h but not sys/capsicum.h;
we now use sys/capsicum.h, so require it to be present (which it is in
FreeBSD 10 and later).
Guy Harris [Fri, 9 Nov 2018 19:33:55 +0000 (11:33 -0800)]
Require sys/capsicum.h to use Capsicum.
My PC-BSD 9.1 VM, at least, has sys/capability.h but not sys/capsicum.h;
we now use sys/capsicum.h, so require it to be present (which it is in
FreeBSD 10 and later).
Guy Harris [Sun, 14 Oct 2018 05:51:54 +0000 (22:51 -0700)]
Fix nd_snprintf(buf, buflen, "string");
If this is VS prior to 2015 or MinGW, we can't trust snprintf(); we have
to use _snprintf_s(), but that requires us to insert _TRUNCATE as an
argument after the buffer and buffer length and before the format string
and arguments, if any, to the format string.
That means we need to use a vararg macro; however, if we make the format
string a regular argument to the macro, that means that, if there are no
arguments *after* the format string, you end up with an argument list to
_snprintf_s() that ends with "fmt, ", and that's not valid C.
*If* we knew this was GCC or Clang, we could use a GNU C-specific hack,
wherein, if __VA_ARGS__ is preceded by ## and there's a comma before
that, the comma is removed if __VA_ARGS__ is empty, but this might be
Microsoft's C compiler in a version of Visual Studio prior to VS 2015,
which might not support that.
So we have to just have the macro take, as the ... arguments, the format
string and its arguments.