1 2 /* 3 * CDDL HEADER START 4 * 5 * The contents of this file are subject to the terms of the 6 * Common Development and Distribution License (the "License"). 7 * You may not use this file except in compliance with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 23 /* 24 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 25 * Use is subject to license terms. 26 */ 27 28 #ifndef _ISNS_PROTOCOL_H 29 #define _ISNS_PROTOCOL_H 30 31 #pragma ident "%Z%%M% %I% %E% SMI" 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 #include <netinet/in.h> 38 #include <sys/socket.h> 39 #include <sys/types.h> 40 41 #define ISNSP_VERSION (0x01) 42 43 #define ISNS_DEFAULT_SERVER_PORT (3205) 44 45 #define ISNSP_HEADER_SIZE (12) 46 #define ISNSP_MAX_PAYLOAD_SIZE (65532) 47 #define ISNSP_MAX_PDU_SIZE (ISNSP_HEADER_SIZE + \ 48 ISNSP_MAX_PAYLOAD_SIZE) 49 50 #define ISNS_TLV_ATTR_ID_LEN (4) 51 #define ISNS_TLV_ATTR_LEN_LEN (4) 52 #define MAX_ISNS_MESG_ATTR_ENTRIES (8) 53 #define MAX_ISNS_OPER_ATTR_ENTRIES (32) 54 55 /* iSNS Entity Protocol, iSNS Draft - section 6.2.2. */ 56 #define ISNS_ENTITY_PROTOCOL_NO (1) 57 #define ISNS_ENTITY_PROTOCOL_ISCSI (2) 58 #define ISNS_ENTITY_PROTOCOL_FCP (3) 59 60 /* iSNS Function IDs, iSNS Draft - section 4.1.3. */ 61 #define ISNS_DEV_ATTR_REG (0x0001) 62 #define ISNS_DEV_ATTR_QRY (0x0002) 63 #define ISNS_DEV_GET_NEXT (0x0003) 64 #define ISNS_DEV_DEREG (0x0004) 65 #define ISNS_SCN_REG (0x0005) 66 #define ISNS_SCN_DEREG (0x0006) 67 #define ISNS_SCN (0x0008) 68 #define ISNS_ESI (0x000D) 69 #define ISNS_HEARTBEAT (0x000E) 70 #define ISNS_DEV_ATTR_REG_RSP (0x8001) 71 #define ISNS_DEV_ATTR_QRY_RSP (0x8002) 72 #define ISNS_DEV_DEREG_RSP (0x8004) 73 #define ISNS_SCN_REG_RSP (0x8005) 74 #define ISNS_SCN_DEREG_RSP (0x8006) 75 #define ISNS_SCN_RSP (0x8008) 76 #define ISNS_ESI_RSP (0x800D) 77 78 /* iSNS Flags, iSNS Draft - section 5.1.4. */ 79 #define ISNS_FLAG_FIRST_PDU (0x0400) 80 #define ISNS_FLAG_LAST_PDU (0x0800) 81 #define ISNS_FLAG_REPLACE_REG (0x1000) 82 #define ISNS_FLAG_AUTH_BLK_PRESENTED (0x2000) 83 #define ISNS_FLAG_SERVER (0x4000) 84 #define ISNS_FLAG_CLIENT (0x8000) 85 86 /* iSNS Response Status, iSNS Draft - section 5.4 */ 87 #define ISNS_RSP_SUCCESSFUL (0x0000) 88 #define ISNS_RSP_UNKNOWN_ERROR (0x0001) 89 #define ISNS_RSP_MSG_FORMAT_ERROR (0x0002) 90 #define ISNS_RSP_INVALID_REGIS (0x0003) 91 #define ISNS_RSP_INVALID_QRY (0x0005) 92 #define ISNS_RSP_SRC_UNKNOWN (0x0006) 93 #define ISNS_RSP_SRC_ABSENT (0x0007) 94 #define ISNS_RSP_SRC_UNAUTHORIZED (0x0008) 95 #define ISNS_RSP_NO_SUCH_ENTRY (0x0009) 96 #define ISNS_RSP_VER_NOT_SUPPORTED (0X0010) 97 #define ISNS_RSP_INTERNAL_ERROR (0x0011) 98 #define ISNS_RSP_BUSY (0x0012) 99 #define ISNS_RSP_OPTION_NOT_UNDERSTOOD (0x0013) 100 #define ISNS_RSP_INVALID_UPDATE (0x0014) 101 #define ISNS_RSP_MSG_NOT_SUPPORTED (0x0015) 102 #define ISNS_RSP_SCN_EVENT_REJECTED (0X0016) 103 #define ISNS_RSP_SCN_REGIS_REJECTED (0x0017) 104 #define ISNS_RSP_ATTR_NOT_IMPL (0x0018) 105 #define ISNS_RSP_ESI_NOT_AVAILABLE (0x0021) 106 #define ISNS_RSP_INVALID_DEREGIS (0x0022) 107 #define ISNS_RSP_REGIS_NOT_SUPPORTED (0x0023) 108 109 /* iSCSI Node Type, iSNS Draft - section 6.4.2. */ 110 #define ISNS_TARGET_NODE_TYPE (0x0001) 111 #define ISNS_INITIATOR_NODE_TYPE (0x0002) 112 #define ISNS_CONTROL_NODE_TYPE (0x0004) 113 114 /* iSCSI Node SCN Bitmap, iSNS Draft - section 6.4.4. */ 115 #define ISNS_INIT_SELF_INFO_ONLY (0x0080) /* Bit 24 */ 116 #define ISNS_TARGET_SELF_INFO_ONLY (0x0040) /* Bit 25 */ 117 #define ISNS_MGMT_REG (0x0020) /* Bit 26 */ 118 #define ISNS_OBJ_REMOVED (0x0010) /* Bit 27 */ 119 #define ISNS_OBJ_ADDED (0x0008) /* Bit 28 */ 120 #define ISNS_OBJ_UPDATED (0x0004) /* Bit 29 */ 121 #define ISNS_OBJ_MEMBER_REMOVED (0x0002) /* Bit 30 */ 122 #define ISNS_OBJ_MEMBER_ADDED (0x0001) /* Bit 31 */ 123 124 /* iSNS Attribute IDs, iSNS Draft - section 6.1. */ 125 #define ISNS_DELIMITER_ATTR_ID (0) 126 #define ISNS_EID_ATTR_ID (1) 127 #define ISNS_ENTITY_PROTOCOL_ATTR_ID (2) 128 #define ISNS_TIMESTAMP_ATTR_ID (4) 129 #define ISNS_PORTAL_IP_ADDR_ATTR_ID (16) 130 #define ISNS_PORTAL_PORT_ATTR_ID (17) 131 #define ISNS_PORTAL_NAME_ATTR_ID (18) 132 #define ISNS_ESI_INTERVAL_ATTR_ID (19) 133 #define ISNS_ESI_PORT_ATTR_ID (20) 134 #define ISNS_SCN_PORT_ATTR_ID (23) 135 #define ISNS_ISCSI_NAME_ATTR_ID (32) 136 #define ISNS_ISCSI_NODE_TYPE_ATTR_ID (33) 137 #define ISNS_ISCSI_ALIAS_ATTR_ID (34) 138 #define ISNS_ISCSI_SCN_BITMAP_ATTR_ID (35) 139 #define ISNS_PG_ISCSI_NAME_ATTR_ID (48) 140 #define ISNS_PG_PORTAL_IP_ADDR_ATTR_ID (49) 141 #define ISNS_PG_PORTAL_PORT_ATTR_ID (50) 142 #define ISNS_PG_TAG_ATTR_ID (51) 143 #define ISNS_PG_INDEX_ATTR_ID (52) 144 145 /* iSNS Defaults */ 146 #define ISNS_DEFAULT_SERVER_PORT (3205) 147 148 typedef struct isns_tlv { 149 uint32_t attr_id; 150 uint32_t attr_len; 151 uint8_t attr_value[1]; 152 } isns_tlv_t; 153 154 typedef struct isns_packet_data { 155 uint16_t version; 156 uint16_t func_id; 157 uint16_t payload_len; 158 uint16_t flags; 159 uint16_t xid; 160 uint16_t seq; 161 162 int num_of_tlvs; 163 isns_tlv_t tlvs[MAX_ISNS_OPER_ATTR_ENTRIES]; 164 } isns_packet_data_t; 165 166 typedef struct isns_reg_mesg { 167 isns_tlv_t src_attr; 168 int num_of_mesg_attrs; 169 isns_tlv_t *mesg_attrs[MAX_ISNS_MESG_ATTR_ENTRIES]; 170 isns_tlv_t delimiter_attr; 171 isns_tlv_t *operating_attrs[MAX_ISNS_OPER_ATTR_ENTRIES]; 172 } isns_reg_mesg_t; 173 174 typedef struct isns_resp_mesg { 175 uint8_t status[4]; 176 isns_tlv_t messages_attrs[MAX_ISNS_MESG_ATTR_ENTRIES]; 177 isns_tlv_t delimiter_attr; 178 isns_tlv_t operating_attrs[MAX_ISNS_OPER_ATTR_ENTRIES]; 179 } isns_resp_mesg_t; 180 181 typedef struct isns_pdu { 182 uint16_t version; 183 uint16_t func_id; 184 uint16_t payload_len; 185 uint16_t flags; 186 uint16_t xid; 187 uint16_t seq; 188 uint8_t payload[1]; 189 } isns_pdu_t; 190 191 typedef struct isns_resp { 192 uint32_t status; 193 uint8_t data[1]; 194 } isns_resp_t; 195 196 #ifdef __cplusplus 197 } 198 #endif 199 200 #endif /* _ISNS_PROTOCOL_H */ 201