aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-02-13 01:17:58 +0000
committerGuy Harris <guy@alum.mit.edu>2002-02-13 01:17:58 +0000
commita006c4fcca985cbefa95e622558ff27bdcac91f0 (patch)
tree37db49888f31541b17fde38a34e1802571ea441f
parent2c62907ff6da38de0bf4258dc4f663906c8f63ee (diff)
Have the private data for the SCSI dissection routines be a pointer to a
structure containing a 32-bit conversation ID (which uniquely identifies conversations between a SCSI initiator and target) and a 32-bit task ID (which uniquely identifies a task within that conversation). Have the NDMP dissector create conversations when it sees an "execute CDB" request, and use the conversation index as the conversation ID and the sequence number for requests and reply sequence for replies as the task ID. Have it use "dissect_scsi_payload()" to dissect the payload of "execute CDB" requests and replies. svn path=/trunk/; revision=4726
-rw-r--r--packet-iscsi.c22
-rw-r--r--packet-ndmp.c265
-rw-r--r--packet-scsi.c51
-rw-r--r--packet-scsi.h14
4 files changed, 258 insertions, 94 deletions
diff --git a/packet-iscsi.c b/packet-iscsi.c
index e6697de963..8b5348de4a 100644
--- a/packet-iscsi.c
+++ b/packet-iscsi.c
@@ -6,7 +6,7 @@
* Optionally, may be compiled for compatibility with
* draft-ietf-ips-iscsi-08.txt by defining DRAFT08
*
- * $Id: packet-iscsi.c,v 1.25 2002/02/02 03:27:54 guy Exp $
+ * $Id: packet-iscsi.c,v 1.26 2002/02/13 01:17:58 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -706,6 +706,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
conversation_t *conversation = NULL;
iscsi_conv_data_t *cdata = NULL;
iscsi_conv_key_t ckey, *req_key;
+ scsi_task_id_t task_key;
int paddedDataSegmentLength = data_segment_len;
if(paddedDataSegmentLength & 3)
paddedDataSegmentLength += 4 - (paddedDataSegmentLength & 3);
@@ -731,8 +732,14 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
cdata = (iscsi_conv_data_t *)g_hash_table_lookup (iscsi_req_hash,
&ckey);
+
+ task_key.conv_id = ckey.conv_idx;
+ task_key.task_id = ckey.itt;
+ pinfo->private_data = &task_key;
+ } else {
+ /* no conversation, meaning we didn't see the request */
+ pinfo->private_data = NULL;
}
- pinfo->private_data = cdata;
if (cdata) {
del_usecs = (pinfo->fd->abs_secs - cdata->abs_secs)* 1000000 +
@@ -761,8 +768,6 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
*/
cdata->abs_usecs = pinfo->fd->abs_usecs;
cdata->abs_secs = pinfo->fd->abs_secs;
- /* The SCSI protocol uses this as the key to detect a
- * SCSI-level conversation. */
}
else {
req_key = g_mem_chunk_alloc (iscsi_req_keys);
@@ -774,10 +779,13 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
cdata->abs_secs = pinfo->fd->abs_secs;
g_hash_table_insert (iscsi_req_hash, req_key, cdata);
- /* The SCSI protocol uses this as the key to detect a
- * SCSI-level conversation. */
}
- pinfo->private_data = cdata;
+
+ /* The SCSI protocol uses this as the key to detect a
+ * SCSI-level conversation. */
+ task_key.conv_id = ckey.conv_idx;
+ task_key.task_id = ckey.itt;
+ pinfo->private_data = &task_key;
}
else {
pinfo->private_data = NULL;
diff --git a/packet-ndmp.c b/packet-ndmp.c
index 76f550e609..48de9e8298 100644
--- a/packet-ndmp.c
+++ b/packet-ndmp.c
@@ -2,7 +2,7 @@
* Routines for NDMP dissection
* 2001 Ronnie Sahlberg (see AUTHORS for email)
*
- * $Id: packet-ndmp.c,v 1.14 2002/02/12 23:56:37 guy Exp $
+ * $Id: packet-ndmp.c,v 1.15 2002/02/13 01:17:58 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -40,6 +40,7 @@
#include <glib.h>
#include <epan/packet.h>
+#include <epan/conversation.h>
#include "packet-rpc.h"
#include "packet-scsi.h"
#include "packet-frame.h"
@@ -221,6 +222,7 @@ static gint ett_ndmp_tape_attr = -1;
static gint ett_ndmp_execute_cdb_flags = -1;
static gint ett_ndmp_execute_cdb_cdb = -1;
static gint ett_ndmp_execute_cdb_sns = -1;
+static gint ett_ndmp_execute_cdb_payload = -1;
static gint ett_ndmp_tape_invalid = -1;
static gint ett_ndmp_tape_flags = -1;
static gint ett_ndmp_addr = -1;
@@ -425,7 +427,8 @@ static const value_string msg_vals[] = {
static int
-dissect_connect_open_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_connect_open_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* version number */
proto_tree_add_item(tree, hf_ndmp_version, tvb, offset, 4, FALSE);
@@ -435,7 +438,8 @@ dissect_connect_open_request(tvbuff_t *tvb, int offset, packet_info *pinfo, prot
}
static int
-dissect_error(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_error(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree,
+ guint32 seq)
{
/* error */
proto_tree_add_item(tree, hf_ndmp_error, tvb, offset, 4, FALSE);
@@ -445,7 +449,8 @@ dissect_error(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
}
static int
-dissect_ndmp_get_host_info_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_ndmp_get_host_info_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* error */
proto_tree_add_item(tree, hf_ndmp_error, tvb, offset, 4, FALSE);
@@ -485,7 +490,6 @@ static const value_string addr_type_vals[] = {
static int
dissect_ndmp_addr_type(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
{
- /*address type*/
proto_tree_add_item(tree, hf_ndmp_addr_type, tvb, offset, 4, FALSE);
offset += 4;
@@ -493,7 +497,16 @@ dissect_ndmp_addr_type(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree
}
static int
-dissect_ndmp_config_get_connection_type_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_ndmp_addr_msg(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
+{
+ /*address type*/
+ return dissect_ndmp_addr_type(tvb, offset, pinfo, tree);
+}
+
+static int
+dissect_ndmp_config_get_connection_type_reply(tvbuff_t *tvb, int offset,
+ packet_info *pinfo, proto_tree *tree, guint32 seq)
{
/* error */
proto_tree_add_item(tree, hf_ndmp_error, tvb, offset, 4, FALSE);
@@ -518,7 +531,6 @@ static const value_string auth_type_vals[] = {
static int
dissect_auth_type(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
{
- /* auth type */
proto_tree_add_item(tree, hf_ndmp_auth_type, tvb, offset, 4, FALSE);
offset += 4;
@@ -526,7 +538,16 @@ dissect_auth_type(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tre
}
static int
-dissect_auth_attr(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_get_auth_type_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
+{
+ /* auth type */
+ return dissect_auth_type(tvb, offset, pinfo, tree);
+}
+
+static int
+dissect_auth_attr_msg(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
guint type;
@@ -656,7 +677,8 @@ dissect_butype_info(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *t
}
static int
-dissect_get_butype_info_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_get_butype_info_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* error */
proto_tree_add_item(tree, hf_ndmp_error, tvb, offset, 4, FALSE);
@@ -782,7 +804,8 @@ dissect_fs_info(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
}
static int
-dissect_get_fs_info_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_get_fs_info_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* error */
proto_tree_add_item(tree, hf_ndmp_error, tvb, offset, 4, FALSE);
@@ -872,7 +895,8 @@ dissect_tape_info(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tre
}
static int
-dissect_get_tape_info_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_get_tape_info_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* error */
proto_tree_add_item(tree, hf_ndmp_error, tvb, offset, 4, FALSE);
@@ -900,7 +924,8 @@ dissect_scsi_info(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tre
}
static int
-dissect_get_scsi_info_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_get_scsi_info_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* error */
proto_tree_add_item(tree, hf_ndmp_error, tvb, offset, 4, FALSE);
@@ -914,7 +939,8 @@ dissect_get_scsi_info_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto
}
static int
-dissect_get_server_info_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_get_server_info_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* error */
proto_tree_add_item(tree, hf_ndmp_error, tvb, offset, 4, FALSE);
@@ -941,7 +967,8 @@ dissect_get_server_info_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, pro
}
static int
-dissect_scsi_device(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_scsi_open_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* device */
offset = dissect_rpc_string(tvb, pinfo, tree,
@@ -951,7 +978,8 @@ dissect_scsi_device(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *t
}
static int
-dissect_scsi_get_state_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_scsi_get_state_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* error */
proto_tree_add_item(tree, hf_ndmp_error, tvb, offset, 4, FALSE);
@@ -973,7 +1001,8 @@ dissect_scsi_get_state_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, prot
}
static int
-dissect_scsi_set_state_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_scsi_set_state_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* device */
offset = dissect_rpc_string(tvb, pinfo, tree,
@@ -1024,7 +1053,7 @@ dissect_execute_cdb_cdb(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tre
guint32 cdb_len;
guint32 cdb_len_full;
- cdb_len = tvb_get_ntohl(tvb, offset+0);
+ cdb_len = tvb_get_ntohl(tvb, offset);
cdb_len_full = rpc_roundup(cdb_len);
if (parent_tree) {
@@ -1045,9 +1074,61 @@ dissect_execute_cdb_cdb(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tre
return offset;
}
+
+static int
+dissect_execute_cdb_payload(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *parent_tree,
+ char *name, int hf_len, gboolean isreq)
+{
+ proto_item* item = NULL;
+ proto_tree* tree = NULL;
+ guint32 payload_len;
+ guint32 payload_len_full;
+
+ payload_len = tvb_get_ntohl(tvb, offset);
+ payload_len_full = rpc_roundup(payload_len);
+
+ if (parent_tree) {
+ item = proto_tree_add_text(parent_tree, tvb, offset,
+ 4+payload_len_full, "%s", name);
+ tree = proto_item_add_subtree(item,
+ ett_ndmp_execute_cdb_payload);
+ }
+
+ proto_tree_add_uint(tree, hf_len, tvb, offset, 4, payload_len);
+ offset += 4;
+
+ if (payload_len != 0) {
+ dissect_scsi_payload(tvb, pinfo, tree, offset, isreq,
+ payload_len);
+ offset += payload_len_full;
+ }
+
+ return offset;
+}
+
static int
-dissect_execute_cdb_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_execute_cdb_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
+ conversation_t *conversation;
+ scsi_task_id_t task_key;
+
+ /*
+ * We need to provide SCSI task information to the SCSI
+ * dissection routines. We use a conversation plus the
+ * sequence number in requests and the reply sequence
+ * number in replies to identify SCSI tasks.
+ */
+ conversation = find_conversation(&pinfo->src, &pinfo->dst,
+ pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
+ if (conversation == NULL) {
+ conversation = conversation_new(&pinfo->src, &pinfo->dst,
+ pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
+ }
+ task_key.conv_id = conversation->index;
+ task_key.task_id = seq;
+ pinfo->private_data = &task_key;
+
/* flags */
offset = dissect_execute_cdb_flags(tvb, offset, pinfo, tree);
@@ -1063,9 +1144,10 @@ dissect_execute_cdb_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto
offset = dissect_execute_cdb_cdb(tvb, offset, pinfo, tree);
/* dataout */
- /* XXX - is this present if DATA_OUT isn't set? */
- offset = dissect_rpc_data(tvb, pinfo, tree, hf_ndmp_execute_cdb_dataout,
- offset);
+ offset = dissect_execute_cdb_payload(tvb, offset, pinfo, tree,
+ "Data out", hf_ndmp_execute_cdb_dataout_len, TRUE);
+
+ return offset;
}
static int
@@ -1076,7 +1158,7 @@ dissect_execute_cdb_sns(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tre
guint32 sns_len;
guint32 sns_len_full;
- sns_len = tvb_get_ntohl(tvb, offset+0);
+ sns_len = tvb_get_ntohl(tvb, offset);
sns_len_full = rpc_roundup(sns_len);
if (parent_tree) {
@@ -1098,8 +1180,29 @@ dissect_execute_cdb_sns(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tre
}
static int
-dissect_execute_cdb_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_execute_cdb_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
+ conversation_t *conversation;
+ scsi_task_id_t task_key;
+
+ /*
+ * We need to provide SCSI task information to the SCSI
+ * dissection routines. We use a conversation plus the
+ * sequence number in requests and the reply sequence
+ * number in replies to identify SCSI tasks.
+ */
+ conversation = find_conversation(&pinfo->src, &pinfo->dst,
+ pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
+ if (conversation != NULL) {
+ task_key.conv_id = conversation->index;
+ task_key.task_id = seq;
+ pinfo->private_data = &task_key;
+ } else {
+ /* no conversation, meaning we didn't see the request */
+ pinfo->private_data = NULL;
+ }
+
/* error */
proto_tree_add_item(tree, hf_ndmp_error, tvb, offset, 4, FALSE);
offset += 4;
@@ -1113,8 +1216,8 @@ dissect_execute_cdb_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_t
offset += 4;
/* datain */
- offset = dissect_rpc_data(tvb, pinfo, tree, hf_ndmp_execute_cdb_datain,
- offset);
+ offset = dissect_execute_cdb_payload(tvb, offset, pinfo, tree,
+ "Data in", hf_ndmp_execute_cdb_datain_len, FALSE);
/* ext_sense */
offset = dissect_execute_cdb_sns(tvb, offset, pinfo, tree);
@@ -1131,7 +1234,8 @@ static const value_string tape_open_mode_vals[] = {
};
static int
-dissect_tape_open_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_tape_open_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* device */
offset = dissect_rpc_string(tvb, pinfo, tree,
@@ -1251,7 +1355,8 @@ dissect_tape_flags(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *pa
}
static int
-dissect_tape_get_state_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_tape_get_state_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* invalid bits */
offset=dissect_tape_invalid(tvb, offset, pinfo, tree);
@@ -1313,7 +1418,8 @@ static const value_string tape_mtio_vals[] = {
};
static int
-dissect_tape_mtio_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_tape_mtio_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* op */
proto_tree_add_item(tree, hf_ndmp_tape_mtio_op, tvb, offset, 4, FALSE);
@@ -1327,7 +1433,8 @@ dissect_tape_mtio_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_t
}
static int
-dissect_tape_mtio_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_tape_mtio_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* error */
proto_tree_add_item(tree, hf_ndmp_error, tvb, offset, 4, FALSE);
@@ -1432,7 +1539,8 @@ dissect_ndmp_addr(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *par
}
static int
-dissect_mover_get_state_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_mover_get_state_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* error */
proto_tree_add_item(tree, hf_ndmp_error, tvb, offset, 4, FALSE);
@@ -1493,7 +1601,8 @@ static const value_string mover_mode_vals[] = {
};
static int
-dissect_mover_listen_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_mover_listen_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* mode */
proto_tree_add_item(tree, hf_ndmp_mover_mode, tvb, offset, 4, FALSE);
@@ -1507,7 +1616,8 @@ dissect_mover_listen_request(tvbuff_t *tvb, int offset, packet_info *pinfo, prot
}
static int
-dissect_mover_listen_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_mover_listen_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* error */
proto_tree_add_item(tree, hf_ndmp_error, tvb, offset, 4, FALSE);
@@ -1520,7 +1630,8 @@ dissect_mover_listen_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_
}
static int
-dissect_mover_set_window_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_mover_set_window_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* window offset */
proto_tree_add_item(tree, hf_ndmp_window_offset, tvb, offset, 8, FALSE);
@@ -1534,7 +1645,8 @@ dissect_mover_set_window_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
}
static int
-dissect_mover_set_record_size_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_mover_set_record_size_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* record size */
proto_tree_add_item(tree, hf_ndmp_record_size, tvb, offset, 4, FALSE);
@@ -1544,7 +1656,8 @@ dissect_mover_set_record_size_request(tvbuff_t *tvb, int offset, packet_info *pi
}
static int
-dissect_mover_connect_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_mover_connect_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* mode */
proto_tree_add_item(tree, hf_ndmp_mover_mode, tvb, offset, 4, FALSE);
@@ -1557,7 +1670,8 @@ dissect_mover_connect_request(tvbuff_t *tvb, int offset, packet_info *pinfo, pro
}
static int
-dissect_log_file_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_log_file_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* file */
offset = dissect_rpc_string(tvb, pinfo, tree,
@@ -1583,7 +1697,8 @@ static const value_string log_type_vals[] = {
};
static int
-dissect_log_message_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_log_message_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* type */
proto_tree_add_item(tree, hf_ndmp_log_type, tvb, offset, 4, FALSE);
@@ -1601,7 +1716,8 @@ dissect_log_message_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto
}
static int
-dissect_notify_data_halted_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_notify_data_halted_request(tvbuff_t *tvb, int offset,
+ packet_info *pinfo, proto_tree *tree, guint32 seq)
{
/* halt */
proto_tree_add_item(tree, hf_ndmp_halt, tvb, offset, 4, FALSE);
@@ -1625,7 +1741,8 @@ static const value_string connected_vals[] = {
};
static int
-dissect_notify_connected_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_notify_connected_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* connected */
proto_tree_add_item(tree, hf_ndmp_connected, tvb, offset, 4, FALSE);
@@ -1644,7 +1761,8 @@ dissect_notify_connected_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
static int
-dissect_notify_mover_paused_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_notify_mover_paused_request(tvbuff_t *tvb, int offset,
+ packet_info *pinfo, proto_tree *tree, guint32 seq)
{
/* mover pause */
proto_tree_add_item(tree, hf_ndmp_mover_pause, tvb, offset, 4, FALSE);
@@ -1696,9 +1814,16 @@ dissect_auth_data(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tre
return offset;
}
+static int
+dissect_connect_client_auth_request(tvbuff_t *tvb, int offset,
+ packet_info *pinfo, proto_tree *tree, guint32 seq)
+{
+ return dissect_auth_data(tvb, offset, pinfo, tree);
+}
static int
-dissect_connect_server_auth_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_connect_server_auth_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* error */
proto_tree_add_item(tree, hf_ndmp_error, tvb, offset, 4, FALSE);
@@ -1711,7 +1836,8 @@ dissect_connect_server_auth_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
}
static int
-dissect_tape_write_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_tape_write_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* data */
offset = dissect_rpc_data(tvb, pinfo, tree, hf_ndmp_data, offset);
@@ -1720,7 +1846,8 @@ dissect_tape_write_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_
}
static int
-dissect_tape_write_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_tape_write_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* error */
proto_tree_add_item(tree, hf_ndmp_error, tvb, offset, 4, FALSE);
@@ -1734,7 +1861,8 @@ dissect_tape_write_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tr
}
static int
-dissect_tape_read_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_tape_read_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* count */
proto_tree_add_item(tree, hf_ndmp_count, tvb, offset, 4, FALSE);
@@ -1744,7 +1872,8 @@ dissect_tape_read_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_t
}
static int
-dissect_tape_read_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_tape_read_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* error */
proto_tree_add_item(tree, hf_ndmp_error, tvb, offset, 4, FALSE);
@@ -1989,7 +2118,8 @@ dissect_file(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *parent_t
}
static int
-dissect_fh_add_file_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_fh_add_file_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* files */
offset = dissect_rpc_array(tvb, pinfo, tree, offset,
@@ -2017,7 +2147,8 @@ dissect_dir(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
}
static int
-dissect_fh_add_dir_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_fh_add_dir_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* dirs */
offset = dissect_rpc_array(tvb, pinfo, tree, offset,
@@ -2046,7 +2177,8 @@ dissect_node(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
static int
-dissect_fh_add_node_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_fh_add_node_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* node */
offset = dissect_rpc_array(tvb, pinfo, tree, offset,
@@ -2056,7 +2188,8 @@ dissect_fh_add_node_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto
}
static int
-dissect_data_start_backup_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_data_start_backup_request(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/*butype name*/
offset = dissect_rpc_string(tvb, pinfo, tree,
@@ -2101,7 +2234,8 @@ dissect_nlist(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
static int
-dissect_data_start_recover_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_data_start_recover_request(tvbuff_t *tvb, int offset,
+ packet_info *pinfo, proto_tree *tree, guint32 seq)
{
/* default env */
offset = dissect_rpc_array(tvb, pinfo, tree, offset,
@@ -2119,7 +2253,8 @@ dissect_data_start_recover_request(tvbuff_t *tvb, int offset, packet_info *pinfo
}
static int
-dissect_data_get_env_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_data_get_env_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
/* error */
proto_tree_add_item(tree, hf_ndmp_error, tvb, offset, 4, FALSE);
@@ -2203,7 +2338,8 @@ static const value_string data_halted_vals[] = {
};
static int
-dissect_data_get_state_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_data_get_state_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq)
{
nstime_t ns;
@@ -2257,8 +2393,10 @@ dissect_data_get_state_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, prot
typedef struct _ndmp_command {
guint32 cmd;
- int (*request) (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
- int (*response)(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
+ int (*request) (tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq);
+ int (*response)(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 seq);
} ndmp_command;
static const ndmp_command ndmp_commands[] = {
@@ -2267,7 +2405,7 @@ static const ndmp_command ndmp_commands[] = {
{NDMP_CONFIG_GET_CONNECTION_TYPE,
NULL, dissect_ndmp_config_get_connection_type_reply},
{NDMP_CONFIG_GET_AUTH_ATTR,
- dissect_auth_type, dissect_auth_attr},
+ dissect_get_auth_type_request, dissect_auth_attr_msg},
{NDMP_CONFIG_GET_BUTYPE_INFO,
NULL, dissect_get_butype_info_reply},
{NDMP_CONFIG_GET_FS_INFO,
@@ -2279,7 +2417,7 @@ static const ndmp_command ndmp_commands[] = {
{NDMP_CONFIG_GET_SERVER_INFO,
NULL, dissect_get_server_info_reply},
{NDMP_SCSI_OPEN,
- dissect_scsi_device, dissect_error},
+ dissect_scsi_open_request, dissect_error},
{NDMP_SCSI_CLOSE,
NULL, dissect_error},
{NDMP_SCSI_GET_STATE,
@@ -2319,9 +2457,9 @@ static const ndmp_command ndmp_commands[] = {
{NDMP_DATA_STOP,
NULL, dissect_error},
{NDMP_DATA_LISTEN,
- dissect_ndmp_addr_type, dissect_mover_listen_reply},
+ dissect_ndmp_addr_msg, dissect_mover_listen_reply},
{NDMP_DATA_CONNECT,
- dissect_ndmp_addr, dissect_error},
+ dissect_ndmp_addr_msg, dissect_error},
{NDMP_NOTIFY_DATA_HALTED,
dissect_notify_data_halted_request, NULL},
{NDMP_NOTIFY_CONNECTED,
@@ -2345,11 +2483,11 @@ static const ndmp_command ndmp_commands[] = {
{NDMP_CONNECT_OPEN,
dissect_connect_open_request, dissect_error},
{NDMP_CONNECT_CLIENT_AUTH,
- dissect_auth_data, dissect_error},
+ dissect_connect_client_auth_request, dissect_error},
{NDMP_CONNECT_CLOSE,
NULL,NULL},
{NDMP_CONNECT_SERVER_AUTH,
- dissect_auth_attr, dissect_connect_server_auth_reply},
+ dissect_auth_attr_msg, dissect_connect_server_auth_reply},
{NDMP_MOVER_GET_STATE,
NULL, dissect_mover_get_state_reply},
{NDMP_MOVER_LISTEN,
@@ -2461,11 +2599,13 @@ dissect_ndmp_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree
if(nh->type==NDMP_MESSAGE_REQUEST){
if(ndmp_commands[i].request){
- offset=ndmp_commands[i].request(tvb, offset, pinfo, cmd_tree);
+ offset=ndmp_commands[i].request(tvb, offset, pinfo, cmd_tree,
+ nh->seq);
}
} else {
if(ndmp_commands[i].response){
- offset=ndmp_commands[i].response(tvb, offset, pinfo, cmd_tree);
+ offset=ndmp_commands[i].response(tvb, offset, pinfo, cmd_tree,
+ nh->rep_seq);
}
}
@@ -3244,6 +3384,7 @@ proto_register_ndmp(void)
&ett_ndmp_execute_cdb_flags,
&ett_ndmp_execute_cdb_cdb,
&ett_ndmp_execute_cdb_sns,
+ &ett_ndmp_execute_cdb_payload,
&ett_ndmp_tape_invalid,
&ett_ndmp_tape_flags,
&ett_ndmp_addr,
diff --git a/packet-scsi.c b/packet-scsi.c
index 26639f5120..152668d131 100644
--- a/packet-scsi.c
+++ b/packet-scsi.c
@@ -2,7 +2,7 @@
* Routines for decoding SCSI CDBs and responses
* Author: Dinesh G Dutt (ddutt@cisco.com)
*
- * $Id: packet-scsi.c,v 1.4 2002/02/12 23:52:34 guy Exp $
+ * $Id: packet-scsi.c,v 1.5 2002/02/13 01:17:58 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -29,7 +29,7 @@
* The SCSI decoder has been built right now that it is invoked directly by the
* SCSI transport layers as compared to the standard mechanism of being invoked
* via a dissector chain. There are multiple reasons for this:
- * - The SCSI CDB is typically embedded inside the transport alongwith other
+ * - The SCSI CDB is typically embedded inside the transport along with other
* header fields that have nothing to do with SCSI. So, it is required to be
* invoked on a embedded subset of the packet.
* - Originally, Ethereal couldn't do filtering on protocol trees that were not
@@ -54,12 +54,16 @@
* guint);
*
* In addition to this, the other requirement made from the transport is to
- * provide a unique way to determine a SCSI task. In Fibre channel networks,
+ * provide a unique way to determine a SCSI task. In Fibre Channel networks,
* this is the exchange ID pair alongwith the source/destination addresses; in
* iSCSI it is the initiator task tag along with the src/dst address and port
* numbers. This is to be provided to the SCSI decoder via the private_data
* field in the packet_info data structure. The private_data field is treated
- * as a 32-bit field to uniquely identify a SCSI task.
+ * as a pointer to a "scsi_task_id_t" structure, containing a conversation
+ * ID (a number uniquely identifying a conversation between a particular
+ * initiator and target, e.g. between two Fibre Channel addresses or between
+ * two TCP address/port pairs for iSCSI or NDMP) and a task ID (a number
+ * uniquely identifying a task within that conversation).
*
* This decoder attempts to track the type of SCSI device based on the response
* to the Inquiry command. If the trace does not contain an Inquiry command,
@@ -1083,11 +1087,11 @@ const value_string scsi_status_val[] = {
static gint scsi_def_devtype = SCSI_DEV_SBC;
-/* The next two structures are used to track SCSI req/rsp */
-typedef struct _scsi_task_key {
- guint32 conv_idx;
-} scsi_task_key_t;
-
+/*
+ * We track SCSI requests and responses with a hash table.
+ * The key is a "scsi_task_id_t" structure; the data is a
+ * "scsi_task_data_t" structure.
+ */
typedef struct _scsi_task_data {
guint32 opcode;
scsi_device_type devtype;
@@ -1121,19 +1125,19 @@ static dissector_handle_t data_handle;
static gint
scsi_equal(gconstpointer v, gconstpointer w)
{
- scsi_task_key_t *v1 = (scsi_task_key_t *)v;
- scsi_task_key_t *v2 = (scsi_task_key_t *)w;
+ scsi_task_id_t *v1 = (scsi_task_id_t *)v;
+ scsi_task_id_t *v2 = (scsi_task_id_t *)w;
- return (v1->conv_idx == v2->conv_idx);
+ return (v1->conv_id == v2->conv_id && v1->task_id == v2->task_id);
}
static guint
scsi_hash (gconstpointer v)
{
- scsi_task_key_t *key = (scsi_task_key_t *)v;
+ scsi_task_id_t *key = (scsi_task_id_t *)v;
guint val;
- val = key->conv_idx;
+ val = key->conv_id + key->task_id;
return val;
}
@@ -1169,17 +1173,17 @@ static scsi_task_data_t *
scsi_new_task (packet_info *pinfo)
{
scsi_task_data_t *cdata = NULL;
- scsi_task_key_t ckey, *req_key;
+ scsi_task_id_t ckey, *req_key;
conversation_t *conversation;
if ((pinfo != NULL) && (pinfo->private_data)) {
- ckey.conv_idx = (guint32)pinfo->private_data;
+ ckey = *(scsi_task_id_t *)pinfo->private_data;
cdata = (scsi_task_data_t *)g_hash_table_lookup (scsi_req_hash,
&ckey);
if (!cdata) {
req_key = g_mem_chunk_alloc (scsi_req_keys);
- req_key->conv_idx = (guint32 )pinfo->private_data;
+ *req_key = *(scsi_task_id_t *)pinfo->private_data;
cdata = g_mem_chunk_alloc (scsi_req_vals);
@@ -1193,11 +1197,11 @@ static scsi_task_data_t *
scsi_find_task (packet_info *pinfo)
{
scsi_task_data_t *cdata = NULL;
- scsi_task_key_t ckey, *req_key;
+ scsi_task_id_t ckey;
conversation_t *conversation;
if ((pinfo != NULL) && (pinfo->private_data)) {
- ckey.conv_idx = (guint32)pinfo->private_data;
+ ckey = *(scsi_task_id_t *)pinfo->private_data;
cdata = (scsi_task_data_t *)g_hash_table_lookup (scsi_req_hash,
&ckey);
@@ -1209,11 +1213,11 @@ static void
scsi_end_task (packet_info *pinfo)
{
scsi_task_data_t *cdata = NULL;
- scsi_task_key_t ckey, *req_key;
+ scsi_task_id_t ckey;
conversation_t *conversation;
if ((pinfo != NULL) && (pinfo->private_data)) {
- ckey.conv_idx = (guint32)pinfo->private_data;
+ ckey = *(scsi_task_id_t *)pinfo->private_data;
cdata = (scsi_task_data_t *)g_hash_table_lookup (scsi_req_hash,
&ckey);
if (cdata) {
@@ -1244,9 +1248,9 @@ scsi_init_protocol(void)
scsi_req_hash = g_hash_table_new(scsi_hash, scsi_equal);
scsi_req_keys = g_mem_chunk_new("scsi_req_keys",
- sizeof(scsi_task_key_t),
+ sizeof(scsi_task_id_t),
scsi_init_count *
- sizeof(scsi_task_key_t),
+ sizeof(scsi_task_id_t),
G_ALLOC_AND_FREE);
scsi_req_vals = g_mem_chunk_new("scsi_req_vals",
sizeof(scsi_task_data_t),
@@ -2684,7 +2688,6 @@ dissect_scsi_cdb (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
gchar *valstr;
conversation_t *conversation;
scsi_task_data_t *cdata;
- scsi_task_key_t ckey, *req_key;
scsi_devtype_key_t dkey;
scsi_devtype_data_t *devdata;
diff --git a/packet-scsi.h b/packet-scsi.h
index 0a5a024ac7..a152ce7ac8 100644
--- a/packet-scsi.h
+++ b/packet-scsi.h
@@ -1,7 +1,7 @@
/* packet-scsi.h
* Author: Dinesh G Dutt (ddutt@cisco.com)
*
- * $Id: packet-scsi.h,v 1.2 2002/02/12 23:52:34 guy Exp $
+ * $Id: packet-scsi.h,v 1.3 2002/02/13 01:17:58 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -35,4 +35,16 @@ void dissect_scsi_rsp (tvbuff_t *, packet_info *, proto_tree *);
void dissect_scsi_payload (tvbuff_t *, packet_info *, proto_tree *, guint,
gboolean, guint32);
void dissect_scsi_snsinfo (tvbuff_t *, packet_info *, proto_tree *, guint, guint);
+
+/*
+ * Private data to be supplied to those functions via "pinfo->private_data";
+ * the structure contains a 32-bit conversation ID and a 32-bit task
+ * ID, where the former identifies a conversation between initiator and
+ * target and the latter identifies a SCSI task within that conversation.
+ */
+typedef struct {
+ guint32 conv_id;
+ guint32 task_id;
+} scsi_task_id_t;
+
#endif