xref: /illumos-gate/usr/src/cmd/iscsiadm/iscsiadm.h (revision a38ddfee9c8c6b6c5a2947ff52fd2338362a4444)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_ISCSIADM_H
27 #define	_ISCSIADM_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/scsi/adapters/iscsi_protocol.h>
34 #include <sys/scsi/adapters/iscsi_if.h>
35 #include <ima.h>
36 
37 #include <cmdparse.h>
38 
39 #define	ADD	SUBCOMMAND(0)
40 #define	LIST	SUBCOMMAND(1)
41 #define	MODIFY	SUBCOMMAND(2)
42 #define	REMOVE	SUBCOMMAND(3)
43 
44 #define	TARGET			OBJECT(0)
45 #define	NODE			OBJECT(1)
46 #define	INITIATOR		OBJECT(2)
47 #define	STATIC_CONFIG		OBJECT(3)
48 #define	DISCOVERY_ADDRESS	OBJECT(4)
49 #define	DISCOVERY		OBJECT(5)
50 #define	TARGET_PARAM		OBJECT(6)
51 #define	ISNS_SERVER_ADDRESS	OBJECT(7)
52 
53 #define	DATA_SEQ_IN_ORDER	0x01
54 #define	DEFAULT_TIME_2_RETAIN	0x02
55 #define	DEFAULT_TIME_2_WAIT	0x03
56 #define	FIRST_BURST_LENGTH	0x04
57 #define	IMMEDIATE_DATA		0x05
58 #define	INITIAL_R2T		0x06
59 #define	MAX_BURST_LENGTH	0x07
60 #define	DATA_PDU_IN_ORDER	0x08
61 #define	MAX_OUTSTANDING_R2T	0x09
62 #define	MAX_RECV_DATA_SEG_LEN	0x0a
63 #define	HEADER_DIGEST		0x0b
64 #define	DATA_DIGEST		0x0c
65 #define	MAX_CONNECTIONS		0x0d
66 #define	ERROR_RECOVERY_LEVEL	0x0e
67 
68 #define	AUTH_NAME		0x01
69 #define	AUTH_PASSWORD		0x02
70 
71 #define	ISCSIADM_ARG_ENABLE	"enable"
72 #define	ISCSIADM_ARG_DISABLE	"disable"
73 /*
74  * This object type is not defined by IMA.
75  */
76 #define	SUN_IMA_OBJECT_TYPE_CONN  13	/* Currently not defined in IMA */
77 #define	SUN_IMA_NODE_ALIAS_LEN	256
78 
79 #define	MAKE_IMA_ERROR(x)	((IMA_STATUS)(IMA_STATUS_ERROR | (x)))
80 #define	SUN_IMA_SYSTEM_ERROR(status) (((IMA_STATUS)(status) & \
81 	(IMA_STATUS)SUN_IMA_ERROR_SYSTEM_ERROR) == 0x8FFF0000 \
82 	? IMA_TRUE : IMA_FALSE)
83 #define	SUN_GET_SYSTEM_ERROR(x)	(((IMA_STATUS)(x) & 0x0000FFFF))
84 #define	SUN_IMA_ERROR_SYSTEM_ERROR MAKE_IMA_ERROR(0x0fff0000)
85 
86 typedef struct _parameterTbl {
87 	char *name;
88 	int val;
89 } parameterTbl_t;
90 
91 /*
92  * The following interfaces are not defined in IMA 1.1. Some of them
93  * are requirement candidates for the next IMA release.
94  */
95 
96 #define	SUN_IMA_MAX_DIGEST_ALGORITHMS	2	/* NONE and CRC 32 */
97 #define	SUN_IMA_IP_ADDRESS_PORT_LEN	256
98 #define	SUN_IMA_MAX_RADIUS_SECRET_LEN	128
99 
100 /* Currently not defined in  IMA_TARGET_DISCOVERY_METHOD enum */
101 #define	IMA_TARGET_DISCOVERY_METHOD_UNKNOWN  0
102 
103 typedef enum
104 {
105     SUN_IMA_DIGEST_NONE = 0,
106     SUN_IMA_DIGEST_CRC32 = 1
107 } SUN_IMA_DIGEST_ALGORITHM;
108 
109 typedef struct _SUN_IMA_DIGEST_ALGORITHM_VALUE
110 {
111     IMA_UINT defaultAlgorithmCount;
112     SUN_IMA_DIGEST_ALGORITHM defaultAlgorithms[SUN_IMA_MAX_DIGEST_ALGORITHMS];
113 
114     IMA_BOOL currentValid;
115     IMA_UINT currentAlgorithmCount;
116     SUN_IMA_DIGEST_ALGORITHM currentAlgorithms[SUN_IMA_MAX_DIGEST_ALGORITHMS];
117 
118     IMA_BOOL negotiatedValid;
119     IMA_UINT negotiatedAlgorithmCount;
120     SUN_IMA_DIGEST_ALGORITHM
121 	negotiatedAlgorithms[SUN_IMA_MAX_DIGEST_ALGORITHMS];
122 } SUN_IMA_DIGEST_ALGORITHM_VALUE;
123 
124 typedef struct _SUN_IMA_DISC_ADDR_PROP_LIST
125 {
126     IMA_UINT discAddrCount;
127     IMA_DISCOVERY_ADDRESS_PROPERTIES props[1];
128 } SUN_IMA_DISC_ADDR_PROP_LIST;
129 
130 typedef struct _SUN_IMA_RADIUS_CONFIG
131 {
132 	char hostnameIpAddress[SUN_IMA_IP_ADDRESS_PORT_LEN];
133 	IMA_BOOL isIpv6;
134 	IMA_UINT16 port;
135 	IMA_BOOL sharedSecretValid;
136 	IMA_UINT sharedSecretLength;
137 	IMA_BYTE sharedSecret[SUN_IMA_MAX_RADIUS_SECRET_LEN];
138 } SUN_IMA_RADIUS_CONFIG;
139 
140 
141 typedef struct _SUN_IMA_DISC_ADDRESS_KEY
142 {
143 	IMA_NODE_NAME name;
144 	IMA_ADDRESS_KEY	address;
145 	IMA_UINT16 tpgt;
146 } SUN_IMA_DISC_ADDRESS_KEY;
147 
148 typedef struct _SUN_IMA_DISC_ADDRESS_KEY_PROPERTIES
149 {
150 	IMA_UINT keyCount;
151 	SUN_IMA_DISC_ADDRESS_KEY keys[1];
152 } SUN_IMA_DISC_ADDRESS_KEY_PROPERTIES;
153 
154 typedef struct _SUN_IMA_TARGET_ADDRESS
155 {
156     IMA_TARGET_ADDRESS imaStruct;
157 	IMA_BOOL	defaultTpgt;	/* If true, tpgt becomes irrelvant */
158 	IMA_UINT16	tpgt;
159 } SUN_IMA_TARGET_ADDRESS;
160 
161 typedef struct _SUN_IMA_STATIC_DISCOVERY_TARGET
162 {
163 	IMA_NODE_NAME	targetName;
164 	SUN_IMA_TARGET_ADDRESS  targetAddress;
165 } SUN_IMA_STATIC_DISCOVERY_TARGET;
166 
167 typedef struct _SUN_IMA_STATIC_DISCOVERY_TARGET_PROPERTIES
168 {
169 	IMA_OID	associatedNodeOid;
170 	IMA_OID	associatedLhbaOid;
171 	SUN_IMA_STATIC_DISCOVERY_TARGET   staticTarget;
172 } SUN_IMA_STATIC_DISCOVERY_TARGET_PROPERTIES;
173 
174 typedef struct _SUN_IMA_CONN_PROPERTIES {
175 	IMA_UINT32	connectionID;
176 	IMA_ADDRESS_KEY	local;
177 	IMA_ADDRESS_KEY	peer;
178 
179 	IMA_BOOL   valuesValid;
180 	IMA_UINT32 defaultTime2Retain;
181 	IMA_UINT32 defaultTime2Wait;
182 	IMA_UINT32 errorRecoveryLevel;
183 	IMA_UINT32 firstBurstLength;
184 	IMA_UINT32 maxBurstLength;
185 	IMA_UINT32 maxConnections;
186 	IMA_UINT32 maxOutstandingR2T;
187 	IMA_UINT32 maxRecvDataSegmentLength;
188 
189 	IMA_BOOL dataPduInOrder;
190 	IMA_BOOL dataSequenceInOrder;
191 	IMA_BOOL immediateData;
192 	IMA_BOOL initialR2T;
193 
194 	IMA_UINT headerDigest;
195 	IMA_UINT dataDigest;
196 
197 } SUN_IMA_CONN_PROPERTIES;
198 
199 
200 #define	SUN_IMA_LU_VENDOR_ID_LEN	ISCSI_INQ_VID_BUF_LEN
201 #define	SUN_IMA_LU_PRODUCT_ID_LEN	ISCSI_INQ_PID_BUF_LEN
202 typedef struct _SUN_IMA_LU_PROPERTIES
203 {
204     IMA_LU_PROPERTIES imaProps;
205     IMA_CHAR	vendorId[SUN_IMA_LU_VENDOR_ID_LEN];
206     IMA_CHAR	productId[SUN_IMA_LU_PRODUCT_ID_LEN];
207 } SUN_IMA_LU_PROPERTIES;
208 
209 typedef struct _SUN_IMA_TARGET_PROPERTIES
210 {
211     IMA_TARGET_PROPERTIES imaProps;
212     IMA_BOOL defaultTpgtConf;	/* If true, tpgtConf is irrelevant */
213     IMA_UINT16 tpgtConf;
214     IMA_BOOL defaultTpgtNego;	/* If true, tpgtNego is not connected */
215     IMA_UINT16 tpgtNego;
216     IMA_BYTE isid[ISCSI_ISID_LEN];
217 } SUN_IMA_TARGET_PROPERTIES;
218 
219 typedef struct _SUN_IMA_CONFIG_SESSIONS {
220 	/* True if sessions are bound to an interface */
221 	IMA_BOOL	bound;	/* OUT */
222 	/*
223 	 * Memory allocated from caller.  In addition
224 	 * on a Set this is the number of configured
225 	 * sessions.
226 	 */
227 	IMA_UINT	in;	/* IN */
228 	/* Number of Configured sessions on Get */
229 	IMA_UINT	out;	/* OUT */
230 	IMA_ADDRESS_KEY	bindings[1];	/* IN/OUT */
231 } SUN_IMA_CONFIG_SESSIONS;
232 
233 typedef struct _SUN_IMA_STATIC_TARGET_PROPERTIES
234 {
235 	IMA_OID	associatedNodeOid;
236 	IMA_OID	associatedLhbaOid;
237 	SUN_IMA_STATIC_DISCOVERY_TARGET   staticTarget;
238 } SUN_IMA_STATIC_TARGET_PROPERTIES;
239 
240 #ifdef	__cplusplus
241 }
242 #endif
243 
244 #endif	/* _ISCSIADM_H */
245