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