3 * ND6 protocol definitions
7 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
10 * Redistribution and use in source and binary forms, with or without modification,
11 * are permitted provided that the following conditions are met:
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * 3. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
22 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
24 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32 * This file is part of the lwIP TCP/IP stack.
34 * Author: Adam Dunkels <adam@sics.se>
37 #ifndef LWIP_HDR_PROT_ND6_H
38 #define LWIP_HDR_PROT_ND6_H
40 #include "lwip/arch.h"
41 #include "lwip/ip6_addr.h"
42 #include "lwip/prot/ip6.h"
48 /** Neighbor solicitation message header. */
49 #ifdef PACK_STRUCT_USE_INCLUDES
50 # include "arch/bpstruct.h"
54 PACK_STRUCT_FLD_8(u8_t type);
55 PACK_STRUCT_FLD_8(u8_t code);
56 PACK_STRUCT_FIELD(u16_t chksum);
57 PACK_STRUCT_FIELD(u32_t reserved);
58 PACK_STRUCT_FLD_S(ip6_addr_p_t target_address);
62 #ifdef PACK_STRUCT_USE_INCLUDES
63 # include "arch/epstruct.h"
66 /** Neighbor advertisement message header. */
67 #ifdef PACK_STRUCT_USE_INCLUDES
68 # include "arch/bpstruct.h"
72 PACK_STRUCT_FLD_8(u8_t type);
73 PACK_STRUCT_FLD_8(u8_t code);
74 PACK_STRUCT_FIELD(u16_t chksum);
75 PACK_STRUCT_FLD_8(u8_t flags);
76 PACK_STRUCT_FLD_8(u8_t reserved[3]);
77 PACK_STRUCT_FLD_S(ip6_addr_p_t target_address);
81 #ifdef PACK_STRUCT_USE_INCLUDES
82 # include "arch/epstruct.h"
84 #define ND6_FLAG_ROUTER (0x80)
85 #define ND6_FLAG_SOLICITED (0x40)
86 #define ND6_FLAG_OVERRIDE (0x20)
88 /** Router solicitation message header. */
89 #ifdef PACK_STRUCT_USE_INCLUDES
90 # include "arch/bpstruct.h"
94 PACK_STRUCT_FLD_8(u8_t type);
95 PACK_STRUCT_FLD_8(u8_t code);
96 PACK_STRUCT_FIELD(u16_t chksum);
97 PACK_STRUCT_FIELD(u32_t reserved);
101 #ifdef PACK_STRUCT_USE_INCLUDES
102 # include "arch/epstruct.h"
105 /** Router advertisement message header. */
106 #define ND6_RA_FLAG_MANAGED_ADDR_CONFIG (0x80)
107 #define ND6_RA_FLAG_OTHER_CONFIG (0x40)
108 #define ND6_RA_FLAG_HOME_AGENT (0x20)
109 #define ND6_RA_PREFERENCE_MASK (0x18)
110 #define ND6_RA_PREFERENCE_HIGH (0x08)
111 #define ND6_RA_PREFERENCE_MEDIUM (0x00)
112 #define ND6_RA_PREFERENCE_LOW (0x18)
113 #define ND6_RA_PREFERENCE_DISABLED (0x10)
114 #ifdef PACK_STRUCT_USE_INCLUDES
115 # include "arch/bpstruct.h"
119 PACK_STRUCT_FLD_8(u8_t type);
120 PACK_STRUCT_FLD_8(u8_t code);
121 PACK_STRUCT_FIELD(u16_t chksum);
122 PACK_STRUCT_FLD_8(u8_t current_hop_limit);
123 PACK_STRUCT_FLD_8(u8_t flags);
124 PACK_STRUCT_FIELD(u16_t router_lifetime);
125 PACK_STRUCT_FIELD(u32_t reachable_time);
126 PACK_STRUCT_FIELD(u32_t retrans_timer);
127 /* Options follow. */
128 } PACK_STRUCT_STRUCT;
130 #ifdef PACK_STRUCT_USE_INCLUDES
131 # include "arch/epstruct.h"
134 /** Redirect message header. */
135 #ifdef PACK_STRUCT_USE_INCLUDES
136 # include "arch/bpstruct.h"
139 struct redirect_header {
140 PACK_STRUCT_FLD_8(u8_t type);
141 PACK_STRUCT_FLD_8(u8_t code);
142 PACK_STRUCT_FIELD(u16_t chksum);
143 PACK_STRUCT_FIELD(u32_t reserved);
144 PACK_STRUCT_FLD_S(ip6_addr_p_t target_address);
145 PACK_STRUCT_FLD_S(ip6_addr_p_t destination_address);
146 /* Options follow. */
147 } PACK_STRUCT_STRUCT;
149 #ifdef PACK_STRUCT_USE_INCLUDES
150 # include "arch/epstruct.h"
153 /** Link-layer address option. */
154 #define ND6_OPTION_TYPE_SOURCE_LLADDR (0x01)
155 #define ND6_OPTION_TYPE_TARGET_LLADDR (0x02)
156 #ifdef PACK_STRUCT_USE_INCLUDES
157 # include "arch/bpstruct.h"
160 struct lladdr_option {
161 PACK_STRUCT_FLD_8(u8_t type);
162 PACK_STRUCT_FLD_8(u8_t length);
163 PACK_STRUCT_FLD_8(u8_t addr[NETIF_MAX_HWADDR_LEN]);
164 } PACK_STRUCT_STRUCT;
166 #ifdef PACK_STRUCT_USE_INCLUDES
167 # include "arch/epstruct.h"
170 /** The address field is variable and not fixed in length, use the
171 * appropriate macros when accessing the length field or calculating
174 #define __OFFSETOF(t, m) ((size_t)(&(((t *)0)->m)))
175 #define __ROUND_UP(n, m) ((((n) + ((m) - 1)) / (m)) * (m))
176 #define ND6_LLADDR_OPTION_LENGTH_SHIFT 3
177 #define ND6_LLADDR_OPTION_LENGTH_SIZE (1 << ND6_LLADDR_OPTION_LENGTH_SHIFT)
178 #define ND6_LLADDR_OPTION_LENGTH_MASK (ND6_LLADDR_OPTION_LENGTH_SIZE - 1)
179 #define ND6_LLADDR_OPTION_LENGTH_ENCODE(hwlen) (__ROUND_UP(hwlen, ND6_LLADDR_OPTION_LENGTH_SIZE) >> ND6_LLADDR_OPTION_LENGTH_SHIFT)
180 #define ND6_LLADDR_OPTION_LENGTH_DECODE(value) ((value) << ND6_LLADDR_OPTION_LENGTH_SHIFT)
181 #define ND6_LLADDR_OPTION_SIZE(hwlen) (__OFFSETOF(struct lladdr_option, addr) + (hwlen))
183 /** Prefix information option. */
184 #define ND6_OPTION_TYPE_PREFIX_INFO (0x03)
185 #define ND6_PREFIX_FLAG_ON_LINK (0x80)
186 #define ND6_PREFIX_FLAG_AUTONOMOUS (0x40)
187 #define ND6_PREFIX_FLAG_ROUTER_ADDRESS (0x20)
188 #define ND6_PREFIX_FLAG_SITE_PREFIX (0x10)
189 #ifdef PACK_STRUCT_USE_INCLUDES
190 # include "arch/bpstruct.h"
193 struct prefix_option {
194 PACK_STRUCT_FLD_8(u8_t type);
195 PACK_STRUCT_FLD_8(u8_t length);
196 PACK_STRUCT_FLD_8(u8_t prefix_length);
197 PACK_STRUCT_FLD_8(u8_t flags);
198 PACK_STRUCT_FIELD(u32_t valid_lifetime);
199 PACK_STRUCT_FIELD(u32_t preferred_lifetime);
200 PACK_STRUCT_FLD_8(u8_t reserved2[3]);
201 PACK_STRUCT_FLD_8(u8_t site_prefix_length);
202 PACK_STRUCT_FLD_S(ip6_addr_p_t prefix);
203 } PACK_STRUCT_STRUCT;
205 #ifdef PACK_STRUCT_USE_INCLUDES
206 # include "arch/epstruct.h"
209 /** Redirected header option. */
210 #define ND6_OPTION_TYPE_REDIR_HDR (0x04)
211 #ifdef PACK_STRUCT_USE_INCLUDES
212 # include "arch/bpstruct.h"
215 struct redirected_header_option {
216 PACK_STRUCT_FLD_8(u8_t type);
217 PACK_STRUCT_FLD_8(u8_t length);
218 PACK_STRUCT_FLD_8(u8_t reserved[6]);
219 /* Portion of redirected packet follows. */
220 /* PACK_STRUCT_FLD_8(u8_t redirected[8]); */
221 } PACK_STRUCT_STRUCT;
223 #ifdef PACK_STRUCT_USE_INCLUDES
224 # include "arch/epstruct.h"
228 #define ND6_OPTION_TYPE_MTU (0x05)
229 #ifdef PACK_STRUCT_USE_INCLUDES
230 # include "arch/bpstruct.h"
234 PACK_STRUCT_FLD_8(u8_t type);
235 PACK_STRUCT_FLD_8(u8_t length);
236 PACK_STRUCT_FIELD(u16_t reserved);
237 PACK_STRUCT_FIELD(u32_t mtu);
238 } PACK_STRUCT_STRUCT;
240 #ifdef PACK_STRUCT_USE_INCLUDES
241 # include "arch/epstruct.h"
244 /** Route information option. */
245 #define ND6_OPTION_TYPE_ROUTE_INFO (24)
246 #ifdef PACK_STRUCT_USE_INCLUDES
247 # include "arch/bpstruct.h"
250 struct route_option {
251 PACK_STRUCT_FLD_8(u8_t type);
252 PACK_STRUCT_FLD_8(u8_t length);
253 PACK_STRUCT_FLD_8(u8_t prefix_length);
254 PACK_STRUCT_FLD_8(u8_t preference);
255 PACK_STRUCT_FIELD(u32_t route_lifetime);
256 PACK_STRUCT_FLD_S(ip6_addr_p_t prefix);
257 } PACK_STRUCT_STRUCT;
259 #ifdef PACK_STRUCT_USE_INCLUDES
260 # include "arch/epstruct.h"
263 /** Recursive DNS Server Option. */
264 #if LWIP_ND6_RDNSS_MAX_DNS_SERVERS
265 #define LWIP_RDNSS_OPTION_MAX_SERVERS LWIP_ND6_RDNSS_MAX_DNS_SERVERS
267 #define LWIP_RDNSS_OPTION_MAX_SERVERS 1
269 #define ND6_OPTION_TYPE_RDNSS (25)
270 #ifdef PACK_STRUCT_USE_INCLUDES
271 # include "arch/bpstruct.h"
274 struct rdnss_option {
275 PACK_STRUCT_FLD_8(u8_t type);
276 PACK_STRUCT_FLD_8(u8_t length);
277 PACK_STRUCT_FIELD(u16_t reserved);
278 PACK_STRUCT_FIELD(u32_t lifetime);
279 PACK_STRUCT_FLD_S(ip6_addr_p_t rdnss_address[LWIP_RDNSS_OPTION_MAX_SERVERS]);
280 } PACK_STRUCT_STRUCT;
282 #ifdef PACK_STRUCT_USE_INCLUDES
283 # include "arch/epstruct.h"
290 #endif /* LWIP_HDR_PROT_ND6_H */