xref: /titanic_41/usr/src/uts/common/netinet/ip6.h (revision b509e89b2befbaa42939abad9da1d7f5a8c6aaae)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * ip6.h - Common structures and definitions as defined by
28  * advanced BSD API.
29  */
30 
31 #ifndef	_NETINET_IP6_H
32 #define	_NETINET_IP6_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 #include <sys/types.h>
41 #include <netinet/in.h>
42 
43 struct	ip6_hdr {
44 	union {
45 		struct ip6_hdrctl {
46 			uint32_t	ip6_un1_flow;   /* 4 bits version, */
47 							/* 8 bits tclass, and */
48 							/* 20 bits flow-ID */
49 			uint16_t	ip6_un1_plen;   /* payload length */
50 			uint8_t		ip6_un1_nxt;    /* next header */
51 			uint8_t		ip6_un1_hlim;   /* hop limit */
52 		} ip6_un1;
53 		uint8_t	ip6_un2_vfc;	/* 4 bits version and */
54 					/* top 4 bits of tclass */
55 	} ip6_ctlun;
56 	struct in6_addr ip6_src;	/* source address */
57 	struct in6_addr ip6_dst;	/* destination address */
58 };
59 typedef struct ip6_hdr	ip6_t;
60 
61 #define	ip6_vfc		ip6_ctlun.ip6_un2_vfc	/* 4 bits version and */
62 						/* top 4 bits of tclass */
63 #define	ip6_flow	ip6_ctlun.ip6_un1.ip6_un1_flow
64 #define	ip6_vcf		ip6_flow		/* Version, tclass, flow-ID */
65 #define	ip6_plen	ip6_ctlun.ip6_un1.ip6_un1_plen
66 #define	ip6_nxt		ip6_ctlun.ip6_un1.ip6_un1_nxt
67 #define	ip6_hlim	ip6_ctlun.ip6_un1.ip6_un1_hlim
68 #define	ip6_hops	ip6_ctlun.ip6_un1.ip6_un1_hlim
69 
70 /* Hop-by-Hop options header */
71 struct ip6_hbh {
72 	uint8_t	ip6h_nxt;	/* next header */
73 	uint8_t	ip6h_len;	/* length in units of 8 octets */
74 		/* followed by options */
75 };
76 typedef struct ip6_hbh	ip6_hbh_t;
77 
78 /* Destination options header */
79 struct ip6_dest {
80 	uint8_t	ip6d_nxt;	/* next header */
81 	uint8_t	ip6d_len;	/* length in units of 8 octets */
82 		/* followed by options */
83 };
84 typedef struct ip6_dest	ip6_dest_t;
85 
86 /* Routing header */
87 struct ip6_rthdr {
88 	uint8_t	ip6r_nxt;	/* next header */
89 	uint8_t	ip6r_len;	/* length in units of 8 octets */
90 	uint8_t	ip6r_type;	/* routing type */
91 	uint8_t	ip6r_segleft;	/* segments left */
92 		/* followed by routing type specific data */
93 };
94 typedef struct ip6_rthdr	ip6_rthdr_t;
95 
96 /* Type 0 Routing header */
97 struct ip6_rthdr0 {
98 	uint8_t	ip6r0_nxt;		/* next header */
99 	uint8_t	ip6r0_len;		/* length in units of 8 octets */
100 	uint8_t	ip6r0_type;		/* always zero */
101 	uint8_t	ip6r0_segleft;		/* segments left */
102 	uint32_t ip6r0_reserved;	/* reserved field */
103 };
104 typedef struct ip6_rthdr0	ip6_rthdr0_t;
105 
106 /* Fragment header */
107 struct ip6_frag {
108 	uint8_t		ip6f_nxt;	/* next header */
109 	uint8_t		ip6f_reserved;	/* reserved field */
110 	uint16_t	ip6f_offlg;	/* offset, reserved, and flag */
111 	uint32_t	ip6f_ident;	/* identification */
112 };
113 typedef struct ip6_frag	ip6_frag_t;
114 
115 /* ip6f_offlg field related constants (in network byte order) */
116 #ifdef _BIG_ENDIAN
117 #define	IP6F_OFF_MASK		0xfff8	/* mask out offset from _offlg */
118 #define	IP6F_RESERVED_MASK	0x0006	/* reserved bits in ip6f_offlg */
119 #define	IP6F_MORE_FRAG		0x0001	/* more-fragments flag */
120 #else
121 #define	IP6F_OFF_MASK		0xf8ff	/* mask out offset from _offlg */
122 #define	IP6F_RESERVED_MASK	0x0600	/* reserved bits in ip6f_offlg */
123 #define	IP6F_MORE_FRAG		0x0100	/* more-fragments flag */
124 #endif
125 
126 /* IPv6 options */
127 struct	ip6_opt {
128 	uint8_t	ip6o_type;
129 	uint8_t	ip6o_len;
130 };
131 
132 /*
133  * The high-order 3 bits of the option type define the behavior
134  * when processing an unknown option and whether or not the option
135  * content changes in flight.
136  */
137 #define	IP6OPT_TYPE(o)		((o) & 0xc0)
138 #define	IP6OPT_TYPE_SKIP	0x00
139 #define	IP6OPT_TYPE_DISCARD	0x40
140 #define	IP6OPT_TYPE_FORCEICMP	0x80
141 #define	IP6OPT_TYPE_ICMP	0xc0
142 #define	IP6OPT_MUTABLE		0x20
143 
144 #define	IP6OPT_PAD1			0x00	/* 00 0 00000 */
145 #define	IP6OPT_PADN			0x01	/* 00 0 00001 */
146 #define	IP6OPT_JUMBO			0xc2	/* 11 0 00010 = 194 */
147 #define	IP6OPT_NSAP_ADDR		0xc3	/* 11 0 00011 */
148 #define	IP6OPT_TUNNEL_LIMIT		0x04	/* 00 0 00100 */
149 #define	IP6OPT_ROUTER_ALERT		0x05	/* 00 0 00101 */
150 #define	IP6OPT_BINDING_UPDATE		0xc6	/* 11 0 00110 */
151 #define	IP6OPT_BINDING_ACK		0x07	/* 00 0 00111 */
152 #define	IP6OPT_BINDING_REQ		0x08	/* 00 0 01000 */
153 #define	IP6OPT_HOME_ADDRESS		0xc9	/* 11 0 01001 */
154 #define	IP6OPT_EID			0x8a	/* 10 0 01010 */
155 
156 #define	IP6OPT_LS			0x0a	/* 00 0 01010 */
157 
158 #define	IP6_MAX_OPT_LENGTH	255
159 
160 /* Jumbo Payload Option */
161 struct	ip6_opt_jumbo {
162 	uint8_t	ip6oj_type;
163 	uint8_t	ip6oj_len;
164 	uint8_t ip6oj_jumbo_len[4];
165 };
166 #define	IP6OPT_JUMBO_LEN	6
167 
168 /* NSAP Address Option */
169 struct	ip6_opt_nsap {
170 	uint8_t	ip6on_type;
171 	uint8_t	ip6on_len;
172 	uint8_t ip6on_src_nsap_len;
173 	uint8_t ip6on_dst_nsap_len;
174 	/* Followed by source NSAP */
175 	/* Followed by destination NSAP */
176 };
177 
178 /* Tunnel Limit Option */
179 struct	ip6_opt_tunnel {
180 	uint8_t	ip6ot_type;
181 	uint8_t	ip6ot_len;
182 	uint8_t ip6ot_encap_limit;
183 };
184 
185 /* Router Alert Option */
186 struct	ip6_opt_router {
187 	uint8_t	ip6or_type;
188 	uint8_t	ip6or_len;
189 	uint8_t ip6or_value[2];
190 };
191 
192 /* Router alert values (in network byte order) */
193 #ifdef _BIG_ENDIAN
194 #define	IP6_ALERT_MLD			0x0000
195 #define	IP6_ALERT_RSVP			0x0001
196 #define	IP6_ALERT_AN			0x0002
197 #else
198 #define	IP6_ALERT_MLD			0x0000
199 #define	IP6_ALERT_RSVP			0x0100
200 #define	IP6_ALERT_AN			0x0200
201 #endif
202 
203 /* Binding Update Option */
204 struct	ip6_opt_binding_update {
205 	uint8_t	ip6ou_type;
206 	uint8_t	ip6ou_len;
207 	uint8_t ip6ou_flags;
208 	uint8_t ip6ou_prefixlen;
209 	uint8_t ip6ou_seqno[2];
210 	uint8_t ip6ou_lifetime[4];
211 	uint8_t ip6ou_coa[16];		/* Optional based on flags */
212 	/* Followed by sub-options */
213 };
214 
215 /* Binding Update Flags */
216 #define	IP6_BUF_ACK	0x80	/* Request a binding ack */
217 #define	IP6_BUF_HOME	0x40	/* Home Registration */
218 #define	IP6_BUF_COA	0x20	/* Care-of-address present in option */
219 #define	IP6_BUF_ROUTER	0x10	/* Sending mobile node is a router */
220 
221 /* Binding Ack Option */
222 struct	ip6_opt_binding_ack {
223 	uint8_t	ip6oa_type;
224 	uint8_t	ip6oa_len;
225 	uint8_t ip6oa_status;
226 	uint8_t ip6oa_seqno[2];
227 	uint8_t ip6oa_lifetime[4];
228 	uint8_t ip6oa_refresh[4];
229 	/* Followed by sub-options */
230 };
231 
232 /* Binding Request Option */
233 struct	ip6_opt_binding_request {
234 	uint8_t	ip6or_type;
235 	uint8_t	ip6or_len;
236 	/* Followed by sub-options */
237 };
238 
239 /* Home Address Option */
240 struct	ip6_opt_home_address {
241 	uint8_t	ip6oh_type;
242 	uint8_t	ip6oh_len;
243 	uint8_t ip6oh_addr[16];		/* Home Address */
244 	/* Followed by sub-options */
245 };
246 
247 /* Labeled Security Option */
248 struct	ip6_opt_labeled_security {
249 	uint8_t ip6ol_type;
250 	uint8_t ip6ol_len;	/* always even for defined values */
251 	uint8_t ip6ol_doi[4];
252 	/* Followed by sub-options */
253 };
254 
255 #define	IP6LS_DOI_V4	0	/* IPv4 transition */
256 
257 #define	IP6LS_TT_LEVEL	1	/* level or classification; 2-octet value */
258 #define	IP6LS_TT_VECTOR	2	/* compartments; bit vector (even # octets) */
259 #define	IP6LS_TT_ENUM	3	/* set membership; list of 2-octet values */
260 #define	IP6LS_TT_RANGES	4	/* set membership; pairs of 2-octet values */
261 #define	IP6LS_TT_V4	5	/* IPv4 compatible option */
262 #define	IP6LS_TT_DEST	6	/* destination-only data; per DOI */
263 
264 #ifdef	__cplusplus
265 }
266 #endif
267 
268 #endif	/* _NETINET_IP6_H */
269