2 * Routines for dissassembly of the Hyper SCSI protocol.
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
7 * Copyright 2002 Richard Sharpe <rsharpe@richardsharpe.com>
9 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include <epan/packet.h>
16 #include <wsutil/array.h>
18 void proto_register_hyperscsi(void);
19 void proto_reg_handoff_hyperscsi(void);
21 static int proto_hyperscsi
;
26 static int hf_hs_tagno
;
27 static int hf_hs_lastfrag
;
28 static int hf_hs_fragno
;
30 static int ett_hyperscsi
;
31 static int ett_hs_hdr
;
32 static int ett_hs_pdu
;
34 static dissector_handle_t hs_handle
;
36 static const true_false_string tfs_lastfrag
= {
41 #define HSCSI_OPCODE_REQUEST 0x00
42 #define HSCSI_OPCODE_REPLY 0x01
43 #define HSCSI_OPCODE_DEV_DISCOVERY 0x10
44 #define HSCSI_OPCODE_ADN_REQUEST 0x11
45 #define HSCSI_OPCODE_ADN_REPLY 0x12
46 #define HSCSI_OPCODE_DISCONNECT 0x13
47 #define HSCSI_OPCODE_ACK_SNR 0x20
48 #define HSCSI_OPCODE_ACK_REPLY 0x21
49 #define HSCSI_OPCODE_ADDR_REPORT 0x30
50 #define HSCSI_OPCODE_ADDR_REPLY 0x31
51 #define HSCSI_OPCODE_LOCAL_REQUEST 0x32
52 #define HSCSI_OPCODE_LOCAL_REPLY 0x33
53 #define HSCSI_OPCODE_REMOTE_REQUEST 0x34
54 #define HSCSI_OPCODE_REMOTE_REPLY 0x35
56 static const value_string hscsi_opcodes
[] = {
57 { HSCSI_OPCODE_REQUEST
, "Command Block Encap Request"},
58 { HSCSI_OPCODE_REPLY
, "Command Block Encap Reply"},
59 { HSCSI_OPCODE_DEV_DISCOVERY
, "Device Discovery Reply"},
60 { HSCSI_OPCODE_ADN_REQUEST
, "Auth/Device Neg Request"},
61 { HSCSI_OPCODE_ADN_REPLY
, "Auth/Device Neg Reply"},
62 { HSCSI_OPCODE_DISCONNECT
, "Disconnect Request"},
63 { HSCSI_OPCODE_ACK_SNR
, "Flow Control Setup/Ack Request"},
64 { HSCSI_OPCODE_ACK_REPLY
, "Flow Control Ack Reply"},
68 #define OPCODE_MASK 0x7F
71 dissect_hyperscsi(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
73 unsigned hs_hdr1
, hs_hdr2
, hs_hdr3
;
78 proto_tree
*hs_hdr_tree
, *hs_pdu_tree
;
81 uint8_t hs_cmd
, hs_ver
;
83 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "HyperSCSI");
84 col_clear(pinfo
->cinfo
, COL_INFO
);
86 ti
= proto_tree_add_item(tree
, proto_hyperscsi
, tvb
, offset
, -1, ENC_NA
);
87 hs_tree
= proto_item_add_subtree(ti
, ett_hyperscsi
);
89 hs_hdr1
= tvb_get_uint8(tvb
, offset
);
91 hs_hdr2
= tvb_get_uint8(tvb
, offset
);
93 hs_hdr3
= tvb_get_uint8(tvb
, offset
);
96 hs_res
= hs_hdr1
>> 4;
97 hs_tagno
= ((hs_hdr1
& 0x0F) << 5 ) | (hs_hdr2
>> 3);
98 hs_fragno
= ((hs_hdr2
&0X03) << 8 ) | hs_hdr3
;
101 * Add the header ... three bytes
105 hs_hdr_tree
= proto_tree_add_subtree(hs_tree
, tvb
, 0, 3, ett_hs_hdr
, NULL
, "HyperSCSI Header");
108 * Now, add the header items
111 proto_tree_add_uint(hs_hdr_tree
, hf_hs_res
, tvb
, 0, 1, hs_res
);
112 proto_tree_add_uint(hs_hdr_tree
, hf_hs_tagno
, tvb
, 0, 2, hs_tagno
);
113 proto_tree_add_item(hs_hdr_tree
, hf_hs_lastfrag
, tvb
, 1, 1, ENC_BIG_ENDIAN
);
114 proto_tree_add_uint(hs_hdr_tree
, hf_hs_fragno
, tvb
, 1, 2, hs_fragno
);
122 hs_ver
= tvb_get_uint8(tvb
, offset
++);
124 hs_cmd
= tvb_get_uint8(tvb
, offset
);
126 hs_cmd
&= OPCODE_MASK
;
128 col_append_str(pinfo
->cinfo
, COL_INFO
,
129 val_to_str(hs_cmd
, hscsi_opcodes
, "Unknown HyperSCSI Request or Response (%u)"));
132 hs_pdu_tree
= proto_tree_add_subtree(hs_tree
, tvb
, 3, -1, ett_hs_pdu
, NULL
, "HyperSCSI PDU");
134 proto_tree_add_uint(hs_pdu_tree
, hf_hs_ver
, tvb
, 3, 1, hs_ver
);
136 proto_tree_add_uint(hs_pdu_tree
, hf_hs_cmd
, tvb
, 4, 1, hs_cmd
);
139 return tvb_captured_length(tvb
);
143 proto_register_hyperscsi(void)
146 static hf_register_info hf
[] = {
148 { "Reserved", "hyperscsi.reserved", FT_UINT8
, BASE_DEC
, NULL
, 0x0,
152 { "Tag No", "hyperscsi.tagno", FT_UINT16
, BASE_DEC
, NULL
, 0x0,
156 { "Last Fragment", "hyperscsi.lastfrag", FT_BOOLEAN
, 8, TFS(&tfs_lastfrag
), 0x04, NULL
, HFILL
}},
159 { "Fragment No", "hyperscsi.fragno", FT_UINT16
, BASE_DEC
, NULL
, 0x0,
163 { "HyperSCSI Version", "hyperscsi.version", FT_UINT8
, BASE_DEC
, NULL
,
167 { "HyperSCSI Command", "hyperscsi.cmd", FT_UINT8
, BASE_DEC
, VALS(hscsi_opcodes
), 0x0,
171 static int *ett
[] = {
177 proto_hyperscsi
= proto_register_protocol("HyperSCSI", "HyperSCSI", "hyperscsi");
178 proto_register_field_array(proto_hyperscsi
, hf
, array_length(hf
));
179 proto_register_subtree_array(ett
, array_length(ett
));
181 hs_handle
= register_dissector("hyperscsi", dissect_hyperscsi
, proto_hyperscsi
);
184 /* XXX <epan/etypes.h> */
185 #define ETHERTYPE_HYPERSCSI 0x889A
188 proto_reg_handoff_hyperscsi(void)
190 dissector_add_uint("ethertype", ETHERTYPE_HYPERSCSI
, hs_handle
);
195 * Editor modelines - https://www.wireshark.org/tools/modelines.html
200 * indent-tabs-mode: nil
203 * ex: set shiftwidth=2 tabstop=8 expandtab:
204 * :indentSize=2:tabSize=8:noTabs=true: