iSCSI
Overview
Copyright (C) 2004-2022 OKTET Labs Ltd. More…
// typedefs typedef int iscsi_target_id; typedef int iscsi_cid; typedef struct iscsi_io_handle_t iscsi_io_handle_t; typedef unsigned iscsi_io_taskid; // enums enum { @72::ISCSI_OPCODE_UNDEF = 0xff, }; enum iscsi_bit_spec_t; enum tapi_iscsi_change_key_val_type; enum tapi_iscsi_parameter; enum tapi_iscsi_parameter_type; // global functions te_errno tapi_iscsi_tgt_csap_create(const char* ta_name, iscsi_digest_type hdr_dig, iscsi_digest_type data_dig, csap_handle_t* csap); te_errno tapi_iscsi_ini_csap_create(const char* ta_name, int sid, csap_handle_t listen_csap, int timeout, iscsi_digest_type hdr_dig, iscsi_digest_type data_dig, csap_handle_t* csap); te_errno tapi_iscsi_sock_csap_create(const char* ta_name, int socket, iscsi_digest_type hdr_dig, iscsi_digest_type data_dig, csap_handle_t* csap); int tapi_iscsi_recv_pkt(const char* ta_name, int sid, csap_handle_t csap, int timeout, csap_handle_t forward_csap, iscsi_target_params_t* params, uint8_t* buffer, size_t* length); int tapi_iscsi_start_poll_recv_pkt(unsigned n_csaps, rcf_trpoll_csap* csaps, int timeout); int tapi_iscsi_recv_polled_pkt(rcf_trpoll_csap* the_csap, iscsi_target_params_t* params, uint8_t* buffer, size_t* length); int tapi_iscsi_send_pkt(const char* ta_name, int sid, csap_handle_t csap, iscsi_target_params_t* params, uint8_t* buffer, size_t length); int tapi_iscsi_send_pkt_last(const char* ta_name, int sid, csap_handle_t csap, uint8_t* buffer, size_t length); int tapi_iscsi_forward_all(const char* ta_name, int session, csap_handle_t csap_rcv, csap_handle_t csap_fwd, unsigned int timeout, unsigned int* forwarded); te_errno tapi_iscsi_exchange_until_silent(const char* ta, int session, csap_handle_t csap_a, csap_handle_t csap_b, unsigned int timeout); te_errno tapi_iscsi_exchange_until_pattern(const char* ta, int session, csap_handle_t csap_a, csap_handle_t csap_b, asn_value* pattern, uint8_t* buffer, size_t* length, unsigned int timeout); te_errno tapi_iscsi_exchange_until_stop(const char* ta, int session, csap_handle_t csap_a, csap_handle_t csap_b, unsigned int timeout); te_errno tapi_iscsi_exchange_stop(const char* ta, int session, csap_handle_t csap_a, csap_handle_t csap_b); te_errno tapi_iscsi_prepare_pattern_unit(iscsi_bit_spec_t i_bit, uint8_t opcode, iscsi_bit_spec_t f_bit, asn_value** pattern); int tapi_iscsi_get_key_num(iscsi_segment_data segment_data); char* tapi_iscsi_get_key_name(iscsi_segment_data segment_data, int key_index); int tapi_iscsi_get_key_index_by_name(iscsi_segment_data segment_data, char* name); iscsi_key_values tapi_iscsi_get_key_values(iscsi_segment_data segment_data, int key_index); int tapi_iscsi_get_key_values_num(iscsi_key_values values); int tapi_iscsi_get_key_value(iscsi_key_values values, int key_value_index, char** value); int tapi_iscsi_add_new_key(iscsi_segment_data segment_data, char* name, int key_index); iscsi_key_values tapi_iscsi_key_values_create(int num, ...); int tapi_iscsi_set_key_values(iscsi_segment_data segment_data, int key_index, iscsi_key_values values); void tapi_iscsi_free_key_values(iscsi_key_values values); int tapi_iscsi_delete_key(iscsi_segment_data segment_data, int key_index); iscsi_segment_data tapi_iscsi_keys_create(int num, ...); int tapi_iscsi_find_key_and_value(iscsi_segment_data segment_data, const char* key_name, int num, ...); int tapi_iscsi_return_key_value(iscsi_segment_data segment_data, const char* key_name, const char* buf, int buf_len); int tapi_iscsi_change_key_values(iscsi_segment_data segment_data, char* key_name, tapi_iscsi_change_key_val_type change, int num, ...); void tapi_iscsi_keys_data_free(iscsi_segment_data); int tapi_iscsi_target_set_parameter(const char* ta, tapi_iscsi_parameter param, const char* value); int tapi_iscsi_target_customize(const char* ta, int id, const char* key, const char* value); int tapi_iscsi_target_customize_intval(const char* ta, int id, const char* key, int value); int tapi_iscsi_target_cause_logout(const char* ta, int id, int timeout); int tapi_iscsi_target_cause_renegotiate(const char* ta, int id, int timeout); int tapi_iscsi_target_will_drop(const char* ta, int id, bool drop_all, int time2wait, int time2retain); int tapi_iscsi_target_set_failure_state(const char* ta, int id, const char* status, const char* sense, const char* add_code); int tapi_iscsi_initiator_advertize_set(const char* ta, iscsi_target_id target_id, iscsi_cid cid, tapi_iscsi_parameter param, bool advertize); int tapi_iscsi_initiator_set_parameter(const char* ta, iscsi_target_id target_id, iscsi_cid cid, tapi_iscsi_parameter param, const char* value, bool advertize); iscsi_target_id tapi_iscsi_initiator_add_target(const char* ta, const struct sockaddr* target_addr); int tapi_iscsi_initiator_del_target(const char* ta, iscsi_target_id tgt_id); iscsi_cid tapi_iscsi_initiator_conn_add(const char* ta, iscsi_target_id tgt_id); iscsi_cid tapi_iscsi_initiator_conn_establish(const char* ta, iscsi_target_id tgt_id, iscsi_cid cid); int tapi_iscsi_initiator_conn_del(const char* ta, iscsi_target_id tgt_id, iscsi_cid cid); int tapi_iscsi_initiator_conn_down(const char* ta, iscsi_target_id tgt_id, iscsi_cid cid); tapi_iscsi_parameter tapi_iscsi_get_param_map(const char* param); int tapi_iscsi_find_key_values(iscsi_segment_data segment_data, const char* key_name, iscsi_key_values* key_array); int tapi_iscsi_key_value_read(iscsi_key_values val_array, int val_index, char* buf, size_t* buf_len); int tapi_iscsi_key_value_write(iscsi_key_values val_array, int val_index, const char* string); static int tapi_iscsi_set_local_secret(const char* ta, const char* secret); static int tapi_iscsi_set_local_name(const char* ta, const char* name); static int tapi_iscsi_set_peer_secret(const char* ta, const char* secret); static int tapi_iscsi_set_peer_name(const char* ta, const char* name); static int tapi_iscsi_set_challenge_length(const char* ta, int len); static int tapi_iscsi_set_encoding_format(const char* ta, int fmt); static int tapi_iscsi_set_tgt_auth_req(const char* ta, int tgt_auth); static int tapi_iscsi_set_security_negotiations_phase(const char* ta, int use); iscsi_digest_type iscsi_digest_str2enum(const char* digest_type); char* iscsi_digest_enum2str(iscsi_digest_type digest_type); int tapi_iscsi_target_inform_new_test(const char* ta); te_errno tapi_iscsi_target_mount(const char* ta); te_errno tapi_iscsi_target_unmount(const char* ta); te_errno tapi_iscsi_target_file_write(const char* ta, const char* fname, const void* data, size_t length, size_t multiply); te_errno tapi_iscsi_target_file_read(const char* ta, const char* fname, void* data, size_t length); te_errno tapi_iscsi_target_raw_write(const char* ta, off_t offset, const void* data, size_t length, size_t multiply); te_errno tapi_iscsi_target_raw_read(const char* ta, off_t offset, void* data, size_t length); te_errno tapi_iscsi_io_prepare(const char* ta, iscsi_target_id id, bool use_signal, bool use_fs, size_t bufsize, iscsi_io_handle_t** ioh); te_errno tapi_iscsi_io_reset(iscsi_io_handle_t* ioh); te_errno tapi_iscsi_io_finish(iscsi_io_handle_t* ioh); bool tapi_iscsi_io_enable_signal(iscsi_io_handle_t* ioh, bool enable); te_errno tapi_iscsi_io_get_status(iscsi_io_handle_t* ioh, iscsi_io_taskid taskid); bool tapi_iscsi_io_is_complete(iscsi_io_handle_t* ioh, iscsi_io_taskid taskid); bool tapi_iscsi_initiator_is_device_ready(const char* ta, iscsi_target_id id); te_errno tapi_iscsi_initiator_mount(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid); te_errno tapi_iscsi_initiator_unmount(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid); te_errno tapi_iscsi_initiator_open(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid, const char* fname, int mode); te_errno tapi_iscsi_initiator_close(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid); te_errno tapi_iscsi_initiator_noop(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid); te_errno tapi_iscsi_initiator_fsync(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid); te_errno tapi_iscsi_initiator_seek(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid, off_t pos); te_errno tapi_iscsi_initiator_write(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid, void* data, size_t length); te_errno tapi_iscsi_initiator_read(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid, void* data, size_t length); te_errno tapi_iscsi_initiator_write_file(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid, const char* fname); te_errno tapi_iscsi_initiator_read_file(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid, const char* fname); // macros #define ISCSI_INITIATOR_SET_ADVERTIZE(_ta_, _target_id_, _cid_, _param_name_, _value_) #define ISCSI_INITIATOR_SET_NOT_ADVERTIZE(_ta_, _target_id_, _cid_, _param_name_, _value_) #define ISCSI_IO_SIGNAL #define ISCSI_TARGET_SET_PARAM(ta_, param_id_, value_) #define ISCSI_TARGET_SET_PARAM_BY_NAME(_ta_, _param_name_, _value_) #define PDU_CONTAINS_KEY(segment_data_, key_name_) #define PDU_CONTAINS_KEY_VALUE_PAIR(segment_data_, key_name_, key_value_) #define TAPI_ISCSI_KEY_INVALID
Detailed Documentation
Copyright (C) 2004-2022 OKTET Labs Ltd. All rights reserved.
Global Functions
te_errno tapi_iscsi_tgt_csap_create(const char* ta_name, iscsi_digest_type hdr_dig, iscsi_digest_type data_dig, csap_handle_t* csap)
Create ‘iscsi’ target CSAP.
Run iSCSI UNH Target Rx thread and create a socket pair to communicate with it.
Parameters:
ta_name |
Test Agent name |
hdr_dig |
Header digests used by iSCSI protocol |
data_dig |
Data digests used by iSCSI protocol |
csap |
Location for handle of new CSAP |
Returns:
Status code of the operation.
te_errno tapi_iscsi_ini_csap_create(const char* ta_name, int sid, csap_handle_t listen_csap, int timeout, iscsi_digest_type hdr_dig, iscsi_digest_type data_dig, csap_handle_t* csap)
Create ‘iscsi’ initiator CSAP.
Parameters:
ta_name |
Test Agent name |
sid |
RCF SID to be used to wait connection on listen_csap |
listen_csap |
TCP listening CSAP, on which TCP connection from the Initiator sould be received |
timeout |
Timeout to wait connection |
hdr_dig |
Header digests used by iSCSI protocol |
data_dig |
Data digests used by iSCSI protocol |
csap |
Location for handle of new CSAP |
Returns:
Status code of the operation.
te_errno tapi_iscsi_sock_csap_create(const char* ta_name, int socket, iscsi_digest_type hdr_dig, iscsi_digest_type data_dig, csap_handle_t* csap)
Create ‘iscsi’ CSAP over connected TCP socket on TA.
Parameters:
ta_name |
Test Agent name |
socket |
File descriptor of TCP socket on TA |
hdr_dig |
Header digests used by iSCSI protocol |
data_dig |
Data digests used by iSCSI protocol |
csap |
Location for handle of new CSAP |
Returns:
Status code of the operation.
int tapi_iscsi_recv_pkt(const char* ta_name, int sid, csap_handle_t csap, int timeout, csap_handle_t forward_csap, iscsi_target_params_t* params, uint8_t* buffer, size_t* length)
Receive one message via iSCSI CSAP.
Parameters:
ta_name |
Test Agent name |
sid |
RCF SID |
csap |
Identifier of CSAP |
timeout |
Timeout of operation in milliseconds |
forward_csap |
Identifier of CSAP, to which received data should be forwarded, may be CSAP_INVALID_HANDLE |
params |
Location for iSCSI current params (OUT) |
buffer |
Location for received data (OUT) |
length |
Length of buffer / received data (IN/OUT) |
Returns:
Zero on success or error code.
int tapi_iscsi_start_poll_recv_pkt(unsigned n_csaps, rcf_trpoll_csap* csaps, int timeout)
Prepare for receive a message on one of several CSAPS
Parameters:
n_csaps |
Number of CSAPs to poll |
csaps |
CSAP poll structures |
timeout |
Timeout of a receive in milliseconds |
Returns:
Status code
int tapi_iscsi_recv_polled_pkt(rcf_trpoll_csap* the_csap, iscsi_target_params_t* params, uint8_t* buffer, size_t* length)
Wait for a message on one of several CSAPs
Parameters:
n_csaps |
Number of CSAPs to poll |
csaps |
CSAP poll structures |
timeout |
Timeout of a receive in milliseconds |
params |
Location for iSCSI current params (OUT) |
ready_index |
An index in |
buffer |
Location for received data (OUT) |
length |
Length of buffer / received data (IN/OUT) |
Returns:
Status code
int tapi_iscsi_send_pkt(const char* ta_name, int sid, csap_handle_t csap, iscsi_target_params_t* params, uint8_t* buffer, size_t length)
Send one message via iSCSI CSAP.
Parameters:
ta_name |
test Agent name |
sid |
RCF SID |
csap |
identifier of CSAP |
params |
iSCSI new params |
buffer |
data to be sent |
length |
length of buffer |
Returns:
Zero on success or error code.
int tapi_iscsi_send_pkt_last(const char* ta_name, int sid, csap_handle_t csap, uint8_t* buffer, size_t length)
Send LAST message via iSCSI CSAP, and try to ensure sending FIN in the last TCP push. Note: use only with network TCP connection, not AF_LOCAL.
Parameters:
ta_name |
test Agent name |
sid |
RCF SID |
csap |
identifier of CSAP |
buffer |
data to be sent |
length |
length of buffer |
Returns:
Zero on success or error code.
int tapi_iscsi_forward_all(const char* ta_name, int session, csap_handle_t csap_rcv, csap_handle_t csap_fwd, unsigned int timeout, unsigned int* forwarded)
Receive all data which currently are waiting for receive in specified iSCSI CSAP and forward them into another CSAP, without passing via RCF to test.
Parameters:
ta |
TA name |
sid |
RCF session id |
csap_rcv |
identifier of receive CSAP |
csap_fwd |
identifier of CSAP which should obtain data |
timeout |
timeout to wait data, in milliseconds |
forwarded |
number of forwarded PDUs (OUT) |
Returns:
status code
te_errno tapi_iscsi_exchange_until_silent(const char* ta, int session, csap_handle_t csap_a, csap_handle_t csap_b, unsigned int timeout)
Pass all iSCSI PDUs from one iSCSI CSAP to another and reverse, until in both directions silence will be established during specified timeout.
Parameters:
ta |
TA name |
sid |
RCF session id |
csap_a |
identifier of one side CSAP |
csap_b |
identifier of another side CSAP |
timeout |
timeout to wait data, in milliseconds |
Returns:
status code
te_errno tapi_iscsi_exchange_until_pattern(const char* ta, int session, csap_handle_t csap_a, csap_handle_t csap_b, asn_value* pattern, uint8_t* buffer, size_t* length, unsigned int timeout)
Pass all iSCSI PDUs from one iSCSI CSAP to another and reverse, until packet, matching to specified pattern, will be catched on csap_a. This packet will be passed to the test, if ‘buffer’ is not NULL.
Parameters:
ta |
TA name. |
sid |
RCF session id. |
csap_a |
Identifier of one side CSAP. |
csap_b |
Identifier of another side CSAP. |
pattern |
ASN value with PatternUnit NDS. |
buffer |
Location for received data (OUT). |
length |
Length of buffer / received data (IN/OUT). |
timeout |
Timeout to wait data, in milliseconds. |
Returns:
status code
te_errno tapi_iscsi_prepare_pattern_unit(iscsi_bit_spec_t i_bit, uint8_t opcode, iscsi_bit_spec_t f_bit, asn_value** pattern)
Prepare pattern_unit with iSCSI PDU.
Parameters:
i_bit |
Pattern for i-bit field. |
opcode |
Pattern for opcode field, while opcode has only 6 bits, value 0xff used for mark unset. |
f_bit |
Pattern for i-bit field. |
pattern |
location for ASN value prepared (OUT). |
Returns:
status code
int tapi_iscsi_get_key_num(iscsi_segment_data segment_data)
Get number of keys in iSCSI PDU Segment Data.
Parameters:
segment_data |
iSCSI PDU Segment Data in asn format |
Returns:
number of keys ot -1 if error occurred.
char* tapi_iscsi_get_key_name(iscsi_segment_data segment_data, int key_index)
Get key name from iSCSI PDU Segment Data.
Parameters:
segment_data |
iSCSI PDU Segment Data in asn format |
key_index |
key index in iSCSI PDU Segment Data |
Returns:
key name or NULL if error occurred.
int tapi_iscsi_get_key_index_by_name(iscsi_segment_data segment_data, char* name)
Get key index in iSCSI PDU Segment Data by key name.
Parameters:
segment_data |
iSCSI PDU Segment Data in asn format |
name |
key name |
Returns:
key index or TAPI_ISCSI_KEY_INVALID if error occurred.
iscsi_key_values tapi_iscsi_get_key_values(iscsi_segment_data segment_data, int key_index)
Get values of key from iSCSI PDU Segment Data.
Parameters:
segment_data |
iSCSI PDU Segment Data in asn format |
key_index |
key index |
Returns:
key values in asn format or NULL if error occurred.
int tapi_iscsi_get_key_values_num(iscsi_key_values values)
Get number of key values.
Parameters:
values |
key values in asn format |
Returns:
number of values or -1 if error occurred.
int tapi_iscsi_get_key_value(iscsi_key_values values, int key_value_index, char** value)
Get key value from list of values.
Parameters:
values |
key values list in asn format |
key_value_index |
value index in the list |
value |
location for value (OUT) |
Returns:
0 or error code
int tapi_iscsi_add_new_key(iscsi_segment_data segment_data, char* name, int key_index)
Add a new key into an iSCSI PDU Segment Data.
Parameters:
segment_data |
iSCSI PDU Segment Data in asn format |
name |
key name |
key_index |
index of key in iSCSI PDU Segment Data, if key_index is TAPI_ISCSI_KEY_INVALID then key is to be inserted to the end of key list |
Returns:
key index or -1 if error occurred.
iscsi_key_values tapi_iscsi_key_values_create(int num, ...)
Create list of key values in asn format
Parameters:
num |
number of values |
… |
list of pairs (type, value), where type is iscsi_key_value_type_xxx, and value is an appropriate type value |
Returns:
list of values or NULL if error occurred.
int tapi_iscsi_set_key_values(iscsi_segment_data segment_data, int key_index, iscsi_key_values values)
Assign a list of values to a key in iSCSI PDU Segment Data
Parameters:
segment_data |
iSCSI PDU Segment Data in asn format |
key_index |
key index |
values |
list of key values in asn format |
Returns:
0 or error code.
void tapi_iscsi_free_key_values(iscsi_key_values values)
Free list of key values
Parameters:
values |
list of key values. |
int tapi_iscsi_delete_key(iscsi_segment_data segment_data, int key_index)
Delete a key from iSCSI PDU Segment Data in asn format
Parameters:
segment_data |
iSCSI PDU Segment Data in asn format |
key_index |
key index |
Returns:
0 or error code.
iscsi_segment_data tapi_iscsi_keys_create(int num, ...)
Create an iSCSI PDU Segment Data in asn format.
Parameters:
num |
number of keys in iSCSI PDU Segment Data |
… |
list of keys names |
Returns:
iSCSI PDU Segment Data in asn format or NULL if error occurred
int tapi_iscsi_find_key_and_value(iscsi_segment_data segment_data, const char* key_name, int num, ...)
Check that iSCSI PDU SEgment Data contains a key with a given name and its list of values contains list of values followed by num
Parameters:
segment_data |
iSCSI PDU Segment Data in asn format |
key_name |
Key name |
num |
number of key values to be checked |
… |
List of key values, they should be contained in key values list |
Returns:
Status code
int tapi_iscsi_return_key_value(iscsi_segment_data segment_data, const char* key_name, const char* buf, int buf_len)
Find the key and return its value
Parameters:
segment_data |
iSCSI PDU Segment Data in asn format |
key_name |
the name of key (according to RFC3720) |
buf |
Location to return values of the key |
buf_len |
The length of the buf |
Returns:
0 or error code.
int tapi_iscsi_change_key_values(iscsi_segment_data segment_data, char* key_name, tapi_iscsi_change_key_val_type change, int num, ...)
Change key values list according action given (See comments to tapi_iscsi_change_key_val_type)
Parameters:
segment_data |
iSCSI PDU Segment Data in asn format |
key_name |
Key name |
change |
Action to take on key values list |
num |
Number of given key values |
… |
List of key values |
Returns:
Status code
void tapi_iscsi_keys_data_free(iscsi_segment_data)
Free an iSCSI PDU Segment Data.
int tapi_iscsi_initiator_advertize_set(const char* ta, iscsi_target_id target_id, iscsi_cid cid, tapi_iscsi_parameter param, bool advertize)
Function configures parameter not to be advertized. By default the parameter is not advertized. When “SET” operation is called on it the Initiator is told to advertize the parameter.
Parameters:
ta |
Name of the TA on which the Initiator is configured |
target_id |
ID of the Taraget |
param |
Parameter to configure |
int tapi_iscsi_initiator_set_parameter(const char* ta, iscsi_target_id target_id, iscsi_cid cid, tapi_iscsi_parameter param, const char* value, bool advertize)
Function configures parameters of the Initiator.
Parameters:
ta |
Name of the TA on which the Initiator is configured |
target_id |
ID of the target |
param |
Parameter to configure |
value |
New value added |
Returns:
return of the cfg_set_instance_fmt
iscsi_target_id tapi_iscsi_initiator_add_target(const char* ta, const struct sockaddr* target_addr)
Function adds target to the Initiator targets list.
Parameters:
ta |
Name of the TA on which the Initiator is configured |
target_addr |
Address of the target |
Returns:
id of the target or -errno
int tapi_iscsi_initiator_del_target(const char* ta, iscsi_target_id tgt_id)
Function adds target to the Initiator targets list.
Parameters:
ta |
Name of the TA on which the Initiator is configured |
tgt_id |
ID of the target to destroy |
Returns:
id of the target or -errno
iscsi_cid tapi_iscsi_initiator_conn_add(const char* ta, iscsi_target_id tgt_id)
Function adds the connection. It should be called before the connection can be configured.
Parameters:
ta |
Name of the TA on which the Initiator is placed |
tgt_id |
Id of the Target to establish connection with |
Returns:
CID of the newly created connection
iscsi_cid tapi_iscsi_initiator_conn_establish(const char* ta, iscsi_target_id tgt_id, iscsi_cid cid)
Function tries to establish the connection with the given cid between the target and the initiator. Before calling this function the tapi_iscsi_initiator_conn_add() function should be called.
Parameters:
ta |
Name of the TA on which the Initiator is placed |
tgt_id |
Id of the Target to establish connection with |
cid |
ID of the connection to establish |
Returns:
CID of the newly created connection
int tapi_iscsi_initiator_conn_del(const char* ta, iscsi_target_id tgt_id, iscsi_cid cid)
Function tries to delete connection from the Initiator.
Parameters:
ta |
Name of the TA on which the Initiator is placed |
tgt_id |
Id of the Target the connection with which should be deleted |
cid |
ID of the connection to delete |
Returns:
errno
int tapi_iscsi_initiator_conn_down(const char* ta, iscsi_target_id tgt_id, iscsi_cid cid)
Function stops the connection with the given cid between the initiator and the target.
Parameters:
ta |
Name of the TA on which the Initiator is placed |
tgt_id |
Id of the Target the connection with which should be deleted |
cid |
ID of the connection to delete |
Returns:
errno
tapi_iscsi_parameter tapi_iscsi_get_param_map(const char* param)
Function converts string representation of iSCSI parameter to corresponding enum value of tapi_iscsi_parameter type.
Parameters:
param |
Name of the TA on which the Initiator is placed |
Returns:
iSCSI parameter index or -1, if fails
int tapi_iscsi_find_key_values(iscsi_segment_data segment_data, const char* key_name, iscsi_key_values* key_array)
Find specified key name in segment data and determine number of key values for its name.
Parameters:
segment_data |
iSCSI PDU Segment Data in asn format |
key_name |
the name of key (according to RFC3720) |
key_array |
location for pointer to found ASN value to key values array (OUT) |
Returns:
number of key values for passed key name, zero if none, or -1 if error encountered.
int tapi_iscsi_key_value_read(iscsi_key_values val_array, int val_index, char* buf, size_t* buf_len)
Read key value by index of value in array.
Parameters:
val_array |
array with values for some key, ASN Value |
val_index |
index of key value to be read |
buf |
location for key value (OUT) |
buf_len |
length of buffer/read data (IN/OUT) |
Returns:
status of operation
int tapi_iscsi_key_value_write(iscsi_key_values val_array, int val_index, const char* string)
Write key value by index of value in array.
Parameters:
val_array |
array with values for some key, ASN Value |
val_index |
index of key value to be read |
string |
new string key value, NULL for remove |
Returns:
status of operation
static int tapi_iscsi_set_local_secret(const char* ta, const char* secret)
The following functions are DEPRECATED!!! They will be removed as soon as all the tests use the new API
te_errno tapi_iscsi_target_mount(const char* ta)
Mount a target backing store. Note: this will work only if the target is using a file-based backing store.
Parameters:
ta |
Test Agent name |
Returns:
Status code
te_errno tapi_iscsi_target_unmount(const char* ta)
Unmount a target backing store.
Parameters:
ta |
Test Agent name |
Returns:
Status code
te_errno tapi_iscsi_target_file_write(const char* ta, const char* fname, const void* data, size_t length, size_t multiply)
Write data to a target’s backing store filesystem to a file with a given name.
Note: This function should be called only after tapi_iscsi_target_mount().
Parameters:
ta |
Test Agent name |
fname |
A filename to write |
data |
Buffer to write |
length |
Length of data to write |
multiply |
Write the buffer that many times |
Returns:
Status code
See also:
tapi_iscsi_initiator_raw_read
te_errno tapi_iscsi_target_file_read(const char* ta, const char* fname, void* data, size_t length)
Read data from a target’s backing store filesystem from a file with a given name.
Note: This function should be called only after tapi_iscsi_target_mount().
Parameters:
ta |
Test Agent name |
fname |
A filename to read from |
data |
Buffer to store data |
length |
Length of buffer |
Returns:
Status code
See also:
tapi_iscsi_initiator_raw_read
te_errno tapi_iscsi_target_raw_write(const char* ta, off_t offset, const void* data, size_t length, size_t multiply)
Write raw data to a target’s backing store.
Note: This function is NOT to be used in conjunction with tapi_iscsi_target_mount().
Parameters:
ta |
Test Agent name |
offset |
A position to write |
data |
Buffer to write |
length |
Length of data to write |
multiply |
Write the buffer that many times |
Returns:
Status code
See also:
tapi_iscsi_initiator_raw_read
te_errno tapi_iscsi_target_raw_read(const char* ta, off_t offset, void* data, size_t length)
Reads data from a target’s device at a given position
Note: This function is NOT to be used in conjunction with tapi_iscsi_target_mount().
Parameters:
ta |
Test Agent name |
offset |
A position to read from |
data |
Buffer to store data |
length |
Length of data |
Returns:
Status code
See also:
tapi_iscsi_initiator_raw_write
te_errno tapi_iscsi_io_prepare(const char* ta, iscsi_target_id id, bool use_signal, bool use_fs, size_t bufsize, iscsi_io_handle_t** ioh)
Create a new asynchronous I/O handler
Parameters:
ta |
Test Agent name |
id |
target id to connect |
use_signal |
Should a signal be sent after an I/O operation is complete |
use_fs |
|
bufsize |
Buffer size for file copying operations, that is, tapi_iscsi_initiator_read_file() and tapi_iscsi_initiator_write_file(). |
ioh |
A pointer to resulting handler (OUT) |
Returns:
Status code
te_errno tapi_iscsi_io_reset(iscsi_io_handle_t* ioh)
Resets the I/O handler task queue
Parameters:
ioh |
I/O handler |
TE_EINPROGRESS |
There are incomplete tasks pending |
Returns:
Status code
te_errno tapi_iscsi_io_finish(iscsi_io_handle_t* ioh)
Destroy an asynchronous I/O handler
Parameters:
ioh |
I/O handler |
Returns:
Status code
bool tapi_iscsi_io_enable_signal(iscsi_io_handle_t* ioh, bool enable)
Parameters:
ioh |
I/O handler |
enable |
Returns:
Previous state
te_errno tapi_iscsi_io_get_status(iscsi_io_handle_t* ioh, iscsi_io_taskid taskid)
Gets the status code of a task of a I/O handler
Parameters:
ioh |
I/O handle |
taskid |
Task ID |
TE_EINPROGRESS |
if the task has not completed |
Returns:
Status code of a given task
bool tapi_iscsi_io_is_complete(iscsi_io_handle_t* ioh, iscsi_io_taskid taskid)
Checks whether a task has completed
Parameters:
ioh |
I/O handle |
taskid |
Task ID |
Returns:
true
if the task has completed
bool tapi_iscsi_initiator_is_device_ready(const char* ta, iscsi_target_id id)
Checks whether an iSCSI device is present and ready
Parameters:
ta |
Test Agent |
id |
Target id |
Returns:
true
if the device is ready
te_errno tapi_iscsi_initiator_mount(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid)
Request mounting an iSCSI device on the TA, if the I/O handler has been created with “use_fs” == true
. Otherwise a no-op.
Note: you need to call tapi_iscsi_target_mount() before this function to create a filesystem on a target backing store.
Parameters:
ioh |
I/O handler |
taskid |
A pointer to store a task ID or NULL (OUT) |
Returns:
Status code
te_errno tapi_iscsi_initiator_unmount(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid)
Request unmounting an iSCSI device on the TA. No-op if “use_fs” is not true
for the I/O handler.
Parameters:
ioh |
I/O handler |
taskid |
A pointer to store a task ID or NULL (OUT) |
Returns:
Status code
te_errno tapi_iscsi_initiator_open(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid, const char* fname, int mode)
Opens a file on an iSCSI filesystem
Parameters:
ioh |
I/O handler |
taskid |
A pointer to store a task ID or NULL (OUT) |
fname |
Filename |
mode |
Standard UNIX file open mode |
Returns:
Status code
te_errno tapi_iscsi_initiator_close(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid)
Closes a file on an iSCSI filesystem previously opened by tapi_iscsi_initiator_open().
Parameters:
ioh |
I/O handler |
taskid |
A pointer to store a task ID or NULL (OUT) |
Returns:
Status code
te_errno tapi_iscsi_initiator_noop(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid)
Does nothing. Its sole purpose is to providc a task to wait for that never fails (useful when testing for a I/O failure).
Parameters:
ioh |
I/O handler |
taskid |
A pointer to store a task ID or NULL (OUT) |
Returns:
Status code
te_errno tapi_iscsi_initiator_fsync(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid)
Syncs the written data of an iSCSI-mounted filesystem file or a SCSI block device.
Parameters:
ioh |
I/O handler |
taskid |
A pointer to store a task ID or NULL (OUT) |
Returns:
Status code
te_errno tapi_iscsi_initiator_seek(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid, off_t pos)
Request a seek operation on an iSCSI device.
Parameters:
ioh |
I/O handler |
taskid |
A pointer to store a task ID or NULL (OUT) |
pos |
Positiion to seek to |
Returns:
Status code
te_errno tapi_iscsi_initiator_write(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid, void* data, size_t length)
Request a write operation on an iSCSI device.
Parameters:
ioh |
I/O handler |
taskid |
A pointer to store a task ID or NULL (OUT) |
data |
A pointer to a buffer with data |
length |
Length of data to write |
Returns:
Status code
te_errno tapi_iscsi_initiator_read(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid, void* data, size_t length)
Request a read operation on an iSCSI device.
Parameters:
ioh |
I/O handler |
taskid |
A pointer to store a task ID or NULL (OUT) |
data |
A pointer to a buffer to store data |
length |
Length of the buffer |
Returns:
Status code
te_errno tapi_iscsi_initiator_write_file(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid, const char* fname)
Request a write operation on an iSCSI device using data from a file. The copying is done in chunks of size ‘bufsize’ passed to iscsi_io_prepare().
Parameters:
ioh |
I/O handler |
data |
A pointer to a zero-terminated string to write |
taskid |
A pointer to store a task ID or NULL (OUT) |
fname |
Name of a file with data |
Returns:
Status code
te_errno tapi_iscsi_initiator_read_file(iscsi_io_handle_t* ioh, iscsi_io_taskid* taskid, const char* fname)
Request a read operation on an iSCSI device putting data to a file. The copying is done in chunks of size ‘bufsize’ passed to iscsi_io_prepare().
Parameters:
ioh |
I/O handler |
data |
A pointer to a zero-terminated string to verify |
fname |
Name of a file to store data |
Returns:
Status code
Macros
#define ISCSI_INITIATOR_SET_ADVERTIZE(_ta_, _target_id_, _cid_, _param_name_, _value_)
Macro configures the Initiator. The configured parameter will be advertized by the Initiator during the Login State.
Parameters:
_ta_ |
Agent on which the Initiator is configured |
_target_id_ |
ID of the Target for which the parameter is configured |
_param_name_ |
Name of the parameter to configure |
_value_ |
New value of the parameter (in string form) |
#define ISCSI_INITIATOR_SET_NOT_ADVERTIZE(_ta_, _target_id_, _cid_, _param_name_, _value_)
Macro configures the Initiator. The configured parameter will NOT be advertized by the Initiator during the Login State.
Parameters:
_ta_ |
Agent on which the Initiator is configured |
_target_id_ |
ID of the Target for which the parameter is configured |
_param_name_ |
Name of the parameter to configure |
_value_ |
New value of the parameter (in string form) |