Ethereal-dev: [Ethereal-dev] packet-iscsi.c update
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Mark Burton <markb@xxxxxxxxxx>
Date: Sun, 22 Jul 2001 10:01:21 +0100
Hi, the enclosed patch updates the current CVS packet-iscsi.c to use the opcodes from the 07 draft and is functionally the same as that used at the recent UNH iSCSI plugfest. I plan to release another update soon to bring it into line with the 07 draft. Cheers, Mark -------------- Index: packet-iscsi.c =================================================================== RCS file: /cvsroot/ethereal/packet-iscsi.c,v retrieving revision 1.9 diff -u -3 -p -c -r1.9 packet-iscsi.c *** packet-iscsi.c 2001/07/16 06:06:06 1.9 --- packet-iscsi.c 2001/07/22 08:54:09 *************** *** 3,8 **** --- 3,10 ---- * Copyright 2001, Eurologic and Mark Burton <markb@xxxxxxxxxx> * * Conforms to the protocol described in: draft-ietf-ips-iscsi-06.txt + * but uses the 07 opcodes (as used at the July 2001 UNH plugfest) + * * Optionally, supports the protocol described in: draft-ietf-ips-iscsi-03.txt * * $Id: packet-iscsi.c,v 1.9 2001/07/16 06:06:06 guy Exp $ *************** *** 50,60 **** #include "packet.h" #include "prefs.h" ! static int enable_03_mode = TRUE; static int enable_bogosity_filter = TRUE; ! static int bogus_pdu_data_length_threshold = 1024 * 1024; ! static int bogus_pdu_max_digest_padding = 20; static int enable_force_header_digest_crc32 = FALSE; --- 52,64 ---- #include "packet.h" #include "prefs.h" + + /*#define USE_06_OPCODES*/ ! static int enable_03_mode = FALSE; static int enable_bogosity_filter = TRUE; ! static guint32 bogus_pdu_data_length_threshold = 1024 * 1024; ! static guint32 bogus_pdu_max_digest_padding = 20; static int enable_force_header_digest_crc32 = FALSE; *************** static int hf_iscsi_Opcode = -1; *** 66,75 **** static int hf_iscsi_Opcode_03 = -1; static int hf_iscsi_Flags = -1; static int hf_iscsi_HeaderDigest32 = -1; - #if 0 static int hf_iscsi_X = -1; static int hf_iscsi_I = -1; - #endif static int hf_iscsi_SCSICommand_X03 = -1; static int hf_iscsi_SCSICommand_F = -1; static int hf_iscsi_SCSICommand_R = -1; --- 70,77 ---- *************** static gint ett_iscsi_CDB = -1; *** 161,166 **** --- 163,169 ---- static gint ett_iscsi_Flags = -1; static const value_string iscsi_opcodes[] = { + #ifdef USE_06_OPCODES {0x00, "NOP Out"}, {0x40, "NOP Out (Immediate)"}, {0x80, "NOP Out (Retry)"}, *************** static const value_string iscsi_opcodes[ *** 198,203 **** --- 201,227 ---- {0xd0, "Ready To Transfer"}, {0xd1, "Asynchronous Message"}, {0xef, "Reject"}, + #else + {0x00, "NOP Out"}, + {0x01, "SCSI Command"}, + {0x02, "SCSI Task Management Command"}, + {0x03, "Login Command"}, + {0x04, "Text Command"}, + {0x05, "SCSI Write Data"}, + {0x06, "Logout Command"}, + {0x10, "SNACK Request"}, + + {0xe0, "NOP In"}, + {0xe1, "SCSI Command Response"}, + {0xe2, "SCSI Task Management Response"}, + {0xe3, "Login Response"}, + {0xe4, "Text Response"}, + {0xe5, "SCSI Read Data"}, + {0xe6, "Logout Response"}, + {0xf1, "Ready To Transfer"}, + {0xf2, "Asynchronous Message"}, + {0xff, "Reject"}, + #endif {0, NULL}, }; *************** addTextKeys(proto_tree *tt, tvbuff_t *tv *** 623,629 **** static gint handleHeaderDigest(proto_item *ti, tvbuff_t *tvb, guint offset, int headerLen) { ! guint32 packet_len = tvb_length_remaining(tvb, offset); if(packet_len >= (headerLen + 4)) { guint32 crc = ~calculateCRC32(tvb_get_ptr(tvb, offset, headerLen), headerLen, CRC32C_PRELOAD); guint32 sent = tvb_get_ntohl(tvb, offset + headerLen); --- 647,653 ---- static gint handleHeaderDigest(proto_item *ti, tvbuff_t *tvb, guint offset, int headerLen) { ! int packet_len = tvb_length_remaining(tvb, offset); if(packet_len >= (headerLen + 4)) { guint32 crc = ~calculateCRC32(tvb_get_ptr(tvb, offset, headerLen), headerLen, CRC32C_PRELOAD); guint32 sent = tvb_get_ntohl(tvb, offset + headerLen); *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 669,674 **** --- 693,705 ---- data_segment_len = tvb_get_ntohl(tvb, offset + 4); } else { + #ifndef USE_06_OPCODES + if((opcode & 0x20) == 0) { + /* initiator -> target */ + /* mask out X and I bits */ + opcode &= 0x3f; + } + #endif opcode_str = match_strval(opcode, iscsi_opcodes); data_segment_len = tvb_get_ntohl(tvb, offset + 4) & 0x00ffffff; } *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 714,720 **** if(blurb != NULL) col_append_fstr(pinfo->fd, COL_INFO, " (%s)", blurb); } ! else if(!enable_03_mode && opcode == 0xc1) { /* SCSI Command Response */ const char *blurb = NULL; if(tvb_get_guint8(tvb, offset + 1) & 0x01) --- 745,757 ---- if(blurb != NULL) col_append_fstr(pinfo->fd, COL_INFO, " (%s)", blurb); } ! else if(!enable_03_mode && ! #ifdef USE_06_OPCODES ! opcode == 0xc1 ! #else ! opcode == 0x21 ! #endif ! ) { /* SCSI Command Response */ const char *blurb = NULL; if(tvb_get_guint8(tvb, offset + 1) & 0x01) *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 734,752 **** ti = proto_tree_add_protocol_format(tree, proto_iscsi, tvb, offset, packet_len, "iSCSI (%s)", (char *)opcode_str); if((enable_03_mode && opcode == 0x00) || (!enable_03_mode && (opcode == 0x00 || opcode == 0x40 || ! opcode == 0x80))) { /* NOP Out */ - if(enable_03_mode) { - proto_tree_add_uint(ti, hf_iscsi_Opcode_03, tvb, - offset + 0, 1, opcode); - } - else { - proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb, - offset + 0, 1, opcode); - } { gint b = tvb_get_guint8(tvb, offset + 1); proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); --- 771,808 ---- ti = proto_tree_add_protocol_format(tree, proto_iscsi, tvb, offset, packet_len, "iSCSI (%s)", (char *)opcode_str); + if(enable_03_mode) { + proto_tree_add_uint(ti, hf_iscsi_Opcode_03, tvb, + offset + 0, 1, opcode); + } + else { + proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb, + offset + 0, 1, opcode); + #ifndef USE_06_OPCODES + if((opcode & 0x20) == 0) { + /* initiator -> target */ + gint b = tvb_get_guint8(tvb, offset + 0); + if(opcode != 0x05 && + opcode != 0x06 && + opcode != 0x10) + proto_tree_add_boolean(ti, hf_iscsi_X, tvb, offset + 0, 1, b); + if(opcode != 0x03 && + opcode != 0x05) + proto_tree_add_boolean(ti, hf_iscsi_I, tvb, offset + 0, 1, b); + } + #endif + } + if((enable_03_mode && opcode == 0x00) || + #ifdef USE_06_OPCODES (!enable_03_mode && (opcode == 0x00 || opcode == 0x40 || ! opcode == 0x80)) ! #else ! (!enable_03_mode && opcode == 0x00) ! #endif ! ) { /* NOP Out */ { gint b = tvb_get_guint8(tvb, offset + 1); proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 771,786 **** offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x80) || ! (!enable_03_mode && opcode == 0xc0)) { /* NOP In */ - if(enable_03_mode) { - proto_tree_add_uint(ti, hf_iscsi_Opcode_03, tvb, - offset + 0, 1, opcode); - } - else { - proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb, - offset + 0, 1, opcode); - } { gint b = tvb_get_guint8(tvb, offset + 1); proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); --- 827,839 ---- offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x80) || ! #ifdef USE_06_OPCODES ! (!enable_03_mode && opcode == 0xc0) ! #else ! (!enable_03_mode && opcode == 0xe0) ! #endif ! ) { /* NOP In */ { gint b = tvb_get_guint8(tvb, offset + 1); proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 801,813 **** offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x01) || (!enable_03_mode && (opcode == 0x01 || opcode == 0x41 || ! opcode == 0x81))) { /* SCSI Command */ if(enable_03_mode) { - proto_tree_add_uint(ti, hf_iscsi_Opcode_03, tvb, - offset + 0, 1, opcode); { gint b = tvb_get_guint8(tvb, offset + 1); proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); --- 854,869 ---- offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x01) || + #ifdef USE_06_OPCODES (!enable_03_mode && (opcode == 0x01 || opcode == 0x41 || ! opcode == 0x81)) ! #else ! (!enable_03_mode && opcode == 0x01) ! #endif ! ) { /* SCSI Command */ if(enable_03_mode) { { gint b = tvb_get_guint8(tvb, offset + 1); proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 822,829 **** proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } else { - proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb, - offset + 0, 1, opcode); { gint b = tvb_get_guint8(tvb, offset + 1); proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); --- 878,883 ---- *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 879,889 **** } } else if((enable_03_mode && opcode == 0x81) || ! (!enable_03_mode && opcode == 0xc1)) { /* SCSI Response */ if(enable_03_mode) { - proto_tree_add_uint(ti, hf_iscsi_Opcode_03, tvb, - offset + 0, 1, opcode); { gint b = tvb_get_guint8(tvb, offset + 1); proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); --- 933,946 ---- } } else if((enable_03_mode && opcode == 0x81) || ! #ifdef USE_06_OPCODES ! (!enable_03_mode && opcode == 0xc1) ! #else ! (!enable_03_mode && opcode == 0xe1) ! #endif ! ) { /* SCSI Response */ if(enable_03_mode) { { gint b = tvb_get_guint8(tvb, offset + 1); proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 897,904 **** proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } else { - proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb, - offset + 0, 1, opcode); { gint b = tvb_get_guint8(tvb, offset + 1); proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); --- 954,959 ---- *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 933,952 **** offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x02) || (!enable_03_mode && (opcode == 0x02 || opcode == 0x42 || ! opcode == 0x82))) { /* SCSI Task Command */ if(enable_03_mode) { - proto_tree_add_uint(ti, hf_iscsi_Opcode_03, tvb, - offset + 0, 1, opcode); - } - else { - proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb, - offset + 0, 1, opcode); - } - proto_tree_add_item(ti, hf_iscsi_SCSITask_Function, tvb, offset + 1, 1, FALSE); - if(enable_03_mode) { proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } proto_tree_add_item(ti, hf_iscsi_LUN, tvb, offset + 8, 8, FALSE); --- 988,1004 ---- offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x02) || + #ifdef USE_06_OPCODES (!enable_03_mode && (opcode == 0x02 || opcode == 0x42 || ! opcode == 0x82)) ! #else ! (!enable_03_mode && opcode == 0x02) ! #endif ! ) { /* SCSI Task Command */ + proto_tree_add_item(ti, hf_iscsi_SCSITask_Function, tvb, offset + 1, 1, FALSE); if(enable_03_mode) { proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } proto_tree_add_item(ti, hf_iscsi_LUN, tvb, offset + 8, 8, FALSE); *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 957,973 **** offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x82) || ! (!enable_03_mode && opcode == 0xc2)) { /* SCSI Task Response */ if(enable_03_mode) { - proto_tree_add_uint(ti, hf_iscsi_Opcode_03, tvb, - offset + 0, 1, opcode); proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } - else { - proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb, - offset + 0, 1, opcode); - } proto_tree_add_item(ti, hf_iscsi_LUN, tvb, offset + 8, 8, FALSE); proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, FALSE); proto_tree_add_item(ti, hf_iscsi_SCSITask_ReferencedTaskTag, tvb, offset + 20, 4, FALSE); --- 1009,1024 ---- offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x82) || ! #ifdef USE_06_OPCODES ! (!enable_03_mode && opcode == 0xc2) ! #else ! (!enable_03_mode && opcode == 0xe2) ! #endif ! ) { /* SCSI Task Response */ if(enable_03_mode) { proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } proto_tree_add_item(ti, hf_iscsi_LUN, tvb, offset + 8, 8, FALSE); proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, FALSE); proto_tree_add_item(ti, hf_iscsi_SCSITask_ReferencedTaskTag, tvb, offset + 20, 4, FALSE); *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 978,1000 **** offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x03) || (!enable_03_mode && (opcode == 0x03 || ! opcode == 0x83))) { /* Login Command */ ! if(enable_03_mode) { ! proto_tree_add_uint(ti, hf_iscsi_Opcode_03, tvb, ! offset + 0, 1, opcode); ! } ! else { ! proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb, ! offset + 0, 1, opcode); ! { ! gint b = tvb_get_guint8(tvb, offset + 1); ! proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); ! proto_tree *tt = proto_item_add_subtree(tf, ett_iscsi_Flags); ! ! proto_tree_add_boolean(tt, hf_iscsi_Login_F, tvb, offset + 1, 1, b); ! } } proto_tree_add_item(ti, hf_iscsi_VersionMax, tvb, offset + 2, 1, FALSE); proto_tree_add_item(ti, hf_iscsi_VersionMin, tvb, offset + 3, 1, FALSE); --- 1029,1048 ---- offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x03) || + #ifdef USE_06_OPCODES (!enable_03_mode && (opcode == 0x03 || ! opcode == 0x83)) ! #else ! (!enable_03_mode && opcode == 0x03) ! #endif ! ) { /* Login Command */ ! if(!enable_03_mode) { ! gint b = tvb_get_guint8(tvb, offset + 1); ! proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); ! proto_tree *tt = proto_item_add_subtree(tf, ett_iscsi_Flags); ! ! proto_tree_add_boolean(tt, hf_iscsi_Login_F, tvb, offset + 1, 1, b); } proto_tree_add_item(ti, hf_iscsi_VersionMax, tvb, offset + 2, 1, FALSE); proto_tree_add_item(ti, hf_iscsi_VersionMin, tvb, offset + 3, 1, FALSE); *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 1029,1044 **** } } else if((enable_03_mode && opcode == 0x83) || ! (!enable_03_mode && opcode == 0xc3)) { /* Login Response */ - if(enable_03_mode) { - proto_tree_add_uint(ti, hf_iscsi_Opcode_03, tvb, - offset + 0, 1, opcode); - } - else { - proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb, - offset + 0, 1, opcode); - } { gint b = tvb_get_guint8(tvb, offset + 1); proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); --- 1077,1089 ---- } } else if((enable_03_mode && opcode == 0x83) || ! #ifdef USE_06_OPCODES ! (!enable_03_mode && opcode == 0xc3) ! #else ! (!enable_03_mode && opcode == 0xe3) ! #endif ! ) { /* Login Response */ { gint b = tvb_get_guint8(tvb, offset + 1); proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 1080,1104 **** } } else if((enable_03_mode && opcode == 0x04) || (!enable_03_mode && (opcode == 0x04 || opcode == 0x44 || ! opcode == 0x84))) { /* Text Command */ if(enable_03_mode) { - proto_tree_add_uint(ti, hf_iscsi_Opcode_03, tvb, - offset + 0, 1, opcode); proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } else { ! proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb, ! offset + 0, 1, opcode); ! { ! gint b = tvb_get_guint8(tvb, offset + 1); ! proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); ! proto_tree *tt = proto_item_add_subtree(tf, ett_iscsi_Flags); ! ! proto_tree_add_boolean(tt, hf_iscsi_Text_F, tvb, offset + 1, 1, b); ! } proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, data_segment_len); } proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, FALSE); --- 1125,1148 ---- } } else if((enable_03_mode && opcode == 0x04) || + #ifdef USE_06_OPCODES (!enable_03_mode && (opcode == 0x04 || opcode == 0x44 || ! opcode == 0x84)) ! #else ! (!enable_03_mode && opcode == 0x04) ! #endif ! ) { /* Text Command */ if(enable_03_mode) { proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } else { ! gint b = tvb_get_guint8(tvb, offset + 1); ! proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); ! proto_tree *tt = proto_item_add_subtree(tf, ett_iscsi_Flags); ! ! proto_tree_add_boolean(tt, hf_iscsi_Text_F, tvb, offset + 1, 1, b); proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, data_segment_len); } proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, FALSE); *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 1118,1140 **** } } else if((enable_03_mode && opcode == 0x84) || ! (!enable_03_mode && (opcode == 0xc4))) { /* Text Response */ if(enable_03_mode) { - proto_tree_add_uint(ti, hf_iscsi_Opcode_03, tvb, - offset + 0, 1, opcode); proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } else { ! proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb, ! offset + 0, 1, opcode); ! { ! gint b = tvb_get_guint8(tvb, offset + 1); ! proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); ! proto_tree *tt = proto_item_add_subtree(tf, ett_iscsi_Flags); ! ! proto_tree_add_boolean(tt, hf_iscsi_Text_F, tvb, offset + 1, 1, b); ! } proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, data_segment_len); } proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, FALSE); --- 1162,1183 ---- } } else if((enable_03_mode && opcode == 0x84) || ! #ifdef USE_06_OPCODES ! (!enable_03_mode && (opcode == 0xc4)) ! #else ! (!enable_03_mode && opcode == 0xe4) ! #endif ! ) { /* Text Response */ if(enable_03_mode) { proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } else { ! gint b = tvb_get_guint8(tvb, offset + 1); ! proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); ! proto_tree *tt = proto_item_add_subtree(tf, ett_iscsi_Flags); ! ! proto_tree_add_boolean(tt, hf_iscsi_Text_F, tvb, offset + 1, 1, b); proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, data_segment_len); } proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, FALSE); *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 1156,1169 **** } else if(opcode == 0x05) { /* SCSI Data (write) */ - if(enable_03_mode) { - proto_tree_add_uint(ti, hf_iscsi_Opcode_03, tvb, - offset + 0, 1, opcode); - } - else { - proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb, - offset + 0, 1, opcode); - } { gint b = tvb_get_guint8(tvb, offset + 1); proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); --- 1199,1204 ---- *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 1187,1222 **** offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x85) || ! (!enable_03_mode && opcode == 0xc5)) { /* SCSI Data (read) */ if(enable_03_mode) { ! proto_tree_add_uint(ti, hf_iscsi_Opcode_03, tvb, ! offset + 0, 1, opcode); ! { ! gint b = tvb_get_guint8(tvb, offset + 1); ! proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); ! proto_tree *tt = proto_item_add_subtree(tf, ett_iscsi_Flags); ! proto_tree_add_boolean(tt, hf_iscsi_SCSIData_P03, tvb, offset + 1, 1, b); ! proto_tree_add_boolean(tt, hf_iscsi_SCSIData_S03, tvb, offset + 1, 1, b); ! proto_tree_add_boolean(tt, hf_iscsi_SCSIData_O03, tvb, offset + 1, 1, b); ! proto_tree_add_boolean(tt, hf_iscsi_SCSIData_U03, tvb, offset + 1, 1, b); ! } proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } else { ! proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb, ! offset + 0, 1, opcode); ! { ! gint b = tvb_get_guint8(tvb, offset + 1); ! proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); ! proto_tree *tt = proto_item_add_subtree(tf, ett_iscsi_Flags); ! proto_tree_add_boolean(tt, hf_iscsi_SCSIData_F, tvb, offset + 1, 1, b); ! proto_tree_add_boolean(tt, hf_iscsi_SCSIData_O, tvb, offset + 1, 1, b); ! proto_tree_add_boolean(tt, hf_iscsi_SCSIData_U, tvb, offset + 1, 1, b); ! proto_tree_add_boolean(tt, hf_iscsi_SCSIData_S, tvb, offset + 1, 1, b); ! } proto_tree_add_item(ti, hf_iscsi_StatusResponse_is_status, tvb, offset + 3, 1, FALSE); proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, data_segment_len); } --- 1222,1254 ---- offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x85) || ! #ifdef USE_06_OPCODES ! (!enable_03_mode && opcode == 0xc5) ! #else ! (!enable_03_mode && opcode == 0xe5) ! #endif ! ) { /* SCSI Data (read) */ if(enable_03_mode) { ! gint b = tvb_get_guint8(tvb, offset + 1); ! proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); ! proto_tree *tt = proto_item_add_subtree(tf, ett_iscsi_Flags); ! proto_tree_add_boolean(tt, hf_iscsi_SCSIData_P03, tvb, offset + 1, 1, b); ! proto_tree_add_boolean(tt, hf_iscsi_SCSIData_S03, tvb, offset + 1, 1, b); ! proto_tree_add_boolean(tt, hf_iscsi_SCSIData_O03, tvb, offset + 1, 1, b); ! proto_tree_add_boolean(tt, hf_iscsi_SCSIData_U03, tvb, offset + 1, 1, b); proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } else { ! gint b = tvb_get_guint8(tvb, offset + 1); ! proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); ! proto_tree *tt = proto_item_add_subtree(tf, ett_iscsi_Flags); ! proto_tree_add_boolean(tt, hf_iscsi_SCSIData_F, tvb, offset + 1, 1, b); ! proto_tree_add_boolean(tt, hf_iscsi_SCSIData_O, tvb, offset + 1, 1, b); ! proto_tree_add_boolean(tt, hf_iscsi_SCSIData_U, tvb, offset + 1, 1, b); ! proto_tree_add_boolean(tt, hf_iscsi_SCSIData_S, tvb, offset + 1, 1, b); proto_tree_add_item(ti, hf_iscsi_StatusResponse_is_status, tvb, offset + 3, 1, FALSE); proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, data_segment_len); } *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 1238,1253 **** offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x06) || ! (!enable_03_mode && (opcode == 0x06 || opcode == 0x46))) { /* Logout Command */ if(enable_03_mode) { - proto_tree_add_uint(ti, hf_iscsi_Opcode_03, tvb, - offset + 0, 1, opcode); proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } else { - proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb, - offset + 0, 1, opcode); proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, data_segment_len); } proto_tree_add_item(ti, hf_iscsi_CID, tvb, offset + 8, 2, FALSE); --- 1270,1286 ---- offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x06) || ! #ifdef USE_06_OPCODES ! (!enable_03_mode && (opcode == 0x06 || opcode == 0x46)) ! #else ! (!enable_03_mode && opcode == 0x06) ! #endif ! ) { /* Logout Command */ if(enable_03_mode) { proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } else { proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, data_segment_len); } proto_tree_add_item(ti, hf_iscsi_CID, tvb, offset + 8, 2, FALSE); *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 1262,1289 **** offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x86) || ! (!enable_03_mode && opcode == 0xc6)) { /* Logout Response */ if(enable_03_mode) { - proto_tree_add_uint(ti, hf_iscsi_Opcode_03, tvb, - offset + 0, 1, opcode); proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } - else { - proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb, - offset + 0, 1, opcode); - } proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, FALSE); proto_tree_add_item(ti, hf_iscsi_ExpCmdSN, tvb, offset + 28, 4, FALSE); proto_tree_add_item(ti, hf_iscsi_MaxCmdSN, tvb, offset + 32, 4, FALSE); proto_tree_add_item(ti, hf_iscsi_Logout_Response, tvb, offset + 36, 1, FALSE); offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } ! else if((!enable_03_mode && (opcode == 0x10 || opcode == 0x50))) { int S = 0; /* SNACK Request */ - proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb, - offset + 0, 1, opcode); { gint b = tvb_get_guint8(tvb, offset + 1); proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); --- 1295,1325 ---- offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x86) || ! #ifdef USE_06_OPCODES ! (!enable_03_mode && opcode == 0xc6) ! #else ! (!enable_03_mode && opcode == 0xe6) ! #endif ! ) { /* Logout Response */ if(enable_03_mode) { proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, FALSE); proto_tree_add_item(ti, hf_iscsi_ExpCmdSN, tvb, offset + 28, 4, FALSE); proto_tree_add_item(ti, hf_iscsi_MaxCmdSN, tvb, offset + 32, 4, FALSE); proto_tree_add_item(ti, hf_iscsi_Logout_Response, tvb, offset + 36, 1, FALSE); offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } ! else if( ! #ifdef USE_06_OPCODES ! (!enable_03_mode && (opcode == 0x10 || opcode == 0x50)) ! #else ! (!enable_03_mode && opcode == 0x10) ! #endif ! ) { int S = 0; /* SNACK Request */ { gint b = tvb_get_guint8(tvb, offset + 1); proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 1306,1322 **** offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x90) || ! (!enable_03_mode && opcode == 0xd0)) { /* R2T */ if(enable_03_mode) { - proto_tree_add_uint(ti, hf_iscsi_Opcode_03, tvb, - offset + 0, 1, opcode); proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } - else { - proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb, - offset + 0, 1, opcode); - } proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, FALSE); proto_tree_add_item(ti, hf_iscsi_TargetTransferTag, tvb, offset + 20, 4, FALSE); if(!enable_03_mode) { --- 1342,1357 ---- offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x90) || ! #ifdef USE_06_OPCODES ! (!enable_03_mode && opcode == 0xd0) ! #else ! (!enable_03_mode && opcode == 0xf1) ! #endif ! ) { /* R2T */ if(enable_03_mode) { proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, FALSE); proto_tree_add_item(ti, hf_iscsi_TargetTransferTag, tvb, offset + 20, 4, FALSE); if(!enable_03_mode) { *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 1336,1351 **** offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x91) || ! (!enable_03_mode && opcode == 0xd1)) { /* Asynchronous Message */ if(enable_03_mode) { - proto_tree_add_uint(ti, hf_iscsi_Opcode_03, tvb, - offset + 0, 1, opcode); proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } else { - proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb, - offset + 0, 1, opcode); proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, data_segment_len); } proto_tree_add_item(ti, hf_iscsi_LUN, tvb, offset + 8, 8, FALSE); --- 1371,1387 ---- offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } else if((enable_03_mode && opcode == 0x91) || ! #ifdef USE_06_OPCODES ! (!enable_03_mode && opcode == 0xd1) ! #else ! (!enable_03_mode && opcode == 0xf2) ! #endif ! ) { /* Asynchronous Message */ if(enable_03_mode) { proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); } else { proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, data_segment_len); } proto_tree_add_item(ti, hf_iscsi_LUN, tvb, offset + 8, 8, FALSE); *************** dissect_iscsi(tvbuff_t *tvb, packet_info *** 1366,1382 **** proto_tree_add_item(ti, hf_iscsi_Parameter3, tvb, offset + 42, 2, FALSE); offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } ! else if(opcode == 0xef) { /* Reject */ if(enable_03_mode) { - proto_tree_add_uint(ti, hf_iscsi_Opcode_03, tvb, - offset + 0, 1, opcode); proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); proto_tree_add_item(ti, hf_iscsi_Reject_Reason03, tvb, offset + 36, 1, FALSE); } else { - proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb, - offset + 0, 1, opcode); proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, data_segment_len); proto_tree_add_item(ti, hf_iscsi_Reject_Reason, tvb, offset + 40, 1, FALSE); proto_tree_add_item(ti, hf_iscsi_Reject_FirstBadByte, tvb, offset + 42, 1, FALSE); --- 1402,1420 ---- proto_tree_add_item(ti, hf_iscsi_Parameter3, tvb, offset + 42, 2, FALSE); offset += 48 + handleHeaderDigest(ti, tvb, offset, 48); } ! else if((enable_03_mode && opcode == 0xef) || ! #ifdef USE_06_OPCODES ! (!enable_03_mode && opcode == 0xef) ! #else ! (!enable_03_mode && opcode == 0xff) ! #endif ! ) { /* Reject */ if(enable_03_mode) { proto_tree_add_uint(ti, hf_iscsi_Length03, tvb, offset + 4, 4, data_segment_len); proto_tree_add_item(ti, hf_iscsi_Reject_Reason03, tvb, offset + 36, 1, FALSE); } else { proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, data_segment_len); proto_tree_add_item(ti, hf_iscsi_Reject_Reason, tvb, offset + 40, 1, FALSE); proto_tree_add_item(ti, hf_iscsi_Reject_FirstBadByte, tvb, offset + 42, 1, FALSE); *************** proto_register_iscsi(void) *** 1428,1467 **** FT_UINT8, BASE_HEX, VALS(iscsi_opcodes_03), 0, "Opcode", HFILL } }, - #if 0 { &hf_iscsi_X, ! { "X", "iscsi.x", FT_BOOLEAN, 8, TFS(&iscsi_meaning_X), 0x80, "Command Retry", HFILL } }, { &hf_iscsi_I, ! { "I", "iscsi.i", FT_BOOLEAN, 8, TFS(&iscsi_meaning_I), 0x40, "Immediate delivery", HFILL } }, - #endif { &hf_iscsi_Flags, { "Flags", "iscsi.flags", FT_UINT8, BASE_HEX, NULL, 0, "Opcode specific flags", HFILL } }, { &hf_iscsi_SCSICommand_X03, ! { "X", "iscsi.scsicommand.x", FT_BOOLEAN, 8, TFS(&iscsi_meaning_X), 0x80, "Command Retry", HFILL } }, { &hf_iscsi_SCSICommand_F, ! { "F", "iscsi.scsicommand.f", FT_BOOLEAN, 8, TFS(&iscsi_meaning_F), 0x80, "PDU completes command", HFILL } }, { &hf_iscsi_SCSICommand_R, ! { "R", "iscsi.scsicommand.r", FT_BOOLEAN, 8, TFS(&iscsi_meaning_R), 0x40, "Command reads from SCSI target", HFILL } }, { &hf_iscsi_SCSICommand_W, ! { "W", "iscsi.scsicommand.r", FT_BOOLEAN, 8, TFS(&iscsi_meaning_W), 0x20, "Command writes to SCSI target", HFILL } }, --- 1466,1503 ---- FT_UINT8, BASE_HEX, VALS(iscsi_opcodes_03), 0, "Opcode", HFILL } }, { &hf_iscsi_X, ! { "X", "iscsi.X", FT_BOOLEAN, 8, TFS(&iscsi_meaning_X), 0x80, "Command Retry", HFILL } }, { &hf_iscsi_I, ! { "I", "iscsi.I", FT_BOOLEAN, 8, TFS(&iscsi_meaning_I), 0x40, "Immediate delivery", HFILL } }, { &hf_iscsi_Flags, { "Flags", "iscsi.flags", FT_UINT8, BASE_HEX, NULL, 0, "Opcode specific flags", HFILL } }, { &hf_iscsi_SCSICommand_X03, ! { "X", "iscsi.scsicommand.X", FT_BOOLEAN, 8, TFS(&iscsi_meaning_X), 0x80, "Command Retry", HFILL } }, { &hf_iscsi_SCSICommand_F, ! { "F", "iscsi.scsicommand.F", FT_BOOLEAN, 8, TFS(&iscsi_meaning_F), 0x80, "PDU completes command", HFILL } }, { &hf_iscsi_SCSICommand_R, ! { "R", "iscsi.scsicommand.R", FT_BOOLEAN, 8, TFS(&iscsi_meaning_R), 0x40, "Command reads from SCSI target", HFILL } }, { &hf_iscsi_SCSICommand_W, ! { "W", "iscsi.scsicommand.W", FT_BOOLEAN, 8, TFS(&iscsi_meaning_W), 0x20, "Command writes to SCSI target", HFILL } }, *************** proto_register_iscsi(void) *** 1621,1637 **** "Bi-directional read residual count", HFILL } }, { &hf_iscsi_SCSIData_F, ! { "F", "iscsi.scsidata.f", FT_BOOLEAN, 8, TFS(&iscsi_meaning_F), 0x80, "Final PDU", HFILL } }, { &hf_iscsi_SCSIData_P03, ! { "P", "iscsi.scsidata.p", FT_BOOLEAN, 8, TFS(&iscsi_meaning_P), 0x80, "Poll requested", HFILL } }, { &hf_iscsi_SCSIData_S03, ! { "S", "iscsi.scsidata.s", FT_BOOLEAN, 8, TFS(&iscsi_meaning_S), 0x04, "PDU Contains SCSI command status", HFILL } }, --- 1657,1673 ---- "Bi-directional read residual count", HFILL } }, { &hf_iscsi_SCSIData_F, ! { "F", "iscsi.scsidata.F", FT_BOOLEAN, 8, TFS(&iscsi_meaning_F), 0x80, "Final PDU", HFILL } }, { &hf_iscsi_SCSIData_P03, ! { "P", "iscsi.scsidata.P", FT_BOOLEAN, 8, TFS(&iscsi_meaning_P), 0x80, "Poll requested", HFILL } }, { &hf_iscsi_SCSIData_S03, ! { "S", "iscsi.scsidata.S", FT_BOOLEAN, 8, TFS(&iscsi_meaning_S), 0x04, "PDU Contains SCSI command status", HFILL } }, *************** proto_register_iscsi(void) *** 1646,1652 **** "Residual underflow", HFILL } }, { &hf_iscsi_SCSIData_S, ! { "S", "iscsi.scsidata.s", FT_BOOLEAN, 8, TFS(&iscsi_meaning_S), 0x01, "PDU Contains SCSI command status", HFILL } }, --- 1682,1688 ---- "Residual underflow", HFILL } }, { &hf_iscsi_SCSIData_S, ! { "S", "iscsi.scsidata.S", FT_BOOLEAN, 8, TFS(&iscsi_meaning_S), 0x01, "PDU Contains SCSI command status", HFILL } }, *************** proto_register_iscsi(void) *** 1716,1722 **** "Initial command sequence number", HFILL } }, { &hf_iscsi_Login_F, ! { "F", "iscsi.login.f", FT_BOOLEAN, 8, TFS(&iscsi_meaning_F), 0x80, "Final PDU in login sequence", HFILL } }, --- 1752,1758 ---- "Initial command sequence number", HFILL } }, { &hf_iscsi_Login_F, ! { "F", "iscsi.login.F", FT_BOOLEAN, 8, TFS(&iscsi_meaning_F), 0x80, "Final PDU in login sequence", HFILL } }, *************** proto_register_iscsi(void) *** 1736,1757 **** "Key/value pair", HFILL } }, { &hf_iscsi_Text_F, ! { "F", "iscsi.text.f", FT_BOOLEAN, 8, TFS(&iscsi_meaning_F), 0x80, "Final PDU in text sequence", HFILL } }, { &hf_iscsi_NOP_P, ! { "P", "iscsi.nop.p", FT_BOOLEAN, 8, TFS(&iscsi_meaning_P), 0x80, "Poll requested", HFILL } }, { &hf_iscsi_ExpDataSN, ! { "ExpCmdSN", "iscsi.expdatasn", FT_UINT32, BASE_HEX, NULL, 0, "Next expected data sequence number", HFILL } }, { &hf_iscsi_R2TExpDataSN, ! { "R2TExpCmdSN", "iscsi.r2texpdatasn", FT_UINT32, BASE_HEX, NULL, 0, "Next expected R2T data sequence number", HFILL } }, --- 1772,1793 ---- "Key/value pair", HFILL } }, { &hf_iscsi_Text_F, ! { "F", "iscsi.text.F", FT_BOOLEAN, 8, TFS(&iscsi_meaning_F), 0x80, "Final PDU in text sequence", HFILL } }, { &hf_iscsi_NOP_P, ! { "P", "iscsi.nop.P", FT_BOOLEAN, 8, TFS(&iscsi_meaning_P), 0x80, "Poll requested", HFILL } }, { &hf_iscsi_ExpDataSN, ! { "ExpDataSN", "iscsi.expdatasn", FT_UINT32, BASE_HEX, NULL, 0, "Next expected data sequence number", HFILL } }, { &hf_iscsi_R2TExpDataSN, ! { "R2TExpDataSN", "iscsi.r2texpdatasn", FT_UINT32, BASE_HEX, NULL, 0, "Next expected R2T data sequence number", HFILL } }, *************** proto_register_iscsi(void) *** 1841,1847 **** "Reason for command rejection", HFILL } }, { &hf_iscsi_SNACK_S, ! { "S", "iscsi.snack.s", FT_BOOLEAN, 8, TFS(&iscsi_meaning_SNACK_S), 0x01, "Status not data SNACK requested", HFILL } }, --- 1877,1883 ---- "Reason for command rejection", HFILL } }, { &hf_iscsi_SNACK_S, ! { "S", "iscsi.snack.S", FT_BOOLEAN, 8, TFS(&iscsi_meaning_SNACK_S), 0x01, "Status not data SNACK requested", HFILL } },
- Follow-Ups:
- Re: [Ethereal-dev] packet-iscsi.c update
- From: Guy Harris
- Re: [Ethereal-dev] packet-iscsi.c update
- Prev by Date: Re: [Ethereal-dev] smb, dcerpc, having old-style dissector call a tvbuff one?
- Next by Date: Re: [Ethereal-dev] packet-iscsi.c update
- Previous by thread: [Ethereal-dev] idl2eth plans
- Next by thread: Re: [Ethereal-dev] packet-iscsi.c update
- Index(es):