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