1 | /* $NetBSD: iscsi.h,v 1.4 2016/06/15 04:30:30 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 struct { |
58 | unsigned int mutual_auth:1; |
59 | unsigned int is_secure:1; |
60 | unsigned int auth_number:4; |
61 | iscsi_auth_types_t auth_type[ISCSI_AUTH_OPTIONS]; |
62 | } iscsi_auth_info_t; |
63 | |
64 | /* |
65 | mutual_auth |
66 | Indicates that authentication should be mutual, i.e. |
67 | the initiator should authenticate the target, and the target |
68 | should authenticate the initiator. If not specified, the target |
69 | will authenticate the initiator only. |
70 | is_secure |
71 | Indicates that the connection is secure. |
72 | auth_number |
73 | Indicates the number of elements in auth_type. |
74 | When 0, no authentication will be used. |
75 | auth_type |
76 | Contains up to ISCSI_AUTH_OPTIONS enumerator values of type |
77 | ISCSI_AUTH_TYPES that indicates the authentication method that |
78 | should be used to establish a login connection (none, CHAP, KRB5, |
79 | etc.), in order of priority. The first element is the most |
80 | preferred method, the last element the least preferred. |
81 | |
82 | */ |
83 | |
84 | typedef enum { |
85 | ISCSI_DIGEST_None = 0, |
86 | ISCSI_DIGEST_CRC32C = 1 |
87 | } iscsi_digest_t; |
88 | |
89 | /* |
90 | ISCSI_DIGEST_None |
91 | Indicates that no CRC is to be generated. |
92 | ISCSI_DIGEST_CRC32C |
93 | Indicates the CRC32C digest should be used. |
94 | */ |
95 | |
96 | typedef enum { |
97 | ISCSI_LOGINTYPE_DISCOVERY = 0, |
98 | ISCSI_LOGINTYPE_NOMAP = 1, |
99 | ISCSI_LOGINTYPE_MAP = 2 |
100 | } iscsi_login_session_type_t; |
101 | |
102 | /* |
103 | ISCSI_LOGINTYPE_DISCOVERY |
104 | Indicates that the login session is for discovery only. |
105 | Initiators use this type of session to send a SCSI SendTargets |
106 | command to an iSCSI target to request assistance in |
107 | discovering other targets accessible to the target that |
108 | receives the SendTargets command. |
109 | ISCSI_LOGINTYPE_NOMAP |
110 | This establishes a normal (full featured) session, but does |
111 | not report the target LUNs to the operating system as |
112 | available drives. Communication with the target is limited |
113 | to io-controls through the driver. |
114 | ISCSI_LOGINTYPE_MAP |
115 | Indicates that the login session is full featured, and reports |
116 | all target LUNs to the operating system to map as logical drives. |
117 | */ |
118 | |
119 | typedef struct { |
120 | uint8_t address[ISCSI_ADDRESS_LENGTH]; |
121 | uint16_t port; |
122 | uint16_t group_tag; |
123 | } iscsi_portal_address_t; |
124 | |
125 | /* |
126 | address |
127 | IP address of the target (V4 dotted quad or V6 hex). |
128 | port |
129 | IP port number. |
130 | group_tag |
131 | Target portal group tag (0 if unknown). |
132 | */ |
133 | |
134 | |
135 | /* ------------------------- Status Values -------------------------- */ |
136 | |
137 | #define ISCSI_STATUS_SUCCESS 0 /* Indicates success. */ |
138 | #define ISCSI_STATUS_LIST_EMPTY 1 /* The requested list is empty. */ |
139 | #define ISCSI_STATUS_DUPLICATE_NAME 2 /* The specified symbolic identifier is not unique. */ |
140 | #define ISCSI_STATUS_GENERAL_ERROR 3 /* A non-specific error occurred. */ |
141 | #define ISCSI_STATUS_LOGIN_FAILED 4 /* The login failed. */ |
142 | #define ISCSI_STATUS_CONNECTION_FAILED 5 /* The attempt to establish a connection failed. */ |
143 | #define ISCSI_STATUS_AUTHENTICATION_FAILED 6 /* Authentication negotiation failed. */ |
144 | #define ISCSI_STATUS_NO_RESOURCES 7 /* Could not allocate resources (e.g. memory). */ |
145 | #define ISCSI_STATUS_MAXED_CONNECTIONS 8 /* Maximum number of connections exceeded. */ |
146 | #define ISCSI_STATUS_INVALID_SESSION_ID 9 /* Session ID not found */ |
147 | #define ISCSI_STATUS_INVALID_CONNECTION_ID 10 /* Connection ID not found */ |
148 | #define ISCSI_STATUS_INVALID_SOCKET 11 /* Specified socket is invalid */ |
149 | #define ISCSI_STATUS_NOTIMPL 12 /* Feature not implemented */ |
150 | #define ISCSI_STATUS_CHECK_CONDITION 13 /* Target reported CHECK CONDITION */ |
151 | #define ISCSI_STATUS_TARGET_BUSY 14 /* Target reported BUSY */ |
152 | #define ISCSI_STATUS_TARGET_ERROR 15 /* Target reported other error */ |
153 | #define ISCSI_STATUS_TARGET_FAILURE 16 /* Command Response was Target Failure */ |
154 | #define ISCSI_STATUS_TARGET_DROP 17 /* Target dropped connection */ |
155 | #define ISCSI_STATUS_SOCKET_ERROR 18 /* Communication failure */ |
156 | #define ISCSI_STATUS_PARAMETER_MISSING 19 /* A required ioctl parameter is missing */ |
157 | #define ISCSI_STATUS_PARAMETER_INVALID 20 /* A parameter is malformed (string too long etc.) */ |
158 | #define ISCSI_STATUS_MAP_FAILED 21 /* Mapping the LUNs failed */ |
159 | #define ISCSI_STATUS_NO_INITIATOR_NAME 22 /* Initiator name was not set */ |
160 | #define ISCSI_STATUS_NEGOTIATION_ERROR 23 /* Negotiation failure (invalid key or value) */ |
161 | #define ISCSI_STATUS_TIMEOUT 24 /* Command timed out (at iSCSI level) */ |
162 | #define ISCSI_STATUS_PROTOCOL_ERROR 25 /* Internal Error (Protocol error reject) */ |
163 | #define ISCSI_STATUS_PDU_ERROR 26 /* Internal Error (Invalid PDU field reject) */ |
164 | #define ISCSI_STATUS_CMD_NOT_SUPPORTED 27 /* Target does not support iSCSI command */ |
165 | #define ISCSI_STATUS_DRIVER_UNLOAD 28 /* Driver is unloading */ |
166 | #define ISCSI_STATUS_LOGOUT 29 /* Session was logged out */ |
167 | #define ISCSI_STATUS_PDUS_LOST 30 /* Excessive PDU loss */ |
168 | #define ISCSI_STATUS_INVALID_EVENT_ID 31 /* Invalid Event ID */ |
169 | #define ISCSI_STATUS_EVENT_DEREGISTERED 32 /* Wait for event cancelled by deregistration */ |
170 | #define ISCSI_STATUS_EVENT_WAITING 33 /* Someone is already waiting for this event */ |
171 | #define ISCSI_STATUS_TASK_NOT_FOUND 34 /* Task Management: task not found */ |
172 | #define ISCSI_STATUS_LUN_NOT_FOUND 35 /* Task Management: LUN not found */ |
173 | #define ISCSI_STATUS_TASK_ALLEGIANT 36 /* Task Management: Task still allegiant */ |
174 | #define ISCSI_STATUS_CANT_REASSIGN 37 /* Task Management: Task reassignment not supported */ |
175 | #define ISCSI_STATUS_FUNCTION_UNSUPPORTED 38 /* Task Management: Function unsupported */ |
176 | #define ISCSI_STATUS_FUNCTION_NOT_AUTHORIZED 39 /* Task Management: Function not authorized */ |
177 | #define ISCSI_STATUS_FUNCTION_REJECTED 40 /* Task Management: Function rejected */ |
178 | #define ISCSI_STATUS_UNKNOWN_REASON 41 /* Task Management: Unknown reason code */ |
179 | #define ISCSI_STATUS_DUPLICATE_ID 42 /* Given ID is a duplicate */ |
180 | #define ISCSI_STATUS_INVALID_ID 43 /* Given ID was not found */ |
181 | #define ISCSI_STATUS_TARGET_LOGOUT 44 /* Target requested logout */ |
182 | #define ISCSI_STATUS_LOGOUT_CID_NOT_FOUND 45 /* Logout error: CID not found */ |
183 | #define ISCSI_STATUS_LOGOUT_RECOVERY_NS 46 /* Logout error: Recovery not supported */ |
184 | #define ISCSI_STATUS_LOGOUT_ERROR 47 /* Logout error: Unknown reason */ |
185 | #define ISCSI_STATUS_QUEUE_FULL 48 /* iSCSI send window exhausted */ |
186 | |
187 | #define ISCSID_STATUS_SUCCESS 0 /* Indicates success. */ |
188 | #define ISCSID_STATUS_LIST_EMPTY 1001 /* The requested list is empty. */ |
189 | #define ISCSID_STATUS_DUPLICATE_NAME 1002 /* The specified name is not unique. */ |
190 | #define ISCSID_STATUS_GENERAL_ERROR 1003 /* A non-specific error occurred. */ |
191 | #define ISCSID_STATUS_CONNECT_ERROR 1005 /* Failed to connect to target */ |
192 | #define ISCSID_STATUS_NO_RESOURCES 1007 /* Could not allocate resources (e.g. memory). */ |
193 | #define ISCSID_STATUS_INVALID_SESSION_ID 1009 /* Session ID not found */ |
194 | #define ISCSID_STATUS_INVALID_CONNECTION_ID 1010 /* Connection ID not found */ |
195 | #define ISCSID_STATUS_NOTIMPL 1012 /* Feature not implemented */ |
196 | #define ISCSID_STATUS_SOCKET_ERROR 1018 /* Failed to create socket */ |
197 | #define ISCSID_STATUS_PARAMETER_MISSING 1019 /* A required parameter is missing */ |
198 | #define ISCSID_STATUS_PARAMETER_INVALID 1020 /* A parameter is malformed (string too long etc.) */ |
199 | #define ISCSID_STATUS_INVALID_PARAMETER 1020 /* Alternate spelling of above */ |
200 | #define ISCSID_STATUS_NO_INITIATOR_NAME 1022 /* Initiator name was not set */ |
201 | #define ISCSID_STATUS_TIMEOUT 1024 /* Request timed out */ |
202 | #define ISCSID_STATUS_DRIVER_NOT_LOADED 1028 /* Driver not loaded */ |
203 | #define ISCSID_STATUS_INVALID_REQUEST 1101 /* Unknown request code */ |
204 | #define ISCSID_STATUS_INVALID_PORTAL_ID 1102 /* Portal ID not found */ |
205 | #define ISCSID_STATUS_INVALID_TARGET_ID 1103 /* Target ID not found */ |
206 | #define ISCSID_STATUS_NOT_FOUND 1104 /* Search failed */ |
207 | #define ISCSID_STATUS_HOST_NOT_FOUND 1105 /* Target address not found */ |
208 | #define ISCSID_STATUS_HOST_TRY_AGAIN 1106 /* Target address retreival failed, try again later */ |
209 | #define ISCSID_STATUS_HOST_ERROR 1107 /* Target address invalid */ |
210 | #define ISCSID_STATUS_NO_TARGETS_FOUND 1108 /* No targets found during refresh */ |
211 | #define ISCSID_STATUS_INVALID_ISNS_ID 1111 /* iSNS ID not found */ |
212 | #define ISCSID_STATUS_ISNS_ERROR 1112 /* Problem connecting to iSNS */ |
213 | #define ISCSID_STATUS_ISNS_SERVER_ERROR 1113 /* iSNS server returned garbage */ |
214 | #define ISCSID_STATUS_DUPLICATE_ENTRY 1114 /* The specified entry already exists */ |
215 | #define ISCSID_STATUS_INVALID_INITIATOR_ID 1115 /* Initiator ID not found */ |
216 | #define ISCSID_STATUS_INITIATOR_BIND_ERROR 1116 /* Bind to initiator portal failed */ |
217 | |
218 | #endif /* !_ISCSI_H */ |
219 | |