xref: /illumos-gate/usr/src/lib/libipsecutil/common/ikedoor.h (revision c7777ac86feebafbc8c24a8a6d8e4d9915137fe6)
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 /*
22*c7777ac8SPaul 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  */
4320dc9b2eSvk199839 #define	DOORVER 2
447c478bd9Sstevel@tonic-gate #define	DOORNM	"/var/run/ike_door"
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate typedef enum {
487c478bd9Sstevel@tonic-gate 	IKE_SVC_GET_DBG,
497c478bd9Sstevel@tonic-gate 	IKE_SVC_SET_DBG,
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate 	IKE_SVC_GET_PRIV,
527c478bd9Sstevel@tonic-gate 	IKE_SVC_SET_PRIV,
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate 	IKE_SVC_GET_STATS,
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate 	IKE_SVC_GET_P1,
577c478bd9Sstevel@tonic-gate 	IKE_SVC_DEL_P1,
587c478bd9Sstevel@tonic-gate 	IKE_SVC_DUMP_P1S,
597c478bd9Sstevel@tonic-gate 	IKE_SVC_FLUSH_P1S,
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate 	IKE_SVC_GET_RULE,
627c478bd9Sstevel@tonic-gate 	IKE_SVC_NEW_RULE,
637c478bd9Sstevel@tonic-gate 	IKE_SVC_DEL_RULE,
647c478bd9Sstevel@tonic-gate 	IKE_SVC_DUMP_RULES,
657c478bd9Sstevel@tonic-gate 	IKE_SVC_READ_RULES,
667c478bd9Sstevel@tonic-gate 	IKE_SVC_WRITE_RULES,
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate 	IKE_SVC_GET_PS,
697c478bd9Sstevel@tonic-gate 	IKE_SVC_NEW_PS,
707c478bd9Sstevel@tonic-gate 	IKE_SVC_DEL_PS,
717c478bd9Sstevel@tonic-gate 	IKE_SVC_DUMP_PS,
727c478bd9Sstevel@tonic-gate 	IKE_SVC_READ_PS,
737c478bd9Sstevel@tonic-gate 	IKE_SVC_WRITE_PS,
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate 	IKE_SVC_DBG_RBDUMP,
767c478bd9Sstevel@tonic-gate 
770f2065ccSmarkfen 	IKE_SVC_GET_DEFS,
780f2065ccSmarkfen 
79*c7777ac8SPaul Wernau 	IKE_SVC_SET_PIN,
80*c7777ac8SPaul Wernau 	IKE_SVC_DEL_PIN,
81*c7777ac8SPaul Wernau 
82*c7777ac8SPaul Wernau 	IKE_SVC_DUMP_CERTCACHE,
83*c7777ac8SPaul Wernau 	IKE_SVC_FLUSH_CERTCACHE,
84*c7777ac8SPaul Wernau 
857c478bd9Sstevel@tonic-gate 	IKE_SVC_ERROR
867c478bd9Sstevel@tonic-gate } ike_svccmd_t;
877c478bd9Sstevel@tonic-gate 
889c2c14abSThejaswini Singarajipura /* DPD status */
899c2c14abSThejaswini Singarajipura 
909c2c14abSThejaswini Singarajipura typedef enum dpd_status {
919c2c14abSThejaswini Singarajipura 	DPD_NOT_INITIATED = 0,
929c2c14abSThejaswini Singarajipura 	DPD_IN_PROGRESS,
939c2c14abSThejaswini Singarajipura 	DPD_SUCCESSFUL,
949c2c14abSThejaswini Singarajipura 	DPD_FAILURE
959c2c14abSThejaswini Singarajipura } dpd_status_t;
969c2c14abSThejaswini Singarajipura 
977c478bd9Sstevel@tonic-gate #define	IKE_SVC_MAX	IKE_SVC_ERROR
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate /*
1017c478bd9Sstevel@tonic-gate  * Support structures/defines
1027c478bd9Sstevel@tonic-gate  */
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate #define	IKEDOORROUNDUP(i)   P2ROUNDUP((i), sizeof (uint64_t))
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate /*
1077c478bd9Sstevel@tonic-gate  * Debug categories.  The debug level is a bitmask made up of
1087c478bd9Sstevel@tonic-gate  * flags indicating the desired categories; only 31 bits are
1097c478bd9Sstevel@tonic-gate  * available, as the highest-order bit designates an invalid
1107c478bd9Sstevel@tonic-gate  * setting.
1117c478bd9Sstevel@tonic-gate  */
1127c478bd9Sstevel@tonic-gate #define	D_INVALID	0x80000000
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate #define	D_CERT		0x00000001	/* certificate management */
1157c478bd9Sstevel@tonic-gate #define	D_KEY		0x00000002	/* key management */
1167c478bd9Sstevel@tonic-gate #define	D_OP		0x00000004	/* operational: config, init, mem */
1177c478bd9Sstevel@tonic-gate #define	D_P1		0x00000008	/* phase 1 negotiation */
1187c478bd9Sstevel@tonic-gate #define	D_P2		0x00000010	/* phase 2 negotiation */
1197c478bd9Sstevel@tonic-gate #define	D_PFKEY		0x00000020	/* pf key interface */
1207c478bd9Sstevel@tonic-gate #define	D_POL		0x00000040	/* policy management */
1217c478bd9Sstevel@tonic-gate #define	D_PROP		0x00000080	/* proposal construction */
1227c478bd9Sstevel@tonic-gate #define	D_DOOR		0x00000100	/* door server */
1237c478bd9Sstevel@tonic-gate #define	D_CONFIG	0x00000200	/* config file processing */
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate #define	D_HIGHBIT	0x00000200
1267c478bd9Sstevel@tonic-gate #define	D_ALL		0x000003ff
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate /*
1297c478bd9Sstevel@tonic-gate  * Access privilege levels: define level of access to keying information.
1307c478bd9Sstevel@tonic-gate  * The privileges granted at each level is a superset of the privileges
1317c478bd9Sstevel@tonic-gate  * granted at all lower levels.
1327c478bd9Sstevel@tonic-gate  *
1337c478bd9Sstevel@tonic-gate  * The door operations which require special privileges are:
1347c478bd9Sstevel@tonic-gate  *
1357c478bd9Sstevel@tonic-gate  *	- receiving keying material for SAs and preshared key entries
1367c478bd9Sstevel@tonic-gate  *	  IKE_PRIV_KEYMAT must be set for this.
1377c478bd9Sstevel@tonic-gate  *
1387c478bd9Sstevel@tonic-gate  *	- get/dump/new/delete/read/write preshared keys
1397c478bd9Sstevel@tonic-gate  *	  IKE_PRIV_KEYMAT or IKE_PRIV_MODKEYS must be set to do this.
1407c478bd9Sstevel@tonic-gate  *	  If IKE_PRIV_MODKEYS is set, the information returned for a
1417c478bd9Sstevel@tonic-gate  *	  get/dump request will not include the actual key; in order
1427c478bd9Sstevel@tonic-gate  *	  to get the key itself, IKE_PRIV_KEYMAT must be set.
1437c478bd9Sstevel@tonic-gate  *
1447c478bd9Sstevel@tonic-gate  *	- modifying the privilege level: the daemon's privilege level
1457c478bd9Sstevel@tonic-gate  *	  is set when the daemon is started; the level may only be
1467c478bd9Sstevel@tonic-gate  *	  lowered via the door interface.
1477c478bd9Sstevel@tonic-gate  *
1487c478bd9Sstevel@tonic-gate  * All other operations are allowed at any privilege level.
1497c478bd9Sstevel@tonic-gate  */
1507c478bd9Sstevel@tonic-gate #define	IKE_PRIV_MINIMUM	0
1517c478bd9Sstevel@tonic-gate #define	IKE_PRIV_MODKEYS	1
1527c478bd9Sstevel@tonic-gate #define	IKE_PRIV_KEYMAT		2
1537c478bd9Sstevel@tonic-gate #define	IKE_PRIV_MAXIMUM	2
1547c478bd9Sstevel@tonic-gate 
1557c478bd9Sstevel@tonic-gate /* global ike stats formatting structure */
1567c478bd9Sstevel@tonic-gate typedef struct {
1577c478bd9Sstevel@tonic-gate 	uint32_t	st_init_p1_current;
1587c478bd9Sstevel@tonic-gate 	uint32_t	st_resp_p1_current;
1597c478bd9Sstevel@tonic-gate 	uint32_t	st_init_p1_total;
1607c478bd9Sstevel@tonic-gate 	uint32_t	st_resp_p1_total;
1617c478bd9Sstevel@tonic-gate 	uint32_t	st_init_p1_attempts;
1627c478bd9Sstevel@tonic-gate 	uint32_t	st_resp_p1_attempts;
1637c478bd9Sstevel@tonic-gate 	uint32_t	st_init_p1_noresp;   /* failed; no response from peer */
1647c478bd9Sstevel@tonic-gate 	uint32_t	st_init_p1_respfail; /* failed, but peer responded */
1657c478bd9Sstevel@tonic-gate 	uint32_t	st_resp_p1_fail;
1667c478bd9Sstevel@tonic-gate 	uint32_t	st_reserved;
1677c478bd9Sstevel@tonic-gate 	char		st_pkcs11_libname[PATH_MAX];
1687c478bd9Sstevel@tonic-gate } ike_stats_t;
1697c478bd9Sstevel@tonic-gate 
1700f2065ccSmarkfen /* structure used to pass default values used by in.iked back to ikeadm */
1710f2065ccSmarkfen typedef struct {
1720f2065ccSmarkfen 	uint32_t	rule_p1_lifetime_secs;
1730f2065ccSmarkfen 	uint32_t	rule_p1_minlife;
1740f2065ccSmarkfen 	uint32_t	rule_p1_nonce_len;
1750f2065ccSmarkfen 	uint32_t	rule_p2_lifetime_secs;
1760f2065ccSmarkfen 	uint32_t	rule_p2_softlife_secs;
1779c2c14abSThejaswini Singarajipura 	uint32_t	rule_p2_idletime_secs;
1781a6921e0Smarkfen 	uint32_t	sys_p2_lifetime_secs;
1791a6921e0Smarkfen 	uint32_t	sys_p2_softlife_secs;
1809c2c14abSThejaswini Singarajipura 	uint32_t	sys_p2_idletime_secs;
1810f2065ccSmarkfen 	uint32_t	rule_p2_lifetime_kb;
1820f2065ccSmarkfen 	uint32_t	rule_p2_softlife_kb;
1831a6921e0Smarkfen 	uint32_t	sys_p2_lifetime_bytes;
1841a6921e0Smarkfen 	uint32_t	sys_p2_softlife_bytes;
1850f2065ccSmarkfen 	uint32_t	rule_p2_minlife;
1860f2065ccSmarkfen 	uint32_t	rule_p2_def_minlife;
1870f2065ccSmarkfen 	uint32_t	rule_p2_nonce_len;
1880f2065ccSmarkfen 	uint32_t	rule_p2_pfs;
1890f2065ccSmarkfen 	uint32_t	rule_p2_minsoft;
1900f2065ccSmarkfen 	uint32_t	rule_max_certs;
1910f2065ccSmarkfen 	uint32_t	rule_ike_port;
1920f2065ccSmarkfen 	uint32_t	rule_natt_port;
1930f2065ccSmarkfen } ike_defaults_t;
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate /* data formatting structures for P1 SA dumps */
1967c478bd9Sstevel@tonic-gate typedef struct {
1977c478bd9Sstevel@tonic-gate 	struct sockaddr_storage	loc_addr;
1987c478bd9Sstevel@tonic-gate 	struct sockaddr_storage	rem_addr;
1997c478bd9Sstevel@tonic-gate #define	beg_iprange	loc_addr
2007c478bd9Sstevel@tonic-gate #define	end_iprange	rem_addr
2017c478bd9Sstevel@tonic-gate } ike_addr_pr_t;
2027c478bd9Sstevel@tonic-gate 
2037c478bd9Sstevel@tonic-gate typedef struct {
2047c478bd9Sstevel@tonic-gate 	uint64_t	cky_i;
2057c478bd9Sstevel@tonic-gate 	uint64_t	cky_r;
2067c478bd9Sstevel@tonic-gate } ike_cky_pr_t;
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate typedef struct {
2097c478bd9Sstevel@tonic-gate 	ike_cky_pr_t	p1hdr_cookies;
2107c478bd9Sstevel@tonic-gate 	uint8_t		p1hdr_major;
2117c478bd9Sstevel@tonic-gate 	uint8_t		p1hdr_minor;
2127c478bd9Sstevel@tonic-gate 	uint8_t		p1hdr_xchg;
2137c478bd9Sstevel@tonic-gate 	uint8_t		p1hdr_isinit;
2147c478bd9Sstevel@tonic-gate 	uint32_t	p1hdr_state;
2159c2c14abSThejaswini Singarajipura 	boolean_t	p1hdr_support_dpd;
2169c2c14abSThejaswini Singarajipura 	dpd_status_t	p1hdr_dpd_state;
2179c2c14abSThejaswini Singarajipura 	time_t		p1hdr_dpd_time;
2187c478bd9Sstevel@tonic-gate } ike_p1_hdr_t;
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate /* values for p1hdr_xchg (aligned with RFC2408, section 3.1) */
2217c478bd9Sstevel@tonic-gate #define	IKE_XCHG_NONE			0
2227c478bd9Sstevel@tonic-gate #define	IKE_XCHG_BASE			1
2237c478bd9Sstevel@tonic-gate #define	IKE_XCHG_IDENTITY_PROTECT	2
2247c478bd9Sstevel@tonic-gate #define	IKE_XCHG_AUTH_ONLY		3
2257c478bd9Sstevel@tonic-gate #define	IKE_XCHG_AGGRESSIVE		4
2267c478bd9Sstevel@tonic-gate /* following not from RFC; used only for preshared key definitions */
2277c478bd9Sstevel@tonic-gate #define	IKE_XCHG_IP_AND_AGGR		240
2287c478bd9Sstevel@tonic-gate /* also not from RFC; used as wildcard */
2297c478bd9Sstevel@tonic-gate #define	IKE_XCHG_ANY			256
2307c478bd9Sstevel@tonic-gate 
2317c478bd9Sstevel@tonic-gate /* values for p1hdr_state */
2327c478bd9Sstevel@tonic-gate #define	IKE_SA_STATE_INVALID	0
2337c478bd9Sstevel@tonic-gate #define	IKE_SA_STATE_INIT	1
2347c478bd9Sstevel@tonic-gate #define	IKE_SA_STATE_SENT_SA	2
2357c478bd9Sstevel@tonic-gate #define	IKE_SA_STATE_SENT_KE	3
2367c478bd9Sstevel@tonic-gate #define	IKE_SA_STATE_SENT_LAST	4
2377c478bd9Sstevel@tonic-gate #define	IKE_SA_STATE_DONE	5
2387c478bd9Sstevel@tonic-gate #define	IKE_SA_STATE_DELETED	6
2397c478bd9Sstevel@tonic-gate 
2407c478bd9Sstevel@tonic-gate typedef struct {
2417c478bd9Sstevel@tonic-gate 	uint16_t	p1xf_dh_group;
2427c478bd9Sstevel@tonic-gate 	uint16_t	p1xf_encr_alg;
24320dc9b2eSvk199839 	uint16_t	p1xf_encr_low_bits;
24420dc9b2eSvk199839 	uint16_t	p1xf_encr_high_bits;
2457c478bd9Sstevel@tonic-gate 	uint16_t	p1xf_auth_alg;
2467c478bd9Sstevel@tonic-gate 	uint16_t	p1xf_auth_meth;
2477c478bd9Sstevel@tonic-gate 	uint16_t	p1xf_prf;
2487c478bd9Sstevel@tonic-gate 	uint16_t	p1xf_pfs;
2497c478bd9Sstevel@tonic-gate 	uint32_t	p1xf_max_secs;
2507c478bd9Sstevel@tonic-gate 	uint32_t	p1xf_max_kbytes;
2517c478bd9Sstevel@tonic-gate 	uint32_t	p1xf_max_keyuses;
2527c478bd9Sstevel@tonic-gate } ike_p1_xform_t;
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate /* values for p1xf_dh_group (aligned with RFC2409, Appendix A) */
2557c478bd9Sstevel@tonic-gate #define	IKE_GRP_DESC_MODP_768	1
2567c478bd9Sstevel@tonic-gate #define	IKE_GRP_DESC_MODP_1024	2
2577c478bd9Sstevel@tonic-gate #define	IKE_GRP_DESC_EC2N_155	3
2587c478bd9Sstevel@tonic-gate #define	IKE_GRP_DESC_EC2N_185	4
259020bf065Smarkfen /* values for p1xf_dh_group (aligned with RFC3526) */
2607c478bd9Sstevel@tonic-gate #define	IKE_GRP_DESC_MODP_1536	5
261020bf065Smarkfen #define	IKE_GRP_DESC_MODP_2048	14
262020bf065Smarkfen #define	IKE_GRP_DESC_MODP_3072	15
263020bf065Smarkfen #define	IKE_GRP_DESC_MODP_4096	16
264020bf065Smarkfen #define	IKE_GRP_DESC_MODP_6144	17
265020bf065Smarkfen #define	IKE_GRP_DESC_MODP_8192	18
2667c478bd9Sstevel@tonic-gate 
2677c478bd9Sstevel@tonic-gate /* values for p1xf_auth_meth (aligned with RFC2409, Appendix A) */
2687c478bd9Sstevel@tonic-gate #define	IKE_AUTH_METH_PRE_SHARED_KEY	1
2697c478bd9Sstevel@tonic-gate #define	IKE_AUTH_METH_DSS_SIG		2
2707c478bd9Sstevel@tonic-gate #define	IKE_AUTH_METH_RSA_SIG		3
2717c478bd9Sstevel@tonic-gate #define	IKE_AUTH_METH_RSA_ENCR		4
2727c478bd9Sstevel@tonic-gate #define	IKE_AUTH_METH_RSA_ENCR_REVISED	5
2737c478bd9Sstevel@tonic-gate 
2747c478bd9Sstevel@tonic-gate /* values for p1xf_prf */
2757c478bd9Sstevel@tonic-gate #define	IKE_PRF_NONE		0
2767c478bd9Sstevel@tonic-gate #define	IKE_PRF_HMAC_MD5	1
2777c478bd9Sstevel@tonic-gate #define	IKE_PRF_HMAC_SHA1	2
2780358d3a6Sdanmcd #define	IKE_PRF_HMAC_SHA256	5
2790358d3a6Sdanmcd #define	IKE_PRF_HMAC_SHA384	6
2800358d3a6Sdanmcd #define	IKE_PRF_HMAC_SHA512	7
2817c478bd9Sstevel@tonic-gate 
2827c478bd9Sstevel@tonic-gate typedef struct {
2837c478bd9Sstevel@tonic-gate 	/*
2847c478bd9Sstevel@tonic-gate 	 * NOTE: the new and del counters count the actual number of SAs,
2857c478bd9Sstevel@tonic-gate 	 * not the number of "suites", as defined in the ike monitoring
2867c478bd9Sstevel@tonic-gate 	 * mib draft; we do this because we don't have a good way of
2877c478bd9Sstevel@tonic-gate 	 * tracking the deletion of entire suites (we're notified of
2887c478bd9Sstevel@tonic-gate 	 * deleted qm sas individually).
2897c478bd9Sstevel@tonic-gate 	 */
2907c478bd9Sstevel@tonic-gate 	uint32_t	p1stat_new_qm_sas;
2917c478bd9Sstevel@tonic-gate 	uint32_t	p1stat_del_qm_sas;
2927c478bd9Sstevel@tonic-gate 	uint64_t	p1stat_start;
2937c478bd9Sstevel@tonic-gate 	uint32_t	p1stat_kbytes;
2947c478bd9Sstevel@tonic-gate 	uint32_t	p1stat_keyuses;
2957c478bd9Sstevel@tonic-gate } ike_p1_stats_t;
2967c478bd9Sstevel@tonic-gate 
2977c478bd9Sstevel@tonic-gate typedef struct {
2987c478bd9Sstevel@tonic-gate 	uint32_t	p1err_decrypt;
2997c478bd9Sstevel@tonic-gate 	uint32_t	p1err_hash;
3007c478bd9Sstevel@tonic-gate 	uint32_t	p1err_otherrx;
3017c478bd9Sstevel@tonic-gate 	uint32_t	p1err_tx;
3027c478bd9Sstevel@tonic-gate } ike_p1_errors_t;
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate typedef struct {
3057c478bd9Sstevel@tonic-gate 	uint32_t	p1key_type;
3067c478bd9Sstevel@tonic-gate 	uint32_t	p1key_len;
3077c478bd9Sstevel@tonic-gate 	/*
3087c478bd9Sstevel@tonic-gate 	 * followed by (len - sizeof (ike_p1_key_t)) bytes of hex data,
3097c478bd9Sstevel@tonic-gate 	 * 64-bit aligned (pad bytes are added at the end, if necessary,
3107c478bd9Sstevel@tonic-gate 	 * and NOT INCLUDED in the len value, which reflects the actual
3117c478bd9Sstevel@tonic-gate 	 * key size).
3127c478bd9Sstevel@tonic-gate 	 */
3137c478bd9Sstevel@tonic-gate } ike_p1_key_t;
3147c478bd9Sstevel@tonic-gate 
3157c478bd9Sstevel@tonic-gate /* key info types for ike_p1_key_t struct */
3167c478bd9Sstevel@tonic-gate #define	IKE_KEY_PRESHARED	1
3177c478bd9Sstevel@tonic-gate #define	IKE_KEY_SKEYID		2
3187c478bd9Sstevel@tonic-gate #define	IKE_KEY_SKEYID_D	3
3197c478bd9Sstevel@tonic-gate #define	IKE_KEY_SKEYID_A	4
3207c478bd9Sstevel@tonic-gate #define	IKE_KEY_SKEYID_E	5
3217c478bd9Sstevel@tonic-gate #define	IKE_KEY_ENCR		6
3227c478bd9Sstevel@tonic-gate #define	IKE_KEY_IV		7
3237c478bd9Sstevel@tonic-gate 
3247c478bd9Sstevel@tonic-gate typedef struct {
3257c478bd9Sstevel@tonic-gate 	ike_p1_hdr_t	p1sa_hdr;
3267c478bd9Sstevel@tonic-gate 	ike_p1_xform_t	p1sa_xform;
3277c478bd9Sstevel@tonic-gate 	ike_addr_pr_t	p1sa_ipaddrs;
3287c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_stat_off;
3297c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_stat_len;
3307c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_error_off;
3317c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_error_len;
3327c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_localid_off;
3337c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_localid_len;
3347c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_remoteid_off;
3357c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_remoteid_len;
3367c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_key_off;
3377c478bd9Sstevel@tonic-gate 	uint16_t	p1sa_key_len;
3387c478bd9Sstevel@tonic-gate 	uint32_t	p1sa_reserved;
3397c478bd9Sstevel@tonic-gate 	/*
3407c478bd9Sstevel@tonic-gate 	 * variable-length structures will be included here, as
3417c478bd9Sstevel@tonic-gate 	 * indicated by offset/length fields.
3427c478bd9Sstevel@tonic-gate 	 * stats and errors will be formatted as ike_p1_stats_t and
3437c478bd9Sstevel@tonic-gate 	 * ike_p1_errors_t, respectively.
3447c478bd9Sstevel@tonic-gate 	 * key info will be formatted as a series of p1_key_t structs.
3457c478bd9Sstevel@tonic-gate 	 * local/remote ids will be formatted as sadb_ident_t structs.
3467c478bd9Sstevel@tonic-gate 	 */
3477c478bd9Sstevel@tonic-gate } ike_p1_sa_t;
3487c478bd9Sstevel@tonic-gate 
3497c478bd9Sstevel@tonic-gate 
3507c478bd9Sstevel@tonic-gate #define	MAX_LABEL_LEN	256
3517c478bd9Sstevel@tonic-gate 
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate /* data formatting structure for policy (rule) dumps */
3547c478bd9Sstevel@tonic-gate 
3557c478bd9Sstevel@tonic-gate typedef struct {
3567c478bd9Sstevel@tonic-gate 	char		rule_label[MAX_LABEL_LEN];
3577c478bd9Sstevel@tonic-gate 	uint32_t	rule_kmcookie;
3587c478bd9Sstevel@tonic-gate 	uint16_t	rule_ike_mode;
3597c478bd9Sstevel@tonic-gate 	uint16_t	rule_local_idtype;	/* SADB_IDENTTYPE_* value */
3607c478bd9Sstevel@tonic-gate 	uint32_t	rule_p1_nonce_len;
3617c478bd9Sstevel@tonic-gate 	uint32_t	rule_p2_nonce_len;
3627c478bd9Sstevel@tonic-gate 	uint32_t	rule_p2_pfs;
3630f2065ccSmarkfen 	uint32_t	rule_p2_lifetime_secs;
3640f2065ccSmarkfen 	uint32_t	rule_p2_softlife_secs;
3659c2c14abSThejaswini Singarajipura 	uint32_t	rule_p2_idletime_secs;
3660f2065ccSmarkfen 	uint32_t	rule_p2_lifetime_kb;
3670f2065ccSmarkfen 	uint32_t	rule_p2_softlife_kb;
3687c478bd9Sstevel@tonic-gate 	uint16_t	rule_xform_cnt;
3697c478bd9Sstevel@tonic-gate 	uint16_t	rule_xform_off;
3707c478bd9Sstevel@tonic-gate 	uint16_t	rule_locip_cnt;
3717c478bd9Sstevel@tonic-gate 	uint16_t	rule_locip_off;
3727c478bd9Sstevel@tonic-gate 	uint16_t	rule_remip_cnt;
3737c478bd9Sstevel@tonic-gate 	uint16_t	rule_remip_off;
3747c478bd9Sstevel@tonic-gate 	uint16_t	rule_locid_inclcnt;
3757c478bd9Sstevel@tonic-gate 	uint16_t	rule_locid_exclcnt;
3767c478bd9Sstevel@tonic-gate 	uint16_t	rule_locid_off;
3777c478bd9Sstevel@tonic-gate 	uint16_t	rule_remid_inclcnt;
3787c478bd9Sstevel@tonic-gate 	uint16_t	rule_remid_exclcnt;
3797c478bd9Sstevel@tonic-gate 	uint16_t	rule_remid_off;
3807c478bd9Sstevel@tonic-gate 	/*
3817c478bd9Sstevel@tonic-gate 	 * Followed by several lists of variable-length structures, described
3827c478bd9Sstevel@tonic-gate 	 * by counts and offsets:
3837c478bd9Sstevel@tonic-gate 	 *	transforms			ike_p1_xform_t structs
3847c478bd9Sstevel@tonic-gate 	 *	ranges of local ip addrs	ike_addr_pr_t structs
3857c478bd9Sstevel@tonic-gate 	 *	ranges of remote ip addrs	ike_addr_pr_t structs
3867c478bd9Sstevel@tonic-gate 	 *	local identification strings	null-terminated ascii strings
3877c478bd9Sstevel@tonic-gate 	 *	remote identification strings	null-terminated ascii strings
3887c478bd9Sstevel@tonic-gate 	 */
3897c478bd9Sstevel@tonic-gate } ike_rule_t;
3907c478bd9Sstevel@tonic-gate 
3917c478bd9Sstevel@tonic-gate 
3927c478bd9Sstevel@tonic-gate /*
3937c478bd9Sstevel@tonic-gate  * data formatting structure for preshared keys
3947c478bd9Sstevel@tonic-gate  * ps_ike_mode field uses the IKE_XCHG_* defs
3957c478bd9Sstevel@tonic-gate  */
3967c478bd9Sstevel@tonic-gate typedef struct {
3977c478bd9Sstevel@tonic-gate 	ike_addr_pr_t	ps_ipaddrs;
3987c478bd9Sstevel@tonic-gate 	uint16_t	ps_ike_mode;
3997c478bd9Sstevel@tonic-gate 	uint16_t	ps_localid_off;
4007c478bd9Sstevel@tonic-gate 	uint16_t	ps_localid_len;
4017c478bd9Sstevel@tonic-gate 	uint16_t	ps_remoteid_off;
4027c478bd9Sstevel@tonic-gate 	uint16_t	ps_remoteid_len;
4037c478bd9Sstevel@tonic-gate 	uint16_t	ps_key_off;
4047c478bd9Sstevel@tonic-gate 	uint16_t	ps_key_len;
4057c478bd9Sstevel@tonic-gate 	uint16_t	ps_key_bits;
4067c478bd9Sstevel@tonic-gate 	/*
4077c478bd9Sstevel@tonic-gate 	 * followed by variable-length structures, as indicated by
4087c478bd9Sstevel@tonic-gate 	 * offset/length fields.
4097c478bd9Sstevel@tonic-gate 	 * key info will be formatted as an array of bytes.
4107c478bd9Sstevel@tonic-gate 	 * local/remote ids will be formatted as sadb_ident_t structs.
4117c478bd9Sstevel@tonic-gate 	 */
4127c478bd9Sstevel@tonic-gate } ike_ps_t;
4137c478bd9Sstevel@tonic-gate 
414*c7777ac8SPaul Wernau #define	DN_MAX			1024
415*c7777ac8SPaul Wernau #define	CERT_OFF_WIRE		-1
416*c7777ac8SPaul Wernau #define	CERT_NO_PRIVKEY		0
417*c7777ac8SPaul Wernau #define	CERT_PRIVKEY_LOCKED	1
418*c7777ac8SPaul Wernau #define	CERT_PRIVKEY_AVAIL	2
419*c7777ac8SPaul Wernau 
420*c7777ac8SPaul Wernau /*
421*c7777ac8SPaul Wernau  * data formatting structure for cached certs
422*c7777ac8SPaul Wernau  */
423*c7777ac8SPaul Wernau typedef struct {
424*c7777ac8SPaul Wernau 	uint32_t	cache_id;
425*c7777ac8SPaul Wernau 	uint32_t	class;
426*c7777ac8SPaul Wernau 	int		linkage;
427*c7777ac8SPaul Wernau 	char		subject[DN_MAX];
428*c7777ac8SPaul Wernau 	char		issuer[DN_MAX];
429*c7777ac8SPaul Wernau } ike_certcache_t;
4307c478bd9Sstevel@tonic-gate 
4317c478bd9Sstevel@tonic-gate /* identification types */
4327c478bd9Sstevel@tonic-gate #define	IKE_ID_IDENT_PAIR	1
4337c478bd9Sstevel@tonic-gate #define	IKE_ID_ADDR_PAIR	2
4347c478bd9Sstevel@tonic-gate #define	IKE_ID_CKY_PAIR		3
4357c478bd9Sstevel@tonic-gate #define	IKE_ID_LABEL		4
4367c478bd9Sstevel@tonic-gate 
4377c478bd9Sstevel@tonic-gate 
4387c478bd9Sstevel@tonic-gate /* locations for read/write requests */
4397c478bd9Sstevel@tonic-gate #define	IKE_RW_LOC_DEFAULT	1
4407c478bd9Sstevel@tonic-gate #define	IKE_RW_LOC_USER_SPEC	2
4417c478bd9Sstevel@tonic-gate 
4427c478bd9Sstevel@tonic-gate 
4437c478bd9Sstevel@tonic-gate /* door interface error codes */
4447c478bd9Sstevel@tonic-gate #define	IKE_ERR_NO_OBJ		1	/* nothing found to match the request */
4457c478bd9Sstevel@tonic-gate #define	IKE_ERR_NO_DESC		2	/* fd was required with this request */
4467c478bd9Sstevel@tonic-gate #define	IKE_ERR_ID_INVALID	3	/* invalid id info was provided */
4477c478bd9Sstevel@tonic-gate #define	IKE_ERR_LOC_INVALID	4	/* invalid location info was provided */
4487c478bd9Sstevel@tonic-gate #define	IKE_ERR_CMD_INVALID	5	/* invalid command was provided */
4497c478bd9Sstevel@tonic-gate #define	IKE_ERR_DATA_INVALID	6	/* invalid data was provided */
4507c478bd9Sstevel@tonic-gate #define	IKE_ERR_CMD_NOTSUP	7	/* unsupported command */
4517c478bd9Sstevel@tonic-gate #define	IKE_ERR_REQ_INVALID	8	/* badly formatted request */
4527c478bd9Sstevel@tonic-gate #define	IKE_ERR_NO_PRIV		9	/* privilege level not high enough */
4537c478bd9Sstevel@tonic-gate #define	IKE_ERR_SYS_ERR		10	/* syserr occurred while processing */
45415b07f80Spwernau #define	IKE_ERR_DUP_IGNORED	11	/* attempt to add a duplicate entry */
455*c7777ac8SPaul Wernau #define	IKE_ERR_NO_TOKEN	12	/* cannot login into pkcs#11 token */
456*c7777ac8SPaul Wernau #define	IKE_ERR_NO_AUTH		13	/* not authorized */
457*c7777ac8SPaul Wernau #define	IKE_ERR_IN_PROGRESS	14	/* operation already in progress */
458*c7777ac8SPaul Wernau #define	IKE_ERR_NO_MEM		15	/* insufficient memory */
4597c478bd9Sstevel@tonic-gate 
4607c478bd9Sstevel@tonic-gate 
4617c478bd9Sstevel@tonic-gate /*
4627c478bd9Sstevel@tonic-gate  * IKE_SVC_GET_DBG
4637c478bd9Sstevel@tonic-gate  * Used to request the current debug level.
4647c478bd9Sstevel@tonic-gate  *
4657c478bd9Sstevel@tonic-gate  * Upon request, dbg_level is 0 (don't care).
4667c478bd9Sstevel@tonic-gate  *
4677c478bd9Sstevel@tonic-gate  * Upon return, dbg_level contains the current value.
4687c478bd9Sstevel@tonic-gate  *
4697c478bd9Sstevel@tonic-gate  *
4707c478bd9Sstevel@tonic-gate  * IKE_SVC_SET_DBG
4717c478bd9Sstevel@tonic-gate  * Used to request modification of the debug level.
4727c478bd9Sstevel@tonic-gate  *
4737c478bd9Sstevel@tonic-gate  * Upon request, dbg_level contains desired level.  If debug output is
4747c478bd9Sstevel@tonic-gate  * to be directed to a different file, the fd should be passed in the
4757c478bd9Sstevel@tonic-gate  * door_desc_t field of the door_arg_t param.  NOTE: if the daemon is
4767c478bd9Sstevel@tonic-gate  * currently running in the background with no debug set, an output
4777c478bd9Sstevel@tonic-gate  * file MUST be given.
4787c478bd9Sstevel@tonic-gate  *
4797c478bd9Sstevel@tonic-gate  * Upon return, dbg_level contains the old debug level, and acknowledges
4807c478bd9Sstevel@tonic-gate  * successful completion of the request.  If an error is encountered,
4817c478bd9Sstevel@tonic-gate  * ike_err_t is returned instead, with appropriate error value and cmd
4827c478bd9Sstevel@tonic-gate  * IKE_SVC_ERROR.
4837c478bd9Sstevel@tonic-gate  */
4847c478bd9Sstevel@tonic-gate typedef struct {
4857c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
4867c478bd9Sstevel@tonic-gate 	uint32_t	dbg_level;
4877c478bd9Sstevel@tonic-gate } ike_dbg_t;
4887c478bd9Sstevel@tonic-gate 
4897c478bd9Sstevel@tonic-gate /*
4907c478bd9Sstevel@tonic-gate  * IKE_SVC_GET_PRIV
4917c478bd9Sstevel@tonic-gate  * Used to request the current privilege level.
4927c478bd9Sstevel@tonic-gate  *
4937c478bd9Sstevel@tonic-gate  * Upon request, priv_level is 0 (don't care).
4947c478bd9Sstevel@tonic-gate  *
4957c478bd9Sstevel@tonic-gate  * Upon return, priv_level contains the current value.
4967c478bd9Sstevel@tonic-gate  *
4977c478bd9Sstevel@tonic-gate  *
4987c478bd9Sstevel@tonic-gate  * IKE_SVC_SET_PRIV
4997c478bd9Sstevel@tonic-gate  * Used to request modification of the privilege level.
5007c478bd9Sstevel@tonic-gate  *
5017c478bd9Sstevel@tonic-gate  * Upon request, priv_level contains the desired level.  The level may
5027c478bd9Sstevel@tonic-gate  * only be lowered via the door interface; it cannot be raised.  Thus,
5037c478bd9Sstevel@tonic-gate  * if in.iked is started at the lowest level, it cannot be changed.
5047c478bd9Sstevel@tonic-gate  *
5057c478bd9Sstevel@tonic-gate  * Upon return, priv_level contains the old privilege level, and
5067c478bd9Sstevel@tonic-gate  * acknowledges successful completion of the request.  If an error is
5077c478bd9Sstevel@tonic-gate  * encountered, ike_err_t is returned instead, with appropriate error
5087c478bd9Sstevel@tonic-gate  * value and cmd IKE_SVC_ERROR.
5097c478bd9Sstevel@tonic-gate  */
5107c478bd9Sstevel@tonic-gate typedef struct {
5117c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
5127c478bd9Sstevel@tonic-gate 	uint32_t	priv_level;
5137c478bd9Sstevel@tonic-gate } ike_priv_t;
5147c478bd9Sstevel@tonic-gate 
5157c478bd9Sstevel@tonic-gate 
5167c478bd9Sstevel@tonic-gate /*
5177c478bd9Sstevel@tonic-gate  * IKE_SVC_GET_STATS
5187c478bd9Sstevel@tonic-gate  * Used to request current statistics on Phase 1 SA creation and
5197c478bd9Sstevel@tonic-gate  * failures.  The statistics represent all activity in in.iked.
5207c478bd9Sstevel@tonic-gate  *
5217c478bd9Sstevel@tonic-gate  * Upon request, cmd is set, and stat_len does not matter.
5227c478bd9Sstevel@tonic-gate  *
5237c478bd9Sstevel@tonic-gate  * Upon successful return, stat_len contains the total size of the
5247c478bd9Sstevel@tonic-gate  * returned buffer, which contains first the ike_statreq_t struct,
5257c478bd9Sstevel@tonic-gate  * followed by the stat data in the ike_stats_t structure. In case
5267c478bd9Sstevel@tonic-gate  * of an error in processing the request, ike_err_t is returned with
5277c478bd9Sstevel@tonic-gate  * IKE_SVC_ERROR command and appropriate error code.
5287c478bd9Sstevel@tonic-gate  */
5297c478bd9Sstevel@tonic-gate typedef struct {
5307c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
5317c478bd9Sstevel@tonic-gate 	uint32_t	stat_len;
5327c478bd9Sstevel@tonic-gate } ike_statreq_t;
5337c478bd9Sstevel@tonic-gate 
5340f2065ccSmarkfen /*
5350f2065ccSmarkfen  * IKE_SVC_GET_DEFS
5360f2065ccSmarkfen  * Used to request default values from in.iked.
5370f2065ccSmarkfen  *
5380f2065ccSmarkfen  * Upon request, cmd is set, and stat_len does not matter.
5390f2065ccSmarkfen  *
5400f2065ccSmarkfen  * Upon successful return, stat_len contains the total size of the
5410f2065ccSmarkfen  * returned buffer, this contains a pair of ike_defaults_t's.
5420f2065ccSmarkfen  */
5430f2065ccSmarkfen typedef struct {
5440f2065ccSmarkfen 	ike_svccmd_t	cmd;
5450f2065ccSmarkfen 	uint32_t	stat_len;
5460f2065ccSmarkfen 	uint32_t	version;
5470f2065ccSmarkfen } ike_defreq_t;
5487c478bd9Sstevel@tonic-gate 
5497c478bd9Sstevel@tonic-gate /*
550*c7777ac8SPaul Wernau  * IKE_SVC_DUMP_{P1S|RULES|PS|CERTCACHE}
5517c478bd9Sstevel@tonic-gate  * Used to request a table dump, and to return info for a single table
5527c478bd9Sstevel@tonic-gate  * item.  The expectation is that all of the table data will be passed
5537c478bd9Sstevel@tonic-gate  * through the door, one entry at a time; an individual request must be
5547c478bd9Sstevel@tonic-gate  * sent for each entry, however (the door server can't send unrequested
5557c478bd9Sstevel@tonic-gate  * data).
5567c478bd9Sstevel@tonic-gate  *
5577c478bd9Sstevel@tonic-gate  * Upon request: cmd is set, and dump_next contains the item number
5587c478bd9Sstevel@tonic-gate  * requested (0 for first request).  dump_len is 0; no data follows.
5597c478bd9Sstevel@tonic-gate  *
5607c478bd9Sstevel@tonic-gate  * Upon return: cmd is set, and dump_next contains the item number of
5617c478bd9Sstevel@tonic-gate  * the *next* item in the table (to be used in the subsequent request).
5627c478bd9Sstevel@tonic-gate  * dump_next = 0 indicates that this is the last item in the table.
5637c478bd9Sstevel@tonic-gate  * dump_len is the total length (data + struct) returned.  Data is
5647c478bd9Sstevel@tonic-gate  * formatted as indicated by the cmd type:
5657c478bd9Sstevel@tonic-gate  *   IKE_SVC_DUMP_P1S:		ike_p1_sa_t
5667c478bd9Sstevel@tonic-gate  *   IKE_SVC_DUMP_RULES:	ike_rule_t
5677c478bd9Sstevel@tonic-gate  *   IKE_SVC_DUMP_PS:		ike_ps_t
568*c7777ac8SPaul Wernau  *   IKE_SVC_DUMP_CERTCACHE:	ike_certcache_t
5697c478bd9Sstevel@tonic-gate  */
5707c478bd9Sstevel@tonic-gate typedef struct {
5717c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
5727c478bd9Sstevel@tonic-gate 	uint32_t	dump_len;
5737c478bd9Sstevel@tonic-gate 	union {
5747c478bd9Sstevel@tonic-gate 		struct {
5757c478bd9Sstevel@tonic-gate 			uint32_t	dump_unext;
5767c478bd9Sstevel@tonic-gate 			uint32_t	dump_ureserved;
5777c478bd9Sstevel@tonic-gate 		} dump_actual;
5787c478bd9Sstevel@tonic-gate 		uint64_t dump_alignment;
5797c478bd9Sstevel@tonic-gate 	} dump_u;
5807c478bd9Sstevel@tonic-gate #define	dump_next dump_u.dump_actual.dump_unext
5817c478bd9Sstevel@tonic-gate #define	dump_reserved dump_u.dump_actual.dump_ureserved
5827c478bd9Sstevel@tonic-gate 	/* dump_len - sizeof (ike_dump_t) bytes of data included here */
5837c478bd9Sstevel@tonic-gate } ike_dump_t;
5847c478bd9Sstevel@tonic-gate 
5857c478bd9Sstevel@tonic-gate 
5867c478bd9Sstevel@tonic-gate /*
5877c478bd9Sstevel@tonic-gate  * IKE_SVC_GET_{P1|RULE|PS}
5887c478bd9Sstevel@tonic-gate  * Used to request and return individual table items.
5897c478bd9Sstevel@tonic-gate  *
5907c478bd9Sstevel@tonic-gate  * Upon request: get_len is the total msg length (struct + id data);
5917c478bd9Sstevel@tonic-gate  * get_idtype indicates the type of identification being used.
5927c478bd9Sstevel@tonic-gate  *   IKE_SVC_GET_P1:		ike_addr_pr_t or ike_cky_pr_t
5937c478bd9Sstevel@tonic-gate  *   IKE_SVC_GET_RULE:		char string (label)
5947c478bd9Sstevel@tonic-gate  *   IKE_SVC_GET_PS:		ike_addr_pr_t or pair of sadb_ident_t
5957c478bd9Sstevel@tonic-gate  *
5967c478bd9Sstevel@tonic-gate  * Upon return: get_len is the total size (struct + data), get_idtype
5977c478bd9Sstevel@tonic-gate  * is unused, and the data that follows is formatted according to cmd:
5987c478bd9Sstevel@tonic-gate  *   IKE_SVC_GET_P1:		ike_p1_sa_t
5997c478bd9Sstevel@tonic-gate  *   IKE_SVC_GET_RULE:		ike_rule_t
6007c478bd9Sstevel@tonic-gate  *   IKE_SVC_GET_PS:		ike_ps_t
6017c478bd9Sstevel@tonic-gate  */
6027c478bd9Sstevel@tonic-gate typedef struct {
6037c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
6047c478bd9Sstevel@tonic-gate 	uint32_t	get_len;
6057c478bd9Sstevel@tonic-gate 	union {
6067c478bd9Sstevel@tonic-gate 		struct {
6077c478bd9Sstevel@tonic-gate 			uint32_t	getu_idtype;
6087c478bd9Sstevel@tonic-gate 			uint32_t	getu_reserved;
6097c478bd9Sstevel@tonic-gate 		} get_actual;
6107c478bd9Sstevel@tonic-gate 		uint64_t get_alignment;
6117c478bd9Sstevel@tonic-gate 	} get_u;
6127c478bd9Sstevel@tonic-gate #define	get_idtype get_u.get_actual.getu_idtype
6137c478bd9Sstevel@tonic-gate #define	get_reserved get_u.get_actual.getu_reserved
6147c478bd9Sstevel@tonic-gate 	/* get_len - sizeof (ike_get_t) bytes of data included here */
6157c478bd9Sstevel@tonic-gate } ike_get_t;
6167c478bd9Sstevel@tonic-gate 
6177c478bd9Sstevel@tonic-gate 
6187c478bd9Sstevel@tonic-gate /*
6197c478bd9Sstevel@tonic-gate  * IKE_SVC_NEW_{RULE|PS}
6207c478bd9Sstevel@tonic-gate  * Used to request and acknowledge insertion of a table item.
6217c478bd9Sstevel@tonic-gate  *
6227c478bd9Sstevel@tonic-gate  * Upon request: new_len is the total (data + struct) size passed, or 0.
6237c478bd9Sstevel@tonic-gate  * new_len = 0 => a door_desc_t is also included with a file descriptor
6247c478bd9Sstevel@tonic-gate  * for a file containing the data to be added.  The file should include
6257c478bd9Sstevel@tonic-gate  * a single item: a rule, or a pre-shared key.  For new_len != 0, the
6267c478bd9Sstevel@tonic-gate  * data is formatted according to the cmd type:
6277c478bd9Sstevel@tonic-gate  *   IKE_SVC_NEW_RULE:		ike_rule_t
6287c478bd9Sstevel@tonic-gate  *   IKE_SVC_NEW_PS:		ike_ps_t
6297c478bd9Sstevel@tonic-gate  *
6307c478bd9Sstevel@tonic-gate  * Upon return: new_len is 0; simply acknowledges successful insertion
6317c478bd9Sstevel@tonic-gate  * of the requested item.  If insertion is not successful, ike_err_t is
6327c478bd9Sstevel@tonic-gate  * returned instead with appropriate error value.
6337c478bd9Sstevel@tonic-gate  */
6347c478bd9Sstevel@tonic-gate typedef struct {
6357c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
6367c478bd9Sstevel@tonic-gate 	uint32_t	new_len;
6377c478bd9Sstevel@tonic-gate 	/* new_len - sizeof (ike_new_t) bytes included here */
6387c478bd9Sstevel@tonic-gate 	uint64_t	new_align;	/* Padding for 64-bit alignment. */
6397c478bd9Sstevel@tonic-gate } ike_new_t;
6407c478bd9Sstevel@tonic-gate 
6417c478bd9Sstevel@tonic-gate 
6427c478bd9Sstevel@tonic-gate /*
6437c478bd9Sstevel@tonic-gate  * IKE_SVC_DEL_{P1|RULE|PS}
6447c478bd9Sstevel@tonic-gate  * Used to request and acknowledge the deletion of an individual table
6457c478bd9Sstevel@tonic-gate  * item.
6467c478bd9Sstevel@tonic-gate  *
6477c478bd9Sstevel@tonic-gate  * Upon request: del_len is the total msg length (struct + id data);
6487c478bd9Sstevel@tonic-gate  * del_idtype indicates the type of identification being used.
6497c478bd9Sstevel@tonic-gate  *   IKE_SVC_DEL_P1:		ike_addr_pr_t or ike_cky_pr_t
6507c478bd9Sstevel@tonic-gate  *   IKE_SVC_DEL_RULE:		char string (label)
6517c478bd9Sstevel@tonic-gate  *   IKE_SVC_DEL_PS:		ike_addr_pr_t or pair of sadb_ident_t
6527c478bd9Sstevel@tonic-gate  *
6537c478bd9Sstevel@tonic-gate  * Upon return: acknowledges deletion of the requested item; del_len and
6547c478bd9Sstevel@tonic-gate  * del_idtype are unspecified.  If deletion is not successful, ike_err_t
6557c478bd9Sstevel@tonic-gate  * is returned instead with appropriate error value.
6567c478bd9Sstevel@tonic-gate  */
6577c478bd9Sstevel@tonic-gate typedef struct {
6587c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
6597c478bd9Sstevel@tonic-gate 	uint32_t	del_len;
6607c478bd9Sstevel@tonic-gate 	uint32_t	del_idtype;
6617c478bd9Sstevel@tonic-gate 	uint32_t	del_reserved;
6627c478bd9Sstevel@tonic-gate 	/* del_len - sizeof (ike_del_t) bytes of data included here. */
6637c478bd9Sstevel@tonic-gate } ike_del_t;
6647c478bd9Sstevel@tonic-gate 
6657c478bd9Sstevel@tonic-gate 
6667c478bd9Sstevel@tonic-gate /*
6677c478bd9Sstevel@tonic-gate  * IKE_SVC_READ_{RULES|PS}
6687c478bd9Sstevel@tonic-gate  * Used to ask daemon to re-read particular configuration info.
6697c478bd9Sstevel@tonic-gate  *
6707c478bd9Sstevel@tonic-gate  * Upon request: rw_loc indicates where the info should be read from:
6717c478bd9Sstevel@tonic-gate  * either from a user-supplied file descriptor(s), or from the default
6727c478bd9Sstevel@tonic-gate  * location(s).  If rw_loc indicates user-supplied location, the file
6737c478bd9Sstevel@tonic-gate  * descriptor(s) should be passed in the door_desc_t struct.  For the
6747c478bd9Sstevel@tonic-gate  * IKE_SVC_READ_RULES cmd, two file descriptors should be specified:
6757c478bd9Sstevel@tonic-gate  * first, one for the config file which contains the data to be read,
6767c478bd9Sstevel@tonic-gate  * and second, one for the cookie file which will be written to as
6777c478bd9Sstevel@tonic-gate  * in.iked process the config file.
6787c478bd9Sstevel@tonic-gate  *
6797c478bd9Sstevel@tonic-gate  * Upon return: rw_loc is unspecified; the message simply acknowledges
6807c478bd9Sstevel@tonic-gate  * successful completion of the request.  If an error occurred,
6817c478bd9Sstevel@tonic-gate  * ike_err_t is returned instead with appropriate error value.
6827c478bd9Sstevel@tonic-gate  *
6837c478bd9Sstevel@tonic-gate  *
6847c478bd9Sstevel@tonic-gate  * IKE_SVC_WRITE_{RULES|PS}
6857c478bd9Sstevel@tonic-gate  * Used to ask daemon to write its current config info to files.
6867c478bd9Sstevel@tonic-gate  *
6877c478bd9Sstevel@tonic-gate  * Request and return are handled the same as for the IKE_SVC_READ_*
6887c478bd9Sstevel@tonic-gate  * cmds; however, the rw_loc MUST be a user-supplied location.  Also,
6897c478bd9Sstevel@tonic-gate  * for the IKE_SVC_WRITE_RULES cmd, the cookie file fd is not required;
6907c478bd9Sstevel@tonic-gate  * only a single fd, for the file to which the config info should be
6917c478bd9Sstevel@tonic-gate  * written, should be passed in.
6927c478bd9Sstevel@tonic-gate  */
6937c478bd9Sstevel@tonic-gate typedef struct {
6947c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
6957c478bd9Sstevel@tonic-gate 	uint32_t	rw_loc;
6967c478bd9Sstevel@tonic-gate } ike_rw_t;
6977c478bd9Sstevel@tonic-gate 
6987c478bd9Sstevel@tonic-gate 
6997c478bd9Sstevel@tonic-gate /*
7007c478bd9Sstevel@tonic-gate  * IKE_SVC_FLUSH_P1S
701*c7777ac8SPaul Wernau  * IKE_SVC_FLUSH_CERTCACHE
702*c7777ac8SPaul Wernau  *
703*c7777ac8SPaul Wernau  * Used to request and acknowledge tear-down of all P1 SAs
704*c7777ac8SPaul Wernau  * or to flush the certificate cache.
7057c478bd9Sstevel@tonic-gate  */
7067c478bd9Sstevel@tonic-gate typedef struct {
7077c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
7087c478bd9Sstevel@tonic-gate } ike_flush_t;
7097c478bd9Sstevel@tonic-gate 
7107c478bd9Sstevel@tonic-gate 
711*c7777ac8SPaul Wernau #ifndef PKCS11_TOKSIZE
712*c7777ac8SPaul Wernau #define	PKCS11_TOKSIZE 32
713*c7777ac8SPaul Wernau #endif
714*c7777ac8SPaul Wernau #define	MAX_PIN_LEN 256
715*c7777ac8SPaul Wernau /*
716*c7777ac8SPaul Wernau  * IKE_SVC_SET_PIN
717*c7777ac8SPaul Wernau  * IKE_SVC_DEL_PIN
718*c7777ac8SPaul Wernau  *
719*c7777ac8SPaul Wernau  * Used to supply a pin for a PKCS#11 tokenj object.
720*c7777ac8SPaul Wernau  *
721*c7777ac8SPaul Wernau  */
722*c7777ac8SPaul Wernau typedef struct {
723*c7777ac8SPaul Wernau 	ike_svccmd_t	cmd;
724*c7777ac8SPaul Wernau 	char pkcs11_token[PKCS11_TOKSIZE];
725*c7777ac8SPaul Wernau 	uchar_t token_pin[MAX_PIN_LEN];
726*c7777ac8SPaul Wernau } ike_pin_t;
727*c7777ac8SPaul Wernau 
7287c478bd9Sstevel@tonic-gate /*
7297c478bd9Sstevel@tonic-gate  * IKE_SVC_ERROR
7307c478bd9Sstevel@tonic-gate  * Used on return if server encountered an error while processing
7317c478bd9Sstevel@tonic-gate  * the request.  An appropriate error code is included (as defined
7327c478bd9Sstevel@tonic-gate  * in this header file); in the case of IKE_ERR_SYS_ERR, a value
7337c478bd9Sstevel@tonic-gate  * from the UNIX errno space is included in the ike_err_unix field.
7347c478bd9Sstevel@tonic-gate  */
7357c478bd9Sstevel@tonic-gate typedef struct {
7367c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
7377c478bd9Sstevel@tonic-gate 	uint32_t	ike_err;
7387c478bd9Sstevel@tonic-gate 	uint32_t	ike_err_unix;
7397c478bd9Sstevel@tonic-gate 	uint32_t	ike_err_reserved;
7407c478bd9Sstevel@tonic-gate } ike_err_t;
7417c478bd9Sstevel@tonic-gate 
7427c478bd9Sstevel@tonic-gate /*
7437c478bd9Sstevel@tonic-gate  * Generic type for use when the request/reply type is unknown
7447c478bd9Sstevel@tonic-gate  */
7457c478bd9Sstevel@tonic-gate typedef struct {
7467c478bd9Sstevel@tonic-gate 	ike_svccmd_t	cmd;
7477c478bd9Sstevel@tonic-gate } ike_cmd_t;
7487c478bd9Sstevel@tonic-gate 
7497c478bd9Sstevel@tonic-gate 
7507c478bd9Sstevel@tonic-gate /*
751*c7777ac8SPaul Wernau  * Union containing all possible request/return structures.
7527c478bd9Sstevel@tonic-gate  */
7537c478bd9Sstevel@tonic-gate typedef union {
7547c478bd9Sstevel@tonic-gate 	ike_cmd_t	svc_cmd;
7557c478bd9Sstevel@tonic-gate 	ike_dbg_t	svc_dbg;
7567c478bd9Sstevel@tonic-gate 	ike_priv_t	svc_priv;
7577c478bd9Sstevel@tonic-gate 	ike_statreq_t	svc_stats;
7587c478bd9Sstevel@tonic-gate 	ike_dump_t	svc_dump;
7597c478bd9Sstevel@tonic-gate 	ike_get_t	svc_get;
7607c478bd9Sstevel@tonic-gate 	ike_new_t	svc_new;
7617c478bd9Sstevel@tonic-gate 	ike_del_t	svc_del;
7627c478bd9Sstevel@tonic-gate 	ike_rw_t	svc_rw;
7637c478bd9Sstevel@tonic-gate 	ike_flush_t	svc_flush;
764*c7777ac8SPaul Wernau 	ike_pin_t	svc_pin;
7657c478bd9Sstevel@tonic-gate 	ike_err_t	svc_err;
7660f2065ccSmarkfen 	ike_defreq_t	svc_defaults;
7677c478bd9Sstevel@tonic-gate } ike_service_t;
7687c478bd9Sstevel@tonic-gate 
7697c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
7707c478bd9Sstevel@tonic-gate }
7717c478bd9Sstevel@tonic-gate #endif
7727c478bd9Sstevel@tonic-gate 
7737c478bd9Sstevel@tonic-gate #endif	/* _IKEDOOR_H */
774