4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 #ifndef _ISNS_SERVER_H
29 #define _ISNS_SERVER_H
36 #include <sys/param.h>
37 #include <isns_protocol.h>
40 #define ASSERT(EXP) assert(EXP)
45 #define ISNS_RSP_MASK (0x8000)
48 * definitions for SMF.
50 #define ISNS_SERVER_SVC_NAME "network/isns_server"
51 #define ISNS_SERVER_CONFIG "config"
52 #define CONFIG_DATA_STORE "data_store_location"
53 #define CONFIG_ESI_THRESHOLD "ESI_retry_threshold_count"
54 #define CONFIG_MGMT_SCN "Management_SCN_Enabled"
55 #define CONFIG_CONTROL_NODES "Authorized_Control_Nodes"
57 #define OPT_DAEMONLIZE "daemonlize"
60 #define ISNS_DAEMON_SYSLOG_PP "isns"
62 #define FIRST_TAG_ENTITY ISNS_EID_ATTR_ID
63 #define FIRST_TAG_ISCSI ISNS_ISCSI_NAME_ATTR_ID
64 #define FIRST_TAG_PORTAL ISNS_PORTAL_IP_ADDR_ATTR_ID
65 #define FIRST_TAG_PG ISNS_PG_ISCSI_NAME_ATTR_ID
66 #define FIRST_TAG_DD ISNS_DD_ID_ATTR_ID
67 #define FIRST_TAG_DDS ISNS_DD_SET_ID_ATTR_ID
68 #define FIRST_TAG_ASSOC_ISCSI ISNS_DD_ISCSI_INDEX_ATTR_ID
69 #define FIRST_TAG_ASSOC_DD ISNS_DD_ID_ATTR_ID
71 #define LAST_TAG_ENTITY ISNS_ENTITY_INDEX_ATTR_ID
72 #define LAST_TAG_ISCSI ISNS_ISCSI_AUTH_METHOD_ATTR_ID
73 #define LAST_TAG_PORTAL ISNS_SCN_PORT_ATTR_ID
74 #define LAST_TAG_PG ISNS_PG_INDEX_ATTR_ID
75 #define LAST_TAG_DD ISNS_DD_FEATURES_ATTR_ID
76 #define LAST_TAG_DDS ISNS_DD_SET_STATUS_ATTR_ID
77 #define LAST_TAG_ASSOC_ISCSI ISNS_DD_ISCSI_NAME_ATTR_ID
78 #define LAST_TAG_ASSOC_DD ISNS_DD_ID_ATTR_ID
80 #define NUM_OF_ENTITY_ATTRS \
81 (LAST_TAG_ENTITY - FIRST_TAG_ENTITY + 1)
82 #define NUM_OF_ISCSI_ATTRS \
83 (LAST_TAG_ISCSI - FIRST_TAG_ISCSI + 1)
84 #define NUM_OF_PORTAL_ATTRS \
85 (LAST_TAG_PORTAL - FIRST_TAG_PORTAL + 1)
86 #define NUM_OF_PG_ATTRS \
87 (LAST_TAG_PG - FIRST_TAG_PG + 1)
88 #define NUM_OF_DD_ATTRS \
89 (LAST_TAG_DD - FIRST_TAG_DD + 1)
90 #define NUM_OF_DDS_ATTRS \
91 (LAST_TAG_DDS - FIRST_TAG_DDS + 1)
92 #define NUM_OF_ASSOC_ISCSI_ATTRS \
93 (LAST_TAG_ASSOC_ISCSI - FIRST_TAG_ASSOC_ISCSI + 1)
94 #define NUM_OF_ASSOC_DD_ATTRS \
95 (LAST_TAG_ASSOC_DD - FIRST_TAG_ASSOC_DD + 1)
97 #define ATTR_INDEX_ENTITY(TAG) ((TAG) - FIRST_TAG_ENTITY)
98 #define ATTR_INDEX_ISCSI(TAG) ((TAG) - FIRST_TAG_ISCSI)
99 #define ATTR_INDEX_PORTAL(TAG) ((TAG) - FIRST_TAG_PORTAL)
100 #define ATTR_INDEX_PG(TAG) ((TAG) - FIRST_TAG_PG)
101 #define ATTR_INDEX_DD(TAG) ((TAG) - FIRST_TAG_DD)
102 #define ATTR_INDEX_DDS(TAG) ((TAG) - FIRST_TAG_DDS)
103 #define ATTR_INDEX_ASSOC_ISCSI(TAG) ((TAG) - FIRST_TAG_ASSOC_ISCSI)
104 #define ATTR_INDEX_ASSOC_DD(TAG) ((TAG) - FIRST_TAG_ASSOC_DD)
105 #define ATTR_INDEX(TAG, TYPE) ((TAG) - TAG_RANGE[TYPE][0])
107 #define ISCSI_ATTR(ISCSI, TAG) ((ISCSI)->attrs[ATTR_INDEX_ISCSI(TAG)].value)
112 typedef enum isns_otype
{
114 * iSNS objects as they are defined in RFC 4171.
124 * dummy object types for future extension.
131 * madeup object for internal implementation.
135 MAX_OBJ_TYPE_FOR_SIZE
138 #define MAX_LOOKUP_CTRL (3)
149 * lookup control data.
151 typedef struct lookup_ctrl
{
154 uint16_t id
[MAX_LOOKUP_CTRL
];
155 uint8_t op
[MAX_LOOKUP_CTRL
];
160 } data
[MAX_LOOKUP_CTRL
];
163 #define SET_UID_LCP(LCP, TYPE, UID) {\
165 (LCP)->curr_uid = 0;\
166 (LCP)->id[0] = UID_ATTR_INDEX[TYPE];\
167 (LCP)->op[0] = OP_INTEGER;\
168 (LCP)->data[0].ui = UID;\
172 #define UPDATE_LCP_UID(LCP, UID) {\
173 (LCP)->curr_uid = 0;\
174 (LCP)->id[0] = UID_ATTR_INDEX[(LCP)->type];\
175 (LCP)->op[0] = OP_INTEGER;\
176 (LCP)->data[0].ui = UID;\
181 * isns object attribute
183 typedef struct isns_attr
{
195 #define MAX_KEY_ATTRS (3)
198 * isns generic object.
200 typedef struct isns_obj
{
202 isns_attr_t attrs
[1];
205 #define ISCSI_PARENT_TYPE (OBJ_ENTITY)
206 #define PORTAL_PARENT_TYPE (OBJ_ENTITY)
207 #define PG_PARENT_TYPE (OBJ_ENTITY)
208 #define ASSOC_ISCSI_PARENT_TYPE (OBJ_DD)
209 #define ASSOC_DD_PARENT_TYPE (OBJ_DDS)
214 typedef struct isns_dds
{
216 isns_attr_t attrs
[NUM_OF_DDS_ATTRS
];
219 typedef struct isns_assoc_dd
{
221 isns_attr_t attrs
[NUM_OF_ASSOC_DD_ATTRS
];
223 /* parent object uid */
224 #ifdef ASSOC_DD_PARENT_TYPE
229 #define DDS_ENABLED(UI) ((UI) & (ISNS_DDS_STATUS))
230 #define ENABLE_DDS(DDS) (((DDS)->status) |= (ISNS_DDS_STATUS))
231 #define DISABLE_DDS(DDS) (((DDS)->status) &= ~(ISNS_DDS_STATUS))
233 #define DD_BOOTLIST_ENABLED(UI) ((UI) & (ISNS_DD_BOOTLIST))
235 typedef struct isns_dd
{
237 isns_attr_t attrs
[NUM_OF_DD_ATTRS
];
240 typedef struct isns_assoc_iscsi
{
242 isns_attr_t attrs
[NUM_OF_ASSOC_ISCSI_ATTRS
];
244 /* parent object uid */
245 #ifdef ASSOC_ISCSI_PARENT_TYPE
248 } isns_assoc_iscsi_t
;
250 #define MAX_ISCSI_CHILD (0)
251 #define MAX_PORTAL_CHILD (0)
252 #define MAX_PG_CHILD (0)
253 #define MAX_ENTITY_CHILD (2)
254 #define MAX_CHILD_TYPE (2)
256 #define PG_REF_COUNT (2)
258 #define MAX_REF_COUNT (2)
260 typedef struct isns_iscsi
{
262 isns_attr_t attrs
[NUM_OF_ISCSI_ATTRS
];
264 /* parent object uid */
265 #ifdef ISCSI_PARENT_TYPE
268 /* subordinate object uid(s) */
269 #if defined(MAX_ISCSI_CHILD) && (MAX_ISCSI_CHILD > 0)
270 uint32_t *cuid
[MAX_ISCSI_CHILD
];
274 #define IS_ISCSI_TARGET(NODE) (((NODE)->type) & ISNS_TARGET_NODE_TYPE)
275 #define IS_ISCSI_INITIATOR(NODE) (((NODE)->type) & ISNS_INITIATOR_NODE_TYPE)
276 #define IS_ISCSI_CONTROL(NODE) (((NODE)->type) & ISNS_CONTROL_NODE_TYPE)
278 #define IS_TYPE_TARGET(TYPE) ((TYPE) & ISNS_TARGET_NODE_TYPE)
279 #define IS_TYPE_INITIATOR(TYPE) ((TYPE) & ISNS_INITIATOR_NODE_TYPE)
280 #define IS_TYPE_CONTROL(TYPE) ((TYPE) & ISNS_CONTROL_NODE_TYPE)
281 #define IS_TYPE_UNKNOWN(TYPE) (!IS_TYPE_TARGET(TYPE) && \
282 !IS_TYPE_INITIATOR(TYPE) && \
283 !IS_TYPE_CONTROL(TYPE))
285 #define IS_SCN_INIT_SELF_INFO_ONLY(UI) ((UI) & ISNS_INIT_SELF_INFO_ONLY)
286 #define IS_SCN_TARGET_SELF_INFO_ONLY(UI) ((UI) & ISNS_TARGET_SELF_INFO_ONLY)
287 #define IS_SCN_MGMT_REG(UI) ((UI) & ISNS_MGMT_REG)
288 #define IS_SCN_OBJ_REMOVED(UI) ((UI) & ISNS_OBJECT_REMOVED)
289 #define IS_SCN_OBJ_ADDED(UI) ((UI) & ISNS_OBJECT_ADDED)
290 #define IS_SCN_OBJ_UPDATED(UI) ((UI) & ISNS_OBJECT_UPDATED)
291 #define IS_SCN_MEMBER_REMOVED(UI) ((UI) & ISNS_MEMBER_REMOVED)
292 #define IS_SCN_MEMBER_ADDED(UI) ((UI) & ISNS_MEMBER_ADDED)
294 typedef struct isns_portal
{
296 isns_attr_t attrs
[NUM_OF_PORTAL_ATTRS
];
298 /* parent object uid */
299 #ifdef PORTAL_PARENT_TYPE
302 /* subordinate object uid(s) */
303 #if defined(MAX_PORTAL_CHILD) && (MAX_PORTAL_CHILD > 0)
304 uint32_t *cuid
[MAX_PORTAL_CHILD
];
308 #define PORTAL_PORT(UI) ((UI) & ISNS_PORT_BITS)
309 #define ESI_PORT(UI) ((UI) & ISNS_PORT_BITS)
310 #define IS_ESI_UDP(UI) ((UI) & ISNS_PORT_TYPE)
311 #define SCN_PORT(UI) ((UI) & ISNS_PORT_BITS)
312 #define IS_SCN_UDP(UI) ((UI) & ISNS_PORT_TYPE)
314 #define PORT_NUMBER(UI) ((UI) & ISNS_PORT_BITS)
315 #define IS_PORT_UDP(UI) ((UI) & ISNS_PORT_TYPE)
317 typedef struct isns_pg
{
319 isns_attr_t attrs
[NUM_OF_PG_ATTRS
];
321 /* parent object uid */
322 #ifdef PG_PARENT_TYPE
325 /* subordinate object uid(s) */
326 #if defined(MAX_PG_CHILD) && (MAX_PG_CHILD > 0)
327 uint32_t *cuid
[MAX_PG_CHILD
];
330 #if defined(PG_REF_COUNT) && (PG_REF_COUNT > 0)
331 uint32_t ref
[PG_REF_COUNT
];
335 #define PG_TAG(PGT) (((PGT)->tag) & ISNS_PG_TAG)
337 typedef struct isns_entity
{
339 isns_attr_t attrs
[NUM_OF_ENTITY_ATTRS
];
341 /* parent object uid */
342 #ifdef ENTITY_PARENT_TYPE
345 /* subordinate object uid(s) */
346 #if defined(MAX_ENTITY_CHILD) && (MAX_ENTITY_CHILD > 0)
347 uint32_t *cuid
[MAX_ENTITY_CHILD
];
351 #define PROTOCOL_MAX_VER(ENTITY) ((((ENTITY)->versions) >> \
354 #define PROTOCOL_MIN_VER(ENTITY) (((ENTITY)->versions) & ISNS_VERSION)
356 #define DEFAULT_EID_LEN 20
357 #define DEFAULT_EID_PATTERN "isns: %.6d"
359 #define DEFAULT_DD_NAME "Default"
360 #define DEFAULT_DD_SET_NAME "Default"
362 #define DEFAULT_DD_FEATURES 0
363 #define DEFAULT_DD_SET_STATUS 0
365 #define MIN_ESI_INTVAL (20) /* 20 seconds */
366 #define DEFAULT_ESI_INTVAL (3 * 60) /* 3 mintues */
368 #define ONE_DAY (86400)
369 #define INFINITY (4294967295UL) /* >136 years, max # of uint32_t */
372 * function prototype.
379 uint16_t get_server_xid(void);
381 void inc_thr_count(void);
382 void dec_thr_count(void);
383 void shutdown_server(void);
389 #endif /* _ISNS_SERVER_H */