xref: /titanic_41/usr/src/cmd/isns/isnsd/isns_qry.h (revision 457bba004f54d164d0490055e5ab325a62f26832)
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_QRY_H
28 #define	_ISNS_QRY_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #define	TLV2TYPE(TLV)	\
35 	(TLV)->attr_id >= FIRST_TAG_DD ? OBJ_DD : \
36 	(TLV)->attr_id >= FIRST_TAG_DDS ? OBJ_DDS : \
37 	(TLV)->attr_id >= FIRST_TAG_PG ? OBJ_PG : \
38 	(TLV)->attr_id >= FIRST_TAG_ISCSI ? OBJ_ISCSI : \
39 	(TLV)->attr_id >= FIRST_TAG_PORTAL ? OBJ_PORTAL : \
40 	(TLV)->attr_id >= FIRST_TAG_ENTITY ? OBJ_ENTITY : 0;
41 
42 #define	FOR_EACH_OBJS(IDS, NUM, UID, STMT)	\
43 {\
44 	uint32_t i1609 = 0;\
45 	while (i1609 < (NUM)) {\
46 		UID = (IDS)[i1609];\
47 		STMT\
48 		i1609 ++;\
49 	}\
50 }
51 
52 #define	NEXT_OP(OP, OP_LEN, OP_TYPE)	\
53 do {\
54 	NEXT_TLV((OP), (OP_LEN));\
55 } while ((OP_LEN) >= 8 &&\
56 	(OP)->attr_id >= TAG_RANGE[OP_TYPE][0] &&\
57 	(OP)->attr_id <= TAG_RANGE[OP_TYPE][2]);
58 
59 #define	FOR_EACH_OP(OP, OP_LEN, OP_TYPE, STMT)	\
60 {\
61 	while ((OP_LEN) >= 8) {\
62 		OP_TYPE = TLV2TYPE(OP);\
63 		STMT\
64 		NEXT_OP((OP), (OP_LEN), (OP_TYPE));\
65 	}\
66 }
67 
68 int validate_qry_key(isns_type_t, isns_tlv_t *, uint16_t,
69 	isns_attr_t *);
70 int get_qry_keys(bmp_t *, uint32_t, isns_type_t *,
71 	isns_tlv_t *, uint16_t, uint32_t **, uint32_t *);
72 int get_qry_ops(uint32_t, isns_type_t,
73 	isns_type_t, uint32_t **, uint32_t *, uint32_t *);
74 int get_qry_ops2(uint32_t *, uint32_t, isns_type_t,
75 	uint32_t **, uint32_t *, uint32_t *);
76 int get_qry_attrs(uint32_t, isns_type_t, isns_tlv_t *,
77 	uint16_t, conn_arg_t *);
78 int get_qry_attrs1(uint32_t, isns_type_t, isns_tlv_t *,
79 	uint16_t, conn_arg_t *);
80 uint32_t get_next_obj(isns_tlv_t *, uint32_t, isns_type_t,
81 	uint32_t *, uint32_t);
82 
83 #ifdef __cplusplus
84 }
85 #endif
86 
87 #endif /* _ISNS_QRY_H */
88