xref: /titanic_50/usr/src/lib/libiscsit/common/libiscsit.h (revision bf604c6405d5cbc4e94e3d0ecc9e6e074ed4ea67)
1a6d42e7dSPeter Dunlap /*
2a6d42e7dSPeter Dunlap  * CDDL HEADER START
3a6d42e7dSPeter Dunlap  *
4a6d42e7dSPeter Dunlap  * The contents of this file are subject to the terms of the
5a6d42e7dSPeter Dunlap  * Common Development and Distribution License (the "License").
6a6d42e7dSPeter Dunlap  * You may not use this file except in compliance with the License.
7a6d42e7dSPeter Dunlap  *
8a6d42e7dSPeter Dunlap  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9a6d42e7dSPeter Dunlap  * or http://www.opensolaris.org/os/licensing.
10a6d42e7dSPeter Dunlap  * See the License for the specific language governing permissions
11a6d42e7dSPeter Dunlap  * and limitations under the License.
12a6d42e7dSPeter Dunlap  *
13a6d42e7dSPeter Dunlap  * When distributing Covered Code, include this CDDL HEADER in each
14a6d42e7dSPeter Dunlap  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15a6d42e7dSPeter Dunlap  * If applicable, add the following below this CDDL HEADER, with the
16a6d42e7dSPeter Dunlap  * fields enclosed by brackets "[]" replaced with your own identifying
17a6d42e7dSPeter Dunlap  * information: Portions Copyright [yyyy] [name of copyright owner]
18a6d42e7dSPeter Dunlap  *
19a6d42e7dSPeter Dunlap  * CDDL HEADER END
20a6d42e7dSPeter Dunlap  */
21a6d42e7dSPeter Dunlap /*
22a6d42e7dSPeter Dunlap  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23a6d42e7dSPeter Dunlap  * Use is subject to license terms.
24a6d42e7dSPeter Dunlap  */
25a6d42e7dSPeter Dunlap 
26a6d42e7dSPeter Dunlap #ifndef	_LIBISCSIT_H
27a6d42e7dSPeter Dunlap #define	_LIBISCSIT_H
28a6d42e7dSPeter Dunlap 
29a6d42e7dSPeter Dunlap #ifndef _KERNEL
30a6d42e7dSPeter Dunlap #include <libnvpair.h>
31a6d42e7dSPeter Dunlap #include <sys/socket.h>
32a6d42e7dSPeter Dunlap #endif
33a6d42e7dSPeter Dunlap 
34*bf604c64SPeter Dunlap #include <sys/iscsit/iscsit_common.h>
35*bf604c64SPeter Dunlap 
36a6d42e7dSPeter Dunlap #ifdef	__cplusplus
37a6d42e7dSPeter Dunlap extern "C" {
38a6d42e7dSPeter Dunlap #endif
39a6d42e7dSPeter Dunlap 
40a6d42e7dSPeter Dunlap #define	MAX_TPGT	256
41a6d42e7dSPeter Dunlap #define	CFG_TPGTLIST	"tpgt-list"
42a6d42e7dSPeter Dunlap 
43a6d42e7dSPeter Dunlap /*
44a6d42e7dSPeter Dunlap  * Object Hierarchy
45a6d42e7dSPeter Dunlap  *
46a6d42e7dSPeter Dunlap  *  _______________________
47a6d42e7dSPeter Dunlap  * |                       |
48a6d42e7dSPeter Dunlap  * |  iSCSI Target Config  |
49a6d42e7dSPeter Dunlap  * |      it_config_t      |
50a6d42e7dSPeter Dunlap  * |_______________________|
51a6d42e7dSPeter Dunlap  *    |     |
52a6d42e7dSPeter Dunlap  *    |     |
53a6d42e7dSPeter Dunlap  *    |     |      ________     ________              ________
54a6d42e7dSPeter Dunlap  *    |     |     |        |   |        |            |        |
55a6d42e7dSPeter Dunlap  *    |     |     | Target |-->| Target |--  - -  -->| Target |
56a6d42e7dSPeter Dunlap  *    |     |     |________|   |________|            |________|
57a6d42e7dSPeter Dunlap  *    |     |           |
58a6d42e7dSPeter Dunlap  *    |     |           |
59a6d42e7dSPeter Dunlap  *    |     |           |
60a6d42e7dSPeter Dunlap  *    |     |           |       ______              ______
61a6d42e7dSPeter Dunlap  *    |     |           |      |      |            |      |
62a6d42e7dSPeter Dunlap  *    |     |           +----->| TPGT |--  - -  -->| TPGT |
63a6d42e7dSPeter Dunlap  *    |     |                  |______|            |______|
64a6d42e7dSPeter Dunlap  *    |     |                       |                   |
65a6d42e7dSPeter Dunlap  *    |  +--+                       |                   |
66a6d42e7dSPeter Dunlap  *    |  |   _______     _______    |         ______    |
67a6d42e7dSPeter Dunlap  *    |  |  |       |   |       |<--+        |      |<--+
68a6d42e7dSPeter Dunlap  *    |  +->|  TPG  |-->|  TPG  |--  - -  -->| TPG  |
69a6d42e7dSPeter Dunlap  *    |     |_______|   |_______|            |______|
70a6d42e7dSPeter Dunlap  *    |
71a6d42e7dSPeter Dunlap  *    |      ___________     ___________              ___________
72a6d42e7dSPeter Dunlap  *    |     |           |   |           |            |           |
73a6d42e7dSPeter Dunlap  *    +---->| Initiator |-->| Initiator |--  - -  -->| Initiator |
74a6d42e7dSPeter Dunlap  *          |  Context  |   |  Context  |            |  Context  |
75a6d42e7dSPeter Dunlap  *          |___________|   |___________|            |___________|
76a6d42e7dSPeter Dunlap  *
77a6d42e7dSPeter Dunlap  *
78a6d42e7dSPeter Dunlap  * it_config_t includes a list of global properties
79a6d42e7dSPeter Dunlap  *
80a6d42e7dSPeter Dunlap  * Targets include a list of properties which override the global properties
81a6d42e7dSPeter Dunlap  * if set
82a6d42e7dSPeter Dunlap  *
83a6d42e7dSPeter Dunlap  * Initiators also include a list of properties but never inherit properties
84a6d42e7dSPeter Dunlap  * from the global config.
85a6d42e7dSPeter Dunlap  */
86a6d42e7dSPeter Dunlap 
87a6d42e7dSPeter Dunlap /*
88a6d42e7dSPeter Dunlap  * Function:  it_config_load()
89a6d42e7dSPeter Dunlap  *
90a6d42e7dSPeter Dunlap  * Allocate and create an it_config_t structure representing the
91a6d42e7dSPeter Dunlap  * current iSCSI configuration.  This structure is compiled using
92a6d42e7dSPeter Dunlap  * the 'provider' data returned by stmfGetProviderData().  If there
93a6d42e7dSPeter Dunlap  * is no provider data associated with iscsit, the it_config_t
94a6d42e7dSPeter Dunlap  * structure will be set to a default configuration.
95a6d42e7dSPeter Dunlap  *
96a6d42e7dSPeter Dunlap  * Parameters:
97a6d42e7dSPeter Dunlap  *    cfg		A C representation of the current iSCSI configuration
98a6d42e7dSPeter Dunlap  *
99a6d42e7dSPeter Dunlap  * Return Values:
100a6d42e7dSPeter Dunlap  *    0			Success
101a6d42e7dSPeter Dunlap  *    ENOMEM		Could not allocate resources
102a6d42e7dSPeter Dunlap  *    EINVAL		Invalid parameter
103a6d42e7dSPeter Dunlap  */
104a6d42e7dSPeter Dunlap int
105a6d42e7dSPeter Dunlap it_config_load(it_config_t **cfg);
106a6d42e7dSPeter Dunlap 
107a6d42e7dSPeter Dunlap /*
108a6d42e7dSPeter Dunlap  * Function:  it_config_commit()
109a6d42e7dSPeter Dunlap  *
110a6d42e7dSPeter Dunlap  * Informs the iscsit service that the configuration has changed and
111a6d42e7dSPeter Dunlap  * commits the new configuration to persistent store by calling
112a6d42e7dSPeter Dunlap  * stmfSetProviderData.  This function can be called multiple times
113a6d42e7dSPeter Dunlap  * during a configuration sequence if necessary.
114a6d42e7dSPeter Dunlap  *
115a6d42e7dSPeter Dunlap  * Parameters:
116a6d42e7dSPeter Dunlap  *    cfg		A C representation of the current iSCSI configuration
117a6d42e7dSPeter Dunlap  *
118a6d42e7dSPeter Dunlap  * Return Values:
119a6d42e7dSPeter Dunlap  *    0			Success
120a6d42e7dSPeter Dunlap  *    ENOMEM		Could not allocate resources
121a6d42e7dSPeter Dunlap  *    EINVAL		Invalid it_config_t structure
122a6d42e7dSPeter Dunlap  *    STMF_ERROR_SERVICE_DATA_VERSION	Configuration was updated by another
123a6d42e7dSPeter Dunlap  *			client.  See stmfSetProviderDataProt().
124a6d42e7dSPeter Dunlap  */
125a6d42e7dSPeter Dunlap int
126a6d42e7dSPeter Dunlap it_config_commit(it_config_t *cfg);
127a6d42e7dSPeter Dunlap 
128a6d42e7dSPeter Dunlap /*
129a6d42e7dSPeter Dunlap  * Function:  it_config_setprop()
130a6d42e7dSPeter Dunlap  *
131a6d42e7dSPeter Dunlap  * Validate the provided property list and set the global properties
132a6d42e7dSPeter Dunlap  * for iSCSI Target.  If errlist is not NULL, returns detailed
133a6d42e7dSPeter Dunlap  * errors for each property that failed.  The format for errorlist
134a6d42e7dSPeter Dunlap  * is key = property, value = error string.
135a6d42e7dSPeter Dunlap  *
136a6d42e7dSPeter Dunlap  * Parameters:
137a6d42e7dSPeter Dunlap  *
138a6d42e7dSPeter Dunlap  *    cfg		The current iSCSI configuration obtained from
139a6d42e7dSPeter Dunlap  *			it_config_load()
140a6d42e7dSPeter Dunlap  *    proplist		nvlist_t containing properties for this target.
141a6d42e7dSPeter Dunlap  *    errlist		(optional)  nvlist_t of errors encountered when
142a6d42e7dSPeter Dunlap  *			validating the properties.
143a6d42e7dSPeter Dunlap  *
144a6d42e7dSPeter Dunlap  * Return Values:
145a6d42e7dSPeter Dunlap  *    0			Success
146a6d42e7dSPeter Dunlap  *    ENOMEM		Could not allocate resources
147a6d42e7dSPeter Dunlap  *    EINVAL		Invalid property
148a6d42e7dSPeter Dunlap  *
149a6d42e7dSPeter Dunlap  */
150a6d42e7dSPeter Dunlap int
151a6d42e7dSPeter Dunlap it_config_setprop(it_config_t *cfg, nvlist_t *proplist, nvlist_t **errlist);
152a6d42e7dSPeter Dunlap 
153a6d42e7dSPeter Dunlap /*
154a6d42e7dSPeter Dunlap  * Function:  it_config_free()
155a6d42e7dSPeter Dunlap  *
156a6d42e7dSPeter Dunlap  * Free any resources associated with the it_config_t structure.
157a6d42e7dSPeter Dunlap  *
158a6d42e7dSPeter Dunlap  * Parameters:
159a6d42e7dSPeter Dunlap  *    cfg		A C representation of the current iSCSI configuration
160a6d42e7dSPeter Dunlap  */
161a6d42e7dSPeter Dunlap void
162a6d42e7dSPeter Dunlap it_config_free(it_config_t *cfg);
163a6d42e7dSPeter Dunlap 
164a6d42e7dSPeter Dunlap /*
165a6d42e7dSPeter Dunlap  * Function:  it_tgt_create()
166a6d42e7dSPeter Dunlap  *
167a6d42e7dSPeter Dunlap  * Allocate and create an it_tgt_t structure representing a new iSCSI
168a6d42e7dSPeter Dunlap  * target node.  If tgt_name is NULL, then a unique target node name will
169a6d42e7dSPeter Dunlap  * be generated automatically.  Otherwise, the value of tgt_name will be
170a6d42e7dSPeter Dunlap  * used as the target node name.  The new it_tgt_t structure is added to
171a6d42e7dSPeter Dunlap  * the target list (cfg_tgt_list) in the configuration structure, and the
172a6d42e7dSPeter Dunlap  * new target will not be instantiated until the modified configuration
173a6d42e7dSPeter Dunlap  * is committed by calling it_config_commit().
174a6d42e7dSPeter Dunlap  *
175a6d42e7dSPeter Dunlap  * Parameters:
176a6d42e7dSPeter Dunlap  *    cfg		The current iSCSI configuration obtained from
177a6d42e7dSPeter Dunlap  *			it_config_load()
178a6d42e7dSPeter Dunlap  *    tgt		Pointer to an iSCSI target structure
179a6d42e7dSPeter Dunlap  *    tgt_name		The target node name for the target to be created.
180a6d42e7dSPeter Dunlap  *			The name must be in either IQN or EUI format.  If
181a6d42e7dSPeter Dunlap  *			this value is NULL, a node name will be generated
182a6d42e7dSPeter Dunlap  *			automatically in IQN format.
183a6d42e7dSPeter Dunlap  *
184a6d42e7dSPeter Dunlap  * Return Values:
185a6d42e7dSPeter Dunlap  *    0			Success
186a6d42e7dSPeter Dunlap  *    ENOMEM		Could not allocate resources
187a6d42e7dSPeter Dunlap  *    EINVAL		Invalid parameter
188a6d42e7dSPeter Dunlap  *    EEXIST		The requested target node name is already configured
189a6d42e7dSPeter Dunlap  *    EFAULT		Invalid iSCSI target name
190a6d42e7dSPeter Dunlap  */
191a6d42e7dSPeter Dunlap int
192a6d42e7dSPeter Dunlap it_tgt_create(it_config_t *cfg, it_tgt_t **tgt, char *tgt_name);
193a6d42e7dSPeter Dunlap 
194a6d42e7dSPeter Dunlap /*
195a6d42e7dSPeter Dunlap  * Function:  it_tgt_setprop()
196a6d42e7dSPeter Dunlap  *
197a6d42e7dSPeter Dunlap  * Validate the provided property list and set the properties for
198a6d42e7dSPeter Dunlap  * the specified target.  If errlist is not NULL, returns detailed
199a6d42e7dSPeter Dunlap  * errors for each property that failed.  The format for errorlist
200a6d42e7dSPeter Dunlap  * is key = property, value = error string.
201a6d42e7dSPeter Dunlap  *
202a6d42e7dSPeter Dunlap  * Parameters:
203a6d42e7dSPeter Dunlap  *
204a6d42e7dSPeter Dunlap  *    cfg		The current iSCSI configuration obtained from
205a6d42e7dSPeter Dunlap  *			it_config_load()
206a6d42e7dSPeter Dunlap  *    tgt		Pointer to an iSCSI target structure
207a6d42e7dSPeter Dunlap  *    proplist		nvlist_t containing properties for this target.
208a6d42e7dSPeter Dunlap  *    errlist		(optional)  nvlist_t of errors encountered when
209a6d42e7dSPeter Dunlap  *			validating the properties.
210a6d42e7dSPeter Dunlap  *
211a6d42e7dSPeter Dunlap  * Return Values:
212a6d42e7dSPeter Dunlap  *    0			Success
213a6d42e7dSPeter Dunlap  *    ENOMEM		Could not allocate resources
214a6d42e7dSPeter Dunlap  *    EINVAL		Invalid property
215a6d42e7dSPeter Dunlap  *
216a6d42e7dSPeter Dunlap  */
217a6d42e7dSPeter Dunlap int
218a6d42e7dSPeter Dunlap it_tgt_setprop(it_config_t *cfg, it_tgt_t *tgt, nvlist_t *proplist,
219a6d42e7dSPeter Dunlap     nvlist_t **errlist);
220a6d42e7dSPeter Dunlap 
221a6d42e7dSPeter Dunlap 
222a6d42e7dSPeter Dunlap /*
223a6d42e7dSPeter Dunlap  * Function:  it_tgt_delete()
224a6d42e7dSPeter Dunlap  *
225a6d42e7dSPeter Dunlap  * Delete target represented by 'tgt', where 'tgt' is an existing
226a6d42e7dSPeter Dunlap  * it_tgt_t structure within the configuration 'cfg'.  The target removal
227a6d42e7dSPeter Dunlap  * will not take effect until the modified configuration is committed
228a6d42e7dSPeter Dunlap  * by calling it_config_commit().
229a6d42e7dSPeter Dunlap  *
230a6d42e7dSPeter Dunlap  * Parameters:
231a6d42e7dSPeter Dunlap  *    cfg		The current iSCSI configuration obtained from
232a6d42e7dSPeter Dunlap  *			it_config_load()
233a6d42e7dSPeter Dunlap  *    tgt		Pointer to an iSCSI target structure
234a6d42e7dSPeter Dunlap  *    force		Set the target to offline before removing it from
235a6d42e7dSPeter Dunlap  *			the config.  If not specified, the operation will
236a6d42e7dSPeter Dunlap  *			fail if the target is determined to be online.
237a6d42e7dSPeter Dunlap  *
238a6d42e7dSPeter Dunlap  * Return Values:
239a6d42e7dSPeter Dunlap  *    0			Success
240a6d42e7dSPeter Dunlap  *    EBUSY		Target is online
241a6d42e7dSPeter Dunlap  */
242a6d42e7dSPeter Dunlap int
243a6d42e7dSPeter Dunlap it_tgt_delete(it_config_t *cfg, it_tgt_t *tgt, boolean_t force);
244a6d42e7dSPeter Dunlap 
245a6d42e7dSPeter Dunlap /*
246a6d42e7dSPeter Dunlap  * Function:  it_tpgt_create()
247a6d42e7dSPeter Dunlap  *
248a6d42e7dSPeter Dunlap  * Allocate and create an it_tpgt_t structure representing a new iSCSI
249a6d42e7dSPeter Dunlap  * target portal group tag.  The new it_tpgt_t structure is added to the
250a6d42e7dSPeter Dunlap  * target tpgt list (tgt_tpgt_list) in the it_tgt_t structure.  The new
251a6d42e7dSPeter Dunlap  * target portal group tag will not be instantiated until the modified
252a6d42e7dSPeter Dunlap  * configuration is committed by calling it_config_commit().
253a6d42e7dSPeter Dunlap  *
254a6d42e7dSPeter Dunlap  * Parameters:
255a6d42e7dSPeter Dunlap  *    cfg		The current iSCSI configuration obtained from
256a6d42e7dSPeter Dunlap  *			it_config_load()
257a6d42e7dSPeter Dunlap  *    tgt		Pointer to the iSCSI target structure associated
258a6d42e7dSPeter Dunlap  *			with the target portal group tag
259a6d42e7dSPeter Dunlap  *    tpgt		Pointer to a target portal group tag structure
260a6d42e7dSPeter Dunlap  *    tpg_name		The name of the TPG to be associated with this TPGT
261a6d42e7dSPeter Dunlap  *    tpgt_tag		16-bit numerical identifier for this TPGT.  Valid
262a6d42e7dSPeter Dunlap  *			values are 2 through 65535.  If tpgt_tag is '0',
263a6d42e7dSPeter Dunlap  *			this function will assign an appropriate tag number.
264a6d42e7dSPeter Dunlap  *			If tpgt_tag is != 0, and the requested number is
265a6d42e7dSPeter Dunlap  *			unavailable, another value will be chosen.
266a6d42e7dSPeter Dunlap  *
267a6d42e7dSPeter Dunlap  * Return Values:
268a6d42e7dSPeter Dunlap  *    0			Success
269a6d42e7dSPeter Dunlap  *    ENOMEM		Could not allocate resources
270a6d42e7dSPeter Dunlap  *    EINVAL		Invalid parameter
271a6d42e7dSPeter Dunlap  *    EEXIST		Specified TPG is already associated with the target
272a6d42e7dSPeter Dunlap  *    E2BIG		All tag numbers already in use
273a6d42e7dSPeter Dunlap  */
274a6d42e7dSPeter Dunlap int
275a6d42e7dSPeter Dunlap it_tpgt_create(it_config_t *cfg, it_tgt_t *tgt, it_tpgt_t **tpgt,
276a6d42e7dSPeter Dunlap     char *tpg_name, uint16_t tpgt_tag);
277a6d42e7dSPeter Dunlap 
278a6d42e7dSPeter Dunlap /*
279a6d42e7dSPeter Dunlap  * Function:  it_tpgt_delete()
280a6d42e7dSPeter Dunlap  *
281a6d42e7dSPeter Dunlap  * Delete the target portal group tag represented by 'tpgt', where
282a6d42e7dSPeter Dunlap  * 'tpgt' is an existing is_tpgt_t structure within the target 'tgt'.
283a6d42e7dSPeter Dunlap  * The target portal group tag removal will not take effect until the
284a6d42e7dSPeter Dunlap  * modified configuation is committed by calling it_config_commit().
285a6d42e7dSPeter Dunlap  *
286a6d42e7dSPeter Dunlap  * Parameters:
287a6d42e7dSPeter Dunlap  *    cfg		The current iSCSI configuration obtained from
288a6d42e7dSPeter Dunlap  *			it_config_load()
289a6d42e7dSPeter Dunlap  *    tgt		Pointer to the iSCSI target structure associated
290a6d42e7dSPeter Dunlap  *			with the target portal group tag
291a6d42e7dSPeter Dunlap  *    tpgt		Pointer to a target portal group tag structure
292a6d42e7dSPeter Dunlap  */
293a6d42e7dSPeter Dunlap void
294a6d42e7dSPeter Dunlap it_tpgt_delete(it_config_t *cfg, it_tgt_t *tgt, it_tpgt_t *tpgt);
295a6d42e7dSPeter Dunlap 
296a6d42e7dSPeter Dunlap /*
297a6d42e7dSPeter Dunlap  * Function:  it_tpg_create()
298a6d42e7dSPeter Dunlap  *
299a6d42e7dSPeter Dunlap  * Allocate and create an it_tpg_t structure representing a new iSCSI
300a6d42e7dSPeter Dunlap  * target portal group.  The new it_tpg_t structure is added to the global
301a6d42e7dSPeter Dunlap  * tpg list (cfg_tgt_list) in the it_config_t structure.  The new target
302a6d42e7dSPeter Dunlap  * portal group will not be instantiated until the modified configuration
303a6d42e7dSPeter Dunlap  * is committed by calling it_config_commit().
304a6d42e7dSPeter Dunlap  *
305a6d42e7dSPeter Dunlap  * Parameters:
306a6d42e7dSPeter Dunlap  *    cfg		The current iSCSI configuration obtained from
307a6d42e7dSPeter Dunlap  *			it_config_load()
308a6d42e7dSPeter Dunlap  *    tpg		Pointer to the it_tpg_t structure representing
309a6d42e7dSPeter Dunlap  *			the target portal group
310a6d42e7dSPeter Dunlap  *    tpg_name		Identifier for the target portal group
311a6d42e7dSPeter Dunlap  *    portal_ip_port	A string containing an appropriatedly formatted
312a6d42e7dSPeter Dunlap  *			IP address:port.  Both IPv4 and IPv6 addresses are
313a6d42e7dSPeter Dunlap  *			permitted.  This value becomes the first portal in
314a6d42e7dSPeter Dunlap  *			the TPG -- applications can add additional values
315a6d42e7dSPeter Dunlap  *			using it_portal_create() before committing the TPG.
316a6d42e7dSPeter Dunlap  * Return Values:
317a6d42e7dSPeter Dunlap  *    0			Success
318a6d42e7dSPeter Dunlap  *    ENOMEM		Cannot allocate resources
319a6d42e7dSPeter Dunlap  *    EINVAL		Invalid parameter
320a6d42e7dSPeter Dunlap  *    EEXIST		Portal already configured for another portal group
321a6d42e7dSPeter Dunlap  *			associated with this target.
322a6d42e7dSPeter Dunlap  */
323a6d42e7dSPeter Dunlap int
324a6d42e7dSPeter Dunlap it_tpg_create(it_config_t *cfg, it_tpg_t **tpg, char *tpg_name,
325a6d42e7dSPeter Dunlap     char *portal_ip_port);
326a6d42e7dSPeter Dunlap 
327a6d42e7dSPeter Dunlap /*
328a6d42e7dSPeter Dunlap  * Function:  it_tpg_delete()
329a6d42e7dSPeter Dunlap  *
330a6d42e7dSPeter Dunlap  * Delete target portal group represented by 'tpg', where 'tpg' is an
331a6d42e7dSPeter Dunlap  * existing it_tpg_t structure within the global configuration 'cfg'.
332a6d42e7dSPeter Dunlap  * The target portal group removal will not take effect until the
333a6d42e7dSPeter Dunlap  * modified configuration is committed by calling it_config_commit().
334a6d42e7dSPeter Dunlap  *
335a6d42e7dSPeter Dunlap  * Parameters:
336a6d42e7dSPeter Dunlap  *    cfg		The current iSCSI configuration obtained from
337a6d42e7dSPeter Dunlap  *			it_config_load()
338a6d42e7dSPeter Dunlap  *    tpg		Pointer to the it_tpg_t structure representing
339a6d42e7dSPeter Dunlap  *			the target portal group
340a6d42e7dSPeter Dunlap  *    force		Remove this target portal group even if it's
341a6d42e7dSPeter Dunlap  *			associated with one or more targets.
342a6d42e7dSPeter Dunlap  *
343a6d42e7dSPeter Dunlap  * Return Values:
344a6d42e7dSPeter Dunlap  *    0			Success
345a6d42e7dSPeter Dunlap  *    EINVAL		Invalid parameter
346a6d42e7dSPeter Dunlap  *    EBUSY		Portal group associated with one or more targets.
347a6d42e7dSPeter Dunlap  */
348a6d42e7dSPeter Dunlap int
349a6d42e7dSPeter Dunlap it_tpg_delete(it_config_t *cfg, it_tpg_t *tpg, boolean_t force);
350a6d42e7dSPeter Dunlap 
351a6d42e7dSPeter Dunlap /*
352a6d42e7dSPeter Dunlap  * Function:  it_portal_create()
353a6d42e7dSPeter Dunlap  *
354a6d42e7dSPeter Dunlap  * Add an it_portal_t structure representing a new portal to the specified
355a6d42e7dSPeter Dunlap  * target portal group.  The change to the target portal group will not take
356a6d42e7dSPeter Dunlap  * effect until the modified configuration is committed by calling
357a6d42e7dSPeter Dunlap  * it_config_commit().
358a6d42e7dSPeter Dunlap  *
359a6d42e7dSPeter Dunlap  * Parameters:
360a6d42e7dSPeter Dunlap  *    cfg		The current iSCSI configration obtained from
361a6d42e7dSPeter Dunlap  *			it_config_load()
362a6d42e7dSPeter Dunlap  *    tpg		Pointer to the it_tpg_t structure representing the
363a6d42e7dSPeter Dunlap  *			target portal group or "none" to remove
364a6d42e7dSPeter Dunlap  *    portal		Pointer to the it_portal_t structure representing
365a6d42e7dSPeter Dunlap  *			the portal
366a6d42e7dSPeter Dunlap  *    portal_ip_port	A string containing an appropriately formatted
367a6d42e7dSPeter Dunlap  *			IP address or IP address:port in either IPv4 or
368a6d42e7dSPeter Dunlap  *			IPv6 format.
369a6d42e7dSPeter Dunlap  * Return Values:
370a6d42e7dSPeter Dunlap  *    0			Success
371a6d42e7dSPeter Dunlap  *    ENOMEM		Could not allocate resources
372a6d42e7dSPeter Dunlap  *    EINVAL		Invalid parameter
373a6d42e7dSPeter Dunlap  *    EEXIST		Portal already configured for another portal group
374a6d42e7dSPeter Dunlap  */
375a6d42e7dSPeter Dunlap int
376a6d42e7dSPeter Dunlap it_portal_create(it_config_t *cfg, it_tpg_t *tpg, it_portal_t **portal,
377a6d42e7dSPeter Dunlap     char *portal_ip_port);
378a6d42e7dSPeter Dunlap 
379a6d42e7dSPeter Dunlap /*
380a6d42e7dSPeter Dunlap  * Function:  it_portal_delete()
381a6d42e7dSPeter Dunlap  *
382a6d42e7dSPeter Dunlap  * Remove the specified portal from the specified target portal group.
383a6d42e7dSPeter Dunlap  * The portal removal will not take effect until the modified configuration
384a6d42e7dSPeter Dunlap  * is committed by calling it_config_commit().
385a6d42e7dSPeter Dunlap  *
386a6d42e7dSPeter Dunlap  * Parameters:
387a6d42e7dSPeter Dunlap  *    cfg		The current iSCSI configration obtained from
388a6d42e7dSPeter Dunlap  *			it_config_load()
389a6d42e7dSPeter Dunlap  *    tpg		Pointer to the it_tpg_t structure representing the
390a6d42e7dSPeter Dunlap  *			target portal group
391a6d42e7dSPeter Dunlap  *    portal		Pointer to the it_portal_t structure representing
392a6d42e7dSPeter Dunlap  *			the portal
393a6d42e7dSPeter Dunlap  */
394a6d42e7dSPeter Dunlap void
395a6d42e7dSPeter Dunlap it_portal_delete(it_config_t *cfg, it_tpg_t *tpg, it_portal_t *portal);
396a6d42e7dSPeter Dunlap 
397a6d42e7dSPeter Dunlap /*
398a6d42e7dSPeter Dunlap  * Function:  it_ini_create()
399a6d42e7dSPeter Dunlap  *
400a6d42e7dSPeter Dunlap  * Add an initiator context to the global configuration. The new
401a6d42e7dSPeter Dunlap  * initiator context will not be instantiated until the modified
402a6d42e7dSPeter Dunlap  * configuration is committed by calling it_config_commit().
403a6d42e7dSPeter Dunlap  *
404a6d42e7dSPeter Dunlap  * Parameters:
405a6d42e7dSPeter Dunlap  *    cfg		The current iSCSI configration obtained from
406a6d42e7dSPeter Dunlap  *			it_config_load()
407a6d42e7dSPeter Dunlap  *    ini		Pointer to the it_ini_t structure representing
408a6d42e7dSPeter Dunlap  *			the initiator context.
409a6d42e7dSPeter Dunlap  *    ini_node_name	The iSCSI node name of the remote initiator.
410a6d42e7dSPeter Dunlap  *
411a6d42e7dSPeter Dunlap  * Return Values:
412a6d42e7dSPeter Dunlap  *    0			Success
413a6d42e7dSPeter Dunlap  *    ENOMEM		Could not allocate resources
414a6d42e7dSPeter Dunlap  *    EINVAL		Invalid parameter.
415a6d42e7dSPeter Dunlap  *    EEXIST		Initiator already configured
416a6d42e7dSPeter Dunlap  *    EFAULT		Invalid initiator name
417a6d42e7dSPeter Dunlap  */
418a6d42e7dSPeter Dunlap int
419a6d42e7dSPeter Dunlap it_ini_create(it_config_t *cfg, it_ini_t **ini, char *ini_node_name);
420a6d42e7dSPeter Dunlap 
421a6d42e7dSPeter Dunlap /*
422a6d42e7dSPeter Dunlap  * Function:  it_ini_setprop()
423a6d42e7dSPeter Dunlap  *
424a6d42e7dSPeter Dunlap  * Validate the provided property list and set the initiator properties.
425a6d42e7dSPeter Dunlap  * If errlist is not NULL, returns detailed errors for each property
426a6d42e7dSPeter Dunlap  * that failed.  The format for errorlist is
427a6d42e7dSPeter Dunlap  *		 key = property, value = error string.
428a6d42e7dSPeter Dunlap  *
429a6d42e7dSPeter Dunlap  * Parameters:
430a6d42e7dSPeter Dunlap  *
431a6d42e7dSPeter Dunlap  *    ini		The initiator being updated.
432a6d42e7dSPeter Dunlap  *    proplist		nvlist_t containing properties for this target.
433a6d42e7dSPeter Dunlap  *    errlist		(optional)  nvlist_t of errors encountered when
434a6d42e7dSPeter Dunlap  *			validating the properties.
435a6d42e7dSPeter Dunlap  *
436a6d42e7dSPeter Dunlap  * Return Values:
437a6d42e7dSPeter Dunlap  *    0			Success
438a6d42e7dSPeter Dunlap  *    ENOMEM		Could not allocate resources
439a6d42e7dSPeter Dunlap  *    EINVAL		Invalid property
440a6d42e7dSPeter Dunlap  *
441a6d42e7dSPeter Dunlap  */
442a6d42e7dSPeter Dunlap int
443a6d42e7dSPeter Dunlap it_ini_setprop(it_ini_t *ini, nvlist_t *proplist, nvlist_t **errlist);
444a6d42e7dSPeter Dunlap 
445a6d42e7dSPeter Dunlap /*
446a6d42e7dSPeter Dunlap  * Function:  it_ini_delete()
447a6d42e7dSPeter Dunlap  *
448a6d42e7dSPeter Dunlap  * Remove the specified initiator context from the global configuration.
449a6d42e7dSPeter Dunlap  * The removal will not take effect until the modified configuration is
450a6d42e7dSPeter Dunlap  * committed by calling it_config_commit().
451a6d42e7dSPeter Dunlap  *
452a6d42e7dSPeter Dunlap  * Parameters:
453a6d42e7dSPeter Dunlap  *    cfg		The current iSCSI configration obtained from
454a6d42e7dSPeter Dunlap  *			it_config_load()
455a6d42e7dSPeter Dunlap  *    ini		Pointer to the it_ini_t structure representing
456a6d42e7dSPeter Dunlap  *			the initiator context.
457a6d42e7dSPeter Dunlap  */
458a6d42e7dSPeter Dunlap void
459a6d42e7dSPeter Dunlap it_ini_delete(it_config_t *cfg, it_ini_t *ini);
460a6d42e7dSPeter Dunlap 
461a6d42e7dSPeter Dunlap /*
462a6d42e7dSPeter Dunlap  * Function:  it_config_free()
463a6d42e7dSPeter Dunlap  *
464a6d42e7dSPeter Dunlap  * Free any resources associated with the it_config_t structure.
465a6d42e7dSPeter Dunlap  *
466a6d42e7dSPeter Dunlap  * Parameters:
467a6d42e7dSPeter Dunlap  *    cfg       A C representation of the current iSCSI configuration
468a6d42e7dSPeter Dunlap  */
469a6d42e7dSPeter Dunlap void
470a6d42e7dSPeter Dunlap it_config_free(it_config_t *cfg);
471a6d42e7dSPeter Dunlap 
472a6d42e7dSPeter Dunlap /*
473a6d42e7dSPeter Dunlap  * Function:  it_tgt_free()
474a6d42e7dSPeter Dunlap  *
475a6d42e7dSPeter Dunlap  * Frees an it_tgt_t structure.  If tgt_next is not NULL, frees
476a6d42e7dSPeter Dunlap  * all structures in the list.
477a6d42e7dSPeter Dunlap  */
478a6d42e7dSPeter Dunlap void
479a6d42e7dSPeter Dunlap it_tgt_free(it_tgt_t *tgt);
480a6d42e7dSPeter Dunlap 
481a6d42e7dSPeter Dunlap /*
482a6d42e7dSPeter Dunlap  * Function:  it_tpgt_free()
483a6d42e7dSPeter Dunlap  *
484a6d42e7dSPeter Dunlap  * Deallocates resources of an it_tpgt_t structure.  If tpgt->next
485a6d42e7dSPeter Dunlap  * is not NULL, frees all members of the list.
486a6d42e7dSPeter Dunlap  */
487a6d42e7dSPeter Dunlap void
488a6d42e7dSPeter Dunlap it_tpgt_free(it_tpgt_t *tpgt);
489a6d42e7dSPeter Dunlap 
490a6d42e7dSPeter Dunlap /*
491a6d42e7dSPeter Dunlap  * Function:  it_tpg_free()
492a6d42e7dSPeter Dunlap  *
493a6d42e7dSPeter Dunlap  * Deallocates resources associated with an it_tpg_t structure.
494a6d42e7dSPeter Dunlap  * If tpg->next is not NULL, frees all members of the list.
495a6d42e7dSPeter Dunlap  */
496a6d42e7dSPeter Dunlap void
497a6d42e7dSPeter Dunlap it_tpg_free(it_tpg_t *tpg);
498a6d42e7dSPeter Dunlap 
499a6d42e7dSPeter Dunlap /*
500a6d42e7dSPeter Dunlap  * Function:  it_ini_free()
501a6d42e7dSPeter Dunlap  *
502a6d42e7dSPeter Dunlap  * Deallocates resources of an it_ini_t structure. If ini->next is
503a6d42e7dSPeter Dunlap  * not NULL, frees all members of the list.
504a6d42e7dSPeter Dunlap  */
505a6d42e7dSPeter Dunlap void
506a6d42e7dSPeter Dunlap it_ini_free(it_ini_t *ini);
507a6d42e7dSPeter Dunlap 
508a6d42e7dSPeter Dunlap /*
509a6d42e7dSPeter Dunlap  * Function:  validate_iscsi_name()
510a6d42e7dSPeter Dunlap  *
511a6d42e7dSPeter Dunlap  * Ensures the passed-in string is a valid IQN or EUI iSCSI name
512a6d42e7dSPeter Dunlap  */
513a6d42e7dSPeter Dunlap boolean_t
514a6d42e7dSPeter Dunlap validate_iscsi_name(char *in_name);
515a6d42e7dSPeter Dunlap 
516a6d42e7dSPeter Dunlap #ifdef	__cplusplus
517a6d42e7dSPeter Dunlap }
518a6d42e7dSPeter Dunlap #endif
519a6d42e7dSPeter Dunlap 
520a6d42e7dSPeter Dunlap #endif	/* _LIBISCSIT_H */
521