Add support for building tinc with MSVC
[tinc] / src / ipv6.h
1 #ifndef TINC_IPV6_H
2 #define TINC_IPV6_H
3
4 /*
5     ipv6.h -- missing IPv6 related definitions
6     Copyright (C) 2005 Ivo Timmermans
7                   2006-2016 Guus Sliepen <guus@tinc-vpn.org>
8
9     This program is free software; you can redistribute it and/or modify
10     it under the terms of the GNU General Public License as published by
11     the Free Software Foundation; either version 2 of the License, or
12     (at your option) any later version.
13
14     This program is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17     GNU General Public License for more details.
18
19     You should have received a copy of the GNU General Public License along
20     with this program; if not, write to the Free Software Foundation, Inc.,
21     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 */
23
24 #include "system.h"
25
26 #ifndef AF_INET6
27 #define AF_INET6 10
28 #endif
29
30 #ifndef IPPROTO_ICMPV6
31 #define IPPROTO_ICMPV6 58
32 #endif
33
34 #ifndef IN6_IS_ADDR_V4MAPPED
35 #define IN6_IS_ADDR_V4MAPPED(a) \
36         ((((__const uint32_t *) (a))[0] == 0) \
37          && (((__const uint32_t *) (a))[1] == 0) \
38          && (((__const uint32_t *) (a))[2] == htonl (0xffff)))
39 #endif
40
41 #ifndef HAVE_STRUCT_IP6_HDR
42 struct ip6_hdr {
43         union {
44                 struct ip6_hdrctl {
45                         uint32_t ip6_un1_flow;
46                         uint16_t ip6_un1_plen;
47                         uint8_t ip6_un1_nxt;
48                         uint8_t ip6_un1_hlim;
49                 } ip6_un1;
50                 uint8_t ip6_un2_vfc;
51         } ip6_ctlun;
52         struct in6_addr ip6_src;
53         struct in6_addr ip6_dst;
54 };
55 #define ip6_vfc ip6_ctlun.ip6_un2_vfc
56 #define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
57 #define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
58 #define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
59 #define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
60 #define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
61 #endif
62
63 #ifndef HAVE_STRUCT_ICMP6_HDR
64 struct icmp6_hdr {
65         uint8_t icmp6_type;
66         uint8_t icmp6_code;
67         uint16_t icmp6_cksum;
68         union {
69                 uint32_t icmp6_un_data32[1];
70                 uint16_t icmp6_un_data16[2];
71                 uint8_t icmp6_un_data8[4];
72         } icmp6_dataun;
73 };
74 #define ICMP6_DST_UNREACH_NOROUTE 0
75 #define ICMP6_DST_UNREACH 1
76 #define ICMP6_PACKET_TOO_BIG 2
77 #define ICMP6_TIME_EXCEEDED 3
78 #define ICMP6_DST_UNREACH_ADMIN 1
79 #define ICMP6_DST_UNREACH_ADDR 3
80 #define ICMP6_TIME_EXCEED_TRANSIT 0
81 #define ND_NEIGHBOR_SOLICIT 135
82 #define ND_NEIGHBOR_ADVERT 136
83 #define icmp6_data32 icmp6_dataun.icmp6_un_data32
84 #define icmp6_data16 icmp6_dataun.icmp6_un_data16
85 #define icmp6_data8 icmp6_dataun.icmp6_un_data8
86 #define icmp6_mtu icmp6_data32[0]
87 #endif
88
89 #ifndef HAVE_STRUCT_ND_NEIGHBOR_SOLICIT
90 struct nd_neighbor_solicit {
91         struct icmp6_hdr nd_ns_hdr;
92         struct in6_addr nd_ns_target;
93 };
94 #define ND_OPT_SOURCE_LINKADDR 1
95 #define ND_OPT_TARGET_LINKADDR 2
96 #define nd_ns_type nd_ns_hdr.icmp6_type
97 #define nd_ns_code nd_ns_hdr.icmp6_code
98 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
99 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
100 #endif
101
102 #ifndef HAVE_STRUCT_ND_OPT_HDR
103 struct nd_opt_hdr {
104         uint8_t nd_opt_type;
105         uint8_t nd_opt_len;
106 };
107 #endif
108
109 #endif