diff options
Diffstat (limited to 'src/server/iscsi.h')
| -rw-r--r-- | src/server/iscsi.h | 92 |
1 files changed, 51 insertions, 41 deletions
diff --git a/src/server/iscsi.h b/src/server/iscsi.h index 29b89aa..df737b6 100644 --- a/src/server/iscsi.h +++ b/src/server/iscsi.h @@ -301,90 +301,90 @@ int iscsi_hashmap_iterate(iscsi_hashmap *map, iscsi_hashmap_callback callback, u /// iSCSI initiator (client) command opcode: NOP-Out. -#define ISCSI_CLIENT_NOP_OUT 0x00 +#define ISCSI_OPCODE_CLIENT_NOP_OUT 0x00 /// iSCSI initiator (client) command opcode: SCSI Command (encapsulates a SCSI Command Descriptor Block). -#define ISCSI_CLIENT_SCSI_CMD 0x01 +#define ISCSI_OPCODE_CLIENT_SCSI_CMD 0x01 /// iSCSI initiator (client) command opcode: SCSI Task Management Function Request. -#define ISCSI_CLIENT_TASK_FUNC_REQ 0x02 +#define ISCSI_OPCODE_CLIENT_TASK_FUNC_REQ 0x02 /// iSCSI initiator (client) command opcode: Login Request. -#define ISCSI_CLIENT_LOGIN_REQ 0x03 +#define ISCSI_OPCODE_CLIENT_LOGIN_REQ 0x03 /// iSCSI initiator (client) command opcode: Text Request. -#define ISCSI_CLIENT_TEXT_REQ 0x04 +#define ISCSI_OPCODE_CLIENT_TEXT_REQ 0x04 /// iSCSI initiator (client) command opcode: SCSI Data-Out (for write operations). -#define ISCSI_CLIENT_SCSI_DATA_OUT 0x05 +#define ISCSI_OPCODE_CLIENT_SCSI_DATA_OUT 0x05 /// iSCSI initiator (client) command opcode: Logout Request. -#define ISCSI_CLIENT_LOGOUT_REQ 0x06 +#define ISCSI_OPCODE_CLIENT_LOGOUT_REQ 0x06 /// iSCSI initiator (client) command opcode: Selective Negative / Sequence Number Acknowledgment (SNACK) Request. -#define ISCSI_CLIENT_SNACK_REQ 0x10 +#define ISCSI_OPCODE_CLIENT_SNACK_REQ 0x10 /// iSCSI initiator (client) command opcode: Vendor-specific code #1. -#define ISCSI_CLIENT_VENDOR_CODE1 0x1C +#define ISCSI_OPCODE_CLIENT_VENDOR_CODE1 0x1C /// iSCSI initiator (client) command opcode: Vendor-specific code #2. -#define ISCSI_CLIENT_VENDOR_CODE2 0x1D +#define ISCSI_OPCODE_CLIENT_VENDOR_CODE2 0x1D /// iSCSI initiator (client) command opcode: Vendor-specific code #3. -#define ISCSI_CLIENT_VENDOR_CODE3 0x1E +#define ISCSI_OPCODE_CLIENT_VENDOR_CODE3 0x1E /// First iSCSI initiator (client) command opcode. -#define ISCSI_CLIENT_FIRST_OPCODE 0x00 +#define ISCSI_OPCODE_CLIENT_FIRST 0x00 /// Last iSCSI initiator (client) command opcode. -#define ISCSI_CLIENT_LAST_OPCODE 0x1F +#define ISCSI_OPCODE_CLIENT_LAST 0x1F /// iSCSI target (server) command opcode: NOP-In. -#define ISCSI_SERVER_NOP_IN 0x20 +#define ISCSI_OPCODE_SERVER_NOP_IN 0x20 /// iSCSI target (server) command opcode: SCSI Response - contains SCSI status and possibly sense information or other response information. -#define ISCSI_SERVER_SCSI_RESPONSE 0x21 +#define ISCSI_OPCODE_SERVER_SCSI_RESPONSE 0x21 /// iSCSI target (server) command opcode: SCSI Task Management Function Response. -#define ISCSI_SERVER_TASK_FUNC_RES 0x22 +#define ISCSI_OPCODE_SERVER_TASK_FUNC_RES 0x22 /// iSCSI target (server) command opcode: Login Response. -#define ISCSI_SERVER_LOGIN_RES 0x23 +#define ISCSI_OPCODE_SERVER_LOGIN_RES 0x23 /// iSCSI target (server) command opcode: Text Response. -#define ISCSI_SERVER_TEXT_RES 0x24 +#define ISCSI_OPCODE_SERVER_TEXT_RES 0x24 /// iSCSI target (server) command opcode: SCSI Data-In (for read operations). -#define ISCSI_SERVER_SCSI_DATA_IN 0x25 +#define ISCSI_OPCODE_SERVER_SCSI_DATA_IN 0x25 /// iSCSI target (server) command opcode: Logout Response. -#define ISCSI_SERVER_LOGOUT_RES 0x26 +#define ISCSI_OPCODE_SERVER_LOGOUT_RES 0x26 /// iSCSI target (server) command opcode: Ready To Transfer (R2T) - sent by target when it is ready to receive data. -#define ISCSI_SERVER_READY_XFER 0x31 +#define ISCSI_OPCODE_SERVER_READY_XFER 0x31 /// iSCSI target (server) command opcode: Asynchronous Message - sent by target to indicate certain special conditions. -#define ISCSI_SERVER_ASYNC_MSG 0x32 +#define ISCSI_OPCODE_SERVER_ASYNC_MSG 0x32 /// iSCSI target (server) command opcode: Vendor-specific code #1. -#define ISCSI_SERVER_VENDOR_CODE1 0x3C +#define ISCSI_OPCODE_SERVER_VENDOR_CODE1 0x3C /// iSCSI target (server) command opcode: Vendor-specific code #2. -#define ISCSI_SERVER_VENDOR_CODE2 0x3D +#define ISCSI_OPCODE_SERVER_VENDOR_CODE2 0x3D /// iSCSI target (server) command opcode: Vendor-specific code #3. -#define ISCSI_SERVER_VENDOR_CODE3 0x3E +#define ISCSI_OPCODE_SERVER_VENDOR_CODE3 0x3E /// iSCSI target (server) command opcode: Reject. -#define ISCSI_SERVER_REJECT 0x3F +#define ISCSI_OPCODE_SERVER_REJECT 0x3F /// First iSCSI target (server) command opcode. -#define ISCSI_SERVER_FIRST_OPCODE 0x20 +#define ISCSI_OPCODE_SERVER_FIRST 0x20 /// Last iSCSI target (server) command opcode. -#define ISCSI_SERVER_LAST_OPCODE 0x3F +#define ISCSI_OPCODE_SERVER_LAST 0x3F /// iSCSI opcode bit mask (bits 0-5 used). @@ -6040,6 +6040,9 @@ int iscsi_port_transport_id_set(iscsi_port *port, const uint8_t *name, const uin * and associates a disk image file. */ typedef struct iscsi_lun { + /// Assocated DNBD3 image for this LUN. + dnbd3_image_t *image; + /// LUN identifier (always MUST be between 0 and 7). int id; @@ -6101,10 +6104,7 @@ typedef struct iscsi_device { int flags; /// Number of ports. - int num_ports; - - /// Portocol identifier. - uint8_t protocol_id; + uint num_ports; } iscsi_device; @@ -6123,23 +6123,21 @@ typedef struct iscsi_device_find_lun_id { } iscsi_device_find_lun_id; -/// iSCSI target node flags: Header digest. -#define ISCSI_TARGET_NODE_FLAGS_DIGEST_HEADER (1 << 0L) +/// iSCSI target node maximum length +#define ISCSI_TARGET_NODE_MAX_NAME_LEN 223UL -/// iSCSI target node flags: Data digest. -#define ISCSI_TARGET_NODE_FLAGS_DIGEST_DATA (1 << 1L) /// iSCSI target node flags: CHAP authentication disabled. -#define ISCSI_TARGET_NODE_FLAGS_CHAP_DISABLE (1 << 2L) +#define ISCSI_TARGET_NODE_FLAGS_CHAP_DISABLE (1 << 0L) /// iSCSI target node flags: CHAP authentication required. -#define ISCSI_TARGET_NODE_FLAGS_CHAP_REQUIRE (1 << 3L) +#define ISCSI_TARGET_NODE_FLAGS_CHAP_REQUIRE (1 << 1L) /// iSCSI target node flags: CHAP authentication mutual. -#define ISCSI_TARGET_NODE_FLAGS_CHAP_MUTUAL (1 << 4L) +#define ISCSI_TARGET_NODE_FLAGS_CHAP_MUTUAL (1 << 2L) /// iSCSI target node flags: Destroyed. -#define ISCSI_TARGET_NODE_FLAGS_DESTROYED (1 << 5L) +#define ISCSI_TARGET_NODE_FLAGS_DESTROYED (1 << 3L) /** @@ -6615,9 +6613,12 @@ typedef struct iscsi_pdu { /// DataSegmentLength. uint ds_len; - /// Position of DataSegment buffer for next read. + /// Position of DataSegment buffer for next operation. uint pos; + /// Allocated DataSegment buffer length. + uint len; + /// Associated iSCSI connection. iscsi_connection *conn; @@ -6708,11 +6709,20 @@ void iscsi_task_put(iscsi_task *task); // Enqueues an iSCSI task into it's under int iscsi_task_find_callback(uint8_t *key, const size_t key_size, uint8_t *value, uint8_t *user_data); // Finds an iSCSI task by Target Transfer Tag (TTT) int iscsi_device_find_lun_callback(uint8_t *key, const size_t key_size, uint8_t *value, uint8_t *user_data); // Finds an iSCSI LUN by LUN identifier +iscsi_lun *iscsi_lun_create(const uint id); // Allocates and initializes an iSCSI LUN structure for linkage with a DNBD3 image +void iscsi_lun_destroy(iscsi_lun *lun); // Deallocates all resources acquired by iscsi_lun_create + uint64_t iscsi_lun_get_from_scsi(const int lun_id); // Converts an internal representation of a LUN identifier to an iSCSI LUN required for packet data int iscsi_lun_get_from_iscsi(const uint64_t lun); // Converts an iSCSI LUN from packet data to internal SCSI LUN identifier +iscsi_device *iscsi_device_create(const uint8_t *name, const uint luns); // Creates and initializes an iSCSI device with a maximum number of LUNs +void iscsi_device_destroy(iscsi_device *device); // Deallocates all resources acquired by iscsi_device_create + iscsi_port *iscsi_device_find_port_by_portal_group_tag(const iscsi_device *device, const uint64_t id); // Gets an iSCSI device being in use by portal group identifier +iscsi_target_node *iscsi_target_node_create(const uint8_t *name, const uint8_t *alias, const int index, const uint luns, const uint queue_depth, const int flags, const int32_t chap_group, const int header_digest, const int data_digest); // Creates and initializes an iSCSI target node +void iscsi_target_node_destroy(iscsi_target_node *target); // Deallocates all resources acquired by iscsi_target_node_create + int iscsi_target_node_send(iscsi_connection *conn, const uint8_t *dst_iqn, const uint8_t *src_iqn, uint8_t *buf, uint pos, const uint len); // Sends a buffer from a source iSCSI IQN to target iSCSI IQNs int iscsi_target_node_find_callback(uint8_t *key, const size_t key_size, uint8_t *value, uint8_t *user_data); // Finds an iSCSI target node by case insensitive name search iscsi_target_node *iscsi_target_node_find(uint8_t *target_name); // Searches an iSCSI target node by name using case insensitive search |
