Commit Graph

42 Commits

Author SHA1 Message Date
a1346054
afb52045dd Remove last remaining trailing whitespace 2021-09-04 07:52:28 +00:00
Rui
dcae3b01d7 MPTCP: Add missing MP_CAPABLE Flags
Parse previous ignored flags from MP_CAPABLE option
2021-08-18 22:51:27 +01:00
Davide Caratti
1ac47641c5 mptcp: add support for MP_TCPRST
dissect the MP_TCPRST sub-option in accordance to RFC8684 §3.6.

Link: https://github.com/multipath-tcp/mptcp_net-next/issues/189
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2021-07-12 10:51:58 +02:00
Paolo Abeni
3ae3f2c660 MPTCP: parse MPC data_len field
The RFC 8684 introduced a new field in the MPC header: the data_len.
If the client has not seen yet a DSS sub-option from the server, it
must use MPC with data_lan instead of a DSS for the first packet
carrying a data payload.

This change print the data_len, if present, after the receiver_key.

The field is already there in the existent pcap test trace, we just
need to update the expected output.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2021-05-06 09:52:58 +00:00
Michal Ruprich
3c8346f0ef MPTCP: Print 'Length' inside mptcp options
Current mptcp parser prints 'mptcp <Subtype>...' but RFC 8684 in Section
3. states that the format should be 'mptcp <Length> <Subtype>...'
2021-04-09 12:01:27 +00:00
Denis Ovsienko
3ebae89488 MPTCP: Put GET_U_1() outside of macros.
This way it is much easier to proof-read the bounds checks coverage
even without the comments. Fixup some whitespace while at it.
2021-01-17 20:24:45 +00:00
Denis Ovsienko
bf8990f63b MPTCP: Modernize packet parsing style.
Remove the last ND_TCHECK*() instance, which was redundant. Rewrite some
code to articulate the hidden GET_U_1() instances.
2020-12-15 01:06:24 +00:00
Francois-Xavier Le Bail
12f90451bb MPTCP: Fix terminating a 'struct tok' array 2020-10-08 14:08:00 +02:00
Francois-Xavier Le Bail
1c75daed55 MPTCP: Use %u for an unsigned value 2020-10-06 17:32:28 +02:00
Davide Caratti
19b771391a mptcp: add support for ADD_ADDR "echo bit"
print "v1-echo" if the echo bit is set in the ADD_ADDR suboption (see
RFC8684 §3.4.1). While at it, dissect the 4 bits after the MPTCP option
subtype when the value is "ADD_ADDR" (0x3), according to protocol v0 and
v1. Add a selftest with a capture taken from a recent Linux kernel
implementation, and fix printout of add-addr in the existing selftests.

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2020-10-03 16:41:20 +01:00
Denis Ovsienko
5c2027db88 Rename min() and max() to ND_MIN() and ND_MAX(). [skip ci]
As discussed on tcpdump-workers, it was a place for a potential clash
with non-macros.
2020-08-24 21:53:58 +01:00
Peter Krystad
fdd065fb0f MPTCP: parse v1 ADD_ADDR option
RFC6824bis-18 (MPTCP version 1) makes changes to the MPTCP
ADD_ADDR option format.

An HMAC field is added to the option and the IP version field is
removed and replaced with an Echo bit that provides a reliability
mechanism.

This change allows either v0 or v1 ADD_ADDR options
to be parsed and displayed correctly.

Signed-off-by: Peter Krystad <peter.krystad@linux.intel.com>
2020-03-02 11:26:30 +01:00
Davide Caratti
4738c1fa73 MPTCP: parse MP_CAPABLE v1 options
A new version of MPTCP protocol (RFC8684) has been published, with some
changes to the MP_CAPABLE options handling. Let tcpdump print the protocol
version, and adjust parsing of MP_CAPABLE options according to RFC8684.

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2020-02-28 14:34:47 +01: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
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
Francois-Xavier Le Bail
b1006d2e46 MPTCP: Add a bounds check 2018-06-02 09:32:56 +02: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
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
513f782ae1 Use quoted include netdissect-stdinc.h instead of angle-bracketed one 2018-01-21 10:28:15 +01:00
Francois-Xavier Le Bail
e2982e7f6f Update ND_PRINT() as a variadic macro 2018-01-07 13:36:41 +01:00
Guy Harris
379714096c Use nd_ types, add EXTRACT_ calls. 2017-12-30 17:36:46 -08:00
Francois-Xavier Le Bail
da20bc56d6 Rename EXTRACT_ macros
Now all the macros have a name meaning a count in bytes.

With _S_: signed, _U_: unsigned

e.g.:
EXTRACT_BE_32BITS -> EXTRACT_BE_U_4
EXTRACT_LE_32BITS -> EXTRACT_LE_U_4
...
EXTRACT_BE_INT32 -> EXTRACT_BE_S_4

and have:
EXTRACT_8BITS -> EXTRACT_U_1
EXTRACT_INT8  -> EXTRACT_S_1
2017-11-22 23:54:09 +01:00
Francois-Xavier Le Bail
01cd3621f1 Use more the EXTRACT_8BITS() macro to fetch a one-byte value (22/n)
In ND_PRINT() macro calls, *p++.

