summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-iscsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'epan/dissectors/packet-iscsi.c')
-rw-r--r--epan/dissectors/packet-iscsi.c738
1 files changed, 420 insertions, 318 deletions
diff --git a/epan/dissectors/packet-iscsi.c b/epan/dissectors/packet-iscsi.c
index 69072b9d..1420f5a2 100644
--- a/epan/dissectors/packet-iscsi.c
+++ b/epan/dissectors/packet-iscsi.c
@@ -57,142 +57,144 @@ static const value_string ahs_type_vals[] = {
{0, NULL}
};
-static dissector_handle_t iscsi_handle=NULL;
+static dissector_handle_t iscsi_handle;
-static gint iscsi_protocol_version = ISCSI_PROTOCOL_DRAFT13;
+static int iscsi_protocol_version = ISCSI_PROTOCOL_DRAFT13;
-static gboolean iscsi_desegment = TRUE;
+static bool iscsi_desegment = true;
-static int demand_good_f_bit = FALSE;
-static int enable_bogosity_filter = TRUE;
-static guint32 bogus_pdu_data_length_threshold = 256 * 1024;
+static bool demand_good_f_bit;
+static bool enable_bogosity_filter = true;
+static uint32_t bogus_pdu_data_length_threshold = 256 * 1024;
#define TCP_PORT_ISCSI_RANGE "3260"
static range_t *global_iscsi_port_range;
-static guint iscsi_system_port = 860;
+static unsigned iscsi_system_port = 860;
/* Initialize the protocol and registered fields */
-static int proto_iscsi = -1;
-static int hf_iscsi_time = -1;
-static int hf_iscsi_request_frame = -1;
-static int hf_iscsi_data_in_frame = -1;
-static int hf_iscsi_data_out_frame = -1;
-static int hf_iscsi_response_frame = -1;
-static int hf_iscsi_AHS_length = -1;
-static int hf_iscsi_AHS_type = -1;
-static int hf_iscsi_AHS_blob = -1;
-static int hf_iscsi_AHS_read_data_length = -1;
-static int hf_iscsi_AHS_extended_cdb = -1;
-static int hf_iscsi_Padding = -1;
-static int hf_iscsi_ping_data = -1;
-static int hf_iscsi_immediate_data = -1;
-static int hf_iscsi_async_event_data = -1;
-static int hf_iscsi_vendor_specific_data = -1;
-static int hf_iscsi_Opcode = -1;
-static int hf_iscsi_Flags = -1;
-static int hf_iscsi_HeaderDigest32 = -1;
-static int hf_iscsi_DataDigest32 = -1;
+static int proto_iscsi;
+static int hf_iscsi_time;
+static int hf_iscsi_r2t_time;
+static int hf_iscsi_request_frame;
+static int hf_iscsi_r2t_frame;
+static int hf_iscsi_data_in_frame;
+static int hf_iscsi_data_out_frame;
+static int hf_iscsi_response_frame;
+static int hf_iscsi_AHS_length;
+static int hf_iscsi_AHS_type;
+static int hf_iscsi_AHS_blob;
+static int hf_iscsi_AHS_read_data_length;
+static int hf_iscsi_AHS_extended_cdb;
+static int hf_iscsi_Padding;
+static int hf_iscsi_ping_data;
+static int hf_iscsi_immediate_data;
+static int hf_iscsi_async_event_data;
+static int hf_iscsi_vendor_specific_data;
+static int hf_iscsi_Opcode;
+static int hf_iscsi_Flags;
+static int hf_iscsi_HeaderDigest32;
+static int hf_iscsi_DataDigest32;
/* #ifdef DRAFT08 */
-static int hf_iscsi_X = -1;
+static int hf_iscsi_X;
/* #endif */
-static int hf_iscsi_I = -1;
-static int hf_iscsi_SCSICommand_F = -1;
-static int hf_iscsi_SCSICommand_R = -1;
-static int hf_iscsi_SCSICommand_W = -1;
-static int hf_iscsi_SCSICommand_Attr = -1;
-static int hf_iscsi_SCSICommand_CRN = -1;
-static int hf_iscsi_DataSegmentLength = -1;
-static int hf_iscsi_TotalAHSLength = -1;
-static int hf_iscsi_InitiatorTaskTag = -1;
-static int hf_iscsi_ExpectedDataTransferLength = -1;
-static int hf_iscsi_CmdSN = -1;
-static int hf_iscsi_ExpStatSN = -1;
-static int hf_iscsi_StatSN = -1;
-static int hf_iscsi_ExpCmdSN = -1;
-static int hf_iscsi_MaxCmdSN = -1;
-static int hf_iscsi_SCSIResponse_o = -1;
-static int hf_iscsi_SCSIResponse_u = -1;
-static int hf_iscsi_SCSIResponse_O = -1;
-static int hf_iscsi_SCSIResponse_U = -1;
-static int hf_iscsi_SCSIResponse_BidiReadResidualCount = -1;
-static int hf_iscsi_SCSIResponse_ResidualCount = -1;
-static int hf_iscsi_SCSIResponse_Response = -1;
-static int hf_iscsi_SCSIResponse_Status = -1;
-static int hf_iscsi_SenseLength = -1;
-static int hf_iscsi_SCSIData_F = -1;
-static int hf_iscsi_SCSIData_A = -1;
-static int hf_iscsi_SCSIData_S = -1;
-static int hf_iscsi_SCSIData_O = -1;
-static int hf_iscsi_SCSIData_U = -1;
-static int hf_iscsi_TargetTransferTag = -1;
-static int hf_iscsi_DataSN = -1;
-static int hf_iscsi_BufferOffset = -1;
-static int hf_iscsi_SCSIData_ResidualCount = -1;
-static int hf_iscsi_VersionMin = -1;
-static int hf_iscsi_VersionMax = -1;
-static int hf_iscsi_VersionActive = -1;
-static int hf_iscsi_CID = -1;
-static int hf_iscsi_ISID8 = -1;
-static int hf_iscsi_ISID = -1;
+static int hf_iscsi_I;
+static int hf_iscsi_SCSICommand_F;
+static int hf_iscsi_SCSICommand_R;
+static int hf_iscsi_SCSICommand_W;
+static int hf_iscsi_SCSICommand_Attr;
+static int hf_iscsi_SCSICommand_CRN;
+static int hf_iscsi_DataSegmentLength;
+static int hf_iscsi_TotalAHSLength;
+static int hf_iscsi_InitiatorTaskTag;
+static int hf_iscsi_ExpectedDataTransferLength;
+static int hf_iscsi_CmdSN;
+static int hf_iscsi_ExpStatSN;
+static int hf_iscsi_StatSN;
+static int hf_iscsi_ExpCmdSN;
+static int hf_iscsi_MaxCmdSN;
+static int hf_iscsi_SCSIResponse_o;
+static int hf_iscsi_SCSIResponse_u;
+static int hf_iscsi_SCSIResponse_O;
+static int hf_iscsi_SCSIResponse_U;
+static int hf_iscsi_SCSIResponse_BidiReadResidualCount;
+static int hf_iscsi_SCSIResponse_ResidualCount;
+static int hf_iscsi_SCSIResponse_Response;
+static int hf_iscsi_SCSIResponse_Status;
+static int hf_iscsi_SenseLength;
+static int hf_iscsi_SCSIData_F;
+static int hf_iscsi_SCSIData_A;
+static int hf_iscsi_SCSIData_S;
+static int hf_iscsi_SCSIData_O;
+static int hf_iscsi_SCSIData_U;
+static int hf_iscsi_TargetTransferTag;
+static int hf_iscsi_DataSN;
+static int hf_iscsi_BufferOffset;
+static int hf_iscsi_SCSIData_ResidualCount;
+static int hf_iscsi_VersionMin;
+static int hf_iscsi_VersionMax;
+static int hf_iscsi_VersionActive;
+static int hf_iscsi_CID;
+static int hf_iscsi_ISID8;
+static int hf_iscsi_ISID;
/* #if defined(DRAFT09) */
-static int hf_iscsi_ISID_Type = -1;
-static int hf_iscsi_ISID_NamingAuthority = -1;
-static int hf_iscsi_ISID_Qualifier = -1;
+static int hf_iscsi_ISID_Type;
+static int hf_iscsi_ISID_NamingAuthority;
+static int hf_iscsi_ISID_Qualifier;
/* #elif !defined(DRAFT08) */
-static int hf_iscsi_ISID_t = -1;
-static int hf_iscsi_ISID_a = -1;
-static int hf_iscsi_ISID_b = -1;
-static int hf_iscsi_ISID_c = -1;
-static int hf_iscsi_ISID_d = -1;
+static int hf_iscsi_ISID_t;
+static int hf_iscsi_ISID_a;
+static int hf_iscsi_ISID_b;
+static int hf_iscsi_ISID_c;
+static int hf_iscsi_ISID_d;
/* #endif */
-static int hf_iscsi_TSID = -1;
-static int hf_iscsi_TSIH = -1;
+static int hf_iscsi_TSID;
+static int hf_iscsi_TSIH;
/* #ifdef DRAFT09 */
-static int hf_iscsi_Login_X = -1;
+static int hf_iscsi_Login_X;
/* #endif */
-static int hf_iscsi_Login_C = -1;
-static int hf_iscsi_Login_T = -1;
-static int hf_iscsi_Login_CSG = -1;
-static int hf_iscsi_Login_NSG = -1;
-static int hf_iscsi_Login_Status = -1;
-static int hf_iscsi_KeyValue = -1;
-static int hf_iscsi_Text_C = -1;
-static int hf_iscsi_Text_F = -1;
-static int hf_iscsi_ExpDataSN = -1;
-static int hf_iscsi_R2TSN = -1;
-static int hf_iscsi_TaskManagementFunction_ReferencedTaskTag = -1;
-static int hf_iscsi_RefCmdSN = -1;
-static int hf_iscsi_TaskManagementFunction_Function = -1;
-static int hf_iscsi_TaskManagementFunction_Response = -1;
-static int hf_iscsi_Logout_Reason = -1;
-static int hf_iscsi_Logout_Response = -1;
-static int hf_iscsi_Time2Wait = -1;
-static int hf_iscsi_Time2Retain = -1;
-static int hf_iscsi_DesiredDataLength = -1;
-static int hf_iscsi_AsyncEvent = -1;
-static int hf_iscsi_EventVendorCode = -1;
-static int hf_iscsi_Parameter1 = -1;
-static int hf_iscsi_Parameter2 = -1;
-static int hf_iscsi_Parameter3 = -1;
-static int hf_iscsi_Reject_Reason = -1;
-static int hf_iscsi_snack_type = -1;
-static int hf_iscsi_BegRun = -1;
-static int hf_iscsi_RunLength = -1;
+static int hf_iscsi_Login_C;
+static int hf_iscsi_Login_T;
+static int hf_iscsi_Login_CSG;
+static int hf_iscsi_Login_NSG;
+static int hf_iscsi_Login_Status;
+static int hf_iscsi_KeyValue;
+static int hf_iscsi_Text_C;
+static int hf_iscsi_Text_F;
+static int hf_iscsi_ExpDataSN;
+static int hf_iscsi_R2TSN;
+static int hf_iscsi_TaskManagementFunction_ReferencedTaskTag;
+static int hf_iscsi_RefCmdSN;
+static int hf_iscsi_TaskManagementFunction_Function;
+static int hf_iscsi_TaskManagementFunction_Response;
+static int hf_iscsi_Logout_Reason;
+static int hf_iscsi_Logout_Response;
+static int hf_iscsi_Time2Wait;
+static int hf_iscsi_Time2Retain;
+static int hf_iscsi_DesiredDataLength;
+static int hf_iscsi_AsyncEvent;
+static int hf_iscsi_EventVendorCode;
+static int hf_iscsi_Parameter1;
+static int hf_iscsi_Parameter2;
+static int hf_iscsi_Parameter3;
+static int hf_iscsi_Reject_Reason;
+static int hf_iscsi_snack_type;
+static int hf_iscsi_BegRun;
+static int hf_iscsi_RunLength;
/* Initialize the subtree pointers */
-static gint ett_iscsi = -1;
-static gint ett_iscsi_KeyValues = -1;
-static gint ett_iscsi_CDB = -1;
-static gint ett_iscsi_Flags = -1;
-static gint ett_iscsi_RejectHeader = -1;
-static gint ett_iscsi_lun = -1;
+static int ett_iscsi;
+static int ett_iscsi_KeyValues;
+static int ett_iscsi_CDB;
+static int ett_iscsi_Flags;
+static int ett_iscsi_RejectHeader;
+static int ett_iscsi_lun;
/* #ifndef DRAFT08 */
-static gint ett_iscsi_ISID = -1;
+static int ett_iscsi_ISID;
/* #endif */
-static expert_field ei_iscsi_keyvalue_invalid = EI_INIT;
-static expert_field ei_iscsi_opcode_invalid = EI_INIT;
+static expert_field ei_iscsi_keyvalue_invalid;
+static expert_field ei_iscsi_opcode_invalid;
enum iscsi_digest {
ISCSI_DIGEST_AUTO,
@@ -495,9 +497,10 @@ static const value_string iscsi_reject_reasons[] = {
* COMMAND/DATA_IN/DATA_OUT/RESPONSE matching
*/
typedef struct _iscsi_conv_data {
- guint32 data_in_frame;
- guint32 data_out_frame;
- guint32 itt;
+ uint32_t data_in_frame;
+ uint32_t data_out_frame;
+ uint32_t r2t_frame;
+ uint32_t itt;
itlq_nexus_t itlq;
} iscsi_conv_data_t;
@@ -516,15 +519,15 @@ typedef struct _iscsi_conv_data {
static address null_address = ADDRESS_INIT_NONE;
static void
-iscsi_dissect_TargetAddress(packet_info *pinfo, tvbuff_t* tvb, proto_tree *tree, guint offset)
+iscsi_dissect_TargetAddress(packet_info *pinfo, tvbuff_t* tvb, proto_tree *tree, unsigned offset)
{
address addr = ADDRESS_INIT_NONE;
- guint16 port;
+ uint16_t port;
int colon_offset;
int end_offset;
char *ip_str, *port_str;
- colon_offset = tvb_find_guint8(tvb, offset, -1, ':');
+ colon_offset = tvb_find_uint8(tvb, offset, -1, ':');
if (colon_offset == -1) {
/* RFC 7143 13.8 TargetAddress "If the TCP port is not specified,
* it is assumed to be the IANA-assigned default port for iSCSI",
@@ -534,16 +537,16 @@ iscsi_dissect_TargetAddress(packet_info *pinfo, tvbuff_t* tvb, proto_tree *tree,
}
/* We found a colon, so there's at least one byte and this won't fail. */
- if (tvb_get_guint8(tvb, offset) == '[') {
+ if (tvb_get_uint8(tvb, offset) == '[') {
offset++;
/* could be an ipv6 address */
- end_offset = tvb_find_guint8(tvb, offset, -1, ']');
+ end_offset = tvb_find_uint8(tvb, offset, -1, ']');
if (end_offset == -1) {
return;
}
/* look for the colon before the port, if any */
- colon_offset = tvb_find_guint8(tvb, end_offset, -1, ':');
+ colon_offset = tvb_find_uint8(tvb, end_offset, -1, ':');
if (colon_offset == -1) {
return;
}
@@ -569,7 +572,7 @@ iscsi_dissect_TargetAddress(packet_info *pinfo, tvbuff_t* tvb, proto_tree *tree,
}
/* Extract the port */
- end_offset = tvb_find_guint8(tvb, colon_offset, -1, ',');
+ end_offset = tvb_find_uint8(tvb, colon_offset, -1, ',');
int port_len;
if (end_offset == -1) {
port_len = tvb_reported_length_remaining(tvb, colon_offset + 1);
@@ -596,9 +599,9 @@ iscsi_dissect_TargetAddress(packet_info *pinfo, tvbuff_t* tvb, proto_tree *tree,
}
-static gint
-addTextKeys(packet_info *pinfo, proto_tree *tt, tvbuff_t *tvb, gint offset, guint32 text_len) {
- const gint limit = offset + text_len;
+static int
+addTextKeys(packet_info *pinfo, proto_tree *tt, tvbuff_t *tvb, int offset, uint32_t text_len) {
+ const int limit = offset + text_len;
tvbuff_t *keyvalue_tvb;
int len, value_offset;
@@ -609,7 +612,7 @@ addTextKeys(packet_info *pinfo, proto_tree *tt, tvbuff_t *tvb, gint offset, guin
*/
proto_tree_add_item_ret_length(tt, hf_iscsi_KeyValue, tvb, offset, -1, ENC_ASCII, &len);
keyvalue_tvb = tvb_new_subset_length(tvb, offset, len);
- value_offset = tvb_find_guint8(keyvalue_tvb, 0, len, '=');
+ value_offset = tvb_find_uint8(keyvalue_tvb, 0, len, '=');
if (value_offset == -1) {
break;
}
@@ -624,15 +627,15 @@ addTextKeys(packet_info *pinfo, proto_tree *tt, tvbuff_t *tvb, gint offset, guin
return offset;
}
-static gint
-handleHeaderDigest(iscsi_session_t *iscsi_session, proto_item *ti, tvbuff_t *tvb, guint offset, int headerLen) {
+static int
+handleHeaderDigest(iscsi_session_t *iscsi_session, proto_item *ti, tvbuff_t *tvb, unsigned offset, int headerLen) {
int available_bytes = tvb_captured_length_remaining(tvb, offset);
switch(iscsi_session->header_digest){
case ISCSI_DIGEST_CRC32:
if(available_bytes >= (headerLen + 4)) {
- guint32 crc = ~crc32c_tvb_offset_calculate(tvb, offset, headerLen, CRC32C_PRELOAD);
- guint32 sent = tvb_get_ntohl(tvb, offset + headerLen);
+ uint32_t crc = ~crc32c_tvb_offset_calculate(tvb, offset, headerLen, CRC32C_PRELOAD);
+ uint32_t sent = tvb_get_ntohl(tvb, offset + headerLen);
if(crc == sent) {
proto_tree_add_uint_format_value(ti, hf_iscsi_HeaderDigest32, tvb, offset + headerLen, 4, sent, "0x%08x (Good CRC32)", sent);
} else {
@@ -646,16 +649,16 @@ handleHeaderDigest(iscsi_session_t *iscsi_session, proto_item *ti, tvbuff_t *tvb
return offset + headerLen;
}
-static gint
-handleDataDigest(iscsi_session_t *iscsi_session, proto_item *ti, tvbuff_t *tvb, guint offset, int dataLen) {
+static int
+handleDataDigest(iscsi_session_t *iscsi_session, proto_item *ti, tvbuff_t *tvb, unsigned offset, int dataLen) {
int available_bytes = tvb_captured_length_remaining(tvb, offset);
if (dataLen > 0) {
switch (iscsi_session->data_digest){
case ISCSI_DIGEST_CRC32:
if(available_bytes >= (dataLen + 4)) {
- guint32 crc = ~crc32c_tvb_offset_calculate(tvb, offset, dataLen, CRC32C_PRELOAD);
- guint32 sent = tvb_get_ntohl(tvb, offset + dataLen);
+ uint32_t crc = ~crc32c_tvb_offset_calculate(tvb, offset, dataLen, CRC32C_PRELOAD);
+ uint32_t sent = tvb_get_ntohl(tvb, offset + dataLen);
if(crc == sent) {
proto_tree_add_uint_format_value(ti, hf_iscsi_DataDigest32, tvb, offset + dataLen, 4, sent, "0x%08x (Good CRC32)", sent);
}
@@ -672,7 +675,7 @@ handleDataDigest(iscsi_session_t *iscsi_session, proto_item *ti, tvbuff_t *tvb,
}
static int
-handleDataSegment(iscsi_session_t *iscsi_session, proto_item *ti, tvbuff_t *tvb, guint offset, guint dataSegmentLen, guint endOffset, int hf_id) {
+handleDataSegment(iscsi_session_t *iscsi_session, proto_item *ti, tvbuff_t *tvb, unsigned offset, unsigned dataSegmentLen, unsigned endOffset, int hf_id) {
if(endOffset > offset) {
int dataOffset = offset;
int dataLen = MIN(dataSegmentLen, endOffset - offset);
@@ -693,7 +696,7 @@ handleDataSegment(iscsi_session_t *iscsi_session, proto_item *ti, tvbuff_t *tvb,
}
static int
-handleDataSegmentAsTextKeys(iscsi_session_t *iscsi_session, packet_info *pinfo, proto_item *ti, tvbuff_t *tvb, guint offset, guint dataSegmentLen, guint endOffset, int digestsActive) {
+handleDataSegmentAsTextKeys(iscsi_session_t *iscsi_session, packet_info *pinfo, proto_item *ti, tvbuff_t *tvb, unsigned offset, unsigned dataSegmentLen, unsigned endOffset, int digestsActive) {
if(endOffset > offset) {
int dataOffset = offset;
int textLen = MIN(dataSegmentLen, endOffset - offset);
@@ -716,31 +719,30 @@ handleDataSegmentAsTextKeys(iscsi_session_t *iscsi_session, packet_info *pinfo,
/* Code to actually dissect the packets */
static void
// NOLINTNEXTLINE(misc-no-recursion)
-dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset, guint8 opcode, guint32 data_segment_len, iscsi_session_t *iscsi_session, conversation_t *conversation) {
-
- guint original_offset = offset;
- proto_tree *ti = NULL, *opcode_item = NULL;
- guint8 scsi_status = 0;
- gboolean S_bit=FALSE;
- gboolean A_bit=FALSE;
- guint cdb_offset = offset + 32; /* offset of CDB from start of PDU */
- guint end_offset = offset + tvb_captured_length_remaining(tvb, offset);
+dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned offset, uint8_t opcode, uint32_t data_segment_len, iscsi_session_t *iscsi_session, conversation_t *conversation) {
+
+ unsigned original_offset = offset;
+ proto_tree *ti = NULL, *opcode_item = NULL, *itm = NULL;
+ uint8_t scsi_status = 0;
+ bool S_bit=false;
+ bool A_bit=false;
+ unsigned cdb_offset = offset + 32; /* offset of CDB from start of PDU */
+ unsigned end_offset = offset + tvb_captured_length_remaining(tvb, offset);
iscsi_conv_data_t *cdata = NULL;
int paddedDataSegmentLength = data_segment_len;
- guint16 lun=0xffff;
- guint immediate_data_length=0;
- guint immediate_data_offset=0;
+ uint16_t lun=0xffff;
+ unsigned immediate_data_length=0;
+ unsigned immediate_data_offset=0;
itl_nexus_t *itl=NULL;
- guint ahs_cdb_length=0;
- guint ahs_cdb_offset=0;
- guint32 data_offset=0;
+ unsigned ahs_cdb_length=0;
+ unsigned ahs_cdb_offset=0;
+ uint32_t data_offset=0;
wmem_tree_key_t key[3];
- guint32 itt;
+ uint32_t itt;
const char* opcode_str = val_to_str_const(opcode, iscsi_opcodes, "Unknown");
if(paddedDataSegmentLength & 3)
paddedDataSegmentLength += 4 - (paddedDataSegmentLength & 3);
-
/* Make entries in Protocol column and Info column on summary display */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "iSCSI");
@@ -761,11 +763,13 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
cdata->itlq.data_length = 0;
cdata->itlq.bidir_data_length = 0;
cdata->itlq.fc_time = pinfo->abs_ts;
+ cdata->itlq.r2t_time = pinfo->abs_ts;
cdata->itlq.first_exchange_frame = 0;
cdata->itlq.last_exchange_frame = 0;
cdata->itlq.flags = 0;
cdata->itlq.alloc_len = 0;
cdata->itlq.extra_data = NULL;
+ cdata->r2t_frame = 0;
cdata->data_in_frame = 0;
cdata->data_out_frame = 0;
cdata->itt = itt;
@@ -799,25 +803,30 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
cdata->itlq.extra_data = NULL;
cdata->data_in_frame = 0;
cdata->data_out_frame = 0;
+ cdata->r2t_frame = 0;
cdata->itt = itt;
}
if (opcode == ISCSI_OPCODE_SCSI_RESPONSE ||
opcode == ISCSI_OPCODE_SCSI_DATA_IN) {
- scsi_status = tvb_get_guint8 (tvb, offset+3);
+ scsi_status = tvb_get_uint8 (tvb, offset+3);
}
if ((opcode == ISCSI_OPCODE_SCSI_RESPONSE) ||
(opcode == ISCSI_OPCODE_SCSI_DATA_IN) ||
- (opcode == ISCSI_OPCODE_SCSI_DATA_OUT)) {
+ (opcode == ISCSI_OPCODE_SCSI_DATA_OUT) ||
+ (opcode == ISCSI_OPCODE_R2T)) {
/* first time we see this packet. check if we can find the request */
switch(opcode){
case ISCSI_OPCODE_SCSI_RESPONSE:
cdata->itlq.last_exchange_frame=pinfo->num;
break;
+ case ISCSI_OPCODE_R2T:
+ cdata->r2t_frame=pinfo->num;
+ break;
case ISCSI_OPCODE_SCSI_DATA_IN:
/* a bit ugly but we need to check the S bit here */
- if(tvb_get_guint8(tvb, offset+1)&ISCSI_SCSI_DATA_FLAG_S){
+ if(tvb_get_uint8(tvb, offset+1)&ISCSI_SCSI_DATA_FLAG_S){
cdata->itlq.last_exchange_frame=pinfo->num;
}
cdata->data_in_frame=pinfo->num;
@@ -840,30 +849,30 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
for error recoverylevel 0 and when the A bit is clear in a
Data-In PDU, there will not be a LUN field in the iscsi layer.
*/
- if(tvb_get_guint8(tvb, offset+8)&0x40){
+ if(tvb_get_uint8(tvb, offset+8)&0x40){
/* volume set addressing */
- lun=tvb_get_guint8(tvb,offset+8)&0x3f;
+ lun=tvb_get_uint8(tvb,offset+8)&0x3f;
lun<<=8;
- lun|=tvb_get_guint8(tvb,offset+9);
+ lun|=tvb_get_uint8(tvb,offset+9);
} else {
- lun=tvb_get_guint8(tvb,offset+9);
+ lun=tvb_get_uint8(tvb,offset+9);
}
cdata->itlq.lun=lun;
cdata->itlq.first_exchange_frame=pinfo->num;
- itl=(itl_nexus_t *)wmem_map_lookup(iscsi_session->itl, GUINT_TO_POINTER((gulong)lun));
+ itl=(itl_nexus_t *)wmem_map_lookup(iscsi_session->itl, GUINT_TO_POINTER((unsigned long)lun));
if(!itl){
itl=wmem_new(wmem_file_scope(), itl_nexus_t);
itl->cmdset=0xff;
itl->conversation=conversation;
- wmem_map_insert(iscsi_session->itl, GUINT_TO_POINTER((gulong)lun), itl);
+ wmem_map_insert(iscsi_session->itl, GUINT_TO_POINTER((unsigned long)lun), itl);
}
}
if(!itl){
- itl=(itl_nexus_t *)wmem_map_lookup(iscsi_session->itl, GUINT_TO_POINTER((gulong)cdata->itlq.lun));
+ itl=(itl_nexus_t *)wmem_map_lookup(iscsi_session->itl, GUINT_TO_POINTER((unsigned long)cdata->itlq.lun));
}
@@ -874,46 +883,46 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
if (opcode == ISCSI_OPCODE_SCSI_RESPONSE ||
(opcode == ISCSI_OPCODE_SCSI_DATA_IN &&
- (tvb_get_guint8(tvb, offset + 1) & ISCSI_SCSI_DATA_FLAG_S))) {
- col_append_fstr (pinfo->cinfo, COL_INFO, " (%s)",
+ (tvb_get_uint8(tvb, offset + 1) & ISCSI_SCSI_DATA_FLAG_S))) {
+ col_append_fstr (pinfo->cinfo, COL_INFO, " (%s) ",
val_to_str (scsi_status, scsi_status_val, "0x%x"));
}
else if (opcode == ISCSI_OPCODE_LOGIN_RESPONSE) {
- guint16 login_status = tvb_get_ntohs(tvb, offset+36);
- col_append_fstr (pinfo->cinfo, COL_INFO, " (%s)",
+ uint16_t login_status = tvb_get_ntohs(tvb, offset+36);
+ col_append_fstr (pinfo->cinfo, COL_INFO, " (%s) ",
val_to_str (login_status, iscsi_login_status, "0x%x"));
}
else if (opcode == ISCSI_OPCODE_LOGOUT_COMMAND) {
- guint8 logoutReason;
+ uint8_t logoutReason;
if(iscsi_protocol_version == ISCSI_PROTOCOL_DRAFT08) {
- logoutReason = tvb_get_guint8(tvb, offset+11);
+ logoutReason = tvb_get_uint8(tvb, offset+11);
} else if(iscsi_protocol_version >= ISCSI_PROTOCOL_DRAFT13) {
- logoutReason = tvb_get_guint8(tvb, offset+1) & 0x7f;
+ logoutReason = tvb_get_uint8(tvb, offset+1) & 0x7f;
}
else {
- logoutReason = tvb_get_guint8(tvb, offset+23);
+ logoutReason = tvb_get_uint8(tvb, offset+23);
}
- col_append_fstr (pinfo->cinfo, COL_INFO, " (%s)",
+ col_append_fstr (pinfo->cinfo, COL_INFO, " (%s) ",
val_to_str (logoutReason, iscsi_logout_reasons, "0x%x"));
}
else if (opcode == ISCSI_OPCODE_TASK_MANAGEMENT_FUNCTION) {
- guint8 tmf = tvb_get_guint8(tvb, offset + 1) & 0x7f;
- col_append_fstr (pinfo->cinfo, COL_INFO, " (%s)",
+ uint8_t tmf = tvb_get_uint8(tvb, offset + 1) & 0x7f;
+ col_append_fstr (pinfo->cinfo, COL_INFO, " (%s) ",
val_to_str (tmf, iscsi_task_management_functions, "0x%x"));
}
else if (opcode == ISCSI_OPCODE_TASK_MANAGEMENT_FUNCTION_RESPONSE) {
- guint8 resp = tvb_get_guint8(tvb, offset + 2);
- col_append_fstr (pinfo->cinfo, COL_INFO, " (%s)",
+ uint8_t resp = tvb_get_uint8(tvb, offset + 2);
+ col_append_fstr (pinfo->cinfo, COL_INFO, " (%s) ",
val_to_str (resp, iscsi_task_management_responses, "0x%x"));
}
else if (opcode == ISCSI_OPCODE_REJECT) {
- guint8 reason = tvb_get_guint8(tvb, offset + 2);
- col_append_fstr (pinfo->cinfo, COL_INFO, " (%s)",
+ uint8_t reason = tvb_get_uint8(tvb, offset + 2);
+ col_append_fstr (pinfo->cinfo, COL_INFO, " (%s) ",
val_to_str (reason, iscsi_reject_reasons, "0x%x"));
}
else if (opcode == ISCSI_OPCODE_ASYNC_MESSAGE) {
- guint8 asyncEvent = tvb_get_guint8(tvb, offset + 36);
- col_append_fstr (pinfo->cinfo, COL_INFO, " (%s)",
+ uint8_t asyncEvent = tvb_get_uint8(tvb, offset + 36);
+ col_append_fstr (pinfo->cinfo, COL_INFO, " (%s) ",
val_to_str (asyncEvent, iscsi_asyncevents, "0x%x"));
}
}
@@ -924,7 +933,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
proto_item *tp;
/* create display subtree for the protocol */
tp = proto_tree_add_protocol_format(tree, proto_iscsi, tvb,
- offset, -1, "iSCSI (%s)",
+ offset, -1, "iSCSI (%s) ",
opcode_str);
ti = proto_item_add_subtree(tp, ett_iscsi);
}
@@ -935,7 +944,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
}
if((opcode & TARGET_OPCODE_BIT) == 0) {
/* initiator -> target */
- gint b = tvb_get_guint8(tvb, offset + 0);
+ int b = tvb_get_uint8(tvb, offset + 0);
if(iscsi_protocol_version == ISCSI_PROTOCOL_DRAFT08) {
if(opcode != ISCSI_OPCODE_SCSI_DATA_OUT &&
opcode != ISCSI_OPCODE_LOGOUT_COMMAND &&
@@ -977,9 +986,9 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
offset = handleDataSegment(iscsi_session, ti, tvb, offset, data_segment_len, end_offset, hf_iscsi_ping_data);
} else if(opcode == ISCSI_OPCODE_SCSI_COMMAND) {
/* SCSI Command */
- guint32 ahsLen = tvb_get_guint8(tvb, offset + 4) * 4;
+ uint32_t ahsLen = tvb_get_uint8(tvb, offset + 4) * 4;
{
- gint b = tvb_get_guint8(tvb, offset + 1);
+ int b = tvb_get_uint8(tvb, offset + 1);
static int * const flags[] = {
&hf_iscsi_SCSICommand_F,
&hf_iscsi_SCSICommand_R,
@@ -1009,9 +1018,9 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
proto_tree_add_item(ti, hf_iscsi_CmdSN, tvb, offset + 24, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(ti, hf_iscsi_ExpStatSN, tvb, offset + 28, 4, ENC_BIG_ENDIAN);
if(ahsLen > 0) {
- guint ahs_offset=offset+48;
- guint16 ahs_length=0;
- guint8 ahs_type=0;
+ unsigned ahs_offset=offset+48;
+ uint16_t ahs_length=0;
+ uint8_t ahs_type=0;
while(ahs_offset<(offset+48+ahsLen)){
@@ -1019,7 +1028,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
proto_tree_add_item(ti, hf_iscsi_AHS_length, tvb, ahs_offset, 2, ENC_BIG_ENDIAN);
ahs_offset+=2;
- ahs_type=tvb_get_guint8(tvb, ahs_offset);
+ ahs_type=tvb_get_uint8(tvb, ahs_offset);
proto_tree_add_item(ti, hf_iscsi_AHS_type, tvb, ahs_offset, 1, ENC_BIG_ENDIAN);
ahs_offset++;
@@ -1126,7 +1135,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
/* Login Command */
int digestsActive = 0;
{
- gint b = tvb_get_guint8(tvb, offset + 1);
+ int b = tvb_get_uint8(tvb, offset + 1);
if(iscsi_protocol_version == ISCSI_PROTOCOL_DRAFT08) {
if((b & CSG_MASK) >= ISCSI_CSG_OPERATIONAL_NEGOTIATION)
digestsActive = 1;
@@ -1198,7 +1207,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
/* Login Response */
int digestsActive = 0;
{
- gint b = tvb_get_guint8(tvb, offset + 1);
+ int b = tvb_get_uint8(tvb, offset + 1);
if(iscsi_protocol_version == ISCSI_PROTOCOL_DRAFT08) {
if((b & CSG_MASK) >= ISCSI_CSG_OPERATIONAL_NEGOTIATION)
digestsActive = 1;
@@ -1264,7 +1273,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
} else if(opcode == ISCSI_OPCODE_TEXT_COMMAND) {
/* Text Command */
{
- gint b = tvb_get_guint8(tvb, offset + 1);
+ int b = tvb_get_uint8(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);
@@ -1285,11 +1294,11 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
proto_tree_add_item(ti, hf_iscsi_CmdSN, tvb, offset + 24, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(ti, hf_iscsi_ExpStatSN, tvb, offset + 28, 4, ENC_BIG_ENDIAN);
offset = handleHeaderDigest(iscsi_session, ti, tvb, offset, 48);
- offset = handleDataSegmentAsTextKeys(iscsi_session, pinfo, ti, tvb, offset, data_segment_len, end_offset, TRUE);
+ offset = handleDataSegmentAsTextKeys(iscsi_session, pinfo, ti, tvb, offset, data_segment_len, end_offset, true);
} else if(opcode == ISCSI_OPCODE_TEXT_RESPONSE) {
/* Text Response */
{
- gint b = tvb_get_guint8(tvb, offset + 1);
+ int b = tvb_get_uint8(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);
@@ -1311,7 +1320,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
proto_tree_add_item(ti, hf_iscsi_ExpCmdSN, tvb, offset + 28, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(ti, hf_iscsi_MaxCmdSN, tvb, offset + 32, 4, ENC_BIG_ENDIAN);
offset = handleHeaderDigest(iscsi_session, ti, tvb, offset, 48);
- offset = handleDataSegmentAsTextKeys(iscsi_session, pinfo, ti, tvb, offset, data_segment_len, end_offset, TRUE);
+ offset = handleDataSegmentAsTextKeys(iscsi_session, pinfo, ti, tvb, offset, data_segment_len, end_offset, true);
} else if(opcode == ISCSI_OPCODE_SCSI_DATA_OUT) {
/* SCSI Data Out (write) */
static int * const flags[] = {
@@ -1356,7 +1365,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
&hf_iscsi_SCSIData_S,
NULL
};
- gint b;
+ int b;
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT08) {
proto_tree_add_bitmask_with_flags(ti, tvb, offset+1, hf_iscsi_Flags,
@@ -1366,13 +1375,13 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
ett_iscsi_Flags, scsi_data_in, ENC_NA, BMT_NO_APPEND);
}
- b = tvb_get_guint8(tvb, offset + 1);
+ b = tvb_get_uint8(tvb, offset + 1);
if(b&ISCSI_SCSI_DATA_FLAG_S){
- S_bit=TRUE;
+ S_bit=true;
}
if(b&ISCSI_SCSI_DATA_FLAG_A){
- A_bit=TRUE;
+ A_bit=true;
}
}
@@ -1453,7 +1462,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
/* SNACK Request */
{
#if 0
- gint b = tvb_get_guint8(tvb, offset + 1);
+ int b = tvb_get_uint8(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);
#endif
@@ -1545,7 +1554,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
offset=end_offset;
} else if(opcode == ISCSI_OPCODE_REJECT) {
proto_tree *tt;
- guint8 next_opcode;
+ uint8_t next_opcode;
/* Reject */
proto_tree_add_item(ti, hf_iscsi_Reject_Reason, tvb, offset + 2, 1, ENC_BIG_ENDIAN);
@@ -1559,7 +1568,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
proto_tree_add_item(ti, hf_iscsi_DataSN, tvb, offset + 36, 4, ENC_BIG_ENDIAN);
offset = handleHeaderDigest(iscsi_session, ti, tvb, offset, 48);
- next_opcode = tvb_get_guint8(tvb, offset) & OPCODE_MASK;
+ next_opcode = tvb_get_uint8(tvb, offset) & OPCODE_MASK;
tt = proto_tree_add_subtree(ti, tvb, offset, -1, ett_iscsi_RejectHeader, NULL, "Rejected Header");
@@ -1588,49 +1597,132 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
case ISCSI_OPCODE_SCSI_RESPONSE:
if (cdata->itlq.first_exchange_frame){
nstime_t delta_time;
- proto_tree_add_uint(ti, hf_iscsi_request_frame, tvb, 0, 0, cdata->itlq.first_exchange_frame);
+ itm = proto_tree_add_uint(ti, hf_iscsi_request_frame, tvb, 0, 0, cdata->itlq.first_exchange_frame);
+ proto_item_set_generated(itm);
nstime_delta(&delta_time, &pinfo->abs_ts, &cdata->itlq.fc_time);
- proto_tree_add_time(ti, hf_iscsi_time, tvb, 0, 0, &delta_time);
+ itm = proto_tree_add_time(ti, hf_iscsi_time, tvb, 0, 0, &delta_time);
+ proto_item_set_generated(itm);
+ }
+ if (cdata->r2t_frame) {
+ itm = proto_tree_add_uint(ti, hf_iscsi_r2t_frame, tvb, 0, 0, cdata->r2t_frame);
+ proto_item_set_generated(itm);
+ }
+ if (cdata->data_in_frame) {
+ itm = proto_tree_add_uint(ti, hf_iscsi_data_in_frame, tvb, 0, 0, cdata->data_in_frame);
+ proto_item_set_generated(itm);
+ }
+ if (cdata->data_out_frame) {
+ itm = proto_tree_add_uint(ti, hf_iscsi_data_out_frame, tvb, 0, 0, cdata->data_out_frame);
+ proto_item_set_generated(itm);
+ }
+ break;
+
+ case ISCSI_OPCODE_R2T:
+ if (cdata->itlq.first_exchange_frame) {
+ itm = proto_tree_add_uint(ti, hf_iscsi_request_frame, tvb, 0, 0, cdata->itlq.first_exchange_frame);
+ proto_item_set_generated(itm);
+ }
+ if (cdata->itlq.first_exchange_frame && (cdata->itlq.first_exchange_frame < pinfo->num)) {
+ nstime_t delta_time;
+ nstime_delta(&delta_time, &pinfo->abs_ts, &cdata->itlq.r2t_time);
+ itm = proto_tree_add_time(ti, hf_iscsi_r2t_time, tvb, 0, 0, &delta_time);
+ proto_item_set_generated(itm);
}
- if (cdata->data_in_frame)
- proto_tree_add_uint(ti, hf_iscsi_data_in_frame, tvb, 0, 0, cdata->data_in_frame);
- if (cdata->data_out_frame)
- proto_tree_add_uint(ti, hf_iscsi_data_out_frame, tvb, 0, 0, cdata->data_out_frame);
+ if (cdata->data_out_frame) {
+ itm = proto_tree_add_uint(ti, hf_iscsi_data_out_frame, tvb, 0, 0, cdata->data_out_frame);
+ proto_item_set_generated(itm);
+ }
+ if (cdata->itlq.last_exchange_frame) {
+ itm = proto_tree_add_uint(ti, hf_iscsi_response_frame, tvb, 0, 0, cdata->itlq.last_exchange_frame);
+ proto_item_set_generated(itm);
+ }
+
+ if (cdata->itlq.lun == 0xffff)
+ col_append_str (pinfo->cinfo, COL_INFO,
+ " <missing request> "
+ );
+ else
+ col_append_fstr (pinfo->cinfo, COL_INFO,
+ " LUN: 0x0%x, OK to write %u bytes (%u blocks) ",
+ cdata->itlq.lun,
+ cdata->itlq.data_length,
+ cdata->itlq.data_length>=512 ? cdata->itlq.data_length/512 : 0
+ );
break;
case ISCSI_OPCODE_SCSI_DATA_IN:
/* if we have phase collaps then we might have the
response embedded in the last DataIn segment */
if(!S_bit){
- if (cdata->itlq.first_exchange_frame)
- proto_tree_add_uint(ti, hf_iscsi_request_frame, tvb, 0, 0, cdata->itlq.first_exchange_frame);
- if (cdata->itlq.last_exchange_frame)
- proto_tree_add_uint(ti, hf_iscsi_response_frame, tvb, 0, 0, cdata->itlq.last_exchange_frame);
+ if (cdata->itlq.first_exchange_frame) {
+ itm = proto_tree_add_uint(ti, hf_iscsi_response_frame, tvb, 0, 0, cdata->itlq.last_exchange_frame);
+ proto_item_set_generated(itm);
+ }
} else {
if (cdata->itlq.first_exchange_frame){
nstime_t delta_time;
- proto_tree_add_uint(ti, hf_iscsi_request_frame, tvb, 0, 0, cdata->itlq.first_exchange_frame);
+ itm = proto_tree_add_uint(ti, hf_iscsi_request_frame, tvb, 0, 0, cdata->itlq.first_exchange_frame);
+ proto_item_set_generated(itm);
nstime_delta(&delta_time, &pinfo->abs_ts, &cdata->itlq.fc_time);
- proto_tree_add_time(ti, hf_iscsi_time, tvb, 0, 0, &delta_time);
+ itm = proto_tree_add_time(ti, hf_iscsi_time, tvb, 0, 0, &delta_time);
+ proto_item_set_generated(itm);
}
}
- if (cdata->data_out_frame)
- proto_tree_add_uint(ti, hf_iscsi_data_out_frame, tvb, 0, 0, cdata->data_out_frame);
+ if (cdata->data_out_frame) {
+ itm = proto_tree_add_uint(ti, hf_iscsi_data_out_frame, tvb, 0, 0, cdata->data_out_frame);
+ proto_item_set_generated(itm);
+ }
+
+ col_set_fence(pinfo->cinfo, COL_INFO);
+ col_append_fstr (pinfo->cinfo, COL_INFO,
+ " LUN: %u, read %u bytes (%u blocks) ",
+ cdata->itlq.lun,
+ data_segment_len,
+ data_segment_len>=512 ? data_segment_len/512 : 0
+ );
break;
case ISCSI_OPCODE_SCSI_DATA_OUT:
- if (cdata->itlq.first_exchange_frame)
- proto_tree_add_uint(ti, hf_iscsi_request_frame, tvb, 0, 0, cdata->itlq.first_exchange_frame);
- if (cdata->data_in_frame)
- proto_tree_add_uint(ti, hf_iscsi_data_in_frame, tvb, 0, 0, cdata->data_in_frame);
- if (cdata->itlq.last_exchange_frame)
- proto_tree_add_uint(ti, hf_iscsi_response_frame, tvb, 0, 0, cdata->itlq.last_exchange_frame);
+ if (cdata->itlq.first_exchange_frame) {
+ itm = proto_tree_add_uint(ti, hf_iscsi_request_frame, tvb, 0, 0, cdata->itlq.first_exchange_frame);
+ proto_item_set_generated(itm);
+ }
+ if (cdata->r2t_frame) {
+ itm = proto_tree_add_uint(ti, hf_iscsi_r2t_frame, tvb, 0, 0, cdata->r2t_frame);
+ proto_item_set_generated(itm);
+ }
+ if (cdata->data_in_frame) {
+ itm = proto_tree_add_uint(ti, hf_iscsi_data_in_frame, tvb, 0, 0, cdata->data_in_frame);
+ proto_item_set_generated(itm);
+ }
+ if (cdata->itlq.last_exchange_frame) {
+ itm = proto_tree_add_uint(ti, hf_iscsi_response_frame, tvb, 0, 0, cdata->itlq.last_exchange_frame);
+ proto_item_set_generated(itm);
+ }
+
+ col_set_fence(pinfo->cinfo, COL_INFO);
+ col_append_fstr (pinfo->cinfo, COL_INFO,
+ " LUN: 0x0%x, wrote %u bytes (%u blocks) ",
+ cdata->itlq.lun,
+ data_segment_len,
+ data_segment_len>=512 ? data_segment_len/512 : 0
+ );
break;
case ISCSI_OPCODE_SCSI_COMMAND:
- if (cdata->data_in_frame)
- proto_tree_add_uint(ti, hf_iscsi_data_in_frame, tvb, 0, 0, cdata->data_in_frame);
- if (cdata->data_out_frame)
- proto_tree_add_uint(ti, hf_iscsi_data_out_frame, tvb, 0, 0, cdata->data_out_frame);
- if (cdata->itlq.last_exchange_frame)
- proto_tree_add_uint(ti, hf_iscsi_response_frame, tvb, 0, 0, cdata->itlq.last_exchange_frame);
+ if (cdata->r2t_frame) {
+ itm = proto_tree_add_uint(ti, hf_iscsi_r2t_frame, tvb, 0, 0, cdata->r2t_frame);
+ proto_item_set_generated(itm);
+ }
+ if (cdata->data_in_frame) {
+ itm = proto_tree_add_uint(ti, hf_iscsi_data_in_frame, tvb, 0, 0, cdata->data_in_frame);
+ proto_item_set_generated(itm);
+ }
+ if (cdata->data_out_frame) {
+ itm = proto_tree_add_uint(ti, hf_iscsi_data_out_frame, tvb, 0, 0, cdata->data_out_frame);
+ proto_item_set_generated(itm);
+ }
+ if (cdata->itlq.last_exchange_frame) {
+ itm = proto_tree_add_uint(ti, hf_iscsi_response_frame, tvb, 0, 0, cdata->itlq.last_exchange_frame);
+ proto_item_set_generated(itm);
+ }
break;
}
@@ -1648,12 +1740,12 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
tvb_len=tvb_captured_length_remaining(tvb, cdb_offset);
tvb_rlen=tvb_reported_length_remaining(tvb, cdb_offset);
if(ahs_cdb_length && ahs_cdb_length<1024){
- guint8 *cdb_buf;
+ uint8_t *cdb_buf;
/* We have a variable length CDB where bytes >16 is transported
* in the AHS.
*/
- cdb_buf=(guint8 *)wmem_alloc(pinfo->pool, 16+ahs_cdb_length);
+ cdb_buf=(uint8_t *)wmem_alloc(pinfo->pool, 16+ahs_cdb_length);
/* the 16 first bytes of the cdb */
tvb_memcpy(tvb, cdb_buf, cdb_offset, 16);
/* the remainder of the cdb from the ahs */
@@ -1688,7 +1780,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
tvb_rlen=immediate_data_length;
data_tvb=tvb_new_subset_length_caplen(tvb, immediate_data_offset, tvb_len, tvb_rlen);
dissect_scsi_payload (data_tvb, pinfo, tree,
- TRUE,
+ true,
&cdata->itlq, itl,
0);
}
@@ -1748,14 +1840,14 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
}
static int
-dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean check_port) {
+dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, bool check_port) {
/* Set up structures needed to add the protocol subtree and manage it */
- guint offset = 0;
- guint32 available_bytes = tvb_captured_length(tvb);
+ unsigned offset = 0;
+ uint32_t available_bytes = tvb_captured_length(tvb);
int digestsActive = 1;
conversation_t *conversation = NULL;
iscsi_session_t *iscsi_session=NULL;
- guint8 opcode, tmpbyte;
+ uint8_t opcode, tmpbyte;
if (available_bytes < 48) {
/* heuristic already rejected the packet if size < 48,
@@ -1765,7 +1857,7 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
return -1;
}
- opcode = tvb_get_guint8(tvb, offset + 0);
+ opcode = tvb_get_uint8(tvb, offset + 0);
opcode &= OPCODE_MASK;
/* heuristics to verify that the packet looks sane. the heuristics
@@ -1780,29 +1872,29 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
switch(opcode){
case ISCSI_OPCODE_NOP_IN:
/* top two bits of byte 0 must be 0 */
- if(tvb_get_guint8(tvb, offset+0)&0xc0){
+ if(tvb_get_uint8(tvb, offset+0)&0xc0){
return 0;
}
/* byte 1 must be 0x80 */
- if(tvb_get_guint8(tvb, offset+1)!=0x80){
+ if(tvb_get_uint8(tvb, offset+1)!=0x80){
return 0;
}
/* bytes 2 and 3 must be 0 */
- if(tvb_get_guint8(tvb, offset+2)||tvb_get_guint8(tvb, offset+3)){
+ if(tvb_get_uint8(tvb, offset+2)||tvb_get_uint8(tvb, offset+3)){
return 0;
}
break;
case ISCSI_OPCODE_NOP_OUT:
/* top bit of byte 0 must be 0 */
- if(tvb_get_guint8(tvb, offset+0)&0x80){
+ if(tvb_get_uint8(tvb, offset+0)&0x80){
return 0;
}
/* byte 1 must be 0x80 */
- if(tvb_get_guint8(tvb, offset+1)!=0x80){
+ if(tvb_get_uint8(tvb, offset+1)!=0x80){
return 0;
}
/* bytes 2 and 3 must be 0 */
- if(tvb_get_guint8(tvb, offset+2)||tvb_get_guint8(tvb, offset+3)){
+ if(tvb_get_uint8(tvb, offset+2)||tvb_get_uint8(tvb, offset+3)){
return 0;
}
/* assume ITT and TTT must always be non NULL (ok they can be NULL
@@ -1822,14 +1914,14 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
break;
case ISCSI_OPCODE_LOGIN_COMMAND:
/* top two bits in byte 0 must be 0x40 */
- if((tvb_get_guint8(tvb, offset+0)&0xc0)!=0x40){
+ if((tvb_get_uint8(tvb, offset+0)&0xc0)!=0x40){
return 0;
}
/* both the T and C bits can not be set
* and the two reserved bits in byte 1 must be 0
*/
- tmpbyte=tvb_get_guint8(tvb, offset+1);
+ tmpbyte=tvb_get_uint8(tvb, offset+1);
switch(tmpbyte&0xf0){
case 0x80:
case 0x40:
@@ -1853,14 +1945,14 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
break;
case ISCSI_OPCODE_LOGIN_RESPONSE:
/* top two bits in byte 0 must be 0 */
- if(tvb_get_guint8(tvb, offset+0)&0xc0){
+ if(tvb_get_uint8(tvb, offset+0)&0xc0){
return 0;
}
/* both the T and C bits can not be set
* and the two reserved bits in byte 1 must be 0
*/
- tmpbyte=tvb_get_guint8(tvb, offset+1);
+ tmpbyte=tvb_get_uint8(tvb, offset+1);
switch(tmpbyte&0xf0){
case 0x80:
case 0x40:
@@ -1896,11 +1988,11 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
break;
case ISCSI_OPCODE_TASK_MANAGEMENT_FUNCTION:
/* top bit in byte 0 must be 0 */
- if(tvb_get_guint8(tvb, offset+0)&0x80){
+ if(tvb_get_uint8(tvb, offset+0)&0x80){
return 0;
}
/* top bit in byte 1 must be set */
- tmpbyte=tvb_get_guint8(tvb, offset+1);
+ tmpbyte=tvb_get_uint8(tvb, offset+1);
if(!(tmpbyte&0x80)){
return 0;
}
@@ -1919,20 +2011,20 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
break;
case ISCSI_OPCODE_TASK_MANAGEMENT_FUNCTION_RESPONSE:
/* top two bits in byte 0 must be 0 */
- if(tvb_get_guint8(tvb, offset+0)&0xc0){
+ if(tvb_get_uint8(tvb, offset+0)&0xc0){
return 0;
}
/* byte 1 must be 0x80 */
- if(tvb_get_guint8(tvb, offset+1)!=0x80){
+ if(tvb_get_uint8(tvb, offset+1)!=0x80){
return 0;
}
/* response must be 0-6 or 255 */
- tmpbyte=tvb_get_guint8(tvb,offset+2);
+ tmpbyte=tvb_get_uint8(tvb,offset+2);
if(tmpbyte>6 && tmpbyte<255){
return 0;
}
/* byte 3 must be 0 */
- if(tvb_get_guint8(tvb,offset+3)){
+ if(tvb_get_uint8(tvb,offset+3)){
return 0;
}
/* ahs and dsl as well as the 32bit words at offsets 8, 12, 20, 36
@@ -1950,11 +2042,11 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
break;
case ISCSI_OPCODE_LOGOUT_COMMAND:
/* top bit in byte 0 must be 0 */
- if(tvb_get_guint8(tvb, offset+0)&0x80){
+ if(tvb_get_uint8(tvb, offset+0)&0x80){
return 0;
}
/* top bit in byte 1 must be set */
- tmpbyte=tvb_get_guint8(tvb, offset+1);
+ tmpbyte=tvb_get_uint8(tvb, offset+1);
if(!(tmpbyte&0x80)){
return 0;
}
@@ -1981,11 +2073,11 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
break;
case ISCSI_OPCODE_SNACK_REQUEST:
/* top two bits in byte 0 must be 0 */
- if(tvb_get_guint8(tvb, offset+0)&0xc0){
+ if(tvb_get_uint8(tvb, offset+0)&0xc0){
return 0;
}
/* top 4 bits in byte 1 must be 0x80 */
- tmpbyte=tvb_get_guint8(tvb, offset+1);
+ tmpbyte=tvb_get_uint8(tvb, offset+1);
if((tmpbyte&0xf0)!=0x80){
return 0;
}
@@ -2028,11 +2120,11 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
break;
case ISCSI_OPCODE_R2T:
/* top two bits in byte 0 must be 0 */
- if(tvb_get_guint8(tvb, offset+0)&0xc0){
+ if(tvb_get_uint8(tvb, offset+0)&0xc0){
return 0;
}
/* byte 1 must be 0x80 */
- if(tvb_get_guint8(tvb, offset+1)!=0x80){
+ if(tvb_get_uint8(tvb, offset+1)!=0x80){
return 0;
}
/* bytes 2,3 must be null */
@@ -2050,19 +2142,19 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
break;
case ISCSI_OPCODE_REJECT:
/* top two bits in byte 0 must be 0 */
- if(tvb_get_guint8(tvb, offset+0)&0xc0){
+ if(tvb_get_uint8(tvb, offset+0)&0xc0){
return 0;
}
/* byte 1 must be 0x80 */
- if(tvb_get_guint8(tvb, offset+1)!=0x80){
+ if(tvb_get_uint8(tvb, offset+1)!=0x80){
return 0;
}
/* reason must be known */
- if(!try_val_to_str(tvb_get_guint8(tvb,offset+2), iscsi_reject_reasons)){
+ if(!try_val_to_str(tvb_get_uint8(tvb,offset+2), iscsi_reject_reasons)){
return 0;
}
/* byte 3 must be 0 */
- if(tvb_get_guint8(tvb, offset+3)){
+ if(tvb_get_uint8(tvb, offset+3)){
return 0;
}
/* the 32bit words at offsets 8, 12, 20, 40, 44
@@ -2082,13 +2174,13 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
break;
case ISCSI_OPCODE_TEXT_COMMAND:
/* top bit in byte 0 must be 0 */
- if(tvb_get_guint8(tvb, offset+0)&0x80){
+ if(tvb_get_uint8(tvb, offset+0)&0x80){
return 0;
}
/* one of the F and C bits must be set but not both
* low 6 bits in byte 1 must be 0
*/
- switch(tvb_get_guint8(tvb,offset+1)){
+ switch(tvb_get_uint8(tvb,offset+1)){
case 0x80:
case 0x40:
break;
@@ -2111,13 +2203,13 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
break;
case ISCSI_OPCODE_TEXT_RESPONSE:
/* top two bits in byte 0 must be 0 */
- if(tvb_get_guint8(tvb, offset+0)&0xc0){
+ if(tvb_get_uint8(tvb, offset+0)&0xc0){
return 0;
}
/* one of the F and C bits must be set but not both
* low 6 bits in byte 1 must be 0
*/
- switch(tvb_get_guint8(tvb,offset+1)){
+ switch(tvb_get_uint8(tvb,offset+1)){
case 0x80:
case 0x40:
break;
@@ -2139,11 +2231,11 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
break;
case ISCSI_OPCODE_SCSI_COMMAND:
/* top bit in byte 0 must be 0 */
- if(tvb_get_guint8(tvb, offset+0)&0x80){
+ if(tvb_get_uint8(tvb, offset+0)&0x80){
return 0;
}
/* reserved bits in byte 1 must be 0 */
- if(tvb_get_guint8(tvb, offset+1)&0x18){
+ if(tvb_get_uint8(tvb, offset+1)&0x18){
return 0;
}
/* bytes 2,3 must be null */
@@ -2152,18 +2244,18 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
}
/* if expected data transfer length is set, W and/or R have to be set */
if(tvb_get_ntohl(tvb,offset+20)){
- if(!(tvb_get_guint8(tvb, offset+1)&0x60)){
+ if(!(tvb_get_uint8(tvb, offset+1)&0x60)){
return 0;
}
}
break;
case ISCSI_OPCODE_SCSI_RESPONSE:
/* top two bits in byte 0 must be 0 */
- if(tvb_get_guint8(tvb, offset+0)&0xc0){
+ if(tvb_get_uint8(tvb, offset+0)&0xc0){
return 0;
}
/* top bit in byte 1 must be 1 */
- tmpbyte=tvb_get_guint8(tvb,offset+1);
+ tmpbyte=tvb_get_uint8(tvb,offset+1);
if(!(tmpbyte&0x80)){
return 0;
}
@@ -2172,7 +2264,7 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
return 0;
}
/* status must be known */
- if(!try_val_to_str(tvb_get_guint8(tvb,offset+3), scsi_status_val)){
+ if(!try_val_to_str(tvb_get_uint8(tvb,offset+3), scsi_status_val)){
return 0;
}
/* the 32bit words at offsets 8, 12
@@ -2185,11 +2277,11 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
break;
case ISCSI_OPCODE_ASYNC_MESSAGE:
/* top two bits in byte 0 must be 0 */
- if(tvb_get_guint8(tvb, offset+0)&0xc0){
+ if(tvb_get_uint8(tvb, offset+0)&0xc0){
return 0;
}
/* byte 1 must be 0x80 */
- if(tvb_get_guint8(tvb, offset+1)!=0x80){
+ if(tvb_get_uint8(tvb, offset+1)!=0x80){
return 0;
}
/* bytes 2,3 must be null */
@@ -2210,19 +2302,19 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
break;
case ISCSI_OPCODE_LOGOUT_RESPONSE:
/* top two bits in byte 0 must be 0 */
- if(tvb_get_guint8(tvb, offset+0)&0xc0){
+ if(tvb_get_uint8(tvb, offset+0)&0xc0){
return 0;
}
/* byte 1 must be 0x80 */
- if(tvb_get_guint8(tvb, offset+1)!=0x80){
+ if(tvb_get_uint8(tvb, offset+1)!=0x80){
return 0;
}
/* response must be known */
- if(!try_val_to_str(tvb_get_guint8(tvb,offset+2), iscsi_logout_response)){
+ if(!try_val_to_str(tvb_get_uint8(tvb,offset+2), iscsi_logout_response)){
return 0;
}
/* byte 3 must be 0 */
- if(tvb_get_guint8(tvb,offset+3)){
+ if(tvb_get_uint8(tvb,offset+3)){
return 0;
}
/* ahs and dsl as well as the 32bit words at offsets 8, 12, 20, 36
@@ -2239,11 +2331,11 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
break;
case ISCSI_OPCODE_SCSI_DATA_OUT:
/* top two bits in byte 0 must be 0 */
- if(tvb_get_guint8(tvb, offset+0)&0xc0){
+ if(tvb_get_uint8(tvb, offset+0)&0xc0){
return 0;
}
/* low 7 bits in byte 1 must be 0 */
- if(tvb_get_guint8(tvb,offset+1)&0x7f){
+ if(tvb_get_uint8(tvb,offset+1)&0x7f){
return 0;
}
/* bytes 2,3 must be null */
@@ -2261,15 +2353,15 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
break;
case ISCSI_OPCODE_SCSI_DATA_IN:
/* top two bits in byte 0 must be 0 */
- if(tvb_get_guint8(tvb, offset+0)&0xc0){
+ if(tvb_get_uint8(tvb, offset+0)&0xc0){
return 0;
}
/* reserved bits in byte 1 must be 0 */
- if(tvb_get_guint8(tvb,offset+1)&0x38){
+ if(tvb_get_uint8(tvb,offset+1)&0x38){
return 0;
}
/* byte 2 must be reserved */
- if(tvb_get_guint8(tvb,offset+2)){
+ if(tvb_get_uint8(tvb,offset+2)){
return 0;
}
break;
@@ -2287,15 +2379,15 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
/* process multiple iSCSI PDUs per packet */
while(available_bytes >= 48 || (iscsi_desegment && available_bytes >= 8)) {
- guint32 data_segment_len;
- guint32 pduLen = 48;
- guint8 secondPduByte = tvb_get_guint8(tvb, offset + 1);
- int badPdu = FALSE;
- guint8 ahsLen=0;
- guint32 data_segment_offset, data_segment_len_padded;
+ uint32_t data_segment_len;
+ uint32_t pduLen = 48;
+ uint8_t secondPduByte = tvb_get_uint8(tvb, offset + 1);
+ bool badPdu = false;
+ uint8_t ahsLen=0;
+ uint32_t data_segment_offset, data_segment_len_padded;
/* mask out any extra bits in the opcode byte */
- opcode = tvb_get_guint8(tvb, offset + 0);
+ opcode = tvb_get_uint8(tvb, offset + 0);
opcode &= OPCODE_MASK;
if(opcode == ISCSI_OPCODE_TASK_MANAGEMENT_FUNCTION ||
@@ -2309,30 +2401,30 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
data_segment_len = tvb_get_ntohl(tvb, offset + 4) & 0x00ffffff;
if (!try_val_to_str(opcode, iscsi_opcodes)) {
- badPdu = TRUE;
+ badPdu = true;
}
if(!badPdu && check_port) {
- badPdu = TRUE;
+ badPdu = true;
if ((opcode & TARGET_OPCODE_BIT) && value_is_in_range(global_iscsi_port_range, pinfo->srcport)) {
- badPdu = FALSE;
+ badPdu = false;
}
if (!(opcode & TARGET_OPCODE_BIT) && value_is_in_range(global_iscsi_port_range, pinfo->destport)) {
- badPdu = FALSE;
+ badPdu = false;
}
if ((opcode & TARGET_OPCODE_BIT) && pinfo->srcport == iscsi_system_port) {
- badPdu = FALSE;
+ badPdu = false;
}
if (!(opcode & TARGET_OPCODE_BIT) && pinfo->destport == iscsi_system_port) {
- badPdu = FALSE;
+ badPdu = false;
}
}
if(!badPdu && enable_bogosity_filter) {
/* try and distinguish between data and real headers */
if(data_segment_len > bogus_pdu_data_length_threshold) {
- badPdu = TRUE;
+ badPdu = true;
}
else if(demand_good_f_bit &&
!(secondPduByte & 0x80) &&
@@ -2346,7 +2438,7 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
opcode == ISCSI_OPCODE_ASYNC_MESSAGE ||
opcode == ISCSI_OPCODE_SNACK_REQUEST ||
opcode == ISCSI_OPCODE_REJECT)) {
- badPdu = TRUE;
+ badPdu = true;
} else if(opcode==ISCSI_OPCODE_NOP_OUT) {
/* TransferTag for NOP-Out should either be -1 or
the tag value we want for a response.
@@ -2354,7 +2446,7 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
datablock.
*/
if(tvb_get_ntohl(tvb, offset+20)==0){
- badPdu = TRUE;
+ badPdu = true;
}
}
}
@@ -2377,7 +2469,7 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
if(opcode == ISCSI_OPCODE_SCSI_COMMAND) {
/* ahsLen */
- ahsLen = tvb_get_guint8(tvb, offset + 4);
+ ahsLen = tvb_get_uint8(tvb, offset + 4);
pduLen += ahsLen * 4;
}
@@ -2408,9 +2500,9 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
conversation_set_dissector(conversation, iscsi_handle);
}
/* try to autodetect if header digest is used or not */
- if (digestsActive && (available_bytes >= (guint32) (48+4+ahsLen*4)) &&
+ if (digestsActive && (available_bytes >= (uint32_t) (48+4+ahsLen*4)) &&
(iscsi_session->header_digest == ISCSI_DIGEST_AUTO)) {
- guint32 crc;
+ uint32_t crc;
/* we have enough data to test if HeaderDigest is enabled */
crc= ~crc32c_tvb_offset_calculate(tvb, offset, 48+ahsLen*4, CRC32C_PRELOAD);
if(crc==tvb_get_ntohl(tvb,48+ahsLen*4)){
@@ -2443,7 +2535,7 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
if (digestsActive &&
(available_bytes >= data_segment_offset + data_segment_len_padded + 4) &&
(iscsi_session->data_digest == ISCSI_DIGEST_AUTO)) {
- guint32 crc;
+ uint32_t crc;
/* we have enough data to test if DataDigest is enabled */
crc = ~crc32c_tvb_offset_calculate(tvb, data_segment_offset, data_segment_len_padded, CRC32C_PRELOAD);
if (crc == tvb_get_ntohl(tvb, data_segment_offset + data_segment_len_padded)) {
@@ -2497,7 +2589,7 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
a PDU.
*/
if(!pinfo->fd->visited){
- if(pduLen>(guint32)tvb_reported_length_remaining(tvb, offset)){
+ if(pduLen>(uint32_t)tvb_reported_length_remaining(tvb, offset)){
pinfo->want_pdu_tracking=2;
pinfo->bytes_until_next_pdu=pduLen-tvb_reported_length_remaining(tvb, offset);
}
@@ -2526,7 +2618,7 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
*/
static int
dissect_iscsi_handle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) {
- return dissect_iscsi(tvb, pinfo, tree, FALSE);
+ return dissect_iscsi(tvb, pinfo, tree, false);
}
/* This is called through the heuristic handler.
@@ -2534,18 +2626,18 @@ dissect_iscsi_handle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *
setting for iSCSI in order to reduce the number of
false positives.
*/
-static gboolean
+static bool
dissect_iscsi_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) {
- guint32 available_bytes = tvb_captured_length(tvb);
+ uint32_t available_bytes = tvb_captured_length(tvb);
/* quick check to see if the packet is long enough to contain the
* minimum amount of information we need */
if (available_bytes < 48 ){
/* no, so give up */
- return FALSE;
+ return false;
}
- return dissect_iscsi(tvb, pinfo, tree, TRUE) != 0;
+ return dissect_iscsi(tvb, pinfo, tree, true) != 0;
}
@@ -2567,27 +2659,37 @@ proto_register_iscsi(void)
{ &hf_iscsi_request_frame,
{ "Request in", "iscsi.request_frame",
FT_FRAMENUM, BASE_NONE, NULL, 0,
- "The request to this transaction is in this frame", HFILL }},
+ "Frame number of the request", HFILL }},
{ &hf_iscsi_time,
{ "Time from request", "iscsi.time",
FT_RELATIVE_TIME, BASE_NONE, NULL, 0,
"Time between the Command and the Response", HFILL }},
+ { &hf_iscsi_r2t_frame,
+ { "Ready To Transfer", "iscsi.r2t_frame",
+ FT_FRAMENUM, BASE_NONE, NULL, 0,
+ "Frame number of the R2T", HFILL }},
+
+ { &hf_iscsi_r2t_time,
+ { "Time from request to R2T", "iscsi.r2t_time",
+ FT_RELATIVE_TIME, BASE_NONE, NULL, 0,
+ "Time from the client's request to the server's R2T", HFILL }},
+
{ &hf_iscsi_data_in_frame,
{ "Data In in", "iscsi.data_in_frame",
FT_FRAMENUM, BASE_NONE, NULL, 0,
- "The Data In for this transaction is in this frame", HFILL }},
+ "Frame number of the final Data In (could be multiple)", HFILL }},
{ &hf_iscsi_data_out_frame,
- { "Data Out in", "iscsi.data_out_frame",
+ { "Final Data Out in", "iscsi.data_out_frame",
FT_FRAMENUM, BASE_NONE, NULL, 0,
- "The Data Out for this transaction is in this frame", HFILL }},
+ "Frame number of the final Data Out (could be multiple)", HFILL }},
{ &hf_iscsi_response_frame,
{ "Response in", "iscsi.response_frame",
FT_FRAMENUM, BASE_NONE, NULL, 0,
- "The response to this transaction is in this frame", HFILL }},
+ "Frame number of the response", HFILL }},
{ &hf_iscsi_AHS_length,
{ "AHS Length", "iscsi.ahs.length",
FT_UINT16, BASE_DEC, NULL, 0,
@@ -3066,7 +3168,7 @@ proto_register_iscsi(void)
};
/* Setup protocol subtree array */
- static gint *ett[] = {
+ static int *ett[] = {
&ett_iscsi,
&ett_iscsi_KeyValues,
&ett_iscsi_CDB,
@@ -3102,7 +3204,7 @@ proto_register_iscsi(void)
"The iSCSI protocol version",
&iscsi_protocol_version,
iscsi_protocol_versions,
- FALSE);
+ false);
prefs_register_bool_preference(iscsi_module,
"desegment_iscsi_messages",