blob: eca7b4598bbc8499502c7c7ec45b9edd62050600 [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. */
Elliott Hughes203e13d2016-07-22 14:56:18 -070069#include <sys/cdefs.h>
Elliott Hughes3a040d82013-07-08 11:16:24 -070070
Steinar H. Gunderson6846a452011-01-20 01:31:36 +010071#define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)
72 - sizeof(struct icmp6_hdr) */
73
74struct icmp6_hdr {
75 u_int8_t icmp6_type; /* type field */
76 u_int8_t icmp6_code; /* code field */
77 u_int16_t icmp6_cksum; /* checksum field */
78 union {
79 u_int32_t icmp6_un_data32[1]; /* type-specific field */
80 u_int16_t icmp6_un_data16[2]; /* type-specific field */
81 u_int8_t icmp6_un_data8[4]; /* type-specific field */
82 } icmp6_dataun;
83} __packed;
84
85#define icmp6_data32 icmp6_dataun.icmp6_un_data32
86#define icmp6_data16 icmp6_dataun.icmp6_un_data16
87#define icmp6_data8 icmp6_dataun.icmp6_un_data8
88#define icmp6_pptr icmp6_data32[0] /* parameter prob */
89#define icmp6_mtu icmp6_data32[0] /* packet too big */
90#define icmp6_id icmp6_data16[0] /* echo request/reply */
91#define icmp6_seq icmp6_data16[1] /* echo request/reply */
92#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
93
94#define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
95#define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
96#define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
97#define ICMP6_PARAM_PROB 4 /* ip6 header bad */
98
99#define ICMP6_ECHO_REQUEST 128 /* echo service */
100#define ICMP6_ECHO_REPLY 129 /* echo reply */
101#define MLD_LISTENER_QUERY 130 /* multicast listener query */
102#define MLD_LISTENER_REPORT 131 /* multicast listener report */
103#define MLD_LISTENER_DONE 132 /* multicast listener done */
Lorenzo Colittice7c4042013-07-01 17:07:03 +0900104#define MLD_LISTENER_REDUCTION MLD_LISTENER_DONE /* RFC3542 definition */
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100105
106/* RFC2292 decls */
107#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
108#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
109#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
110
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100111#define ND_ROUTER_SOLICIT 133 /* router solicitation */
112#define ND_ROUTER_ADVERT 134 /* router advertisement */
113#define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
114#define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */
115#define ND_REDIRECT 137 /* redirect */
116
117#define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
118
119#define ICMP6_WRUREQUEST 139 /* who are you request */
120#define ICMP6_WRUREPLY 140 /* who are you reply */
121#define ICMP6_FQDN_QUERY 139 /* FQDN query */
122#define ICMP6_FQDN_REPLY 140 /* FQDN reply */
123#define ICMP6_NI_QUERY 139 /* node information request */
124#define ICMP6_NI_REPLY 140 /* node information reply */
Lorenzo Colittice7c4042013-07-01 17:07:03 +0900125#define MLDV2_LISTENER_REPORT 143 /* RFC3810 listener report */
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100126
127/* The definitions below are experimental. TBA */
128#define MLD_MTRACE_RESP 200 /* mtrace response(to sender) */
129#define MLD_MTRACE 201 /* mtrace messages */
130
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100131#define ICMP6_MAXTYPE 201
132
133#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
134#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
135#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
136#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
137#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
138#define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
Lorenzo Colittice7c4042013-07-01 17:07:03 +0900139#define ICMP6_DST_UNREACH_POLICY 5 /* source address failed ingress/egress policy */
140#define ICMP6_DST_UNREACH_REJROUTE 6 /* reject route to destination */
141#define ICMP6_DST_UNREACH_SOURCERT 7 /* error in source routing header */
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100142
143#define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
144#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
145
146#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
147#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
148#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
149
150#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
151
152#define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
153#define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
154#define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
155
156#define ICMP6_NI_SUCCESS 0 /* node information successful reply */
157#define ICMP6_NI_REFUSED 1 /* node information request is refused */
158#define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
159
160#define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
161#define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
162#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
163
164/* Used in kernel only */
165#define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
166#define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
167
168/*
169 * Multicast Listener Discovery
170 */
171struct mld_hdr {
172 struct icmp6_hdr mld_icmp6_hdr;
173 struct in6_addr mld_addr; /* multicast address */
174} __packed;
175
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100176/* shortcut macro definitions */
177#define mld_type mld_icmp6_hdr.icmp6_type
178#define mld_code mld_icmp6_hdr.icmp6_code
179#define mld_cksum mld_icmp6_hdr.icmp6_cksum
180#define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
181#define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
182
183#define MLD_MINLEN 24
184
185/*
186 * Neighbor Discovery
187 */
188
189struct nd_router_solicit { /* router solicitation */
190 struct icmp6_hdr nd_rs_hdr;
191 /* could be followed by options */
192} __packed;
193
194#define nd_rs_type nd_rs_hdr.icmp6_type
195#define nd_rs_code nd_rs_hdr.icmp6_code
196#define nd_rs_cksum nd_rs_hdr.icmp6_cksum
197#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
198
199struct nd_router_advert { /* router advertisement */
200 struct icmp6_hdr nd_ra_hdr;
201 u_int32_t nd_ra_reachable; /* reachable time */
202 u_int32_t nd_ra_retransmit; /* retransmit timer */
203 /* could be followed by options */
204} __packed;
205
206#define nd_ra_type nd_ra_hdr.icmp6_type
207#define nd_ra_code nd_ra_hdr.icmp6_code
208#define nd_ra_cksum nd_ra_hdr.icmp6_cksum
209#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
210#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
211#define ND_RA_FLAG_MANAGED 0x80
212#define ND_RA_FLAG_OTHER 0x40
213#define ND_RA_FLAG_HOME_AGENT 0x20
214
215/*
Lorenzo Colittice7c4042013-07-01 17:07:03 +0900216 * Router preference values based on RFC4191.
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100217 */
218#define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
219
220#define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
221#define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
222#define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
223#define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
224
225#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
226
227struct nd_neighbor_solicit { /* neighbor solicitation */
228 struct icmp6_hdr nd_ns_hdr;
229 struct in6_addr nd_ns_target; /*target address */
230 /* could be followed by options */
231} __packed;
232
233#define nd_ns_type nd_ns_hdr.icmp6_type
234#define nd_ns_code nd_ns_hdr.icmp6_code
235#define nd_ns_cksum nd_ns_hdr.icmp6_cksum
236#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
237
238struct nd_neighbor_advert { /* neighbor advertisement */
239 struct icmp6_hdr nd_na_hdr;
240 struct in6_addr nd_na_target; /* target address */
241 /* could be followed by options */
242} __packed;
243
244#define nd_na_type nd_na_hdr.icmp6_type
245#define nd_na_code nd_na_hdr.icmp6_code
246#define nd_na_cksum nd_na_hdr.icmp6_cksum
247#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
248#if BYTE_ORDER == BIG_ENDIAN
249#define ND_NA_FLAG_ROUTER 0x80000000
250#define ND_NA_FLAG_SOLICITED 0x40000000
251#define ND_NA_FLAG_OVERRIDE 0x20000000
252#else
253#if BYTE_ORDER == LITTLE_ENDIAN
254#define ND_NA_FLAG_ROUTER 0x80
255#define ND_NA_FLAG_SOLICITED 0x40
256#define ND_NA_FLAG_OVERRIDE 0x20
257#endif
258#endif
259
260struct nd_redirect { /* redirect */
261 struct icmp6_hdr nd_rd_hdr;
262 struct in6_addr nd_rd_target; /* target address */
263 struct in6_addr nd_rd_dst; /* destination address */
264 /* could be followed by options */
265} __packed;
266
267#define nd_rd_type nd_rd_hdr.icmp6_type
268#define nd_rd_code nd_rd_hdr.icmp6_code
269#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
270#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
271
272struct nd_opt_hdr { /* Neighbor discovery option header */
273 u_int8_t nd_opt_type;
274 u_int8_t nd_opt_len;
275 /* followed by option specific data*/
276} __packed;
277
278#define ND_OPT_SOURCE_LINKADDR 1
279#define ND_OPT_TARGET_LINKADDR 2
280#define ND_OPT_PREFIX_INFORMATION 3
281#define ND_OPT_REDIRECTED_HEADER 4
282#define ND_OPT_MTU 5
283#define ND_OPT_ADVINTERVAL 7
284#define ND_OPT_HOMEAGENT_INFO 8
285#define ND_OPT_SOURCE_ADDRLIST 9
286#define ND_OPT_TARGET_ADDRLIST 10
Lorenzo Colittice7c4042013-07-01 17:07:03 +0900287#define ND_OPT_MAP 23 /* RFC 5380 */
288#define ND_OPT_ROUTE_INFO 24 /* RFC 4191 */
289#define ND_OPT_RDNSS 25 /* RFC 6016 */
290#define ND_OPT_DNSSL 31 /* RFC 6016 */
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100291
292struct nd_opt_route_info { /* route info */
293 u_int8_t nd_opt_rti_type;
294 u_int8_t nd_opt_rti_len;
295 u_int8_t nd_opt_rti_prefixlen;
296 u_int8_t nd_opt_rti_flags;
297 u_int32_t nd_opt_rti_lifetime;
298 /* prefix follows */
299};
300
301struct nd_opt_prefix_info { /* prefix information */
302 u_int8_t nd_opt_pi_type;
303 u_int8_t nd_opt_pi_len;
304 u_int8_t nd_opt_pi_prefix_len;
305 u_int8_t nd_opt_pi_flags_reserved;
306 u_int32_t nd_opt_pi_valid_time;
307 u_int32_t nd_opt_pi_preferred_time;
308 u_int32_t nd_opt_pi_reserved2;
309 struct in6_addr nd_opt_pi_prefix;
310} __packed;
311
312#define ND_OPT_PI_FLAG_ONLINK 0x80
313#define ND_OPT_PI_FLAG_AUTO 0x40
314
315struct nd_opt_rd_hdr { /* redirected header */
316 u_int8_t nd_opt_rh_type;
317 u_int8_t nd_opt_rh_len;
318 u_int16_t nd_opt_rh_reserved1;
319 u_int32_t nd_opt_rh_reserved2;
320 /* followed by IP header and data */
321} __packed;
322
323struct nd_opt_mtu { /* MTU option */
324 u_int8_t nd_opt_mtu_type;
325 u_int8_t nd_opt_mtu_len;
326 u_int16_t nd_opt_mtu_reserved;
327 u_int32_t nd_opt_mtu_mtu;
328} __packed;
329
Lorenzo Colittice7c4042013-07-01 17:07:03 +0900330struct nd_opt_rdnss { /* RDNSS option RFC 6106 */
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100331 u_int8_t nd_opt_rdnss_type;
332 u_int8_t nd_opt_rdnss_len;
333 u_int16_t nd_opt_rdnss_reserved;
334 u_int32_t nd_opt_rdnss_lifetime;
335 /* followed by list of IP prefixes */
336} __packed;
337
Lorenzo Colittice7c4042013-07-01 17:07:03 +0900338struct nd_opt_dnssl { /* DNSSL option RFC 6106 */
339 u_int8_t nd_opt_dnssl_type;
340 u_int8_t nd_opt_dnssl_len;
341 u_int16_t nd_opt_dnssl_reserved;
342 u_int32_t nd_opt_dnssl_lifetime;
343 /* followed by list of IP prefixes */
344} __packed;
345
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100346/*
347 * icmp6 namelookup
348 */
349
350struct icmp6_namelookup {
351 struct icmp6_hdr icmp6_nl_hdr;
352 u_int8_t icmp6_nl_nonce[8];
353 int32_t icmp6_nl_ttl;
354#if 0
355 u_int8_t icmp6_nl_len;
356 u_int8_t icmp6_nl_name[3];
357#endif
358 /* could be followed by options */
359} __packed;
360
361/*
362 * icmp6 node information
363 */
364struct icmp6_nodeinfo {
365 struct icmp6_hdr icmp6_ni_hdr;
366 u_int8_t icmp6_ni_nonce[8];
367 /* could be followed by reply data */
368} __packed;
369
Elliott Hughesc2cd33e2013-07-08 15:05:50 -0700370/*
371 * BEGIN android-removed: glibc doesn't have these, and external/ping declares them itself.
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100372#define ni_type icmp6_ni_hdr.icmp6_type
373#define ni_code icmp6_ni_hdr.icmp6_code
374#define ni_cksum icmp6_ni_hdr.icmp6_cksum
375#define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
376#define ni_flags icmp6_ni_hdr.icmp6_data16[1]
Elliott Hughesc2cd33e2013-07-08 15:05:50 -0700377 * END android-removed
378 */
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100379
380#define NI_QTYPE_NOOP 0 /* NOOP */
381#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
382#define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
383#define NI_QTYPE_DNSNAME 2 /* DNS Name */
384#define NI_QTYPE_NODEADDR 3 /* Node Addresses */
385#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
386
387#if BYTE_ORDER == BIG_ENDIAN
388#define NI_SUPTYPE_FLAG_COMPRESS 0x1
389#define NI_FQDN_FLAG_VALIDTTL 0x1
390#elif BYTE_ORDER == LITTLE_ENDIAN
391#define NI_SUPTYPE_FLAG_COMPRESS 0x0100
392#define NI_FQDN_FLAG_VALIDTTL 0x0100
393#endif
394
395#ifdef NAME_LOOKUPS_04
396#if BYTE_ORDER == BIG_ENDIAN
397#define NI_NODEADDR_FLAG_LINKLOCAL 0x1
398#define NI_NODEADDR_FLAG_SITELOCAL 0x2
399#define NI_NODEADDR_FLAG_GLOBAL 0x4
400#define NI_NODEADDR_FLAG_ALL 0x8
401#define NI_NODEADDR_FLAG_TRUNCATE 0x10
402#define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */
403#elif BYTE_ORDER == LITTLE_ENDIAN
404#define NI_NODEADDR_FLAG_LINKLOCAL 0x0100
405#define NI_NODEADDR_FLAG_SITELOCAL 0x0200
406#define NI_NODEADDR_FLAG_GLOBAL 0x0400
407#define NI_NODEADDR_FLAG_ALL 0x0800
408#define NI_NODEADDR_FLAG_TRUNCATE 0x1000
409#define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */
410#endif
411#else /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */
412#if BYTE_ORDER == BIG_ENDIAN
413#define NI_NODEADDR_FLAG_TRUNCATE 0x1
414#define NI_NODEADDR_FLAG_ALL 0x2
415#define NI_NODEADDR_FLAG_COMPAT 0x4
416#define NI_NODEADDR_FLAG_LINKLOCAL 0x8
417#define NI_NODEADDR_FLAG_SITELOCAL 0x10
418#define NI_NODEADDR_FLAG_GLOBAL 0x20
419#define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */
420#elif BYTE_ORDER == LITTLE_ENDIAN
421#define NI_NODEADDR_FLAG_TRUNCATE 0x0100
422#define NI_NODEADDR_FLAG_ALL 0x0200
423#define NI_NODEADDR_FLAG_COMPAT 0x0400
424#define NI_NODEADDR_FLAG_LINKLOCAL 0x0800
425#define NI_NODEADDR_FLAG_SITELOCAL 0x1000
426#define NI_NODEADDR_FLAG_GLOBAL 0x2000
427#define NI_NODEADDR_FLAG_ANYCAST 0x4000 /* just experimental. not in spec */
428#endif
429#endif
430
431struct ni_reply_fqdn {
432 u_int32_t ni_fqdn_ttl; /* TTL */
433 u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
434 u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
435} __packed;
436
437/*
438 * Router Renumbering. as router-renum-08.txt
439 */
440struct icmp6_router_renum { /* router renumbering header */
441 struct icmp6_hdr rr_hdr;
442 u_int8_t rr_segnum;
443 u_int8_t rr_flags;
444 u_int16_t rr_maxdelay;
445 u_int32_t rr_reserved;
446} __packed;
447
448#define ICMP6_RR_FLAGS_TEST 0x80
449#define ICMP6_RR_FLAGS_REQRESULT 0x40
450#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
451#define ICMP6_RR_FLAGS_SPECSITE 0x10
452#define ICMP6_RR_FLAGS_PREVDONE 0x08
453
454#define rr_type rr_hdr.icmp6_type
455#define rr_code rr_hdr.icmp6_code
456#define rr_cksum rr_hdr.icmp6_cksum
457#define rr_seqnum rr_hdr.icmp6_data32[0]
458
459struct rr_pco_match { /* match prefix part */
460 u_int8_t rpm_code;
461 u_int8_t rpm_len;
462 u_int8_t rpm_ordinal;
463 u_int8_t rpm_matchlen;
464 u_int8_t rpm_minlen;
465 u_int8_t rpm_maxlen;
466 u_int16_t rpm_reserved;
467 struct in6_addr rpm_prefix;
468} __packed;
469
470#define RPM_PCO_ADD 1
471#define RPM_PCO_CHANGE 2
472#define RPM_PCO_SETGLOBAL 3
473#define RPM_PCO_MAX 4
474
475struct rr_pco_use { /* use prefix part */
476 u_int8_t rpu_uselen;
477 u_int8_t rpu_keeplen;
478 u_int8_t rpu_ramask;
479 u_int8_t rpu_raflags;
480 u_int32_t rpu_vltime;
481 u_int32_t rpu_pltime;
482 u_int32_t rpu_flags;
483 struct in6_addr rpu_prefix;
484} __packed;
485#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
486#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
487
488#if BYTE_ORDER == BIG_ENDIAN
489#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
490#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
491#elif BYTE_ORDER == LITTLE_ENDIAN
492#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
493#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
494#endif
495
496struct rr_result { /* router renumbering result message */
497 u_int16_t rrr_flags;
498 u_int8_t rrr_ordinal;
499 u_int8_t rrr_matchedlen;
500 u_int32_t rrr_ifid;
501 struct in6_addr rrr_prefix;
502} __packed;
503#if BYTE_ORDER == BIG_ENDIAN
504#define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
505#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
506#elif BYTE_ORDER == LITTLE_ENDIAN
507#define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
508#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
509#endif
510
511/*
512 * icmp6 filter structures.
513 */
514
515struct icmp6_filter {
516 u_int32_t icmp6_filt[8];
517};
518
Lorenzo Colittibfc6a592013-07-03 15:42:06 +0900519/*
520 * BEGIN android-changed
521 * Linux and *BSD kernels use opposite values to indicate pass/block in ICMPv6
522 * filters, and assign a different value to the ICMP6_FILTER sockopt.
523 */
524#define ICMP6_FILTER 1
525
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100526#define ICMP6_FILTER_SETPASSALL(filterp) \
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100527 (void)memset(filterp, 0x00, sizeof(struct icmp6_filter))
Lorenzo Colittibfc6a592013-07-03 15:42:06 +0900528#define ICMP6_FILTER_SETBLOCKALL(filterp) \
529 (void)memset(filterp, 0xff, sizeof(struct icmp6_filter))
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100530#define ICMP6_FILTER_SETPASS(type, filterp) \
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100531 (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
Lorenzo Colittibfc6a592013-07-03 15:42:06 +0900532#define ICMP6_FILTER_SETBLOCK(type, filterp) \
533 (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100534#define ICMP6_FILTER_WILLPASS(type, filterp) \
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100535 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
Lorenzo Colittibfc6a592013-07-03 15:42:06 +0900536#define ICMP6_FILTER_WILLBLOCK(type, filterp) \
537 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
538/*
539 * END android-changed
540 */
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100541
Steinar H. Gunderson6846a452011-01-20 01:31:36 +0100542#endif /* !_NETINET_ICMP6_H_ */