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