xref: /onnv-gate/usr/src/uts/common/net/pfkeyv2.h (revision 10934:e209937a4f19)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
53055Sdanmcd  * Common Development and Distribution License (the "License").
63055Sdanmcd  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
2210019SMark.Fenwick@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_NET_PFKEYV2_H
270Sstevel@tonic-gate #define	_NET_PFKEYV2_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate /*
300Sstevel@tonic-gate  * Definitions and structures for PF_KEY version 2.  See RFC 2367 for
310Sstevel@tonic-gate  * more details.  SA == Security Association, which is what PF_KEY provides
320Sstevel@tonic-gate  * an API for managing.
330Sstevel@tonic-gate  */
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #ifdef	__cplusplus
360Sstevel@tonic-gate extern "C" {
370Sstevel@tonic-gate #endif
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #define	PF_KEY_V2		2
400Sstevel@tonic-gate #define	PFKEYV2_REVISION	200109L
410Sstevel@tonic-gate 
420Sstevel@tonic-gate /*
430Sstevel@tonic-gate  * Base PF_KEY message.
440Sstevel@tonic-gate  */
450Sstevel@tonic-gate 
460Sstevel@tonic-gate typedef struct sadb_msg {
470Sstevel@tonic-gate 	uint8_t sadb_msg_version;	/* Version, currently PF_KEY_V2 */
480Sstevel@tonic-gate 	uint8_t sadb_msg_type;		/* ADD, UPDATE, etc. */
490Sstevel@tonic-gate 	uint8_t sadb_msg_errno;		/* Error number from UNIX errno space */
500Sstevel@tonic-gate 	uint8_t sadb_msg_satype;	/* ESP, AH, etc. */
510Sstevel@tonic-gate 	uint16_t sadb_msg_len;		/* Length in 64-bit words. */
520Sstevel@tonic-gate 	uint16_t sadb_msg_reserved;	/* must be zero */
530Sstevel@tonic-gate /*
540Sstevel@tonic-gate  * Use the reserved field for extended diagnostic information on errno
550Sstevel@tonic-gate  * responses.
560Sstevel@tonic-gate  */
570Sstevel@tonic-gate #define	sadb_x_msg_diagnostic sadb_msg_reserved
580Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
590Sstevel@tonic-gate 	union {
600Sstevel@tonic-gate 		struct {
610Sstevel@tonic-gate 			uint32_t sadb_x_msg_useq;	/* Set by originator */
620Sstevel@tonic-gate 			uint32_t sadb_x_msg_upid;	/* Set by originator */
630Sstevel@tonic-gate 		} sadb_x_msg_actual;
640Sstevel@tonic-gate 		uint64_t sadb_x_msg_alignment;
650Sstevel@tonic-gate 	} sadb_x_msg_u;
660Sstevel@tonic-gate #define	sadb_msg_seq sadb_x_msg_u.sadb_x_msg_actual.sadb_x_msg_useq
670Sstevel@tonic-gate #define	sadb_msg_pid sadb_x_msg_u.sadb_x_msg_actual.sadb_x_msg_upid
680Sstevel@tonic-gate } sadb_msg_t;
690Sstevel@tonic-gate 
700Sstevel@tonic-gate /*
710Sstevel@tonic-gate  * Generic extension header.
720Sstevel@tonic-gate  */
730Sstevel@tonic-gate 
740Sstevel@tonic-gate typedef struct sadb_ext {
750Sstevel@tonic-gate 	union {
760Sstevel@tonic-gate 		/* Union is for guaranteeing 64-bit alignment. */
770Sstevel@tonic-gate 		struct {
780Sstevel@tonic-gate 			uint16_t sadb_x_ext_ulen;	/* In 64s, inclusive */
790Sstevel@tonic-gate 			uint16_t sadb_x_ext_utype;	/* 0 is reserved */
800Sstevel@tonic-gate 		} sadb_x_ext_actual;
810Sstevel@tonic-gate 		uint64_t sadb_x_ext_alignment;
820Sstevel@tonic-gate 	} sadb_x_ext_u;
830Sstevel@tonic-gate #define	sadb_ext_len sadb_x_ext_u.sadb_x_ext_actual.sadb_x_ext_ulen
840Sstevel@tonic-gate #define	sadb_ext_type sadb_x_ext_u.sadb_x_ext_actual.sadb_x_ext_utype
850Sstevel@tonic-gate } sadb_ext_t;
860Sstevel@tonic-gate 
870Sstevel@tonic-gate /*
880Sstevel@tonic-gate  * Security Association information extension.
890Sstevel@tonic-gate  */
900Sstevel@tonic-gate 
910Sstevel@tonic-gate typedef struct sadb_sa {
920Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
930Sstevel@tonic-gate 	union {
940Sstevel@tonic-gate 		struct {
950Sstevel@tonic-gate 			uint16_t sadb_x_sa_ulen;
960Sstevel@tonic-gate 			uint16_t sadb_x_sa_uexttype;	/* ASSOCIATION */
970Sstevel@tonic-gate 			uint32_t sadb_x_sa_uspi;	/* Sec. Param. Index */
980Sstevel@tonic-gate 		} sadb_x_sa_uactual;
990Sstevel@tonic-gate 		uint64_t sadb_x_sa_alignment;
1000Sstevel@tonic-gate 	} sadb_x_sa_u;
1010Sstevel@tonic-gate #define	sadb_sa_len sadb_x_sa_u.sadb_x_sa_uactual.sadb_x_sa_ulen
1020Sstevel@tonic-gate #define	sadb_sa_exttype sadb_x_sa_u.sadb_x_sa_uactual.sadb_x_sa_uexttype
1030Sstevel@tonic-gate #define	sadb_sa_spi sadb_x_sa_u.sadb_x_sa_uactual.sadb_x_sa_uspi
1040Sstevel@tonic-gate 	uint8_t sadb_sa_replay;		/* Replay counter */
1050Sstevel@tonic-gate 	uint8_t sadb_sa_state;		/* MATURE, DEAD, DYING, LARVAL */
1060Sstevel@tonic-gate 	uint8_t sadb_sa_auth;		/* Authentication algorithm */
1070Sstevel@tonic-gate 	uint8_t sadb_sa_encrypt;	/* Encryption algorithm */
1080Sstevel@tonic-gate 	uint32_t sadb_sa_flags;		/* SA flags. */
1090Sstevel@tonic-gate } sadb_sa_t;
1100Sstevel@tonic-gate 
1110Sstevel@tonic-gate /*
1120Sstevel@tonic-gate  * SA Lifetime extension.  Already 64-bit aligned thanks to uint64_t fields.
1130Sstevel@tonic-gate  */
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate typedef struct sadb_lifetime {
1160Sstevel@tonic-gate 	uint16_t sadb_lifetime_len;
1170Sstevel@tonic-gate 	uint16_t sadb_lifetime_exttype;		/* SOFT, HARD, CURRENT */
1180Sstevel@tonic-gate 	uint32_t sadb_lifetime_allocations;
1190Sstevel@tonic-gate 	uint64_t sadb_lifetime_bytes;
1200Sstevel@tonic-gate 	uint64_t sadb_lifetime_addtime;	/* These fields are assumed to hold */
1210Sstevel@tonic-gate 	uint64_t sadb_lifetime_usetime;	/* >= sizeof (time_t). */
1220Sstevel@tonic-gate } sadb_lifetime_t;
1230Sstevel@tonic-gate 
1240Sstevel@tonic-gate /*
1250Sstevel@tonic-gate  * SA address information.
1260Sstevel@tonic-gate  */
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate typedef struct sadb_address {
1290Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
1300Sstevel@tonic-gate 	union {
1310Sstevel@tonic-gate 		struct {
1320Sstevel@tonic-gate 			uint16_t sadb_x_address_ulen;
1330Sstevel@tonic-gate 			uint16_t sadb_x_address_uexttype; /* SRC, DST, PROXY */
1340Sstevel@tonic-gate 			uint8_t sadb_x_address_uproto; /* Proto for ports... */
1350Sstevel@tonic-gate 			uint8_t sadb_x_address_uprefixlen; /* Prefix length. */
1360Sstevel@tonic-gate 			uint16_t sadb_x_address_ureserved; /* Padding */
1370Sstevel@tonic-gate 		} sadb_x_address_actual;
1380Sstevel@tonic-gate 		uint64_t sadb_x_address_alignment;
1390Sstevel@tonic-gate 	} sadb_x_address_u;
1400Sstevel@tonic-gate #define	sadb_address_len \
1410Sstevel@tonic-gate 	sadb_x_address_u.sadb_x_address_actual.sadb_x_address_ulen
1420Sstevel@tonic-gate #define	sadb_address_exttype \
1430Sstevel@tonic-gate 	sadb_x_address_u.sadb_x_address_actual.sadb_x_address_uexttype
1440Sstevel@tonic-gate #define	sadb_address_proto \
1450Sstevel@tonic-gate 	sadb_x_address_u.sadb_x_address_actual.sadb_x_address_uproto
1460Sstevel@tonic-gate #define	sadb_address_prefixlen \
1470Sstevel@tonic-gate 	sadb_x_address_u.sadb_x_address_actual.sadb_x_address_uprefixlen
1480Sstevel@tonic-gate #define	sadb_address_reserved \
1490Sstevel@tonic-gate 	sadb_x_address_u.sadb_x_address_actual.sadb_x_address_ureserved
1500Sstevel@tonic-gate 	/* Followed by a sockaddr structure which may contain ports. */
1510Sstevel@tonic-gate } sadb_address_t;
1520Sstevel@tonic-gate 
1530Sstevel@tonic-gate /*
1540Sstevel@tonic-gate  * SA key information.
1550Sstevel@tonic-gate  */
1560Sstevel@tonic-gate 
1570Sstevel@tonic-gate typedef struct sadb_key {
1580Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
1590Sstevel@tonic-gate 	union {
1600Sstevel@tonic-gate 		struct {
1610Sstevel@tonic-gate 			uint16_t sadb_x_key_ulen;
1620Sstevel@tonic-gate 			uint16_t sadb_x_key_uexttype;	/* AUTH, ENCRYPT */
1630Sstevel@tonic-gate 			uint16_t sadb_x_key_ubits;	/* Actual len (bits) */
1640Sstevel@tonic-gate 			uint16_t sadb_x_key_ureserved;
1650Sstevel@tonic-gate 		} sadb_x_key_actual;
1660Sstevel@tonic-gate 		uint64_t sadb_x_key_alignment;
1670Sstevel@tonic-gate 	} sadb_x_key_u;
1680Sstevel@tonic-gate #define	sadb_key_len sadb_x_key_u.sadb_x_key_actual.sadb_x_key_ulen
1690Sstevel@tonic-gate #define	sadb_key_exttype sadb_x_key_u.sadb_x_key_actual.sadb_x_key_uexttype
1700Sstevel@tonic-gate #define	sadb_key_bits sadb_x_key_u.sadb_x_key_actual.sadb_x_key_ubits
1710Sstevel@tonic-gate #define	sadb_key_reserved sadb_x_key_u.sadb_x_key_actual.sadb_x_key_ureserved
1720Sstevel@tonic-gate 	/* Followed by actual key(s) in canonical (outbound proc.) order. */
1730Sstevel@tonic-gate } sadb_key_t;
1740Sstevel@tonic-gate 
1750Sstevel@tonic-gate /*
1760Sstevel@tonic-gate  * SA Identity information.  Already 64-bit aligned thanks to uint64_t fields.
1770Sstevel@tonic-gate  */
1780Sstevel@tonic-gate 
1790Sstevel@tonic-gate typedef struct sadb_ident {
1800Sstevel@tonic-gate 	uint16_t sadb_ident_len;
1810Sstevel@tonic-gate 	uint16_t sadb_ident_exttype;	/* SRC, DST, PROXY */
1820Sstevel@tonic-gate 	uint16_t sadb_ident_type;	/* FQDN, USER_FQDN, etc. */
1830Sstevel@tonic-gate 	uint16_t sadb_ident_reserved;	/* Padding */
1840Sstevel@tonic-gate 	uint64_t sadb_ident_id;		/* For userid, etc. */
1850Sstevel@tonic-gate 	/* Followed by an identity null-terminate C string if present. */
1860Sstevel@tonic-gate } sadb_ident_t;
1870Sstevel@tonic-gate 
1880Sstevel@tonic-gate /*
1890Sstevel@tonic-gate  * SA sensitivity information.  This is mostly useful on MLS systems.
1900Sstevel@tonic-gate  */
1910Sstevel@tonic-gate 
1920Sstevel@tonic-gate typedef struct sadb_sens {
1930Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
1940Sstevel@tonic-gate 	union {
1950Sstevel@tonic-gate 		struct {
1960Sstevel@tonic-gate 			uint16_t sadb_x_sens_ulen;
1970Sstevel@tonic-gate 			uint16_t sadb_x_sens_uexttype;	/* SENSITIVITY */
1980Sstevel@tonic-gate 			uint32_t sadb_x_sens_udpd;	/* Protection domain */
1990Sstevel@tonic-gate 		} sadb_x_sens_actual;
2000Sstevel@tonic-gate 		uint64_t sadb_x_sens_alignment;
2010Sstevel@tonic-gate 	} sadb_x_sens_u;
2020Sstevel@tonic-gate #define	sadb_sens_len sadb_x_sens_u.sadb_x_sens_actual.sadb_x_sens_ulen
2030Sstevel@tonic-gate #define	sadb_sens_exttype sadb_x_sens_u.sadb_x_sens_actual.sadb_x_sens_uexttype
2040Sstevel@tonic-gate #define	sadb_sens_dpd sadb_x_sens_u.sadb_x_sens_actual.sadb_x_sens_udpd
2050Sstevel@tonic-gate 	uint8_t sadb_sens_sens_level;
2060Sstevel@tonic-gate 	uint8_t sadb_sens_sens_len;		/* 64-bit words */
2070Sstevel@tonic-gate 	uint8_t sadb_sens_integ_level;
2080Sstevel@tonic-gate 	uint8_t sadb_sens_integ_len;		/* 64-bit words */
209*10934Ssommerfeld@sun.com 	uint32_t sadb_x_sens_flags;
2100Sstevel@tonic-gate 	/*
2110Sstevel@tonic-gate 	 * followed by two uint64_t arrays
2120Sstevel@tonic-gate 	 * uint64_t sadb_sens_bitmap[sens_bitmap_len];
2130Sstevel@tonic-gate 	 * uint64_t sadb_integ_bitmap[integ_bitmap_len];
2140Sstevel@tonic-gate 	 */
2150Sstevel@tonic-gate } sadb_sens_t;
2160Sstevel@tonic-gate 
2170Sstevel@tonic-gate /*
218*10934Ssommerfeld@sun.com  * We recycled the formerly reserved word for flags.
219*10934Ssommerfeld@sun.com  */
220*10934Ssommerfeld@sun.com 
221*10934Ssommerfeld@sun.com #define	sadb_sens_reserved sadb_x_sens_flags
222*10934Ssommerfeld@sun.com 
223*10934Ssommerfeld@sun.com #define	SADB_X_SENS_IMPLICIT 0x1	 /* implicit labelling */
224*10934Ssommerfeld@sun.com #define	SADB_X_SENS_UNLABELED 0x2	 /* peer is unlabeled */
225*10934Ssommerfeld@sun.com 
226*10934Ssommerfeld@sun.com /*
227*10934Ssommerfeld@sun.com  * a proposal extension.  This is found in an ACQUIRE message, and it
2280Sstevel@tonic-gate  * proposes what sort of SA the kernel would like to ACQUIRE.
2290Sstevel@tonic-gate  */
2300Sstevel@tonic-gate 
2310Sstevel@tonic-gate /* First, a base structure... */
2320Sstevel@tonic-gate 
2330Sstevel@tonic-gate typedef struct sadb_x_propbase {
2340Sstevel@tonic-gate 	uint16_t sadb_x_propb_len;
2350Sstevel@tonic-gate 	uint16_t sadb_x_propb_exttype;	/* PROPOSAL, X_EPROP */
2360Sstevel@tonic-gate 	union {
2370Sstevel@tonic-gate 		struct {
2380Sstevel@tonic-gate 			uint8_t sadb_x_propb_lenres_replay;
2390Sstevel@tonic-gate 			uint8_t sadb_x_propb_lenres_eres;
2400Sstevel@tonic-gate 			uint16_t sadb_x_propb_lenres_numecombs;
2410Sstevel@tonic-gate 		} sadb_x_propb_lenres;
2420Sstevel@tonic-gate 		struct {
2430Sstevel@tonic-gate 			uint8_t sadb_x_propb_oldres_replay;
2440Sstevel@tonic-gate 			uint8_t sadb_x_propb_oldres_reserved[3];
2450Sstevel@tonic-gate 		} sadb_x_propb_oldres;
2460Sstevel@tonic-gate 	} sadb_x_propb_u;
2470Sstevel@tonic-gate #define	sadb_x_propb_replay \
2480Sstevel@tonic-gate 	sadb_x_propb_u.sadb_x_propb_lenres.sadb_x_propb_lenres_replay
2490Sstevel@tonic-gate #define	sadb_x_propb_reserved \
2500Sstevel@tonic-gate 	sadb_x_propb_u.sadb_x_propb_oldres.sadb_x_propb_oldres_reserved
2510Sstevel@tonic-gate #define	sadb_x_propb_ereserved \
2520Sstevel@tonic-gate 	sadb_x_propb_u.sadb_x_propb_lenres.sadb_x_propb_lenres_eres
2530Sstevel@tonic-gate #define	sadb_x_propb_numecombs \
2540Sstevel@tonic-gate 	sadb_x_propb_u.sadb_x_propb_lenres.sadb_x_propb_lenres_numecombs
2550Sstevel@tonic-gate 	/* Followed by sadb_comb[] array or sadb_ecomb[] array. */
2560Sstevel@tonic-gate } sadb_x_propbase_t;
2570Sstevel@tonic-gate 
2580Sstevel@tonic-gate /* Now, the actual sadb_prop structure, which will have alignment in it! */
2590Sstevel@tonic-gate 
2600Sstevel@tonic-gate typedef struct sadb_prop {
2610Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
2620Sstevel@tonic-gate 	union {
2630Sstevel@tonic-gate 		sadb_x_propbase_t sadb_x_prop_actual;
2640Sstevel@tonic-gate 		uint64_t sadb_x_prop_alignment;
2650Sstevel@tonic-gate 	} sadb_x_prop_u;
2660Sstevel@tonic-gate #define	sadb_prop_len sadb_x_prop_u.sadb_x_prop_actual.sadb_x_propb_len
2670Sstevel@tonic-gate #define	sadb_prop_exttype sadb_x_prop_u.sadb_x_prop_actual.sadb_x_propb_exttype
2680Sstevel@tonic-gate #define	sadb_prop_replay sadb_x_prop_u.sadb_x_prop_actual.sadb_x_propb_replay
2690Sstevel@tonic-gate #define	sadb_prop_reserved \
2700Sstevel@tonic-gate 	sadb_x_prop_u.sadb_x_prop_actual.sadb_x_propb_reserved
2710Sstevel@tonic-gate #define	sadb_x_prop_ereserved \
2720Sstevel@tonic-gate 	sadb_x_prop_u.sadb_x_prop_actual.sadb_x_propb_ereserved
2730Sstevel@tonic-gate #define	sadb_x_prop_numecombs \
2740Sstevel@tonic-gate 	sadb_x_prop_u.sadb_x_prop_actual.sadb_x_propb_numecombs
2750Sstevel@tonic-gate } sadb_prop_t;
2760Sstevel@tonic-gate 
2770Sstevel@tonic-gate /*
2780Sstevel@tonic-gate  * This is a proposed combination.  Many of these can follow a proposal
2790Sstevel@tonic-gate  * extension.  Already 64-bit aligned thanks to uint64_t fields.
2800Sstevel@tonic-gate  */
2810Sstevel@tonic-gate 
2820Sstevel@tonic-gate typedef struct sadb_comb {
2830Sstevel@tonic-gate 	uint8_t sadb_comb_auth;			/* Authentication algorithm */
2840Sstevel@tonic-gate 	uint8_t sadb_comb_encrypt;		/* Encryption algorithm */
2850Sstevel@tonic-gate 	uint16_t sadb_comb_flags;		/* Comb. flags (e.g. PFS) */
2860Sstevel@tonic-gate 	uint16_t sadb_comb_auth_minbits;	/* Bit strengths for auth */
2870Sstevel@tonic-gate 	uint16_t sadb_comb_auth_maxbits;
2880Sstevel@tonic-gate 	uint16_t sadb_comb_encrypt_minbits;	/* Bit strengths for encrypt */
2890Sstevel@tonic-gate 	uint16_t sadb_comb_encrypt_maxbits;
2900Sstevel@tonic-gate 	uint32_t sadb_comb_reserved;
2910Sstevel@tonic-gate 	uint32_t sadb_comb_soft_allocations;	/* Lifetime proposals for */
2920Sstevel@tonic-gate 	uint32_t sadb_comb_hard_allocations;	/* this combination. */
2930Sstevel@tonic-gate 	uint64_t sadb_comb_soft_bytes;
2940Sstevel@tonic-gate 	uint64_t sadb_comb_hard_bytes;
2950Sstevel@tonic-gate 	uint64_t sadb_comb_soft_addtime;
2960Sstevel@tonic-gate 	uint64_t sadb_comb_hard_addtime;
2970Sstevel@tonic-gate 	uint64_t sadb_comb_soft_usetime;
2980Sstevel@tonic-gate 	uint64_t sadb_comb_hard_usetime;
2990Sstevel@tonic-gate } sadb_comb_t;
3000Sstevel@tonic-gate 
3010Sstevel@tonic-gate /*
3020Sstevel@tonic-gate  * An extended combination that can comprise of many SA types.
3030Sstevel@tonic-gate  * A single combination has algorithms and SA types locked.
3040Sstevel@tonic-gate  * These are represented by algorithm descriptors, the second structure
3050Sstevel@tonic-gate  * in the list.  For example, if the EACQUIRE requests AH(MD5) + ESP(DES/null)
3060Sstevel@tonic-gate  * _or_ ESP(DES/MD5), it would have two combinations:
3070Sstevel@tonic-gate  *
3080Sstevel@tonic-gate  * COMB: algdes(AH, AUTH, MD5), algdes(ESP, CRYPT, DES)
3090Sstevel@tonic-gate  * COMB: algdes(ESP, AUTH, MD5), algdes(ESP, CRYPT, DES)
3100Sstevel@tonic-gate  *
3110Sstevel@tonic-gate  * If an SA type supports an algorithm type, and there's no descriptor,
3120Sstevel@tonic-gate  * assume it requires NONE, just like it were explicitly stated.
3130Sstevel@tonic-gate  * (This includes ESP NULL encryption, BTW.)
3140Sstevel@tonic-gate  *
3150Sstevel@tonic-gate  * Already 64-bit aligned thanks to uint64_t fields.
3160Sstevel@tonic-gate  */
3170Sstevel@tonic-gate 
3180Sstevel@tonic-gate typedef struct sadb_x_ecomb {
3190Sstevel@tonic-gate 	uint8_t sadb_x_ecomb_numalgs;
3200Sstevel@tonic-gate 	uint8_t sadb_x_ecomb_reserved;
3210Sstevel@tonic-gate 	uint16_t sadb_x_ecomb_flags;	/* E.g. PFS? */
3220Sstevel@tonic-gate 	uint32_t sadb_x_ecomb_reserved2;
3230Sstevel@tonic-gate 	uint32_t sadb_x_ecomb_soft_allocations;
3240Sstevel@tonic-gate 	uint32_t sadb_x_ecomb_hard_allocations;
3250Sstevel@tonic-gate 	uint64_t sadb_x_ecomb_soft_bytes;
3260Sstevel@tonic-gate 	uint64_t sadb_x_ecomb_hard_bytes;
3270Sstevel@tonic-gate 	uint64_t sadb_x_ecomb_soft_addtime;
3280Sstevel@tonic-gate 	uint64_t sadb_x_ecomb_hard_addtime;
3290Sstevel@tonic-gate 	uint64_t sadb_x_ecomb_soft_usetime;
3300Sstevel@tonic-gate 	uint64_t sadb_x_ecomb_hard_usetime;
3310Sstevel@tonic-gate } sadb_x_ecomb_t;
3320Sstevel@tonic-gate 
3330Sstevel@tonic-gate typedef struct sadb_x_algdesc {
3340Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
3350Sstevel@tonic-gate 	union {
3360Sstevel@tonic-gate 		struct {
3370Sstevel@tonic-gate 			uint8_t sadb_x_algdesc_usatype;	/* ESP, AH, etc. */
3380Sstevel@tonic-gate 			uint8_t sadb_x_algdesc_ualgtype; /* AUTH, CRYPT, COMP */
3390Sstevel@tonic-gate 			uint8_t sadb_x_algdesc_ualg;	/* 3DES, MD5, etc. */
3400Sstevel@tonic-gate 			uint8_t sadb_x_algdesc_ureserved;
3410Sstevel@tonic-gate 			uint16_t sadb_x_algdesc_uminbits; /* Bit strengths. */
3420Sstevel@tonic-gate 			uint16_t sadb_x_algdesc_umaxbits;
3430Sstevel@tonic-gate 		} sadb_x_algdesc_actual;
3440Sstevel@tonic-gate 		uint64_t sadb_x_algdesc_alignment;
3450Sstevel@tonic-gate 	} sadb_x_algdesc_u;
3460Sstevel@tonic-gate #define	sadb_x_algdesc_satype \
3470Sstevel@tonic-gate 	sadb_x_algdesc_u.sadb_x_algdesc_actual.sadb_x_algdesc_usatype
3480Sstevel@tonic-gate #define	sadb_x_algdesc_algtype \
3490Sstevel@tonic-gate 	sadb_x_algdesc_u.sadb_x_algdesc_actual.sadb_x_algdesc_ualgtype
3500Sstevel@tonic-gate #define	sadb_x_algdesc_alg \
3510Sstevel@tonic-gate 	sadb_x_algdesc_u.sadb_x_algdesc_actual.sadb_x_algdesc_ualg
3520Sstevel@tonic-gate #define	sadb_x_algdesc_reserved \
3530Sstevel@tonic-gate 	sadb_x_algdesc_u.sadb_x_algdesc_actual.sadb_x_algdesc_ureserved
3540Sstevel@tonic-gate #define	sadb_x_algdesc_minbits \
3550Sstevel@tonic-gate 	sadb_x_algdesc_u.sadb_x_algdesc_actual.sadb_x_algdesc_uminbits
3560Sstevel@tonic-gate #define	sadb_x_algdesc_maxbits \
3570Sstevel@tonic-gate 	sadb_x_algdesc_u.sadb_x_algdesc_actual.sadb_x_algdesc_umaxbits
3580Sstevel@tonic-gate } sadb_x_algdesc_t;
3590Sstevel@tonic-gate 
3600Sstevel@tonic-gate /*
3610Sstevel@tonic-gate  * When key mgmt. registers with the kernel, the kernel will tell key mgmt.
3620Sstevel@tonic-gate  * its supported algorithms.
3630Sstevel@tonic-gate  */
3640Sstevel@tonic-gate 
3650Sstevel@tonic-gate typedef struct sadb_supported {
3660Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
3670Sstevel@tonic-gate 	union {
3680Sstevel@tonic-gate 		struct {
3690Sstevel@tonic-gate 			uint16_t sadb_x_supported_ulen;
3700Sstevel@tonic-gate 			uint16_t sadb_x_supported_uexttype;
3710Sstevel@tonic-gate 			uint32_t sadb_x_supported_ureserved;
3720Sstevel@tonic-gate 		} sadb_x_supported_actual;
3730Sstevel@tonic-gate 		uint64_t sadb_x_supported_alignment;
3740Sstevel@tonic-gate 	} sadb_x_supported_u;
3750Sstevel@tonic-gate #define	sadb_supported_len \
3760Sstevel@tonic-gate 	sadb_x_supported_u.sadb_x_supported_actual.sadb_x_supported_ulen
3770Sstevel@tonic-gate #define	sadb_supported_exttype \
3780Sstevel@tonic-gate 	sadb_x_supported_u.sadb_x_supported_actual.sadb_x_supported_uexttype
3790Sstevel@tonic-gate #define	sadb_supported_reserved \
3800Sstevel@tonic-gate 	sadb_x_supported_u.sadb_x_supported_actual.sadb_x_supported_ureserved
3810Sstevel@tonic-gate } sadb_supported_t;
3820Sstevel@tonic-gate 
3830Sstevel@tonic-gate /* First, a base structure... */
3840Sstevel@tonic-gate typedef struct sadb_x_algb {
3850Sstevel@tonic-gate 	uint8_t sadb_x_algb_id;		/* Algorithm type. */
3860Sstevel@tonic-gate 	uint8_t sadb_x_algb_ivlen;		/* IV len, in bits */
3870Sstevel@tonic-gate 	uint16_t sadb_x_algb_minbits;	/* Min. key len (in bits) */
3880Sstevel@tonic-gate 	uint16_t sadb_x_algb_maxbits;	/* Max. key length */
3890Sstevel@tonic-gate 	union {
3900Sstevel@tonic-gate 		uint16_t sadb_x_algb_ureserved;
3910Sstevel@tonic-gate 		uint8_t sadb_x_algb_udefaults[2];
3920Sstevel@tonic-gate 	} sadb_x_algb_union;
3930Sstevel@tonic-gate 
3940Sstevel@tonic-gate #define	sadb_x_algb_reserved sadb_x_algb_union.sadb_x_algb_ureserved
3950Sstevel@tonic-gate #define	sadb_x_algb_increment sadb_x_algb_union.sadb_x_algb_udefaults[0]
39610824SMark.Fenwick@Sun.COM #define	sadb_x_algb_saltbits sadb_x_algb_union.sadb_x_algb_udefaults[1]
3970Sstevel@tonic-gate /*
3980Sstevel@tonic-gate  * alg_increment: the number of bits from a key length to the next
3990Sstevel@tonic-gate  */
4000Sstevel@tonic-gate } sadb_x_algb_t;
4010Sstevel@tonic-gate 
4020Sstevel@tonic-gate /* Now, the actual sadb_alg structure, which will have alignment in it. */
4030Sstevel@tonic-gate typedef struct sadb_alg {
4040Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
4050Sstevel@tonic-gate 	union {
4060Sstevel@tonic-gate 		sadb_x_algb_t sadb_x_alg_actual;
4070Sstevel@tonic-gate 		uint64_t sadb_x_alg_alignment;
4080Sstevel@tonic-gate 	} sadb_x_alg_u;
4090Sstevel@tonic-gate #define	sadb_alg_id sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_id
4100Sstevel@tonic-gate #define	sadb_alg_ivlen sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_ivlen
4110Sstevel@tonic-gate #define	sadb_alg_minbits sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_minbits
4120Sstevel@tonic-gate #define	sadb_alg_maxbits sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_maxbits
4130Sstevel@tonic-gate #define	sadb_alg_reserved sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_reserved
4140Sstevel@tonic-gate #define	sadb_x_alg_increment \
4150Sstevel@tonic-gate 	sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_increment
41610824SMark.Fenwick@Sun.COM #define	sadb_x_alg_saltbits sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_saltbits
4170Sstevel@tonic-gate } sadb_alg_t;
4180Sstevel@tonic-gate 
4190Sstevel@tonic-gate /*
4200Sstevel@tonic-gate  * If key mgmt. needs an SPI in a range (including 0 to 0xFFFFFFFF), it
4210Sstevel@tonic-gate  * asks the kernel with this extension in the SADB_GETSPI message.
4220Sstevel@tonic-gate  */
4230Sstevel@tonic-gate 
4240Sstevel@tonic-gate typedef struct sadb_spirange {
4250Sstevel@tonic-gate 	uint16_t sadb_spirange_len;
4260Sstevel@tonic-gate 	uint16_t sadb_spirange_exttype;	/* SPI_RANGE */
4270Sstevel@tonic-gate 	uint32_t sadb_spirange_min;
4280Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
4290Sstevel@tonic-gate 	union {
4300Sstevel@tonic-gate 		struct {
4310Sstevel@tonic-gate 			uint32_t sadb_x_spirange_umax;
4320Sstevel@tonic-gate 			uint32_t sadb_x_spirange_ureserved;
4330Sstevel@tonic-gate 		} sadb_x_spirange_actual;
4340Sstevel@tonic-gate 		uint64_t sadb_x_spirange_alignment;
4350Sstevel@tonic-gate 	} sadb_x_spirange_u;
4360Sstevel@tonic-gate #define	sadb_spirange_max \
4370Sstevel@tonic-gate 	sadb_x_spirange_u.sadb_x_spirange_actual.sadb_x_spirange_umax
4380Sstevel@tonic-gate #define	sadb_spirange_reserved \
4390Sstevel@tonic-gate 	sadb_x_spirange_u.sadb_x_spirange_actual.sadb_x_spirange_ureserved
4400Sstevel@tonic-gate } sadb_spirange_t;
4410Sstevel@tonic-gate 
4420Sstevel@tonic-gate /*
4430Sstevel@tonic-gate  * For the "extended REGISTER" which'll tell the kernel to send me
4440Sstevel@tonic-gate  * "extended ACQUIREs".
4450Sstevel@tonic-gate  */
4460Sstevel@tonic-gate 
4470Sstevel@tonic-gate typedef struct sadb_x_ereg {
4480Sstevel@tonic-gate 	/* Union is for guaranteeing 64-bit alignment. */
4490Sstevel@tonic-gate 	union {
4500Sstevel@tonic-gate 		struct {
4510Sstevel@tonic-gate 			uint16_t sadb_x_ereg_ulen;
4520Sstevel@tonic-gate 			uint16_t sadb_x_ereg_uexttype;	/* X_EREG */
4530Sstevel@tonic-gate 			/* Array of SA types, 0-terminated. */
4540Sstevel@tonic-gate 			uint8_t sadb_x_ereg_usatypes[4];
4550Sstevel@tonic-gate 		} sadb_x_ereg_actual;
4560Sstevel@tonic-gate 		uint64_t sadb_x_ereg_alignment;
4570Sstevel@tonic-gate 	} sadb_x_ereg_u;
4580Sstevel@tonic-gate #define	sadb_x_ereg_len \
4590Sstevel@tonic-gate 	sadb_x_ereg_u.sadb_x_ereg_actual.sadb_x_ereg_ulen
4600Sstevel@tonic-gate #define	sadb_x_ereg_exttype \
4610Sstevel@tonic-gate 	sadb_x_ereg_u.sadb_x_ereg_actual.sadb_x_ereg_uexttype
4620Sstevel@tonic-gate #define	sadb_x_ereg_satypes \
4630Sstevel@tonic-gate 	sadb_x_ereg_u.sadb_x_ereg_actual.sadb_x_ereg_usatypes
4640Sstevel@tonic-gate } sadb_x_ereg_t;
4650Sstevel@tonic-gate 
4660Sstevel@tonic-gate /*
4670Sstevel@tonic-gate  * For conveying a Key Management Cookie with SADB_GETSPI, SADB_ADD,
4680Sstevel@tonic-gate  * SADB_ACQUIRE, or SADB_X_INVERSE_ACQUIRE.
4690Sstevel@tonic-gate  */
4700Sstevel@tonic-gate 
4710Sstevel@tonic-gate typedef struct sadb_x_kmc {
4720Sstevel@tonic-gate 	uint16_t sadb_x_kmc_len;
4730Sstevel@tonic-gate 	uint16_t sadb_x_kmc_exttype;	/* X_KM_COOKIE */
4740Sstevel@tonic-gate 	uint32_t sadb_x_kmc_proto;	/* KM protocol */
4750Sstevel@tonic-gate 	union {
4760Sstevel@tonic-gate 		struct {
4770Sstevel@tonic-gate 			uint32_t sadb_x_kmc_ucookie;	/* KMP-specific */
4780Sstevel@tonic-gate 			uint32_t sadb_x_kmc_ureserved;	/* Must be zero */
4790Sstevel@tonic-gate 		} sadb_x_kmc_actual;
4800Sstevel@tonic-gate 		uint64_t sadb_x_kmc_alignment;
4810Sstevel@tonic-gate 	} sadb_x_kmc_u;
4820Sstevel@tonic-gate #define	sadb_x_kmc_cookie sadb_x_kmc_u.sadb_x_kmc_actual.sadb_x_kmc_ucookie
4830Sstevel@tonic-gate #define	sadb_x_kmc_reserved sadb_x_kmc_u.sadb_x_kmc_actual.sadb_x_kmc_ureserved
4840Sstevel@tonic-gate } sadb_x_kmc_t;
4850Sstevel@tonic-gate 
4866668Smarkfen typedef struct sadb_x_pair {
4876668Smarkfen 	union {
4886668Smarkfen 		/* Union is for guaranteeing 64-bit alignment. */
4896668Smarkfen 		struct {
4906668Smarkfen 			uint16_t sadb_x_pair_ulen;
4916668Smarkfen 			uint16_t sadb_x_pair_uexttype;
4926668Smarkfen 			uint32_t sadb_x_pair_uspi;	/* SPI of paired SA */
4936668Smarkfen 		} sadb_x_pair_actual;
4946668Smarkfen 		uint64_t sadb_x_ext_alignment;
4956668Smarkfen 	} sadb_x_pair_u;
4966668Smarkfen #define	sadb_x_pair_len sadb_x_pair_u.sadb_x_pair_actual.sadb_x_pair_ulen
4976668Smarkfen #define	sadb_x_pair_exttype \
4986668Smarkfen 	sadb_x_pair_u.sadb_x_pair_actual.sadb_x_pair_uexttype
4996668Smarkfen #define	sadb_x_pair_spi sadb_x_pair_u.sadb_x_pair_actual.sadb_x_pair_uspi
5006668Smarkfen } sadb_x_pair_t;
5010Sstevel@tonic-gate 
5020Sstevel@tonic-gate /*
5037749SThejaswini.Singarajipura@Sun.COM  * For the Sequence numbers to be used with SADB_DUMP, SADB_GET, SADB_UPDATE.
5047749SThejaswini.Singarajipura@Sun.COM  */
5057749SThejaswini.Singarajipura@Sun.COM 
5067749SThejaswini.Singarajipura@Sun.COM typedef struct sadb_x_replay_ctr {
5077749SThejaswini.Singarajipura@Sun.COM 	uint16_t sadb_x_rc_len;
5087749SThejaswini.Singarajipura@Sun.COM 	uint16_t sadb_x_rc_exttype;
5097749SThejaswini.Singarajipura@Sun.COM 	uint32_t sadb_x_rc_replay32;    /* For 240x SAs. */
5107749SThejaswini.Singarajipura@Sun.COM 	uint64_t sadb_x_rc_replay64;    /* For 430x SAs. */
5117749SThejaswini.Singarajipura@Sun.COM } sadb_x_replay_ctr_t;
5127749SThejaswini.Singarajipura@Sun.COM 
5137749SThejaswini.Singarajipura@Sun.COM /*
5147749SThejaswini.Singarajipura@Sun.COM  * For extended DUMP request. Dumps the SAs which were idle for
5157749SThejaswini.Singarajipura@Sun.COM  * longer than the timeout specified.
5167749SThejaswini.Singarajipura@Sun.COM  */
5177749SThejaswini.Singarajipura@Sun.COM 
5187749SThejaswini.Singarajipura@Sun.COM typedef struct sadb_x_edump {
5197749SThejaswini.Singarajipura@Sun.COM 	uint16_t sadb_x_edump_len;
5207749SThejaswini.Singarajipura@Sun.COM 	uint16_t sadb_x_edump_exttype;
5217749SThejaswini.Singarajipura@Sun.COM 	uint32_t sadb_x_edump_reserved;
5227749SThejaswini.Singarajipura@Sun.COM 	uint64_t sadb_x_edump_timeout;
5237749SThejaswini.Singarajipura@Sun.COM } sadb_x_edump_t;
5247749SThejaswini.Singarajipura@Sun.COM 
5257749SThejaswini.Singarajipura@Sun.COM /*
5260Sstevel@tonic-gate  * Base message types.
5270Sstevel@tonic-gate  */
5280Sstevel@tonic-gate 
5290Sstevel@tonic-gate #define	SADB_RESERVED	0
5300Sstevel@tonic-gate #define	SADB_GETSPI	1
5310Sstevel@tonic-gate #define	SADB_UPDATE	2
5320Sstevel@tonic-gate #define	SADB_ADD	3
5330Sstevel@tonic-gate #define	SADB_DELETE	4
5340Sstevel@tonic-gate #define	SADB_GET	5
5350Sstevel@tonic-gate #define	SADB_ACQUIRE	6
5360Sstevel@tonic-gate #define	SADB_REGISTER	7
5370Sstevel@tonic-gate #define	SADB_EXPIRE	8
5380Sstevel@tonic-gate #define	SADB_FLUSH	9
5390Sstevel@tonic-gate #define	SADB_DUMP	10   /* not used normally */
5400Sstevel@tonic-gate #define	SADB_X_PROMISC	11
5410Sstevel@tonic-gate #define	SADB_X_INVERSE_ACQUIRE	12
5426668Smarkfen #define	SADB_X_UPDATEPAIR	13
5437749SThejaswini.Singarajipura@Sun.COM #define	SADB_X_DELPAIR		14
5447749SThejaswini.Singarajipura@Sun.COM #define	SADB_X_DELPAIR_STATE	15
5457749SThejaswini.Singarajipura@Sun.COM #define	SADB_MAX		15
5460Sstevel@tonic-gate 
5470Sstevel@tonic-gate /*
5480Sstevel@tonic-gate  * SA flags
5490Sstevel@tonic-gate  */
5500Sstevel@tonic-gate 
5510Sstevel@tonic-gate #define	SADB_SAFLAGS_PFS	0x1	/* Perfect forward secrecy? */
5520Sstevel@tonic-gate #define	SADB_SAFLAGS_NOREPLAY	0x2	/* Replay field NOT PRESENT. */
5530Sstevel@tonic-gate 
5540Sstevel@tonic-gate /* Below flags are used by this implementation.  Grow from left-to-right. */
5550Sstevel@tonic-gate #define	SADB_X_SAFLAGS_USED	0x80000000	/* SA used/not used */
5560Sstevel@tonic-gate #define	SADB_X_SAFLAGS_UNIQUE	0x40000000	/* SA unique/reusable */
5570Sstevel@tonic-gate #define	SADB_X_SAFLAGS_AALG1	0x20000000	/* Auth-alg specific flag 1 */
5580Sstevel@tonic-gate #define	SADB_X_SAFLAGS_AALG2	0x10000000	/* Auth-alg specific flag 2 */
5590Sstevel@tonic-gate #define	SADB_X_SAFLAGS_EALG1	 0x8000000	/* Encr-alg specific flag 1 */
5600Sstevel@tonic-gate #define	SADB_X_SAFLAGS_EALG2	 0x4000000	/* Encr-alg specific flag 2 */
5610Sstevel@tonic-gate #define	SADB_X_SAFLAGS_KM1	 0x2000000	/* Key mgmt. specific flag 1 */
5620Sstevel@tonic-gate #define	SADB_X_SAFLAGS_KM2	 0x1000000	/* Key mgmt. specific flag 2 */
5630Sstevel@tonic-gate #define	SADB_X_SAFLAGS_KM3	  0x800000	/* Key mgmt. specific flag 3 */
5640Sstevel@tonic-gate #define	SADB_X_SAFLAGS_KM4	  0x400000	/* Key mgmt. specific flag 4 */
5653055Sdanmcd #define	SADB_X_SAFLAGS_KRES1	  0x200000	/* Reserved by the kernel */
5660Sstevel@tonic-gate #define	SADB_X_SAFLAGS_NATT_LOC	  0x100000	/* this has a natted src SA */
5670Sstevel@tonic-gate #define	SADB_X_SAFLAGS_NATT_REM	   0x80000	/* this has a natted dst SA */
5683055Sdanmcd #define	SADB_X_SAFLAGS_KRES2	   0x40000	/* Reserved by the kernel */
5693055Sdanmcd #define	SADB_X_SAFLAGS_TUNNEL	   0x20000	/* tunnel mode */
5706668Smarkfen #define	SADB_X_SAFLAGS_PAIRED	   0x10000	/* inbound/outbound pair */
5716668Smarkfen #define	SADB_X_SAFLAGS_OUTBOUND	    0x8000	/* SA direction bit */
5726668Smarkfen #define	SADB_X_SAFLAGS_INBOUND	    0x4000	/* SA direction bit */
5737066Sdanmcd #define	SADB_X_SAFLAGS_NATTED	    0x1000	/* Local node is behind a NAT */
5743055Sdanmcd 
5753055Sdanmcd #define	SADB_X_SAFLAGS_KRES	\
5763055Sdanmcd 	SADB_X_SAFLAGS_KRES1 | SADB_X_SAFLAGS_KRES2
5773055Sdanmcd 
5780Sstevel@tonic-gate /*
5790Sstevel@tonic-gate  * SA state.
5800Sstevel@tonic-gate  */
5810Sstevel@tonic-gate 
5827749SThejaswini.Singarajipura@Sun.COM #define	SADB_SASTATE_LARVAL		0
5837749SThejaswini.Singarajipura@Sun.COM #define	SADB_SASTATE_MATURE		1
5847749SThejaswini.Singarajipura@Sun.COM #define	SADB_SASTATE_DYING		2
5857749SThejaswini.Singarajipura@Sun.COM #define	SADB_SASTATE_DEAD		3
5867749SThejaswini.Singarajipura@Sun.COM #define	SADB_X_SASTATE_ACTIVE_ELSEWHERE	4
5877749SThejaswini.Singarajipura@Sun.COM #define	SADB_X_SASTATE_IDLE		5
5887749SThejaswini.Singarajipura@Sun.COM #define	SADB_X_SASTATE_ACTIVE		6
5890Sstevel@tonic-gate 
5907749SThejaswini.Singarajipura@Sun.COM #define	SADB_SASTATE_MAX		6
5910Sstevel@tonic-gate 
5920Sstevel@tonic-gate /*
5930Sstevel@tonic-gate  * SA type.  Gaps are present in the number space because (for the time being)
5940Sstevel@tonic-gate  * these types correspond to the SA types in the IPsec DOI document.
5950Sstevel@tonic-gate  */
5960Sstevel@tonic-gate 
5970Sstevel@tonic-gate #define	SADB_SATYPE_UNSPEC	0
5980Sstevel@tonic-gate #define	SADB_SATYPE_AH		2  /* RFC-1826 */
5990Sstevel@tonic-gate #define	SADB_SATYPE_ESP		3  /* RFC-1827 */
6000Sstevel@tonic-gate #define	SADB_SATYPE_RSVP	5  /* RSVP Authentication */
6010Sstevel@tonic-gate #define	SADB_SATYPE_OSPFV2	6  /* OSPFv2 Authentication */
6020Sstevel@tonic-gate #define	SADB_SATYPE_RIPV2	7  /* RIPv2 Authentication */
6030Sstevel@tonic-gate #define	SADB_SATYPE_MIP		8  /* Mobile IPv4 Authentication */
6040Sstevel@tonic-gate 
6050Sstevel@tonic-gate #define	SADB_SATYPE_MAX		8
6060Sstevel@tonic-gate 
6070Sstevel@tonic-gate /*
6080Sstevel@tonic-gate  * Algorithm types.  Gaps are present because (for the time being) these types
6090Sstevel@tonic-gate  * correspond to the SA types in the IPsec DOI document.
6100Sstevel@tonic-gate  *
6110Sstevel@tonic-gate  * NOTE:  These are numbered to play nice with the IPsec DOI.  That's why
6120Sstevel@tonic-gate  *	  there are gaps.
6130Sstevel@tonic-gate  */
6140Sstevel@tonic-gate 
6150Sstevel@tonic-gate /* Authentication algorithms */
6160Sstevel@tonic-gate #define	SADB_AALG_NONE		0
6170Sstevel@tonic-gate #define	SADB_AALG_MD5HMAC	2
6180Sstevel@tonic-gate #define	SADB_AALG_SHA1HMAC	3
6196126Sdanmcd #define	SADB_AALG_SHA256HMAC	5
6206126Sdanmcd #define	SADB_AALG_SHA384HMAC	6
6216126Sdanmcd #define	SADB_AALG_SHA512HMAC	7
6220Sstevel@tonic-gate 
6236126Sdanmcd #define	SADB_AALG_MAX		7
6240Sstevel@tonic-gate 
6250Sstevel@tonic-gate /* Encryption algorithms */
6260Sstevel@tonic-gate #define	SADB_EALG_NONE		0
6270Sstevel@tonic-gate #define	SADB_EALG_DESCBC	2
6280Sstevel@tonic-gate #define	SADB_EALG_3DESCBC	3
6290Sstevel@tonic-gate #define	SADB_EALG_BLOWFISH	7
6300Sstevel@tonic-gate #define	SADB_EALG_NULL		11
6310Sstevel@tonic-gate #define	SADB_EALG_AES		12
63210824SMark.Fenwick@Sun.COM #define	SADB_EALG_AES_CCM_8	14
63310824SMark.Fenwick@Sun.COM #define	SADB_EALG_AES_CCM_12	15
63410824SMark.Fenwick@Sun.COM #define	SADB_EALG_AES_CCM_16	16
63510824SMark.Fenwick@Sun.COM #define	SADB_EALG_AES_GCM_8	18
63610824SMark.Fenwick@Sun.COM #define	SADB_EALG_AES_GCM_12	19
63710824SMark.Fenwick@Sun.COM #define	SADB_EALG_AES_GCM_16	20
63810824SMark.Fenwick@Sun.COM #define	SADB_EALG_MAX		20
6390Sstevel@tonic-gate 
6400Sstevel@tonic-gate /*
6410Sstevel@tonic-gate  * Extension header values.
6420Sstevel@tonic-gate  */
6430Sstevel@tonic-gate 
6440Sstevel@tonic-gate #define	SADB_EXT_RESERVED		0
6450Sstevel@tonic-gate 
6460Sstevel@tonic-gate #define	SADB_EXT_SA			1
6470Sstevel@tonic-gate #define	SADB_EXT_LIFETIME_CURRENT	2
6480Sstevel@tonic-gate #define	SADB_EXT_LIFETIME_HARD		3
6490Sstevel@tonic-gate #define	SADB_EXT_LIFETIME_SOFT		4
6500Sstevel@tonic-gate #define	SADB_EXT_ADDRESS_SRC		5
6510Sstevel@tonic-gate #define	SADB_EXT_ADDRESS_DST		6
6523055Sdanmcd /* These two are synonyms. */
6530Sstevel@tonic-gate #define	SADB_EXT_ADDRESS_PROXY		7
6543055Sdanmcd #define	SADB_X_EXT_ADDRESS_INNER_SRC	SADB_EXT_ADDRESS_PROXY
6550Sstevel@tonic-gate #define	SADB_EXT_KEY_AUTH		8
6560Sstevel@tonic-gate #define	SADB_EXT_KEY_ENCRYPT		9
6570Sstevel@tonic-gate #define	SADB_EXT_IDENTITY_SRC		10
6580Sstevel@tonic-gate #define	SADB_EXT_IDENTITY_DST		11
6590Sstevel@tonic-gate #define	SADB_EXT_SENSITIVITY		12
6600Sstevel@tonic-gate #define	SADB_EXT_PROPOSAL		13
6610Sstevel@tonic-gate #define	SADB_EXT_SUPPORTED_AUTH		14
6620Sstevel@tonic-gate #define	SADB_EXT_SUPPORTED_ENCRYPT	15
6630Sstevel@tonic-gate #define	SADB_EXT_SPIRANGE		16
6640Sstevel@tonic-gate #define	SADB_X_EXT_EREG			17
6650Sstevel@tonic-gate #define	SADB_X_EXT_EPROP		18
6660Sstevel@tonic-gate #define	SADB_X_EXT_KM_COOKIE		19
6670Sstevel@tonic-gate #define	SADB_X_EXT_ADDRESS_NATT_LOC	20
6680Sstevel@tonic-gate #define	SADB_X_EXT_ADDRESS_NATT_REM	21
6693055Sdanmcd #define	SADB_X_EXT_ADDRESS_INNER_DST	22
6706668Smarkfen #define	SADB_X_EXT_PAIR			23
6717749SThejaswini.Singarajipura@Sun.COM #define	SADB_X_EXT_REPLAY_VALUE		24
6727749SThejaswini.Singarajipura@Sun.COM #define	SADB_X_EXT_EDUMP		25
6737749SThejaswini.Singarajipura@Sun.COM #define	SADB_X_EXT_LIFETIME_IDLE	26
674*10934Ssommerfeld@sun.com #define	SADB_X_EXT_OUTER_SENS		27
6750Sstevel@tonic-gate 
676*10934Ssommerfeld@sun.com #define	SADB_EXT_MAX			27
6770Sstevel@tonic-gate 
6780Sstevel@tonic-gate /*
6790Sstevel@tonic-gate  * Identity types.
6800Sstevel@tonic-gate  */
6810Sstevel@tonic-gate 
6820Sstevel@tonic-gate #define	SADB_IDENTTYPE_RESERVED 0
6830Sstevel@tonic-gate 
6840Sstevel@tonic-gate /*
6850Sstevel@tonic-gate  * For PREFIX and ADDR_RANGE, use the AF of the PROXY if present, or the SRC
6860Sstevel@tonic-gate  * if not present.
6870Sstevel@tonic-gate  */
6880Sstevel@tonic-gate #define	SADB_IDENTTYPE_PREFIX		1
6890Sstevel@tonic-gate #define	SADB_IDENTTYPE_FQDN		2  /* Fully qualified domain name. */
6900Sstevel@tonic-gate #define	SADB_IDENTTYPE_USER_FQDN	3  /* e.g. root@domain.com */
6910Sstevel@tonic-gate #define	SADB_X_IDENTTYPE_DN		4  /* ASN.1 DER Distinguished Name. */
6920Sstevel@tonic-gate #define	SADB_X_IDENTTYPE_GN		5  /* ASN.1 DER Generic Name. */
6930Sstevel@tonic-gate #define	SADB_X_IDENTTYPE_KEY_ID		6  /* Generic KEY ID. */
6940Sstevel@tonic-gate #define	SADB_X_IDENTTYPE_ADDR_RANGE	7
6950Sstevel@tonic-gate 
6960Sstevel@tonic-gate #define	SADB_IDENTTYPE_MAX 	7
6970Sstevel@tonic-gate 
6980Sstevel@tonic-gate /*
6990Sstevel@tonic-gate  * Protection DOI values for the SENSITIVITY extension.  There are no values
7000Sstevel@tonic-gate  * currently, so the MAX is the only non-zero value available.
7010Sstevel@tonic-gate  */
7020Sstevel@tonic-gate 
7030Sstevel@tonic-gate #define	SADB_DPD_NONE	0
7040Sstevel@tonic-gate 
7050Sstevel@tonic-gate #define	SADB_DPD_MAX	1
7060Sstevel@tonic-gate 
7070Sstevel@tonic-gate /*
7080Sstevel@tonic-gate  * Diagnostic codes.  These supplement error messages.  Be sure to
7090Sstevel@tonic-gate  * update libipsecutil's keysock_diag() if you change any of these.
7100Sstevel@tonic-gate  */
7110Sstevel@tonic-gate 
7120Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_PRESET		-1	/* Internal value. */
7130Sstevel@tonic-gate 
7140Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_NONE			0
7150Sstevel@tonic-gate 
7160Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_UNKNOWN_MSG		1
7170Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_UNKNOWN_EXT		2
7180Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_EXTLEN		3
7190Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_UNKNOWN_SATYPE	4
7200Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_SATYPE_NEEDED		5
7210Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_NO_SADBS		6
7220Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_NO_EXT		7
7230Sstevel@tonic-gate /* Bad address family value */
7240Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_SRC_AF		8
7250Sstevel@tonic-gate /* in sockaddr->sa_family. */
7260Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_DST_AF		9
7273055Sdanmcd /* These two are synonyms. */
7280Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_PROXY_AF		10
7293055Sdanmcd #define	SADB_X_DIAGNOSTIC_BAD_INNER_SRC_AF	10
7303055Sdanmcd 
7310Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_AF_MISMATCH		11
7320Sstevel@tonic-gate 
7330Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_SRC		12
7340Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_DST		13
7350Sstevel@tonic-gate 
7360Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_ALLOC_HSERR		14
7370Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BYTES_HSERR		15
7380Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_ADDTIME_HSERR		16
7390Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_USETIME_HSERR		17
7400Sstevel@tonic-gate 
7410Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MISSING_SRC		18
7420Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MISSING_DST		19
7430Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MISSING_SA		20
7440Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MISSING_EKEY		21
7450Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MISSING_AKEY		22
7460Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MISSING_RANGE		23
7470Sstevel@tonic-gate 
7480Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_SRC		24
7490Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_DST		25
7500Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_SA		26
7510Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_EKEY	27
7520Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_AKEY	28
7530Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_RANGE	29
7540Sstevel@tonic-gate 
7550Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MALFORMED_SRC		30
7560Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MALFORMED_DST		31
7570Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MALFORMED_SA		32
7580Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MALFORMED_EKEY	33
7590Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MALFORMED_AKEY	34
7600Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MALFORMED_RANGE	35
7610Sstevel@tonic-gate 
7620Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_AKEY_PRESENT		36
7630Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_EKEY_PRESENT		37
7640Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_PROP_PRESENT		38
7650Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_SUPP_PRESENT		39
7660Sstevel@tonic-gate 
7670Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_AALG		40
7680Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_EALG		41
7690Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_SAFLAGS		42
7700Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_SASTATE		43
7710Sstevel@tonic-gate 
7720Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_AKEYBITS		44
7730Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_BAD_EKEYBITS		45
7740Sstevel@tonic-gate 
7750Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_ENCR_NOTSUPP		46
7760Sstevel@tonic-gate 
7770Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_WEAK_EKEY		47
7780Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_WEAK_AKEY		48
7790Sstevel@tonic-gate 
7800Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_KMP		49
7810Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_KMC		50
7820Sstevel@tonic-gate 
7830Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MISSING_NATT_LOC	51
7840Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MISSING_NATT_REM	52
7850Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_NATT_LOC	53
7860Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_NATT_REM	54
7870Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MALFORMED_NATT_LOC	55
7880Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_MALFORMED_NATT_REM	56
7890Sstevel@tonic-gate #define	SADB_X_DIAGNOSTIC_DUPLICATE_NATT_PORTS	57
7903055Sdanmcd 
7913055Sdanmcd #define	SADB_X_DIAGNOSTIC_MISSING_INNER_SRC	58
7923055Sdanmcd #define	SADB_X_DIAGNOSTIC_MISSING_INNER_DST	59
7933055Sdanmcd #define	SADB_X_DIAGNOSTIC_DUPLICATE_INNER_SRC	60
7943055Sdanmcd #define	SADB_X_DIAGNOSTIC_DUPLICATE_INNER_DST	61
7953055Sdanmcd #define	SADB_X_DIAGNOSTIC_MALFORMED_INNER_SRC	62
7963055Sdanmcd #define	SADB_X_DIAGNOSTIC_MALFORMED_INNER_DST	63
7973055Sdanmcd 
7983055Sdanmcd #define	SADB_X_DIAGNOSTIC_PREFIX_INNER_SRC	64
7993055Sdanmcd #define	SADB_X_DIAGNOSTIC_PREFIX_INNER_DST	65
8003055Sdanmcd #define	SADB_X_DIAGNOSTIC_BAD_INNER_DST_AF	66
8013055Sdanmcd #define	SADB_X_DIAGNOSTIC_INNER_AF_MISMATCH	67
8023055Sdanmcd 
8033055Sdanmcd #define	SADB_X_DIAGNOSTIC_BAD_NATT_REM_AF	68
8043055Sdanmcd #define	SADB_X_DIAGNOSTIC_BAD_NATT_LOC_AF	69
8053055Sdanmcd 
8063055Sdanmcd #define	SADB_X_DIAGNOSTIC_PROTO_MISMATCH	70
8073055Sdanmcd #define	SADB_X_DIAGNOSTIC_INNER_PROTO_MISMATCH	71
8083055Sdanmcd 
8093055Sdanmcd #define	SADB_X_DIAGNOSTIC_DUAL_PORT_SETS	72
8103055Sdanmcd 
8116668Smarkfen #define	SADB_X_DIAGNOSTIC_PAIR_INAPPROPRIATE	73
8126668Smarkfen #define	SADB_X_DIAGNOSTIC_PAIR_ADD_MISMATCH	74
8136668Smarkfen #define	SADB_X_DIAGNOSTIC_PAIR_ALREADY		75
8146668Smarkfen #define	SADB_X_DIAGNOSTIC_PAIR_SA_NOTFOUND	76
8156668Smarkfen #define	SADB_X_DIAGNOSTIC_BAD_SA_DIRECTION	77
8166668Smarkfen 
8176668Smarkfen #define	SADB_X_DIAGNOSTIC_SA_NOTFOUND		78
8186668Smarkfen #define	SADB_X_DIAGNOSTIC_SA_EXPIRED		79
81910019SMark.Fenwick@Sun.COM #define	SADB_X_DIAGNOSTIC_BAD_CTX		80
82010019SMark.Fenwick@Sun.COM #define	SADB_X_DIAGNOSTIC_INVALID_REPLAY	81
82110019SMark.Fenwick@Sun.COM #define	SADB_X_DIAGNOSTIC_MISSING_LIFETIME	82
822*10934Ssommerfeld@sun.com 
823*10934Ssommerfeld@sun.com #define	SADB_X_DIAGNOSTIC_BAD_LABEL		83
824*10934Ssommerfeld@sun.com #define	SADB_X_DIAGNOSTIC_MAX			83
8250Sstevel@tonic-gate 
8260Sstevel@tonic-gate /* Algorithm type for sadb_x_algdesc above... */
8270Sstevel@tonic-gate 
8280Sstevel@tonic-gate #define	SADB_X_ALGTYPE_NONE		0
8290Sstevel@tonic-gate #define	SADB_X_ALGTYPE_AUTH		1
8300Sstevel@tonic-gate #define	SADB_X_ALGTYPE_CRYPT		2
8310Sstevel@tonic-gate #define	SADB_X_ALGTYPE_COMPRESS		3
8320Sstevel@tonic-gate 
8330Sstevel@tonic-gate #define	SADB_X_ALGTYPE_MAX		3
8340Sstevel@tonic-gate 
8350Sstevel@tonic-gate /* Key management protocol for sadb_x_kmc above... */
8360Sstevel@tonic-gate 
8370Sstevel@tonic-gate #define	SADB_X_KMP_MANUAL	0
8380Sstevel@tonic-gate #define	SADB_X_KMP_IKE		1
8390Sstevel@tonic-gate #define	SADB_X_KMP_KINK		2
8400Sstevel@tonic-gate 
8410Sstevel@tonic-gate #define	SADB_X_KMP_MAX		2
8420Sstevel@tonic-gate 
8430Sstevel@tonic-gate /*
8440Sstevel@tonic-gate  * Handy conversion macros.  Not part of the PF_KEY spec...
8450Sstevel@tonic-gate  */
8460Sstevel@tonic-gate 
8470Sstevel@tonic-gate #define	SADB_64TO8(x)	((x) << 3)
8480Sstevel@tonic-gate #define	SADB_8TO64(x)	((x) >> 3)
8490Sstevel@tonic-gate #define	SADB_8TO1(x)	((x) << 3)
8500Sstevel@tonic-gate #define	SADB_1TO8(x)	((x) >> 3)
8510Sstevel@tonic-gate 
8520Sstevel@tonic-gate #ifdef	__cplusplus
8530Sstevel@tonic-gate }
8540Sstevel@tonic-gate #endif
8550Sstevel@tonic-gate 
8560Sstevel@tonic-gate #endif	/* _NET_PFKEYV2_H */
857