xref: /illumos-gate/usr/src/uts/common/netinet/icmp6.h (revision 0f1702c5)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0f1702c5SYu Xiangning  * Common Development and Distribution License (the "License").
6*0f1702c5SYu Xiangning  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*0f1702c5SYu Xiangning  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_NETINET_ICMP6_H
277c478bd9Sstevel@tonic-gate #define	_NETINET_ICMP6_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
307c478bd9Sstevel@tonic-gate extern "C" {
317c478bd9Sstevel@tonic-gate #endif
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <sys/types.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate /*
367c478bd9Sstevel@tonic-gate  * Type and code definitions for ICMPv6.
377c478bd9Sstevel@tonic-gate  * Based on RFC2292.
387c478bd9Sstevel@tonic-gate  */
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #define	ICMP6_INFOMSG_MASK		0x80 /* all informational messages */
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /* Minimum ICMPv6 header length. */
437c478bd9Sstevel@tonic-gate #define	ICMP6_MINLEN	8
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate typedef struct icmp6_hdr {
467c478bd9Sstevel@tonic-gate 	uint8_t	 icmp6_type;	/* type field */
477c478bd9Sstevel@tonic-gate 	uint8_t	 icmp6_code;	/* code field */
487c478bd9Sstevel@tonic-gate 	uint16_t icmp6_cksum;	/* checksum field */
497c478bd9Sstevel@tonic-gate 	union {
507c478bd9Sstevel@tonic-gate 		uint32_t icmp6_un_data32[1];	/* type-specific field */
517c478bd9Sstevel@tonic-gate 		uint16_t icmp6_un_data16[2];	/* type-specific field */
527c478bd9Sstevel@tonic-gate 		uint8_t	 icmp6_un_data8[4];	/* type-specific field */
537c478bd9Sstevel@tonic-gate 	} icmp6_dataun;
547c478bd9Sstevel@tonic-gate } icmp6_t;
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate #define	icmp6_data32	icmp6_dataun.icmp6_un_data32
577c478bd9Sstevel@tonic-gate #define	icmp6_data16	icmp6_dataun.icmp6_un_data16
587c478bd9Sstevel@tonic-gate #define	icmp6_data8	icmp6_dataun.icmp6_un_data8
597c478bd9Sstevel@tonic-gate #define	icmp6_pptr	icmp6_data32[0]	/* parameter prob */
607c478bd9Sstevel@tonic-gate #define	icmp6_mtu	icmp6_data32[0]	/* packet too big */
617c478bd9Sstevel@tonic-gate #define	icmp6_id	icmp6_data16[0]	/* echo request/reply */
627c478bd9Sstevel@tonic-gate #define	icmp6_seq	icmp6_data16[1]	/* echo request/reply */
637c478bd9Sstevel@tonic-gate #define	icmp6_maxdelay	icmp6_data16[0]	/* mcast group membership */
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate /* Multicast Listener Discovery messages (RFC 3542 (v1), RFC 3810 (v2)). */
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate #define	MLD_MINLEN		24
687c478bd9Sstevel@tonic-gate #define	MLD_V2_QUERY_MINLEN	28
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /* Query Header, common to v1 and v2 */
717c478bd9Sstevel@tonic-gate typedef struct mld_hdr {
727c478bd9Sstevel@tonic-gate 	struct icmp6_hdr	mld_icmp6_hdr;
737c478bd9Sstevel@tonic-gate 	struct in6_addr		mld_addr; /* multicast address */
747c478bd9Sstevel@tonic-gate } mld_hdr_t;
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate #define	mld_type	mld_icmp6_hdr.icmp6_type
777c478bd9Sstevel@tonic-gate #define	mld_code	mld_icmp6_hdr.icmp6_code
787c478bd9Sstevel@tonic-gate #define	mld_cksum	mld_icmp6_hdr.icmp6_cksum
797c478bd9Sstevel@tonic-gate #define	mld_maxdelay	mld_icmp6_hdr.icmp6_data16[0]
807c478bd9Sstevel@tonic-gate #define	mld_reserved	mld_icmp6_hdr.icmp6_data16[1]
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate /* MLDv2 query */
837c478bd9Sstevel@tonic-gate typedef struct mld2q {
847c478bd9Sstevel@tonic-gate 	mld_hdr_t	mld2q_hdr;
857c478bd9Sstevel@tonic-gate 	uint8_t		mld2q_sqrv;	/* S Flag, Q's Robustness Variable  */
867c478bd9Sstevel@tonic-gate 	uint8_t		mld2q_qqic;	/* Querier's Query Interval Code    */
877c478bd9Sstevel@tonic-gate 	uint16_t	mld2q_numsrc;	/* number of sources		    */
887c478bd9Sstevel@tonic-gate } mld2q_t;
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate #define	mld2q_type	mld2q_hdr.mld_icmp6_hdr.icmp6_type
917c478bd9Sstevel@tonic-gate #define	mld2q_code	mld2q_hdr.mld_icmp6_hdr.icmp6_code
927c478bd9Sstevel@tonic-gate #define	mld2q_cksum	mld2q_hdr.mld_icmp6_hdr.icmp6_cksum
937c478bd9Sstevel@tonic-gate #define	mld2q_mxrc	mld2q_hdr.mld_icmp6_hdr.icmp6_data16[0]
947c478bd9Sstevel@tonic-gate #define	mld2q_addr	mld2q_hdr.mld_addr
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate #define	MLD_V2_SFLAG_MASK		0x8	/* mask off s part of sqrv */
977c478bd9Sstevel@tonic-gate #define	MLD_V2_RV_MASK			0x7	/* mask off qrv part of sqrv */
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate /* definitions used to extract max response delay from mrc field */
1007c478bd9Sstevel@tonic-gate #define	MLD_V2_MAXRT_FPMIN	0x8000
1017c478bd9Sstevel@tonic-gate #define	MLD_V2_MAXRT_MANT_MASK	0x0fff
1027c478bd9Sstevel@tonic-gate #define	MLD_V2_MAXRT_EXP_MASK	0x7000
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate /* definitions used to extract querier's query interval from qqic field */
1057c478bd9Sstevel@tonic-gate #define	MLD_V2_QQI_FPMIN	0x80
1067c478bd9Sstevel@tonic-gate #define	MLD_V2_QQI_MANT_MASK	0x0f
1077c478bd9Sstevel@tonic-gate #define	MLD_V2_QQI_EXP_MASK	0x70
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate /* MLDv2 response */
1107c478bd9Sstevel@tonic-gate typedef icmp6_t		mld2r_t;
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate #define	mld2r_type	icmp6_type
1137c478bd9Sstevel@tonic-gate #define	mld2r_res	icmp6_code
1147c478bd9Sstevel@tonic-gate #define	mld2r_cksum	icmp6_cksum
1157c478bd9Sstevel@tonic-gate #define	mld2r_res1	icmp6_data16[0]
1167c478bd9Sstevel@tonic-gate #define	mld2r_nummar	icmp6_data16[1]
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate /* MLDv2 multicast address record */
1197c478bd9Sstevel@tonic-gate typedef struct mld2mar {
1207c478bd9Sstevel@tonic-gate 	uint8_t		mld2mar_type;	/* type of record		    */
1217c478bd9Sstevel@tonic-gate 	uint8_t		mld2mar_auxlen;	/* auxiliary data length	    */
1227c478bd9Sstevel@tonic-gate 	uint16_t	mld2mar_numsrc;	/* number of sources		    */
1237c478bd9Sstevel@tonic-gate 	struct in6_addr	mld2mar_group;	/* group address being reported	    */
1247c478bd9Sstevel@tonic-gate } mld2mar_t;
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate /* For router renumbering. */
1287c478bd9Sstevel@tonic-gate struct icmp6_router_renum {	/* router renumbering header */
1297c478bd9Sstevel@tonic-gate 	struct icmp6_hdr	rr_hdr;
1307c478bd9Sstevel@tonic-gate 	uint8_t			rr_segnum;
1317c478bd9Sstevel@tonic-gate 	uint8_t			rr_flags;
1327c478bd9Sstevel@tonic-gate 	uint16_t		rr_maxdelay;
1337c478bd9Sstevel@tonic-gate 	uint32_t		rr_reserved;
1347c478bd9Sstevel@tonic-gate };
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate #define	rr_type		rr_hdr.icmp6_type
1377c478bd9Sstevel@tonic-gate #define	rr_code		rr_hdr.icmp6_code
1387c478bd9Sstevel@tonic-gate #define	rr_cksum	rr_hdr.icmp6_cksum
1397c478bd9Sstevel@tonic-gate #define	rr_seqnum	rr_hdr.icmp6_data32[0]
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate /* Router renumbering flags */
1427c478bd9Sstevel@tonic-gate #define	ICMP6_RR_FLAGS_TEST		0x80
1437c478bd9Sstevel@tonic-gate #define	ICMP6_RR_FLAGS_REQRESULT	0x40
1447c478bd9Sstevel@tonic-gate #define	ICMP6_RR_FLAGS_FORCEAPPLY	0x20
1457c478bd9Sstevel@tonic-gate #define	ICMP6_RR_FLAGS_SPECSITE		0x10
1467c478bd9Sstevel@tonic-gate #define	ICMP6_RR_FLAGS_PREVDONE		0x08
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate struct rr_pco_match {	/* match prefix part */
1497c478bd9Sstevel@tonic-gate 	uint8_t			rpm_code;
1507c478bd9Sstevel@tonic-gate 	uint8_t			rpm_len;
1517c478bd9Sstevel@tonic-gate 	uint8_t			rpm_ordinal;
1527c478bd9Sstevel@tonic-gate 	uint8_t			rpm_matchlen;
1537c478bd9Sstevel@tonic-gate 	uint8_t			rpm_minlen;
1547c478bd9Sstevel@tonic-gate 	uint8_t			rpm_maxlen;
1557c478bd9Sstevel@tonic-gate 	uint16_t		rpm_reserved;
1567c478bd9Sstevel@tonic-gate 	struct in6_addr		rpm_prefix;
1577c478bd9Sstevel@tonic-gate };
1587c478bd9Sstevel@tonic-gate 
1597c478bd9Sstevel@tonic-gate /* PCO code values */
1607c478bd9Sstevel@tonic-gate #define	RPM_PCO_ADD			1
1617c478bd9Sstevel@tonic-gate #define	RPM_PCO_CHANGE			2
1627c478bd9Sstevel@tonic-gate #define	RPM_PCO_SETGLOBAL		3
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate struct rr_pco_use {	/* use prefix part */
1657c478bd9Sstevel@tonic-gate 	uint8_t			rpu_uselen;
1667c478bd9Sstevel@tonic-gate 	uint8_t			rpu_keeplen;
1677c478bd9Sstevel@tonic-gate 	uint8_t			rpu_ramask;
1687c478bd9Sstevel@tonic-gate 	uint8_t			rpu_raflags;
1697c478bd9Sstevel@tonic-gate 	uint32_t		rpu_vltime;
1707c478bd9Sstevel@tonic-gate 	uint32_t		rpu_pltime;
1717c478bd9Sstevel@tonic-gate 	uint32_t		rpu_flags;
1727c478bd9Sstevel@tonic-gate 	struct in6_addr		rpu_prefix;
1737c478bd9Sstevel@tonic-gate };
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate #define	ICMP6_RR_PCOUSE_RAFLAGS_ONLINK	0x20
1767c478bd9Sstevel@tonic-gate #define	ICMP6_RR_PCOUSE_RAFLAGS_AUTO	0x10
1777c478bd9Sstevel@tonic-gate 
1787c478bd9Sstevel@tonic-gate #ifdef _BIG_ENDIAN
1797c478bd9Sstevel@tonic-gate #define	ICMP_RR_PCOUSE_FLAGS_DECRVLTIME	0x80000000
1807c478bd9Sstevel@tonic-gate #define	ICMP_RR_PCOUSE_FLAGS_DECRPLTIME	0x40000000
1817c478bd9Sstevel@tonic-gate #else /* _BIG_ENDIAN */
1827c478bd9Sstevel@tonic-gate #define	ICMP_RR_PCOUSE_FLAGS_DECRVLTIME	0x80
1837c478bd9Sstevel@tonic-gate #define	ICMP_RR_PCOUSE_FLAGS_DECRPLTIME	0x40
1847c478bd9Sstevel@tonic-gate #endif /* _BIG_ENDIAN */
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate struct rr_result {	/* router renumbering result message */
1877c478bd9Sstevel@tonic-gate 	uint16_t		rrr_flags;
1887c478bd9Sstevel@tonic-gate 	uint8_t			rrr_ordinal;
1897c478bd9Sstevel@tonic-gate 	uint8_t			rrr_matchedlen;
1907c478bd9Sstevel@tonic-gate 	uint32_t		rrr_ifid;
1917c478bd9Sstevel@tonic-gate 	struct in6_addr		rrr_prefix;
1927c478bd9Sstevel@tonic-gate };
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate #ifdef _BIG_ENDIAN
1957c478bd9Sstevel@tonic-gate #define	ICMP6_RR_RESULT_FLAGS_OOB	0x0002
1967c478bd9Sstevel@tonic-gate #define	ICMP6_RR_RESULT_FLAGS_FORBIDDEN	0x0001
1977c478bd9Sstevel@tonic-gate #else /* _BIG_ENDIAN */
1987c478bd9Sstevel@tonic-gate #define	ICMP6_RR_RESULT_FLAGS_OOB	0x0200
1997c478bd9Sstevel@tonic-gate #define	ICMP6_RR_RESULT_FLAGS_FORBIDDEN	0x0100
2007c478bd9Sstevel@tonic-gate #endif /* _BIG_ENDIAN */
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate /* ICMPv6 error types */
2037c478bd9Sstevel@tonic-gate #define	ICMP6_DST_UNREACH		1
2047c478bd9Sstevel@tonic-gate #define	ICMP6_PACKET_TOO_BIG		2
2057c478bd9Sstevel@tonic-gate #define	ICMP6_TIME_EXCEEDED		3
2067c478bd9Sstevel@tonic-gate #define	ICMP6_PARAM_PROB		4
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate #define	ICMP6_INFOMSG_MASK		0x80 /* all informational messages */
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate /* ICMPv6 query types */
2117c478bd9Sstevel@tonic-gate #define	ICMP6_ECHO_REQUEST		128
2127c478bd9Sstevel@tonic-gate #define	ICMP6_ECHO_REPLY		129
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate /*
2157c478bd9Sstevel@tonic-gate  * ICMPv6 group membership types
2167c478bd9Sstevel@tonic-gate  * ICMP6_MEMBERSHIP* types are the older names for these constants and should
2177c478bd9Sstevel@tonic-gate  * not be used in new code.
2187c478bd9Sstevel@tonic-gate  */
2197c478bd9Sstevel@tonic-gate #define	MLD_LISTENER_QUERY		130
2207c478bd9Sstevel@tonic-gate #define	ICMP6_MEMBERSHIP_QUERY		130
2217c478bd9Sstevel@tonic-gate #define	MLD_LISTENER_REPORT		131
2227c478bd9Sstevel@tonic-gate #define	ICMP6_MEMBERSHIP_REPORT		131
2237c478bd9Sstevel@tonic-gate #define	MLD_LISTENER_REDUCTION		132
2247c478bd9Sstevel@tonic-gate #define	ICMP6_MEMBERSHIP_REDUCTION	132
2257c478bd9Sstevel@tonic-gate #define	MLD_V2_LISTENER_REPORT		143
2267c478bd9Sstevel@tonic-gate 
2277c478bd9Sstevel@tonic-gate /* types for neighbor discovery */
2287c478bd9Sstevel@tonic-gate #define	ND_ROUTER_SOLICIT		133
2297c478bd9Sstevel@tonic-gate #define	ND_ROUTER_ADVERT		134
2307c478bd9Sstevel@tonic-gate #define	ND_NEIGHBOR_SOLICIT		135
2317c478bd9Sstevel@tonic-gate #define	ND_NEIGHBOR_ADVERT		136
2327c478bd9Sstevel@tonic-gate #define	ND_REDIRECT			137
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate /* router renumbering */
2357c478bd9Sstevel@tonic-gate #define	ICMP6_ROUTER_RENUMBERING	138
2367c478bd9Sstevel@tonic-gate 
2377c478bd9Sstevel@tonic-gate #define	ICMP6_MAX_INFO_TYPE		138
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate #define	ICMP6_IS_ERROR(x) ((x) < 128)
2407c478bd9Sstevel@tonic-gate 
2417c478bd9Sstevel@tonic-gate /* codes for ICMP6_DST_UNREACH */
2427c478bd9Sstevel@tonic-gate #define	ICMP6_DST_UNREACH_NOROUTE	0 /* no route to destination */
2437c478bd9Sstevel@tonic-gate #define	ICMP6_DST_UNREACH_ADMIN		1 /* communication with destination */
2447c478bd9Sstevel@tonic-gate 					/* administratively prohibited */
2457c478bd9Sstevel@tonic-gate #define	ICMP6_DST_UNREACH_NOTNEIGHBOR	2 /* not a neighbor */
2467c478bd9Sstevel@tonic-gate #define	ICMP6_DST_UNREACH_BEYONDSCOPE	2 /* beyond scope of source */
2477c478bd9Sstevel@tonic-gate #define	ICMP6_DST_UNREACH_ADDR		3 /* address unreachable */
2487c478bd9Sstevel@tonic-gate #define	ICMP6_DST_UNREACH_NOPORT	4 /* bad port */
2497c478bd9Sstevel@tonic-gate 
2507c478bd9Sstevel@tonic-gate /* codes for ICMP6_TIME_EXCEEDED */
2517c478bd9Sstevel@tonic-gate #define	ICMP6_TIME_EXCEED_TRANSIT	0 /* Hop Limit == 0 in transit */
2527c478bd9Sstevel@tonic-gate #define	ICMP6_TIME_EXCEED_REASSEMBLY	1 /* Reassembly time out */
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate /* codes for ICMP6_PARAM_PROB */
2557c478bd9Sstevel@tonic-gate #define	ICMP6_PARAMPROB_HEADER		0 /* erroneous header field */
2567c478bd9Sstevel@tonic-gate #define	ICMP6_PARAMPROB_NEXTHEADER	1 /* unrecognized Next Header */
2577c478bd9Sstevel@tonic-gate #define	ICMP6_PARAMPROB_OPTION		2 /* unrecognized IPv6 option */
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate /* Default MLD max report delay value */
2607c478bd9Sstevel@tonic-gate #define	ICMP6_MAX_HOST_REPORT_DELAY	10	/* max delay for response to */
2617c478bd9Sstevel@tonic-gate 						/* query (in seconds)   */
2627c478bd9Sstevel@tonic-gate 
2637c478bd9Sstevel@tonic-gate typedef struct nd_router_solicit {	/* router solicitation */
2647c478bd9Sstevel@tonic-gate 	icmp6_t		nd_rs_hdr;
2657c478bd9Sstevel@tonic-gate 	/* could be followed by options */
2667c478bd9Sstevel@tonic-gate } nd_router_solicit_t;
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate #define	nd_rs_type	nd_rs_hdr.icmp6_type
2697c478bd9Sstevel@tonic-gate #define	nd_rs_code	nd_rs_hdr.icmp6_code
2707c478bd9Sstevel@tonic-gate #define	nd_rs_cksum	nd_rs_hdr.icmp6_cksum
2717c478bd9Sstevel@tonic-gate #define	nd_rs_reserved	nd_rs_hdr.icmp6_data32[0]
2727c478bd9Sstevel@tonic-gate 
2737c478bd9Sstevel@tonic-gate typedef struct nd_router_advert {	/* router advertisement */
2747c478bd9Sstevel@tonic-gate 	icmp6_t		nd_ra_hdr;
2757c478bd9Sstevel@tonic-gate 	uint32_t	nd_ra_reachable;   /* reachable time */
2767c478bd9Sstevel@tonic-gate 	uint32_t	nd_ra_retransmit;  /* retransmit timer */
2777c478bd9Sstevel@tonic-gate 	/* could be followed by options */
2787c478bd9Sstevel@tonic-gate } nd_router_advert_t;
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate #define	nd_ra_type		nd_ra_hdr.icmp6_type
2817c478bd9Sstevel@tonic-gate #define	nd_ra_code		nd_ra_hdr.icmp6_code
2827c478bd9Sstevel@tonic-gate #define	nd_ra_cksum		nd_ra_hdr.icmp6_cksum
2837c478bd9Sstevel@tonic-gate #define	nd_ra_curhoplimit	nd_ra_hdr.icmp6_data8[0]
2847c478bd9Sstevel@tonic-gate #define	nd_ra_flags_reserved	nd_ra_hdr.icmp6_data8[1]
2857c478bd9Sstevel@tonic-gate 
2867c478bd9Sstevel@tonic-gate #define	ND_RA_FLAG_OTHER	0x40
2877c478bd9Sstevel@tonic-gate #define	ND_RA_FLAG_MANAGED	0x80
2887c478bd9Sstevel@tonic-gate 
2897c478bd9Sstevel@tonic-gate #define	nd_ra_router_lifetime    nd_ra_hdr.icmp6_data16[1]
2907c478bd9Sstevel@tonic-gate 
2917c478bd9Sstevel@tonic-gate typedef struct nd_neighbor_solicit {   /* neighbor solicitation */
2927c478bd9Sstevel@tonic-gate 	icmp6_t		nd_ns_hdr;
2937c478bd9Sstevel@tonic-gate 	struct in6_addr nd_ns_target; /* target address */
2947c478bd9Sstevel@tonic-gate 	/* could be followed by options */
2957c478bd9Sstevel@tonic-gate } nd_neighbor_solicit_t;
2967c478bd9Sstevel@tonic-gate 
2977c478bd9Sstevel@tonic-gate #define	nd_ns_type		nd_ns_hdr.icmp6_type
2987c478bd9Sstevel@tonic-gate #define	nd_ns_code		nd_ns_hdr.icmp6_code
2997c478bd9Sstevel@tonic-gate #define	nd_ns_cksum		nd_ns_hdr.icmp6_cksum
3007c478bd9Sstevel@tonic-gate #define	nd_ns_reserved		nd_ns_hdr.icmp6_data32[0]
3017c478bd9Sstevel@tonic-gate 
3027c478bd9Sstevel@tonic-gate typedef struct nd_neighbor_advert {	/* neighbor advertisement */
3037c478bd9Sstevel@tonic-gate 	icmp6_t		  nd_na_hdr;
3047c478bd9Sstevel@tonic-gate 	struct in6_addr   nd_na_target; /* target address */
3057c478bd9Sstevel@tonic-gate 	/* could be followed by options */
3067c478bd9Sstevel@tonic-gate } nd_neighbor_advert_t;
3077c478bd9Sstevel@tonic-gate 
3087c478bd9Sstevel@tonic-gate #define	nd_na_type	nd_na_hdr.icmp6_type
3097c478bd9Sstevel@tonic-gate #define	nd_na_code	nd_na_hdr.icmp6_code
3107c478bd9Sstevel@tonic-gate #define	nd_na_cksum	nd_na_hdr.icmp6_cksum
3117c478bd9Sstevel@tonic-gate 
3127c478bd9Sstevel@tonic-gate #define	nd_na_flags_reserved	nd_na_hdr.icmp6_data32[0]
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate /*
3157c478bd9Sstevel@tonic-gate  * The first three bits of the flgs_reserved field of the ND structure are
3167c478bd9Sstevel@tonic-gate  * defined in this order:
3177c478bd9Sstevel@tonic-gate  *	Router flag
3187c478bd9Sstevel@tonic-gate  *	Solicited flag
3197c478bd9Sstevel@tonic-gate  * 	Override flag
3207c478bd9Sstevel@tonic-gate  */
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate /* Save valuable htonl() cycles on little-endian boxen. */
3237c478bd9Sstevel@tonic-gate 
3247c478bd9Sstevel@tonic-gate #ifdef _BIG_ENDIAN
3257c478bd9Sstevel@tonic-gate 
3267c478bd9Sstevel@tonic-gate #define	ND_NA_FLAG_ROUTER	0x80000000
3277c478bd9Sstevel@tonic-gate #define	ND_NA_FLAG_SOLICITED	0x40000000
3287c478bd9Sstevel@tonic-gate #define	ND_NA_FLAG_OVERRIDE	0x20000000
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate #else /* _BIG_ENDIAN */
3317c478bd9Sstevel@tonic-gate 
3327c478bd9Sstevel@tonic-gate #define	ND_NA_FLAG_ROUTER	0x80
3337c478bd9Sstevel@tonic-gate #define	ND_NA_FLAG_SOLICITED	0x40
3347c478bd9Sstevel@tonic-gate #define	ND_NA_FLAG_OVERRIDE	0x20
3357c478bd9Sstevel@tonic-gate 
3367c478bd9Sstevel@tonic-gate #endif /* _BIG_ENDIAN */
3377c478bd9Sstevel@tonic-gate 
3387c478bd9Sstevel@tonic-gate typedef struct nd_redirect {	/* redirect */
3397c478bd9Sstevel@tonic-gate 	icmp6_t		nd_rd_hdr;
3407c478bd9Sstevel@tonic-gate 	struct in6_addr	nd_rd_target; /* target address */
3417c478bd9Sstevel@tonic-gate 	struct in6_addr	nd_rd_dst;    /* destination address */
3427c478bd9Sstevel@tonic-gate 	/* could be followed by options */
3437c478bd9Sstevel@tonic-gate } nd_redirect_t;
3447c478bd9Sstevel@tonic-gate 
3457c478bd9Sstevel@tonic-gate #define	nd_rd_type	nd_rd_hdr.icmp6_type
3467c478bd9Sstevel@tonic-gate #define	nd_rd_code	nd_rd_hdr.icmp6_code
3477c478bd9Sstevel@tonic-gate #define	nd_rd_cksum	nd_rd_hdr.icmp6_cksum
3487c478bd9Sstevel@tonic-gate #define	nd_rd_reserved	nd_rd_hdr.icmp6_data32[0]
3497c478bd9Sstevel@tonic-gate 
3507c478bd9Sstevel@tonic-gate typedef struct nd_opt_hdr {	/* Neighbor discovery option header */
3517c478bd9Sstevel@tonic-gate 	uint8_t	nd_opt_type;
3527c478bd9Sstevel@tonic-gate 	uint8_t	nd_opt_len;	/* in units of 8 octets */
3537c478bd9Sstevel@tonic-gate 	/* followed by option specific data */
3547c478bd9Sstevel@tonic-gate } nd_opt_hdr_t;
3557c478bd9Sstevel@tonic-gate 
3567c478bd9Sstevel@tonic-gate /* Neighbor discovery option types */
3577c478bd9Sstevel@tonic-gate #define	ND_OPT_SOURCE_LINKADDR		1
3587c478bd9Sstevel@tonic-gate #define	ND_OPT_TARGET_LINKADDR		2
3597c478bd9Sstevel@tonic-gate #define	ND_OPT_PREFIX_INFORMATION	3
3607c478bd9Sstevel@tonic-gate #define	ND_OPT_REDIRECTED_HEADER	4
3617c478bd9Sstevel@tonic-gate #define	ND_OPT_MTU			5
3627c478bd9Sstevel@tonic-gate 
3637c478bd9Sstevel@tonic-gate typedef struct nd_opt_prefix_info {	/* prefix information */
3647c478bd9Sstevel@tonic-gate 	uint8_t   nd_opt_pi_type;
3657c478bd9Sstevel@tonic-gate 	uint8_t   nd_opt_pi_len;
3667c478bd9Sstevel@tonic-gate 	uint8_t   nd_opt_pi_prefix_len;
3677c478bd9Sstevel@tonic-gate 	uint8_t   nd_opt_pi_flags_reserved;
3687c478bd9Sstevel@tonic-gate 	uint32_t  nd_opt_pi_valid_time;
3697c478bd9Sstevel@tonic-gate 	uint32_t  nd_opt_pi_preferred_time;
3707c478bd9Sstevel@tonic-gate 	uint32_t  nd_opt_pi_reserved2;
3717c478bd9Sstevel@tonic-gate 	struct in6_addr  nd_opt_pi_prefix;
3727c478bd9Sstevel@tonic-gate } nd_opt_prefix_info_t;
3737c478bd9Sstevel@tonic-gate 
3747c478bd9Sstevel@tonic-gate #define	ND_OPT_PI_FLAG_AUTO	0x40
3757c478bd9Sstevel@tonic-gate #define	ND_OPT_PI_FLAG_ONLINK	0x80
3767c478bd9Sstevel@tonic-gate 
3777c478bd9Sstevel@tonic-gate typedef struct nd_opt_rd_hdr {	/* redirected header */
3787c478bd9Sstevel@tonic-gate 	uint8_t   nd_opt_rh_type;
3797c478bd9Sstevel@tonic-gate 	uint8_t   nd_opt_rh_len;
3807c478bd9Sstevel@tonic-gate 	uint16_t  nd_opt_rh_reserved1;
3817c478bd9Sstevel@tonic-gate 	uint32_t  nd_opt_rh_reserved2;
3827c478bd9Sstevel@tonic-gate 	/* followed by IP header and data */
3837c478bd9Sstevel@tonic-gate } nd_opt_rd_hdr_t;
3847c478bd9Sstevel@tonic-gate 
3857c478bd9Sstevel@tonic-gate typedef struct nd_opt_mtu {	/* MTU option */
3867c478bd9Sstevel@tonic-gate 	uint8_t   nd_opt_mtu_type;
3877c478bd9Sstevel@tonic-gate 	uint8_t   nd_opt_mtu_len;
3887c478bd9Sstevel@tonic-gate 	uint16_t  nd_opt_mtu_reserved;
3897c478bd9Sstevel@tonic-gate 	uint32_t  nd_opt_mtu_mtu;
3907c478bd9Sstevel@tonic-gate } nd_opt_mtu_t;
3917c478bd9Sstevel@tonic-gate 
3927c478bd9Sstevel@tonic-gate /* Note: the option is variable length (at least 8 bytes long) */
3937c478bd9Sstevel@tonic-gate #ifndef ND_MAX_HDW_LEN
3947c478bd9Sstevel@tonic-gate #define	ND_MAX_HDW_LEN	64
3957c478bd9Sstevel@tonic-gate #endif
3967c478bd9Sstevel@tonic-gate struct nd_opt_lla {
3977c478bd9Sstevel@tonic-gate 	uint8_t	nd_opt_lla_type;
3987c478bd9Sstevel@tonic-gate 	uint8_t	nd_opt_lla_len;	/* in units of 8 octets */
3997c478bd9Sstevel@tonic-gate 	uint8_t	nd_opt_lla_hdw_addr[ND_MAX_HDW_LEN];
4007c478bd9Sstevel@tonic-gate };
4017c478bd9Sstevel@tonic-gate 
4027c478bd9Sstevel@tonic-gate 
4037c478bd9Sstevel@tonic-gate /* Neighbor discovery protocol constants */
4047c478bd9Sstevel@tonic-gate 
4057c478bd9Sstevel@tonic-gate /* Router constants */
4067c478bd9Sstevel@tonic-gate #define	ND_MAX_INITIAL_RTR_ADVERT_INTERVAL	16000	/* milliseconds */
4077c478bd9Sstevel@tonic-gate #define	ND_MAX_INITIAL_RTR_ADVERTISEMENTS	3	/* transmissions */
4087c478bd9Sstevel@tonic-gate #define	ND_MAX_FINAL_RTR_ADVERTISEMENTS		3	/* transmissions */
4097c478bd9Sstevel@tonic-gate #define	ND_MIN_DELAY_BETWEEN_RAS		3000	/* milliseconds */
4107c478bd9Sstevel@tonic-gate #define	ND_MAX_RA_DELAY_TIME			500	/* milliseconds */
4117c478bd9Sstevel@tonic-gate 
4127c478bd9Sstevel@tonic-gate /* Host constants */
4137c478bd9Sstevel@tonic-gate #define	ND_MAX_RTR_SOLICITATION_DELAY		1000	/* milliseconds */
4147c478bd9Sstevel@tonic-gate #define	ND_RTR_SOLICITATION_INTERVAL		4000	/* milliseconds */
4157c478bd9Sstevel@tonic-gate #define	ND_MAX_RTR_SOLICITATIONS		3	/* transmissions */
4167c478bd9Sstevel@tonic-gate 
4177c478bd9Sstevel@tonic-gate /* Node constants */
4187c478bd9Sstevel@tonic-gate #define	ND_MAX_MULTICAST_SOLICIT		3	/* transmissions */
4197c478bd9Sstevel@tonic-gate #define	ND_MAX_UNICAST_SOLICIT			3	/* transmissions */
4207c478bd9Sstevel@tonic-gate #define	ND_MAX_ANYCAST_DELAY_TIME		1000	/* milliseconds */
4217c478bd9Sstevel@tonic-gate #define	ND_MAX_NEIGHBOR_ADVERTISEMENT		3	/* transmissions */
4227c478bd9Sstevel@tonic-gate #define	ND_REACHABLE_TIME			30000	/* milliseconds */
4237c478bd9Sstevel@tonic-gate #define	ND_RETRANS_TIMER			1000	/* milliseconds */
4247c478bd9Sstevel@tonic-gate #define	ND_DELAY_FIRST_PROBE_TIME		5000	/* milliseconds */
4257c478bd9Sstevel@tonic-gate #define	ND_MIN_RANDOM_FACTOR			.5
4267c478bd9Sstevel@tonic-gate #define	ND_MAX_RANDOM_FACTOR			1.5
4277c478bd9Sstevel@tonic-gate 
4287c478bd9Sstevel@tonic-gate #define	ND_MAX_REACHTIME			3600000	/* milliseconds */
4297c478bd9Sstevel@tonic-gate #define	ND_MAX_REACHRETRANSTIME			100000	/* milliseconds */
4307c478bd9Sstevel@tonic-gate 
4317c478bd9Sstevel@tonic-gate /*
4327c478bd9Sstevel@tonic-gate  * ICMPv6 type filtering for IPPROTO_ICMPV6 ICMP6_FILTER socket option
4337c478bd9Sstevel@tonic-gate  */
4347c478bd9Sstevel@tonic-gate #define	ICMP6_FILTER	0x01	/* Set filter */
4357c478bd9Sstevel@tonic-gate 
4367c478bd9Sstevel@tonic-gate typedef struct icmp6_filter {
4377c478bd9Sstevel@tonic-gate 	uint32_t	__icmp6_filt[8];
4387c478bd9Sstevel@tonic-gate } icmp6_filter_t;
4397c478bd9Sstevel@tonic-gate 
4407c478bd9Sstevel@tonic-gate /* Pass all ICMPv6 messages to the application */
4417c478bd9Sstevel@tonic-gate #define	ICMP6_FILTER_SETPASSALL(filterp) ( \
4427c478bd9Sstevel@tonic-gate 	((filterp)->__icmp6_filt[0] = 0xFFFFFFFFU), \
4437c478bd9Sstevel@tonic-gate 	((filterp)->__icmp6_filt[1] = 0xFFFFFFFFU), \
4447c478bd9Sstevel@tonic-gate 	((filterp)->__icmp6_filt[2] = 0xFFFFFFFFU), \
4457c478bd9Sstevel@tonic-gate 	((filterp)->__icmp6_filt[3] = 0xFFFFFFFFU), \
4467c478bd9Sstevel@tonic-gate 	((filterp)->__icmp6_filt[4] = 0xFFFFFFFFU), \
4477c478bd9Sstevel@tonic-gate 	((filterp)->__icmp6_filt[5] = 0xFFFFFFFFU), \
4487c478bd9Sstevel@tonic-gate 	((filterp)->__icmp6_filt[6] = 0xFFFFFFFFU), \
4497c478bd9Sstevel@tonic-gate 	((filterp)->__icmp6_filt[7] = 0xFFFFFFFFU))
4507c478bd9Sstevel@tonic-gate 
4517c478bd9Sstevel@tonic-gate /* ICMPv6 messages are blocked from being passed to the application */
4527c478bd9Sstevel@tonic-gate #define	ICMP6_FILTER_SETBLOCKALL(filterp) ( \
4537c478bd9Sstevel@tonic-gate 	((filterp)->__icmp6_filt[0] = 0x0), \
4547c478bd9Sstevel@tonic-gate 	((filterp)->__icmp6_filt[1] = 0x0), \
4557c478bd9Sstevel@tonic-gate 	((filterp)->__icmp6_filt[2] = 0x0), \
4567c478bd9Sstevel@tonic-gate 	((filterp)->__icmp6_filt[3] = 0x0), \
4577c478bd9Sstevel@tonic-gate 	((filterp)->__icmp6_filt[4] = 0x0), \
4587c478bd9Sstevel@tonic-gate 	((filterp)->__icmp6_filt[5] = 0x0), \
4597c478bd9Sstevel@tonic-gate 	((filterp)->__icmp6_filt[6] = 0x0), \
4607c478bd9Sstevel@tonic-gate 	((filterp)->__icmp6_filt[7] = 0x0))
4617c478bd9Sstevel@tonic-gate 
4627c478bd9Sstevel@tonic-gate /* Pass messages of a given type to the application */
4637c478bd9Sstevel@tonic-gate #define	ICMP6_FILTER_SETPASS(type, filterp) \
4647c478bd9Sstevel@tonic-gate 	((((filterp)->__icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31))))
4657c478bd9Sstevel@tonic-gate 
4667c478bd9Sstevel@tonic-gate /* Block messages of a given type from being passed to the application */
4677c478bd9Sstevel@tonic-gate #define	ICMP6_FILTER_SETBLOCK(type, filterp) \
4687c478bd9Sstevel@tonic-gate 	((((filterp)->__icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))))
4697c478bd9Sstevel@tonic-gate 
4707c478bd9Sstevel@tonic-gate /* Test if message of a given type will be passed to an application */
4717c478bd9Sstevel@tonic-gate #define	ICMP6_FILTER_WILLPASS(type, filterp) \
4727c478bd9Sstevel@tonic-gate 	((((filterp)->__icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
4737c478bd9Sstevel@tonic-gate 
4747c478bd9Sstevel@tonic-gate /*
4757c478bd9Sstevel@tonic-gate  * Test if message of a given type will blocked from
4767c478bd9Sstevel@tonic-gate  * being passed to an application
4777c478bd9Sstevel@tonic-gate  */
4787c478bd9Sstevel@tonic-gate #define	ICMP6_FILTER_WILLBLOCK(type, filterp) \
4797c478bd9Sstevel@tonic-gate 	((((filterp)->__icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
4807c478bd9Sstevel@tonic-gate 
481*0f1702c5SYu Xiangning #define	ICMP_IOC_DEFAULT_Q	(('I' << 8) + 51)
4827c478bd9Sstevel@tonic-gate 
4837c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
4847c478bd9Sstevel@tonic-gate }
4857c478bd9Sstevel@tonic-gate #endif
4867c478bd9Sstevel@tonic-gate 
4877c478bd9Sstevel@tonic-gate #endif /* _NETINET_ICMP6_H */
488