2003-07-07 11:13:31 +00:00
|
|
|
/*
|
|
|
|
ipv6.h -- missing IPv6 related definitions
|
2006-04-26 13:52:58 +00:00
|
|
|
Copyright (C) 2005 Ivo Timmermans
|
2016-04-14 21:24:22 +00:00
|
|
|
2006-2016 Guus Sliepen <guus@tinc-vpn.org>
|
2003-07-07 11:13:31 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2009-09-24 22:01:00 +00:00
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2003-07-07 11:13:31 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __TINC_IPV6_H__
|
|
|
|
#define __TINC_IPV6_H__
|
|
|
|
|
|
|
|
#ifndef AF_INET6
|
|
|
|
#define AF_INET6 10
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef IPPROTO_ICMPV6
|
|
|
|
#define IPPROTO_ICMPV6 58
|
|
|
|
#endif
|
|
|
|
|
2003-07-11 16:13:00 +00:00
|
|
|
#ifndef IN6_IS_ADDR_V4MAPPED
|
|
|
|
#define IN6_IS_ADDR_V4MAPPED(a) \
|
2012-10-10 15:17:49 +00:00
|
|
|
((((__const uint32_t *) (a))[0] == 0) \
|
|
|
|
&& (((__const uint32_t *) (a))[1] == 0) \
|
|
|
|
&& (((__const uint32_t *) (a))[2] == htonl (0xffff)))
|
2003-07-11 16:13:00 +00:00
|
|
|
#endif
|
|
|
|
|
2003-07-18 13:42:35 +00:00
|
|
|
#ifndef HAVE_STRUCT_IP6_HDR
|
2003-07-07 11:13:31 +00:00
|
|
|
struct ip6_hdr {
|
|
|
|
union {
|
|
|
|
struct ip6_hdrctl {
|
|
|
|
uint32_t ip6_un1_flow;
|
|
|
|
uint16_t ip6_un1_plen;
|
|
|
|
uint8_t ip6_un1_nxt;
|
|
|
|
uint8_t ip6_un1_hlim;
|
|
|
|
} ip6_un1;
|
|
|
|
uint8_t ip6_un2_vfc;
|
|
|
|
} ip6_ctlun;
|
|
|
|
struct in6_addr ip6_src;
|
|
|
|
struct in6_addr ip6_dst;
|
Make sure packet header structures are correctly packed on Windows.
Modern versions of GCC handle structure packing differently when
compiling for Windows, as reported in the following GCC bug report:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991
In practice, this affects tinc because it uses packed structs as a
convenient way to populate packet headers. "struct ip" is especially
affected - on Linux, sizeof(struct ip) returns 20 as expected, while on
Windows, it returns 24 because of the broken alignment.
This in turn completely breaks code that has to populate an IP header.
Specifically, this breaks route_ipv4_unreachable() which is responsible,
among other things, for the generation of ICMP Fragmentation Needed
messages. On Windows, these messages are corrupted beyond hope because
of this alignment issue. For TCP connections that are established
before tinc obtains a fix on the MTU (and thus are not MSS clamped),
this can result in massive disruption.
This commit fixes the issue by forcing GCC to use standard alignment
for all packed structures in the tinc codebase instead of the MSVC
alignment.
2015-03-15 10:00:56 +00:00
|
|
|
} __attribute__ ((__gcc_struct__, __packed__));
|
2003-07-07 11:50:52 +00:00
|
|
|
#define ip6_vfc ip6_ctlun.ip6_un2_vfc
|
|
|
|
#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
|
|
|
|
#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
|
|
|
|
#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
|
|
|
|
#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
|
|
|
|
#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
|
2003-07-18 13:42:35 +00:00
|
|
|
#endif
|
2003-07-07 11:13:31 +00:00
|
|
|
|
2003-07-18 13:42:35 +00:00
|
|
|
#ifndef HAVE_STRUCT_ICMP6_HDR
|
2003-07-07 11:13:31 +00:00
|
|
|
struct icmp6_hdr {
|
|
|
|
uint8_t icmp6_type;
|
|
|
|
uint8_t icmp6_code;
|
|
|
|
uint16_t icmp6_cksum;
|
|
|
|
union {
|
|
|
|
uint32_t icmp6_un_data32[1];
|
|
|
|
uint16_t icmp6_un_data16[2];
|
|
|
|
uint8_t icmp6_un_data8[4];
|
|
|
|
} icmp6_dataun;
|
Make sure packet header structures are correctly packed on Windows.
Modern versions of GCC handle structure packing differently when
compiling for Windows, as reported in the following GCC bug report:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991
In practice, this affects tinc because it uses packed structs as a
convenient way to populate packet headers. "struct ip" is especially
affected - on Linux, sizeof(struct ip) returns 20 as expected, while on
Windows, it returns 24 because of the broken alignment.
This in turn completely breaks code that has to populate an IP header.
Specifically, this breaks route_ipv4_unreachable() which is responsible,
among other things, for the generation of ICMP Fragmentation Needed
messages. On Windows, these messages are corrupted beyond hope because
of this alignment issue. For TCP connections that are established
before tinc obtains a fix on the MTU (and thus are not MSS clamped),
this can result in massive disruption.
This commit fixes the issue by forcing GCC to use standard alignment
for all packed structures in the tinc codebase instead of the MSVC
alignment.
2015-03-15 10:00:56 +00:00
|
|
|
} __attribute__ ((__gcc_struct__, __packed__));
|
2003-07-07 11:13:31 +00:00
|
|
|
#define ICMP6_DST_UNREACH_NOROUTE 0
|
|
|
|
#define ICMP6_DST_UNREACH 1
|
2003-12-22 11:05:23 +00:00
|
|
|
#define ICMP6_PACKET_TOO_BIG 2
|
2012-03-08 21:19:20 +00:00
|
|
|
#define ICMP6_TIME_EXCEEDED 3
|
2010-04-11 17:20:02 +00:00
|
|
|
#define ICMP6_DST_UNREACH_ADMIN 1
|
2003-07-07 11:13:31 +00:00
|
|
|
#define ICMP6_DST_UNREACH_ADDR 3
|
2012-03-08 21:19:20 +00:00
|
|
|
#define ICMP6_TIME_EXCEED_TRANSIT 0
|
2003-07-07 11:13:31 +00:00
|
|
|
#define ND_NEIGHBOR_SOLICIT 135
|
|
|
|
#define ND_NEIGHBOR_ADVERT 136
|
2003-11-08 15:09:03 +00:00
|
|
|
#define icmp6_data32 icmp6_dataun.icmp6_un_data32
|
|
|
|
#define icmp6_data16 icmp6_dataun.icmp6_un_data16
|
|
|
|
#define icmp6_data8 icmp6_dataun.icmp6_un_data8
|
2003-12-22 11:05:23 +00:00
|
|
|
#define icmp6_mtu icmp6_data32[0]
|
2003-07-18 13:42:35 +00:00
|
|
|
#endif
|
2003-07-07 11:13:31 +00:00
|
|
|
|
2003-07-18 13:42:35 +00:00
|
|
|
#ifndef HAVE_STRUCT_ND_NEIGHBOR_SOLICIT
|
2003-07-07 11:13:31 +00:00
|
|
|
struct nd_neighbor_solicit {
|
|
|
|
struct icmp6_hdr nd_ns_hdr;
|
|
|
|
struct in6_addr nd_ns_target;
|
Make sure packet header structures are correctly packed on Windows.
Modern versions of GCC handle structure packing differently when
compiling for Windows, as reported in the following GCC bug report:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991
In practice, this affects tinc because it uses packed structs as a
convenient way to populate packet headers. "struct ip" is especially
affected - on Linux, sizeof(struct ip) returns 20 as expected, while on
Windows, it returns 24 because of the broken alignment.
This in turn completely breaks code that has to populate an IP header.
Specifically, this breaks route_ipv4_unreachable() which is responsible,
among other things, for the generation of ICMP Fragmentation Needed
messages. On Windows, these messages are corrupted beyond hope because
of this alignment issue. For TCP connections that are established
before tinc obtains a fix on the MTU (and thus are not MSS clamped),
this can result in massive disruption.
This commit fixes the issue by forcing GCC to use standard alignment
for all packed structures in the tinc codebase instead of the MSVC
alignment.
2015-03-15 10:00:56 +00:00
|
|
|
} __attribute__ ((__gcc_struct__, __packed__));
|
2003-07-07 11:13:31 +00:00
|
|
|
#define ND_OPT_SOURCE_LINKADDR 1
|
|
|
|
#define ND_OPT_TARGET_LINKADDR 2
|
2003-11-08 15:09:03 +00:00
|
|
|
#define nd_ns_type nd_ns_hdr.icmp6_type
|
|
|
|
#define nd_ns_code nd_ns_hdr.icmp6_code
|
|
|
|
#define nd_ns_cksum nd_ns_hdr.icmp6_cksum
|
|
|
|
#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
|
2003-07-18 13:42:35 +00:00
|
|
|
#endif
|
2003-07-07 11:13:31 +00:00
|
|
|
|
2003-07-18 13:42:35 +00:00
|
|
|
#ifndef HAVE_STRUCT_ND_OPT_HDR
|
2003-07-07 11:13:31 +00:00
|
|
|
struct nd_opt_hdr {
|
|
|
|
uint8_t nd_opt_type;
|
|
|
|
uint8_t nd_opt_len;
|
Make sure packet header structures are correctly packed on Windows.
Modern versions of GCC handle structure packing differently when
compiling for Windows, as reported in the following GCC bug report:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991
In practice, this affects tinc because it uses packed structs as a
convenient way to populate packet headers. "struct ip" is especially
affected - on Linux, sizeof(struct ip) returns 20 as expected, while on
Windows, it returns 24 because of the broken alignment.
This in turn completely breaks code that has to populate an IP header.
Specifically, this breaks route_ipv4_unreachable() which is responsible,
among other things, for the generation of ICMP Fragmentation Needed
messages. On Windows, these messages are corrupted beyond hope because
of this alignment issue. For TCP connections that are established
before tinc obtains a fix on the MTU (and thus are not MSS clamped),
this can result in massive disruption.
This commit fixes the issue by forcing GCC to use standard alignment
for all packed structures in the tinc codebase instead of the MSVC
alignment.
2015-03-15 10:00:56 +00:00
|
|
|
} __attribute__ ((__gcc_struct__, __packed__));
|
2003-07-07 11:13:31 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __TINC_IPV6_H__ */
|