xref: /illumos-gate/usr/src/uts/common/sys/idm/idm_text.h (revision 2ef9abdc)
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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 #ifndef _IDM_TEXT_H_
26 #define	_IDM_TEXT_H_
27 
28 #ifdef	__cplusplus
29 extern "C" {
30 #endif
31 
32 #include <sys/idm/idm_impl.h>
33 
34 /*
35  * Numerical identifiers for iSCSI name-value pair keys (just so that
36  * we can use case statements to handle a particular key-value pair
37  * after we find it in idm_kvpair_xlate).
38  *
39  * We want to use a bitmask to keep track of negotiated key-value pairs
40  * so keep this enum under 64 values -- or spend some time reworking the
41  * login code.
42  */
43 typedef enum {
44 	KI_AUTH_METHOD = 1,
45 	KI_KRB_AP_REQ,
46 	KI_KRB_AP_REP,
47 
48 	/* SPKM */
49 	KI_SPKM_REQ,
50 	KI_SPKM_ERROR,
51 	KI_SPKM_REP_TI,
52 	KI_SPKM_REP_IT,
53 
54 	/*
55 	 * SRP
56 	 */
57 	KI_SRP_U,
58 	KI_TARGET_AUTH,
59 	KI_SRP_GROUP,
60 	KI_SRP_A,
61 	KI_SRP_B,
62 	KI_SRP_M,
63 	KI_SRM_HM,
64 
65 	/*
66 	 * CHAP
67 	 */
68 	KI_CHAP_A,
69 	KI_CHAP_I,
70 	KI_CHAP_C,
71 	KI_CHAP_N,
72 	KI_CHAP_R,
73 
74 
75 	/*
76 	 * ISCSI Operational Parameter Keys
77 	 */
78 	KI_HEADER_DIGEST,
79 	KI_DATA_DIGEST,
80 	KI_MAX_CONNECTIONS,
81 	KI_SEND_TARGETS,
82 	KI_TARGET_NAME,
83 	KI_INITIATOR_NAME,
84 	KI_TARGET_ALIAS,
85 	KI_INITIATOR_ALIAS,
86 	KI_TARGET_ADDRESS,
87 	KI_TARGET_PORTAL_GROUP_TAG,
88 	KI_INITIAL_R2T,
89 	KI_IMMEDIATE_DATA,
90 	KI_MAX_RECV_DATA_SEGMENT_LENGTH,
91 	KI_MAX_BURST_LENGTH,
92 	KI_FIRST_BURST_LENGTH,
93 	KI_DEFAULT_TIME_2_WAIT,
94 	KI_DEFAULT_TIME_2_RETAIN,
95 	KI_MAX_OUTSTANDING_R2T,
96 	KI_DATA_PDU_IN_ORDER,
97 	KI_DATA_SEQUENCE_IN_ORDER,
98 	KI_ERROR_RECOVERY_LEVEL,
99 	KI_SESSION_TYPE,
100 	KI_OFMARKER,
101 	KI_OFMARKERINT,
102 	KI_IFMARKER,
103 	KI_IFMARKERINT,
104 
105 	/*
106 	 * iSER-specific keys
107 	 */
108 	KI_RDMA_EXTENSIONS,
109 	KI_TARGET_RECV_DATA_SEGMENT_LENGTH,
110 	KI_INITIATOR_RECV_DATA_SEGMENT_LENGTH,
111 	KI_MAX_OUTSTANDING_UNEXPECTED_PDUS,
112 
113 	/*
114 	 * End of list marker, no keys below here.
115 	 */
116 	KI_MAX_KEY
117 } iscsikey_id_t;
118 
119 /* Numerical types for iSCSI name-value pair values */
120 typedef enum {
121 	KT_TEXT,
122 	KT_ISCSI_NAME,
123 	KT_ISCSI_LOCAL_NAME,
124 	KT_BOOLEAN,
125 	KT_NUMERICAL, /* Hex or decimal constant */
126 	KT_LARGE_NUMERICAL, /* Hex, decimal or Base64 constant */
127 	KT_NUMERIC_RANGE,
128 	KT_REGULAR_BINARY, /* Hex, decimal, base64 not longer than 64 bits */
129 	KT_LARGE_BINARY, /* Hex, decimal, base64 longer than 64 bites */
130 	KT_BINARY,	/* Regular binary or large binary */
131 	KT_SIMPLE,
132 	KT_LIST_OF_VALUES
133 } idmkey_type_t;
134 
135 typedef struct {
136 	iscsikey_id_t		ik_key_id;
137 	char			*ik_key_name;
138 	idmkey_type_t		ik_idm_type; /* RFC type */
139 	boolean_t		ik_declarative;
140 } idm_kv_xlate_t;
141 
142 const idm_kv_xlate_t *
143 idm_lookup_kv_xlate(const char *key, int keylen);
144 
145 int
146 idm_nvlist_add_keyvalue(nvlist_t *nvl, char *key, int keylen, char *value);
147 
148 int
149 idm_textbuf_to_nvlist(nvlist_t *nvl, char **textbuf, int *textbuflen);
150 
151 int
152 idm_textbuf_to_firstfraglen(void *textbuf, int textbuflen);
153 
154 int
155 idm_nvlist_to_textbuf(nvlist_t *nvl, char **textbuf, int *textbuflen,
156     int *tblen_required);
157 
158 kv_status_t
159 idm_nvstat_to_kvstat(int nvrc);
160 
161 void
162 idm_kvstat_to_error(kv_status_t kvrc, uint8_t *class, uint8_t *detail);
163 
164 int
165 idm_nvlist_add_id(nvlist_t *nvl, iscsikey_id_t kv_id, char *value);
166 
167 nvpair_t *
168 idm_get_next_listvalue(nvpair_t *value_list, nvpair_t *curr_nvp);
169 
170 char *
171 idm_id_to_name(iscsikey_id_t kv_id);
172 
173 char *
174 idm_nvpair_value_to_textbuf(nvpair_t *nvp);
175 
176 idm_status_t
177 idm_pdu_list_to_nvlist(list_t *pdu_list, nvlist_t **nvlist,
178     uint8_t *error_detail);
179 
180 void *
181 idm_nvlist_to_itextbuf(nvlist_t *nvl);
182 
183 char *
184 idm_pdu_init_text_data(idm_pdu_t *pdu, void *arg,
185     int max_xfer_len, char *bufptr, int *transit);
186 
187 void
188 idm_itextbuf_free(void *arg);
189 
190 #ifdef	__cplusplus
191 }
192 #endif
193 
194 #endif /* _IDM_TEXT_H_ */
195