Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ocs_isns.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2015, Emulex
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  *
31  */
32 
33 /**
34  * @file
35  * Defines the iSNS functions to register and query the iSNS server
36  * This code should be OS independant.
37  */
38 
39 #ifndef _OCS_ISNS_H
40 #define _OCS_ISNS_H
41 
42 #include "ocs_os.h"
43 #include "ocs_hal.h"
44 
45 #define PDU_MEM_SIZE 1000
46 #define ISCSI_PROTOCOL 2
47 #define ISNS_ESI_PORT 5001
48 #define ISNS_ESI_INTERVAL 360
49 
50 #define ISNS_VERSION 0x0001
51 
52 #define ISNS_TRANSACTION_ID_1 0xdead
53 #define ISNS_TRANSACTION_ID_2 0xbeef
54 
55 #define ISNS_STARTING_SEQ_ID 0x0000
56 
57 /* isns function names */
58 #define ISNS_FUNC_DEV_ATTR_REG 0x0001
59 #define ISNS_FUNC_DEV_ATTR_QRY 0x0002
60 #define ISNS_FUNC_DEV_ATTR_DEREG 0x0004
61 
62 #define ISNS_FLAG_FIRST (1 << 10)
63 #define ISNS_FLAG_LAST (1 << 11)
64 #define ISNS_FLAG_REPLACE (1 << 12)
65 #define ISNS_FLAG_AUTEHNT_BLOCK (1 << 13)
66 #define ISNS_FLAG_SERVER (1 << 14)
67 #define ISNS_FLAG_CLIENT (1 << 15)
68 
69 /* set to 1 to enable ESI */
70 #define ISNS_ENABLE_ESI 1
71 
72 /* ocs_keep_alive timer in seconds */
73 #define ISNS_KEEP_ALIVE_TIMER_PERIOD 30
74 
75 /* isns tag names */
76 #define ISNS_TAG_DELIMITER 0
77 #define ISNS_TAG_ENTITY_IDENTIFIER 1
78 #define ISNS_TAG_ENTITY_PROTOCOL 2
79 #define ISNS_TAG_MGMT_IP_ADDRESS 3
80 #define ISNS_TAG_TIMIMESTAMP 4
81 #define ISNS_TAG_PROTOCOL_RANGE 5
82 #define ISNS_TAG_REG_PERIOD 6
83 #define ISNS_TAG_ENTITY_INDEX 7
84 #define ISNS_TAG_ENTITY_NEXT_INDEX 8
85 #define ISNS_TAG_PORTAL_IP_ADDRESS 16
86 #define ISNS_TAG_PORTAL_TCP_PORT 17
87 #define ISNS_TAG_ESI_INTERVAL 19
88 #define ISNS_TAG_ESI_PORT 20
89 #define ISNS_TAG_PORTAL_INDEX 22
90 #define ISNS_TAG_SCN_PORT 23
91 #define ISNS_TAG_ISCSI_NAME 32
92 #define ISNS_TAG_ISCSI_NODE_TYPE 33
93 #define ISNS_TAG_ISCSI_ALIAS 34
94 
95 /*isns error names */
96 #define ISNS_ERROR_UNKNOWN 1
97 #define ISNS_ERROR_MSG_FORMAT 2
98 #define ISNS_ERROR_INVALID_REG 3
99 #define ISNS_ERROR_RESERVED 4
100 #define ISNS_ERROR_INVALID_QUERY 5
101 #define ISNS_ERROR_SOURCE_UNKNOWN 6
102 #define ISNS_ERROR_SOURCE_ABSENT 7
103 #define ISNS_ERROR_SOURCE_UNATHORIZED 8
104 #define ISNS_ERROR_NO_SUCH_ENTRY 9
105 #define ISNS_ERROR_VERSION_NOT_SUPPORTED 10
106 #define ISNS_ERROR_INTERNAL_ERROR 11
107 #define ISNS_ERROR_BUSY 12
108 #define ISNS_ERROR_OPTION_NOT_UNDERSTOOD 13
109 #define ISNS_ERROR_INVALID_UPDATE 14
110 #define ISNS_ERROR_FUNC_ID 15
111 #define ISNS_ERROR_SCN_EVENT_REJ 16
112 #define ISNS_ERROR_SCN_REG_REJ 17
113 #define ISNS_ERROR_NOT_IMPL 18
114 #define ISNS_ERROR_DOMAIN_ID_UNAVAILABLE 19
115 #define ISNS_ERROR_UNALLCATED_DOMAIN_ID 20
116 #define ISNS_ERROR_ESI_UNAVAILABLE 21
117 #define ISNS_ERROR_INVALID_DEREG 22
118 #define ISNS_ERROR_REG_FEATURE_UNSUPPORTED 23
119 
120 
121 typedef struct isns_hdr_s {
122 #if BYTE_ORDER == LITTLE_ENDIAN
123  uint16_t iSNSP_version;
124  uint16_t function_id;
125  uint16_t payload_length;
126  uint16_t flags;
127  uint16_t transaction_id;
128  uint16_t sequence_id;
129 
130 #else
131 #error big endian version not defined
132 #endif
133 } isns_hdr_t;
134 
135 typedef struct ocs_isns_ip_port_s {
136  char ip[48];
137  uint16_t port;
139 
140 typedef struct ocs_isns_node_s {
141  char iname[256];
142  uint16_t ipp_count;
145 
146 
147 /* Initialization and Configuration */
149 int32_t ocs_isns_teardown(ocs_iscsi_t *);
150 
151 /* Utility functions */
152 int8_t ocs_isns_register(ocs_iscsi_t *, uint8_t, uint8_t, ocs_ip_address_t *, char *);
153 void* ocs_isns_qry_tgts(ocs_iscsi_t * , ocs_ip_address_t *, uint16_t *);
154 int8_t ocs_isns_deregister(ocs_t *, ocs_ip_address_t *, char *);
155 
156 /* Nodes helper functions */
157 char * ocs_get_iscsi_name(ocs_iscsi_t *, void *, uint16_t);
158 uint16_t ocs_get_iscsi_ipp_count(ocs_iscsi_t *, void *, uint16_t);
159 char * ocs_get_ip(ocs_iscsi_t *, void *, uint16_t, uint16_t);
160 uint16_t ocs_get_port(ocs_iscsi_t *, void *, uint16_t, uint16_t);
161 
163 
164 
165 /* isns log function */
166 #define ocs_isns_log(os, fmt, ...) \
167  do { \
168  if (ocs_debug_is_enabled(OCS_DEBUG_ENABLE_ISNS_LOG)) \
169  ocs_log_info(os, fmt, ##__VA_ARGS__); \
170  } while (0)
171 
172 
173 #endif /* !_OCS_ISNS_H */
174 
175 /* vim: set noexpandtab textwidth=120: */
void ocs_str_to_ip_struct(ocs_iscsi_t *iscsi, char *ip, ocs_ip_address_t *ip_struct)
Converts a string ip into an ip struct.
Definition: ocs_isns.c:256
uint16_t payload_length
Definition: ocs_isns.h:125
int8_t ocs_isns_register(ocs_iscsi_t *iscsi, uint8_t reg_tgts, uint8_t reg_ini, ocs_ip_address_t *isns_ip, char *eid)
Sends the DevAttrReg message to the iSNS server.
Definition: ocs_isns.c:1420
char * ocs_get_iscsi_name(ocs_iscsi_t *iscsi, void *p, uint16_t index)
Gets the iscsi name of a given node.
Definition: ocs_isns.c:223
uint16_t function_id
Definition: ocs_isns.h:124
uint16_t transaction_id
Definition: ocs_isns.h:127
iSCSI object
Definition: ocs_iscsi.h:293
ocs_isns_ip_port_t * ipp
Definition: ocs_isns.h:143
void * ocs_isns_qry_tgts(ocs_iscsi_t *iscsi, ocs_ip_address_t *isns_ip, uint16_t *ret_nodes_count)
Sends the DevAttrReg message to the iSNS server.
Definition: ocs_isns.c:925
uint16_t ocs_get_iscsi_ipp_count(ocs_iscsi_t *iscsi, void *p, uint16_t index)
Gets the count of the ip_port structs in a given node.
Definition: ocs_isns.c:240
uint16_t flags
Definition: ocs_isns.h:126
uint16_t iSNSP_version
Definition: ocs_isns.h:123
int32_t ocs_isns_initialize(ocs_iscsi_t *iscsi)
Initialize the iSNS module.
Definition: ocs_isns.c:58
char * ocs_get_ip(ocs_iscsi_t *iscsi, void *p, uint16_t index, uint16_t ip_index)
Gets the ip address of a given isns node.
Definition: ocs_isns.c:301
uint16_t ocs_get_port(ocs_iscsi_t *iscsi, void *p, uint16_t index, uint16_t ip_index)
Gets the port of a given isns node.
Definition: ocs_isns.c:325
int32_t ocs_isns_teardown(ocs_iscsi_t *iscsi)
Shutdown the iSNS module.
Definition: ocs_isns.c:74
uint16_t sequence_id
Definition: ocs_isns.h:128
structure wrapping an IP address together with it&#39;s type.
Definition: ocs_iscsi_api.h:74
int8_t ocs_isns_deregister(ocs_t *ocs, ocs_ip_address_t *isns_ip, char *eid)
Sends the DevDereg message to the iSNS server.
Definition: ocs_isns.c:1806
uint16_t ipp_count
Definition: ocs_isns.h:142