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