summaryrefslogtreecommitdiff
path: root/libopeniscsiusr/libopeniscsiusr/libopeniscsiusr_session.h
blob: 5a0c6670b6f8b5b7f5489b332763339274b5ddd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
/*
 * Copyright (C) 2017 Red Hat, Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Author: Gris Ge <fge@redhat.com>
 */

#ifndef _LIB_OPEN_ISCSI_USR_SESSION_H_
#define _LIB_OPEN_ISCSI_USR_SESSION_H_

#include "libopeniscsiusr_common.h"

#include <stdint.h>

/**
 * iscsi_session_sid_get() - Retrieve iSCSI session ID of specified session.
 *
 * Retrieve iSCSI session ID. The session ID here is the integer used
 * in '/sys/class/iscsi_session/session<session_id>/'
 *
 * @se:
 *	Pointer of 'struct iscsi_session'.
 *	If this pointer is NULL, your program will be terminated by assert.
 *
 * Return:
 *	uint32_t.
 */
__DLL_EXPORT uint32_t iscsi_session_sid_get(struct iscsi_session *se);

/**
 * iscsi_session_persistent_address_get() - Retrieve iSCSI target persistent
 * address of specified session
 *
 * Retrieve the iSCSI target persistent address of specified iSCSI session.
 * The 'persistent address' is the network address where iSCSI initiator send
 * initial request. When iSCSI redirection in use, this address might not be
 * the network address used for actual iSCSI transaction.
 * Please use `iscsi_session_address_get()` for target network address of
 * iSCSI transaction.
 *
 * @se:
 *	Pointer of 'struct iscsi_session'.
 *	If this pointer is NULL, your program will be terminated by assert.
 *
 * Return:
 *	const char *. Empty string if not supported.
 *	No need to free this memory, the resources will get freed by
 *	iscsi_session_free() or iscsi_sessions_free().
 */
__DLL_EXPORT const char *iscsi_session_persistent_address_get
	(struct iscsi_session *se);

/**
 * iscsi_session_persistent_port_get() - Retrieve iSCSI target persistent
 * port of specified session
 *
 * Retrieve the iSCSI target persistent port of specified iSCSI session.
 * The 'persistent port' is the network port where iSCSI initiator send
 * initial request. When iSCSI redirection in use, this port might not be
 * the network port used for actual iSCSI transaction.
 * Please use `iscsi_session_port_get()` for target network address of
 * iSCSI transaction.
 *
 * @se:
 *	Pointer of 'struct iscsi_session'.
 *	If this pointer is NULL, your program will be terminated by assert.
 *
 * Return:
 *	int32_t. -1 if not supported.
 */
__DLL_EXPORT int32_t iscsi_session_persistent_port_get
	(struct iscsi_session *se);

/**
 * iscsi_session_target_name_get() - Retrieve iSCSI target name of specified
 * session
 *
 * Retrieve the iSCSI target name of specified iSCSI session.
 * The iSCSI Target Name specifies the worldwide unique name of the target.
 *
 * @se:
 *	Pointer of 'struct iscsi_session'.
 *	If this pointer is NULL, your program will be terminated by assert.
 *
 * Return:
 *	const char *.
 *	No need to free this memory, the resources will get freed by
 *	iscsi_session_free() or iscsi_sessions_free().
 */
__DLL_EXPORT const char *iscsi_session_target_name_get
	(struct iscsi_session *se);

/**
 * iscsi_session_username_get() - Retrieve authentication username of specified
 * session.
 *
 * Retrieve the authentication username of specified iSCSI session.
 * Currently open-iscsi only support CHAP authentication method.
 * It's controlled this setting in iscsid.conf:
 * 'node.session.auth.username'
 *
 * @se:
 *	Pointer of 'struct iscsi_session'.
 *	If this pointer is NULL, your program will be terminated by assert.
 *
 * Return:
 *	const char *. Empty string if not using CHAP authentication or failed
 *	to read authentication information.
 *	No need to free this memory, the resources will get freed by
 *	iscsi_session_free() or iscsi_sessions_free().
 */
__DLL_EXPORT const char *iscsi_session_username_get(struct iscsi_session *se);

