xref: /onnv-gate/usr/src/lib/libiscsit/common/libiscsit.h (revision 8062:c4ebf3c55811)
17978SPeter.Dunlap@Sun.COM /*
27978SPeter.Dunlap@Sun.COM  * CDDL HEADER START
37978SPeter.Dunlap@Sun.COM  *
47978SPeter.Dunlap@Sun.COM  * The contents of this file are subject to the terms of the
57978SPeter.Dunlap@Sun.COM  * Common Development and Distribution License (the "License").
67978SPeter.Dunlap@Sun.COM  * You may not use this file except in compliance with the License.
77978SPeter.Dunlap@Sun.COM  *
87978SPeter.Dunlap@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97978SPeter.Dunlap@Sun.COM  * or http://www.opensolaris.org/os/licensing.
107978SPeter.Dunlap@Sun.COM  * See the License for the specific language governing permissions
117978SPeter.Dunlap@Sun.COM  * and limitations under the License.
127978SPeter.Dunlap@Sun.COM  *
137978SPeter.Dunlap@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
147978SPeter.Dunlap@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157978SPeter.Dunlap@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
167978SPeter.Dunlap@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
177978SPeter.Dunlap@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
187978SPeter.Dunlap@Sun.COM  *
197978SPeter.Dunlap@Sun.COM  * CDDL HEADER END
207978SPeter.Dunlap@Sun.COM  */
217978SPeter.Dunlap@Sun.COM /*
227978SPeter.Dunlap@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237978SPeter.Dunlap@Sun.COM  * Use is subject to license terms.
247978SPeter.Dunlap@Sun.COM  */
257978SPeter.Dunlap@Sun.COM 
267978SPeter.Dunlap@Sun.COM #ifndef	_LIBISCSIT_H
277978SPeter.Dunlap@Sun.COM #define	_LIBISCSIT_H
287978SPeter.Dunlap@Sun.COM 
297978SPeter.Dunlap@Sun.COM #ifndef _KERNEL
307978SPeter.Dunlap@Sun.COM #include <libnvpair.h>
317978SPeter.Dunlap@Sun.COM #include <sys/socket.h>
327978SPeter.Dunlap@Sun.COM #endif
337978SPeter.Dunlap@Sun.COM 
34*8062SPeter.Dunlap@Sun.COM #include <sys/iscsit/iscsit_common.h>
35*8062SPeter.Dunlap@Sun.COM 
367978SPeter.Dunlap@Sun.COM #ifdef	__cplusplus
377978SPeter.Dunlap@Sun.COM extern "C" {
387978SPeter.Dunlap@Sun.COM #endif
397978SPeter.Dunlap@Sun.COM 
407978SPeter.Dunlap@Sun.COM #define	MAX_TPGT	256
417978SPeter.Dunlap@Sun.COM #define	CFG_TPGTLIST	"tpgt-list"
427978SPeter.Dunlap@Sun.COM 
437978SPeter.Dunlap@Sun.COM /*
447978SPeter.Dunlap@Sun.COM  * Object Hierarchy
457978SPeter.Dunlap@Sun.COM  *
467978SPeter.Dunlap@Sun.COM  *  _______________________
477978SPeter.Dunlap@Sun.COM  * |                       |
487978SPeter.Dunlap@Sun.COM  * |  iSCSI Target Config  |
497978SPeter.Dunlap@Sun.COM  * |      it_config_t      |
507978SPeter.Dunlap@Sun.COM  * |_______________________|
517978SPeter.Dunlap@Sun.COM  *    |     |
527978SPeter.Dunlap@Sun.COM  *    |     |
537978SPeter.Dunlap@Sun.COM  *    |     |      ________     ________              ________
547978SPeter.Dunlap@Sun.COM  *    |     |     |        |   |        |            |        |
557978SPeter.Dunlap@Sun.COM  *    |     |     | Target |-->| Target |--  - -  -->| Target |
567978SPeter.Dunlap@Sun.COM  *    |     |     |________|   |________|            |________|
577978SPeter.Dunlap@Sun.COM  *    |     |           |
587978SPeter.Dunlap@Sun.COM  *    |     |           |
597978SPeter.Dunlap@Sun.COM  *    |     |           |
607978SPeter.Dunlap@Sun.COM  *    |     |           |       ______              ______
617978SPeter.Dunlap@Sun.COM  *    |     |           |      |      |            |      |
627978SPeter.Dunlap@Sun.COM  *    |     |           +----->| TPGT |--  - -  -->| TPGT |
637978SPeter.Dunlap@Sun.COM  *    |     |                  |______|            |______|
647978SPeter.Dunlap@Sun.COM  *    |     |                       |                   |
657978SPeter.Dunlap@Sun.COM  *    |  +--+                       |                   |
667978SPeter.Dunlap@Sun.COM  *    |  |   _______     _______    |         ______    |
677978SPeter.Dunlap@Sun.COM  *    |  |  |       |   |       |<--+        |      |<--+
687978SPeter.Dunlap@Sun.COM  *    |  +->|  TPG  |-->|  TPG  |--  - -  -->| TPG  |
697978SPeter.Dunlap@Sun.COM  *    |     |_______|   |_______|            |______|
707978SPeter.Dunlap@Sun.COM  *    |
717978SPeter.Dunlap@Sun.COM  *    |      ___________     ___________              ___________
727978SPeter.Dunlap@Sun.COM  *    |     |           |   |           |            |           |
737978SPeter.Dunlap@Sun.COM  *    +---->| Initiator |-->| Initiator |--  - -  -->| Initiator |
747978SPeter.Dunlap@Sun.COM  *          |  Context  |   |  Context  |            |  Context  |
757978SPeter.Dunlap@Sun.COM  *          |___________|   |___________|            |___________|
767978SPeter.Dunlap@Sun.COM  *
777978SPeter.Dunlap@Sun.COM  *
787978SPeter.Dunlap@Sun.COM  * it_config_t includes a list of global properties
797978SPeter.Dunlap@Sun.COM  *
807978SPeter.Dunlap@Sun.COM  * Targets include a list of properties which override the global properties
817978SPeter.Dunlap@Sun.COM  * if set
827978SPeter.Dunlap@Sun.COM  *
837978SPeter.Dunlap@Sun.COM  * Initiators also include a list of properties but never inherit properties
847978SPeter.Dunlap@Sun.COM  * from the global config.
857978SPeter.Dunlap@Sun.COM  */
867978SPeter.Dunlap@Sun.COM 
877978SPeter.Dunlap@Sun.COM /*
887978SPeter.Dunlap@Sun.COM  * Function:  it_config_load()
897978SPeter.Dunlap@Sun.COM  *
907978SPeter.Dunlap@Sun.COM  * Allocate and create an it_config_t structure representing the
917978SPeter.Dunlap@Sun.COM  * current iSCSI configuration.  This structure is compiled using
927978SPeter.Dunlap@Sun.COM  * the 'provider' data returned by stmfGetProviderData().  If there
937978SPeter.Dunlap@Sun.COM  * is no provider data associated with iscsit, the it_config_t
947978SPeter.Dunlap@Sun.COM  * structure will be set to a default configuration.
957978SPeter.Dunlap@Sun.COM  *
967978SPeter.Dunlap@Sun.COM  * Parameters:
977978SPeter.Dunlap@Sun.COM  *    cfg		A C representation of the current iSCSI configuration
987978SPeter.Dunlap@Sun.COM  *
997978SPeter.Dunlap@Sun.COM  * Return Values:
1007978SPeter.Dunlap@Sun.COM  *    0			Success
1017978SPeter.Dunlap@Sun.COM  *    ENOMEM		Could not allocate resources
1027978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid parameter
1037978SPeter.Dunlap@Sun.COM  */
1047978SPeter.Dunlap@Sun.COM int
1057978SPeter.Dunlap@Sun.COM it_config_load(it_config_t **cfg);
1067978SPeter.Dunlap@Sun.COM 
1077978SPeter.Dunlap@Sun.COM /*
1087978SPeter.Dunlap@Sun.COM  * Function:  it_config_commit()
1097978SPeter.Dunlap@Sun.COM  *
1107978SPeter.Dunlap@Sun.COM  * Informs the iscsit service that the configuration has changed and
1117978SPeter.Dunlap@Sun.COM  * commits the new configuration to persistent store by calling
1127978SPeter.Dunlap@Sun.COM  * stmfSetProviderData.  This function can be called multiple times
1137978SPeter.Dunlap@Sun.COM  * during a configuration sequence if necessary.
1147978SPeter.Dunlap@Sun.COM  *
1157978SPeter.Dunlap@Sun.COM  * Parameters:
1167978SPeter.Dunlap@Sun.COM  *    cfg		A C representation of the current iSCSI configuration
1177978SPeter.Dunlap@Sun.COM  *
1187978SPeter.Dunlap@Sun.COM  * Return Values:
1197978SPeter.Dunlap@Sun.COM  *    0			Success
1207978SPeter.Dunlap@Sun.COM  *    ENOMEM		Could not allocate resources
1217978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid it_config_t structure
1227978SPeter.Dunlap@Sun.COM  *    STMF_ERROR_SERVICE_DATA_VERSION	Configuration was updated by another
1237978SPeter.Dunlap@Sun.COM  *			client.  See stmfSetProviderDataProt().
1247978SPeter.Dunlap@Sun.COM  */
1257978SPeter.Dunlap@Sun.COM int
1267978SPeter.Dunlap@Sun.COM it_config_commit(it_config_t *cfg);
1277978SPeter.Dunlap@Sun.COM 
1287978SPeter.Dunlap@Sun.COM /*
1297978SPeter.Dunlap@Sun.COM  * Function:  it_config_setprop()
1307978SPeter.Dunlap@Sun.COM  *
1317978SPeter.Dunlap@Sun.COM  * Validate the provided property list and set the global properties
1327978SPeter.Dunlap@Sun.COM  * for iSCSI Target.  If errlist is not NULL, returns detailed
1337978SPeter.Dunlap@Sun.COM  * errors for each property that failed.  The format for errorlist
1347978SPeter.Dunlap@Sun.COM  * is key = property, value = error string.
1357978SPeter.Dunlap@Sun.COM  *
1367978SPeter.Dunlap@Sun.COM  * Parameters:
1377978SPeter.Dunlap@Sun.COM  *
1387978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configuration obtained from
1397978SPeter.Dunlap@Sun.COM  *			it_config_load()
1407978SPeter.Dunlap@Sun.COM  *    proplist		nvlist_t containing properties for this target.
1417978SPeter.Dunlap@Sun.COM  *    errlist		(optional)  nvlist_t of errors encountered when
1427978SPeter.Dunlap@Sun.COM  *			validating the properties.
1437978SPeter.Dunlap@Sun.COM  *
1447978SPeter.Dunlap@Sun.COM  * Return Values:
1457978SPeter.Dunlap@Sun.COM  *    0			Success
1467978SPeter.Dunlap@Sun.COM  *    ENOMEM		Could not allocate resources
1477978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid property
1487978SPeter.Dunlap@Sun.COM  *
1497978SPeter.Dunlap@Sun.COM  */
1507978SPeter.Dunlap@Sun.COM int
1517978SPeter.Dunlap@Sun.COM it_config_setprop(it_config_t *cfg, nvlist_t *proplist, nvlist_t **errlist);
1527978SPeter.Dunlap@Sun.COM 
1537978SPeter.Dunlap@Sun.COM /*
1547978SPeter.Dunlap@Sun.COM  * Function:  it_config_free()
1557978SPeter.Dunlap@Sun.COM  *
1567978SPeter.Dunlap@Sun.COM  * Free any resources associated with the it_config_t structure.
1577978SPeter.Dunlap@Sun.COM  *
1587978SPeter.Dunlap@Sun.COM  * Parameters:
1597978SPeter.Dunlap@Sun.COM  *    cfg		A C representation of the current iSCSI configuration
1607978SPeter.Dunlap@Sun.COM  */
1617978SPeter.Dunlap@Sun.COM void
1627978SPeter.Dunlap@Sun.COM it_config_free(it_config_t *cfg);
1637978SPeter.Dunlap@Sun.COM 
1647978SPeter.Dunlap@Sun.COM /*
1657978SPeter.Dunlap@Sun.COM  * Function:  it_tgt_create()
1667978SPeter.Dunlap@Sun.COM  *
1677978SPeter.Dunlap@Sun.COM  * Allocate and create an it_tgt_t structure representing a new iSCSI
1687978SPeter.Dunlap@Sun.COM  * target node.  If tgt_name is NULL, then a unique target node name will
1697978SPeter.Dunlap@Sun.COM  * be generated automatically.  Otherwise, the value of tgt_name will be
1707978SPeter.Dunlap@Sun.COM  * used as the target node name.  The new it_tgt_t structure is added to
1717978SPeter.Dunlap@Sun.COM  * the target list (cfg_tgt_list) in the configuration structure, and the
1727978SPeter.Dunlap@Sun.COM  * new target will not be instantiated until the modified configuration
1737978SPeter.Dunlap@Sun.COM  * is committed by calling it_config_commit().
1747978SPeter.Dunlap@Sun.COM  *
1757978SPeter.Dunlap@Sun.COM  * Parameters:
1767978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configuration obtained from
1777978SPeter.Dunlap@Sun.COM  *			it_config_load()
1787978SPeter.Dunlap@Sun.COM  *    tgt		Pointer to an iSCSI target structure
1797978SPeter.Dunlap@Sun.COM  *    tgt_name		The target node name for the target to be created.
1807978SPeter.Dunlap@Sun.COM  *			The name must be in either IQN or EUI format.  If
1817978SPeter.Dunlap@Sun.COM  *			this value is NULL, a node name will be generated
1827978SPeter.Dunlap@Sun.COM  *			automatically in IQN format.
1837978SPeter.Dunlap@Sun.COM  *
1847978SPeter.Dunlap@Sun.COM  * Return Values:
1857978SPeter.Dunlap@Sun.COM  *    0			Success
1867978SPeter.Dunlap@Sun.COM  *    ENOMEM		Could not allocate resources
1877978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid parameter
1887978SPeter.Dunlap@Sun.COM  *    EEXIST		The requested target node name is already configured
1897978SPeter.Dunlap@Sun.COM  *    EFAULT		Invalid iSCSI target name
1907978SPeter.Dunlap@Sun.COM  */
1917978SPeter.Dunlap@Sun.COM int
1927978SPeter.Dunlap@Sun.COM it_tgt_create(it_config_t *cfg, it_tgt_t **tgt, char *tgt_name);
1937978SPeter.Dunlap@Sun.COM 
1947978SPeter.Dunlap@Sun.COM /*
1957978SPeter.Dunlap@Sun.COM  * Function:  it_tgt_setprop()
1967978SPeter.Dunlap@Sun.COM  *
1977978SPeter.Dunlap@Sun.COM  * Validate the provided property list and set the properties for
1987978SPeter.Dunlap@Sun.COM  * the specified target.  If errlist is not NULL, returns detailed
1997978SPeter.Dunlap@Sun.COM  * errors for each property that failed.  The format for errorlist
2007978SPeter.Dunlap@Sun.COM  * is key = property, value = error string.
2017978SPeter.Dunlap@Sun.COM  *
2027978SPeter.Dunlap@Sun.COM  * Parameters:
2037978SPeter.Dunlap@Sun.COM  *
2047978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configuration obtained from
2057978SPeter.Dunlap@Sun.COM  *			it_config_load()
2067978SPeter.Dunlap@Sun.COM  *    tgt		Pointer to an iSCSI target structure
2077978SPeter.Dunlap@Sun.COM  *    proplist		nvlist_t containing properties for this target.
2087978SPeter.Dunlap@Sun.COM  *    errlist		(optional)  nvlist_t of errors encountered when
2097978SPeter.Dunlap@Sun.COM  *			validating the properties.
2107978SPeter.Dunlap@Sun.COM  *
2117978SPeter.Dunlap@Sun.COM  * Return Values:
2127978SPeter.Dunlap@Sun.COM  *    0			Success
2137978SPeter.Dunlap@Sun.COM  *    ENOMEM		Could not allocate resources
2147978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid property
2157978SPeter.Dunlap@Sun.COM  *
2167978SPeter.Dunlap@Sun.COM  */
2177978SPeter.Dunlap@Sun.COM int
2187978SPeter.Dunlap@Sun.COM it_tgt_setprop(it_config_t *cfg, it_tgt_t *tgt, nvlist_t *proplist,
2197978SPeter.Dunlap@Sun.COM     nvlist_t **errlist);
2207978SPeter.Dunlap@Sun.COM 
2217978SPeter.Dunlap@Sun.COM 
2227978SPeter.Dunlap@Sun.COM /*
2237978SPeter.Dunlap@Sun.COM  * Function:  it_tgt_delete()
2247978SPeter.Dunlap@Sun.COM  *
2257978SPeter.Dunlap@Sun.COM  * Delete target represented by 'tgt', where 'tgt' is an existing
2267978SPeter.Dunlap@Sun.COM  * it_tgt_t structure within the configuration 'cfg'.  The target removal
2277978SPeter.Dunlap@Sun.COM  * will not take effect until the modified configuration is committed
2287978SPeter.Dunlap@Sun.COM  * by calling it_config_commit().
2297978SPeter.Dunlap@Sun.COM  *
2307978SPeter.Dunlap@Sun.COM  * Parameters:
2317978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configuration obtained from
2327978SPeter.Dunlap@Sun.COM  *			it_config_load()
2337978SPeter.Dunlap@Sun.COM  *    tgt		Pointer to an iSCSI target structure
2347978SPeter.Dunlap@Sun.COM  *    force		Set the target to offline before removing it from
2357978SPeter.Dunlap@Sun.COM  *			the config.  If not specified, the operation will
2367978SPeter.Dunlap@Sun.COM  *			fail if the target is determined to be online.
2377978SPeter.Dunlap@Sun.COM  *
2387978SPeter.Dunlap@Sun.COM  * Return Values:
2397978SPeter.Dunlap@Sun.COM  *    0			Success
2407978SPeter.Dunlap@Sun.COM  *    EBUSY		Target is online
2417978SPeter.Dunlap@Sun.COM  */
2427978SPeter.Dunlap@Sun.COM int
2437978SPeter.Dunlap@Sun.COM it_tgt_delete(it_config_t *cfg, it_tgt_t *tgt, boolean_t force);
2447978SPeter.Dunlap@Sun.COM 
2457978SPeter.Dunlap@Sun.COM /*
2467978SPeter.Dunlap@Sun.COM  * Function:  it_tpgt_create()
2477978SPeter.Dunlap@Sun.COM  *
2487978SPeter.Dunlap@Sun.COM  * Allocate and create an it_tpgt_t structure representing a new iSCSI
2497978SPeter.Dunlap@Sun.COM  * target portal group tag.  The new it_tpgt_t structure is added to the
2507978SPeter.Dunlap@Sun.COM  * target tpgt list (tgt_tpgt_list) in the it_tgt_t structure.  The new
2517978SPeter.Dunlap@Sun.COM  * target portal group tag will not be instantiated until the modified
2527978SPeter.Dunlap@Sun.COM  * configuration is committed by calling it_config_commit().
2537978SPeter.Dunlap@Sun.COM  *
2547978SPeter.Dunlap@Sun.COM  * Parameters:
2557978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configuration obtained from
2567978SPeter.Dunlap@Sun.COM  *			it_config_load()
2577978SPeter.Dunlap@Sun.COM  *    tgt		Pointer to the iSCSI target structure associated
2587978SPeter.Dunlap@Sun.COM  *			with the target portal group tag
2597978SPeter.Dunlap@Sun.COM  *    tpgt		Pointer to a target portal group tag structure
2607978SPeter.Dunlap@Sun.COM  *    tpg_name		The name of the TPG to be associated with this TPGT
2617978SPeter.Dunlap@Sun.COM  *    tpgt_tag		16-bit numerical identifier for this TPGT.  Valid
2627978SPeter.Dunlap@Sun.COM  *			values are 2 through 65535.  If tpgt_tag is '0',
2637978SPeter.Dunlap@Sun.COM  *			this function will assign an appropriate tag number.
2647978SPeter.Dunlap@Sun.COM  *			If tpgt_tag is != 0, and the requested number is
2657978SPeter.Dunlap@Sun.COM  *			unavailable, another value will be chosen.
2667978SPeter.Dunlap@Sun.COM  *
2677978SPeter.Dunlap@Sun.COM  * Return Values:
2687978SPeter.Dunlap@Sun.COM  *    0			Success
2697978SPeter.Dunlap@Sun.COM  *    ENOMEM		Could not allocate resources
2707978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid parameter
2717978SPeter.Dunlap@Sun.COM  *    EEXIST		Specified TPG is already associated with the target
2727978SPeter.Dunlap@Sun.COM  *    E2BIG		All tag numbers already in use
2737978SPeter.Dunlap@Sun.COM  */
2747978SPeter.Dunlap@Sun.COM int
2757978SPeter.Dunlap@Sun.COM it_tpgt_create(it_config_t *cfg, it_tgt_t *tgt, it_tpgt_t **tpgt,
2767978SPeter.Dunlap@Sun.COM     char *tpg_name, uint16_t tpgt_tag);
2777978SPeter.Dunlap@Sun.COM 
2787978SPeter.Dunlap@Sun.COM /*
2797978SPeter.Dunlap@Sun.COM  * Function:  it_tpgt_delete()
2807978SPeter.Dunlap@Sun.COM  *
2817978SPeter.Dunlap@Sun.COM  * Delete the target portal group tag represented by 'tpgt', where
2827978SPeter.Dunlap@Sun.COM  * 'tpgt' is an existing is_tpgt_t structure within the target 'tgt'.
2837978SPeter.Dunlap@Sun.COM  * The target portal group tag removal will not take effect until the
2847978SPeter.Dunlap@Sun.COM  * modified configuation is committed by calling it_config_commit().
2857978SPeter.Dunlap@Sun.COM  *
2867978SPeter.Dunlap@Sun.COM  * Parameters:
2877978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configuration obtained from
2887978SPeter.Dunlap@Sun.COM  *			it_config_load()
2897978SPeter.Dunlap@Sun.COM  *    tgt		Pointer to the iSCSI target structure associated
2907978SPeter.Dunlap@Sun.COM  *			with the target portal group tag
2917978SPeter.Dunlap@Sun.COM  *    tpgt		Pointer to a target portal group tag structure
2927978SPeter.Dunlap@Sun.COM  */
2937978SPeter.Dunlap@Sun.COM void
2947978SPeter.Dunlap@Sun.COM it_tpgt_delete(it_config_t *cfg, it_tgt_t *tgt, it_tpgt_t *tpgt);
2957978SPeter.Dunlap@Sun.COM 
2967978SPeter.Dunlap@Sun.COM /*
2977978SPeter.Dunlap@Sun.COM  * Function:  it_tpg_create()
2987978SPeter.Dunlap@Sun.COM  *
2997978SPeter.Dunlap@Sun.COM  * Allocate and create an it_tpg_t structure representing a new iSCSI
3007978SPeter.Dunlap@Sun.COM  * target portal group.  The new it_tpg_t structure is added to the global
3017978SPeter.Dunlap@Sun.COM  * tpg list (cfg_tgt_list) in the it_config_t structure.  The new target
3027978SPeter.Dunlap@Sun.COM  * portal group will not be instantiated until the modified configuration
3037978SPeter.Dunlap@Sun.COM  * is committed by calling it_config_commit().
3047978SPeter.Dunlap@Sun.COM  *
3057978SPeter.Dunlap@Sun.COM  * Parameters:
3067978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configuration obtained from
3077978SPeter.Dunlap@Sun.COM  *			it_config_load()
3087978SPeter.Dunlap@Sun.COM  *    tpg		Pointer to the it_tpg_t structure representing
3097978SPeter.Dunlap@Sun.COM  *			the target portal group
3107978SPeter.Dunlap@Sun.COM  *    tpg_name		Identifier for the target portal group
3117978SPeter.Dunlap@Sun.COM  *    portal_ip_port	A string containing an appropriatedly formatted
3127978SPeter.Dunlap@Sun.COM  *			IP address:port.  Both IPv4 and IPv6 addresses are
3137978SPeter.Dunlap@Sun.COM  *			permitted.  This value becomes the first portal in
3147978SPeter.Dunlap@Sun.COM  *			the TPG -- applications can add additional values
3157978SPeter.Dunlap@Sun.COM  *			using it_portal_create() before committing the TPG.
3167978SPeter.Dunlap@Sun.COM  * Return Values:
3177978SPeter.Dunlap@Sun.COM  *    0			Success
3187978SPeter.Dunlap@Sun.COM  *    ENOMEM		Cannot allocate resources
3197978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid parameter
3207978SPeter.Dunlap@Sun.COM  *    EEXIST		Portal already configured for another portal group
3217978SPeter.Dunlap@Sun.COM  *			associated with this target.
3227978SPeter.Dunlap@Sun.COM  */
3237978SPeter.Dunlap@Sun.COM int
3247978SPeter.Dunlap@Sun.COM it_tpg_create(it_config_t *cfg, it_tpg_t **tpg, char *tpg_name,
3257978SPeter.Dunlap@Sun.COM     char *portal_ip_port);
3267978SPeter.Dunlap@Sun.COM 
3277978SPeter.Dunlap@Sun.COM /*
3287978SPeter.Dunlap@Sun.COM  * Function:  it_tpg_delete()
3297978SPeter.Dunlap@Sun.COM  *
3307978SPeter.Dunlap@Sun.COM  * Delete target portal group represented by 'tpg', where 'tpg' is an
3317978SPeter.Dunlap@Sun.COM  * existing it_tpg_t structure within the global configuration 'cfg'.
3327978SPeter.Dunlap@Sun.COM  * The target portal group removal will not take effect until the
3337978SPeter.Dunlap@Sun.COM  * modified configuration is committed by calling it_config_commit().
3347978SPeter.Dunlap@Sun.COM  *
3357978SPeter.Dunlap@Sun.COM  * Parameters:
3367978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configuration obtained from
3377978SPeter.Dunlap@Sun.COM  *			it_config_load()
3387978SPeter.Dunlap@Sun.COM  *    tpg		Pointer to the it_tpg_t structure representing
3397978SPeter.Dunlap@Sun.COM  *			the target portal group
3407978SPeter.Dunlap@Sun.COM  *    force		Remove this target portal group even if it's
3417978SPeter.Dunlap@Sun.COM  *			associated with one or more targets.
3427978SPeter.Dunlap@Sun.COM  *
3437978SPeter.Dunlap@Sun.COM  * Return Values:
3447978SPeter.Dunlap@Sun.COM  *    0			Success
3457978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid parameter
3467978SPeter.Dunlap@Sun.COM  *    EBUSY		Portal group associated with one or more targets.
3477978SPeter.Dunlap@Sun.COM  */
3487978SPeter.Dunlap@Sun.COM int
3497978SPeter.Dunlap@Sun.COM it_tpg_delete(it_config_t *cfg, it_tpg_t *tpg, boolean_t force);
3507978SPeter.Dunlap@Sun.COM 
3517978SPeter.Dunlap@Sun.COM /*
3527978SPeter.Dunlap@Sun.COM  * Function:  it_portal_create()
3537978SPeter.Dunlap@Sun.COM  *
3547978SPeter.Dunlap@Sun.COM  * Add an it_portal_t structure representing a new portal to the specified
3557978SPeter.Dunlap@Sun.COM  * target portal group.  The change to the target portal group will not take
3567978SPeter.Dunlap@Sun.COM  * effect until the modified configuration is committed by calling
3577978SPeter.Dunlap@Sun.COM  * it_config_commit().
3587978SPeter.Dunlap@Sun.COM  *
3597978SPeter.Dunlap@Sun.COM  * Parameters:
3607978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configration obtained from
3617978SPeter.Dunlap@Sun.COM  *			it_config_load()
3627978SPeter.Dunlap@Sun.COM  *    tpg		Pointer to the it_tpg_t structure representing the
3637978SPeter.Dunlap@Sun.COM  *			target portal group or "none" to remove
3647978SPeter.Dunlap@Sun.COM  *    portal		Pointer to the it_portal_t structure representing
3657978SPeter.Dunlap@Sun.COM  *			the portal
3667978SPeter.Dunlap@Sun.COM  *    portal_ip_port	A string containing an appropriately formatted
3677978SPeter.Dunlap@Sun.COM  *			IP address or IP address:port in either IPv4 or
3687978SPeter.Dunlap@Sun.COM  *			IPv6 format.
3697978SPeter.Dunlap@Sun.COM  * Return Values:
3707978SPeter.Dunlap@Sun.COM  *    0			Success
3717978SPeter.Dunlap@Sun.COM  *    ENOMEM		Could not allocate resources
3727978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid parameter
3737978SPeter.Dunlap@Sun.COM  *    EEXIST		Portal already configured for another portal group
3747978SPeter.Dunlap@Sun.COM  */
3757978SPeter.Dunlap@Sun.COM int
3767978SPeter.Dunlap@Sun.COM it_portal_create(it_config_t *cfg, it_tpg_t *tpg, it_portal_t **portal,
3777978SPeter.Dunlap@Sun.COM     char *portal_ip_port);
3787978SPeter.Dunlap@Sun.COM 
3797978SPeter.Dunlap@Sun.COM /*
3807978SPeter.Dunlap@Sun.COM  * Function:  it_portal_delete()
3817978SPeter.Dunlap@Sun.COM  *
3827978SPeter.Dunlap@Sun.COM  * Remove the specified portal from the specified target portal group.
3837978SPeter.Dunlap@Sun.COM  * The portal removal will not take effect until the modified configuration
3847978SPeter.Dunlap@Sun.COM  * is committed by calling it_config_commit().
3857978SPeter.Dunlap@Sun.COM  *
3867978SPeter.Dunlap@Sun.COM  * Parameters:
3877978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configration obtained from
3887978SPeter.Dunlap@Sun.COM  *			it_config_load()
3897978SPeter.Dunlap@Sun.COM  *    tpg		Pointer to the it_tpg_t structure representing the
3907978SPeter.Dunlap@Sun.COM  *			target portal group
3917978SPeter.Dunlap@Sun.COM  *    portal		Pointer to the it_portal_t structure representing
3927978SPeter.Dunlap@Sun.COM  *			the portal
3937978SPeter.Dunlap@Sun.COM  */
3947978SPeter.Dunlap@Sun.COM void
3957978SPeter.Dunlap@Sun.COM it_portal_delete(it_config_t *cfg, it_tpg_t *tpg, it_portal_t *portal);
3967978SPeter.Dunlap@Sun.COM 
3977978SPeter.Dunlap@Sun.COM /*
3987978SPeter.Dunlap@Sun.COM  * Function:  it_ini_create()
3997978SPeter.Dunlap@Sun.COM  *
4007978SPeter.Dunlap@Sun.COM  * Add an initiator context to the global configuration. The new
4017978SPeter.Dunlap@Sun.COM  * initiator context will not be instantiated until the modified
4027978SPeter.Dunlap@Sun.COM  * configuration is committed by calling it_config_commit().
4037978SPeter.Dunlap@Sun.COM  *
4047978SPeter.Dunlap@Sun.COM  * Parameters:
4057978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configration obtained from
4067978SPeter.Dunlap@Sun.COM  *			it_config_load()
4077978SPeter.Dunlap@Sun.COM  *    ini		Pointer to the it_ini_t structure representing
4087978SPeter.Dunlap@Sun.COM  *			the initiator context.
4097978SPeter.Dunlap@Sun.COM  *    ini_node_name	The iSCSI node name of the remote initiator.
4107978SPeter.Dunlap@Sun.COM  *
4117978SPeter.Dunlap@Sun.COM  * Return Values:
4127978SPeter.Dunlap@Sun.COM  *    0			Success
4137978SPeter.Dunlap@Sun.COM  *    ENOMEM		Could not allocate resources
4147978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid parameter.
4157978SPeter.Dunlap@Sun.COM  *    EEXIST		Initiator already configured
4167978SPeter.Dunlap@Sun.COM  *    EFAULT		Invalid initiator name
4177978SPeter.Dunlap@Sun.COM  */
4187978SPeter.Dunlap@Sun.COM int
4197978SPeter.Dunlap@Sun.COM it_ini_create(it_config_t *cfg, it_ini_t **ini, char *ini_node_name);
4207978SPeter.Dunlap@Sun.COM 
4217978SPeter.Dunlap@Sun.COM /*
4227978SPeter.Dunlap@Sun.COM  * Function:  it_ini_setprop()
4237978SPeter.Dunlap@Sun.COM  *
4247978SPeter.Dunlap@Sun.COM  * Validate the provided property list and set the initiator properties.
4257978SPeter.Dunlap@Sun.COM  * If errlist is not NULL, returns detailed errors for each property
4267978SPeter.Dunlap@Sun.COM  * that failed.  The format for errorlist is
4277978SPeter.Dunlap@Sun.COM  *		 key = property, value = error string.
4287978SPeter.Dunlap@Sun.COM  *
4297978SPeter.Dunlap@Sun.COM  * Parameters:
4307978SPeter.Dunlap@Sun.COM  *
4317978SPeter.Dunlap@Sun.COM  *    ini		The initiator being updated.
4327978SPeter.Dunlap@Sun.COM  *    proplist		nvlist_t containing properties for this target.
4337978SPeter.Dunlap@Sun.COM  *    errlist		(optional)  nvlist_t of errors encountered when
4347978SPeter.Dunlap@Sun.COM  *			validating the properties.
4357978SPeter.Dunlap@Sun.COM  *
4367978SPeter.Dunlap@Sun.COM  * Return Values:
4377978SPeter.Dunlap@Sun.COM  *    0			Success
4387978SPeter.Dunlap@Sun.COM  *    ENOMEM		Could not allocate resources
4397978SPeter.Dunlap@Sun.COM  *    EINVAL		Invalid property
4407978SPeter.Dunlap@Sun.COM  *
4417978SPeter.Dunlap@Sun.COM  */
4427978SPeter.Dunlap@Sun.COM int
4437978SPeter.Dunlap@Sun.COM it_ini_setprop(it_ini_t *ini, nvlist_t *proplist, nvlist_t **errlist);
4447978SPeter.Dunlap@Sun.COM 
4457978SPeter.Dunlap@Sun.COM /*
4467978SPeter.Dunlap@Sun.COM  * Function:  it_ini_delete()
4477978SPeter.Dunlap@Sun.COM  *
4487978SPeter.Dunlap@Sun.COM  * Remove the specified initiator context from the global configuration.
4497978SPeter.Dunlap@Sun.COM  * The removal will not take effect until the modified configuration is
4507978SPeter.Dunlap@Sun.COM  * committed by calling it_config_commit().
4517978SPeter.Dunlap@Sun.COM  *
4527978SPeter.Dunlap@Sun.COM  * Parameters:
4537978SPeter.Dunlap@Sun.COM  *    cfg		The current iSCSI configration obtained from
4547978SPeter.Dunlap@Sun.COM  *			it_config_load()
4557978SPeter.Dunlap@Sun.COM  *    ini		Pointer to the it_ini_t structure representing
4567978SPeter.Dunlap@Sun.COM  *			the initiator context.
4577978SPeter.Dunlap@Sun.COM  */
4587978SPeter.Dunlap@Sun.COM void
4597978SPeter.Dunlap@Sun.COM it_ini_delete(it_config_t *cfg, it_ini_t *ini);
4607978SPeter.Dunlap@Sun.COM 
4617978SPeter.Dunlap@Sun.COM /*
4627978SPeter.Dunlap@Sun.COM  * Function:  it_config_free()
4637978SPeter.Dunlap@Sun.COM  *
4647978SPeter.Dunlap@Sun.COM  * Free any resources associated with the it_config_t structure.
4657978SPeter.Dunlap@Sun.COM  *
4667978SPeter.Dunlap@Sun.COM  * Parameters:
4677978SPeter.Dunlap@Sun.COM  *    cfg       A C representation of the current iSCSI configuration
4687978SPeter.Dunlap@Sun.COM  */
4697978SPeter.Dunlap@Sun.COM void
4707978SPeter.Dunlap@Sun.COM it_config_free(it_config_t *cfg);
4717978SPeter.Dunlap@Sun.COM 
4727978SPeter.Dunlap@Sun.COM /*
4737978SPeter.Dunlap@Sun.COM  * Function:  it_tgt_free()
4747978SPeter.Dunlap@Sun.COM  *
4757978SPeter.Dunlap@Sun.COM  * Frees an it_tgt_t structure.  If tgt_next is not NULL, frees
4767978SPeter.Dunlap@Sun.COM  * all structures in the list.
4777978SPeter.Dunlap@Sun.COM  */
4787978SPeter.Dunlap@Sun.COM void
4797978SPeter.Dunlap@Sun.COM it_tgt_free(it_tgt_t *tgt);
4807978SPeter.Dunlap@Sun.COM 
4817978SPeter.Dunlap@Sun.COM /*
4827978SPeter.Dunlap@Sun.COM  * Function:  it_tpgt_free()
4837978SPeter.Dunlap@Sun.COM  *
4847978SPeter.Dunlap@Sun.COM  * Deallocates resources of an it_tpgt_t structure.  If tpgt->next
4857978SPeter.Dunlap@Sun.COM  * is not NULL, frees all members of the list.
4867978SPeter.Dunlap@Sun.COM  */
4877978SPeter.Dunlap@Sun.COM void
4887978SPeter.Dunlap@Sun.COM it_tpgt_free(it_tpgt_t *tpgt);
4897978SPeter.Dunlap@Sun.COM 
4907978SPeter.Dunlap@Sun.COM /*
4917978SPeter.Dunlap@Sun.COM  * Function:  it_tpg_free()
4927978SPeter.Dunlap@Sun.COM  *
4937978SPeter.Dunlap@Sun.COM  * Deallocates resources associated with an it_tpg_t structure.
4947978SPeter.Dunlap@Sun.COM  * If tpg->next is not NULL, frees all members of the list.
4957978SPeter.Dunlap@Sun.COM  */
4967978SPeter.Dunlap@Sun.COM void
4977978SPeter.Dunlap@Sun.COM it_tpg_free(it_tpg_t *tpg);
4987978SPeter.Dunlap@Sun.COM 
4997978SPeter.Dunlap@Sun.COM /*
5007978SPeter.Dunlap@Sun.COM  * Function:  it_ini_free()
5017978SPeter.Dunlap@Sun.COM  *
5027978SPeter.Dunlap@Sun.COM  * Deallocates resources of an it_ini_t structure. If ini->next is
5037978SPeter.Dunlap@Sun.COM  * not NULL, frees all members of the list.
5047978SPeter.Dunlap@Sun.COM  */
5057978SPeter.Dunlap@Sun.COM void
5067978SPeter.Dunlap@Sun.COM it_ini_free(it_ini_t *ini);
5077978SPeter.Dunlap@Sun.COM 
5087978SPeter.Dunlap@Sun.COM /*
5097978SPeter.Dunlap@Sun.COM  * Function:  validate_iscsi_name()
5107978SPeter.Dunlap@Sun.COM  *
5117978SPeter.Dunlap@Sun.COM  * Ensures the passed-in string is a valid IQN or EUI iSCSI name
5127978SPeter.Dunlap@Sun.COM  */
5137978SPeter.Dunlap@Sun.COM boolean_t
5147978SPeter.Dunlap@Sun.COM validate_iscsi_name(char *in_name);
5157978SPeter.Dunlap@Sun.COM 
5167978SPeter.Dunlap@Sun.COM #ifdef	__cplusplus
5177978SPeter.Dunlap@Sun.COM }
5187978SPeter.Dunlap@Sun.COM #endif
5197978SPeter.Dunlap@Sun.COM 
5207978SPeter.Dunlap@Sun.COM #endif	/* _LIBISCSIT_H */
521