iscsi_if.h revision a6d42e7d71324c5193c3b94d57d96ba2925d52e1
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _ISCSI_IF_H
#define _ISCSI_IF_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
#endif
#include <sys/iscsi_protocol.h>
/*
* Each of the top level structures have a version field as
* the first member. That version value will be set by the
* caller. The consumer of the structure will check to see
* if the version is correct.
*/
#define ISCSI_INTERFACE_VERSION 3
/*
* The maximum length of an iSCSI name is 223. 224 is used
* to provide space for a null character.
*/
#define ISCSI_MAX_NAME_LEN 224
/*
* Login parameter values are used instead of ascii text
* between the IMA plug-in and kernel.
*/
/*
* number of login parameters - needs to be updated when new parameter added
*/
#define ISCSI_NUM_LOGIN_PARAM 0x000E
/*
* Used internally by the persistent store code. Currently a bitmap is kept of
* which params are currently set. This allows for quick a look up instead of
* cycling through the possible entries. Using an unsigned int as the bitmap we
* can have parameter numbers up through 31. Since the current only has 22
* we're okay.
*/
#define ISCSI_LOGIN_PARAM_DB_ENTRY 0x0020
/*
* Special case. When this parameter value is set in iscsi_param_set_t
* the member s_value (type iscsi_param_set_t) is not used.
* The name field contains the InitiatorName for the system which
* should be used for all future sessions.
*/
#define ISCSI_LOGIN_PARAM_INITIATOR_NAME 0x0021
#define ISCSI_LOGIN_PARAM_INITIATOR_ALIAS 0x0022
#define ISCSI_DEVCTL "devctl"
/*
* ioctls supported by the driver.
*/
/*
* Misc. defines
*/
#define ISCSI_CHAP_NAME_LEN 512
#define ISCSI_CHAP_SECRET_LEN 16
#define ISCSI_TGT_OID_LIST 0x0001
#define ISCSI_STATIC_TGT_OID_LIST 0x0002
#define ISCSI_TGT_PARAM_OID_LIST 0x0004
#define ISCSI_SESS_PARAM 0x0001
#define ISCSI_CONN_PARAM 0x0002
/* digest level defines */
#define ISCSI_DIGEST_NONE 0
#define ISCSI_DIGEST_CRC32C 1
/*
* A last error associated with each target session is returned in the
* iscsi_target_t structure.
*/
typedef enum iscsi_error {
/*
* The values associated with each enum is based on the IMA specification.
*/
typedef enum iSCSIDiscoveryMethod {
#define ISCSI_ALL_DISCOVERY_METHODS (iSCSIDiscoveryMethodStatic | \
/*
* Before anything can be done to a target it must have an OID.
*/
typedef struct iscsi_oid {
/*
* tpgt is only 16 bits per spec. use 32 in ioctl to reduce
* packing issue. Also -1 tpgt denotes default value. iSCSI
* stack will detemermine tpgt during login.
*/
int o_tpgt; /* In */
} iscsi_oid_t;
#define ISCSI_OID_NOTSET 0
#define ISCSI_DEFAULT_TPGT -1
/*
* iSCSI Login Parameters - Reference iscsi draft for
* definitions of the below login params.
*/
typedef struct iscsi_login_params {
int first_burst_length; /* range: 512 - 2**24-1 */
int max_burst_length; /* range: 512 - 2**24-1 */
int default_time_to_wait;
int header_digest;
int data_digest;
int max_recv_data_seg_len; /* range: 512 - 2**24-1 */
int max_xmit_data_seg_len; /* range: 512 - 2**24-1 */
int max_connections;
int max_outstanding_r2t;
int error_recovery_level;
/*
* Once parameters have been set via ISCSI_SET_PARAM the login is initiated
* by sending an ISCSI_LOGIN ioctl with the following structure filled in.
*/
typedef struct entry {
int e_vers;
union {
} e_u;
/*
* e_insize indicates which of the previous structs is valid.
*/
int e_insize;
int e_port;
int e_tpgt;
} entry_t;
/*
* Used when setting or gettnig the Initiator Name or Alias.
*/
typedef struct node_name {
unsigned char n_name[ISCSI_MAX_NAME_LEN];
int n_len;
} node_name_t;
typedef struct _iSCSIMinMaxValue {
typedef struct _iSCSIBoolValue {
typedef struct _iSCSIParamValueGet {
typedef struct _iSCSILoginParamGet {
/*
* To indicate whether session or connection related param is
* being requested.
*/
typedef struct iscsi_set_value {
/*
* All of the members of this structure are set by the user agent and
* consumed by the driver.
*/
typedef struct iSCSILoginParamSet {
/*
* Data in this structure is set by the user agent and consumed by
* the driver.
*/
typedef struct chap_props {
unsigned char c_user[128];
unsigned char c_secret[16];
typedef enum authMethod {
authMethodNone = 0x00,
authMethodCHAP = 0x01,
authMethodSRP = 0x02,
authMethodKRB5 = 0x04,
authMethodSPKM1 = 0x08,
authMethodSPKM2 = 0x10
} authMethod_t;
/*
* Data in this structure is set by the user agent and consumed by
* the driver.
*/
typedef struct auth_props {
/*
* Data in this structure is set by the user agent and consumed by
* the driver.
*/
#define MAX_RAD_SHARED_SECRET_LEN 128
typedef struct radius_props {
union {
} r_addr;
/*
* r_insize indicates which of the previous structs is valid.
*/
int r_insize;
typedef struct _IPAddress {
union {
} i_addr;
/* i_insize determines which is valid in the union above */
int i_insize;
typedef struct _iSCSITargetAddressKey {
} iscsi_addr_t;
typedef struct _iSCSITargetAddressKeyProperties {
al_oid; /* In */
typedef struct _iSCSITargetProperties {
p_oid; /* In */
/* ---- If connected == B_TRUE then lastErr has no meaning. ---- */
/*
* Target portal group tag = -1 value means default.
*/
int p_tpgt_conf; /* Out */
int p_tpgt_nego; /* Out */
typedef struct _iSCSITargetDeviceList {
tl_in_cnt, /* In */
tl_tgt_list_type, /* In */
tl_out_cnt, /* Out */
typedef struct _iSCSIStaticTargetProperties {
p_oid; /* In */
typedef enum iscsi_lun_status {
/*
* SCSI inquiry vendor and product identifier buffer length - these values are
* defined by the identifier length plus 1 byte for the
* null termination.
*/
typedef struct iscsi_lun_props {
lp_tgt_oid, /* In */
lp_oid, /* In */
lp_num, /* Out */
lp_status; /* Out */
typedef struct iscsi_if_lun {
typedef struct iscsi_lun_list {
ll_in_cnt, /* In */
ll_out_cnt; /* Out */
typedef struct iscsi_conn_props {
cp_oid, /* In */
cp_cid, /* In */
cp_sess_oid; /* In */
union {
struct sockaddr_in soa4;
struct sockaddr_in6 soa6;
} cp_local; /* Out */
union {
struct sockaddr_in soa4;
struct sockaddr_in6 soa6;
} cp_peer; /* Out */
typedef struct iscsi_if_conn {
typedef struct iscsi_conn_list {
cl_in_cnt, /* In */
cl_out_cnt; /* Out */
typedef enum iSNSDiscoveryMethod {
typedef struct iSCSIDiscoveryProperties {
unsigned char iSNSDomainName[256];
typedef struct iscsi_uscsi {
int iu_tpgt;
#if defined(_SYSCALL32)
typedef struct iscsi_uscsi32 {
int iu_tpgt;
struct uscsi_cmd32 iu_ucmd;
#endif /* _SYSCALL32 */
typedef struct iscsi_sendtgts_entry {
/* ---- Node name, NULL terminated UTF-8 string ---- */
int ste_tpgt;
typedef struct iscsi_sendtgts_list {
stl_out_cnt; /* Out */
typedef struct iscsi_statictgt_entry {
/* iSNS Draft - section 4.1.1. */
typedef struct isns_portal_group {
union {
} pg_ip_addr;
int insize;
typedef struct isns_portal_group_list {
typedef struct isns_server_portal_group_list {
#define ISCSI_MIN_CONFIG_SESSIONS 1
/* lowered max config sessions due to ct_power_cnt >= 0 assert */
#define ISCSI_MAX_CONFIG_SESSIONS 4
typedef struct iscsi_config_sess {
#define ISCSI_SESSION_CONFIG_SIZE(SIZE) \
(sizeof (iscsi_config_sess_t) + \
/*
* Event class and subclass information
*/
#define EC_ISCSI "EC_iSCSI"
#define ESC_ISCSI_STATIC_START "ESC_static_start"
#define ESC_ISCSI_STATIC_END "ESC_static_end"
#define ESC_ISCSI_SEND_TARGETS_START "ESC_send_targets_start"
#define ESC_ISCSI_SEND_TARGETS_END "ESC_send_targets_end"
#define ESC_ISCSI_SLP_START "ESC_slp_start"
#define ESC_ISCSI_SLP_END "ESC_slp_end"
#define ESC_ISCSI_ISNS_START "ESC_isns_start"
#define ESC_ISCSI_ISNS_END "ESC_isns_end"
#define ESC_ISCSI_PROP_CHANGE "ESC_prop_change"
#ifdef _KERNEL
/* ---- iscsi_utils.c ---- */
extern int iscsid_open(char *, int, int);
extern int iscsid_close(int);
extern int iscsid_remove(char *filename);
extern int iscsid_errno;
#endif
/*
* Function prototypes for those routines found in the common code
*/
/* ---- utils.c ---- */
extern boolean_t utils_iqn_create(char *, int);
extern char *prt_bitmap(int, char *, char *, int);
extern char *utils_map_param(int);
#ifdef __cplusplus
}
#endif
#endif /* _ISCSI_IF_H */