1*7978SPeter.Dunlap@Sun.COM /*
2*7978SPeter.Dunlap@Sun.COM  * CDDL HEADER START
3*7978SPeter.Dunlap@Sun.COM  *
4*7978SPeter.Dunlap@Sun.COM  * The contents of this file are subject to the terms of the
5*7978SPeter.Dunlap@Sun.COM  * Common Development and Distribution License (the "License").
6*7978SPeter.Dunlap@Sun.COM  * You may not use this file except in compliance with the License.
7*7978SPeter.Dunlap@Sun.COM  *
8*7978SPeter.Dunlap@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7978SPeter.Dunlap@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*7978SPeter.Dunlap@Sun.COM  * See the License for the specific language governing permissions
11*7978SPeter.Dunlap@Sun.COM  * and limitations under the License.
12*7978SPeter.Dunlap@Sun.COM  *
13*7978SPeter.Dunlap@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*7978SPeter.Dunlap@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7978SPeter.Dunlap@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*7978SPeter.Dunlap@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*7978SPeter.Dunlap@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*7978SPeter.Dunlap@Sun.COM  *
19*7978SPeter.Dunlap@Sun.COM  * CDDL HEADER END
20*7978SPeter.Dunlap@Sun.COM  */
21*7978SPeter.Dunlap@Sun.COM /*
22*7978SPeter.Dunlap@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*7978SPeter.Dunlap@Sun.COM  * Use is subject to license terms.
24*7978SPeter.Dunlap@Sun.COM  */
25*7978SPeter.Dunlap@Sun.COM 
26*7978SPeter.Dunlap@Sun.COM #ifndef	_LIBISCSIT_H
27*7978SPeter.Dunlap@Sun.COM #define	_LIBISCSIT_H
28*7978SPeter.Dunlap@Sun.COM 
29*7978SPeter.Dunlap@Sun.COM #ifndef _KERNEL
30*7978SPeter.Dunlap@Sun.COM #include <libnvpair.h>
31*7978SPeter.Dunlap@Sun.COM #include <sys/socket.h>
32*7978SPeter.Dunlap@Sun.COM #endif
33*7978SPeter.Dunlap@Sun.COM 
34*7978SPeter.Dunlap@Sun.COM #ifdef	__cplusplus
35*7978SPeter.Dunlap@Sun.COM extern "C" {
36*7978SPeter.Dunlap@Sun.COM #endif
37*7978SPeter.Dunlap@Sun.COM 
38*7978SPeter.Dunlap@Sun.COM #define	ISCSIT_MODNAME		"iscsit"
39*7978SPeter.Dunlap@Sun.COM #define	ISCSIT_NODE		"/devices/pseudo/iscsit@0:iscsit"
40*7978SPeter.Dunlap@Sun.COM 
41*7978SPeter.Dunlap@Sun.COM #define	MAX_TPGT	256
42*7978SPeter.Dunlap@Sun.COM #define	CFG_TPGTLIST	"tpgt-list"
43*7978SPeter.Dunlap@Sun.COM 
44*7978SPeter.Dunlap@Sun.COM /*
45*7978SPeter.Dunlap@Sun.COM  * Object Hierarchy
46*7978SPeter.Dunlap@Sun.COM  *
47*7978SPeter.Dunlap@Sun.COM  *  _______________________
48*7978SPeter.Dunlap@Sun.COM  * |                       |
49*7978SPeter.Dunlap@Sun.COM  * |  iSCSI Target Config  |
50*7978SPeter.Dunlap@Sun.COM  * |      it_config_t      |
51*7978SPeter.Dunlap@Sun.COM  * |_______________________|
52*7978SPeter.Dunlap@Sun.COM  *    |     |
53*7978SPeter.Dunlap@Sun.COM  *    |     |
54*7978SPeter.Dunlap@Sun.COM  *    |     |      ________     ________              ________
55*7978SPeter.Dunlap@Sun.COM  *    |     |     |        |   |        |            |        |
56*7978SPeter.Dunlap@Sun.COM  *    |     |     | Target |-->| Target |--  - -  -->| Target |
57*7978SPeter.Dunlap@Sun.COM  *    |     |     |________|   |________|            |________|
58*7978SPeter.Dunlap@Sun.COM  *    |     |           |
59*7978SPeter.Dunlap@Sun.COM  *    |     |           |
60*7978SPeter.Dunlap@Sun.COM  *    |     |           |
61*7978SPeter.Dunlap@Sun.COM  *    |     |           |       ______              ______
62*7978SPeter.Dunlap@Sun.COM  *    |     |           |      |      |            |      |
63*7978SPeter.Dunlap@Sun.COM  *    |     |           +----->| TPGT |--  - -  -->| TPGT |
64*7978SPeter.Dunlap@Sun.COM  *    |     |                  |______|            |______|
65*7978SPeter.Dunlap@Sun.COM  *    |     |                       |                   |
66*7978SPeter.Dunlap@Sun.COM  *    |  +--+                       |                   |
67*7978SPeter.Dunlap@Sun.COM  *    |  |   _______     _______    |         ______    |
68*7978SPeter.Dunlap@Sun.COM  *    |  |  |       |   |       |<--+        |      |<--+
69*7978SPeter.Dunlap@Sun.COM  *    |  +->|  TPG  |-->|  TPG  |--  - -  -->| TPG  |
70*7978SPeter.Dunlap@Sun.COM  *    |     |_______|   |_______|            |______|
71*7978SPeter.Dunlap@Sun.COM  *    |
72*7978SPeter.Dunlap@Sun.COM  *    |      ___________     ___________              ___________
73*7978SPeter.Dunlap@Sun.COM  *    |     |           |   |           |            |           |
74*7978SPeter.Dunlap@Sun.COM  *    +---->| Initiator |-->| Initiator |--  - -  -->| Initiator |
75*7978SPeter.Dunlap@Sun.COM  *          |  Context  |   |  Context  |            |  Context  |
76*7978SPeter.Dunlap@Sun.COM  *          |___________|   |___________|            |___________|
77*7978SPeter.Dunlap@Sun.COM  *
78*7978SPeter.Dunlap@Sun.COM  *
79*7978SPeter.Dunlap@Sun.COM  * it_config_t includes a list of global properties
80*7978SPeter.Dunlap@Sun.COM  *
81*7978SPeter.Dunlap@Sun.COM  * Targets include a list of properties which override the global properties
82*7978SPeter.Dunlap@Sun.COM  * if set
83*7978SPeter.Dunlap@Sun.COM  *
84*7978SPeter.Dunlap@Sun.COM  * Initiators also include a list of properties but never inherit properties
85*7978SPeter.Dunlap@Sun.COM  * from the global config.
86*7978SPeter.Dunlap@Sun.COM  */
87*7978SPeter.Dunlap@Sun.COM 
88*7978SPeter.Dunlap@Sun.COM /*  Maximum size of a Target Portal Group name */
89*7978SPeter.Dunlap@Sun.COM #define	MAX_TPG_NAMELEN		256		/* XXX */
90*7978SPeter.Dunlap@Sun.COM 
91*7978SPeter.Dunlap@Sun.COM /* Maximum size of an iSCSI Target Node name */
92*7978SPeter.Dunlap@Sun.COM #define	MAX_ISCSI_NODENAMELEN	256		/* XXX */
93*7978SPeter.Dunlap@Sun.COM 
94*7978SPeter.Dunlap@Sun.COM /*
95*7978SPeter.Dunlap@Sun.COM  * A target portal group tag is a binding between a target and a target
96*7978SPeter.Dunlap@Sun.COM  * portal group along with a numerical value associated with that binding.
97*7978SPeter.Dunlap@Sun.COM  * The numerical identifier is used as the 'target portal group tag' defined
98*7978SPeter.Dunlap@Sun.COM  * in RFC3720.
99*7978SPeter.Dunlap@Sun.COM  *
100*7978SPeter.Dunlap@Sun.COM  *  tpgt_tpg_name	The name of the target portal group associated with
101*7978SPeter.Dunlap@Sun.COM  *			this target portal group tag.
102*7978SPeter.Dunlap@Sun.COM  *  tpgt_generation	Generation number which is incremented each time the
103*7978SPeter.Dunlap@Sun.COM  *			structure changes.
104*7978SPeter.Dunlap@Sun.COM  *  tpgt_next		Next target portal group tag in th list of target portal
105*7978SPeter.Dunlap@Sun.COM  *			group tags.  If tpgt_next is NUL, then this is the last
106*7978SPeter.Dunlap@Sun.COM  *			target portal group in the list.
107*7978SPeter.Dunlap@Sun.COM  *  tpgt_tag		A numerical identifier that uniquely identifies a
108*7978SPeter.Dunlap@Sun.COM  *			target portal group within the associated target node.
109*7978SPeter.Dunlap@Sun.COM  */
110*7978SPeter.Dunlap@Sun.COM typedef struct it_tpgt_s {
111*7978SPeter.Dunlap@Sun.COM 	char			tpgt_tpg_name[MAX_TPG_NAMELEN];
112*7978SPeter.Dunlap@Sun.COM 	uint64_t		tpgt_generation;
113*7978SPeter.Dunlap@Sun.COM 	struct it_tpgt_s	*tpgt_next;
114*7978SPeter.Dunlap@Sun.COM 	uint16_t		tpgt_tag;
115*7978SPeter.Dunlap@Sun.COM } it_tpgt_t;
116*7978SPeter.Dunlap@Sun.COM 
117*7978SPeter.Dunlap@Sun.COM /*
118*7978SPeter.Dunlap@Sun.COM  * An iSCSI target node is represented by an it_tgt_structure.  Each
119*7978SPeter.Dunlap@Sun.COM  * target node includes a list of associated target portal group tags
120*7978SPeter.Dunlap@Sun.COM  * and a list of properties.
121*7978SPeter.Dunlap@Sun.COM  *
122*7978SPeter.Dunlap@Sun.COM  *  tgt_name		The iSCSI target node name in either IQN or EUI
123*7978SPeter.Dunlap@Sun.COM  *			format (see RFC3720).
124*7978SPeter.Dunlap@Sun.COM  *  tgt_generation	Generation number which is incremented each time
125*7978SPeter.Dunlap@Sun.COM  *			the structure changes.
126*7978SPeter.Dunlap@Sun.COM  *  tgt_next		Next target in the list of targets.  If tgt_next
127*7978SPeter.Dunlap@Sun.COM  *			is NULL, then this is the last target in the list.
128*7978SPeter.Dunlap@Sun.COM  *  tgt_tpgt_list	A linked list representing the current target
129*7978SPeter.Dunlap@Sun.COM  *			portal group tags associated with this target.
130*7978SPeter.Dunlap@Sun.COM  *  tgt_tpgt_count	The number of currently defined target portal
131*7978SPeter.Dunlap@Sun.COM  *			group tags.
132*7978SPeter.Dunlap@Sun.COM  *  tgt_properties	An nvlist representation of the properties
133*7978SPeter.Dunlap@Sun.COM  *			associated with this target.  This list can be
134*7978SPeter.Dunlap@Sun.COM  *			manipulated using libnvpair(3lib), and should be
135*7978SPeter.Dunlap@Sun.COM  *			validated and stored using it_tgt_setprop().
136*7978SPeter.Dunlap@Sun.COM  *
137*7978SPeter.Dunlap@Sun.COM  * Target nvlist Properties:
138*7978SPeter.Dunlap@Sun.COM  *
139*7978SPeter.Dunlap@Sun.COM  *  nvlist Key		Type		Valid Values
140*7978SPeter.Dunlap@Sun.COM  *  --------------------------------------------------------------------
141*7978SPeter.Dunlap@Sun.COM  *  targetchapuser	string		any string or "none" to remove
142*7978SPeter.Dunlap@Sun.COM  *  targetchapsecret	string		string of at least 12 characters
143*7978SPeter.Dunlap@Sun.COM  *					but not more than 255 characters.
144*7978SPeter.Dunlap@Sun.COM  *					secret will be base64 encoded when
145*7978SPeter.Dunlap@Sun.COM  *					stored.
146*7978SPeter.Dunlap@Sun.COM  *  alias		string		any string or "none" to remove
147*7978SPeter.Dunlap@Sun.COM  *  auth		string		"radius", "chap", or "none"
148*7978SPeter.Dunlap@Sun.COM  *
149*7978SPeter.Dunlap@Sun.COM  */
150*7978SPeter.Dunlap@Sun.COM typedef struct it_tgt_s {
151*7978SPeter.Dunlap@Sun.COM 	char			tgt_name[MAX_ISCSI_NODENAMELEN];
152*7978SPeter.Dunlap@Sun.COM 	uint64_t		tgt_generation;
153*7978SPeter.Dunlap@Sun.COM 	struct it_tgt_s		*tgt_next;
154*7978SPeter.Dunlap@Sun.COM 	it_tpgt_t		*tgt_tpgt_list;
155*7978SPeter.Dunlap@Sun.COM 	uint32_t		tgt_tpgt_count;
156*7978SPeter.Dunlap@Sun.COM 	nvlist_t		*tgt_properties;
157*7978SPeter.Dunlap@Sun.COM } it_tgt_t;
158*7978SPeter.Dunlap@Sun.COM 
159*7978SPeter.Dunlap@Sun.COM /*
160*7978SPeter.Dunlap@Sun.COM  * A target portal is represented by an IP address and a listening
161*7978SPeter.Dunlap@Sun.COM  * TCP port.
162*7978SPeter.Dunlap@Sun.COM  *
163*7978SPeter.Dunlap@Sun.COM  *  portal_addr		sockaddr_storage structure representing the
164*7978SPeter.Dunlap@Sun.COM  *			IPv4 or IPv6 address and TCP port associated
165*7978SPeter.Dunlap@Sun.COM  *			with the portal.
166*7978SPeter.Dunlap@Sun.COM  *  portal_next		Next portal in the list of portals.  If
167*7978SPeter.Dunlap@Sun.COM  *			portal_next is NULL, this is the last portal
168*7978SPeter.Dunlap@Sun.COM  *			in the list.
169*7978SPeter.Dunlap@Sun.COM  */
170*7978SPeter.Dunlap@Sun.COM typedef struct it_portal_s {
171*7978SPeter.Dunlap@Sun.COM 	struct sockaddr_storage portal_addr;
172*7978SPeter.Dunlap@Sun.COM 	struct it_portal_s	*next;
173*7978SPeter.Dunlap@Sun.COM } it_portal_t;
174*7978SPeter.Dunlap@Sun.COM 
175*7978SPeter.Dunlap@Sun.COM /*
176*7978SPeter.Dunlap@Sun.COM  * A portal is an IP address and TCP port and a portal group is a set
177*7978SPeter.Dunlap@Sun.COM  * of portals.  Each defined portal belongs to exactly one portal group.
178*7978SPeter.Dunlap@Sun.COM  * Applications can associate a target portal group with a particular
179*7978SPeter.Dunlap@Sun.COM  * target using a target portal group name.  Initiators can only connect
180*7978SPeter.Dunlap@Sun.COM  * to targets through the portals associated with the target's target
181*7978SPeter.Dunlap@Sun.COM  * portal group tags.
182*7978SPeter.Dunlap@Sun.COM  *
183*7978SPeter.Dunlap@Sun.COM  *  tpg_name		Identifier for the target portal group.
184*7978SPeter.Dunlap@Sun.COM  *  tpg_generation	Generation number which is incremented each
185*7978SPeter.Dunlap@Sun.COM  *			time this structure changes.
186*7978SPeter.Dunlap@Sun.COM  *  tpg_next		Next target portal group in the list of target
187*7978SPeter.Dunlap@Sun.COM  *			portal groups.  If tpg_next is NULL, this is the
188*7978SPeter.Dunlap@Sun.COM  *			last target portal group in the list.
189*7978SPeter.Dunlap@Sun.COM  *  tpg_portal_count	Number of it_portal_t structures in the list.
190*7978SPeter.Dunlap@Sun.COM  *  tpg_portal_list	Linked list of it_portal_t structures.
191*7978SPeter.Dunlap@Sun.COM  */
192*7978SPeter.Dunlap@Sun.COM typedef struct it_tpg_s {
193*7978SPeter.Dunlap@Sun.COM 	char			tpg_name[MAX_TPG_NAMELEN];
194*7978SPeter.Dunlap@Sun.COM 	uint64_t		tpg_generation;
195*7978SPeter.Dunlap@Sun.COM 	struct it_tpg_s		*tpg_next;
196*7978SPeter.Dunlap@Sun.COM 	uint32_t		tpg_portal_count;
197*7978SPeter.Dunlap@Sun.COM 	it_portal_t		*tpg_portal_list;
198*7978SPeter.Dunlap@Sun.COM } it_tpg_t;
199*7978SPeter.Dunlap@Sun.COM 
200*7978SPeter.Dunlap@Sun.COM /*
201*7978SPeter.Dunlap@Sun.COM  * A context representing a remote iSCSI initiator node.  The purpose
202*7978SPeter.Dunlap@Sun.COM  * of this structure is to maintain information specific to a remote
203*7978SPeter.Dunlap@Sun.COM  * initiator such as the CHAP username and CHAP secret.
204*7978SPeter.Dunlap@Sun.COM  *
205*7978SPeter.Dunlap@Sun.COM  *  ini_name		the iSCSI node name of the remote initiator.
206*7978SPeter.Dunlap@Sun.COM  *  ini_generation	Generation number which is incremented each
207*7978SPeter.Dunlap@Sun.COM  *			time this structure changes.
208*7978SPeter.Dunlap@Sun.COM  *  ini_next		Next initiator in the list of initiators.
209*7978SPeter.Dunlap@Sun.COM  *			If ini_next is NULL, this is the last initiator
210*7978SPeter.Dunlap@Sun.COM  *			in the list.
211*7978SPeter.Dunlap@Sun.COM  *  ini_properties	Name/Value list containing the properties
212*7978SPeter.Dunlap@Sun.COM  *			associated with the initiator context.  This list
213*7978SPeter.Dunlap@Sun.COM  *			can be manipulated using libnvpair(3lib), and should
214*7978SPeter.Dunlap@Sun.COM  *			be validated and stored using it_ini_setprop().
215*7978SPeter.Dunlap@Sun.COM  *
216*7978SPeter.Dunlap@Sun.COM  * Initiator nvlist Properties:
217*7978SPeter.Dunlap@Sun.COM  *
218*7978SPeter.Dunlap@Sun.COM  *  nvlist Key		Type		Valid Values
219*7978SPeter.Dunlap@Sun.COM  *  --------------------------------------------------------------------
220*7978SPeter.Dunlap@Sun.COM  *  chapuser		string		any string
221*7978SPeter.Dunlap@Sun.COM  *  chapsecret		string		string of at least 12 characters
222*7978SPeter.Dunlap@Sun.COM  *					but not more than 255 characters.
223*7978SPeter.Dunlap@Sun.COM  *					secret will be base64 encoded when
224*7978SPeter.Dunlap@Sun.COM  *					stored.
225*7978SPeter.Dunlap@Sun.COM  */
226*7978SPeter.Dunlap@Sun.COM typedef struct it_ini_s {
227*7978SPeter.Dunlap@Sun.COM 	char		ini_name[MAX_ISCSI_NODENAMELEN];
228*7978SPeter.Dunlap@Sun.COM 	uint64_t	ini_generation;
229*7978SPeter.Dunlap@Sun.COM 	struct it_ini_s	*ini_next;
230*7978SPeter.Dunlap@Sun.COM 	nvlist_t	*ini_properties;
231*7978SPeter.Dunlap@Sun.COM } it_ini_t;
232*7978SPeter.Dunlap@Sun.COM 
233*7978SPeter.Dunlap@Sun.COM 
234*7978SPeter.Dunlap@Sun.COM /*
235*7978SPeter.Dunlap@Sun.COM  * This structure represents a complete configuration for the iscsit
236*7978SPeter.Dunlap@Sun.COM  * port provider.  In addition to the global configuration, it_config_t
237*7978SPeter.Dunlap@Sun.COM  * includes lists of child objects including targets, target portal
238*7978SPeter.Dunlap@Sun.COM  * groups and initiator contexts.  Each object includes a "generation"
239*7978SPeter.Dunlap@Sun.COM  * value which is used by the iscsit kernel driver to identify changes
240*7978SPeter.Dunlap@Sun.COM  * from one configuration update to the next.
241*7978SPeter.Dunlap@Sun.COM  *
242*7978SPeter.Dunlap@Sun.COM  *  stmf_token		A uint64_t that contains the value returned from a
243*7978SPeter.Dunlap@Sun.COM  *			successful call to stmfGetProviderDataProt(3STMF).
244*7978SPeter.Dunlap@Sun.COM  *			This token is used to verify that the configuration
245*7978SPeter.Dunlap@Sun.COM  *			data persistently stored in COMSTAR has not been
246*7978SPeter.Dunlap@Sun.COM  *			modified since this version was loaded.
247*7978SPeter.Dunlap@Sun.COM  *  config_version	Version number for this configuration structure
248*7978SPeter.Dunlap@Sun.COM  *  config_tgt_list	Linked list of target contexts representing the
249*7978SPeter.Dunlap@Sun.COM  *			currently defined targets.  Applications can add
250*7978SPeter.Dunlap@Sun.COM  *			targets to or remove targets from this list using
251*7978SPeter.Dunlap@Sun.COM  *			the it_tgt_create and it_tgt_delete functions.
252*7978SPeter.Dunlap@Sun.COM  *  config_tgt_count	The number of currently defined targets.
253*7978SPeter.Dunlap@Sun.COM  *  config_tpg_list	Linked list of target portal group contexts.
254*7978SPeter.Dunlap@Sun.COM  *			Applications can add or remove target portal groups
255*7978SPeter.Dunlap@Sun.COM  *			to/from this list using the it_tpg_create and
256*7978SPeter.Dunlap@Sun.COM  *			it_tpg_delete functions.
257*7978SPeter.Dunlap@Sun.COM  *  config_tpg_count	The number of currently defined target portal groups
258*7978SPeter.Dunlap@Sun.COM  *  config_ini_list	Linked list of initiator contexts.  Applications
259*7978SPeter.Dunlap@Sun.COM  *			can add initiator contexts or remove initiator
260*7978SPeter.Dunlap@Sun.COM  *			contexts from this list using the it_ini_create
261*7978SPeter.Dunlap@Sun.COM  *			and it_ini_delete functions.
262*7978SPeter.Dunlap@Sun.COM  *  config_ini_count	The number of currently defined initiator contexts.
263*7978SPeter.Dunlap@Sun.COM  *  config_global_properties
264*7978SPeter.Dunlap@Sun.COM  *			Name/Value list representing the current global
265*7978SPeter.Dunlap@Sun.COM  *			property settings.  This list can be manipulated
266*7978SPeter.Dunlap@Sun.COM  *			using libnvpair(3lib), and should be validated
267*7978SPeter.Dunlap@Sun.COM  *			and stored using it_config_setprop().
268*7978SPeter.Dunlap@Sun.COM  *  config_isns_svr_list
269*7978SPeter.Dunlap@Sun.COM  *			Linked list of currently defined iSNS servers.
270*7978SPeter.Dunlap@Sun.COM  *			Applications can add or remove iSNS servers by
271*7978SPeter.Dunlap@Sun.COM  *			using the it_config_setprop() function and changing
272*7978SPeter.Dunlap@Sun.COM  *			the array of iSNS servers stored in the "isnsserver"
273*7978SPeter.Dunlap@Sun.COM  *			property.
274*7978SPeter.Dunlap@Sun.COM  *  config_isns_svr_count
275*7978SPeter.Dunlap@Sun.COM  *			The number of currently defined iSNS servers.
276*7978SPeter.Dunlap@Sun.COM  *
277*7978SPeter.Dunlap@Sun.COM  * Global nvlist Properties:
278*7978SPeter.Dunlap@Sun.COM  *
279*7978SPeter.Dunlap@Sun.COM  *  nvlist Key		Type		Valid Values
280*7978SPeter.Dunlap@Sun.COM  *  --------------------------------------------------------------------
281*7978SPeter.Dunlap@Sun.COM  *  alias		string		any string
282*7978SPeter.Dunlap@Sun.COM  *  auth		string		"radius", "chap", or "none"
283*7978SPeter.Dunlap@Sun.COM  *  isns		boolean		B_TRUE, B_FALSE
284*7978SPeter.Dunlap@Sun.COM  *  isnsserver		string array	Array of portal specifications of
285*7978SPeter.Dunlap@Sun.COM  *					the form IPaddress:port.  Port
286*7978SPeter.Dunlap@Sun.COM  *					is optional; if not specified, the
287*7978SPeter.Dunlap@Sun.COM  *					default iSNS port number of 3205 will
288*7978SPeter.Dunlap@Sun.COM  *					be used.  IPv6 addresses should
289*7978SPeter.Dunlap@Sun.COM  *					be enclosed in square brackets '[' ']'.
290*7978SPeter.Dunlap@Sun.COM  *					If "none" is specified, all defined
291*7978SPeter.Dunlap@Sun.COM  *					iSNS servers will be removed from the
292*7978SPeter.Dunlap@Sun.COM  *					configuration.
293*7978SPeter.Dunlap@Sun.COM  *  radiusserver	string		IPaddress:port specification as
294*7978SPeter.Dunlap@Sun.COM  *					described for 'isnsserver'.
295*7978SPeter.Dunlap@Sun.COM  *  radiussecret	string		string of at least 12 characters
296*7978SPeter.Dunlap@Sun.COM  *					but not more than 255 characters.
297*7978SPeter.Dunlap@Sun.COM  *					secret will be base64 encoded when
298*7978SPeter.Dunlap@Sun.COM  *					stored.
299*7978SPeter.Dunlap@Sun.COM  */
300*7978SPeter.Dunlap@Sun.COM typedef struct it_config_s {
301*7978SPeter.Dunlap@Sun.COM 	uint64_t		stmf_token;
302*7978SPeter.Dunlap@Sun.COM 	uint32_t		config_version;
303*7978SPeter.Dunlap@Sun.COM 	it_tgt_t		*config_tgt_list;
304*7978SPeter.Dunlap@Sun.COM 	uint32_t		config_tgt_count;
305*7978SPeter.Dunlap@Sun.COM 	it_tpg_t		*config_tpg_list;
306*7978SPeter.Dunlap@Sun.COM 	uint32_t		config_tpg_count;
307*7978SPeter.Dunlap@Sun.COM 	it_ini_t		*config_ini_list;
308*7978SPeter.Dunlap@Sun.COM 	uint32_t		config_ini_count;
309*7978SPeter.Dunlap@Sun.COM 	it_portal_t		*config_isns_svr_list;
310*7978SPeter.Dunlap@Sun.COM 	uint32_t		config_isns_svr_count;
311*7978SPeter.Dunlap@Sun.COM 	nvlist_t		*config_global_properties;
312*7978SPeter.Dunlap@Sun.COM } it_config_t;
313*7978SPeter.Dunlap@Sun.COM 
314*7978SPeter.Dunlap@Sun.COM /*
315*7978SPeter.Dunlap@Sun.COM  * Function:  it_config_load()
316*7978SPeter.Dunlap@Sun.COM  *
317*7978SPeter.Dunlap@Sun.COM  * Allocate and create an it_config_t structure representing the
318*7978SPeter.Dunlap@Sun.COM  * current iSCSI configuration.  This structure is compiled using
319*7978SPeter.Dunlap@Sun.COM  * the 'provider' data returned by stmfGetProviderData().  If there
320*7978SPeter.Dunlap@Sun.COM  * is no provider data associated with iscsit, the it_config_t
321*7978SPeter.Dunlap@Sun.COM  * structure will be set to a default configuration.
322*7978SPeter.Dunlap@Sun.COM  *
323*7978SPeter.Dunlap@Sun.COM  * Parameters:
324*7978SPeter.Dunlap@Sun.COM  *    cfg		A C representation of the current iSCSI configuration
325*7978SPeter.Dunlap@Sun.COM  *
326*7978SPeter.Dunlap@Sun.COM  * Return Values:
327*7978SPeter.Dunlap@Sun.COM  *    0			Success
328*7978SPeter.Dunlap@Sun.COM  *    ENOMEM		Could not allocate resources
329*7978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid parameter
330*7978SPeter.Dunlap@Sun.COM  */
331*7978SPeter.Dunlap@Sun.COM int
332*7978SPeter.Dunlap@Sun.COM it_config_load(it_config_t **cfg);
333*7978SPeter.Dunlap@Sun.COM 
334*7978SPeter.Dunlap@Sun.COM /*
335*7978SPeter.Dunlap@Sun.COM  * Function:  it_config_commit()
336*7978SPeter.Dunlap@Sun.COM  *
337*7978SPeter.Dunlap@Sun.COM  * Informs the iscsit service that the configuration has changed and
338*7978SPeter.Dunlap@Sun.COM  * commits the new configuration to persistent store by calling
339*7978SPeter.Dunlap@Sun.COM  * stmfSetProviderData.  This function can be called multiple times
340*7978SPeter.Dunlap@Sun.COM  * during a configuration sequence if necessary.
341*7978SPeter.Dunlap@Sun.COM  *
342*7978SPeter.Dunlap@Sun.COM  * Parameters:
343*7978SPeter.Dunlap@Sun.COM  *    cfg		A C representation of the current iSCSI configuration
344*7978SPeter.Dunlap@Sun.COM  *
345*7978SPeter.Dunlap@Sun.COM  * Return Values:
346*7978SPeter.Dunlap@Sun.COM  *    0			Success
347*7978SPeter.Dunlap@Sun.COM  *    ENOMEM		Could not allocate resources
348*7978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid it_config_t structure
349*7978SPeter.Dunlap@Sun.COM  *    STMF_ERROR_SERVICE_DATA_VERSION	Configuration was updated by another
350*7978SPeter.Dunlap@Sun.COM  *			client.  See stmfSetProviderDataProt().
351*7978SPeter.Dunlap@Sun.COM  */
352*7978SPeter.Dunlap@Sun.COM int
353*7978SPeter.Dunlap@Sun.COM it_config_commit(it_config_t *cfg);
354*7978SPeter.Dunlap@Sun.COM 
355*7978SPeter.Dunlap@Sun.COM /*
356*7978SPeter.Dunlap@Sun.COM  * Function:  it_config_setprop()
357*7978SPeter.Dunlap@Sun.COM  *
358*7978SPeter.Dunlap@Sun.COM  * Validate the provided property list and set the global properties
359*7978SPeter.Dunlap@Sun.COM  * for iSCSI Target.  If errlist is not NULL, returns detailed
360*7978SPeter.Dunlap@Sun.COM  * errors for each property that failed.  The format for errorlist
361*7978SPeter.Dunlap@Sun.COM  * is key = property, value = error string.
362*7978SPeter.Dunlap@Sun.COM  *
363*7978SPeter.Dunlap@Sun.COM  * Parameters:
364*7978SPeter.Dunlap@Sun.COM  *
365*7978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configuration obtained from
366*7978SPeter.Dunlap@Sun.COM  *			it_config_load()
367*7978SPeter.Dunlap@Sun.COM  *    proplist		nvlist_t containing properties for this target.
368*7978SPeter.Dunlap@Sun.COM  *    errlist		(optional)  nvlist_t of errors encountered when
369*7978SPeter.Dunlap@Sun.COM  *			validating the properties.
370*7978SPeter.Dunlap@Sun.COM  *
371*7978SPeter.Dunlap@Sun.COM  * Return Values:
372*7978SPeter.Dunlap@Sun.COM  *    0			Success
373*7978SPeter.Dunlap@Sun.COM  *    ENOMEM		Could not allocate resources
374*7978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid property
375*7978SPeter.Dunlap@Sun.COM  *
376*7978SPeter.Dunlap@Sun.COM  */
377*7978SPeter.Dunlap@Sun.COM int
378*7978SPeter.Dunlap@Sun.COM it_config_setprop(it_config_t *cfg, nvlist_t *proplist, nvlist_t **errlist);
379*7978SPeter.Dunlap@Sun.COM 
380*7978SPeter.Dunlap@Sun.COM /*
381*7978SPeter.Dunlap@Sun.COM  * Function:  it_config_free()
382*7978SPeter.Dunlap@Sun.COM  *
383*7978SPeter.Dunlap@Sun.COM  * Free any resources associated with the it_config_t structure.
384*7978SPeter.Dunlap@Sun.COM  *
385*7978SPeter.Dunlap@Sun.COM  * Parameters:
386*7978SPeter.Dunlap@Sun.COM  *    cfg		A C representation of the current iSCSI configuration
387*7978SPeter.Dunlap@Sun.COM  */
388*7978SPeter.Dunlap@Sun.COM void
389*7978SPeter.Dunlap@Sun.COM it_config_free(it_config_t *cfg);
390*7978SPeter.Dunlap@Sun.COM 
391*7978SPeter.Dunlap@Sun.COM /*
392*7978SPeter.Dunlap@Sun.COM  * Function:  it_tgt_create()
393*7978SPeter.Dunlap@Sun.COM  *
394*7978SPeter.Dunlap@Sun.COM  * Allocate and create an it_tgt_t structure representing a new iSCSI
395*7978SPeter.Dunlap@Sun.COM  * target node.  If tgt_name is NULL, then a unique target node name will
396*7978SPeter.Dunlap@Sun.COM  * be generated automatically.  Otherwise, the value of tgt_name will be
397*7978SPeter.Dunlap@Sun.COM  * used as the target node name.  The new it_tgt_t structure is added to
398*7978SPeter.Dunlap@Sun.COM  * the target list (cfg_tgt_list) in the configuration structure, and the
399*7978SPeter.Dunlap@Sun.COM  * new target will not be instantiated until the modified configuration
400*7978SPeter.Dunlap@Sun.COM  * is committed by calling it_config_commit().
401*7978SPeter.Dunlap@Sun.COM  *
402*7978SPeter.Dunlap@Sun.COM  * Parameters:
403*7978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configuration obtained from
404*7978SPeter.Dunlap@Sun.COM  *			it_config_load()
405*7978SPeter.Dunlap@Sun.COM  *    tgt		Pointer to an iSCSI target structure
406*7978SPeter.Dunlap@Sun.COM  *    tgt_name		The target node name for the target to be created.
407*7978SPeter.Dunlap@Sun.COM  *			The name must be in either IQN or EUI format.  If
408*7978SPeter.Dunlap@Sun.COM  *			this value is NULL, a node name will be generated
409*7978SPeter.Dunlap@Sun.COM  *			automatically in IQN format.
410*7978SPeter.Dunlap@Sun.COM  *
411*7978SPeter.Dunlap@Sun.COM  * Return Values:
412*7978SPeter.Dunlap@Sun.COM  *    0			Success
413*7978SPeter.Dunlap@Sun.COM  *    ENOMEM		Could not allocate resources
414*7978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid parameter
415*7978SPeter.Dunlap@Sun.COM  *    EEXIST		The requested target node name is already configured
416*7978SPeter.Dunlap@Sun.COM  *    EFAULT		Invalid iSCSI target name
417*7978SPeter.Dunlap@Sun.COM  */
418*7978SPeter.Dunlap@Sun.COM int
419*7978SPeter.Dunlap@Sun.COM it_tgt_create(it_config_t *cfg, it_tgt_t **tgt, char *tgt_name);
420*7978SPeter.Dunlap@Sun.COM 
421*7978SPeter.Dunlap@Sun.COM /*
422*7978SPeter.Dunlap@Sun.COM  * Function:  it_tgt_setprop()
423*7978SPeter.Dunlap@Sun.COM  *
424*7978SPeter.Dunlap@Sun.COM  * Validate the provided property list and set the properties for
425*7978SPeter.Dunlap@Sun.COM  * the specified target.  If errlist is not NULL, returns detailed
426*7978SPeter.Dunlap@Sun.COM  * errors for each property that failed.  The format for errorlist
427*7978SPeter.Dunlap@Sun.COM  * is key = property, value = error string.
428*7978SPeter.Dunlap@Sun.COM  *
429*7978SPeter.Dunlap@Sun.COM  * Parameters:
430*7978SPeter.Dunlap@Sun.COM  *
431*7978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configuration obtained from
432*7978SPeter.Dunlap@Sun.COM  *			it_config_load()
433*7978SPeter.Dunlap@Sun.COM  *    tgt		Pointer to an iSCSI target structure
434*7978SPeter.Dunlap@Sun.COM  *    proplist		nvlist_t containing properties for this target.
435*7978SPeter.Dunlap@Sun.COM  *    errlist		(optional)  nvlist_t of errors encountered when
436*7978SPeter.Dunlap@Sun.COM  *			validating the properties.
437*7978SPeter.Dunlap@Sun.COM  *
438*7978SPeter.Dunlap@Sun.COM  * Return Values:
439*7978SPeter.Dunlap@Sun.COM  *    0			Success
440*7978SPeter.Dunlap@Sun.COM  *    ENOMEM		Could not allocate resources
441*7978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid property
442*7978SPeter.Dunlap@Sun.COM  *
443*7978SPeter.Dunlap@Sun.COM  */
444*7978SPeter.Dunlap@Sun.COM int
445*7978SPeter.Dunlap@Sun.COM it_tgt_setprop(it_config_t *cfg, it_tgt_t *tgt, nvlist_t *proplist,
446*7978SPeter.Dunlap@Sun.COM     nvlist_t **errlist);
447*7978SPeter.Dunlap@Sun.COM 
448*7978SPeter.Dunlap@Sun.COM 
449*7978SPeter.Dunlap@Sun.COM /*
450*7978SPeter.Dunlap@Sun.COM  * Function:  it_tgt_delete()
451*7978SPeter.Dunlap@Sun.COM  *
452*7978SPeter.Dunlap@Sun.COM  * Delete target represented by 'tgt', where 'tgt' is an existing
453*7978SPeter.Dunlap@Sun.COM  * it_tgt_t structure within the configuration 'cfg'.  The target removal
454*7978SPeter.Dunlap@Sun.COM  * will not take effect until the modified configuration is committed
455*7978SPeter.Dunlap@Sun.COM  * by calling it_config_commit().
456*7978SPeter.Dunlap@Sun.COM  *
457*7978SPeter.Dunlap@Sun.COM  * Parameters:
458*7978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configuration obtained from
459*7978SPeter.Dunlap@Sun.COM  *			it_config_load()
460*7978SPeter.Dunlap@Sun.COM  *    tgt		Pointer to an iSCSI target structure
461*7978SPeter.Dunlap@Sun.COM  *    force		Set the target to offline before removing it from
462*7978SPeter.Dunlap@Sun.COM  *			the config.  If not specified, the operation will
463*7978SPeter.Dunlap@Sun.COM  *			fail if the target is determined to be online.
464*7978SPeter.Dunlap@Sun.COM  *
465*7978SPeter.Dunlap@Sun.COM  * Return Values:
466*7978SPeter.Dunlap@Sun.COM  *    0			Success
467*7978SPeter.Dunlap@Sun.COM  *    EBUSY		Target is online
468*7978SPeter.Dunlap@Sun.COM  */
469*7978SPeter.Dunlap@Sun.COM int
470*7978SPeter.Dunlap@Sun.COM it_tgt_delete(it_config_t *cfg, it_tgt_t *tgt, boolean_t force);
471*7978SPeter.Dunlap@Sun.COM 
472*7978SPeter.Dunlap@Sun.COM /*
473*7978SPeter.Dunlap@Sun.COM  * Function:  it_tpgt_create()
474*7978SPeter.Dunlap@Sun.COM  *
475*7978SPeter.Dunlap@Sun.COM  * Allocate and create an it_tpgt_t structure representing a new iSCSI
476*7978SPeter.Dunlap@Sun.COM  * target portal group tag.  The new it_tpgt_t structure is added to the
477*7978SPeter.Dunlap@Sun.COM  * target tpgt list (tgt_tpgt_list) in the it_tgt_t structure.  The new
478*7978SPeter.Dunlap@Sun.COM  * target portal group tag will not be instantiated until the modified
479*7978SPeter.Dunlap@Sun.COM  * configuration is committed by calling it_config_commit().
480*7978SPeter.Dunlap@Sun.COM  *
481*7978SPeter.Dunlap@Sun.COM  * Parameters:
482*7978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configuration obtained from
483*7978SPeter.Dunlap@Sun.COM  *			it_config_load()
484*7978SPeter.Dunlap@Sun.COM  *    tgt		Pointer to the iSCSI target structure associated
485*7978SPeter.Dunlap@Sun.COM  *			with the target portal group tag
486*7978SPeter.Dunlap@Sun.COM  *    tpgt		Pointer to a target portal group tag structure
487*7978SPeter.Dunlap@Sun.COM  *    tpg_name		The name of the TPG to be associated with this TPGT
488*7978SPeter.Dunlap@Sun.COM  *    tpgt_tag		16-bit numerical identifier for this TPGT.  Valid
489*7978SPeter.Dunlap@Sun.COM  *			values are 2 through 65535.  If tpgt_tag is '0',
490*7978SPeter.Dunlap@Sun.COM  *			this function will assign an appropriate tag number.
491*7978SPeter.Dunlap@Sun.COM  *			If tpgt_tag is != 0, and the requested number is
492*7978SPeter.Dunlap@Sun.COM  *			unavailable, another value will be chosen.
493*7978SPeter.Dunlap@Sun.COM  *
494*7978SPeter.Dunlap@Sun.COM  * Return Values:
495*7978SPeter.Dunlap@Sun.COM  *    0			Success
496*7978SPeter.Dunlap@Sun.COM  *    ENOMEM		Could not allocate resources
497*7978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid parameter
498*7978SPeter.Dunlap@Sun.COM  *    EEXIST		Specified TPG is already associated with the target
499*7978SPeter.Dunlap@Sun.COM  *    E2BIG		All tag numbers already in use
500*7978SPeter.Dunlap@Sun.COM  */
501*7978SPeter.Dunlap@Sun.COM int
502*7978SPeter.Dunlap@Sun.COM it_tpgt_create(it_config_t *cfg, it_tgt_t *tgt, it_tpgt_t **tpgt,
503*7978SPeter.Dunlap@Sun.COM     char *tpg_name, uint16_t tpgt_tag);
504*7978SPeter.Dunlap@Sun.COM 
505*7978SPeter.Dunlap@Sun.COM /*
506*7978SPeter.Dunlap@Sun.COM  * Function:  it_tpgt_delete()
507*7978SPeter.Dunlap@Sun.COM  *
508*7978SPeter.Dunlap@Sun.COM  * Delete the target portal group tag represented by 'tpgt', where
509*7978SPeter.Dunlap@Sun.COM  * 'tpgt' is an existing is_tpgt_t structure within the target 'tgt'.
510*7978SPeter.Dunlap@Sun.COM  * The target portal group tag removal will not take effect until the
511*7978SPeter.Dunlap@Sun.COM  * modified configuation is committed by calling it_config_commit().
512*7978SPeter.Dunlap@Sun.COM  *
513*7978SPeter.Dunlap@Sun.COM  * Parameters:
514*7978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configuration obtained from
515*7978SPeter.Dunlap@Sun.COM  *			it_config_load()
516*7978SPeter.Dunlap@Sun.COM  *    tgt		Pointer to the iSCSI target structure associated
517*7978SPeter.Dunlap@Sun.COM  *			with the target portal group tag
518*7978SPeter.Dunlap@Sun.COM  *    tpgt		Pointer to a target portal group tag structure
519*7978SPeter.Dunlap@Sun.COM  */
520*7978SPeter.Dunlap@Sun.COM void
521*7978SPeter.Dunlap@Sun.COM it_tpgt_delete(it_config_t *cfg, it_tgt_t *tgt, it_tpgt_t *tpgt);
522*7978SPeter.Dunlap@Sun.COM 
523*7978SPeter.Dunlap@Sun.COM /*
524*7978SPeter.Dunlap@Sun.COM  * Function:  it_tpg_create()
525*7978SPeter.Dunlap@Sun.COM  *
526*7978SPeter.Dunlap@Sun.COM  * Allocate and create an it_tpg_t structure representing a new iSCSI
527*7978SPeter.Dunlap@Sun.COM  * target portal group.  The new it_tpg_t structure is added to the global
528*7978SPeter.Dunlap@Sun.COM  * tpg list (cfg_tgt_list) in the it_config_t structure.  The new target
529*7978SPeter.Dunlap@Sun.COM  * portal group will not be instantiated until the modified configuration
530*7978SPeter.Dunlap@Sun.COM  * is committed by calling it_config_commit().
531*7978SPeter.Dunlap@Sun.COM  *
532*7978SPeter.Dunlap@Sun.COM  * Parameters:
533*7978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configuration obtained from
534*7978SPeter.Dunlap@Sun.COM  *			it_config_load()
535*7978SPeter.Dunlap@Sun.COM  *    tpg		Pointer to the it_tpg_t structure representing
536*7978SPeter.Dunlap@Sun.COM  *			the target portal group
537*7978SPeter.Dunlap@Sun.COM  *    tpg_name		Identifier for the target portal group
538*7978SPeter.Dunlap@Sun.COM  *    portal_ip_port	A string containing an appropriatedly formatted
539*7978SPeter.Dunlap@Sun.COM  *			IP address:port.  Both IPv4 and IPv6 addresses are
540*7978SPeter.Dunlap@Sun.COM  *			permitted.  This value becomes the first portal in
541*7978SPeter.Dunlap@Sun.COM  *			the TPG -- applications can add additional values
542*7978SPeter.Dunlap@Sun.COM  *			using it_portal_create() before committing the TPG.
543*7978SPeter.Dunlap@Sun.COM  * Return Values:
544*7978SPeter.Dunlap@Sun.COM  *    0			Success
545*7978SPeter.Dunlap@Sun.COM  *    ENOMEM		Cannot allocate resources
546*7978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid parameter
547*7978SPeter.Dunlap@Sun.COM  *    EEXIST		Portal already configured for another portal group
548*7978SPeter.Dunlap@Sun.COM  *			associated with this target.
549*7978SPeter.Dunlap@Sun.COM  */
550*7978SPeter.Dunlap@Sun.COM int
551*7978SPeter.Dunlap@Sun.COM it_tpg_create(it_config_t *cfg, it_tpg_t **tpg, char *tpg_name,
552*7978SPeter.Dunlap@Sun.COM     char *portal_ip_port);
553*7978SPeter.Dunlap@Sun.COM 
554*7978SPeter.Dunlap@Sun.COM /*
555*7978SPeter.Dunlap@Sun.COM  * Function:  it_tpg_delete()
556*7978SPeter.Dunlap@Sun.COM  *
557*7978SPeter.Dunlap@Sun.COM  * Delete target portal group represented by 'tpg', where 'tpg' is an
558*7978SPeter.Dunlap@Sun.COM  * existing it_tpg_t structure within the global configuration 'cfg'.
559*7978SPeter.Dunlap@Sun.COM  * The target portal group removal will not take effect until the
560*7978SPeter.Dunlap@Sun.COM  * modified configuration is committed by calling it_config_commit().
561*7978SPeter.Dunlap@Sun.COM  *
562*7978SPeter.Dunlap@Sun.COM  * Parameters:
563*7978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configuration obtained from
564*7978SPeter.Dunlap@Sun.COM  *			it_config_load()
565*7978SPeter.Dunlap@Sun.COM  *    tpg		Pointer to the it_tpg_t structure representing
566*7978SPeter.Dunlap@Sun.COM  *			the target portal group
567*7978SPeter.Dunlap@Sun.COM  *    force		Remove this target portal group even if it's
568*7978SPeter.Dunlap@Sun.COM  *			associated with one or more targets.
569*7978SPeter.Dunlap@Sun.COM  *
570*7978SPeter.Dunlap@Sun.COM  * Return Values:
571*7978SPeter.Dunlap@Sun.COM  *    0			Success
572*7978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid parameter
573*7978SPeter.Dunlap@Sun.COM  *    EBUSY		Portal group associated with one or more targets.
574*7978SPeter.Dunlap@Sun.COM  */
575*7978SPeter.Dunlap@Sun.COM int
576*7978SPeter.Dunlap@Sun.COM it_tpg_delete(it_config_t *cfg, it_tpg_t *tpg, boolean_t force);
577*7978SPeter.Dunlap@Sun.COM 
578*7978SPeter.Dunlap@Sun.COM /*
579*7978SPeter.Dunlap@Sun.COM  * Function:  it_portal_create()
580*7978SPeter.Dunlap@Sun.COM  *
581*7978SPeter.Dunlap@Sun.COM  * Add an it_portal_t structure representing a new portal to the specified
582*7978SPeter.Dunlap@Sun.COM  * target portal group.  The change to the target portal group will not take
583*7978SPeter.Dunlap@Sun.COM  * effect until the modified configuration is committed by calling
584*7978SPeter.Dunlap@Sun.COM  * it_config_commit().
585*7978SPeter.Dunlap@Sun.COM  *
586*7978SPeter.Dunlap@Sun.COM  * Parameters:
587*7978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configration obtained from
588*7978SPeter.Dunlap@Sun.COM  *			it_config_load()
589*7978SPeter.Dunlap@Sun.COM  *    tpg		Pointer to the it_tpg_t structure representing the
590*7978SPeter.Dunlap@Sun.COM  *			target portal group or "none" to remove
591*7978SPeter.Dunlap@Sun.COM  *    portal		Pointer to the it_portal_t structure representing
592*7978SPeter.Dunlap@Sun.COM  *			the portal
593*7978SPeter.Dunlap@Sun.COM  *    portal_ip_port	A string containing an appropriately formatted
594*7978SPeter.Dunlap@Sun.COM  *			IP address or IP address:port in either IPv4 or
595*7978SPeter.Dunlap@Sun.COM  *			IPv6 format.
596*7978SPeter.Dunlap@Sun.COM  * Return Values:
597*7978SPeter.Dunlap@Sun.COM  *    0			Success
598*7978SPeter.Dunlap@Sun.COM  *    ENOMEM		Could not allocate resources
599*7978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid parameter
600*7978SPeter.Dunlap@Sun.COM  *    EEXIST		Portal already configured for another portal group
601*7978SPeter.Dunlap@Sun.COM  */
602*7978SPeter.Dunlap@Sun.COM int
603*7978SPeter.Dunlap@Sun.COM it_portal_create(it_config_t *cfg, it_tpg_t *tpg, it_portal_t **portal,
604*7978SPeter.Dunlap@Sun.COM     char *portal_ip_port);
605*7978SPeter.Dunlap@Sun.COM 
606*7978SPeter.Dunlap@Sun.COM /*
607*7978SPeter.Dunlap@Sun.COM  * Function:  it_portal_delete()
608*7978SPeter.Dunlap@Sun.COM  *
609*7978SPeter.Dunlap@Sun.COM  * Remove the specified portal from the specified target portal group.
610*7978SPeter.Dunlap@Sun.COM  * The portal removal will not take effect until the modified configuration
611*7978SPeter.Dunlap@Sun.COM  * is committed by calling it_config_commit().
612*7978SPeter.Dunlap@Sun.COM  *
613*7978SPeter.Dunlap@Sun.COM  * Parameters:
614*7978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configration obtained from
615*7978SPeter.Dunlap@Sun.COM  *			it_config_load()
616*7978SPeter.Dunlap@Sun.COM  *    tpg		Pointer to the it_tpg_t structure representing the
617*7978SPeter.Dunlap@Sun.COM  *			target portal group
618*7978SPeter.Dunlap@Sun.COM  *    portal		Pointer to the it_portal_t structure representing
619*7978SPeter.Dunlap@Sun.COM  *			the portal
620*7978SPeter.Dunlap@Sun.COM  */
621*7978SPeter.Dunlap@Sun.COM void
622*7978SPeter.Dunlap@Sun.COM it_portal_delete(it_config_t *cfg, it_tpg_t *tpg, it_portal_t *portal);
623*7978SPeter.Dunlap@Sun.COM 
624*7978SPeter.Dunlap@Sun.COM /*
625*7978SPeter.Dunlap@Sun.COM  * Function:  it_ini_create()
626*7978SPeter.Dunlap@Sun.COM  *
627*7978SPeter.Dunlap@Sun.COM  * Add an initiator context to the global configuration. The new
628*7978SPeter.Dunlap@Sun.COM  * initiator context will not be instantiated until the modified
629*7978SPeter.Dunlap@Sun.COM  * configuration is committed by calling it_config_commit().
630*7978SPeter.Dunlap@Sun.COM  *
631*7978SPeter.Dunlap@Sun.COM  * Parameters:
632*7978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configration obtained from
633*7978SPeter.Dunlap@Sun.COM  *			it_config_load()
634*7978SPeter.Dunlap@Sun.COM  *    ini		Pointer to the it_ini_t structure representing
635*7978SPeter.Dunlap@Sun.COM  *			the initiator context.
636*7978SPeter.Dunlap@Sun.COM  *    ini_node_name	The iSCSI node name of the remote initiator.
637*7978SPeter.Dunlap@Sun.COM  *
638*7978SPeter.Dunlap@Sun.COM  * Return Values:
639*7978SPeter.Dunlap@Sun.COM  *    0			Success
640*7978SPeter.Dunlap@Sun.COM  *    ENOMEM		Could not allocate resources
641*7978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid parameter.
642*7978SPeter.Dunlap@Sun.COM  *    EEXIST		Initiator already configured
643*7978SPeter.Dunlap@Sun.COM  *    EFAULT		Invalid initiator name
644*7978SPeter.Dunlap@Sun.COM  */
645*7978SPeter.Dunlap@Sun.COM int
646*7978SPeter.Dunlap@Sun.COM it_ini_create(it_config_t *cfg, it_ini_t **ini, char *ini_node_name);
647*7978SPeter.Dunlap@Sun.COM 
648*7978SPeter.Dunlap@Sun.COM /*
649*7978SPeter.Dunlap@Sun.COM  * Function:  it_ini_setprop()
650*7978SPeter.Dunlap@Sun.COM  *
651*7978SPeter.Dunlap@Sun.COM  * Validate the provided property list and set the initiator properties.
652*7978SPeter.Dunlap@Sun.COM  * If errlist is not NULL, returns detailed errors for each property
653*7978SPeter.Dunlap@Sun.COM  * that failed.  The format for errorlist is
654*7978SPeter.Dunlap@Sun.COM  *		 key = property, value = error string.
655*7978SPeter.Dunlap@Sun.COM  *
656*7978SPeter.Dunlap@Sun.COM  * Parameters:
657*7978SPeter.Dunlap@Sun.COM  *
658*7978SPeter.Dunlap@Sun.COM  *    ini		The initiator being updated.
659*7978SPeter.Dunlap@Sun.COM  *    proplist		nvlist_t containing properties for this target.
660*7978SPeter.Dunlap@Sun.COM  *    errlist		(optional)  nvlist_t of errors encountered when
661*7978SPeter.Dunlap@Sun.COM  *			validating the properties.
662*7978SPeter.Dunlap@Sun.COM  *
663*7978SPeter.Dunlap@Sun.COM  * Return Values:
664*7978SPeter.Dunlap@Sun.COM  *    0			Success
665*7978SPeter.Dunlap@Sun.COM  *    ENOMEM		Could not allocate resources
666*7978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid property
667*7978SPeter.Dunlap@Sun.COM  *
668*7978SPeter.Dunlap@Sun.COM  */
669*7978SPeter.Dunlap@Sun.COM int
670*7978SPeter.Dunlap@Sun.COM it_ini_setprop(it_ini_t *ini, nvlist_t *proplist, nvlist_t **errlist);
671*7978SPeter.Dunlap@Sun.COM 
672*7978SPeter.Dunlap@Sun.COM /*
673*7978SPeter.Dunlap@Sun.COM  * Function:  it_ini_delete()
674*7978SPeter.Dunlap@Sun.COM  *
675*7978SPeter.Dunlap@Sun.COM  * Remove the specified initiator context from the global configuration.
676*7978SPeter.Dunlap@Sun.COM  * The removal will not take effect until the modified configuration is
677*7978SPeter.Dunlap@Sun.COM  * committed by calling it_config_commit().
678*7978SPeter.Dunlap@Sun.COM  *
679*7978SPeter.Dunlap@Sun.COM  * Parameters:
680*7978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configration obtained from
681*7978SPeter.Dunlap@Sun.COM  *			it_config_load()
682*7978SPeter.Dunlap@Sun.COM  *    ini		Pointer to the it_ini_t structure representing
683*7978SPeter.Dunlap@Sun.COM  *			the initiator context.
684*7978SPeter.Dunlap@Sun.COM  */
685*7978SPeter.Dunlap@Sun.COM void
686*7978SPeter.Dunlap@Sun.COM it_ini_delete(it_config_t *cfg, it_ini_t *ini);
687*7978SPeter.Dunlap@Sun.COM 
688*7978SPeter.Dunlap@Sun.COM /*
689*7978SPeter.Dunlap@Sun.COM  * Function:  it_config_free()
690*7978SPeter.Dunlap@Sun.COM  *
691*7978SPeter.Dunlap@Sun.COM  * Free any resources associated with the it_config_t structure.
692*7978SPeter.Dunlap@Sun.COM  *
693*7978SPeter.Dunlap@Sun.COM  * Parameters:
694*7978SPeter.Dunlap@Sun.COM  *    cfg       A C representation of the current iSCSI configuration
695*7978SPeter.Dunlap@Sun.COM  */
696*7978SPeter.Dunlap@Sun.COM void
697*7978SPeter.Dunlap@Sun.COM it_config_free(it_config_t *cfg);
698*7978SPeter.Dunlap@Sun.COM 
699*7978SPeter.Dunlap@Sun.COM /*
700*7978SPeter.Dunlap@Sun.COM  * Function:  it_tgt_free()
701*7978SPeter.Dunlap@Sun.COM  *
702*7978SPeter.Dunlap@Sun.COM  * Frees an it_tgt_t structure.  If tgt_next is not NULL, frees
703*7978SPeter.Dunlap@Sun.COM  * all structures in the list.
704*7978SPeter.Dunlap@Sun.COM  */
705*7978SPeter.Dunlap@Sun.COM void
706*7978SPeter.Dunlap@Sun.COM it_tgt_free(it_tgt_t *tgt);
707*7978SPeter.Dunlap@Sun.COM 
708*7978SPeter.Dunlap@Sun.COM /*
709*7978SPeter.Dunlap@Sun.COM  * Function:  it_tpgt_free()
710*7978SPeter.Dunlap@Sun.COM  *
711*7978SPeter.Dunlap@Sun.COM  * Deallocates resources of an it_tpgt_t structure.  If tpgt->next
712*7978SPeter.Dunlap@Sun.COM  * is not NULL, frees all members of the list.
713*7978SPeter.Dunlap@Sun.COM  */
714*7978SPeter.Dunlap@Sun.COM void
715*7978SPeter.Dunlap@Sun.COM it_tpgt_free(it_tpgt_t *tpgt);
716*7978SPeter.Dunlap@Sun.COM 
717*7978SPeter.Dunlap@Sun.COM /*
718*7978SPeter.Dunlap@Sun.COM  * Function:  it_tpg_free()
719*7978SPeter.Dunlap@Sun.COM  *
720*7978SPeter.Dunlap@Sun.COM  * Deallocates resources associated with an it_tpg_t structure.
721*7978SPeter.Dunlap@Sun.COM  * If tpg->next is not NULL, frees all members of the list.
722*7978SPeter.Dunlap@Sun.COM  */
723*7978SPeter.Dunlap@Sun.COM void
724*7978SPeter.Dunlap@Sun.COM it_tpg_free(it_tpg_t *tpg);
725*7978SPeter.Dunlap@Sun.COM 
726*7978SPeter.Dunlap@Sun.COM /*
727*7978SPeter.Dunlap@Sun.COM  * Function:  it_ini_free()
728*7978SPeter.Dunlap@Sun.COM  *
729*7978SPeter.Dunlap@Sun.COM  * Deallocates resources of an it_ini_t structure. If ini->next is
730*7978SPeter.Dunlap@Sun.COM  * not NULL, frees all members of the list.
731*7978SPeter.Dunlap@Sun.COM  */
732*7978SPeter.Dunlap@Sun.COM void
733*7978SPeter.Dunlap@Sun.COM it_ini_free(it_ini_t *ini);
734*7978SPeter.Dunlap@Sun.COM 
735*7978SPeter.Dunlap@Sun.COM /*
736*7978SPeter.Dunlap@Sun.COM  * Function:  validate_iscsi_name()
737*7978SPeter.Dunlap@Sun.COM  *
738*7978SPeter.Dunlap@Sun.COM  * Ensures the passed-in string is a valid IQN or EUI iSCSI name
739*7978SPeter.Dunlap@Sun.COM  */
740*7978SPeter.Dunlap@Sun.COM boolean_t
741*7978SPeter.Dunlap@Sun.COM validate_iscsi_name(char *in_name);
742*7978SPeter.Dunlap@Sun.COM 
743*7978SPeter.Dunlap@Sun.COM #ifdef	__cplusplus
744*7978SPeter.Dunlap@Sun.COM }
745*7978SPeter.Dunlap@Sun.COM #endif
746*7978SPeter.Dunlap@Sun.COM 
747*7978SPeter.Dunlap@Sun.COM #endif	/* _LIBISCSIT_H */
748