xref: /titanic_52/usr/src/uts/common/netinet/ip6.h (revision 45916cd2fec6e79bca5dee0421bd39e3c2910d1e)
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*45916cd2Sjpk  * Common Development and Distribution License (the "License").
6*45916cd2Sjpk  * 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*45916cd2Sjpk  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
277c478bd9Sstevel@tonic-gate  * ip6.h - Common structures and definitions as defined by
287c478bd9Sstevel@tonic-gate  * advanced BSD API.
297c478bd9Sstevel@tonic-gate  */
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifndef	_NETINET_IP6_H
327c478bd9Sstevel@tonic-gate #define	_NETINET_IP6_H
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
377c478bd9Sstevel@tonic-gate extern "C" {
387c478bd9Sstevel@tonic-gate #endif
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #include <sys/types.h>
417c478bd9Sstevel@tonic-gate #include <netinet/in.h>
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate struct	ip6_hdr {
447c478bd9Sstevel@tonic-gate 	union {
457c478bd9Sstevel@tonic-gate 		struct ip6_hdrctl {
467c478bd9Sstevel@tonic-gate 			uint32_t	ip6_un1_flow;   /* 4 bits version, */
477c478bd9Sstevel@tonic-gate 							/* 8 bits tclass, and */
487c478bd9Sstevel@tonic-gate 							/* 20 bits flow-ID */
497c478bd9Sstevel@tonic-gate 			uint16_t	ip6_un1_plen;   /* payload length */
507c478bd9Sstevel@tonic-gate 			uint8_t		ip6_un1_nxt;    /* next header */
517c478bd9Sstevel@tonic-gate 			uint8_t		ip6_un1_hlim;   /* hop limit */
527c478bd9Sstevel@tonic-gate 		} ip6_un1;
537c478bd9Sstevel@tonic-gate 		uint8_t	ip6_un2_vfc;	/* 4 bits version and */
547c478bd9Sstevel@tonic-gate 					/* top 4 bits of tclass */
557c478bd9Sstevel@tonic-gate 	} ip6_ctlun;
567c478bd9Sstevel@tonic-gate 	struct in6_addr ip6_src;	/* source address */
577c478bd9Sstevel@tonic-gate 	struct in6_addr ip6_dst;	/* destination address */
587c478bd9Sstevel@tonic-gate };
597c478bd9Sstevel@tonic-gate typedef struct ip6_hdr	ip6_t;
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate #define	ip6_vfc		ip6_ctlun.ip6_un2_vfc	/* 4 bits version and */
627c478bd9Sstevel@tonic-gate 						/* top 4 bits of tclass */
637c478bd9Sstevel@tonic-gate #define	ip6_flow	ip6_ctlun.ip6_un1.ip6_un1_flow
647c478bd9Sstevel@tonic-gate #define	ip6_vcf		ip6_flow		/* Version, tclass, flow-ID */
657c478bd9Sstevel@tonic-gate #define	ip6_plen	ip6_ctlun.ip6_un1.ip6_un1_plen
667c478bd9Sstevel@tonic-gate #define	ip6_nxt		ip6_ctlun.ip6_un1.ip6_un1_nxt
677c478bd9Sstevel@tonic-gate #define	ip6_hlim	ip6_ctlun.ip6_un1.ip6_un1_hlim
687c478bd9Sstevel@tonic-gate #define	ip6_hops	ip6_ctlun.ip6_un1.ip6_un1_hlim
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /* Hop-by-Hop options header */
717c478bd9Sstevel@tonic-gate struct ip6_hbh {
727c478bd9Sstevel@tonic-gate 	uint8_t	ip6h_nxt;	/* next header */
737c478bd9Sstevel@tonic-gate 	uint8_t	ip6h_len;	/* length in units of 8 octets */
747c478bd9Sstevel@tonic-gate 		/* followed by options */
757c478bd9Sstevel@tonic-gate };
767c478bd9Sstevel@tonic-gate typedef struct ip6_hbh	ip6_hbh_t;
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate /* Destination options header */
797c478bd9Sstevel@tonic-gate struct ip6_dest {
807c478bd9Sstevel@tonic-gate 	uint8_t	ip6d_nxt;	/* next header */
817c478bd9Sstevel@tonic-gate 	uint8_t	ip6d_len;	/* length in units of 8 octets */
827c478bd9Sstevel@tonic-gate 		/* followed by options */
837c478bd9Sstevel@tonic-gate };
847c478bd9Sstevel@tonic-gate typedef struct ip6_dest	ip6_dest_t;
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate /* Routing header */
877c478bd9Sstevel@tonic-gate struct ip6_rthdr {
887c478bd9Sstevel@tonic-gate 	uint8_t	ip6r_nxt;	/* next header */
897c478bd9Sstevel@tonic-gate 	uint8_t	ip6r_len;	/* length in units of 8 octets */
907c478bd9Sstevel@tonic-gate 	uint8_t	ip6r_type;	/* routing type */
917c478bd9Sstevel@tonic-gate 	uint8_t	ip6r_segleft;	/* segments left */
927c478bd9Sstevel@tonic-gate 		/* followed by routing type specific data */
937c478bd9Sstevel@tonic-gate };
947c478bd9Sstevel@tonic-gate typedef struct ip6_rthdr	ip6_rthdr_t;
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate /* Type 0 Routing header */
977c478bd9Sstevel@tonic-gate struct ip6_rthdr0 {
987c478bd9Sstevel@tonic-gate 	uint8_t	ip6r0_nxt;		/* next header */
997c478bd9Sstevel@tonic-gate 	uint8_t	ip6r0_len;		/* length in units of 8 octets */
1007c478bd9Sstevel@tonic-gate 	uint8_t	ip6r0_type;		/* always zero */
1017c478bd9Sstevel@tonic-gate 	uint8_t	ip6r0_segleft;		/* segments left */
1027c478bd9Sstevel@tonic-gate 	uint32_t ip6r0_reserved;	/* reserved field */
1037c478bd9Sstevel@tonic-gate };
1047c478bd9Sstevel@tonic-gate typedef struct ip6_rthdr0	ip6_rthdr0_t;
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate /* Fragment header */
1077c478bd9Sstevel@tonic-gate struct ip6_frag {
1087c478bd9Sstevel@tonic-gate 	uint8_t		ip6f_nxt;	/* next header */
1097c478bd9Sstevel@tonic-gate 	uint8_t		ip6f_reserved;	/* reserved field */
1107c478bd9Sstevel@tonic-gate 	uint16_t	ip6f_offlg;	/* offset, reserved, and flag */
1117c478bd9Sstevel@tonic-gate 	uint32_t	ip6f_ident;	/* identification */
1127c478bd9Sstevel@tonic-gate };
1137c478bd9Sstevel@tonic-gate typedef struct ip6_frag	ip6_frag_t;
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate /* ip6f_offlg field related constants (in network byte order) */
1167c478bd9Sstevel@tonic-gate #ifdef _BIG_ENDIAN
1177c478bd9Sstevel@tonic-gate #define	IP6F_OFF_MASK		0xfff8	/* mask out offset from _offlg */
1187c478bd9Sstevel@tonic-gate #define	IP6F_RESERVED_MASK	0x0006	/* reserved bits in ip6f_offlg */
1197c478bd9Sstevel@tonic-gate #define	IP6F_MORE_FRAG		0x0001	/* more-fragments flag */
1207c478bd9Sstevel@tonic-gate #else
1217c478bd9Sstevel@tonic-gate #define	IP6F_OFF_MASK		0xf8ff	/* mask out offset from _offlg */
1227c478bd9Sstevel@tonic-gate #define	IP6F_RESERVED_MASK	0x0600	/* reserved bits in ip6f_offlg */
1237c478bd9Sstevel@tonic-gate #define	IP6F_MORE_FRAG		0x0100	/* more-fragments flag */
1247c478bd9Sstevel@tonic-gate #endif
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate /* IPv6 options */
1277c478bd9Sstevel@tonic-gate struct	ip6_opt {
1287c478bd9Sstevel@tonic-gate 	uint8_t	ip6o_type;
1297c478bd9Sstevel@tonic-gate 	uint8_t	ip6o_len;
1307c478bd9Sstevel@tonic-gate };
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate /*
1337c478bd9Sstevel@tonic-gate  * The high-order 3 bits of the option type define the behavior
1347c478bd9Sstevel@tonic-gate  * when processing an unknown option and whether or not the option
1357c478bd9Sstevel@tonic-gate  * content changes in flight.
1367c478bd9Sstevel@tonic-gate  */
1377c478bd9Sstevel@tonic-gate #define	IP6OPT_TYPE(o)		((o) & 0xc0)
1387c478bd9Sstevel@tonic-gate #define	IP6OPT_TYPE_SKIP	0x00
1397c478bd9Sstevel@tonic-gate #define	IP6OPT_TYPE_DISCARD	0x40
1407c478bd9Sstevel@tonic-gate #define	IP6OPT_TYPE_FORCEICMP	0x80
1417c478bd9Sstevel@tonic-gate #define	IP6OPT_TYPE_ICMP	0xc0
1427c478bd9Sstevel@tonic-gate #define	IP6OPT_MUTABLE		0x20
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate #define	IP6OPT_PAD1			0x00	/* 00 0 00000 */
1457c478bd9Sstevel@tonic-gate #define	IP6OPT_PADN			0x01	/* 00 0 00001 */
1467c478bd9Sstevel@tonic-gate #define	IP6OPT_JUMBO			0xc2	/* 11 0 00010 = 194 */
1477c478bd9Sstevel@tonic-gate #define	IP6OPT_NSAP_ADDR		0xc3	/* 11 0 00011 */
1487c478bd9Sstevel@tonic-gate #define	IP6OPT_TUNNEL_LIMIT		0x04	/* 00 0 00100 */
1497c478bd9Sstevel@tonic-gate #define	IP6OPT_ROUTER_ALERT		0x05	/* 00 0 00101 */
1507c478bd9Sstevel@tonic-gate #define	IP6OPT_BINDING_UPDATE		0xc6	/* 11 0 00110 */
1517c478bd9Sstevel@tonic-gate #define	IP6OPT_BINDING_ACK		0x07	/* 00 0 00111 */
1527c478bd9Sstevel@tonic-gate #define	IP6OPT_BINDING_REQ		0x08	/* 00 0 01000 */
1537c478bd9Sstevel@tonic-gate #define	IP6OPT_HOME_ADDRESS		0xc9	/* 11 0 01001 */
1547c478bd9Sstevel@tonic-gate #define	IP6OPT_EID			0x8a	/* 10 0 01010 */
1557c478bd9Sstevel@tonic-gate 
156*45916cd2Sjpk #define	IP6OPT_LS			0x0a	/* 00 0 01010 */
157*45916cd2Sjpk 
158*45916cd2Sjpk #define	IP6_MAX_OPT_LENGTH	255
159*45916cd2Sjpk 
1607c478bd9Sstevel@tonic-gate /* Jumbo Payload Option */
1617c478bd9Sstevel@tonic-gate struct	ip6_opt_jumbo {
1627c478bd9Sstevel@tonic-gate 	uint8_t	ip6oj_type;
1637c478bd9Sstevel@tonic-gate 	uint8_t	ip6oj_len;
1647c478bd9Sstevel@tonic-gate 	uint8_t ip6oj_jumbo_len[4];
1657c478bd9Sstevel@tonic-gate };
1667c478bd9Sstevel@tonic-gate #define	IP6OPT_JUMBO_LEN	6
1677c478bd9Sstevel@tonic-gate 
1687c478bd9Sstevel@tonic-gate /* NSAP Address Option */
1697c478bd9Sstevel@tonic-gate struct	ip6_opt_nsap {
1707c478bd9Sstevel@tonic-gate 	uint8_t	ip6on_type;
1717c478bd9Sstevel@tonic-gate 	uint8_t	ip6on_len;
1727c478bd9Sstevel@tonic-gate 	uint8_t ip6on_src_nsap_len;
1737c478bd9Sstevel@tonic-gate 	uint8_t ip6on_dst_nsap_len;
1747c478bd9Sstevel@tonic-gate 	/* Followed by source NSAP */
1757c478bd9Sstevel@tonic-gate 	/* Followed by destination NSAP */
1767c478bd9Sstevel@tonic-gate };
1777c478bd9Sstevel@tonic-gate 
1787c478bd9Sstevel@tonic-gate /* Tunnel Limit Option */
1797c478bd9Sstevel@tonic-gate struct	ip6_opt_tunnel {
1807c478bd9Sstevel@tonic-gate 	uint8_t	ip6ot_type;
1817c478bd9Sstevel@tonic-gate 	uint8_t	ip6ot_len;
1827c478bd9Sstevel@tonic-gate 	uint8_t ip6ot_encap_limit;
1837c478bd9Sstevel@tonic-gate };
1847c478bd9Sstevel@tonic-gate 
1857c478bd9Sstevel@tonic-gate /* Router Alert Option */
1867c478bd9Sstevel@tonic-gate struct	ip6_opt_router {
1877c478bd9Sstevel@tonic-gate 	uint8_t	ip6or_type;
1887c478bd9Sstevel@tonic-gate 	uint8_t	ip6or_len;
1897c478bd9Sstevel@tonic-gate 	uint8_t ip6or_value[2];
1907c478bd9Sstevel@tonic-gate };
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate /* Router alert values (in network byte order) */
1937c478bd9Sstevel@tonic-gate #ifdef _BIG_ENDIAN
1947c478bd9Sstevel@tonic-gate #define	IP6_ALERT_MLD			0x0000
1957c478bd9Sstevel@tonic-gate #define	IP6_ALERT_RSVP			0x0001
1967c478bd9Sstevel@tonic-gate #define	IP6_ALERT_AN			0x0002
1977c478bd9Sstevel@tonic-gate #else
1987c478bd9Sstevel@tonic-gate #define	IP6_ALERT_MLD			0x0000
1997c478bd9Sstevel@tonic-gate #define	IP6_ALERT_RSVP			0x0100
2007c478bd9Sstevel@tonic-gate #define	IP6_ALERT_AN			0x0200
2017c478bd9Sstevel@tonic-gate #endif
2027c478bd9Sstevel@tonic-gate 
2037c478bd9Sstevel@tonic-gate /* Binding Update Option */
2047c478bd9Sstevel@tonic-gate struct	ip6_opt_binding_update {
2057c478bd9Sstevel@tonic-gate 	uint8_t	ip6ou_type;
2067c478bd9Sstevel@tonic-gate 	uint8_t	ip6ou_len;
2077c478bd9Sstevel@tonic-gate 	uint8_t ip6ou_flags;
2087c478bd9Sstevel@tonic-gate 	uint8_t ip6ou_prefixlen;
2097c478bd9Sstevel@tonic-gate 	uint8_t ip6ou_seqno[2];
2107c478bd9Sstevel@tonic-gate 	uint8_t ip6ou_lifetime[4];
2117c478bd9Sstevel@tonic-gate 	uint8_t ip6ou_coa[16];		/* Optional based on flags */
2127c478bd9Sstevel@tonic-gate 	/* Followed by sub-options */
2137c478bd9Sstevel@tonic-gate };
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate /* Binding Update Flags */
2167c478bd9Sstevel@tonic-gate #define	IP6_BUF_ACK	0x80	/* Request a binding ack */
2177c478bd9Sstevel@tonic-gate #define	IP6_BUF_HOME	0x40	/* Home Registration */
2187c478bd9Sstevel@tonic-gate #define	IP6_BUF_COA	0x20	/* Care-of-address present in option */
2197c478bd9Sstevel@tonic-gate #define	IP6_BUF_ROUTER	0x10	/* Sending mobile node is a router */
2207c478bd9Sstevel@tonic-gate 
2217c478bd9Sstevel@tonic-gate /* Binding Ack Option */
2227c478bd9Sstevel@tonic-gate struct	ip6_opt_binding_ack {
2237c478bd9Sstevel@tonic-gate 	uint8_t	ip6oa_type;
2247c478bd9Sstevel@tonic-gate 	uint8_t	ip6oa_len;
2257c478bd9Sstevel@tonic-gate 	uint8_t ip6oa_status;
2267c478bd9Sstevel@tonic-gate 	uint8_t ip6oa_seqno[2];
2277c478bd9Sstevel@tonic-gate 	uint8_t ip6oa_lifetime[4];
2287c478bd9Sstevel@tonic-gate 	uint8_t ip6oa_refresh[4];
2297c478bd9Sstevel@tonic-gate 	/* Followed by sub-options */
2307c478bd9Sstevel@tonic-gate };
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate /* Binding Request Option */
2337c478bd9Sstevel@tonic-gate struct	ip6_opt_binding_request {
2347c478bd9Sstevel@tonic-gate 	uint8_t	ip6or_type;
2357c478bd9Sstevel@tonic-gate 	uint8_t	ip6or_len;
2367c478bd9Sstevel@tonic-gate 	/* Followed by sub-options */
2377c478bd9Sstevel@tonic-gate };
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate /* Home Address Option */
2407c478bd9Sstevel@tonic-gate struct	ip6_opt_home_address {
2417c478bd9Sstevel@tonic-gate 	uint8_t	ip6oh_type;
2427c478bd9Sstevel@tonic-gate 	uint8_t	ip6oh_len;
2437c478bd9Sstevel@tonic-gate 	uint8_t ip6oh_addr[16];		/* Home Address */
2447c478bd9Sstevel@tonic-gate 	/* Followed by sub-options */
2457c478bd9Sstevel@tonic-gate };
2467c478bd9Sstevel@tonic-gate 
247*45916cd2Sjpk /* Labeled Security Option */
248*45916cd2Sjpk struct	ip6_opt_labeled_security {
249*45916cd2Sjpk 	uint8_t ip6ol_type;
250*45916cd2Sjpk 	uint8_t ip6ol_len;	/* always even for defined values */
251*45916cd2Sjpk 	uint8_t ip6ol_doi[4];
252*45916cd2Sjpk 	/* Followed by sub-options */
253*45916cd2Sjpk };
254*45916cd2Sjpk 
255*45916cd2Sjpk #define	IP6LS_DOI_V4	0	/* IPv4 transition */
256*45916cd2Sjpk 
257*45916cd2Sjpk #define	IP6LS_TT_LEVEL	1	/* level or classification; 2-octet value */
258*45916cd2Sjpk #define	IP6LS_TT_VECTOR	2	/* compartments; bit vector (even # octets) */
259*45916cd2Sjpk #define	IP6LS_TT_ENUM	3	/* set membership; list of 2-octet values */
260*45916cd2Sjpk #define	IP6LS_TT_RANGES	4	/* set membership; pairs of 2-octet values */
261*45916cd2Sjpk #define	IP6LS_TT_V4	5	/* IPv4 compatible option */
262*45916cd2Sjpk #define	IP6LS_TT_DEST	6	/* destination-only data; per DOI */
263*45916cd2Sjpk 
2647c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2657c478bd9Sstevel@tonic-gate }
2667c478bd9Sstevel@tonic-gate #endif
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate #endif	/* _NETINET_IP6_H */
269