2 * Routines for dissassembly of the Hyper SCSI protocol.
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
9 * Copyright 2002 Richard Sharpe <rsharpe@richardsharpe.com>
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include <epan/packet.h>
32 static int proto_hyperscsi
;
34 static int hf_hs_cmd
= -1;
35 static int hf_hs_ver
= -1;
36 static int hf_hs_res
= -1;
37 static int hf_hs_tagno
= -1;
38 static int hf_hs_lastfrag
= -1;
39 static int hf_hs_fragno
= -1;
41 static gint ett_hyperscsi
= -1;
42 static gint ett_hs_hdr
= -1;
43 static gint ett_hs_pdu
= -1;
45 static const true_false_string tfs_lastfrag
= {
50 #define HSCSI_OPCODE_REQUEST 0x00
51 #define HSCSI_OPCODE_REPLY 0x01
52 #define HSCSI_OPCODE_DEV_DISCOVERY 0x10
53 #define HSCSI_OPCODE_ADN_REQUEST 0x11
54 #define HSCSI_OPCODE_ADN_REPLY 0x12
55 #define HSCSI_OPCODE_DISCONNECT 0x13
56 #define HSCSI_OPCODE_ACK_SNR 0x20
57 #define HSCSI_OPCODE_ACK_REPLY 0x21
58 #define HSCSI_OPCODE_ADDR_REPORT 0x30
59 #define HSCSI_OPCODE_ADDR_REPLY 0x31
60 #define HSCSI_OPCODE_LOCAL_REQUEST 0x32
61 #define HSCSI_OPCODE_LOCAL_REPLY 0x33
62 #define HSCSI_OPCODE_REMOTE_REQUEST 0x34
63 #define HSCSI_OPCODE_REMOTE_REPLY 0x35
65 static const value_string hscsi_opcodes
[] = {
66 { HSCSI_OPCODE_REQUEST
, "Command Block Encap Request"},
67 { HSCSI_OPCODE_REPLY
, "Command Block Encap Reply"},
68 { HSCSI_OPCODE_DEV_DISCOVERY
, "Device Discovery Reply"},
69 { HSCSI_OPCODE_ADN_REQUEST
, "Auth/Device Neg Request"},
70 { HSCSI_OPCODE_ADN_REPLY
, "Auth/Device Neg Reply"},
71 { HSCSI_OPCODE_DISCONNECT
, "Disconnect Request"},
72 { HSCSI_OPCODE_ACK_SNR
, "Flow Control Setup/Ack Request"},
73 { HSCSI_OPCODE_ACK_REPLY
, "Flow Control Ack Reply"},
77 #define OPCODE_MASK 0x7F
80 dissect_hyperscsi(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
82 guint hs_hdr1
, hs_hdr2
, hs_hdr3
;
87 proto_tree
*hs_hdr_tree
, *hs_pdu_tree
;
88 proto_tree
*hs_tree
= NULL
;
90 guint8 hs_cmd
, hs_ver
;
92 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "HyperSCSI");
93 col_clear(pinfo
->cinfo
, COL_INFO
);
96 ti
= proto_tree_add_item(tree
, proto_hyperscsi
, tvb
, offset
, -1, ENC_NA
);
97 hs_tree
= proto_item_add_subtree(ti
, ett_hyperscsi
);
100 hs_hdr1
= tvb_get_guint8(tvb
, offset
);
102 hs_hdr2
= tvb_get_guint8(tvb
, offset
);
104 hs_hdr3
= tvb_get_guint8(tvb
, offset
);
107 hs_res
= hs_hdr1
>> 4;
108 hs_tagno
= ((hs_hdr1
& 0x0F) << 5 ) | (hs_hdr2
>> 3);
109 hs_fragno
= ((hs_hdr2
&0X03) << 8 ) | hs_hdr3
;
112 * Add the header ... three bytes
116 ti
= proto_tree_add_text(hs_tree
, tvb
, 0, 3, "HyperSCSI Header");
117 hs_hdr_tree
= proto_item_add_subtree(ti
, ett_hs_hdr
);
120 * Now, add the header items
123 proto_tree_add_uint(hs_hdr_tree
, hf_hs_res
, tvb
, 0, 1, hs_res
);
124 proto_tree_add_uint(hs_hdr_tree
, hf_hs_tagno
, tvb
, 0, 2, hs_tagno
);
125 proto_tree_add_item(hs_hdr_tree
, hf_hs_lastfrag
, tvb
, 1, 1, ENC_BIG_ENDIAN
);
126 proto_tree_add_uint(hs_hdr_tree
, hf_hs_fragno
, tvb
, 1, 2, hs_fragno
);
134 hs_ver
= tvb_get_guint8(tvb
, offset
++);
136 hs_cmd
= tvb_get_guint8(tvb
, offset
);
138 hs_cmd
&= OPCODE_MASK
;
140 col_append_str(pinfo
->cinfo
, COL_INFO
,
141 val_to_str(hs_cmd
, hscsi_opcodes
, "Unknown HyperSCSI Request or Response (%u)"));
144 ti
= proto_tree_add_text(hs_tree
, tvb
, 3, -1, "HyperSCSI PDU");
145 hs_pdu_tree
= proto_item_add_subtree(ti
, ett_hs_pdu
);
147 proto_tree_add_uint(hs_pdu_tree
, hf_hs_ver
, tvb
, 3, 1, hs_ver
);
149 proto_tree_add_uint(hs_pdu_tree
, hf_hs_cmd
, tvb
, 4, 1, hs_cmd
);
155 proto_register_hyperscsi(void)
158 static hf_register_info hf
[] = {
160 { "Reserved", "hyperscsi.reserved", FT_UINT8
, BASE_DEC
, NULL
, 0x0,
164 { "Tag No", "hyperscsi.tagno", FT_UINT16
, BASE_DEC
, NULL
, 0x0,
168 { "Last Fragment", "hyperscsi.lastfrag", FT_BOOLEAN
, 8, TFS(&tfs_lastfrag
), 0x04, NULL
, HFILL
}},
171 { "Fragment No", "hyperscsi.fragno", FT_UINT16
, BASE_DEC
, NULL
, 0x0,
175 { "HyperSCSI Version", "hyperscsi.version", FT_UINT8
, BASE_DEC
, NULL
,
179 { "HyperSCSI Command", "hyperscsi.cmd", FT_UINT8
, BASE_DEC
, VALS(hscsi_opcodes
), 0x0,
183 static gint
*ett
[] = {
189 proto_hyperscsi
= proto_register_protocol("HyperSCSI", "HyperSCSI", "hyperscsi");
190 proto_register_field_array(proto_hyperscsi
, hf
, array_length(hf
));
191 proto_register_subtree_array(ett
, array_length(ett
));
193 register_dissector("hyperscsi", dissect_hyperscsi
, proto_hyperscsi
);
196 #define ETHERTYPE_HYPERSCSI 0x889A
199 proto_reg_handoff_hyperscsi(void)
201 dissector_handle_t hs_handle
;
203 hs_handle
= find_dissector("hyperscsi");
204 dissector_add_uint("ethertype", ETHERTYPE_HYPERSCSI
, hs_handle
);