Commit Graph

225 Commits

Author SHA1 Message Date
Guy Harris
56504177e8 icmp6: make opt_len a full-width u_int.
That way, when it's multiplied by 8 (shifted left 3 positions), the
result will be a u_int, as it should be, not a signed int.
2020-05-26 22:05:17 -07:00
Guy Harris
306c2a0384 More bounds checking when fetching addresses and converting to strings.
Replace more calls to ipaddr_string()/ip6addr_string() with calls to
GET_IPADDR_STRING()/GET_IP6ADDR_STRING() macros performing bounds
checking.

Add similar bounds-checking inline functions and macros to wrap
linkaddr_string(), etheraddr_string(), and isonsap_string() and convert
calls to them to use the macros as well.

Shuffle the inline functions in addrtoname.h around a bit, so that the
inline functions, external declarations, and macros are all in the same
order.
2020-01-19 19:55:38 -08:00
Guy Harris
1ed63b5d06 Remove more old-compiler compensation.
We require an environment with a C99-compatible snprintf(), so we don't
need to work around older implementations.  Make the configuration
process fail if we don't have snprintf() and vsnprintf().

We require at least VS 2015, so we don't have to check for _MSC_VER >=
1400.  Make the build fail if we don't have at least VS 2015.

We apparently do, however, have to use __inline, as the VS 2015
documentation doesn't meaning plain old "inline".  Update a comment.
2019-08-08 23:21:35 -07:00
Francois-Xavier Le Bail
0c9cfdcb0d Use nd_ipv6 rather than struct in6_addr 2019-06-10 15:32:20 +02:00
Tom Jones
a31dc7ed10 Add support for incomplete header chain param prob message
Add support for incomplete header chain paramater problem message as
defined in Section 6 of RFC7112.
2019-05-09 22:16:53 +02:00
Guy Harris
bef667db65 Clean up types to squelch narrowing warnings. 2019-04-17 19:53:00 -07:00
Francois-Xavier Le Bail
1095f1011a DNS: Rename a printer
Rename ns_nprint() to fqdn_print(), with _print suffix like in most
similar cases.

Moreover:
Move a misplaced comment.
2019-04-03 14:38:07 +02:00
Francois-Xavier Le Bail
ee68aa3646 Use the new GET_ macros instead of the EXTRACT_ ones
The exceptions are currently:
Some EXTRACT_ in print-juniper.c, not used on packet buffer pointer.
An EXTRACT_BE_U_3 in addrtoname.c, not always used on packet buffer
pointer.
2019-03-26 21:06:24 +01:00
Loganaden Velvindron
cc2d4cbd8c 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.
2019-03-16 16:03:27 +01:00
Guy Harris
2de3a27ab7 Have all Internet-checksum computing routines return a uint16_t.
Those checksums are 16-bit; change the return types of those routines
appropriately.
2018-12-11 00:50:15 -08:00
Denis Ovsienko
185f90fe42 ICMPv6: add a comment for the previous commit
[skip ci]
2018-11-12 17:24:51 +00:00
Andreas Jaggi
df2d0f19d2 show ICMPv6 echo request ID 2018-11-12 18:14:01 +00:00
Francois-Xavier Le Bail
ebf60e3cce Add a nd_print_trunc() call 2018-09-24 21:42:08 +02:00
Francois-Xavier Le Bail
0446070756 ICMPv6: Fix some truncation codes 2018-09-24 07:44:46 +02:00
Francois-Xavier Le Bail
77a49fcb6e Add the nd_print_invalid() function
It prints " (invalid)", used for malformed or corrupted packets.

Moreover:
Update CONTRIBUTING.
2018-09-11 13:09:05 +02:00
Francois-Xavier Le Bail
46efa1bc47 Fix spaces 2018-09-03 15:18:19 +02:00
Francois-Xavier Le Bail
180fae3dc2 Use more the nd_print_trunc() call
Update the output of some tests accordingly.
2018-08-20 16:37:08 +02:00
Francois-Xavier Le Bail
ef85f48a7e ICMPv6: Fix printing 'Reachable Time' and 'Retrans Timer' as milliseconds
Update 'retrans time' to 'retrans timer'.

See: https://tools.ietf.org/html/rfc4861#section-4.2.

Update the output of some tests accordingly.
2018-07-09 20:28:19 +02:00
Francois-Xavier Le Bail
01ced9f115 ICMPv6: Add a length check
If the length is zero, it's invalid, print that.

Add a test with this case.
2018-06-23 19:59:07 +02:00
Francois-Xavier Le Bail
f28f87d6ee ICMPv6: Avoid reinventing ND_TCHECK_*() macros 2018-06-03 17:38:52 +02:00
Francois-Xavier Le Bail
1889ef324c Remove some spaces (style) 2018-05-10 17:40:20 +02:00
Francois-Xavier Le Bail
0cced4fcdc Remove the safeputchar() function
Print the characters filtering out non-printable with fn_print_char().

Update the output of some tests accordingly.
2018-05-02 03:33:02 +02:00
Francois-Xavier Le Bail
56e6581c34 Remove useless comments 2018-03-19 15:16:32 +01:00
Francois-Xavier Le Bail
546558eabd Add the ndo_protocol field in the netdissect_options structure
Update this field in printer entry functions.
It will be used for some printings.
2018-03-16 19:44:47 +01:00
Francois-Xavier Le Bail
e048961ec1 ICMPv6: Squelch a GCC warning
The warning was:
./print-icmp6.c: In function 'icmp6_print':
./print-icmp6.c:1284:10: warning: cast discards '__attribute__((const))'
  qualifier from pointer target type [-Wcast-qual]
    in6 = (const nd_ipv6 *)(dp + 1);
          ^
