icmp6.h revision 54263
1/*
2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the project nor the names of its contributors
14 *    may be used to endorse or promote products derived from this software
15 *    without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * $FreeBSD: head/sys/netinet6/icmp6.h 54263 1999-12-07 17:39:16Z shin $
30 */
31
32/*
33 * Copyright (c) 1982, 1986, 1993
34 *	The Regents of the University of California.  All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 * 1. Redistributions of source code must retain the above copyright
40 *    notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 *    notice, this list of conditions and the following disclaimer in the
43 *    documentation and/or other materials provided with the distribution.
44 * 3. All advertising materials mentioning features or use of this software
45 *    must display the following acknowledgement:
46 *	This product includes software developed by the University of
47 *	California, Berkeley and its contributors.
48 * 4. Neither the name of the University nor the names of its contributors
49 *    may be used to endorse or promote products derived from this software
50 *    without specific prior written permission.
51 *
52 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
53 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
56 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62 * SUCH DAMAGE.
63 *
64 *	@(#)ip_icmp.h	8.1 (Berkeley) 6/10/93
65 */
66
67#ifndef _NETINET6_ICMPV6_H_
68#define _NETINET6_ICMPV6_H_
69
70#define ICMPV6_PLD_MAXLEN	1232	/* IPV6_MMTU - sizeof(struct ip6_hdr)
71					   - sizeof(struct icmp6_hdr) */
72
73struct icmp6_hdr {
74	u_int8_t	icmp6_type;	/* type field */
75	u_int8_t	icmp6_code;	/* code field */
76	u_int16_t	icmp6_cksum;	/* checksum field */
77	union {
78		u_int32_t	icmp6_un_data32[1]; /* type-specific field */
79		u_int16_t	icmp6_un_data16[2]; /* type-specific field */
80		u_int8_t	icmp6_un_data8[4];  /* type-specific field */
81	} icmp6_dataun;
82};
83
84#define	icmp6_data32	icmp6_dataun.icmp6_un_data32
85#define	icmp6_data16	icmp6_dataun.icmp6_un_data16
86#define	icmp6_data8	icmp6_dataun.icmp6_un_data8
87#define	icmp6_pptr	icmp6_data32[0]		/* parameter prob */
88#define	icmp6_mtu	icmp6_data32[0]		/* packet too big */
89#define	icmp6_id	icmp6_data16[0]		/* echo request/reply */
90#define	icmp6_seq	icmp6_data16[1]		/* echo request/reply */
91#define	icmp6_maxdelay	icmp6_data16[0]		/* mcast group membership */
92
93#define	ICMP6_DST_UNREACH		1	/* dest unreachable, codes: */
94#define	ICMP6_PACKET_TOO_BIG		2	/* packet too big */
95#define	ICMP6_TIME_EXCEEDED		3	/* time exceeded, code: */
96#define	ICMP6_PARAM_PROB		4	/* ip6 header bad */
97
98#define	ICMP6_ECHO_REQUEST		128	/* echo service */
99#define	ICMP6_ECHO_REPLY		129	/* echo reply */
100#define	ICMP6_MEMBERSHIP_QUERY		130	/* group membership query */
101#define	MLD6_LISTENER_QUERY		130 	/* multicast listener query */
102#define	ICMP6_MEMBERSHIP_REPORT		131	/* group membership report */
103#define	MLD6_LISTENER_REPORT		131	/* multicast listener report */
104#define	ICMP6_MEMBERSHIP_REDUCTION	132	/* group membership termination */
105#define	MLD6_LISTENER_DONE		132	/* multicast listener done */
106
107#define	ND_ROUTER_SOLICIT		133	/* router solicitation */
108#define	ND_ROUTER_ADVERT		134	/* router advertisment */
109#define	ND_NEIGHBOR_SOLICIT		135	/* neighbor solicitation */
110#define	ND_NEIGHBOR_ADVERT		136	/* neighbor advertisment */
111#define	ND_REDIRECT			137	/* redirect */
112
113#define	ICMP6_ROUTER_RENUMBERING	138	/* router renumbering */
114
115#define	ICMP6_WRUREQUEST		139	/* who are you request */
116#define	ICMP6_WRUREPLY			140	/* who are you reply */
117#define	ICMP6_FQDN_QUERY		139	/* FQDN query */
118#define	ICMP6_FQDN_REPLY		140	/* FQDN reply */
119#define	ICMP6_NI_QUERY			139	/* node information request */
120#define	ICMP6_NI_REPLY			140	/* node information reply */
121
122/* The definitions below are experimental. TBA */
123#define	MLD6_MTRACE_RESP		141	/* mtrace response(to sender) */
124#define	MLD6_MTRACE			142	/* mtrace messages */
125
126#define	ICMP6_MAXTYPE			142
127
128#define	ICMP6_DST_UNREACH_NOROUTE	0	/* no route to destination */
129#define	ICMP6_DST_UNREACH_ADMIN	 	1	/* administratively prohibited */
130#define	ICMP6_DST_UNREACH_NOTNEIGHBOR	2	/* not a neighbor(obsolete) */
131#define	ICMP6_DST_UNREACH_BEYONDSCOPE	2	/* beyond scope of source address */
132#define	ICMP6_DST_UNREACH_ADDR		3	/* address unreachable */
133#define	ICMP6_DST_UNREACH_NOPORT	4	/* port unreachable */
134
135#define	ICMP6_TIME_EXCEED_TRANSIT 	0	/* ttl==0 in transit */
136#define	ICMP6_TIME_EXCEED_REASSEMBLY	1	/* ttl==0 in reass */
137
138#define	ICMP6_PARAMPROB_HEADER 	 	0	/* erroneous header field */
139#define	ICMP6_PARAMPROB_NEXTHEADER	1	/* unrecognized next header */
140#define	ICMP6_PARAMPROB_OPTION		2	/* unrecognized option */
141
142#define	ICMP6_INFOMSG_MASK		0x80	/* all informational messages */
143
144#define	ICMP6_NI_SUCESS		0	/* node information successful reply */
145#define	ICMP6_NI_REFUSED	1	/* node information request is refused */
146#define	ICMP6_NI_UNKNOWN	2	/* unknown Qtype */
147
148#define	ICMP6_ROUTER_RENUMBERING_COMMAND  0	/* rr command */
149#define	ICMP6_ROUTER_RENUMBERING_RESULT   1	/* rr result */
150#define	ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET   255	/* rr seq num reset */
151
152/* Used in kernel only */
153#define	ND_REDIRECT_ONLINK	0	/* redirect to an on-link node */
154#define	ND_REDIRECT_ROUTER	1	/* redirect to a better router */
155
156/*
157 * Multicast Listener Discovery
158 */
159struct mld6_hdr {
160	struct	icmp6_hdr	mld6_hdr;
161	struct	in6_addr	mld6_addr; /* multicast address */
162};
163
164#define	mld6_type	mld6_hdr.icmp6_type
165#define	mld6_code	mld6_hdr.icmp6_code
166#define	mld6_cksum	mld6_hdr.icmp6_cksum
167#define	mld6_maxdelay	mld6_hdr.icmp6_data16[0]
168#define	mld6_reserved	mld6_hdr.icmp6_data16[1]
169
170/*
171 * Neighbor Discovery
172 */
173
174struct nd_router_solicit {	/* router solicitation */
175	struct	icmp6_hdr 	nd_rs_hdr;
176	/* could be followed by options */
177};
178
179#define	nd_rs_type	nd_rs_hdr.icmp6_type
180#define	nd_rs_code	nd_rs_hdr.icmp6_code
181#define	nd_rs_cksum	nd_rs_hdr.icmp6_cksum
182#define	nd_rs_reserved	nd_rs_hdr.icmp6_data32[0]
183
184struct nd_router_advert {	/* router advertisement */
185	struct	icmp6_hdr	nd_ra_hdr;
186	u_int32_t	nd_ra_reachable;	/* reachable time */
187	u_int32_t	nd_ra_retransmit;	/* retransmit timer */
188	/* could be followed by options */
189};
190
191#define	nd_ra_type		nd_ra_hdr.icmp6_type
192#define	nd_ra_code		nd_ra_hdr.icmp6_code
193#define	nd_ra_cksum		nd_ra_hdr.icmp6_cksum
194#define	nd_ra_curhoplimit	nd_ra_hdr.icmp6_data8[0]
195#define	nd_ra_flags_reserved	nd_ra_hdr.icmp6_data8[1]
196#define	ND_RA_FLAG_MANAGED	0x80
197#define	ND_RA_FLAG_OTHER	0x40
198#define	nd_ra_router_lifetime	nd_ra_hdr.icmp6_data16[1]
199
200struct nd_neighbor_solicit {	/* neighbor solicitation */
201	struct	icmp6_hdr	nd_ns_hdr;
202	struct	in6_addr	nd_ns_target;	/*target address */
203	/* could be followed by options */
204};
205
206#define	nd_ns_type		nd_ns_hdr.icmp6_type
207#define	nd_ns_code		nd_ns_hdr.icmp6_code
208#define	nd_ns_cksum		nd_ns_hdr.icmp6_cksum
209#define	nd_ns_reserved		nd_ns_hdr.icmp6_data32[0]
210
211struct nd_neighbor_advert {	/* neighbor advertisement */
212	struct	icmp6_hdr	nd_na_hdr;
213	struct	in6_addr	nd_na_target;	/* target address */
214	/* could be followed by options */
215};
216
217#define	nd_na_type		nd_na_hdr.icmp6_type
218#define	nd_na_code		nd_na_hdr.icmp6_code
219#define	nd_na_cksum		nd_na_hdr.icmp6_cksum
220#define	nd_na_flags_reserved	nd_na_hdr.icmp6_data32[0]
221#if BYTE_ORDER == BIG_ENDIAN
222#define	ND_NA_FLAG_ROUTER		0x80000000
223#define	ND_NA_FLAG_SOLICITED		0x40000000
224#define	ND_NA_FLAG_OVERRIDE		0x20000000
225#elif BYTE_ORDER == LITTLE_ENDIAN
226#define	ND_NA_FLAG_ROUTER		0x80
227#define	ND_NA_FLAG_SOLICITED		0x40
228#define	ND_NA_FLAG_OVERRIDE		0x20
229#endif
230
231struct nd_redirect {		/* redirect */
232	struct	icmp6_hdr	nd_rd_hdr;
233	struct	in6_addr	nd_rd_target;	/* target address */
234	struct	in6_addr	nd_rd_dst;	/* destination address */
235	/* could be followed by options */
236};
237
238#define	nd_rd_type		nd_rd_hdr.icmp6_type
239#define	nd_rd_code		nd_rd_hdr.icmp6_code
240#define	nd_rd_cksum		nd_rd_hdr.icmp6_cksum
241#define	nd_rd_reserved		nd_rd_hdr.icmp6_data32[0]
242
243struct nd_opt_hdr {		/* Neighbor discovery option header */
244	u_int8_t	nd_opt_type;
245	u_int8_t	nd_opt_len;
246	/* followed by option specific data*/
247};
248
249#define	ND_OPT_SOURCE_LINKADDR		1
250#define	ND_OPT_TARGET_LINKADDR		2
251#define	ND_OPT_PREFIX_INFORMATION	3
252#define	ND_OPT_REDIRECTED_HEADER	4
253#define	ND_OPT_MTU			5
254
255struct nd_opt_prefix_info {	/* prefix information */
256	u_int8_t	nd_opt_pi_type;
257	u_int8_t	nd_opt_pi_len;
258	u_int8_t	nd_opt_pi_prefix_len;
259	u_int8_t	nd_opt_pi_flags_reserved;
260	u_int32_t	nd_opt_pi_valid_time;
261	u_int32_t	nd_opt_pi_preferred_time;
262	u_int32_t	nd_opt_pi_reserved2;
263	struct	in6_addr	nd_opt_pi_prefix;
264};
265
266#define	ND_OPT_PI_FLAG_ONLINK		0x80
267#define	ND_OPT_PI_FLAG_AUTO		0x40
268
269struct nd_opt_rd_hdr {         /* redirected header */
270	u_int8_t	nd_opt_rh_type;
271	u_int8_t	nd_opt_rh_len;
272	u_int16_t	nd_opt_rh_reserved1;
273	u_int32_t	nd_opt_rh_reserved2;
274	/* followed by IP header and data */
275};
276
277struct nd_opt_mtu {		/* MTU option */
278	u_int8_t	nd_opt_mtu_type;
279	u_int8_t	nd_opt_mtu_len;
280	u_int16_t	nd_opt_mtu_reserved;
281	u_int32_t	nd_opt_mtu_mtu;
282};
283
284/*
285 * icmp6 namelookup
286 */
287
288struct icmp6_namelookup {
289	struct	icmp6_hdr	icmp6_nl_hdr;
290	u_int64_t	icmp6_nl_nonce;
291	u_int32_t	icmp6_nl_ttl;
292	/* could be followed by options */
293};
294
295/*
296 * icmp6 node information
297 */
298struct icmp6_nodeinfo {
299	struct	icmp6_hdr icmp6_ni_hdr;
300	u_int64_t	icmp6_ni_nonce;
301	/* could be followed by reply data */
302};
303
304#define	ni_type		icmp6_ni_hdr.icmp6_type
305#define	ni_code		icmp6_ni_hdr.icmp6_code
306#define	ni_cksum	icmp6_ni_hdr.icmp6_cksum
307#define	ni_qtype	icmp6_ni_hdr.icmp6_data16[0]
308#define	ni_flags	icmp6_ni_hdr.icmp6_data16[1]
309
310
311#define	NI_QTYPE_NOOP		0 /* NOOP  */
312#define	NI_QTYPE_SUPTYPES	1 /* Supported Qtypes */
313#define	NI_QTYPE_FQDN		2 /* FQDN */
314#define	NI_QTYPE_NODEADDR	3 /* Node Addresses. XXX: spec says 2, but it may be a typo... */
315
316#if BYTE_ORDER == BIG_ENDIAN
317#define	NI_SUPTYPE_FLAG_COMPRESS	0x1
318#define	NI_FQDN_FLAG_VALIDTTL		0x1
319#define	NI_NODEADDR_FLAG_LINKLOCAL	0x1
320#define	NI_NODEADDR_FLAG_SITELOCAL	0x2
321#define	NI_NODEADDR_FLAG_GLOBAL		0x4
322#define	NI_NODEADDR_FLAG_ALL		0x8
323#define	NI_NODEADDR_FLAG_TRUNCATE	0x10
324#define	NI_NODEADDR_FLAG_ANYCAST	0x20 /* just experimental. not in spec */
325#elif BYTE_ORDER == LITTLE_ENDIAN
326#define	NI_SUPTYPE_FLAG_COMPRESS	0x0100
327#define	NI_FQDN_FLAG_VALIDTTL		0x0100
328#define	NI_NODEADDR_FLAG_LINKLOCAL	0x0100
329#define	NI_NODEADDR_FLAG_SITELOCAL	0x0200
330#define	NI_NODEADDR_FLAG_GLOBAL		0x0400
331#define	NI_NODEADDR_FLAG_ALL		0x0800
332#define	NI_NODEADDR_FLAG_TRUNCATE	0x1000
333#define	NI_NODEADDR_FLAG_ANYCAST	0x2000 /* just experimental. not in spec */
334#endif
335
336struct ni_reply_fqdn {
337	u_int32_t	ni_fqdn_ttl;	/* TTL */
338	u_int8_t	ni_fqdn_namelen; /* length in octets of the FQDN */
339	u_int8_t	ni_fqdn_name[3]; /* XXX: alignment */
340};
341
342/*
343 * Router Renumbering. as router-renum-08.txt
344 */
345struct icmp6_router_renum {	/* router renumbering header */
346	struct icmp6_hdr	rr_hdr;
347	u_int8_t	rr_segnum;
348	u_int8_t	rr_flags;
349	u_int16_t	rr_maxdelay;
350	u_int32_t	rr_reserved;
351};
352#define	ICMP6_RR_FLAGS_SEGNUM		0x80
353#define	ICMP6_RR_FLAGS_TEST		0x40
354#define	ICMP6_RR_FLAGS_REQRESULT	0x20
355#define	ICMP6_RR_FLAGS_FORCEAPPLY	0x10
356#define	ICMP6_RR_FLAGS_SPECSITE		0x08
357#define	ICMP6_RR_FLAGS_PREVDONE		0x04
358
359#define	rr_type		rr_hdr.icmp6_type
360#define	rr_code		rr_hdr.icmp6_code
361#define	rr_cksum	rr_hdr.icmp6_cksum
362#define	rr_seqnum 	rr_hdr.icmp6_data32[0]
363
364struct rr_pco_match {		/* match prefix part */
365	u_int8_t	rpm_code;
366	u_int8_t	rpm_len;
367	u_int8_t	rpm_ordinal;
368	u_int8_t	rpm_matchlen;
369	u_int8_t	rpm_minlen;
370	u_int8_t	rpm_maxlen;
371	u_int16_t	rpm_reserved;
372	struct	in6_addr	rpm_prefix;
373};
374
375#define	RPM_PCO_ADD		1
376#define	RPM_PCO_CHANGE		2
377#define	RPM_PCO_SETGLOBAL	3
378
379struct rr_pco_use {		/* use prefix part */
380	u_int8_t	rpu_uselen;
381	u_int8_t	rpu_keeplen;
382	u_int8_t	rpu_ramask;
383	u_int8_t	rpu_raflags;
384	u_int32_t	rpu_vltime;
385	u_int32_t	rpu_pltime;
386	u_int32_t	rpu_flags;
387	struct	in6_addr rpu_prefix;
388};
389#define	ICMP6_RR_PCOUSE_RAFLAGS_ONLINK	0x20
390#define	ICMP6_RR_PCOUSE_RAFLAGS_AUTO	0x10
391
392#if BYTE_ORDER == BIG_ENDIAN
393#define	ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME     0x80000000
394#define	ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME     0x40000000
395#elif BYTE_ORDER == LITTLE_ENDIAN
396#define	ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME     0x80
397#define	ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME     0x40
398#endif
399
400struct rr_result {		/* router renumbering result message */
401	u_int16_t	rrr_flags;
402	u_int8_t	rrr_ordinal;
403	u_int8_t	rrr_matchedlen;
404	u_int32_t	rrr_ifid;
405	struct	in6_addr rrr_prefix;
406};
407#if BYTE_ORDER == BIG_ENDIAN
408#define	ICMP6_RR_RESULT_FLAGS_OOB		0x0002
409#define	ICMP6_RR_RESULT_FLAGS_FORBIDDEN		0x0001
410#elif BYTE_ORDER == LITTLE_ENDIAN
411#define	ICMP6_RR_RESULT_FLAGS_OOB		0x02
412#define	ICMP6_RR_RESULT_FLAGS_FORBIDDEN		0x01
413#endif
414
415/*
416 * icmp6 filter structures.
417 */
418
419struct icmp6_filter {
420	u_int32_t	icmp6_filter[8];
421};
422
423#ifdef _KERNEL
424#define	ICMP6_FILTER_SETPASSALL(filterp) \
425    {								\
426	int i; u_char *p;					\
427	p = (u_char *)filterp;					\
428	for (i = 0; i < sizeof(struct icmp6_filter); i++)	\
429		p[i] = 0xff;					\
430    }
431#define	ICMP6_FILTER_SETBLOCKALL(filterp) \
432	bzero(filterp, sizeof(struct icmp6_filter))
433#else /* _KERNEL */
434#define	ICMP6_FILTER_SETPASSALL(filterp) \
435	memset(filterp, 0xff, sizeof(struct icmp6_filter))
436#define	ICMP6_FILTER_SETBLOCKALL(filterp) \
437	memset(filterp, 0x00, sizeof(struct icmp6_filter))
438#endif /* _KERNEL */
439
440#define	ICMP6_FILTER_SETPASS(type, filterp) \
441	(((filterp)->icmp6_filter[(type) >> 5]) |= (1 << ((type) & 31)))
442#define	ICMP6_FILTER_SETBLOCK(type, filterp) \
443	(((filterp)->icmp6_filter[(type) >> 5]) &= ~(1 << ((type) & 31)))
444#define	ICMP6_FILTER_WILLPASS(type, filterp) \
445	((((filterp)->icmp6_filter[(type) >> 5]) & (1 << ((type) & 31))) != 0)
446#define	ICMP6_FILTER_WILLBLOCK(type, filterp) \
447	((((filterp)->icmp6_filter[(type) >> 5]) & (1 << ((type) & 31))) == 0)
448
449/*
450 * Variables related to this implementation
451 * of the internet control message protocol version 6.
452 */
453struct icmp6stat {
454/* statistics related to icmp6 packets generated */
455	u_long	icp6s_error;		/* # of calls to icmp6_error */
456	u_long	icp6s_canterror;	/* no error 'cuz old was icmp */
457	u_long	icp6s_toofreq;		/* no error 'cuz rate limitation */
458	u_long	icp6s_outhist[256];
459/* statistics related to input messages proccesed */
460	u_long	icp6s_badcode;		/* icmp6_code out of range */
461	u_long	icp6s_tooshort;		/* packet < sizeof(struct icmp6_hdr) */
462	u_long	icp6s_checksum;		/* bad checksum */
463	u_long	icp6s_badlen;		/* calculated bound mismatch */
464	u_long	icp6s_reflect;		/* number of responses */
465	u_long	icp6s_inhist[256];
466};
467
468/*
469 * Names for ICMP sysctl objects
470 */
471#define	ICMPV6CTL_STATS			1
472#define	ICMPV6CTL_REDIRACCEPT		2 /* accept/process redirects */
473#define	ICMPV6CTL_REDIRTIMEOUT		3 /* redirect cache time */
474#define	ICMPV6CTL_ERRRATELIMIT		5 /* ICMPv6 error rate limitation */
475#define	ICMPV6CTL_ND6_PRUNE		6
476#define	ICMPV6CTL_ND6_DELAY		8
477#define	ICMPV6CTL_ND6_UMAXTRIES		9
478#define	ICMPV6CTL_ND6_MMAXTRIES		10
479#define	ICMPV6CTL_ND6_USELOOPBACK	11
480#define	ICMPV6CTL_ND6_PROXYALL		12
481#define	ICMPV6CTL_MAXID			13
482
483#define ICMPV6CTL_NAMES { \
484	{ 0, 0 }, \
485	{ 0, 0 }, \
486	{ "rediraccept", CTLTYPE_INT }, \
487	{ "redirtimeout", CTLTYPE_INT }, \
488	{ 0, 0 }, \
489	{ "errratelimit", CTLTYPE_INT }, \
490	{ "nd6_prune", CTLTYPE_INT }, \
491	{ 0, 0 }, \
492	{ "nd6_delay", CTLTYPE_INT }, \
493	{ "nd6_umaxtries", CTLTYPE_INT }, \
494	{ "nd6_mmaxtries", CTLTYPE_INT }, \
495	{ "nd6_useloopback", CTLTYPE_INT }, \
496	{ "nd6_proxyall", CTLTYPE_INT }, \
497}
498
499#define ICMPV6CTL_VARS { \
500	0, \
501	0, \
502	&icmp6_rediraccept,   \
503	&icmp6_redirtimeout,  \
504	0, \
505	0, \
506	&icmp6errratelim, \
507	&nd6_prune,	\
508	0, \
509	&nd6_delay,	\
510	&nd6_umaxtries, \
511	&nd6_mmaxtries,	\
512	&nd6_useloopback, \
513	&nd6_proxyall, \
514}
515
516#define RTF_PROBEMTU	RTF_PROTO1
517
518#ifdef _KERNEL
519#ifdef SYSCTL_DECL
520SYSCTL_DECL(_net_inet6_icmp6);
521#endif
522# ifdef __STDC__
523struct	rtentry;
524struct	rttimer;
525struct	in6_multi;
526# endif
527void	icmp6_init __P((void));
528void	icmp6_paramerror __P((struct mbuf *, int));
529void	icmp6_error __P((struct mbuf *, int, int, int));
530int	icmp6_input __P((struct mbuf **, int *, int));
531void	icmp6_fasttimo __P((void));
532void	icmp6_reflect __P((struct mbuf *, size_t));
533void	icmp6_prepare __P((struct mbuf *));
534void	icmp6_redirect_input __P((struct mbuf *, int));
535void	icmp6_redirect_output __P((struct mbuf *, struct rtentry *));
536
537/* XXX: is this the right place for these macros? */
538#define icmp6_ifstat_inc(ifp, tag) \
539do {								\
540	if ((ifp) && (ifp)->if_index <= if_index			\
541	 && (ifp)->if_index < icmp6_ifstatmax			\
542	 && icmp6_ifstat && icmp6_ifstat[(ifp)->if_index]) {	\
543		icmp6_ifstat[(ifp)->if_index]->tag++;		\
544	}							\
545} while (0)
546
547#define icmp6_ifoutstat_inc(ifp, type, code) \
548do { \
549		icmp6_ifstat_inc(ifp, ifs6_out_msg); \
550 		if (type < ICMP6_INFOMSG_MASK) \
551 			icmp6_ifstat_inc(ifp, ifs6_out_error); \
552		switch(type) { \
553		 case ICMP6_DST_UNREACH: \
554			 icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \
555			 if (code == ICMP6_DST_UNREACH_ADMIN) \
556				 icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \
557			 break; \
558		 case ICMP6_PACKET_TOO_BIG: \
559			 icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \
560			 break; \
561		 case ICMP6_TIME_EXCEEDED: \
562			 icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \
563			 break; \
564		 case ICMP6_PARAM_PROB: \
565			 icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \
566			 break; \
567		 case ICMP6_ECHO_REQUEST: \
568			 icmp6_ifstat_inc(ifp, ifs6_out_echo); \
569			 break; \
570		 case ICMP6_ECHO_REPLY: \
571			 icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
572			 break; \
573		 case MLD6_LISTENER_QUERY: \
574			 icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
575			 break; \
576		 case MLD6_LISTENER_REPORT: \
577			 icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
578			 break; \
579		 case MLD6_LISTENER_DONE: \
580			 icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
581			 break; \
582		 case ND_ROUTER_SOLICIT: \
583			 icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \
584			 break; \
585		 case ND_ROUTER_ADVERT: \
586			 icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \
587			 break; \
588		 case ND_NEIGHBOR_SOLICIT: \
589			 icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \
590			 break; \
591		 case ND_NEIGHBOR_ADVERT: \
592			 icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
593			 break; \
594		 case ND_REDIRECT: \
595			 icmp6_ifstat_inc(ifp, ifs6_out_redirect); \
596			 break; \
597		} \
598} while (0)
599
600extern int	icmp6_rediraccept;	/* accept/process redirects */
601extern int	icmp6_redirtimeout;	/* cache time for redirect routes */
602#endif /* _KERNEL */
603
604#endif /* not _NETINET6_ICMPV6_H_ */
605
606