diff --git a/include/iscsi-private.h b/include/iscsi-private.h index 4f95f3e..c65d407 100644 --- a/include/iscsi-private.h +++ b/include/iscsi-private.h @@ -52,16 +52,6 @@ struct iscsi_in_pdu { void iscsi_free_iscsi_in_pdu(struct iscsi_context *iscsi, struct iscsi_in_pdu *in); void iscsi_free_iscsi_inqueue(struct iscsi_context *iscsi, struct iscsi_in_pdu *inqueue); -enum iscsi_initial_r2t { - ISCSI_INITIAL_R2T_NO = 0, - ISCSI_INITIAL_R2T_YES = 1 -}; - -enum iscsi_immediate_data { - ISCSI_IMMEDIATE_DATA_NO = 0, - ISCSI_IMMEDIATE_DATA_YES = 1 -}; - struct iscsi_context { char initiator_name[MAX_STRING_SIZE+1]; char target_name[MAX_STRING_SIZE+1]; diff --git a/include/iscsi.h b/include/iscsi.h index 827b9de..ec5168f 100644 --- a/include/iscsi.h +++ b/include/iscsi.h @@ -84,6 +84,34 @@ struct iscsi_url { struct iscsi_context *iscsi; }; +/* + * This function is used to set the desired mode for immediate data. + * This can be set on a context before it has been logged in to the target + * and controls how the initiator will try to negotiate the immediate data. + * + * Default is for libiscsi to try to negotiate ISCSI_IMMEDIATE_DATA_YES + */ +enum iscsi_immediate_data { + ISCSI_IMMEDIATE_DATA_NO = 0, + ISCSI_IMMEDIATE_DATA_YES = 1 +}; +int iscsi_set_immediate_data(struct iscsi_context *iscsi, enum iscsi_immediate_data immediate_data); + +/* + * This function is used to set the desired mode for initial_r2t + * This can be set on a context before it has been logged in to the target + * and controls how the initiator will try to negotiate the initial r2t. + * + * Default is for libiscsi to try to negotiate ISCSI_INITIAL_R2T_YES + */ +enum iscsi_initial_r2t { + ISCSI_INITIAL_R2T_NO = 0, + ISCSI_INITIAL_R2T_YES = 1 +}; +int +iscsi_set_initial_r2t(struct iscsi_context *iscsi, enum iscsi_initial_r2t initial_r2t); + + /* * This function is used to parse an iSCSI URL into a iscsi_url structure. * iSCSI URL format : diff --git a/lib/init.c b/lib/init.c index 5269fb6..7da7b04 100644 --- a/lib/init.c +++ b/lib/init.c @@ -502,3 +502,28 @@ iscsi_set_initiator_username_pwd(struct iscsi_context *iscsi, strncpy(iscsi->passwd,passwd,MAX_STRING_SIZE); return 0; } + +int +iscsi_set_immediate_data(struct iscsi_context *iscsi, enum iscsi_immediate_data immediate_data) +{ + if (iscsi->is_loggedin != 0) { + iscsi_set_error(iscsi, "Already logged in when trying to set immediate_data"); + return -1; + } + + iscsi->want_immediate_data = immediate_data; + return 0; +} + +int +iscsi_set_initial_r2t(struct iscsi_context *iscsi, enum iscsi_initial_r2t initial_r2t) +{ + if (iscsi->is_loggedin != 0) { + iscsi_set_error(iscsi, "Already logged in when trying to set initial_r2t"); + return -1; + } + + iscsi->want_initial_r2t = initial_r2t; + return 0; +} + diff --git a/lib/libiscsi.def b/lib/libiscsi.def index ea01803..ea7e49b 100644 --- a/lib/libiscsi.def +++ b/lib/libiscsi.def @@ -65,6 +65,8 @@ iscsi_scsi_command_sync iscsi_scsi_cancel_task iscsi_service iscsi_set_alias +iscsi_set_immediate_data +iscsi_set_initial_r2t iscsi_set_log_level iscsi_set_log_fn iscsi_set_header_digest diff --git a/lib/libiscsi.syms b/lib/libiscsi.syms index 3344061..60e3b09 100644 --- a/lib/libiscsi.syms +++ b/lib/libiscsi.syms @@ -63,6 +63,8 @@ iscsi_scsi_command_sync iscsi_scsi_cancel_task iscsi_service iscsi_set_alias +iscsi_set_immediate_data +iscsi_set_initial_r2t iscsi_set_log_level iscsi_set_log_fn iscsi_set_header_digest