2 * Routines for decoding SCSI CDBs and responses
3 * Author: Dinesh G Dutt (ddutt@cisco.com)
5 * $Id: packet-scsi.c,v 1.32 2003/07/09 03:42:55 guy Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 2002 Gerald Combs
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 * Some Notes on using the SCSI Decoder:
29 * The SCSI decoder has been built right now that it is invoked directly by the
30 * SCSI transport layers as compared to the standard mechanism of being invoked
31 * via a dissector chain. There are multiple reasons for this:
32 * - The SCSI CDB is typically embedded inside the transport along with other
33 * header fields that have nothing to do with SCSI. So, it is required to be
34 * invoked on a embedded subset of the packet.
35 * - Originally, Ethereal couldn't do filtering on protocol trees that were not
38 * There are four main routines that are provided:
39 * o dissect_scsi_cdb - invoked on receiving a SCSI Command
40 * void dissect_scsi_cdb (tvbuff_t *, packet_info *, proto_tree *, guint,
42 * o dissect_scsi_payload - invoked to decode SCSI responses
43 * void dissect_scsi_payload (tvbuff_t *, packet_info *, proto_tree *, guint,
45 * The final parameter is the length of the response field that is negotiated
46 * as part of the SCSI transport layer. If this is not tracked by the
47 * transport, it can be set to 0.
48 * o dissect_scsi_rsp - invoked to destroy the data structures associated with a
50 * void dissect_scsi_rsp (tvbuff_t *, packet_info *, proto_tree *);
51 * o dissect_scsi_snsinfo - invoked to decode the sense data provided in case of
53 * void dissect_scsi_snsinfo (tvbuff_t *, packet_info *, proto_tree *, guint,
56 * In addition to this, the other requirement made from the transport is to
57 * provide a unique way to determine a SCSI task. In Fibre Channel networks,
58 * this is the exchange ID pair alongwith the source/destination addresses; in
59 * iSCSI it is the initiator task tag along with the src/dst address and port
60 * numbers. This is to be provided to the SCSI decoder via the private_data
61 * field in the packet_info data structure. The private_data field is treated
62 * as a pointer to a "scsi_task_id_t" structure, containing a conversation
63 * ID (a number uniquely identifying a conversation between a particular
64 * initiator and target, e.g. between two Fibre Channel addresses or between
65 * two TCP address/port pairs for iSCSI or NDMP) and a task ID (a number
66 * uniquely identifying a task within that conversation).
68 * This decoder attempts to track the type of SCSI device based on the response
69 * to the Inquiry command. If the trace does not contain an Inquiry command,
70 * the decoding of the commands is done as per a user preference. Currently,
71 * only SBC (disks) and SSC (tapes) are the alternatives offered. The basic
72 * SCSI command set (SPC-2/3) is decoded for all SCSI devices. If there is a
73 * mixture of devices in the trace, some with Inquiry response and some
74 * without, the user preference is used only for those devices whose type the
75 * decoder has not been able to determine.
84 #include <epan/strutil.h>
85 #include <epan/conversation.h>
86 #include <epan/int-64bit.h>
88 #include "packet-scsi.h"
90 static int proto_scsi = -1;
91 static int hf_scsi_spcopcode = -1;
92 static int hf_scsi_sbcopcode = -1;
93 static int hf_scsi_sscopcode = -1;
94 static int hf_scsi_smcopcode = -1;
95 static int hf_scsi_control = -1;
96 static int hf_scsi_inquiry_flags = -1;
97 static int hf_scsi_inquiry_evpd_page = -1;
98 static int hf_scsi_inquiry_cmdt_page = -1;
99 static int hf_scsi_alloclen = -1;
100 static int hf_scsi_logsel_flags = -1;
101 static int hf_scsi_logsel_pc = -1;
102 static int hf_scsi_paramlen = -1;
103 static int hf_scsi_logsns_flags = -1;
104 static int hf_scsi_logsns_pc = -1;
105 static int hf_scsi_logsns_pagecode = -1;
106 static int hf_scsi_paramlen16 = -1;
107 static int hf_scsi_modesel_flags = -1;
108 static int hf_scsi_alloclen16 = -1;
109 static int hf_scsi_modesns_pc = -1;
110 static int hf_scsi_spcpagecode = -1;
111 static int hf_scsi_sbcpagecode = -1;
112 static int hf_scsi_sscpagecode = -1;
113 static int hf_scsi_smcpagecode = -1;
114 static int hf_scsi_modesns_flags = -1;
115 static int hf_scsi_persresvin_svcaction = -1;
116 static int hf_scsi_persresvout_svcaction = -1;
117 static int hf_scsi_persresv_scope = -1;
118 static int hf_scsi_persresv_type = -1;
119 static int hf_scsi_release_flags = -1;
120 static int hf_scsi_release_thirdpartyid = -1;
121 static int hf_scsi_alloclen32 = -1;
122 static int hf_scsi_formatunit_flags = -1;
123 static int hf_scsi_formatunit_interleave = -1;
124 static int hf_scsi_formatunit_vendor = -1;
125 static int hf_scsi_rdwr6_lba = -1;
126 static int hf_scsi_rdwr6_xferlen = -1;
127 static int hf_scsi_rdwr10_lba = -1;
128 static int hf_scsi_read_flags = -1;
129 static int hf_scsi_rdwr12_xferlen = -1;
130 static int hf_scsi_rdwr16_lba = -1;
131 static int hf_scsi_readcapacity_flags = -1;
132 static int hf_scsi_readcapacity_lba = -1;
133 static int hf_scsi_readcapacity_pmi = -1;
134 static int hf_scsi_rdwr10_xferlen = -1;
135 static int hf_scsi_readdefdata_flags = -1;
136 static int hf_scsi_cdb_defectfmt = -1;
137 static int hf_scsi_reassignblks_flags = -1;
138 static int hf_scsi_inq_qualifier = -1;
139 static int hf_scsi_inq_devtype = -1;
140 static int hf_scsi_inq_version = -1;
141 static int hf_scsi_rluns_lun = -1;
142 static int hf_scsi_rluns_multilun = -1;
143 static int hf_scsi_modesns_errrep = -1;
144 static int hf_scsi_modesns_tst = -1;
145 static int hf_scsi_modesns_qmod = -1;
146 static int hf_scsi_modesns_qerr = -1;
147 static int hf_scsi_modesns_rac = -1;
148 static int hf_scsi_modesns_tas = -1;
149 static int hf_scsi_protocol = -1;
150 static int hf_scsi_sns_errtype = -1;
151 static int hf_scsi_snskey = -1;
152 static int hf_scsi_snsinfo = -1;
153 static int hf_scsi_addlsnslen = -1;
154 static int hf_scsi_asc = -1;
155 static int hf_scsi_ascascq = -1;
156 static int hf_scsi_ascq = -1;
157 static int hf_scsi_fru = -1;
158 static int hf_scsi_sksv = -1;
159 static int hf_scsi_inq_normaca = -1;
160 static int hf_scsi_persresv_key = -1;
161 static int hf_scsi_persresv_scopeaddr = -1;
162 static int hf_scsi_add_cdblen = -1;
163 static int hf_scsi_svcaction = -1;
166 static gint ett_scsi = -1;
167 static gint ett_scsi_page = -1;
169 typedef guint32 scsi_cmnd_type;
170 typedef guint32 scsi_device_type;
172 /* Valid SCSI Command Types */
173 #define SCSI_CMND_SPC2 1
174 #define SCSI_CMND_SBC2 2
175 #define SCSI_CMND_SSC2 3
176 #define SCSI_CMND_SMC2 4
178 /* SPC and SPC-2 Commands */
180 #define SCSI_SPC_CHANGE_DEFINITION 0x40
181 #define SCSI_SPC_COMPARE 0x39
182 #define SCSI_SPC_COPY 0x18
183 #define SCSI_SPC_COPY_AND_VERIFY 0x3A
184 #define SCSI_SPC2_INQUIRY 0x12
185 #define SCSI_SPC2_EXTCOPY 0x83
186 #define SCSI_SPC2_LOGSELECT 0x4C
187 #define SCSI_SPC2_LOGSENSE 0x4D
188 #define SCSI_SPC2_MODESELECT6 0x15
189 #define SCSI_SPC2_MODESELECT10 0x55
190 #define SCSI_SPC2_MODESENSE6 0x1A
191 #define SCSI_SPC2_MODESENSE10 0x5A
192 #define SCSI_SPC2_PERSRESVIN 0x5E
193 #define SCSI_SPC2_PERSRESVOUT 0x5F
194 #define SCSI_SPC2_PREVMEDREMOVAL 0x1E
195 #define SCSI_SPC2_READBUFFER 0x3C
196 #define SCSI_SPC2_RCVCOPYRESULTS 0x84
197 #define SCSI_SPC2_RCVDIAGRESULTS 0x1C
198 #define SCSI_SPC2_RELEASE6 0x17
199 #define SCSI_SPC2_RELEASE10 0x57
200 #define SCSI_SPC2_REPORTDEVICEID 0xA3
201 #define SCSI_SPC2_REPORTLUNS 0xA0
202 #define SCSI_SPC2_REQSENSE 0x03
203 #define SCSI_SPC2_RESERVE6 0x16
204 #define SCSI_SPC2_RESERVE10 0x56
205 #define SCSI_SPC2_SENDDIAG 0x1D
206 #define SCSI_SPC2_SETDEVICEID 0xA4
207 #define SCSI_SPC2_TESTUNITRDY 0x00
208 #define SCSI_SPC2_WRITEBUFFER 0x3B
209 #define SCSI_SPC2_VARLENCDB 0x7F
211 static const value_string scsi_spc2_val[] = {
212 {SCSI_SPC_CHANGE_DEFINITION , "Change Definition"},
213 {SCSI_SPC_COMPARE , "Compare"},
214 {SCSI_SPC_COPY , "Copy"},
215 {SCSI_SPC_COPY_AND_VERIFY , "Copy And Verify"},
216 {SCSI_SPC2_EXTCOPY , "Extended Copy"},
217 {SCSI_SPC2_INQUIRY , "Inquiry"},
218 {SCSI_SPC2_LOGSELECT , "Log Select"},
219 {SCSI_SPC2_LOGSENSE , "Log Sense"},
220 {SCSI_SPC2_MODESELECT6 , "Mode Select(6)"},
221 {SCSI_SPC2_MODESELECT10 , "Mode Select(10)"},
222 {SCSI_SPC2_MODESENSE6 , "Mode Sense(6)"},
223 {SCSI_SPC2_MODESENSE10 , "Mode Sense(10)"},
224 {SCSI_SPC2_PERSRESVIN , "Persistent Reserve In"},
225 {SCSI_SPC2_PERSRESVOUT , "Persistent Reserve Out"},
226 {SCSI_SPC2_PREVMEDREMOVAL , "Prevent/Allow Medium Removal"},
227 {SCSI_SPC2_RCVCOPYRESULTS , "Receive Copy Results"},
228 {SCSI_SPC2_RCVDIAGRESULTS , "Receive Diagnostics Results"},
229 {SCSI_SPC2_READBUFFER , "Read Buffer"},
230 {SCSI_SPC2_RELEASE6 , "Release(6)"},
231 {SCSI_SPC2_RELEASE10 , "Release(10)"},
232 {SCSI_SPC2_REPORTDEVICEID , "Report Device ID"},
233 {SCSI_SPC2_REPORTLUNS , "Report LUNs"},
234 {SCSI_SPC2_REQSENSE , "Request Sense"},
235 {SCSI_SPC2_RESERVE6 , "Reserve(6)"},
236 {SCSI_SPC2_RESERVE10 , "Reserve(10)"},
237 {SCSI_SPC2_SENDDIAG , "Send Diagnostic"},
238 {SCSI_SPC2_TESTUNITRDY , "Test Unit Ready"},
239 {SCSI_SPC2_WRITEBUFFER , "Write Buffer"},
240 {SCSI_SPC2_VARLENCDB , "Variable Length CDB"},
245 #define SCSI_SBC2_FORMATUNIT 0x04
246 #define SCSI_SBC2_LOCKUNLKCACHE10 0x36
247 #define SCSI_SBC2_LOCKUNLKCACHE16 0x92
248 #define SCSI_SBC2_PREFETCH10 0x34
249 #define SCSI_SBC2_PREFETCH16 0x90
250 #define SCSI_SBC2_READ6 0x08
251 #define SCSI_SBC2_READ10 0x28
252 #define SCSI_SBC2_READ12 0xA8
253 #define SCSI_SBC2_READ16 0x88
254 #define SCSI_SBC2_READCAPACITY 0x25
255 #define SCSI_SBC2_READDEFDATA10 0x37
256 #define SCSI_SBC2_READDEFDATA12 0xB7
257 #define SCSI_SBC2_READLONG 0x3E
258 #define SCSI_SBC2_REASSIGNBLKS 0x07
259 #define SCSI_SBC2_REBUILD16 0x81
260 #define SCSI_SBC2_REBUILD32 0x7F
261 #define SCSI_SBC2_REGENERATE16 0x82
262 #define SCSI_SBC2_REGENERATE32 0x7F
263 #define SCSI_SBC2_SEEK10 0x2B
264 #define SCSI_SBC2_SETLIMITS10 0x33
265 #define SCSI_SBC2_SETLIMITS12 0xB3
266 #define SCSI_SBC2_STARTSTOPUNIT 0x1B
267 #define SCSI_SBC2_SYNCCACHE10 0x35
268 #define SCSI_SBC2_SYNCCACHE16 0x91
269 #define SCSI_SBC2_VERIFY10 0x2F
270 #define SCSI_SBC2_VERIFY12 0xAF
271 #define SCSI_SBC2_VERIFY16 0x8F
272 #define SCSI_SBC2_WRITE6 0x0A
273 #define SCSI_SBC2_WRITE10 0x2A
274 #define SCSI_SBC2_WRITE12 0xAA
275 #define SCSI_SBC2_WRITE16 0x8A
276 #define SCSI_SBC2_WRITENVERIFY10 0x2E
277 #define SCSI_SBC2_WRITENVERIFY12 0xAE
278 #define SCSI_SBC2_WRITENVERIFY16 0x8E
279 #define SCSI_SBC2_WRITELONG 0x3F
280 #define SCSI_SBC2_WRITESAME10 0x41
281 #define SCSI_SBC2_WRITESAME16 0x93
282 #define SCSI_SBC2_XDREAD10 0x52
283 #define SCSI_SBC2_XDREAD32 0x7F
284 #define SCSI_SBC2_XDWRITE10 0x50
285 #define SCSI_SBC2_XDWRITE32 0x7F
286 #define SCSI_SBC2_XDWRITEREAD10 0x53
287 #define SCSI_SBC2_XDWRITEREAD32 0x7F
288 #define SCSI_SBC2_XDWRITEEXTD16 0x80
289 #define SCSI_SBC2_XDWRITEEXTD32 0x7F
290 #define SCSI_SBC2_XPWRITE10 0x51
291 #define SCSI_SBC2_XPWRITE32 0x7F
294 static const value_string scsi_sbc2_val[] = {
295 {SCSI_SBC2_FORMATUNIT , "Format Unit"},
296 {SCSI_SBC2_LOCKUNLKCACHE10, "Lock Unlock Cache(10)"},
297 {SCSI_SBC2_LOCKUNLKCACHE16, "Lock Unlock Cache(16)"},
298 {SCSI_SBC2_PREFETCH10, "Pre-Fetch(10)"},
299 {SCSI_SBC2_PREFETCH16, "Pre-Fetch(16)"},
300 {SCSI_SBC2_READ6 , "Read(6)"},
301 {SCSI_SBC2_READ10 , "Read(10)"},
302 {SCSI_SBC2_READ12 , "Read(12)"},
303 {SCSI_SBC2_READ16 , "Read(16)"},
304 {SCSI_SBC2_READCAPACITY , "Read Capacity"},
305 {SCSI_SBC2_READDEFDATA10 , "Read Defect Data(10)"},
306 {SCSI_SBC2_READDEFDATA12 , "Read Defect Data(12)"},
307 {SCSI_SBC2_READLONG, "Read Long"},
308 {SCSI_SBC2_REASSIGNBLKS , "Reassign Blocks"},
309 {SCSI_SBC2_REBUILD16, "Rebuild(16)"},
310 {SCSI_SBC2_REBUILD32, "Rebuild(32)"},
311 {SCSI_SBC2_REGENERATE16, "Regenerate(16)"},
312 {SCSI_SBC2_REGENERATE32, "Regenerate(32)"},
313 {SCSI_SBC2_SEEK10, "Seek(10)"},
314 {SCSI_SBC2_SETLIMITS10, "Set Limits(10)"},
315 {SCSI_SBC2_SETLIMITS12, "Set Limits(12)"},
316 {SCSI_SBC2_STARTSTOPUNIT, "Start Stop Unit"},
317 {SCSI_SBC2_SYNCCACHE10, "Synchronize Cache(10)"},
318 {SCSI_SBC2_SYNCCACHE16, "Synchronize Cache(16)"},
319 {SCSI_SBC2_VERIFY10, "Verify(10)"},
320 {SCSI_SBC2_VERIFY12, "Verify(12)"},
321 {SCSI_SBC2_VERIFY16, "Verify(16)"},
322 {SCSI_SBC2_WRITE6 , "Write(6)"},
323 {SCSI_SBC2_WRITE10 , "Write(10)"},
324 {SCSI_SBC2_WRITE12 , "Write(12)"},
325 {SCSI_SBC2_WRITE16 , "Write(16)"},
326 {SCSI_SBC2_WRITENVERIFY10, "Write & Verify(10)"},
327 {SCSI_SBC2_WRITENVERIFY12, "Write & Verify(12)"},
328 {SCSI_SBC2_WRITENVERIFY16, "Write & Verify(16)"},
329 {SCSI_SBC2_WRITELONG, "Write Long"},
330 {SCSI_SBC2_WRITESAME10, "Write Same(10)"},
331 {SCSI_SBC2_WRITESAME16, "Write Same(16)"},
332 {SCSI_SBC2_XDREAD10, "XdRead(10)"},
333 {SCSI_SBC2_XDREAD32, "XdRead(32)"},
334 {SCSI_SBC2_XDWRITE10, "XdWrite(10)"},
335 {SCSI_SBC2_XDWRITE32, "XdWrite(32)"},
336 {SCSI_SBC2_XDWRITEREAD10, "XdWriteRead(10)"},
337 {SCSI_SBC2_XDWRITEREAD32, "XdWriteRead(32)"},
338 {SCSI_SBC2_XDWRITEEXTD16, "XdWrite Extended(16)"},
339 {SCSI_SBC2_XDWRITEEXTD32, "XdWrite Extended(32)"},
340 {SCSI_SBC2_XPWRITE10, "XpWrite(10)"},
341 {SCSI_SBC2_XPWRITE32, "XpWrite(32)"},
346 #define SCSI_SSC2_ERASE_16 0x93
347 #define SCSI_SSC2_FORMAT_MEDIUM 0x04
348 #define SCSI_SSC2_LOAD_UNLOAD 0x1B
349 #define SCSI_SSC2_LOCATE_16 0x92
350 #define SCSI_SSC2_READ_16 0x88
351 #define SCSI_SSC2_READ_BLOCK_LIMITS 0x05
352 #define SCSI_SSC2_READ_POSITION 0x34
353 #define SCSI_SSC2_READ_REVERSE_16 0x81
354 #define SCSI_SSC2_RECOVER_BUFFERED_DATA 0x14
355 #define SCSI_SSC2_REPORT_DENSITY_SUPPORT 0x44
356 #define SCSI_SSC2_REWIND 0x01
357 #define SCSI_SSC2_SET_CAPACITY 0x0B
358 #define SCSI_SSC2_SPACE_16 0x91
359 #define SCSI_SSC2_VERIFY_16 0x8F
360 #define SCSI_SSC2_WRITE_16 0x8A
361 #define SCSI_SSC2_WRITE_FILEMARKS_16 0x80
362 #define SCSI_SSC2_ERASE_6 0x19
363 #define SCSI_SSC2_LOCATE_10 0x2B
364 #define SCSI_SSC2_LOCATE_16 0x92
365 #define SCSI_SSC2_READ6 0x08
366 #define SCSI_SSC2_READ_REVERSE_6 0x0F
367 #define SCSI_SSC2_SPACE_6 0x11
368 #define SCSI_SSC2_VERIFY_6 0x13
369 #define SCSI_SSC2_WRITE6 0x0A
370 #define SCSI_SSC2_WRITE_FILEMARKS_6 0x10
372 static const value_string scsi_ssc2_val[] = {
373 {SCSI_SSC2_ERASE_16 , "Erase(16)"},
374 {SCSI_SSC2_FORMAT_MEDIUM , "Format Medium"},
375 {SCSI_SSC2_LOAD_UNLOAD , "Load Unload"},
376 {SCSI_SSC2_LOCATE_16 , "Locate(16)"},
377 {SCSI_SSC2_READ_16 , "Read(16)"},
378 {SCSI_SSC2_READ_BLOCK_LIMITS , "Read Block Limits"},
379 {SCSI_SSC2_READ_POSITION , "Read Position"},
380 {SCSI_SSC2_READ_REVERSE_16 , "Read Reverse(16)"},
381 {SCSI_SSC2_RECOVER_BUFFERED_DATA , "Recover Buffered Data"},
382 {SCSI_SSC2_REPORT_DENSITY_SUPPORT , "Report Density Support"},
383 {SCSI_SSC2_REWIND , "Rewind"},
384 {SCSI_SSC2_SET_CAPACITY , "Set Capacity"},
385 {SCSI_SSC2_SPACE_16 , "Space(16)"},
386 {SCSI_SSC2_VERIFY_16 , "Verify(16)"},
387 {SCSI_SSC2_WRITE_16 , "Write(16)"},
388 {SCSI_SSC2_WRITE_FILEMARKS_16 , "Write Filemarks(16)"},
389 {SCSI_SSC2_ERASE_6 , "Erase(6)"},
390 {SCSI_SSC2_LOCATE_10 , "Locate(10)"},
391 {SCSI_SSC2_LOCATE_16 , "Locate(16)"},
392 {SCSI_SSC2_READ6 , "Read(6)"},
393 {SCSI_SSC2_READ_REVERSE_6 , "Read Reverse(6)"},
394 {SCSI_SSC2_SPACE_6 , "Space(6)"},
395 {SCSI_SSC2_VERIFY_6 , "Verify(6)"},
396 {SCSI_SSC2_WRITE6 , "Write(6)"},
397 {SCSI_SSC2_WRITE_FILEMARKS_6 , "Write Filemarks(6)"},
402 #define SCSI_SMC2_EXCHANGE_MEDIUM 0x40
403 #define SCSI_SMC2_INITIALIZE_ELEMENT_STATUS 0x07
404 #define SCSI_SMC2_INITIALIZE_ELEMENT_STATUS_RANGE 0x37
405 #define SCSI_SMC2_MOVE_MEDIUM 0xA5
406 #define SCSI_SMC2_MOVE_MEDIUM_ATTACHED 0xA7
407 #define SCSI_SMC2_POSITION_TO_ELEMENT 0x2B
408 #define SCSI_SMC2_READ_ATTRIBUTE 0x8C
409 #define SCSI_SMC2_READ_ELEMENT_STATUS 0xB8
410 #define SCSI_SMC2_READ_ELEMENT_STATUS_ATTACHED 0xB4
411 #define SCSI_SMC2_REQUEST_VOLUME_ELEMENT_ADDRESS 0xB5
412 #define SCSI_SMC2_SEND_VOLUME_TAG 0xB6
413 #define SCSI_SMC2_WRITE_ATTRIBUTE 0x8D
415 static const value_string scsi_smc2_val[] = {
416 {SCSI_SMC2_EXCHANGE_MEDIUM , "Exchange Medium"},
417 {SCSI_SMC2_INITIALIZE_ELEMENT_STATUS , "Initialize Element Status"},
418 {SCSI_SMC2_INITIALIZE_ELEMENT_STATUS_RANGE, "Initialize Element Status With Range"},
419 {SCSI_SMC2_MOVE_MEDIUM , "Move Medium"},
420 {SCSI_SMC2_MOVE_MEDIUM_ATTACHED , "Move Medium Attached"},
421 {SCSI_SMC2_POSITION_TO_ELEMENT , "Position To Element"},
422 {SCSI_SMC2_READ_ATTRIBUTE , "Read Attribute"},
423 {SCSI_SMC2_READ_ELEMENT_STATUS , "Read Element Status"},
424 {SCSI_SMC2_READ_ELEMENT_STATUS_ATTACHED , "Read Element Status Attached"},
425 {SCSI_SMC2_REQUEST_VOLUME_ELEMENT_ADDRESS , "Request Volume Element Address"},
426 {SCSI_SMC2_SEND_VOLUME_TAG , "Send Volume Tag"},
427 {SCSI_SMC2_WRITE_ATTRIBUTE , "Write Attribute"},
431 #define SCSI_EVPD_SUPPPG 0x00
432 #define SCSI_EVPD_DEVSERNUM 0x80
433 #define SCSI_EVPD_OPER 0x81
434 #define SCSI_EVPD_ASCIIOPER 0x82
435 #define SCSI_EVPD_DEVID 0x83
437 static const value_string scsi_evpd_pagecode_val[] = {
438 {SCSI_EVPD_SUPPPG, "Supported Vital Product Data Pages"},
439 {0x01, "ASCII Information Page"},
440 {0x02, "ASCII Information Page"},
441 {0x03, "ASCII Information Page"},
442 {0x04, "ASCII Information Page"},
443 {0x05, "ASCII Information Page"},
444 {0x06, "ASCII Information Page"},
445 {0x07, "ASCII Information Page"},
446 /* XXX - 0x01 through 0x7F are all ASCII information pages */
447 {SCSI_EVPD_DEVSERNUM, "Unit Serial Number Page"},
448 {SCSI_EVPD_OPER, "Implemented Operating Definition Page"},
449 {SCSI_EVPD_ASCIIOPER, "ASCII Implemented Operating Definition Page"},
450 {SCSI_EVPD_DEVID, "Device Identification Page"},
454 static const value_string scsi_logsel_pc_val[] = {
455 {0, "Current Threshold Values"},
456 {1, "Current Cumulative Values"},
457 {2, "Default Threshold Values"},
458 {3, "Default Cumulative Values"},
462 static const value_string scsi_logsns_pc_val[] = {
463 {0, "Threshold Values"},
464 {1, "Cumulative Values"},
465 {2, "Default Threshold Values"},
466 {3, "Default Cumulative Values"},
470 static const value_string scsi_logsns_page_val[] = {
471 {0xF, "Application Client Page"},
472 {0x1, "Buffer Overrun/Underrun Page"},
473 {0x3, "Error Counter (read) Page"},
474 {0x4, "Error Counter (read reverse) Page"},
475 {0x5, "Error Counter (verify) Page"},
476 {0x1, "Error Counter (write) Page"},
477 {0xB, "Last n Deferred Errors or Async Events Page"},
478 {0x7, "Last n Error Events Page"},
479 {0x6, "Non-medium Error Page"},
480 {0x10, "Self-test Results Page"},
481 {0xE, "Start-Stop Cycle Counter Page"},
482 {0x0, "Supported Log Pages"},
483 {0xD, "Temperature Page"},
487 static const value_string scsi_modesns_pc_val[] = {
488 {0, "Current Values"},
489 {1, "Changeable Values"},
490 {2, "Default Values"},
495 #define SCSI_SPC2_MODEPAGE_CTL 0x0A
496 #define SCSI_SPC2_MODEPAGE_DISCON 0x02
497 #define SCSI_SCSI2_MODEPAGE_PERDEV 0x09 /* Obsolete in SPC-2; generic in SCSI-2 */
498 #define SCSI_SPC2_MODEPAGE_INFOEXCP 0x1C
499 #define SCSI_SPC2_MODEPAGE_PWR 0x1A
500 #define SCSI_SPC2_MODEPAGE_LUN 0x18
501 #define SCSI_SPC2_MODEPAGE_PORT 0x19
502 #define SCSI_SPC2_MODEPAGE_VEND 0x00
504 static const value_string scsi_spc2_modepage_val[] = {
505 {SCSI_SPC2_MODEPAGE_CTL, "Control"},
506 {SCSI_SPC2_MODEPAGE_DISCON, "Disconnect-Reconnect"},
507 {SCSI_SCSI2_MODEPAGE_PERDEV, "Peripheral Device"},
508 {SCSI_SPC2_MODEPAGE_INFOEXCP, "Informational Exceptions Control"},
509 {SCSI_SPC2_MODEPAGE_PWR, "Power Condition"},
510 {SCSI_SPC2_MODEPAGE_LUN, "Protocol Specific LUN"},
511 {SCSI_SPC2_MODEPAGE_PORT, "Protocol-Specific Port"},
512 {SCSI_SPC2_MODEPAGE_VEND, "Vendor Specific Page"},
513 {0x3F, "Return All Mode Pages"},
517 #define SCSI_SBC2_MODEPAGE_RDWRERR 0x01
518 #define SCSI_SBC2_MODEPAGE_FMTDEV 0x03
519 #define SCSI_SBC2_MODEPAGE_DISKGEOM 0x04
520 #define SCSI_SBC2_MODEPAGE_FLEXDISK 0x05
521 #define SCSI_SBC2_MODEPAGE_VERERR 0x07
522 #define SCSI_SBC2_MODEPAGE_CACHE 0x08
523 #define SCSI_SBC2_MODEPAGE_MEDTYPE 0x0B
524 #define SCSI_SBC2_MODEPAGE_NOTPART 0x0C
525 #define SCSI_SBC2_MODEPAGE_XORCTL 0x10
527 static const value_string scsi_sbc2_modepage_val[] = {
528 {SCSI_SBC2_MODEPAGE_RDWRERR, "Read/Write Error Recovery"},
529 {SCSI_SBC2_MODEPAGE_FMTDEV, "Format Device"},
530 {SCSI_SBC2_MODEPAGE_DISKGEOM, "Rigid Disk Geometry"},
531 {SCSI_SBC2_MODEPAGE_FLEXDISK, "Flexible Disk"},
532 {SCSI_SBC2_MODEPAGE_VERERR, "Verify Error Recovery"},
533 {SCSI_SBC2_MODEPAGE_CACHE, "Caching"},
534 {SCSI_SBC2_MODEPAGE_MEDTYPE, "Medium Types Supported"},
535 {SCSI_SBC2_MODEPAGE_NOTPART, "Notch & Partition"},
536 {SCSI_SBC2_MODEPAGE_XORCTL, "XOR Control"},
537 {0x3F, "Return All Mode Pages"},
541 #define SCSI_SSC2_MODEPAGE_DATACOMP 0x0F /* data compression */
542 #define SCSI_SSC2_MODEPAGE_DEVCONF 0x10 /* device configuration */
543 #define SCSI_SSC2_MODEPAGE_MEDPAR1 0x11 /* medium partition (1) */
544 #define SCSI_SSC2_MODEPAGE_MEDPAR2 0x12 /* medium partition (2) */
545 #define SCSI_SSC2_MODEPAGE_MEDPAR3 0x13 /* medium partition (3) */
546 #define SCSI_SSC2_MODEPAGE_MEDPAR4 0x14 /* medium partition (4) */
548 static const value_string scsi_ssc2_modepage_val[] = {
549 {SCSI_SSC2_MODEPAGE_DATACOMP, "Data Compression"},
550 {SCSI_SSC2_MODEPAGE_DEVCONF, "Device Configuration"},
551 {SCSI_SSC2_MODEPAGE_MEDPAR1, "Medium Partition (1)"},
552 {SCSI_SSC2_MODEPAGE_MEDPAR2, "Medium Partition (2)"},
553 {SCSI_SSC2_MODEPAGE_MEDPAR3, "Medium Partition (3)"},
554 {SCSI_SSC2_MODEPAGE_MEDPAR4, "Medium Partition (4)"},
555 {0x3F, "Return All Mode Pages"},
559 #define SCSI_SMC2_MODEPAGE_EAA 0x1D /* element address assignment */
560 #define SCSI_SMC2_MODEPAGE_TRANGEOM 0x1E /* transport geometry parameters */
561 #define SCSI_SMC2_MODEPAGE_DEVCAP 0x1F /* device capabilities */
563 static const value_string scsi_smc2_modepage_val[] = {
564 {SCSI_SMC2_MODEPAGE_EAA, "Element Address Assignment"},
565 {SCSI_SMC2_MODEPAGE_TRANGEOM, "Transport Geometry Parameters"},
566 {SCSI_SMC2_MODEPAGE_DEVCAP, "Device Capabilities"},
567 {0x3F, "Return All Mode Pages"},
571 #define SCSI_SPC2_RESVIN_SVCA_RDKEYS 0
572 #define SCSI_SPC2_RESVIN_SVCA_RDRESV 1
574 static const value_string scsi_persresvin_svcaction_val[] = {
575 {SCSI_SPC2_RESVIN_SVCA_RDKEYS, "Read Keys"},
576 {SCSI_SPC2_RESVIN_SVCA_RDRESV, "Read Reservation"},
580 static const value_string scsi_persresvout_svcaction_val[] = {
586 {5, "Preempt & Abort"},
587 {6, "Register & Ignore Existing Key"},
591 static const value_string scsi_persresv_scope_val[] = {
594 {2, "Element Scope"},
598 static const value_string scsi_persresv_type_val[] = {
601 {5, "Write Excl, Registrants Only"},
602 {7, "Excl Access, Registrants Only"},
606 static const value_string scsi_qualifier_val[] = {
607 {0x0, "Device type is connected to logical unit"},
608 {0x1, "Device type is supported by server but is not connected to logical unit"},
609 {0x3, "Device type is not supported by server"},
612 static const value_string scsi_devtype_val[] = {
613 {SCSI_DEV_SBC , "Direct Access Device"},
614 {SCSI_DEV_SSC , "Sequential Access Device"},
615 {SCSI_DEV_PRNT , "Printer"},
616 {SCSI_DEV_PROC , "Processor"},
617 {SCSI_DEV_WORM , "WORM"},
618 {SCSI_DEV_CDROM , "CD-ROM"},
619 {SCSI_DEV_SCAN , "Scanner"},
620 {SCSI_DEV_OPTMEM, "Optical Memory"},
621 {SCSI_DEV_SMC , "Medium Changer"},
622 {SCSI_DEV_COMM , "Communication"},
623 {SCSI_DEV_RAID , "Storage Array"},
624 {SCSI_DEV_SES , "Enclosure Services"},
625 {SCSI_DEV_RBC , "Simplified Block Device"},
626 {SCSI_DEV_OCRW , "Optical Card Reader/Writer"},
627 {SCSI_DEV_OSD , "Object-based Storage Device"},
628 {SCSI_DEV_ADC , "Automation/Drive Interface"},
629 {0x1E , "Well known logical unit"},
630 {SCSI_DEV_NOLUN , "Unknown or no device type"},
634 static const enum_val_t scsi_devtype_options[] = {
635 {"Block Device", SCSI_DEV_SBC},
636 {"Sequential Device", SCSI_DEV_SSC},
640 static const value_string scsi_inquiry_vers_val[] = {
641 {0, "No Compliance to any Standard"},
642 {2, "Compliance to ANSI X3.131:1994"},
643 {3, "Compliance to ANSI X3.301:1997"},
644 {4, "Compliance to SPC-2"},
645 {0x80, "Compliance to ISO/IEC 9316:1995"},
646 {0x82, "Compliance to ISO/IEC 9316:1995 and to ANSI X3.131:1994"},
647 {0x83, "Compliance to ISO/IEC 9316:1995 and to ANSI X3.301:1997"},
648 {0x84, "Compliance to ISO/IEC 9316:1995 and SPC-2"},
652 static const value_string scsi_modesense_medtype_sbc_val[] = {
654 {0x01, "Flexible disk, single-sided; unspecified medium"},
655 {0x02, "Flexible disk, double-sided; unspecified medium"},
656 {0x05, "Flexible disk, single-sided, single density; 200mm/8in diameter"},
657 {0x06, "Flexible disk, double-sided, single density; 200mm/8in diameter"},
658 {0x09, "Flexible disk, single-sided, double density; 200mm/8in diameter"},
659 {0x0A, "Flexible disk, double-sided, double density; 200mm/8in diameter"},
660 {0x0D, "Flexible disk, single-sided, single density; 130mm/5.25in diameter"},
661 {0x12, "Flexible disk, double-sided, single density; 130mm/5.25in diameter"},
662 {0x16, "Flexible disk, single-sided, double density; 130mm/5.25in diameter"},
663 {0x1A, "Flexible disk, double-sided, double density; 130mm/5.25in diameter"},
664 {0x1E, "Flexible disk, double-sided; 90mm/3.5in diameter"},
665 {0x40, "Direct-access magnetic tape, 12 tracks"},
666 {0x44, "Direct-access magnetic tape, 24 tracks"},
670 static const value_string scsi_verdesc_val[] = {
671 {0x0d40, "FC-AL (No Version)"},
672 {0x0d5c, "FC-AL ANSI X3.272:1996"},
673 {0x0d60, "FC-AL-2 (no version claimed)"},
674 {0x0d7c, "FC-AL-2 ANSI NCITS.332:1999"},
675 {0x0d61, "FC-AL-2 T11/1133 revision 7.0"},
676 {0x1320, "FC-FLA (no version claimed)"},
677 {0x133c, "FC-FLA ANSI NCITS TR-20:1998"},
678 {0x133b, "FC-FLA T11/1235 revision 7"},
679 {0x0da0, "FC-FS (no version claimed)"},
680 {0x0db7, "FC-FS T11/1331 revision 1.2"},
681 {0x08c0, "FCP (no version claimed)"},
682 {0x08dc, "FCP ANSI X3.269:1996"},
683 {0x08db, "FCP T10/0993 revision 12"},
684 {0x1340, "FC-PLDA (no version claimed)"},
685 {0x135c, "FC-PLDA ANSI NCITS TR-19:1998"},
686 {0x135b, "FC-PLDA T11/1162 revision 2.1"},
687 {0x0900, "FCP-2 (no version claimed)"},
688 {0x0901, "FCP-2 T10/1144 revision 4"},
689 {0x003c, "SAM ANSI X3.270:1996"},
690 {0x003b, "SAM T10/0994 revision 18"},
691 {0x0040, "SAM-2 (no version claimed)"},
692 {0x0020, "SAM (no version claimed)"},
693 {0x0180, "SBC (no version claimed)"},
694 {0x019c, "SBC ANSI NCITS.306:1998"},
695 {0x019b, "SBC T10/0996 revision 08c"},
696 {0x0320, "SBC-2 (no version claimed)"},
697 {0x01c0, "SES (no version claimed)"},
698 {0x01dc, "SES ANSI NCITS.305:1998"},
699 {0x01db, "SES T10/1212 revision 08b"},
700 {0x01de, "SES ANSI NCITS.305:1998 w/ Amendment ANSI NCITS.305/AM1:2000"},
701 {0x01dd, "SES T10/1212 revision 08b w/ Amendment ANSI NCITS.305/AM1:2000"},
702 {0x0120, "SPC (no version claimed)"},
703 {0x013c, "SPC ANSI X3.301:1997"},
704 {0x013b, "SPC T10/0995 revision 11a"},
705 {0x0260, "SPC-2 (no version claimed)"},
706 {0x0267, "SPC-2 T10/1236 revision 12"},
707 {0x0269, "SPC-2 T10/1236 revision 18"},
708 {0x0300, "SPC-3 (no version claimed)"},
709 {0x0960, "iSCSI (no version claimed)"},
710 {0x0d80, "FC-PH-3 (no version claimed)"},
711 {0x0d9c, "FC-PH-3 ANSI X3.303-1998"},
712 {0x0d20, "FC-PH (no version claimed)"},
716 /* Command Support Data "Support" field definitions */
717 static const value_string scsi_cmdt_supp_val[] = {
718 {0, "Data not currently available"},
719 {1, "SCSI Command not supported"},
721 {3, "SCSI Command supported in conformance with a SCSI standard"},
722 {4, "Vendor Specific"},
723 {5, "SCSI Command supported in a vendor specific manner"},
724 {6, "Vendor Specific"},
729 #define CODESET_BINARY 1
730 #define CODESET_ASCII 2
732 static const value_string scsi_devid_codeset_val[] = {
734 {CODESET_BINARY, "Identifier field contains binary values"},
735 {CODESET_ASCII, "Identifier field contains ASCII graphic codes"},
739 static const value_string scsi_devid_assoc_val[] = {
740 {0, "Identifier is associated with addressed logical/physical device"},
741 {1, "Identifier is associated with the port that received the request"},
745 static const value_string scsi_devid_idtype_val[] = {
746 {0, "Vendor-specific ID (non-globally unique)"},
747 {1, "Vendor-ID + vendor-specific ID (globally unique)"},
750 {4, "4-byte Binary Number/Reserved"},
754 static const value_string scsi_modesns_mrie_val[] = {
755 {0, "No Reporting of Informational Exception Condition"},
756 {1, "Asynchronous Error Reporting"},
757 {2, "Generate Unit Attention"},
758 {3, "Conditionally Generate Recovered Error"},
759 {4, "Unconditionally Generate Recovered Error"},
760 {5, "Generate No Sense"},
761 {6, "Only Report Informational Exception Condition on Request"},
765 static const value_string scsi_modesns_tst_val[] = {
766 {0, "Task Set Per LU For All Initiators"},
767 {1, "Task Set Per Initiator Per LU"},
771 static const value_string scsi_modesns_qmod_val[] = {
772 {0, "Restricted reordering"},
773 {1, "Unrestricted reordering"},
777 static const true_false_string scsi_modesns_qerr_val = {
778 "All blocked tasks shall be aborted on CHECK CONDITION",
779 "Blocked tasks shall resume after ACA/CA is cleared",
782 static const true_false_string scsi_modesns_tas_val = {
783 "Terminated tasks aborted without informing initiators",
784 "Tasks aborted by another initiator terminated with TASK ABORTED",
787 static const true_false_string scsi_modesns_rac_val = {
788 "Report a CHECK CONDITION Instead of Long Busy Condition",
789 "Long Busy Conditions Maybe Reported",
792 /* SCSI Transport Protocols */
793 #define SCSI_PROTO_FCP 0
794 #define SCSI_PROTO_iSCSI 5
796 static const value_string scsi_proto_val[] = {
802 static const value_string scsi_fcp_rrtov_val[] = {
803 {0, "No Timer Specified"},
810 static const value_string scsi_sensekey_val[] = {
812 {0x1, "Recovered Error"},
814 {0x3, "Medium Error"},
815 {0x4, "Hardware Error"},
816 {0x5, "Illegal Request"},
817 {0x6, "Unit Attention"},
818 {0x7, "Data Protection"},
819 {0x8, "Blank Check"},
820 {0x9, "Vendor Specific"},
821 {0xA, "Copy Aborted"},
822 {0xB, "Command Aborted"},
823 {0xC, "Obsolete Error Code"},
824 {0xD, "Overflow Command"},
830 static const value_string scsi_sns_errtype_val[] = {
831 {0x70, "Current Error"},
832 {0x71, "Deferred Error"},
833 {0x7F, "Vendor Specific"},
837 static const value_string scsi_asc_val[] = {
838 {0x0000, "No Additional Sense Information"},
839 {0x0006, "I/O Process Terminated"},
840 {0x0016, "Operation In Progress"},
841 {0x0017, "Cleaning Requested"},
842 {0x0100, "No Index/Sector Signal"},
843 {0x0200, "No Seek Complete"},
844 {0x0300, "Peripheral Device Write Fault"},
845 {0x0400, "Logical Unit Not Ready, Cause Not Reportable"},
846 {0x0401, "Logical Unit Is In Process Of Becoming Ready"},
847 {0x0402, "Logical Unit Not Ready, Initializing Cmd. Required"},
848 {0x0403, "Logical Unit Not Ready, Manual Intervention Required"},
849 {0x0404, "Logical Unit Not Ready, Format In Progress"},
850 {0x0405, "Logical Unit Not Ready, Rebuild In Progress"},
851 {0x0406, "Logical Unit Not Ready, Recalculation In Progress"},
852 {0x0407, "Logical Unit Not Ready, Operation In Progress"},
853 {0x0409, "Logical Unit Not Ready, Self-Test In Progress"},
854 {0x0500, "Logical Unit Does Not Respond To Selection"},
855 {0x0600, "No Reference Position Found"},
856 {0x0700, "Multiple Peripheral Devices Selected"},
857 {0x0800, "Logical Unit Communication Failure"},
858 {0x0801, "Logical Unit Communication Time-Out"},
859 {0x0802, "Logical Unit Communication Parity Error"},
860 {0x0803, "Logical Unit Communication Crc Error (Ultra-Dma/32)"},
861 {0x0804, "Unreachable Copy Target"},
862 {0x0900, "Track Following Error"},
863 {0x0904, "Head Select Fault"},
864 {0x0A00, "Error Log Overflow"},
866 {0x0B01, "Warning - Specified Temperature Exceeded"},
867 {0x0B02, "Warning - Enclosure Degraded"},
868 {0x0C02, "Write Error - Auto Reallocation Failed"},
869 {0x0C03, "Write Error - Recommend Reassignment"},
870 {0x0C04, "Compression Check Miscompare Error"},
871 {0x0C05, "Data Expansion Occurred During Compression"},
872 {0x0C06, "Block Not Compressible"},
873 {0x0D00, "Error Detected By Third Party Temporary Initiator"},
874 {0x0D01, "Third Party Device Failure"},
875 {0x0D02, "Copy Target Device Not Reachable"},
876 {0x0D03, "Incorrect Copy Target Device Type"},
877 {0x0D04, "Copy Target Device Data Underrun"},
878 {0x0D05, "Copy Target Device Data Overrun"},
879 {0x1000, "Id Crc Or Ecc Error"},
880 {0x1100, "Unrecovered Read Error"},
881 {0x1101, "Read Retries Exhausted"},
882 {0x1102, "Error Too Long To Correct"},
883 {0x1103, "Multiple Read Errors"},
884 {0x1104, "Unrecovered Read Error - Auto Reallocate Failed"},
885 {0x110A, "Miscorrected Error"},
886 {0x110B, "Unrecovered Read Error - Recommend Reassignment"},
887 {0x110C, "Unrecovered Read Error - Recommend Rewrite The Data"},
888 {0x110D, "De-Compression Crc Error"},
889 {0x110E, "Cannot Decompress Using Declared Algorithm"},
890 {0x1200, "Address Mark Not Found For Id Field"},
891 {0x1300, "Address Mark Not Found For Data Field"},
892 {0x1400, "Recorded Entity Not Found"},
893 {0x1401, "Record Not Found"},
894 {0x1405, "Record Not Found - Recommend Reassignment"},
895 {0x1406, "Record Not Found - Data Auto-Reallocated"},
896 {0x1500, "Random Positioning Error"},
897 {0x1501, "Mechanical Positioning Error"},
898 {0x1502, "Positioning Error Detected By Read Of Medium"},
899 {0x1600, "Data Synchronization Mark Error"},
900 {0x1601, "Data Sync Error - Data Rewritten"},
901 {0x1602, "Data Sync Error - Recommend Rewrite"},
902 {0x1603, "Data Sync Error - Data Auto-Reallocated"},
903 {0x1604, "Data Sync Error - Recommend Reassignment"},
904 {0x1700, "Recovered Data With No Error Correction Applied"},
905 {0x1701, "Recovered Data With Retries"},
906 {0x1702, "Recovered Data With Positive Head Offset"},
907 {0x1703, "Recovered Data With Negative Head Offset"},
908 {0x1705, "Recovered Data Using Previous Sector Id"},
909 {0x1706, "Recovered Data Without Ecc - Data Auto-Reallocated"},
910 {0x1707, "Recovered Data Without Ecc - Recommend Reassignment"},
911 {0x1708, "Recovered Data Without Ecc - Recommend Rewrite"},
912 {0x1709, "Recovered Data Without Ecc - Data Rewritten"},
913 {0x1800, "Recovered Data With Error Correction Applied"},
914 {0x1801, "Recovered Data With Error Corr. & Retries Applied"},
915 {0x1802, "Recovered Data - Data Auto-Reallocated"},
916 {0x1805, "Recovered Data - Recommend Reassignment"},
917 {0x1806, "Recovered Data - Recommend Rewrite"},
918 {0x1807, "Recovered Data With Ecc - Data Rewritten"},
919 {0x1900, "List Error"},
920 {0x1901, "List Not Available"},
921 {0x1902, "List Error In Primary List"},
922 {0x1903, "List Error In Grown List"},
923 {0x1A00, "Parameter List Length Error"},
924 {0x1B00, "Synchronous Data Transfer Error"},
925 {0x1C00, "Defect List Not Found"},
926 {0x1C01, "Primary Defect List Not Found"},
927 {0x1C02, "Grown Defect List Not Found"},
928 {0x1D00, "Miscompare During Verify Operation"},
929 {0x1E00, "Recovered Id With Ecc Correction"},
930 {0x1F00, "Defect List Transfer"},
931 {0x2000, "Invalid Command Operation Code"},
932 {0x2100, "Logical Block Address Out Of Range"},
933 {0x2101, "Invalid Element Address"},
934 {0x2400, "Invalid Field In Cdb"},
935 {0x2401, "Cdb Decryption Error"},
936 {0x2500, "Logical Unit Not Supported"},
937 {0x2600, "Invalid Field In Parameter List"},
938 {0x2601, "Parameter Not Supported"},
939 {0x2602, "Parameter Value Invalid"},
940 {0x2603, "Threshold Parameters Not Supported"},
941 {0x2604, "Invalid Release Of Persistent Reservation"},
942 {0x2605, "Data Decryption Error"},
943 {0x2606, "Too Many Target Descriptors"},
944 {0x2607, "Unsupported Target Descriptor Type Code"},
945 {0x2608, "Too Many Segment Descriptors"},
946 {0x2609, "Unsupported Segment Descriptor Type Code"},
947 {0x260A, "Unexpected Inexact Segment"},
948 {0x260B, "Inline Data Length Exceeded"},
949 {0x260C, "Invalid Operation For Copy Source Or Destination"},
950 {0x260D, "Copy Segment Granularity Violation"},
951 {0x2700, "Write Protected"},
952 {0x2701, "Hardware Write Protected"},
953 {0x2702, "Logical Unit Software Write Protected"},
954 {0x2800, "Not Ready To Ready Change, Medium May Have Changed"},
955 {0x2801, "Import Or Export Element Accessed"},
956 {0x2900, "Power On, Reset, Or Bus Device Reset Occurred"},
957 {0x2901, "Power On Occurred"},
958 {0x2902, "Scsi Bus Reset Occurred"},
959 {0x2903, "Bus Device Reset Function Occurred"},
960 {0x2904, "Device Internal Reset"},
961 {0x2905, "Transceiver Mode Changed To Single-Ended"},
962 {0x2906, "Transceiver Mode Changed To Lvd"},
963 {0x2A00, "Parameters Changed"},
964 {0x2A01, "Mode Parameters Changed"},
965 {0x2A02, "Log Parameters Changed"},
966 {0x2A03, "Reservations Preempted"},
967 {0x2A04, "Reservations Released"},
968 {0x2A05, "Registrations Preempted"},
969 {0x2B00, "Copy Cannot Execute Since Host Cannot Disconnect"},
970 {0x2C00, "Command Sequence Error"},
971 {0x2F00, "Commands Cleared By Another Initiator"},
972 {0x3000, "Incompatible Medium Installed"},
973 {0x3001, "Cannot Read Medium - Unknown Format"},
974 {0x3002, "Cannot Read Medium - Incompatible Format"},
975 {0x3003, "Cleaning Cartridge Installed"},
976 {0x3004, "Cannot Write Medium - Unknown Format"},
977 {0x3005, "Cannot Write Medium - Incompatible Format"},
978 {0x3006, "Cannot Format Medium - Incompatible Medium"},
979 {0x3007, "Cleaning Failure"},
980 {0x3100, "Medium Format Corrupted"},
981 {0x3101, "Format Command Failed"},
982 {0x3200, "No Defect Spare Location Available"},
983 {0x3201, "Defect List Update Failure"},
984 {0x3400, "Enclosure Failure"},
985 {0x3500, "Enclosure Services Failure"},
986 {0x3501, "Unsupported Enclosure Function"},
987 {0x3502, "Enclosure Services Unavailable"},
988 {0x3503, "Enclosure Services Transfer Failure"},
989 {0x3504, "Enclosure Services Transfer Refused"},
990 {0x3700, "Rounded Parameter"},
991 {0x3900, "Saving Parameters Not Supported"},
992 {0x3A00, "Medium Not Present"},
993 {0x3A01, "Medium Not Present - Tray Closed"},
994 {0x3A02, "Medium Not Present - Tray Open"},
995 {0x3A03, "Medium Not Present - Loadable"},
996 {0x3A04, "Medium Not Present - Medium Auxiliary Memory Accessible"},
997 {0x3B0D, "Medium Destination Element Full"},
998 {0x3B0E, "Medium Source Element Empty"},
999 {0x3B11, "Medium Magazine Not Accessible"},
1000 {0x3B12, "Medium Magazine Removed"},
1001 {0x3B13, "Medium Magazine Inserted"},
1002 {0x3B14, "Medium Magazine Locked"},
1003 {0x3B15, "Medium Magazine Unlocked"},
1004 {0x3D00, "Invalid Bits In Identify Message"},
1005 {0x3E00, "Logical Unit Has Not Self-Configured Yet"},
1006 {0x3E01, "Logical Unit Failure"},
1007 {0x3E02, "Timeout On Logical Unit"},
1008 {0x3E03, "Logical Unit Failed Self-Test"},
1009 {0x3E04, "Logical Unit Unable To Update Self-Test Log"},
1010 {0x3F00, "Target Operating Conditions Have Changed"},
1011 {0x3F01, "Microcode Has Been Changed"},
1012 {0x3F02, "Changed Operating Definition"},
1013 {0x3F03, "Inquiry Data Has Changed"},
1014 {0x3F04, "Component Device Attached"},
1015 {0x3F05, "Device Identifier Changed"},
1016 {0x3F06, "Redundancy Group Created Or Modified"},
1017 {0x3F07, "Redundancy Group Deleted"},
1018 {0x3F08, "Spare Created Or Modified"},
1019 {0x3F09, "Spare Deleted"},
1020 {0x3F0A, "Volume Set Created Or Modified"},
1021 {0x3F0B, "Volume Set Deleted"},
1022 {0x3F0C, "Volume Set Deassigned"},
1023 {0x3F0D, "Volume Set Reassigned"},
1024 {0x3F0E, "Reported Luns Data Has Changed"},
1025 {0x3F0F, "Echo Buffer Overwritten"},
1026 {0x3F10, "Medium Loadable"},
1027 {0x3F11, "Medium Auxiliary Memory Accessible"},
1028 {0x4200, "Self-Test Failure (Should Use 40 Nn)"},
1029 {0x4300, "Message Error"},
1030 {0x4400, "Internal Target Failure"},
1031 {0x4500, "Select Or Reselect Failure"},
1032 {0x4600, "Unsuccessful Soft Reset"},
1033 {0x4700, "Scsi Parity Error"},
1034 {0x4701, "Data Phase Crc Error Detected"},
1035 {0x4702, "Scsi Parity Error Detected During St Data Phase"},
1036 {0x4703, "Information Unit Crc Error Detected"},
1037 {0x4704, "Asynchronous Information Protection Error Detected"},
1038 {0x4800, "Initiator Detected Error Message Received"},
1039 {0x4900, "Invalid Message Error"},
1040 {0x4A00, "Command Phase Error"},
1041 {0x4B00, "Data Phase Error"},
1042 {0x4C00, "Logical Unit Failed Self-Configuration"},
1043 {0x4D00, "Tagged Overlapped Commands (Nn = Queue Tag)"},
1044 {0x4E00, "Overlapped Commands Attempted"},
1045 {0x5300, "Media Load Or Eject Failed"},
1046 {0x5302, "Medium Removal Prevented"},
1047 {0x5501, "System Buffer Full"},
1048 {0x5502, "Insufficient Reservation Resources"},
1049 {0x5503, "Insufficient Resources"},
1050 {0x5504, "Insufficient Registration Resources"},
1051 {0x5A00, "Operator Request Or State Change Input"},
1052 {0x5A01, "Operator Medium Removal Request"},
1053 {0x5A02, "Operator Selected Write Protect"},
1054 {0x5A03, "Operator Selected Write Permit"},
1055 {0x5B00, "Log Exception"},
1056 {0x5B01, "Threshold Condition Met"},
1057 {0x5B02, "Log Counter At Maximum"},
1058 {0x5B03, "Log List Codes Exhausted"},
1060 {0x5C02, "Synchronized"},
1061 {0x5D00, "Failure Prediction Threshold Exceeded"},
1062 {0x5D10, "Failure General Hard Drive Failure"},
1063 {0x5D11, "Failure Drive Error Rate Too High"},
1064 {0x5D12, "Failure Data Error Rate Too High"},
1065 {0x5D13, "Failure Seek Error Rate Too High"},
1066 {0x5D14, "Failure Too Many Block Reassigns"},
1067 {0x5D15, "Failure Access Times Too High"},
1068 {0x5D16, "Failure Start Unit Times Too High"},
1069 {0x5D17, "Failure Channel Parametrics"},
1070 {0x5D18, "Failure Controller Detected"},
1071 {0x5D19, "Failure Throughput Performance"},
1072 {0x5D1A, "Failure Seek Time Performance"},
1073 {0x5D1B, "Failure Spin-Up Retry Count"},
1074 {0x5D1C, "Failure Drive Calibration Retry"},
1075 {0x5D20, "Failure General Hard Drive Failure"},
1076 {0x5D21, "Failure Drive Error Rate Too High"},
1077 {0x5D22, "Failure Data Error Rate Too High"},
1078 {0x5D23, "Failure Seek Error Rate Too High"},
1079 {0x5D24, "Failure Too Many Block Reassigns"},
1080 {0x5D25, "Failure Access Times Too High"},
1081 {0x5D26, "Failure Start Unit Times Too High"},
1082 {0x5D27, "Failure Channel Parametrics"},
1083 {0x5D28, "Failure Controller Detected"},
1084 {0x5D29, "Failure Throughput Performance"},
1085 {0x5D2A, "Failure Seek Time Performance"},
1086 {0x5D2B, "Failure Spin-Up Retry Count"},
1087 {0x5D2C, "Failure Drive Calibration Retry"},
1088 {0x5D30, "Impending Failure General Hard Drive"},
1089 {0x5D31, "Impending Failure Drive Error Rate Too High"},
1090 {0x5D32, "Impending Failure Data Error Rate Too High"},
1091 {0x5D33, "Impending Failure Seek Error Rate Too High"},
1092 {0x5D34, "Impending Failure Too Many Block Reassigns"},
1093 {0x5D35, "Impending Failure Access Times Too High"},
1094 {0x5D36, "Impending Failure Start Unit Times Too High"},
1095 {0x5D37, "Impending Failure Channel Parametrics"},
1096 {0x5D38, "Impending Failure Controller Detected"},
1097 {0x5D39, "Impending Failure Throughput Performance"},
1098 {0x5D3A, "Impending Failure Seek Time Performance"},
1099 {0x5D3B, "Impending Failure Spin-Up Retry Count"},
1100 {0x5D3C, "Impending Failure Drive Calibration Retry"},
1101 {0x5D40, "Failure General Hard Drive Failure"},
1102 {0x5D41, "Failure Drive Error Rate Too High"},
1103 {0x5D42, "Failure Data Error Rate Too High"},
1104 {0x5D43, "Failure Seek Error Rate Too High"},
1105 {0x5D44, "Failure Too Many Block Reassigns"},
1106 {0x5D45, "Failure Access Times Too High"},
1107 {0x5D46, "Failure Start Unit Times Too High"},
1108 {0x5D47, "Failure Channel Parametrics"},
1109 {0x5D48, "Failure Controller Detected"},
1110 {0x5D49, "Failure Throughput Performance"},
1111 {0x5D4A, "Failure Seek Time Performance"},
1112 {0x5D4B, "Failure Spin-Up Retry Count"},
1113 {0x5D4C, "Failure Drive Calibration Retry Count"},
1114 {0x5D50, "Failure General Hard Drive Failure"},
1115 {0x5D51, "Failure Drive Error Rate Too High"},
1116 {0x5D52, "Failure Data Error Rate Too High"},
1117 {0x5D53, "Failure Seek Error Rate Too High"},
1118 {0x5D54, "Failure Too Many Block Reassigns"},
1119 {0x5D55, "Failure Access Times Too High"},
1120 {0x5D56, "Failure Start Unit Times Too High"},
1121 {0x5D57, "Failure Channel Parametrics"},
1122 {0x5D58, "Failure Controller Detected"},
1123 {0x5D59, "Failure Throughput Performance"},
1124 {0x5D5A, "Failure Seek Time Performance"},
1125 {0x5D5B, "Failure Spin-Up Retry Count"},
1126 {0x5D5C, "Failure Drive Calibration Retry Count"},
1127 {0x5D60, "Failure General Hard Drive Failure"},
1128 {0x5D61, "Failure Drive Error Rate Too High"},
1129 {0x5D62, "Failure Data Error Rate Too High"},
1130 {0x5D63, "Failure Seek Error Rate Too High"},
1131 {0x5D64, "Failure Too Many Block Reassigns"},
1132 {0x5D65, "Failure Access Times Too High"},
1133 {0x5D66, "Failure Start Unit Times Too High"},
1134 {0x5D67, "Failure Channel Parametrics"},
1135 {0x5D68, "Failure Controller Detected"},
1136 {0x5D69, "Failure Throughput Performance"},
1137 {0x5D6A, "Failure Seek Time Performance"},
1138 {0x5D6B, "Failure Spin-Up Retry Count"},
1139 {0x5D6C, "Failure Drive Calibration Retry Count"},
1140 {0x5DFF, "Failure Prediction Threshold Exceeded (False)"},
1141 {0x5E00, "Low Power Condition On"},
1142 {0x5E01, "Idle Condition Activated By Timer"},
1143 {0x5E02, "Standby Condition Activated By Timer"},
1144 {0x5E03, "Idle Condition Activated By Command"},
1145 {0x5E04, "Standby Condition Activated By Command"},
1146 {0x6500, "Voltage Fault"},
1150 /* SCSI Status Codes */
1151 const value_string scsi_status_val[] = {
1153 {0x02, "Check Condition"},
1154 {0x04, "Condition Met"},
1156 {0x10, "Intermediate"},
1157 {0x14, "Intermediate Condition Met"},
1158 {0x18, "Reservation Conflict"},
1159 {0x28, "Task Set Full"},
1160 {0x30, "ACA Active"},
1161 {0x40, "Task Aborted"},
1165 static gint scsi_def_devtype = SCSI_DEV_SBC;
1168 * We track SCSI requests and responses with a hash table.
1169 * The key is a "scsi_task_id_t" structure; the data is a
1170 * "scsi_task_data_t" structure.
1174 * the command code and type of command (it's not present in the
1175 * response, and we need it to dissect the response);
1176 * the type of device it's on;
1178 * and we also have a field to record flags in case the interpretation
1179 * of the response data depends on data from the command.
1181 typedef struct _scsi_task_data {
1184 scsi_device_type devtype;
1189 * The next two data structures are used to track SCSI device type.
1191 * XXX - it might not be sufficient to use the address of the server
1192 * to which SCSI CDBs are being sent to identify the device, as
1194 * 1) a server might have multiple targets or logical units;
1196 * 2) a server might make a different logical unit refer to
1197 * different devices for different clients;
1199 * so we should really base this on the connection index for the
1200 * connection and on a device identifier supplied to us by our caller,
1201 * not on a network-layer address.
1203 typedef struct _scsi_devtype_key {
1205 } scsi_devtype_key_t;
1207 typedef struct _scsi_devtype_data {
1208 scsi_device_type devtype;
1209 } scsi_devtype_data_t;
1211 static GHashTable *scsi_req_hash = NULL;
1212 static GMemChunk *scsi_req_keys = NULL;
1213 static GMemChunk *scsi_req_vals = NULL;
1214 static guint32 scsi_init_count = 25;
1216 static GHashTable *scsidev_req_hash = NULL;
1217 static GMemChunk *scsidev_req_keys = NULL;
1218 static GMemChunk *scsidev_req_vals = NULL;
1219 static guint32 scsidev_init_count = 25;
1221 static dissector_handle_t data_handle;
1227 scsi_equal(gconstpointer v, gconstpointer w)
1229 const scsi_task_id_t *v1 = (const scsi_task_id_t *)v;
1230 const scsi_task_id_t *v2 = (const scsi_task_id_t *)w;
1232 return (v1->conv_id == v2->conv_id && v1->task_id == v2->task_id);
1236 scsi_hash (gconstpointer v)
1238 const scsi_task_id_t *key = (const scsi_task_id_t *)v;
1241 val = key->conv_id + key->task_id;
1247 scsidev_equal (gconstpointer v, gconstpointer w)
1249 const scsi_devtype_key_t *k1 = (const scsi_devtype_key_t *)v;
1250 const scsi_devtype_key_t *k2 = (const scsi_devtype_key_t *)w;
1252 if (ADDRESSES_EQUAL (&k1->devid, &k2->devid))
1259 scsidev_hash (gconstpointer v)
1261 const scsi_devtype_key_t *key = (const scsi_devtype_key_t *)v;
1266 for (i = 0; i < key->devid.len; i++)
1267 val += key->devid.data[i];
1268 val += key->devid.type;
1273 static scsi_task_data_t *
1274 scsi_new_task (packet_info *pinfo)
1276 scsi_task_data_t *cdata = NULL;
1277 scsi_task_id_t ckey, *req_key;
1279 if ((pinfo != NULL) && (pinfo->private_data)) {
1280 ckey = *(scsi_task_id_t *)pinfo->private_data;
1282 cdata = (scsi_task_data_t *)g_hash_table_lookup (scsi_req_hash,
1285 req_key = g_mem_chunk_alloc (scsi_req_keys);
1286 *req_key = *(scsi_task_id_t *)pinfo->private_data;
1288 cdata = g_mem_chunk_alloc (scsi_req_vals);
1290 g_hash_table_insert (scsi_req_hash, req_key, cdata);
1296 static scsi_task_data_t *
1297 scsi_find_task (packet_info *pinfo)
1299 scsi_task_data_t *cdata = NULL;
1300 scsi_task_id_t ckey;
1302 if ((pinfo != NULL) && (pinfo->private_data)) {
1303 ckey = *(scsi_task_id_t *)pinfo->private_data;
1305 cdata = (scsi_task_data_t *)g_hash_table_lookup (scsi_req_hash,
1312 scsi_end_task (packet_info *pinfo)
1314 scsi_task_data_t *cdata = NULL;
1315 scsi_task_id_t ckey;
1317 if ((pinfo != NULL) && (pinfo->private_data)) {
1318 ckey = *(scsi_task_id_t *)pinfo->private_data;
1319 cdata = (scsi_task_data_t *)g_hash_table_lookup (scsi_req_hash,
1322 g_mem_chunk_free (scsi_req_vals, cdata);
1323 g_hash_table_remove (scsi_req_hash, &ckey);
1329 * Protocol initialization
1332 free_devtype_key_dev_info(gpointer key_arg, gpointer value_arg _U_,
1333 gpointer user_data _U_)
1335 scsi_devtype_key_t *key = key_arg;
1337 if (key->devid.data != NULL) {
1338 g_free((gpointer)key->devid.data);
1339 key->devid.data = NULL;
1344 scsi_init_protocol(void)
1347 * First, free up the data for the addresses attached to
1348 * scsi_devtype_key_t structures. Do so before we free
1349 * those structures or destroy the hash table in which
1352 if (scsidev_req_hash != NULL) {
1353 g_hash_table_foreach(scsidev_req_hash, free_devtype_key_dev_info,
1358 g_mem_chunk_destroy(scsi_req_keys);
1360 g_mem_chunk_destroy(scsi_req_vals);
1361 if (scsidev_req_keys)
1362 g_mem_chunk_destroy (scsidev_req_keys);
1363 if (scsidev_req_vals)
1364 g_mem_chunk_destroy (scsidev_req_vals);
1366 g_hash_table_destroy(scsi_req_hash);
1367 if (scsidev_req_hash)
1368 g_hash_table_destroy (scsidev_req_hash);
1370 scsi_req_hash = g_hash_table_new(scsi_hash, scsi_equal);
1371 scsi_req_keys = g_mem_chunk_new("scsi_req_keys",
1372 sizeof(scsi_task_id_t),
1374 sizeof(scsi_task_id_t),
1376 scsi_req_vals = g_mem_chunk_new("scsi_req_vals",
1377 sizeof(scsi_task_data_t),
1379 sizeof(scsi_task_data_t),
1381 scsidev_req_hash = g_hash_table_new (scsidev_hash, scsidev_equal);
1382 scsidev_req_keys = g_mem_chunk_new("scsidev_req_keys",
1383 sizeof(scsi_devtype_key_t),
1384 scsidev_init_count *
1385 sizeof(scsi_devtype_key_t),
1387 scsidev_req_vals = g_mem_chunk_new("scsidev_req_vals",
1388 sizeof(scsi_devtype_data_t),
1389 scsidev_init_count *
1390 sizeof(scsi_devtype_data_t),
1395 dissect_scsi_evpd (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
1396 guint offset, guint tot_len _U_)
1398 proto_tree *evpd_tree;
1400 guint pcode, plen, i, idlen;
1401 guint8 codeset, flags;
1405 pcode = tvb_get_guint8 (tvb, offset+1);
1406 plen = tvb_get_guint8 (tvb, offset+3);
1407 ti = proto_tree_add_text (tree, tvb, offset, plen+4, "Page Code: %s",
1408 val_to_str (pcode, scsi_evpd_pagecode_val,
1409 "Unknown (0x%08x)"));
1410 evpd_tree = proto_item_add_subtree (ti, ett_scsi_page);
1412 proto_tree_add_item (evpd_tree, hf_scsi_inq_qualifier, tvb, offset,
1414 proto_tree_add_item (evpd_tree, hf_scsi_inq_devtype, tvb, offset,
1416 proto_tree_add_text (evpd_tree, tvb, offset+1, 1,
1418 val_to_str (pcode, scsi_evpd_pagecode_val,
1419 "Unknown (0x%02x)"));
1420 proto_tree_add_text (evpd_tree, tvb, offset+3, 1,
1421 "Page Length: %u", plen);
1424 case SCSI_EVPD_SUPPPG:
1425 for (i = 0; i < plen; i++) {
1426 proto_tree_add_text (evpd_tree, tvb, offset+i, 1,
1427 "Supported Page: %s",
1428 val_to_str (tvb_get_guint8 (tvb, offset+i),
1429 scsi_evpd_pagecode_val,
1430 "Unknown (0x%02x)"));
1433 case SCSI_EVPD_DEVID:
1435 codeset = tvb_get_guint8 (tvb, offset) & 0x0F;
1436 proto_tree_add_text (evpd_tree, tvb, offset, 1,
1438 val_to_str (codeset,
1439 scsi_devid_codeset_val,
1440 "Unknown (0x%02x)"));
1445 proto_tree_add_text (evpd_tree, tvb, offset, 0,
1446 "Product data goes past end of page");
1449 flags = tvb_get_guint8 (tvb, offset);
1450 proto_tree_add_text (evpd_tree, tvb, offset, 1,
1452 val_to_str ((flags & 0x30) >> 4,
1453 scsi_devid_assoc_val,
1454 "Unknown (0x%02x)"));
1455 proto_tree_add_text (evpd_tree, tvb, offset, 1,
1456 "Identifier Type: %s",
1457 val_to_str ((flags & 0x0F),
1458 scsi_devid_idtype_val,
1459 "Unknown (0x%02x)"));
1463 /* Skip reserved byte */
1465 proto_tree_add_text (evpd_tree, tvb, offset, 0,
1466 "Product data goes past end of page");
1473 proto_tree_add_text (evpd_tree, tvb, offset, 0,
1474 "Product data goes past end of page");
1477 idlen = tvb_get_guint8 (tvb, offset);
1478 proto_tree_add_text (evpd_tree, tvb, offset, 1,
1479 "Identifier Length: %u", idlen);
1485 proto_tree_add_text (evpd_tree, tvb, offset, 0,
1486 "Product data goes past end of page");
1489 if (codeset == CODESET_ASCII) {
1490 proto_tree_add_text (evpd_tree, tvb, offset, idlen,
1492 tvb_format_text (tvb, offset,
1496 * XXX - decode this based on the identifier type,
1497 * if the codeset is CODESET_BINARY?
1499 proto_tree_add_text (evpd_tree, tvb, offset, idlen,
1501 tvb_bytes_to_str (tvb, offset,
1509 case SCSI_EVPD_DEVSERNUM:
1511 tvb_memcpy (tvb, str, offset, MIN(plen, sizeof(str) - 1));
1512 str[sizeof(str) - 1] = '\0';
1513 proto_tree_add_text (evpd_tree, tvb, offset, plen,
1514 "Product Serial Number: %s", str);
1522 dissect_scsi_cmddt (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
1523 guint offset, guint tot_len _U_)
1525 proto_tree *cmdt_tree;
1530 plen = tvb_get_guint8 (tvb, offset+5);
1531 ti = proto_tree_add_text (tree, tvb, offset, plen, "Command Data");
1532 cmdt_tree = proto_item_add_subtree (ti, ett_scsi_page);
1534 proto_tree_add_item (cmdt_tree, hf_scsi_inq_qualifier, tvb, offset,
1536 proto_tree_add_item (cmdt_tree, hf_scsi_inq_devtype, tvb, offset,
1538 proto_tree_add_text (cmdt_tree, tvb, offset+1, 1, "Support: %s",
1539 match_strval (tvb_get_guint8 (tvb, offset+1) & 0x7,
1540 scsi_cmdt_supp_val));
1541 proto_tree_add_text (cmdt_tree, tvb, offset+2, 1, "Version: %s",
1542 val_to_str (tvb_get_guint8 (tvb, offset+2),
1544 "Unknown (0x%02x)"));
1545 proto_tree_add_text (cmdt_tree, tvb, offset+5, 1, "CDB Size: %u",
1551 dissect_scsi_inquiry (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1552 guint offset, gboolean isreq, gboolean iscdb,
1553 guint32 payload_len, scsi_task_data_t *cdata)
1555 guint8 flags, i, devtype;
1558 scsi_devtype_data_t *devdata = NULL;
1559 scsi_devtype_key_t dkey, *req_key;
1561 if (!isreq && (cdata == NULL || !(cdata->flags & 0x3))) {
1563 * INQUIRY response with device type information; add device type
1564 * to list of known devices & their types if not already known.
1566 * We don't use COPY_ADDRESS because "dkey.devid" isn't
1567 * persistent, and therefore it can point to the stuff
1568 * in "pinfo->src". (Were we to use COPY_ADDRESS, we'd
1569 * have to free the address data it allocated before we return.)
1571 dkey.devid = pinfo->src;
1572 devdata = (scsi_devtype_data_t *)g_hash_table_lookup (scsidev_req_hash,
1575 req_key = g_mem_chunk_alloc (scsidev_req_keys);
1576 COPY_ADDRESS (&(req_key->devid), &(pinfo->src));
1578 devdata = g_mem_chunk_alloc (scsidev_req_vals);
1579 devdata->devtype = tvb_get_guint8 (tvb, offset) & SCSI_DEV_BITS;
1581 g_hash_table_insert (scsidev_req_hash, req_key, devdata);
1584 devtype = tvb_get_guint8 (tvb, offset);
1585 if ((devtype & SCSI_DEV_BITS) != SCSI_DEV_NOLUN) {
1586 /* Some initiators probe more than the available LUNs which
1587 * results in Inquiry data being returned indicating that a LUN
1588 * is not supported. We don't want to overwrite the device type
1589 * with such responses.
1591 devdata->devtype = (devtype & SCSI_DEV_BITS);
1599 if (isreq && iscdb) {
1600 flags = tvb_get_guint8 (tvb, offset);
1601 if (cdata != NULL) {
1602 cdata->flags = flags;
1605 proto_tree_add_uint_format (tree, hf_scsi_inquiry_flags, tvb, offset, 1,
1606 flags, "CMDT = %u, EVPD = %u",
1607 flags & 0x2, flags & 0x1);
1609 proto_tree_add_item (tree, hf_scsi_inquiry_evpd_page, tvb, offset+1,
1612 else if (flags & 0x2) {
1613 proto_tree_add_item (tree, hf_scsi_inquiry_cmdt_page, tvb, offset+1,
1617 proto_tree_add_item (tree, hf_scsi_alloclen, tvb, offset+3, 1, 0);
1618 flags = tvb_get_guint8 (tvb, offset+4);
1619 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
1621 "Vendor Unique = %u, NACA = %u, Link = %u",
1622 flags & 0xC0, flags & 0x4, flags & 0x1);
1625 if (cdata && (cdata->flags & 0x1)) {
1626 dissect_scsi_evpd (tvb, pinfo, tree, offset, payload_len);
1629 else if (cdata && (cdata->flags & 0x2)) {
1630 dissect_scsi_cmddt (tvb, pinfo, tree, offset, payload_len);
1634 proto_tree_add_item (tree, hf_scsi_inq_qualifier, tvb, offset,
1636 proto_tree_add_item (tree, hf_scsi_inq_devtype, tvb, offset, 1, 0);
1637 proto_tree_add_item (tree, hf_scsi_inq_version, tvb, offset+2, 1, 0);
1639 flags = tvb_get_guint8 (tvb, offset+3);
1640 proto_tree_add_item_hidden (tree, hf_scsi_inq_normaca, tvb,
1642 proto_tree_add_text (tree, tvb, offset+3, 1, "NormACA: %u, HiSup: %u",
1643 ((flags & 0x20) >> 5), ((flags & 0x10) >> 4));
1644 tot_len = tvb_get_guint8 (tvb, offset+4);
1645 proto_tree_add_text (tree, tvb, offset+4, 1, "Additional Length: %u",
1647 flags = tvb_get_guint8 (tvb, offset+6);
1648 proto_tree_add_text (tree, tvb, offset+6, 1,
1649 "BQue: %u, SES: %u, MultiP: %u, Addr16: %u",
1650 ((flags & 0x80) >> 7), (flags & 0x40) >> 6,
1651 (flags & 10) >> 4, (flags & 0x01));
1652 flags = tvb_get_guint8 (tvb, offset+7);
1653 proto_tree_add_text (tree, tvb, offset+7, 1,
1654 "RelAdr: %u, Linked: %u, CmdQue: %u",
1655 (flags & 0x80) >> 7, (flags & 0x08) >> 3,
1656 (flags & 0x02) >> 1);
1657 tvb_memcpy (tvb, str, offset+8, 8);
1659 proto_tree_add_text (tree, tvb, offset+8, 8, "Vendor Id: %s", str);
1660 tvb_memcpy (tvb, str, offset+16, 16);
1662 proto_tree_add_text (tree, tvb, offset+16, 16, "Product ID: %s", str);
1663 tvb_memcpy (tvb, str, offset+32, 4);
1665 proto_tree_add_text (tree, tvb, offset+32, 4, "Product Revision: %s",
1669 if ((tot_len > 58) && tvb_bytes_exist (tvb, offset, 16)) {
1670 for (i = 0; i < 8; i++) {
1671 proto_tree_add_text (tree, tvb, offset, 2,
1672 "Vendor Descriptor %u: %s",
1674 val_to_str (tvb_get_ntohs (tvb, offset),
1676 "Unknown (0x%04x)"));
1684 dissect_scsi_extcopy (tvbuff_t *tvb _U_, packet_info *pinfo _U_,
1685 proto_tree *tree _U_, guint offset _U_,
1686 gboolean isreq _U_, gboolean iscdb _U_)
1692 dissect_scsi_logselect (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
1693 guint offset, gboolean isreq, gboolean iscdb)
1700 if (isreq && iscdb) {
1701 flags = tvb_get_guint8 (tvb, offset);
1703 proto_tree_add_uint_format (tree, hf_scsi_logsel_flags, tvb, offset, 1,
1704 flags, "PCR = %u, SP = %u", flags & 0x2,
1706 proto_tree_add_uint_format (tree, hf_scsi_logsel_pc, tvb, offset+1, 1,
1707 tvb_get_guint8 (tvb, offset+1),
1708 "PC: 0x%x", flags & 0xC0);
1709 proto_tree_add_item (tree, hf_scsi_paramlen16, tvb, offset+6, 2, 0);
1711 flags = tvb_get_guint8 (tvb, offset+8);
1712 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1,
1714 "Vendor Unique = %u, NACA = %u, Link = %u",
1715 flags & 0xC0, flags & 0x4, flags & 0x1);
1722 dissect_scsi_logsense (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
1723 guint offset, gboolean isreq, gboolean iscdb)
1730 if (isreq && iscdb) {
1731 flags = tvb_get_guint8 (tvb, offset);
1733 proto_tree_add_uint_format (tree, hf_scsi_logsns_flags, tvb, offset, 1,
1734 flags, "PPC = %u, SP = %u", flags & 0x2,
1736 proto_tree_add_uint_format (tree, hf_scsi_logsns_pc, tvb, offset+1, 1,
1737 tvb_get_guint8 (tvb, offset+1),
1738 "PC: 0x%x", flags & 0xC0);
1739 proto_tree_add_item (tree, hf_scsi_logsns_pagecode, tvb, offset+1,
1741 proto_tree_add_text (tree, tvb, offset+4, 2, "Parameter Pointer: 0x%04x",
1742 tvb_get_ntohs (tvb, offset+4));
1743 proto_tree_add_item (tree, hf_scsi_alloclen16, tvb, offset+6, 2, 0);
1745 flags = tvb_get_guint8 (tvb, offset+8);
1746 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1,
1748 "Vendor Unique = %u, NACA = %u, Link = %u",
1749 flags & 0xC0, flags & 0x4, flags & 0x1);
1756 dissect_scsi_blockdescs (tvbuff_t *tvb, packet_info *pinfo _U_,
1757 proto_tree *scsi_tree, guint offset,
1758 guint payload_len, guint desclen,
1759 scsi_device_type devtype, gboolean longlba)
1761 while (desclen != 0) {
1763 if (payload_len < 8)
1767 payload_len -= desclen;
1770 proto_tree_add_text (scsi_tree, tvb, offset, 8, "No. of Blocks: %s",
1771 u64toa (tvb_get_ptr (tvb, offset, 8)));
1776 if (payload_len < 1)
1780 proto_tree_add_text (scsi_tree, tvb, offset, 1, "Density Code: 0x%02x",
1781 tvb_get_guint8 (tvb, offset));
1786 if (payload_len < 3)
1790 payload_len -= desclen;
1793 /* 3 reserved bytes */
1798 if (payload_len < 4)
1802 payload_len -= desclen;
1805 proto_tree_add_text (scsi_tree, tvb, offset, 4, "Block Length: %u",
1806 tvb_get_ntohl (tvb, offset));
1811 if (devtype == SCSI_DEV_SBC) {
1812 if (payload_len < 4)
1816 payload_len -= desclen;
1819 proto_tree_add_text (scsi_tree, tvb, offset, 4, "No. of Blocks: %u",
1820 tvb_get_ntohl (tvb, offset));
1825 if (payload_len < 1)
1829 proto_tree_add_text (scsi_tree, tvb, offset, 1, "Density Code: 0x%02x",
1830 tvb_get_guint8 (tvb, offset));
1835 if (payload_len < 3)
1839 payload_len -= desclen;
1842 proto_tree_add_text (scsi_tree, tvb, offset, 3, "Block Length: %u",
1843 tvb_get_ntoh24 (tvb, offset));
1848 if (payload_len < 1)
1852 proto_tree_add_text (scsi_tree, tvb, offset, 1, "Density Code: 0x%02x",
1853 tvb_get_guint8 (tvb, offset));
1858 if (payload_len < 3)
1862 payload_len -= desclen;
1865 proto_tree_add_text (scsi_tree, tvb, offset, 3, "No. of Blocks: %u",
1866 tvb_get_ntoh24 (tvb, offset));
1871 if (payload_len < 1)
1880 if (payload_len < 3)
1884 payload_len -= desclen;
1887 proto_tree_add_text (scsi_tree, tvb, offset, 3, "Block Length: %u",
1888 tvb_get_ntoh24 (tvb, offset));
1899 dissect_scsi_spc2_modepage (tvbuff_t *tvb, packet_info *pinfo _U_,
1900 proto_tree *tree, guint offset, guint8 pcode)
1902 guint8 flags, proto;
1905 case SCSI_SPC2_MODEPAGE_CTL:
1906 flags = tvb_get_guint8 (tvb, offset+2);
1907 proto_tree_add_item (tree, hf_scsi_modesns_tst, tvb, offset+2, 1, 0);
1908 proto_tree_add_text (tree, tvb, offset+2, 1,
1909 "Global Logging Target Save Disable: %u, Report Log Exception Condition: %u",
1910 (flags & 0x2) >> 1, (flags & 0x1));
1911 flags = tvb_get_guint8 (tvb, offset+3);
1912 proto_tree_add_item (tree, hf_scsi_modesns_qmod, tvb, offset+3, 1, 0);
1913 proto_tree_add_item (tree, hf_scsi_modesns_qerr, tvb, offset+3, 1, 0);
1914 proto_tree_add_text (tree, tvb, offset+3, 1, "Disable Queuing: %u",
1916 flags = tvb_get_guint8 (tvb, offset+4);
1917 proto_tree_add_item (tree, hf_scsi_modesns_rac, tvb, offset+4, 1, 0);
1918 proto_tree_add_item (tree, hf_scsi_modesns_tas, tvb, offset+4, 1, 0);
1919 proto_tree_add_text (tree, tvb, offset+4, 1,
1920 "SWP: %u, RAERP: %u, UAAERP: %u, EAERP: %u",
1921 (flags & 0x8) >> 3, (flags & 0x4) >> 2,
1922 (flags & 0x2) >> 2, (flags & 0x1));
1923 proto_tree_add_text (tree, tvb, offset+5, 1, "Autoload Mode: 0x%x",
1924 tvb_get_guint8 (tvb, offset+5) & 0x7);
1925 proto_tree_add_text (tree, tvb, offset+6, 2,
1926 "Ready AER Holdoff Period: %u ms",
1927 tvb_get_ntohs (tvb, offset+6));
1928 proto_tree_add_text (tree, tvb, offset+8, 2,
1929 "Busy Timeout Period: %u ms",
1930 tvb_get_ntohs (tvb, offset+8)*100);
1931 proto_tree_add_text (tree, tvb, offset+10, 2,
1932 "Extended Self-Test Completion Time: %u",
1933 tvb_get_ntohs (tvb, offset+10));
1935 case SCSI_SPC2_MODEPAGE_DISCON:
1936 proto_tree_add_text (tree, tvb, offset+2, 1, "Buffer Full Ratio: %u",
1937 tvb_get_guint8 (tvb, offset+2));
1938 proto_tree_add_text (tree, tvb, offset+3, 1, "Buffer Empty Ratio: %u",
1939 tvb_get_guint8 (tvb, offset+3));
1940 proto_tree_add_text (tree, tvb, offset+4, 2, "Bus Inactivity Limit: %u",
1941 tvb_get_ntohs (tvb, offset+4));
1942 proto_tree_add_text (tree, tvb, offset+6, 2, "Disconnect Time Limit: %u",
1943 tvb_get_ntohs (tvb, offset+6));
1944 proto_tree_add_text (tree, tvb, offset+8, 2, "Connect Time Limit: %u",
1945 tvb_get_ntohs (tvb, offset+8));
1946 proto_tree_add_text (tree, tvb, offset+10, 2,
1947 "Maximum Burst Size: %u bytes",
1948 tvb_get_ntohs (tvb, offset+10)*512);
1949 flags = tvb_get_guint8 (tvb, offset+12);
1950 proto_tree_add_text (tree, tvb, offset+12, 1,
1951 "EMDP: %u, FAA: %u, FAB: %u, FAC: %u",
1952 (flags & 0x80) >> 7, (flags & 0x40) >> 6,
1953 (flags & 0x20) >> 5, (flags & 0x10) >> 4);
1954 proto_tree_add_text (tree, tvb, offset+14, 2,
1955 "First Burst Size: %u bytes",
1956 tvb_get_ntohs (tvb, offset+14)*512);
1958 case SCSI_SPC2_MODEPAGE_INFOEXCP:
1959 flags = tvb_get_guint8 (tvb, offset+2);
1960 proto_tree_add_text (tree, tvb, offset+2, 1,
1961 "Perf: %u, EBF: %u, EWasc: %u, DExcpt: %u, Test: %u, LogErr: %u",
1962 (flags & 0x80) >> 7, (flags & 0x20) >> 5,
1963 (flags & 0x10) >> 4, (flags & 0x08) >> 3,
1964 (flags & 0x04) >> 2, (flags & 0x01));
1965 if (!((flags & 0x10) >> 4) && ((flags & 0x08) >> 3)) {
1966 proto_tree_add_item_hidden (tree, hf_scsi_modesns_errrep, tvb,
1970 proto_tree_add_item (tree, hf_scsi_modesns_errrep, tvb, offset+3, 1, 0);
1972 proto_tree_add_text (tree, tvb, offset+4, 4, "Interval Timer: %u",
1973 tvb_get_ntohl (tvb, offset+4));
1974 proto_tree_add_text (tree, tvb, offset+8, 4, "Report Count: %u",
1975 tvb_get_ntohl (tvb, offset+8));
1977 case SCSI_SPC2_MODEPAGE_PWR:
1978 flags = tvb_get_guint8 (tvb, offset+3);
1979 proto_tree_add_text (tree, tvb, offset+3, 1, "Idle: %u, Standby: %u",
1980 (flags & 0x2) >> 1, (flags & 0x1));
1981 proto_tree_add_text (tree, tvb, offset+4, 2,
1982 "Idle Condition Timer: %u ms",
1983 tvb_get_ntohs (tvb, offset+4) * 100);
1984 proto_tree_add_text (tree, tvb, offset+6, 2,
1985 "Standby Condition Timer: %u ms",
1986 tvb_get_ntohs (tvb, offset+6) * 100);
1988 case SCSI_SPC2_MODEPAGE_LUN:
1990 case SCSI_SPC2_MODEPAGE_PORT:
1991 proto = tvb_get_guint8 (tvb, offset+2) & 0x0F;
1992 proto_tree_add_item (tree, hf_scsi_protocol, tvb, offset+2, 1, 0);
1993 if (proto == SCSI_PROTO_FCP) {
1994 flags = tvb_get_guint8 (tvb, offset+3);
1995 proto_tree_add_text (tree, tvb, offset+3, 1,
1996 "DTFD: %u, PLPB: %u, DDIS: %u, DLM: %u, RHA: %u, ALWI: %u, DTIPE: %u, DTOLI:%u",
1997 (flags & 0x80) >> 7, (flags & 0x40) >> 6,
1998 (flags & 0x20) >> 5, (flags & 0x10) >> 4,
1999 (flags & 0x08) >> 3, (flags & 0x04) >> 2,
2000 (flags & 0x02) >> 1, (flags & 0x1));
2001 proto_tree_add_text (tree, tvb, offset+6, 1, "RR_TOV Units: %s",
2002 val_to_str (tvb_get_guint8 (tvb, offset+6) & 0x7,
2004 "Unknown (0x%02x)"));
2005 proto_tree_add_text (tree, tvb, offset+7, 1, "RR_TOV: %u",
2006 tvb_get_guint8 (tvb, offset+7));
2008 else if (proto == SCSI_PROTO_iSCSI) {
2015 case SCSI_SCSI2_MODEPAGE_PERDEV:
2024 dissect_scsi_sbc2_modepage (tvbuff_t *tvb, packet_info *pinfo _U_,
2025 proto_tree *tree, guint offset, guint8 pcode)
2030 case SCSI_SBC2_MODEPAGE_FMTDEV:
2031 proto_tree_add_text (tree, tvb, offset+2, 2, "Tracks Per Zone: %u",
2032 tvb_get_ntohs (tvb, offset+2));
2033 proto_tree_add_text (tree, tvb, offset+4, 2,
2034 "Alternate Sectors Per Zone: %u",
2035 tvb_get_ntohs (tvb, offset+4));
2036 proto_tree_add_text (tree, tvb, offset+6, 2,
2037 "Alternate Tracks Per Zone: %u",
2038 tvb_get_ntohs (tvb, offset+6));
2039 proto_tree_add_text (tree, tvb, offset+8, 2,
2040 "Alternate Tracks Per LU: %u",
2041 tvb_get_ntohs (tvb, offset+8));
2042 proto_tree_add_text (tree, tvb, offset+10, 2, "Sectors Per Track: %u",
2043 tvb_get_ntohs (tvb, offset+10));
2044 proto_tree_add_text (tree, tvb, offset+12, 2,
2045 "Data Bytes Per Physical Sector: %u",
2046 tvb_get_ntohs (tvb, offset+12));
2047 proto_tree_add_text (tree, tvb, offset+14, 2, "Interleave: %u",
2048 tvb_get_ntohs (tvb, offset+14));
2049 proto_tree_add_text (tree, tvb, offset+16, 2, "Track Skew Factor: %u",
2050 tvb_get_ntohs (tvb, offset+16));
2051 proto_tree_add_text (tree, tvb, offset+18, 2,
2052 "Cylinder Skew Factor: %u",
2053 tvb_get_ntohs (tvb, offset+18));
2054 flags = tvb_get_guint8 (tvb, offset+20);
2055 proto_tree_add_text (tree, tvb, offset+20, 1,
2056 "SSEC: %u, HSEC: %u, RMB: %u, SURF: %u",
2057 (flags & 0x80) >> 7, (flags & 0x40) >> 6,
2058 (flags & 0x20) >> 5, (flags & 0x10) >> 4);
2060 case SCSI_SBC2_MODEPAGE_RDWRERR:
2061 flags = tvb_get_guint8 (tvb, offset+2);
2062 proto_tree_add_text (tree, tvb, offset+2, 1,
2063 "AWRE: %u, ARRE: %u, TB: %u, RC: %u, EER: %u, PER: %u, DTE: %u, DCR: %u",
2064 (flags & 0x80) >> 7, (flags & 0x40) >> 6,
2065 (flags & 0x20) >> 5, (flags & 0x10) >> 4,
2066 (flags & 0x08) >> 3, (flags & 0x04) >> 2,
2067 (flags & 0x02) >> 1, (flags & 0x01));
2068 proto_tree_add_text (tree, tvb, offset+3, 1, "Read Retry Count: %u",
2069 tvb_get_guint8 (tvb, offset+3));
2070 proto_tree_add_text (tree, tvb, offset+4, 1, "Correction Span: %u",
2071 tvb_get_guint8 (tvb, offset+4));
2072 proto_tree_add_text (tree, tvb, offset+5, 1, "Head Offset Count: %u",
2073 tvb_get_guint8 (tvb, offset+5));
2074 proto_tree_add_text (tree, tvb, offset+6, 1,
2075 "Data Strobe Offset Count: %u",
2076 tvb_get_guint8 (tvb, offset+6));
2077 proto_tree_add_text (tree, tvb, offset+8, 1, "Write Retry Count: %u",
2078 tvb_get_guint8 (tvb, offset+8));
2079 proto_tree_add_text (tree, tvb, offset+10, 2,
2080 "Recovery Time Limit: %u ms",
2081 tvb_get_ntohs (tvb, offset+10));
2083 case SCSI_SBC2_MODEPAGE_DISKGEOM:
2084 proto_tree_add_text (tree, tvb, offset+2, 3, "Number of Cylinders: %u",
2085 tvb_get_ntoh24 (tvb, offset+2));
2086 proto_tree_add_text (tree, tvb, offset+5, 1, "Number of Heads: %u",
2087 tvb_get_guint8 (tvb, offset+5));
2088 proto_tree_add_text (tree, tvb, offset+6, 3,
2089 "Starting Cyl Pre-compensation: %u",
2090 tvb_get_ntoh24 (tvb, offset+6));
2091 proto_tree_add_text (tree, tvb, offset+9, 3,
2092 "Starting Cyl-reduced Write Current: %u",
2093 tvb_get_ntoh24 (tvb, offset+9));
2094 proto_tree_add_text (tree, tvb, offset+12, 2, "Device Step Rate: %u",
2095 tvb_get_ntohs (tvb, offset+12));
2096 proto_tree_add_text (tree, tvb, offset+14, 3, "Landing Zone Cyl: %u",
2097 tvb_get_ntoh24 (tvb, offset+14));
2098 proto_tree_add_text (tree, tvb, offset+18, 1, "Rotational Offset: %u",
2099 tvb_get_guint8 (tvb, offset+18));
2100 proto_tree_add_text (tree, tvb, offset+20, 2,
2101 "Medium Rotation Rate: %u",
2102 tvb_get_ntohs (tvb, offset+20));
2104 case SCSI_SBC2_MODEPAGE_FLEXDISK:
2106 case SCSI_SBC2_MODEPAGE_VERERR:
2108 case SCSI_SBC2_MODEPAGE_CACHE:
2109 flags = tvb_get_guint8 (tvb, offset+2);
2110 proto_tree_add_text (tree, tvb, offset+2, 1,
2111 "IC: %u, ABPF: %u, CAP %u, Disc: %u, Size: %u, WCE: %u, MF: %u, RCD: %u",
2112 (flags & 0x80) >> 7, (flags & 0x40) >> 6,
2113 (flags & 0x20) >> 5, (flags & 0x10) >> 4,
2114 (flags & 0x08) >> 3, (flags & 0x04) >> 2,
2115 (flags & 0x02) >> 1, (flags & 0x01));
2116 flags = tvb_get_guint8 (tvb, offset+3);
2117 proto_tree_add_text (tree, tvb, offset+3, 1,
2118 "Demand Read Retention Priority: %u, Write Retention Priority: %u",
2119 (flags & 0xF0) >> 4, (flags & 0x0F));
2120 proto_tree_add_text (tree, tvb, offset+4, 2,
2121 "Disable Pre-fetch Xfer Len: %u",
2122 tvb_get_ntohs (tvb, offset+4));
2123 proto_tree_add_text (tree, tvb, offset+6, 2, "Minimum Pre-Fetch: %u",
2124 tvb_get_ntohs (tvb, offset+6));
2125 proto_tree_add_text (tree, tvb, offset+8, 2, "Maximum Pre-Fetch: %u",
2126 tvb_get_ntohs (tvb, offset+8));
2127 proto_tree_add_text (tree, tvb, offset+10, 2,
2128 "Maximum Pre-Fetch Ceiling: %u",
2129 tvb_get_ntohs (tvb, offset+10));
2130 flags = tvb_get_guint8 (tvb, offset+12);
2131 proto_tree_add_text (tree, tvb, offset+12, 1,
2132 "FSW: %u, LBCSS: %u, DRA: %u, Vendor Specific: %u",
2133 (flags & 0x80) >> 7, (flags & 0x40) >> 6,
2134 (flags & 0x20) >> 5, (flags & 0x1F) >> 4);
2135 proto_tree_add_text (tree, tvb, offset+13, 1,
2136 "Number of Cache Segments: %u",
2137 tvb_get_guint8 (tvb, offset+13));
2138 proto_tree_add_text (tree, tvb, offset+14, 2, "Cache Segment Size: %u",
2139 tvb_get_ntohs (tvb, offset+14));
2140 proto_tree_add_text (tree, tvb, offset+17, 3,
2141 "Non-Cache Segment Size: %u",
2142 tvb_get_ntoh24 (tvb, offset+17));
2144 case SCSI_SBC2_MODEPAGE_MEDTYPE:
2146 case SCSI_SBC2_MODEPAGE_NOTPART:
2148 case SCSI_SBC2_MODEPAGE_XORCTL:
2156 static const value_string compression_algorithm_vals[] = {
2157 {0x00, "No algorithm selected"},
2158 {0x01, "Default algorithm"},
2159 {0x03, "IBM ALDC with 512-byte buffer"},
2160 {0x04, "IBM ALDC with 1024-byte buffer"},
2161 {0x05, "IBM ALDC with 2048-byte buffer"},
2164 {0xFF, "Unregistered algorithm"},
2169 dissect_scsi_ssc2_modepage (tvbuff_t *tvb _U_, packet_info *pinfo _U_,
2170 proto_tree *tree _U_, guint offset _U_,
2176 case SCSI_SSC2_MODEPAGE_DATACOMP:
2177 flags = tvb_get_guint8 (tvb, offset+2);
2178 proto_tree_add_text (tree, tvb, offset+2, 1,
2180 (flags & 0x80) >> 7, (flags & 0x40) >> 6);
2181 flags = tvb_get_guint8 (tvb, offset+3);
2182 proto_tree_add_text (tree, tvb, offset+3, 1,
2184 (flags & 0x80) >> 7, (flags & 0x60) >> 5);
2185 proto_tree_add_text (tree, tvb, offset+4, 4,
2186 "Compression algorithm: %s",
2187 val_to_str (tvb_get_ntohl (tvb, offset+4),
2188 compression_algorithm_vals,
2189 "Unknown (0x%08x)"));
2190 proto_tree_add_text (tree, tvb, offset+8, 4,
2191 "Decompression algorithm: %s",
2192 val_to_str (tvb_get_ntohl (tvb, offset+4),
2193 compression_algorithm_vals,
2194 "Unknown (0x%08x)"));
2196 case SCSI_SSC2_MODEPAGE_DEVCONF:
2198 case SCSI_SSC2_MODEPAGE_MEDPAR1:
2200 case SCSI_SSC2_MODEPAGE_MEDPAR2:
2202 case SCSI_SSC2_MODEPAGE_MEDPAR3:
2204 case SCSI_SSC2_MODEPAGE_MEDPAR4:
2213 dissect_scsi_smc2_modepage (tvbuff_t *tvb, packet_info *pinfo _U_,
2214 proto_tree *tree, guint offset, guint8 pcode)
2217 guint8 param_list_len;
2220 case SCSI_SMC2_MODEPAGE_EAA:
2221 param_list_len = tvb_get_guint8 (tvb, offset+2);
2222 proto_tree_add_text (tree, tvb, offset+2, 1, "Parameter List Length: %u",
2224 if (param_list_len < 2)
2226 proto_tree_add_text (tree, tvb, offset+3, 2, "First Medium Transport Element Address: %u",
2227 tvb_get_ntohs (tvb, offset+3));
2228 param_list_len -= 2;
2229 if (param_list_len < 2)
2231 proto_tree_add_text (tree, tvb, offset+5, 2, "Number of Medium Transport Elements: %u",
2232 tvb_get_ntohs (tvb, offset+5));
2233 param_list_len -= 2;
2234 if (param_list_len < 2)
2236 proto_tree_add_text (tree, tvb, offset+7, 2, "First Storage Element Address: %u",
2237 tvb_get_ntohs (tvb, offset+7));
2238 param_list_len -= 2;
2239 if (param_list_len < 2)
2241 proto_tree_add_text (tree, tvb, offset+9, 2, "Number of Storage Elements: %u",
2242 tvb_get_ntohs (tvb, offset+9));
2243 param_list_len -= 2;
2244 if (param_list_len < 2)
2246 proto_tree_add_text (tree, tvb, offset+11, 2, "First Import/Export Element Address: %u",
2247 tvb_get_ntohs (tvb, offset+11));
2248 param_list_len -= 2;
2249 if (param_list_len < 2)
2251 proto_tree_add_text (tree, tvb, offset+13, 2, "Number of Import/Export Elements: %u",
2252 tvb_get_ntohs (tvb, offset+13));
2253 param_list_len -= 2;
2254 if (param_list_len < 2)
2256 proto_tree_add_text (tree, tvb, offset+15, 2, "First Data Transfer Element Address: %u",
2257 tvb_get_ntohs (tvb, offset+15));
2258 param_list_len -= 2;
2259 if (param_list_len < 2)
2261 proto_tree_add_text (tree, tvb, offset+17, 2, "Number of Data Transfer Elements: %u",
2262 tvb_get_ntohs (tvb, offset+17));
2264 case SCSI_SMC2_MODEPAGE_TRANGEOM:
2266 case SCSI_SMC2_MODEPAGE_DEVCAP:
2267 flags = tvb_get_guint8 (tvb, offset+2);
2268 proto_tree_add_text (tree, tvb, offset+2, 1,
2269 "STORDT: %u, STORI/E: %u, STORST: %u, STORMT: %u",
2270 (flags & 0x08) >> 3, (flags & 0x04) >> 2,
2271 (flags & 0x02) >> 1, (flags & 0x01));
2272 flags = tvb_get_guint8 (tvb, offset+4);
2273 proto_tree_add_text (tree, tvb, offset+4, 1,
2274 "MT->DT: %u, MT->I/E: %u, MT->ST: %u, MT->MT: %u",
2275 (flags & 0x08) >> 3, (flags & 0x04) >> 2,
2276 (flags & 0x02) >> 1, (flags & 0x01));
2277 flags = tvb_get_guint8 (tvb, offset+5);
2278 proto_tree_add_text (tree, tvb, offset+5, 1,
2279 "ST->DT: %u, ST->I/E: %u, ST->ST: %u, ST->MT: %u",
2280 (flags & 0x08) >> 3, (flags & 0x04) >> 2,
2281 (flags & 0x02) >> 1, (flags & 0x01));
2282 flags = tvb_get_guint8 (tvb, offset+6);
2283 proto_tree_add_text (tree, tvb, offset+6, 1,
2284 "I/E->DT: %u, I/E->I/E: %u, I/E->ST: %u, I/E->MT: %u",
2285 (flags & 0x08) >> 3, (flags & 0x04) >> 2,
2286 (flags & 0x02) >> 1, (flags & 0x01));
2287 flags = tvb_get_guint8 (tvb, offset+7);
2288 proto_tree_add_text (tree, tvb, offset+7, 1,
2289 "DT->DT: %u, DT->I/E: %u, DT->ST: %u, DT->MT: %u",
2290 (flags & 0x08) >> 3, (flags & 0x04) >> 2,
2291 (flags & 0x02) >> 1, (flags & 0x01));
2292 flags = tvb_get_guint8 (tvb, offset+12);
2293 proto_tree_add_text (tree, tvb, offset+12, 1,
2294 "MT<>DT: %u, MT<>I/E: %u, MT<>ST: %u, MT<>MT: %u",
2295 (flags & 0x08) >> 3, (flags & 0x04) >> 2,
2296 (flags & 0x02) >> 1, (flags & 0x01));
2297 flags = tvb_get_guint8 (tvb, offset+13);
2298 proto_tree_add_text (tree, tvb, offset+13, 1,
2299 "ST<>DT: %u, ST<>I/E: %u, ST<>ST: %u, ST<>MT: %u",
2300 (flags & 0x08) >> 3, (flags & 0x04) >> 2,
2301 (flags & 0x02) >> 1, (flags & 0x01));
2302 flags = tvb_get_guint8 (tvb, offset+14);
2303 proto_tree_add_text (tree, tvb, offset+14, 1,
2304 "I/E<>DT: %u, I/E<>I/E: %u, I/E<>ST: %u, I/E<>MT: %u",
2305 (flags & 0x08) >> 3, (flags & 0x04) >> 2,
2306 (flags & 0x02) >> 1, (flags & 0x01));
2307 flags = tvb_get_guint8 (tvb, offset+15);
2308 proto_tree_add_text (tree, tvb, offset+15, 1,
2309 "DT<>DT: %u, DT<>I/E: %u, DT<>ST: %u, DT<>MT: %u",
2310 (flags & 0x08) >> 3, (flags & 0x04) >> 2,
2311 (flags & 0x02) >> 1, (flags & 0x01));
2320 dissect_scsi_modepage (tvbuff_t *tvb, packet_info *pinfo,
2321 proto_tree *scsi_tree, guint offset,
2322 scsi_device_type devtype)
2327 const value_string *modepage_val;
2329 gboolean (*dissect_modepage)(tvbuff_t *, packet_info *, proto_tree *,
2332 pcode = tvb_get_guint8 (tvb, offset);
2333 plen = tvb_get_guint8 (tvb, offset+1);
2335 if (match_strval (pcode & SCSI_MS_PCODE_BITS,
2336 scsi_spc2_modepage_val) == NULL) {
2338 * This isn't a generic mode page that applies to all SCSI
2339 * device types; try to interpret it based on what we deduced,
2340 * or were told, the device type is.
2344 modepage_val = scsi_sbc2_modepage_val;
2345 hf_pagecode = hf_scsi_sbcpagecode;
2346 dissect_modepage = dissect_scsi_sbc2_modepage;
2350 modepage_val = scsi_ssc2_modepage_val;
2351 hf_pagecode = hf_scsi_sscpagecode;
2352 dissect_modepage = dissect_scsi_ssc2_modepage;
2356 modepage_val = scsi_smc2_modepage_val;
2357 hf_pagecode = hf_scsi_smcpagecode;
2358 dissect_modepage = dissect_scsi_smc2_modepage;
2363 * The "val_to_str()" lookup will fail in this table
2364 * (it failed in "match_strval()"), so it'll return
2365 * "Unknown (XXX)", which is what we want.
2367 modepage_val = scsi_spc2_modepage_val;
2368 hf_pagecode = hf_scsi_spcpagecode;
2369 dissect_modepage = dissect_scsi_spc2_modepage;
2373 modepage_val = scsi_spc2_modepage_val;
2374 hf_pagecode = hf_scsi_spcpagecode;
2375 dissect_modepage = dissect_scsi_spc2_modepage;
2377 ti = proto_tree_add_text (scsi_tree, tvb, offset, plen+2, "%s Mode Page",
2378 val_to_str (pcode & SCSI_MS_PCODE_BITS,
2379 modepage_val, "Unknown (0x%08x)"));
2380 tree = proto_item_add_subtree (ti, ett_scsi_page);
2381 proto_tree_add_text (tree, tvb, offset, 1, "PS: %u", (pcode & 0x80) >> 7);
2383 proto_tree_add_item (tree, hf_pagecode, tvb, offset, 1, 0);
2384 proto_tree_add_text (tree, tvb, offset+1, 1, "Page Length: %u",
2387 if (!tvb_bytes_exist (tvb, offset, plen)) {
2388 /* XXX - why not just drive on and throw an exception? */
2392 if (!(*dissect_modepage)(tvb, pinfo, tree, offset,
2393 pcode & SCSI_MS_PCODE_BITS)) {
2394 proto_tree_add_text (tree, tvb, offset+2, plen,
2401 dissect_scsi_modeselect6 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
2402 guint offset, gboolean isreq, gboolean iscdb,
2403 scsi_device_type devtype, guint payload_len)
2406 guint tot_len, desclen, plen;
2411 if (isreq && iscdb) {
2412 flags = tvb_get_guint8 (tvb, offset);
2414 proto_tree_add_uint_format (tree, hf_scsi_modesel_flags, tvb, offset, 1,
2415 flags, "PF = %u, SP = %u", flags & 0x10,
2417 proto_tree_add_item (tree, hf_scsi_paramlen, tvb, offset+3, 1, 0);
2419 flags = tvb_get_guint8 (tvb, offset+4);
2420 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
2422 "Vendor Unique = %u, NACA = %u, Link = %u",
2423 flags & 0xC0, flags & 0x4, flags & 0x1);
2426 /* Mode Parameter has the following format:
2427 * Mode Parameter Header
2428 * - Mode Data Len, Medium Type, Dev Specific Parameter,
2430 * Block Descriptor (s)
2431 * - Number of blocks, density code, block length
2433 * - Page code, Page length, Page Parameters
2435 if (payload_len < 1)
2437 tot_len = tvb_get_guint8 (tvb, offset);
2438 proto_tree_add_text (tree, tvb, offset, 1, "Mode Data Length: %u",
2442 /* The mode data length is reserved for MODE SELECT, so we just
2443 use the payload length. */
2445 if (payload_len < 1)
2450 proto_tree_add_text (tree, tvb, offset, 1, "Medium Type: %s",
2451 val_to_str(tvb_get_guint8 (tvb, offset),
2452 scsi_modesense_medtype_sbc_val,
2453 "Unknown (0x%02x)"));
2457 proto_tree_add_text (tree, tvb, offset, 1, "Medium Type: 0x%02x",
2458 tvb_get_guint8 (tvb, offset));
2464 if (payload_len < 1)
2466 proto_tree_add_text (tree, tvb, offset, 1,
2467 "Device-Specific Parameter: 0x%02x",
2468 tvb_get_guint8 (tvb, offset));
2472 if (payload_len < 1)
2474 desclen = tvb_get_guint8 (tvb, offset);
2475 proto_tree_add_text (tree, tvb, offset, 1,
2476 "Block Descriptor Length: %u", desclen);
2480 if (!dissect_scsi_blockdescs (tvb, pinfo, tree, offset, payload_len,
2481 desclen, devtype, FALSE))
2484 payload_len -= desclen;
2486 /* offset points to the start of the mode page */
2487 while ((payload_len > 0) && tvb_bytes_exist (tvb, offset, 2)) {
2488 plen = dissect_scsi_modepage (tvb, pinfo, tree, offset, devtype);
2490 payload_len -= plen;
2496 dissect_scsi_modeselect10 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
2497 guint offset, gboolean isreq, gboolean iscdb,
2498 scsi_device_type devtype, guint payload_len)
2502 guint tot_len, desclen, plen;
2507 if (isreq && iscdb) {
2508 flags = tvb_get_guint8 (tvb, offset);
2510 proto_tree_add_uint_format (tree, hf_scsi_modesel_flags, tvb, offset, 1,
2511 flags, "PF = %u, SP = %u", flags & 0x10,
2513 proto_tree_add_item (tree, hf_scsi_paramlen16, tvb, offset+6, 2, 0);
2515 flags = tvb_get_guint8 (tvb, offset+8);
2516 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1,
2518 "Vendor Unique = %u, NACA = %u, Link = %u",
2519 flags & 0xC0, flags & 0x4, flags & 0x1);
2522 /* Mode Parameter has the following format:
2523 * Mode Parameter Header
2524 * - Mode Data Len, Medium Type, Dev Specific Parameter,
2526 * Block Descriptor (s)
2527 * - Number of blocks, density code, block length
2529 * - Page code, Page length, Page Parameters
2531 if (payload_len < 1)
2533 tot_len = tvb_get_ntohs (tvb, offset);
2534 proto_tree_add_text (tree, tvb, offset, 2, "Mode Data Length: %u",
2538 /* The mode data length is reserved for MODE SELECT, so we just
2539 use the payload length. */
2541 if (payload_len < 1)
2546 proto_tree_add_text (tree, tvb, offset, 1, "Medium Type: %s",
2547 val_to_str(tvb_get_guint8 (tvb, offset),
2548 scsi_modesense_medtype_sbc_val,
2549 "Unknown (0x%02x)"));
2553 proto_tree_add_text (tree, tvb, offset, 1, "Medium Type: 0x%02x",
2554 tvb_get_guint8 (tvb, offset));
2560 if (payload_len < 1)
2562 proto_tree_add_text (tree, tvb, offset, 1,
2563 "Device-Specific Parameter: 0x%02x",
2564 tvb_get_guint8 (tvb, offset));
2568 if (payload_len < 1)
2570 longlba = tvb_get_guint8 (tvb, offset) & 0x1;
2571 proto_tree_add_text (tree, tvb, offset, 1, "LongLBA: %u", longlba);
2572 offset += 2; /* skip LongLBA byte and reserved byte */
2575 if (payload_len < 1)
2577 desclen = tvb_get_guint8 (tvb, offset);
2578 proto_tree_add_text (tree, tvb, offset, 1,
2579 "Block Descriptor Length: %u", desclen);
2583 if (!dissect_scsi_blockdescs (tvb, pinfo, tree, offset, payload_len,
2584 desclen, devtype, longlba))
2587 payload_len -= desclen;
2589 /* offset points to the start of the mode page */
2590 while ((payload_len > 0) && tvb_bytes_exist (tvb, offset, 2)) {
2591 plen = dissect_scsi_modepage (tvb, pinfo, tree, offset, devtype);
2593 payload_len -= plen;
2599 dissect_scsi_pagecode (tvbuff_t *tvb, packet_info *pinfo _U_,
2600 proto_tree *tree, guint offset,
2601 scsi_device_type devtype)
2607 pcode = tvb_get_guint8 (tvb, offset);
2608 if ((valstr = match_strval (pcode & SCSI_MS_PCODE_BITS,
2609 scsi_spc2_modepage_val)) == NULL) {
2611 * This isn't a generic mode page that applies to all SCSI
2612 * device types; try to interpret it based on what we deduced,
2613 * or were told, the device type is.
2617 hf_pagecode = hf_scsi_sbcpagecode;
2621 hf_pagecode = hf_scsi_sscpagecode;
2625 hf_pagecode = hf_scsi_smcpagecode;
2629 hf_pagecode = hf_scsi_spcpagecode;
2633 hf_pagecode = hf_scsi_spcpagecode;
2635 proto_tree_add_uint (tree, hf_pagecode, tvb, offset, 1, pcode);
2639 dissect_scsi_modesense6 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
2640 guint offset, gboolean isreq, gboolean iscdb,
2641 scsi_device_type devtype, guint payload_len)
2644 guint tot_len, desclen, plen;
2649 if (isreq && iscdb) {
2650 flags = tvb_get_guint8 (tvb, offset);
2652 proto_tree_add_uint_format (tree, hf_scsi_modesns_flags, tvb, offset, 1,
2653 flags, "DBD = %u", flags & 0x8);
2654 proto_tree_add_item (tree, hf_scsi_modesns_pc, tvb, offset+1, 1, 0);
2655 dissect_scsi_pagecode (tvb, pinfo, tree, offset+1, devtype);
2656 proto_tree_add_item (tree, hf_scsi_alloclen, tvb, offset+3, 1, 0);
2658 flags = tvb_get_guint8 (tvb, offset+4);
2659 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
2661 "Vendor Unique = %u, NACA = %u, Link = %u",
2662 flags & 0xC0, flags & 0x4, flags & 0x1);
2665 /* Mode sense response has the following format:
2666 * Mode Parameter Header
2667 * - Mode Data Len, Medium Type, Dev Specific Parameter,
2669 * Block Descriptor (s)
2670 * - Number of blocks, density code, block length
2672 * - Page code, Page length, Page Parameters
2674 tot_len = tvb_get_guint8 (tvb, offset);
2675 proto_tree_add_text (tree, tvb, offset, 1, "Mode Data Length: %u",
2679 /* The actual payload is the min of the length in the response & the
2680 * space allocated by the initiator as specified in the request.
2682 * XXX - the payload length includes the length field, so we
2683 * really should subtract the length of the length field from
2684 * the payload length - but can it really be zero here?
2686 if (payload_len && (tot_len > payload_len))
2687 tot_len = payload_len;
2691 proto_tree_add_text (tree, tvb, offset, 1, "Medium Type: 0x%02x",
2692 tvb_get_guint8 (tvb, offset));
2698 proto_tree_add_text (tree, tvb, offset, 1,
2699 "Device-Specific Parameter: 0x%02x",
2700 tvb_get_guint8 (tvb, offset));
2706 desclen = tvb_get_guint8 (tvb, offset);
2707 proto_tree_add_text (tree, tvb, offset, 1,
2708 "Block Descriptor Length: %u", desclen);
2712 if (!dissect_scsi_blockdescs (tvb, pinfo, tree, offset, tot_len,
2713 desclen, devtype, FALSE))
2718 /* offset points to the start of the mode page */
2719 while ((tot_len > 0) && tvb_bytes_exist (tvb, offset, 2)) {
2720 plen = dissect_scsi_modepage (tvb, pinfo, tree, offset, devtype);
2728 dissect_scsi_modesense10 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
2729 guint offset, gboolean isreq, gboolean iscdb,
2730 scsi_device_type devtype, guint payload_len)
2734 guint tot_len, desclen, plen;
2739 if (isreq && iscdb) {
2740 flags = tvb_get_guint8 (tvb, offset);
2742 proto_tree_add_uint_format (tree, hf_scsi_modesns_flags, tvb, offset, 1,
2743 flags, "LLBAA = %u, DBD = %u", flags & 0x10,
2745 proto_tree_add_item (tree, hf_scsi_modesns_pc, tvb, offset+1, 1, 0);
2746 dissect_scsi_pagecode (tvb, pinfo, tree, offset+1, devtype);
2747 proto_tree_add_item (tree, hf_scsi_alloclen16, tvb, offset+6, 2, 0);
2749 flags = tvb_get_guint8 (tvb, offset+8);
2750 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1,
2752 "Vendor Unique = %u, NACA = %u, Link = %u",
2753 flags & 0xC0, flags & 0x4, flags & 0x1);
2756 /* Mode sense response has the following format:
2757 * Mode Parameter Header
2758 * - Mode Data Len, Medium Type, Dev Specific Parameter,
2760 * Block Descriptor (s)
2761 * - Number of blocks, density code, block length
2763 * - Page code, Page length, Page Parameters
2765 tot_len = tvb_get_ntohs (tvb, offset);
2766 proto_tree_add_text (tree, tvb, offset, 2, "Mode Data Length: %u",
2769 /* The actual payload is the min of the length in the response & the
2770 * space allocated by the initiator as specified in the request.
2772 * XXX - the payload length includes the length field, so we
2773 * really should subtract the length of the length field from
2774 * the payload length - but can it really be zero here?
2776 if (payload_len && (tot_len > payload_len))
2777 tot_len = payload_len;
2781 proto_tree_add_text (tree, tvb, offset, 1, "Medium Type: 0x%02x",
2782 tvb_get_guint8 (tvb, offset));
2788 proto_tree_add_text (tree, tvb, offset, 1,
2789 "Device-Specific Parameter: 0x%02x",
2790 tvb_get_guint8 (tvb, offset));
2796 longlba = tvb_get_guint8 (tvb, offset) & 0x1;
2797 proto_tree_add_text (tree, tvb, offset, 1, "LongLBA: %u", longlba);
2798 offset += 2; /* skip LongLBA byte and reserved byte */
2803 desclen = tvb_get_guint8 (tvb, offset);
2804 proto_tree_add_text (tree, tvb, offset, 1,
2805 "Block Descriptor Length: %u", desclen);
2809 if (!dissect_scsi_blockdescs (tvb, pinfo, tree, offset, tot_len,
2810 desclen, devtype, longlba))
2815 /* offset points to the start of the mode page */
2816 while ((tot_len > 0) && tvb_bytes_exist (tvb, offset, 2)) {
2817 plen = dissect_scsi_modepage (tvb, pinfo, tree, offset, devtype);
2825 dissect_scsi_persresvin (tvbuff_t *tvb, packet_info *pinfo _U_,
2826 proto_tree *tree, guint offset, gboolean isreq,
2827 gboolean iscdb, scsi_task_data_t *cdata,
2837 if (isreq && iscdb) {
2838 proto_tree_add_item (tree, hf_scsi_persresvin_svcaction, tvb, offset+1,
2840 proto_tree_add_item (tree, hf_scsi_alloclen16, tvb, offset+6, 2, 0);
2842 flags = tvb_get_guint8 (tvb, offset+8);
2843 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1,
2845 "Vendor Unique = %u, NACA = %u, Link = %u",
2846 flags & 0xC0, flags & 0x4, flags & 0x1);
2847 /* We store the service action since we want to interpret the data */
2848 cdata->flags = tvb_get_guint8 (tvb, offset+1);
2852 flags = cdata->flags;
2857 proto_tree_add_text (tree, tvb, offset, 4, "Generation Number: 0x%08x",
2858 tvb_get_ntohl (tvb, offset));
2859 len = tvb_get_ntohl (tvb, offset+4);
2860 proto_tree_add_text (tree, tvb, offset, 4, "Additional Length: %u",
2862 len = (payload_len > len) ? len : payload_len;
2864 if ((flags & 0x1F) == SCSI_SPC2_RESVIN_SVCA_RDKEYS) {
2865 /* XXX - what if len is < 8? That may be illegal, but
2866 that doesn't make it impossible.... */
2867 numrec = (len - 8)/8;
2870 for (i = 0; i < numrec; i++) {
2871 proto_tree_add_item (tree, hf_scsi_persresv_key, tvb, offset,
2876 else if ((flags & 0x1F) == SCSI_SPC2_RESVIN_SVCA_RDRESV) {
2877 proto_tree_add_item (tree, hf_scsi_persresv_key, tvb, offset+8,
2879 proto_tree_add_item (tree, hf_scsi_persresv_scopeaddr, tvb,
2881 proto_tree_add_item (tree, hf_scsi_persresv_scope, tvb, offset+13,
2883 proto_tree_add_item (tree, hf_scsi_persresv_type, tvb, offset+13,
2890 dissect_scsi_persresvout (tvbuff_t *tvb, packet_info *pinfo _U_,
2891 proto_tree *tree, guint offset, gboolean isreq,
2892 gboolean iscdb, scsi_task_data_t *cdata _U_,
2893 guint payload_len _U_)
2900 if (isreq && iscdb) {
2901 proto_tree_add_item (tree, hf_scsi_persresvin_svcaction, tvb, offset,
2903 proto_tree_add_item (tree, hf_scsi_persresv_scope, tvb, offset+1, 1, 0);
2904 proto_tree_add_item (tree, hf_scsi_persresv_type, tvb, offset+1, 1, 0);
2905 proto_tree_add_item (tree, hf_scsi_paramlen16, tvb, offset+6, 2, 0);
2907 flags = tvb_get_guint8 (tvb, offset+8);
2908 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1,
2910 "Vendor Unique = %u, NACA = %u, Link = %u",
2911 flags & 0xC0, flags & 0x4, flags & 0x1);
2918 dissect_scsi_release6 (tvbuff_t *tvb, packet_info *pinfo _U_,
2919 proto_tree *tree, guint offset, gboolean isreq,
2927 if (isreq && iscdb) {
2928 flags = tvb_get_guint8 (tvb, offset+4);
2929 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
2931 "Vendor Unique = %u, NACA = %u, Link = %u",
2932 flags & 0xC0, flags & 0x4, flags & 0x1);
2937 dissect_scsi_release10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
2938 guint offset, gboolean isreq, gboolean iscdb)
2945 if (isreq && iscdb) {
2946 flags = tvb_get_guint8 (tvb, offset);
2948 proto_tree_add_uint_format (tree, hf_scsi_release_flags, tvb, offset, 1,
2950 "Flags: 3rd Party ID = %u, LongID = %u",
2951 flags & 0x10, flags & 0x2);
2952 if ((flags & 0x12) == 0x10) {
2953 proto_tree_add_item (tree, hf_scsi_release_thirdpartyid, tvb,
2956 proto_tree_add_item (tree, hf_scsi_paramlen16, tvb, offset+6, 2, 0);
2958 flags = tvb_get_guint8 (tvb, offset+8);
2959 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1,
2961 "Vendor Unique = %u, NACA = %u, Link = %u",
2962 flags & 0xC0, flags & 0x4, flags & 0x1);
2967 dissect_scsi_reportdeviceid (tvbuff_t *tvb _U_, packet_info *pinfo _U_,
2968 proto_tree *tree _U_, guint offset _U_,
2969 gboolean isreq _U_, gboolean iscdb _U_)
2975 dissect_scsi_reportluns (tvbuff_t *tvb, packet_info *pinfo _U_,
2976 proto_tree *tree, guint offset, gboolean isreq,
2977 gboolean iscdb, guint payload_len)
2985 if (isreq && iscdb) {
2986 proto_tree_add_item (tree, hf_scsi_alloclen32, tvb, offset+5, 4, 0);
2988 flags = tvb_get_guint8 (tvb, offset+10);
2989 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+10, 1,
2991 "Vendor Unique = %u, NACA = %u, Link = %u",
2992 flags & 0xC0, flags & 0x4, flags & 0x1);
2995 listlen = tvb_get_ntohl (tvb, offset);
2996 proto_tree_add_text (tree, tvb, offset, 4, "LUN List Length: %u",
3000 if (payload_len != 0) {
3001 listlen = (listlen < payload_len) ? listlen : payload_len;
3004 for (i = 0; i < listlen/8; i++) {
3005 if (!tvb_get_guint8 (tvb, offset))
3006 proto_tree_add_item (tree, hf_scsi_rluns_lun, tvb, offset+1, 1,
3009 proto_tree_add_item (tree, hf_scsi_rluns_multilun, tvb, offset,
3017 dissect_scsi_reqsense (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
3018 guint offset, gboolean isreq, gboolean iscdb)
3025 if (isreq && iscdb) {
3026 proto_tree_add_item (tree, hf_scsi_alloclen, tvb, offset+3, 1, 0);
3028 flags = tvb_get_guint8 (tvb, offset+4);
3029 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
3031 "Vendor Unique = %u, NACA = %u, Link = %u",
3032 flags & 0xC0, flags & 0x4, flags & 0x1);
3037 dissect_scsi_reserve6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
3038 guint offset, gboolean isreq, gboolean iscdb)
3045 if (isreq && iscdb) {
3046 flags = tvb_get_guint8 (tvb, offset+4);
3047 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
3049 "Vendor Unique = %u, NACA = %u, Link = %u",
3050 flags & 0xC0, flags & 0x4, flags & 0x1);
3055 dissect_scsi_reserve10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
3056 guint offset, gboolean isreq, gboolean iscdb)
3063 if (isreq && iscdb) {
3064 flags = tvb_get_guint8 (tvb, offset);
3066 proto_tree_add_uint_format (tree, hf_scsi_release_flags, tvb, offset, 1,
3068 "Flags: 3rd Party ID = %u, LongID = %u",
3069 flags & 0x10, flags & 0x2);
3070 if ((flags & 0x12) == 0x10) {
3071 proto_tree_add_item (tree, hf_scsi_release_thirdpartyid, tvb,
3074 proto_tree_add_item (tree, hf_scsi_paramlen16, tvb, offset+6, 2, 0);
3076 flags = tvb_get_guint8 (tvb, offset+8);
3077 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1,
3079 "Vendor Unique = %u, NACA = %u, Link = %u",
3080 flags & 0xC0, flags & 0x4, flags & 0x1);
3085 dissect_scsi_testunitrdy (tvbuff_t *tvb, packet_info *pinfo _U_,
3086 proto_tree *tree, guint offset, gboolean isreq,
3094 if (isreq && iscdb) {
3095 flags = tvb_get_guint8 (tvb, offset+4);
3096 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
3098 "Vendor Unique = %u, NACA = %u, Link = %u",
3099 flags & 0xC0, flags & 0x4, flags & 0x1);
3104 dissect_scsi_formatunit (tvbuff_t *tvb, packet_info *pinfo _U_,
3105 proto_tree *tree, guint offset, gboolean isreq,
3113 if (isreq && iscdb) {
3114 flags = tvb_get_guint8 (tvb, offset);
3115 proto_tree_add_uint_format (tree, hf_scsi_formatunit_flags, tvb, offset,
3117 "Flags: Longlist = %u, FMTDATA = %u, CMPLIST = %u",
3118 flags & 0x20, flags & 0x8, flags & 0x4);
3119 proto_tree_add_item (tree, hf_scsi_cdb_defectfmt, tvb, offset, 1, 0);
3120 proto_tree_add_item (tree, hf_scsi_formatunit_vendor, tvb, offset+1,
3122 proto_tree_add_item (tree, hf_scsi_formatunit_interleave, tvb, offset+2,
3124 flags = tvb_get_guint8 (tvb, offset+4);
3125 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
3127 "Vendor Unique = %u, NACA = %u, Link = %u",
3128 flags & 0xC0, flags & 0x4, flags & 0x1);
3133 dissect_scsi_sbc2_rdwr6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
3134 guint offset, gboolean isreq, gboolean iscdb)
3139 if (check_col (pinfo->cinfo, COL_INFO))
3140 col_append_fstr (pinfo->cinfo, COL_INFO, "(LBA: 0x%06x, Len: %u)",
3141 tvb_get_ntoh24 (tvb, offset),
3142 tvb_get_guint8 (tvb, offset+3));
3145 if (tree && isreq && iscdb) {
3146 proto_tree_add_item (tree, hf_scsi_rdwr6_lba, tvb, offset, 3, 0);
3147 proto_tree_add_item (tree, hf_scsi_rdwr6_xferlen, tvb, offset+3, 1, 0);
3148 flags = tvb_get_guint8 (tvb, offset+4);
3149 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
3151 "Vendor Unique = %u, NACA = %u, Link = %u",
3152 flags & 0xC0, flags & 0x4, flags & 0x1);
3157 dissect_scsi_rdwr10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
3158 guint offset, gboolean isreq, gboolean iscdb)
3163 if (check_col (pinfo->cinfo, COL_INFO))
3164 col_append_fstr (pinfo->cinfo, COL_INFO, "(LBA: 0x%08x, Len: %u)",
3165 tvb_get_ntohl (tvb, offset+1),
3166 tvb_get_ntohs (tvb, offset+6));
3169 if (tree && isreq && iscdb) {
3170 flags = tvb_get_guint8 (tvb, offset);
3172 proto_tree_add_uint_format (tree, hf_scsi_read_flags, tvb, offset, 1,
3174 "DPO = %u, FUA = %u, RelAddr = %u",
3175 flags & 0x10, flags & 0x8, flags & 0x1);
3176 proto_tree_add_item (tree, hf_scsi_rdwr10_lba, tvb, offset+1, 4, 0);
3177 proto_tree_add_item (tree, hf_scsi_rdwr10_xferlen, tvb, offset+6, 2, 0);
3178 flags = tvb_get_guint8 (tvb, offset+8);
3179 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1,
3181 "Vendor Unique = %u, NACA = %u, Link = %u",
3182 flags & 0xC0, flags & 0x4, flags & 0x1);
3187 dissect_scsi_rdwr12 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
3188 guint offset, gboolean isreq, gboolean iscdb)
3193 if (check_col (pinfo->cinfo, COL_INFO))
3194 col_append_fstr (pinfo->cinfo, COL_INFO, "(LBA: 0x%08x, Len: %u)",
3195 tvb_get_ntohl (tvb, offset+1),
3196 tvb_get_ntohl (tvb, offset+5));
3199 if (tree && isreq && iscdb) {
3200 flags = tvb_get_guint8 (tvb, offset);
3202 proto_tree_add_uint_format (tree, hf_scsi_read_flags, tvb, offset, 1,
3204 "DPO = %u, FUA = %u, RelAddr = %u",
3205 flags & 0x10, flags & 0x8, flags & 0x1);
3206 proto_tree_add_item (tree, hf_scsi_rdwr10_lba, tvb, offset+1, 4, 0);
3207 proto_tree_add_item (tree, hf_scsi_rdwr12_xferlen, tvb, offset+5, 4, 0);
3208 flags = tvb_get_guint8 (tvb, offset+10);
3209 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+10, 1,
3211 "Vendor Unique = %u, NACA = %u, Link = %u",
3212 flags & 0xC0, flags & 0x4, flags & 0x1);
3217 dissect_scsi_rdwr16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
3218 guint offset, gboolean isreq, gboolean iscdb)
3222 if (tree && isreq && iscdb) {
3223 flags = tvb_get_guint8 (tvb, offset);
3225 proto_tree_add_uint_format (tree, hf_scsi_read_flags, tvb, offset, 1,
3227 "DPO = %u, FUA = %u, RelAddr = %u",
3228 flags & 0x10, flags & 0x8, flags & 0x1);
3229 proto_tree_add_item (tree, hf_scsi_rdwr16_lba, tvb, offset+1, 8, 0);
3230 proto_tree_add_item (tree, hf_scsi_rdwr12_xferlen, tvb, offset+9, 4, 0);
3231 flags = tvb_get_guint8 (tvb, offset+14);
3232 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1,
3234 "Vendor Unique = %u, NACA = %u, Link = %u",
3235 flags & 0xC0, flags & 0x4, flags & 0x1);
3240 dissect_scsi_readcapacity (tvbuff_t *tvb, packet_info *pinfo _U_,
3241 proto_tree *tree, guint offset, gboolean isreq,
3250 if (isreq && iscdb) {
3251 flags = tvb_get_guint8 (tvb, offset);
3253 proto_tree_add_uint_format (tree, hf_scsi_readcapacity_flags, tvb,
3255 "LongLBA = %u, RelAddr = %u",
3256 flags & 0x2, flags & 0x1);
3257 proto_tree_add_item (tree, hf_scsi_readcapacity_lba, tvb, offset+1,
3259 proto_tree_add_item (tree, hf_scsi_readcapacity_pmi, tvb, offset+7,
3262 flags = tvb_get_guint8 (tvb, offset+8);
3263 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1,
3265 "Vendor Unique = %u, NACA = %u, Link = %u",
3266 flags & 0xC0, flags & 0x4, flags & 0x1);
3269 len = tvb_get_ntohl (tvb, offset);
3270 proto_tree_add_text (tree, tvb, offset, 4, "LBA: %u (%u MB)",
3271 len, len/(1024*1024));
3272 proto_tree_add_text (tree, tvb, offset+4, 4, "Block Length: %u bytes",
3273 tvb_get_ntohl (tvb, offset+4));
3278 dissect_scsi_readdefdata10 (tvbuff_t *tvb, packet_info *pinfo _U_,
3279 proto_tree *tree, guint offset, gboolean isreq,
3287 if (isreq && iscdb) {
3288 flags = tvb_get_guint8 (tvb, offset);
3290 proto_tree_add_uint_format (tree, hf_scsi_readdefdata_flags, tvb,
3291 offset, 1, flags, "PLIST = %u, GLIST = %u",
3292 flags & 0x10, flags & 0x8);
3293 proto_tree_add_item (tree, hf_scsi_cdb_defectfmt, tvb, offset, 1, 0);
3294 proto_tree_add_item (tree, hf_scsi_alloclen16, tvb, offset+6, 2, 0);
3295 flags = tvb_get_guint8 (tvb, offset+8);
3296 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1,
3298 "Vendor Unique = %u, NACA = %u, Link = %u",
3299 flags & 0xC0, flags & 0x4, flags & 0x1);
3304 dissect_scsi_readdefdata12 (tvbuff_t *tvb, packet_info *pinfo _U_,
3305 proto_tree *tree, guint offset, gboolean isreq,
3313 if (isreq && iscdb) {
3314 flags = tvb_get_guint8 (tvb, offset);
3316 proto_tree_add_uint_format (tree, hf_scsi_readdefdata_flags, tvb,
3317 offset, 1, flags, "PLIST = %u, GLIST = %u",
3318 flags & 0x10, flags & 0x8);
3319 proto_tree_add_item (tree, hf_scsi_cdb_defectfmt, tvb, offset, 1, 0);
3320 proto_tree_add_item (tree, hf_scsi_alloclen32, tvb, offset+5, 4, 0);
3321 flags = tvb_get_guint8 (tvb, offset+10);
3322 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+10, 1,
3324 "Vendor Unique = %u, NACA = %u, Link = %u",
3325 flags & 0xC0, flags & 0x4, flags & 0x1);
3330 dissect_scsi_reassignblks (tvbuff_t *tvb, packet_info *pinfo _U_,
3331 proto_tree *tree, guint offset, gboolean isreq,
3339 if (isreq && iscdb) {
3340 flags = tvb_get_guint8 (tvb, offset);
3342 proto_tree_add_uint_format (tree, hf_scsi_reassignblks_flags, tvb,
3344 "LongLBA = %u, LongList = %u",
3345 flags & 0x2, flags & 0x1);
3346 flags = tvb_get_guint8 (tvb, offset+4);
3347 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
3349 "Vendor Unique = %u, NACA = %u, Link = %u",
3350 flags & 0xC0, flags & 0x4, flags & 0x1);
3355 dissect_scsi_varlencdb (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
3356 guint offset, gboolean isreq, gboolean iscdb)
3361 if (isreq && iscdb) {
3362 proto_tree_add_item (tree, hf_scsi_control, tvb, offset, 1, 0);
3363 proto_tree_add_item (tree, hf_scsi_add_cdblen, tvb, offset+6, 1, 0);
3364 proto_tree_add_item (tree, hf_scsi_svcaction, tvb, offset+7, 2, 0);
3370 dissect_scsi_ssc2_read6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
3371 guint offset, gboolean isreq, gboolean iscdb)
3376 if (check_col (pinfo->cinfo, COL_INFO))
3377 col_append_fstr (pinfo->cinfo, COL_INFO, "(Len: %u)",
3378 tvb_get_ntoh24 (tvb, offset+1));
3381 if (tree && isreq && iscdb) {
3382 flags = tvb_get_guint8 (tvb, offset);
3383 proto_tree_add_text (tree, tvb, offset, 1,
3384 "SILI: %u, FIXED: %u",
3385 (flags & 0x02) >> 1, flags & 0x01);
3386 proto_tree_add_item (tree, hf_scsi_rdwr6_xferlen, tvb, offset+1, 3, 0);
3387 flags = tvb_get_guint8 (tvb, offset+4);
3388 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
3390 "Vendor Unique = %u, NACA = %u, Link = %u",
3391 flags & 0xC0, flags & 0x4, flags & 0x1);
3396 dissect_scsi_ssc2_write6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
3397 guint offset, gboolean isreq, gboolean iscdb)
3402 if (check_col (pinfo->cinfo, COL_INFO))
3403 col_append_fstr (pinfo->cinfo, COL_INFO, "(Len: %u)",
3404 tvb_get_ntoh24 (tvb, offset+1));
3407 if (tree && isreq && iscdb) {
3408 flags = tvb_get_guint8 (tvb, offset);
3409 proto_tree_add_text (tree, tvb, offset, 1,
3410 "FIXED: %u", flags & 0x01);
3411 proto_tree_add_item (tree, hf_scsi_rdwr6_xferlen, tvb, offset+1, 3,
3413 flags = tvb_get_guint8 (tvb, offset+4);
3414 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
3416 "Vendor Unique = %u, NACA = %u, Link = %u",
3417 flags & 0xC0, flags & 0x4, flags & 0x1);
3422 dissect_scsi_ssc2_writefilemarks6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
3423 guint offset, gboolean isreq, gboolean iscdb)
3428 if (check_col (pinfo->cinfo, COL_INFO))
3429 col_append_fstr (pinfo->cinfo, COL_INFO, "(Len: %u)",
3430 tvb_get_ntoh24 (tvb, offset+1));
3433 if (tree && isreq && iscdb) {
3434 flags = tvb_get_guint8 (tvb, offset);
3435 proto_tree_add_text (tree, tvb, offset, 1,
3436 "WSMK: %u, IMMED: %u",
3437 (flags & 0x02) >> 1, flags & 0x01);
3438 proto_tree_add_item (tree, hf_scsi_rdwr6_xferlen, tvb, offset+1, 3,
3440 flags = tvb_get_guint8 (tvb, offset+4);
3441 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
3443 "Vendor Unique = %u, NACA = %u, Link = %u",
3444 flags & 0xC0, flags & 0x4, flags & 0x1);
3449 dissect_scsi_ssc2_loadunload (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
3450 guint offset, gboolean isreq, gboolean iscdb)
3454 if (isreq && iscdb) {
3455 if (check_col (pinfo->cinfo, COL_INFO))
3456 col_append_fstr (pinfo->cinfo, COL_INFO, "(Immed: %u)",
3457 tvb_get_guint8 (tvb, offset) & 0x01);
3462 proto_tree_add_text (tree, tvb, offset, 1,
3463 "Immed: %u", tvb_get_guint8 (tvb, offset) & 0x01);
3464 flags = tvb_get_guint8 (tvb, offset+3);
3465 proto_tree_add_text (tree, tvb, offset+3, 1,
3466 "Hold: %u, EOT: %u, Reten: %u, Load: %u",
3467 (flags & 0x08) >> 3, (flags & 0x04) >> 2,
3468 (flags & 0x02) >> 1, (flags & 0x01));
3469 flags = tvb_get_guint8 (tvb, offset+4);
3470 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
3472 "Vendor Unique = %u, NACA = %u, Link = %u",
3473 flags & 0xC0, flags & 0x4, flags & 0x1);
3478 dissect_scsi_ssc2_readblocklimits (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
3479 guint offset, gboolean isreq, gboolean iscdb)
3481 guint8 flags, granularity;
3486 if (isreq && iscdb) {
3487 flags = tvb_get_guint8 (tvb, offset+4);
3488 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
3490 "Vendor Unique = %u, NACA = %u, Link = %u",
3491 flags & 0xC0, flags & 0x4, flags & 0x1);
3494 granularity = tvb_get_guint8 (tvb, offset);
3495 proto_tree_add_text (tree, tvb, offset, 1, "Granularity: %u (%u %s)",
3496 granularity, 1 << granularity,
3497 plurality(1 << granularity, "byte", "bytes"));
3498 proto_tree_add_text (tree, tvb, offset+1, 3, "Maximum Block Length Limit: %u bytes",
3499 tvb_get_ntoh24 (tvb, offset+1));
3500 proto_tree_add_text (tree, tvb, offset+4, 2, "Minimum Block Length Limit: %u bytes",
3501 tvb_get_ntohs (tvb, offset+4));
3505 #define SHORT_FORM_BLOCK_ID 0x00
3506 #define SHORT_FORM_VENDOR_SPECIFIC 0x01
3507 #define LONG_FORM 0x06
3508 #define EXTENDED_FORM 0x08
3510 static const value_string service_action_vals[] = {
3511 {SHORT_FORM_BLOCK_ID, "Short Form - Block ID"},
3512 {SHORT_FORM_VENDOR_SPECIFIC, "Short Form - Vendor-Specific"},
3513 {LONG_FORM, "Long Form"},
3514 {EXTENDED_FORM, "Extended Form"},
3524 dissect_scsi_ssc2_readposition (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
3525 guint offset, gboolean isreq, gboolean iscdb,
3526 scsi_task_data_t *cdata)
3528 gint service_action;
3534 if (isreq && iscdb) {
3535 service_action = tvb_get_guint8 (tvb, offset) & 0x1F;
3536 proto_tree_add_text (tree, tvb, offset, 1,
3537 "Service Action: %s",
3538 val_to_str (service_action,
3539 service_action_vals,
3540 "Unknown (0x%02x)"));
3541 /* Remember the service action so we can decode the reply */
3542 if (cdata != NULL) {
3543 cdata->flags = service_action;
3545 proto_tree_add_text (tree, tvb, offset+6, 2,
3546 "Parameter Len: %u",
3547 tvb_get_ntohs (tvb, offset+6));
3548 flags = tvb_get_guint8 (tvb, offset+8);
3549 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1,
3551 "Vendor Unique = %u, NACA = %u, Link = %u",
3552 flags & 0xC0, flags & 0x4, flags & 0x1);
3556 service_action = cdata->flags;
3558 service_action = -1; /* unknown */
3559 switch (service_action) {
3560 case SHORT_FORM_BLOCK_ID:
3561 case SHORT_FORM_VENDOR_SPECIFIC:
3562 flags = tvb_get_guint8 (tvb, offset);
3563 proto_tree_add_text (tree, tvb, offset, 1,
3564 "BOP: %u, EOP: %u, BCU: %u, BYCU: %u, BPU: %u, PERR: %u",
3565 (flags & 0x80) >> 7, (flags & 0x40) >> 6,
3566 (flags & BCU) >> 5, (flags & BYCU) >> 4,
3567 (flags & BPU) >> 2, (flags & 0x02) >> 1);
3570 proto_tree_add_text (tree, tvb, offset, 1,
3571 "Partition Number: %u",
3572 tvb_get_guint8 (tvb, offset));
3575 offset += 2; /* reserved */
3577 if (!(flags & BPU)) {
3578 proto_tree_add_text (tree, tvb, offset, 4,
3579 "First Block Location: %u",
3580 tvb_get_ntohl (tvb, offset));
3583 proto_tree_add_text (tree, tvb, offset, 4,
3584 "Last Block Location: %u",
3585 tvb_get_ntohl (tvb, offset));
3590 offset += 1; /* reserved */
3592 if (!(flags & BCU)) {
3593 proto_tree_add_text (tree, tvb, offset, 3,
3594 "Number of Blocks in Buffer: %u",
3595 tvb_get_ntoh24 (tvb, offset));
3599 if (!(flags & BYCU)) {
3600 proto_tree_add_text (tree, tvb, offset, 4,
3601 "Number of Bytes in Buffer: %u",
3602 tvb_get_ntohl (tvb, offset));
3608 flags = tvb_get_guint8 (tvb, offset);
3609 proto_tree_add_text (tree, tvb, offset, 1,
3610 "BOP: %u, EOP: %u, MPU: %u, BPU: %u",
3611 (flags & 0x80) >> 7, (flags & 0x40) >> 6,
3612 (flags & MPU) >> 3, (flags & BPU) >> 2);
3615 offset += 3; /* reserved */
3617 if (!(flags & BPU)) {
3618 proto_tree_add_text (tree, tvb, offset, 4,
3619 "Partition Number: %u",
3620 tvb_get_ntohl (tvb, offset));
3623 proto_tree_add_text (tree, tvb, offset, 8,
3625 u64toa (tvb_get_ptr (tvb, offset, 8)));
3630 if (!(flags & MPU)) {
3631 proto_tree_add_text (tree, tvb, offset, 8,
3633 u64toa (tvb_get_ptr (tvb, offset, 8)));
3636 proto_tree_add_text (tree, tvb, offset, 8,
3638 u64toa (tvb_get_ptr (tvb, offset, 8)));
3645 flags = tvb_get_guint8 (tvb, offset);
3646 proto_tree_add_text (tree, tvb, offset, 1,
3647 "BOP: %u, EOP: %u, BCU: %u, BYCU: %u, MPU: %u, BPU: %u, PERR: %u",
3648 (flags & 0x80) >> 7, (flags & 0x40) >> 6,
3649 (flags & BCU) >> 5, (flags & BYCU) >> 4,
3650 (flags & MPU) >> 3, (flags & BPU) >> 2,
3651 (flags & 0x02) >> 1);
3654 proto_tree_add_text (tree, tvb, offset, 1,
3655 "Partition Number: %u",
3656 tvb_get_guint8 (tvb, offset));
3659 proto_tree_add_text (tree, tvb, offset, 2,
3660 "Additional Length: %u",
3661 tvb_get_ntohs (tvb, offset));
3664 offset += 1; /* reserved */
3666 if (!(flags & BCU)) {
3667 proto_tree_add_text (tree, tvb, offset, 3,
3668 "Number of Blocks in Buffer: %u",
3669 tvb_get_ntoh24 (tvb, offset));
3673 if (!(flags & BPU)) {
3674 proto_tree_add_text (tree, tvb, offset, 8,
3675 "First Block Location: %s",
3676 u64toa (tvb_get_ptr (tvb, offset, 8)));
3679 proto_tree_add_text (tree, tvb, offset, 8,
3680 "Last Block Location: %s",
3681 u64toa (tvb_get_ptr (tvb, offset, 8)));
3686 offset += 1; /* reserved */
3688 if (!(flags & BYCU)) {
3689 proto_tree_add_text (tree, tvb, offset, 8,
3690 "Number of Bytes in Buffer: %s",
3691 u64toa (tvb_get_ptr (tvb, offset, 8)));
3703 dissect_scsi_ssc2_rewind (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
3704 guint offset, gboolean isreq, gboolean iscdb)
3708 if (isreq && iscdb) {
3709 if (check_col (pinfo->cinfo, COL_INFO))
3710 col_append_fstr (pinfo->cinfo, COL_INFO, "(Immed: %u)",
3711 tvb_get_guint8 (tvb, offset) & 0x01);
3716 proto_tree_add_text (tree, tvb, offset, 1,
3717 "Immed: %u", tvb_get_guint8 (tvb, offset) & 0x01);
3718 flags = tvb_get_guint8 (tvb, offset+4);
3719 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
3721 "Vendor Unique = %u, NACA = %u, Link = %u",
3722 flags & 0xC0, flags & 0x4, flags & 0x1);
3727 dissect_scsi_smc2_movemedium (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
3728 guint offset, gboolean isreq, gboolean iscdb)
3732 if (tree && isreq && iscdb) {
3733 proto_tree_add_text (tree, tvb, offset+1, 2,
3734 "Medium Transport Address: %u",
3735 tvb_get_ntohs (tvb, offset+1));
3736 proto_tree_add_text (tree, tvb, offset+3, 2,
3737 "Source Address: %u",
3738 tvb_get_ntohs (tvb, offset+3));
3739 proto_tree_add_text (tree, tvb, offset+5, 2,
3740 "Destination Address: %u",
3741 tvb_get_ntohs (tvb, offset+5));
3742 flags = tvb_get_guint8 (tvb, offset+9);
3743 proto_tree_add_text (tree, tvb, offset+9, 1,
3744 "INV: %u", flags & 0x01);
3745 flags = tvb_get_guint8 (tvb, offset+10);
3746 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+10, 1,
3748 "Vendor Unique = %u, NACA = %u, Link = %u",
3749 flags & 0xC0, flags & 0x4, flags & 0x1);
3755 #define I_E_ELEM 0x3
3758 static const value_string element_type_code_vals[] = {
3759 {0x0, "All element types"},
3760 {MT_ELEM, "Medium transport element"},
3761 {ST_ELEM, "Storage element"},
3762 {I_E_ELEM, "Import/export element"},
3763 {DT_ELEM, "Data transfer element"},
3767 #define PVOLTAG 0x80
3768 #define AVOLTAG 0x40
3772 #define ID_VALID 0x20
3773 #define LU_VALID 0x10
3778 dissect_scsi_smc2_volume_tag (tvbuff_t *tvb, packet_info *pinfo _U_,
3779 proto_tree *tree, guint offset,
3785 tvb_memcpy (tvb, (guint8 *)volid, offset, 32);
3791 if (*(p - 1) != ' ')
3795 proto_tree_add_text (tree, tvb, offset, 36,
3796 "%s: Volume Identification = \"%s\", Volume Sequence Number = %u",
3797 name, volid, tvb_get_ntohs (tvb, offset+34));
3801 dissect_scsi_smc2_element (tvbuff_t *tvb, packet_info *pinfo _U_,
3802 proto_tree *tree, guint offset,
3803 guint elem_bytecnt, guint8 elem_type,
3804 guint8 voltag_flags)
3809 if (elem_bytecnt < 2)
3811 proto_tree_add_text (tree, tvb, offset, 2,
3812 "Element Address: %u",
3813 tvb_get_ntohs (tvb, offset));
3817 if (elem_bytecnt < 1)
3819 flags = tvb_get_guint8 (tvb, offset);
3820 switch (elem_type) {
3823 proto_tree_add_text (tree, tvb, offset, 1,
3824 "EXCEPT: %u, FULL: %u",
3825 (flags & EXCEPT) >> 2, flags & 0x01);
3830 proto_tree_add_text (tree, tvb, offset, 1,
3831 "ACCESS: %u, EXCEPT: %u, FULL: %u",
3832 (flags & 0x08) >> 3,
3833 (flags & EXCEPT) >> 2, flags & 0x01);
3837 proto_tree_add_text (tree, tvb, offset, 1,
3838 "cmc: %u, INENAB: %u, EXENAB: %u, ACCESS: %u, EXCEPT: %u, IMPEXP: %u, FULL: %u",
3839 (flags & 0x40) >> 6,
3840 (flags & 0x20) >> 5,
3841 (flags & 0x10) >> 4,
3842 (flags & 0x08) >> 3,
3843 (flags & EXCEPT) >> 2,
3844 (flags & 0x02) >> 1,
3851 if (elem_bytecnt < 1)
3853 offset += 1; /* reserved */
3856 if (elem_bytecnt < 2)
3858 if (flags & EXCEPT) {
3859 proto_tree_add_text (tree, tvb, offset, 2,
3860 "Additional Sense Code+Qualifier: %s",
3861 val_to_str (tvb_get_ntohs (tvb, offset),
3862 scsi_asc_val, "Unknown (0x%04x)"));
3867 if (elem_bytecnt < 3)
3869 switch (elem_type) {
3872 flags = tvb_get_guint8 (tvb, offset);
3873 if (flags & LU_VALID) {
3874 proto_tree_add_text (tree, tvb, offset, 1,
3875 "NOT BUS: %u, ID VALID: %u, LU VALID: 1, LUN: %u",
3876 (flags & 0x80) >> 7,
3877 (flags & ID_VALID) >> 5,
3879 } else if (flags & ID_VALID) {
3880 proto_tree_add_text (tree, tvb, offset, 1,
3881 "ID VALID: 1, LU VALID: 0");
3883 proto_tree_add_text (tree, tvb, offset, 1,
3884 "ID VALID: 0, LU VALID: 0");
3887 if (flags & ID_VALID) {
3888 proto_tree_add_text (tree, tvb, offset, 1,
3889 "SCSI Bus Address: %u",
3890 tvb_get_guint8 (tvb, offset));
3893 offset += 1; /* reserved */
3897 offset += 3; /* reserved */
3902 if (elem_bytecnt < 3)
3904 flags = tvb_get_guint8 (tvb, offset);
3905 if (flags & SVALID) {
3906 proto_tree_add_text (tree, tvb, offset, 1,
3907 "SVALID: 1, INVERT: %u",
3908 (flags & 0x40) >> 6);
3910 proto_tree_add_text (tree, tvb, offset, 2,
3911 "Source Storage Element Address: %u",
3912 tvb_get_ntohs (tvb, offset));
3915 proto_tree_add_text (tree, tvb, offset, 1,
3921 if (voltag_flags & PVOLTAG) {
3922 if (elem_bytecnt < 36)
3924 dissect_scsi_smc2_volume_tag (tvb, pinfo, tree, offset,
3925 "Primary Volume Tag Information");
3930 if (voltag_flags & AVOLTAG) {
3931 if (elem_bytecnt < 36)
3933 dissect_scsi_smc2_volume_tag (tvb, pinfo, tree, offset,
3934 "Alternate Volume Tag Information");
3939 if (elem_bytecnt < 1)
3941 flags = tvb_get_guint8 (tvb, offset);
3942 proto_tree_add_text (tree, tvb, offset, 1,
3944 val_to_str (flags & 0x0F,
3945 scsi_devid_codeset_val,
3946 "Unknown (0x%02x)"));
3950 if (elem_bytecnt < 1)
3952 flags = tvb_get_guint8 (tvb, offset);
3953 proto_tree_add_text (tree, tvb, offset, 1,
3954 "Identifier Type: %s",
3955 val_to_str ((flags & 0x0F),
3956 scsi_devid_idtype_val,
3957 "Unknown (0x%02x)"));
3961 if (elem_bytecnt < 1)
3963 offset += 1; /* reserved */
3966 if (elem_bytecnt < 1)
3968 ident_len = tvb_get_guint8 (tvb, offset);
3969 proto_tree_add_text (tree, tvb, offset, 1,
3970 "Identifier Length: %u",
3975 if (ident_len != 0) {
3976 if (elem_bytecnt < ident_len)
3978 proto_tree_add_text (tree, tvb, offset, ident_len,
3980 tvb_bytes_to_str (tvb, offset, ident_len));
3981 offset += ident_len;
3982 elem_bytecnt -= ident_len;
3984 if (elem_bytecnt != 0) {
3985 proto_tree_add_text (tree, tvb, offset, elem_bytecnt,
3986 "Vendor-specific Data: %s",
3987 tvb_bytes_to_str (tvb, offset, elem_bytecnt));
3992 dissect_scsi_smc2_elements (tvbuff_t *tvb, packet_info *pinfo,
3993 proto_tree *tree, guint offset,
3994 guint desc_bytecnt, guint8 elem_type,
3995 guint8 voltag_flags, guint16 elem_desc_len)
3999 while (desc_bytecnt != 0) {
4000 elem_bytecnt = elem_desc_len;
4001 if (elem_bytecnt > desc_bytecnt)
4002 elem_bytecnt = desc_bytecnt;
4003 dissect_scsi_smc2_element (tvb, pinfo, tree, offset, elem_bytecnt,
4004 elem_type, voltag_flags);
4005 offset += elem_bytecnt;
4006 desc_bytecnt -= elem_bytecnt;
4011 dissect_scsi_smc2_readelementstatus (tvbuff_t *tvb, packet_info *pinfo,
4012 proto_tree *tree, guint offset, gboolean isreq,
4016 guint numelem, bytecnt, desc_bytecnt;
4018 guint8 voltag_flags;
4019 guint16 elem_desc_len;
4024 if (isreq && iscdb) {
4025 flags = tvb_get_guint8 (tvb, offset);
4026 proto_tree_add_text (tree, tvb, offset, 1,
4027 "VOLTAG: %u, Element Type Code: %s",
4028 (flags & 0x10) >> 4,
4029 val_to_str (flags & 0xF, element_type_code_vals,
4031 proto_tree_add_text (tree, tvb, offset+1, 2,
4032 "Starting Element Address: %u",
4033 tvb_get_ntohs (tvb, offset+1));
4034 proto_tree_add_text (tree, tvb, offset+3, 2,
4035 "Number of Elements: %u",
4036 tvb_get_ntohs (tvb, offset+3));
4037 flags = tvb_get_guint8 (tvb, offset+4);
4038 proto_tree_add_text (tree, tvb, offset+4, 1,
4039 "CURDATA: %u, DVCID: %u",
4040 (flags & 0x02) >> 1, flags & 0x01);
4041 proto_tree_add_text (tree, tvb, offset+5, 3,
4042 "Allocation Length: %u",
4043 tvb_get_ntoh24 (tvb, offset+5));
4044 flags = tvb_get_guint8 (tvb, offset+10);
4045 proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+10, 1,
4047 "Vendor Unique = %u, NACA = %u, Link = %u",
4048 flags & 0xC0, flags & 0x4, flags & 0x1);
4051 proto_tree_add_text (tree, tvb, offset, 2,
4052 "First Element Address Reported: %u",
4053 tvb_get_ntohs (tvb, offset));
4055 numelem = tvb_get_ntohs (tvb, offset);
4056 proto_tree_add_text (tree, tvb, offset, 2,
4057 "Number of Elements Available: %u", numelem);
4059 offset += 1; /* reserved */
4060 bytecnt = tvb_get_ntoh24 (tvb, offset);
4061 proto_tree_add_text (tree, tvb, offset, 3,
4062 "Byte Count of Report Available: %u", bytecnt);
4064 while (bytecnt != 0) {
4067 elem_type = tvb_get_guint8 (tvb, offset);
4068 proto_tree_add_text (tree, tvb, offset, 1,
4069 "Element Type Code: %s",
4070 val_to_str (elem_type, element_type_code_vals,
4077 voltag_flags = tvb_get_guint8 (tvb, offset);
4078 proto_tree_add_text (tree, tvb, offset, 1,
4079 "PVOLTAG: %u, AVOLTAG: %u",
4080 (voltag_flags & PVOLTAG) >> 7,
4081 (voltag_flags & AVOLTAG) >> 6);
4087 elem_desc_len = tvb_get_ntohs (tvb, offset);
4088 proto_tree_add_text (tree, tvb, offset, 2,
4089 "Element Descriptor Length: %u",
4096 offset += 1; /* reserved */
4101 desc_bytecnt = tvb_get_ntoh24 (tvb, offset);
4102 proto_tree_add_text (tree, tvb, offset, 3,
4103 "Byte Count Of Descriptor Data Available: %u",
4108 if (desc_bytecnt > bytecnt)
4109 desc_bytecnt = bytecnt;
4110 dissect_scsi_smc2_elements (tvb, pinfo, tree, offset,
4111 desc_bytecnt, elem_type,
4112 voltag_flags, elem_desc_len);
4113 offset += desc_bytecnt;
4114 bytecnt -= desc_bytecnt;
4120 dissect_scsi_rsp (tvbuff_t *tvb _U_, packet_info *pinfo _U_,
4121 proto_tree *tree _U_)
4123 /* Nothing to do here, just blow up the data structures for this SCSI
4126 scsi_end_task (pinfo);
4131 dissect_scsi_snsinfo (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
4132 guint offset, guint snslen)
4136 proto_tree *sns_tree;
4138 scsi_end_task (pinfo);
4141 ti = proto_tree_add_protocol_format (tree, proto_scsi, tvb, offset,
4142 snslen, "SCSI: SNS Info");
4143 sns_tree = proto_item_add_subtree (ti, ett_scsi);
4145 flags = tvb_get_guint8 (tvb, offset);
4146 proto_tree_add_text (sns_tree, tvb, offset, 1, "Valid: %u",
4147 (flags & 0x80) >> 7);
4148 proto_tree_add_item (sns_tree, hf_scsi_sns_errtype, tvb, offset, 1, 0);
4149 flags = tvb_get_guint8 (tvb, offset+2);
4150 proto_tree_add_text (sns_tree, tvb, offset+2, 1,
4151 "Filemark: %u, EOM: %u, ILI: %u",
4152 (flags & 0x80) >> 7, (flags & 0x40) >> 6,
4153 (flags & 0x20) >> 5);
4154 proto_tree_add_item (sns_tree, hf_scsi_snskey, tvb, offset+2, 1, 0);
4155 proto_tree_add_item (sns_tree, hf_scsi_snsinfo, tvb, offset+3, 4, 0);
4156 proto_tree_add_item (sns_tree, hf_scsi_addlsnslen, tvb, offset+7, 1, 0);
4157 proto_tree_add_text (sns_tree, tvb, offset+8, 4,
4158 "Command-Specific Information: %s",
4159 tvb_bytes_to_str (tvb, offset+8, 4));
4160 proto_tree_add_item (sns_tree, hf_scsi_ascascq, tvb, offset+12, 2, 0);
4161 proto_tree_add_item_hidden (sns_tree, hf_scsi_asc, tvb, offset+12, 1, 0);
4162 proto_tree_add_item_hidden (sns_tree, hf_scsi_ascq, tvb, offset+13,
4164 proto_tree_add_item (sns_tree, hf_scsi_fru, tvb, offset+14, 1, 0);
4165 proto_tree_add_item (sns_tree, hf_scsi_sksv, tvb, offset+15, 1, 0);
4166 proto_tree_add_text (sns_tree, tvb, offset+15, 3,
4167 "Sense Key Specific: %s",
4168 tvb_bytes_to_str (tvb, offset+15, 3));
4173 dissect_scsi_cdb (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
4174 guint start, guint cdblen, gint devtype_arg)
4178 proto_tree *scsi_tree = NULL;
4180 scsi_device_type devtype;
4181 scsi_cmnd_type cmd = 0; /* 0 is undefined type */
4183 scsi_task_data_t *cdata;
4184 scsi_devtype_key_t dkey;
4185 scsi_devtype_data_t *devdata;
4187 opcode = tvb_get_guint8 (tvb, offset);
4189 if (devtype_arg != SCSI_DEV_UNKNOWN)
4190 devtype = devtype_arg;
4193 * Try to look up the device data for this device.
4195 * We don't use COPY_ADDRESS because "dkey.devid" isn't
4196 * persistent, and therefore it can point to the stuff
4197 * in "pinfo->src". (Were we to use COPY_ADDRESS, we'd
4198 * have to free the address data it allocated before we return.)
4200 dkey.devid = pinfo->dst;
4202 devdata = (scsi_devtype_data_t *)g_hash_table_lookup (scsidev_req_hash,
4204 if (devdata != NULL) {
4205 devtype = devdata->devtype;
4208 devtype = (scsi_device_type)scsi_def_devtype;
4212 if ((valstr = match_strval (opcode, scsi_spc2_val)) == NULL) {
4214 * This isn't a generic command that applies to all SCSI
4215 * device types; try to interpret it based on what we deduced,
4216 * or were told, the device type is.
4218 * Right now, the only choices are SBC or SSC. If we ever expand
4219 * this to decode other device types, this piece of code needs to
4224 valstr = match_strval (opcode, scsi_sbc2_val);
4225 cmd = SCSI_CMND_SBC2;
4229 valstr = match_strval (opcode, scsi_ssc2_val);
4230 cmd = SCSI_CMND_SSC2;
4234 valstr = match_strval (opcode, scsi_smc2_val);
4235 cmd = SCSI_CMND_SMC2;
4239 cmd = SCSI_CMND_SPC2;
4244 cmd = SCSI_CMND_SPC2;
4247 if (valstr != NULL) {
4248 if (check_col (pinfo->cinfo, COL_INFO)) {
4249 col_add_fstr (pinfo->cinfo, COL_INFO, "SCSI: %s", valstr);
4253 if (check_col (pinfo->cinfo, COL_INFO)) {
4254 col_add_fstr (pinfo->cinfo, COL_INFO, "SCSI Command: 0x%02x", opcode);
4258 cdata = scsi_new_task (pinfo);
4261 cdata->opcode = opcode;
4263 cdata->devtype = devtype;
4267 ti = proto_tree_add_protocol_format (tree, proto_scsi, tvb, start,
4268 cdblen, "SCSI CDB");
4269 scsi_tree = proto_item_add_subtree (ti, ett_scsi);
4271 if (valstr != NULL) {
4272 if (cmd == SCSI_CMND_SPC2) {
4273 proto_tree_add_uint_format (scsi_tree, hf_scsi_spcopcode, tvb,
4275 tvb_get_guint8 (tvb, offset),
4276 "Opcode: %s (0x%02x)", valstr,
4279 else if (cmd == SCSI_CMND_SBC2) {
4280 proto_tree_add_uint_format (scsi_tree, hf_scsi_sbcopcode, tvb,
4282 tvb_get_guint8 (tvb, offset),
4283 "Opcode: %s (0x%02x)", valstr,
4286 else if (cmd == SCSI_CMND_SSC2) {
4287 proto_tree_add_uint_format (scsi_tree, hf_scsi_sscopcode, tvb,
4289 tvb_get_guint8 (tvb, offset),
4290 "Opcode: %s (0x%02x)", valstr,
4293 else if (cmd == SCSI_CMND_SMC2) {
4294 proto_tree_add_uint_format (scsi_tree, hf_scsi_smcopcode, tvb,
4296 tvb_get_guint8 (tvb, offset),
4297 "Opcode: %s (0x%02x)", valstr,
4301 /* "Can't happen" */
4302 g_assert_not_reached();
4306 proto_tree_add_item (scsi_tree, hf_scsi_spcopcode, tvb, offset, 1, 0);
4311 case SCSI_CMND_SPC2:
4313 case SCSI_SPC2_INQUIRY:
4314 dissect_scsi_inquiry (tvb, pinfo, scsi_tree, offset+1, TRUE,
4318 case SCSI_SPC2_EXTCOPY:
4319 dissect_scsi_extcopy (tvb, pinfo, scsi_tree, offset+1, TRUE,
4323 case SCSI_SPC2_LOGSELECT:
4324 dissect_scsi_logselect (tvb, pinfo, scsi_tree, offset+1, TRUE,
4328 case SCSI_SPC2_LOGSENSE:
4329 dissect_scsi_logsense (tvb, pinfo, scsi_tree, offset+1, TRUE,
4333 case SCSI_SPC2_MODESELECT6:
4334 dissect_scsi_modeselect6 (tvb, pinfo, scsi_tree, offset+1,
4335 TRUE, TRUE, devtype, 0);
4338 case SCSI_SPC2_MODESELECT10:
4339 dissect_scsi_modeselect10 (tvb, pinfo, scsi_tree, offset+1,
4340 TRUE, TRUE, devtype, 0);
4343 case SCSI_SPC2_MODESENSE6:
4344 dissect_scsi_modesense6 (tvb, pinfo, scsi_tree, offset+1, TRUE,
4348 case SCSI_SPC2_MODESENSE10:
4349 dissect_scsi_modesense10 (tvb, pinfo, scsi_tree, offset+1,
4350 TRUE, TRUE, devtype, 0);
4353 case SCSI_SPC2_PERSRESVIN:
4354 dissect_scsi_persresvin (tvb, pinfo, scsi_tree, offset+1, TRUE,
4358 case SCSI_SPC2_PERSRESVOUT:
4359 dissect_scsi_persresvout (tvb, pinfo, scsi_tree, offset+1,
4360 TRUE, TRUE, cdata, 0);
4363 case SCSI_SPC2_RELEASE6:
4364 dissect_scsi_release6 (tvb, pinfo, scsi_tree, offset+1, TRUE,
4368 case SCSI_SPC2_RELEASE10:
4369 dissect_scsi_release10 (tvb, pinfo, scsi_tree, offset+1, TRUE,
4373 case SCSI_SPC2_REPORTDEVICEID:
4374 dissect_scsi_reportdeviceid (tvb, pinfo, scsi_tree, offset+1,
4378 case SCSI_SPC2_REPORTLUNS:
4379 dissect_scsi_reportluns (tvb, pinfo, scsi_tree, offset+1, TRUE,
4383 case SCSI_SPC2_REQSENSE:
4384 dissect_scsi_reqsense (tvb, pinfo, scsi_tree, offset+1, TRUE,
4388 case SCSI_SPC2_RESERVE6:
4389 dissect_scsi_reserve6 (tvb, pinfo, scsi_tree, offset+1, TRUE,
4393 case SCSI_SPC2_RESERVE10:
4394 dissect_scsi_reserve10 (tvb, pinfo, scsi_tree, offset+1, TRUE,
4398 case SCSI_SPC2_TESTUNITRDY:
4399 dissect_scsi_testunitrdy (tvb, pinfo, scsi_tree, offset+1,
4403 case SCSI_SPC2_VARLENCDB:
4404 dissect_scsi_varlencdb (tvb, pinfo, scsi_tree, offset+1,
4409 call_dissector (data_handle, tvb, pinfo, scsi_tree);
4414 case SCSI_CMND_SBC2:
4417 case SCSI_SBC2_FORMATUNIT:
4418 dissect_scsi_formatunit (tvb, pinfo, scsi_tree, offset+1, TRUE,
4422 case SCSI_SBC2_READ6:
4423 dissect_scsi_sbc2_rdwr6 (tvb, pinfo, scsi_tree, offset+1, TRUE,
4427 case SCSI_SBC2_READ10:
4428 dissect_scsi_rdwr10 (tvb, pinfo, scsi_tree, offset+1, TRUE,
4432 case SCSI_SBC2_READ12:
4433 dissect_scsi_rdwr12 (tvb, pinfo, scsi_tree, offset+1, TRUE,
4437 case SCSI_SBC2_READ16:
4438 dissect_scsi_rdwr16 (tvb, pinfo, scsi_tree, offset+1, TRUE,
4442 case SCSI_SBC2_READCAPACITY:
4443 dissect_scsi_readcapacity (tvb, pinfo, scsi_tree, offset+1,
4447 case SCSI_SBC2_READDEFDATA10:
4448 dissect_scsi_readdefdata10 (tvb, pinfo, scsi_tree, offset+1,
4452 case SCSI_SBC2_READDEFDATA12:
4453 dissect_scsi_readdefdata12 (tvb, pinfo, scsi_tree, offset+1,
4457 case SCSI_SBC2_REASSIGNBLKS:
4458 dissect_scsi_reassignblks (tvb, pinfo, scsi_tree, offset+1,
4462 case SCSI_SBC2_WRITE6:
4463 dissect_scsi_sbc2_rdwr6 (tvb, pinfo, scsi_tree, offset+1, TRUE,
4467 case SCSI_SBC2_WRITE10:
4468 dissect_scsi_rdwr10 (tvb, pinfo, scsi_tree, offset+1, TRUE,
4472 case SCSI_SBC2_WRITE12:
4473 dissect_scsi_rdwr12 (tvb, pinfo, scsi_tree, offset+1, TRUE,
4477 case SCSI_SBC2_WRITE16:
4478 dissect_scsi_rdwr16 (tvb, pinfo, scsi_tree, offset+1, TRUE,
4483 call_dissector (data_handle, tvb, pinfo, scsi_tree);
4488 case SCSI_CMND_SSC2:
4491 case SCSI_SSC2_READ6:
4492 dissect_scsi_ssc2_read6 (tvb, pinfo, scsi_tree, offset+1, TRUE,
4496 case SCSI_SSC2_WRITE6:
4497 dissect_scsi_ssc2_write6 (tvb, pinfo, scsi_tree, offset+1, TRUE,
4501 case SCSI_SSC2_WRITE_FILEMARKS_6:
4502 dissect_scsi_ssc2_writefilemarks6 (tvb, pinfo, scsi_tree, offset+1, TRUE,
4506 case SCSI_SSC2_LOAD_UNLOAD:
4507 dissect_scsi_ssc2_loadunload (tvb, pinfo, scsi_tree, offset+1, TRUE,
4511 case SCSI_SSC2_READ_BLOCK_LIMITS:
4512 dissect_scsi_ssc2_readblocklimits (tvb, pinfo, scsi_tree, offset+1, TRUE,
4516 case SCSI_SSC2_READ_POSITION:
4517 dissect_scsi_ssc2_readposition (tvb, pinfo, scsi_tree, offset+1, TRUE,
4521 case SCSI_SSC2_REWIND:
4522 dissect_scsi_ssc2_rewind (tvb, pinfo, scsi_tree, offset+1, TRUE,
4527 call_dissector (data_handle, tvb, pinfo, scsi_tree);
4532 case SCSI_CMND_SMC2:
4535 case SCSI_SMC2_MOVE_MEDIUM:
4536 case SCSI_SMC2_MOVE_MEDIUM_ATTACHED:
4537 dissect_scsi_smc2_movemedium (tvb, pinfo, scsi_tree, offset+1, TRUE,
4541 case SCSI_SMC2_READ_ELEMENT_STATUS:
4542 case SCSI_SMC2_READ_ELEMENT_STATUS_ATTACHED:
4543 dissect_scsi_smc2_readelementstatus (tvb, pinfo, scsi_tree, offset+1, TRUE,
4548 call_dissector (data_handle, tvb, pinfo, scsi_tree);
4554 call_dissector (data_handle, tvb, pinfo, scsi_tree);
4560 dissect_scsi_payload (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
4561 guint offset, gboolean isreq, guint32 payload_len)
4564 proto_tree *scsi_tree = NULL;
4565 guint8 opcode = 0xFF;
4566 scsi_cmnd_type cmd = 0; /* 0 is undefined type */
4567 scsi_device_type devtype;
4568 scsi_task_data_t *cdata = NULL;
4570 cdata = scsi_find_task (pinfo);
4573 /* we have no record of this exchange and so we can't dissect the
4579 opcode = cdata->opcode;
4581 devtype = cdata->devtype;
4585 case SCSI_CMND_SPC2:
4586 ti = proto_tree_add_protocol_format (tree, proto_scsi, tvb, offset,
4588 "SCSI Payload (%s %s)",
4592 isreq ? "Request" : "Response");
4595 case SCSI_CMND_SBC2:
4596 ti = proto_tree_add_protocol_format (tree, proto_scsi, tvb, offset,
4598 "SCSI Payload (%s %s)",
4602 isreq ? "Request" : "Response");
4605 case SCSI_CMND_SSC2:
4606 ti = proto_tree_add_protocol_format (tree, proto_scsi, tvb, offset,
4608 "SCSI Payload (%s %s)",
4612 isreq ? "Request" : "Response");
4615 case SCSI_CMND_SMC2:
4616 ti = proto_tree_add_protocol_format (tree, proto_scsi, tvb, offset,
4618 "SCSI Payload (%s %s)",
4622 isreq ? "Request" : "Response");
4626 ti = proto_tree_add_protocol_format (tree, proto_scsi, tvb, offset,
4628 "SCSI Payload (0x%02x %s)",
4630 isreq ? "Request" : "Response");
4634 scsi_tree = proto_item_add_subtree (ti, ett_scsi);
4639 * We have to dissect INQUIRY responses, in order to determine the
4642 * We don't bother dissecting other payload if we're not buildng
4645 if (cmd == SCSI_CMND_SPC2 && opcode == SCSI_SPC2_INQUIRY) {
4646 dissect_scsi_inquiry (tvb, pinfo, scsi_tree, offset, isreq,
4647 FALSE, payload_len, cdata);
4651 case SCSI_CMND_SPC2:
4653 case SCSI_SPC2_INQUIRY:
4654 dissect_scsi_inquiry (tvb, pinfo, scsi_tree, offset, isreq,
4655 FALSE, payload_len, cdata);
4658 case SCSI_SPC2_EXTCOPY:
4659 dissect_scsi_extcopy (tvb, pinfo, scsi_tree, offset, isreq,
4663 case SCSI_SPC2_LOGSELECT:
4664 dissect_scsi_logselect (tvb, pinfo, scsi_tree, offset, isreq,
4668 case SCSI_SPC2_LOGSENSE:
4669 dissect_scsi_logsense (tvb, pinfo, scsi_tree, offset, isreq,
4673 case SCSI_SPC2_MODESELECT6:
4674 dissect_scsi_modeselect6 (tvb, pinfo, scsi_tree, offset,
4675 isreq, FALSE, devtype, payload_len);
4678 case SCSI_SPC2_MODESELECT10:
4679 dissect_scsi_modeselect10 (tvb, pinfo, scsi_tree, offset,
4680 isreq, FALSE, devtype, payload_len);
4683 case SCSI_SPC2_MODESENSE6:
4684 dissect_scsi_modesense6 (tvb, pinfo, scsi_tree, offset, isreq,
4685 FALSE, devtype, payload_len);
4688 case SCSI_SPC2_MODESENSE10:
4689 dissect_scsi_modesense10 (tvb, pinfo, scsi_tree, offset,
4690 isreq, FALSE, devtype, payload_len);
4693 case SCSI_SPC2_PERSRESVIN:
4694 dissect_scsi_persresvin (tvb, pinfo, scsi_tree, offset, isreq,
4695 FALSE, cdata, payload_len);
4698 case SCSI_SPC2_PERSRESVOUT:
4699 dissect_scsi_persresvout (tvb, pinfo, scsi_tree, offset,
4700 isreq, FALSE, cdata, payload_len);
4703 case SCSI_SPC2_RELEASE6:
4704 dissect_scsi_release6 (tvb, pinfo, scsi_tree, offset, isreq,
4708 case SCSI_SPC2_RELEASE10:
4709 dissect_scsi_release10 (tvb, pinfo, scsi_tree, offset, isreq,
4713 case SCSI_SPC2_REPORTDEVICEID:
4714 dissect_scsi_reportdeviceid (tvb, pinfo, scsi_tree, offset,
4718 case SCSI_SPC2_REPORTLUNS:
4719 dissect_scsi_reportluns (tvb, pinfo, scsi_tree, offset, isreq,
4720 FALSE, payload_len);
4723 case SCSI_SPC2_REQSENSE:
4724 dissect_scsi_reqsense (tvb, pinfo, scsi_tree, offset, isreq,
4728 case SCSI_SPC2_RESERVE6:
4729 dissect_scsi_reserve6 (tvb, pinfo, scsi_tree, offset, isreq,
4733 case SCSI_SPC2_RESERVE10:
4734 dissect_scsi_reserve10 (tvb, pinfo, scsi_tree, offset, isreq,
4738 case SCSI_SPC2_TESTUNITRDY:
4739 dissect_scsi_testunitrdy (tvb, pinfo, scsi_tree, offset,
4744 call_dissector (data_handle, tvb, pinfo, scsi_tree);
4749 case SCSI_CMND_SBC2:
4752 case SCSI_SBC2_FORMATUNIT:
4753 dissect_scsi_formatunit (tvb, pinfo, scsi_tree, offset, isreq,
4757 case SCSI_SBC2_READ6:
4758 dissect_scsi_sbc2_rdwr6 (tvb, pinfo, scsi_tree, offset, isreq,
4762 case SCSI_SBC2_READ10:
4763 dissect_scsi_rdwr10 (tvb, pinfo, scsi_tree, offset, isreq,
4767 case SCSI_SBC2_READ12:
4768 dissect_scsi_rdwr12 (tvb, pinfo, scsi_tree, offset, isreq,
4772 case SCSI_SBC2_READ16:
4773 dissect_scsi_rdwr16 (tvb, pinfo, scsi_tree, offset, isreq,
4777 case SCSI_SBC2_READCAPACITY:
4778 dissect_scsi_readcapacity (tvb, pinfo, scsi_tree, offset,
4782 case SCSI_SBC2_READDEFDATA10:
4783 dissect_scsi_readdefdata10 (tvb, pinfo, scsi_tree, offset,
4787 case SCSI_SBC2_READDEFDATA12:
4788 dissect_scsi_readdefdata12 (tvb, pinfo, scsi_tree, offset,
4792 case SCSI_SBC2_REASSIGNBLKS:
4793 dissect_scsi_reassignblks (tvb, pinfo, scsi_tree, offset,
4797 case SCSI_SBC2_WRITE6:
4798 dissect_scsi_sbc2_rdwr6 (tvb, pinfo, scsi_tree, offset, isreq,
4802 case SCSI_SBC2_WRITE10:
4803 dissect_scsi_rdwr10 (tvb, pinfo, scsi_tree, offset, isreq,
4807 case SCSI_SBC2_WRITE12:
4808 dissect_scsi_rdwr12 (tvb, pinfo, scsi_tree, offset, isreq,
4812 case SCSI_SBC2_WRITE16:
4813 dissect_scsi_rdwr16 (tvb, pinfo, scsi_tree, offset, isreq,
4818 call_dissector (data_handle, tvb, pinfo, scsi_tree);
4823 case SCSI_CMND_SSC2:
4826 case SCSI_SSC2_READ6:
4827 dissect_scsi_ssc2_read6 (tvb, pinfo, scsi_tree, offset, isreq,
4831 case SCSI_SSC2_WRITE6:
4832 dissect_scsi_ssc2_write6 (tvb, pinfo, scsi_tree, offset, isreq,
4836 case SCSI_SSC2_WRITE_FILEMARKS_6:
4837 dissect_scsi_ssc2_writefilemarks6 (tvb, pinfo, scsi_tree, offset, isreq,
4841 case SCSI_SSC2_LOAD_UNLOAD:
4842 dissect_scsi_ssc2_loadunload (tvb, pinfo, scsi_tree, offset, isreq,
4846 case SCSI_SSC2_READ_BLOCK_LIMITS:
4847 dissect_scsi_ssc2_readblocklimits (tvb, pinfo, scsi_tree, offset, isreq,
4851 case SCSI_SSC2_READ_POSITION:
4852 dissect_scsi_ssc2_readposition (tvb, pinfo, scsi_tree, offset, isreq,
4856 case SCSI_SSC2_REWIND:
4857 dissect_scsi_ssc2_rewind (tvb, pinfo, scsi_tree, offset, isreq,
4862 call_dissector (data_handle, tvb, pinfo, scsi_tree);
4867 case SCSI_CMND_SMC2:
4870 case SCSI_SMC2_MOVE_MEDIUM:
4871 case SCSI_SMC2_MOVE_MEDIUM_ATTACHED:
4872 dissect_scsi_smc2_movemedium (tvb, pinfo, scsi_tree, offset, isreq,
4876 case SCSI_SMC2_READ_ELEMENT_STATUS:
4877 case SCSI_SMC2_READ_ELEMENT_STATUS_ATTACHED:
4878 dissect_scsi_smc2_readelementstatus (tvb, pinfo, scsi_tree, offset, isreq,
4883 call_dissector (data_handle, tvb, pinfo, scsi_tree);
4889 call_dissector (data_handle, tvb, pinfo, scsi_tree);
4896 proto_register_scsi (void)
4898 /* Setup list of header fields See Section 1.6.1 for details*/
4899 static hf_register_info hf[] = {
4900 { &hf_scsi_spcopcode,
4901 {"SPC-2 Opcode", "scsi.spc.opcode", FT_UINT8, BASE_HEX,
4902 VALS (scsi_spc2_val), 0x0, "", HFILL}},
4903 { &hf_scsi_sbcopcode,
4904 {"SBC-2 Opcode", "scsi.sbc.opcode", FT_UINT8, BASE_HEX,
4905 VALS (scsi_sbc2_val), 0x0, "", HFILL}},
4906 { &hf_scsi_sscopcode,
4907 {"SSC-2 Opcode", "scsi.ssc.opcode", FT_UINT8, BASE_HEX,
4908 VALS (scsi_ssc2_val), 0x0, "", HFILL}},
4909 { &hf_scsi_smcopcode,
4910 {"SMC-2 Opcode", "scsi.smc.opcode", FT_UINT8, BASE_HEX,
4911 VALS (scsi_smc2_val), 0x0, "", HFILL}},
4913 {"Control", "scsi.cdb.control", FT_UINT8, BASE_HEX, NULL, 0x0, "",
4915 { &hf_scsi_inquiry_flags,
4916 {"Flags", "scsi.inquiry.flags", FT_UINT8, BASE_HEX, NULL, 0x0, "",
4918 { &hf_scsi_inquiry_evpd_page,
4919 {"EVPD Page Code", "scsi.inquiry.evpd.pagecode", FT_UINT8, BASE_HEX,
4920 VALS (scsi_evpd_pagecode_val), 0x0, "", HFILL}},
4921 { &hf_scsi_inquiry_cmdt_page,
4922 {"CMDT Page Code", "scsi.inquiry.cmdt.pagecode", FT_UINT8, BASE_HEX,
4923 NULL, 0x0, "", HFILL}},
4924 { &hf_scsi_alloclen,
4925 {"Allocation Length", "scsi.cdb.alloclen", FT_UINT8, BASE_DEC, NULL,
4927 { &hf_scsi_logsel_flags,
4928 {"Flags", "scsi.logsel.flags", FT_UINT8, BASE_HEX, NULL, 0x0, "",
4930 { &hf_scsi_logsel_pc,
4931 {"Page Control", "scsi.logsel.pc", FT_UINT8, BASE_DEC,
4932 VALS (scsi_logsel_pc_val), 0xC0, "", HFILL}},
4933 { &hf_scsi_paramlen,
4934 {"Parameter Length", "scsi.cdb.paramlen", FT_UINT8, BASE_DEC, NULL,
4936 { &hf_scsi_logsns_flags,
4937 {"Flags", "scsi.logsns.flags", FT_UINT16, BASE_HEX, NULL, 0x0, "",
4939 { &hf_scsi_logsns_pc,
4940 {"Page Control", "scsi.logsns.pc", FT_UINT8, BASE_DEC,
4941 VALS (scsi_logsns_pc_val), 0xC0, "", HFILL}},
4942 { &hf_scsi_logsns_pagecode,
4943 {"Page Code", "scsi.logsns.pagecode", FT_UINT8, BASE_HEX,
4944 VALS (scsi_logsns_page_val), 0x3F0, "", HFILL}},
4945 { &hf_scsi_paramlen16,
4946 {"Parameter Length", "scsi.cdb.paramlen16", FT_UINT16, BASE_DEC, NULL,
4948 { &hf_scsi_modesel_flags,
4949 {"Mode Sense/Select Flags", "scsi.cdb.mode.flags", FT_UINT8, BASE_HEX,
4950 NULL, 0x0, "", HFILL}},
4951 { &hf_scsi_alloclen16,
4952 {"Allocation Length", "scsi.cdb.alloclen16", FT_UINT16, BASE_DEC,
4953 NULL, 0x0, "", HFILL}},
4954 { &hf_scsi_modesns_pc,
4955 {"Page Control", "scsi.mode.pc", FT_UINT8, BASE_DEC,
4956 VALS (scsi_modesns_pc_val), 0xC0, "", HFILL}},
4957 { &hf_scsi_spcpagecode,
4958 {"SPC-2 Page Code", "scsi.mode.spc.pagecode", FT_UINT8, BASE_HEX,
4959 VALS (scsi_spc2_modepage_val), 0x3F, "", HFILL}},
4960 { &hf_scsi_sbcpagecode,
4961 {"SBC-2 Page Code", "scsi.mode.sbc.pagecode", FT_UINT8, BASE_HEX,
4962 VALS (scsi_sbc2_modepage_val), 0x3F, "", HFILL}},
4963 { &hf_scsi_sscpagecode,
4964 {"SSC-2 Page Code", "scsi.mode.ssc.pagecode", FT_UINT8, BASE_HEX,
4965 VALS (scsi_ssc2_modepage_val), 0x3F, "", HFILL}},
4966 { &hf_scsi_smcpagecode,
4967 {"SMC-2 Page Code", "scsi.mode.smc.pagecode", FT_UINT8, BASE_HEX,
4968 VALS (scsi_smc2_modepage_val), 0x3F, "", HFILL}},
4969 { &hf_scsi_modesns_flags,
4970 {"Flags", "scsi.mode.flags", FT_UINT8, BASE_HEX, NULL, 0x0, "",
4972 { &hf_scsi_persresvin_svcaction,
4973 {"Service Action", "scsi.persresvin.svcaction", FT_UINT8, BASE_HEX,
4974 VALS (scsi_persresvin_svcaction_val), 0x0F, "", HFILL}},
4975 { &hf_scsi_persresvout_svcaction,
4976 {"Service Action", "scsi.persresvout.svcaction", FT_UINT8, BASE_HEX,
4977 VALS (scsi_persresvout_svcaction_val), 0x0F, "", HFILL}},
4978 { &hf_scsi_persresv_scope,
4979 {"Reservation Scope", "scsi.persresv.scope", FT_UINT8, BASE_HEX,
4980 VALS (scsi_persresv_scope_val), 0xF0, "", HFILL}},
4981 { &hf_scsi_persresv_type,
4982 {"Reservation Type", "scsi.persresv.type", FT_UINT8, BASE_HEX,
4983 VALS (scsi_persresv_type_val), 0x0F, "", HFILL}},
4984 { &hf_scsi_release_flags,
4985 {"Release Flags", "scsi.release.flags", FT_UINT8, BASE_HEX, NULL,
4987 { &hf_scsi_release_thirdpartyid,
4988 {"Third-Party ID", "scsi.release.thirdpartyid", FT_BYTES, BASE_HEX,
4989 NULL, 0x0, "", HFILL}},
4990 { &hf_scsi_alloclen32,
4991 {"Allocation Length", "scsi.cdb.alloclen32", FT_UINT32, BASE_DEC,
4992 NULL, 0x0, "", HFILL}},
4993 { &hf_scsi_formatunit_flags,
4994 {"Flags", "scsi.formatunit.flags", FT_UINT8, BASE_HEX, NULL, 0xF8,
4996 { &hf_scsi_cdb_defectfmt,
4997 {"Defect List Format", "scsi.cdb.defectfmt", FT_UINT8, BASE_DEC,
4998 NULL, 0x7, "", HFILL}},
4999 { &hf_scsi_formatunit_interleave,
5000 {"Interleave", "scsi.formatunit.interleave", FT_UINT16, BASE_HEX,
5001 NULL, 0x0, "", HFILL}},
5002 { &hf_scsi_formatunit_vendor,
5003 {"Vendor Unique", "scsi.formatunit.vendor", FT_UINT8, BASE_HEX, NULL,
5005 { &hf_scsi_rdwr6_lba,
5006 {"Logical Block Address (LBA)", "scsi.rdwr6.lba", FT_UINT24, BASE_DEC,
5007 NULL, 0x0FFFFF, "", HFILL}},
5008 { &hf_scsi_rdwr6_xferlen,
5009 {"Transfer Length", "scsi.rdwr6.xferlen", FT_UINT24, BASE_DEC, NULL, 0x0,
5011 { &hf_scsi_rdwr10_lba,
5012 {"Logical Block Address (LBA)", "scsi.rdwr10.lba", FT_UINT32, BASE_DEC,
5013 NULL, 0x0, "", HFILL}},
5014 { &hf_scsi_rdwr10_xferlen,
5015 {"Transfer Length", "scsi.rdwr10.xferlen", FT_UINT16, BASE_DEC, NULL,
5017 { &hf_scsi_read_flags,
5018 {"Flags", "scsi.read.flags", FT_UINT8, BASE_HEX, NULL, 0x0, "",
5020 { &hf_scsi_rdwr12_xferlen,
5021 {"Transfer Length", "scsi.rdwr12.xferlen", FT_UINT32, BASE_DEC, NULL,
5023 { &hf_scsi_rdwr16_lba,
5024 {"Logical Block Address (LBA)", "scsi.rdwr16.lba", FT_BYTES, BASE_DEC,
5025 NULL, 0x0, "", HFILL}},
5026 { &hf_scsi_readcapacity_flags,
5027 {"Flags", "scsi.readcapacity.flags", FT_UINT8, BASE_HEX, NULL, 0x0,
5029 { &hf_scsi_readcapacity_lba,
5030 {"Logical Block Address", "scsi.readcapacity.lba", FT_UINT32, BASE_DEC,
5031 NULL, 0x0, "", HFILL}},
5032 { &hf_scsi_readcapacity_pmi,
5033 {"PMI", "scsi.readcapacity.pmi", FT_UINT8, BASE_DEC, NULL, 0x1, "",
5035 { &hf_scsi_readdefdata_flags,
5036 {"Flags", "scsi.readdefdata.flags", FT_UINT8, BASE_HEX, NULL, 0x0, "",
5038 { &hf_scsi_reassignblks_flags,
5039 {"Flags", "scsi.reassignblks.flags", FT_UINT8, BASE_HEX, NULL, 0x0, "",
5041 { &hf_scsi_inq_qualifier,
5042 {"Peripheral Qualifier", "scsi.inquiry.qualifier", FT_UINT8, BASE_HEX,
5043 VALS (scsi_qualifier_val), 0xE0, "", HFILL}},
5044 { &hf_scsi_inq_devtype,
5045 {"Peripheral Device Type", "scsi.inquiry.devtype", FT_UINT8, BASE_HEX,
5046 VALS (scsi_devtype_val), SCSI_DEV_BITS, "", HFILL}},
5047 { & hf_scsi_inq_version,
5048 {"Version", "scsi.inquiry.version", FT_UINT8, BASE_HEX,
5049 VALS (scsi_inquiry_vers_val), 0x0, "", HFILL}},
5050 { &hf_scsi_inq_normaca,
5051 {"NormACA", "scsi.inquiry.normaca", FT_UINT8, BASE_HEX, NULL, 0x20,
5053 { &hf_scsi_rluns_lun,
5054 {"LUN", "scsi.reportluns.lun", FT_UINT8, BASE_DEC, NULL, 0x0, "",
5056 { &hf_scsi_rluns_multilun,
5057 {"Multi-level LUN", "scsi.reportluns.mlun", FT_BYTES, BASE_HEX, NULL,
5059 { &hf_scsi_modesns_errrep,
5060 {"MRIE", "scsi.mode.mrie", FT_UINT8, BASE_HEX,
5061 VALS (scsi_modesns_mrie_val), 0x0F, "", HFILL}},
5062 { &hf_scsi_modesns_tst,
5063 {"Task Set Type", "scsi.mode.tst", FT_UINT8, BASE_DEC,
5064 VALS (scsi_modesns_tst_val), 0xE0, "", HFILL}},
5065 { &hf_scsi_modesns_qmod,
5066 {"Queue Algorithm Modifier", "scsi.mode.qmod", FT_UINT8, BASE_HEX,
5067 VALS (scsi_modesns_qmod_val), 0xF0, "", HFILL}},
5068 { &hf_scsi_modesns_qerr,
5069 {"Queue Error Management", "scsi.mode.qerr", FT_BOOLEAN, BASE_HEX,
5070 TFS (&scsi_modesns_qerr_val), 0x2, "", HFILL}},
5071 { &hf_scsi_modesns_tas,
5072 {"Task Aborted Status", "scsi.mode.tac", FT_BOOLEAN, BASE_HEX,
5073 TFS (&scsi_modesns_tas_val), 0x80, "", HFILL}},
5074 { &hf_scsi_modesns_rac,
5075 {"Report a Check", "ssci.mode.rac", FT_BOOLEAN, BASE_HEX,
5076 TFS (&scsi_modesns_rac_val), 0x40, "", HFILL}},
5077 { &hf_scsi_protocol,
5078 {"Protocol", "scsi.proto", FT_UINT8, BASE_DEC, VALS (scsi_proto_val),
5080 { &hf_scsi_sns_errtype,
5081 {"SNS Error Type", "scsi.sns.errtype", FT_UINT8, BASE_HEX,
5082 VALS (scsi_sns_errtype_val), 0x7F, "", HFILL}},
5084 {"Sense Key", "scsi.sns.key", FT_UINT8, BASE_HEX,
5085 VALS (scsi_sensekey_val), 0x0F, "", HFILL}},
5087 {"Sense Info", "scsi.sns.info", FT_UINT32, BASE_HEX, NULL, 0x0, "",
5089 { &hf_scsi_addlsnslen,
5090 {"Additional Sense Length", "scsi.sns.addlen", FT_UINT8, BASE_DEC,
5091 NULL, 0x0, "", HFILL}},
5093 {"Additional Sense Code", "scsi.sns.asc", FT_UINT8, BASE_HEX, NULL,
5096 {"Additional Sense Code Qualifier", "scsi.sns.ascq", FT_UINT8,
5097 BASE_HEX, NULL, 0x0, "", HFILL}},
5099 {"Additional Sense Code+Qualifier", "scsi.sns.ascascq", FT_UINT16,
5100 BASE_HEX, VALS (scsi_asc_val), 0x0, "", HFILL}},
5102 {"Field Replaceable Unit Code", "scsi.sns.fru", FT_UINT8, BASE_HEX,
5103 NULL, 0x0, "", HFILL}},
5105 {"SKSV", "scsi.sns.sksv", FT_BOOLEAN, BASE_HEX, NULL, 0x80, "",
5107 { &hf_scsi_persresv_key,
5108 {"Reservation Key", "scsi.spc2.resv.key", FT_BYTES, BASE_HEX, NULL,
5110 { &hf_scsi_persresv_scopeaddr,
5111 {"Scope Address", "scsi.spc2.resv.scopeaddr", FT_BYTES, BASE_HEX, NULL,
5113 { &hf_scsi_add_cdblen,
5114 {"Additional CDB Length", "scsi.spc2.addcdblen", FT_UINT8, BASE_DEC,
5115 NULL, 0x0, "", HFILL}},
5116 { &hf_scsi_svcaction,
5117 {"Service Action", "scsi.spc2.svcaction", FT_UINT16, BASE_HEX, NULL,
5121 /* Setup protocol subtree array */
5122 static gint *ett[] = {
5126 module_t *scsi_module;
5128 /* Register the protocol name and description */
5129 proto_scsi = proto_register_protocol("SCSI", "SCSI", "scsi");
5131 /* Required function calls to register the header fields and subtrees used */
5132 proto_register_field_array(proto_scsi, hf, array_length(hf));
5133 proto_register_subtree_array(ett, array_length(ett));
5134 register_init_routine (&scsi_init_protocol);
5135 data_handle = find_dissector ("data");
5137 /* add preferences to decode SCSI message */
5138 scsi_module = prefs_register_protocol (proto_scsi, NULL);
5139 prefs_register_enum_preference (scsi_module, "decode_scsi_messages_as",
5140 "Decode SCSI Messages As",
5141 "When Target Cannot Be Identified, Decode SCSI Messages As",
5142 &scsi_def_devtype, scsi_devtype_options, TRUE);