2018-02-14 11:51:09 +01:00
Guy Harris
a7ca1167ed Undo the previous change; it didn't help.
Either we're missing something or GCC is.
2018-02-13 20:53:40 -08:00
Guy Harris
98440166f7 Try to squelch a GCC warning.
Maybe I've gotten lost in a twisty little maze of typedefs and array
pointers, all different, but I don't see how casting a const struct
icmp6_hdr * to a const nd_ipv6 * discards constness, and clang on my Mac
agrees with me.

First cast to const u_char * and then to const nd_ipv6 *, in the hopes
that GCC won't complain.
2018-02-13 20:49:07 -08:00
Guy Harris
c2a9094394 Merge branch 'master' of github.com:the-tcpdump-group/tcpdump 2018-01-31 00:47:26 -08:00
Guy Harris
0dad1934af Have ip{6}addr_string take a u_char * as the second argument.
Fix warnings that introduces.
2018-01-31 00:43:45 -08:00
Francois-Xavier Le Bail
150fa329b5 Remove unneeded '&' when getting a pointer to a nd_ipv6 type 2018-01-31 08:33:31 +01:00
Guy Harris
44c822e9f6 More nd_ipv6-ification. 2018-01-30 21:06:06 -08:00
Guy Harris
3db38df8ed Use nd_ipv6 rather than struct in6_addr in packet-layout structures.
Also, use it, and nd_ipv4, in sizeof() operations.
2018-01-30 17:29:33 -08:00
Guy Harris
c499612a7f Add nd_{v}snprintf() routines/wrappers.
Some versions of the MSVC runtime library have a non-C99-compliant
vsnprintf(), which we want to avoid.  On Windows, use snprintf() and
vsnprintf() for VS 2015 and later, where they both exist in
C99-compliant forms, and wrap _{v}snprintf_s() otherwise (they're
guaranteed to do the null termination that we want).
2018-01-29 15:48:55 -08:00
Francois-Xavier Le Bail
380fd7a4b0 ICMPv6: Use more ND_TCHECK_n() macros
Moreover:
Remove unneeded '&' when getting a pointer to an nd_uintN_t type
2018-01-24 18:24:57 +01:00
Francois-Xavier Le Bail
95d9d4925a ICMPv6: Make some code clearer 2018-01-24 14:16:03 +01:00
Francois-Xavier Le Bail
6e15ad4b99 Use more ND_TCHECK_n() macros 2018-01-22 21:51:29 +01:00
Guy Harris
fb2479d733 Always include <config.h> rather than "config.h".
This can prevent bizarre failures if, for example, you've done a
configuration in the top-level source directory, leaving behind one
config.h file, and then do an out-of-tree build in another directory,
with different configuration options.  This way, we always pick up the
same config.h, in the build directory.
2018-01-21 12:27:28 -08:00
Francois-Xavier Le Bail
bc44bb9b7d ICMPv6: Use more ND_TTEST_n() macros 2018-01-21 19:22:34 +01:00
Francois-Xavier Le Bail
513f782ae1 Use quoted include netdissect-stdinc.h instead of angle-bracketed one 2018-01-21 10:28:15 +01:00
Guy Harris
64677b0d78 Clean up signed vs. unsigned. 2018-01-11 11:52:30 -08:00
Francois-Xavier Le Bail
e2982e7f6f Update ND_PRINT() as a variadic macro 2018-01-07 13:36:41 +01:00
Francois-Xavier Le Bail
ff1c209392 Fix some Coccinelle warnings "a \ character appears outside of a #define" 2018-01-04 13:26:39 +01:00
Francois-Xavier Le Bail
d526e47658 Use ND_TTEST_SIZE()/ND_TCHECK_SIZE() macros (1/n) 2018-01-03 21:32:07 +01:00
Guy Harris
58f2aa4b57 Use nd_ types, clean up ICMPv6 dissection.
Use nd_ types for various packet structures, and use EXTRACT_ macros as
necessary.  Get rid of & in EXTRACT_ macros if not necessary.

The 1-byte pad RPL suboption is called PAD1, not PAD0, in the RFC.

Rename rpl_dio_printopt() to rpl_printopts() because 1) it's for all RPL
messages and 2) it prints multiple options.  Clean up its processing
loop.

Pass rpl_print() the ICMPv6 code, not a pointer to the full header; all
it needs is the code.

Use %u to print unsigned values.

In Node Information node address lists, the TTL comes before the
address, as per the RFC.  Dissect it that way.
2017-12-18 21:41:18 -08:00
Guy Harris
09393e2faa Pull rpl.h into print-icmp6.c; nothing else uses it. 2017-12-14 20:30:09 -08:00
Francois-Xavier Le Bail
81e4dfecd3 ICMPv6: Replace ND_TCHECK2 calls by ND_TCHECK_LEN calls 2017-12-14 22:21:52 +01:00
Guy Harris
6fe4295795 Use nd_ types for AH headers. 2017-12-13 20:43:33 -08:00
Francois-Xavier Le Bail
5cea270318 Remove all storage class specifier 'register'
Let the compiler do the optimizations (or not) based on build options.

Avoid 'value has been optimized out' messages in gdb using '-O0'.
2017-12-13 19:17:47 +01:00
Guy Harris
a95802aa0d Use nd_ types in the IPv6 structures.
And add the EXTRACT_U_1() calls as needed.

Change some other EXTRACT_ calls that no longer need an & operator.
2017-12-11 19:38:35 -08:00
Francois-Xavier Le Bail
84ef17ac0e Replace ND_TTEST2()/ND_TCHECK2() macros by macros using pointers (1/n)
ND_TTEST2(var, l)  -> ND_TTEST_LEN(p, l)
ND_TCHECK2(var, l) -> ND_TCHECK_LEN(p, l)
2017-12-11 22:11:01 +01:00