/**
 * iscsi_session_password_get() - Retrieve authentication password of specified
 * session.
 *
 * Retrieve the authentication password of specified iSCSI session.
 * Currently open-iscsi only support CHAP authentication method.
 * It's controlled this setting in iscsid.conf:
 * 'node.session.auth.password'
 *
 * @se:
 *	Pointer of 'struct iscsi_session'.
 *	If this pointer is NULL, your program will be terminated by assert.
 *
 * Return:
 *	const char *. Empty string if not using CHAP authentication or failed
 *	to read authentication information.
 *	No need to free this memory, the resources will get freed by
 *	iscsi_session_free() or iscsi_sessions_free().
 */
__DLL_EXPORT const char *iscsi_session_password_get(struct iscsi_session *se);

/**
 * iscsi_session_username_in_get() - Retrieve authentication username of
 * specified session.
 *
 * Retrieve the inbound authentication username of specified iSCSI session.
 * Currently open-iscsi only support CHAP authentication method.
 * The inbound authentication here means the iSCSI initiator authenticates the
 * iSCSI target using CHAP.
 * It's controlled this setting in iscsid.conf:
 * 'node.session.auth.username_in'
 *
 * @se:
 *	Pointer of 'struct iscsi_session'.
 *	If this pointer is NULL, your program will be terminated by assert.
 *
 * Return:
 *	const char *. Empty string if not using inbound CHAP authentication or
 *	failed to read authentication information.
 *	No need to free this memory, the resources will get freed by
 *	iscsi_session_free() or iscsi_sessions_free().
 */
__DLL_EXPORT const char *iscsi_session_username_in_get
	(struct iscsi_session *se);

/**
 * iscsi_session_password_in_get() - Retrieve authentication password of
 * specified session.
 *
 * Retrieve the inbound authentication password of specified iSCSI session.
 * Currently open-iscsi only support CHAP authentication method.
 * The inbound authentication here means the iSCSI initiator authenticates the
 * iSCSI target using CHAP.
 * It's controlled this setting in iscsid.conf:
 * 'node.session.auth.password_in'
 *
 * @se:
 *	Pointer of 'struct iscsi_session'.
 *	If this pointer is NULL, your program will be terminated by assert.
 *
 * Return:
 *	const char *. Empty string if not using inbound CHAP authentication or
 *	failed to read authentication information.
 *	No need to free this memory, the resources will get freed by
 *	iscsi_session_free() or iscsi_sessions_free().
 */
__DLL_EXPORT const char *iscsi_session_password_in_get
	(struct iscsi_session *se);

/**
 * iscsi_session_recovery_tmo_get() - Retrieve recovery timeout value of
 * specified session
 *
 * Retrieve the recovery timeout value of specified iSCSI session.
 * The recovery timeout here means the seconds of time to wait for session
 * re-establishment before failing SCSI commands back to the application when
 * running the Linux SCSI Layer error handler.
 * It could be controlled via this setting in iscsid.conf:
 * 'node.session.timeo.replacement_timeout'.
 *
 * @se:
 *	Pointer of 'struct iscsi_session'.
 *	If this pointer is NULL, your program will be terminated by assert.
 *
 * Return:
 *	int32_t. If the value is 0, IO will be failed immediately. If the value
 *	is less than 0, IO will remain queued until the session is logged back
 *	in, or until the user runs the logout command.
 */
__DLL_EXPORT int32_t iscsi_session_recovery_tmo_get(struct iscsi_session *se);

/**
 * iscsi_session_lu_reset_tmo_get() - Retrieve logical unit timeout value of
 * specified session
 *
 * Retrieve the logical unit timeout value of specified iSCSI session.
 * The logical unit timeout here means the seconds of time to wait for a logical
 * unit response before before failing the operation and trying session
 * re-establishment.
 * It could be controlled via this setting in iscsid.conf:
 * 'node.session.err_timeo.lu_reset_timeout'
 *
 * @se:
 *	Pointer of 'struct iscsi_session'.
 *	If this pointer is NULL, your program will be terminated by assert.
 *
 * Return:
 *	int32_t. -1 if not supported.
 */
__DLL_EXPORT int32_t iscsi_session_lu_reset_tmo_get(struct iscsi_session *se);

