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