Libiscsi: Adding new_pdu function to transport abstraction
Signed-off-by: Roy Shterman <roysh@mellanox.com>
This commit is contained in:
committed by
Ronnie Sahlberg
parent
e3df0bbf96
commit
2671e10565
@@ -383,11 +383,14 @@ void iscsi_timeout_scan(struct iscsi_context *iscsi);
|
|||||||
void iscsi_reconnect_cb(struct iscsi_context *iscsi _U_, int status,
|
void iscsi_reconnect_cb(struct iscsi_context *iscsi _U_, int status,
|
||||||
void *command_data, void *private_data);
|
void *command_data, void *private_data);
|
||||||
|
|
||||||
|
struct iscsi_pdu *iscsi_tcp_new_pdu(struct iscsi_context *iscsi, size_t size);
|
||||||
|
|
||||||
void iscsi_init_tcp_transport(struct iscsi_context *iscsi);
|
void iscsi_init_tcp_transport(struct iscsi_context *iscsi);
|
||||||
|
|
||||||
struct iscsi_transport {
|
struct iscsi_transport {
|
||||||
int (*connect)(struct iscsi_context *iscsi, union socket_address *sa, int ai_family);
|
int (*connect)(struct iscsi_context *iscsi, union socket_address *sa, int ai_family);
|
||||||
int (*queue_pdu)(struct iscsi_context *iscsi, struct iscsi_pdu *pdu);
|
int (*queue_pdu)(struct iscsi_context *iscsi, struct iscsi_pdu *pdu);
|
||||||
|
struct iscsi_pdu* (*new_pdu)(struct iscsi_context *iscsi, size_t size);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tcp_transport {
|
struct tcp_transport {
|
||||||
|
|||||||
12
lib/pdu.c
12
lib/pdu.c
@@ -79,6 +79,16 @@ void iscsi_dump_pdu_header(struct iscsi_context *iscsi, unsigned char *data) {
|
|||||||
ISCSI_LOG(iscsi, 2, "PDU header:%s", dump);
|
ISCSI_LOG(iscsi, 2, "PDU header:%s", dump);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct iscsi_pdu*
|
||||||
|
iscsi_tcp_new_pdu(struct iscsi_context *iscsi, size_t size)
|
||||||
|
{
|
||||||
|
struct iscsi_pdu *pdu;
|
||||||
|
|
||||||
|
pdu = iscsi_szmalloc(iscsi, size);
|
||||||
|
|
||||||
|
return pdu;
|
||||||
|
}
|
||||||
|
|
||||||
struct iscsi_pdu *
|
struct iscsi_pdu *
|
||||||
iscsi_allocate_pdu(struct iscsi_context *iscsi, enum iscsi_opcode opcode,
|
iscsi_allocate_pdu(struct iscsi_context *iscsi, enum iscsi_opcode opcode,
|
||||||
enum iscsi_opcode response_opcode, uint32_t itt,
|
enum iscsi_opcode response_opcode, uint32_t itt,
|
||||||
@@ -86,7 +96,7 @@ iscsi_allocate_pdu(struct iscsi_context *iscsi, enum iscsi_opcode opcode,
|
|||||||
{
|
{
|
||||||
struct iscsi_pdu *pdu;
|
struct iscsi_pdu *pdu;
|
||||||
|
|
||||||
pdu = iscsi_szmalloc(iscsi, sizeof(struct iscsi_pdu));
|
pdu = iscsi->t->new_pdu(iscsi, sizeof(struct iscsi_pdu));
|
||||||
if (pdu == NULL) {
|
if (pdu == NULL) {
|
||||||
iscsi_set_error(iscsi, "failed to allocate pdu");
|
iscsi_set_error(iscsi, "failed to allocate pdu");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -1055,6 +1055,7 @@ void iscsi_init_tcp_transport(struct iscsi_context *iscsi)
|
|||||||
{
|
{
|
||||||
iscsi->t->connect = iscsi_tcp_connect;
|
iscsi->t->connect = iscsi_tcp_connect;
|
||||||
iscsi->t->queue_pdu = iscsi_tcp_queue_pdu;
|
iscsi->t->queue_pdu = iscsi_tcp_queue_pdu;
|
||||||
|
iscsi->t->new_pdu = iscsi_tcp_new_pdu;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user