/**
 * iscsi_session_tgt_reset_tmo_get() - Retrieve target response timeout value of
 * of specified session
 *
 * Retrieve the target response timeout value of specified iSCSI session.
 * The target response timeout here means the seconds of time to wait for a
 * target response before before failing the operation and trying session
 * re-establishment.
 * It could be controlled via this setting in iscsid.conf:
 * 'node.session.err_timeo.tgt_reset_timeout'.
 *
 * @se:
 *	Pointer of 'struct iscsi_session'.
 *	If this pointer is NULL, your program will be terminated by assert.
 *
 * Return:
 *	int32_t. -1 if not supported.
 */
__DLL_EXPORT int32_t iscsi_session_tgt_reset_tmo_get(struct iscsi_session *se);

/**
 * iscsi_session_abort_tmo_get() - Retrieve abort response timeout value of
 * specified session
 *
 * Retrieve the abort response timeout value of specified iSCSI session.
 * The abort response timeout here means the seconds of time to wait for a
 * abort response before before failing the operation and trying session
 * re-establishment.
 * It could be controlled via this setting in iscsid.conf:
 * 'node.session.err_timeo.abort_timeout'.
 *
 * @se:
 *	Pointer of 'struct iscsi_session'.
 *	If this pointer is NULL, your program will be terminated by assert.
 *
 * Return:
 *	int32_t. -1 if not supported.
 */
__DLL_EXPORT int32_t iscsi_session_abort_tmo_get(struct iscsi_session *se);

/**
 * iscsi_session_tpgt_get() - Retrieve target portal group tag of specified
 * session
 *
 * Retrieve the target portal group tag of specified iSCSI session.
 *
 * The target portal group tag is a value that uniquely identifies a portal
 * group within an iSCSI target node. This key carries the value of the tag of
 * the portal group that is servicing the Login request. The iSCSI target
 * returns this key to the initiator in the Login Response PDU to the first
 * Login Request PDU that has the C bit set to 0 when TargetName is given by the
 * initiator.
 *
 * @se:
 *	Pointer of 'struct iscsi_session'.
 *	If this pointer is NULL, your program will be terminated by assert.
 *
 * Return:
 *	int32_t. -1 if not supported.
 */
__DLL_EXPORT int32_t iscsi_session_tpgt_get(struct iscsi_session *se);

/**
 * iscsi_session_address_get() - Retrieve iSCSI target address of specified
 * session
 *
 * Retrieve the iSCSI target network address of specified iSCSI session.
 *
 * @se:
 *	Pointer of 'struct iscsi_session'.
 *	If this pointer is NULL, your program will be terminated by assert.
 *
 * Return:
 *	const char *. Empty string if not supported.
 *	No need to free this memory, the resources will get freed by
 *	iscsi_session_free() or iscsi_sessions_free().
 */
__DLL_EXPORT const char *iscsi_session_address_get
	(struct iscsi_session *se);

/**
 * iscsi_session_port_get() - Retrieve iSCSI target port of specified session
 *
 * Retrieve the iSCSI target port of specified iSCSI session.
 *
 * @se:
 *	Pointer of 'struct iscsi_session'.
 *	If this pointer is NULL, your program will be terminated by assert.
 *
 * Return:
 *	int32_t. -1 if not supported.
 */
__DLL_EXPORT int32_t iscsi_session_port_get(struct iscsi_session *se);

/**
 * iscsi_session_iface_get() - Retrieve iSCSI interface information of
 * specified session
 *
 * Retrieve the iSCSI interface information of specified iSCSI session.
 * For the properties of 'struct iscsi_iface', please refer to the functions
 * defined in 'libopeniscsiusr_iface.h' file.
 *
 * @se:
 *	Pointer of 'struct iscsi_session'.
 *	If this pointer is NULL, your program will be terminated by assert.
 *
 * Return:
 *	Pointer of 'struct iscsi_iface'. NULL if not supported.
 *	No need to free this memory, the resources will get freed by
 *	iscsi_session_free() or iscsi_sessions_free().
 */
__DLL_EXPORT struct iscsi_iface *iscsi_session_iface_get
	(struct iscsi_session *se);

#endif /* End of _LIB_OPEN_ISCSI_USR_SESSION_H_ */