2009-10-08 15:10:43 +00:00
|
|
|
/* TODO for the cases where one just can not autodetect whether header digest
|
|
|
|
is used or not we might need a new preference
|
|
|
|
HeaderDigest :
|
2005-01-29 04:44:40 +00:00
|
|
|
Automatic (default)
|
|
|
|
None
|
|
|
|
CRC32
|
|
|
|
*/
|
2009-10-08 15:10:43 +00:00
|
|
|
|
2001-05-30 18:52:38 +00:00
|
|
|
/* packet-iscsi.c
|
|
|
|
* Routines for iSCSI dissection
|
|
|
|
* Copyright 2001, Eurologic and Mark Burton <markb@ordern.com>
|
2004-02-18 09:10:02 +00:00
|
|
|
* 2004 Request/Response matching and Service Response Time: ronnie sahlberg
|
2001-05-30 18:52:38 +00:00
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2001-05-30 18:52:38 +00:00
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2001-05-30 18:52:38 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2001-05-30 18:52:38 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2001-05-30 18:52:38 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2010-04-29 08:41:23 +00:00
|
|
|
#include <stdio.h>
|
2001-05-30 18:52:38 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
2004-09-27 22:55:15 +00:00
|
|
|
#include <epan/prefs.h>
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/conversation.h>
|
2002-01-10 01:28:45 +00:00
|
|
|
#include "packet-scsi.h"
|
2009-08-21 20:25:24 +00:00
|
|
|
#include <epan/nstime.h>
|
2005-08-12 23:00:01 +00:00
|
|
|
#include <epan/emem.h>
|
2011-08-11 21:59:02 +00:00
|
|
|
#include <epan/range.h>
|
2011-08-31 09:00:54 +00:00
|
|
|
#include <wsutil/crc32.h>
|
2001-05-30 18:52:38 +00:00
|
|
|
|
2002-05-14 21:35:17 +00:00
|
|
|
/* the absolute values of these constants don't matter as long as
|
|
|
|
* latter revisions of the protocol are assigned a larger number */
|
|
|
|
#define ISCSI_PROTOCOL_DRAFT08 1
|
|
|
|
#define ISCSI_PROTOCOL_DRAFT09 2
|
|
|
|
#define ISCSI_PROTOCOL_DRAFT11 3
|
2002-05-15 19:32:22 +00:00
|
|
|
#define ISCSI_PROTOCOL_DRAFT12 4
|
2002-06-24 07:57:50 +00:00
|
|
|
#define ISCSI_PROTOCOL_DRAFT13 5
|
2002-05-14 21:35:17 +00:00
|
|
|
|
|
|
|
static enum_val_t iscsi_protocol_versions[] = {
|
2004-05-24 02:25:21 +00:00
|
|
|
{ "draft-08", "Draft 08", ISCSI_PROTOCOL_DRAFT08 },
|
|
|
|
{ "draft-09", "Draft 09", ISCSI_PROTOCOL_DRAFT09 },
|
|
|
|
{ "draft-11", "Draft 11", ISCSI_PROTOCOL_DRAFT11 },
|
|
|
|
{ "draft-12", "Draft 12", ISCSI_PROTOCOL_DRAFT12 },
|
|
|
|
{ "draft-13", "Draft 13", ISCSI_PROTOCOL_DRAFT13 },
|
|
|
|
{ NULL, NULL, 0 }
|
2002-05-14 21:35:17 +00:00
|
|
|
};
|
|
|
|
|
2006-09-30 09:34:58 +00:00
|
|
|
static const value_string ahs_type_vals[] = {
|
|
|
|
{1, "Extended CDB"},
|
|
|
|
{2, "Expected Bidirection Read Data Length"},
|
|
|
|
{0, NULL}
|
|
|
|
};
|
|
|
|
|
2005-04-30 16:14:57 +00:00
|
|
|
static dissector_handle_t iscsi_handle=NULL;
|
|
|
|
|
2002-06-24 07:57:50 +00:00
|
|
|
static gint iscsi_protocol_version = ISCSI_PROTOCOL_DRAFT13;
|
2002-05-14 21:35:17 +00:00
|
|
|
|
2001-10-21 19:04:20 +00:00
|
|
|
static gboolean iscsi_desegment = TRUE;
|
2001-10-21 17:20:10 +00:00
|
|
|
|
2001-11-04 00:58:23 +00:00
|
|
|
static int demand_good_f_bit = FALSE;
|
2001-05-30 18:52:38 +00:00
|
|
|
static int enable_bogosity_filter = TRUE;
|
2001-10-21 17:20:10 +00:00
|
|
|
static guint32 bogus_pdu_data_length_threshold = 256 * 1024;
|
|
|
|
|
|
|
|
static int enableDataDigests = FALSE;
|
|
|
|
|
|
|
|
static int dataDigestIsCRC32 = TRUE;
|
|
|
|
|
2005-07-09 00:53:17 +00:00
|
|
|
static guint dataDigestSize = 4;
|
2001-05-30 18:52:38 +00:00
|
|
|
|
2011-11-09 02:48:51 +00:00
|
|
|
#define TCP_PORT_ISCSI_RANGE "3260"
|
2011-08-11 21:59:02 +00:00
|
|
|
|
|
|
|
static range_t *global_iscsi_port_range;
|
2010-05-18 22:00:17 +00:00
|
|
|
static guint iscsi_system_port = 860;
|
2001-06-28 08:05:26 +00:00
|
|
|
|
2001-05-30 18:52:38 +00:00
|
|
|
/* Initialize the protocol and registered fields */
|
|
|
|
static int proto_iscsi = -1;
|
2003-06-21 10:16:18 +00:00
|
|
|
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;
|
2006-09-30 09:34:58 +00:00
|
|
|
static int hf_iscsi_AHS_length = -1;
|
|
|
|
static int hf_iscsi_AHS_type = -1;
|
2006-10-08 04:13:18 +00:00
|
|
|
static int hf_iscsi_AHS_blob = -1;
|
|
|
|
static int hf_iscsi_AHS_read_data_length = -1;
|
|
|
|
static int hf_iscsi_AHS_extended_cdb = -1;
|
2001-06-28 08:05:26 +00:00
|
|
|
static int hf_iscsi_Padding = -1;
|
2001-10-19 20:53:14 +00:00
|
|
|
static int hf_iscsi_ping_data = -1;
|
|
|
|
static int hf_iscsi_immediate_data = -1;
|
2007-01-23 09:38:41 +00:00
|
|
|
static int hf_iscsi_async_event_data = -1;
|
2002-05-14 21:35:17 +00:00
|
|
|
static int hf_iscsi_vendor_specific_data = -1;
|
2001-05-30 18:52:38 +00:00
|
|
|
static int hf_iscsi_Opcode = -1;
|
2001-05-31 19:20:41 +00:00
|
|
|
static int hf_iscsi_Flags = -1;
|
2001-06-28 08:05:26 +00:00
|
|
|
static int hf_iscsi_HeaderDigest32 = -1;
|
2001-10-21 17:20:10 +00:00
|
|
|
static int hf_iscsi_DataDigest = -1;
|
|
|
|
static int hf_iscsi_DataDigest32 = -1;
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #ifdef DRAFT08 */
|
2001-05-30 18:52:38 +00:00
|
|
|
static int hf_iscsi_X = -1;
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #endif */
|
2001-05-30 18:52:38 +00:00
|
|
|
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_LUN = -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;
|
2001-10-19 20:53:14 +00:00
|
|
|
static int hf_iscsi_SCSIResponse_ResidualCount = -1;
|
|
|
|
static int hf_iscsi_SCSIResponse_Response = -1;
|
|
|
|
static int hf_iscsi_SCSIResponse_Status = -1;
|
2002-01-21 22:23:38 +00:00
|
|
|
static int hf_iscsi_SenseLength = -1;
|
2001-05-30 18:52:38 +00:00
|
|
|
static int hf_iscsi_SCSIData_F = -1;
|
2002-05-15 19:32:22 +00:00
|
|
|
static int hf_iscsi_SCSIData_A = -1;
|
2001-05-30 18:52:38 +00:00
|
|
|
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;
|
2001-10-19 20:53:14 +00:00
|
|
|
static int hf_iscsi_VersionActive = -1;
|
2001-05-30 18:52:38 +00:00
|
|
|
static int hf_iscsi_CID = -1;
|
2002-05-14 21:35:17 +00:00
|
|
|
static int hf_iscsi_ISID8 = -1;
|
2001-05-30 18:52:38 +00:00
|
|
|
static int hf_iscsi_ISID = -1;
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #if defined(DRAFT09) */
|
2002-04-04 10:20:24 +00:00
|
|
|
static int hf_iscsi_ISID_Type = -1;
|
|
|
|
static int hf_iscsi_ISID_NamingAuthority = -1;
|
|
|
|
static int hf_iscsi_ISID_Qualifier = -1;
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #elif !defined(DRAFT08) */
|
2002-03-20 21:28:14 +00:00
|
|
|
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;
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #endif */
|
2001-05-30 18:52:38 +00:00
|
|
|
static int hf_iscsi_TSID = -1;
|
2002-05-15 19:32:22 +00:00
|
|
|
static int hf_iscsi_TSIH = -1;
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #ifdef DRAFT09 */
|
2002-01-21 22:23:38 +00:00
|
|
|
static int hf_iscsi_Login_X = -1;
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #endif */
|
2002-09-26 08:20:22 +00:00
|
|
|
static int hf_iscsi_Login_C = -1;
|
2001-10-19 20:53:14 +00:00
|
|
|
static int hf_iscsi_Login_T = -1;
|
|
|
|
static int hf_iscsi_Login_CSG = -1;
|
|
|
|
static int hf_iscsi_Login_NSG = -1;
|
2001-05-30 18:52:38 +00:00
|
|
|
static int hf_iscsi_Login_Status = -1;
|
|
|
|
static int hf_iscsi_KeyValue = -1;
|
2002-09-26 08:20:22 +00:00
|
|
|
static int hf_iscsi_Text_C = -1;
|
2001-05-30 18:52:38 +00:00
|
|
|
static int hf_iscsi_Text_F = -1;
|
|
|
|
static int hf_iscsi_ExpDataSN = -1;
|
2001-10-19 20:53:14 +00:00
|
|
|
static int hf_iscsi_R2TSN = -1;
|
2001-11-04 00:58:23 +00:00
|
|
|
static int hf_iscsi_TaskManagementFunction_ReferencedTaskTag = -1;
|
2001-10-19 20:53:14 +00:00
|
|
|
static int hf_iscsi_RefCmdSN = -1;
|
2001-11-04 00:58:23 +00:00
|
|
|
static int hf_iscsi_TaskManagementFunction_Function = -1;
|
|
|
|
static int hf_iscsi_TaskManagementFunction_Response = -1;
|
2001-05-30 18:52:38 +00:00
|
|
|
static int hf_iscsi_Logout_Reason = -1;
|
|
|
|
static int hf_iscsi_Logout_Response = -1;
|
2001-10-19 20:53:14 +00:00
|
|
|
static int hf_iscsi_Time2Wait = -1;
|
|
|
|
static int hf_iscsi_Time2Retain = -1;
|
2001-05-30 18:52:38 +00:00
|
|
|
static int hf_iscsi_DesiredDataLength = -1;
|
2001-10-19 20:53:14 +00:00
|
|
|
static int hf_iscsi_AsyncEvent = -1;
|
|
|
|
static int hf_iscsi_EventVendorCode = -1;
|
2001-05-30 18:52:38 +00:00
|
|
|
static int hf_iscsi_Parameter1 = -1;
|
|
|
|
static int hf_iscsi_Parameter2 = -1;
|
2001-06-28 08:05:26 +00:00
|
|
|
static int hf_iscsi_Parameter3 = -1;
|
2001-05-30 18:52:38 +00:00
|
|
|
static int hf_iscsi_Reject_Reason = -1;
|
2001-10-19 20:53:14 +00:00
|
|
|
static int hf_iscsi_snack_type = -1;
|
2001-05-30 18:52:38 +00:00
|
|
|
static int hf_iscsi_BegRun = -1;
|
|
|
|
static int hf_iscsi_RunLength = -1;
|
|
|
|
|
|
|
|
/* Initialize the subtree pointers */
|
2002-04-04 23:24:09 +00:00
|
|
|
static gint ett_iscsi = -1;
|
2001-05-30 18:52:38 +00:00
|
|
|
static gint ett_iscsi_KeyValues = -1;
|
|
|
|
static gint ett_iscsi_CDB = -1;
|
2001-05-31 19:20:41 +00:00
|
|
|
static gint ett_iscsi_Flags = -1;
|
2011-02-27 01:11:24 +00:00
|
|
|
static gint ett_iscsi_RejectHeader = -1;
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #ifndef DRAFT08 */
|
2002-01-21 22:23:38 +00:00
|
|
|
static gint ett_iscsi_ISID = -1;
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #endif */
|
2001-05-30 18:52:38 +00:00
|
|
|
|
2011-11-09 02:48:51 +00:00
|
|
|
#define ISCSI_HEADER_DIGEST_AUTO 0
|
|
|
|
#define ISCSI_HEADER_DIGEST_NONE 1
|
|
|
|
#define ISCSI_HEADER_DIGEST_CRC32 2
|
2006-04-06 09:47:31 +00:00
|
|
|
/* this structure contains session wide state for a specific tcp conversation */
|
2004-08-29 02:55:02 +00:00
|
|
|
typedef struct _iscsi_session_t {
|
2011-11-09 02:48:51 +00:00
|
|
|
guint32 header_digest;
|
|
|
|
emem_tree_t *itlq; /* indexed by ITT */
|
|
|
|
emem_tree_t *itl; /* indexed by LUN */
|
2004-08-29 02:55:02 +00:00
|
|
|
} iscsi_session_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #ifdef DRAFT08 */
|
2001-10-19 20:53:14 +00:00
|
|
|
#define X_BIT 0x80
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #endif */
|
|
|
|
|
2001-10-19 20:53:14 +00:00
|
|
|
#define I_BIT 0x40
|
|
|
|
|
2002-01-31 00:44:36 +00:00
|
|
|
#define OPCODE_MASK 0x3f
|
|
|
|
|
2001-10-19 20:53:14 +00:00
|
|
|
#define TARGET_OPCODE_BIT 0x20
|
|
|
|
|
2001-11-04 00:58:23 +00:00
|
|
|
#define ISCSI_OPCODE_NOP_OUT 0x00
|
|
|
|
#define ISCSI_OPCODE_SCSI_COMMAND 0x01
|
|
|
|
#define ISCSI_OPCODE_TASK_MANAGEMENT_FUNCTION 0x02
|
|
|
|
#define ISCSI_OPCODE_LOGIN_COMMAND 0x03
|
|
|
|
#define ISCSI_OPCODE_TEXT_COMMAND 0x04
|
|
|
|
#define ISCSI_OPCODE_SCSI_DATA_OUT 0x05
|
|
|
|
#define ISCSI_OPCODE_LOGOUT_COMMAND 0x06
|
|
|
|
#define ISCSI_OPCODE_SNACK_REQUEST 0x10
|
2002-05-14 21:35:17 +00:00
|
|
|
#define ISCSI_OPCODE_VENDOR_SPECIFIC_I0 0x1c
|
|
|
|
#define ISCSI_OPCODE_VENDOR_SPECIFIC_I1 0x1d
|
|
|
|
#define ISCSI_OPCODE_VENDOR_SPECIFIC_I2 0x1e
|
2001-11-04 00:58:23 +00:00
|
|
|
|
2002-01-21 22:23:38 +00:00
|
|
|
#define ISCSI_OPCODE_NOP_IN 0x20
|
|
|
|
#define ISCSI_OPCODE_SCSI_RESPONSE 0x21
|
|
|
|
#define ISCSI_OPCODE_TASK_MANAGEMENT_FUNCTION_RESPONSE 0x22
|
|
|
|
#define ISCSI_OPCODE_LOGIN_RESPONSE 0x23
|
|
|
|
#define ISCSI_OPCODE_TEXT_RESPONSE 0x24
|
|
|
|
#define ISCSI_OPCODE_SCSI_DATA_IN 0x25
|
|
|
|
#define ISCSI_OPCODE_LOGOUT_RESPONSE 0x26
|
|
|
|
#define ISCSI_OPCODE_R2T 0x31
|
|
|
|
#define ISCSI_OPCODE_ASYNC_MESSAGE 0x32
|
|
|
|
#define ISCSI_OPCODE_REJECT 0x3f
|
2002-05-14 21:35:17 +00:00
|
|
|
#define ISCSI_OPCODE_VENDOR_SPECIFIC_T0 0x3c
|
|
|
|
#define ISCSI_OPCODE_VENDOR_SPECIFIC_T1 0x3d
|
|
|
|
#define ISCSI_OPCODE_VENDOR_SPECIFIC_T2 0x3e
|
2001-11-04 00:58:23 +00:00
|
|
|
|
|
|
|
#define CSG_SHIFT 2
|
|
|
|
#define CSG_MASK (0x03 << CSG_SHIFT)
|
2002-01-31 00:44:36 +00:00
|
|
|
#define NSG_MASK 0x03
|
2001-11-04 00:58:23 +00:00
|
|
|
|
|
|
|
#define ISCSI_CSG_SECURITY_NEGOTIATION (0 << CSG_SHIFT)
|
|
|
|
#define ISCSI_CSG_OPERATIONAL_NEGOTIATION (1 << CSG_SHIFT)
|
|
|
|
#define ISCSI_CSG_FULL_FEATURE_PHASE (3 << CSG_SHIFT)
|
2001-10-21 17:20:10 +00:00
|
|
|
|
2002-02-02 03:27:54 +00:00
|
|
|
#define ISCSI_SCSI_DATA_FLAG_S 0x01
|
|
|
|
#define ISCSI_SCSI_DATA_FLAG_U 0x02
|
|
|
|
#define ISCSI_SCSI_DATA_FLAG_O 0x04
|
2002-05-15 19:32:22 +00:00
|
|
|
#define ISCSI_SCSI_DATA_FLAG_A 0x40
|
2002-02-02 03:27:54 +00:00
|
|
|
#define ISCSI_SCSI_DATA_FLAG_F 0x80
|
|
|
|
|
2001-10-19 20:53:14 +00:00
|
|
|
static const value_string iscsi_opcodes[] = {
|
2001-11-04 00:58:23 +00:00
|
|
|
{ ISCSI_OPCODE_NOP_OUT, "NOP Out" },
|
|
|
|
{ ISCSI_OPCODE_SCSI_COMMAND, "SCSI Command" },
|
|
|
|
{ ISCSI_OPCODE_TASK_MANAGEMENT_FUNCTION, "Task Management Function" },
|
|
|
|
{ ISCSI_OPCODE_LOGIN_COMMAND, "Login Command" },
|
|
|
|
{ ISCSI_OPCODE_TEXT_COMMAND, "Text Command" },
|
2002-01-10 01:28:45 +00:00
|
|
|
{ ISCSI_OPCODE_SCSI_DATA_OUT, "SCSI Data Out" },
|
2001-11-04 00:58:23 +00:00
|
|
|
{ ISCSI_OPCODE_LOGOUT_COMMAND, "Logout Command" },
|
|
|
|
{ ISCSI_OPCODE_SNACK_REQUEST, "SNACK Request" },
|
2002-05-14 21:35:17 +00:00
|
|
|
{ ISCSI_OPCODE_VENDOR_SPECIFIC_I0, "Vendor Specific I0" },
|
|
|
|
{ ISCSI_OPCODE_VENDOR_SPECIFIC_I1, "Vendor Specific I1" },
|
|
|
|
{ ISCSI_OPCODE_VENDOR_SPECIFIC_I2, "Vendor Specific I2" },
|
2001-11-04 00:58:23 +00:00
|
|
|
|
|
|
|
{ ISCSI_OPCODE_NOP_IN, "NOP In" },
|
|
|
|
{ ISCSI_OPCODE_SCSI_RESPONSE, "SCSI Response" },
|
|
|
|
{ ISCSI_OPCODE_TASK_MANAGEMENT_FUNCTION_RESPONSE, "Task Management Function Response" },
|
|
|
|
{ ISCSI_OPCODE_LOGIN_RESPONSE, "Login Response" },
|
|
|
|
{ ISCSI_OPCODE_TEXT_RESPONSE, "Text Response" },
|
2002-01-10 01:28:45 +00:00
|
|
|
{ ISCSI_OPCODE_SCSI_DATA_IN, "SCSI Data In" },
|
2001-11-04 00:58:23 +00:00
|
|
|
{ ISCSI_OPCODE_LOGOUT_RESPONSE, "Logout Response" },
|
|
|
|
{ ISCSI_OPCODE_R2T, "Ready To Transfer" },
|
|
|
|
{ ISCSI_OPCODE_ASYNC_MESSAGE, "Asynchronous Message" },
|
|
|
|
{ ISCSI_OPCODE_REJECT, "Reject"},
|
2002-05-14 21:35:17 +00:00
|
|
|
{ ISCSI_OPCODE_VENDOR_SPECIFIC_T0, "Vendor Specific T0" },
|
|
|
|
{ ISCSI_OPCODE_VENDOR_SPECIFIC_T1, "Vendor Specific T1" },
|
|
|
|
{ ISCSI_OPCODE_VENDOR_SPECIFIC_T2, "Vendor Specific T2" },
|
2001-05-30 18:52:38 +00:00
|
|
|
{0, NULL},
|
|
|
|
};
|
|
|
|
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #ifdef DRAFT08 */
|
2001-05-30 18:52:38 +00:00
|
|
|
static const true_false_string iscsi_meaning_X = {
|
|
|
|
"Retry",
|
|
|
|
"Not retry"
|
|
|
|
};
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #endif */
|
2002-03-20 21:28:14 +00:00
|
|
|
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #ifdef DRAFT09 */
|
2002-01-21 22:23:38 +00:00
|
|
|
static const true_false_string iscsi_meaning_login_X = {
|
|
|
|
"Reinstate failed connection",
|
|
|
|
"New connection"
|
|
|
|
};
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #endif */
|
2001-05-30 18:52:38 +00:00
|
|
|
|
|
|
|
static const true_false_string iscsi_meaning_I = {
|
|
|
|
"Immediate delivery",
|
|
|
|
"Queued delivery"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const true_false_string iscsi_meaning_F = {
|
|
|
|
"Final PDU in sequence",
|
|
|
|
"Not final PDU in sequence"
|
|
|
|
};
|
|
|
|
|
2002-05-15 19:32:22 +00:00
|
|
|
static const true_false_string iscsi_meaning_A = {
|
|
|
|
"Acknowledge requested",
|
|
|
|
"Acknowledge not requested"
|
|
|
|
};
|
|
|
|
|
2001-10-19 20:53:14 +00:00
|
|
|
static const true_false_string iscsi_meaning_T = {
|
|
|
|
"Transit to next login stage",
|
|
|
|
"Stay in current login stage"
|
2001-05-30 18:52:38 +00:00
|
|
|
};
|
|
|
|
|
2002-09-26 08:20:22 +00:00
|
|
|
static const true_false_string iscsi_meaning_C = {
|
|
|
|
"Text is incomplete",
|
|
|
|
"Text is complete"
|
|
|
|
};
|
|
|
|
|
2001-05-30 18:52:38 +00:00
|
|
|
static const true_false_string iscsi_meaning_S = {
|
|
|
|
"Response contains SCSI status",
|
|
|
|
"Response does not contain SCSI status"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const true_false_string iscsi_meaning_R = {
|
|
|
|
"Data will be read from target",
|
|
|
|
"No data will be read from target"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const true_false_string iscsi_meaning_W = {
|
|
|
|
"Data will be written to target",
|
|
|
|
"No data will be written to target"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const true_false_string iscsi_meaning_o = {
|
|
|
|
"Read part of bi-directional command overflowed",
|
|
|
|
"No overflow of read part of bi-directional command",
|
|
|
|
};
|
|
|
|
|
|
|
|
static const true_false_string iscsi_meaning_u = {
|
|
|
|
"Read part of bi-directional command underflowed",
|
|
|
|
"No underflow of read part of bi-directional command",
|
|
|
|
};
|
|
|
|
|
|
|
|
static const true_false_string iscsi_meaning_O = {
|
|
|
|
"Residual overflow occurred",
|
|
|
|
"No residual overflow occurred",
|
|
|
|
};
|
|
|
|
|
|
|
|
static const true_false_string iscsi_meaning_U = {
|
|
|
|
"Residual underflow occurred",
|
|
|
|
"No residual underflow occurred",
|
|
|
|
};
|
|
|
|
|
2001-10-19 20:53:14 +00:00
|
|
|
static const value_string iscsi_scsi_responses[] = {
|
|
|
|
{ 0, "Command completed at target" },
|
|
|
|
{ 1, "Response does not contain SCSI status"},
|
|
|
|
{ 0, NULL }
|
2001-05-30 18:52:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string iscsi_scsicommand_taskattrs[] = {
|
|
|
|
{0, "Untagged"},
|
|
|
|
{1, "Simple"},
|
|
|
|
{2, "Ordered"},
|
|
|
|
{3, "Head of Queue"},
|
|
|
|
{4, "ACA"},
|
|
|
|
{0, NULL},
|
|
|
|
};
|
|
|
|
|
2002-02-02 03:27:54 +00:00
|
|
|
static const value_string iscsi_task_management_responses[] = {
|
2001-05-30 18:52:38 +00:00
|
|
|
{0, "Function complete"},
|
|
|
|
{1, "Task not in task set"},
|
|
|
|
{2, "LUN does not exist"},
|
2001-11-04 00:58:23 +00:00
|
|
|
{3, "Task still allegiant"},
|
|
|
|
{4, "Task failover not supported"},
|
|
|
|
{5, "Task management function not supported"},
|
2002-02-02 03:27:54 +00:00
|
|
|
{6, "Authorisation failed"},
|
2001-05-30 18:52:38 +00:00
|
|
|
{255, "Function rejected"},
|
|
|
|
{0, NULL},
|
|
|
|
};
|
|
|
|
|
2001-11-04 00:58:23 +00:00
|
|
|
static const value_string iscsi_task_management_functions[] = {
|
2001-05-30 18:52:38 +00:00
|
|
|
{1, "Abort Task"},
|
|
|
|
{2, "Abort Task Set"},
|
|
|
|
{3, "Clear ACA"},
|
|
|
|
{4, "Clear Task Set"},
|
|
|
|
{5, "Logical Unit Reset"},
|
|
|
|
{6, "Target Warm Reset"},
|
|
|
|
{7, "Target Cold Reset"},
|
2006-06-20 13:16:50 +00:00
|
|
|
{8, "Target Reassign"},
|
2001-05-30 18:52:38 +00:00
|
|
|
{0, NULL},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string iscsi_login_status[] = {
|
2001-10-19 20:53:14 +00:00
|
|
|
{0x0000, "Success"},
|
|
|
|
{0x0101, "Target moved temporarily"},
|
|
|
|
{0x0102, "Target moved permanently"},
|
|
|
|
{0x0200, "Initiator error (miscellaneous error)"},
|
2002-11-14 19:08:17 +00:00
|
|
|
{0x0201, "Authentication failed"},
|
2001-10-19 20:53:14 +00:00
|
|
|
{0x0202, "Authorisation failure"},
|
|
|
|
{0x0203, "Target not found"},
|
|
|
|
{0x0204, "Target removed"},
|
|
|
|
{0x0205, "Unsupported version"},
|
|
|
|
{0x0206, "Too many connections"},
|
|
|
|
{0x0207, "Missing parameter"},
|
|
|
|
{0x0208, "Can't include in session"},
|
|
|
|
{0x0209, "Session type not supported"},
|
2002-03-20 21:28:14 +00:00
|
|
|
{0x020a, "Session does not exist"},
|
|
|
|
{0x020b, "Invalid request during login"},
|
2001-10-19 20:53:14 +00:00
|
|
|
{0x0300, "Target error (miscellaneous error)"},
|
|
|
|
{0x0301, "Service unavailable"},
|
|
|
|
{0x0302, "Out of resources"},
|
2001-05-30 18:52:38 +00:00
|
|
|
{0, NULL},
|
|
|
|
};
|
|
|
|
|
2001-10-19 20:53:14 +00:00
|
|
|
static const value_string iscsi_login_stage[] = {
|
|
|
|
{0, "Security negotiation"},
|
|
|
|
{1, "Operational negotiation"},
|
|
|
|
{3, "Full feature phase"},
|
2001-05-30 18:52:38 +00:00
|
|
|
{0, NULL},
|
|
|
|
};
|
|
|
|
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #ifndef DRAFT08 */
|
2002-01-21 22:23:38 +00:00
|
|
|
static const value_string iscsi_isid_type[] = {
|
|
|
|
{0x00, "IEEE OUI"},
|
|
|
|
{0x01, "IANA Enterprise Number"},
|
|
|
|
{0x02, "Random"},
|
|
|
|
{0, NULL},
|
|
|
|
};
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #endif */
|
2002-01-21 22:23:38 +00:00
|
|
|
|
2001-05-30 18:52:38 +00:00
|
|
|
static const value_string iscsi_logout_reasons[] = {
|
2001-10-19 20:53:14 +00:00
|
|
|
{0, "Close session"},
|
|
|
|
{1, "Close connection"},
|
2001-05-30 18:52:38 +00:00
|
|
|
{2, "Remove connection for recovery"},
|
|
|
|
{0, NULL},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string iscsi_logout_response[] = {
|
|
|
|
{0, "Connection closed successfully"},
|
2001-10-19 20:53:14 +00:00
|
|
|
{1, "CID not found"},
|
|
|
|
{2, "Connection recovery not supported"},
|
|
|
|
{3, "Cleanup failed for various reasons"},
|
2001-05-30 18:52:38 +00:00
|
|
|
{0, NULL},
|
|
|
|
};
|
|
|
|
|
2001-10-19 20:53:14 +00:00
|
|
|
static const value_string iscsi_asyncevents[] = {
|
|
|
|
{0, "A SCSI asynchronous event is reported in the sense data"},
|
|
|
|
{1, "Target requests logout"},
|
|
|
|
{2, "Target will/has dropped connection"},
|
|
|
|
{3, "Target will/has dropped all connections"},
|
2002-06-24 07:57:50 +00:00
|
|
|
{4, "Target requests parameter negotiation"},
|
2001-06-28 08:05:26 +00:00
|
|
|
{0, NULL},
|
|
|
|
};
|
|
|
|
|
2001-10-19 20:53:14 +00:00
|
|
|
static const value_string iscsi_snack_types[] = {
|
|
|
|
{0, "Data/R2T"},
|
|
|
|
{1, "Status"},
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #ifndef DRAFT08 */
|
2002-03-20 21:28:14 +00:00
|
|
|
{2, "Data ACK"},
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #endif */
|
2002-09-26 08:20:22 +00:00
|
|
|
{3, "R-Data"},
|
2001-10-19 20:53:14 +00:00
|
|
|
{0, NULL}
|
2001-05-30 18:52:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string iscsi_reject_reasons[] = {
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #ifdef DRAFT08 */
|
2001-10-19 20:53:14 +00:00
|
|
|
{0x01, "Full feature phase command before login"},
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #endif */
|
2001-10-19 20:53:14 +00:00
|
|
|
{0x02, "Data (payload) digest error"},
|
|
|
|
{0x03, "Data SNACK reject"},
|
|
|
|
{0x04, "Protocol error"},
|
|
|
|
{0x05, "Command not supported in this session type"},
|
|
|
|
{0x06, "Immediate command reject (too many immediate commands)"},
|
|
|
|
{0x07, "Task in progress"},
|
2002-09-26 08:20:22 +00:00
|
|
|
{0x08, "Invalid Data Ack"},
|
|
|
|
{0x09, "Invalid PDU field"},
|
|
|
|
{0x0a, "Long operation reject"},
|
2001-10-19 20:53:14 +00:00
|
|
|
{0x0b, "Negotiation reset"},
|
2002-09-26 08:20:22 +00:00
|
|
|
{0x0c, "Waiting for logout"},
|
2001-05-30 18:52:38 +00:00
|
|
|
{0, NULL},
|
|
|
|
};
|
|
|
|
|
2009-10-08 15:10:43 +00:00
|
|
|
/* structure and functions to keep track of
|
|
|
|
* COMMAND/DATA_IN/DATA_OUT/RESPONSE matching
|
2002-01-10 01:28:45 +00:00
|
|
|
*/
|
2003-06-21 10:16:18 +00:00
|
|
|
typedef struct _iscsi_conv_data {
|
|
|
|
guint32 data_in_frame;
|
|
|
|
guint32 data_out_frame;
|
2006-04-20 09:43:56 +00:00
|
|
|
itlq_nexus_t itlq;
|
2003-06-21 10:16:18 +00:00
|
|
|
} iscsi_conv_data_t;
|
2002-01-10 01:28:45 +00:00
|
|
|
|
2010-04-29 08:41:23 +00:00
|
|
|
/* TargetAddress describes a iscsi port, possibly using a non-standard port
|
|
|
|
so we can use this to set up a conversation dissector to that port.
|
|
|
|
|
|
|
|
TargetAddress is of the form :
|
|
|
|
TargetAddress=domainname[:port][,portal-group-tag]
|
|
|
|
|
|
|
|
where domainname is either a dns-name, an ipv4 address is dotted-decimal
|
|
|
|
form or a bracketed ipv6 address.
|
|
|
|
so treat this as signalling, parse the value and register iscis as a conversation
|
|
|
|
dissector for the address/port that TargetAddress points to.
|
|
|
|
(it starts to be common to use redirectors to point to non-3260 ports)
|
|
|
|
*/
|
2010-10-10 23:28:40 +00:00
|
|
|
static void
|
2010-04-29 08:41:23 +00:00
|
|
|
iscsi_dissect_TargetAddress(packet_info *pinfo, proto_tree *tree _U_,char *val)
|
|
|
|
{
|
2011-11-09 02:48:51 +00:00
|
|
|
address *addr = NULL;
|
|
|
|
int port;
|
|
|
|
char *value = ep_strdup(val);
|
|
|
|
char *p = NULL, *pgt = NULL;
|
|
|
|
|
|
|
|
if (value[0] == '[') {
|
|
|
|
/* this looks like an ipv6 address */
|
|
|
|
p = strchr(value, ']');
|
|
|
|
if (p != NULL) {
|
|
|
|
*p = 0;
|
|
|
|
p += 2; /* skip past "]:" */
|
|
|
|
|
|
|
|
pgt = strchr(p, ',');
|
|
|
|
if (pgt != NULL) {
|
|
|
|
*pgt++ = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cant handle ipv6 yet */
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* This is either a ipv4 address or a dns name */
|
|
|
|
int i0,i1,i2,i3;
|
|
|
|
if (sscanf(value, "%d.%d.%d.%d", &i0,&i1,&i2,&i3) == 4) {
|
|
|
|
/* looks like a ipv4 address */
|
|
|
|
p = strchr(value, ':');
|
|
|
|
if (p != NULL) {
|
|
|
|
*p++ = 0;
|
|
|
|
|
|
|
|
pgt = strchr(p, ',');
|
|
|
|
if (pgt != NULL) {
|
|
|
|
*pgt++ = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = ep_alloc(sizeof(address));
|
|
|
|
addr->type = AT_IPv4;
|
|
|
|
addr->len = 4;
|
|
|
|
addr->data = ep_alloc(4);
|
|
|
|
((char *)addr->data)[0] = i0;
|
|
|
|
((char *)addr->data)[1] = i1;
|
|
|
|
((char *)addr->data)[2] = i2;
|
|
|
|
((char *)addr->data)[3] = i3;
|
|
|
|
|
|
|
|
port = atoi(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* attach a conversation dissector to this address/port tuple */
|
|
|
|
if (addr && !pinfo->fd->flags.visited) {
|
|
|
|
conversation_t *conv;
|
|
|
|
|
|
|
|
conv = conversation_new(pinfo->fd->num, addr, addr, PT_TCP, port, port, NO_ADDR2|NO_PORT2);
|
|
|
|
if (conv == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
conversation_set_dissector(conv, iscsi_handle);
|
|
|
|
}
|
2010-04-29 08:41:23 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-06-28 08:05:26 +00:00
|
|
|
static gint
|
2010-04-29 08:41:23 +00:00
|
|
|
addTextKeys(packet_info *pinfo, proto_tree *tt, tvbuff_t *tvb, gint offset, guint32 text_len) {
|
2001-05-30 18:52:38 +00:00
|
|
|
const gint limit = offset + text_len;
|
2010-04-29 08:41:23 +00:00
|
|
|
|
2001-05-30 18:52:38 +00:00
|
|
|
while(offset < limit) {
|
2011-11-09 02:48:51 +00:00
|
|
|
char *key = NULL, *value = NULL;
|
|
|
|
gint len = tvb_strnlen(tvb, offset, limit - offset);
|
|
|
|
|
|
|
|
if(len == -1) {
|
|
|
|
len = limit - offset;
|
|
|
|
} else {
|
|
|
|
len = len + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
key = tvb_get_ephemeral_string(tvb, offset, len);
|
|
|
|
if (key == NULL) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
value = strchr(key, '=');
|
|
|
|
if (value == NULL) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
*value++ = 0;
|
|
|
|
|
|
|
|
if (!strcmp(key, "TargetAddress")) {
|
|
|
|
iscsi_dissect_TargetAddress(pinfo, tt, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
proto_tree_add_item(tt, hf_iscsi_KeyValue, tvb, offset, len, ENC_ASCII|ENC_NA);
|
|
|
|
offset += len;
|
2001-05-30 18:52:38 +00:00
|
|
|
}
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
2001-06-28 08:05:26 +00:00
|
|
|
static gint
|
2004-08-29 04:12:35 +00:00
|
|
|
handleHeaderDigest(iscsi_session_t *iscsi_session, proto_item *ti, tvbuff_t *tvb, guint offset, int headerLen) {
|
2001-10-19 20:53:14 +00:00
|
|
|
int available_bytes = tvb_length_remaining(tvb, offset);
|
2004-08-29 04:12:35 +00:00
|
|
|
|
|
|
|
switch(iscsi_session->header_digest){
|
|
|
|
case ISCSI_HEADER_DIGEST_CRC32:
|
2011-11-09 02:48:51 +00:00
|
|
|
if(available_bytes >= (headerLen + 4)) {
|
|
|
|
guint32 crc = ~crc32c_calculate(tvb_get_ptr(tvb, offset, headerLen), headerLen, CRC32C_PRELOAD);
|
|
|
|
guint32 sent = tvb_get_ntohl(tvb, offset + headerLen);
|
|
|
|
if(crc == sent) {
|
|
|
|
proto_tree_add_uint_format(ti, hf_iscsi_HeaderDigest32, tvb, offset + headerLen, 4, sent, "HeaderDigest: 0x%08x (Good CRC32)", sent);
|
|
|
|
} else {
|
|
|
|
proto_tree_add_uint_format(ti, hf_iscsi_HeaderDigest32, tvb, offset + headerLen, 4, sent, "HeaderDigest: 0x%08x (Bad CRC32, should be 0x%08x)", sent, crc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return offset + headerLen + 4;
|
2001-10-21 17:20:10 +00:00
|
|
|
}
|
|
|
|
return offset + headerLen;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
handleDataDigest(proto_item *ti, tvbuff_t *tvb, guint offset, int dataLen) {
|
|
|
|
int available_bytes = tvb_length_remaining(tvb, offset);
|
|
|
|
if(enableDataDigests) {
|
2011-11-09 02:48:51 +00:00
|
|
|
if(dataDigestIsCRC32) {
|
|
|
|
if(available_bytes >= (dataLen + 4)) {
|
|
|
|
guint32 crc = ~crc32c_calculate(tvb_get_ptr(tvb, offset, dataLen), dataLen, CRC32C_PRELOAD);
|
|
|
|
guint32 sent = tvb_get_ntohl(tvb, offset + dataLen);
|
|
|
|
if(crc == sent) {
|
|
|
|
proto_tree_add_uint_format(ti, hf_iscsi_DataDigest32, tvb, offset + dataLen, 4, sent, "DataDigest: 0x%08x (Good CRC32)", sent);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
proto_tree_add_uint_format(ti, hf_iscsi_DataDigest32, tvb, offset + dataLen, 4, sent, "DataDigest: 0x%08x (Bad CRC32, should be 0x%08x)", sent, crc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return offset + dataLen + 4;
|
|
|
|
}
|
|
|
|
if((unsigned)available_bytes >= (dataLen + dataDigestSize)) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_DataDigest, tvb, offset + dataLen, dataDigestSize, ENC_NA);
|
|
|
|
}
|
|
|
|
return offset + dataLen + dataDigestSize;
|
2001-06-28 08:05:26 +00:00
|
|
|
}
|
2001-10-21 17:20:10 +00:00
|
|
|
return offset + dataLen;
|
2001-06-28 08:05:26 +00:00
|
|
|
}
|
|
|
|
|
2001-10-19 20:53:14 +00:00
|
|
|
static int
|
2001-10-21 17:20:10 +00:00
|
|
|
handleDataSegment(proto_item *ti, tvbuff_t *tvb, guint offset, guint dataSegmentLen, guint endOffset, int hf_id) {
|
|
|
|
if(endOffset > offset) {
|
2011-11-09 02:48:51 +00:00
|
|
|
int dataOffset = offset;
|
|
|
|
int dataLen = MIN(dataSegmentLen, endOffset - offset);
|
|
|
|
if(dataLen > 0) {
|
2011-11-09 17:33:18 +00:00
|
|
|
proto_tree_add_item(ti, hf_id, tvb, offset, dataLen, ENC_NA);
|
2011-11-09 02:48:51 +00:00
|
|
|
offset += dataLen;
|
|
|
|
}
|
|
|
|
if(offset < endOffset && (offset & 3) != 0) {
|
|
|
|
int padding = 4 - (offset & 3);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_Padding, tvb, offset, padding, ENC_NA);
|
|
|
|
offset += padding;
|
|
|
|
}
|
|
|
|
if(dataSegmentLen > 0 && offset < endOffset)
|
|
|
|
offset = handleDataDigest(ti, tvb, dataOffset, offset - dataOffset);
|
2001-10-21 17:20:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-04-29 08:41:23 +00:00
|
|
|
handleDataSegmentAsTextKeys(packet_info *pinfo, proto_item *ti, tvbuff_t *tvb, guint offset, guint dataSegmentLen, guint endOffset, int digestsActive) {
|
2001-10-21 17:20:10 +00:00
|
|
|
if(endOffset > offset) {
|
2011-11-09 02:48:51 +00:00
|
|
|
int dataOffset = offset;
|
|
|
|
int textLen = MIN(dataSegmentLen, endOffset - offset);
|
|
|
|
if(textLen > 0) {
|
|
|
|
proto_item *tf = proto_tree_add_text(ti, tvb, offset, textLen, "Key/Value Pairs");
|
|
|
|
proto_tree *tt = proto_item_add_subtree(tf, ett_iscsi_KeyValues);
|
|
|
|
offset = addTextKeys(pinfo, tt, tvb, offset, textLen);
|
|
|
|
}
|
|
|
|
if(offset < endOffset && (offset & 3) != 0) {
|
|
|
|
int padding = 4 - (offset & 3);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_Padding, tvb, offset, padding, ENC_NA);
|
|
|
|
offset += padding;
|
|
|
|
}
|
|
|
|
if(digestsActive && dataSegmentLen > 0 && offset < endOffset)
|
|
|
|
offset = handleDataDigest(ti, tvb, dataOffset, offset - dataOffset);
|
2001-10-21 17:20:10 +00:00
|
|
|
}
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Code to actually dissect the packets */
|
|
|
|
static void
|
2006-10-12 10:54:36 +00:00
|
|
|
dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset, guint8 opcode, const char *opcode_str, guint32 data_segment_len, iscsi_session_t *iscsi_session, conversation_t *conversation) {
|
2002-01-10 01:28:45 +00:00
|
|
|
|
2001-10-19 20:53:14 +00:00
|
|
|
guint original_offset = offset;
|
2002-04-04 23:24:09 +00:00
|
|
|
proto_tree *ti = NULL;
|
2002-01-10 01:28:45 +00:00
|
|
|
guint8 scsi_status = 0;
|
2004-02-18 09:10:02 +00:00
|
|
|
gboolean S_bit=FALSE;
|
2001-10-19 20:53:14 +00:00
|
|
|
guint cdb_offset = offset + 32; /* offset of CDB from start of PDU */
|
|
|
|
guint end_offset = offset + tvb_length_remaining(tvb, offset);
|
2002-01-10 01:28:45 +00:00
|
|
|
iscsi_conv_data_t *cdata = NULL;
|
2002-01-16 20:25:07 +00:00
|
|
|
int paddedDataSegmentLength = data_segment_len;
|
2005-03-17 10:18:18 +00:00
|
|
|
guint16 lun=0xffff;
|
2005-05-29 01:49:09 +00:00
|
|
|
guint immediate_data_length=0;
|
|
|
|
guint immediate_data_offset=0;
|
2006-04-21 11:08:24 +00:00
|
|
|
itl_nexus_t *itl=NULL;
|
2006-10-08 04:13:18 +00:00
|
|
|
guint ahs_cdb_length=0;
|
|
|
|
guint ahs_cdb_offset=0;
|
2006-10-13 09:16:45 +00:00
|
|
|
guint32 data_offset=0;
|
2005-02-17 12:07:45 +00:00
|
|
|
|
2002-01-16 20:25:07 +00:00
|
|
|
if(paddedDataSegmentLength & 3)
|
2011-11-09 02:48:51 +00:00
|
|
|
paddedDataSegmentLength += 4 - (paddedDataSegmentLength & 3);
|
2001-05-30 18:52:38 +00:00
|
|
|
|
|
|
|
/* Make entries in Protocol column and Info column on summary display */
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "iSCSI");
|
2001-05-30 18:52:38 +00:00
|
|
|
|
2006-04-07 10:15:15 +00:00
|
|
|
/* XXX we need a way to handle replayed iscsi itt here */
|
2006-04-21 11:08:24 +00:00
|
|
|
cdata=(iscsi_conv_data_t *)se_tree_lookup32(iscsi_session->itlq, tvb_get_ntohl(tvb, offset+16));
|
2006-04-07 10:15:15 +00:00
|
|
|
if(!cdata){
|
|
|
|
cdata = se_alloc (sizeof(iscsi_conv_data_t));
|
2006-04-20 09:43:56 +00:00
|
|
|
cdata->itlq.lun=0xffff;
|
|
|
|
cdata->itlq.scsi_opcode=0xffff;
|
2011-11-09 02:48:51 +00:00
|
|
|
cdata->itlq.task_flags=0;
|
|
|
|
cdata->itlq.data_length=0;
|
|
|
|
cdata->itlq.bidir_data_length=0;
|
2006-04-20 09:43:56 +00:00
|
|
|
cdata->itlq.fc_time = pinfo->fd->abs_ts;
|
|
|
|
cdata->itlq.first_exchange_frame=0;
|
|
|
|
cdata->itlq.last_exchange_frame=0;
|
2006-04-22 02:16:52 +00:00
|
|
|
cdata->itlq.flags=0;
|
|
|
|
cdata->itlq.alloc_len=0;
|
2006-09-30 04:10:28 +00:00
|
|
|
cdata->itlq.extra_data=NULL;
|
2006-04-07 10:15:15 +00:00
|
|
|
cdata->data_in_frame=0;
|
|
|
|
cdata->data_out_frame=0;
|
|
|
|
|
2006-04-21 11:08:24 +00:00
|
|
|
se_tree_insert32(iscsi_session->itlq, tvb_get_ntohl(tvb, offset+16), cdata);
|
2006-04-07 10:15:15 +00:00
|
|
|
}
|
|
|
|
|
2002-02-02 03:27:54 +00:00
|
|
|
if (opcode == ISCSI_OPCODE_SCSI_RESPONSE ||
|
2011-11-09 02:48:51 +00:00
|
|
|
opcode == ISCSI_OPCODE_SCSI_DATA_IN) {
|
2002-01-10 01:28:45 +00:00
|
|
|
scsi_status = tvb_get_guint8 (tvb, offset+3);
|
|
|
|
}
|
2001-05-30 18:52:38 +00:00
|
|
|
|
2002-01-10 01:28:45 +00:00
|
|
|
if ((opcode == ISCSI_OPCODE_SCSI_RESPONSE) ||
|
|
|
|
(opcode == ISCSI_OPCODE_SCSI_DATA_IN) ||
|
|
|
|
(opcode == ISCSI_OPCODE_SCSI_DATA_OUT)) {
|
2006-04-06 10:41:49 +00:00
|
|
|
/* first time we see this packet. check if we can find the request */
|
2006-04-07 10:15:15 +00:00
|
|
|
switch(opcode){
|
|
|
|
case ISCSI_OPCODE_SCSI_RESPONSE:
|
2006-04-20 09:43:56 +00:00
|
|
|
cdata->itlq.last_exchange_frame=pinfo->fd->num;
|
2006-04-07 10:15:15 +00:00
|
|
|
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){
|
2006-04-20 09:43:56 +00:00
|
|
|
cdata->itlq.last_exchange_frame=pinfo->fd->num;
|
2003-06-21 10:16:18 +00:00
|
|
|
}
|
2006-04-07 10:15:15 +00:00
|
|
|
cdata->data_in_frame=pinfo->fd->num;
|
|
|
|
break;
|
|
|
|
case ISCSI_OPCODE_SCSI_DATA_OUT:
|
|
|
|
cdata->data_out_frame=pinfo->fd->num;
|
|
|
|
break;
|
2004-08-29 01:15:32 +00:00
|
|
|
}
|
|
|
|
|
2003-06-21 10:16:18 +00:00
|
|
|
} else if (opcode == ISCSI_OPCODE_SCSI_COMMAND) {
|
2005-03-17 10:18:18 +00:00
|
|
|
/*we need the LUN value for some of the commands so we can pass it
|
|
|
|
across to the SCSI dissector.
|
|
|
|
Not correct but simple and probably accurate enough :
|
|
|
|
If bit 6 of first bit is 0 then just take second byte as the LUN
|
|
|
|
If bit 6 of first bit is 1, then take 6 bits from first byte
|
|
|
|
and all of second byte and pretend it is the lun value
|
2011-11-09 02:48:51 +00:00
|
|
|
people that care can add host specific dissection of vsa later.
|
2005-03-17 10:18:18 +00:00
|
|
|
|
|
|
|
We need to keep track of this on a per transaction basis since
|
2009-10-08 15:10:43 +00:00
|
|
|
for error recoverylevel 0 and when the A bit is clear in a
|
2005-03-17 10:18:18 +00:00
|
|
|
Data-In PDU, there will not be a LUN field in teh iscsi layer.
|
|
|
|
*/
|
|
|
|
if(tvb_get_guint8(tvb, offset+8)&0x40){
|
2011-11-09 02:48:51 +00:00
|
|
|
/* volume set addressing */
|
|
|
|
lun=tvb_get_guint8(tvb,offset+8)&0x3f;
|
|
|
|
lun<<=8;
|
|
|
|
lun|=tvb_get_guint8(tvb,offset+9);
|
2005-03-17 10:18:18 +00:00
|
|
|
} else {
|
2011-11-09 02:48:51 +00:00
|
|
|
lun=tvb_get_guint8(tvb,offset+9);
|
2005-03-17 10:18:18 +00:00
|
|
|
}
|
2002-02-13 01:17:58 +00:00
|
|
|
|
2006-04-20 09:43:56 +00:00
|
|
|
cdata->itlq.lun=lun;
|
|
|
|
cdata->itlq.first_exchange_frame=pinfo->fd->num;
|
2006-04-07 10:15:15 +00:00
|
|
|
|
2006-04-21 11:08:24 +00:00
|
|
|
itl=(itl_nexus_t *)se_tree_lookup32(iscsi_session->itl, lun);
|
|
|
|
if(!itl){
|
|
|
|
itl=se_alloc(sizeof(itl_nexus_t));
|
|
|
|
itl->cmdset=0xff;
|
2006-10-12 10:54:36 +00:00
|
|
|
itl->conversation=conversation;
|
2006-04-21 11:08:24 +00:00
|
|
|
se_tree_insert32(iscsi_session->itl, lun, itl);
|
|
|
|
}
|
|
|
|
|
2002-01-10 01:28:45 +00:00
|
|
|
}
|
2006-04-21 11:08:24 +00:00
|
|
|
|
|
|
|
if(!itl){
|
|
|
|
itl=(itl_nexus_t *)se_tree_lookup32(iscsi_session->itl, cdata->itlq.lun);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-01-10 01:28:45 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO)) {
|
2001-05-30 18:52:38 +00:00
|
|
|
|
2002-01-10 01:28:45 +00:00
|
|
|
if (opcode != ISCSI_OPCODE_SCSI_COMMAND) {
|
2002-01-31 00:44:36 +00:00
|
|
|
|
2002-12-02 23:43:30 +00:00
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, opcode_str);
|
2002-01-31 00:44:36 +00:00
|
|
|
|
2011-11-09 02:48:51 +00:00
|
|
|
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)",
|
|
|
|
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)",
|
|
|
|
val_to_str (login_status, iscsi_login_status, "0x%x"));
|
|
|
|
}
|
|
|
|
else if (opcode == ISCSI_OPCODE_LOGOUT_COMMAND) {
|
|
|
|
guint8 logoutReason;
|
|
|
|
if(iscsi_protocol_version == ISCSI_PROTOCOL_DRAFT08) {
|
|
|
|
logoutReason = tvb_get_guint8(tvb, offset+11);
|
|
|
|
} else if(iscsi_protocol_version >= ISCSI_PROTOCOL_DRAFT13) {
|
|
|
|
logoutReason = tvb_get_guint8(tvb, offset+1) & 0x7f;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
logoutReason = tvb_get_guint8(tvb, offset+23);
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
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)",
|
|
|
|
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)",
|
|
|
|
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)",
|
|
|
|
val_to_str (asyncEvent, iscsi_asyncevents, "0x%x"));
|
|
|
|
}
|
|
|
|
}
|
2001-05-30 18:52:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* In the interest of speed, if "tree" is NULL, don't do any
|
|
|
|
work not necessary to generate protocol tree items. */
|
|
|
|
if (tree) {
|
2011-11-09 02:48:51 +00:00
|
|
|
proto_item *tp;
|
|
|
|
/* create display subtree for the protocol */
|
|
|
|
tp = proto_tree_add_protocol_format(tree, proto_iscsi, tvb,
|
|
|
|
offset, -1, "iSCSI (%s)",
|
|
|
|
opcode_str);
|
|
|
|
ti = proto_item_add_subtree(tp, ett_iscsi);
|
2003-06-21 10:16:18 +00:00
|
|
|
}
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_Opcode, tvb,
|
2011-11-09 02:48:51 +00:00
|
|
|
offset + 0, 1, opcode);
|
2003-06-21 10:16:18 +00:00
|
|
|
if((opcode & TARGET_OPCODE_BIT) == 0) {
|
2011-11-09 02:48:51 +00:00
|
|
|
/* initiator -> target */
|
|
|
|
gint b = tvb_get_guint8(tvb, offset + 0);
|
|
|
|
if(iscsi_protocol_version == ISCSI_PROTOCOL_DRAFT08) {
|
|
|
|
if(opcode != ISCSI_OPCODE_SCSI_DATA_OUT &&
|
|
|
|
opcode != ISCSI_OPCODE_LOGOUT_COMMAND &&
|
|
|
|
opcode != ISCSI_OPCODE_SNACK_REQUEST)
|
|
|
|
proto_tree_add_boolean(ti, hf_iscsi_X, tvb, offset + 0, 1, b);
|
|
|
|
}
|
|
|
|
if(opcode != ISCSI_OPCODE_SCSI_DATA_OUT &&
|
|
|
|
opcode != ISCSI_OPCODE_LOGIN_COMMAND &&
|
|
|
|
opcode != ISCSI_OPCODE_SNACK_REQUEST)
|
|
|
|
proto_tree_add_boolean(ti, hf_iscsi_I, tvb, offset + 0, 1, b);
|
2003-06-21 10:16:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(opcode == ISCSI_OPCODE_NOP_OUT) {
|
2011-11-09 02:48:51 +00:00
|
|
|
/* NOP Out */
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, tvb_get_ntoh24(tvb, offset + 5));
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_LUN, tvb, offset + 8, 8, ENC_NA);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TargetTransferTag, tvb, offset + 20, 4, ENC_BIG_ENDIAN);
|
|
|
|
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 = handleDataSegment(ti, tvb, offset, data_segment_len, end_offset, hf_iscsi_ping_data);
|
2003-06-21 10:16:18 +00:00
|
|
|
} else if(opcode == ISCSI_OPCODE_NOP_IN) {
|
2011-11-09 02:48:51 +00:00
|
|
|
/* NOP In */
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, tvb_get_ntoh24(tvb, offset + 5));
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_LUN, tvb, offset + 8, 8, ENC_NA);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TargetTransferTag, tvb, offset + 20, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_StatSN, tvb, offset + 24, 4, ENC_BIG_ENDIAN);
|
|
|
|
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 = handleDataSegment(ti, tvb, offset, data_segment_len, end_offset, hf_iscsi_ping_data);
|
2003-06-21 10:16:18 +00:00
|
|
|
} else if(opcode == ISCSI_OPCODE_SCSI_COMMAND) {
|
2011-11-09 02:48:51 +00:00
|
|
|
/* SCSI Command */
|
|
|
|
guint32 ahsLen = tvb_get_guint8(tvb, offset + 4) * 4;
|
|
|
|
{
|
|
|
|
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_SCSICommand_F, tvb, offset + 1, 1, b);
|
|
|
|
proto_tree_add_boolean(tt, hf_iscsi_SCSICommand_R, tvb, offset + 1, 1, b);
|
|
|
|
if(b&0x40){
|
|
|
|
cdata->itlq.task_flags|=SCSI_DATA_READ;
|
|
|
|
}
|
|
|
|
proto_tree_add_boolean(tt, hf_iscsi_SCSICommand_W, tvb, offset + 1, 1, b);
|
|
|
|
if(b&0x20){
|
|
|
|
cdata->itlq.task_flags|=SCSI_DATA_WRITE;
|
|
|
|
}
|
|
|
|
proto_tree_add_uint(tt, hf_iscsi_SCSICommand_Attr, tvb, offset + 1, 1, b);
|
|
|
|
}
|
|
|
|
if(iscsi_protocol_version < ISCSI_PROTOCOL_DRAFT12) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_SCSICommand_CRN, tvb, offset + 3, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, tvb_get_ntoh24(tvb, offset + 5));
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_LUN, tvb, offset + 8, 8, ENC_NA);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_ExpectedDataTransferLength, tvb, offset + 20, 4, ENC_BIG_ENDIAN);
|
|
|
|
cdata->itlq.data_length=tvb_get_ntohl(tvb, offset+20);
|
|
|
|
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;
|
|
|
|
|
|
|
|
while(ahs_offset<(offset+48+ahsLen)){
|
|
|
|
|
|
|
|
ahs_length=tvb_get_ntohs(tvb, ahs_offset);
|
|
|
|
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);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_AHS_type, tvb, ahs_offset, 1, ENC_BIG_ENDIAN);
|
|
|
|
ahs_offset++;
|
|
|
|
|
|
|
|
switch(ahs_type){
|
|
|
|
case 0x01: /* extended CDB */
|
|
|
|
/* additional cdb */
|
|
|
|
ahs_cdb_offset=ahs_offset+1;
|
|
|
|
ahs_cdb_length=ahs_length-1;
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_AHS_extended_cdb, tvb, ahs_cdb_offset, ahs_cdb_length, ENC_NA);
|
|
|
|
ahs_offset+=ahs_length;
|
|
|
|
break;
|
|
|
|
case 0x02: /* bidirectional read data length */
|
|
|
|
/* skip reserved byte */
|
|
|
|
ahs_offset++;
|
|
|
|
/* read data length */
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_AHS_read_data_length, tvb, ahs_offset, 4, ENC_BIG_ENDIAN);
|
|
|
|
cdata->itlq.bidir_data_length=tvb_get_ntohl(tvb, ahs_offset);
|
|
|
|
ahs_offset+=4;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_AHS_blob, tvb, ahs_offset, ahs_length, ENC_NA);
|
|
|
|
ahs_offset+=ahs_length;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* strip off padding bytes */
|
|
|
|
if(ahs_offset&0x0003){
|
|
|
|
ahs_offset=(ahs_offset+3)&0xfffc;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
offset = handleHeaderDigest(iscsi_session, ti, tvb, offset, 48 + ahsLen);
|
|
|
|
|
|
|
|
immediate_data_offset=offset;
|
|
|
|
offset = handleDataSegment(ti, tvb, offset, data_segment_len, end_offset, hf_iscsi_immediate_data);
|
|
|
|
immediate_data_length=offset-immediate_data_offset;
|
2003-06-21 10:16:18 +00:00
|
|
|
} else if(opcode == ISCSI_OPCODE_SCSI_RESPONSE) {
|
2011-11-09 02:48:51 +00:00
|
|
|
/* SCSI 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);
|
|
|
|
proto_tree *tt = proto_item_add_subtree(tf, ett_iscsi_Flags);
|
|
|
|
|
|
|
|
proto_tree_add_boolean(tt, hf_iscsi_SCSIResponse_o, tvb, offset + 1, 1, b);
|
|
|
|
proto_tree_add_boolean(tt, hf_iscsi_SCSIResponse_u, tvb, offset + 1, 1, b);
|
|
|
|
proto_tree_add_boolean(tt, hf_iscsi_SCSIResponse_O, tvb, offset + 1, 1, b);
|
|
|
|
proto_tree_add_boolean(tt, hf_iscsi_SCSIResponse_U, tvb, offset + 1, 1, b);
|
|
|
|
}
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_SCSIResponse_Response, tvb, offset + 2, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_SCSIResponse_Status, tvb, offset + 3, 1, ENC_BIG_ENDIAN);
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, tvb_get_ntoh24(tvb, offset + 5));
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
|
|
|
|
if(iscsi_protocol_version <= ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_SCSIResponse_ResidualCount, tvb, offset + 20, 4, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_StatSN, tvb, offset + 24, 4, ENC_BIG_ENDIAN);
|
|
|
|
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);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_ExpDataSN, tvb, offset + 36, 4, ENC_BIG_ENDIAN);
|
|
|
|
if(iscsi_protocol_version <= ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_SCSIResponse_BidiReadResidualCount, tvb, offset + 44, 4, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_SCSIResponse_BidiReadResidualCount, tvb, offset + 40, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_SCSIResponse_ResidualCount, tvb, offset + 44, 4, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
offset = handleHeaderDigest(iscsi_session, ti, tvb, offset, 48);
|
|
|
|
/* do not update offset here because the data segment is
|
|
|
|
* dissected below */
|
|
|
|
handleDataDigest(ti, tvb, offset, paddedDataSegmentLength);
|
2003-06-21 10:16:18 +00:00
|
|
|
} else if(opcode == ISCSI_OPCODE_TASK_MANAGEMENT_FUNCTION) {
|
2011-11-09 02:48:51 +00:00
|
|
|
/* Task Management Function */
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TaskManagementFunction_Function, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, tvb_get_ntoh24(tvb, offset + 5));
|
|
|
|
}
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_LUN, tvb, offset + 8, 8, ENC_NA);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TaskManagementFunction_ReferencedTaskTag, tvb, offset + 20, 4, ENC_BIG_ENDIAN);
|
|
|
|
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);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_RefCmdSN, tvb, offset + 32, 4, ENC_BIG_ENDIAN);
|
|
|
|
offset = handleHeaderDigest(iscsi_session, ti, tvb, offset, 48);
|
2003-06-21 10:16:18 +00:00
|
|
|
} else if(opcode == ISCSI_OPCODE_TASK_MANAGEMENT_FUNCTION_RESPONSE) {
|
2011-11-09 02:48:51 +00:00
|
|
|
/* Task Management Function Response */
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TaskManagementFunction_Response, tvb, offset + 2, 1, ENC_BIG_ENDIAN);
|
|
|
|
if(iscsi_protocol_version <= ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, tvb_get_ntoh24(tvb, offset + 5));
|
|
|
|
}
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
|
|
|
|
if(iscsi_protocol_version < ISCSI_PROTOCOL_DRAFT12) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TaskManagementFunction_ReferencedTaskTag, tvb, offset + 20, 4, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_StatSN, tvb, offset + 24, 4, ENC_BIG_ENDIAN);
|
|
|
|
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);
|
2003-06-21 10:16:18 +00:00
|
|
|
} else if(opcode == ISCSI_OPCODE_LOGIN_COMMAND) {
|
2011-11-09 02:48:51 +00:00
|
|
|
/* Login Command */
|
|
|
|
int digestsActive = 0;
|
|
|
|
{
|
|
|
|
gint b = tvb_get_guint8(tvb, offset + 1);
|
|
|
|
if(iscsi_protocol_version == ISCSI_PROTOCOL_DRAFT08) {
|
|
|
|
if((b & CSG_MASK) >= ISCSI_CSG_OPERATIONAL_NEGOTIATION)
|
|
|
|
digestsActive = 1;
|
|
|
|
}
|
2001-10-19 20:53:14 +00:00
|
|
|
#if 0
|
2011-11-09 02:48:51 +00:00
|
|
|
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);
|
2001-10-19 20:53:14 +00:00
|
|
|
#endif
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2011-11-09 02:48:51 +00:00
|
|
|
proto_tree_add_boolean(ti, hf_iscsi_Login_T, tvb, offset + 1, 1, b);
|
|
|
|
if(iscsi_protocol_version >= ISCSI_PROTOCOL_DRAFT13) {
|
|
|
|
proto_tree_add_boolean(ti, hf_iscsi_Login_C, tvb, offset + 1, 1, b);
|
|
|
|
}
|
|
|
|
if(iscsi_protocol_version == ISCSI_PROTOCOL_DRAFT08) {
|
|
|
|
proto_tree_add_boolean(ti, hf_iscsi_Login_X, tvb, offset + 1, 1, b);
|
|
|
|
}
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_Login_CSG, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
|
|
|
|
|
|
|
|
/* NSG is undefined unless T is set */
|
|
|
|
if(b&0x80){
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_Login_NSG, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_VersionMax, tvb, offset + 2, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_VersionMin, tvb, offset + 3, 1, ENC_BIG_ENDIAN);
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, tvb_get_ntoh24(tvb, offset + 5));
|
|
|
|
if(iscsi_protocol_version == ISCSI_PROTOCOL_DRAFT08) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_CID, tvb, offset + 8, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_ISID8, tvb, offset + 12, 2, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
proto_item *tf = proto_tree_add_item(ti, hf_iscsi_ISID, tvb, offset + 8, 6, ENC_NA);
|
|
|
|
proto_tree *tt = proto_item_add_subtree(tf, ett_iscsi_ISID);
|
|
|
|
if(iscsi_protocol_version == ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(tt, hf_iscsi_ISID_Type, tvb, offset + 8, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(tt, hf_iscsi_ISID_NamingAuthority, tvb, offset + 9, 3, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(tt, hf_iscsi_ISID_Qualifier, tvb, offset + 12, 2, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
proto_tree_add_item(tt, hf_iscsi_ISID_t, tvb, offset + 8, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(tt, hf_iscsi_ISID_a, tvb, offset + 8, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(tt, hf_iscsi_ISID_b, tvb, offset + 9, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(tt, hf_iscsi_ISID_c, tvb, offset + 11, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(tt, hf_iscsi_ISID_d, tvb, offset + 12, 2, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(iscsi_protocol_version < ISCSI_PROTOCOL_DRAFT12) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TSID, tvb, offset + 14, 2, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TSIH, tvb, offset + 14, 2, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT08) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_CID, tvb, offset + 20, 2, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
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(digestsActive){
|
|
|
|
offset = handleHeaderDigest(iscsi_session, ti, tvb, offset, 48);
|
|
|
|
} else {
|
|
|
|
offset += 48;
|
|
|
|
}
|
|
|
|
offset = handleDataSegmentAsTextKeys(pinfo, ti, tvb, offset, data_segment_len, end_offset, digestsActive);
|
2003-06-21 10:16:18 +00:00
|
|
|
} else if(opcode == ISCSI_OPCODE_LOGIN_RESPONSE) {
|
2011-11-09 02:48:51 +00:00
|
|
|
/* Login Response */
|
|
|
|
int digestsActive = 0;
|
|
|
|
{
|
|
|
|
gint b = tvb_get_guint8(tvb, offset + 1);
|
|
|
|
if(iscsi_protocol_version == ISCSI_PROTOCOL_DRAFT08) {
|
|
|
|
if((b & CSG_MASK) >= ISCSI_CSG_OPERATIONAL_NEGOTIATION)
|
|
|
|
digestsActive = 1;
|
|
|
|
}
|
2001-10-19 20:53:14 +00:00
|
|
|
#if 0
|
2011-11-09 02:48:51 +00:00
|
|
|
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);
|
2001-10-19 20:53:14 +00:00
|
|
|
#endif
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2011-11-09 02:48:51 +00:00
|
|
|
proto_tree_add_boolean(ti, hf_iscsi_Login_T, tvb, offset + 1, 1, b);
|
|
|
|
if(iscsi_protocol_version >= ISCSI_PROTOCOL_DRAFT13) {
|
|
|
|
proto_tree_add_boolean(ti, hf_iscsi_Login_C, tvb, offset + 1, 1, b);
|
|
|
|
}
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_Login_CSG, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
|
|
|
|
/* NSG is undefined unless T is set */
|
|
|
|
if(b&0x80){
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_Login_NSG, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_VersionMax, tvb, offset + 2, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_VersionActive, tvb, offset + 3, 1, ENC_BIG_ENDIAN);
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, tvb_get_ntoh24(tvb, offset + 5));
|
|
|
|
if(iscsi_protocol_version == ISCSI_PROTOCOL_DRAFT08) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_ISID8, tvb, offset + 12, 2, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
proto_item *tf = proto_tree_add_item(ti, hf_iscsi_ISID, tvb, offset + 8, 6, ENC_NA);
|
|
|
|
proto_tree *tt = proto_item_add_subtree(tf, ett_iscsi_ISID);
|
|
|
|
if(iscsi_protocol_version == ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(tt, hf_iscsi_ISID_Type, tvb, offset + 8, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(tt, hf_iscsi_ISID_NamingAuthority, tvb, offset + 9, 3, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(tt, hf_iscsi_ISID_Qualifier, tvb, offset + 12, 2, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
proto_tree_add_item(tt, hf_iscsi_ISID_t, tvb, offset + 8, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(tt, hf_iscsi_ISID_a, tvb, offset + 8, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(tt, hf_iscsi_ISID_b, tvb, offset + 9, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(tt, hf_iscsi_ISID_c, tvb, offset + 11, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(tt, hf_iscsi_ISID_d, tvb, offset + 12, 2, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(iscsi_protocol_version < ISCSI_PROTOCOL_DRAFT12) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TSID, tvb, offset + 14, 2, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TSIH, tvb, offset + 14, 2, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_StatSN, tvb, offset + 24, 4, ENC_BIG_ENDIAN);
|
|
|
|
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);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_Login_Status, tvb, offset + 36, 2, ENC_BIG_ENDIAN);
|
|
|
|
if(digestsActive){
|
|
|
|
offset = handleHeaderDigest(iscsi_session, ti, tvb, offset, 48);
|
|
|
|
} else {
|
|
|
|
offset += 48;
|
|
|
|
}
|
|
|
|
offset = handleDataSegmentAsTextKeys(pinfo, ti, tvb, offset, data_segment_len, end_offset, digestsActive);
|
2003-06-21 10:16:18 +00:00
|
|
|
} else if(opcode == ISCSI_OPCODE_TEXT_COMMAND) {
|
2011-11-09 02:48:51 +00:00
|
|
|
/* Text Command */
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
if(iscsi_protocol_version >= ISCSI_PROTOCOL_DRAFT13) {
|
|
|
|
proto_tree_add_boolean(tt, hf_iscsi_Text_C, tvb, offset + 1, 1, b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, tvb_get_ntoh24(tvb, offset + 5));
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_LUN, tvb, offset + 8, 8, ENC_NA);
|
|
|
|
}
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TargetTransferTag, tvb, offset + 20, 4, ENC_BIG_ENDIAN);
|
|
|
|
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(pinfo, ti, tvb, offset, data_segment_len, end_offset, TRUE);
|
2003-06-21 10:16:18 +00:00
|
|
|
} else if(opcode == ISCSI_OPCODE_TEXT_RESPONSE) {
|
2011-11-09 02:48:51 +00:00
|
|
|
/* Text 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);
|
|
|
|
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);
|
|
|
|
if(iscsi_protocol_version >= ISCSI_PROTOCOL_DRAFT13) {
|
|
|
|
proto_tree_add_boolean(tt, hf_iscsi_Text_C, tvb, offset + 1, 1, b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, tvb_get_ntoh24(tvb, offset + 5));
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_LUN, tvb, offset + 8, 8, ENC_NA);
|
|
|
|
}
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TargetTransferTag, tvb, offset + 20, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_StatSN, tvb, offset + 24, 4, ENC_BIG_ENDIAN);
|
|
|
|
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(pinfo, ti, tvb, offset, data_segment_len, end_offset, TRUE);
|
2003-06-21 10:16:18 +00:00
|
|
|
} else if(opcode == ISCSI_OPCODE_SCSI_DATA_OUT) {
|
2011-11-09 02:48:51 +00:00
|
|
|
/* SCSI Data Out (write) */
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, tvb_get_ntoh24(tvb, offset + 5));
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_LUN, tvb, offset + 8, 8, ENC_NA);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TargetTransferTag, tvb, offset + 20, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_ExpStatSN, tvb, offset + 28, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_DataSN, tvb, offset + 36, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_BufferOffset, tvb, offset + 40, 4, ENC_BIG_ENDIAN);
|
|
|
|
data_offset=tvb_get_ntohl(tvb, offset+40);
|
|
|
|
|
|
|
|
offset = handleHeaderDigest(iscsi_session, ti, tvb, offset, 48);
|
|
|
|
/* do not update offset here because the data segment is
|
|
|
|
* dissected below */
|
|
|
|
handleDataDigest(ti, tvb, offset, paddedDataSegmentLength);
|
2003-06-21 10:16:18 +00:00
|
|
|
} else if(opcode == ISCSI_OPCODE_SCSI_DATA_IN) {
|
2011-11-09 02:48:51 +00:00
|
|
|
/* SCSI Data In (read) */
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
|
|
|
if(b&ISCSI_SCSI_DATA_FLAG_S){
|
|
|
|
S_bit=TRUE;
|
|
|
|
}
|
|
|
|
proto_tree_add_boolean(tt, hf_iscsi_SCSIData_F, tvb, offset + 1, 1, b);
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT08) {
|
|
|
|
proto_tree_add_boolean(tt, hf_iscsi_SCSIData_A, 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);
|
|
|
|
}
|
|
|
|
if(S_bit){
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_SCSIResponse_Status, tvb, offset + 3, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, tvb_get_ntoh24(tvb, offset + 5));
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_LUN, tvb, offset + 8, 8, ENC_NA);
|
|
|
|
}
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
|
|
|
|
if(iscsi_protocol_version <= ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_SCSIData_ResidualCount, tvb, offset + 20, 4, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TargetTransferTag, tvb, offset + 20, 4, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_StatSN, tvb, offset + 24, 4, ENC_BIG_ENDIAN);
|
|
|
|
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);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_DataSN, tvb, offset + 36, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_BufferOffset, tvb, offset + 40, 4, ENC_BIG_ENDIAN);
|
|
|
|
data_offset=tvb_get_ntohl(tvb, offset+40);
|
|
|
|
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_SCSIData_ResidualCount, tvb, offset + 44, 4, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
offset = handleHeaderDigest(iscsi_session, ti, tvb, offset, 48);
|
|
|
|
/* do not update offset here because the data segment is
|
|
|
|
* dissected below */
|
|
|
|
handleDataDigest(ti, tvb, offset, paddedDataSegmentLength);
|
2003-06-21 10:16:18 +00:00
|
|
|
} else if(opcode == ISCSI_OPCODE_LOGOUT_COMMAND) {
|
2011-11-09 02:48:51 +00:00
|
|
|
/* Logout Command */
|
|
|
|
if(iscsi_protocol_version >= ISCSI_PROTOCOL_DRAFT13) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_Logout_Reason, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, tvb_get_ntoh24(tvb, offset + 5));
|
|
|
|
}
|
|
|
|
if(iscsi_protocol_version == ISCSI_PROTOCOL_DRAFT08) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_CID, tvb, offset + 8, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_Logout_Reason, tvb, offset + 11, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT08) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_CID, tvb, offset + 20, 2, ENC_BIG_ENDIAN);
|
|
|
|
if(iscsi_protocol_version < ISCSI_PROTOCOL_DRAFT13) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_Logout_Reason, tvb, offset + 23, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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);
|
2003-06-21 10:16:18 +00:00
|
|
|
} else if(opcode == ISCSI_OPCODE_LOGOUT_RESPONSE) {
|
2011-11-09 02:48:51 +00:00
|
|
|
/* Logout Response */
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_Logout_Response, tvb, offset + 2, 1, ENC_BIG_ENDIAN);
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, tvb_get_ntoh24(tvb, offset + 5));
|
|
|
|
}
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_StatSN, tvb, offset + 24, 4, ENC_BIG_ENDIAN);
|
|
|
|
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);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_Time2Wait, tvb, offset + 40, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_Time2Retain, tvb, offset + 42, 2, ENC_BIG_ENDIAN);
|
|
|
|
offset = handleHeaderDigest(iscsi_session, ti, tvb, offset, 48);
|
2003-06-21 10:16:18 +00:00
|
|
|
} else if(opcode == ISCSI_OPCODE_SNACK_REQUEST) {
|
2011-11-09 02:48:51 +00:00
|
|
|
/* SNACK Request */
|
|
|
|
{
|
2001-10-19 20:53:14 +00:00
|
|
|
#if 0
|
2011-11-09 02:48:51 +00:00
|
|
|
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);
|
2001-10-19 20:53:14 +00:00
|
|
|
#endif
|
2001-05-31 19:20:41 +00:00
|
|
|
|
2011-11-09 02:48:51 +00:00
|
|
|
proto_tree_add_item(ti, hf_iscsi_snack_type, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, tvb_get_ntoh24(tvb, offset + 5));
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_LUN, tvb, offset + 8, 8, ENC_NA);
|
|
|
|
}
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
|
|
|
|
if(iscsi_protocol_version <= ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_BegRun, tvb, offset + 20, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_RunLength, tvb, offset + 24, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_ExpStatSN, tvb, offset + 28, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_ExpDataSN, tvb, offset + 36, 4, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TargetTransferTag, tvb, offset + 20, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_ExpStatSN, tvb, offset + 28, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_BegRun, tvb, offset + 40, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_RunLength, tvb, offset + 44, 4, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
offset = handleHeaderDigest(iscsi_session, ti, tvb, offset, 48);
|
2003-06-21 10:16:18 +00:00
|
|
|
} else if(opcode == ISCSI_OPCODE_R2T) {
|
2011-11-09 02:48:51 +00:00
|
|
|
/* R2T */
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, tvb_get_ntoh24(tvb, offset + 5));
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_LUN, tvb, offset + 8, 8, ENC_NA);
|
|
|
|
}
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_InitiatorTaskTag, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TargetTransferTag, tvb, offset + 20, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_StatSN, tvb, offset + 24, 4, ENC_BIG_ENDIAN);
|
|
|
|
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);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_R2TSN, tvb, offset + 36, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_BufferOffset, tvb, offset + 40, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_DesiredDataLength, tvb, offset + 44, 4, ENC_BIG_ENDIAN);
|
|
|
|
offset = handleHeaderDigest(iscsi_session, ti, tvb, offset, 48);
|
2003-06-21 10:16:18 +00:00
|
|
|
} else if(opcode == ISCSI_OPCODE_ASYNC_MESSAGE) {
|
2011-11-09 02:48:51 +00:00
|
|
|
int dsl, snsl;
|
|
|
|
|
|
|
|
/* Asynchronous Message */
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
dsl=tvb_get_ntoh24(tvb, offset+5);
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, tvb_get_ntoh24(tvb, offset + 5));
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_LUN, tvb, offset + 8, 8, ENC_NA);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_StatSN, tvb, offset + 24, 4, ENC_BIG_ENDIAN);
|
|
|
|
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);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_AsyncEvent, tvb, offset + 36, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_EventVendorCode, tvb, offset + 37, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_Parameter1, tvb, offset + 38, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_Parameter2, tvb, offset + 40, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_Parameter3, tvb, offset + 42, 2, ENC_BIG_ENDIAN);
|
|
|
|
offset = handleHeaderDigest(iscsi_session, ti, tvb, offset, 48);
|
|
|
|
|
|
|
|
/* If we have a datasegment this contains scsi sense info followed
|
|
|
|
* by iscsi event data. (rfc3720 10.9.4)
|
|
|
|
*/
|
|
|
|
if(dsl){
|
|
|
|
snsl=tvb_get_ntohs(tvb, offset);
|
|
|
|
offset+=2;
|
|
|
|
if(snsl){
|
|
|
|
tvbuff_t *data_tvb;
|
|
|
|
int tvb_len, tvb_rlen;
|
|
|
|
|
|
|
|
tvb_len=tvb_length_remaining(tvb, offset);
|
|
|
|
if(tvb_len>snsl)
|
|
|
|
tvb_len=snsl;
|
|
|
|
tvb_rlen=tvb_reported_length_remaining(tvb, offset);
|
|
|
|
if(tvb_rlen>snsl)
|
|
|
|
tvb_rlen=snsl;
|
|
|
|
data_tvb=tvb_new_subset(tvb, offset, tvb_len, tvb_rlen);
|
|
|
|
dissect_scsi_snsinfo (data_tvb, pinfo, tree, 0,
|
|
|
|
tvb_len,
|
|
|
|
&cdata->itlq, itl);
|
|
|
|
|
|
|
|
offset+=snsl;
|
|
|
|
}
|
|
|
|
if((end_offset-offset)>0){
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_async_event_data, tvb, offset, end_offset-offset, ENC_NA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
offset=end_offset;
|
2003-06-21 10:16:18 +00:00
|
|
|
} else if(opcode == ISCSI_OPCODE_REJECT) {
|
2011-11-09 02:48:51 +00:00
|
|
|
proto_item *tf;
|
|
|
|
proto_tree *tt;
|
|
|
|
int next_opcode;
|
|
|
|
const char *next_opcode_str;
|
|
|
|
|
|
|
|
/* Reject */
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_Reject_Reason, tvb, offset + 2, 1, ENC_BIG_ENDIAN);
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, tvb_get_ntoh24(tvb, offset + 5));
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_StatSN, tvb, offset + 24, 4, ENC_BIG_ENDIAN);
|
|
|
|
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);
|
|
|
|
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) & 0x3f;
|
|
|
|
next_opcode_str = match_strval(next_opcode, iscsi_opcodes);
|
|
|
|
|
|
|
|
tf = proto_tree_add_text(ti, tvb, offset, -1, "Rejected Header");
|
|
|
|
tt = proto_item_add_subtree(tf, ett_iscsi_RejectHeader);
|
|
|
|
|
|
|
|
dissect_iscsi_pdu(tvb, pinfo, tt, offset, next_opcode, next_opcode_str, 0, iscsi_session, conversation);
|
2003-06-21 10:16:18 +00:00
|
|
|
} else if(opcode == ISCSI_OPCODE_VENDOR_SPECIFIC_I0 ||
|
2011-11-09 02:48:51 +00:00
|
|
|
opcode == ISCSI_OPCODE_VENDOR_SPECIFIC_I1 ||
|
|
|
|
opcode == ISCSI_OPCODE_VENDOR_SPECIFIC_I2 ||
|
|
|
|
opcode == ISCSI_OPCODE_VENDOR_SPECIFIC_T0 ||
|
|
|
|
opcode == ISCSI_OPCODE_VENDOR_SPECIFIC_T1 ||
|
|
|
|
opcode == ISCSI_OPCODE_VENDOR_SPECIFIC_T2) {
|
|
|
|
/* Vendor specific opcodes */
|
|
|
|
if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) {
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_DataSegmentLength, tvb, offset + 5, 3, tvb_get_ntoh24(tvb, offset + 5));
|
|
|
|
offset = handleHeaderDigest(iscsi_session, ti, tvb, offset, 48);
|
|
|
|
offset = handleDataSegment(ti, tvb, offset, data_segment_len, end_offset, hf_iscsi_vendor_specific_data);
|
2001-10-19 20:53:14 +00:00
|
|
|
}
|
2002-05-14 21:35:17 +00:00
|
|
|
|
2004-02-18 09:10:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* handle request/response matching */
|
2006-04-07 10:15:15 +00:00
|
|
|
switch(opcode){
|
|
|
|
case ISCSI_OPCODE_SCSI_RESPONSE:
|
2006-04-20 09:43:56 +00:00
|
|
|
if (cdata->itlq.first_exchange_frame){
|
2006-04-07 10:15:15 +00:00
|
|
|
nstime_t delta_time;
|
2006-04-20 09:43:56 +00:00
|
|
|
proto_tree_add_uint(ti, hf_iscsi_request_frame, tvb, 0, 0, cdata->itlq.first_exchange_frame);
|
|
|
|
nstime_delta(&delta_time, &pinfo->fd->abs_ts, &cdata->itlq.fc_time);
|
2006-04-07 10:15:15 +00:00
|
|
|
proto_tree_add_time(ti, hf_iscsi_time, tvb, 0, 0, &delta_time);
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
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){
|
2006-04-20 09:43:56 +00:00
|
|
|
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);
|
2006-04-07 10:15:15 +00:00
|
|
|
} else {
|
2006-04-20 09:43:56 +00:00
|
|
|
if (cdata->itlq.first_exchange_frame){
|
2011-11-09 02:48:51 +00:00
|
|
|
nstime_t delta_time;
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_request_frame, tvb, 0, 0, cdata->itlq.first_exchange_frame);
|
|
|
|
nstime_delta(&delta_time, &pinfo->fd->abs_ts, &cdata->itlq.fc_time);
|
|
|
|
proto_tree_add_time(ti, hf_iscsi_time, tvb, 0, 0, &delta_time);
|
2006-04-07 10:15:15 +00:00
|
|
|
}
|
2004-02-18 09:10:02 +00:00
|
|
|
}
|
2006-04-07 10:15:15 +00:00
|
|
|
if (cdata->data_out_frame)
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_data_out_frame, tvb, 0, 0, cdata->data_out_frame);
|
|
|
|
break;
|
|
|
|
case ISCSI_OPCODE_SCSI_DATA_OUT:
|
2006-04-20 09:43:56 +00:00
|
|
|
if (cdata->itlq.first_exchange_frame)
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_request_frame, tvb, 0, 0, cdata->itlq.first_exchange_frame);
|
2006-04-07 10:15:15 +00:00
|
|
|
if (cdata->data_in_frame)
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_data_in_frame, tvb, 0, 0, cdata->data_in_frame);
|
2006-04-20 09:43:56 +00:00
|
|
|
if (cdata->itlq.last_exchange_frame)
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_response_frame, tvb, 0, 0, cdata->itlq.last_exchange_frame);
|
2006-04-07 10:15:15 +00:00
|
|
|
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);
|
2006-04-20 09:43:56 +00:00
|
|
|
if (cdata->itlq.last_exchange_frame)
|
|
|
|
proto_tree_add_uint(ti, hf_iscsi_response_frame, tvb, 0, 0, cdata->itlq.last_exchange_frame);
|
2006-04-07 10:15:15 +00:00
|
|
|
break;
|
2004-02-18 09:10:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-06-21 10:16:18 +00:00
|
|
|
proto_item_set_len(ti, offset - original_offset);
|
|
|
|
|
2002-05-14 21:35:17 +00:00
|
|
|
if((opcode & ((iscsi_protocol_version == ISCSI_PROTOCOL_DRAFT08)?
|
2011-11-09 02:48:51 +00:00
|
|
|
~(X_BIT | I_BIT) :
|
|
|
|
~I_BIT)) == ISCSI_OPCODE_SCSI_COMMAND) {
|
|
|
|
tvbuff_t *cdb_tvb, *data_tvb;
|
|
|
|
int tvb_len, tvb_rlen;
|
2005-05-29 02:30:49 +00:00
|
|
|
|
2002-01-10 01:28:45 +00:00
|
|
|
/* SCSI Command */
|
2011-11-09 02:48:51 +00:00
|
|
|
tvb_len=tvb_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;
|
|
|
|
|
|
|
|
/* We have a variable length CDB where bytes >16 is transported
|
|
|
|
* in the AHS.
|
|
|
|
*/
|
|
|
|
cdb_buf=g_malloc(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 */
|
|
|
|
tvb_memcpy(tvb, cdb_buf+16, ahs_cdb_offset, ahs_cdb_length);
|
|
|
|
|
|
|
|
cdb_tvb = tvb_new_child_real_data(tvb, cdb_buf,
|
|
|
|
ahs_cdb_length+16,
|
|
|
|
ahs_cdb_length+16);
|
|
|
|
tvb_set_free_cb(cdb_tvb, g_free);
|
|
|
|
|
|
|
|
add_new_data_source(pinfo, cdb_tvb, "CDB+AHS");
|
|
|
|
} else {
|
|
|
|
if(tvb_len>16){
|
|
|
|
tvb_len=16;
|
|
|
|
}
|
|
|
|
if(tvb_rlen>16){
|
|
|
|
tvb_rlen=16;
|
|
|
|
}
|
|
|
|
cdb_tvb=tvb_new_subset(tvb, cdb_offset, tvb_len, tvb_rlen);
|
|
|
|
}
|
2006-04-21 22:00:38 +00:00
|
|
|
dissect_scsi_cdb(cdb_tvb, pinfo, tree, SCSI_DEV_UNKNOWN, &cdata->itlq, itl);
|
2011-11-09 02:48:51 +00:00
|
|
|
/* we dont want the immediata below to overwrite our CDB info */
|
|
|
|
if (check_col(pinfo->cinfo, COL_INFO)) {
|
|
|
|
col_set_fence(pinfo->cinfo, COL_INFO);
|
|
|
|
}
|
|
|
|
/* where there any ImmediateData ? */
|
|
|
|
if(immediate_data_length){
|
2005-05-29 02:30:49 +00:00
|
|
|
/* Immediate Data TVB */
|
2011-11-09 02:48:51 +00:00
|
|
|
tvb_len=tvb_length_remaining(tvb, immediate_data_offset);
|
|
|
|
if(tvb_len>(int)immediate_data_length)
|
|
|
|
tvb_len=immediate_data_length;
|
|
|
|
tvb_rlen=tvb_reported_length_remaining(tvb, immediate_data_offset);
|
|
|
|
if(tvb_rlen>(int)immediate_data_length)
|
|
|
|
tvb_rlen=immediate_data_length;
|
|
|
|
data_tvb=tvb_new_subset(tvb, immediate_data_offset, tvb_len, tvb_rlen);
|
2005-05-29 03:18:53 +00:00
|
|
|
dissect_scsi_payload (data_tvb, pinfo, tree,
|
2011-11-09 02:48:51 +00:00
|
|
|
TRUE,
|
|
|
|
&cdata->itlq, itl,
|
|
|
|
0);
|
|
|
|
}
|
2002-01-10 01:28:45 +00:00
|
|
|
}
|
|
|
|
else if (opcode == ISCSI_OPCODE_SCSI_RESPONSE) {
|
|
|
|
if (scsi_status == 0x2) {
|
|
|
|
/* A SCSI response with Check Condition contains sense data */
|
|
|
|
/* offset is setup correctly by the iscsi code for response above */
|
2011-11-09 02:48:51 +00:00
|
|
|
if((end_offset - offset) >= 2) {
|
|
|
|
int senseLen = tvb_get_ntohs(tvb, offset);
|
|
|
|
if(ti != NULL)
|
|
|
|
proto_tree_add_item(ti, hf_iscsi_SenseLength, tvb, offset, 2, ENC_BIG_ENDIAN);
|
|
|
|
offset += 2;
|
|
|
|
if(senseLen > 0){
|
|
|
|
tvbuff_t *data_tvb;
|
|
|
|
int tvb_len, tvb_rlen;
|
|
|
|
|
|
|
|
tvb_len=tvb_length_remaining(tvb, offset);
|
|
|
|
if(tvb_len>senseLen)
|
|
|
|
tvb_len=senseLen;
|
|
|
|
tvb_rlen=tvb_reported_length_remaining(tvb, offset);
|
|
|
|
if(tvb_rlen>senseLen)
|
|
|
|
tvb_rlen=senseLen;
|
|
|
|
data_tvb=tvb_new_subset(tvb, offset, tvb_len, tvb_rlen);
|
|
|
|
dissect_scsi_snsinfo (data_tvb, pinfo, tree, 0,
|
|
|
|
tvb_len,
|
|
|
|
&cdata->itlq, itl);
|
|
|
|
}
|
|
|
|
}
|
2002-01-10 01:28:45 +00:00
|
|
|
}
|
|
|
|
else {
|
2006-04-21 11:08:24 +00:00
|
|
|
dissect_scsi_rsp(tvb, pinfo, tree, &cdata->itlq, itl, scsi_status);
|
2002-01-10 01:28:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((opcode == ISCSI_OPCODE_SCSI_DATA_IN) ||
|
|
|
|
(opcode == ISCSI_OPCODE_SCSI_DATA_OUT)) {
|
2011-11-09 02:48:51 +00:00
|
|
|
tvbuff_t *data_tvb;
|
|
|
|
int tvb_len, tvb_rlen;
|
2005-05-29 02:30:49 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* offset is setup correctly by the iscsi code for response above */
|
2011-11-09 02:48:51 +00:00
|
|
|
tvb_len=tvb_length_remaining(tvb, offset);
|
|
|
|
if(tvb_len>(int)data_segment_len)
|
|
|
|
tvb_len=data_segment_len;
|
|
|
|
tvb_rlen=tvb_reported_length_remaining(tvb, offset);
|
|
|
|
if(tvb_rlen>(int)data_segment_len)
|
|
|
|
tvb_rlen=data_segment_len;
|
|
|
|
data_tvb=tvb_new_subset(tvb, offset, tvb_len, tvb_rlen);
|
2005-05-29 03:18:53 +00:00
|
|
|
dissect_scsi_payload (data_tvb, pinfo, tree,
|
2011-11-09 02:48:51 +00:00
|
|
|
(opcode==ISCSI_OPCODE_SCSI_DATA_OUT),
|
|
|
|
&cdata->itlq, itl,
|
|
|
|
data_offset);
|
2006-04-07 10:15:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(S_bit){
|
2006-04-21 11:08:24 +00:00
|
|
|
dissect_scsi_rsp(tvb, pinfo, tree, &cdata->itlq, itl, scsi_status);
|
2002-01-10 01:28:45 +00:00
|
|
|
}
|
2001-05-30 18:52:38 +00:00
|
|
|
}
|
|
|
|
|
2001-10-19 20:53:14 +00:00
|
|
|
static gboolean
|
2003-06-15 02:02:59 +00:00
|
|
|
dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean check_port) {
|
2001-10-19 20:53:14 +00:00
|
|
|
/* Set up structures needed to add the protocol subtree and manage it */
|
2001-10-21 17:20:10 +00:00
|
|
|
guint iSCSIPdusDissected = 0;
|
2001-10-19 20:53:14 +00:00
|
|
|
guint offset = 0;
|
2007-10-23 05:50:00 +00:00
|
|
|
guint32 available_bytes = tvb_length(tvb);
|
2004-08-28 23:54:16 +00:00
|
|
|
int digestsActive = 1;
|
2004-08-29 01:15:32 +00:00
|
|
|
conversation_t *conversation = NULL;
|
2004-08-29 02:55:02 +00:00
|
|
|
iscsi_session_t *iscsi_session=NULL;
|
2006-06-20 13:16:50 +00:00
|
|
|
guint8 opcode, tmpbyte;
|
2001-10-19 20:53:14 +00:00
|
|
|
|
2011-03-25 20:04:54 +00:00
|
|
|
if (available_bytes < 48) {
|
2011-11-09 02:48:51 +00:00
|
|
|
/* heuristic already rejected the packet if size < 48,
|
|
|
|
assume it's an iscsi packet with a segmented header */
|
2008-07-30 14:28:04 +00:00
|
|
|
pinfo->desegment_offset = offset;
|
2011-03-25 20:04:54 +00:00
|
|
|
pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
|
2008-07-30 14:28:04 +00:00
|
|
|
return TRUE;
|
2001-10-19 20:53:14 +00:00
|
|
|
}
|
|
|
|
|
2006-06-20 13:16:50 +00:00
|
|
|
opcode = tvb_get_guint8(tvb, offset + 0);
|
|
|
|
opcode &= OPCODE_MASK;
|
|
|
|
|
|
|
|
/* heuristics to verify that the packet looks sane. the heuristics
|
|
|
|
* are based on the RFC version of iscsi.
|
|
|
|
* (we should retire support for older iscsi versions in wireshark)
|
|
|
|
* -- ronnie s
|
|
|
|
*/
|
|
|
|
/* opcode must be any of the ones from the standard
|
|
|
|
* also check the header that it looks "sane"
|
|
|
|
* all reserved or undefined bits in iscsi must be set to zero.
|
|
|
|
*/
|
|
|
|
switch(opcode){
|
2006-09-29 11:12:18 +00:00
|
|
|
case ISCSI_OPCODE_NOP_IN:
|
2011-11-09 02:48:51 +00:00
|
|
|
/* top two bits of byte 0 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+0)&0xc0){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* byte 1 must be 0x80 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+1)!=0x80){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* bytes 2 and 3 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+2)||tvb_get_guint8(tvb, offset+3)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2006-06-20 13:16:50 +00:00
|
|
|
case ISCSI_OPCODE_NOP_OUT:
|
2011-11-09 02:48:51 +00:00
|
|
|
/* top bit of byte 0 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+0)&0x80){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* byte 1 must be 0x80 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+1)!=0x80){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* bytes 2 and 3 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+2)||tvb_get_guint8(tvb, offset+3)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* assume ITT and TTT must always be non NULL (ok they can be NULL
|
|
|
|
* from time to time but it usually means we are in the middle
|
|
|
|
* of a zeroed datablock).
|
|
|
|
*/
|
|
|
|
if(!tvb_get_letohl(tvb,offset+16) || !tvb_get_letohl(tvb,offset+20)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* all reserved bytes between 32 - 47 must be null */
|
|
|
|
if(tvb_get_letohl(tvb,offset+32)
|
|
|
|
|| tvb_get_letohl(tvb,offset+36)
|
|
|
|
|| tvb_get_letohl(tvb,offset+40)
|
|
|
|
|| tvb_get_letohl(tvb,offset+44)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2006-06-20 13:16:50 +00:00
|
|
|
case ISCSI_OPCODE_LOGIN_COMMAND:
|
2011-11-09 02:48:51 +00:00
|
|
|
/* top two bits in byte 0 must be 0x40 */
|
|
|
|
if((tvb_get_guint8(tvb, offset+0)&0xc0)!=0x40){
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* 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);
|
|
|
|
switch(tmpbyte&0xf0){
|
|
|
|
case 0x80:
|
|
|
|
case 0x40:
|
|
|
|
case 0x00:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* CSG and NSG must not be 2 */
|
|
|
|
if(((tmpbyte & 0x03) == 0x02)
|
|
|
|
|| ((tmpbyte & 0x0c) == 0x08)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* if T bit is set NSG must not be 0 */
|
|
|
|
if(tmpbyte&0x80){
|
|
|
|
if(!(tmpbyte&0x03)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* should we test that datasegmentlen is non zero? */
|
|
|
|
break;
|
2006-06-20 13:16:50 +00:00
|
|
|
case ISCSI_OPCODE_LOGIN_RESPONSE:
|
2011-11-09 02:48:51 +00:00
|
|
|
/* top two bits in byte 0 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+0)&0xc0){
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* 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);
|
|
|
|
switch(tmpbyte&0xf0){
|
|
|
|
case 0x80:
|
|
|
|
case 0x40:
|
|
|
|
case 0x00:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* CSG and NSG must not be 2 */
|
|
|
|
if(((tmpbyte & 0x03) == 0x02)
|
|
|
|
|| ((tmpbyte & 0x0c) == 0x08)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* if T bit is set NSG must not be 0 */
|
|
|
|
if(tmpbyte&0x80){
|
|
|
|
if(!(tmpbyte&0x03)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* the 32bit words at offsets 20, 40, 44 must be zero */
|
|
|
|
if(tvb_get_letohl(tvb,offset+20)
|
|
|
|
|| tvb_get_letohl(tvb,offset+40)
|
|
|
|
|| tvb_get_letohl(tvb,offset+44)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* the two bytes at offset 38 must be zero */
|
|
|
|
if(tvb_get_letohs(tvb,offset+38)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* should we test that datasegmentlen is non zero unless we just
|
|
|
|
* entered full featured phase?
|
|
|
|
*/
|
|
|
|
break;
|
2006-06-20 13:16:50 +00:00
|
|
|
case ISCSI_OPCODE_TASK_MANAGEMENT_FUNCTION:
|
2011-11-09 02:48:51 +00:00
|
|
|
/* top bit in byte 0 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+0)&0x80){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* top bit in byte 1 must be set */
|
|
|
|
tmpbyte=tvb_get_guint8(tvb, offset+1);
|
|
|
|
if(!(tmpbyte&0x80)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* Function must be known */
|
|
|
|
if(!match_strval(tmpbyte&0x7f, iscsi_task_management_functions)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* bytes 2,3 must be null */
|
|
|
|
if(tvb_get_letohs(tvb,offset+2)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* ahs and dsl must be null */
|
|
|
|
if(tvb_get_letohl(tvb,offset+4)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2006-06-20 13:16:50 +00:00
|
|
|
case ISCSI_OPCODE_TASK_MANAGEMENT_FUNCTION_RESPONSE:
|
2011-11-09 02:48:51 +00:00
|
|
|
/* top two bits in byte 0 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+0)&0xc0){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* byte 1 must be 0x80 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+1)!=0x80){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* response must be 0-6 or 255 */
|
|
|
|
tmpbyte=tvb_get_guint8(tvb,offset+2);
|
|
|
|
if(tmpbyte>6 && tmpbyte<255){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* byte 3 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb,offset+3)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* ahs and dsl as well as the 32bit words at offsets 8, 12, 20, 36
|
|
|
|
* 40, 44 must all be 0
|
|
|
|
*/
|
|
|
|
if(tvb_get_letohl(tvb,offset+4)
|
|
|
|
|| tvb_get_letohl(tvb,offset+8)
|
|
|
|
|| tvb_get_letohl(tvb,offset+12)
|
|
|
|
|| tvb_get_letohl(tvb,offset+20)
|
|
|
|
|| tvb_get_letohl(tvb,offset+36)
|
|
|
|
|| tvb_get_letohl(tvb,offset+40)
|
|
|
|
|| tvb_get_letohl(tvb,offset+44)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2006-06-20 13:16:50 +00:00
|
|
|
case ISCSI_OPCODE_LOGOUT_COMMAND:
|
2011-11-09 02:48:51 +00:00
|
|
|
/* top bit in byte 0 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+0)&0x80){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* top bit in byte 1 must be set */
|
|
|
|
tmpbyte=tvb_get_guint8(tvb, offset+1);
|
|
|
|
if(!(tmpbyte&0x80)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* Reason code must be known */
|
|
|
|
if(!match_strval(tmpbyte&0x7f, iscsi_logout_reasons)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* bytes 2,3 must be null */
|
|
|
|
if(tvb_get_letohs(tvb,offset+2)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* ahs and dsl as well as the 32bit words at offsets 8, 12, 32, 36
|
|
|
|
* 40, 44 must all be 0
|
|
|
|
*/
|
|
|
|
if(tvb_get_letohl(tvb,offset+4)
|
|
|
|
|| tvb_get_letohl(tvb,offset+8)
|
|
|
|
|| tvb_get_letohl(tvb,offset+12)
|
|
|
|
|| tvb_get_letohl(tvb,offset+32)
|
|
|
|
|| tvb_get_letohl(tvb,offset+36)
|
|
|
|
|| tvb_get_letohl(tvb,offset+40)
|
|
|
|
|| tvb_get_letohl(tvb,offset+44)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2006-06-20 13:16:50 +00:00
|
|
|
case ISCSI_OPCODE_SNACK_REQUEST:
|
2011-11-09 02:48:51 +00:00
|
|
|
/* top two bits in byte 0 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+0)&0xc0){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* top 4 bits in byte 1 must be 0x80 */
|
|
|
|
tmpbyte=tvb_get_guint8(tvb, offset+1);
|
|
|
|
if((tmpbyte&0xf0)!=0x80){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* type must be known */
|
|
|
|
if(!match_strval(tmpbyte&0x0f, iscsi_snack_types)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* for status/snack and datack itt must be 0xffffffff
|
|
|
|
* for rdata/snack ttt must not be 0 or 0xffffffff
|
|
|
|
*/
|
|
|
|
switch(tmpbyte&0x0f){
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
if(tvb_get_letohl(tvb,offset+16)!=0xffffffff){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if(tvb_get_letohl(tvb,offset+20)==0xffffffff){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if(tvb_get_letohl(tvb,offset+20)==0){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* bytes 2,3 must be null */
|
|
|
|
if(tvb_get_letohs(tvb,offset+2)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* the 32bit words at offsets 24, 32, 36
|
|
|
|
* must all be 0
|
|
|
|
*/
|
|
|
|
if(tvb_get_letohl(tvb,offset+24)
|
|
|
|
|| tvb_get_letohl(tvb,offset+32)
|
|
|
|
|| tvb_get_letohl(tvb,offset+36)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2006-06-20 13:16:50 +00:00
|
|
|
case ISCSI_OPCODE_R2T:
|
2011-11-09 02:48:51 +00:00
|
|
|
/* top two bits in byte 0 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+0)&0xc0){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* byte 1 must be 0x80 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+1)!=0x80){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* bytes 2,3 must be null */
|
|
|
|
if(tvb_get_letohs(tvb,offset+2)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* ahs and dsl must be null */
|
|
|
|
if(tvb_get_letohl(tvb,offset+4)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* desired data transfer length must not be null */
|
|
|
|
if(!tvb_get_letohl(tvb,offset+44)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2006-06-20 13:16:50 +00:00
|
|
|
case ISCSI_OPCODE_REJECT:
|
2011-11-09 02:48:51 +00:00
|
|
|
/* top two bits in byte 0 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+0)&0xc0){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* byte 1 must be 0x80 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+1)!=0x80){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* reason must be known */
|
|
|
|
if(!match_strval(tvb_get_guint8(tvb,offset+2), iscsi_reject_reasons)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* byte 3 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+3)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* the 32bit words at offsets 8, 12, 20, 40, 44
|
|
|
|
* must all be 0
|
|
|
|
*/
|
|
|
|
if(tvb_get_letohl(tvb,offset+8)
|
|
|
|
|| tvb_get_letohl(tvb,offset+12)
|
|
|
|
|| tvb_get_letohl(tvb,offset+20)
|
|
|
|
|| tvb_get_letohl(tvb,offset+40)
|
|
|
|
|| tvb_get_letohl(tvb,offset+44)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* the 32bit word at 16 must be 0xffffffff */
|
|
|
|
if(tvb_get_letohl(tvb,offset+16)!=0xffffffff){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2006-06-20 13:16:50 +00:00
|
|
|
case ISCSI_OPCODE_TEXT_COMMAND:
|
2011-11-09 02:48:51 +00:00
|
|
|
/* top bit in byte 0 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+0)&0x80){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* 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)){
|
|
|
|
case 0x80:
|
|
|
|
case 0x40:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* bytes 2,3 must be null */
|
|
|
|
if(tvb_get_letohs(tvb,offset+2)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* the 32bit words at offsets 32, 36, 40, 44
|
|
|
|
* must all be 0
|
|
|
|
*/
|
|
|
|
if(tvb_get_letohl(tvb,offset+32)
|
|
|
|
|| tvb_get_letohl(tvb,offset+36)
|
|
|
|
|| tvb_get_letohl(tvb,offset+40)
|
|
|
|
|| tvb_get_letohl(tvb,offset+44)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2006-06-20 13:16:50 +00:00
|
|
|
case ISCSI_OPCODE_TEXT_RESPONSE:
|
2011-11-09 02:48:51 +00:00
|
|
|
/* top two bits in byte 0 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+0)&0xc0){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* 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)){
|
|
|
|
case 0x80:
|
|
|
|
case 0x40:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* bytes 2,3 must be null */
|
|
|
|
if(tvb_get_letohs(tvb,offset+2)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* the 32bit words at offsets 36, 40, 44
|
|
|
|
* must all be 0
|
|
|
|
*/
|
|
|
|
if(tvb_get_letohl(tvb,offset+36)
|
|
|
|
|| tvb_get_letohl(tvb,offset+40)
|
|
|
|
|| tvb_get_letohl(tvb,offset+44)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2006-06-20 13:16:50 +00:00
|
|
|
case ISCSI_OPCODE_SCSI_COMMAND:
|
2011-11-09 02:48:51 +00:00
|
|
|
/* top bit in byte 0 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+0)&0x80){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* reserved bits in byte 1 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+1)&0x18){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* bytes 2,3 must be null */
|
|
|
|
if(tvb_get_letohs(tvb,offset+2)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* last 6 bytes of LUN are always 0 */
|
2011-12-27 17:08:33 +00:00
|
|
|
if(tvb_get_ntoh48(tvb, offset+10)){
|
2011-11-09 02:48:51 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* expected data transfer length is never >16MByte ? */
|
|
|
|
if(tvb_get_guint8(tvb,offset+20)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2006-06-20 13:16:50 +00:00
|
|
|
case ISCSI_OPCODE_SCSI_RESPONSE:
|
2011-11-09 02:48:51 +00:00
|
|
|
/* top two bits in byte 0 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+0)&0xc0){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* top bit in byte 1 must be 1 */
|
|
|
|
tmpbyte=tvb_get_guint8(tvb,offset+1);
|
|
|
|
if(!(tmpbyte&0x80)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* the reserved bits in byte 1 must be 0 */
|
|
|
|
if(tmpbyte&0x61){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* status must be known */
|
|
|
|
if(!match_strval(tvb_get_guint8(tvb,offset+3), scsi_status_val)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* the 32bit words at offsets 8, 12
|
|
|
|
* must all be 0
|
|
|
|
*/
|
|
|
|
if(tvb_get_letohl(tvb,offset+8)
|
|
|
|
|| tvb_get_letohl(tvb,offset+12)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2006-06-20 13:16:50 +00:00
|
|
|
case ISCSI_OPCODE_ASYNC_MESSAGE:
|
2011-11-09 02:48:51 +00:00
|
|
|
/* top two bits in byte 0 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+0)&0xc0){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* byte 1 must be 0x80 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+1)!=0x80){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* bytes 2,3 must be null */
|
|
|
|
if(tvb_get_letohs(tvb,offset+2)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* the 32bit words at offsets 20, 44
|
|
|
|
* must all be 0
|
|
|
|
*/
|
|
|
|
if(tvb_get_letohl(tvb,offset+20)
|
|
|
|
|| tvb_get_letohl(tvb,offset+44)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* the 32bit word at 16 must be 0xffffffff */
|
|
|
|
if(tvb_get_letohl(tvb,offset+16)!=0xffffffff){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2006-06-20 13:16:50 +00:00
|
|
|
case ISCSI_OPCODE_LOGOUT_RESPONSE:
|
2011-11-09 02:48:51 +00:00
|
|
|
/* top two bits in byte 0 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+0)&0xc0){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* byte 1 must be 0x80 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+1)!=0x80){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* response must be known */
|
|
|
|
if(!match_strval(tvb_get_guint8(tvb,offset+2), iscsi_logout_response)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* byte 3 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb,offset+3)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* ahs and dsl as well as the 32bit words at offsets 8, 12, 20, 36
|
|
|
|
* 44 must all be 0
|
|
|
|
*/
|
|
|
|
if(tvb_get_letohl(tvb,offset+4)
|
|
|
|
|| tvb_get_letohl(tvb,offset+8)
|
|
|
|
|| tvb_get_letohl(tvb,offset+12)
|
|
|
|
|| tvb_get_letohl(tvb,offset+20)
|
|
|
|
|| tvb_get_letohl(tvb,offset+36)
|
|
|
|
|| tvb_get_letohl(tvb,offset+44)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2006-06-20 13:16:50 +00:00
|
|
|
case ISCSI_OPCODE_SCSI_DATA_OUT:
|
2011-11-09 02:48:51 +00:00
|
|
|
/* top two bits in byte 0 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+0)&0xc0){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* low 7 bits in byte 1 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb,offset+1)&0x7f){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* bytes 2,3 must be null */
|
|
|
|
if(tvb_get_letohs(tvb,offset+2)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* the 32bit words at offsets 24, 32, 44
|
|
|
|
* must all be 0
|
|
|
|
*/
|
|
|
|
if(tvb_get_letohl(tvb,offset+24)
|
|
|
|
|| tvb_get_letohl(tvb,offset+32)
|
|
|
|
|| tvb_get_letohl(tvb,offset+44)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2006-06-20 13:16:50 +00:00
|
|
|
case ISCSI_OPCODE_SCSI_DATA_IN:
|
2011-11-09 02:48:51 +00:00
|
|
|
/* top two bits in byte 0 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb, offset+0)&0xc0){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* reserved bits in byte 1 must be 0 */
|
|
|
|
if(tvb_get_guint8(tvb,offset+1)&0x38){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* byte 2 must be reserved */
|
|
|
|
if(tvb_get_guint8(tvb,offset+2)){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2006-06-20 13:16:50 +00:00
|
|
|
case ISCSI_OPCODE_VENDOR_SPECIFIC_I0:
|
|
|
|
case ISCSI_OPCODE_VENDOR_SPECIFIC_I1:
|
|
|
|
case ISCSI_OPCODE_VENDOR_SPECIFIC_I2:
|
|
|
|
case ISCSI_OPCODE_VENDOR_SPECIFIC_T0:
|
|
|
|
case ISCSI_OPCODE_VENDOR_SPECIFIC_T1:
|
|
|
|
case ISCSI_OPCODE_VENDOR_SPECIFIC_T2:
|
2011-11-09 02:48:51 +00:00
|
|
|
break;
|
2006-06-20 13:16:50 +00:00
|
|
|
default:
|
2011-11-09 02:48:51 +00:00
|
|
|
return FALSE;
|
2006-06-20 13:16:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-21 17:20:10 +00:00
|
|
|
/* process multiple iSCSI PDUs per packet */
|
|
|
|
while(available_bytes >= 48 || (iscsi_desegment && available_bytes >= 8)) {
|
2011-11-09 02:48:51 +00:00
|
|
|
const char *opcode_str = NULL;
|
|
|
|
guint32 data_segment_len;
|
|
|
|
guint32 pduLen = 48;
|
|
|
|
guint8 secondPduByte = tvb_get_guint8(tvb, offset + 1);
|
|
|
|
int badPdu = FALSE;
|
|
|
|
guint8 ahsLen=0;
|
|
|
|
|
|
|
|
/* mask out any extra bits in the opcode byte */
|
|
|
|
opcode = tvb_get_guint8(tvb, offset + 0);
|
|
|
|
opcode &= OPCODE_MASK;
|
|
|
|
|
|
|
|
opcode_str = match_strval(opcode, iscsi_opcodes);
|
|
|
|
if(opcode == ISCSI_OPCODE_TASK_MANAGEMENT_FUNCTION ||
|
|
|
|
opcode == ISCSI_OPCODE_TASK_MANAGEMENT_FUNCTION_RESPONSE ||
|
|
|
|
opcode == ISCSI_OPCODE_R2T ||
|
|
|
|
opcode == ISCSI_OPCODE_LOGOUT_COMMAND ||
|
|
|
|
opcode == ISCSI_OPCODE_LOGOUT_RESPONSE ||
|
|
|
|
opcode == ISCSI_OPCODE_SNACK_REQUEST)
|
|
|
|
data_segment_len = 0;
|
|
|
|
else
|
|
|
|
data_segment_len = tvb_get_ntohl(tvb, offset + 4) & 0x00ffffff;
|
|
|
|
|
|
|
|
if(opcode_str == NULL) {
|
|
|
|
badPdu = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(!badPdu && check_port) {
|
|
|
|
badPdu = TRUE;
|
|
|
|
if ((opcode & TARGET_OPCODE_BIT) && value_is_in_range(global_iscsi_port_range, pinfo->srcport)) {
|
|
|
|
badPdu = FALSE;
|
|
|
|
}
|
|
|
|
if (!(opcode & TARGET_OPCODE_BIT) && value_is_in_range(global_iscsi_port_range, pinfo->destport)) {
|
|
|
|
badPdu = FALSE;
|
|
|
|
}
|
|
|
|
if ((opcode & TARGET_OPCODE_BIT) && pinfo->srcport == iscsi_system_port) {
|
|
|
|
badPdu = FALSE;
|
|
|
|
}
|
|
|
|
if (!(opcode & TARGET_OPCODE_BIT) && pinfo->destport == iscsi_system_port) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
else if(demand_good_f_bit &&
|
|
|
|
!(secondPduByte & 0x80) &&
|
|
|
|
(opcode == ISCSI_OPCODE_NOP_OUT ||
|
|
|
|
opcode == ISCSI_OPCODE_NOP_IN ||
|
|
|
|
opcode == ISCSI_OPCODE_LOGOUT_COMMAND ||
|
|
|
|
opcode == ISCSI_OPCODE_LOGOUT_RESPONSE ||
|
|
|
|
opcode == ISCSI_OPCODE_SCSI_RESPONSE ||
|
|
|
|
opcode == ISCSI_OPCODE_TASK_MANAGEMENT_FUNCTION_RESPONSE ||
|
|
|
|
opcode == ISCSI_OPCODE_R2T ||
|
|
|
|
opcode == ISCSI_OPCODE_ASYNC_MESSAGE ||
|
|
|
|
opcode == ISCSI_OPCODE_SNACK_REQUEST ||
|
|
|
|
opcode == ISCSI_OPCODE_REJECT)) {
|
|
|
|
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.
|
|
|
|
Assume 0 means we are just inside a big all zero
|
|
|
|
datablock.
|
|
|
|
*/
|
|
|
|
if(tvb_get_ntohl(tvb, offset+20)==0){
|
|
|
|
badPdu = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(badPdu) {
|
|
|
|
return iSCSIPdusDissected > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(opcode == ISCSI_OPCODE_LOGIN_COMMAND ||
|
|
|
|
opcode == ISCSI_OPCODE_LOGIN_RESPONSE) {
|
|
|
|
if(iscsi_protocol_version == ISCSI_PROTOCOL_DRAFT08) {
|
|
|
|
if((secondPduByte & CSG_MASK) < ISCSI_CSG_OPERATIONAL_NEGOTIATION) {
|
|
|
|
/* digests are not yet turned on */
|
|
|
|
digestsActive = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
digestsActive = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(opcode == ISCSI_OPCODE_SCSI_COMMAND) {
|
|
|
|
/* ahsLen */
|
|
|
|
ahsLen = tvb_get_guint8(tvb, offset + 4);
|
|
|
|
pduLen += ahsLen * 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
pduLen += data_segment_len;
|
|
|
|
if((pduLen & 3) != 0)
|
|
|
|
pduLen += 4 - (pduLen & 3);
|
|
|
|
|
|
|
|
|
|
|
|
if(digestsActive && data_segment_len > 0 && enableDataDigests) {
|
|
|
|
if(dataDigestIsCRC32)
|
|
|
|
pduLen += 4;
|
|
|
|
else
|
|
|
|
pduLen += dataDigestSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make sure we have a conversation for this session */
|
2010-05-13 18:28:34 +00:00
|
|
|
conversation = find_or_create_conversation(pinfo);
|
|
|
|
|
2006-04-06 09:47:31 +00:00
|
|
|
iscsi_session=conversation_get_proto_data(conversation, proto_iscsi);
|
2004-08-29 02:55:02 +00:00
|
|
|
if(!iscsi_session){
|
2006-04-06 09:47:31 +00:00
|
|
|
iscsi_session=se_alloc(sizeof(iscsi_session_t));
|
|
|
|
iscsi_session->header_digest=ISCSI_HEADER_DIGEST_AUTO;
|
2006-08-14 08:29:29 +00:00
|
|
|
iscsi_session->itlq=se_tree_create_non_persistent(EMEM_TREE_TYPE_RED_BLACK, "iSCSI ITLQ");
|
|
|
|
iscsi_session->itl=se_tree_create_non_persistent(EMEM_TREE_TYPE_RED_BLACK, "iSCSI ITL");
|
2006-04-06 09:47:31 +00:00
|
|
|
conversation_add_proto_data(conversation, proto_iscsi, iscsi_session);
|
|
|
|
|
|
|
|
/* DataOut PDUs are often mistaken by DCERPC heuristics to be
|
2009-10-08 15:10:43 +00:00
|
|
|
* that protocol. Now that we know this is iscsi, set a
|
2006-04-06 09:47:31 +00:00
|
|
|
* dissector for this conversation to block other heuristic
|
2009-10-08 15:10:43 +00:00
|
|
|
* dissectors.
|
2006-04-06 09:47:31 +00:00
|
|
|
*/
|
|
|
|
conversation_set_dissector(conversation, iscsi_handle);
|
2004-08-29 01:15:32 +00:00
|
|
|
}
|
2004-08-29 04:12:35 +00:00
|
|
|
/* try to autodetect if header digest is used or not */
|
2011-11-09 02:48:51 +00:00
|
|
|
if(digestsActive && (available_bytes>=(guint32) (48+4+ahsLen*4)) && (iscsi_session->header_digest==ISCSI_HEADER_DIGEST_AUTO) ){
|
2004-08-29 04:12:35 +00:00
|
|
|
guint32 crc;
|
2011-11-09 02:48:51 +00:00
|
|
|
/* we have enough data to test if HeaderDigest is enabled */
|
2009-10-08 15:10:43 +00:00
|
|
|
crc= ~crc32c_calculate(tvb_get_ptr(tvb, offset, 48+ahsLen*4), 48+ahsLen*4, CRC32C_PRELOAD);
|
2006-09-30 21:49:11 +00:00
|
|
|
if(crc==tvb_get_ntohl(tvb,48+ahsLen*4)){
|
2004-08-29 04:12:35 +00:00
|
|
|
iscsi_session->header_digest=ISCSI_HEADER_DIGEST_CRC32;
|
|
|
|
} else {
|
|
|
|
iscsi_session->header_digest=ISCSI_HEADER_DIGEST_NONE;
|
|
|
|
}
|
2011-11-09 02:48:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Add header digest length to pdulen */
|
|
|
|
if(digestsActive){
|
|
|
|
switch(iscsi_session->header_digest){
|
|
|
|
case ISCSI_HEADER_DIGEST_CRC32:
|
|
|
|
pduLen += 4;
|
|
|
|
break;
|
|
|
|
case ISCSI_HEADER_DIGEST_NONE:
|
|
|
|
break;
|
|
|
|
case ISCSI_HEADER_DIGEST_AUTO:
|
|
|
|
/* oops we didnt know what digest is used yet */
|
|
|
|
/* here we should use some default */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DISSECTOR_ASSERT_NOT_REACHED();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Desegmentation check.
|
|
|
|
*/
|
|
|
|
if(iscsi_desegment && pinfo->can_desegment) {
|
|
|
|
if(pduLen > available_bytes) {
|
|
|
|
/*
|
|
|
|
* This frame doesn't have all of the data for
|
|
|
|
* this message, but we can do reassembly on it.
|
|
|
|
*
|
|
|
|
* Tell the TCP dissector where the data for this
|
|
|
|
* message starts in the data it handed us, and
|
|
|
|
* how many more bytes we need, and return.
|
|
|
|
*/
|
|
|
|
pinfo->desegment_offset = offset;
|
|
|
|
pinfo->desegment_len = pduLen - available_bytes;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is to help TCP keep track of PDU boundaries
|
|
|
|
and allows it to find PDUs that are not aligned to
|
|
|
|
the start of a TCP segments.
|
|
|
|
Since it also allows TCP to know what is in the middle
|
|
|
|
of a large PDU, it reduces the probability of a segment
|
|
|
|
in the middle of a large PDU transfer being misdissected as
|
|
|
|
a PDU.
|
|
|
|
*/
|
|
|
|
if(!pinfo->fd->flags.visited){
|
|
|
|
if(pduLen>(guint32)tvb_reported_length_remaining(tvb, offset)){
|
|
|
|
pinfo->want_pdu_tracking=2;
|
|
|
|
pinfo->bytes_until_next_pdu=pduLen-tvb_reported_length_remaining(tvb, offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(check_col(pinfo->cinfo, COL_INFO)) {
|
|
|
|
if(iSCSIPdusDissected == 0)
|
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "");
|
|
|
|
else
|
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, ", ");
|
|
|
|
}
|
|
|
|
|
|
|
|
dissect_iscsi_pdu(tvb, pinfo, tree, offset, opcode, opcode_str, data_segment_len, iscsi_session, conversation);
|
|
|
|
if(pduLen > available_bytes)
|
|
|
|
pduLen = available_bytes;
|
|
|
|
offset += pduLen;
|
|
|
|
available_bytes -= pduLen;
|
|
|
|
++iSCSIPdusDissected;
|
2001-10-19 20:53:14 +00:00
|
|
|
}
|
|
|
|
|
2001-10-21 17:20:10 +00:00
|
|
|
return iSCSIPdusDissected > 0;
|
2001-10-19 20:53:14 +00:00
|
|
|
}
|
|
|
|
|
2011-11-09 02:48:51 +00:00
|
|
|
/* This is called for those sessions where we have explicitly said
|
2003-06-15 02:02:59 +00:00
|
|
|
this to be iSCSI using "Decode As..."
|
|
|
|
In this case we will not check the port number for sanity and just
|
|
|
|
do as the user said.
|
2006-06-20 13:16:50 +00:00
|
|
|
We still check that the PDU header looks sane though.
|
2003-06-15 02:02:59 +00:00
|
|
|
*/
|
2006-06-20 13:16:50 +00:00
|
|
|
static int
|
2003-06-15 02:02:59 +00:00
|
|
|
dissect_iscsi_handle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
|
2006-06-20 13:16:50 +00:00
|
|
|
return dissect_iscsi(tvb, pinfo, tree, FALSE);
|
2003-06-15 02:02:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This is called through the heuristic handler.
|
|
|
|
In this case we also want to check that the port matches the preference
|
|
|
|
setting for iSCSI in order to reduce the number of
|
|
|
|
false positives.
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
dissect_iscsi_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
|
2008-07-30 14:28:04 +00:00
|
|
|
guint32 available_bytes = tvb_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 ){
|
2011-11-09 02:48:51 +00:00
|
|
|
/* no, so give up */
|
|
|
|
return FALSE;
|
2008-07-30 14:28:04 +00:00
|
|
|
}
|
|
|
|
|
2003-06-15 02:02:59 +00:00
|
|
|
return dissect_iscsi(tvb, pinfo, tree, TRUE);
|
|
|
|
}
|
|
|
|
|
2001-10-19 20:53:14 +00:00
|
|
|
|
2006-05-21 04:49:01 +00:00
|
|
|
/* Register the protocol with Wireshark */
|
2001-05-30 18:52:38 +00:00
|
|
|
|
2001-10-21 17:20:10 +00:00
|
|
|
/*
|
|
|
|
* this format is require because a script is used to build the C
|
|
|
|
* function that calls all the protocol registration.
|
2001-05-30 18:52:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_iscsi(void)
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
2011-08-11 21:59:02 +00:00
|
|
|
module_t *iscsi_module;
|
2001-05-30 18:52:38 +00:00
|
|
|
|
2001-10-21 17:20:10 +00:00
|
|
|
/* Setup list of header fields See Section 1.6.1 for details*/
|
2001-05-30 18:52:38 +00:00
|
|
|
static hf_register_info hf[] = {
|
2011-11-09 02:48:51 +00:00
|
|
|
{ &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 }},
|
|
|
|
|
|
|
|
{ &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_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 }},
|
|
|
|
|
|
|
|
{ &hf_iscsi_data_out_frame,
|
|
|
|
{ "Data Out in", "iscsi.data_out_frame",
|
|
|
|
FT_FRAMENUM, BASE_NONE, NULL, 0,
|
|
|
|
"The Data Out for this transaction is in this frame", 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 }},
|
|
|
|
{ &hf_iscsi_AHS_length,
|
|
|
|
{ "AHS Length", "iscsi.ahs.length",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0,
|
|
|
|
"Length of Additional header segment", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_AHS_read_data_length,
|
|
|
|
{ "Bidirectional Read Data Length", "iscsi.ahs.bidir.length",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_AHS_type,
|
|
|
|
{ "AHS Type", "iscsi.ahs.type",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(ahs_type_vals), 0,
|
|
|
|
"Type of Additional header segment", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_AHS_extended_cdb,
|
|
|
|
{ "AHS Extended CDB", "iscsi.ahs.extended_cdb",
|
|
|
|
FT_BYTES, BASE_NONE, NULL, 0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_AHS_blob,
|
|
|
|
{ "Unknown AHS blob", "iscsi.ahs.unknown_blob",
|
|
|
|
FT_BYTES, BASE_NONE, NULL, 0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_Padding,
|
|
|
|
{ "Padding", "iscsi.padding",
|
|
|
|
FT_BYTES, BASE_NONE, NULL, 0,
|
|
|
|
"Padding to 4 byte boundary", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_ping_data,
|
|
|
|
{ "PingData", "iscsi.pingdata",
|
|
|
|
FT_BYTES, BASE_NONE, NULL, 0,
|
|
|
|
"Ping Data", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_immediate_data,
|
|
|
|
{ "ImmediateData", "iscsi.immediatedata",
|
|
|
|
FT_BYTES, BASE_NONE, NULL, 0,
|
|
|
|
"Immediate Data", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_async_event_data,
|
|
|
|
{ "AsyncEventData", "iscsi.asynceventdata",
|
|
|
|
FT_BYTES, BASE_NONE, NULL, 0,
|
|
|
|
"Async Event Data", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_vendor_specific_data,
|
|
|
|
{ "VendorSpecificData", "iscsi.vendorspecificdata",
|
|
|
|
FT_BYTES, BASE_NONE, NULL, 0,
|
|
|
|
"Vendor Specific Data", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_HeaderDigest32,
|
|
|
|
{ "HeaderDigest", "iscsi.headerdigest32",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Header Digest", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_DataDigest,
|
|
|
|
{ "DataDigest", "iscsi.datadigest",
|
|
|
|
FT_BYTES, BASE_NONE, NULL, 0,
|
|
|
|
"Data Digest", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_DataDigest32,
|
|
|
|
{ "DataDigest", "iscsi.datadigest32",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Data Digest", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_Opcode,
|
|
|
|
{ "Opcode", "iscsi.opcode",
|
|
|
|
FT_UINT8, BASE_HEX, VALS(iscsi_opcodes), 0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #ifdef DRAFT08 */
|
2011-11-09 02:48:51 +00:00
|
|
|
{ &hf_iscsi_X,
|
|
|
|
{ "X", "iscsi.X",
|
|
|
|
FT_BOOLEAN, 8, TFS(&iscsi_meaning_X), 0x80,
|
|
|
|
"Command Retry", HFILL }
|
|
|
|
},
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #endif */
|
2011-11-09 02:48:51 +00:00
|
|
|
{ &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_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 }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_SCSICommand_Attr,
|
|
|
|
{ "Attr", "iscsi.scsicommand.attr",
|
|
|
|
FT_UINT8, BASE_HEX, VALS(iscsi_scsicommand_taskattrs), 0x07,
|
|
|
|
"SCSI task attributes", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_SCSICommand_CRN,
|
|
|
|
{ "CRN", "iscsi.scsicommand.crn",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0,
|
|
|
|
"SCSI command reference number", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_DataSegmentLength,
|
|
|
|
{ "DataSegmentLength", "iscsi.datasegmentlength",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Data segment length (bytes)", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_TotalAHSLength,
|
|
|
|
{ "TotalAHSLength", "iscsi.totalahslength",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0,
|
|
|
|
"Total additional header segment length (4 byte words)", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_LUN,
|
|
|
|
{ "LUN", "iscsi.lun",
|
|
|
|
FT_BYTES, BASE_NONE, NULL, 0,
|
|
|
|
"Logical Unit Number", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_InitiatorTaskTag,
|
|
|
|
{ "InitiatorTaskTag", "iscsi.initiatortasktag",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Initiator's task tag", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_ExpectedDataTransferLength,
|
|
|
|
{ "ExpectedDataTransferLength", "iscsi.scsicommand.expecteddatatransferlength",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Expected length of data transfer", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_CmdSN,
|
|
|
|
{ "CmdSN", "iscsi.cmdsn",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Sequence number for this command", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_ExpStatSN,
|
|
|
|
{ "ExpStatSN", "iscsi.expstatsn",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Next expected status sequence number", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_SCSIResponse_ResidualCount,
|
|
|
|
{ "ResidualCount", "iscsi.scsiresponse.residualcount",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Residual count", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_StatSN,
|
|
|
|
{ "StatSN", "iscsi.statsn",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Status sequence number", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_ExpCmdSN,
|
|
|
|
{ "ExpCmdSN", "iscsi.expcmdsn",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Next expected command sequence number", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_MaxCmdSN,
|
|
|
|
{ "MaxCmdSN", "iscsi.maxcmdsn",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Maximum acceptable command sequence number", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_SCSIResponse_o,
|
|
|
|
{ "o", "iscsi.scsiresponse.o",
|
|
|
|
FT_BOOLEAN, 8, TFS(&iscsi_meaning_o), 0x10,
|
|
|
|
"Bi-directional read residual overflow", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_SCSIResponse_u,
|
|
|
|
{ "u", "iscsi.scsiresponse.u",
|
|
|
|
FT_BOOLEAN, 8, TFS(&iscsi_meaning_u), 0x08,
|
|
|
|
"Bi-directional read residual underflow", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_SCSIResponse_O,
|
|
|
|
{ "O", "iscsi.scsiresponse.O",
|
|
|
|
FT_BOOLEAN, 8, TFS(&iscsi_meaning_O), 0x04,
|
|
|
|
"Residual overflow", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_SCSIResponse_U,
|
|
|
|
{ "U", "iscsi.scsiresponse.U",
|
|
|
|
FT_BOOLEAN, 8, TFS(&iscsi_meaning_U), 0x02,
|
|
|
|
"Residual underflow", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_SCSIResponse_Status,
|
|
|
|
{ "Status", "iscsi.scsiresponse.status",
|
|
|
|
FT_UINT8, BASE_HEX, VALS(scsi_status_val), 0,
|
|
|
|
"SCSI command status value", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_SCSIResponse_Response,
|
|
|
|
{ "Response", "iscsi.scsiresponse.response",
|
|
|
|
FT_UINT8, BASE_HEX, VALS(iscsi_scsi_responses), 0,
|
|
|
|
"SCSI command response value", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_SCSIResponse_BidiReadResidualCount,
|
|
|
|
{ "BidiReadResidualCount", "iscsi.scsiresponse.bidireadresidualcount",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Bi-directional read residual count", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_SenseLength,
|
|
|
|
{ "SenseLength", "iscsi.scsiresponse.senselength",
|
|
|
|
FT_UINT16, BASE_HEX, NULL, 0,
|
|
|
|
"Sense data length", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_SCSIData_F,
|
|
|
|
{ "F", "iscsi.scsidata.F",
|
|
|
|
FT_BOOLEAN, 8, TFS(&iscsi_meaning_F), ISCSI_SCSI_DATA_FLAG_F,
|
|
|
|
"Final PDU", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_SCSIData_A,
|
|
|
|
{ "A", "iscsi.scsidata.A",
|
|
|
|
FT_BOOLEAN, 8, TFS(&iscsi_meaning_A), ISCSI_SCSI_DATA_FLAG_A,
|
|
|
|
"Acknowledge Requested", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_SCSIData_S,
|
|
|
|
{ "S", "iscsi.scsidata.S",
|
|
|
|
FT_BOOLEAN, 8, TFS(&iscsi_meaning_S), ISCSI_SCSI_DATA_FLAG_S,
|
|
|
|
"PDU Contains SCSI command status", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_SCSIData_U,
|
|
|
|
{ "U", "iscsi.scsidata.U",
|
|
|
|
FT_BOOLEAN, 8, TFS(&iscsi_meaning_U), ISCSI_SCSI_DATA_FLAG_U,
|
|
|
|
"Residual underflow", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_SCSIData_O,
|
|
|
|
{ "O", "iscsi.scsidata.O",
|
|
|
|
FT_BOOLEAN, 8, TFS(&iscsi_meaning_O), ISCSI_SCSI_DATA_FLAG_O,
|
|
|
|
"Residual overflow", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_TargetTransferTag,
|
|
|
|
{ "TargetTransferTag", "iscsi.targettransfertag",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Target transfer tag", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_BufferOffset,
|
|
|
|
{ "BufferOffset", "iscsi.bufferOffset",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Buffer offset", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_SCSIData_ResidualCount,
|
|
|
|
{ "ResidualCount", "iscsi.scsidata.readresidualcount",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Residual count", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_DataSN,
|
|
|
|
{ "DataSN", "iscsi.datasn",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Data sequence number", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_VersionMax,
|
|
|
|
{ "VersionMax", "iscsi.versionmax",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0,
|
|
|
|
"Maximum supported protocol version", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_VersionMin,
|
|
|
|
{ "VersionMin", "iscsi.versionmin",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0,
|
|
|
|
"Minimum supported protocol version", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_VersionActive,
|
|
|
|
{ "VersionActive", "iscsi.versionactive",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0,
|
|
|
|
"Negotiated protocol version", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_CID,
|
|
|
|
{ "CID", "iscsi.cid",
|
|
|
|
FT_UINT16, BASE_HEX, NULL, 0,
|
|
|
|
"Connection identifier", HFILL }
|
|
|
|
},
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #ifdef DRAFT08 */
|
2011-11-09 02:48:51 +00:00
|
|
|
{ &hf_iscsi_ISID8,
|
|
|
|
{ "ISID", "iscsi.isid",
|
|
|
|
FT_UINT16, BASE_HEX, NULL, 0,
|
|
|
|
"Initiator part of session identifier", HFILL }
|
|
|
|
},
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #else */
|
2011-11-09 02:48:51 +00:00
|
|
|
{ &hf_iscsi_ISID,
|
|
|
|
{ "ISID", "iscsi.isid",
|
|
|
|
FT_BYTES, BASE_NONE, NULL, 0,
|
|
|
|
"Initiator part of session identifier", HFILL }
|
|
|
|
},
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #ifdef DRAFT09 */
|
2011-11-09 02:48:51 +00:00
|
|
|
{ &hf_iscsi_ISID_Type,
|
|
|
|
{ "ISID_Type", "iscsi.isid.type",
|
|
|
|
FT_UINT8, BASE_HEX, VALS(iscsi_isid_type), 0,
|
|
|
|
"Initiator part of session identifier - type", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_ISID_NamingAuthority,
|
|
|
|
{ "ISID_NamingAuthority", "iscsi.isid.namingauthority",
|
|
|
|
FT_UINT24, BASE_HEX, NULL, 0,
|
|
|
|
"Initiator part of session identifier - naming authority", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_ISID_Qualifier,
|
|
|
|
{ "ISID_Qualifier", "iscsi.isid.qualifier",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0,
|
|
|
|
"Initiator part of session identifier - qualifier", HFILL }
|
|
|
|
},
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #else */
|
2011-11-09 02:48:51 +00:00
|
|
|
{ &hf_iscsi_ISID_t,
|
|
|
|
{ "ISID_t", "iscsi.isid.t",
|
|
|
|
FT_UINT8, BASE_HEX, VALS(iscsi_isid_type), 0xc0,
|
|
|
|
"Initiator part of session identifier - t", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_ISID_a,
|
|
|
|
{ "ISID_a", "iscsi.isid.a",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0x3f,
|
|
|
|
"Initiator part of session identifier - a", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_ISID_b,
|
|
|
|
{ "ISID_b", "iscsi.isid.b",
|
|
|
|
FT_UINT16, BASE_HEX, NULL, 0,
|
|
|
|
"Initiator part of session identifier - b", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_ISID_c,
|
|
|
|
{ "ISID_c", "iscsi.isid.c",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0,
|
|
|
|
"Initiator part of session identifier - c", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_ISID_d,
|
|
|
|
{ "ISID_d", "iscsi.isid.d",
|
|
|
|
FT_UINT16, BASE_HEX, NULL, 0,
|
|
|
|
"Initiator part of session identifier - d", HFILL }
|
|
|
|
},
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #endif */
|
|
|
|
/* #endif */
|
2011-11-09 02:48:51 +00:00
|
|
|
{ &hf_iscsi_TSID,
|
|
|
|
{ "TSID", "iscsi.tsid",
|
|
|
|
FT_UINT16, BASE_HEX, NULL, 0,
|
|
|
|
"Target part of session identifier", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_TSIH,
|
|
|
|
{ "TSIH", "iscsi.tsih",
|
|
|
|
FT_UINT16, BASE_HEX, NULL, 0,
|
|
|
|
"Target session identifying handle", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_Login_T,
|
|
|
|
{ "T", "iscsi.login.T",
|
|
|
|
FT_BOOLEAN, 8, TFS(&iscsi_meaning_T), 0x80,
|
|
|
|
"Transit to next login stage", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_Login_C,
|
|
|
|
{ "C", "iscsi.login.C",
|
|
|
|
FT_BOOLEAN, 8, TFS(&iscsi_meaning_C), 0x40,
|
|
|
|
"Text incomplete", HFILL }
|
|
|
|
},
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #ifdef DRAFT09 */
|
2011-11-09 02:48:51 +00:00
|
|
|
{ &hf_iscsi_Login_X,
|
|
|
|
{ "X", "iscsi.login.X",
|
|
|
|
FT_BOOLEAN, 8, TFS(&iscsi_meaning_login_X), 0x40,
|
|
|
|
"Restart Connection", HFILL }
|
|
|
|
},
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #endif */
|
2011-11-09 02:48:51 +00:00
|
|
|
{ &hf_iscsi_Login_CSG,
|
|
|
|
{ "CSG", "iscsi.login.csg",
|
|
|
|
FT_UINT8, BASE_HEX, VALS(iscsi_login_stage), CSG_MASK,
|
|
|
|
"Current stage", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_Login_NSG,
|
|
|
|
{ "NSG", "iscsi.login.nsg",
|
|
|
|
FT_UINT8, BASE_HEX, VALS(iscsi_login_stage), NSG_MASK,
|
|
|
|
"Next stage", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_Login_Status,
|
|
|
|
{ "Status", "iscsi.login.status",
|
|
|
|
FT_UINT16, BASE_HEX, VALS(iscsi_login_status), 0,
|
|
|
|
"Status class and detail", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_KeyValue,
|
|
|
|
{ "KeyValue", "iscsi.keyvalue",
|
|
|
|
FT_STRING, BASE_NONE, NULL, 0,
|
|
|
|
"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_Text_C,
|
|
|
|
{ "C", "iscsi.text.C",
|
|
|
|
FT_BOOLEAN, 8, TFS(&iscsi_meaning_C), 0x40,
|
|
|
|
"Text incomplete", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_ExpDataSN,
|
|
|
|
{ "ExpDataSN", "iscsi.expdatasn",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Next expected data sequence number", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_R2TSN,
|
|
|
|
{ "R2TSN", "iscsi.r2tsn",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"R2T PDU Number", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_TaskManagementFunction_Response,
|
|
|
|
{ "Response", "iscsi.taskmanfun.response",
|
|
|
|
FT_UINT8, BASE_HEX, VALS(iscsi_task_management_responses), 0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_TaskManagementFunction_ReferencedTaskTag,
|
|
|
|
{ "ReferencedTaskTag", "iscsi.taskmanfun.referencedtasktag",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Referenced task tag", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_RefCmdSN,
|
|
|
|
{ "RefCmdSN", "iscsi.refcmdsn",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Command sequence number for command to be aborted", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_TaskManagementFunction_Function,
|
|
|
|
{ "Function", "iscsi.taskmanfun.function",
|
|
|
|
FT_UINT8, BASE_HEX, VALS(iscsi_task_management_functions), 0x7F,
|
|
|
|
"Requested task function", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_Logout_Reason,
|
|
|
|
{ "Reason", "iscsi.logout.reason",
|
|
|
|
FT_UINT8, BASE_HEX, VALS(iscsi_logout_reasons), 0x7F,
|
|
|
|
"Reason for logout", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_Logout_Response,
|
|
|
|
{ "Response", "iscsi.logout.response",
|
|
|
|
FT_UINT8, BASE_HEX, VALS(iscsi_logout_response), 0,
|
|
|
|
"Logout response", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_Time2Wait,
|
|
|
|
{ "Time2Wait", "iscsi.time2wait",
|
|
|
|
FT_UINT16, BASE_HEX, NULL, 0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_Time2Retain,
|
|
|
|
{ "Time2Retain", "iscsi.time2retain",
|
|
|
|
FT_UINT16, BASE_HEX, NULL, 0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_DesiredDataLength,
|
|
|
|
{ "DesiredDataLength", "iscsi.desireddatalength",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Desired data length (bytes)", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_AsyncEvent,
|
|
|
|
{ "AsyncEvent", "iscsi.asyncevent",
|
|
|
|
FT_UINT8, BASE_HEX, VALS(iscsi_asyncevents), 0,
|
|
|
|
"Async event type", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_EventVendorCode,
|
|
|
|
{ "EventVendorCode", "iscsi.eventvendorcode",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0,
|
|
|
|
"Event vendor code", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_Parameter1,
|
|
|
|
{ "Parameter1", "iscsi.parameter1",
|
|
|
|
FT_UINT16, BASE_HEX, NULL, 0,
|
|
|
|
"Parameter 1", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_Parameter2,
|
|
|
|
{ "Parameter2", "iscsi.parameter2",
|
|
|
|
FT_UINT16, BASE_HEX, NULL, 0,
|
|
|
|
"Parameter 2", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_Parameter3,
|
|
|
|
{ "Parameter3", "iscsi.parameter3",
|
|
|
|
FT_UINT16, BASE_HEX, NULL, 0,
|
|
|
|
"Parameter 3", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_Reject_Reason,
|
|
|
|
{ "Reason", "iscsi.reject.reason",
|
|
|
|
FT_UINT8, BASE_HEX, VALS(iscsi_reject_reasons), 0,
|
|
|
|
"Reason for command rejection", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_snack_type,
|
|
|
|
{ "S", "iscsi.snack.type",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(iscsi_snack_types), 0x0f,
|
|
|
|
"Type of SNACK requested", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_BegRun,
|
|
|
|
{ "BegRun", "iscsi.snack.begrun",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"First missed DataSN or StatSN", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_iscsi_RunLength,
|
|
|
|
{ "RunLength", "iscsi.snack.runlength",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0,
|
|
|
|
"Number of additional missing status PDUs in this run", HFILL }
|
|
|
|
},
|
2001-05-30 18:52:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Setup protocol subtree array */
|
|
|
|
static gint *ett[] = {
|
2011-11-09 02:48:51 +00:00
|
|
|
&ett_iscsi,
|
|
|
|
&ett_iscsi_KeyValues,
|
|
|
|
&ett_iscsi_CDB,
|
|
|
|
&ett_iscsi_Flags,
|
|
|
|
&ett_iscsi_RejectHeader,
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #ifndef DRAFT08 */
|
2011-11-09 02:48:51 +00:00
|
|
|
&ett_iscsi_ISID,
|
2002-05-14 21:35:17 +00:00
|
|
|
/* #endif */
|
2001-05-30 18:52:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Register the protocol name and description */
|
2001-10-23 05:40:36 +00:00
|
|
|
proto_iscsi = proto_register_protocol("iSCSI", "iSCSI", "iscsi");
|
2001-05-30 18:52:38 +00:00
|
|
|
|
2001-10-21 17:20:10 +00:00
|
|
|
/* Required function calls to register the header fields and
|
|
|
|
* subtrees used */
|
2001-05-30 18:52:38 +00:00
|
|
|
proto_register_field_array(proto_iscsi, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2011-08-11 21:59:02 +00:00
|
|
|
iscsi_module = prefs_register_protocol(proto_iscsi, NULL);
|
|
|
|
|
|
|
|
prefs_register_enum_preference(iscsi_module,
|
2011-11-09 02:48:51 +00:00
|
|
|
"protocol_version",
|
|
|
|
"Protocol version",
|
|
|
|
"The iSCSI protocol version",
|
|
|
|
&iscsi_protocol_version,
|
|
|
|
iscsi_protocol_versions,
|
|
|
|
FALSE);
|
2011-08-11 21:59:02 +00:00
|
|
|
|
|
|
|
prefs_register_bool_preference(iscsi_module,
|
2011-11-09 02:48:51 +00:00
|
|
|
"desegment_iscsi_messages",
|
|
|
|
"Reassemble iSCSI messages\nspanning multiple TCP segments",
|
|
|
|
"Whether the iSCSI dissector should reassemble messages spanning multiple TCP segments."
|
|
|
|
" To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
|
|
|
|
&iscsi_desegment);
|
2011-08-11 21:59:02 +00:00
|
|
|
|
|
|
|
prefs_register_bool_preference(iscsi_module,
|
2011-11-09 02:48:51 +00:00
|
|
|
"bogus_pdu_filter",
|
|
|
|
"Enable bogus pdu filter",
|
|
|
|
"When enabled, packets that appear bogus are ignored",
|
|
|
|
&enable_bogosity_filter);
|
2011-08-11 21:59:02 +00:00
|
|
|
|
|
|
|
prefs_register_bool_preference(iscsi_module,
|
2011-11-09 02:48:51 +00:00
|
|
|
"demand_good_f_bit",
|
|
|
|
"Ignore packets with bad F bit",
|
|
|
|
"Ignore packets that haven't set the F bit when they should have",
|
|
|
|
&demand_good_f_bit);
|
2011-08-11 21:59:02 +00:00
|
|
|
|
|
|
|
prefs_register_uint_preference(iscsi_module,
|
2011-11-09 02:48:51 +00:00
|
|
|
"bogus_pdu_max_data_len",
|
|
|
|
"Bogus pdu max data length threshold",
|
|
|
|
"Treat packets whose data segment length is greater than this value as bogus",
|
|
|
|
10,
|
|
|
|
&bogus_pdu_data_length_threshold);
|
2011-08-11 21:59:02 +00:00
|
|
|
|
|
|
|
range_convert_str(&global_iscsi_port_range, TCP_PORT_ISCSI_RANGE, MAX_TCP_PORT);
|
|
|
|
prefs_register_range_preference(iscsi_module,
|
2011-11-09 02:48:51 +00:00
|
|
|
"target_ports",
|
|
|
|
"Target Ports Range",
|
|
|
|
"Range of iSCSI target ports"
|
|
|
|
"(default " TCP_PORT_ISCSI_RANGE ")",
|
|
|
|
&global_iscsi_port_range, MAX_TCP_PORT);
|
2011-08-11 21:59:02 +00:00
|
|
|
|
|
|
|
prefs_register_uint_preference(iscsi_module,
|
2011-11-09 02:48:51 +00:00
|
|
|
"target_system_port",
|
|
|
|
"Target system port",
|
|
|
|
"System port number of iSCSI target",
|
|
|
|
10,
|
|
|
|
&iscsi_system_port);
|
2011-08-11 21:59:02 +00:00
|
|
|
|
|
|
|
prefs_register_bool_preference(iscsi_module,
|
2011-11-09 02:48:51 +00:00
|
|
|
"enable_data_digests",
|
|
|
|
"Enable data digests",
|
|
|
|
"When enabled, pdus are assumed to contain a data digest",
|
|
|
|
&enableDataDigests);
|
2011-08-11 21:59:02 +00:00
|
|
|
|
|
|
|
prefs_register_bool_preference(iscsi_module,
|
2011-11-09 02:48:51 +00:00
|
|
|
"data_digest_is_crc32c",
|
|
|
|
"Data digest is CRC32C",
|
|
|
|
"When enabled, data digests are assumed to be CRC32C",
|
|
|
|
&dataDigestIsCRC32);
|
2011-08-11 21:59:02 +00:00
|
|
|
|
|
|
|
prefs_register_uint_preference(iscsi_module,
|
2011-11-09 02:48:51 +00:00
|
|
|
"data_digest_size",
|
|
|
|
"Data digest size",
|
|
|
|
"The size of a data digest (bytes)",
|
|
|
|
10,
|
|
|
|
&dataDigestSize);
|
2011-08-11 21:59:02 +00:00
|
|
|
|
|
|
|
/* Preference supported in older versions.
|
|
|
|
Register them as obsolete. */
|
|
|
|
prefs_register_obsolete_preference(iscsi_module,
|
2011-11-09 02:48:51 +00:00
|
|
|
"version_03_compatible");
|
2011-08-11 21:59:02 +00:00
|
|
|
prefs_register_obsolete_preference(iscsi_module,
|
2011-11-09 02:48:51 +00:00
|
|
|
"bogus_pdu_max_digest_padding");
|
2011-08-11 21:59:02 +00:00
|
|
|
prefs_register_obsolete_preference(iscsi_module,
|
2011-11-09 02:48:51 +00:00
|
|
|
"header_digest_is_crc32c");
|
2011-08-11 21:59:02 +00:00
|
|
|
prefs_register_obsolete_preference(iscsi_module,
|
2011-11-09 02:48:51 +00:00
|
|
|
"header_digest_size");
|
2011-08-11 21:59:02 +00:00
|
|
|
prefs_register_obsolete_preference(iscsi_module,
|
2011-11-09 02:48:51 +00:00
|
|
|
"enable_header_digests");
|
2001-05-30 18:52:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-21 17:20:10 +00:00
|
|
|
/*
|
|
|
|
* If this dissector uses sub-dissector registration add a
|
|
|
|
* registration routine.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This format is required because a script is used to find these
|
|
|
|
* routines and create the code that calls these routines.
|
|
|
|
*/
|
2001-05-30 18:52:38 +00:00
|
|
|
void
|
|
|
|
proto_reg_handoff_iscsi(void)
|
|
|
|
{
|
2003-06-15 02:02:59 +00:00
|
|
|
heur_dissector_add("tcp", dissect_iscsi_heur, proto_iscsi);
|
|
|
|
|
2006-06-20 13:16:50 +00:00
|
|
|
iscsi_handle = new_create_dissector_handle(dissect_iscsi_handle, proto_iscsi);
|
2003-06-15 02:02:59 +00:00
|
|
|
dissector_add_handle("tcp.port", iscsi_handle);
|
2001-05-30 18:52:38 +00:00
|
|
|
}
|