summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/io/scsi/adapters/iscsi/isns_protocol.h
blob: 1bcd78693715e861d07cab893df591a0b25a7cba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*
 * 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
 * or http://www.opensolaris.org/os/licensing.
 * 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	_ISNS_PROTOCOL_H
#define	_ISNS_PROTOCOL_H

#ifdef __cplusplus
extern "C" {
#endif

#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>

#define	ISNSP_VERSION			(0x01)

#define	ISNS_DEFAULT_SERVER_PORT	(3205)

#define	ISNSP_HEADER_SIZE		(12)
#define	ISNSP_MAX_PAYLOAD_SIZE		(65532)
#define	ISNSP_MAX_PDU_SIZE		(ISNSP_HEADER_SIZE + \
					ISNSP_MAX_PAYLOAD_SIZE)

#define	ISNS_TLV_ATTR_ID_LEN		(4)
#define	ISNS_TLV_ATTR_LEN_LEN		(4)
#define	MAX_ISNS_MESG_ATTR_ENTRIES	(8)
#define	MAX_ISNS_OPER_ATTR_ENTRIES	(32)

/* iSNS Entity Protocol, iSNS Draft - section 6.2.2. */
#define	ISNS_ENTITY_PROTOCOL_NO		(1)
#define	ISNS_ENTITY_PROTOCOL_ISCSI	(2)
#define	ISNS_ENTITY_PROTOCOL_FCP	(3)

/* iSNS Function IDs, iSNS Draft - section 4.1.3. */
#define	ISNS_DEV_ATTR_REG		(0x0001)
#define	ISNS_DEV_ATTR_QRY		(0x0002)
#define	ISNS_DEV_GET_NEXT		(0x0003)
#define	ISNS_DEV_DEREG			(0x0004)
#define	ISNS_SCN_REG			(0x0005)
#define	ISNS_SCN_DEREG			(0x0006)
#define	ISNS_SCN			(0x0008)
#define	ISNS_ESI			(0x000D)
#define	ISNS_HEARTBEAT			(0x000E)
#define	ISNS_DEV_ATTR_REG_RSP		(0x8001)
#define	ISNS_DEV_ATTR_QRY_RSP		(0x8002)
#define	ISNS_DEV_DEREG_RSP		(0x8004)
#define	ISNS_SCN_REG_RSP		(0x8005)
#define	ISNS_SCN_DEREG_RSP		(0x8006)
#define	ISNS_SCN_RSP			(0x8008)
#define	ISNS_ESI_RSP			(0x800D)

/* iSNS Flags, iSNS Draft - section 5.1.4. */
#define	ISNS_FLAG_FIRST_PDU		(0x0400)
#define	ISNS_FLAG_LAST_PDU		(0x0800)
#define	ISNS_FLAG_REPLACE_REG		(0x1000)
#define	ISNS_FLAG_AUTH_BLK_PRESENTED	(0x2000)
#define	ISNS_FLAG_SERVER		(0x4000)
#define	ISNS_FLAG_CLIENT		(0x8000)

/* iSNS Response Status, iSNS Draft - section 5.4 */
#define	ISNS_RSP_SUCCESSFUL		(0)
#define	ISNS_RSP_UNKNOWN_ERROR		(1)
#define	ISNS_RSP_MSG_FORMAT_ERROR	(2)
#define	ISNS_RSP_INVALID_REGIS		(3)
#define	ISNS_RSP_INVALID_QRY		(5)
#define	ISNS_RSP_SRC_UNKNOWN		(6)
#define	ISNS_RSP_SRC_ABSENT		(7)
#define	ISNS_RSP_SRC_UNAUTHORIZED	(8)
#define	ISNS_RSP_NO_SUCH_ENTRY		(9)
#define	ISNS_RSP_VER_NOT_SUPPORTED	(10)
#define	ISNS_RSP_INTERNAL_ERROR		(11)
#define	ISNS_RSP_BUSY			(12)
#define	ISNS_RSP_OPTION_NOT_UNDERSTOOD	(13)
#define	ISNS_RSP_INVALID_UPDATE		(14)
#define	ISNS_RSP_MSG_NOT_SUPPORTED	(15)
#define	ISNS_RSP_SCN_EVENT_REJECTED	(16)
#define	ISNS_RSP_SCN_REGIS_REJECTED	(17)
#define	ISNS_RSP_ATTR_NOT_IMPL		(18)
#define	ISNS_RSP_ESI_NOT_AVAILABLE	(21)
#define	ISNS_RSP_INVALID_DEREGIS	(22)
#define	ISNS_RSP_REGIS_NOT_SUPPORTED	(23)

