xref: /onnv-gate/usr/src/cmd/isns/isnsd/isns_server.h (revision 7836:4e95154b5b7a)
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 /*
23*7836SJohn.Forte@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24*7836SJohn.Forte@Sun.COM  * Use is subject to license terms.
25*7836SJohn.Forte@Sun.COM  */
26*7836SJohn.Forte@Sun.COM 
27*7836SJohn.Forte@Sun.COM 
28*7836SJohn.Forte@Sun.COM #ifndef _ISNS_SERVER_H
29*7836SJohn.Forte@Sun.COM #define	_ISNS_SERVER_H
30*7836SJohn.Forte@Sun.COM 
31*7836SJohn.Forte@Sun.COM #ifdef __cplusplus
32*7836SJohn.Forte@Sun.COM extern "C" {
33*7836SJohn.Forte@Sun.COM #endif
34*7836SJohn.Forte@Sun.COM 
35*7836SJohn.Forte@Sun.COM #include <assert.h>
36*7836SJohn.Forte@Sun.COM #include <sys/param.h>
37*7836SJohn.Forte@Sun.COM #include <isns_protocol.h>
38*7836SJohn.Forte@Sun.COM 
39*7836SJohn.Forte@Sun.COM #ifdef DEBUG
40*7836SJohn.Forte@Sun.COM #define	ASSERT(EXP)	assert(EXP)
41*7836SJohn.Forte@Sun.COM #else
42*7836SJohn.Forte@Sun.COM #define	ASSERT(EXP)
43*7836SJohn.Forte@Sun.COM #endif
44*7836SJohn.Forte@Sun.COM 
45*7836SJohn.Forte@Sun.COM #define	ISNS_RSP_MASK	(0x8000)
46*7836SJohn.Forte@Sun.COM 
47*7836SJohn.Forte@Sun.COM /*
48*7836SJohn.Forte@Sun.COM  * definitions for SMF.
49*7836SJohn.Forte@Sun.COM  */
50*7836SJohn.Forte@Sun.COM #define	ISNS_SERVER_SVC_NAME	"network/isns_server"
51*7836SJohn.Forte@Sun.COM #define	ISNS_SERVER_CONFIG	"config"
52*7836SJohn.Forte@Sun.COM #define	CONFIG_DATA_STORE	"data_store_location"
53*7836SJohn.Forte@Sun.COM #define	CONFIG_ESI_THRESHOLD	"ESI_retry_threshold_count"
54*7836SJohn.Forte@Sun.COM #define	CONFIG_MGMT_SCN		"Management_SCN_Enabled"
55*7836SJohn.Forte@Sun.COM #define	CONFIG_CONTROL_NODES	"Authorized_Control_Nodes"
56*7836SJohn.Forte@Sun.COM #ifdef DEBUG
57*7836SJohn.Forte@Sun.COM #define	OPT_DAEMONLIZE		"daemonlize"
58*7836SJohn.Forte@Sun.COM #endif
59*7836SJohn.Forte@Sun.COM 
60*7836SJohn.Forte@Sun.COM #define	ISNS_DAEMON_SYSLOG_PP "isns"
61*7836SJohn.Forte@Sun.COM 
62*7836SJohn.Forte@Sun.COM #define	FIRST_TAG_ENTITY	ISNS_EID_ATTR_ID
63*7836SJohn.Forte@Sun.COM #define	FIRST_TAG_ISCSI		ISNS_ISCSI_NAME_ATTR_ID
64*7836SJohn.Forte@Sun.COM #define	FIRST_TAG_PORTAL	ISNS_PORTAL_IP_ADDR_ATTR_ID
65*7836SJohn.Forte@Sun.COM #define	FIRST_TAG_PG		ISNS_PG_ISCSI_NAME_ATTR_ID
66*7836SJohn.Forte@Sun.COM #define	FIRST_TAG_DD		ISNS_DD_ID_ATTR_ID
67*7836SJohn.Forte@Sun.COM #define	FIRST_TAG_DDS		ISNS_DD_SET_ID_ATTR_ID
68*7836SJohn.Forte@Sun.COM #define	FIRST_TAG_ASSOC_ISCSI	ISNS_DD_ISCSI_INDEX_ATTR_ID
69*7836SJohn.Forte@Sun.COM #define	FIRST_TAG_ASSOC_DD	ISNS_DD_ID_ATTR_ID
70*7836SJohn.Forte@Sun.COM 
71*7836SJohn.Forte@Sun.COM #define	LAST_TAG_ENTITY		ISNS_ENTITY_INDEX_ATTR_ID
72*7836SJohn.Forte@Sun.COM #define	LAST_TAG_ISCSI		ISNS_ISCSI_AUTH_METHOD_ATTR_ID
73*7836SJohn.Forte@Sun.COM #define	LAST_TAG_PORTAL		ISNS_SCN_PORT_ATTR_ID
74*7836SJohn.Forte@Sun.COM #define	LAST_TAG_PG		ISNS_PG_INDEX_ATTR_ID
75*7836SJohn.Forte@Sun.COM #define	LAST_TAG_DD		ISNS_DD_FEATURES_ATTR_ID
76*7836SJohn.Forte@Sun.COM #define	LAST_TAG_DDS		ISNS_DD_SET_STATUS_ATTR_ID
77*7836SJohn.Forte@Sun.COM #define	LAST_TAG_ASSOC_ISCSI	ISNS_DD_ISCSI_NAME_ATTR_ID
78*7836SJohn.Forte@Sun.COM #define	LAST_TAG_ASSOC_DD	ISNS_DD_ID_ATTR_ID
79*7836SJohn.Forte@Sun.COM 
80*7836SJohn.Forte@Sun.COM #define	NUM_OF_ENTITY_ATTRS \
81*7836SJohn.Forte@Sun.COM 	(LAST_TAG_ENTITY - FIRST_TAG_ENTITY + 1)
82*7836SJohn.Forte@Sun.COM #define	NUM_OF_ISCSI_ATTRS \
83*7836SJohn.Forte@Sun.COM 	(LAST_TAG_ISCSI - FIRST_TAG_ISCSI + 1)
84*7836SJohn.Forte@Sun.COM #define	NUM_OF_PORTAL_ATTRS \
85*7836SJohn.Forte@Sun.COM 	(LAST_TAG_PORTAL - FIRST_TAG_PORTAL + 1)
86*7836SJohn.Forte@Sun.COM #define	NUM_OF_PG_ATTRS \
87*7836SJohn.Forte@Sun.COM 	(LAST_TAG_PG - FIRST_TAG_PG + 1)
88*7836SJohn.Forte@Sun.COM #define	NUM_OF_DD_ATTRS \
89*7836SJohn.Forte@Sun.COM 	(LAST_TAG_DD - FIRST_TAG_DD + 1)
90*7836SJohn.Forte@Sun.COM #define	NUM_OF_DDS_ATTRS \
91*7836SJohn.Forte@Sun.COM 	(LAST_TAG_DDS - FIRST_TAG_DDS + 1)
92*7836SJohn.Forte@Sun.COM #define	NUM_OF_ASSOC_ISCSI_ATTRS \
93*7836SJohn.Forte@Sun.COM 	(LAST_TAG_ASSOC_ISCSI - FIRST_TAG_ASSOC_ISCSI + 1)
94*7836SJohn.Forte@Sun.COM #define	NUM_OF_ASSOC_DD_ATTRS \
95*7836SJohn.Forte@Sun.COM 	(LAST_TAG_ASSOC_DD - FIRST_TAG_ASSOC_DD + 1)
96*7836SJohn.Forte@Sun.COM 
97*7836SJohn.Forte@Sun.COM #define	ATTR_INDEX_ENTITY(TAG)	((TAG) - FIRST_TAG_ENTITY)
98*7836SJohn.Forte@Sun.COM #define	ATTR_INDEX_ISCSI(TAG)	((TAG) - FIRST_TAG_ISCSI)
99*7836SJohn.Forte@Sun.COM #define	ATTR_INDEX_PORTAL(TAG)	((TAG) - FIRST_TAG_PORTAL)
100*7836SJohn.Forte@Sun.COM #define	ATTR_INDEX_PG(TAG)	((TAG) - FIRST_TAG_PG)
101*7836SJohn.Forte@Sun.COM #define	ATTR_INDEX_DD(TAG)	((TAG) - FIRST_TAG_DD)
102*7836SJohn.Forte@Sun.COM #define	ATTR_INDEX_DDS(TAG)	((TAG) - FIRST_TAG_DDS)
103*7836SJohn.Forte@Sun.COM #define	ATTR_INDEX_ASSOC_ISCSI(TAG)	((TAG) - FIRST_TAG_ASSOC_ISCSI)
104*7836SJohn.Forte@Sun.COM #define	ATTR_INDEX_ASSOC_DD(TAG)	((TAG) - FIRST_TAG_ASSOC_DD)
105*7836SJohn.Forte@Sun.COM #define	ATTR_INDEX(TAG, TYPE)	((TAG) - TAG_RANGE[TYPE][0])
106*7836SJohn.Forte@Sun.COM 
107*7836SJohn.Forte@Sun.COM #define	ISCSI_ATTR(ISCSI, TAG)	((ISCSI)->attrs[ATTR_INDEX_ISCSI(TAG)].value)
108*7836SJohn.Forte@Sun.COM 
109*7836SJohn.Forte@Sun.COM /*
110*7836SJohn.Forte@Sun.COM  * isns object type.
111*7836SJohn.Forte@Sun.COM  */
112*7836SJohn.Forte@Sun.COM typedef enum isns_otype {
113*7836SJohn.Forte@Sun.COM 	/*
114*7836SJohn.Forte@Sun.COM 	 * iSNS objects as they are defined in RFC 4171.
115*7836SJohn.Forte@Sun.COM 	 */
116*7836SJohn.Forte@Sun.COM 	OBJ_ENTITY = 0x1,
117*7836SJohn.Forte@Sun.COM 	OBJ_ISCSI,
118*7836SJohn.Forte@Sun.COM 	OBJ_PORTAL,
119*7836SJohn.Forte@Sun.COM 	OBJ_PG,
120*7836SJohn.Forte@Sun.COM 	OBJ_DD,
121*7836SJohn.Forte@Sun.COM 	OBJ_DDS,
122*7836SJohn.Forte@Sun.COM 	MAX_OBJ_TYPE,
123*7836SJohn.Forte@Sun.COM 	/*
124*7836SJohn.Forte@Sun.COM 	 * dummy object types for future extension.
125*7836SJohn.Forte@Sun.COM 	 */
126*7836SJohn.Forte@Sun.COM 	OBJ_DUMMY1,
127*7836SJohn.Forte@Sun.COM 	OBJ_DUMMY2,
128*7836SJohn.Forte@Sun.COM 	OBJ_DUMMY3,
129*7836SJohn.Forte@Sun.COM 	OBJ_DUMMY4,
130*7836SJohn.Forte@Sun.COM 	/*
131*7836SJohn.Forte@Sun.COM 	 * madeup object for internal implementation.
132*7836SJohn.Forte@Sun.COM 	 */
133*7836SJohn.Forte@Sun.COM 	OBJ_ASSOC_ISCSI,
134*7836SJohn.Forte@Sun.COM 	OBJ_ASSOC_DD,
135*7836SJohn.Forte@Sun.COM 	MAX_OBJ_TYPE_FOR_SIZE
136*7836SJohn.Forte@Sun.COM } isns_type_t;
137*7836SJohn.Forte@Sun.COM 
138*7836SJohn.Forte@Sun.COM #define	MAX_LOOKUP_CTRL	(3)
139*7836SJohn.Forte@Sun.COM /*
140*7836SJohn.Forte@Sun.COM  * lookup operation.
141*7836SJohn.Forte@Sun.COM  */
142*7836SJohn.Forte@Sun.COM typedef enum {
143*7836SJohn.Forte@Sun.COM 	OP_STRING = 1,
144*7836SJohn.Forte@Sun.COM 	OP_INTEGER,
145*7836SJohn.Forte@Sun.COM 	OP_MEMORY_IP6
146*7836SJohn.Forte@Sun.COM } lookup_method_t;
147*7836SJohn.Forte@Sun.COM 
148*7836SJohn.Forte@Sun.COM /*
149*7836SJohn.Forte@Sun.COM  * lookup control data.
150*7836SJohn.Forte@Sun.COM  */
151*7836SJohn.Forte@Sun.COM typedef struct lookup_ctrl {
152*7836SJohn.Forte@Sun.COM 	isns_type_t type;
153*7836SJohn.Forte@Sun.COM 	uint32_t curr_uid;
154*7836SJohn.Forte@Sun.COM 	uint16_t id[MAX_LOOKUP_CTRL];
155*7836SJohn.Forte@Sun.COM 	uint8_t op[MAX_LOOKUP_CTRL];
156*7836SJohn.Forte@Sun.COM 	union {
157*7836SJohn.Forte@Sun.COM 		uchar_t *ptr;
158*7836SJohn.Forte@Sun.COM 		uint32_t ui;
159*7836SJohn.Forte@Sun.COM 		in6_addr_t *ip;
160*7836SJohn.Forte@Sun.COM 	} data[MAX_LOOKUP_CTRL];
161*7836SJohn.Forte@Sun.COM } lookup_ctrl_t;
162*7836SJohn.Forte@Sun.COM 
163*7836SJohn.Forte@Sun.COM #define	SET_UID_LCP(LCP, TYPE, UID)	{\
164*7836SJohn.Forte@Sun.COM 	(LCP)->type = TYPE;\
165*7836SJohn.Forte@Sun.COM 	(LCP)->curr_uid = 0;\
166*7836SJohn.Forte@Sun.COM 	(LCP)->id[0] = UID_ATTR_INDEX[TYPE];\
167*7836SJohn.Forte@Sun.COM 	(LCP)->op[0] = OP_INTEGER;\
168*7836SJohn.Forte@Sun.COM 	(LCP)->data[0].ui = UID;\
169*7836SJohn.Forte@Sun.COM 	(LCP)->op[1] = 0;\
170*7836SJohn.Forte@Sun.COM }
171*7836SJohn.Forte@Sun.COM 
172*7836SJohn.Forte@Sun.COM #define	UPDATE_LCP_UID(LCP, UID)	{\
173*7836SJohn.Forte@Sun.COM 	(LCP)->curr_uid = 0;\
174*7836SJohn.Forte@Sun.COM 	(LCP)->id[0] = UID_ATTR_INDEX[(LCP)->type];\
175*7836SJohn.Forte@Sun.COM 	(LCP)->op[0] = OP_INTEGER;\
176*7836SJohn.Forte@Sun.COM 	(LCP)->data[0].ui = UID;\
177*7836SJohn.Forte@Sun.COM 	(LCP)->op[1] = 0;\
178*7836SJohn.Forte@Sun.COM }
179*7836SJohn.Forte@Sun.COM 
180*7836SJohn.Forte@Sun.COM /*
181*7836SJohn.Forte@Sun.COM  * isns object attribute
182*7836SJohn.Forte@Sun.COM  */
183*7836SJohn.Forte@Sun.COM typedef struct isns_attr {
184*7836SJohn.Forte@Sun.COM 	uint32_t tag;
185*7836SJohn.Forte@Sun.COM 	uint32_t len;
186*7836SJohn.Forte@Sun.COM 	union {
187*7836SJohn.Forte@Sun.COM 		int32_t i;
188*7836SJohn.Forte@Sun.COM 		uint32_t ui;
189*7836SJohn.Forte@Sun.COM 		in6_addr_t *ip;
190*7836SJohn.Forte@Sun.COM 		uchar_t *ptr;
191*7836SJohn.Forte@Sun.COM 		time_t timestamp;
192*7836SJohn.Forte@Sun.COM 	} value;
193*7836SJohn.Forte@Sun.COM } isns_attr_t;
194*7836SJohn.Forte@Sun.COM 
195*7836SJohn.Forte@Sun.COM #define	MAX_KEY_ATTRS	(3)
196*7836SJohn.Forte@Sun.COM 
197*7836SJohn.Forte@Sun.COM /*
198*7836SJohn.Forte@Sun.COM  * isns generic object.
199*7836SJohn.Forte@Sun.COM  */
200*7836SJohn.Forte@Sun.COM typedef struct isns_obj {
201*7836SJohn.Forte@Sun.COM 	isns_type_t type;
202*7836SJohn.Forte@Sun.COM 	isns_attr_t attrs[1];
203*7836SJohn.Forte@Sun.COM } isns_obj_t;
204*7836SJohn.Forte@Sun.COM 
205*7836SJohn.Forte@Sun.COM #define	ISCSI_PARENT_TYPE	(OBJ_ENTITY)
206*7836SJohn.Forte@Sun.COM #define	PORTAL_PARENT_TYPE	(OBJ_ENTITY)
207*7836SJohn.Forte@Sun.COM #define	PG_PARENT_TYPE		(OBJ_ENTITY)
208*7836SJohn.Forte@Sun.COM #define	ASSOC_ISCSI_PARENT_TYPE	(OBJ_DD)
209*7836SJohn.Forte@Sun.COM #define	ASSOC_DD_PARENT_TYPE	(OBJ_DDS)
210*7836SJohn.Forte@Sun.COM 
211*7836SJohn.Forte@Sun.COM /*
212*7836SJohn.Forte@Sun.COM  * iSNS objects.
213*7836SJohn.Forte@Sun.COM  */
214*7836SJohn.Forte@Sun.COM typedef struct isns_dds {
215*7836SJohn.Forte@Sun.COM 	isns_type_t type;
216*7836SJohn.Forte@Sun.COM 	isns_attr_t attrs[NUM_OF_DDS_ATTRS];
217*7836SJohn.Forte@Sun.COM } isns_dds_t;
218*7836SJohn.Forte@Sun.COM 
219*7836SJohn.Forte@Sun.COM typedef struct isns_assoc_dd {
220*7836SJohn.Forte@Sun.COM 	isns_type_t type;
221*7836SJohn.Forte@Sun.COM 	isns_attr_t attrs[NUM_OF_ASSOC_DD_ATTRS];
222*7836SJohn.Forte@Sun.COM 
223*7836SJohn.Forte@Sun.COM 	/* parent object uid */
224*7836SJohn.Forte@Sun.COM #ifdef ASSOC_DD_PARENT_TYPE
225*7836SJohn.Forte@Sun.COM 	uint32_t puid;
226*7836SJohn.Forte@Sun.COM #endif
227*7836SJohn.Forte@Sun.COM } isns_assoc_dd_t;
228*7836SJohn.Forte@Sun.COM 
229*7836SJohn.Forte@Sun.COM #define	DDS_ENABLED(UI) ((UI) & (ISNS_DDS_STATUS))
230*7836SJohn.Forte@Sun.COM #define	ENABLE_DDS(DDS)  (((DDS)->status) |= (ISNS_DDS_STATUS))
231*7836SJohn.Forte@Sun.COM #define	DISABLE_DDS(DDS) (((DDS)->status) &= ~(ISNS_DDS_STATUS))
232*7836SJohn.Forte@Sun.COM 
233*7836SJohn.Forte@Sun.COM #define	DD_BOOTLIST_ENABLED(UI) ((UI) & (ISNS_DD_BOOTLIST))
234*7836SJohn.Forte@Sun.COM 
235*7836SJohn.Forte@Sun.COM typedef struct isns_dd {
236*7836SJohn.Forte@Sun.COM 	isns_type_t type;
237*7836SJohn.Forte@Sun.COM 	isns_attr_t attrs[NUM_OF_DD_ATTRS];
238*7836SJohn.Forte@Sun.COM } isns_dd_t;
239*7836SJohn.Forte@Sun.COM 
240*7836SJohn.Forte@Sun.COM typedef struct isns_assoc_iscsi {
241*7836SJohn.Forte@Sun.COM 	isns_type_t type;
242*7836SJohn.Forte@Sun.COM 	isns_attr_t attrs[NUM_OF_ASSOC_ISCSI_ATTRS];
243*7836SJohn.Forte@Sun.COM 
244*7836SJohn.Forte@Sun.COM 	/* parent object uid */
245*7836SJohn.Forte@Sun.COM #ifdef ASSOC_ISCSI_PARENT_TYPE
246*7836SJohn.Forte@Sun.COM 	uint32_t puid;
247*7836SJohn.Forte@Sun.COM #endif
248*7836SJohn.Forte@Sun.COM } isns_assoc_iscsi_t;
249*7836SJohn.Forte@Sun.COM 
250*7836SJohn.Forte@Sun.COM #define	MAX_ISCSI_CHILD		(0)
251*7836SJohn.Forte@Sun.COM #define	MAX_PORTAL_CHILD	(0)
252*7836SJohn.Forte@Sun.COM #define	MAX_PG_CHILD		(0)
253*7836SJohn.Forte@Sun.COM #define	MAX_ENTITY_CHILD	(2)
254*7836SJohn.Forte@Sun.COM #define	MAX_CHILD_TYPE		(2)
255*7836SJohn.Forte@Sun.COM 
256*7836SJohn.Forte@Sun.COM #define	PG_REF_COUNT		(2)
257*7836SJohn.Forte@Sun.COM 
258*7836SJohn.Forte@Sun.COM #define	MAX_REF_COUNT		(2)
259*7836SJohn.Forte@Sun.COM 
260*7836SJohn.Forte@Sun.COM typedef struct isns_iscsi {
261*7836SJohn.Forte@Sun.COM 	isns_type_t type;
262*7836SJohn.Forte@Sun.COM 	isns_attr_t attrs[NUM_OF_ISCSI_ATTRS];
263*7836SJohn.Forte@Sun.COM 
264*7836SJohn.Forte@Sun.COM 	/* parent object uid */
265*7836SJohn.Forte@Sun.COM #ifdef ISCSI_PARENT_TYPE
266*7836SJohn.Forte@Sun.COM 	uint32_t puid;
267*7836SJohn.Forte@Sun.COM #endif
268*7836SJohn.Forte@Sun.COM 	/* subordinate object uid(s) */
269*7836SJohn.Forte@Sun.COM #if defined(MAX_ISCSI_CHILD) && (MAX_ISCSI_CHILD > 0)
270*7836SJohn.Forte@Sun.COM 	uint32_t *cuid[MAX_ISCSI_CHILD];
271*7836SJohn.Forte@Sun.COM #endif
272*7836SJohn.Forte@Sun.COM } isns_iscsi_t;
273*7836SJohn.Forte@Sun.COM 
274*7836SJohn.Forte@Sun.COM #define	IS_ISCSI_TARGET(NODE)    (((NODE)->type) & ISNS_TARGET_NODE_TYPE)
275*7836SJohn.Forte@Sun.COM #define	IS_ISCSI_INITIATOR(NODE) (((NODE)->type) & ISNS_INITIATOR_NODE_TYPE)
276*7836SJohn.Forte@Sun.COM #define	IS_ISCSI_CONTROL(NODE)   (((NODE)->type) & ISNS_CONTROL_NODE_TYPE)
277*7836SJohn.Forte@Sun.COM 
278*7836SJohn.Forte@Sun.COM #define	IS_TYPE_TARGET(TYPE)	((TYPE) & ISNS_TARGET_NODE_TYPE)
279*7836SJohn.Forte@Sun.COM #define	IS_TYPE_INITIATOR(TYPE)	((TYPE) & ISNS_INITIATOR_NODE_TYPE)
280*7836SJohn.Forte@Sun.COM #define	IS_TYPE_CONTROL(TYPE)	((TYPE) & ISNS_CONTROL_NODE_TYPE)
281*7836SJohn.Forte@Sun.COM #define	IS_TYPE_UNKNOWN(TYPE)	(!IS_TYPE_TARGET(TYPE) && \
282*7836SJohn.Forte@Sun.COM 				!IS_TYPE_INITIATOR(TYPE) && \
283*7836SJohn.Forte@Sun.COM 				!IS_TYPE_CONTROL(TYPE))
284*7836SJohn.Forte@Sun.COM 
285*7836SJohn.Forte@Sun.COM #define	IS_SCN_INIT_SELF_INFO_ONLY(UI) ((UI) & ISNS_INIT_SELF_INFO_ONLY)
286*7836SJohn.Forte@Sun.COM #define	IS_SCN_TARGET_SELF_INFO_ONLY(UI) ((UI) & ISNS_TARGET_SELF_INFO_ONLY)
287*7836SJohn.Forte@Sun.COM #define	IS_SCN_MGMT_REG(UI)		((UI) & ISNS_MGMT_REG)
288*7836SJohn.Forte@Sun.COM #define	IS_SCN_OBJ_REMOVED(UI)	((UI) & ISNS_OBJECT_REMOVED)
289*7836SJohn.Forte@Sun.COM #define	IS_SCN_OBJ_ADDED(UI)	((UI) & ISNS_OBJECT_ADDED)
290*7836SJohn.Forte@Sun.COM #define	IS_SCN_OBJ_UPDATED(UI)	((UI) & ISNS_OBJECT_UPDATED)
291*7836SJohn.Forte@Sun.COM #define	IS_SCN_MEMBER_REMOVED(UI)   ((UI) & ISNS_MEMBER_REMOVED)
292*7836SJohn.Forte@Sun.COM #define	IS_SCN_MEMBER_ADDED(UI)	((UI) & ISNS_MEMBER_ADDED)
293*7836SJohn.Forte@Sun.COM 
294*7836SJohn.Forte@Sun.COM typedef struct isns_portal {
295*7836SJohn.Forte@Sun.COM 	isns_type_t type;
296*7836SJohn.Forte@Sun.COM 	isns_attr_t attrs[NUM_OF_PORTAL_ATTRS];
297*7836SJohn.Forte@Sun.COM 
298*7836SJohn.Forte@Sun.COM 	/* parent object uid */
299*7836SJohn.Forte@Sun.COM #ifdef PORTAL_PARENT_TYPE
300*7836SJohn.Forte@Sun.COM 	uint32_t puid;
301*7836SJohn.Forte@Sun.COM #endif
302*7836SJohn.Forte@Sun.COM 	/* subordinate object uid(s) */
303*7836SJohn.Forte@Sun.COM #if defined(MAX_PORTAL_CHILD) && (MAX_PORTAL_CHILD > 0)
304*7836SJohn.Forte@Sun.COM 	uint32_t *cuid[MAX_PORTAL_CHILD];
305*7836SJohn.Forte@Sun.COM #endif
306*7836SJohn.Forte@Sun.COM } isns_portal_t;
307*7836SJohn.Forte@Sun.COM 
308*7836SJohn.Forte@Sun.COM #define	PORTAL_PORT(UI) ((UI) & ISNS_PORT_BITS)
309*7836SJohn.Forte@Sun.COM #define	ESI_PORT(UI)    ((UI) & ISNS_PORT_BITS)
310*7836SJohn.Forte@Sun.COM #define	IS_ESI_UDP(UI)  ((UI) & ISNS_PORT_TYPE)
311*7836SJohn.Forte@Sun.COM #define	SCN_PORT(UI)    ((UI) & ISNS_PORT_BITS)
312*7836SJohn.Forte@Sun.COM #define	IS_SCN_UDP(UI)  ((UI) & ISNS_PORT_TYPE)
313*7836SJohn.Forte@Sun.COM 
314*7836SJohn.Forte@Sun.COM #define	PORT_NUMBER(UI)	((UI) & ISNS_PORT_BITS)
315*7836SJohn.Forte@Sun.COM #define	IS_PORT_UDP(UI)	((UI) & ISNS_PORT_TYPE)
316*7836SJohn.Forte@Sun.COM 
317*7836SJohn.Forte@Sun.COM typedef struct isns_pg {
318*7836SJohn.Forte@Sun.COM 	isns_type_t type;
319*7836SJohn.Forte@Sun.COM 	isns_attr_t attrs[NUM_OF_PG_ATTRS];
320*7836SJohn.Forte@Sun.COM 
321*7836SJohn.Forte@Sun.COM 	/* parent object uid */
322*7836SJohn.Forte@Sun.COM #ifdef PG_PARENT_TYPE
323*7836SJohn.Forte@Sun.COM 	uint32_t puid;
324*7836SJohn.Forte@Sun.COM #endif
325*7836SJohn.Forte@Sun.COM 	/* subordinate object uid(s) */
326*7836SJohn.Forte@Sun.COM #if defined(MAX_PG_CHILD) && (MAX_PG_CHILD > 0)
327*7836SJohn.Forte@Sun.COM 	uint32_t *cuid[MAX_PG_CHILD];
328*7836SJohn.Forte@Sun.COM #endif
329*7836SJohn.Forte@Sun.COM 	/* ref count */
330*7836SJohn.Forte@Sun.COM #if defined(PG_REF_COUNT) && (PG_REF_COUNT > 0)
331*7836SJohn.Forte@Sun.COM 	uint32_t ref[PG_REF_COUNT];
332*7836SJohn.Forte@Sun.COM #endif
333*7836SJohn.Forte@Sun.COM } isns_pg_t;
334*7836SJohn.Forte@Sun.COM 
335*7836SJohn.Forte@Sun.COM #define	PG_TAG(PGT)	(((PGT)->tag) & ISNS_PG_TAG)
336*7836SJohn.Forte@Sun.COM 
337*7836SJohn.Forte@Sun.COM typedef struct isns_entity {
338*7836SJohn.Forte@Sun.COM 	isns_type_t type;
339*7836SJohn.Forte@Sun.COM 	isns_attr_t attrs[NUM_OF_ENTITY_ATTRS];
340*7836SJohn.Forte@Sun.COM 
341*7836SJohn.Forte@Sun.COM 	/* parent object uid */
342*7836SJohn.Forte@Sun.COM #ifdef ENTITY_PARENT_TYPE
343*7836SJohn.Forte@Sun.COM 	uint32_t puid;
344*7836SJohn.Forte@Sun.COM #endif
345*7836SJohn.Forte@Sun.COM 	/* subordinate object uid(s) */
346*7836SJohn.Forte@Sun.COM #if defined(MAX_ENTITY_CHILD) && (MAX_ENTITY_CHILD > 0)
347*7836SJohn.Forte@Sun.COM 	uint32_t *cuid[MAX_ENTITY_CHILD];
348*7836SJohn.Forte@Sun.COM #endif
349*7836SJohn.Forte@Sun.COM } isns_entity_t;
350*7836SJohn.Forte@Sun.COM 
351*7836SJohn.Forte@Sun.COM #define	PROTOCOL_MAX_VER(ENTITY)	((((ENTITY)->versions) >> \
352*7836SJohn.Forte@Sun.COM 							ISNS_VER_SHIFT) && \
353*7836SJohn.Forte@Sun.COM 						ISNS_VERSION)
354*7836SJohn.Forte@Sun.COM #define	PROTOCOL_MIN_VER(ENTITY)	(((ENTITY)->versions) & ISNS_VERSION)
355*7836SJohn.Forte@Sun.COM 
356*7836SJohn.Forte@Sun.COM #define	DEFAULT_EID_LEN	20
357*7836SJohn.Forte@Sun.COM #define	DEFAULT_EID_PATTERN	"isns: %.6d"
358*7836SJohn.Forte@Sun.COM 
359*7836SJohn.Forte@Sun.COM #define	DEFAULT_DD_NAME		"Default"
360*7836SJohn.Forte@Sun.COM #define	DEFAULT_DD_SET_NAME	"Default"
361*7836SJohn.Forte@Sun.COM 
362*7836SJohn.Forte@Sun.COM #define	DEFAULT_DD_FEATURES	0
363*7836SJohn.Forte@Sun.COM #define	DEFAULT_DD_SET_STATUS	0
364*7836SJohn.Forte@Sun.COM 
365*7836SJohn.Forte@Sun.COM #define	MIN_ESI_INTVAL		(20)		/* 20 seconds */
366*7836SJohn.Forte@Sun.COM #define	DEFAULT_ESI_INTVAL	(3 * 60)	/* 3 mintues */
367*7836SJohn.Forte@Sun.COM 
368*7836SJohn.Forte@Sun.COM #define	ONE_DAY		(86400)
369*7836SJohn.Forte@Sun.COM #define	INFINITY	(4294967295UL)	/* >136 years, max # of uint32_t */
370*7836SJohn.Forte@Sun.COM 
371*7836SJohn.Forte@Sun.COM /*
372*7836SJohn.Forte@Sun.COM  * function prototype.
373*7836SJohn.Forte@Sun.COM  */
374*7836SJohn.Forte@Sun.COM void *
375*7836SJohn.Forte@Sun.COM isns_port_watcher(
376*7836SJohn.Forte@Sun.COM 	void *
377*7836SJohn.Forte@Sun.COM );
378*7836SJohn.Forte@Sun.COM 
379*7836SJohn.Forte@Sun.COM uint16_t get_server_xid(void);
380*7836SJohn.Forte@Sun.COM 
381*7836SJohn.Forte@Sun.COM void inc_thr_count(void);
382*7836SJohn.Forte@Sun.COM void dec_thr_count(void);
383*7836SJohn.Forte@Sun.COM void shutdown_server(void);
384*7836SJohn.Forte@Sun.COM 
385*7836SJohn.Forte@Sun.COM #ifdef __cplusplus
386*7836SJohn.Forte@Sun.COM }
387*7836SJohn.Forte@Sun.COM #endif
388*7836SJohn.Forte@Sun.COM 
389*7836SJohn.Forte@Sun.COM #endif /* _ISNS_SERVER_H */
390