Commit Graph

29 Commits

Author SHA1 Message Date
Denis Ovsienko
6ff13bdf40 Lose underscores in some macro names. [skip ci] 2020-09-13 16:06:43 +01:00
Richard Scheffenegger
7f304d2869 Remove historic ECN definitions from IPv6 2020-02-29 23:43:49 +01:00
Francois-Xavier Le Bail
8534f3b7bf Use more HTTPS in URLs
[skip ci]
2019-08-19 15:49:21 +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
Guy Harris
f727010777 Get rid of ND_UNALIGNED.
Structures that describe packet formats now all use nd_ types, none of
which require more than 1-byte alignment, so compilers shouldn't assume
that anything in those structures is aligned on any particular boundary,
even without a "this is unaligned" hint.
2018-02-14 14:03:41 -08:00
Francois-Xavier Le Bail
7755951df7 RT6: Replace 'struct in6_addr' members type with a 'nd_ipv6' one
In 'struct ip6_hdr', 'struct ip6_rthdr0' and 'struct ip6_srh'.
This avoid some 'undefined-behavior' warnings with clang and option
-fsanitize=undefined enabled.

print-rt6.c:66:3: runtime error: member access within misaligned address
0x61d00001eab6 for type 'const struct ip6_rthdr0', which requires 4 byte
alignment
0x61d00001eab6: note: pointer points here
 00 00 00 04 3a 02  00 01 00 00 00 00 22 00  00 00 00 00 02 10 00 02  00 00 00 00 00 04 80 00  d3 ab
             ^
SUMMARY: AddressSanitizer: undefined-behavior print-rt6.c:66:3 in
2018-01-30 22:17:36 +01:00
Guy Harris
45fc519a2a Don't test for __attribute__ in the configure script.
Instead, use compiler test macros to check whether *particular*
attributes are supported, and set various #defines appropriately, in
header files.

Rename the UNALIGNED structure attribute to ND_UNALIGNED, and ask
whether we still need it.
2018-01-21 17:57:20 -08:00
Ahmed Abdelsalam
9c33608cb2 Add support for IPv6 routing header type 4
IPv6 routing header type 4 is known as Segment Routing Header (SRH).
It is used by Segment Routing (SR) to steer a packet through a
controlled set of instructions, called segments. It is described in
https://tools.ietf.org/html/draft-ietf-6man-segment-routing-header-07

An extension is added to allow tcpdump to print SRH information.
2017-12-29 17:43:35 +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
1ead603da6 RT6: Fix alignment issue with Solaris Studio 12.3 on Solaris 10 SPARC
Fix the 'Bus Error - core dumped' issue with the 'ipv6-routing-header' test
when '-m64' compiling option is used.

Fix with the method described in commit 1376682.

/opt/solarisstudio12.3/bin/cc -V
gives:
cc: Sun C 5.12 SunOS_sparc Patch 148917-09 2016/08/02
2017-09-13 12:25:44 +01:00
Guy Harris
7ac73d6cd4 CVE-2017-12986/IPv6 R.H.: Update to reflect the actual IPv6 RFC.
In RFC 1883, the Type 0 routing header had a 1-byte reserved field and a
3-byte strict/loose bit map; in RFC 2460, that changed to a 4-byte
reserved field.

This fixes a buffer over-read discovered by Brian 'geeknik' Carpenter (by
making an ND_TCHECK() call check for the presence in the captured data
of all 4 bytes of the reserved field; we were printing it as a 4-byte
field, so we needed to check for them).

Add a test using the capture file supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Guy Harris
83b356e177 Don't overwrite the destination IPv6 address for routing headers.
If we have a routing header, instead of overwriting the packet's IPv6
destination address in the packet with the final destination, so that
the next protocol's checksum routine can use it, we do as we do for
IPv4, and, in the "next protocol checksum" routine, scan the headers
looking for a routing header and, if we find one, copy the final
destination from it.