/* iSCSI Node Type, iSNS Draft - section 6.4.2. */
#define	ISNS_TARGET_NODE_TYPE		(0x0001)
#define	ISNS_INITIATOR_NODE_TYPE	(0x0002)
#define	ISNS_CONTROL_NODE_TYPE		(0x0004)

/* iSCSI Node SCN Bitmap, iSNS Draft - section 6.4.4. */
#define	ISNS_INIT_SELF_INFO_ONLY	(0x0080)	/* Bit 24 */
#define	ISNS_TARGET_SELF_INFO_ONLY	(0x0040)	/* Bit 25 */
#define	ISNS_MGMT_REG			(0x0020)	/* Bit 26 */
#define	ISNS_OBJ_REMOVED		(0x0010)	/* Bit 27 */
#define	ISNS_OBJ_ADDED			(0x0008)	/* Bit 28 */
#define	ISNS_OBJ_UPDATED		(0x0004)	/* Bit 29 */
#define	ISNS_OBJ_MEMBER_REMOVED		(0x0002)	/* Bit 30 */
#define	ISNS_OBJ_MEMBER_ADDED		(0x0001)	/* Bit 31 */

/* iSNS Attribute IDs, iSNS Draft - section 6.1. */
#define	ISNS_DELIMITER_ATTR_ID		(0)
#define	ISNS_EID_ATTR_ID		(1)
#define	ISNS_ENTITY_PROTOCOL_ATTR_ID	(2)
#define	ISNS_TIMESTAMP_ATTR_ID		(4)
#define	ISNS_PORTAL_IP_ADDR_ATTR_ID	(16)
#define	ISNS_PORTAL_PORT_ATTR_ID	(17)
#define	ISNS_PORTAL_NAME_ATTR_ID	(18)
#define	ISNS_ESI_INTERVAL_ATTR_ID	(19)
#define	ISNS_ESI_PORT_ATTR_ID		(20)
#define	ISNS_SCN_PORT_ATTR_ID		(23)
#define	ISNS_ISCSI_NAME_ATTR_ID		(32)
#define	ISNS_ISCSI_NODE_TYPE_ATTR_ID	(33)
#define	ISNS_ISCSI_ALIAS_ATTR_ID	(34)
#define	ISNS_ISCSI_SCN_BITMAP_ATTR_ID	(35)
#define	ISNS_PG_ISCSI_NAME_ATTR_ID	(48)
#define	ISNS_PG_PORTAL_IP_ADDR_ATTR_ID	(49)
#define	ISNS_PG_PORTAL_PORT_ATTR_ID	(50)
#define	ISNS_PG_TAG_ATTR_ID		(51)
#define	ISNS_PG_INDEX_ATTR_ID		(52)

/* iSNS Defaults */
#define	ISNS_DEFAULT_SERVER_PORT	(3205)

typedef struct isns_tlv {
	uint32_t attr_id;
	uint32_t attr_len;
	uint8_t attr_value[1];
} isns_tlv_t;

typedef struct isns_packet_data {
	uint16_t version;
	uint16_t func_id;
	uint16_t payload_len;
	uint16_t flags;
	uint16_t xid;
	uint16_t seq;

	int num_of_tlvs;
	isns_tlv_t tlvs[MAX_ISNS_OPER_ATTR_ENTRIES];
} isns_packet_data_t;

typedef struct isns_reg_mesg {
	isns_tlv_t src_attr;
	int num_of_mesg_attrs;
	isns_tlv_t *mesg_attrs[MAX_ISNS_MESG_ATTR_ENTRIES];
	isns_tlv_t delimiter_attr;
	isns_tlv_t *operating_attrs[MAX_ISNS_OPER_ATTR_ENTRIES];
} isns_reg_mesg_t;

typedef struct isns_resp_mesg {
	uint8_t	status[4];
	isns_tlv_t messages_attrs[MAX_ISNS_MESG_ATTR_ENTRIES];
	isns_tlv_t delimiter_attr;
	isns_tlv_t operating_attrs[MAX_ISNS_OPER_ATTR_ENTRIES];
} isns_resp_mesg_t;

typedef struct isns_pdu {
	uint16_t version;
	uint16_t func_id;
	uint16_t payload_len;
	uint16_t flags;
	uint16_t xid;
	uint16_t seq;
	uint8_t payload[1];
} isns_pdu_t;

typedef struct isns_resp {
	uint32_t status;
	uint8_t data[1];
} isns_resp_t;

#ifdef __cplusplus
}
#endif

#endif /* _ISNS_PROTOCOL_H */