Fix spelling errors.
[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-2012 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 #ifndef AF_INET6
25 #define AF_INET6 10
26 #endif
27
28 #ifndef IPPROTO_ICMPV6
29 #define IPPROTO_ICMPV6 58
30 #endif
31
32 #ifndef HAVE_STRUCT_IN6_ADDR
33 struct in6_addr {
34         union {
35                 uint8_t u6_addr8[16];
36                 uint16_t u6_addr16[8];
37                 uint32_t u6_addr32[4];
38         } in6_u;
39 } __attribute__((__packed__));
40 #define s6_addr in6_u.u6_addr8
41 #define s6_addr16 in6_u.u6_addr16
42 #define s6_addr32 in6_u.u6_addr32
43 #endif
44
45 #ifndef HAVE_STRUCT_SOCKADDR_IN6
46 struct sockaddr_in6 {
47         uint16_t sin6_family;
48         uint16_t sin6_port;
49         uint32_t sin6_flowinfo;
50         struct in6_addr sin6_addr;
51         uint32_t sin6_scope_id;
52 } __attribute__((__packed__));
53 #endif
54
55 #ifndef IN6_IS_ADDR_V4MAPPED
56 #define IN6_IS_ADDR_V4MAPPED(a) \
57         ((((const uint32_t *) (a))[0] == 0) \
58          && (((const uint32_t *) (a))[1] == 0) \
59          && (((const uint32_t *) (a))[2] == htonl (0xffff)))
60 #endif
61
62 #ifndef HAVE_STRUCT_IP6_HDR
63 struct ip6_hdr {
64         union {
65                 struct ip6_hdrctl {
66                         uint32_t ip6_un1_flow;
67                         uint16_t ip6_un1_plen;
68                         uint8_t ip6_un1_nxt;
69                         uint8_t ip6_un1_hlim;
70                 } ip6_un1;
71                 uint8_t ip6_un2_vfc;
72         } ip6_ctlun;
73         struct in6_addr ip6_src;
74         struct in6_addr ip6_dst;
75 } __attribute__((__packed__));
76 #define ip6_vfc ip6_ctlun.ip6_un2_vfc
77 #define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
78 #define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
79 #define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
80 #define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
81 #define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
82 #endif
83
84 #ifndef HAVE_STRUCT_ICMP6_HDR
85 struct icmp6_hdr {
86         uint8_t icmp6_type;
87         uint8_t icmp6_code;
88         uint16_t icmp6_cksum;
89         union {
90                 uint32_t icmp6_un_data32[1];
91                 uint16_t icmp6_un_data16[2];
92                 uint8_t icmp6_un_data8[4];
93         } icmp6_dataun;
94 } __attribute__((__packed__));
95 #define ICMP6_DST_UNREACH_NOROUTE 0
96 #define ICMP6_DST_UNREACH 1
97 #define ICMP6_PACKET_TOO_BIG 2
98 #define ICMP6_TIME_EXCEEDED 3
99 #define ICMP6_DST_UNREACH_ADMIN 1
100 #define ICMP6_DST_UNREACH_ADDR 3
101 #define ICMP6_TIME_EXCEED_TRANSIT 0
102 #define ND_NEIGHBOR_SOLICIT 135
103 #define ND_NEIGHBOR_ADVERT 136
104 #define icmp6_data32 icmp6_dataun.icmp6_un_data32
105 #define icmp6_data16 icmp6_dataun.icmp6_un_data16
106 #define icmp6_data8 icmp6_dataun.icmp6_un_data8
107 #define icmp6_mtu icmp6_data32[0]
108 #endif
109
110 #ifndef HAVE_STRUCT_ND_NEIGHBOR_SOLICIT
111 struct nd_neighbor_solicit {
112         struct icmp6_hdr nd_ns_hdr;
113         struct in6_addr nd_ns_target;
114 } __attribute__((__packed__));
115 #define ND_OPT_SOURCE_LINKADDR 1
116 #define ND_OPT_TARGET_LINKADDR 2
117 #define nd_ns_type nd_ns_hdr.icmp6_type
118 #define nd_ns_code nd_ns_hdr.icmp6_code
119 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
120 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
121 #endif
122
123 #ifndef HAVE_STRUCT_ND_OPT_HDR
124 struct nd_opt_hdr {
125         uint8_t nd_opt_type;
126         uint8_t nd_opt_len;
127 } __attribute__((__packed__));
128 #endif
129
130 #endif