xref: /illumos-gate/usr/src/lib/libipsecutil/common/ikedoor.h (revision 5d3b8cb7141cfa596d20cdc5043b8a6df635938d)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50f2065ccSmarkfen  * Common Development and Distribution License (the "License").
60f2065ccSmarkfen  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22c7777ac8SPaul Wernau  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_IKEDOOR_H
277c478bd9Sstevel@tonic-gate #define	_IKEDOOR_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
307c478bd9Sstevel@tonic-gate extern "C" {
317c478bd9Sstevel@tonic-gate #endif
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <limits.h>
347c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
357c478bd9Sstevel@tonic-gate #include <net/pfkeyv2.h>
367c478bd9Sstevel@tonic-gate #include <door.h>
377c478bd9Sstevel@tonic-gate 
380f2065ccSmarkfen /*
390f2065ccSmarkfen  * This version number is intended to stop the calling process from
400f2065ccSmarkfen  * getting confused if a structure is changed and a mismatch occurs.
410f2065ccSmarkfen  * This should be incremented each time a structure is changed.
420f2065ccSmarkfen  */
43dc739cedSDan McDonald 
44dc739cedSDan McDonald /*
45dc739cedSDan McDonald  * The IKE process may be a 64-bit process, but ikeadm or any other IKE
46dc739cedSDan McDonald  * door consumer does not have to be.  We need to be strict ala. PF_KEY or
47dc739cedSDan McDonald  * any on-the-wire-protocol with respect to structure fields offsets and
48dc739cedSDan McDonald  * alignment.  Please make sure all structures are the same size on both
49dc739cedSDan McDonald  * 64-bit and 32-bit execution environments (or even other ones), and that
50dc739cedSDan McDonald  * apart from trivial 4-byte enums or base headers, that all structures are
51dc739cedSDan McDonald  * multiples of 8-bytes (64-bits).
52dc739cedSDan McDonald  */
53dc739cedSDan McDonald #define	DOORVER 3
547c478bd9Sstevel@tonic-gate #define	DOORNM	"/var/run/ike_door"
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate typedef enum {
587c478bd9Sstevel@tonic-gate 	IKE_SVC_GET_DBG,
597c478bd9Sstevel@tonic-gate 	IKE_SVC_SET_DBG,
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate 	IKE_SVC_GET_PRIV,
627c478bd9Sstevel@tonic-gate 	IKE_SVC_SET_PRIV,
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate 	IKE_SVC_GET_STATS,
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate 	IKE_SVC_GET_P1,
677c478bd9Sstevel@tonic-gate 	IKE_SVC_DEL_P1,
687c478bd9Sstevel@tonic-gate 	IKE_SVC_DUMP_P1S,
697c478bd9Sstevel@tonic-gate 	IKE_SVC_FLUSH_P1S,
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate 	IKE_SVC_GET_RULE,
727c478bd9Sstevel@tonic-gate 	IKE_SVC_NEW_RULE,
737c478bd9Sstevel@tonic-gate 	IKE_SVC_DEL_RULE,
747c478bd9Sstevel@tonic-gate 	IKE_SVC_DUMP_RULES,
757c478bd9Sstevel@tonic-gate 	IKE_SVC_READ_RULES,
767c478bd9Sstevel@tonic-gate 	IKE_SVC_WRITE_RULES,
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate 	IKE_SVC_GET_PS,
797c478bd9Sstevel@tonic-gate 	IKE_SVC_NEW_PS,
807c478bd9Sstevel@tonic-gate 	IKE_SVC_DEL_PS,
817c478bd9Sstevel@tonic-gate 	IKE_SVC_DUMP_PS,
827c478bd9Sstevel@tonic-gate 	IKE_SVC_READ_PS,
837c478bd9Sstevel@tonic-gate 	IKE_SVC_WRITE_PS,
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate 	IKE_SVC_DBG_RBDUMP,
867c478bd9Sstevel@tonic-gate 
870f2065ccSmarkfen 	IKE_SVC_GET_DEFS,
880f2065ccSmarkfen 
89c7777ac8SPaul Wernau 	IKE_SVC_SET_PIN,
90c7777ac8SPaul Wernau 	IKE_SVC_DEL_PIN,
91c7777ac8SPaul Wernau 
92c7777ac8SPaul Wernau 	IKE_SVC_DUMP_CERTCACHE,
93c7777ac8SPaul Wernau 	IKE_SVC_FLUSH_CERTCACHE,
94c7777ac8SPaul Wernau 
957c478bd9Sstevel@tonic-gate 	IKE_SVC_ERROR
967c478bd9Sstevel@tonic-gate } ike_svccmd_t;
977c478bd9Sstevel@tonic-gate 
989c2c14abSThejaswini Singarajipura /* DPD status */
999c2c14abSThejaswini Singarajipura 
1009c2c14abSThejaswini Singarajipura typedef enum dpd_status {
1019c2c14abSThejaswini Singarajipura 	DPD_NOT_INITIATED = 0,
1029c2c14abSThejaswini Singarajipura 	DPD_IN_PROGRESS,
1039c2c14abSThejaswini Singarajipura 	DPD_SUCCESSFUL,
1049c2c14abSThejaswini Singarajipura 	DPD_FAILURE
1059c2c14abSThejaswini Singarajipura } dpd_status_t;
1069c2c14abSThejaswini Singarajipura 
1077c478bd9Sstevel@tonic-gate #define	IKE_SVC_MAX	IKE_SVC_ERROR
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate /*
1117c478bd9Sstevel@tonic-gate  * Support structures/defines
1127c478bd9Sstevel@tonic-gate  */
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate #define	IKEDOORROUNDUP(i)   P2ROUNDUP((i), sizeof (uint64_t))
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate /*
1177c478bd9Sstevel@tonic-gate  * Debug categories.  The debug level is a bitmask made up of
1187c478bd9Sstevel@tonic-gate  * flags indicating the desired categories; only 31 bits are
1197c478bd9Sstevel@tonic-gate  * available, as the highest-order bit designates an invalid
1207c478bd9Sstevel@tonic-gate  * setting.
1217c478bd9Sstevel@tonic-gate  */
1227c478bd9Sstevel@tonic-gate #define	D_INVALID	0x80000000
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate #define	D_CERT		0x00000001	/* certificate management */
1257c478bd9Sstevel@tonic-gate #define	D_KEY		0x00000002	/* key management */
1267c478bd9Sstevel@tonic-gate #define	D_OP		0x00000004	/* operational: config, init, mem */
1277c478bd9Sstevel@tonic-gate #define	D_P1		0x00000008	/* phase 1 negotiation */
1287c478bd9Sstevel@tonic-gate #define	D_P2		0x00000010	/* phase 2 negotiation */
1297c478bd9Sstevel@tonic-gate #define	D_PFKEY		0x00000020	/* pf key interface */
1307c478bd9Sstevel@tonic-gate #define	D_POL		0x00000040	/* policy management */
1317c478bd9Sstevel@tonic-gate #define	D_PROP		0x00000080	/* proposal construction */
1327c478bd9Sstevel@tonic-gate #define	D_DOOR		0x00000100	/* door server */
1337c478bd9Sstevel@tonic-gate #define	D_CONFIG	0x00000200	/* config file processing */
134*5d3b8cb7SBill Sommerfeld #define	D_LABEL		0x00000400	/* MAC labels */
1357c478bd9Sstevel@tonic-gate 
136*5d3b8cb7SBill Sommerfeld #define	D_HIGHBIT	0x00000400
137*5d3b8cb7SBill Sommerfeld #define	D_ALL		0x000007ff
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate /*
1407c478bd9Sstevel@tonic-gate  * Access privilege levels: define level of access to keying information.
1417c478bd9Sstevel@tonic-gate  * The privileges granted at each level is a superset of the privileges
1427c478bd9Sstevel@tonic-gate  * granted at all lower levels.
1437c478bd9Sstevel@tonic-gate  *
1447c478bd9Sstevel@tonic-gate  * The door operations which require special privileges are:
1457c478bd9Sstevel@tonic-gate  *
1467c478bd9Sstevel@tonic-gate  *	- receiving keying material for SAs and preshared key entries
1477c478bd9Sstevel@tonic-gate  *	  IKE_PRIV_KEYMAT must be set for this.
1487c478bd9Sstevel@tonic-gate  *
1497c478bd9Sstevel@tonic-gate  *	- get/dump/new/delete/read/write preshared keys
1507c478bd9Sstevel@tonic-gate  *	  IKE_PRIV_KEYMAT or IKE_PRIV_MODKEYS must be set to do this.
1517c478bd9Sstevel@tonic-gate  *	  If IKE_PRIV_MODKEYS is set, the information returned for a
1527c478bd9Sstevel@tonic-gate  *	  get/dump request will not include the actual key; in order
1537c478bd9Sstevel@tonic-gate  *	  to get the key itself, IKE_PRIV_KEYMAT must be set.
1547c478bd9Sstevel@tonic-gate  *
1557c478bd9Sstevel@tonic-gate  *	- modifying the privilege level: the daemon's privilege level
1567c478bd9Sstevel@tonic-gate  *	  is set when the daemon is started; the level may only be
1577c478bd9Sstevel@tonic-gate  *	  lowered via the door interface.
1587c478bd9Sstevel@tonic-gate  *
1597c478bd9Sstevel@tonic-gate  * All other operations are allowed at any privilege level.
1607c478bd9Sstevel@tonic-gate  */
1617c478bd9Sstevel@tonic-gate #define	IKE_PRIV_MINIMUM	0
1627c478bd9Sstevel@tonic-gate #define	IKE_PRIV_MODKEYS	1
1637c478bd9Sstevel@tonic-gate #define	IKE_PRIV_KEYMAT		2
1647c478bd9Sstevel@tonic-gate #define	IKE_PRIV_MAXIMUM	2
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate /* global ike stats formatting structure */
1677c478bd9Sstevel@tonic-gate typedef struct {
1687c478bd9Sstevel@tonic-gate 	uint32_t	st_init_p1_current;
1697c478bd9Sstevel@tonic-gate 	uint32_t	st_resp_p1_current;
1707c478bd9Sstevel@tonic-gate 	uint32_t	st_init_p1_total;
1717c478bd9Sstevel@tonic-gate 	uint32_t	st_resp_p1_total;
1727c478bd9Sstevel@tonic-gate 	uint32_t	st_init_p1_attempts;
1737c478bd9Sstevel@tonic-gate 	uint32_t	st_resp_p1_attempts;
1747c478bd9Sstevel@tonic-gate 	uint32_t	st_init_p1_noresp;   /* failed; no response from peer */
1757c478bd9Sstevel@tonic-gate 	uint32_t	st_init_p1_respfail; /* failed, but peer responded */
1767c478bd9Sstevel@tonic-gate 	uint32_t	st_resp_p1_fail;
1777c478bd9Sstevel@tonic-gate 	uint32_t	st_reserved;
1787c478bd9Sstevel@tonic-gate 	char		st_pkcs11_libname[PATH_MAX];
1797c478bd9Sstevel@tonic-gate } ike_stats_t;
1807c478bd9Sstevel@tonic-gate 
1810f2065ccSmarkfen /* structure used to pass default values used by in.iked back to ikeadm */
1820f2065ccSmarkfen typedef struct {
1830f2065ccSmarkfen 	uint32_t	rule_p1_lifetime_secs;
1840f2065ccSmarkfen 	uint32_t	rule_p1_minlife;
1850f2065ccSmarkfen 	uint32_t	rule_p1_nonce_len;
1860f2065ccSmarkfen 	uint32_t	rule_p2_lifetime_secs;
1870f2065ccSmarkfen 	uint32_t	rule_p2_softlife_secs;
1889c2c14abSThejaswini Singarajipura 	uint32_t	rule_p2_idletime_secs;
1891a6921e0Smarkfen 	uint32_t	sys_p2_lifetime_secs;
1901a6921e0Smarkfen 	uint32_t	sys_p2_softlife_secs;
1919c2c14abSThejaswini Singarajipura 	uint32_t	sys_p2_idletime_secs;
1920f2065ccSmarkfen 	uint32_t	rule_p2_lifetime_kb;
1930f2065ccSmarkfen 	uint32_t	rule_p2_softlife_kb;
1941a6921e0Smarkfen 	uint32_t	sys_p2_lifetime_bytes;
1951a6921e0Smarkfen 	uint32_t	sys_p2_softlife_bytes;
1960f2065ccSmarkfen 	uint32_t	rule_p2_minlife;
1970f2065ccSmarkfen 	uint32_t	rule_p2_def_minlife;
1980f2065ccSmarkfen 	uint32_t	rule_p2_nonce_len;
1990f2065ccSmarkfen 	uint32_t	rule_p2_pfs;
2000f2065ccSmarkfen 	uint32_t	rule_p2_minsoft;
2010f2065ccSmarkfen 	uint32_t	rule_max_certs;
2020f2065ccSmarkfen 	uint32_t	rule_ike_port;
2030f2065ccSmarkfen 	uint32_t	rule_natt_port;
204dc739cedSDan McDonald 	uint32_t	defaults_reserved;	/* For 64-bit alignment. */
2050f2065ccSmarkfen } ike_defaults_t;
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate /* data formatting structures for P1 SA dumps */
2087c478bd9Sstevel@tonic-gate typedef struct {
2097c478bd9Sstevel@tonic-gate 	struct sockaddr_storage	loc_addr;
2107c478bd9Sstevel@tonic-gate 	struct sockaddr_storage	rem_addr;
2117c478bd9Sstevel@tonic-gate #define	beg_iprange	loc_addr
2127c478bd9Sstevel@tonic-gate #define	end_iprange	rem_addr
2137c478bd9Sstevel@tonic-gate } ike_addr_pr_t;
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate typedef struct {
2167c478bd9Sstevel@tonic-gate 	uint64_t	cky_i;
2177c478bd9Sstevel@tonic-gate 	uint64_t	cky_r;
2187c478bd9Sstevel@tonic-gate } ike_cky_pr_t;
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate typedef struct {
2217c478bd9Sstevel@tonic-gate 	ike_cky_pr_t	p1hdr_cookies;
2227c478bd9Sstevel@tonic-gate 	uint8_t		p1hdr_major;
2237c478bd9Sstevel@tonic-gate 	uint8_t		p1hdr_minor;
2247c478bd9Sstevel@tonic-gate 	uint8_t		p1hdr_xchg;
2257c478bd9Sstevel@tonic-gate 	uint8_t		p1hdr_isinit;
2267c478bd9Sstevel@tonic-gate 	uint32_t	p1hdr_state;
2279c2c14abSThejaswini Singarajipura 	boolean_t	p1hdr_support_dpd;
2289c2c14abSThejaswini Singarajipura 	dpd_status_t	p1hdr_dpd_state;
229dc739cedSDan McDonald 	uint64_t	p1hdr_dpd_time;
2307c478bd9Sstevel@tonic-gate } ike_p1_hdr_t;
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate /* values for p1hdr_xchg (aligned with RFC2408, section 3.1) */
2337c478bd9Sstevel@tonic-gate #define	IKE_XCHG_NONE			0
2347c478bd9Sstevel@tonic-gate #define	IKE_XCHG_BASE			1
2357c478bd9Sstevel@tonic-gate #define	IKE_XCHG_IDENTITY_PROTECT	2
2367c478bd9Sstevel@tonic-gate #define	IKE_XCHG_AUTH_ONLY		3
2377c478bd9Sstevel@tonic-gate #define	IKE_XCHG_AGGRESSIVE		4
2387c478bd9Sstevel@tonic-gate /* following not from RFC; used only for preshared key definitions */
2397c478bd9Sstevel@tonic-gate #define	IKE_XCHG_IP_AND_AGGR		240
2407c478bd9Sstevel@tonic-gate /* also not from RFC; used as wildcard */
2417c478bd9Sstevel@tonic-gate #define	IKE_XCHG_ANY			256
2427c478bd9Sstevel@tonic-gate 
2437c478bd9Sstevel@tonic-gate /* values for p1hdr_state */
2447c478bd9Sstevel@tonic-gate #define	IKE_SA_STATE_INVALID	0
2457c478bd9Sstevel@tonic-gate #define	IKE_SA_STATE_INIT	1
2467c478bd9Sstevel@tonic-gate #define	IKE_SA_STATE_SENT_SA	2
2477c478bd9Sstevel@tonic-gate #define	IKE_SA_STATE_SENT_KE	3
2487c478bd9Sstevel@tonic-gate #define	IKE_SA_STATE_SENT_LAST	4
2497c478bd9Sstevel@tonic-gate #define	IKE_SA_STATE_DONE	5
2507c478bd9Sstevel@tonic-gate #define	IKE_SA_STATE_DELETED	6
2517c478bd9Sstevel@tonic-gate 
2527c478bd9Sstevel@tonic-gate typedef struct {
2537c478bd9Sstevel@tonic-gate 	uint16_t	p1xf_dh_group;
2547c478bd9Sstevel@tonic-gate 	uint16_t	p1xf_encr_alg;
25520dc9b2eSvk199839 	uint16_t	p1xf_encr_low_bits;
25620dc9b2eSvk199839 	uint16_t	p1xf_encr_high_bits;
2577c478bd9Sstevel@tonic-gate 	uint16_t	p1xf_auth_alg;
2587c478bd9Sstevel@tonic-gate 	uint16_t	p1xf_auth_meth;
2597c478bd9Sstevel@tonic-gate 	uint16_t	p1xf_prf;
2607c478bd9Sstevel@tonic-gate 	uint16_t	p1xf_pfs;
2617c478bd9Sstevel@tonic-gate 	uint32_t	p1xf_max_secs;
2627c478bd9Sstevel@tonic-gate 	uint32_t	p1xf_max_kbytes;
2637c478bd9Sstevel@tonic-gate 	uint32_t	p1xf_max_keyuses;
264dc739cedSDan McDonald 	uint32_t	p1xf_reserved;	/* Alignment to 64-bit. */
2657c478bd9Sstevel@tonic-gate } ike_p1_xform_t;
2667c478bd9Sstevel@tonic-gate 
2677c478bd9Sstevel@tonic-gate /* values for p1xf_dh_group (aligned with RFC2409, Appendix A) */
2687c478bd9Sstevel@tonic-gate #define	IKE_GRP_DESC_MODP_768	1
2697c478bd9Sstevel@tonic-gate #define	IKE_GRP_DESC_MODP_1024	2
2707c478bd9Sstevel@tonic-gate #define	IKE_GRP_DESC_EC2N_155	3
2717c478bd9Sstevel@tonic-gate #define	IKE_GRP_DESC_EC2N_185	4
272020bf065Smarkfen /* values for p1xf_dh_group (aligned with RFC3526) */
2737c478bd9Sstevel@tonic-gate #define	IKE_GRP_DESC_MODP_1536	5
274020bf065Smarkfen #define	IKE_GRP_DESC_MODP_2048	14
275020bf065Smarkfen #define	IKE_GRP_DESC_MODP_3072	15
276020bf065Smarkfen #define	IKE_GRP_DESC_MODP_4096	16
277020bf065Smarkfen #define	IKE_GRP_DESC_MODP_6144	17
278020bf065Smarkfen #define	IKE_GRP_DESC_MODP_8192	18
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate /* values for p1xf_auth_meth (aligned with RFC2409, Appendix A) */
2817c478bd9Sstevel@tonic-gate #define	IKE_AUTH_METH_PRE_SHARED_KEY	1
2827c478bd9Sstevel@tonic-gate #define	IKE_AUTH_METH_DSS_SIG		2
2837c478bd9Sstevel@tonic-gate #define	IKE_AUTH_METH_RSA_SIG		3
2847c478bd9Sstevel@tonic-gate #define	IKE_AUTH_METH_RSA_ENCR		4
2857c478bd9Sstevel@tonic-gate #define	IKE_AUTH_METH_RSA_ENCR_REVISED	5
2867c478bd9Sstevel@tonic-gate 
2877c478bd9Sstevel@tonic-gate /* values for p1xf_prf */
2887c478bd9Sstevel@tonic-gate #define	IKE_PRF_NONE		0
2897c478bd9Sstevel@tonic-gate #define	IKE_PRF_HMAC_MD5	1
2907c478bd9Sstevel@tonic-gate #define	IKE_PRF_HMAC_SHA1	2
2910358d3a6Sdanmcd #define	IKE_PRF_HMAC_SHA256	5
2920358d3a6Sdanmcd #define	IKE_PRF_HMAC_SHA384	6
2930358d3a6Sdanmcd #define	IKE_PRF_HMAC_SHA512	7
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate typedef struct {
2967c478bd9Sstevel@tonic-gate 	/*
2977c478bd9Sstevel@tonic-gate 	 * NOTE: the new and del counters count the actual number of SAs,
2987c478bd9Sstevel@tonic-gate 	 * not the number of "suites", as defined in the ike monitoring
2997c478bd9Sstevel@tonic-gate 	 * mib draft; we do this because we don't have a good way of
3007c478bd9Sstevel@tonic-gate 	 * tracking the deletion of entire suites (we're notified of
3017c478bd9Sstevel@tonic-gate 	 * deleted qm sas individually).
3027c478bd9Sstevel@tonic-gate 	 */
3037c478bd9Sstevel@tonic-gate 	uint32_t	p1stat_new_qm_sas;
3047c478bd9Sstevel@tonic-gate 	uint32_t	p1stat_del_qm_sas;
3057c478bd9Sstevel@tonic-gate 	uint64_t	p1stat_start;
3067c478bd9Sstevel@tonic-gate 	uint32_t	p1stat_kbytes;
3077c478bd9Sstevel@tonic-gate 	uint32_t	p1stat_keyuses;
3087c478bd9Sstevel@tonic-gate } ike_p1_stats_t;
3097c478bd9Sstevel@tonic-gate 
3107c478bd9Sstevel@tonic-gate typedef struct {
3117c478bd9Sstevel@tonic-gate 	uint32_t	p1err_decrypt;
3127c478bd9Sstevel@tonic-gate 	uint32_t	p1err_hash;
3137c478bd9Sstevel@tonic-gate 	uint32_t	p1err_otherrx;
3147c478bd9Sstevel@tonic-gate 	uint32_t	p1err_tx;
3157c478bd9Sstevel@tonic-gate } ike_p1_errors_t;
3167c478bd9Sstevel@tonic-gate 
3177c478bd9Sstevel@tonic-gate typedef struct {
3187c478bd9Sstevel@tonic-gate 	uint32_t	p1key_type;
3197c478bd9Sstevel@tonic-gate 	uint32_t	p1key_len;
3207c478bd9Sstevel@tonic-gate 	/*
3217c478bd9Sstevel@tonic-gate 	 * followed by (len - sizeof (ike_p1_key_t)) bytes of hex data,
3227c478bd9Sstevel@tonic-gate 	 * 64-bit aligned (pad bytes are added at the end, if necessary,
3237c478bd9Sstevel@tonic-gate 	 * and NOT INCLUDED in the len value, which reflects the actual
3247c478bd9Sstevel@tonic-gate 	 * key size).
3257c478bd9Sstevel@tonic-gate 	 */
3267c478bd9Sstevel@tonic-gate } ike_p1_key_t;
3277c478bd9Sstevel@tonic-gate 
3287c478bd9Sstevel@tonic-gate /* key info types for ike_p1_key_t struct */
3297c478bd9Sstevel@tonic-gate #define	IKE_KEY_PRESHARED	1
3307c478bd9Sstevel@tonic-gate #define	IKE_KEY_SKEYID		2
3317c478bd9Sstevel@tonic-gate #define	IKE_KEY_SKEYID_D	3
3327c478bd9Sstevel@tonic-gate #define	IKE_KEY_SKEYID_A	4
3337c478bd9Sstevel@tonic-gate #define	IKE_KEY_SKEYID_E	5
3347c478bd9Sstevel@tonic-gate #define	IKE_KEY_ENCR		6
3357c478bd9Sstevel@tonic-gate #define	IKE_KEY_IV		7
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate typedef struct {
3387c478bd9Sstevel@tonic-gate 	ike_p1_hdr_t	p1sa_hdr;
3397c478bd9Sstevel@tonic-gate 	ike_p1_xform_t	p1sa_xform;
3407c478bd9Sstevel@tonic-gate 	ike_addr_pr_t	p1sa_ipaddrs;
3417c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_stat_off;
3427c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_stat_len;
3437c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_error_off;
3447c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_error_len;
3457c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_localid_off;
3467c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_localid_len;
3477c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_remoteid_off;
3487c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_remoteid_len;
3497c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_key_off;
3507c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_key_len;
3517c478bd9Sstevel@tonic-gate 	uint32_t	p1sa_reserved;
3527c478bd9Sstevel@tonic-gate 	/*
3537c478bd9Sstevel@tonic-gate 	 * variable-length structures will be included here, as
3547c478bd9Sstevel@tonic-gate 	 * indicated by offset/length fields.
3557c478bd9Sstevel@tonic-gate 	 * stats and errors will be formatted as ike_p1_stats_t and
3567c478bd9Sstevel@tonic-gate 	 * ike_p1_errors_t, respectively.
3577c478bd9Sstevel@tonic-gate 	 * key info will be formatted as a series of p1_key_t structs.
3587c478bd9Sstevel@tonic-gate 	 * local/remote ids will be formatted as sadb_ident_t structs.
3597c478bd9Sstevel@tonic-gate 	 */
3607c478bd9Sstevel@tonic-gate } ike_p1_sa_t;
3617c478bd9Sstevel@tonic-gate 
3627c478bd9Sstevel@tonic-gate 
3637c478bd9Sstevel@tonic-gate #define	MAX_LABEL_LEN	256
3647c478bd9Sstevel@tonic-gate 
3657c478bd9Sstevel@tonic-gate 
3667c478bd9Sstevel@tonic-gate /* data formatting structure for policy (rule) dumps */
3677c478bd9Sstevel@tonic-gate 
3687c478bd9Sstevel@tonic-gate typedef struct {
3697c478bd9Sstevel@tonic-gate 	char		rule_label[MAX_LABEL_LEN];
3707c478bd9Sstevel@tonic-gate 	uint32_t	rule_kmcookie;
3717c478bd9Sstevel@tonic-gate 	uint16_t	rule_ike_mode;
3727c478bd9Sstevel@tonic-gate 	uint16_t	rule_local_idtype;	/* SADB_IDENTTYPE_* value */
3737c478bd9Sstevel@tonic-gate 	uint32_t	rule_p1_nonce_len;
3747c478bd9Sstevel@tonic-gate 	uint32_t	rule_p2_nonce_len;
3757c478bd9Sstevel@tonic-gate 	uint32_t	rule_p2_pfs;
3760f2065ccSmarkfen 	uint32_t	rule_p2_lifetime_secs;
3770f2065ccSmarkfen 	uint32_t	rule_p2_softlife_secs;
3789c2c14abSThejaswini Singarajipura 	uint32_t	rule_p2_idletime_secs;
3790f2065ccSmarkfen 	uint32_t	rule_p2_lifetime_kb;
3800f2065ccSmarkfen 	uint32_t	rule_p2_softlife_kb;
3817c478bd9Sstevel@tonic-gate 	uint16_t	rule_xform_cnt;
3827c478bd9Sstevel@tonic-gate 	uint16_t	rule_xform_off;
3837c478bd9Sstevel@tonic-gate 	uint16_t	rule_locip_cnt;
3847c478bd9Sstevel@tonic-gate 	uint16_t	rule_locip_off;
3857c478bd9Sstevel@tonic-gate 	uint16_t	rule_remip_cnt;
3867c478bd9Sstevel@tonic-gate 	uint16_t	rule_remip_off;
3877c478bd9Sstevel@tonic-gate 	uint16_t	rule_locid_inclcnt;
3887c478bd9Sstevel@tonic-gate 	uint16_t	rule_locid_exclcnt;
3897c478bd9Sstevel@tonic-gate 	uint16_t	rule_locid_off;
3907c478bd9Sstevel@tonic-gate 	uint16_t	rule_remid_inclcnt;
3917c478bd9Sstevel@tonic-gate 	uint16_t	rule_remid_exclcnt;
3927c478bd9Sstevel@tonic-gate 	uint16_t	rule_remid_off;
3937c478bd9Sstevel@tonic-gate 	/*
3947c478bd9Sstevel@tonic-gate 	 * Followed by several lists of variable-length structures, described
3957c478bd9Sstevel@tonic-gate 	 * by counts and offsets:
3967c478bd9Sstevel@tonic-gate 	 *	transforms			ike_p1_xform_t structs
3977c478bd9Sstevel@tonic-gate 	 *	ranges of local ip addrs	ike_addr_pr_t structs
3987c478bd9Sstevel@tonic-gate 	 *	ranges of remote ip addrs	ike_addr_pr_t structs
3997c478bd9Sstevel@tonic-gate 	 *	local identification strings	null-terminated ascii strings
4007c478bd9Sstevel@tonic-gate 	 *	remote identification strings	null-terminated ascii strings
4017c478bd9Sstevel@tonic-gate 	 */
4027c478bd9Sstevel@tonic-gate } ike_rule_t;
4037c478bd9Sstevel@tonic-gate 
4047c478bd9Sstevel@tonic-gate 
4057c478bd9Sstevel@tonic-gate /*
4067c478bd9Sstevel@tonic-gate  * data formatting structure for preshared keys
4077c478bd9Sstevel@tonic-gate  * ps_ike_mode field uses the IKE_XCHG_* defs
4087c478bd9Sstevel@tonic-gate  */
4097c478bd9Sstevel@tonic-gate typedef struct {
4107c478bd9Sstevel@tonic-gate 	ike_addr_pr_t	ps_ipaddrs;
4117c478bd9Sstevel@tonic-gate 	uint16_t	ps_ike_mode;
4127c478bd9Sstevel@tonic-gate 	uint16_t	ps_localid_off;
4137c478bd9Sstevel@tonic-gate 	uint16_t	ps_localid_len;
4147c478bd9Sstevel@tonic-gate 	uint16_t	ps_remoteid_off;
4157c478bd9Sstevel@tonic-gate 	uint16_t	ps_remoteid_len;
4167c478bd9Sstevel@tonic-gate 	uint16_t	ps_key_off;
4177c478bd9Sstevel@tonic-gate 	uint16_t	ps_key_len;
4187c478bd9Sstevel@tonic-gate 	uint16_t	ps_key_bits;
4197c478bd9Sstevel@tonic-gate 	/*
4207c478bd9Sstevel@tonic-gate 	 * followed by variable-length structures, as indicated by
4217c478bd9Sstevel@tonic-gate 	 * offset/length fields.
4227c478bd9Sstevel@tonic-gate 	 * key info will be formatted as an array of bytes.
4237c478bd9Sstevel@tonic-gate 	 * local/remote ids will be formatted as sadb_ident_t structs.
4247c478bd9Sstevel@tonic-gate 	 */
4257c478bd9Sstevel@tonic-gate } ike_ps_t;
4267c478bd9Sstevel@tonic-gate 
427c7777ac8SPaul Wernau #define	DN_MAX			1024
428c7777ac8SPaul Wernau #define	CERT_OFF_WIRE		-1
429c7777ac8SPaul Wernau #define	CERT_NO_PRIVKEY		0
430c7777ac8SPaul Wernau #define	CERT_PRIVKEY_LOCKED	1
431c7777ac8SPaul Wernau #define	CERT_PRIVKEY_AVAIL	2
432c7777ac8SPaul Wernau 
433c7777ac8SPaul Wernau /*
434c7777ac8SPaul Wernau  * data formatting structure for cached certs
435c7777ac8SPaul Wernau  */
436c7777ac8SPaul Wernau typedef struct {
437c7777ac8SPaul Wernau 	uint32_t	cache_id;
438c7777ac8SPaul Wernau 	uint32_t	class;
439c7777ac8SPaul Wernau 	int		linkage;
440dc739cedSDan McDonald 	uint32_t	certcache_padding;	/* For 64-bit alignment. */
441c7777ac8SPaul Wernau 	char		subject[DN_MAX];
442c7777ac8SPaul Wernau 	char		issuer[DN_MAX];
443c7777ac8SPaul Wernau } ike_certcache_t;
4447c478bd9Sstevel@tonic-gate 
4457c478bd9Sstevel@tonic-gate /* identification types */
4467c478bd9Sstevel@tonic-gate #define	IKE_ID_IDENT_PAIR	1
4477c478bd9Sstevel@tonic-gate #define	IKE_ID_ADDR_PAIR	2
4487c478bd9Sstevel@tonic-gate #define	IKE_ID_CKY_PAIR		3
4497c478bd9Sstevel@tonic-gate #define	IKE_ID_LABEL		4
4507c478bd9Sstevel@tonic-gate 
4517c478bd9Sstevel@tonic-gate 
4527c478bd9Sstevel@tonic-gate /* locations for read/write requests */
4537c478bd9Sstevel@tonic-gate #define	IKE_RW_LOC_DEFAULT	1
4547c478bd9Sstevel@tonic-gate #define	IKE_RW_LOC_USER_SPEC	2
4557c478bd9Sstevel@tonic-gate 
4567c478bd9Sstevel@tonic-gate 
4577c478bd9Sstevel@tonic-gate /* door interface error codes */
4587c478bd9Sstevel@tonic-gate #define	IKE_ERR_NO_OBJ		1	/* nothing found to match the request */
4597c478bd9Sstevel@tonic-gate #define	IKE_ERR_NO_DESC		2	/* fd was required with this request */
4607c478bd9Sstevel@tonic-gate #define	IKE_ERR_ID_INVALID	3	/* invalid id info was provided */
4617c478bd9Sstevel@tonic-gate #define	IKE_ERR_LOC_INVALID	4	/* invalid location info was provided */
4627c478bd9Sstevel@tonic-gate #define	IKE_ERR_CMD_INVALID	5	/* invalid command was provided */
4637c478bd9Sstevel@tonic-gate #define	IKE_ERR_DATA_INVALID	6	/* invalid data was provided */
4647c478bd9Sstevel@tonic-gate #define	IKE_ERR_CMD_NOTSUP	7	/* unsupported command */
4657c478bd9Sstevel@tonic-gate #define	IKE_ERR_REQ_INVALID	8	/* badly formatted request */
4667c478bd9Sstevel@tonic-gate #define	IKE_ERR_NO_PRIV		9	/* privilege level not high enough */
4677c478bd9Sstevel@tonic-gate #define	IKE_ERR_SYS_ERR		10	/* syserr occurred while processing */
46815b07f80Spwernau #define	IKE_ERR_DUP_IGNORED	11	/* attempt to add a duplicate entry */
469c7777ac8SPaul Wernau #define	IKE_ERR_NO_TOKEN	12	/* cannot login into pkcs#11 token */
470c7777ac8SPaul Wernau #define	IKE_ERR_NO_AUTH		13	/* not authorized */
471c7777ac8SPaul Wernau #define	IKE_ERR_IN_PROGRESS	14	/* operation already in progress */
472c7777ac8SPaul Wernau #define	IKE_ERR_NO_MEM		15	/* insufficient memory */
4737c478bd9Sstevel@tonic-gate 
4747c478bd9Sstevel@tonic-gate 
4757c478bd9Sstevel@tonic-gate /*
4767c478bd9Sstevel@tonic-gate  * IKE_SVC_GET_DBG
4777c478bd9Sstevel@tonic-gate  * Used to request the current debug level.
4787c478bd9Sstevel@tonic-gate  *
4797c478bd9Sstevel@tonic-gate  * Upon request, dbg_level is 0 (don't care).
4807c478bd9Sstevel@tonic-gate  *
4817c478bd9Sstevel@tonic-gate  * Upon return, dbg_level contains the current value.
4827c478bd9Sstevel@tonic-gate  *
4837c478bd9Sstevel@tonic-gate  *
4847c478bd9Sstevel@tonic-gate  * IKE_SVC_SET_DBG
4857c478bd9Sstevel@tonic-gate  * Used to request modification of the debug level.
4867c478bd9Sstevel@tonic-gate  *
4877c478bd9Sstevel@tonic-gate  * Upon request, dbg_level contains desired level.  If debug output is
4887c478bd9Sstevel@tonic-gate  * to be directed to a different file, the fd should be passed in the
4897c478bd9Sstevel@tonic-gate  * door_desc_t field of the door_arg_t param.  NOTE: if the daemon is
4907c478bd9Sstevel@tonic-gate  * currently running in the background with no debug set, an output
4917c478bd9Sstevel@tonic-gate  * file MUST be given.
4927c478bd9Sstevel@tonic-gate  *
4937c478bd9Sstevel@tonic-gate  * Upon return, dbg_level contains the old debug level, and acknowledges
4947c478bd9Sstevel@tonic-gate  * successful completion of the request.  If an error is encountered,
4957c478bd9Sstevel@tonic-gate  * ike_err_t is returned instead, with appropriate error value and cmd
4967c478bd9Sstevel@tonic-gate  * IKE_SVC_ERROR.
4977c478bd9Sstevel@tonic-gate  */
4987c478bd9Sstevel@tonic-gate typedef struct {
4997c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
5007c478bd9Sstevel@tonic-gate 	uint32_t	dbg_level;
5017c478bd9Sstevel@tonic-gate } ike_dbg_t;
5027c478bd9Sstevel@tonic-gate 
5037c478bd9Sstevel@tonic-gate /*
5047c478bd9Sstevel@tonic-gate  * IKE_SVC_GET_PRIV
5057c478bd9Sstevel@tonic-gate  * Used to request the current privilege level.
5067c478bd9Sstevel@tonic-gate  *
5077c478bd9Sstevel@tonic-gate  * Upon request, priv_level is 0 (don't care).
5087c478bd9Sstevel@tonic-gate  *
5097c478bd9Sstevel@tonic-gate  * Upon return, priv_level contains the current value.
5107c478bd9Sstevel@tonic-gate  *
5117c478bd9Sstevel@tonic-gate  *
5127c478bd9Sstevel@tonic-gate  * IKE_SVC_SET_PRIV
5137c478bd9Sstevel@tonic-gate  * Used to request modification of the privilege level.
5147c478bd9Sstevel@tonic-gate  *
5157c478bd9Sstevel@tonic-gate  * Upon request, priv_level contains the desired level.  The level may
5167c478bd9Sstevel@tonic-gate  * only be lowered via the door interface; it cannot be raised.  Thus,
5177c478bd9Sstevel@tonic-gate  * if in.iked is started at the lowest level, it cannot be changed.
5187c478bd9Sstevel@tonic-gate  *
5197c478bd9Sstevel@tonic-gate  * Upon return, priv_level contains the old privilege level, and
5207c478bd9Sstevel@tonic-gate  * acknowledges successful completion of the request.  If an error is
5217c478bd9Sstevel@tonic-gate  * encountered, ike_err_t is returned instead, with appropriate error
5227c478bd9Sstevel@tonic-gate  * value and cmd IKE_SVC_ERROR.
5237c478bd9Sstevel@tonic-gate  */
5247c478bd9Sstevel@tonic-gate typedef struct {
5257c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
5267c478bd9Sstevel@tonic-gate 	uint32_t	priv_level;
5277c478bd9Sstevel@tonic-gate } ike_priv_t;
5287c478bd9Sstevel@tonic-gate 
5297c478bd9Sstevel@tonic-gate 
5307c478bd9Sstevel@tonic-gate /*
5317c478bd9Sstevel@tonic-gate  * IKE_SVC_GET_STATS
5327c478bd9Sstevel@tonic-gate  * Used to request current statistics on Phase 1 SA creation and
5337c478bd9Sstevel@tonic-gate  * failures.  The statistics represent all activity in in.iked.
5347c478bd9Sstevel@tonic-gate  *
5357c478bd9Sstevel@tonic-gate  * Upon request, cmd is set, and stat_len does not matter.
5367c478bd9Sstevel@tonic-gate  *
5377c478bd9Sstevel@tonic-gate  * Upon successful return, stat_len contains the total size of the
5387c478bd9Sstevel@tonic-gate  * returned buffer, which contains first the ike_statreq_t struct,
5397c478bd9Sstevel@tonic-gate  * followed by the stat data in the ike_stats_t structure. In case
5407c478bd9Sstevel@tonic-gate  * of an error in processing the request, ike_err_t is returned with
5417c478bd9Sstevel@tonic-gate  * IKE_SVC_ERROR command and appropriate error code.
5427c478bd9Sstevel@tonic-gate  */
5437c478bd9Sstevel@tonic-gate typedef struct {
5447c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
5457c478bd9Sstevel@tonic-gate 	uint32_t	stat_len;
5467c478bd9Sstevel@tonic-gate } ike_statreq_t;
5477c478bd9Sstevel@tonic-gate 
5480f2065ccSmarkfen /*
5490f2065ccSmarkfen  * IKE_SVC_GET_DEFS
5500f2065ccSmarkfen  * Used to request default values from in.iked.
5510f2065ccSmarkfen  *
5520f2065ccSmarkfen  * Upon request, cmd is set, and stat_len does not matter.
5530f2065ccSmarkfen  *
5540f2065ccSmarkfen  * Upon successful return, stat_len contains the total size of the
5550f2065ccSmarkfen  * returned buffer, this contains a pair of ike_defaults_t's.
5560f2065ccSmarkfen  */
5570f2065ccSmarkfen typedef struct {
5580f2065ccSmarkfen 	ike_svccmd_t	cmd;
5590f2065ccSmarkfen 	uint32_t	stat_len;
5600f2065ccSmarkfen 	uint32_t	version;
561dc739cedSDan McDonald 	uint32_t	defreq_reserved;	/* For 64-bit alignment. */
5620f2065ccSmarkfen } ike_defreq_t;
5637c478bd9Sstevel@tonic-gate 
5647c478bd9Sstevel@tonic-gate /*
565c7777ac8SPaul Wernau  * IKE_SVC_DUMP_{P1S|RULES|PS|CERTCACHE}
5667c478bd9Sstevel@tonic-gate  * Used to request a table dump, and to return info for a single table
5677c478bd9Sstevel@tonic-gate  * item.  The expectation is that all of the table data will be passed
5687c478bd9Sstevel@tonic-gate  * through the door, one entry at a time; an individual request must be
5697c478bd9Sstevel@tonic-gate  * sent for each entry, however (the door server can't send unrequested
5707c478bd9Sstevel@tonic-gate  * data).
5717c478bd9Sstevel@tonic-gate  *
5727c478bd9Sstevel@tonic-gate  * Upon request: cmd is set, and dump_next contains the item number
5737c478bd9Sstevel@tonic-gate  * requested (0 for first request).  dump_len is 0; no data follows.
5747c478bd9Sstevel@tonic-gate  *
5757c478bd9Sstevel@tonic-gate  * Upon return: cmd is set, and dump_next contains the item number of
5767c478bd9Sstevel@tonic-gate  * the *next* item in the table (to be used in the subsequent request).
5777c478bd9Sstevel@tonic-gate  * dump_next = 0 indicates that this is the last item in the table.
5787c478bd9Sstevel@tonic-gate  * dump_len is the total length (data + struct) returned.  Data is
5797c478bd9Sstevel@tonic-gate  * formatted as indicated by the cmd type:
5807c478bd9Sstevel@tonic-gate  *   IKE_SVC_DUMP_P1S:		ike_p1_sa_t
5817c478bd9Sstevel@tonic-gate  *   IKE_SVC_DUMP_RULES:	ike_rule_t
5827c478bd9Sstevel@tonic-gate  *   IKE_SVC_DUMP_PS:		ike_ps_t
583c7777ac8SPaul Wernau  *   IKE_SVC_DUMP_CERTCACHE:	ike_certcache_t
5847c478bd9Sstevel@tonic-gate  */
5857c478bd9Sstevel@tonic-gate typedef struct {
5867c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
5877c478bd9Sstevel@tonic-gate 	uint32_t	dump_len;
5887c478bd9Sstevel@tonic-gate 	union {
5897c478bd9Sstevel@tonic-gate 		struct {
5907c478bd9Sstevel@tonic-gate 			uint32_t	dump_unext;
5917c478bd9Sstevel@tonic-gate 			uint32_t	dump_ureserved;
5927c478bd9Sstevel@tonic-gate 		} dump_actual;
5937c478bd9Sstevel@tonic-gate 		uint64_t dump_alignment;
5947c478bd9Sstevel@tonic-gate 	} dump_u;
5957c478bd9Sstevel@tonic-gate #define	dump_next dump_u.dump_actual.dump_unext
5967c478bd9Sstevel@tonic-gate #define	dump_reserved dump_u.dump_actual.dump_ureserved
5977c478bd9Sstevel@tonic-gate 	/* dump_len - sizeof (ike_dump_t) bytes of data included here */
5987c478bd9Sstevel@tonic-gate } ike_dump_t;
5997c478bd9Sstevel@tonic-gate 
6007c478bd9Sstevel@tonic-gate 
6017c478bd9Sstevel@tonic-gate /*
6027c478bd9Sstevel@tonic-gate  * IKE_SVC_GET_{P1|RULE|PS}
6037c478bd9Sstevel@tonic-gate  * Used to request and return individual table items.
6047c478bd9Sstevel@tonic-gate  *
6057c478bd9Sstevel@tonic-gate  * Upon request: get_len is the total msg length (struct + id data);
6067c478bd9Sstevel@tonic-gate  * get_idtype indicates the type of identification being used.
6077c478bd9Sstevel@tonic-gate  *   IKE_SVC_GET_P1:		ike_addr_pr_t or ike_cky_pr_t
6087c478bd9Sstevel@tonic-gate  *   IKE_SVC_GET_RULE:		char string (label)
6097c478bd9Sstevel@tonic-gate  *   IKE_SVC_GET_PS:		ike_addr_pr_t or pair of sadb_ident_t
6107c478bd9Sstevel@tonic-gate  *
6117c478bd9Sstevel@tonic-gate  * Upon return: get_len is the total size (struct + data), get_idtype
6127c478bd9Sstevel@tonic-gate  * is unused, and the data that follows is formatted according to cmd:
6137c478bd9Sstevel@tonic-gate  *   IKE_SVC_GET_P1:		ike_p1_sa_t
6147c478bd9Sstevel@tonic-gate  *   IKE_SVC_GET_RULE:		ike_rule_t
6157c478bd9Sstevel@tonic-gate  *   IKE_SVC_GET_PS:		ike_ps_t
6167c478bd9Sstevel@tonic-gate  */
6177c478bd9Sstevel@tonic-gate typedef struct {
6187c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
6197c478bd9Sstevel@tonic-gate 	uint32_t	get_len;
6207c478bd9Sstevel@tonic-gate 	union {
6217c478bd9Sstevel@tonic-gate 		struct {
6227c478bd9Sstevel@tonic-gate 			uint32_t	getu_idtype;
6237c478bd9Sstevel@tonic-gate 			uint32_t	getu_reserved;
6247c478bd9Sstevel@tonic-gate 		} get_actual;
6257c478bd9Sstevel@tonic-gate 		uint64_t get_alignment;
6267c478bd9Sstevel@tonic-gate 	} get_u;
6277c478bd9Sstevel@tonic-gate #define	get_idtype get_u.get_actual.getu_idtype
6287c478bd9Sstevel@tonic-gate #define	get_reserved get_u.get_actual.getu_reserved
6297c478bd9Sstevel@tonic-gate 	/* get_len - sizeof (ike_get_t) bytes of data included here */
6307c478bd9Sstevel@tonic-gate } ike_get_t;
6317c478bd9Sstevel@tonic-gate 
6327c478bd9Sstevel@tonic-gate 
6337c478bd9Sstevel@tonic-gate /*
6347c478bd9Sstevel@tonic-gate  * IKE_SVC_NEW_{RULE|PS}
6357c478bd9Sstevel@tonic-gate  * Used to request and acknowledge insertion of a table item.
6367c478bd9Sstevel@tonic-gate  *
6377c478bd9Sstevel@tonic-gate  * Upon request: new_len is the total (data + struct) size passed, or 0.
6387c478bd9Sstevel@tonic-gate  * new_len = 0 => a door_desc_t is also included with a file descriptor
6397c478bd9Sstevel@tonic-gate  * for a file containing the data to be added.  The file should include
6407c478bd9Sstevel@tonic-gate  * a single item: a rule, or a pre-shared key.  For new_len != 0, the
6417c478bd9Sstevel@tonic-gate  * data is formatted according to the cmd type:
6427c478bd9Sstevel@tonic-gate  *   IKE_SVC_NEW_RULE:		ike_rule_t
6437c478bd9Sstevel@tonic-gate  *   IKE_SVC_NEW_PS:		ike_ps_t
6447c478bd9Sstevel@tonic-gate  *
6457c478bd9Sstevel@tonic-gate  * Upon return: new_len is 0; simply acknowledges successful insertion
6467c478bd9Sstevel@tonic-gate  * of the requested item.  If insertion is not successful, ike_err_t is
6477c478bd9Sstevel@tonic-gate  * returned instead with appropriate error value.
6487c478bd9Sstevel@tonic-gate  */
6497c478bd9Sstevel@tonic-gate typedef struct {
6507c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
6517c478bd9Sstevel@tonic-gate 	uint32_t	new_len;
6527c478bd9Sstevel@tonic-gate 	/* new_len - sizeof (ike_new_t) bytes included here */
6537c478bd9Sstevel@tonic-gate 	uint64_t	new_align;	/* Padding for 64-bit alignment. */
6547c478bd9Sstevel@tonic-gate } ike_new_t;
6557c478bd9Sstevel@tonic-gate 
6567c478bd9Sstevel@tonic-gate 
6577c478bd9Sstevel@tonic-gate /*
6587c478bd9Sstevel@tonic-gate  * IKE_SVC_DEL_{P1|RULE|PS}
6597c478bd9Sstevel@tonic-gate  * Used to request and acknowledge the deletion of an individual table
6607c478bd9Sstevel@tonic-gate  * item.
6617c478bd9Sstevel@tonic-gate  *
6627c478bd9Sstevel@tonic-gate  * Upon request: del_len is the total msg length (struct + id data);
6637c478bd9Sstevel@tonic-gate  * del_idtype indicates the type of identification being used.
6647c478bd9Sstevel@tonic-gate  *   IKE_SVC_DEL_P1:		ike_addr_pr_t or ike_cky_pr_t
6657c478bd9Sstevel@tonic-gate  *   IKE_SVC_DEL_RULE:		char string (label)
6667c478bd9Sstevel@tonic-gate  *   IKE_SVC_DEL_PS:		ike_addr_pr_t or pair of sadb_ident_t
6677c478bd9Sstevel@tonic-gate  *
6687c478bd9Sstevel@tonic-gate  * Upon return: acknowledges deletion of the requested item; del_len and
6697c478bd9Sstevel@tonic-gate  * del_idtype are unspecified.  If deletion is not successful, ike_err_t
6707c478bd9Sstevel@tonic-gate  * is returned instead with appropriate error value.
6717c478bd9Sstevel@tonic-gate  */
6727c478bd9Sstevel@tonic-gate typedef struct {
6737c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
6747c478bd9Sstevel@tonic-gate 	uint32_t	del_len;
6757c478bd9Sstevel@tonic-gate 	uint32_t	del_idtype;
6767c478bd9Sstevel@tonic-gate 	uint32_t	del_reserved;
6777c478bd9Sstevel@tonic-gate 	/* del_len - sizeof (ike_del_t) bytes of data included here. */
6787c478bd9Sstevel@tonic-gate } ike_del_t;
6797c478bd9Sstevel@tonic-gate 
6807c478bd9Sstevel@tonic-gate 
6817c478bd9Sstevel@tonic-gate /*
6827c478bd9Sstevel@tonic-gate  * IKE_SVC_READ_{RULES|PS}
6837c478bd9Sstevel@tonic-gate  * Used to ask daemon to re-read particular configuration info.
6847c478bd9Sstevel@tonic-gate  *
6857c478bd9Sstevel@tonic-gate  * Upon request: rw_loc indicates where the info should be read from:
6867c478bd9Sstevel@tonic-gate  * either from a user-supplied file descriptor(s), or from the default
6877c478bd9Sstevel@tonic-gate  * location(s).  If rw_loc indicates user-supplied location, the file
6887c478bd9Sstevel@tonic-gate  * descriptor(s) should be passed in the door_desc_t struct.  For the
6897c478bd9Sstevel@tonic-gate  * IKE_SVC_READ_RULES cmd, two file descriptors should be specified:
6907c478bd9Sstevel@tonic-gate  * first, one for the config file which contains the data to be read,
6917c478bd9Sstevel@tonic-gate  * and second, one for the cookie file which will be written to as
6927c478bd9Sstevel@tonic-gate  * in.iked process the config file.
6937c478bd9Sstevel@tonic-gate  *
6947c478bd9Sstevel@tonic-gate  * Upon return: rw_loc is unspecified; the message simply acknowledges
6957c478bd9Sstevel@tonic-gate  * successful completion of the request.  If an error occurred,
6967c478bd9Sstevel@tonic-gate  * ike_err_t is returned instead with appropriate error value.
6977c478bd9Sstevel@tonic-gate  *
6987c478bd9Sstevel@tonic-gate  *
6997c478bd9Sstevel@tonic-gate  * IKE_SVC_WRITE_{RULES|PS}
7007c478bd9Sstevel@tonic-gate  * Used to ask daemon to write its current config info to files.
7017c478bd9Sstevel@tonic-gate  *
7027c478bd9Sstevel@tonic-gate  * Request and return are handled the same as for the IKE_SVC_READ_*
7037c478bd9Sstevel@tonic-gate  * cmds; however, the rw_loc MUST be a user-supplied location.  Also,
7047c478bd9Sstevel@tonic-gate  * for the IKE_SVC_WRITE_RULES cmd, the cookie file fd is not required;
7057c478bd9Sstevel@tonic-gate  * only a single fd, for the file to which the config info should be
7067c478bd9Sstevel@tonic-gate  * written, should be passed in.
7077c478bd9Sstevel@tonic-gate  */
7087c478bd9Sstevel@tonic-gate typedef struct {
7097c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
7107c478bd9Sstevel@tonic-gate 	uint32_t	rw_loc;
7117c478bd9Sstevel@tonic-gate } ike_rw_t;
7127c478bd9Sstevel@tonic-gate 
7137c478bd9Sstevel@tonic-gate 
7147c478bd9Sstevel@tonic-gate /*
7157c478bd9Sstevel@tonic-gate  * IKE_SVC_FLUSH_P1S
716c7777ac8SPaul Wernau  * IKE_SVC_FLUSH_CERTCACHE
717c7777ac8SPaul Wernau  *
718c7777ac8SPaul Wernau  * Used to request and acknowledge tear-down of all P1 SAs
719c7777ac8SPaul Wernau  * or to flush the certificate cache.
7207c478bd9Sstevel@tonic-gate  */
7217c478bd9Sstevel@tonic-gate typedef struct {
7227c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
7237c478bd9Sstevel@tonic-gate } ike_flush_t;
7247c478bd9Sstevel@tonic-gate 
7257c478bd9Sstevel@tonic-gate 
726c7777ac8SPaul Wernau #ifndef PKCS11_TOKSIZE
727c7777ac8SPaul Wernau #define	PKCS11_TOKSIZE 32
728c7777ac8SPaul Wernau #endif
729c7777ac8SPaul Wernau #define	MAX_PIN_LEN 256
730c7777ac8SPaul Wernau /*
731c7777ac8SPaul Wernau  * IKE_SVC_SET_PIN
732c7777ac8SPaul Wernau  * IKE_SVC_DEL_PIN
733c7777ac8SPaul Wernau  *
734c7777ac8SPaul Wernau  * Used to supply a pin for a PKCS#11 tokenj object.
735c7777ac8SPaul Wernau  *
736c7777ac8SPaul Wernau  */
737c7777ac8SPaul Wernau typedef struct {
738c7777ac8SPaul Wernau 	ike_svccmd_t	cmd;
739dc739cedSDan McDonald 	uint32_t	pin_reserved;	/* For 64-bit alignment. */
740c7777ac8SPaul Wernau 	char pkcs11_token[PKCS11_TOKSIZE];
741c7777ac8SPaul Wernau 	uchar_t token_pin[MAX_PIN_LEN];
742c7777ac8SPaul Wernau } ike_pin_t;
743c7777ac8SPaul Wernau 
7447c478bd9Sstevel@tonic-gate /*
7457c478bd9Sstevel@tonic-gate  * IKE_SVC_ERROR
7467c478bd9Sstevel@tonic-gate  * Used on return if server encountered an error while processing
7477c478bd9Sstevel@tonic-gate  * the request.  An appropriate error code is included (as defined
7487c478bd9Sstevel@tonic-gate  * in this header file); in the case of IKE_ERR_SYS_ERR, a value
7497c478bd9Sstevel@tonic-gate  * from the UNIX errno space is included in the ike_err_unix field.
7507c478bd9Sstevel@tonic-gate  */
7517c478bd9Sstevel@tonic-gate typedef struct {
7527c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
7537c478bd9Sstevel@tonic-gate 	uint32_t	ike_err;
7547c478bd9Sstevel@tonic-gate 	uint32_t	ike_err_unix;
7557c478bd9Sstevel@tonic-gate 	uint32_t	ike_err_reserved;
7567c478bd9Sstevel@tonic-gate } ike_err_t;
7577c478bd9Sstevel@tonic-gate 
7587c478bd9Sstevel@tonic-gate /*
7597c478bd9Sstevel@tonic-gate  * Generic type for use when the request/reply type is unknown
7607c478bd9Sstevel@tonic-gate  */
7617c478bd9Sstevel@tonic-gate typedef struct {
7627c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
7637c478bd9Sstevel@tonic-gate } ike_cmd_t;
7647c478bd9Sstevel@tonic-gate 
7657c478bd9Sstevel@tonic-gate 
7667c478bd9Sstevel@tonic-gate /*
767c7777ac8SPaul Wernau  * Union containing all possible request/return structures.
7687c478bd9Sstevel@tonic-gate  */
7697c478bd9Sstevel@tonic-gate typedef union {
7707c478bd9Sstevel@tonic-gate 	ike_cmd_t	svc_cmd;
7717c478bd9Sstevel@tonic-gate 	ike_dbg_t	svc_dbg;
7727c478bd9Sstevel@tonic-gate 	ike_priv_t	svc_priv;
7737c478bd9Sstevel@tonic-gate 	ike_statreq_t	svc_stats;
7747c478bd9Sstevel@tonic-gate 	ike_dump_t	svc_dump;
7757c478bd9Sstevel@tonic-gate 	ike_get_t	svc_get;
7767c478bd9Sstevel@tonic-gate 	ike_new_t	svc_new;
7777c478bd9Sstevel@tonic-gate 	ike_del_t	svc_del;
7787c478bd9Sstevel@tonic-gate 	ike_rw_t	svc_rw;
7797c478bd9Sstevel@tonic-gate 	ike_flush_t	svc_flush;
780c7777ac8SPaul Wernau 	ike_pin_t	svc_pin;
7817c478bd9Sstevel@tonic-gate 	ike_err_t	svc_err;
7820f2065ccSmarkfen 	ike_defreq_t	svc_defaults;
7837c478bd9Sstevel@tonic-gate } ike_service_t;
7847c478bd9Sstevel@tonic-gate 
7857c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
7867c478bd9Sstevel@tonic-gate }
7877c478bd9Sstevel@tonic-gate #endif
7887c478bd9Sstevel@tonic-gate 
7897c478bd9Sstevel@tonic-gate #endif	/* _IKEDOOR_H */
790