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