1 /*
2    Copyright (C) 2010 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
3 
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU Lesser General Public License as published by
6    the Free Software Foundation; either version 2.1 of the License, or
7    (at your option) any later version.
8 
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU Lesser General Public License for more details.
13 
14    You should have received a copy of the GNU Lesser General Public License
15    along with this program; if not, see <http://www.gnu.org/licenses/>.
16 */
17 #ifndef __iscsi_h__
18 #define __iscsi_h__
19 
20 #include <stdint.h>
21 #include <sys/types.h>
22 
23 #if defined(_WIN32)
24 #define EXTERN __declspec( dllexport )
25 #else
26 #define EXTERN
27 #endif
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 
34 struct iscsi_context;
35 struct sockaddr;
36 struct scsi_iovec;
37 
38 /* API VERSION */
39 #define LIBISCSI_API_VERSION (20170105)
40 
41 /* FEATURES */
42 #define LIBISCSI_FEATURE_IOVECTOR (1)
43 #define LIBISCSI_FEATURE_NOP_COUNTER (1)
44 #define LIBISCSI_FEATURE_ISER (1)
45 
46 #define MAX_STRING_SIZE (255)
47 
48 /*
49  * Syntax for normal and portal/discovery URLs.
50  */
51 #define ISCSI_URL_SYNTAX "\"iscsi://[<username>[%<password>]@]" \
52   "<host>[:<port>]/<target-iqn>/<lun>\""
53 #define ISCSI_PORTAL_URL_SYNTAX "\"iscsi://[<username>[%<password>]@]" \
54   "<host>[:<port>]\""
55 
56 enum iscsi_transport_type {
57 	TCP_TRANSPORT = 0,
58 	ISER_TRANSPORT = 1
59 };
60 
61 EXTERN void iscsi_set_cache_allocations(struct iscsi_context *iscsi, int ca);
62 
63 /*
64  * The following three functions are used to integrate libiscsi in an event
65  * system.
66  */
67 /*
68  * Returns the file descriptor that libiscsi uses.
69  */
70 EXTERN int iscsi_get_fd(struct iscsi_context *iscsi);
71 /*
72  * Returns which events that we need to poll for for the iscsi file descriptor.
73  *
74  * This function can return 0 which means that there are no events to
75  * poll for at this time. In that case the application should wait some time
76  * before calling iscsi_which_events() again. This could for example happen
77  * if we fail to reconnect the TCP session during an automatic session
78  * reconnect.
79  * When this function returns 0, the application should wait >=100ms
80  * before trying again.
81  */
82 EXTERN int iscsi_which_events(struct iscsi_context *iscsi);
83 /*
84  * Called to process the events when events become available for the iscsi
85  * file descriptor.
86  */
87 EXTERN int iscsi_service(struct iscsi_context *iscsi, int revents);
88 /*
89  * How many commands are in flight.
90  */
91 EXTERN int iscsi_queue_length(struct iscsi_context *iscsi);
92 /*
93  * How many commands are queued for dispatch.
94  */
95 EXTERN int iscsi_out_queue_length(struct iscsi_context *iscsi);
96 
97 
98 /************************************************************
99  * Timeout Handling.
100  * Libiscsi does not use or interface with any system timers.
101  * Instead all timeout processing in libiscsi is done as part
102  * of the iscsi_service() processing.
103  *
104  * This means that if you use the timeout function below you must
105  * device your application to call out to iscsi_service() at regular
106  * intervals.
107  * An easy way to do this is calling iscsi_service(iscsi, 0), i.e.
108  * by passing 0 as the revents arguments once every second or so.
109  ************************************************************/
110 
111 /*
112  * Set the timeout in seconds after which a task/pdu will timeout.
113  * This timeout applies to SCSI task PDUs as well as normal iSCSI
114  * PDUs such as login/task management/logout/...
115  *
116  * Each PDU is assigned its timeout value upon creation and can not be
117  * changed afterwards. I.e. When you change the default timeout, it will
118  * only affect any commands that are issued in the future but will not
119  * affect the timeouts for any commands already in flight.
120  *
121  * The recommended usecase is to set to a default value for all PDUs
122  * and only change the default temporarily when a specific task needs
123  * a different timeout.
124  *
125  * // Set default to 5 seconds for all commands at beginning of program.
126  * iscsi_set_timeout(iscsi, 5);
127  *
128  * ...
129  * // SANITIZE command will take long so set it to no tiemout.
130  * iscsi_set_timeout(iscsi, 0);
131  * iscsi_sanitize_task(iscsi, ...
132  * iscsi_set_timeout(iscsi, <set back to original value>);
133  * ...
134  *
135  *
136  * Default is 0 == no timeout.
137  */
138 EXTERN int iscsi_set_timeout(struct iscsi_context *iscsi, int timeout);
139 
140 /*
141  * To set tcp keepalive for the session.
142  * Only options supported by given platform (if any) are set.
143  */
144 EXTERN int iscsi_set_tcp_keepalive(struct iscsi_context *iscsi, int idle, int count, int interval);
145 
146 struct iscsi_url {
147        char portal[MAX_STRING_SIZE + 1];
148        char target[MAX_STRING_SIZE + 1];
149        char user[MAX_STRING_SIZE + 1];
150        char passwd[MAX_STRING_SIZE + 1];
151        char target_user[MAX_STRING_SIZE + 1];
152        char target_passwd[MAX_STRING_SIZE + 1];
153        int lun;
154        struct iscsi_context *iscsi;
155        enum iscsi_transport_type transport;
156 };
157 
158 /*
159  * This function is used to set the desired mode for immediate data.
160  * This can be set on a context before it has been logged in to the target
161  * and controls how the initiator will try to negotiate the immediate data.
162  *
163  * Default is for libiscsi to try to negotiate ISCSI_IMMEDIATE_DATA_YES
164  */
165 enum iscsi_immediate_data {
166 	ISCSI_IMMEDIATE_DATA_NO  = 0,
167 	ISCSI_IMMEDIATE_DATA_YES = 1
168 };
169 EXTERN int iscsi_set_immediate_data(struct iscsi_context *iscsi, enum iscsi_immediate_data immediate_data);
170 
171 /*
172  * This function is used to set the desired mode for initial_r2t
173  * This can be set on a context before it has been logged in to the target
174  * and controls how the initiator will try to negotiate the initial r2t.
175  *
176  * Default is for libiscsi to try to negotiate ISCSI_INITIAL_R2T_NO
177  */
178 enum iscsi_initial_r2t {
179 	ISCSI_INITIAL_R2T_NO  = 0,
180 	ISCSI_INITIAL_R2T_YES = 1
181 };
182 EXTERN int
183 iscsi_set_initial_r2t(struct iscsi_context *iscsi, enum iscsi_initial_r2t initial_r2t);
184 
185 
186 /*
187  * This function is used to parse an iSCSI URL into a iscsi_url structure.
188  * iSCSI URL format :
189  * iscsi://[<username>[%<password>]@]<host>[:<port>]/<target-iqn>/<lun>
190  *
191  * Target names are url encoded with '%' as a special character.
192  * Example:
193  * "iqn.ronnie.test%3A1234" will be translated to "iqn.ronnie.test:1234"
194  *
195  * Function will return a pointer to an iscsi url structure if successful,
196  * or it will return NULL and set iscsi_get_error() accordingly if there was a problem
197  * with the URL.
198  *
199  * CHAP username/password can also be provided via environment variables
200  * LIBISCSI_CHAP_USERNAME=ronnie
201  * LIBISCSI_CHAP_PASSWORD=password
202  *
203  * The returned structure is freed by calling iscsi_destroy_url()
204  */
205 EXTERN struct iscsi_url *iscsi_parse_full_url(struct iscsi_context *iscsi, const char *url);
206 EXTERN void iscsi_destroy_url(struct iscsi_url *iscsi_url);
207 
208 /*
209  * This function is used to parse an iSCSI Portal URL into a iscsi_url structure.
210  * iSCSI Portal URL format :
211  * iscsi://[<username>[%<password>]@]<host>[:<port>]
212  *
213  * iSCSI Portal URL is used when describing a discovery session, where the target-iqn and the
214  * lun is not yet known.
215  *
216  * Function will return a pointer to an iscsi url structure if successful,
217  * or it will return NULL and set iscsi_get_error() accordingly if there was a problem
218  * with the URL.
219  *
220  * CHAP username/password can also be provided via environment variables
221  * LIBISCSI_CHAP_USERNAME=ronnie
222  * LIBISCSI_CHAP_PASSWORD=password
223  *
224  * The returned structure is freed by calling iscsi_destroy_url()
225  */
226 EXTERN struct iscsi_url *
227 iscsi_parse_portal_url(struct iscsi_context *iscsi, const char *url);
228 
229 /*
230  * This function returns a description of the last encountered error.
231  */
232 EXTERN const char *iscsi_get_error(struct iscsi_context *iscsi);
233 
234 /*
235  * Create a context for an ISCSI session.
236  * Initiator_name is the iqn name we want to identify to the target as.
237  *
238  * Returns:
239  *  non-NULL: success
240  *  NULL: error
241  */
242 EXTERN struct iscsi_context *iscsi_create_context(const char *initiator_name);
243 
244 /*
245  * Destroy an existing ISCSI context and tear down any existing connection.
246  * Callbacks for any command in flight will be invoked with
247  * SCSI_STATUS_CANCELLED.
248  *
249  * Returns:
250  *  0: success
251  * <0: error
252  */
253 EXTERN int iscsi_destroy_context(struct iscsi_context *iscsi);
254 
255 /*
256  * Sets and initializes the transport type for a context.
257  * TCP_TRANSPORT is the default and is available on all platforms.
258  * ISER_TRANSPORT is conditionally supported on Linux where available.
259  *
260  * Returns:
261  *  0: success
262  * <0: error
263  */
264 EXTERN int iscsi_init_transport(struct iscsi_context *iscsi,
265                                 enum iscsi_transport_type transport);
266 
267 /*
268  * Set an optional alias name to identify with when connecting to the target
269  *
270  * Returns:
271  *  0: success
272  * <0: error
273  */
274 EXTERN int iscsi_set_alias(struct iscsi_context *iscsi, const char *alias);
275 
276 
277 /*
278  * Set the iqn name of the taqget to login to.
279  * The target name must be set before a normal-login can be initiated.
280  * Only discovery-logins are possible without setting the target iqn name.
281  *
282  * Returns:
283  *  0: success
284  * <0: error
285  */
286 EXTERN int iscsi_set_targetname(struct iscsi_context *iscsi, const char *targetname);
287 
288 /*
289  * This function returns any target address supplied in a login response when
290  * the target has moved.
291  */
292 EXTERN const char *iscsi_get_target_address(struct iscsi_context *iscsi);
293 
294 /* Type of iscsi sessions. Discovery sessions are used to query for what
295  * targets exist behind the portal connected to. Normal sessions are used to
296  * log in and do I/O to the SCSI LUNs
297  */
298 enum iscsi_session_type {
299 	ISCSI_SESSION_DISCOVERY = 1,
300 	ISCSI_SESSION_NORMAL    = 2
301 };
302 /*
303  * Set the session type for a scsi context.
304  * Session type can only be set/changed before the context
305  * is logged in to the target.
306  *
307  * Returns:
308  *  0: success
309  * <0: error
310  */
311 EXTERN int iscsi_set_session_type(struct iscsi_context *iscsi,
312 			   enum iscsi_session_type session_type);
313 
314 
315 /*
316  * Types of header digest we support. Default is NONE
317  */
318 enum iscsi_header_digest {
319 	ISCSI_HEADER_DIGEST_NONE        = 0,
320 	ISCSI_HEADER_DIGEST_NONE_CRC32C = 1,
321 	ISCSI_HEADER_DIGEST_CRC32C_NONE = 2,
322 	ISCSI_HEADER_DIGEST_CRC32C      = 3,
323 	ISCSI_HEADER_DIGEST_LAST        = ISCSI_HEADER_DIGEST_CRC32C
324 };
325 
326 /*
327  * Set the desired header digest for a scsi context.
328  * Header digest can only be set/changed before the context
329  * is logged in to the target.
330  *
331  * Returns:
332  *  0: success
333  * <0: error
334  */
335 EXTERN int iscsi_set_header_digest(struct iscsi_context *iscsi,
336 			    enum iscsi_header_digest header_digest);
337 
338 /*
339  * Specify the username and password to use for chap authentication
340  */
341 EXTERN int iscsi_set_initiator_username_pwd(struct iscsi_context *iscsi,
342     					    const char *user,
343 					    const char *passwd);
344 /*
345  * Specify the username and password to use for target chap authentication.
346  * Target/bidirectional CHAP is only supported if you also have normal
347  * CHAP authentication.
348  * You must configure CHAP first using iscsi_set_initiator_username_pwd()
349 `* before you can set up target authentication.
350  */
351 EXTERN int iscsi_set_target_username_pwd(struct iscsi_context *iscsi,
352 					 const char *user,
353 					 const char *passwd);
354 
355 /*
356  * check if the context is logged in or not
357  */
358 EXTERN int iscsi_is_logged_in(struct iscsi_context *iscsi);
359 
360 
361 enum scsi_status {
362 	SCSI_STATUS_GOOD                 = 0,
363 	SCSI_STATUS_CHECK_CONDITION      = 2,
364 	SCSI_STATUS_CONDITION_MET        = 4,
365 	SCSI_STATUS_BUSY                 = 8,
366 	SCSI_STATUS_RESERVATION_CONFLICT = 0x18,
367 	SCSI_STATUS_TASK_SET_FULL        = 0x28,
368 	SCSI_STATUS_ACA_ACTIVE           = 0x30,
369 	SCSI_STATUS_TASK_ABORTED         = 0x40,
370 	SCSI_STATUS_REDIRECT             = 0x101,
371 	SCSI_STATUS_CANCELLED            = 0x0f000000,
372 	SCSI_STATUS_ERROR                = 0x0f000001,
373 	SCSI_STATUS_TIMEOUT              = 0x0f000002
374 };
375 
376 
377 /*
378  * Generic callback for completion of iscsi_*_async().
379  * command_data depends on status.
380  */
381 typedef void (*iscsi_command_cb)(struct iscsi_context *iscsi, int status,
382 				 void *command_data, void *private_data);
383 
384 
385 
386 /*
387  * Asynchronous call to connect a TCP connection to the target-host/port
388  *
389  * Returns:
390  *  0 if the call was initiated and a connection will be attempted. Result of
391  * the connection will be reported through the callback function.
392  * <0 if there was an error. The callback function will not be invoked.
393  *
394  * This command is unique in that the callback can be invoked twice.
395  *
396  * Callback parameters :
397  * status can be either of :
398  *    SCSI_STATUS_GOOD     : Connection was successful. Command_data is NULL.
399  *                           In this case the callback will be invoked a
400  *                           second time once the connection is torn down.
401  *
402  *    SCSI_STATUS_ERROR    : Either failed to establish the connection, or
403  *                           an already established connection has failed
404  *                           with an error.
405  *
406  * The callback will NOT be invoked if the session is explicitely torn down
407  * through a call to iscsi_disconnect() or iscsi_destroy_context().
408  */
409 EXTERN int iscsi_connect_async(struct iscsi_context *iscsi, const char *portal,
410 			iscsi_command_cb cb, void *private_data);
411 
412 /*
413  * Synchronous call to connect a TCP connection to the target-host/port
414  *
415  * Returns:
416  *  0 if connected successfully.
417  * <0 if there was an error.
418  *
419  */
420 EXTERN int iscsi_connect_sync(struct iscsi_context *iscsi, const char *portal);
421 
422 
423 /*
424  * Asynchronous call to connect a lun
425  * This function will connect to the portal, login, and verify that the lun
426  * is available.
427  *
428  * Returns:
429  *  0 if the call was initiated and a connection will be attempted. Result
430  *    of the connection will be reported through the callback function.
431  * <0 if there was an error. The callback function will not be invoked.
432  *
433  * This command is unique in that the callback can be invoked twice.
434  *
435  * Callback parameters :
436  * status can be either of :
437  *    SCSI_STATUS_GOOD     : Connection was successful. Command_data is NULL.
438  *                           In this case the callback will be invoked a
439  *                           second time once the connection is torn down.
440  *
441  *    SCSI_STATUS_ERROR    : Either failed to establish the connection, or
442  *                           an already established connection has failed
443  *                           with an error.
444  *
445  * The callback will NOT be invoked if the session is explicitely torn down
446  * through a call to iscsi_disconnect() or iscsi_destroy_context().
447  */
448 EXTERN int iscsi_full_connect_async(struct iscsi_context *iscsi, const char *portal,
449 			     int lun, iscsi_command_cb cb, void *private_data);
450 
451 /*
452  * Synchronous call to connect a lun
453  * This function will connect to the portal, login, and verify that the lun
454  * is available.
455  *
456  * Returns:
457  *  0 if the cconnect was successful.
458  * <0 if there was an error.
459  */
460 EXTERN int iscsi_full_connect_sync(struct iscsi_context *iscsi, const char *portal,
461 			    int lun);
462 
463 /*
464  * Disconnect a connection to a target.
465  * You can not disconnect while being logged in to a target.
466  *
467  * Returns:
468  *  0 disconnect was successful
469  * <0 error
470  */
471 EXTERN int iscsi_disconnect(struct iscsi_context *iscsi);
472 
473 /*
474  * Disconnect a connection to a target and try to reconnect (async version).
475  * This call returns immediately and the reconnect is processed in the
476  * background. Commands send to this connection will be queued and not
477  * processed until we have successfully reconnected.
478  *
479  * Returns:
480  *  0 reconnect was successful
481  * <0 error
482  */
483 EXTERN int iscsi_reconnect(struct iscsi_context *iscsi);
484 
485 /*
486  * Disconnect a connection to a target and try to reconnect (sync version).
487  * This call will block until the connection is reestablished.
488  *
489  * Returns:
490  *  0 reconnect was successful
491  * <0 error
492  */
493 EXTERN int iscsi_reconnect_sync(struct iscsi_context *iscsi);
494 
495 /*
496  * Asynchronous call to perform an ISCSI login.
497  *
498  * Returns:
499  *  0 if the call was initiated and a login will be attempted. Result of the
500  *    login will be reported through the callback function.
501  * <0 if there was an error. The callback function will not be invoked.
502  *
503  * Callback parameters :
504  * status can be either of :
505  *    SCSI_STATUS_GOOD     : login was successful. Command_data is always
506  *                           NULL.
507  *    SCSI_STATUS_CANCELLED: login was aborted. Command_data is NULL.
508  *    SCSI_STATUS_ERROR    : login failed. Command_data is NULL.
509  */
510 EXTERN int iscsi_login_async(struct iscsi_context *iscsi, iscsi_command_cb cb,
511 		      void *private_data);
512 
513 /*
514  * Synchronous call to perform an ISCSI login.
515  *
516  * Returns:
517  *  0 if the login was successful
518  * <0 if there was an error.
519  */
520 EXTERN int iscsi_login_sync(struct iscsi_context *iscsi);
521 
522 
523 /*
524  * Asynchronous call to perform an ISCSI logout.
525  *
526  * Returns:
527  *  0 if the call was initiated and a logout will be attempted. Result of the
528  *    logout will be reported through the callback function.
529  * <0 if there was an error. The callback function will not be invoked.
530  *
531  * Callback parameters :
532  * status can be either of :
533  *    SCSI_STATUS_GOOD     : logout was successful. Command_data is always
534  *                           NULL.
535  *    SCSI_STATUS_CANCELLED: logout was aborted. Command_data is NULL.
536  */
537 EXTERN int iscsi_logout_async(struct iscsi_context *iscsi, iscsi_command_cb cb,
538 		       void *private_data);
539 
540 /*
541  * Synchronous call to perform an ISCSI logout.
542  *
543  * Returns:
544  *  0 if the logout was successful
545  * <0 if there was an error.
546  */
547 EXTERN int iscsi_logout_sync(struct iscsi_context *iscsi);
548 
549 
550 struct iscsi_target_portal {
551        struct iscsi_target_portal *next;
552        const char *portal;
553 };
554 
555 struct iscsi_discovery_address {
556        struct iscsi_discovery_address *next;
557        const char *target_name;
558        struct iscsi_target_portal *portals;
559 };
560 
561 /*
562  * Asynchronous call to perform an ISCSI discovery.
563  *
564  * discoveries can only be done on connected and logged in discovery sessions.
565  *
566  * Returns:
567  *  0 if the call was initiated and a discovery  will be attempted. Result
568  *    will be reported through the callback function.
569  * <0 if there was an error. The callback function will not be invoked.
570  *
571  * Callback parameters :
572  * status can be either of :
573  *    SCSI_STATUS_GOOD     : Discovery was successful. Command_data is a
574  *                           pointer to a iscsi_discovery_address list of
575  *                           structures.
576  *                           This list of structures is only valid for the
577  *                           duration of the callback and all data will be
578  *                           freed once the callback returns.
579  *    SCSI_STATUS_CANCELLED : Discovery was aborted. Command_data is NULL.
580  */
581 EXTERN int iscsi_discovery_async(struct iscsi_context *iscsi, iscsi_command_cb cb,
582 			  void *private_data);
583 
584 /*
585  * Synchronous call to perform an ISCSI discovery.
586  *
587  * discoveries can only be done on connected and logged in discovery sessions.
588  *
589  * Returns:
590  *  NULL if there was an error.
591  *  struct iscsi_discovery_address* if the discovery was successfull.
592  *    The data returned must be released by calling iscsi_free_discovery_data.
593  */
594 EXTERN struct iscsi_discovery_address *iscsi_discovery_sync(
595         struct iscsi_context *iscsi);
596 
597 /* Free the discovery data structures returned by iscsi_discovery_sync
598  */
599 EXTERN void iscsi_free_discovery_data(struct iscsi_context *iscsi,
600                                       struct iscsi_discovery_address *da);
601 
602 /*
603  * Asynchronous call to perform an ISCSI NOP-OUT call
604  *
605  * Returns:
606  *  0 if the call was initiated and a nop-out will be attempted. Result will
607  *    be reported through the callback function.
608  * <0 if there was an error. The callback function will not be invoked.
609  *
610  * Callback parameters :
611  * status can be either of :
612  *    SCSI_STATUS_GOOD     : NOP-OUT was successful and the server responded
613  *                           with a NOP-IN callback_data is a iscsi_data
614  *                           structure containing the data returned from
615  *                           the server.
616  *    SCSI_STATUS_CANCELLED : Discovery was aborted. Command_data is NULL.
617  *
618  * The callback may be NULL if you only want to let libiscsi count the in-flight
619  * NOPs.
620  */
621 EXTERN int iscsi_nop_out_async(struct iscsi_context *iscsi, iscsi_command_cb cb,
622 			unsigned char *data, int len, void *private_data);
623 
624 
625 /* read out the number of consecutive nop outs that did not receive an answer */
626 EXTERN int iscsi_get_nops_in_flight(struct iscsi_context *iscsi);
627 
628 struct scsi_task;
629 struct scsi_sense;
630 
631 enum iscsi_task_mgmt_funcs {
632      ISCSI_TM_ABORT_TASK        = 0x01,
633      ISCSI_TM_ABORT_TASK_SET    = 0x02,
634      ISCSI_TM_CLEAR_ACA         = 0x03,
635      ISCSI_TM_CLEAR_TASK_SET    = 0x04,
636      ISCSI_TM_LUN_RESET         = 0x05,
637      ISCSI_TM_TARGET_WARM_RESET = 0x06,
638      ISCSI_TM_TARGET_COLD_RESET = 0x07,
639      ISCSI_TM_TASK_REASSIGN     = 0x08
640 };
641 
642 enum iscsi_task_mgmt_response {
643 	ISCSI_TMR_FUNC_COMPLETE				= 0x0,
644 	ISCSI_TMR_TASK_DOES_NOT_EXIST			= 0x1,
645 	ISCSI_TMR_LUN_DOES_NOT_EXIST			= 0x2,
646 	ISCSI_TMR_TASK_STILL_ALLEGIANT			= 0x3,
647 	ISCSI_TMR_TASK_ALLEGIANCE_REASS_NOT_SUPPORTED	= 0x4,
648 	ISCSI_TMR_TMF_NOT_SUPPORTED			= 0x5,
649 	ISCSI_TMR_FUNC_AUTH_FAILED			= 0x6,
650 	ISCSI_TMR_FUNC_REJECTED				= 0xFF
651 };
652 
653 /*
654  * Asynchronous call for task management
655  *
656  * Returns:
657  *  0 if the call was initiated and the task mgmt function will be invoked.
658  *    The result will be reported through the callback function.
659  * <0 if there was an error. The callback function will not be invoked.
660  *
661  * Callback parameters :
662  * status can be either of :
663  *    SCSI_STATUS_GOOD     : Connection was successful. Command_data is a pointer to uint32_t
664  *                           containing the response code as per RFC3720/10.6.1
665  *
666  *    SCSI_STATUS_ERROR     : Error.
667  *
668  * The callback will NOT be invoked if the session is explicitely torn down
669  * through a call to iscsi_disconnect() or iscsi_destroy_context().
670  *
671  * abort_task will also cancel the scsi task. The callback for the scsi task will be invoked with
672  *            SCSI_STATUS_CANCELLED
673  * abort_task_set, lun_reset, target_warn_reset, target_cold_reset will cancel all tasks. The callback for
674  *            all tasks will be invoked with SCSI_STATUS_CANCELLED
675  */
676 EXTERN int
677 iscsi_task_mgmt_async(struct iscsi_context *iscsi,
678 		      int lun, enum iscsi_task_mgmt_funcs function,
679 		      uint32_t ritt, uint32_t rcmdscn,
680 		      iscsi_command_cb cb, void *private_data);
681 
682 EXTERN int
683 iscsi_task_mgmt_abort_task_async(struct iscsi_context *iscsi,
684 		      struct scsi_task *task,
685 		      iscsi_command_cb cb, void *private_data);
686 EXTERN int
687 iscsi_task_mgmt_abort_task_set_async(struct iscsi_context *iscsi,
688 		      uint32_t lun,
689 		      iscsi_command_cb cb, void *private_data);
690 EXTERN int
691 iscsi_task_mgmt_lun_reset_async(struct iscsi_context *iscsi,
692 		      uint32_t lun,
693 		      iscsi_command_cb cb, void *private_data);
694 EXTERN int
695 iscsi_task_mgmt_target_warm_reset_async(struct iscsi_context *iscsi,
696 		      iscsi_command_cb cb, void *private_data);
697 EXTERN int
698 iscsi_task_mgmt_target_cold_reset_async(struct iscsi_context *iscsi,
699 		      iscsi_command_cb cb, void *private_data);
700 
701 
702 
703 /*
704  * Synchronous calls for task management
705  *
706  * Returns:
707  *  0 success.
708  * <0 error.
709  */
710 EXTERN int
711 iscsi_task_mgmt_sync(struct iscsi_context *iscsi,
712 		     int lun, enum iscsi_task_mgmt_funcs function,
713 		     uint32_t ritt, uint32_t rcmdscn);
714 
715 EXTERN int
716 iscsi_task_mgmt_abort_task_sync(struct iscsi_context *iscsi, struct scsi_task *task);
717 
718 EXTERN int
719 iscsi_task_mgmt_abort_task_set_sync(struct iscsi_context *iscsi, uint32_t lun);
720 
721 EXTERN int
722 iscsi_task_mgmt_lun_reset_sync(struct iscsi_context *iscsi, uint32_t lun);
723 
724 EXTERN int
725 iscsi_task_mgmt_target_warm_reset_sync(struct iscsi_context *iscsi);
726 
727 EXTERN int
728 iscsi_task_mgmt_target_cold_reset_sync(struct iscsi_context *iscsi);
729 
730 
731 
732 
733 /* These are the possible status values for the callbacks for scsi commands.
734  * The content of command_data depends on the status type.
735  *
736  * status :
737  *   SCSI_STATUS_GOOD the scsi command completed successfullt on the target.
738  *   If this scsi command returns DATA-IN, that data is stored in an scsi_task
739  *   structure returned in the command_data parameter. This buffer will be
740  *   automatically freed once the callback returns.
741  *
742  *   SCSI_STATUS_CHECK_CONDITION the scsi command failed with a scsi sense.
743  *   Command_data contains a struct scsi_task. When the callback returns,
744  *   this buffer will automatically become freed.
745  *
746  *   SCSI_STATUS_CANCELLED the scsi command was aborted. Command_data is
747  *   NULL.
748  *
749  *   SCSI_STATUS_ERROR the command failed. Command_data is NULL.
750  */
751 
752 struct iscsi_data {
753        size_t size;
754        unsigned char *data;
755 };
756 
757 
758 /*
759  * These functions will set the ISID type and value.
760  * By default, contexts will automatically be assigned a 'random'
761  * type and value on creation, but this can be overridden
762  * by an appplication using these functions.
763  *
764  * Setting the ISID can only be done before loggin in to the target.
765  */
766 EXTERN int
767 iscsi_set_isid_oui(struct iscsi_context *iscsi, uint32_t oui, uint32_t qualifier);
768 EXTERN int
769 iscsi_set_isid_en(struct iscsi_context *iscsi, uint32_t en, uint32_t qualifier);
770 EXTERN int
771 iscsi_set_isid_random(struct iscsi_context *iscsi, uint32_t rnd, uint32_t qualifier);
772 EXTERN int
773 iscsi_set_isid_reserved(struct iscsi_context *iscsi);
774 
775 
776 struct scsi_mode_page;
777 
778 
779 
780 /*
781  * The scsi commands use/return a scsi_task structure when invoked
782  * and also through the callback.
783  *
784  * You must release this structure when you are finished with the task
785  * by calling scsi_free_scsi_task().
786  * Most of the time this means you should call this function before returning
787  * from the callback.
788  */
789 
790 EXTERN int iscsi_scsi_command_async(struct iscsi_context *iscsi, int lun,
791 			     struct scsi_task *task, iscsi_command_cb cb,
792 			     struct iscsi_data *data, void *private_data);
793 
794 /*
795  * Async commands for SCSI
796  *
797  * These async functions return a scsi_task structure, or NULL if the command failed.
798  * This structure can be used by task management functions to abort the task or a whole task set.
799  */
800 EXTERN struct scsi_task *
801 iscsi_reportluns_task(struct iscsi_context *iscsi, int report_type,
802 			   int alloc_len, iscsi_command_cb cb,
803 			   void *private_data);
804 EXTERN struct scsi_task *
805 iscsi_testunitready_task(struct iscsi_context *iscsi, int lun,
806 			      iscsi_command_cb cb, void *private_data);
807 EXTERN struct scsi_task *
808 iscsi_inquiry_task(struct iscsi_context *iscsi, int lun, int evpd,
809 			int page_code, int maxsize, iscsi_command_cb cb,
810 			void *private_data);
811 EXTERN struct scsi_task *
812 iscsi_readcapacity10_task(struct iscsi_context *iscsi, int lun, int lba,
813 			       int pmi, iscsi_command_cb cb,
814 			       void *private_data);
815 EXTERN struct scsi_task *
816 iscsi_readcapacity16_task(struct iscsi_context *iscsi, int lun,
817 			  iscsi_command_cb cb,
818 			  void *private_data);
819 EXTERN struct scsi_task *
820 iscsi_readdefectdata10_task(struct iscsi_context *iscsi, int lun,
821                             int req_plist, int req_glist,
822                             int defect_list_format, uint16_t alloc_len,
823                             iscsi_command_cb cb, void *private_data);
824 EXTERN struct scsi_task *
825 iscsi_readdefectdata12_task(struct iscsi_context *iscsi, int lun,
826                             int req_plist, int req_glist,
827                             int defect_list_format,
828                             uint32_t address_descriptor_index,
829                             uint32_t alloc_len,
830                             iscsi_command_cb cb, void *private_data);
831 EXTERN struct scsi_task *
832 iscsi_sanitize_task(struct iscsi_context *iscsi, int lun,
833 		    int immed, int ause, int sa, int param_len,
834 		    struct iscsi_data *data,
835 		    iscsi_command_cb cb, void *private_data);
836 EXTERN struct scsi_task *
837 iscsi_sanitize_block_erase_task(struct iscsi_context *iscsi, int lun,
838 			       int immed, int ause,
839 			       iscsi_command_cb cb, void *private_data);
840 EXTERN struct scsi_task *
841 iscsi_sanitize_crypto_erase_task(struct iscsi_context *iscsi, int lun,
842 				 int immed, int ause,
843 				 iscsi_command_cb cb, void *private_data);
844 EXTERN struct scsi_task *
845 iscsi_sanitize_exit_failure_mode_task(struct iscsi_context *iscsi, int lun,
846 				      int immed, int ause,
847 				      iscsi_command_cb cb, void *private_data);
848 EXTERN struct scsi_task *
849 iscsi_get_lba_status_task(struct iscsi_context *iscsi, int lun,
850 			  uint64_t starting_lba, uint32_t alloc_len,
851 			  iscsi_command_cb cb,
852 			  void *private_data);
853 EXTERN struct scsi_task *
854 iscsi_synchronizecache10_task(struct iscsi_context *iscsi, int lun,
855 				   int lba, int num_blocks, int syncnv,
856 				   int immed, iscsi_command_cb cb,
857 				   void *private_data);
858 EXTERN struct scsi_task *
859 iscsi_synchronizecache16_task(struct iscsi_context *iscsi, int lun,
860 				   uint64_t lba, uint32_t num_blocks, int syncnv,
861 				   int immed, iscsi_command_cb cb,
862 				   void *private_data);
863 EXTERN struct scsi_task *
864 iscsi_prefetch10_task(struct iscsi_context *iscsi, int lun,
865 		      uint32_t lba, int num_blocks,
866 		      int immed, int group,
867 		      iscsi_command_cb cb, void *private_data);
868 EXTERN struct scsi_task *
869 iscsi_prefetch16_task(struct iscsi_context *iscsi, int lun,
870 		      uint64_t lba, int num_blocks,
871 		      int immed, int group,
872 		      iscsi_command_cb cb, void *private_data);
873 EXTERN struct scsi_task *
874 iscsi_read6_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
875 		       uint32_t datalen, int blocksize, iscsi_command_cb cb,
876 		       void *private_data);
877 EXTERN struct scsi_task *
878 iscsi_read6_iov_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
879 		       uint32_t datalen, int blocksize, iscsi_command_cb cb,
880 		       void *private_data, struct scsi_iovec *iov, int niov);
881 EXTERN struct scsi_task *
882 iscsi_read10_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
883 		  uint32_t datalen, int blocksize,
884 		  int rdprotect, int dpo, int fua, int fua_nv, int group_number,
885 		  iscsi_command_cb cb, void *private_data);
886 EXTERN struct scsi_task *
887 iscsi_read10_iov_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
888 		  uint32_t datalen, int blocksize,
889 		  int rdprotect, int dpo, int fua, int fua_nv, int group_number,
890 		  iscsi_command_cb cb, void *private_data, struct scsi_iovec *iov, int niov);
891 EXTERN struct scsi_task *
892 iscsi_write10_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
893 		   unsigned char *data, uint32_t datalen, int blocksize,
894 		   int wrprotect, int dpo, int fua, int fua_nv, int group_number,
895 		   iscsi_command_cb cb, void *private_data);
896 EXTERN struct scsi_task *
897 iscsi_write10_iov_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
898 		   unsigned char *data, uint32_t datalen, int blocksize,
899 		   int wrprotect, int dpo, int fua, int fua_nv, int group_number,
900 		   iscsi_command_cb cb, void *private_data, struct scsi_iovec *iov, int niov);
901 EXTERN struct scsi_task *
902 iscsi_writeverify10_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
903 		   unsigned char *data, uint32_t datalen, int blocksize,
904 		   int wrprotect, int dpo, int bytchk, int group_number,
905 		   iscsi_command_cb cb, void *private_data);
906 EXTERN struct scsi_task *
907 iscsi_writeverify10_iov_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
908 		   unsigned char *data, uint32_t datalen, int blocksize,
909 		   int wrprotect, int dpo, int bytchk, int group_number,
910 		   iscsi_command_cb cb, void *private_data, struct scsi_iovec *iov, int niov);
911 EXTERN struct scsi_task *
912 iscsi_read12_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
913 		   uint32_t datalen, int blocksize,
914 		   int rdprotect, int dpo, int fua, int fua_nv, int group_number,
915 		   iscsi_command_cb cb, void *private_data);
916 EXTERN struct scsi_task *
917 iscsi_read12_iov_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
918 		   uint32_t datalen, int blocksize,
919 		   int rdprotect, int dpo, int fua, int fua_nv, int group_number,
920 		   iscsi_command_cb cb, void *private_data, struct scsi_iovec *iov, int niov);
921 EXTERN struct scsi_task *
922 iscsi_write12_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
923 		   unsigned char *data, uint32_t datalen, int blocksize,
924 		   int wrprotect, int dpo, int fua, int fua_nv, int group_number,
925 		   iscsi_command_cb cb, void *private_data);
926 EXTERN struct scsi_task *
927 iscsi_write12_iov_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
928 		   unsigned char *data, uint32_t datalen, int blocksize,
929 		   int wrprotect, int dpo, int fua, int fua_nv, int group_number,
930 		   iscsi_command_cb cb, void *private_data, struct scsi_iovec *iov, int niov);
931 EXTERN struct scsi_task *
932 iscsi_writeverify12_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
933 		   unsigned char *data, uint32_t datalen, int blocksize,
934 		   int wrprotect, int dpo, int bytchk, int group_number,
935 		   iscsi_command_cb cb, void *private_data);
936 EXTERN struct scsi_task *
937 iscsi_writeverify12_iov_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
938 		   unsigned char *data, uint32_t datalen, int blocksize,
939 		   int wrprotect, int dpo, int bytchk, int group_number,
940 		   iscsi_command_cb cb, void *private_data, struct scsi_iovec *iov, int niov);
941 EXTERN struct scsi_task *
942 iscsi_read16_task(struct iscsi_context *iscsi, int lun, uint64_t lba,
943 		   uint32_t datalen, int blocksize,
944 		   int rdprotect, int dpo, int fua, int fua_nv, int group_number,
945 		   iscsi_command_cb cb, void *private_data);
946 EXTERN struct scsi_task *
947 iscsi_read16_iov_task(struct iscsi_context *iscsi, int lun, uint64_t lba,
948 		   uint32_t datalen, int blocksize,
949 		   int rdprotect, int dpo, int fua, int fua_nv, int group_number,
950 		   iscsi_command_cb cb, void *private_data, struct scsi_iovec *iov, int niov);
951 EXTERN struct scsi_task *
952 iscsi_write16_task(struct iscsi_context *iscsi, int lun, uint64_t lba,
953 		   unsigned char *data, uint32_t datalen, int blocksize,
954 		   int wrprotect, int dpo, int fua, int fua_nv, int group_number,
955 		   iscsi_command_cb cb, void *private_data);
956 EXTERN struct scsi_task *
957 iscsi_write16_iov_task(struct iscsi_context *iscsi, int lun, uint64_t lba,
958 		   unsigned char *data, uint32_t datalen, int blocksize,
959 		   int wrprotect, int dpo, int fua, int fua_nv, int group_number,
960 		   iscsi_command_cb cb, void *private_data, struct scsi_iovec *iov, int niov);
961 EXTERN struct scsi_task *
962 iscsi_writeatomic16_task(struct iscsi_context *iscsi, int lun, uint64_t lba,
963 			 unsigned char *data, uint32_t datalen, int blocksize,
964 			 int wrprotect, int dpo, int fua, int group_number,
965 		   iscsi_command_cb cb, void *private_data);
966 EXTERN struct scsi_task *
967 iscsi_writeatomic16_iov_task(struct iscsi_context *iscsi, int lun, uint64_t lba,
968 			     unsigned char *data, uint32_t datalen, int blocksize,
969 			     int wrprotect, int dpo, int fua, int group_number,
970 			     iscsi_command_cb cb, void *private_data,
971 			     struct scsi_iovec *iov, int niov);
972 EXTERN struct scsi_task *
973 iscsi_orwrite_task(struct iscsi_context *iscsi, int lun, uint64_t lba,
974 		   unsigned char *data, uint32_t datalen, int blocksize,
975 		   int wrprotect, int dpo, int fua, int fua_nv, int group_number,
976 		   iscsi_command_cb cb, void *private_data);
977 EXTERN struct scsi_task *
978 iscsi_orwrite_iov_task(struct iscsi_context *iscsi, int lun, uint64_t lba,
979 		       unsigned char *data, uint32_t datalen, int blocksize,
980 		       int wrprotect, int dpo, int fua, int fua_nv, int group_number,
981 		       iscsi_command_cb cb, void *private_data, struct scsi_iovec *iov, int niov);
982 EXTERN struct scsi_task *
983 iscsi_startstopunit_task(struct iscsi_context *iscsi, int lun,
984 			 int immed, int pcm, int pc,
985 			 int no_flush, int loej, int start,
986 			 iscsi_command_cb cb, void *private_data);
987 EXTERN struct scsi_task *
988 iscsi_preventallow_task(struct iscsi_context *iscsi, int lun,
989 			int prevent,
990 			iscsi_command_cb cb, void *private_data);
991 EXTERN struct scsi_task *
992 iscsi_compareandwrite_task(struct iscsi_context *iscsi, int lun, uint64_t lba,
993 		   unsigned char *data, uint32_t datalen, int blocksize,
994 		   int wrprotect, int dpo, int fua, int fua_nv, int group_number,
995 		   iscsi_command_cb cb, void *private_data);
996 EXTERN struct scsi_task *
997 iscsi_compareandwrite_iov_task(struct iscsi_context *iscsi, int lun, uint64_t lba,
998 			       unsigned char *data, uint32_t datalen, int blocksize,
999 			       int wrprotect, int dpo, int fua, int fua_nv, int group_number,
1000 			       iscsi_command_cb cb, void *private_data, struct scsi_iovec *iov, int niov);
1001 EXTERN struct scsi_task *
1002 iscsi_writeverify16_task(struct iscsi_context *iscsi, int lun, uint64_t lba,
1003 		   unsigned char *data, uint32_t datalen, int blocksize,
1004 		   int wrprotect, int dpo, int bytchk, int group_number,
1005 		   iscsi_command_cb cb, void *private_data);
1006 EXTERN struct scsi_task *
1007 iscsi_writeverify16_iov_task(struct iscsi_context *iscsi, int lun, uint64_t lba,
1008 		   unsigned char *data, uint32_t datalen, int blocksize,
1009 		   int wrprotect, int dpo, int bytchk, int group_number,
1010 		   iscsi_command_cb cb, void *private_data, struct scsi_iovec *iov, int niov);
1011 EXTERN struct scsi_task *
1012 iscsi_verify10_task(struct iscsi_context *iscsi, int lun,
1013 		    unsigned char *data, uint32_t datalen, uint32_t lba,
1014 		    int vprotect, int dpo, int bytchk,
1015 		    int blocksize, iscsi_command_cb cb,
1016 		    void *private_data);
1017 EXTERN struct scsi_task *
1018 iscsi_verify10_iov_task(struct iscsi_context *iscsi, int lun,
1019 			unsigned char *data, uint32_t datalen, uint32_t lba,
1020 			int vprotect, int dpo, int bytchk,
1021 			int blocksize, iscsi_command_cb cb,
1022 			void *private_data, struct scsi_iovec *iov, int niov);
1023 EXTERN struct scsi_task *
1024 iscsi_verify12_task(struct iscsi_context *iscsi, int lun,
1025 		    unsigned char *data, uint32_t datalen, uint32_t lba,
1026 		    int vprotect, int dpo, int bytchk,
1027 		    int blocksize, iscsi_command_cb cb,
1028 		    void *private_data);
1029 EXTERN struct scsi_task *
1030 iscsi_verify12_iov_task(struct iscsi_context *iscsi, int lun,
1031 			unsigned char *data, uint32_t datalen, uint32_t lba,
1032 			int vprotect, int dpo, int bytchk,
1033 			int blocksize, iscsi_command_cb cb,
1034 			void *private_data, struct scsi_iovec *iov, int niov);
1035 EXTERN struct scsi_task *
1036 iscsi_verify16_task(struct iscsi_context *iscsi, int lun,
1037 		    unsigned char *data, uint32_t datalen, uint64_t lba,
1038 		    int vprotect, int dpo, int bytchk,
1039 		    int blocksize, iscsi_command_cb cb,
1040 		    void *private_data);
1041 EXTERN struct scsi_task *
1042 iscsi_verify16_iov_task(struct iscsi_context *iscsi, int lun,
1043 			unsigned char *data, uint32_t datalen, uint64_t lba,
1044 			int vprotect, int dpo, int bytchk,
1045 			int blocksize, iscsi_command_cb cb,
1046 			void *private_data, struct scsi_iovec *iov, int niov);
1047 EXTERN struct scsi_task *
1048 iscsi_writesame10_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
1049 		       unsigned char *data, uint32_t datalen,
1050 		       uint16_t num_blocks,
1051 		       int anchor, int unmap, int wrprotect, int group,
1052 		       iscsi_command_cb cb, void *private_data);
1053 EXTERN struct scsi_task *
1054 iscsi_writesame10_iov_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
1055 			   unsigned char *data, uint32_t datalen,
1056 			   uint16_t num_blocks,
1057 			   int anchor, int unmap, int wrprotect, int group,
1058 			   iscsi_command_cb cb, void *private_data,
1059 			   struct scsi_iovec *iov, int niov);
1060 EXTERN struct scsi_task *
1061 iscsi_writesame16_task(struct iscsi_context *iscsi, int lun, uint64_t lba,
1062 		       unsigned char *data, uint32_t datalen,
1063 		       uint32_t num_blocks,
1064 		       int anchor, int unmap, int wrprotect, int group,
1065 		       iscsi_command_cb cb, void *private_data);
1066 EXTERN struct scsi_task *
1067 iscsi_writesame16_iov_task(struct iscsi_context *iscsi, int lun, uint64_t lba,
1068 			   unsigned char *data, uint32_t datalen,
1069 			   uint32_t num_blocks,
1070 			   int anchor, int unmap, int wrprotect, int group,
1071 			   iscsi_command_cb cb, void *private_data,
1072 			   struct scsi_iovec *iov, int niov);
1073 EXTERN struct scsi_task *
1074 iscsi_modeselect6_task(struct iscsi_context *iscsi, int lun,
1075 		       int pf, int sp, struct scsi_mode_page *mp,
1076 		       iscsi_command_cb cb, void *private_data);
1077 EXTERN struct scsi_task *
1078 iscsi_modeselect10_task(struct iscsi_context *iscsi, int lun,
1079 			int pf, int sp, struct scsi_mode_page *mp,
1080 			iscsi_command_cb cb, void *private_data);
1081 EXTERN struct scsi_task *
1082 iscsi_modesense6_task(struct iscsi_context *iscsi, int lun, int dbd,
1083 			   int pc, int page_code, int sub_page_code,
1084 			   unsigned char alloc_len, iscsi_command_cb cb,
1085 			   void *private_data);
1086 EXTERN struct scsi_task *
1087 iscsi_modesense10_task(struct iscsi_context *iscsi, int lun, int llbaa, int dbd,
1088 			   int pc, int page_code, int sub_page_code,
1089 			   unsigned char alloc_len, iscsi_command_cb cb,
1090 			   void *private_data);
1091 
1092 struct unmap_list {
1093        uint64_t	  lba;
1094        uint32_t	  num;
1095 };
1096 
1097 EXTERN struct scsi_task *
1098 iscsi_persistent_reserve_in_task(struct iscsi_context *iscsi, int lun,
1099 				 int sa, uint16_t xferlen,
1100 				 iscsi_command_cb cb, void *private_data);
1101 
1102 EXTERN struct scsi_task *
1103 iscsi_persistent_reserve_out_task(struct iscsi_context *iscsi, int lun,
1104 				  int sa, int scope, int type, void *params,
1105 				  iscsi_command_cb cb, void *private_data);
1106 
1107 EXTERN struct scsi_task *
1108 iscsi_unmap_task(struct iscsi_context *iscsi, int lun, int anchor, int group,
1109 		 struct unmap_list *list, int list_len,
1110 		 iscsi_command_cb cb, void *private_data);
1111 
1112 EXTERN struct scsi_task *
1113 iscsi_readtoc_task(struct iscsi_context *iscsi, int lun, int msf, int format,
1114 		   int track_session, int maxsize,
1115 		   iscsi_command_cb cb, void *private_data);
1116 
1117 EXTERN struct scsi_task *
1118 iscsi_reserve6_task(struct iscsi_context *iscsi, int lun,
1119 		    iscsi_command_cb cb, void *private_data);
1120 
1121 EXTERN struct scsi_task *
1122 iscsi_release6_task(struct iscsi_context *iscsi, int lun,
1123 		    iscsi_command_cb cb, void *private_data);
1124 
1125 EXTERN struct scsi_task *
1126 iscsi_report_supported_opcodes_task(struct iscsi_context *iscsi, int lun,
1127 				    int rctd, int options,
1128 				    int opcode, int sa,
1129 				    uint32_t alloc_len,
1130 				    iscsi_command_cb cb, void *private_data);
1131 
1132 EXTERN struct scsi_task *
1133 iscsi_receive_copy_results_task(struct iscsi_context *iscsi, int lun,
1134 				int sa, int list_id, int alloc_len,
1135 				iscsi_command_cb cb, void *private_data);
1136 
1137 EXTERN struct scsi_task *
1138 iscsi_extended_copy_task(struct iscsi_context *iscsi, int lun,
1139 			 struct iscsi_data *param_data,
1140 			 iscsi_command_cb cb, void *private_data);
1141 
1142 /*
1143  * Sync commands for SCSI
1144  */
1145 EXTERN struct scsi_task *
1146 iscsi_scsi_command_sync(struct iscsi_context *iscsi, int lun,
1147 			struct scsi_task *task, struct iscsi_data *data);
1148 
1149 EXTERN struct scsi_task *
1150 iscsi_modeselect6_sync(struct iscsi_context *iscsi, int lun,
1151 		       int pf, int sp, struct scsi_mode_page *mp);
1152 
1153 EXTERN struct scsi_task *
1154 iscsi_modeselect10_sync(struct iscsi_context *iscsi, int lun,
1155 			int pf, int sp, struct scsi_mode_page *mp);
1156 
1157 EXTERN struct scsi_task *
1158 iscsi_modesense6_sync(struct iscsi_context *iscsi, int lun, int dbd,
1159 		      int pc, int page_code, int sub_page_code,
1160 		      unsigned char alloc_len);
1161 
1162 EXTERN struct scsi_task *
1163 iscsi_modesense10_sync(struct iscsi_context *iscsi, int lun, int llbaa, int dbd,
1164 		      int pc, int page_code, int sub_page_code,
1165 		      unsigned char alloc_len);
1166 
1167 EXTERN struct scsi_task *
1168 iscsi_reportluns_sync(struct iscsi_context *iscsi, int report_type,
1169 		      int alloc_len);
1170 
1171 EXTERN struct scsi_task *
1172 iscsi_testunitready_sync(struct iscsi_context *iscsi, int lun);
1173 
1174 EXTERN struct scsi_task *
1175 iscsi_inquiry_sync(struct iscsi_context *iscsi, int lun, int evpd,
1176 		   int page_code, int maxsize);
1177 
1178 EXTERN struct scsi_task *
1179 iscsi_read6_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
1180 		  uint32_t datalen, int blocksize);
1181 
1182 EXTERN struct scsi_task *
1183 iscsi_read6_iov_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
1184 		     uint32_t datalen, int blocksize,
1185 		     struct scsi_iovec *iov, int niov);
1186 
1187 EXTERN struct scsi_task *
1188 iscsi_read10_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
1189 		  uint32_t datalen, int blocksize,
1190 		  int rdprotect, int dpo, int fua, int fua_nv, int group_number);
1191 
1192 EXTERN struct scsi_task *
1193 iscsi_read10_iov_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
1194 		      uint32_t datalen, int blocksize,
1195 		      int rdprotect, int dpo, int fua, int fua_nv, int group_number,
1196 		      struct scsi_iovec *iov, int niov);
1197 
1198 EXTERN struct scsi_task *
1199 iscsi_write10_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
1200 		   unsigned char *data, uint32_t datalen, int blocksize,
1201 		   int wrprotect, int dpo, int fua, int fua_nv, int group_number);
1202 
1203 EXTERN struct scsi_task *
1204 iscsi_write10_iov_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
1205 			unsigned char *data, uint32_t datalen, int blocksize,
1206 			int wrprotect, int dpo, int fua, int fua_nv, int group_number,
1207 			struct scsi_iovec *iov, int niov);
1208 EXTERN struct scsi_task *
1209 iscsi_writeverify10_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
1210 		   unsigned char *data, uint32_t datalen, int blocksize,
1211 		   int wrprotect, int dpo, int bytchk, int group_number);
1212 
1213 EXTERN struct scsi_task *
1214 iscsi_writeverify10_iov_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
1215 			     unsigned char *data, uint32_t datalen, int blocksize,
1216 			     int wrprotect, int dpo, int bytchk, int group_number,
1217 			     struct scsi_iovec *iov, int niov);
1218 
1219 EXTERN struct scsi_task *
1220 iscsi_read12_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
1221 		  uint32_t datalen, int blocksize,
1222 		  int rdprotect, int dpo, int fua, int fua_nv, int group_number);
1223 
1224 EXTERN struct scsi_task *
1225 iscsi_read12_iov_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
1226 		      uint32_t datalen, int blocksize,
1227 		      int rdprotect, int dpo, int fua, int fua_nv, int group_number,
1228 		      struct scsi_iovec *iov, int niov);
1229 
1230 EXTERN struct scsi_task *
1231 iscsi_write12_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
1232 		   unsigned char *data, uint32_t datalen, int blocksize,
1233 		   int wrprotect, int dpo, int fua, int fua_nv, int group_number);
1234 
1235 EXTERN struct scsi_task *
1236 iscsi_write12_iov_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
1237 		       unsigned char *data, uint32_t datalen, int blocksize,
1238 		       int wrprotect, int dpo, int fua, int fua_nv, int group_number,
1239 		       struct scsi_iovec *iov, int niov);
1240 
1241 EXTERN struct scsi_task *
1242 iscsi_writeverify12_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
1243 		   unsigned char *data, uint32_t datalen, int blocksize,
1244 		   int wrprotect, int dpo, int bytchk, int group_number);
1245 
1246 EXTERN struct scsi_task *
1247 iscsi_writeverify12_iov_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
1248 			     unsigned char *data, uint32_t datalen, int blocksize,
1249 			     int wrprotect, int dpo, int bytchk, int group_number,
1250 			     struct scsi_iovec *iov, int niov);
1251 
1252 EXTERN struct scsi_task *
1253 iscsi_read16_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
1254 		  uint32_t datalen, int blocksize,
1255 		  int rdprotect, int dpo, int fua, int fua_nv, int group_number);
1256 
1257 EXTERN struct scsi_task *
1258 iscsi_read16_iov_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
1259 		      uint32_t datalen, int blocksize,
1260 		      int rdprotect, int dpo, int fua, int fua_nv, int group_number,
1261 		      struct scsi_iovec *iov, int niov);
1262 
1263 EXTERN struct scsi_task *
1264 iscsi_write16_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
1265 		   unsigned char *data, uint32_t datalen, int blocksize,
1266 		   int wrprotect, int dpo, int fua, int fua_nv, int group_number);
1267 
1268 EXTERN struct scsi_task *
1269 iscsi_write16_iov_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
1270 		       unsigned char *data, uint32_t datalen, int blocksize,
1271 		       int wrprotect, int dpo, int fua, int fua_nv, int group_number,
1272 		       struct scsi_iovec *iov, int niov);
1273 
1274 EXTERN struct scsi_task *
1275 iscsi_writeatomic16_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
1276 			 unsigned char *data, uint32_t datalen, int blocksize,
1277 			 int wrprotect, int dpo, int fua, int group_number);
1278 
1279 EXTERN struct scsi_task *
1280 iscsi_writeatomic16_iov_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
1281 			     unsigned char *data, uint32_t datalen, int blocksize,
1282 			     int wrprotect, int dpo, int fua, int group_number,
1283 			     struct scsi_iovec *iov, int niov);
1284 
1285 EXTERN struct scsi_task *
1286 iscsi_orwrite_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
1287 		   unsigned char *data, uint32_t datalen, int blocksize,
1288 		   int wrprotect, int dpo, int fua, int fua_nv, int group_number);
1289 
1290 EXTERN struct scsi_task *
1291 iscsi_orwrite_iov_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
1292 		       unsigned char *data, uint32_t datalen, int blocksize,
1293 		       int wrprotect, int dpo, int fua, int fua_nv, int group_number,
1294 		       struct scsi_iovec *iov, int niov);
1295 
1296 EXTERN struct scsi_task *
1297 iscsi_startstopunit_sync(struct iscsi_context *iscsi, int lun,
1298 			 int immed, int pcm, int pc,
1299 			 int no_flush, int loej, int start);
1300 
1301 EXTERN struct scsi_task *
1302 iscsi_preventallow_sync(struct iscsi_context *iscsi, int lun,
1303 			int prevent);
1304 
1305 EXTERN struct scsi_task *
1306 iscsi_compareandwrite_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
1307 		   unsigned char *data, uint32_t datalen, int blocksize,
1308 		   int wrprotect, int dpo, int fua, int fua_nv, int group_number);
1309 
1310 EXTERN struct scsi_task *
1311 iscsi_compareandwrite_iov_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
1312 			       unsigned char *data, uint32_t datalen, int blocksize,
1313 			       int wrprotect, int dpo, int fua, int fua_nv, int group_number,
1314 			       struct scsi_iovec *iov, int niov);
1315 
1316 EXTERN struct scsi_task *
1317 iscsi_writeverify16_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
1318 		   unsigned char *data, uint32_t datalen, int blocksize,
1319 		   int wrprotect, int dpo, int bytchk, int group_number);
1320 
1321 EXTERN struct scsi_task *
1322 iscsi_writeverify16_iov_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
1323 			     unsigned char *data, uint32_t datalen, int blocksize,
1324 			     int wrprotect, int dpo, int bytchk, int group_number,
1325 			     struct scsi_iovec *iov, int niov);
1326 
1327 EXTERN struct scsi_task *
1328 iscsi_readcapacity10_sync(struct iscsi_context *iscsi, int lun, int lba,
1329 			  int pmi);
1330 
1331 EXTERN struct scsi_task *
1332 iscsi_readcapacity16_sync(struct iscsi_context *iscsi, int lun);
1333 
1334 EXTERN struct scsi_task *
1335 iscsi_readdefectdata10_sync(struct iscsi_context *iscsi, int lun,
1336                             int req_plist, int req_glist,
1337                             int defect_list_format, uint16_t alloc_len);
1338 
1339 EXTERN struct scsi_task *
1340 iscsi_readdefectdata12_sync(struct iscsi_context *iscsi, int lun,
1341                             int req_plist, int req_glist,
1342                             int defect_list_format,
1343                             uint32_t address_descriptor_index,
1344                             uint32_t alloc_len);
1345 EXTERN struct scsi_task *
1346 iscsi_get_lba_status_sync(struct iscsi_context *iscsi, int lun, uint64_t starting_lba, uint32_t alloc_len);
1347 
1348 EXTERN struct scsi_task *
1349 iscsi_sanitize_sync(struct iscsi_context *iscsi, int lun,
1350 		    int immed, int ause, int sa, int param_len,
1351 		    struct iscsi_data *data);
1352 EXTERN struct scsi_task *
1353 iscsi_sanitize_block_erase_sync(struct iscsi_context *iscsi, int lun,
1354 		    int immed, int ause);
1355 EXTERN struct scsi_task *
1356 iscsi_sanitize_crypto_erase_sync(struct iscsi_context *iscsi, int lun,
1357 		    int immed, int ause);
1358 EXTERN struct scsi_task *
1359 iscsi_sanitize_exit_failure_mode_sync(struct iscsi_context *iscsi, int lun,
1360 		    int immed, int ause);
1361 EXTERN struct scsi_task *
1362 iscsi_synchronizecache10_sync(struct iscsi_context *iscsi, int lun, int lba,
1363 			      int num_blocks, int syncnv, int immed);
1364 
1365 EXTERN struct scsi_task *
1366 iscsi_synchronizecache16_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
1367 			      uint32_t num_blocks, int syncnv, int immed);
1368 
1369 EXTERN struct scsi_task *
1370 iscsi_prefetch10_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
1371 		      int num_blocks, int immed, int group);
1372 
1373 EXTERN struct scsi_task *
1374 iscsi_prefetch16_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
1375 		      int num_blocks, int immed, int group);
1376 
1377 EXTERN struct scsi_task *
1378 iscsi_verify10_sync(struct iscsi_context *iscsi, int lun,
1379 		    unsigned char *data, uint32_t datalen, uint32_t lba,
1380 		    int vprotect, int dpo, int bytchk,
1381 		    int blocksize);
1382 
1383 EXTERN struct scsi_task *
1384 iscsi_verify10_iov_sync(struct iscsi_context *iscsi, int lun,
1385 			unsigned char *data, uint32_t datalen, uint32_t lba,
1386 			int vprotect, int dpo, int bytchk,
1387 			int blocksize, struct scsi_iovec *iov, int niov);
1388 
1389 EXTERN struct scsi_task *
1390 iscsi_verify12_sync(struct iscsi_context *iscsi, int lun,
1391 		    unsigned char *data, uint32_t datalen, uint32_t lba,
1392 		    int vprotect, int dpo, int bytchk,
1393 		    int blocksize);
1394 
1395 EXTERN struct scsi_task *
1396 iscsi_verify12_iov_sync(struct iscsi_context *iscsi, int lun,
1397 			unsigned char *data, uint32_t datalen, uint32_t lba,
1398 			int vprotect, int dpo, int bytchk,
1399 			int blocksize, struct scsi_iovec *iov, int niov);
1400 
1401 EXTERN struct scsi_task *
1402 iscsi_verify16_sync(struct iscsi_context *iscsi, int lun,
1403 		    unsigned char *data, uint32_t datalen, uint64_t lba,
1404 		    int vprotect, int dpo, int bytchk,
1405 		    int blocksize);
1406 
1407 EXTERN struct scsi_task *
1408 iscsi_verify16_iov_sync(struct iscsi_context *iscsi, int lun,
1409 			unsigned char *data, uint32_t datalen, uint64_t lba,
1410 			int vprotect, int dpo, int bytchk,
1411 			int blocksize, struct scsi_iovec *iov, int niov);
1412 
1413 EXTERN struct scsi_task *
1414 iscsi_writesame10_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
1415 		       unsigned char *data, uint32_t datalen,
1416 		       uint16_t num_blocks,
1417 		       int anchor, int unmap, int wrprotect, int group);
1418 
1419 EXTERN struct scsi_task *
1420 iscsi_writesame10_iov_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
1421 			   unsigned char *data, uint32_t datalen,
1422 			   uint16_t num_blocks,
1423 			   int anchor, int unmap, int wrprotect, int group,
1424 			   struct scsi_iovec *iov, int niov);
1425 
1426 EXTERN struct scsi_task *
1427 iscsi_writesame16_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
1428 		       unsigned char *data, uint32_t datalen,
1429 		       uint32_t num_blocks,
1430 		       int anchor, int unmap, int wrprotect, int group);
1431 
1432 EXTERN struct scsi_task *
1433 iscsi_writesame16_iov_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
1434 			   unsigned char *data, uint32_t datalen,
1435 			   uint32_t num_blocks,
1436 			   int anchor, int unmap, int wrprotect, int group,
1437 			   struct scsi_iovec *iov, int niov);
1438 
1439 EXTERN struct scsi_task *
1440 iscsi_persistent_reserve_in_sync(struct iscsi_context *iscsi, int lun,
1441 				 int sa, uint16_t xferlen);
1442 
1443 EXTERN struct scsi_task *
1444 iscsi_persistent_reserve_out_sync(struct iscsi_context *iscsi, int lun,
1445 				  int sa, int scope, int type, void *params);
1446 
1447 EXTERN struct scsi_task *
1448 iscsi_unmap_sync(struct iscsi_context *iscsi, int lun, int anchor, int group,
1449 		 struct unmap_list *list, int list_len);
1450 
1451 EXTERN struct scsi_task *
1452 iscsi_readtoc_sync(struct iscsi_context *iscsi, int lun, int msf,
1453 		   int format, int track_session, int maxsize);
1454 
1455 EXTERN struct scsi_task *
1456 iscsi_reserve6_sync(struct iscsi_context *iscsi, int lun);
1457 
1458 EXTERN struct scsi_task *
1459 iscsi_release6_sync(struct iscsi_context *iscsi, int lun);
1460 
1461 EXTERN struct scsi_task *
1462 iscsi_report_supported_opcodes_sync(struct iscsi_context *iscsi, int lun,
1463 				    int rctd, int options,
1464 				    int opcode, int sa,
1465 				    uint32_t alloc_len);
1466 
1467 EXTERN struct scsi_task *
1468 iscsi_extended_copy_sync(struct iscsi_context *iscsi, int lun,
1469 			 struct iscsi_data *param_data);
1470 
1471 EXTERN struct scsi_task *
1472 iscsi_receive_copy_results_sync(struct iscsi_context *iscsi, int lun,
1473 				int sa, int list_id, int alloc_len);
1474 
1475 /*
1476  * These functions are used when the application wants to specify its own buffers to read the data
1477  * from the DATA-IN PDUs into, or write the data to DATA-OUT PDUs from.
1478  * The main use is for SCSI READ10/12/16 WRITE10/12/16 operations to have them read/write directly from
1479  * the applications buffer, avoiding coying the data.
1480  *
1481  * This also supports reading into a vector of buffers by calling this function multiple times.
1482  * The individual buffers will be filled in the same order as they were created.
1483  *
1484  * Example READ10:
1485  *     task = iscsi_read10_task(    ( 2 512byte blocks into two buffers)
1486  *     scsi_task_add_data_in_buffer(task, first_buffer, 512
1487  *     scsi_task_add_data_in_buffer(task, second_buffer, 512
1488  *
1489  *
1490  * If you use this function you can not use task->datain in the READ callback.
1491  * task->datain.size will be 0 and
1492  * task->datain.data will be NULL
1493  *
1494  * Example WRITE10: (write 2 blocks)
1495  *     static struct scsi_iovec iov[2];
1496  *
1497  *     task = iscsi_write10_task(iscsi, lun, 0, NULL, 512, 512, 0, 0, 0, 0, 0, callback, private_data);
1498  *     iov[0].iov_base = first_buffer;
1499  *     iov[0].iov_len  = 512;
1500  *     iov[1].iov_base = second_buffer;
1501  *     iov[1].iov_len  = 512;
1502  *     scsi_task_set_iov_out(task, &iov[0], 2);
1503  */
1504 EXTERN int scsi_task_add_data_in_buffer(struct scsi_task *task, int len, unsigned char *buf);
1505 EXTERN int scsi_task_add_data_out_buffer(struct scsi_task *task, int len, unsigned char *buf);
1506 
1507 struct scsi_iovec;
1508 EXTERN void scsi_task_set_iov_out(struct scsi_task *task, struct scsi_iovec *iov, int niov);
1509 EXTERN void scsi_task_set_iov_in(struct scsi_task *task, struct scsi_iovec *iov, int niov);
1510 
1511 EXTERN int scsi_task_get_status(struct scsi_task *task, struct scsi_sense *sense);
1512 
1513 /*
1514  * This function is used when you want to cancel a scsi task.
1515  * The callback for the task will immediately be invoked with SCSI_STATUS_CANCELLED.
1516  * The cancellation is only local in libiscsi. If the task is already in-flight
1517  * this call will not cancel the task at the target.
1518  * To cancel the task also a the target you need to call the task management functions.
1519  */
1520 EXTERN int
1521 iscsi_scsi_cancel_task(struct iscsi_context *iscsi,
1522 		       struct scsi_task *task);
1523 
1524 /*
1525  * This function is used when you want to cancel all scsi tasks.
1526  * The callback for the tasks will immediately be invoked with SCSI_STATUS_CANCELLED.
1527  * The cancellation is only local in libiscsi. If the tasks are already in-flight
1528  * this call will not cancel the tasks at the target.
1529  * To cancel the tasks also a the target you need to call the task management functions.
1530  */
1531 EXTERN void
1532 iscsi_scsi_cancel_all_tasks(struct iscsi_context *iscsi);
1533 
1534 /*
1535  * This function is to set the debugging level where level is
1536  *
1537  * 0  = disabled (default)
1538  * 1  = errors only
1539  * 2  = connection related info
1540  * 3  = user set variables
1541  * 4  = function calls
1542  * 5  = ...
1543  * 10 = everything
1544  */
1545 EXTERN void
1546 iscsi_set_log_level(struct iscsi_context *iscsi, int level);
1547 
1548 typedef void (*iscsi_log_fn)(int level, const char *mesage);
1549 
1550 /* Set the logging function to use */
1551 EXTERN void iscsi_set_log_fn(struct iscsi_context *iscsi, iscsi_log_fn fn);
1552 
1553 /* predefined log function that just writes to stderr */
1554 EXTERN void iscsi_log_to_stderr(int level, const char *message);
1555 
1556 /*
1557  * This function is to set the TCP_USER_TIMEOUT option. It has to be called after iscsi
1558  * context creation. The value given in ms is then applied each time a new socket is created.
1559  */
1560 EXTERN void
1561 iscsi_set_tcp_user_timeout(struct iscsi_context *iscsi, int timeout_ms);
1562 
1563 /*
1564  * This function is to set the TCP_KEEPIDLE option. It has to be called after iscsi
1565  * context creation.
1566  */
1567 EXTERN void
1568 iscsi_set_tcp_keepidle(struct iscsi_context *iscsi, int value);
1569 
1570 /*
1571  * This function is to set the TCP_KEEPCNT option. It has to be called after iscsi
1572  * context creation.
1573  */
1574 EXTERN void
1575 iscsi_set_tcp_keepcnt(struct iscsi_context *iscsi, int value);
1576 
1577 /*
1578  * This function is to set the TCP_KEEPINTVL option. It has to be called after iscsi
1579  * context creation.
1580  */
1581 EXTERN void
1582 iscsi_set_tcp_keepintvl(struct iscsi_context *iscsi, int value);
1583 
1584 /*
1585  * This function is to set the TCP_SYNCNT option. It has to be called after iscsi
1586  * context creation.
1587  */
1588 EXTERN void
1589 iscsi_set_tcp_syncnt(struct iscsi_context *iscsi, int value);
1590 
1591 /*
1592  * This function is to set the interface that outbound connections for this socket are bound to.
1593  * You max specify more than one interface here separated by comma.
1594  */
1595 EXTERN void
1596 iscsi_set_bind_interfaces(struct iscsi_context *iscsi, char * interfaces);
1597 
1598 /*
1599  * This function is to disable auto reconnect logic.
1600  *
1601  *  0 - Disable this feature (auto reconnect)
1602  *  1 - Enable this feature (no auto reconnect)
1603  */
1604 EXTERN void
1605 iscsi_set_noautoreconnect(struct iscsi_context *iscsi, int state);
1606 
1607 
1608 /* This function is to set if we should retry a failed reconnect
1609 
1610    count is defined as follows:
1611     -1 -> retry forever (default)
1612     0  -> never retry
1613     n  -> retry n times
1614 */
1615 EXTERN void
1616 iscsi_set_reconnect_max_retries(struct iscsi_context *iscsi, int count);
1617 
1618 /* Set to true to have libiscsi use TESTUNITREADY and consume any/all
1619    UnitAttentions that may have triggered in the target.
1620  */
1621 EXTERN void
1622 iscsi_set_no_ua_on_reconnect(struct iscsi_context *iscsi, int state);
1623 
1624 #ifdef __cplusplus
1625 }
1626 #endif
1627 
1628 #endif /* __iscsi_h__ */
1629