Denis Ovsienko [Sun, 17 Jan 2021 21:22:34 +0000 (21:22 +0000)]
TCP: Modernize packet parsing style.
Enable ND_LONGJMP_FROM_TCHECK. Report invalid packets as invalid. Remove
most ND_TCHECK*() instances as they were redundant. Update a custom
snapend guard to use nd_trunc_longjmp(). Reduce arity of
print_tcp_fastopen_option(). Use ND_TTEST_LEN() in
tcp_verify_signature() and nd_printn() in print_tcp_rst_data(). For
NFS_PORT remove ND_TTEST_4() from the test condition as it is not a
valid factor, there is the subsequent GET_BE_U_4() to check bounds.
Denis Ovsienko [Fri, 15 Jan 2021 22:30:40 +0000 (22:30 +0000)]
AODV: Modernize packet parsing style.
Make all ND_TCHECK_SIZE() instances redundant and remove them. Always
print a reason when reporting a packet as invalid. Undo the changes from
commit f875106 to remove support for draft-perkins-aodv6-01, which had
expired in 2001. Use tok2str() to print the message type. Don't print an
additional "v6" for RREQ, as the address family is apparent from the UDP
header. Update a test.
Denis Ovsienko [Thu, 14 Jan 2021 03:48:28 +0000 (03:48 +0000)]
RIP: Modernize packet parsing style.
Enable ND_LONGJMP_FROM_TCHECK. Report invalid packets as invalid. Remove
two redundant ND_TCHECK_SIZE() instances and an improvised snapshot end
guard. Check bounds for the remaining part of the packet header after
printing version and command, not before. Lose one pointer and one
length variable in rip_print(), also account for the header size when
estimating the number of routes. Update two tests.
Denis Ovsienko [Wed, 13 Jan 2021 00:43:49 +0000 (00:43 +0000)]
AppleTalk: Modernize packet parsing style.
Enable ND_LONGJMP_FROM_TCHECK. Report invalid packets as invalid. Remove
all improvised snapshot end guards as they were redundant. In
print_cstring() have nd_printjn() guard the snapshot end. Use tok2str()
in nbp_print(). Update two tests.
Denis Ovsienko [Tue, 12 Jan 2021 15:52:23 +0000 (15:52 +0000)]
UDP: Modernize packet parsing style.
Remove all ND_TCHECK_*() instances as redundant. Remove or convert a few
improvised snapshot end guards. Reduce arity of rtcp_print(). Test the
AppleTalk LAP type after testing the UDP port numbers, not before.
Denis Ovsienko [Tue, 12 Jan 2021 13:37:50 +0000 (13:37 +0000)]
UDP: Clean up address and port printing.
udp_print() always knows whether UDP port numbers are available or not,
so split udpipaddr_print() into two functions to lose some arity, much
branching and all type casting. In the new functions test for IPv4
explicitly. In udp_print() convert duplicate code into a conditional
call to udpipaddr_print().
Denis Ovsienko [Sun, 10 Jan 2021 00:53:43 +0000 (00:53 +0000)]
EIGRP: Modernize packet parsing style.
Enable ND_LONGJMP_FROM_TCHECK. Report invalid packets as invalid. Remove
two redundant ND_TCHECK_*() instances. When giving up on a packet for
whatever reason, test that the rest of it is within the buffer. Do the
header length check before accessing any header data and refine the TLV
length checks. Update a test.
Denis Ovsienko [Sat, 9 Jan 2021 22:04:28 +0000 (22:04 +0000)]
EIGRP: Get the packet header fields right.
In the spec the packet diagram instead of a 32-bit AS number shows a
16-bit virtual router ID followed by a 16-bit AS number, implement
that. Also add two missing flag values and use bittok2str() to print
the bitmask. Lose a stale comment and update some tests.
Guy Harris [Fri, 8 Jan 2021 20:23:04 +0000 (12:23 -0800)]
Remove debugging printouts.
The problem appears to be with the
if [ "$COVERITY_SCAN_BRANCH" = 1 ]; then exit 0; fi
line in the script: section of .travis.yml; libpcap has the line
if [ "$COVERITY_SCAN_BRANCH" = 1 ]; then echo "Coverity build - nothing more to do"; exit 0; fi
and also fails, so exiting without a message isn't the problem, and when
I tried adding
if [ "$COVERITY_SCAN_BRANCH" = 0 ]; then echo "Non-Coverity build - pstill nothing more to do"; exit 0; fi
and the ppc64le Linux builds were failing with a timeout rather than
just doing nothing - the AMD64 Linux didn't have a problem, so there's
something different about the non-x86-64 builds that's causing the "exit
0" stuff not to work.
Francois-Xavier Le Bail [Fri, 8 Jan 2021 15:09:41 +0000 (16:09 +0100)]
Add a nd_printjn() function
It prints a counted filename (or other ASCII string), part of
the packet buffer, filtering out non-printable characters.
Stop if truncated (via GET_U_1/longjmp) or after n bytes,
whichever is first.
The suffix comes from: j:longJmp, n:after N bytes.
Guy Harris [Fri, 8 Jan 2021 09:38:16 +0000 (01:38 -0800)]
Travis: we should no longer need to set PKG_CONFIG_PATH for CMake.
FindPCAP.cmake should now pick up directories from CMAKE_PREFIX_PATH and
add the corresponding pkgconfig directories to PKG_CONFIG_PATH before
running pkg-config, so we shouldnt need to set PKG_CONFIG_PATH
ourselves.
We still need to do it when running the autoonf script, as there's no
equivalent for CMAKE_PREFIX_PATH in autoconf.
Guy Harris [Fri, 8 Jan 2021 09:35:31 +0000 (01:35 -0800)]
CMake: add stuff from CMAKE_PREFIX_PATH to PKG_CONFIG_PATH.
Pull in some code from CMake 3.12.4's FindPkgConfig.cmake to arrange
that, when running pkg-config, directories from CMAKE_PREFIX_PATH are in
the PKG_CONFIG_PATH environment variable.
We do this because we want to make sure that, if CMAKE_PREFIX_PATH is
set, and it points to a directory that contains a libpcap that has a .pc
file installed, we get that .pc file, but we don't yet want to require a
minimum of CMake 3.1 or later (CMake 3.1 and later do that
automatically) because there might be some long-term support OS version
that comes with an older version of CMake.
Denis Ovsienko [Fri, 8 Jan 2021 03:23:26 +0000 (03:23 +0000)]
BOOTP: Modernize packet parsing style.
Enable ND_LONGJMP_FROM_TCHECK. Report invalid packets as invalid. Have
nd_printn() and nd_printztn() guard the snapshot end. Replace
client_fqdn_flags() with bittok2str_nosep().
Guy Harris [Thu, 7 Jan 2021 20:45:12 +0000 (12:45 -0800)]
Point cmake at the installed pkg-config directory in /tmp.
Getting CMake to look for the temporarily-installed libpcap.pc file
requires that we set PKG_CONFIG_PATH to /tmp/lib/pkgconfig; otherwise,
the configuration process won't find it, and hilarity ensues.
Try turning the 'BUILD_LIBPCAP=yes CMAKE=yes' builds on, to see if that
fixes them.
Bill Fenner [Fri, 11 Dec 2020 14:20:31 +0000 (06:20 -0800)]
MPLS: rename the "exp" field to "tc"
RFC5462 (https://tools.ietf.org/html/rfc5462) renamed the
MPLS "EXP" field to "Traffic Class" in 2009. Use "tc" as an
abbreviation for this field name.
Denis Ovsienko [Wed, 6 Jan 2021 01:32:07 +0000 (01:32 +0000)]
Geneve: Modernize packet parsing style.
Enable ND_LONGJMP_FROM_TCHECK. Remove one redundant ND_TCHECK_*()
instance and make another one conditional. Report invalid packets as
invalid. Test that a non-Ethernet payload is fully within the packet
buffer. Add a length check to geneve_opts_print() and have it indicate
invalid tunnel options. Constify an argument. Update the packet diagrams
and refer to the RFC rather than the draft.
Francois-Xavier Le Bail [Sat, 2 Jan 2021 13:03:00 +0000 (14:03 +0100)]
Fix a warning on Linux Alpine
The warning was like:
In file included from ./netdissect-stdinc.h:42,
from ./fptype.c:36:
./ftmacros.h:116: warning: "_BSD_SOURCE" redefined
116 | #define _BSD_SOURCE
|
In file included from /usr/include/stdio.h:8,
from /usr/include/fortify/stdio.h:22,
from ./fptype.c:34:
/usr/include/features.h:15: note: this is the location of the previous
definition
15 | #define _BSD_SOURCE 1
|
Guy Harris [Sat, 2 Jan 2021 09:06:36 +0000 (01:06 -0800)]
Fix a build problem on the Linux Travis CI buildbot.
The buildbot is failing in autotools builds - but not in CMake builds;
go figure. Perhaps they're passing different flags to the C compiler,
and, in the autotools builds, the flag causes the compiler to define
whatever it takes to get /usr/include/features.h to define
_DEFAULT_SOURCE as 1, so that our defining it as nothing collides with
that.
(Dear UN*X community: please come up with a platform-independent,
reliable way of saying "expose every single API you have, namespace
pollution be damned. kthxbye.)
Denis Ovsienko [Sat, 2 Jan 2021 04:01:35 +0000 (04:01 +0000)]
OLSR: Modernize packet parsing style.
Enable ND_LONGJMP_FROM_TCHECK. Remove a few redundant ND_TCHECK_*()
instances. Report invalid packets as invalid with a reason, not
truncated. Make helper functions void and lose associated checks.
Denis Ovsienko [Sat, 2 Jan 2021 02:09:43 +0000 (02:09 +0000)]
PGM: Modernize packet parsing style.
Enable ND_LONGJMP_FROM_TCHECK. Remove a few redundant ND_TCHECK_*()
instances. Report invalid packets as invalid, not truncated. Update a
custom snapshot end guard to call nd_trunc_longjmp().
Denis Ovsienko [Tue, 22 Dec 2020 02:37:41 +0000 (02:37 +0000)]
Refine some guidelines in CONTRIBUTING [skip ci]
Improve some language, spell both build systems and all three CI
systems, deduplicate some text, drop ND_TTEST_*(), introduce GET_*()
and explain the bounds checks in a bit more detail.
Denis Ovsienko [Mon, 21 Dec 2020 02:46:37 +0000 (02:46 +0000)]
man: Note the -x/-X quirk for truncated packets [skip ci]
Accurate skipping of the link level header was working before the
conversion started, it will hopefully work after the conversion is
complete, but meanwhile be clear about what it is now.
Denis Ovsienko [Sun, 20 Dec 2020 03:55:12 +0000 (03:55 +0000)]
NSH: Modernize packet parsing style.
Enable ND_LONGJMP_FROM_TCHECK. Remove a redundant ND_TCHECK_LEN()
instance and make another one conditional. Report invalid packets as
invalid with a reason, not truncated.
Update the code from draft-ietf-sfc-nsh-01 to RFC 8300: remove the no
longer existent C-bit, add the TTL field, adjust the MD Type field
offset and size, apply correct mask to TLV length, redo TLV length in
bytes instead of 4-byte words and mind the padding.
Fetch and print one header at a time. Add and use two lookup tables for
MD Type and Next Protocol. Add a version number check. Add a length
check for MD Type 1. Update some error messages. Add a few encoding
diagrams for clarity. Lose a few variables and reduce scope of the
remaining variables. Update a few tests.
Denis Ovsienko [Thu, 10 Dec 2020 01:02:52 +0000 (01:02 +0000)]
MPLS: Modernize packet parsing style.
Enable ND_LONGJMP_FROM_TCHECK. Remove both ND_TCHECK*() instances
because they are redundant. Report invalid packets as invalid, not
truncated. Test whether the invalid packet is entirely in the buffer.
Replace a long switch block with a ternary assignment.
Francois-Xavier Le Bail [Mon, 14 Dec 2020 21:02:01 +0000 (22:02 +0100)]
PFLOG: Try to fix previous commit
The error was:
./print-pflog.c:99:20: error: passing 'char const[16]' to parameter
of type 'const u_char *' (aka 'const unsigned char *') converts
between pointers to integer types with different sign
[-Werror,-Wpointer-sign]
nd_printjnp(ndo, hdr->ruleset, PFLOG_RULESET_NAME_SIZE);
^~~~~~~~~~~~
./netdissect.h:397:61: note: passing argument to parameter here
extern void nd_printjnp(netdissect_options *, const u_char *, u_int);
^