Partial list.
2017-11-22 16:02:02 +01:00
Francois-Xavier Le Bail
577621026d Rename EXTRACT_nBITS() macros to EXTRACT_BE_nBITS()
It indicates clearly that these macros are used to extract big-endian
integral values.
2017-11-18 13:56:40 +01:00
Guy Harris
4c3aee4bb0 CVE-2017-13040/MPTCP: Clean up printing DSS suboption.
Do the length checking inline; that means we print stuff up to the point
at which we run out of option data.

First check to make sure we have at least 4 bytes of option, so we have
flags to check.

This fixes a buffer over-read discovered by Kim Gwan Yeong.

Add a test using the capture file supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Francois-Xavier Le Bail
b38f324af9 Add a summary comment in all other printers
Moreover:
Remove some redundant comments
Update some summary comments
Update the specification URL for ATA over Ethernet (AoE) protocol
2016-08-15 22:42:38 +02:00
Guy Harris
11f73ad248 Don't require IPv6 library support in order to support IPv6 addresses.
Have our own routines to convert between IPv4/IPv6 addresses and
strings; that helps if, for example, we want to build binary versions of
tcpdump for Windows that can run both on NT 5 (W2K/WXP), which doesn't
have inet_ntop() or inet_pton(), and NT 6 (Vista/7/8/10), which do.  It
also means that we don't require IPv6 library support on UN*X to print
addresses (if somebody wants to build tcpdump for older UN*Xes lacking
IPv6 support in the system library or in add-on libraries).

Get rid of files in the missing directory that we don't need, and
various no-longer-necessary autoconf tests.
2015-09-17 14:56:44 -07:00
Francois-Xavier Le Bail
99c91c3aec Rename 'tcpdump-stdinc.h' to 'netdissect-stdinc.h'
Get the full log via: git log --follow netdissect-stdinc.h
2015-09-10 08:50:40 +02:00
Francois-Xavier Le Bail
c1c3c77463 Printers must include 'netdissect.h', not 'interface.h' 2015-09-05 23:35:58 +02:00
Guy Harris
69cb46af91 Fix a bunch of de-constifications. 2015-04-26 17:24:42 -07:00
Denis Ovsienko
38700c7f24 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.
2015-03-22 10:06:15 +00:00
Guy Harris
ed85e20e4d u_intN_t is dead, long live uintN_t.
And, as we require at least autoconf 2.61, and as autoconf 2.61 and
later have AC_TYPE_UINTn_T and AC_TYPE_INTn_T macros, we use them to
define the uintN_t and intN_t macros if the system doesn't define them
for us.

This lets us get rid of bitypes.h as well.
2014-04-23 00:20:40 -07:00
Guy Harris
1cde6435df Netdissectify the to-name resolution routines.
Have them take a netdissect_options * argument, and get the "no name
resolution" flag from it.

Move the declaration of dnaddr_string to addrtoname.h, along with the
other XXX-to-string routines.
2014-04-04 00:43:46 -07:00
Denis Ovsienko
90692fcf97 NDOize ATM, MPTCP, NTP, VTP & Whiteboard decoders 2014-03-20 15:17:35 +04:00
Guy Harris
27d428c0a1 Pull a bunch of headers into the only source file that includes them.
For headers included in only one source file, put the header contents in
the source file in question, and get rid of a bunch of stuff from the
header not used in the source file.
2013-12-30 22:52:15 -08:00
Denis Ovsienko
d8b3af528a make more array declarations static/const 2013-12-19 14:25:01 +04:00
Guy Harris
842e10954c Rename a variable to attempt to fix an AIX compile error.
On AIX 5.1, at least when compiling with xlc, the statement

       struct mp_remove_addr *rem_addr = (struct mp_remove_addr *) opt;

gets a complaint "Syntax error: possible missing '{'?"

"/usr/include/sys/xmem.h" #defines rem_addr; I've no idea whether we're
indirectly including that, but maybe we are and maybe that's causing the
problem.
2013-05-05 19:52:14 -07:00
Guy Harris
1ea8a8c4a4 Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points.  There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware).  In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned.  Don't use them.

Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned.  Use the EXTRACT_nBITS() macros.

__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled.  Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).

Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-05 18:52:54 -07:00
Guy Harris
bf97f9965e Fix some compiler warnings from the previous checkin. 2013-05-05 18:31:48 -07:00
Gregory Detal
3432f69892 Fix MPTCP support
Added:
 * option length check
 * option type and TCP flags check
 * more information printed

Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
2013-05-05 18:29:46 -07:00
Guy Harris
e3591424ed Fix some compiler warnings.
Some of those warnings are real bugs - some routines whose callers
expected them to return values weren't returning values.
2013-04-14 17:21:19 -07:00
Gregory Detal
578dd316f3 Multipath TCP (RFC 6824) support
This commit adds the support of Multipath TCP (MPTCP). MPTCP is a new
extension to TCP standardized at the IETF. MPTCP allows to use several IP
addresses at the same time by distributing data across several subflows (TCP
connections) while still presenting the standard TCP socket API to the
application. Its benefits are better resource utilization, better throughput
and smoother reaction to failures.
2013-04-14 18:20:26 -04:00