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