While we're at it, clean up a few things.
2016-02-12 20:26:39 -08:00
Guy Harris
dbddfda2c8 More getting rid of old u_intN_t. 2014-04-23 00:45:13 -07:00
Francois-Xavier Le Bail
3625533c9a fix partial checksum errors in DCCP decoder, IPv6 case 2014-02-16 18:29:37 +01:00
Denis Ovsienko
3ea7a6988e IPv6: refresh options decoding (GH #47 pt. 3)
Brian Haley points that mobility (sub-)options decoded in
print-ip6opts.c are specific to draft-ietf-mobileip-ipv6 only. RFC3775
(and respectively RFC6275) uses different encoding and parameter space,
which print-mobility.c already handles.

Remove deprecated code and update some related macros.
2014-01-04 16:39:33 +04:00
Denis Ovsienko
fe3253b9b8 remove tcpdump's own CVS keywords
Remove lots of $Header's and a few $Id's that all belong to the former
CVS repository of tcpdump itself. These keywords have been frozen since
the migration to git in late 2008.
2014-01-03 00:59:08 +04:00
fxlb
7be1e976c9 print-ip6: add a test on the header version value 2013-11-12 11:01:20 +01:00
Guy Harris
d18bb2331d Use nextproto6_cksum() for XXX-over-IPv6 checksums.
Get rid of duplicated checksums with IPv6 pseudo-headers.
2011-06-17 00:51:47 -07:00
Guy Harris
94a4b46080 Go with Wireshark's Internet checksum routine.
The Wireshark routine is based on the BSD in-kernel portable checksum
routine (thus BSD-licensed); it takes a vector of pointers and lengths
and checksums the concatenation of the buffers in question (just as the
BSD in-kernel routine checksums a chain of mbufs).

This simplifies the "with a pseudo-header" checksums; hopefully it'll
fix up the problems being seen on some big-endian platforms, which might
be due to hand-calculating some or all of the checksum and doing so
incorrectly.  It also gets rid of some code that might be dereferencing
unaligned pointers.
2011-06-13 14:08:51 -07:00
Guy Harris
53412397f6 Mark various IPv4 and IPv6 headers as unaligned.
This prevents GCC on SPARC from generating code that assumes those
structures are aligned naturally, which they are not guaranteed to be.

Move some #defines from interface.h to tcpdump-stdinc.h to make them
available to code that doesn't include interface.h.

Move the declaration of nextproto6_cksum() to ip6.h, so that only files
that use it get it declared, and thus so that you don't need to define
"struct ip6_hdr" in everything that includes interface.h.  Don't include
ip6.h in tcpdump-stdinc.h.
2010-08-31 10:03:47 -07:00
Hannes Gredler
a0275861d3 modularize ip6 nextlayer checksum generation and
change tcp6 and pim6 to use it.
2009-10-12 10:16:58 +02:00
mcr
05b7f224d8 Patches from NetBSD tree. 2007-08-29 02:31:44 +00:00
guy
1285f9e766 IRIX defines IPV6_VERSION in <netinet/in.h>, and we don't use it, so
remove the definition from ip6.h, to get rid of compiler warnings.
2005-04-20 10:04:16 +00:00
guy
3c252e8be0 Fix up some errors from the previous checkin.
Fix up some const and unsigned issues.

Make static some routines unused outside the file in which they're
defined.
2002-12-11 22:29:21 +00:00
guy
fcc82f451d The "__attribute__((packed))" tag on structures causes some files not to
compile with Sun C, as "interface.h" isn't being included before the
structures are being declared.

Furthermore, in the files that Sun C *can* compile, it doesn't cause Sun
C to generate code that's safe with unaligned accesses, as
"__attribute__" is defined as a do-nothing macro with compilers that
don't support it.

Therefore, we get rid of that tag on the structures to which it was
added, and instead use "EXTRACT_16BIT()" and "EXTRACT_32BIT()" to fetch
16-bit and 32-bit big-endian quantities from packets.  We also fix some
other references to multi-byte quantities to get rid of code that tries
to do unaligned loads on platforms that don't support them.

We also throw in a hack that makes those macros use
"__attribute__((packed))" on structures containing only one 16-bit or
32-bit integer to get the compiler to generate unaligned-safe code
rather than doing it by hand.  (GCC on SPARC produces the same code that
doing it by hand does; I don't know if GCC on any other big-endian
strict-alignment processor generates better code for that case.  On
little-endian processors, as "ntohs()" and "ntohl()" might be functions,
that might actually produce worse code.)

Fix some places to use "%u" rather than "%d" to print unsigned
quantities.
2002-12-11 07:13:49 +00:00
itojun
10afb02ac8 put __attribute__((packed)) to packet headers. s/u_short/u_int16_t/ and so
forth while i'm here
2002-11-09 17:19:16 +00:00
guy
4881292df0 Give a bunch of files RCS and SCCS IDs. 2000-12-17 23:07:48 +00:00
itojun
f3b1a28284 add mobile-ip6 option handling. patches@tcpdump.org #113
from Timo Koskiahde.
2000-12-13 07:57:04 +00:00
itojun
ce132b307b put stripped-down version of ip6.h and icmp6.h into tcpdump tree.
ip6.h is almost normal RFC2292 header.
icmp6.h has couple of extensions (not covered by RFC2292),
like MLD, ICMPv6 nodeinfo, and router renumber.

XXX how to synchronize with future kame changes?
2000-10-07 05:53:09 +00:00