blob: e3e6e9aa7619fc9d61fd9fed94ec208ffab45ba7 [file] [log] [blame]
Lorenzo Colittice7c4042013-07-01 17:07:03 +09001/* $NetBSD: icmp6.h,v 1.47 2013/07/01 12:43:15 christos Exp $ */
Steinar H. Gunderson6846a452011-01-20 01:31:36 +01002/* $KAME: icmp6.h,v 1.84 2003/04/23 10:26:51 itojun Exp $ */
3
4
5/*
6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the project nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34/*
35 * Copyright (c) 1982, 1986, 1993
36 * The Regents of the University of California. All rights reserved.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. Neither the name of the University nor the names of its contributors
47 * may be used to endorse or promote products derived from this software
48 * without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
51 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
54 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * SUCH DAMAGE.
61 *
62 * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
63 */
64
65#ifndef _NETINET_ICMP6_H_
66#define _NETINET_ICMP6_H_
67
Elliott Hughes3a040d82013-07-08 11:16:24 -070068#include <netinet/in.h> /* android-added: glibc source compatibility. */
69
Steinar H. Gunderson6846a452011-01-20 01:31:36 +010070#define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)
71 - sizeof(struct icmp6_hdr) */
72
73struct icmp6_hdr {
74 u_int8_t icmp6_type; /* type field */
75 u_int8_t icmp6_code; /* code field */
76 u_int16_t icmp6_cksum; /* checksum field */
77 union {
78 u_int32_t icmp6_un_data32[1]; /* type-specific field */
79 u_int16_t icmp6_un_data16[2]; /* type-specific field */
80 u_int8_t icmp6_un_data8[4]; /* type-specific field */
81 } icmp6_dataun;
82} __packed;
83
84#define icmp6_data32 icmp6_dataun.icmp6_un_data32
85#define icmp6_data16 icmp6_dataun.icmp6_un_data16
86#define icmp6_data8 icmp6_dataun.icmp6_un_data8
87#define icmp6_pptr icmp6_data32[0] /* parameter prob */
88#define icmp6_mtu icmp6_data32[0] /* packet too big */
89#define icmp6_id icmp6_data16[0] /* echo request/reply */
90#define icmp6_seq icmp6_data16[1] /* echo request/reply */
91#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
92
93#define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
94#define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
95#define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
96#define ICMP6_PARAM_PROB 4 /* ip6 header bad */
97
98#define ICMP6_ECHO_REQUEST 128 /* echo service */
99#define ICMP6_ECHO_REPLY 129 /* echo reply */
100#define MLD_LISTENER_QUERY 130 /* multicast listener query */
101#define MLD_LISTENER_REPORT 131 /* multicast listener report */
102#define MLD_LISTENER_DONE 132 /* multicast listener done */
Lorenzo Colittice7c4042013-07-01 17:07:03 +0900103#define MLD_LISTENER_REDUCTION MLD_LISTENER_DONE /* RFC3542 definition */
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100104
105/* RFC2292 decls */
106#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
107#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
108#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
109
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100110#define ND_ROUTER_SOLICIT 133 /* router solicitation */
111#define ND_ROUTER_ADVERT 134 /* router advertisement */
112#define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
113#define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */
114#define ND_REDIRECT 137 /* redirect */
115
116#define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
117
118#define ICMP6_WRUREQUEST 139 /* who are you request */
119#define ICMP6_WRUREPLY 140 /* who are you reply */
120#define ICMP6_FQDN_QUERY 139 /* FQDN query */
121#define ICMP6_FQDN_REPLY 140 /* FQDN reply */
122#define ICMP6_NI_QUERY 139 /* node information request */
123#define ICMP6_NI_REPLY 140 /* node information reply */
Lorenzo Colittice7c4042013-07-01 17:07:03 +0900124#define MLDV2_LISTENER_REPORT 143 /* RFC3810 listener report */
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100125
126/* The definitions below are experimental. TBA */
127#define MLD_MTRACE_RESP 200 /* mtrace response(to sender) */
128#define MLD_MTRACE 201 /* mtrace messages */
129
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100130#define ICMP6_MAXTYPE 201
131
132#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
133#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
134#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
135#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
136#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
137#define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
Lorenzo Colittice7c4042013-07-01 17:07:03 +0900138#define ICMP6_DST_UNREACH_POLICY 5 /* source address failed ingress/egress policy */
139#define ICMP6_DST_UNREACH_REJROUTE 6 /* reject route to destination */
140#define ICMP6_DST_UNREACH_SOURCERT 7 /* error in source routing header */
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100141
142#define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
143#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
144
145#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
146#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
147#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
148
149#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
150
151#define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
152#define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
153#define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
154
155#define ICMP6_NI_SUCCESS 0 /* node information successful reply */
156#define ICMP6_NI_REFUSED 1 /* node information request is refused */
157#define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
158
159#define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
160#define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
161#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
162
163/* Used in kernel only */
164#define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
165#define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
166
167/*
168 * Multicast Listener Discovery
169 */
170struct mld_hdr {
171 struct icmp6_hdr mld_icmp6_hdr;
172 struct in6_addr mld_addr; /* multicast address */
173} __packed;
174
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100175/* shortcut macro definitions */
176#define mld_type mld_icmp6_hdr.icmp6_type
177#define mld_code mld_icmp6_hdr.icmp6_code
178#define mld_cksum mld_icmp6_hdr.icmp6_cksum
179#define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
180#define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
181
182#define MLD_MINLEN 24
183
184/*
185 * Neighbor Discovery
186 */
187
188struct nd_router_solicit { /* router solicitation */
189 struct icmp6_hdr nd_rs_hdr;
190 /* could be followed by options */
191} __packed;
192
193#define nd_rs_type nd_rs_hdr.icmp6_type
194#define nd_rs_code nd_rs_hdr.icmp6_code
195#define nd_rs_cksum nd_rs_hdr.icmp6_cksum
196#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
197
198struct nd_router_advert { /* router advertisement */
199 struct icmp6_hdr nd_ra_hdr;
200 u_int32_t nd_ra_reachable; /* reachable time */
201 u_int32_t nd_ra_retransmit; /* retransmit timer */
202 /* could be followed by options */
203} __packed;
204
205#define nd_ra_type nd_ra_hdr.icmp6_type
206#define nd_ra_code nd_ra_hdr.icmp6_code
207#define nd_ra_cksum nd_ra_hdr.icmp6_cksum
208#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
209#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
210#define ND_RA_FLAG_MANAGED 0x80
211#define ND_RA_FLAG_OTHER 0x40
212#define ND_RA_FLAG_HOME_AGENT 0x20
213
214/*
Lorenzo Colittice7c4042013-07-01 17:07:03 +0900215 * Router preference values based on RFC4191.
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100216 */
217#define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
218
219#define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
220#define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
221#define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
222#define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
223
224#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
225
226struct nd_neighbor_solicit { /* neighbor solicitation */
227 struct icmp6_hdr nd_ns_hdr;
228 struct in6_addr nd_ns_target; /*target address */
229 /* could be followed by options */
230} __packed;
231
232#define nd_ns_type nd_ns_hdr.icmp6_type
233#define nd_ns_code nd_ns_hdr.icmp6_code
234#define nd_ns_cksum nd_ns_hdr.icmp6_cksum
235#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
236
237struct nd_neighbor_advert { /* neighbor advertisement */
238 struct icmp6_hdr nd_na_hdr;
239 struct in6_addr nd_na_target; /* target address */
240 /* could be followed by options */
241} __packed;
242
243#define nd_na_type nd_na_hdr.icmp6_type
244#define nd_na_code nd_na_hdr.icmp6_code
245#define nd_na_cksum nd_na_hdr.icmp6_cksum
246#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
247#if BYTE_ORDER == BIG_ENDIAN
248#define ND_NA_FLAG_ROUTER 0x80000000
249#define ND_NA_FLAG_SOLICITED 0x40000000
250#define ND_NA_FLAG_OVERRIDE 0x20000000
251#else
252#if BYTE_ORDER == LITTLE_ENDIAN
253#define ND_NA_FLAG_ROUTER 0x80
254#define ND_NA_FLAG_SOLICITED 0x40
255#define ND_NA_FLAG_OVERRIDE 0x20
256#endif
257#endif
258
259struct nd_redirect { /* redirect */
260 struct icmp6_hdr nd_rd_hdr;
261 struct in6_addr nd_rd_target; /* target address */
262 struct in6_addr nd_rd_dst; /* destination address */
263 /* could be followed by options */
264} __packed;
265
266#define nd_rd_type nd_rd_hdr.icmp6_type
267#define nd_rd_code nd_rd_hdr.icmp6_code
268#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
269#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
270
271struct nd_opt_hdr { /* Neighbor discovery option header */
272 u_int8_t nd_opt_type;
273 u_int8_t nd_opt_len;
274 /* followed by option specific data*/
275} __packed;
276
277#define ND_OPT_SOURCE_LINKADDR 1
278#define ND_OPT_TARGET_LINKADDR 2
279#define ND_OPT_PREFIX_INFORMATION 3
280#define ND_OPT_REDIRECTED_HEADER 4
281#define ND_OPT_MTU 5
282#define ND_OPT_ADVINTERVAL 7
283#define ND_OPT_HOMEAGENT_INFO 8
284#define ND_OPT_SOURCE_ADDRLIST 9
285#define ND_OPT_TARGET_ADDRLIST 10
Lorenzo Colittice7c4042013-07-01 17:07:03 +0900286#define ND_OPT_MAP 23 /* RFC 5380 */
287#define ND_OPT_ROUTE_INFO 24 /* RFC 4191 */
288#define ND_OPT_RDNSS 25 /* RFC 6016 */
289#define ND_OPT_DNSSL 31 /* RFC 6016 */
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100290
291struct nd_opt_route_info { /* route info */
292 u_int8_t nd_opt_rti_type;
293 u_int8_t nd_opt_rti_len;
294 u_int8_t nd_opt_rti_prefixlen;
295 u_int8_t nd_opt_rti_flags;
296 u_int32_t nd_opt_rti_lifetime;
297 /* prefix follows */
298};
299
300struct nd_opt_prefix_info { /* prefix information */
301 u_int8_t nd_opt_pi_type;
302 u_int8_t nd_opt_pi_len;
303 u_int8_t nd_opt_pi_prefix_len;
304 u_int8_t nd_opt_pi_flags_reserved;
305 u_int32_t nd_opt_pi_valid_time;
306 u_int32_t nd_opt_pi_preferred_time;
307 u_int32_t nd_opt_pi_reserved2;
308 struct in6_addr nd_opt_pi_prefix;
309} __packed;
310
311#define ND_OPT_PI_FLAG_ONLINK 0x80
312#define ND_OPT_PI_FLAG_AUTO 0x40
313
314struct nd_opt_rd_hdr { /* redirected header */
315 u_int8_t nd_opt_rh_type;
316 u_int8_t nd_opt_rh_len;
317 u_int16_t nd_opt_rh_reserved1;
318 u_int32_t nd_opt_rh_reserved2;
319 /* followed by IP header and data */
320} __packed;
321
322struct nd_opt_mtu { /* MTU option */
323 u_int8_t nd_opt_mtu_type;
324 u_int8_t nd_opt_mtu_len;
325 u_int16_t nd_opt_mtu_reserved;
326 u_int32_t nd_opt_mtu_mtu;
327} __packed;
328
Lorenzo Colittice7c4042013-07-01 17:07:03 +0900329struct nd_opt_rdnss { /* RDNSS option RFC 6106 */
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100330 u_int8_t nd_opt_rdnss_type;
331 u_int8_t nd_opt_rdnss_len;
332 u_int16_t nd_opt_rdnss_reserved;
333 u_int32_t nd_opt_rdnss_lifetime;
334 /* followed by list of IP prefixes */
335} __packed;
336
Lorenzo Colittice7c4042013-07-01 17:07:03 +0900337struct nd_opt_dnssl { /* DNSSL option RFC 6106 */
338 u_int8_t nd_opt_dnssl_type;
339 u_int8_t nd_opt_dnssl_len;
340 u_int16_t nd_opt_dnssl_reserved;
341 u_int32_t nd_opt_dnssl_lifetime;
342 /* followed by list of IP prefixes */
343} __packed;
344
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100345/*
346 * icmp6 namelookup
347 */
348
349struct icmp6_namelookup {
350 struct icmp6_hdr icmp6_nl_hdr;
351 u_int8_t icmp6_nl_nonce[8];
352 int32_t icmp6_nl_ttl;
353#if 0
354 u_int8_t icmp6_nl_len;
355 u_int8_t icmp6_nl_name[3];
356#endif
357 /* could be followed by options */
358} __packed;
359
360/*
361 * icmp6 node information
362 */
363struct icmp6_nodeinfo {
364 struct icmp6_hdr icmp6_ni_hdr;
365 u_int8_t icmp6_ni_nonce[8];
366 /* could be followed by reply data */
367} __packed;
368
Elliott Hughesc2cd33e2013-07-08 15:05:50 -0700369/*
370 * BEGIN android-removed: glibc doesn't have these, and external/ping declares them itself.
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100371#define ni_type icmp6_ni_hdr.icmp6_type
372#define ni_code icmp6_ni_hdr.icmp6_code
373#define ni_cksum icmp6_ni_hdr.icmp6_cksum
374#define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
375#define ni_flags icmp6_ni_hdr.icmp6_data16[1]
Elliott Hughesc2cd33e2013-07-08 15:05:50 -0700376 * END android-removed
377 */
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100378
379#define NI_QTYPE_NOOP 0 /* NOOP */
380#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
381#define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
382#define NI_QTYPE_DNSNAME 2 /* DNS Name */
383#define NI_QTYPE_NODEADDR 3 /* Node Addresses */
384#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
385
386#if BYTE_ORDER == BIG_ENDIAN
387#define NI_SUPTYPE_FLAG_COMPRESS 0x1
388#define NI_FQDN_FLAG_VALIDTTL 0x1
389#elif BYTE_ORDER == LITTLE_ENDIAN
390#define NI_SUPTYPE_FLAG_COMPRESS 0x0100
391#define NI_FQDN_FLAG_VALIDTTL 0x0100
392#endif
393
394#ifdef NAME_LOOKUPS_04
395#if BYTE_ORDER == BIG_ENDIAN
396#define NI_NODEADDR_FLAG_LINKLOCAL 0x1
397#define NI_NODEADDR_FLAG_SITELOCAL 0x2
398#define NI_NODEADDR_FLAG_GLOBAL 0x4
399#define NI_NODEADDR_FLAG_ALL 0x8
400#define NI_NODEADDR_FLAG_TRUNCATE 0x10
401#define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */
402#elif BYTE_ORDER == LITTLE_ENDIAN
403#define NI_NODEADDR_FLAG_LINKLOCAL 0x0100
404#define NI_NODEADDR_FLAG_SITELOCAL 0x0200
405#define NI_NODEADDR_FLAG_GLOBAL 0x0400
406#define NI_NODEADDR_FLAG_ALL 0x0800
407#define NI_NODEADDR_FLAG_TRUNCATE 0x1000
408#define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */
409#endif
410#else /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */
411#if BYTE_ORDER == BIG_ENDIAN
412#define NI_NODEADDR_FLAG_TRUNCATE 0x1
413#define NI_NODEADDR_FLAG_ALL 0x2
414#define NI_NODEADDR_FLAG_COMPAT 0x4
415#define NI_NODEADDR_FLAG_LINKLOCAL 0x8
416#define NI_NODEADDR_FLAG_SITELOCAL 0x10
417#define NI_NODEADDR_FLAG_GLOBAL 0x20
418#define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */
419#elif BYTE_ORDER == LITTLE_ENDIAN
420#define NI_NODEADDR_FLAG_TRUNCATE 0x0100
421#define NI_NODEADDR_FLAG_ALL 0x0200
422#define NI_NODEADDR_FLAG_COMPAT 0x0400
423#define NI_NODEADDR_FLAG_LINKLOCAL 0x0800
424#define NI_NODEADDR_FLAG_SITELOCAL 0x1000
425#define NI_NODEADDR_FLAG_GLOBAL 0x2000
426#define NI_NODEADDR_FLAG_ANYCAST 0x4000 /* just experimental. not in spec */
427#endif
428#endif
429
430struct ni_reply_fqdn {
431 u_int32_t ni_fqdn_ttl; /* TTL */
432 u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
433 u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
434} __packed;
435
436/*
437 * Router Renumbering. as router-renum-08.txt
438 */
439struct icmp6_router_renum { /* router renumbering header */
440 struct icmp6_hdr rr_hdr;
441 u_int8_t rr_segnum;
442 u_int8_t rr_flags;
443 u_int16_t rr_maxdelay;
444 u_int32_t rr_reserved;
445} __packed;
446
447#define ICMP6_RR_FLAGS_TEST 0x80
448#define ICMP6_RR_FLAGS_REQRESULT 0x40
449#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
450#define ICMP6_RR_FLAGS_SPECSITE 0x10
451#define ICMP6_RR_FLAGS_PREVDONE 0x08
452
453#define rr_type rr_hdr.icmp6_type
454#define rr_code rr_hdr.icmp6_code
455#define rr_cksum rr_hdr.icmp6_cksum
456#define rr_seqnum rr_hdr.icmp6_data32[0]
457
458struct rr_pco_match { /* match prefix part */
459 u_int8_t rpm_code;
460 u_int8_t rpm_len;
461 u_int8_t rpm_ordinal;
462 u_int8_t rpm_matchlen;
463 u_int8_t rpm_minlen;
464 u_int8_t rpm_maxlen;
465 u_int16_t rpm_reserved;
466 struct in6_addr rpm_prefix;
467} __packed;
468
469#define RPM_PCO_ADD 1
470#define RPM_PCO_CHANGE 2
471#define RPM_PCO_SETGLOBAL 3
472#define RPM_PCO_MAX 4
473
474struct rr_pco_use { /* use prefix part */
475 u_int8_t rpu_uselen;
476 u_int8_t rpu_keeplen;
477 u_int8_t rpu_ramask;
478 u_int8_t rpu_raflags;
479 u_int32_t rpu_vltime;
480 u_int32_t rpu_pltime;
481 u_int32_t rpu_flags;
482 struct in6_addr rpu_prefix;
483} __packed;
484#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
485#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
486
487#if BYTE_ORDER == BIG_ENDIAN
488#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
489#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
490#elif BYTE_ORDER == LITTLE_ENDIAN
491#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
492#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
493#endif
494
495struct rr_result { /* router renumbering result message */
496 u_int16_t rrr_flags;
497 u_int8_t rrr_ordinal;
498 u_int8_t rrr_matchedlen;
499 u_int32_t rrr_ifid;
500 struct in6_addr rrr_prefix;
501} __packed;
502#if BYTE_ORDER == BIG_ENDIAN
503#define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
504#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
505#elif BYTE_ORDER == LITTLE_ENDIAN
506#define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
507#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
508#endif
509
510/*
511 * icmp6 filter structures.
512 */
513
514struct icmp6_filter {
515 u_int32_t icmp6_filt[8];
516};
517
Lorenzo Colittibfc6a592013-07-03 15:42:06 +0900518/*
519 * BEGIN android-changed
520 * Linux and *BSD kernels use opposite values to indicate pass/block in ICMPv6
521 * filters, and assign a different value to the ICMP6_FILTER sockopt.
522 */
523#define ICMP6_FILTER 1
524
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100525#define ICMP6_FILTER_SETPASSALL(filterp) \
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100526 (void)memset(filterp, 0x00, sizeof(struct icmp6_filter))
Lorenzo Colittibfc6a592013-07-03 15:42:06 +0900527#define ICMP6_FILTER_SETBLOCKALL(filterp) \
528 (void)memset(filterp, 0xff, sizeof(struct icmp6_filter))
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100529#define ICMP6_FILTER_SETPASS(type, filterp) \
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100530 (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
Lorenzo Colittibfc6a592013-07-03 15:42:06 +0900531#define ICMP6_FILTER_SETBLOCK(type, filterp) \
532 (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100533#define ICMP6_FILTER_WILLPASS(type, filterp) \
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100534 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
Lorenzo Colittibfc6a592013-07-03 15:42:06 +0900535#define ICMP6_FILTER_WILLBLOCK(type, filterp) \
536 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
537/*
538 * END android-changed
539 */
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100540
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100541#endif /* !_NETINET_ICMP6_H_ */