xref: /onnv-gate/usr/src/uts/common/sys/iscsit/iscsit_common.h (revision 12370:56f486793f46)
17978SPeter.Dunlap@Sun.COM /*
27978SPeter.Dunlap@Sun.COM  * CDDL HEADER START
37978SPeter.Dunlap@Sun.COM  *
47978SPeter.Dunlap@Sun.COM  * The contents of this file are subject to the terms of the
57978SPeter.Dunlap@Sun.COM  * Common Development and Distribution License (the "License").
67978SPeter.Dunlap@Sun.COM  * You may not use this file except in compliance with the License.
77978SPeter.Dunlap@Sun.COM  *
87978SPeter.Dunlap@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97978SPeter.Dunlap@Sun.COM  * or http://www.opensolaris.org/os/licensing.
107978SPeter.Dunlap@Sun.COM  * See the License for the specific language governing permissions
117978SPeter.Dunlap@Sun.COM  * and limitations under the License.
127978SPeter.Dunlap@Sun.COM  *
137978SPeter.Dunlap@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
147978SPeter.Dunlap@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157978SPeter.Dunlap@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
167978SPeter.Dunlap@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
177978SPeter.Dunlap@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
187978SPeter.Dunlap@Sun.COM  *
197978SPeter.Dunlap@Sun.COM  * CDDL HEADER END
207978SPeter.Dunlap@Sun.COM  */
217978SPeter.Dunlap@Sun.COM /*
22*12370SPeter.Gill@Sun.COM  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
237978SPeter.Dunlap@Sun.COM  */
247978SPeter.Dunlap@Sun.COM 
257978SPeter.Dunlap@Sun.COM #ifndef _ISCSIT_COMMON_H_
267978SPeter.Dunlap@Sun.COM #define	_ISCSIT_COMMON_H_
277978SPeter.Dunlap@Sun.COM 
287978SPeter.Dunlap@Sun.COM #ifdef	_KERNEL
297978SPeter.Dunlap@Sun.COM #include <sys/nvpair.h>
307978SPeter.Dunlap@Sun.COM #else
317978SPeter.Dunlap@Sun.COM #include <libnvpair.h>
327978SPeter.Dunlap@Sun.COM #endif
337978SPeter.Dunlap@Sun.COM 
347978SPeter.Dunlap@Sun.COM #ifdef __cplusplus
357978SPeter.Dunlap@Sun.COM extern "C" {
367978SPeter.Dunlap@Sun.COM #endif
377978SPeter.Dunlap@Sun.COM 
387978SPeter.Dunlap@Sun.COM #define	ISCSIT_API_VERS0		0
397978SPeter.Dunlap@Sun.COM 
408062SPeter.Dunlap@Sun.COM #define	ISCSIT_MODNAME		"iscsit"
418062SPeter.Dunlap@Sun.COM #define	ISCSIT_NODE		"/devices/pseudo/iscsit@0:iscsit"
428062SPeter.Dunlap@Sun.COM 
437978SPeter.Dunlap@Sun.COM typedef enum {
447978SPeter.Dunlap@Sun.COM 	ITCFG_SUCCESS = 0,
457978SPeter.Dunlap@Sun.COM 	ITCFG_INVALID,
467978SPeter.Dunlap@Sun.COM 	ITCFG_TGT_CREATE_ERR,
477978SPeter.Dunlap@Sun.COM 	ITCFG_MISC_ERR
487978SPeter.Dunlap@Sun.COM } it_cfg_status_t;
497978SPeter.Dunlap@Sun.COM 
507978SPeter.Dunlap@Sun.COM /*
517978SPeter.Dunlap@Sun.COM  * This structure is passed back to the driver during ISCSIT_IOC_ENABLE_SVC
527978SPeter.Dunlap@Sun.COM  * in order to provide the fully qualified hostname for use as the EID
537978SPeter.Dunlap@Sun.COM  * by iSNS.
547978SPeter.Dunlap@Sun.COM  */
557978SPeter.Dunlap@Sun.COM 
567978SPeter.Dunlap@Sun.COM #define	ISCSIT_MAX_HOSTNAME_LEN	256
577978SPeter.Dunlap@Sun.COM 
587978SPeter.Dunlap@Sun.COM typedef struct iscsit_hostinfo_s {
597978SPeter.Dunlap@Sun.COM 	uint32_t	length;
607978SPeter.Dunlap@Sun.COM 	char		fqhn[ISCSIT_MAX_HOSTNAME_LEN];
617978SPeter.Dunlap@Sun.COM } iscsit_hostinfo_t;
627978SPeter.Dunlap@Sun.COM 
637978SPeter.Dunlap@Sun.COM #define	ISCSIT_IOC_SET_CONFIG		1
647978SPeter.Dunlap@Sun.COM #define	ISCSIT_IOC_GET_STATE		2
657978SPeter.Dunlap@Sun.COM #define	ISCSIT_IOC_ENABLE_SVC		101
667978SPeter.Dunlap@Sun.COM #define	ISCSIT_IOC_DISABLE_SVC		102
677978SPeter.Dunlap@Sun.COM 
687978SPeter.Dunlap@Sun.COM /* XXX Rationalize these with other error values (used in it_smf.c */
697978SPeter.Dunlap@Sun.COM #define	ITADM_SUCCESS		0
707978SPeter.Dunlap@Sun.COM #define	ITADM_FATAL_ERROR	0x1
717978SPeter.Dunlap@Sun.COM #define	ITADM_NO_MEM		0x2
727978SPeter.Dunlap@Sun.COM #define	ITADM_INVALID		0x4
737978SPeter.Dunlap@Sun.COM #define	ITADM_NODATA		0x8
747978SPeter.Dunlap@Sun.COM #define	ITADM_PERM		0x10
757978SPeter.Dunlap@Sun.COM 
767978SPeter.Dunlap@Sun.COM 
777978SPeter.Dunlap@Sun.COM #define	PROP_AUTH		"auth"
787978SPeter.Dunlap@Sun.COM #define	PROP_ALIAS		"alias"
797978SPeter.Dunlap@Sun.COM #define	PROP_CHAP_USER		"chapuser"
807978SPeter.Dunlap@Sun.COM #define	PROP_CHAP_SECRET	"chapsecret"
817978SPeter.Dunlap@Sun.COM #define	PROP_TARGET_CHAP_USER	"targetchapuser"
827978SPeter.Dunlap@Sun.COM #define	PROP_TARGET_CHAP_SECRET	"targetchapsecret"
837978SPeter.Dunlap@Sun.COM #define	PROP_RADIUS_SERVER	"radiusserver"
847978SPeter.Dunlap@Sun.COM #define	PROP_RADIUS_SECRET	"radiussecret"
857978SPeter.Dunlap@Sun.COM #define	PROP_ISNS_ENABLED	"isns"
867978SPeter.Dunlap@Sun.COM #define	PROP_ISNS_SERVER	"isnsserver"
877978SPeter.Dunlap@Sun.COM #define	PROP_OLD_TARGET_NAME	"oldtargetname"
887978SPeter.Dunlap@Sun.COM 
897978SPeter.Dunlap@Sun.COM #define	PA_AUTH_RADIUS		"radius"
907978SPeter.Dunlap@Sun.COM #define	PA_AUTH_CHAP		"chap"
917978SPeter.Dunlap@Sun.COM #define	PA_AUTH_NONE		"none"
927978SPeter.Dunlap@Sun.COM 
937978SPeter.Dunlap@Sun.COM typedef struct {
947978SPeter.Dunlap@Sun.COM 	int		set_cfg_vers;
957978SPeter.Dunlap@Sun.COM 	int		set_cfg_pnvlist_len;
967978SPeter.Dunlap@Sun.COM 	caddr_t		set_cfg_pnvlist;
977978SPeter.Dunlap@Sun.COM } iscsit_ioc_set_config_t;
987978SPeter.Dunlap@Sun.COM 
997978SPeter.Dunlap@Sun.COM typedef struct {
1007978SPeter.Dunlap@Sun.COM 	int		getst_vers;
1017978SPeter.Dunlap@Sun.COM 	int		getst_pnvlist_len;
1027978SPeter.Dunlap@Sun.COM 	char		*getst_pnvlist;
1037978SPeter.Dunlap@Sun.COM } iscsit_ioc_getstate_t;
1047978SPeter.Dunlap@Sun.COM 
1057978SPeter.Dunlap@Sun.COM #ifdef _SYSCALL32
1067978SPeter.Dunlap@Sun.COM typedef struct {
1077978SPeter.Dunlap@Sun.COM 	int		set_cfg_vers;
1087978SPeter.Dunlap@Sun.COM 	int		set_cfg_pnvlist_len;
1097978SPeter.Dunlap@Sun.COM 	caddr32_t	set_cfg_pnvlist;
1107978SPeter.Dunlap@Sun.COM } iscsit_ioc_set_config32_t;
1117978SPeter.Dunlap@Sun.COM 
1127978SPeter.Dunlap@Sun.COM typedef struct {
1137978SPeter.Dunlap@Sun.COM 	int		getst_vers;
1147978SPeter.Dunlap@Sun.COM 	int		getst_pnvlist_len;
1157978SPeter.Dunlap@Sun.COM 	caddr32_t	getst_pnvlist;
1167978SPeter.Dunlap@Sun.COM } iscsit_ioc_getstate32_t;
1177978SPeter.Dunlap@Sun.COM #endif /* _SYSCALL32 */
1187978SPeter.Dunlap@Sun.COM 
1198062SPeter.Dunlap@Sun.COM /* Shared user/kernel structures */
1208062SPeter.Dunlap@Sun.COM /*  Maximum size of a Target Portal Group name */
1218062SPeter.Dunlap@Sun.COM #define	MAX_TPG_NAMELEN		256		/* XXX */
1228062SPeter.Dunlap@Sun.COM 
1238062SPeter.Dunlap@Sun.COM /* Maximum size of an iSCSI Target Node name */
1248062SPeter.Dunlap@Sun.COM #define	MAX_ISCSI_NODENAMELEN	256		/* XXX */
1258062SPeter.Dunlap@Sun.COM 
1268062SPeter.Dunlap@Sun.COM /*
1278062SPeter.Dunlap@Sun.COM  * A target portal group tag is a binding between a target and a target
1288062SPeter.Dunlap@Sun.COM  * portal group along with a numerical value associated with that binding.
1298062SPeter.Dunlap@Sun.COM  * The numerical identifier is used as the 'target portal group tag' defined
1308062SPeter.Dunlap@Sun.COM  * in RFC3720.
1318062SPeter.Dunlap@Sun.COM  *
1328062SPeter.Dunlap@Sun.COM  *  tpgt_tpg_name	The name of the target portal group associated with
1338062SPeter.Dunlap@Sun.COM  *			this target portal group tag.
1348062SPeter.Dunlap@Sun.COM  *  tpgt_generation	Generation number which is incremented each time the
1358062SPeter.Dunlap@Sun.COM  *			structure changes.
1368062SPeter.Dunlap@Sun.COM  *  tpgt_next		Next target portal group tag in th list of target portal
1378062SPeter.Dunlap@Sun.COM  *			group tags.  If tpgt_next is NUL, then this is the last
1388062SPeter.Dunlap@Sun.COM  *			target portal group in the list.
1398062SPeter.Dunlap@Sun.COM  *  tpgt_tag		A numerical identifier that uniquely identifies a
1408062SPeter.Dunlap@Sun.COM  *			target portal group within the associated target node.
1418062SPeter.Dunlap@Sun.COM  */
1428062SPeter.Dunlap@Sun.COM typedef struct it_tpgt_s {
1438062SPeter.Dunlap@Sun.COM 	char			tpgt_tpg_name[MAX_TPG_NAMELEN];
1448062SPeter.Dunlap@Sun.COM 	uint64_t		tpgt_generation;
1458062SPeter.Dunlap@Sun.COM 	struct it_tpgt_s	*tpgt_next;
1468062SPeter.Dunlap@Sun.COM 	uint16_t		tpgt_tag;
1478062SPeter.Dunlap@Sun.COM } it_tpgt_t;
1488062SPeter.Dunlap@Sun.COM 
1498062SPeter.Dunlap@Sun.COM /*
1508062SPeter.Dunlap@Sun.COM  * An iSCSI target node is represented by an it_tgt_structure.  Each
1518062SPeter.Dunlap@Sun.COM  * target node includes a list of associated target portal group tags
1528062SPeter.Dunlap@Sun.COM  * and a list of properties.
1538062SPeter.Dunlap@Sun.COM  *
1548062SPeter.Dunlap@Sun.COM  *  tgt_name		The iSCSI target node name in either IQN or EUI
1558062SPeter.Dunlap@Sun.COM  *			format (see RFC3720).
1568062SPeter.Dunlap@Sun.COM  *  tgt_generation	Generation number which is incremented each time
1578062SPeter.Dunlap@Sun.COM  *			the structure changes.
1588062SPeter.Dunlap@Sun.COM  *  tgt_next		Next target in the list of targets.  If tgt_next
1598062SPeter.Dunlap@Sun.COM  *			is NULL, then this is the last target in the list.
1608062SPeter.Dunlap@Sun.COM  *  tgt_tpgt_list	A linked list representing the current target
1618062SPeter.Dunlap@Sun.COM  *			portal group tags associated with this target.
1628062SPeter.Dunlap@Sun.COM  *  tgt_tpgt_count	The number of currently defined target portal
1638062SPeter.Dunlap@Sun.COM  *			group tags.
1648062SPeter.Dunlap@Sun.COM  *  tgt_properties	An nvlist representation of the properties
1658062SPeter.Dunlap@Sun.COM  *			associated with this target.  This list can be
1668062SPeter.Dunlap@Sun.COM  *			manipulated using libnvpair(3lib), and should be
1678062SPeter.Dunlap@Sun.COM  *			validated and stored using it_tgt_setprop().
1688062SPeter.Dunlap@Sun.COM  *
1698062SPeter.Dunlap@Sun.COM  * Target nvlist Properties:
1708062SPeter.Dunlap@Sun.COM  *
1718062SPeter.Dunlap@Sun.COM  *  nvlist Key		Type		Valid Values
1728062SPeter.Dunlap@Sun.COM  *  --------------------------------------------------------------------
1738062SPeter.Dunlap@Sun.COM  *  targetchapuser	string		any string or "none" to remove
1748062SPeter.Dunlap@Sun.COM  *  targetchapsecret	string		string of at least 12 characters
1758062SPeter.Dunlap@Sun.COM  *					but not more than 255 characters.
1768062SPeter.Dunlap@Sun.COM  *					secret will be base64 encoded when
1778062SPeter.Dunlap@Sun.COM  *					stored.
1788062SPeter.Dunlap@Sun.COM  *  alias		string		any string or "none" to remove
1798062SPeter.Dunlap@Sun.COM  *  auth		string		"radius", "chap", or "none"
1808062SPeter.Dunlap@Sun.COM  *
1818062SPeter.Dunlap@Sun.COM  */
1828062SPeter.Dunlap@Sun.COM typedef struct it_tgt_s {
1838062SPeter.Dunlap@Sun.COM 	char			tgt_name[MAX_ISCSI_NODENAMELEN];
1848062SPeter.Dunlap@Sun.COM 	uint64_t		tgt_generation;
1858062SPeter.Dunlap@Sun.COM 	struct it_tgt_s		*tgt_next;
1868062SPeter.Dunlap@Sun.COM 	it_tpgt_t		*tgt_tpgt_list;
1878062SPeter.Dunlap@Sun.COM 	uint32_t		tgt_tpgt_count;
1888062SPeter.Dunlap@Sun.COM 	nvlist_t		*tgt_properties;
1898062SPeter.Dunlap@Sun.COM } it_tgt_t;
1908062SPeter.Dunlap@Sun.COM 
1918062SPeter.Dunlap@Sun.COM /*
1928062SPeter.Dunlap@Sun.COM  * A target portal is represented by an IP address and a listening
1938062SPeter.Dunlap@Sun.COM  * TCP port.
1948062SPeter.Dunlap@Sun.COM  *
1958062SPeter.Dunlap@Sun.COM  *  portal_addr		sockaddr_storage structure representing the
1968062SPeter.Dunlap@Sun.COM  *			IPv4 or IPv6 address and TCP port associated
1978062SPeter.Dunlap@Sun.COM  *			with the portal.
1988062SPeter.Dunlap@Sun.COM  *  portal_next		Next portal in the list of portals.  If
1998062SPeter.Dunlap@Sun.COM  *			portal_next is NULL, this is the last portal
2008062SPeter.Dunlap@Sun.COM  *			in the list.
2018062SPeter.Dunlap@Sun.COM  */
2028062SPeter.Dunlap@Sun.COM typedef struct it_portal_s {
2038062SPeter.Dunlap@Sun.COM 	struct sockaddr_storage portal_addr;
204*12370SPeter.Gill@Sun.COM 	struct it_portal_s	*portal_next;
2058062SPeter.Dunlap@Sun.COM } it_portal_t;
2068062SPeter.Dunlap@Sun.COM 
2078062SPeter.Dunlap@Sun.COM /*
2088062SPeter.Dunlap@Sun.COM  * A portal is an IP address and TCP port and a portal group is a set
2098062SPeter.Dunlap@Sun.COM  * of portals.  Each defined portal belongs to exactly one portal group.
2108062SPeter.Dunlap@Sun.COM  * Applications can associate a target portal group with a particular
2118062SPeter.Dunlap@Sun.COM  * target using a target portal group name.  Initiators can only connect
2128062SPeter.Dunlap@Sun.COM  * to targets through the portals associated with the target's target
2138062SPeter.Dunlap@Sun.COM  * portal group tags.
2148062SPeter.Dunlap@Sun.COM  *
2158062SPeter.Dunlap@Sun.COM  *  tpg_name		Identifier for the target portal group.
2168062SPeter.Dunlap@Sun.COM  *  tpg_generation	Generation number which is incremented each
2178062SPeter.Dunlap@Sun.COM  *			time this structure changes.
2188062SPeter.Dunlap@Sun.COM  *  tpg_next		Next target portal group in the list of target
2198062SPeter.Dunlap@Sun.COM  *			portal groups.  If tpg_next is NULL, this is the
2208062SPeter.Dunlap@Sun.COM  *			last target portal group in the list.
2218062SPeter.Dunlap@Sun.COM  *  tpg_portal_count	Number of it_portal_t structures in the list.
2228062SPeter.Dunlap@Sun.COM  *  tpg_portal_list	Linked list of it_portal_t structures.
2238062SPeter.Dunlap@Sun.COM  */
2248062SPeter.Dunlap@Sun.COM typedef struct it_tpg_s {
2258062SPeter.Dunlap@Sun.COM 	char			tpg_name[MAX_TPG_NAMELEN];
2268062SPeter.Dunlap@Sun.COM 	uint64_t		tpg_generation;
2278062SPeter.Dunlap@Sun.COM 	struct it_tpg_s		*tpg_next;
2288062SPeter.Dunlap@Sun.COM 	uint32_t		tpg_portal_count;
2298062SPeter.Dunlap@Sun.COM 	it_portal_t		*tpg_portal_list;
2308062SPeter.Dunlap@Sun.COM } it_tpg_t;
2318062SPeter.Dunlap@Sun.COM 
2328062SPeter.Dunlap@Sun.COM /*
2338062SPeter.Dunlap@Sun.COM  * A context representing a remote iSCSI initiator node.  The purpose
2348062SPeter.Dunlap@Sun.COM  * of this structure is to maintain information specific to a remote
2358062SPeter.Dunlap@Sun.COM  * initiator such as the CHAP username and CHAP secret.
2368062SPeter.Dunlap@Sun.COM  *
2378062SPeter.Dunlap@Sun.COM  *  ini_name		the iSCSI node name of the remote initiator.
2388062SPeter.Dunlap@Sun.COM  *  ini_generation	Generation number which is incremented each
2398062SPeter.Dunlap@Sun.COM  *			time this structure changes.
2408062SPeter.Dunlap@Sun.COM  *  ini_next		Next initiator in the list of initiators.
2418062SPeter.Dunlap@Sun.COM  *			If ini_next is NULL, this is the last initiator
2428062SPeter.Dunlap@Sun.COM  *			in the list.
2438062SPeter.Dunlap@Sun.COM  *  ini_properties	Name/Value list containing the properties
2448062SPeter.Dunlap@Sun.COM  *			associated with the initiator context.  This list
2458062SPeter.Dunlap@Sun.COM  *			can be manipulated using libnvpair(3lib), and should
2468062SPeter.Dunlap@Sun.COM  *			be validated and stored using it_ini_setprop().
2478062SPeter.Dunlap@Sun.COM  *
2488062SPeter.Dunlap@Sun.COM  * Initiator nvlist Properties:
2498062SPeter.Dunlap@Sun.COM  *
2508062SPeter.Dunlap@Sun.COM  *  nvlist Key		Type		Valid Values
2518062SPeter.Dunlap@Sun.COM  *  --------------------------------------------------------------------
2528062SPeter.Dunlap@Sun.COM  *  chapuser		string		any string
2538062SPeter.Dunlap@Sun.COM  *  chapsecret		string		string of at least 12 characters
2548062SPeter.Dunlap@Sun.COM  *					but not more than 255 characters.
2558062SPeter.Dunlap@Sun.COM  *					secret will be base64 encoded when
2568062SPeter.Dunlap@Sun.COM  *					stored.
2578062SPeter.Dunlap@Sun.COM  */
2588062SPeter.Dunlap@Sun.COM typedef struct it_ini_s {
2598062SPeter.Dunlap@Sun.COM 	char		ini_name[MAX_ISCSI_NODENAMELEN];
2608062SPeter.Dunlap@Sun.COM 	uint64_t	ini_generation;
2618062SPeter.Dunlap@Sun.COM 	struct it_ini_s	*ini_next;
2628062SPeter.Dunlap@Sun.COM 	nvlist_t	*ini_properties;
2638062SPeter.Dunlap@Sun.COM } it_ini_t;
2648062SPeter.Dunlap@Sun.COM 
2658062SPeter.Dunlap@Sun.COM 
2668062SPeter.Dunlap@Sun.COM /*
2678062SPeter.Dunlap@Sun.COM  * This structure represents a complete configuration for the iscsit
2688062SPeter.Dunlap@Sun.COM  * port provider.  In addition to the global configuration, it_config_t
2698062SPeter.Dunlap@Sun.COM  * includes lists of child objects including targets, target portal
2708062SPeter.Dunlap@Sun.COM  * groups and initiator contexts.  Each object includes a "generation"
2718062SPeter.Dunlap@Sun.COM  * value which is used by the iscsit kernel driver to identify changes
2728062SPeter.Dunlap@Sun.COM  * from one configuration update to the next.
2738062SPeter.Dunlap@Sun.COM  *
2748062SPeter.Dunlap@Sun.COM  *  stmf_token		A uint64_t that contains the value returned from a
2758062SPeter.Dunlap@Sun.COM  *			successful call to stmfGetProviderDataProt(3STMF).
2768062SPeter.Dunlap@Sun.COM  *			This token is used to verify that the configuration
2778062SPeter.Dunlap@Sun.COM  *			data persistently stored in COMSTAR has not been
2788062SPeter.Dunlap@Sun.COM  *			modified since this version was loaded.
2798062SPeter.Dunlap@Sun.COM  *  config_version	Version number for this configuration structure
2808062SPeter.Dunlap@Sun.COM  *  config_tgt_list	Linked list of target contexts representing the
2818062SPeter.Dunlap@Sun.COM  *			currently defined targets.  Applications can add
2828062SPeter.Dunlap@Sun.COM  *			targets to or remove targets from this list using
2838062SPeter.Dunlap@Sun.COM  *			the it_tgt_create and it_tgt_delete functions.
2848062SPeter.Dunlap@Sun.COM  *  config_tgt_count	The number of currently defined targets.
2858062SPeter.Dunlap@Sun.COM  *  config_tpg_list	Linked list of target portal group contexts.
2868062SPeter.Dunlap@Sun.COM  *			Applications can add or remove target portal groups
2878062SPeter.Dunlap@Sun.COM  *			to/from this list using the it_tpg_create and
2888062SPeter.Dunlap@Sun.COM  *			it_tpg_delete functions.
2898062SPeter.Dunlap@Sun.COM  *  config_tpg_count	The number of currently defined target portal groups
2908062SPeter.Dunlap@Sun.COM  *  config_ini_list	Linked list of initiator contexts.  Applications
2918062SPeter.Dunlap@Sun.COM  *			can add initiator contexts or remove initiator
2928062SPeter.Dunlap@Sun.COM  *			contexts from this list using the it_ini_create
2938062SPeter.Dunlap@Sun.COM  *			and it_ini_delete functions.
2948062SPeter.Dunlap@Sun.COM  *  config_ini_count	The number of currently defined initiator contexts.
2958062SPeter.Dunlap@Sun.COM  *  config_global_properties
2968062SPeter.Dunlap@Sun.COM  *			Name/Value list representing the current global
2978062SPeter.Dunlap@Sun.COM  *			property settings.  This list can be manipulated
2988062SPeter.Dunlap@Sun.COM  *			using libnvpair(3lib), and should be validated
2998062SPeter.Dunlap@Sun.COM  *			and stored using it_config_setprop().
3008062SPeter.Dunlap@Sun.COM  *  config_isns_svr_list
3018062SPeter.Dunlap@Sun.COM  *			Linked list of currently defined iSNS servers.
3028062SPeter.Dunlap@Sun.COM  *			Applications can add or remove iSNS servers by
3038062SPeter.Dunlap@Sun.COM  *			using the it_config_setprop() function and changing
3048062SPeter.Dunlap@Sun.COM  *			the array of iSNS servers stored in the "isnsserver"
3058062SPeter.Dunlap@Sun.COM  *			property.
3068062SPeter.Dunlap@Sun.COM  *  config_isns_svr_count
3078062SPeter.Dunlap@Sun.COM  *			The number of currently defined iSNS servers.
3088062SPeter.Dunlap@Sun.COM  *
3098062SPeter.Dunlap@Sun.COM  * Global nvlist Properties:
3108062SPeter.Dunlap@Sun.COM  *
3118062SPeter.Dunlap@Sun.COM  *  nvlist Key		Type		Valid Values
3128062SPeter.Dunlap@Sun.COM  *  --------------------------------------------------------------------
3138062SPeter.Dunlap@Sun.COM  *  alias		string		any string
3148062SPeter.Dunlap@Sun.COM  *  auth		string		"radius", "chap", or "none"
3158062SPeter.Dunlap@Sun.COM  *  isns		boolean		B_TRUE, B_FALSE
3168062SPeter.Dunlap@Sun.COM  *  isnsserver		string array	Array of portal specifications of
3178062SPeter.Dunlap@Sun.COM  *					the form IPaddress:port.  Port
3188062SPeter.Dunlap@Sun.COM  *					is optional; if not specified, the
3198062SPeter.Dunlap@Sun.COM  *					default iSNS port number of 3205 will
3208062SPeter.Dunlap@Sun.COM  *					be used.  IPv6 addresses should
3218062SPeter.Dunlap@Sun.COM  *					be enclosed in square brackets '[' ']'.
3228062SPeter.Dunlap@Sun.COM  *					If "none" is specified, all defined
3238062SPeter.Dunlap@Sun.COM  *					iSNS servers will be removed from the
3248062SPeter.Dunlap@Sun.COM  *					configuration.
3258062SPeter.Dunlap@Sun.COM  *  radiusserver	string		IPaddress:port specification as
3268062SPeter.Dunlap@Sun.COM  *					described for 'isnsserver'.
3278062SPeter.Dunlap@Sun.COM  *  radiussecret	string		string of at least 12 characters
3288062SPeter.Dunlap@Sun.COM  *					but not more than 255 characters.
3298062SPeter.Dunlap@Sun.COM  *					secret will be base64 encoded when
3308062SPeter.Dunlap@Sun.COM  *					stored.
3318062SPeter.Dunlap@Sun.COM  */
3328062SPeter.Dunlap@Sun.COM typedef struct it_config_s {
3338062SPeter.Dunlap@Sun.COM 	uint64_t		stmf_token;
3348062SPeter.Dunlap@Sun.COM 	uint32_t		config_version;
3358062SPeter.Dunlap@Sun.COM 	it_tgt_t		*config_tgt_list;
3368062SPeter.Dunlap@Sun.COM 	uint32_t		config_tgt_count;
3378062SPeter.Dunlap@Sun.COM 	it_tpg_t		*config_tpg_list;
3388062SPeter.Dunlap@Sun.COM 	uint32_t		config_tpg_count;
3398062SPeter.Dunlap@Sun.COM 	it_ini_t		*config_ini_list;
3408062SPeter.Dunlap@Sun.COM 	uint32_t		config_ini_count;
3418062SPeter.Dunlap@Sun.COM 	it_portal_t		*config_isns_svr_list;
3428062SPeter.Dunlap@Sun.COM 	uint32_t		config_isns_svr_count;
3438062SPeter.Dunlap@Sun.COM 	nvlist_t		*config_global_properties;
3448062SPeter.Dunlap@Sun.COM } it_config_t;
3458062SPeter.Dunlap@Sun.COM 
3468062SPeter.Dunlap@Sun.COM 
3477978SPeter.Dunlap@Sun.COM /*  Functions to convert iSCSI target structures to/from nvlists. */
3487978SPeter.Dunlap@Sun.COM int
3497978SPeter.Dunlap@Sun.COM it_config_to_nv(it_config_t *cfg, nvlist_t **nvl);
3507978SPeter.Dunlap@Sun.COM 
3517978SPeter.Dunlap@Sun.COM /*
3527978SPeter.Dunlap@Sun.COM  * nvlist version of config is 3 list-of-list, + 1 proplist.  arrays
3537978SPeter.Dunlap@Sun.COM  * are interesting, but lists-of-lists are more useful when doing
3547978SPeter.Dunlap@Sun.COM  * individual lookups when we later add support for it.  Also, no
3557978SPeter.Dunlap@Sun.COM  * need to store name in individual struct representation.
3567978SPeter.Dunlap@Sun.COM  */
3577978SPeter.Dunlap@Sun.COM int
3587978SPeter.Dunlap@Sun.COM it_nv_to_config(nvlist_t *nvl, it_config_t **cfg);
3597978SPeter.Dunlap@Sun.COM 
3607978SPeter.Dunlap@Sun.COM int
3617978SPeter.Dunlap@Sun.COM it_nv_to_tgtlist(nvlist_t *nvl, uint32_t *count, it_tgt_t **tgtlist);
3627978SPeter.Dunlap@Sun.COM 
3637978SPeter.Dunlap@Sun.COM int
3647978SPeter.Dunlap@Sun.COM it_tgtlist_to_nv(it_tgt_t *tgtlist, nvlist_t **nvl);
3657978SPeter.Dunlap@Sun.COM 
3667978SPeter.Dunlap@Sun.COM int
3677978SPeter.Dunlap@Sun.COM it_tgt_to_nv(it_tgt_t *tgt, nvlist_t **nvl);
3687978SPeter.Dunlap@Sun.COM 
3697978SPeter.Dunlap@Sun.COM int
3707978SPeter.Dunlap@Sun.COM it_nv_to_tgt(nvlist_t *nvl, char *name, it_tgt_t **tgt);
3717978SPeter.Dunlap@Sun.COM 
3727978SPeter.Dunlap@Sun.COM int
3737978SPeter.Dunlap@Sun.COM it_tpgt_to_nv(it_tpgt_t *tpgt, nvlist_t **nvl);
3747978SPeter.Dunlap@Sun.COM 
3757978SPeter.Dunlap@Sun.COM int
3767978SPeter.Dunlap@Sun.COM it_nv_to_tpgt(nvlist_t *nvl, char *name, it_tpgt_t **tpgt);
3777978SPeter.Dunlap@Sun.COM 
3787978SPeter.Dunlap@Sun.COM int
3797978SPeter.Dunlap@Sun.COM it_tpgtlist_to_nv(it_tpgt_t *tpgtlist, nvlist_t **nvl);
3807978SPeter.Dunlap@Sun.COM 
3817978SPeter.Dunlap@Sun.COM int
3827978SPeter.Dunlap@Sun.COM it_nv_to_tpgtlist(nvlist_t *nvl, uint32_t *count, it_tpgt_t **tpgtlist);
3837978SPeter.Dunlap@Sun.COM 
3847978SPeter.Dunlap@Sun.COM int
3857978SPeter.Dunlap@Sun.COM it_tpg_to_nv(it_tpg_t *tpg, nvlist_t **nvl);
3867978SPeter.Dunlap@Sun.COM 
3877978SPeter.Dunlap@Sun.COM int
3887978SPeter.Dunlap@Sun.COM it_nv_to_tpg(nvlist_t *nvl, char *name, it_tpg_t **tpg);
3897978SPeter.Dunlap@Sun.COM 
3907978SPeter.Dunlap@Sun.COM int
3917978SPeter.Dunlap@Sun.COM it_tpglist_to_nv(it_tpg_t *tpglist, nvlist_t **nvl);
3927978SPeter.Dunlap@Sun.COM 
3937978SPeter.Dunlap@Sun.COM int
3947978SPeter.Dunlap@Sun.COM it_nv_to_tpglist(nvlist_t *nvl, uint32_t *count, it_tpg_t **tpglist);
3957978SPeter.Dunlap@Sun.COM 
3967978SPeter.Dunlap@Sun.COM int
3977978SPeter.Dunlap@Sun.COM it_ini_to_nv(it_ini_t *ini, nvlist_t **nvl);
3987978SPeter.Dunlap@Sun.COM 
3997978SPeter.Dunlap@Sun.COM int
4007978SPeter.Dunlap@Sun.COM it_nv_to_ini(nvlist_t *nvl, char *name, it_ini_t **ini);
4017978SPeter.Dunlap@Sun.COM 
4027978SPeter.Dunlap@Sun.COM int
4037978SPeter.Dunlap@Sun.COM it_inilist_to_nv(it_ini_t *inilist, nvlist_t **nvl);
4047978SPeter.Dunlap@Sun.COM 
4057978SPeter.Dunlap@Sun.COM int
4067978SPeter.Dunlap@Sun.COM it_nv_to_inilist(nvlist_t *nvl, uint32_t *count, it_ini_t **inilist);
4077978SPeter.Dunlap@Sun.COM 
4087978SPeter.Dunlap@Sun.COM it_tgt_t *
4097978SPeter.Dunlap@Sun.COM it_tgt_lookup(it_config_t *cfg, char *tgt_name);
4107978SPeter.Dunlap@Sun.COM 
4117978SPeter.Dunlap@Sun.COM it_tpg_t *
4127978SPeter.Dunlap@Sun.COM it_tpg_lookup(it_config_t *cfg, char *tpg_name);
4137978SPeter.Dunlap@Sun.COM 
4147978SPeter.Dunlap@Sun.COM it_portal_t *
4157978SPeter.Dunlap@Sun.COM it_sns_svr_lookup(it_config_t *cfg, struct sockaddr_storage *sa);
4167978SPeter.Dunlap@Sun.COM 
4177978SPeter.Dunlap@Sun.COM it_portal_t *
4187978SPeter.Dunlap@Sun.COM it_portal_lookup(it_tpg_t *cfg_tpg, struct sockaddr_storage *sa);
4197978SPeter.Dunlap@Sun.COM 
4207978SPeter.Dunlap@Sun.COM int
4217978SPeter.Dunlap@Sun.COM it_sa_compare(struct sockaddr_storage *sa1, struct sockaddr_storage *sa2);
4227978SPeter.Dunlap@Sun.COM 
4237978SPeter.Dunlap@Sun.COM /*
4247978SPeter.Dunlap@Sun.COM  * Convert a sockaddr to the string representation, suitable for
4257978SPeter.Dunlap@Sun.COM  * storing in an nvlist or printing out in a list.
4267978SPeter.Dunlap@Sun.COM  */
4277978SPeter.Dunlap@Sun.COM int
4287978SPeter.Dunlap@Sun.COM sockaddr_to_str(struct sockaddr_storage *sa, char **addr);
4297978SPeter.Dunlap@Sun.COM 
4307978SPeter.Dunlap@Sun.COM /*
4317978SPeter.Dunlap@Sun.COM  * Convert a char string to a sockaddr structure
4327978SPeter.Dunlap@Sun.COM  *
4337978SPeter.Dunlap@Sun.COM  * default_port should be the port to be used, if not specified
4347978SPeter.Dunlap@Sun.COM  * as part of the supplied string 'arg'.
4357978SPeter.Dunlap@Sun.COM  */
4367978SPeter.Dunlap@Sun.COM struct sockaddr_storage *
4377978SPeter.Dunlap@Sun.COM it_common_convert_sa(char *arg, struct sockaddr_storage *buf,
4387978SPeter.Dunlap@Sun.COM     uint32_t default_port);
4397978SPeter.Dunlap@Sun.COM 
4407978SPeter.Dunlap@Sun.COM /*
4417978SPeter.Dunlap@Sun.COM  * Convert an string array of IP-addr:port to a portal list
4427978SPeter.Dunlap@Sun.COM  */
4437978SPeter.Dunlap@Sun.COM int
4447978SPeter.Dunlap@Sun.COM it_array_to_portallist(char **arr, uint32_t count, uint32_t default_port,
4457978SPeter.Dunlap@Sun.COM     it_portal_t **portallist, uint32_t *list_count);
4467978SPeter.Dunlap@Sun.COM 
4477978SPeter.Dunlap@Sun.COM /*
4487978SPeter.Dunlap@Sun.COM  * Function:  it_config_free_cmn()
4497978SPeter.Dunlap@Sun.COM  *
4507978SPeter.Dunlap@Sun.COM  * Free any resources associated with the it_config_t structure.
4517978SPeter.Dunlap@Sun.COM  *
4527978SPeter.Dunlap@Sun.COM  * Parameters:
4537978SPeter.Dunlap@Sun.COM  *    cfg       A C representation of the current iSCSI configuration
4547978SPeter.Dunlap@Sun.COM  */
4557978SPeter.Dunlap@Sun.COM void
4567978SPeter.Dunlap@Sun.COM it_config_free_cmn(it_config_t *cfg);
4577978SPeter.Dunlap@Sun.COM 
4587978SPeter.Dunlap@Sun.COM /*
4597978SPeter.Dunlap@Sun.COM  * Function:  it_tgt_free_cmn()
4607978SPeter.Dunlap@Sun.COM  *
4617978SPeter.Dunlap@Sun.COM  * Frees an it_tgt_t structure.  If tgt_next is not NULL, frees
4627978SPeter.Dunlap@Sun.COM  * all structures in the list.
4637978SPeter.Dunlap@Sun.COM  */
4647978SPeter.Dunlap@Sun.COM void
4657978SPeter.Dunlap@Sun.COM it_tgt_free_cmn(it_tgt_t *tgt);
4667978SPeter.Dunlap@Sun.COM 
4677978SPeter.Dunlap@Sun.COM /*
4687978SPeter.Dunlap@Sun.COM  * Function:  it_tpgt_free_cmn()
4697978SPeter.Dunlap@Sun.COM  *
4707978SPeter.Dunlap@Sun.COM  * Deallocates resources of an it_tpgt_t structure.  If tpgt->next
4717978SPeter.Dunlap@Sun.COM  * is not NULL, frees all members of the list.
4727978SPeter.Dunlap@Sun.COM  */
4737978SPeter.Dunlap@Sun.COM void
4747978SPeter.Dunlap@Sun.COM it_tpgt_free_cmn(it_tpgt_t *tpgt);
4757978SPeter.Dunlap@Sun.COM 
4767978SPeter.Dunlap@Sun.COM /*
4777978SPeter.Dunlap@Sun.COM  * Function:  it_tpg_free_cmn()
4787978SPeter.Dunlap@Sun.COM  *
4797978SPeter.Dunlap@Sun.COM  * Deallocates resources associated with an it_tpg_t structure.
4807978SPeter.Dunlap@Sun.COM  * If tpg->next is not NULL, frees all members of the list.
4817978SPeter.Dunlap@Sun.COM  */
4827978SPeter.Dunlap@Sun.COM void
4837978SPeter.Dunlap@Sun.COM it_tpg_free_cmn(it_tpg_t *tpg);
4847978SPeter.Dunlap@Sun.COM 
4857978SPeter.Dunlap@Sun.COM /*
4867978SPeter.Dunlap@Sun.COM  * Function:  it_ini_free_cmn()
4877978SPeter.Dunlap@Sun.COM  *
4887978SPeter.Dunlap@Sun.COM  * Deallocates resources of an it_ini_t structure. If ini->next is
4897978SPeter.Dunlap@Sun.COM  * not NULL, frees all members of the list.
4907978SPeter.Dunlap@Sun.COM  */
4917978SPeter.Dunlap@Sun.COM void
4927978SPeter.Dunlap@Sun.COM it_ini_free_cmn(it_ini_t *ini);
4937978SPeter.Dunlap@Sun.COM 
4947978SPeter.Dunlap@Sun.COM /*
4957978SPeter.Dunlap@Sun.COM  * Function:  iscsi_binary_to_base64_str()
4967978SPeter.Dunlap@Sun.COM  *
4977978SPeter.Dunlap@Sun.COM  * Encodes a byte array into a base64 string.
4987978SPeter.Dunlap@Sun.COM  */
4997978SPeter.Dunlap@Sun.COM int
5007978SPeter.Dunlap@Sun.COM iscsi_binary_to_base64_str(uint8_t *in_buf, int in_buf_len,
5017978SPeter.Dunlap@Sun.COM     char *base64_str_buf, int base64_buf_len);
5027978SPeter.Dunlap@Sun.COM 
5037978SPeter.Dunlap@Sun.COM /*
5047978SPeter.Dunlap@Sun.COM  * Function:  iscsi_base64_str_to_binary()
5057978SPeter.Dunlap@Sun.COM  *
5067978SPeter.Dunlap@Sun.COM  * Decodes a base64 string into a byte array
5077978SPeter.Dunlap@Sun.COM  */
5087978SPeter.Dunlap@Sun.COM int
5097978SPeter.Dunlap@Sun.COM iscsi_base64_str_to_binary(char *hstr, int hstr_len,
5107978SPeter.Dunlap@Sun.COM     uint8_t *binary, int binary_buf_len, int *out_len);
5117978SPeter.Dunlap@Sun.COM 
5127978SPeter.Dunlap@Sun.COM #ifdef __cplusplus
5137978SPeter.Dunlap@Sun.COM }
5147978SPeter.Dunlap@Sun.COM #endif
5157978SPeter.Dunlap@Sun.COM 
5167978SPeter.Dunlap@Sun.COM #endif /* _ISCSIT_COMMON_H_ */
517