| 1 | /*	$NetBSD: iscsi.h,v 1.5 2023/11/25 10:08:27 mlelstv Exp $	*/ |
| 2 | |
| 3 | /*- |
| 4 | * Copyright (c) 2004,2006,2011 The NetBSD Foundation, Inc. |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * This code is derived from software contributed to The NetBSD Foundation |
| 8 | * by Wasabi Systems, Inc. |
| 9 | * |
| 10 | * Redistribution and use in source and binary forms, with or without |
| 11 | * modification, are permitted provided that the following conditions |
| 12 | * are met: |
| 13 | * 1. Redistributions of source code must retain the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer. |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in the |
| 17 | * documentation and/or other materials provided with the distribution. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
| 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
| 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 | * POSSIBILITY OF SUCH DAMAGE. |
| 30 | */ |
| 31 | #ifndef _ISCSI_H |
| 32 | #define _ISCSI_H |
| 33 | |
| 34 | #define ISCSI_DEV_MAJOR 203 |
| 35 | |
| 36 | #define ISCSI_STRING_LENGTH (223+1) |
| 37 | #define ISCSI_ADDRESS_LENGTH (255+1) |
| 38 | #define ISCSI_AUTH_OPTIONS 4 |
| 39 | |
| 40 | typedef enum { |
| 41 | 	ISCSI_AUTH_None		= 0, |
| 42 | 	ISCSI_AUTH_CHAP		= 1, |
| 43 | 	ISCSI_AUTH_KRB5		= 2, |
| 44 | 	ISCSI_AUTH_SRP		= 3 |
| 45 | } iscsi_auth_types_t; |
| 46 | /* |
| 47 | ISCSI_AUTH_None |
| 48 | Indicates that no authentication is necessary. |
| 49 | ISCSI_AUTH_CHAP |
| 50 | Indicates CHAP authentication should be used. |
| 51 | ISCSI_AUTH_KRB5 |
| 52 | Indicates Kerberos 5 authentication (fur future use). |
| 53 | ISCSI_AUTH_SRP |
| 54 | Indicates SRP authentication (for future use). |
| 55 | */ |
| 56 | |
| 57 | typedef enum { |
| 58 | 	ISCSI_CHAP_MD5		= 5, |
| 59 | 	ISCSI_CHAP_SHA1		= 6, |
| 60 | 	ISCSI_CHAP_SHA256	= 7, |
| 61 | 	ISCSI_CHAP_SHA3_256	= 8 |
| 62 | } iscsi_chap_types_t; |
| 63 | |
| 64 | typedef struct { |
| 65 | 	unsigned int		mutual_auth:1; |
| 66 | 	unsigned int		is_secure:1; |
| 67 | 	unsigned int		auth_number:4; |
| 68 | 	iscsi_auth_types_t	auth_type[ISCSI_AUTH_OPTIONS]; |
| 69 | } iscsi_auth_info_t; |
| 70 | |
| 71 | /* |
| 72 | mutual_auth |
| 73 | Indicates that authentication should be mutual, i.e. |
| 74 | the initiator should authenticate the target, and the target |
| 75 | should authenticate the initiator. If not specified, the target |
| 76 | will authenticate the initiator only. |
| 77 | is_secure |
| 78 | Indicates that the connection is secure. |
| 79 | auth_number |
| 80 | Indicates the number of elements in auth_type. |
| 81 | When 0, no authentication will be used. |
| 82 | auth_type |
| 83 | Contains up to ISCSI_AUTH_OPTIONS enumerator values of type |
| 84 | ISCSI_AUTH_TYPES that indicates the authentication method that |
| 85 | should be used to establish a login connection (none, CHAP, KRB5, |
| 86 | etc.), in order of priority. The first element is the most |
| 87 | preferred method, the last element the least preferred. |
| 88 | |
| 89 | */ |
| 90 | |
| 91 | typedef enum { |
| 92 | 	ISCSI_DIGEST_None	= 0, |
| 93 | 	ISCSI_DIGEST_CRC32C	= 1 |
| 94 | } iscsi_digest_t; |
| 95 | |
| 96 | /* |
| 97 | ISCSI_DIGEST_None |
| 98 | Indicates that no CRC is to be generated. |
| 99 | ISCSI_DIGEST_CRC32C |
| 100 | Indicates the CRC32C digest should be used. |
| 101 | */ |
| 102 | |
| 103 | typedef enum { |
| 104 | 	ISCSI_LOGINTYPE_DISCOVERY	= 0, |
| 105 | 	ISCSI_LOGINTYPE_NOMAP		= 1, |
| 106 | 	ISCSI_LOGINTYPE_MAP		= 2 |
| 107 | } iscsi_login_session_type_t; |
| 108 | |
| 109 | /* |
| 110 | ISCSI_LOGINTYPE_DISCOVERY |
| 111 | Indicates that the login session is for discovery only. |
| 112 | Initiators use this type of session to send a SCSI SendTargets |
| 113 | command to an iSCSI target to request assistance in |
| 114 | discovering other targets accessible to the target that |
| 115 | receives the SendTargets command. |
| 116 | ISCSI_LOGINTYPE_NOMAP |
| 117 | This establishes a normal (full featured) session, but does |
| 118 | not report the target LUNs to the operating system as |
| 119 | available drives. Communication with the target is limited |
| 120 | to io-controls through the driver. |
| 121 | ISCSI_LOGINTYPE_MAP |
| 122 | Indicates that the login session is full featured, and reports |
| 123 | all target LUNs to the operating system to map as logical drives. |
| 124 | */ |
| 125 | |
| 126 | typedef struct { |
| 127 | 	uint8_t		address[ISCSI_ADDRESS_LENGTH]; |
| 128 | 	uint16_t	port; |
| 129 | 	uint16_t	group_tag; |
| 130 | } iscsi_portal_address_t; |
| 131 | |
| 132 | /* |
| 133 | address |
| 134 | IP address of the target (V4 dotted quad or V6 hex). |
| 135 | port |
| 136 | IP port number. |
| 137 | group_tag |
| 138 | Target portal group tag (0 if unknown). |
| 139 | */ |
| 140 | |
| 141 | |
| 142 | /* ------------------------- Status Values -------------------------- */ |
| 143 | |
| 144 | #define ISCSI_STATUS_SUCCESS 0	/* Indicates success. */ |
| 145 | #define ISCSI_STATUS_LIST_EMPTY 1	/* The requested list is empty. */ |
| 146 | #define ISCSI_STATUS_DUPLICATE_NAME 2	/* The specified symbolic identifier is not unique. */ |
| 147 | #define ISCSI_STATUS_GENERAL_ERROR 3	/* A non-specific error occurred. */ |
| 148 | #define ISCSI_STATUS_LOGIN_FAILED 4	/* The login failed. */ |
| 149 | #define ISCSI_STATUS_CONNECTION_FAILED 5	/* The attempt to establish a connection failed. */ |
| 150 | #define ISCSI_STATUS_AUTHENTICATION_FAILED 6	/* Authentication negotiation failed. */ |
| 151 | #define ISCSI_STATUS_NO_RESOURCES 7	/* Could not allocate resources (e.g. memory). */ |
| 152 | #define ISCSI_STATUS_MAXED_CONNECTIONS 8	/* Maximum number of connections exceeded. */ |
| 153 | #define ISCSI_STATUS_INVALID_SESSION_ID 9	/* Session ID not found */ |
| 154 | #define ISCSI_STATUS_INVALID_CONNECTION_ID 10	/* Connection ID not found */ |
| 155 | #define ISCSI_STATUS_INVALID_SOCKET 11	/* Specified socket is invalid */ |
| 156 | #define ISCSI_STATUS_NOTIMPL 12	/* Feature not implemented */ |
| 157 | #define ISCSI_STATUS_CHECK_CONDITION 13	/* Target reported CHECK CONDITION */ |
| 158 | #define ISCSI_STATUS_TARGET_BUSY 14	/* Target reported BUSY */ |
| 159 | #define ISCSI_STATUS_TARGET_ERROR 15	/* Target reported other error */ |
| 160 | #define ISCSI_STATUS_TARGET_FAILURE 16	/* Command Response was Target Failure */ |
| 161 | #define ISCSI_STATUS_TARGET_DROP 17	/* Target dropped connection */ |
| 162 | #define ISCSI_STATUS_SOCKET_ERROR 18	/* Communication failure */ |
| 163 | #define ISCSI_STATUS_PARAMETER_MISSING 19	/* A required ioctl parameter is missing */ |
| 164 | #define ISCSI_STATUS_PARAMETER_INVALID 20	/* A parameter is malformed (string too long etc.) */ |
| 165 | #define ISCSI_STATUS_MAP_FAILED 21	/* Mapping the LUNs failed */ |
| 166 | #define ISCSI_STATUS_NO_INITIATOR_NAME 22	/* Initiator name was not set */ |
| 167 | #define ISCSI_STATUS_NEGOTIATION_ERROR 23	/* Negotiation failure (invalid key or value) */ |
| 168 | #define ISCSI_STATUS_TIMEOUT 24	/* Command timed out (at iSCSI level) */ |
| 169 | #define ISCSI_STATUS_PROTOCOL_ERROR 25	/* Internal Error (Protocol error reject) */ |
| 170 | #define ISCSI_STATUS_PDU_ERROR 26	/* Internal Error (Invalid PDU field reject) */ |
| 171 | #define ISCSI_STATUS_CMD_NOT_SUPPORTED 27	/* Target does not support iSCSI command */ |
| 172 | #define ISCSI_STATUS_DRIVER_UNLOAD 28	/* Driver is unloading */ |
| 173 | #define ISCSI_STATUS_LOGOUT 29	/* Session was logged out */ |
| 174 | #define ISCSI_STATUS_PDUS_LOST 30	/* Excessive PDU loss */ |
| 175 | #define ISCSI_STATUS_INVALID_EVENT_ID 31	/* Invalid Event ID */ |
| 176 | #define ISCSI_STATUS_EVENT_DEREGISTERED 32	/* Wait for event cancelled by deregistration */ |
| 177 | #define ISCSI_STATUS_EVENT_WAITING 33	/* Someone is already waiting for this event */ |
| 178 | #define ISCSI_STATUS_TASK_NOT_FOUND 34	/* Task Management: task not found */ |
| 179 | #define ISCSI_STATUS_LUN_NOT_FOUND 35	/* Task Management: LUN not found */ |
| 180 | #define ISCSI_STATUS_TASK_ALLEGIANT 36	/* Task Management: Task still allegiant */ |
| 181 | #define ISCSI_STATUS_CANT_REASSIGN 37	/* Task Management: Task reassignment not supported */ |
| 182 | #define ISCSI_STATUS_FUNCTION_UNSUPPORTED 38	/* Task Management: Function unsupported */ |
| 183 | #define ISCSI_STATUS_FUNCTION_NOT_AUTHORIZED 39	/* Task Management: Function not authorized */ |
| 184 | #define ISCSI_STATUS_FUNCTION_REJECTED 40	/* Task Management: Function rejected */ |
| 185 | #define ISCSI_STATUS_UNKNOWN_REASON 41	/* Task Management: Unknown reason code */ |
| 186 | #define ISCSI_STATUS_DUPLICATE_ID 42	/* Given ID is a duplicate */ |
| 187 | #define ISCSI_STATUS_INVALID_ID 43	/* Given ID was not found */ |
| 188 | #define ISCSI_STATUS_TARGET_LOGOUT 44	/* Target requested logout */ |
| 189 | #define ISCSI_STATUS_LOGOUT_CID_NOT_FOUND 45	/* Logout error: CID not found */ |
| 190 | #define ISCSI_STATUS_LOGOUT_RECOVERY_NS	 46	/* Logout error: Recovery not supported */ |
| 191 | #define ISCSI_STATUS_LOGOUT_ERROR	 47	/* Logout error: Unknown reason */ |
| 192 | #define ISCSI_STATUS_QUEUE_FULL 48 /* iSCSI send window exhausted */ |
| 193 | |
| 194 | #define ISCSID_STATUS_SUCCESS 0		/* Indicates success. */ |
| 195 | #define ISCSID_STATUS_LIST_EMPTY 1001	/* The requested list is empty. */ |
| 196 | #define ISCSID_STATUS_DUPLICATE_NAME 1002	/* The specified name is not unique. */ |
| 197 | #define ISCSID_STATUS_GENERAL_ERROR 1003	/* A non-specific error occurred. */ |
| 198 | #define ISCSID_STATUS_CONNECT_ERROR 1005	/* Failed to connect to target */ |
| 199 | #define ISCSID_STATUS_NO_RESOURCES 1007	/* Could not allocate resources (e.g. memory). */ |
| 200 | #define ISCSID_STATUS_INVALID_SESSION_ID 1009	/* Session ID not found */ |
| 201 | #define ISCSID_STATUS_INVALID_CONNECTION_ID 1010	/* Connection ID not found */ |
| 202 | #define ISCSID_STATUS_NOTIMPL 1012	/* Feature not implemented */ |
| 203 | #define ISCSID_STATUS_SOCKET_ERROR 1018	/* Failed to create socket */ |
| 204 | #define ISCSID_STATUS_PARAMETER_MISSING 1019	/* A required parameter is missing */ |
| 205 | #define ISCSID_STATUS_PARAMETER_INVALID 1020	/* A parameter is malformed (string too long etc.) */ |
| 206 | #define ISCSID_STATUS_INVALID_PARAMETER 1020	/* Alternate spelling of above */ |
| 207 | #define ISCSID_STATUS_NO_INITIATOR_NAME 1022	/* Initiator name was not set */ |
| 208 | #define ISCSID_STATUS_TIMEOUT 1024	/* Request timed out */ |
| 209 | #define ISCSID_STATUS_DRIVER_NOT_LOADED 1028	/* Driver not loaded */ |
| 210 | #define ISCSID_STATUS_INVALID_REQUEST 1101	/* Unknown request code */ |
| 211 | #define ISCSID_STATUS_INVALID_PORTAL_ID 1102	/* Portal ID not found */ |
| 212 | #define ISCSID_STATUS_INVALID_TARGET_ID 1103	/* Target ID not found */ |
| 213 | #define ISCSID_STATUS_NOT_FOUND 1104	/* Search failed */ |
| 214 | #define ISCSID_STATUS_HOST_NOT_FOUND 1105	/* Target address not found */ |
| 215 | #define ISCSID_STATUS_HOST_TRY_AGAIN 1106	/* Target address retreival failed, try again later */ |
| 216 | #define ISCSID_STATUS_HOST_ERROR 1107	/* Target address invalid */ |
| 217 | #define ISCSID_STATUS_NO_TARGETS_FOUND	 1108	/* No targets found during refresh */ |
| 218 | #define ISCSID_STATUS_INVALID_ISNS_ID 1111	/* iSNS ID not found */ |
| 219 | #define ISCSID_STATUS_ISNS_ERROR 1112	/* Problem connecting to iSNS */ |
| 220 | #define ISCSID_STATUS_ISNS_SERVER_ERROR 1113	/* iSNS server returned garbage */ |
| 221 | #define ISCSID_STATUS_DUPLICATE_ENTRY 1114	/* The specified entry already exists */ |
| 222 | #define ISCSID_STATUS_INVALID_INITIATOR_ID 1115	/* Initiator ID not found */ |
| 223 | #define ISCSID_STATUS_INITIATOR_BIND_ERROR 1116	/* Bind to initiator portal failed */ |
| 224 | |
| 225 | #endif /* !_ISCSI_H */ |