Sam James [Mon, 12 Sep 2022 16:28:58 +0000 (17:28 +0100)]
configure.ac: fix configure tests broken with Clang 15 (implicit function declarations)
Clang 15 makes implicit function declarations fatal by default which
leads to some of tcpdump's configure tests silently failing/returning
the wrong result.
This adds the needed #includes to various tests for the functions used,
resolving the following errors:
```
net-analyzer/tcpdump-4.99.1/clang15.log:47:error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
net-analyzer/tcpdump-4.99.1/clang15.log:51:error: call to undeclared library function 'strcmp' with type 'int (const char *, const char *)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
net-analyzer/tcpdump-4.99.1/clang15.log:55:error: call to undeclared library function 'sscanf' with type 'int (const char *restrict, const char *restrict, ...)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
net-analyzer/tcpdump-4.99.1/clang15.log:68:error: call to undeclared library function 'memset' with type 'void *(void *, int, unsigned long)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
net-analyzer/tcpdump-4.99.1/clang15.log:112:error: call to undeclared function 'ether_ntohost'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
net-analyzer/tcpdump-4.99.1/clang15.log:115:error: call to undeclared library function 'exit' with type 'void (int) __attribute__((noreturn))'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
```
Nicholas Reilly [Wed, 31 Aug 2022 21:01:08 +0000 (17:01 -0400)]
ICMPv6: Fix the Node Information flags
Don't use htons() when defining the constants because the flags
field is already eventually swapped by fetching with GET_BE_U_2().
Remove unused flags NI_SUPTYPE_FLAG_COMPRESS and NI_FQDN_FLAG_VALIDTTL.
Add a test file with various NI_NODEADDR_FLAG* flags.
Francois-Xavier Le Bail [Wed, 10 Aug 2022 13:02:33 +0000 (15:02 +0200)]
CHDLC: Modernize packet parsing
Enable ND_LONGJMP_FROM_TCHECK and remove the "trunc" labels.
Use ND_ICHECK_U() for length checks and add standard "invalid" sections.
Remove a ndo_ll_hdr_len increment in a truncation case.
Update chdlc_print() to a void function.
Remove a now useless variable.
Guy Harris [Thu, 21 Jul 2022 08:32:44 +0000 (01:32 -0700)]
juniper: don't do bounds checking for fields in the cookie.
l2info.cookie is not inside the packet - it's a copy of data from the
packet, with the copy doing the necessary bounds checking - so we
shouldn't use NT_TCHECK or GET macros on it.
Guy Harris [Sun, 17 Jul 2022 17:56:05 +0000 (10:56 -0700)]
pflog: use nd_ipv4 and nd_ipv6 for addresses in the header.
We should be using nd_ types in structures that are overlaid on packets,
so that we control the field offsets (as independently of the compiler
as possible) and to make it more difficult to fetch data fromt he packet
without using packet data accessor routines (to force bounds checking
and conversion from the appropriate byte order to host byte order as
necessary).
It seems possible that some old make implementations could have low
limits on the number and line length of Makefile rules, which would
explain the need for the awk code in mkdep in 1988.
That said, many still-used copies and derivatives of mkdep do not have
the awk code, which hints that either the problem no longer exists or
the workarounds have since settled elsewhere: most compilers that
Autoconf cares to use for dependency generation (GCC, Clang and XL C
16.1) produce dependency rules with long lines already nicely wrapped,
and even though SunStudio 11 produces plenty of short lines, the result
does not affect make on Solaris 9.
Since the only practical effect of the awk code seems to be a bug that
sometimes manifests in edge cases as explained in GH pull request #651,
instead of using a more complicated awk script (as in OpenLDAP) drop it
altogether (as in GCC) and presume the only practical effect to be
elimination of the bug unless proven otherwise.
$ make releasetar
tar: CONTRIBUTING: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
Cleaning...
$ make distclean
After:
$ make releasetar
tar: CONTRIBUTING: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
make: *** [Makefile:475: releasetar] Error 2
Arista: Refine the output format and print HwInfo.
See pull request GH#955.
Add a comment with the Timestamp packet diagram. Define
ARISTA_SUBTYPE_TIMESTAMP as a two-byte integer, same as it is on the
wire. Break the version field into three fields and add printing of
HwInfo. Lose an unused variable and a few named constants. When
carrying whole seconds over from nanoseconds, use a large enough type
for seconds and do not forget to correct nanoseconds afterwards. Print
all fields using tok2str() and DHCP-like format. Update the associated
tests.
Bill Fenner [Tue, 5 Apr 2022 01:24:14 +0000 (18:24 -0700)]
Add pcap file to exercise corner cases for BGP shutdown message printer
This pcap file contains 3 corner cases:
1. A packet with more data than the length provides for
2. A packet that has a shutdown message with zero data
3. A packet whose shutdown message length is longer than the remaining data
in the notification
Guy Harris [Fri, 1 Apr 2022 22:28:33 +0000 (15:28 -0700)]
Fail if nd_push_buffer() or nd_push_snaplen() fails.
Always call ndo->ndo_error with a memory-allocation error if they fail.
Add WARN_UNUSED_RESULT for compilers that support it, and use it for
those routines, so that any future code that doesn't check for failure
gets a warning.
Guy Harris [Thu, 31 Mar 2022 09:29:19 +0000 (02:29 -0700)]
Have routines that set the snapend take a buffer pointer and length as args.
Have nd_push_buffer() take a snapshot length, not a snapshot end, as
its last argument.
Replace nd_push_snapend() and nd_change_snapend() with nd_push_snaplen()
and nd_change_snaplen(), both of which take a pointer into the packet
buffer and snapshot length relative to that pointer as arguments. Have
those routines check the snapshot length to make sure it's not bigger
than the number of bytes in the packet past the pointer, and silently
ignore the requst if it is.
Using a length rather than a pointer avoids the possibility of the
calculation of the snapshot end overflowing and resulting in a snapshot
end *before* the point in the buffer.
Add a test for this, with a capture file containing an IPv6 packet with
an extremely large "jumbo" packet size.
Revert the "Make sure we don't set the snapend before the beginning of
the packet." changes, as they no longer apply with this change (which
also makes sure we don't set the snapend before the beginning of the
packet).
Guy Harris [Tue, 29 Mar 2022 07:51:21 +0000 (00:51 -0700)]
Make sure we don't set the snapend before the beginning of the packet.
If a caller attempts to set it after the current snapend, just silently
ignore the attempt.
If they try to set it before the beginning of the packet, report it as a
bug and quit dissection. Add a new setjmp() return value meaning "bug"
rather than "truncated packet", add an "nd_bug_longjmp()" routine for
reporting bugs where we should quit dissecting, and use that in this
case.
Guy Harris [Sun, 20 Mar 2022 05:17:43 +0000 (22:17 -0700)]
icmp: clean up the extension code and comments.
Remove remaining references to them as being MPLS-related;
draft-bonica-icmp-mpls-02 referred to them as "ICMP Extensions for
MultiProtocol Label Switching", but draft-bonica-internet-icmp-00
redefined it as a general extension mechanism, not MPLS-related, and
that draft eventually became RFC 4884.
draft-bonica-icmp-mpls-02 also defined class 2 objects as objects
containing the remaining packet information past the first 128 bytes;
that never became part of an RFC and class 2 was redefined as an
"Interface Information Object" in RFC 5837.
Give some of these details in comments, and move some
extension-related definitions among the rest of the extension stuff.