xref: /f-stack/tools/compat/include/netinet/icmp6.h (revision d4a07e70)
1127dd473Swhl739 /*	$FreeBSD$	*/
2127dd473Swhl739 /*	$KAME: icmp6.h,v 1.46 2001/04/27 15:09:48 itojun Exp $	*/
3127dd473Swhl739 
4127dd473Swhl739 /*-
5*d4a07e70Sfengbojiang  * SPDX-License-Identifier: BSD-3-Clause
6*d4a07e70Sfengbojiang  *
7127dd473Swhl739  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
8127dd473Swhl739  * All rights reserved.
9127dd473Swhl739  *
10127dd473Swhl739  * Redistribution and use in source and binary forms, with or without
11127dd473Swhl739  * modification, are permitted provided that the following conditions
12127dd473Swhl739  * are met:
13127dd473Swhl739  * 1. Redistributions of source code must retain the above copyright
14127dd473Swhl739  *    notice, this list of conditions and the following disclaimer.
15127dd473Swhl739  * 2. Redistributions in binary form must reproduce the above copyright
16127dd473Swhl739  *    notice, this list of conditions and the following disclaimer in the
17127dd473Swhl739  *    documentation and/or other materials provided with the distribution.
18127dd473Swhl739  * 3. Neither the name of the project nor the names of its contributors
19127dd473Swhl739  *    may be used to endorse or promote products derived from this software
20127dd473Swhl739  *    without specific prior written permission.
21127dd473Swhl739  *
22127dd473Swhl739  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
23127dd473Swhl739  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24127dd473Swhl739  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25127dd473Swhl739  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
26127dd473Swhl739  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27127dd473Swhl739  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28127dd473Swhl739  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29127dd473Swhl739  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30127dd473Swhl739  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31127dd473Swhl739  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32127dd473Swhl739  * SUCH DAMAGE.
33127dd473Swhl739  */
34127dd473Swhl739 
35127dd473Swhl739 /*-
36127dd473Swhl739  * Copyright (c) 1982, 1986, 1993
37127dd473Swhl739  *	The Regents of the University of California.  All rights reserved.
38127dd473Swhl739  *
39127dd473Swhl739  * Redistribution and use in source and binary forms, with or without
40127dd473Swhl739  * modification, are permitted provided that the following conditions
41127dd473Swhl739  * are met:
42127dd473Swhl739  * 1. Redistributions of source code must retain the above copyright
43127dd473Swhl739  *    notice, this list of conditions and the following disclaimer.
44127dd473Swhl739  * 2. Redistributions in binary form must reproduce the above copyright
45127dd473Swhl739  *    notice, this list of conditions and the following disclaimer in the
46127dd473Swhl739  *    documentation and/or other materials provided with the distribution.
47*d4a07e70Sfengbojiang  * 3. Neither the name of the University nor the names of its contributors
48127dd473Swhl739  *    may be used to endorse or promote products derived from this software
49127dd473Swhl739  *    without specific prior written permission.
50127dd473Swhl739  *
51127dd473Swhl739  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
52127dd473Swhl739  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53127dd473Swhl739  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54127dd473Swhl739  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
55127dd473Swhl739  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56127dd473Swhl739  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57127dd473Swhl739  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58127dd473Swhl739  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59127dd473Swhl739  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60127dd473Swhl739  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
61127dd473Swhl739  * SUCH DAMAGE.
62127dd473Swhl739  *
63127dd473Swhl739  *	@(#)ip_icmp.h	8.1 (Berkeley) 6/10/93
64127dd473Swhl739  */
65127dd473Swhl739 
66127dd473Swhl739 #ifndef _NETINET_ICMP6_H_
67127dd473Swhl739 #define _NETINET_ICMP6_H_
68127dd473Swhl739 
69127dd473Swhl739 #ifdef FSTACK
70127dd473Swhl739 #define __packed __attribute__((__packed__))
71127dd473Swhl739 #endif
72127dd473Swhl739 
73127dd473Swhl739 #define ICMPV6_PLD_MAXLEN	1232	/* IPV6_MMTU - sizeof(struct ip6_hdr)
74127dd473Swhl739 					   - sizeof(struct icmp6_hdr) */
75127dd473Swhl739 
76127dd473Swhl739 struct icmp6_hdr {
77127dd473Swhl739 	u_int8_t	icmp6_type;	/* type field */
78127dd473Swhl739 	u_int8_t	icmp6_code;	/* code field */
79127dd473Swhl739 	u_int16_t	icmp6_cksum;	/* checksum field */
80127dd473Swhl739 	union {
81127dd473Swhl739 		u_int32_t	icmp6_un_data32[1]; /* type-specific field */
82127dd473Swhl739 		u_int16_t	icmp6_un_data16[2]; /* type-specific field */
83127dd473Swhl739 		u_int8_t	icmp6_un_data8[4];  /* type-specific field */
84127dd473Swhl739 	} icmp6_dataun;
85127dd473Swhl739 } __packed;
86127dd473Swhl739 
87127dd473Swhl739 #define icmp6_data32	icmp6_dataun.icmp6_un_data32
88127dd473Swhl739 #define icmp6_data16	icmp6_dataun.icmp6_un_data16
89127dd473Swhl739 #define icmp6_data8	icmp6_dataun.icmp6_un_data8
90127dd473Swhl739 #define icmp6_pptr	icmp6_data32[0]		/* parameter prob */
91127dd473Swhl739 #define icmp6_mtu	icmp6_data32[0]		/* packet too big */
92127dd473Swhl739 #define icmp6_id	icmp6_data16[0]		/* echo request/reply */
93127dd473Swhl739 #define icmp6_seq	icmp6_data16[1]		/* echo request/reply */
94127dd473Swhl739 #define icmp6_maxdelay	icmp6_data16[0]		/* mcast group membership */
95127dd473Swhl739 
96127dd473Swhl739 #define ICMP6_DST_UNREACH		1	/* dest unreachable, codes: */
97127dd473Swhl739 #define ICMP6_PACKET_TOO_BIG		2	/* packet too big */
98127dd473Swhl739 #define ICMP6_TIME_EXCEEDED		3	/* time exceeded, code: */
99127dd473Swhl739 #define ICMP6_PARAM_PROB		4	/* ip6 header bad */
100127dd473Swhl739 
101127dd473Swhl739 #define ICMP6_ECHO_REQUEST		128	/* echo service */
102127dd473Swhl739 #define ICMP6_ECHO_REPLY		129	/* echo reply */
103127dd473Swhl739 #define MLD_LISTENER_QUERY		130 	/* multicast listener query */
104127dd473Swhl739 #define MLD_LISTENER_REPORT		131	/* multicast listener report */
105127dd473Swhl739 #define MLD_LISTENER_DONE		132	/* multicast listener done */
106127dd473Swhl739 #define MLD_LISTENER_REDUCTION MLD_LISTENER_DONE /* RFC3542 definition */
107127dd473Swhl739 
108127dd473Swhl739 /* RFC2292 decls */
109127dd473Swhl739 #define ICMP6_MEMBERSHIP_QUERY		130	/* group membership query */
110127dd473Swhl739 #define ICMP6_MEMBERSHIP_REPORT		131	/* group membership report */
111127dd473Swhl739 #define ICMP6_MEMBERSHIP_REDUCTION	132	/* group membership termination */
112127dd473Swhl739 
113127dd473Swhl739 #ifndef _KERNEL
114127dd473Swhl739 /* the followings are for backward compatibility to old KAME apps. */
115127dd473Swhl739 #define MLD6_LISTENER_QUERY	MLD_LISTENER_QUERY
116127dd473Swhl739 #define MLD6_LISTENER_REPORT	MLD_LISTENER_REPORT
117127dd473Swhl739 #define MLD6_LISTENER_DONE	MLD_LISTENER_DONE
118127dd473Swhl739 #endif
119127dd473Swhl739 
120127dd473Swhl739 #define ND_ROUTER_SOLICIT		133	/* router solicitation */
121127dd473Swhl739 #define ND_ROUTER_ADVERT		134	/* router advertisement */
122127dd473Swhl739 #define ND_NEIGHBOR_SOLICIT		135	/* neighbor solicitation */
123127dd473Swhl739 #define ND_NEIGHBOR_ADVERT		136	/* neighbor advertisement */
124127dd473Swhl739 #define ND_REDIRECT			137	/* redirect */
125127dd473Swhl739 
126127dd473Swhl739 #define ICMP6_ROUTER_RENUMBERING	138	/* router renumbering */
127127dd473Swhl739 
128127dd473Swhl739 #define ICMP6_WRUREQUEST		139	/* who are you request */
129127dd473Swhl739 #define ICMP6_WRUREPLY			140	/* who are you reply */
130127dd473Swhl739 #define ICMP6_FQDN_QUERY		139	/* FQDN query */
131127dd473Swhl739 #define ICMP6_FQDN_REPLY		140	/* FQDN reply */
132127dd473Swhl739 #define ICMP6_NI_QUERY			139	/* node information request */
133127dd473Swhl739 #define ICMP6_NI_REPLY			140	/* node information reply */
134127dd473Swhl739 #define MLDV2_LISTENER_REPORT		143	/* RFC3810 listener report */
135127dd473Swhl739 
136127dd473Swhl739 /* The definitions below are experimental. TBA */
137127dd473Swhl739 #define MLD_MTRACE_RESP			200	/* mtrace resp (to sender) */
138127dd473Swhl739 #define MLD_MTRACE			201	/* mtrace messages */
139127dd473Swhl739 
140127dd473Swhl739 #ifndef _KERNEL
141127dd473Swhl739 #define MLD6_MTRACE_RESP	MLD_MTRACE_RESP
142127dd473Swhl739 #define MLD6_MTRACE		MLD_MTRACE
143127dd473Swhl739 #endif
144127dd473Swhl739 
145127dd473Swhl739 #define ICMP6_MAXTYPE			201
146127dd473Swhl739 
147127dd473Swhl739 #define ICMP6_DST_UNREACH_NOROUTE	0	/* no route to destination */
148127dd473Swhl739 #define ICMP6_DST_UNREACH_ADMIN	 	1	/* administratively prohibited */
149127dd473Swhl739 #define ICMP6_DST_UNREACH_NOTNEIGHBOR	2	/* not a neighbor(obsolete) */
150127dd473Swhl739 #define ICMP6_DST_UNREACH_BEYONDSCOPE	2	/* beyond scope of source address */
151127dd473Swhl739 #define ICMP6_DST_UNREACH_ADDR		3	/* address unreachable */
152127dd473Swhl739 #define ICMP6_DST_UNREACH_NOPORT	4	/* port unreachable */
153127dd473Swhl739 #define ICMP6_DST_UNREACH_POLICY	5	/* failed ingress/egress policy */
154127dd473Swhl739 #define ICMP6_DST_UNREACH_REJECT	6	/* Reject route to destination */
155127dd473Swhl739 #define ICMP6_DST_UNREACH_SRCROUTE	7	/* Error in source routing header */
156127dd473Swhl739 
157127dd473Swhl739 #define ICMP6_TIME_EXCEED_TRANSIT 	0	/* ttl==0 in transit */
158127dd473Swhl739 #define ICMP6_TIME_EXCEED_REASSEMBLY	1	/* ttl==0 in reass */
159127dd473Swhl739 
160127dd473Swhl739 #define ICMP6_PARAMPROB_HEADER 	 	0	/* erroneous header field */
161127dd473Swhl739 #define ICMP6_PARAMPROB_NEXTHEADER	1	/* unrecognized next header */
162127dd473Swhl739 #define ICMP6_PARAMPROB_OPTION		2	/* unrecognized option */
163127dd473Swhl739 
164127dd473Swhl739 #define ICMP6_INFOMSG_MASK		0x80	/* all informational messages */
165127dd473Swhl739 
166127dd473Swhl739 #define ICMP6_NI_SUBJ_IPV6	0	/* Query Subject is an IPv6 address */
167127dd473Swhl739 #define ICMP6_NI_SUBJ_FQDN	1	/* Query Subject is a Domain name */
168127dd473Swhl739 #define ICMP6_NI_SUBJ_IPV4	2	/* Query Subject is an IPv4 address */
169127dd473Swhl739 
170127dd473Swhl739 #define ICMP6_NI_SUCCESS	0	/* node information successful reply */
171127dd473Swhl739 #define ICMP6_NI_REFUSED	1	/* node information request is refused */
172127dd473Swhl739 #define ICMP6_NI_UNKNOWN	2	/* unknown Qtype */
173127dd473Swhl739 
174127dd473Swhl739 #define ICMP6_ROUTER_RENUMBERING_COMMAND  0	/* rr command */
175127dd473Swhl739 #define ICMP6_ROUTER_RENUMBERING_RESULT   1	/* rr result */
176127dd473Swhl739 #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET   255	/* rr seq num reset */
177127dd473Swhl739 
178127dd473Swhl739 /* Used in kernel only */
179127dd473Swhl739 #define ND_REDIRECT_ONLINK	0	/* redirect to an on-link node */
180127dd473Swhl739 #define ND_REDIRECT_ROUTER	1	/* redirect to a better router */
181127dd473Swhl739 
182127dd473Swhl739 /*
183127dd473Swhl739  * Multicast Listener Discovery
184127dd473Swhl739  */
185127dd473Swhl739 struct mld_hdr {
186127dd473Swhl739 	struct icmp6_hdr	mld_icmp6_hdr;
187127dd473Swhl739 	struct in6_addr		mld_addr; /* multicast address */
188127dd473Swhl739 } __packed;
189127dd473Swhl739 
190127dd473Swhl739 /* definitions to provide backward compatibility to old KAME applications */
191127dd473Swhl739 #ifndef _KERNEL
192127dd473Swhl739 #define mld6_hdr	mld_hdr
193127dd473Swhl739 #define mld6_type	mld_type
194127dd473Swhl739 #define mld6_code	mld_code
195127dd473Swhl739 #define mld6_cksum	mld_cksum
196127dd473Swhl739 #define mld6_maxdelay	mld_maxdelay
197127dd473Swhl739 #define mld6_reserved	mld_reserved
198127dd473Swhl739 #define mld6_addr	mld_addr
199127dd473Swhl739 #endif
200127dd473Swhl739 
201127dd473Swhl739 /* shortcut macro definitions */
202127dd473Swhl739 #define mld_type	mld_icmp6_hdr.icmp6_type
203127dd473Swhl739 #define mld_code	mld_icmp6_hdr.icmp6_code
204127dd473Swhl739 #define mld_cksum	mld_icmp6_hdr.icmp6_cksum
205127dd473Swhl739 #define mld_maxdelay	mld_icmp6_hdr.icmp6_data16[0]
206127dd473Swhl739 #define mld_reserved	mld_icmp6_hdr.icmp6_data16[1]
207127dd473Swhl739 #define mld_v2_reserved	mld_icmp6_hdr.icmp6_data16[0]
208127dd473Swhl739 #define mld_v2_numrecs	mld_icmp6_hdr.icmp6_data16[1]
209127dd473Swhl739 
210127dd473Swhl739 /*
211127dd473Swhl739  * Neighbor Discovery
212127dd473Swhl739  */
213127dd473Swhl739 
214127dd473Swhl739 struct nd_router_solicit {	/* router solicitation */
215127dd473Swhl739 	struct icmp6_hdr 	nd_rs_hdr;
216127dd473Swhl739 	/* could be followed by options */
217127dd473Swhl739 } __packed;
218127dd473Swhl739 
219127dd473Swhl739 #define nd_rs_type	nd_rs_hdr.icmp6_type
220127dd473Swhl739 #define nd_rs_code	nd_rs_hdr.icmp6_code
221127dd473Swhl739 #define nd_rs_cksum	nd_rs_hdr.icmp6_cksum
222127dd473Swhl739 #define nd_rs_reserved	nd_rs_hdr.icmp6_data32[0]
223127dd473Swhl739 
224127dd473Swhl739 struct nd_router_advert {	/* router advertisement */
225127dd473Swhl739 	struct icmp6_hdr	nd_ra_hdr;
226127dd473Swhl739 	u_int32_t		nd_ra_reachable;	/* reachable time */
227127dd473Swhl739 	u_int32_t		nd_ra_retransmit;	/* retransmit timer */
228127dd473Swhl739 	/* could be followed by options */
229127dd473Swhl739 } __packed;
230127dd473Swhl739 
231127dd473Swhl739 #define nd_ra_type		nd_ra_hdr.icmp6_type
232127dd473Swhl739 #define nd_ra_code		nd_ra_hdr.icmp6_code
233127dd473Swhl739 #define nd_ra_cksum		nd_ra_hdr.icmp6_cksum
234127dd473Swhl739 #define nd_ra_curhoplimit	nd_ra_hdr.icmp6_data8[0]
235127dd473Swhl739 #define nd_ra_flags_reserved	nd_ra_hdr.icmp6_data8[1]
236127dd473Swhl739 #define ND_RA_FLAG_MANAGED	0x80
237127dd473Swhl739 #define ND_RA_FLAG_OTHER	0x40
238127dd473Swhl739 #define ND_RA_FLAG_HA		0x20
239127dd473Swhl739 
240127dd473Swhl739 /*
241127dd473Swhl739  * Router preference values based on draft-draves-ipngwg-router-selection-01.
242127dd473Swhl739  * These are non-standard definitions.
243127dd473Swhl739  */
244127dd473Swhl739 #define ND_RA_FLAG_RTPREF_MASK	0x18 /* 00011000 */
245127dd473Swhl739 
246127dd473Swhl739 #define ND_RA_FLAG_RTPREF_HIGH	0x08 /* 00001000 */
247127dd473Swhl739 #define ND_RA_FLAG_RTPREF_MEDIUM	0x00 /* 00000000 */
248127dd473Swhl739 #define ND_RA_FLAG_RTPREF_LOW	0x18 /* 00011000 */
249127dd473Swhl739 #define ND_RA_FLAG_RTPREF_RSV	0x10 /* 00010000 */
250127dd473Swhl739 
251*d4a07e70Sfengbojiang #ifdef EXPERIMENTAL
252*d4a07e70Sfengbojiang #define	ND_RA_FLAG_IPV6_ONLY	0x02 /* draft-ietf-6man-ipv6only-flag */
253*d4a07e70Sfengbojiang #endif
254*d4a07e70Sfengbojiang 
255127dd473Swhl739 #define nd_ra_router_lifetime	nd_ra_hdr.icmp6_data16[1]
256127dd473Swhl739 
257127dd473Swhl739 struct nd_neighbor_solicit {	/* neighbor solicitation */
258127dd473Swhl739 	struct icmp6_hdr	nd_ns_hdr;
259127dd473Swhl739 	struct in6_addr		nd_ns_target;	/*target address */
260127dd473Swhl739 	/* could be followed by options */
261127dd473Swhl739 } __packed;
262127dd473Swhl739 
263127dd473Swhl739 #define nd_ns_type		nd_ns_hdr.icmp6_type
264127dd473Swhl739 #define nd_ns_code		nd_ns_hdr.icmp6_code
265127dd473Swhl739 #define nd_ns_cksum		nd_ns_hdr.icmp6_cksum
266127dd473Swhl739 #define nd_ns_reserved		nd_ns_hdr.icmp6_data32[0]
267127dd473Swhl739 
268127dd473Swhl739 struct nd_neighbor_advert {	/* neighbor advertisement */
269127dd473Swhl739 	struct icmp6_hdr	nd_na_hdr;
270127dd473Swhl739 	struct in6_addr		nd_na_target;	/* target address */
271127dd473Swhl739 	/* could be followed by options */
272127dd473Swhl739 } __packed;
273127dd473Swhl739 
274127dd473Swhl739 #define nd_na_type		nd_na_hdr.icmp6_type
275127dd473Swhl739 #define nd_na_code		nd_na_hdr.icmp6_code
276127dd473Swhl739 #define nd_na_cksum		nd_na_hdr.icmp6_cksum
277127dd473Swhl739 #define nd_na_flags_reserved	nd_na_hdr.icmp6_data32[0]
278127dd473Swhl739 #if BYTE_ORDER == BIG_ENDIAN
279127dd473Swhl739 #define ND_NA_FLAG_ROUTER		0x80000000
280127dd473Swhl739 #define ND_NA_FLAG_SOLICITED		0x40000000
281127dd473Swhl739 #define ND_NA_FLAG_OVERRIDE		0x20000000
282127dd473Swhl739 #else
283127dd473Swhl739 #if BYTE_ORDER == LITTLE_ENDIAN
284127dd473Swhl739 #define ND_NA_FLAG_ROUTER		0x80
285127dd473Swhl739 #define ND_NA_FLAG_SOLICITED		0x40
286127dd473Swhl739 #define ND_NA_FLAG_OVERRIDE		0x20
287127dd473Swhl739 #endif
288127dd473Swhl739 #endif
289127dd473Swhl739 
290127dd473Swhl739 struct nd_redirect {		/* redirect */
291127dd473Swhl739 	struct icmp6_hdr	nd_rd_hdr;
292127dd473Swhl739 	struct in6_addr		nd_rd_target;	/* target address */
293127dd473Swhl739 	struct in6_addr		nd_rd_dst;	/* destination address */
294127dd473Swhl739 	/* could be followed by options */
295127dd473Swhl739 } __packed;
296127dd473Swhl739 
297127dd473Swhl739 #define nd_rd_type		nd_rd_hdr.icmp6_type
298127dd473Swhl739 #define nd_rd_code		nd_rd_hdr.icmp6_code
299127dd473Swhl739 #define nd_rd_cksum		nd_rd_hdr.icmp6_cksum
300127dd473Swhl739 #define nd_rd_reserved		nd_rd_hdr.icmp6_data32[0]
301127dd473Swhl739 
302127dd473Swhl739 struct nd_opt_hdr {		/* Neighbor discovery option header */
303127dd473Swhl739 	u_int8_t	nd_opt_type;
304127dd473Swhl739 	u_int8_t	nd_opt_len;
305127dd473Swhl739 	/* followed by option specific data*/
306127dd473Swhl739 } __packed;
307127dd473Swhl739 
308127dd473Swhl739 #define ND_OPT_SOURCE_LINKADDR		1
309127dd473Swhl739 #define ND_OPT_TARGET_LINKADDR		2
310127dd473Swhl739 #define ND_OPT_PREFIX_INFORMATION	3
311127dd473Swhl739 #define ND_OPT_REDIRECTED_HEADER	4
312127dd473Swhl739 #define ND_OPT_MTU			5
313127dd473Swhl739 #define ND_OPT_NONCE			14	/* RFC 3971 */
314127dd473Swhl739 #define ND_OPT_ROUTE_INFO		24	/* RFC 4191 */
315127dd473Swhl739 #define ND_OPT_RDNSS			25	/* RFC 6106 */
316127dd473Swhl739 #define ND_OPT_DNSSL			31	/* RFC 6106 */
317127dd473Swhl739 #define ND_OPT_MAX			31
318127dd473Swhl739 
319127dd473Swhl739 struct nd_opt_prefix_info {	/* prefix information */
320127dd473Swhl739 	u_int8_t	nd_opt_pi_type;
321127dd473Swhl739 	u_int8_t	nd_opt_pi_len;
322127dd473Swhl739 	u_int8_t	nd_opt_pi_prefix_len;
323127dd473Swhl739 	u_int8_t	nd_opt_pi_flags_reserved;
324127dd473Swhl739 	u_int32_t	nd_opt_pi_valid_time;
325127dd473Swhl739 	u_int32_t	nd_opt_pi_preferred_time;
326127dd473Swhl739 	u_int32_t	nd_opt_pi_reserved2;
327127dd473Swhl739 	struct in6_addr	nd_opt_pi_prefix;
328127dd473Swhl739 } __packed;
329127dd473Swhl739 
330127dd473Swhl739 #define ND_OPT_PI_FLAG_ONLINK		0x80
331127dd473Swhl739 #define ND_OPT_PI_FLAG_AUTO		0x40
332127dd473Swhl739 
333127dd473Swhl739 struct nd_opt_rd_hdr {		/* redirected header */
334127dd473Swhl739 	u_int8_t	nd_opt_rh_type;
335127dd473Swhl739 	u_int8_t	nd_opt_rh_len;
336127dd473Swhl739 	u_int16_t	nd_opt_rh_reserved1;
337127dd473Swhl739 	u_int32_t	nd_opt_rh_reserved2;
338127dd473Swhl739 	/* followed by IP header and data */
339127dd473Swhl739 } __packed;
340127dd473Swhl739 
341127dd473Swhl739 struct nd_opt_mtu {		/* MTU option */
342127dd473Swhl739 	u_int8_t	nd_opt_mtu_type;
343127dd473Swhl739 	u_int8_t	nd_opt_mtu_len;
344127dd473Swhl739 	u_int16_t	nd_opt_mtu_reserved;
345127dd473Swhl739 	u_int32_t	nd_opt_mtu_mtu;
346127dd473Swhl739 } __packed;
347127dd473Swhl739 
348127dd473Swhl739 #define	ND_OPT_NONCE_LEN	((1 * 8) - 2)
349127dd473Swhl739 #if ((ND_OPT_NONCE_LEN + 2) % 8) != 0
350127dd473Swhl739 #error "(ND_OPT_NONCE_LEN + 2) must be a multiple of 8."
351127dd473Swhl739 #endif
352127dd473Swhl739 struct nd_opt_nonce {		/* nonce option */
353127dd473Swhl739 	u_int8_t	nd_opt_nonce_type;
354127dd473Swhl739 	u_int8_t	nd_opt_nonce_len;
355127dd473Swhl739 	u_int8_t	nd_opt_nonce[ND_OPT_NONCE_LEN];
356127dd473Swhl739 } __packed;
357127dd473Swhl739 
358127dd473Swhl739 struct nd_opt_route_info {	/* route info */
359127dd473Swhl739 	u_int8_t	nd_opt_rti_type;
360127dd473Swhl739 	u_int8_t	nd_opt_rti_len;
361127dd473Swhl739 	u_int8_t	nd_opt_rti_prefixlen;
362127dd473Swhl739 	u_int8_t	nd_opt_rti_flags;
363127dd473Swhl739 	u_int32_t	nd_opt_rti_lifetime;
364127dd473Swhl739 	/* prefix follows */
365127dd473Swhl739 } __packed;
366127dd473Swhl739 
367127dd473Swhl739 struct nd_opt_rdnss {		/* RDNSS option (RFC 6106) */
368127dd473Swhl739 	u_int8_t	nd_opt_rdnss_type;
369127dd473Swhl739 	u_int8_t	nd_opt_rdnss_len;
370127dd473Swhl739 	u_int16_t	nd_opt_rdnss_reserved;
371127dd473Swhl739 	u_int32_t	nd_opt_rdnss_lifetime;
372127dd473Swhl739 	/* followed by list of recursive DNS servers */
373127dd473Swhl739 } __packed;
374127dd473Swhl739 
375127dd473Swhl739 struct nd_opt_dnssl {		/* DNSSL option (RFC 6106) */
376127dd473Swhl739 	u_int8_t	nd_opt_dnssl_type;
377127dd473Swhl739 	u_int8_t	nd_opt_dnssl_len;
378127dd473Swhl739 	u_int16_t	nd_opt_dnssl_reserved;
379127dd473Swhl739 	u_int32_t	nd_opt_dnssl_lifetime;
380127dd473Swhl739 	/* followed by list of DNS search domains */
381127dd473Swhl739 } __packed;
382127dd473Swhl739 
383127dd473Swhl739 /*
384127dd473Swhl739  * icmp6 namelookup
385127dd473Swhl739  */
386127dd473Swhl739 
387127dd473Swhl739 struct icmp6_namelookup {
388127dd473Swhl739 	struct icmp6_hdr 	icmp6_nl_hdr;
389127dd473Swhl739 	u_int8_t	icmp6_nl_nonce[8];
390127dd473Swhl739 	int32_t		icmp6_nl_ttl;
391127dd473Swhl739 #if 0
392127dd473Swhl739 	u_int8_t	icmp6_nl_len;
393127dd473Swhl739 	u_int8_t	icmp6_nl_name[3];
394127dd473Swhl739 #endif
395127dd473Swhl739 	/* could be followed by options */
396127dd473Swhl739 } __packed;
397127dd473Swhl739 
398127dd473Swhl739 /*
399127dd473Swhl739  * icmp6 node information
400127dd473Swhl739  */
401127dd473Swhl739 struct icmp6_nodeinfo {
402127dd473Swhl739 	struct icmp6_hdr icmp6_ni_hdr;
403127dd473Swhl739 	u_int8_t icmp6_ni_nonce[8];
404127dd473Swhl739 	/* could be followed by reply data */
405127dd473Swhl739 } __packed;
406127dd473Swhl739 
407127dd473Swhl739 #define ni_type		icmp6_ni_hdr.icmp6_type
408127dd473Swhl739 #define ni_code		icmp6_ni_hdr.icmp6_code
409127dd473Swhl739 #define ni_cksum	icmp6_ni_hdr.icmp6_cksum
410127dd473Swhl739 #define ni_qtype	icmp6_ni_hdr.icmp6_data16[0]
411127dd473Swhl739 #define ni_flags	icmp6_ni_hdr.icmp6_data16[1]
412127dd473Swhl739 
413127dd473Swhl739 #define NI_QTYPE_NOOP		0 /* NOOP  */
414127dd473Swhl739 #define NI_QTYPE_SUPTYPES	1 /* Supported Qtypes */
415127dd473Swhl739 #define NI_QTYPE_FQDN		2 /* FQDN (draft 04) */
416127dd473Swhl739 #define NI_QTYPE_DNSNAME	2 /* DNS Name */
417127dd473Swhl739 #define NI_QTYPE_NODEADDR	3 /* Node Addresses */
418127dd473Swhl739 #define NI_QTYPE_IPV4ADDR	4 /* IPv4 Addresses */
419127dd473Swhl739 
420127dd473Swhl739 #if BYTE_ORDER == BIG_ENDIAN
421127dd473Swhl739 #define NI_SUPTYPE_FLAG_COMPRESS	0x1
422127dd473Swhl739 #define NI_FQDN_FLAG_VALIDTTL		0x1
423127dd473Swhl739 #elif BYTE_ORDER == LITTLE_ENDIAN
424127dd473Swhl739 #define NI_SUPTYPE_FLAG_COMPRESS	0x0100
425127dd473Swhl739 #define NI_FQDN_FLAG_VALIDTTL		0x0100
426127dd473Swhl739 #endif
427127dd473Swhl739 
428127dd473Swhl739 #ifdef NAME_LOOKUPS_04
429127dd473Swhl739 #if BYTE_ORDER == BIG_ENDIAN
430127dd473Swhl739 #define NI_NODEADDR_FLAG_LINKLOCAL	0x1
431127dd473Swhl739 #define NI_NODEADDR_FLAG_SITELOCAL	0x2
432127dd473Swhl739 #define NI_NODEADDR_FLAG_GLOBAL		0x4
433127dd473Swhl739 #define NI_NODEADDR_FLAG_ALL		0x8
434127dd473Swhl739 #define NI_NODEADDR_FLAG_TRUNCATE	0x10
435127dd473Swhl739 #define NI_NODEADDR_FLAG_ANYCAST	0x20 /* just experimental. not in spec */
436127dd473Swhl739 #elif BYTE_ORDER == LITTLE_ENDIAN
437127dd473Swhl739 #define NI_NODEADDR_FLAG_LINKLOCAL	0x0100
438127dd473Swhl739 #define NI_NODEADDR_FLAG_SITELOCAL	0x0200
439127dd473Swhl739 #define NI_NODEADDR_FLAG_GLOBAL		0x0400
440127dd473Swhl739 #define NI_NODEADDR_FLAG_ALL		0x0800
441127dd473Swhl739 #define NI_NODEADDR_FLAG_TRUNCATE	0x1000
442127dd473Swhl739 #define NI_NODEADDR_FLAG_ANYCAST	0x2000 /* just experimental. not in spec */
443127dd473Swhl739 #endif
444127dd473Swhl739 #else  /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */
445127dd473Swhl739 #if BYTE_ORDER == BIG_ENDIAN
446127dd473Swhl739 #define NI_NODEADDR_FLAG_TRUNCATE	0x1
447127dd473Swhl739 #define NI_NODEADDR_FLAG_ALL		0x2
448127dd473Swhl739 #define NI_NODEADDR_FLAG_COMPAT		0x4
449127dd473Swhl739 #define NI_NODEADDR_FLAG_LINKLOCAL	0x8
450127dd473Swhl739 #define NI_NODEADDR_FLAG_SITELOCAL	0x10
451127dd473Swhl739 #define NI_NODEADDR_FLAG_GLOBAL		0x20
452127dd473Swhl739 #define NI_NODEADDR_FLAG_ANYCAST	0x40 /* just experimental. not in spec */
453127dd473Swhl739 #elif BYTE_ORDER == LITTLE_ENDIAN
454127dd473Swhl739 #define NI_NODEADDR_FLAG_TRUNCATE	0x0100
455127dd473Swhl739 #define NI_NODEADDR_FLAG_ALL		0x0200
456127dd473Swhl739 #define NI_NODEADDR_FLAG_COMPAT		0x0400
457127dd473Swhl739 #define NI_NODEADDR_FLAG_LINKLOCAL	0x0800
458127dd473Swhl739 #define NI_NODEADDR_FLAG_SITELOCAL	0x1000
459127dd473Swhl739 #define NI_NODEADDR_FLAG_GLOBAL		0x2000
460127dd473Swhl739 #define NI_NODEADDR_FLAG_ANYCAST	0x4000 /* just experimental. not in spec */
461127dd473Swhl739 #endif
462127dd473Swhl739 #endif
463127dd473Swhl739 
464127dd473Swhl739 struct ni_reply_fqdn {
465127dd473Swhl739 	u_int32_t ni_fqdn_ttl;	/* TTL */
466127dd473Swhl739 	u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
467127dd473Swhl739 	u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
468127dd473Swhl739 } __packed;
469127dd473Swhl739 
470127dd473Swhl739 /*
471127dd473Swhl739  * Router Renumbering. as router-renum-08.txt
472127dd473Swhl739  */
473127dd473Swhl739 struct icmp6_router_renum {	/* router renumbering header */
474127dd473Swhl739 	struct icmp6_hdr	rr_hdr;
475127dd473Swhl739 	u_int8_t	rr_segnum;
476127dd473Swhl739 	u_int8_t	rr_flags;
477127dd473Swhl739 	u_int16_t	rr_maxdelay;
478127dd473Swhl739 	u_int32_t	rr_reserved;
479127dd473Swhl739 } __packed;
480127dd473Swhl739 
481127dd473Swhl739 #define ICMP6_RR_FLAGS_TEST		0x80
482127dd473Swhl739 #define ICMP6_RR_FLAGS_REQRESULT	0x40
483127dd473Swhl739 #define ICMP6_RR_FLAGS_FORCEAPPLY	0x20
484127dd473Swhl739 #define ICMP6_RR_FLAGS_SPECSITE		0x10
485127dd473Swhl739 #define ICMP6_RR_FLAGS_PREVDONE		0x08
486127dd473Swhl739 
487127dd473Swhl739 #define rr_type		rr_hdr.icmp6_type
488127dd473Swhl739 #define rr_code		rr_hdr.icmp6_code
489127dd473Swhl739 #define rr_cksum	rr_hdr.icmp6_cksum
490127dd473Swhl739 #define rr_seqnum 	rr_hdr.icmp6_data32[0]
491127dd473Swhl739 
492127dd473Swhl739 struct rr_pco_match {		/* match prefix part */
493127dd473Swhl739 	u_int8_t	rpm_code;
494127dd473Swhl739 	u_int8_t	rpm_len;
495127dd473Swhl739 	u_int8_t	rpm_ordinal;
496127dd473Swhl739 	u_int8_t	rpm_matchlen;
497127dd473Swhl739 	u_int8_t	rpm_minlen;
498127dd473Swhl739 	u_int8_t	rpm_maxlen;
499127dd473Swhl739 	u_int16_t	rpm_reserved;
500127dd473Swhl739 	struct	in6_addr	rpm_prefix;
501127dd473Swhl739 } __packed;
502127dd473Swhl739 
503127dd473Swhl739 #define RPM_PCO_ADD		1
504127dd473Swhl739 #define RPM_PCO_CHANGE		2
505127dd473Swhl739 #define RPM_PCO_SETGLOBAL	3
506127dd473Swhl739 #define RPM_PCO_MAX		4
507127dd473Swhl739 
508127dd473Swhl739 struct rr_pco_use {		/* use prefix part */
509127dd473Swhl739 	u_int8_t	rpu_uselen;
510127dd473Swhl739 	u_int8_t	rpu_keeplen;
511127dd473Swhl739 	u_int8_t	rpu_ramask;
512127dd473Swhl739 	u_int8_t	rpu_raflags;
513127dd473Swhl739 	u_int32_t	rpu_vltime;
514127dd473Swhl739 	u_int32_t	rpu_pltime;
515127dd473Swhl739 	u_int32_t	rpu_flags;
516127dd473Swhl739 	struct	in6_addr rpu_prefix;
517127dd473Swhl739 } __packed;
518127dd473Swhl739 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK	0x80
519127dd473Swhl739 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO	0x40
520127dd473Swhl739 
521127dd473Swhl739 #if BYTE_ORDER == BIG_ENDIAN
522127dd473Swhl739 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME     0x80000000
523127dd473Swhl739 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME     0x40000000
524127dd473Swhl739 #elif BYTE_ORDER == LITTLE_ENDIAN
525127dd473Swhl739 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME     0x80
526127dd473Swhl739 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME     0x40
527127dd473Swhl739 #endif
528127dd473Swhl739 
529127dd473Swhl739 struct rr_result {		/* router renumbering result message */
530127dd473Swhl739 	u_int16_t	rrr_flags;
531127dd473Swhl739 	u_int8_t	rrr_ordinal;
532127dd473Swhl739 	u_int8_t	rrr_matchedlen;
533127dd473Swhl739 	u_int32_t	rrr_ifid;
534127dd473Swhl739 	struct	in6_addr rrr_prefix;
535127dd473Swhl739 } __packed;
536127dd473Swhl739 #if BYTE_ORDER == BIG_ENDIAN
537127dd473Swhl739 #define ICMP6_RR_RESULT_FLAGS_OOB		0x0002
538127dd473Swhl739 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN		0x0001
539127dd473Swhl739 #elif BYTE_ORDER == LITTLE_ENDIAN
540127dd473Swhl739 #define ICMP6_RR_RESULT_FLAGS_OOB		0x0200
541127dd473Swhl739 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN		0x0100
542127dd473Swhl739 #endif
543127dd473Swhl739 
544127dd473Swhl739 /*
545127dd473Swhl739  * icmp6 filter structures.
546127dd473Swhl739  */
547127dd473Swhl739 
548127dd473Swhl739 struct icmp6_filter {
549127dd473Swhl739 	u_int32_t icmp6_filt[8];
550127dd473Swhl739 };
551127dd473Swhl739 
552127dd473Swhl739 #ifdef _KERNEL
553127dd473Swhl739 #define	ICMP6_FILTER_SETPASSALL(filterp) \
554127dd473Swhl739 do {								\
555127dd473Swhl739 	int i; u_char *p;					\
556127dd473Swhl739 	p = (u_char *)filterp;					\
557127dd473Swhl739 	for (i = 0; i < sizeof(struct icmp6_filter); i++)	\
558127dd473Swhl739 		p[i] = 0xff;					\
559127dd473Swhl739 } while (/*CONSTCOND*/ 0)
560127dd473Swhl739 #define	ICMP6_FILTER_SETBLOCKALL(filterp) \
561127dd473Swhl739 	bzero(filterp, sizeof(struct icmp6_filter))
562127dd473Swhl739 #else /* _KERNEL */
563127dd473Swhl739 #define	ICMP6_FILTER_SETPASSALL(filterp) \
564127dd473Swhl739 	memset(filterp, 0xff, sizeof(struct icmp6_filter))
565127dd473Swhl739 #define	ICMP6_FILTER_SETBLOCKALL(filterp) \
566127dd473Swhl739 	memset(filterp, 0x00, sizeof(struct icmp6_filter))
567127dd473Swhl739 #endif /* _KERNEL */
568127dd473Swhl739 
569127dd473Swhl739 #define	ICMP6_FILTER_SETPASS(type, filterp) \
570127dd473Swhl739 	(((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
571127dd473Swhl739 #define	ICMP6_FILTER_SETBLOCK(type, filterp) \
572127dd473Swhl739 	(((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
573127dd473Swhl739 #define	ICMP6_FILTER_WILLPASS(type, filterp) \
574127dd473Swhl739 	((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
575127dd473Swhl739 #define	ICMP6_FILTER_WILLBLOCK(type, filterp) \
576127dd473Swhl739 	((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
577127dd473Swhl739 
578127dd473Swhl739 /*
579127dd473Swhl739  * Variables related to this implementation
580127dd473Swhl739  * of the internet control message protocol version 6.
581127dd473Swhl739  */
582127dd473Swhl739 struct icmp6errstat {
583127dd473Swhl739 	uint64_t icp6errs_dst_unreach_noroute;
584127dd473Swhl739 	uint64_t icp6errs_dst_unreach_admin;
585127dd473Swhl739 	uint64_t icp6errs_dst_unreach_beyondscope;
586127dd473Swhl739 	uint64_t icp6errs_dst_unreach_addr;
587127dd473Swhl739 	uint64_t icp6errs_dst_unreach_noport;
588127dd473Swhl739 	uint64_t icp6errs_packet_too_big;
589127dd473Swhl739 	uint64_t icp6errs_time_exceed_transit;
590127dd473Swhl739 	uint64_t icp6errs_time_exceed_reassembly;
591127dd473Swhl739 	uint64_t icp6errs_paramprob_header;
592127dd473Swhl739 	uint64_t icp6errs_paramprob_nextheader;
593127dd473Swhl739 	uint64_t icp6errs_paramprob_option;
594127dd473Swhl739 	uint64_t icp6errs_redirect; /* we regard redirect as an error here */
595127dd473Swhl739 	uint64_t icp6errs_unknown;
596127dd473Swhl739 };
597127dd473Swhl739 
598127dd473Swhl739 struct icmp6stat {
599127dd473Swhl739 /* statistics related to icmp6 packets generated */
600127dd473Swhl739 	uint64_t icp6s_error;		/* # of calls to icmp6_error */
601127dd473Swhl739 	uint64_t icp6s_canterror;	/* no error 'cuz old was icmp */
602127dd473Swhl739 	uint64_t icp6s_toofreq;		/* no error 'cuz rate limitation */
603127dd473Swhl739 	uint64_t icp6s_outhist[256];
604127dd473Swhl739 /* statistics related to input message processed */
605127dd473Swhl739 	uint64_t icp6s_badcode;		/* icmp6_code out of range */
606127dd473Swhl739 	uint64_t icp6s_tooshort;	/* packet < sizeof(struct icmp6_hdr) */
607127dd473Swhl739 	uint64_t icp6s_checksum;	/* bad checksum */
608127dd473Swhl739 	uint64_t icp6s_badlen;		/* calculated bound mismatch */
609127dd473Swhl739 	/*
610127dd473Swhl739 	 * number of responses: this member is inherited from netinet code, but
611127dd473Swhl739 	 * for netinet6 code, it is already available in icp6s_outhist[].
612127dd473Swhl739 	 */
613127dd473Swhl739 	uint64_t icp6s_reflect;
614127dd473Swhl739 	uint64_t icp6s_inhist[256];
615127dd473Swhl739 	uint64_t icp6s_nd_toomanyopt;	/* too many ND options */
616127dd473Swhl739 	struct icmp6errstat icp6s_outerrhist;
617127dd473Swhl739 #define icp6s_odst_unreach_noroute \
618127dd473Swhl739 	icp6s_outerrhist.icp6errs_dst_unreach_noroute
619127dd473Swhl739 #define icp6s_odst_unreach_admin icp6s_outerrhist.icp6errs_dst_unreach_admin
620127dd473Swhl739 #define icp6s_odst_unreach_beyondscope \
621127dd473Swhl739 	icp6s_outerrhist.icp6errs_dst_unreach_beyondscope
622127dd473Swhl739 #define icp6s_odst_unreach_addr icp6s_outerrhist.icp6errs_dst_unreach_addr
623127dd473Swhl739 #define icp6s_odst_unreach_noport icp6s_outerrhist.icp6errs_dst_unreach_noport
624127dd473Swhl739 #define icp6s_opacket_too_big icp6s_outerrhist.icp6errs_packet_too_big
625127dd473Swhl739 #define icp6s_otime_exceed_transit \
626127dd473Swhl739 	icp6s_outerrhist.icp6errs_time_exceed_transit
627127dd473Swhl739 #define icp6s_otime_exceed_reassembly \
628127dd473Swhl739 	icp6s_outerrhist.icp6errs_time_exceed_reassembly
629127dd473Swhl739 #define icp6s_oparamprob_header icp6s_outerrhist.icp6errs_paramprob_header
630127dd473Swhl739 #define icp6s_oparamprob_nextheader \
631127dd473Swhl739 	icp6s_outerrhist.icp6errs_paramprob_nextheader
632127dd473Swhl739 #define icp6s_oparamprob_option icp6s_outerrhist.icp6errs_paramprob_option
633127dd473Swhl739 #define icp6s_oredirect icp6s_outerrhist.icp6errs_redirect
634127dd473Swhl739 #define icp6s_ounknown icp6s_outerrhist.icp6errs_unknown
635127dd473Swhl739 	uint64_t icp6s_pmtuchg;		/* path MTU changes */
636127dd473Swhl739 	uint64_t icp6s_nd_badopt;	/* bad ND options */
637127dd473Swhl739 	uint64_t icp6s_badns;		/* bad neighbor solicitation */
638127dd473Swhl739 	uint64_t icp6s_badna;		/* bad neighbor advertisement */
639*d4a07e70Sfengbojiang 	uint64_t icp6s_badrs;		/* bad router solicitation */
640127dd473Swhl739 	uint64_t icp6s_badra;		/* bad router advertisement */
641127dd473Swhl739 	uint64_t icp6s_badredirect;	/* bad redirect message */
642*d4a07e70Sfengbojiang 	uint64_t icp6s_overflowdefrtr;	/* Too many default routers. */
643*d4a07e70Sfengbojiang 	uint64_t icp6s_overflowprfx;	/* Too many prefixes. */
644*d4a07e70Sfengbojiang 	uint64_t icp6s_overflownndp;	/* Too many neighbour entries. */
645*d4a07e70Sfengbojiang 	uint64_t icp6s_overflowredirect;/* Too many redirects. */
646*d4a07e70Sfengbojiang 	uint64_t icp6s_invlhlim;	/* Invalid hop limit. */
647*d4a07e70Sfengbojiang 	uint64_t icp6s_spare[32];
648127dd473Swhl739 };
649127dd473Swhl739 
650127dd473Swhl739 #ifdef _KERNEL
651127dd473Swhl739 #include <sys/counter.h>
652127dd473Swhl739 
653127dd473Swhl739 VNET_PCPUSTAT_DECLARE(struct icmp6stat, icmp6stat);
654127dd473Swhl739 /*
655127dd473Swhl739  * In-kernel consumers can use these accessor macros directly to update
656127dd473Swhl739  * stats.
657127dd473Swhl739  */
658127dd473Swhl739 #define	ICMP6STAT_ADD(name, val)	\
659127dd473Swhl739     VNET_PCPUSTAT_ADD(struct icmp6stat, icmp6stat, name, (val))
660127dd473Swhl739 #define	ICMP6STAT_INC(name)		ICMP6STAT_ADD(name, 1)
661127dd473Swhl739 
662127dd473Swhl739 /*
663127dd473Swhl739  * Kernel module consumers must use this accessor macro.
664127dd473Swhl739  */
665127dd473Swhl739 void	kmod_icmp6stat_inc(int statnum);
666127dd473Swhl739 #define	KMOD_ICMP6STAT_INC(name)	\
667127dd473Swhl739     kmod_icmp6stat_inc(offsetof(struct icmp6stat, name) / sizeof(uint64_t))
668127dd473Swhl739 #endif
669127dd473Swhl739 
670127dd473Swhl739 /*
671127dd473Swhl739  * Names for ICMP sysctl objects
672127dd473Swhl739  */
673127dd473Swhl739 #define ICMPV6CTL_STATS		1
674127dd473Swhl739 #define ICMPV6CTL_REDIRACCEPT	2	/* accept/process redirects */
675127dd473Swhl739 #define ICMPV6CTL_REDIRTIMEOUT	3	/* redirect cache time */
676127dd473Swhl739 #if 0	/*obsoleted*/
677127dd473Swhl739 #define ICMPV6CTL_ERRRATELIMIT	5	/* ICMPv6 error rate limitation */
678127dd473Swhl739 #endif
679127dd473Swhl739 #define ICMPV6CTL_ND6_PRUNE	6
680127dd473Swhl739 #define ICMPV6CTL_ND6_DELAY	8
681127dd473Swhl739 #define ICMPV6CTL_ND6_UMAXTRIES	9
682127dd473Swhl739 #define ICMPV6CTL_ND6_MMAXTRIES		10
683127dd473Swhl739 #define ICMPV6CTL_ND6_USELOOPBACK	11
684127dd473Swhl739 /*#define ICMPV6CTL_ND6_PROXYALL	12	obsoleted, do not reuse here */
685127dd473Swhl739 #define ICMPV6CTL_NODEINFO	13
686127dd473Swhl739 #define ICMPV6CTL_ERRPPSLIMIT	14	/* ICMPv6 error pps limitation */
687127dd473Swhl739 #define ICMPV6CTL_ND6_MAXNUDHINT	15
688127dd473Swhl739 #define ICMPV6CTL_MTUDISC_HIWAT	16
689127dd473Swhl739 #define ICMPV6CTL_MTUDISC_LOWAT	17
690127dd473Swhl739 #define ICMPV6CTL_ND6_DEBUG	18
691127dd473Swhl739 #define ICMPV6CTL_ND6_DRLIST	19
692127dd473Swhl739 #define ICMPV6CTL_ND6_PRLIST	20
693127dd473Swhl739 #define ICMPV6CTL_MLD_MAXSRCFILTER	21
694127dd473Swhl739 #define ICMPV6CTL_MLD_SOMAXSRC	22
695127dd473Swhl739 #define ICMPV6CTL_MLD_VERSION	23
696127dd473Swhl739 #define ICMPV6CTL_ND6_MAXQLEN	24
697127dd473Swhl739 #define ICMPV6CTL_NODEINFO_OLDMCPREFIX	25
698127dd473Swhl739 #define ICMPV6CTL_MAXID		26
699127dd473Swhl739 
700127dd473Swhl739 #ifdef _KERNEL
701127dd473Swhl739 # ifdef __STDC__
702*d4a07e70Sfengbojiang struct	nhop_object;
703127dd473Swhl739 struct	rttimer;
704127dd473Swhl739 struct	in6_multi;
705127dd473Swhl739 # endif
706127dd473Swhl739 void	icmp6_paramerror(struct mbuf *, int);
707127dd473Swhl739 void	icmp6_error(struct mbuf *, int, int, int);
708127dd473Swhl739 void	icmp6_error2(struct mbuf *, int, int, int, struct ifnet *);
709127dd473Swhl739 int	icmp6_input(struct mbuf **, int *, int);
710127dd473Swhl739 void	icmp6_fasttimo(void);
711127dd473Swhl739 void	icmp6_slowtimo(void);
712127dd473Swhl739 void	icmp6_prepare(struct mbuf *);
713127dd473Swhl739 void	icmp6_redirect_input(struct mbuf *, int);
714*d4a07e70Sfengbojiang void	icmp6_redirect_output(struct mbuf *, struct nhop_object *);
715127dd473Swhl739 
716127dd473Swhl739 struct	ip6ctlparam;
717127dd473Swhl739 void	icmp6_mtudisc_update(struct ip6ctlparam *, int);
718127dd473Swhl739 
719127dd473Swhl739 /* XXX: is this the right place for these macros? */
720127dd473Swhl739 #define icmp6_ifstat_inc(ifp, tag) \
721127dd473Swhl739 do {								\
722127dd473Swhl739 	if (ifp)						\
723127dd473Swhl739 		counter_u64_add(((struct in6_ifextra *)		\
724127dd473Swhl739 		    ((ifp)->if_afdata[AF_INET6]))->icmp6_ifstat[\
725127dd473Swhl739 		    offsetof(struct icmp6_ifstat, tag) / sizeof(uint64_t)], 1);\
726127dd473Swhl739 } while (/*CONSTCOND*/ 0)
727127dd473Swhl739 
728127dd473Swhl739 #define icmp6_ifoutstat_inc(ifp, type, code) \
729127dd473Swhl739 do { \
730127dd473Swhl739 		icmp6_ifstat_inc(ifp, ifs6_out_msg); \
731127dd473Swhl739  		if (type < ICMP6_INFOMSG_MASK) \
732127dd473Swhl739  			icmp6_ifstat_inc(ifp, ifs6_out_error); \
733127dd473Swhl739 		switch (type) { \
734127dd473Swhl739 		 case ICMP6_DST_UNREACH: \
735127dd473Swhl739 			 icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \
736127dd473Swhl739 			 if (code == ICMP6_DST_UNREACH_ADMIN) \
737127dd473Swhl739 				 icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \
738127dd473Swhl739 			 break; \
739127dd473Swhl739 		 case ICMP6_PACKET_TOO_BIG: \
740127dd473Swhl739 			 icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \
741127dd473Swhl739 			 break; \
742127dd473Swhl739 		 case ICMP6_TIME_EXCEEDED: \
743127dd473Swhl739 			 icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \
744127dd473Swhl739 			 break; \
745127dd473Swhl739 		 case ICMP6_PARAM_PROB: \
746127dd473Swhl739 			 icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \
747127dd473Swhl739 			 break; \
748127dd473Swhl739 		 case ICMP6_ECHO_REQUEST: \
749127dd473Swhl739 			 icmp6_ifstat_inc(ifp, ifs6_out_echo); \
750127dd473Swhl739 			 break; \
751127dd473Swhl739 		 case ICMP6_ECHO_REPLY: \
752127dd473Swhl739 			 icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
753127dd473Swhl739 			 break; \
754127dd473Swhl739 		 case MLD_LISTENER_QUERY: \
755127dd473Swhl739 			 icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
756127dd473Swhl739 			 break; \
757127dd473Swhl739 		 case MLD_LISTENER_REPORT: \
758127dd473Swhl739 			 icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
759127dd473Swhl739 			 break; \
760127dd473Swhl739 		 case MLD_LISTENER_DONE: \
761127dd473Swhl739 			 icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
762127dd473Swhl739 			 break; \
763127dd473Swhl739 		 case ND_ROUTER_SOLICIT: \
764127dd473Swhl739 			 icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \
765127dd473Swhl739 			 break; \
766127dd473Swhl739 		 case ND_ROUTER_ADVERT: \
767127dd473Swhl739 			 icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \
768127dd473Swhl739 			 break; \
769127dd473Swhl739 		 case ND_NEIGHBOR_SOLICIT: \
770127dd473Swhl739 			 icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \
771127dd473Swhl739 			 break; \
772127dd473Swhl739 		 case ND_NEIGHBOR_ADVERT: \
773127dd473Swhl739 			 icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
774127dd473Swhl739 			 break; \
775127dd473Swhl739 		 case ND_REDIRECT: \
776127dd473Swhl739 			 icmp6_ifstat_inc(ifp, ifs6_out_redirect); \
777127dd473Swhl739 			 break; \
778127dd473Swhl739 		} \
779127dd473Swhl739 } while (/*CONSTCOND*/ 0)
780127dd473Swhl739 
781127dd473Swhl739 VNET_DECLARE(int, icmp6_rediraccept);	/* accept/process redirects */
782127dd473Swhl739 VNET_DECLARE(int, icmp6_redirtimeout);	/* cache time for redirect routes */
783127dd473Swhl739 
784127dd473Swhl739 #define	V_icmp6_rediraccept	VNET(icmp6_rediraccept)
785127dd473Swhl739 #define	V_icmp6_redirtimeout	VNET(icmp6_redirtimeout)
786127dd473Swhl739 
787127dd473Swhl739 #define ICMP6_NODEINFO_FQDNOK		0x1
788127dd473Swhl739 #define ICMP6_NODEINFO_NODEADDROK	0x2
789127dd473Swhl739 #define ICMP6_NODEINFO_TMPADDROK	0x4
790127dd473Swhl739 #define ICMP6_NODEINFO_GLOBALOK		0x8
791127dd473Swhl739 #endif /* _KERNEL */
792127dd473Swhl739 
793127dd473Swhl739 #endif /* not _NETINET_ICMP6_H_ */
794