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