xref: /titanic_44/usr/src/cmd/isns/isnsd/isns_obj.h (revision 8956713aded83a741173fcd4f9ef1c83521fbea9)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_ISNS_OBJ_H
28 #define	_ISNS_OBJ_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #define	ENTITY_KEY		ISNS_EID_ATTR_ID
35 #define	ISCSI_KEY		ISNS_ISCSI_NAME_ATTR_ID
36 #define	PORTAL_KEY1		ISNS_PORTAL_IP_ADDR_ATTR_ID
37 #define	PORTAL_KEY2		ISNS_PORTAL_PORT_ATTR_ID
38 #define	PG_KEY1			ISNS_PG_ISCSI_NAME_ATTR_ID
39 #define	PG_KEY2			ISNS_PG_PORTAL_IP_ADDR_ATTR_ID
40 #define	PG_KEY3			ISNS_PG_PORTAL_PORT_ATTR_ID
41 #define	PG_PGT			ISNS_PG_TAG_ATTR_ID
42 #define	DD_KEY			ISNS_DD_ID_ATTR_ID
43 #define	DDS_KEY			ISNS_DD_SET_ID_ATTR_ID
44 
45 #define	ENTITY_END		ISNS_ENTITY_CERT_ATTR_ID
46 #define	ISCSI_END		ISNS_ISCSI_AUTH_METHOD_ATTR_ID
47 #define	PORTAL_END		ISNS_PORTAL_CERT_ATTR_ID
48 #define	PG_END			ISNS_PG_NEXT_ID_ATTR_ID
49 #define	DD_END			ISNS_DD_FEATURES_ATTR_ID
50 #define	DDS_END			ISNS_DD_SET_STATUS_ATTR_ID
51 
52 #define	IS_ENTITY_KEY(ID)	((ID) == ENTITY_KEY)
53 #define	IS_ISCSI_KEY(ID)	((ID) == ISCSI_KEY)
54 #define	IS_PORTAL_KEY1(ID)	((ID) == PORTAL_KEY1)
55 #define	IS_PORTAL_KEY2(ID)	((ID) == PORTAL_KEY2)
56 #define	IS_PG_KEY1(ID)		((ID) == PG_KEY1)
57 #define	IS_PG_KEY2(ID)		((ID) == PG_KEY2)
58 #define	IS_PG_KEY3(ID)		((ID) == PG_KEY3)
59 #define	IS_PG_PGT(ID)		((ID) == PG_PGT)
60 
61 #define	IS_ENTITY_ATTR(ID) \
62 	((ID) > ENTITY_KEY && (ID) <= ENTITY_END)
63 #define	IS_ISCSI_ATTR(ID) \
64 	((ID) > ISCSI_KEY && (ID) <= ISCSI_END)
65 #define	IS_PORTAL_ATTR(ID) \
66 	((ID) > PORTAL_KEY2 && (ID) <= PORTAL_END)
67 #define	IS_PG_ATTR(ID) \
68 	((ID) > PG_KEY1 && (ID) <= PG_END)
69 
70 /* functions */
71 int obj_tab_init(struct cache *);
72 
73 uint32_t set_obj_uid(void *, uint32_t);
74 int extract_attr(isns_attr_t *, const isns_tlv_t *, int);
75 int assign_attr(isns_attr_t *, const isns_attr_t *);
76 void free_one_object(isns_obj_t *);
77 void free_object(isns_obj_t *);
78 isns_obj_t *obj_calloc(int);
79 isns_obj_t *make_default_entity();
80 int reg_get_entity(
81 	isns_obj_t **,
82 	isns_tlv_t **,
83 	uint16_t *
84 );
85 int reg_get_obj(
86 	isns_obj_t **,
87 	isns_attr_t *,
88 	isns_tlv_t **,
89 	uint16_t *
90 );
91 int reg_auth_src(isns_type_t, uint32_t, uchar_t *);
92 int set_parent_obj(isns_obj_t *, uint32_t);
93 int buff_child_obj(const isns_type_t, const isns_type_t,
94 	const void *, void const***);
95 int update_child_obj(const isns_type_t, const uint32_t,
96 	void const***, int);
97 int update_ref_obj(const isns_obj_t *);
98 int verify_ref_obj(const isns_type_t, const uint32_t,
99 	void const***);
100 int update_deref_obj(isns_obj_t *);
101 uint32_t set_child_number(isns_obj_t *, int, uint16_t);
102 
103 int key_cmp(lookup_ctrl_t *, isns_obj_t *);
104 int register_object(isns_obj_t *, uint32_t *, int *);
105 int register_assoc(isns_obj_t *, uint32_t *);
106 int dereg_assoc(lookup_ctrl_t *);
107 int dereg_object(lookup_ctrl_t *, int);
108 int dereg_downwards(isns_obj_t *);
109 int data_sync(int);
110 
111 uint32_t obj_hval(void *, uint16_t, uint32_t *);
112 int is_obj_equal(isns_obj_t *, isns_obj_t *);
113 uint32_t get_obj_uid(const void *);
114 uint32_t is_obj_there(lookup_ctrl_t *);
115 uint32_t is_parent_there(uchar_t *);
116 void *assoc_clone(void *, int);
117 int obj_cmp(void *, void *, int);
118 int add_object(void *);
119 int replace_object(void *, void *, uint32_t *, int);
120 #ifdef DEBUG
121 void obj_dump(void *);
122 uint32_t *get_child_n(isns_obj_t *, int);
123 uint32_t get_ref_n(isns_obj_t *, int);
124 #endif
125 uint32_t get_ref_t(isns_obj_t *, isns_type_t);
126 
127 uint32_t *const get_parent_p(const isns_obj_t *);
128 uint32_t get_parent_uid(const isns_obj_t *);
129 uint32_t *get_child_t(isns_obj_t *, int);
130 int is_obj_online(const isns_obj_t *);
131 
132 uint32_t get_timestamp(void);
133 
134 #ifdef __cplusplus
135 }
136 #endif
137 
138 #endif /* _ISNS_OBJ_H */
139