xref: /onnv-gate/usr/src/uts/common/net/pfkeyv2.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef	_NET_PFKEYV2_H
28*0Sstevel@tonic-gate #define	_NET_PFKEYV2_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate /*
33*0Sstevel@tonic-gate  * Definitions and structures for PF_KEY version 2.  See RFC 2367 for
34*0Sstevel@tonic-gate  * more details.  SA == Security Association, which is what PF_KEY provides
35*0Sstevel@tonic-gate  * an API for managing.
36*0Sstevel@tonic-gate  */
37*0Sstevel@tonic-gate 
38*0Sstevel@tonic-gate #ifdef	__cplusplus
39*0Sstevel@tonic-gate extern "C" {
40*0Sstevel@tonic-gate #endif
41*0Sstevel@tonic-gate 
42*0Sstevel@tonic-gate #define	PF_KEY_V2		2
43*0Sstevel@tonic-gate #define	PFKEYV2_REVISION	200109L
44*0Sstevel@tonic-gate 
45*0Sstevel@tonic-gate /*
46*0Sstevel@tonic-gate  * Base PF_KEY message.
47*0Sstevel@tonic-gate  */
48*0Sstevel@tonic-gate 
49*0Sstevel@tonic-gate typedef struct sadb_msg {
50*0Sstevel@tonic-gate 	uint8_t sadb_msg_version;	/* Version, currently PF_KEY_V2 */
51*0Sstevel@tonic-gate 	uint8_t sadb_msg_type;		/* ADD, UPDATE, etc. */
52*0Sstevel@tonic-gate 	uint8_t sadb_msg_errno;		/* Error number from UNIX errno space */
53*0Sstevel@tonic-gate 	uint8_t sadb_msg_satype;	/* ESP, AH, etc. */
54*0Sstevel@tonic-gate 	uint16_t sadb_msg_len;		/* Length in 64-bit words. */
55*0Sstevel@tonic-gate 	uint16_t sadb_msg_reserved;	/* must be zero */
56*0Sstevel@tonic-gate /*
57*0Sstevel@tonic-gate  * Use the reserved field for extended diagnostic information on errno
58*0Sstevel@tonic-gate  * responses.
59*0Sstevel@tonic-gate  */
60*0Sstevel@tonic-gate #define	sadb_x_msg_diagnostic sadb_msg_reserved
61*0Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
62*0Sstevel@tonic-gate 	union {
63*0Sstevel@tonic-gate 		struct {
64*0Sstevel@tonic-gate 			uint32_t sadb_x_msg_useq;	/* Set by originator */
65*0Sstevel@tonic-gate 			uint32_t sadb_x_msg_upid;	/* Set by originator */
66*0Sstevel@tonic-gate 		} sadb_x_msg_actual;
67*0Sstevel@tonic-gate 		uint64_t sadb_x_msg_alignment;
68*0Sstevel@tonic-gate 	} sadb_x_msg_u;
69*0Sstevel@tonic-gate #define	sadb_msg_seq sadb_x_msg_u.sadb_x_msg_actual.sadb_x_msg_useq
70*0Sstevel@tonic-gate #define	sadb_msg_pid sadb_x_msg_u.sadb_x_msg_actual.sadb_x_msg_upid
71*0Sstevel@tonic-gate } sadb_msg_t;
72*0Sstevel@tonic-gate 
73*0Sstevel@tonic-gate /*
74*0Sstevel@tonic-gate  * Generic extension header.
75*0Sstevel@tonic-gate  */
76*0Sstevel@tonic-gate 
77*0Sstevel@tonic-gate typedef struct sadb_ext {
78*0Sstevel@tonic-gate 	union {
79*0Sstevel@tonic-gate 		/* Union is for guaranteeing 64-bit alignment. */
80*0Sstevel@tonic-gate 		struct {
81*0Sstevel@tonic-gate 			uint16_t sadb_x_ext_ulen;	/* In 64s, inclusive */
82*0Sstevel@tonic-gate 			uint16_t sadb_x_ext_utype;	/* 0 is reserved */
83*0Sstevel@tonic-gate 		} sadb_x_ext_actual;
84*0Sstevel@tonic-gate 		uint64_t sadb_x_ext_alignment;
85*0Sstevel@tonic-gate 	} sadb_x_ext_u;
86*0Sstevel@tonic-gate #define	sadb_ext_len sadb_x_ext_u.sadb_x_ext_actual.sadb_x_ext_ulen
87*0Sstevel@tonic-gate #define	sadb_ext_type sadb_x_ext_u.sadb_x_ext_actual.sadb_x_ext_utype
88*0Sstevel@tonic-gate } sadb_ext_t;
89*0Sstevel@tonic-gate 
90*0Sstevel@tonic-gate /*
91*0Sstevel@tonic-gate  * Security Association information extension.
92*0Sstevel@tonic-gate  */
93*0Sstevel@tonic-gate 
94*0Sstevel@tonic-gate typedef struct sadb_sa {
95*0Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
96*0Sstevel@tonic-gate 	union {
97*0Sstevel@tonic-gate 		struct {
98*0Sstevel@tonic-gate 			uint16_t sadb_x_sa_ulen;
99*0Sstevel@tonic-gate 			uint16_t sadb_x_sa_uexttype;	/* ASSOCIATION */
100*0Sstevel@tonic-gate 			uint32_t sadb_x_sa_uspi;	/* Sec. Param. Index */
101*0Sstevel@tonic-gate 		} sadb_x_sa_uactual;
102*0Sstevel@tonic-gate 		uint64_t sadb_x_sa_alignment;
103*0Sstevel@tonic-gate 	} sadb_x_sa_u;
104*0Sstevel@tonic-gate #define	sadb_sa_len sadb_x_sa_u.sadb_x_sa_uactual.sadb_x_sa_ulen
105*0Sstevel@tonic-gate #define	sadb_sa_exttype sadb_x_sa_u.sadb_x_sa_uactual.sadb_x_sa_uexttype
106*0Sstevel@tonic-gate #define	sadb_sa_spi sadb_x_sa_u.sadb_x_sa_uactual.sadb_x_sa_uspi
107*0Sstevel@tonic-gate 	uint8_t sadb_sa_replay;		/* Replay counter */
108*0Sstevel@tonic-gate 	uint8_t sadb_sa_state;		/* MATURE, DEAD, DYING, LARVAL */
109*0Sstevel@tonic-gate 	uint8_t sadb_sa_auth;		/* Authentication algorithm */
110*0Sstevel@tonic-gate 	uint8_t sadb_sa_encrypt;	/* Encryption algorithm */
111*0Sstevel@tonic-gate 	uint32_t sadb_sa_flags;		/* SA flags. */
112*0Sstevel@tonic-gate } sadb_sa_t;
113*0Sstevel@tonic-gate 
114*0Sstevel@tonic-gate /*
115*0Sstevel@tonic-gate  * SA Lifetime extension.  Already 64-bit aligned thanks to uint64_t fields.
116*0Sstevel@tonic-gate  */
117*0Sstevel@tonic-gate 
118*0Sstevel@tonic-gate typedef struct sadb_lifetime {
119*0Sstevel@tonic-gate 	uint16_t sadb_lifetime_len;
120*0Sstevel@tonic-gate 	uint16_t sadb_lifetime_exttype;		/* SOFT, HARD, CURRENT */
121*0Sstevel@tonic-gate 	uint32_t sadb_lifetime_allocations;
122*0Sstevel@tonic-gate 	uint64_t sadb_lifetime_bytes;
123*0Sstevel@tonic-gate 	uint64_t sadb_lifetime_addtime;	/* These fields are assumed to hold */
124*0Sstevel@tonic-gate 	uint64_t sadb_lifetime_usetime;	/* >= sizeof (time_t). */
125*0Sstevel@tonic-gate } sadb_lifetime_t;
126*0Sstevel@tonic-gate 
127*0Sstevel@tonic-gate /*
128*0Sstevel@tonic-gate  * SA address information.
129*0Sstevel@tonic-gate  */
130*0Sstevel@tonic-gate 
131*0Sstevel@tonic-gate typedef struct sadb_address {
132*0Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
133*0Sstevel@tonic-gate 	union {
134*0Sstevel@tonic-gate 		struct {
135*0Sstevel@tonic-gate 			uint16_t sadb_x_address_ulen;
136*0Sstevel@tonic-gate 			uint16_t sadb_x_address_uexttype; /* SRC, DST, PROXY */
137*0Sstevel@tonic-gate 			uint8_t sadb_x_address_uproto; /* Proto for ports... */
138*0Sstevel@tonic-gate 			uint8_t sadb_x_address_uprefixlen; /* Prefix length. */
139*0Sstevel@tonic-gate 			uint16_t sadb_x_address_ureserved; /* Padding */
140*0Sstevel@tonic-gate 		} sadb_x_address_actual;
141*0Sstevel@tonic-gate 		uint64_t sadb_x_address_alignment;
142*0Sstevel@tonic-gate 	} sadb_x_address_u;
143*0Sstevel@tonic-gate #define	sadb_address_len \
144*0Sstevel@tonic-gate 	sadb_x_address_u.sadb_x_address_actual.sadb_x_address_ulen
145*0Sstevel@tonic-gate #define	sadb_address_exttype \
146*0Sstevel@tonic-gate 	sadb_x_address_u.sadb_x_address_actual.sadb_x_address_uexttype
147*0Sstevel@tonic-gate #define	sadb_address_proto \
148*0Sstevel@tonic-gate 	sadb_x_address_u.sadb_x_address_actual.sadb_x_address_uproto
149*0Sstevel@tonic-gate #define	sadb_address_prefixlen \
150*0Sstevel@tonic-gate 	sadb_x_address_u.sadb_x_address_actual.sadb_x_address_uprefixlen
151*0Sstevel@tonic-gate #define	sadb_address_reserved \
152*0Sstevel@tonic-gate 	sadb_x_address_u.sadb_x_address_actual.sadb_x_address_ureserved
153*0Sstevel@tonic-gate 	/* Followed by a sockaddr structure which may contain ports. */
154*0Sstevel@tonic-gate } sadb_address_t;
155*0Sstevel@tonic-gate 
156*0Sstevel@tonic-gate /*
157*0Sstevel@tonic-gate  * SA key information.
158*0Sstevel@tonic-gate  */
159*0Sstevel@tonic-gate 
160*0Sstevel@tonic-gate typedef struct sadb_key {
161*0Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
162*0Sstevel@tonic-gate 	union {
163*0Sstevel@tonic-gate 		struct {
164*0Sstevel@tonic-gate 			uint16_t sadb_x_key_ulen;
165*0Sstevel@tonic-gate 			uint16_t sadb_x_key_uexttype;	/* AUTH, ENCRYPT */
166*0Sstevel@tonic-gate 			uint16_t sadb_x_key_ubits;	/* Actual len (bits) */
167*0Sstevel@tonic-gate 			uint16_t sadb_x_key_ureserved;
168*0Sstevel@tonic-gate 		} sadb_x_key_actual;
169*0Sstevel@tonic-gate 		uint64_t sadb_x_key_alignment;
170*0Sstevel@tonic-gate 	} sadb_x_key_u;
171*0Sstevel@tonic-gate #define	sadb_key_len sadb_x_key_u.sadb_x_key_actual.sadb_x_key_ulen
172*0Sstevel@tonic-gate #define	sadb_key_exttype sadb_x_key_u.sadb_x_key_actual.sadb_x_key_uexttype
173*0Sstevel@tonic-gate #define	sadb_key_bits sadb_x_key_u.sadb_x_key_actual.sadb_x_key_ubits
174*0Sstevel@tonic-gate #define	sadb_key_reserved sadb_x_key_u.sadb_x_key_actual.sadb_x_key_ureserved
175*0Sstevel@tonic-gate 	/* Followed by actual key(s) in canonical (outbound proc.) order. */
176*0Sstevel@tonic-gate } sadb_key_t;
177*0Sstevel@tonic-gate 
178*0Sstevel@tonic-gate /*
179*0Sstevel@tonic-gate  * SA Identity information.  Already 64-bit aligned thanks to uint64_t fields.
180*0Sstevel@tonic-gate  */
181*0Sstevel@tonic-gate 
182*0Sstevel@tonic-gate typedef struct sadb_ident {
183*0Sstevel@tonic-gate 	uint16_t sadb_ident_len;
184*0Sstevel@tonic-gate 	uint16_t sadb_ident_exttype;	/* SRC, DST, PROXY */
185*0Sstevel@tonic-gate 	uint16_t sadb_ident_type;	/* FQDN, USER_FQDN, etc. */
186*0Sstevel@tonic-gate 	uint16_t sadb_ident_reserved;	/* Padding */
187*0Sstevel@tonic-gate 	uint64_t sadb_ident_id;		/* For userid, etc. */
188*0Sstevel@tonic-gate 	/* Followed by an identity null-terminate C string if present. */
189*0Sstevel@tonic-gate } sadb_ident_t;
190*0Sstevel@tonic-gate 
191*0Sstevel@tonic-gate /*
192*0Sstevel@tonic-gate  * SA sensitivity information.  This is mostly useful on MLS systems.
193*0Sstevel@tonic-gate  */
194*0Sstevel@tonic-gate 
195*0Sstevel@tonic-gate typedef struct sadb_sens {
196*0Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
197*0Sstevel@tonic-gate 	union {
198*0Sstevel@tonic-gate 		struct {
199*0Sstevel@tonic-gate 			uint16_t sadb_x_sens_ulen;
200*0Sstevel@tonic-gate 			uint16_t sadb_x_sens_uexttype;	/* SENSITIVITY */
201*0Sstevel@tonic-gate 			uint32_t sadb_x_sens_udpd;	/* Protection domain */
202*0Sstevel@tonic-gate 		} sadb_x_sens_actual;
203*0Sstevel@tonic-gate 		uint64_t sadb_x_sens_alignment;
204*0Sstevel@tonic-gate 	} sadb_x_sens_u;
205*0Sstevel@tonic-gate #define	sadb_sens_len sadb_x_sens_u.sadb_x_sens_actual.sadb_x_sens_ulen
206*0Sstevel@tonic-gate #define	sadb_sens_exttype sadb_x_sens_u.sadb_x_sens_actual.sadb_x_sens_uexttype
207*0Sstevel@tonic-gate #define	sadb_sens_dpd sadb_x_sens_u.sadb_x_sens_actual.sadb_x_sens_udpd
208*0Sstevel@tonic-gate 	uint8_t sadb_sens_sens_level;
209*0Sstevel@tonic-gate 	uint8_t sadb_sens_sens_len;		/* 64-bit words */
210*0Sstevel@tonic-gate 	uint8_t sadb_sens_integ_level;
211*0Sstevel@tonic-gate 	uint8_t sadb_sens_integ_len;		/* 64-bit words */
212*0Sstevel@tonic-gate 	uint32_t sadb_sens_reserved;
213*0Sstevel@tonic-gate 	/*
214*0Sstevel@tonic-gate 	 * followed by two uint64_t arrays
215*0Sstevel@tonic-gate 	 * uint64_t sadb_sens_bitmap[sens_bitmap_len];
216*0Sstevel@tonic-gate 	 * uint64_t sadb_integ_bitmap[integ_bitmap_len];
217*0Sstevel@tonic-gate 	 */
218*0Sstevel@tonic-gate } sadb_sens_t;
219*0Sstevel@tonic-gate 
220*0Sstevel@tonic-gate /*
221*0Sstevel@tonic-gate  * A proposal extension.  This is found in an ACQUIRE message, and it
222*0Sstevel@tonic-gate  * proposes what sort of SA the kernel would like to ACQUIRE.
223*0Sstevel@tonic-gate  */
224*0Sstevel@tonic-gate 
225*0Sstevel@tonic-gate /* First, a base structure... */
226*0Sstevel@tonic-gate 
227*0Sstevel@tonic-gate typedef struct sadb_x_propbase {
228*0Sstevel@tonic-gate 	uint16_t sadb_x_propb_len;
229*0Sstevel@tonic-gate 	uint16_t sadb_x_propb_exttype;	/* PROPOSAL, X_EPROP */
230*0Sstevel@tonic-gate 	union {
231*0Sstevel@tonic-gate 		struct {
232*0Sstevel@tonic-gate 			uint8_t sadb_x_propb_lenres_replay;
233*0Sstevel@tonic-gate 			uint8_t sadb_x_propb_lenres_eres;
234*0Sstevel@tonic-gate 			uint16_t sadb_x_propb_lenres_numecombs;
235*0Sstevel@tonic-gate 		} sadb_x_propb_lenres;
236*0Sstevel@tonic-gate 		struct {
237*0Sstevel@tonic-gate 			uint8_t sadb_x_propb_oldres_replay;
238*0Sstevel@tonic-gate 			uint8_t sadb_x_propb_oldres_reserved[3];
239*0Sstevel@tonic-gate 		} sadb_x_propb_oldres;
240*0Sstevel@tonic-gate 	} sadb_x_propb_u;
241*0Sstevel@tonic-gate #define	sadb_x_propb_replay \
242*0Sstevel@tonic-gate 	sadb_x_propb_u.sadb_x_propb_lenres.sadb_x_propb_lenres_replay
243*0Sstevel@tonic-gate #define	sadb_x_propb_reserved \
244*0Sstevel@tonic-gate 	sadb_x_propb_u.sadb_x_propb_oldres.sadb_x_propb_oldres_reserved
245*0Sstevel@tonic-gate #define	sadb_x_propb_ereserved \
246*0Sstevel@tonic-gate 	sadb_x_propb_u.sadb_x_propb_lenres.sadb_x_propb_lenres_eres
247*0Sstevel@tonic-gate #define	sadb_x_propb_numecombs \
248*0Sstevel@tonic-gate 	sadb_x_propb_u.sadb_x_propb_lenres.sadb_x_propb_lenres_numecombs
249*0Sstevel@tonic-gate 	/* Followed by sadb_comb[] array or sadb_ecomb[] array. */
250*0Sstevel@tonic-gate } sadb_x_propbase_t;
251*0Sstevel@tonic-gate 
252*0Sstevel@tonic-gate /* Now, the actual sadb_prop structure, which will have alignment in it! */
253*0Sstevel@tonic-gate 
254*0Sstevel@tonic-gate typedef struct sadb_prop {
255*0Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
256*0Sstevel@tonic-gate 	union {
257*0Sstevel@tonic-gate 		sadb_x_propbase_t sadb_x_prop_actual;
258*0Sstevel@tonic-gate 		uint64_t sadb_x_prop_alignment;
259*0Sstevel@tonic-gate 	} sadb_x_prop_u;
260*0Sstevel@tonic-gate #define	sadb_prop_len sadb_x_prop_u.sadb_x_prop_actual.sadb_x_propb_len
261*0Sstevel@tonic-gate #define	sadb_prop_exttype sadb_x_prop_u.sadb_x_prop_actual.sadb_x_propb_exttype
262*0Sstevel@tonic-gate #define	sadb_prop_replay sadb_x_prop_u.sadb_x_prop_actual.sadb_x_propb_replay
263*0Sstevel@tonic-gate #define	sadb_prop_reserved \
264*0Sstevel@tonic-gate 	sadb_x_prop_u.sadb_x_prop_actual.sadb_x_propb_reserved
265*0Sstevel@tonic-gate #define	sadb_x_prop_ereserved \
266*0Sstevel@tonic-gate 	sadb_x_prop_u.sadb_x_prop_actual.sadb_x_propb_ereserved
267*0Sstevel@tonic-gate #define	sadb_x_prop_numecombs \
268*0Sstevel@tonic-gate 	sadb_x_prop_u.sadb_x_prop_actual.sadb_x_propb_numecombs
269*0Sstevel@tonic-gate } sadb_prop_t;
270*0Sstevel@tonic-gate 
271*0Sstevel@tonic-gate /*
272*0Sstevel@tonic-gate  * This is a proposed combination.  Many of these can follow a proposal
273*0Sstevel@tonic-gate  * extension.  Already 64-bit aligned thanks to uint64_t fields.
274*0Sstevel@tonic-gate  */
275*0Sstevel@tonic-gate 
276*0Sstevel@tonic-gate typedef struct sadb_comb {
277*0Sstevel@tonic-gate 	uint8_t sadb_comb_auth;			/* Authentication algorithm */
278*0Sstevel@tonic-gate 	uint8_t sadb_comb_encrypt;		/* Encryption algorithm */
279*0Sstevel@tonic-gate 	uint16_t sadb_comb_flags;		/* Comb. flags (e.g. PFS) */
280*0Sstevel@tonic-gate 	uint16_t sadb_comb_auth_minbits;	/* Bit strengths for auth */
281*0Sstevel@tonic-gate 	uint16_t sadb_comb_auth_maxbits;
282*0Sstevel@tonic-gate 	uint16_t sadb_comb_encrypt_minbits;	/* Bit strengths for encrypt */
283*0Sstevel@tonic-gate 	uint16_t sadb_comb_encrypt_maxbits;
284*0Sstevel@tonic-gate 	uint32_t sadb_comb_reserved;
285*0Sstevel@tonic-gate 	uint32_t sadb_comb_soft_allocations;	/* Lifetime proposals for */
286*0Sstevel@tonic-gate 	uint32_t sadb_comb_hard_allocations;	/* this combination. */
287*0Sstevel@tonic-gate 	uint64_t sadb_comb_soft_bytes;
288*0Sstevel@tonic-gate 	uint64_t sadb_comb_hard_bytes;
289*0Sstevel@tonic-gate 	uint64_t sadb_comb_soft_addtime;
290*0Sstevel@tonic-gate 	uint64_t sadb_comb_hard_addtime;
291*0Sstevel@tonic-gate 	uint64_t sadb_comb_soft_usetime;
292*0Sstevel@tonic-gate 	uint64_t sadb_comb_hard_usetime;
293*0Sstevel@tonic-gate } sadb_comb_t;
294*0Sstevel@tonic-gate 
295*0Sstevel@tonic-gate /*
296*0Sstevel@tonic-gate  * An extended combination that can comprise of many SA types.
297*0Sstevel@tonic-gate  * A single combination has algorithms and SA types locked.
298*0Sstevel@tonic-gate  * These are represented by algorithm descriptors, the second structure
299*0Sstevel@tonic-gate  * in the list.  For example, if the EACQUIRE requests AH(MD5) + ESP(DES/null)
300*0Sstevel@tonic-gate  * _or_ ESP(DES/MD5), it would have two combinations:
301*0Sstevel@tonic-gate  *
302*0Sstevel@tonic-gate  * COMB: algdes(AH, AUTH, MD5), algdes(ESP, CRYPT, DES)
303*0Sstevel@tonic-gate  * COMB: algdes(ESP, AUTH, MD5), algdes(ESP, CRYPT, DES)
304*0Sstevel@tonic-gate  *
305*0Sstevel@tonic-gate  * If an SA type supports an algorithm type, and there's no descriptor,
306*0Sstevel@tonic-gate  * assume it requires NONE, just like it were explicitly stated.
307*0Sstevel@tonic-gate  * (This includes ESP NULL encryption, BTW.)
308*0Sstevel@tonic-gate  *
309*0Sstevel@tonic-gate  * Already 64-bit aligned thanks to uint64_t fields.
310*0Sstevel@tonic-gate  */
311*0Sstevel@tonic-gate 
312*0Sstevel@tonic-gate typedef struct sadb_x_ecomb {
313*0Sstevel@tonic-gate 	uint8_t sadb_x_ecomb_numalgs;
314*0Sstevel@tonic-gate 	uint8_t sadb_x_ecomb_reserved;
315*0Sstevel@tonic-gate 	uint16_t sadb_x_ecomb_flags;	/* E.g. PFS? */
316*0Sstevel@tonic-gate 	uint32_t sadb_x_ecomb_reserved2;
317*0Sstevel@tonic-gate 	uint32_t sadb_x_ecomb_soft_allocations;
318*0Sstevel@tonic-gate 	uint32_t sadb_x_ecomb_hard_allocations;
319*0Sstevel@tonic-gate 	uint64_t sadb_x_ecomb_soft_bytes;
320*0Sstevel@tonic-gate 	uint64_t sadb_x_ecomb_hard_bytes;
321*0Sstevel@tonic-gate 	uint64_t sadb_x_ecomb_soft_addtime;
322*0Sstevel@tonic-gate 	uint64_t sadb_x_ecomb_hard_addtime;
323*0Sstevel@tonic-gate 	uint64_t sadb_x_ecomb_soft_usetime;
324*0Sstevel@tonic-gate 	uint64_t sadb_x_ecomb_hard_usetime;
325*0Sstevel@tonic-gate } sadb_x_ecomb_t;
326*0Sstevel@tonic-gate 
327*0Sstevel@tonic-gate typedef struct sadb_x_algdesc {
328*0Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
329*0Sstevel@tonic-gate 	union {
330*0Sstevel@tonic-gate 		struct {
331*0Sstevel@tonic-gate 			uint8_t sadb_x_algdesc_usatype;	/* ESP, AH, etc. */
332*0Sstevel@tonic-gate 			uint8_t sadb_x_algdesc_ualgtype; /* AUTH, CRYPT, COMP */
333*0Sstevel@tonic-gate 			uint8_t sadb_x_algdesc_ualg;	/* 3DES, MD5, etc. */
334*0Sstevel@tonic-gate 			uint8_t sadb_x_algdesc_ureserved;
335*0Sstevel@tonic-gate 			uint16_t sadb_x_algdesc_uminbits; /* Bit strengths. */
336*0Sstevel@tonic-gate 			uint16_t sadb_x_algdesc_umaxbits;
337*0Sstevel@tonic-gate 		} sadb_x_algdesc_actual;
338*0Sstevel@tonic-gate 		uint64_t sadb_x_algdesc_alignment;
339*0Sstevel@tonic-gate 	} sadb_x_algdesc_u;
340*0Sstevel@tonic-gate #define	sadb_x_algdesc_satype \
341*0Sstevel@tonic-gate 	sadb_x_algdesc_u.sadb_x_algdesc_actual.sadb_x_algdesc_usatype
342*0Sstevel@tonic-gate #define	sadb_x_algdesc_algtype \
343*0Sstevel@tonic-gate 	sadb_x_algdesc_u.sadb_x_algdesc_actual.sadb_x_algdesc_ualgtype
344*0Sstevel@tonic-gate #define	sadb_x_algdesc_alg \
345*0Sstevel@tonic-gate 	sadb_x_algdesc_u.sadb_x_algdesc_actual.sadb_x_algdesc_ualg
346*0Sstevel@tonic-gate #define	sadb_x_algdesc_reserved \
347*0Sstevel@tonic-gate 	sadb_x_algdesc_u.sadb_x_algdesc_actual.sadb_x_algdesc_ureserved
348*0Sstevel@tonic-gate #define	sadb_x_algdesc_minbits \
349*0Sstevel@tonic-gate 	sadb_x_algdesc_u.sadb_x_algdesc_actual.sadb_x_algdesc_uminbits
350*0Sstevel@tonic-gate #define	sadb_x_algdesc_maxbits \
351*0Sstevel@tonic-gate 	sadb_x_algdesc_u.sadb_x_algdesc_actual.sadb_x_algdesc_umaxbits
352*0Sstevel@tonic-gate } sadb_x_algdesc_t;
353*0Sstevel@tonic-gate 
354*0Sstevel@tonic-gate /*
355*0Sstevel@tonic-gate  * When key mgmt. registers with the kernel, the kernel will tell key mgmt.
356*0Sstevel@tonic-gate  * its supported algorithms.
357*0Sstevel@tonic-gate  */
358*0Sstevel@tonic-gate 
359*0Sstevel@tonic-gate typedef struct sadb_supported {
360*0Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
361*0Sstevel@tonic-gate 	union {
362*0Sstevel@tonic-gate 		struct {
363*0Sstevel@tonic-gate 			uint16_t sadb_x_supported_ulen;
364*0Sstevel@tonic-gate 			uint16_t sadb_x_supported_uexttype;
365*0Sstevel@tonic-gate 			uint32_t sadb_x_supported_ureserved;
366*0Sstevel@tonic-gate 		} sadb_x_supported_actual;
367*0Sstevel@tonic-gate 		uint64_t sadb_x_supported_alignment;
368*0Sstevel@tonic-gate 	} sadb_x_supported_u;
369*0Sstevel@tonic-gate #define	sadb_supported_len \
370*0Sstevel@tonic-gate 	sadb_x_supported_u.sadb_x_supported_actual.sadb_x_supported_ulen
371*0Sstevel@tonic-gate #define	sadb_supported_exttype \
372*0Sstevel@tonic-gate 	sadb_x_supported_u.sadb_x_supported_actual.sadb_x_supported_uexttype
373*0Sstevel@tonic-gate #define	sadb_supported_reserved \
374*0Sstevel@tonic-gate 	sadb_x_supported_u.sadb_x_supported_actual.sadb_x_supported_ureserved
375*0Sstevel@tonic-gate } sadb_supported_t;
376*0Sstevel@tonic-gate 
377*0Sstevel@tonic-gate /* First, a base structure... */
378*0Sstevel@tonic-gate typedef struct sadb_x_algb {
379*0Sstevel@tonic-gate 	uint8_t sadb_x_algb_id;		/* Algorithm type. */
380*0Sstevel@tonic-gate 	uint8_t sadb_x_algb_ivlen;		/* IV len, in bits */
381*0Sstevel@tonic-gate 	uint16_t sadb_x_algb_minbits;	/* Min. key len (in bits) */
382*0Sstevel@tonic-gate 	uint16_t sadb_x_algb_maxbits;	/* Max. key length */
383*0Sstevel@tonic-gate 	union {
384*0Sstevel@tonic-gate 		uint16_t sadb_x_algb_ureserved;
385*0Sstevel@tonic-gate 		uint8_t sadb_x_algb_udefaults[2];
386*0Sstevel@tonic-gate 	} sadb_x_algb_union;
387*0Sstevel@tonic-gate 
388*0Sstevel@tonic-gate #define	sadb_x_algb_reserved sadb_x_algb_union.sadb_x_algb_ureserved
389*0Sstevel@tonic-gate #define	sadb_x_algb_increment sadb_x_algb_union.sadb_x_algb_udefaults[0]
390*0Sstevel@tonic-gate #define	sadb_x_algb_defincr sadb_x_algb_union.sadb_x_algb_udefaults[1]
391*0Sstevel@tonic-gate /*
392*0Sstevel@tonic-gate  * alg_increment: the number of bits from a key length to the next
393*0Sstevel@tonic-gate  * alg_defincr: the number of increments from the smallest possible
394*0Sstevel@tonic-gate  * key to the default key length
395*0Sstevel@tonic-gate  */
396*0Sstevel@tonic-gate } sadb_x_algb_t;
397*0Sstevel@tonic-gate /* useful macros for dealing with defincr */
398*0Sstevel@tonic-gate #define	SADB_ALG_DEFAULT_LEN(min, incr, defincr) ((min) + ((defincr) * (incr)))
399*0Sstevel@tonic-gate #define	SADB_ALG_DEFAULT_INCR(min, incr, default) (((default) - (min)) / (incr))
400*0Sstevel@tonic-gate 
401*0Sstevel@tonic-gate /* Now, the actual sadb_alg structure, which will have alignment in it. */
402*0Sstevel@tonic-gate typedef struct sadb_alg {
403*0Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
404*0Sstevel@tonic-gate 	union {
405*0Sstevel@tonic-gate 		sadb_x_algb_t sadb_x_alg_actual;
406*0Sstevel@tonic-gate 		uint64_t sadb_x_alg_alignment;
407*0Sstevel@tonic-gate 	} sadb_x_alg_u;
408*0Sstevel@tonic-gate #define	sadb_alg_id sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_id
409*0Sstevel@tonic-gate #define	sadb_alg_ivlen sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_ivlen
410*0Sstevel@tonic-gate #define	sadb_alg_minbits sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_minbits
411*0Sstevel@tonic-gate #define	sadb_alg_maxbits sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_maxbits
412*0Sstevel@tonic-gate #define	sadb_alg_reserved sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_reserved
413*0Sstevel@tonic-gate #define	sadb_x_alg_increment \
414*0Sstevel@tonic-gate 	sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_increment
415*0Sstevel@tonic-gate #define	sadb_x_alg_defincr sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_defincr
416*0Sstevel@tonic-gate } sadb_alg_t;
417*0Sstevel@tonic-gate 
418*0Sstevel@tonic-gate /*
419*0Sstevel@tonic-gate  * If key mgmt. needs an SPI in a range (including 0 to 0xFFFFFFFF), it
420*0Sstevel@tonic-gate  * asks the kernel with this extension in the SADB_GETSPI message.
421*0Sstevel@tonic-gate  */
422*0Sstevel@tonic-gate 
423*0Sstevel@tonic-gate typedef struct sadb_spirange {
424*0Sstevel@tonic-gate 	uint16_t sadb_spirange_len;
425*0Sstevel@tonic-gate 	uint16_t sadb_spirange_exttype;	/* SPI_RANGE */
426*0Sstevel@tonic-gate 	uint32_t sadb_spirange_min;
427*0Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
428*0Sstevel@tonic-gate 	union {
429*0Sstevel@tonic-gate 		struct {
430*0Sstevel@tonic-gate 			uint32_t sadb_x_spirange_umax;
431*0Sstevel@tonic-gate 			uint32_t sadb_x_spirange_ureserved;
432*0Sstevel@tonic-gate 		} sadb_x_spirange_actual;
433*0Sstevel@tonic-gate 		uint64_t sadb_x_spirange_alignment;
434*0Sstevel@tonic-gate 	} sadb_x_spirange_u;
435*0Sstevel@tonic-gate #define	sadb_spirange_max \
436*0Sstevel@tonic-gate 	sadb_x_spirange_u.sadb_x_spirange_actual.sadb_x_spirange_umax
437*0Sstevel@tonic-gate #define	sadb_spirange_reserved \
438*0Sstevel@tonic-gate 	sadb_x_spirange_u.sadb_x_spirange_actual.sadb_x_spirange_ureserved
439*0Sstevel@tonic-gate } sadb_spirange_t;
440*0Sstevel@tonic-gate 
441*0Sstevel@tonic-gate /*
442*0Sstevel@tonic-gate  * For the "extended REGISTER" which'll tell the kernel to send me
443*0Sstevel@tonic-gate  * "extended ACQUIREs".
444*0Sstevel@tonic-gate  */
445*0Sstevel@tonic-gate 
446*0Sstevel@tonic-gate typedef struct sadb_x_ereg {
447*0Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
448*0Sstevel@tonic-gate 	union {
449*0Sstevel@tonic-gate 		struct {
450*0Sstevel@tonic-gate 			uint16_t sadb_x_ereg_ulen;
451*0Sstevel@tonic-gate 			uint16_t sadb_x_ereg_uexttype;	/* X_EREG */
452*0Sstevel@tonic-gate 			/* Array of SA types, 0-terminated. */
453*0Sstevel@tonic-gate 			uint8_t sadb_x_ereg_usatypes[4];
454*0Sstevel@tonic-gate 		} sadb_x_ereg_actual;
455*0Sstevel@tonic-gate 		uint64_t sadb_x_ereg_alignment;
456*0Sstevel@tonic-gate 	} sadb_x_ereg_u;
457*0Sstevel@tonic-gate #define	sadb_x_ereg_len \
458*0Sstevel@tonic-gate 	sadb_x_ereg_u.sadb_x_ereg_actual.sadb_x_ereg_ulen
459*0Sstevel@tonic-gate #define	sadb_x_ereg_exttype \
460*0Sstevel@tonic-gate 	sadb_x_ereg_u.sadb_x_ereg_actual.sadb_x_ereg_uexttype
461*0Sstevel@tonic-gate #define	sadb_x_ereg_satypes \
462*0Sstevel@tonic-gate 	sadb_x_ereg_u.sadb_x_ereg_actual.sadb_x_ereg_usatypes
463*0Sstevel@tonic-gate } sadb_x_ereg_t;
464*0Sstevel@tonic-gate 
465*0Sstevel@tonic-gate /*
466*0Sstevel@tonic-gate  * For conveying a Key Management Cookie with SADB_GETSPI, SADB_ADD,
467*0Sstevel@tonic-gate  * SADB_ACQUIRE, or SADB_X_INVERSE_ACQUIRE.
468*0Sstevel@tonic-gate  */
469*0Sstevel@tonic-gate 
470*0Sstevel@tonic-gate typedef struct sadb_x_kmc {
471*0Sstevel@tonic-gate 	uint16_t sadb_x_kmc_len;
472*0Sstevel@tonic-gate 	uint16_t sadb_x_kmc_exttype;	/* X_KM_COOKIE */
473*0Sstevel@tonic-gate 	uint32_t sadb_x_kmc_proto;	/* KM protocol */
474*0Sstevel@tonic-gate 	union {
475*0Sstevel@tonic-gate 		struct {
476*0Sstevel@tonic-gate 			uint32_t sadb_x_kmc_ucookie;	/* KMP-specific */
477*0Sstevel@tonic-gate 			uint32_t sadb_x_kmc_ureserved;	/* Must be zero */
478*0Sstevel@tonic-gate 		} sadb_x_kmc_actual;
479*0Sstevel@tonic-gate 		uint64_t sadb_x_kmc_alignment;
480*0Sstevel@tonic-gate 	} sadb_x_kmc_u;
481*0Sstevel@tonic-gate #define	sadb_x_kmc_cookie sadb_x_kmc_u.sadb_x_kmc_actual.sadb_x_kmc_ucookie
482*0Sstevel@tonic-gate #define	sadb_x_kmc_reserved sadb_x_kmc_u.sadb_x_kmc_actual.sadb_x_kmc_ureserved
483*0Sstevel@tonic-gate } sadb_x_kmc_t;
484*0Sstevel@tonic-gate 
485*0Sstevel@tonic-gate 
486*0Sstevel@tonic-gate 
487*0Sstevel@tonic-gate /*
488*0Sstevel@tonic-gate  * Base message types.
489*0Sstevel@tonic-gate  */
490*0Sstevel@tonic-gate 
491*0Sstevel@tonic-gate #define	SADB_RESERVED	0
492*0Sstevel@tonic-gate #define	SADB_GETSPI	1
493*0Sstevel@tonic-gate #define	SADB_UPDATE	2
494*0Sstevel@tonic-gate #define	SADB_ADD	3
495*0Sstevel@tonic-gate #define	SADB_DELETE	4
496*0Sstevel@tonic-gate #define	SADB_GET	5
497*0Sstevel@tonic-gate #define	SADB_ACQUIRE	6
498*0Sstevel@tonic-gate #define	SADB_REGISTER	7
499*0Sstevel@tonic-gate #define	SADB_EXPIRE	8
500*0Sstevel@tonic-gate #define	SADB_FLUSH	9
501*0Sstevel@tonic-gate #define	SADB_DUMP	10   /* not used normally */
502*0Sstevel@tonic-gate #define	SADB_X_PROMISC	11
503*0Sstevel@tonic-gate #define	SADB_X_INVERSE_ACQUIRE	12
504*0Sstevel@tonic-gate #define	SADB_MAX		12
505*0Sstevel@tonic-gate 
506*0Sstevel@tonic-gate /*
507*0Sstevel@tonic-gate  * SA flags
508*0Sstevel@tonic-gate  */
509*0Sstevel@tonic-gate 
510*0Sstevel@tonic-gate #define	SADB_SAFLAGS_PFS	0x1	/* Perfect forward secrecy? */
511*0Sstevel@tonic-gate #define	SADB_SAFLAGS_NOREPLAY	0x2	/* Replay field NOT PRESENT. */
512*0Sstevel@tonic-gate 
513*0Sstevel@tonic-gate /* Below flags are used by this implementation.  Grow from left-to-right. */
514*0Sstevel@tonic-gate #define	SADB_X_SAFLAGS_USED	0x80000000	/* SA used/not used */
515*0Sstevel@tonic-gate #define	SADB_X_SAFLAGS_UNIQUE	0x40000000	/* SA unique/reusable */
516*0Sstevel@tonic-gate #define	SADB_X_SAFLAGS_AALG1	0x20000000	/* Auth-alg specific flag 1 */
517*0Sstevel@tonic-gate #define	SADB_X_SAFLAGS_AALG2	0x10000000	/* Auth-alg specific flag 2 */
518*0Sstevel@tonic-gate #define	SADB_X_SAFLAGS_EALG1	 0x8000000	/* Encr-alg specific flag 1 */
519*0Sstevel@tonic-gate #define	SADB_X_SAFLAGS_EALG2	 0x4000000	/* Encr-alg specific flag 2 */
520*0Sstevel@tonic-gate #define	SADB_X_SAFLAGS_KM1	 0x2000000	/* Key mgmt. specific flag 1 */
521*0Sstevel@tonic-gate #define	SADB_X_SAFLAGS_KM2	 0x1000000	/* Key mgmt. specific flag 2 */
522*0Sstevel@tonic-gate #define	SADB_X_SAFLAGS_KM3	  0x800000	/* Key mgmt. specific flag 3 */
523*0Sstevel@tonic-gate #define	SADB_X_SAFLAGS_KM4	  0x400000	/* Key mgmt. specific flag 4 */
524*0Sstevel@tonic-gate 	/* skip x200000 because it's used in the kernel */
525*0Sstevel@tonic-gate #define	SADB_X_SAFLAGS_NATT_LOC	  0x100000	/* this has a natted src SA */
526*0Sstevel@tonic-gate #define	SADB_X_SAFLAGS_NATT_REM	   0x80000	/* this has a natted dst SA */
527*0Sstevel@tonic-gate /*
528*0Sstevel@tonic-gate  * SA state.
529*0Sstevel@tonic-gate  */
530*0Sstevel@tonic-gate 
531*0Sstevel@tonic-gate #define	SADB_SASTATE_LARVAL	  0
532*0Sstevel@tonic-gate #define	SADB_SASTATE_MATURE	  1
533*0Sstevel@tonic-gate #define	SADB_SASTATE_DYING	  2
534*0Sstevel@tonic-gate #define	SADB_SASTATE_DEAD	  3
535*0Sstevel@tonic-gate 
536*0Sstevel@tonic-gate #define	SADB_SASTATE_MAX	  3
537*0Sstevel@tonic-gate 
538*0Sstevel@tonic-gate /*
539*0Sstevel@tonic-gate  * SA type.  Gaps are present in the number space because (for the time being)
540*0Sstevel@tonic-gate  * these types correspond to the SA types in the IPsec DOI document.
541*0Sstevel@tonic-gate  */
542*0Sstevel@tonic-gate 
543*0Sstevel@tonic-gate #define	SADB_SATYPE_UNSPEC	0
544*0Sstevel@tonic-gate #define	SADB_SATYPE_AH		2  /* RFC-1826 */
545*0Sstevel@tonic-gate #define	SADB_SATYPE_ESP		3  /* RFC-1827 */
546*0Sstevel@tonic-gate #define	SADB_SATYPE_RSVP	5  /* RSVP Authentication */
547*0Sstevel@tonic-gate #define	SADB_SATYPE_OSPFV2	6  /* OSPFv2 Authentication */
548*0Sstevel@tonic-gate #define	SADB_SATYPE_RIPV2	7  /* RIPv2 Authentication */
549*0Sstevel@tonic-gate #define	SADB_SATYPE_MIP		8  /* Mobile IPv4 Authentication */
550*0Sstevel@tonic-gate 
551*0Sstevel@tonic-gate #define	SADB_SATYPE_MAX		8
552*0Sstevel@tonic-gate 
553*0Sstevel@tonic-gate /*
554*0Sstevel@tonic-gate  * Algorithm types.  Gaps are present because (for the time being) these types
555*0Sstevel@tonic-gate  * correspond to the SA types in the IPsec DOI document.
556*0Sstevel@tonic-gate  *
557*0Sstevel@tonic-gate  * NOTE:  These are numbered to play nice with the IPsec DOI.  That's why
558*0Sstevel@tonic-gate  *	  there are gaps.
559*0Sstevel@tonic-gate  */
560*0Sstevel@tonic-gate 
561*0Sstevel@tonic-gate /* Authentication algorithms */
562*0Sstevel@tonic-gate #define	SADB_AALG_NONE		0
563*0Sstevel@tonic-gate #define	SADB_AALG_MD5HMAC	2
564*0Sstevel@tonic-gate #define	SADB_AALG_SHA1HMAC	3
565*0Sstevel@tonic-gate 
566*0Sstevel@tonic-gate #define	SADB_AALG_MAX		3
567*0Sstevel@tonic-gate 
568*0Sstevel@tonic-gate /* Encryption algorithms */
569*0Sstevel@tonic-gate #define	SADB_EALG_NONE		0
570*0Sstevel@tonic-gate #define	SADB_EALG_DESCBC	2
571*0Sstevel@tonic-gate #define	SADB_EALG_3DESCBC	3
572*0Sstevel@tonic-gate #define	SADB_EALG_BLOWFISH	7
573*0Sstevel@tonic-gate #define	SADB_EALG_NULL		11
574*0Sstevel@tonic-gate #define	SADB_EALG_AES		12
575*0Sstevel@tonic-gate #define	SADB_EALG_MAX		12
576*0Sstevel@tonic-gate 
577*0Sstevel@tonic-gate /*
578*0Sstevel@tonic-gate  * Extension header values.
579*0Sstevel@tonic-gate  */
580*0Sstevel@tonic-gate 
581*0Sstevel@tonic-gate #define	SADB_EXT_RESERVED		0
582*0Sstevel@tonic-gate 
583*0Sstevel@tonic-gate #define	SADB_EXT_SA			1
584*0Sstevel@tonic-gate #define	SADB_EXT_LIFETIME_CURRENT	2
585*0Sstevel@tonic-gate #define	SADB_EXT_LIFETIME_HARD		3
586*0Sstevel@tonic-gate #define	SADB_EXT_LIFETIME_SOFT		4
587*0Sstevel@tonic-gate #define	SADB_EXT_ADDRESS_SRC		5
588*0Sstevel@tonic-gate #define	SADB_EXT_ADDRESS_DST		6
589*0Sstevel@tonic-gate #define	SADB_EXT_ADDRESS_PROXY		7
590*0Sstevel@tonic-gate #define	SADB_EXT_KEY_AUTH		8
591*0Sstevel@tonic-gate #define	SADB_EXT_KEY_ENCRYPT		9
592*0Sstevel@tonic-gate #define	SADB_EXT_IDENTITY_SRC		10
593*0Sstevel@tonic-gate #define	SADB_EXT_IDENTITY_DST		11
594*0Sstevel@tonic-gate #define	SADB_EXT_SENSITIVITY		12
595*0Sstevel@tonic-gate #define	SADB_EXT_PROPOSAL		13
596*0Sstevel@tonic-gate #define	SADB_EXT_SUPPORTED_AUTH		14
597*0Sstevel@tonic-gate #define	SADB_EXT_SUPPORTED_ENCRYPT	15
598*0Sstevel@tonic-gate #define	SADB_EXT_SPIRANGE		16
599*0Sstevel@tonic-gate #define	SADB_X_EXT_EREG			17
600*0Sstevel@tonic-gate #define	SADB_X_EXT_EPROP		18
601*0Sstevel@tonic-gate #define	SADB_X_EXT_KM_COOKIE		19
602*0Sstevel@tonic-gate #define	SADB_X_EXT_ADDRESS_NATT_LOC	20
603*0Sstevel@tonic-gate #define	SADB_X_EXT_ADDRESS_NATT_REM	21
604*0Sstevel@tonic-gate 
605*0Sstevel@tonic-gate #define	SADB_EXT_MAX			21
606*0Sstevel@tonic-gate 
607*0Sstevel@tonic-gate /*
608*0Sstevel@tonic-gate  * Identity types.
609*0Sstevel@tonic-gate  */
610*0Sstevel@tonic-gate 
611*0Sstevel@tonic-gate #define	SADB_IDENTTYPE_RESERVED 0
612*0Sstevel@tonic-gate 
613*0Sstevel@tonic-gate /*
614*0Sstevel@tonic-gate  * For PREFIX and ADDR_RANGE, use the AF of the PROXY if present, or the SRC
615*0Sstevel@tonic-gate  * if not present.
616*0Sstevel@tonic-gate  */
617*0Sstevel@tonic-gate #define	SADB_IDENTTYPE_PREFIX		1
618*0Sstevel@tonic-gate #define	SADB_IDENTTYPE_FQDN		2  /* Fully qualified domain name. */
619*0Sstevel@tonic-gate #define	SADB_IDENTTYPE_USER_FQDN	3  /* e.g. root@domain.com */
620*0Sstevel@tonic-gate #define	SADB_X_IDENTTYPE_DN		4  /* ASN.1 DER Distinguished Name. */
621*0Sstevel@tonic-gate #define	SADB_X_IDENTTYPE_GN		5  /* ASN.1 DER Generic Name. */
622*0Sstevel@tonic-gate #define	SADB_X_IDENTTYPE_KEY_ID		6  /* Generic KEY ID. */
623*0Sstevel@tonic-gate #define	SADB_X_IDENTTYPE_ADDR_RANGE	7
624*0Sstevel@tonic-gate 
625*0Sstevel@tonic-gate #define	SADB_IDENTTYPE_MAX 	7
626*0Sstevel@tonic-gate 
627*0Sstevel@tonic-gate /*
628*0Sstevel@tonic-gate  * Protection DOI values for the SENSITIVITY extension.  There are no values
629*0Sstevel@tonic-gate  * currently, so the MAX is the only non-zero value available.
630*0Sstevel@tonic-gate  */
631*0Sstevel@tonic-gate 
632*0Sstevel@tonic-gate #define	SADB_DPD_NONE	0
633*0Sstevel@tonic-gate 
634*0Sstevel@tonic-gate #define	SADB_DPD_MAX	1
635*0Sstevel@tonic-gate 
636*0Sstevel@tonic-gate /*
637*0Sstevel@tonic-gate  * Diagnostic codes.  These supplement error messages.  Be sure to
638*0Sstevel@tonic-gate  * update libipsecutil's keysock_diag() if you change any of these.
639*0Sstevel@tonic-gate  */
640*0Sstevel@tonic-gate 
641*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_PRESET		-1	/* Internal value. */
642*0Sstevel@tonic-gate 
643*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_NONE			0
644*0Sstevel@tonic-gate 
645*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_UNKNOWN_MSG		1
646*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_UNKNOWN_EXT		2
647*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_EXTLEN		3
648*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_UNKNOWN_SATYPE	4
649*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_SATYPE_NEEDED		5
650*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_NO_SADBS		6
651*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_NO_EXT		7
652*0Sstevel@tonic-gate /* Bad address family value */
653*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_SRC_AF		8
654*0Sstevel@tonic-gate /* in sockaddr->sa_family. */
655*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_DST_AF		9
656*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_PROXY_AF		10
657*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_AF_MISMATCH		11
658*0Sstevel@tonic-gate 
659*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_SRC		12
660*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_DST		13
661*0Sstevel@tonic-gate 
662*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_ALLOC_HSERR		14
663*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BYTES_HSERR		15
664*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_ADDTIME_HSERR		16
665*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_USETIME_HSERR		17
666*0Sstevel@tonic-gate 
667*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MISSING_SRC		18
668*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MISSING_DST		19
669*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MISSING_SA		20
670*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MISSING_EKEY		21
671*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MISSING_AKEY		22
672*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MISSING_RANGE		23
673*0Sstevel@tonic-gate 
674*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_SRC		24
675*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_DST		25
676*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_SA		26
677*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_EKEY	27
678*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_AKEY	28
679*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_RANGE	29
680*0Sstevel@tonic-gate 
681*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MALFORMED_SRC		30
682*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MALFORMED_DST		31
683*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MALFORMED_SA		32
684*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MALFORMED_EKEY	33
685*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MALFORMED_AKEY	34
686*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MALFORMED_RANGE	35
687*0Sstevel@tonic-gate 
688*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_AKEY_PRESENT		36
689*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_EKEY_PRESENT		37
690*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_PROP_PRESENT		38
691*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_SUPP_PRESENT		39
692*0Sstevel@tonic-gate 
693*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_AALG		40
694*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_EALG		41
695*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_SAFLAGS		42
696*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_SASTATE		43
697*0Sstevel@tonic-gate 
698*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_AKEYBITS		44
699*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_EKEYBITS		45
700*0Sstevel@tonic-gate 
701*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_ENCR_NOTSUPP		46
702*0Sstevel@tonic-gate 
703*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_WEAK_EKEY		47
704*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_WEAK_AKEY		48
705*0Sstevel@tonic-gate 
706*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_KMP		49
707*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_KMC		50
708*0Sstevel@tonic-gate 
709*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MISSING_NATT_LOC	51
710*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MISSING_NATT_REM	52
711*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_NATT_LOC	53
712*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_NATT_REM	54
713*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MALFORMED_NATT_LOC	55
714*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MALFORMED_NATT_REM	56
715*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_NATT_PORTS	57
716*0Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MAX			57
717*0Sstevel@tonic-gate 
718*0Sstevel@tonic-gate /* Algorithm type for sadb_x_algdesc above... */
719*0Sstevel@tonic-gate 
720*0Sstevel@tonic-gate #define	SADB_X_ALGTYPE_NONE		0
721*0Sstevel@tonic-gate #define	SADB_X_ALGTYPE_AUTH		1
722*0Sstevel@tonic-gate #define	SADB_X_ALGTYPE_CRYPT		2
723*0Sstevel@tonic-gate #define	SADB_X_ALGTYPE_COMPRESS		3
724*0Sstevel@tonic-gate 
725*0Sstevel@tonic-gate #define	SADB_X_ALGTYPE_MAX		3
726*0Sstevel@tonic-gate 
727*0Sstevel@tonic-gate /* Key management protocol for sadb_x_kmc above... */
728*0Sstevel@tonic-gate 
729*0Sstevel@tonic-gate #define	SADB_X_KMP_MANUAL	0
730*0Sstevel@tonic-gate #define	SADB_X_KMP_IKE		1
731*0Sstevel@tonic-gate #define	SADB_X_KMP_KINK		2
732*0Sstevel@tonic-gate 
733*0Sstevel@tonic-gate #define	SADB_X_KMP_MAX		2
734*0Sstevel@tonic-gate 
735*0Sstevel@tonic-gate /*
736*0Sstevel@tonic-gate  * Handy conversion macros.  Not part of the PF_KEY spec...
737*0Sstevel@tonic-gate  */
738*0Sstevel@tonic-gate 
739*0Sstevel@tonic-gate #define	SADB_64TO8(x)	((x) << 3)
740*0Sstevel@tonic-gate #define	SADB_8TO64(x)	((x) >> 3)
741*0Sstevel@tonic-gate #define	SADB_8TO1(x)	((x) << 3)
742*0Sstevel@tonic-gate #define	SADB_1TO8(x)	((x) >> 3)
743*0Sstevel@tonic-gate 
744*0Sstevel@tonic-gate #ifdef	__cplusplus
745*0Sstevel@tonic-gate }
746*0Sstevel@tonic-gate #endif
747*0Sstevel@tonic-gate 
748*0Sstevel@tonic-gate #endif	/* _NET_PFKEYV2_H */
749