Skip to content

Commit

Permalink
Dump opcode string in iscsi_dump_pdu_header()
Browse files Browse the repository at this point in the history
Now we have more friendly opcode message once error occurs:
libiscsi:1 command timed out from waitqueue [...]
libiscsi:2 PDU header: 01 c1 ... e9 88[READ16] 00 00 00 ...
                                       ^(human readable opcode string)

Signed-off-by: zhenwei pi <[email protected]>
  • Loading branch information
pizhenwei committed Nov 3, 2023
1 parent 283e99b commit 4c3ac54
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,18 @@ iscsi_itt_post_increment(struct iscsi_context *iscsi) {
}

void iscsi_dump_pdu_header(struct iscsi_context *iscsi, unsigned char *data) {
char dump[ISCSI_RAW_HEADER_SIZE*3+1]={0};
char dump1[33*3+1]={0};
char dump2[(ISCSI_RAW_HEADER_SIZE-33)*3+1]={0};
const char *opcode;
int i;
for (i=0;i<ISCSI_RAW_HEADER_SIZE;i++) {
snprintf(&dump[i * 3], 4, " %02x", data[i]);
for (i=0;i<33;i++) {
snprintf(&dump1[i * 3], 4, " %02x", data[i]);
}
ISCSI_LOG(iscsi, 2, "PDU header:%s", dump);
opcode = scsi_opcode_str(data[32]);
for (;i<ISCSI_RAW_HEADER_SIZE;i++) {
snprintf(&dump2[(i-33) * 3], 4, " %02x", data[i]);
}
ISCSI_LOG(iscsi, 2, "PDU header:%s[%s]%s", dump1, opcode, dump2);
}

struct iscsi_pdu*
Expand Down

0 comments on commit 4c3ac54

Please sign in to comment.