1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
/* packet-hyperscsi.c
* Routines for dissassembly of the Hyper SCSI protocol.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
* Copyright 2002 Richard Sharpe <rsharpe@richardsharpe.com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
void proto_register_hyperscsi(void);
void proto_reg_handoff_hyperscsi(void);
static int proto_hyperscsi;
static int hf_hs_cmd = -1;
static int hf_hs_ver = -1;
static int hf_hs_res = -1;
static int hf_hs_tagno = -1;
static int hf_hs_lastfrag = -1;
static int hf_hs_fragno = -1;
static gint ett_hyperscsi = -1;
static gint ett_hs_hdr = -1;
static gint ett_hs_pdu = -1;
static dissector_handle_t hs_handle;
static const true_false_string tfs_lastfrag = {
"Last Fragment",
"Not Last Fragment"
};
#define HSCSI_OPCODE_REQUEST 0x00
#define HSCSI_OPCODE_REPLY 0x01
#define HSCSI_OPCODE_DEV_DISCOVERY 0x10
#define HSCSI_OPCODE_ADN_REQUEST 0x11
#define HSCSI_OPCODE_ADN_REPLY 0x12
#define HSCSI_OPCODE_DISCONNECT 0x13
#define HSCSI_OPCODE_ACK_SNR 0x20
#define HSCSI_OPCODE_ACK_REPLY 0x21
#define HSCSI_OPCODE_ADDR_REPORT 0x30
#define HSCSI_OPCODE_ADDR_REPLY 0x31
#define HSCSI_OPCODE_LOCAL_REQUEST 0x32
#define HSCSI_OPCODE_LOCAL_REPLY 0x33
#define HSCSI_OPCODE_REMOTE_REQUEST 0x34
#define HSCSI_OPCODE_REMOTE_REPLY 0x35
static const value_string hscsi_opcodes[] = {
{ HSCSI_OPCODE_REQUEST, "Command Block Encap Request"},
{ HSCSI_OPCODE_REPLY, "Command Block Encap Reply"},
{ HSCSI_OPCODE_DEV_DISCOVERY, "Device Discovery Reply"},
{ HSCSI_OPCODE_ADN_REQUEST, "Auth/Device Neg Request"},
{ HSCSI_OPCODE_ADN_REPLY, "Auth/Device Neg Reply"},
{ HSCSI_OPCODE_DISCONNECT, "Disconnect Request"},
{ HSCSI_OPCODE_ACK_SNR, "Flow Control Setup/Ack Request"},
{ HSCSI_OPCODE_ACK_REPLY, "Flow Control Ack Reply"},
{ 0, NULL}
};
#define OPCODE_MASK 0x7F
static int
dissect_hyperscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
guint hs_hdr1, hs_hdr2, hs_hdr3;
guint8 hs_res;
guint16 hs_tagno;
guint16 hs_fragno;
gint offset = 0;
proto_tree *hs_hdr_tree, *hs_pdu_tree;
proto_tree *hs_tree;
proto_item *ti;
guint8 hs_cmd, hs_ver;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "HyperSCSI");
col_clear(pinfo->cinfo, COL_INFO);
ti = proto_tree_add_item(tree, proto_hyperscsi, tvb, offset, -1, ENC_NA);
hs_tree = proto_item_add_subtree(ti, ett_hyperscsi);
hs_hdr1 = tvb_get_guint8(tvb, offset);
offset++;
hs_hdr2 = tvb_get_guint8(tvb, offset);
offset++;
hs_hdr3 = tvb_get_guint8(tvb, offset);
offset++;
hs_res = hs_hdr1 >> 4;
hs_tagno = ((hs_hdr1 & 0x0F) << 5 ) | (hs_hdr2 >> 3);
hs_fragno = ((hs_hdr2 &0X03) << 8 ) | hs_hdr3;
/*
* Add the header ... three bytes
*/
if (tree) {
hs_hdr_tree = proto_tree_add_subtree(hs_tree, tvb, 0, 3, ett_hs_hdr, NULL, "HyperSCSI Header");
/*
* Now, add the header items
*/
proto_tree_add_uint(hs_hdr_tree, hf_hs_res, tvb, 0, 1, hs_res);
proto_tree_add_uint(hs_hdr_tree, hf_hs_tagno, tvb, 0, 2, hs_tagno);
proto_tree_add_item(hs_hdr_tree, hf_hs_lastfrag, tvb, 1, 1, ENC_BIG_ENDIAN);
proto_tree_add_uint(hs_hdr_tree, hf_hs_fragno, tvb, 1, 2, hs_fragno);
}
/*
* Now, add the PDU
*/
hs_ver = tvb_get_guint8(tvb, offset++);
hs_cmd = tvb_get_guint8(tvb, offset);
hs_cmd &= OPCODE_MASK;
col_append_str(pinfo->cinfo, COL_INFO,
val_to_str(hs_cmd, hscsi_opcodes, "Unknown HyperSCSI Request or Response (%u)"));
if (tree) {
hs_pdu_tree = proto_tree_add_subtree(hs_tree, tvb, 3, -1, ett_hs_pdu, NULL, "HyperSCSI PDU");
proto_tree_add_uint(hs_pdu_tree, hf_hs_ver, tvb, 3, 1, hs_ver);
proto_tree_add_uint(hs_pdu_tree, hf_hs_cmd, tvb, 4, 1, hs_cmd);
}
return tvb_captured_length(tvb);
}
void
proto_register_hyperscsi(void)
{
static hf_register_info hf[] = {
{ &hf_hs_res,
{ "Reserved", "hyperscsi.reserved", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL}},
{ &hf_hs_tagno,
{ "Tag No", "hyperscsi.tagno", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_hs_lastfrag,
{ "Last Fragment", "hyperscsi.lastfrag", FT_BOOLEAN, 8, TFS(&tfs_lastfrag), 0x04, NULL, HFILL}},
{ &hf_hs_fragno,
{ "Fragment No", "hyperscsi.fragno", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL}},
{ &hf_hs_ver,
{ "HyperSCSI Version", "hyperscsi.version", FT_UINT8, BASE_DEC, NULL,
0x0, NULL, HFILL}},
{ &hf_hs_cmd,
{ "HyperSCSI Command", "hyperscsi.cmd", FT_UINT8, BASE_DEC, VALS(hscsi_opcodes), 0x0,
NULL, HFILL}},
};
static gint *ett[] = {
&ett_hyperscsi,
&ett_hs_hdr,
&ett_hs_pdu,
};
proto_hyperscsi = proto_register_protocol("HyperSCSI", "HyperSCSI", "hyperscsi");
proto_register_field_array(proto_hyperscsi, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
hs_handle = register_dissector("hyperscsi", dissect_hyperscsi, proto_hyperscsi);
}
/* XXX <epan/etypes.h> */
#define ETHERTYPE_HYPERSCSI 0x889A
void
proto_reg_handoff_hyperscsi(void)
{
dissector_add_uint("ethertype", ETHERTYPE_HYPERSCSI, hs_handle);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
|