1 /* TODO make the contracts require that all functions be called with valid
2  * pointers for itl and itlq and remove all tests for itl/itlq being NULL
3  */
4 /* TODO audit value parameter for proto_tree_add_boolean() calls */
5 /* packet-scsi.c
6  * Routines for decoding SCSI CDBs and responsess
7  * Author: Dinesh G Dutt (ddutt@cisco.com)
8  *
9  * Wireshark - Network traffic analyzer
10  * By Gerald Combs <gerald@wireshark.org>
11  * Copyright 2002 Gerald Combs
12  *
13  * SPDX-License-Identifier: GPL-2.0-or-later
14  */
15 
16 /*
17  * Some Notes on using the SCSI Decoder:
18  *
19  * The SCSI decoder has been built right now so that it is invoked directly by the
20  * SCSI transport layers as compared to the standard mechanism of being invoked
21  * via a dissector chain. There are multiple reasons for this:
22  * - The SCSI CDB is typically embedded inside the transport along with other
23  *   header fields that have nothing to do with SCSI. So, it is required to be
24  *   done this way.
25  * - Originally, Wireshark couldn't do filtering on protocol trees that were not
26  *   on the top level.
27  *
28  * There are four main routines that are provided:
29  * o dissect_scsi_cdb - invoked on receiving a SCSI Command
30  *   void dissect_scsi_cdb(tvbuff_t *, packet_info *, proto_tree *,
31  *                         guint, itlq_nexus_t *, itl_nexus_t *);
32  * o dissect_scsi_payload - invoked to decode SCSI responses
33  *   void dissect_scsi_payload(tvbuff_t *, packet_info *, proto_tree *, guint,
34  *                             gboolean, itlq_nexusu_t *, itl_nexus_t *,
35  *                             guint32 relative_offset);
36  *   The final parameter is the length of the response field that is negotiated
37  *   as part of the SCSI transport layer. If this is not tracked by the
38  *   transport, it can be set to 0.
39  * o dissect_scsi_rsp - invoked to dissect the scsi status code in a response
40  *                      SCSI task.
41  *   void dissect_scsi_rsp(tvbuff_t *, packet_info *, proto_tree *,
42  *                         itlq_nexus_t *, itl_nexus_t *, guint8);
43  * o dissect_scsi_snsinfo - invoked to decode the sense data provided in case of
44  *                          an error.
45  *   void dissect_scsi_snsinfo(tvbuff_t *, packet_info *, proto_tree *, guint,
46  *                             guint, itlq_nexus_t *, itl_nexus_t *);
47  *
48  * In addition to this, the other requirement made from the transport is to
49  * provide ITL and ITLQ structures that are persistent.
50  *
51  * The ITL structure uniquely identifies a Initiator/Target/Lun combination
52  * and is among other things used to keep track of the device type for a
53  * specific LUN.
54  *
55  * The ITLQ structure uniquely identifies a specific scsi task and is used to
56  * keep track of OPCODEs between CDB/DATA/Responses and resp[onse times.
57  *
58  * This decoder attempts to track the type of SCSI device based on the response
59  * to the Inquiry command. If the trace does not contain an Inquiry command,
60  * the decoding of the commands is done as per a user preference. Currently,
61  * only SBC (disks) and SSC (tapes) are the alternatives offered. The basic
62  * SCSI command set (SPC-2/3) is decoded for all SCSI devices. If there is a
63  * mixture of devices in the trace, some with Inquiry response and some
64  * without, the user preference is used only for those devices whose type the
65  * decoder has not been able to determine.
66  *
67  */
68 #include "config.h"
69 
70 #include <stdio.h>
71 #include <epan/packet.h>
72 #include <epan/to_str.h>
73 #include <epan/prefs.h>
74 #include <epan/conversation.h>
75 #include <epan/tap.h>
76 #include <epan/reassemble.h>
77 #include <epan/expert.h>
78 #include "packet-scsi.h"
79 #include "packet-scsi-osd.h"
80 #include "packet-scsi-mmc.h"
81 #include "packet-scsi-sbc.h"
82 #include "packet-scsi-ssc.h"
83 #include "packet-scsi-smc.h"
84 
85 void proto_register_scsi(void);
86 
87 static int proto_scsi                           = -1;
88 static int hf_scsi_inq_control_vendor_specific  = -1;
89 static int hf_scsi_inq_control_reserved         = -1;
90 static int hf_scsi_inq_control_naca             = -1;
91 static int hf_scsi_inq_control_obs1             = -1;
92 static int hf_scsi_inq_control_obs2             = -1;
93 static int hf_scsi_inq_control                  = -1;
94 static int hf_scsi_control_vendor_specific      = -1;
95 static int hf_scsi_control_reserved             = -1;
96 static int hf_scsi_control_naca                 = -1;
97 static int hf_scsi_control_obs1                 = -1;
98 static int hf_scsi_control_obs2                 = -1;
99 int hf_scsi_control                      = -1;
100 int hf_scsi_alloclen16                   = -1;
101 static int hf_scsi_alloclen32                   = -1;
102 static int hf_scsi_time                         = -1;
103 static int hf_scsi_request_frame                = -1;
104 static int hf_scsi_response_frame               = -1;
105 static int hf_scsi_status                       = -1;
106 static int hf_scsi_spcopcode                    = -1;
107 static int hf_scsi_inquiry_flags                = -1;
108 static int hf_scsi_inquiry_evpd_page            = -1;
109 static int hf_scsi_inquiry_cmdt_page            = -1;
110 static int hf_scsi_alloclen                     = -1;
111 static int hf_scsi_paramlen                     = -1;
112 static int hf_scsi_paramlen16                   = -1;
113 static int hf_scsi_modesel_flags                = -1;
114 static int hf_scsi_modesns_pc                   = -1;
115 static int hf_scsi_modepage_ps                  = -1;
116 static int hf_scsi_modepage_spf                 = -1;
117 static int hf_scsi_modepage_plen                = -1;
118 static int hf_scsi_modepage_tcmos               = -1;
119 static int hf_scsi_modepage_scsip               = -1;
120 static int hf_scsi_modepage_ialuae              = -1;
121 static int hf_scsi_modepage_icp                 = -1;
122 static int hf_scsi_modepage_msdl                = -1;
123 static int hf_scsi_spc_pagecode                 = -1;
124 static int hf_scsi_spc_subpagecode              = -1;
125 static int hf_scsi_sbcpagecode                  = -1;
126 static int hf_scsi_sscpagecode                  = -1;
127 static int hf_scsi_smcpagecode                  = -1;
128 static int hf_scsi_mmcpagecode                  = -1;
129 static int hf_scsi_modesns_flags                = -1;
130 static int hf_scsi_persresvin_svcaction         = -1;
131 static int hf_scsi_persresvout_svcaction        = -1;
132 static int hf_scsi_persresv_scope               = -1;
133 static int hf_scsi_persresv_type                = -1;
134 static int hf_scsi_persresvout_reskey           = -1;
135 static int hf_scsi_persresvout_sareskey         = -1;
136 static int hf_scsi_persresvout_obsolete         = -1;
137 static int hf_scsi_persresvout_control          = -1;
138 static int hf_scsi_persresvout_rel_tpi          = -1;
139 static int hf_scsi_persresvout_transportid_len  = -1;
140 static int hf_scsi_persresvout_transportid      = -1;
141 static int hf_scsi_persresv_control_rsvd        = -1;
142 static int hf_scsi_persresv_control_rsvd1       = -1;
143 static int hf_scsi_persresv_control_rsvd2       = -1;
144 static int hf_scsi_persresv_control_spec_i_pt   = -1;
145 static int hf_scsi_persresv_control_all_tg_pt   = -1;
146 static int hf_scsi_persresv_control_aptpl       = -1;
147 static int hf_scsi_persresv_control_unreg       = -1;
148 static int hf_scsi_release_flags                = -1;
149 static int hf_scsi_release_thirdpartyid         = -1;
150 static int hf_scsi_select_report                = -1;
151 static int hf_scsi_inq_add_len                  = -1;
152 static int hf_scsi_inq_peripheral               = -1;
153 static int hf_scsi_inq_qualifier                = -1;
154 static int hf_scsi_inq_vendor_id                = -1;
155 static int hf_scsi_inq_product_id               = -1;
156 static int hf_scsi_inq_product_rev              = -1;
157 static int hf_scsi_inq_vendor_specific          = -1;
158 static int hf_scsi_inq_version_desc             = -1;
159 static int hf_scsi_inq_devtype                  = -1;
160 static int hf_scsi_inq_rmb                      = -1;
161 static int hf_scsi_inq_version                  = -1;
162 static int hf_scsi_lun_address_mode             = -1;
163 static int hf_scsi_lun                          = -1;
164 static int hf_scsi_lun_extended                 = -1;
165 static int hf_scsi_extended_add_method_len      = -1;
166 static int hf_scsi_extended_add_method          = -1;
167 static int hf_scsi_bus                          = -1;
168 static int hf_scsi_target                       = -1;
169 static int hf_scsi_modesns_errrep               = -1;
170 static int hf_scsi_modesns_tst                  = -1;
171 static int hf_scsi_modesns_qmod                 = -1;
172 static int hf_scsi_modesns_qerr                 = -1;
173 static int hf_scsi_modesns_rac                  = -1;
174 static int hf_scsi_modesns_tas                  = -1;
175 static int hf_scsi_protocol                     = -1;
176 static int hf_scsi_sns_errtype                  = -1;
177 static int hf_scsi_snskey                       = -1;
178 static int hf_scsi_snsinfo                      = -1;
179 static int hf_scsi_addlsnslen                   = -1;
180 static int hf_scsi_asc                          = -1;
181 static int hf_scsi_ascascq                      = -1;
182 static int hf_scsi_ascq                         = -1;
183 static int hf_scsi_fru                          = -1;
184 static int hf_scsi_sksv                         = -1;
185 static int hf_scsi_sks_info                     = -1;
186 static int hf_scsi_sks_fp_cd                    = -1;
187 static int hf_scsi_sks_fp_bpv                   = -1;
188 static int hf_scsi_sks_fp_bit                   = -1;
189 static int hf_scsi_sks_fp_field                 = -1;
190 static int hf_scsi_sns_desc_type                = -1;
191 static int hf_scsi_sns_desc_length              = -1;
192 static int hf_scsi_sns_osd_object_not_initiated = -1;
193 static int hf_scsi_sns_osd_object_completed     = -1;
194 static int hf_scsi_sns_osd_object_validation    = -1;
195 static int hf_scsi_sns_osd_object_cmd_cap_v     = -1;
196 static int hf_scsi_sns_osd_object_command       = -1;
197 static int hf_scsi_sns_osd_object_imp_st_att    = -1;
198 static int hf_scsi_sns_osd_object_sa_cap_v      = -1;
199 static int hf_scsi_sns_osd_object_set_att       = -1;
200 static int hf_scsi_sns_osd_object_ga_cap_v      = -1;
201 static int hf_scsi_sns_osd_object_get_att       = -1;
202 static int hf_scsi_sns_osd_partition_id         = -1;
203 static int hf_scsi_sns_osd_object_id            = -1;
204 static int hf_scsi_sns_osd_attr_page            = -1;
205 static int hf_scsi_sns_osd_attr_number          = -1;
206 static int hf_scsi_inq_reladrflags              = -1;
207 static int hf_scsi_inq_reladr                   = -1;
208 static int hf_scsi_inq_linked                   = -1;
209 static int hf_scsi_inq_trandis                  = -1;
210 static int hf_scsi_inq_cmdque                   = -1;
211 static int hf_scsi_inq_bqueflags                = -1;
212 static int hf_scsi_inq_bque                     = -1;
213 static int hf_scsi_inq_encserv                  = -1;
214 static int hf_scsi_inq_multip                   = -1;
215 static int hf_scsi_inq_mchngr                   = -1;
216 static int hf_scsi_inq_ackreqq                  = -1;
217 static int hf_scsi_inq_sccsflags                = -1;
218 static int hf_scsi_inq_sccs                     = -1;
219 static int hf_scsi_inq_acc                      = -1;
220 static int hf_scsi_inq_tpc                      = -1;
221 static int hf_scsi_inq_protect                  = -1;
222 static int hf_scsi_inq_tpgs                     = -1;
223 static int hf_scsi_inq_acaflags                 = -1;
224 static int hf_scsi_inq_rmbflags                 = -1;
225 static int hf_scsi_inq_normaca                  = -1;
226 static int hf_scsi_inq_hisup                    = -1;
227 static int hf_scsi_inq_aerc                     = -1;
228 static int hf_scsi_inq_trmtsk                   = -1;
229 static int hf_scsi_inq_rdf                      = -1;
230 static int hf_scsi_persresv_key                 = -1;
231 static int hf_scsi_persresv_scopeaddr           = -1;
232 static int hf_scsi_add_cdblen                   = -1;
233 static int hf_scsi_svcaction                    = -1;
234 static int hf_scsi_wb_mode                      = -1;
235 static int hf_scsi_wb_bufferid                  = -1;
236 static int hf_scsi_wb_bufoffset                 = -1;
237 static int hf_scsi_paramlen24                   = -1;
238 static int hf_scsi_senddiag_st_code             = -1;
239 static int hf_scsi_senddiag_pf                  = -1;
240 static int hf_scsi_senddiag_st                  = -1;
241 static int hf_scsi_senddiag_devoff              = -1;
242 static int hf_scsi_senddiag_unitoff             = -1;
243 static int hf_scsi_fragments                    = -1;
244 static int hf_scsi_fragment                     = -1;
245 static int hf_scsi_fragment_overlap             = -1;
246 static int hf_scsi_fragment_overlap_conflict    = -1;
247 static int hf_scsi_fragment_multiple_tails      = -1;
248 static int hf_scsi_fragment_too_long_fragment   = -1;
249 static int hf_scsi_fragment_error               = -1;
250 static int hf_scsi_fragment_count               = -1;
251 static int hf_scsi_reassembled_in               = -1;
252 static int hf_scsi_reassembled_length           = -1;
253 static int hf_scsi_log_ppc_flags                = -1;
254 static int hf_scsi_log_pc_flags                 = -1;
255 static int hf_scsi_log_parameter_ptr            = -1;
256 static int hf_scsi_log_ppc                      = -1;
257 static int hf_scsi_log_pcr                      = -1;
258 static int hf_scsi_log_sp                       = -1;
259 static int hf_scsi_log_pagecode                 = -1;
260 static int hf_scsi_log_pc                       = -1;
261 static int hf_scsi_log_page_length              = -1;
262 static int hf_scsi_log_parameter_code           = -1;
263 static int hf_scsi_log_param_len                = -1;
264 static int hf_scsi_log_param_flags              = -1;
265 static int hf_scsi_log_param_data               = -1;
266 static int hf_scsi_log_pf_du                    = -1;
267 static int hf_scsi_log_pf_ds                    = -1;
268 static int hf_scsi_log_pf_tsd                   = -1;
269 static int hf_scsi_log_pf_etc                   = -1;
270 static int hf_scsi_log_pf_tmc                   = -1;
271 static int hf_scsi_log_pf_lbin                  = -1;
272 static int hf_scsi_log_pf_lp                    = -1;
273 static int hf_scsi_log_ta_rw                    = -1;
274 static int hf_scsi_log_ta_ww                    = -1;
275 static int hf_scsi_log_ta_he                    = -1;
276 static int hf_scsi_log_ta_media                 = -1;
277 static int hf_scsi_log_ta_rf                    = -1;
278 static int hf_scsi_log_ta_wf                    = -1;
279 static int hf_scsi_log_ta_ml                    = -1;
280 static int hf_scsi_log_ta_ndg                   = -1;
281 static int hf_scsi_log_ta_wp                    = -1;
282 static int hf_scsi_log_ta_nr                    = -1;
283 static int hf_scsi_log_ta_cm                    = -1;
284 static int hf_scsi_log_ta_uf                    = -1;
285 static int hf_scsi_log_ta_rmcf                  = -1;
286 static int hf_scsi_log_ta_umcf                  = -1;
287 static int hf_scsi_log_ta_mcicf                 = -1;
288 static int hf_scsi_log_ta_fe                    = -1;
289 static int hf_scsi_log_ta_rof                   = -1;
290 static int hf_scsi_log_ta_tdcol                 = -1;
291 static int hf_scsi_log_ta_nml                   = -1;
292 static int hf_scsi_log_ta_cn                    = -1;
293 static int hf_scsi_log_ta_cp                    = -1;
294 static int hf_scsi_log_ta_ecm                   = -1;
295 static int hf_scsi_log_ta_ict                   = -1;
296 static int hf_scsi_log_ta_rr                    = -1;
297 static int hf_scsi_log_ta_dpie                  = -1;
298 static int hf_scsi_log_ta_cff                   = -1;
299 static int hf_scsi_log_ta_psf                   = -1;
300 static int hf_scsi_log_ta_pc                    = -1;
301 static int hf_scsi_log_ta_dm                    = -1;
302 static int hf_scsi_log_ta_hwa                   = -1;
303 static int hf_scsi_log_ta_hwb                   = -1;
304 static int hf_scsi_log_ta_if                    = -1;
305 static int hf_scsi_log_ta_em                    = -1;
306 static int hf_scsi_log_ta_dwf                   = -1;
307 static int hf_scsi_log_ta_drhu                  = -1;
308 static int hf_scsi_log_ta_drtm                  = -1;
309 static int hf_scsi_log_ta_drvo                  = -1;
310 static int hf_scsi_log_ta_pefa                  = -1;
311 static int hf_scsi_log_ta_dire                  = -1;
312 static int hf_scsi_log_ta_lost                  = -1;
313 static int hf_scsi_log_ta_tduau                 = -1;
314 static int hf_scsi_log_ta_tsawf                 = -1;
315 static int hf_scsi_log_ta_tsarf                 = -1;
316 static int hf_scsi_log_ta_nsod                  = -1;
317 static int hf_scsi_log_ta_lofa                  = -1;
318 static int hf_scsi_log_ta_uuf                   = -1;
319 static int hf_scsi_log_ta_aif                   = -1;
320 static int hf_scsi_log_ta_fwf                   = -1;
321 static int hf_scsi_log_ta_wmicf                 = -1;
322 static int hf_scsi_log_ta_wmoa                  = -1;
323 static int hf_scsi_sbc_threshold_exponent       = -1;
324 static int hf_scsi_sbc_lbpu                     = -1;
325 static int hf_scsi_sbc_lbpws                    = -1;
326 static int hf_scsi_sbc_lbpws10                  = -1;
327 static int hf_scsi_sbc_lbprz                    = -1;
328 static int hf_scsi_sbc_anc_sup                  = -1;
329 static int hf_scsi_sbc_dp                       = -1;
330 static int hf_scsi_sbc_ptype                    = -1;
331 static int hf_scsi_block_limits_wsnz            = -1;
332 static int hf_scsi_block_limits_mcawl           = -1;
333 static int hf_scsi_block_limits_otlg            = -1;
334 static int hf_scsi_block_limits_mtl             = -1;
335 static int hf_scsi_block_limits_otl             = -1;
336 static int hf_scsi_block_limits_mpl             = -1;
337 static int hf_scsi_block_limits_mulc            = -1;
338 static int hf_scsi_block_limits_mubdc           = -1;
339 static int hf_scsi_block_limits_oug             = -1;
340 static int hf_scsi_block_limits_ugavalid        = -1;
341 static int hf_scsi_block_limits_uga             = -1;
342 static int hf_scsi_block_limits_mwsl            = -1;
343 static int hf_scsi_block_limits_matl            = -1;
344 static int hf_scsi_block_limits_aa              = -1;
345 static int hf_scsi_block_limits_atlg            = -1;
346 static int hf_scsi_prevent_allow_flags          = -1;
347 static int hf_scsi_prevent_allow_prevent        = -1;
348 static int hf_scsi_mpi_service_action           = -1;
349 static int hf_scsi_report_opcodes_rctd          = -1;
350 static int hf_scsi_report_opcodes_options       = -1;
351 static int hf_scsi_report_opcodes_requested_o   = -1;
352 static int hf_scsi_report_opcodes_requested_sa  = -1;
353 static int hf_scsi_report_opcodes_cdl           = -1;
354 static int hf_scsi_report_opcodes_sa            = -1;
355 static int hf_scsi_report_opcodes_ctdp          = -1;
356 static int hf_scsi_report_opcodes_ctdp_one      = -1;
357 static int hf_scsi_report_opcodes_servactv      = -1;
358 static int hf_scsi_report_opcodes_cdb_length    = -1;
359 static int hf_scsi_report_opcodes_support       = -1;
360 static int hf_scsi_report_opcodes_cdb_usage_data = -1;
361 static int hf_scsi_report_opcodes_tdl           = -1;
362 static int hf_scsi_report_opcodes_npt           = -1;
363 static int hf_scsi_report_opcodes_rct           = -1;
364 static int hf_scsi_inquiry_bdc_mrr              = -1;
365 static int hf_scsi_inquiry_bdc_pt               = -1;
366 static int hf_scsi_inquiry_bdc_wabereq          = -1;
367 static int hf_scsi_inquiry_bdc_wacereq          = -1;
368 static int hf_scsi_inquiry_bdc_nff              = -1;
369 static int hf_scsi_inquiry_bdc_fuab              = -1;
370 static int hf_scsi_inquiry_bdc_vbuls            = -1;
371 /* Generated from convert_proto_tree_add_text.pl */
372 static int hf_scsi_smc_modepage_first_storage_element_address = -1;
373 static int hf_scsi_smc_modepage_first_medium_transport_element_address = -1;
374 static int hf_scsi_ssc2_modepage_dde = -1;
375 static int hf_scsi_inq_cmddt_version = -1;
376 static int hf_scsi_mmc5_modepage_number_of_volume_levels_supported = -1;
377 static int hf_scsi_ssc2_modepage_dce = -1;
378 static int hf_scsi_modesel_block_descriptor_length16 = -1;
379 static int hf_scsi_mmc5_modepage_audio_pause_length = -1;
380 static int hf_scsi_spc_modepage_idle_condition_timer = -1;
381 static int hf_scsi_blockdescs_block_length24 = -1;
382 static int hf_scsi_spc_modepage_report_count = -1;
383 static int hf_scsi_spc_modepage_ready_aer_holdoff_period = -1;
384 static int hf_scsi_sbc_modepage_non_cache_segment_size = -1;
385 static int hf_scsi_blockdescs_no_of_blocks64 = -1;
386 static int hf_scsi_spc_modepage_gltsd = -1;
387 static int hf_scsi_smc_modepage_st_ne_dt = -1;
388 static int hf_scsi_modesel_dev_sbc_medium_type = -1;
389 static int hf_scsi_inq_evpd_devid_identifier_type = -1;
390 static int hf_scsi_inq_evpd_identifier_number = -1;
391 static int hf_scsi_sbc_modepage_write_retry_count = -1;
392 static int hf_scsi_spc_modepage_buffer_empty_ratio = -1;
393 static int hf_scsi_ssc2_modepage_partition_size = -1;
394 static int hf_scsi_mmc5_modepage_initiator_application_code = -1;
395 static int hf_scsi_sbc_modepage_demand_read_retention_priority = -1;
396 static int hf_scsi_smc_modepage_dt_dt = -1;
397 static int hf_scsi_sbc_modepage_ssec = -1;
398 static int hf_scsi_smc_modepage_number_of_medium_transport_elements = -1;
399 static int hf_scsi_mmc5_modepage_copy_management_revision_support = -1;
400 static int hf_scsi_ssc2_modepage_maximum_additional_partitions = -1;
401 static int hf_scsi_blockdescs_density_code = -1;
402 static int hf_scsi_ssc2_modepage_write_object_buffer_full_ratio = -1;
403 static int hf_scsi_spc_modepage_rr_tov = -1;
404 static int hf_scsi_inq_cmddt_support = -1;
405 static int hf_scsi_mmc5_modepage_packet_size = -1;
406 static int hf_scsi_ssc2_modepage_fdp = -1;
407 static int hf_scsi_spc_modepage_autoload_mode = -1;
408 static int hf_scsi_mmc5_modepage_rw_in_lead_in = -1;
409 static int hf_scsi_spc_modepage_perf = -1;
410 static int hf_scsi_inq_evpd_devid_association = -1;
411 static int hf_scsi_smc_modepage_stordt = -1;
412 static int hf_scsi_smc_modepage_ie_dt = -1;
413 static int hf_scsi_spc_modepage_disable_queuing = -1;
414 static int hf_scsi_sbc_modepage_maximum_pre_fetch_ceiling = -1;
415 static int hf_scsi_persresvin_generation_number = -1;
416 static int hf_scsi_ssc2_modepage_read_object_buffer_empty_ratio = -1;
417 static int hf_scsi_spc_modepage_extended_self_test_completion_time = -1;
418 static int hf_scsi_smc_modepage_number_of_import_export_elements = -1;
419 static int hf_scsi_smc_modepage_number_of_storage_elements = -1;
420 static int hf_scsi_sbc_modepage_landing_zone_cyl = -1;
421 static int hf_scsi_smc_modepage_mt_ne_dt = -1;
422 static int hf_scsi_mmc5_modepage_loading_mechanism_type = -1;
423 static int hf_scsi_smc_modepage_mt_dt = -1;
424 static int hf_scsi_smc_modepage_first_import_export_element_address = -1;
425 static int hf_scsi_mmc5_modepage_link_size = -1;
426 static int hf_scsi_ssc2_modepage_decompression_algorithm = -1;
427 static int hf_scsi_reportluns_lun_list_length = -1;
428 static int hf_scsi_spc_modepage_idle = -1;
429 static int hf_scsi_spc_modepage_emdp = -1;
430 static int hf_scsi_inq_evpd_devid_code_set = -1;
431 static int hf_scsi_modesel_longlba = -1;
432 static int hf_scsi_mmc5_modepage_bufe = -1;
433 static int hf_scsi_ssc2_modepage_select_data_compression_algorithm = -1;
434 static int hf_scsi_mmc5_modepage_rotation_control_selected = -1;
435 static int hf_scsi_mmc5_modepage_sub_header_byte = -1;
436 static int hf_scsi_spc_modepage_rr_tov_units = -1;
437 static int hf_scsi_mmc5_modepage_vendor_specific = -1;
438 static int hf_scsi_modesel_block_descriptor_length8 = -1;
439 static int hf_scsi_smc_modepage_ie_ne_dt = -1;
440 static int hf_scsi_modesel_device_specific_parameter = -1;
441 static int hf_scsi_spc_modepage_connect_time_limit = -1;
442 static int hf_scsi_sbc_modepage_medium_rotation_rate = -1;
443 static int hf_scsi_inq_evpd_devid_identifier_length = -1;
444 static int hf_scsi_blockdescs_no_of_blocks32 = -1;
445 static int hf_scsi_inq_evpd_devid_identifier_str = -1;
446 static int hf_scsi_sns_valid = -1;
447 static int hf_scsi_mmc5_modepage_dvd_ram_read = -1;
448 static int hf_scsi_ssc2_modepage_gap_size = -1;
449 static int hf_scsi_smc_modepage_first_data_transfer_element_address = -1;
450 static int hf_scsi_mmc5_modepage_wrparam_multi_session = -1;
451 static int hf_scsi_mmc5_modepage_num_write_speed_performance = -1;
452 static int hf_scsi_mmc5_modepage_buf = -1;
453 static int hf_scsi_mmc5_modepage_lba_space = -1;
454 static int hf_scsi_mmc5_modepage_data_block_type = -1;
455 static int hf_scsi_ssc2_modepage_additional_partitions_defined = -1;
456 static int hf_scsi_spc_modepage_dtfd = -1;
457 static int hf_scsi_spc_modepage_disconnect_time_limit = -1;
458 static int hf_scsi_sbc_modepage_read_retry_count = -1;
459 static int hf_scsi_mmc5_modepage_length = -1;
460 static int hf_scsi_sns_filemark = -1;
461 static int hf_scsi_sbc_modepage_alternate_tracks_per_zone = -1;
462 static int hf_scsi_ssc2_modepage_eod_defined = -1;
463 static int hf_scsi_mmc5_modepage_media_catalog_number = -1;
464 static int hf_scsi_mmc5_modepage_current_write_speed_selected = -1;
465 static int hf_scsi_inq_evpd_devid_identifier_bytes = -1;
466 static int hf_scsi_spc_modepage_interval_timer = -1;
467 static int hf_scsi_ssc2_modepage_oir = -1;
468 static int hf_scsi_sbc_modepage_correction_span = -1;
469 static int hf_scsi_mmc5_modepage_session_format = -1;
470 static int hf_scsi_sbc_modepage_minimum_pre_fetch = -1;
471 static int hf_scsi_spc_modepage_maximum_burst_size = -1;
472 static int hf_scsi_ssc2_modepage_partition_units = -1;
473 static int hf_scsi_sbc_modepage_cache_segment_size = -1;
474 static int hf_scsi_blockdescs_block_length32 = -1;
475 static int hf_scsi_sbc_modepage_number_of_cylinders = -1;
476 static int hf_scsi_sbc_modepage_alternate_tracks_per_lu = -1;
477 static int hf_scsi_inq_evpd_page_length = -1;
478 static int hf_scsi_sbc_modepage_starting_cyl_pre_compensation = -1;
479 static int hf_scsi_sbc_modepage_head_offset_count = -1;
480 static int hf_scsi_sbc_modepage_ic = -1;
481 static int hf_scsi_modesel_mode_data_length16 = -1;
482 static int hf_scsi_sbc_modepage_maximum_pre_fetch = -1;
483 static int hf_scsi_smc_modepage_number_of_data_transfer_elements = -1;
484 static int hf_scsi_ssc2_modepage_object_buffer_size_at_early_warning = -1;
485 static int hf_scsi_mmc5_modepage_buffer_size_supported = -1;
486 static int hf_scsi_persresvin_additional_length = -1;
487 static int hf_scsi_ssc2_modepage_obr = -1;
488 static int hf_scsi_spc_modepage_swp = -1;
489 static int hf_scsi_inq_evpd_supported_page = -1;
490 static int hf_scsi_sbc_modepage_awre = -1;
491 static int hf_scsi_smc_modepage_dt_ne_dt = -1;
492 static int hf_scsi_mmc5_modepage_read_bar_code = -1;
493 static int hf_scsi_ssc2_modepage_media_format_recognition = -1;
494 static int hf_scsi_sns_command_specific_information = -1;
495 static int hf_scsi_ssc2_modepage_write_delay_time = -1;
496 static int hf_scsi_sbc_modepage_track_skew_factor = -1;
497 static int hf_scsi_spc_modepage_standby_condition_timer = -1;
498 static int hf_scsi_sbc_modepage_interleave = -1;
499 static int hf_scsi_sbc_modepage_alternate_sectors_per_zone = -1;
500 static int hf_scsi_sbc_modepage_rotational_offset = -1;
501 static int hf_scsi_spc_modepage_buffer_full_ratio = -1;
502 static int hf_scsi_sbc_modepage_number_of_heads = -1;
503 static int hf_scsi_sbc_modepage_sectors_per_track = -1;
504 static int hf_scsi_sbc_modepage_recovery_time_limit = -1;
505 static int hf_scsi_sbc_modepage_tracks_per_zone = -1;
506 static int hf_scsi_spc_modepage_first_burst_size = -1;
507 static int hf_scsi_inq_evpd_product_serial_number = -1;
508 static int hf_scsi_sbc_modepage_cylinder_skew_factor = -1;
509 static int hf_scsi_sbc_modepage_data_bytes_per_physical_sector = -1;
510 static int hf_scsi_ssc2_modepage_compression_algorithm = -1;
511 static int hf_scsi_ssc2_modepage_caf = -1;
512 static int hf_scsi_sbc_modepage_starting_cyl_reduced_write_current = -1;
513 static int hf_scsi_inq_cmddt_cdb_size = -1;
514 static int hf_scsi_mmc5_modepage_international_standard_recording_code = -1;
515 static int hf_scsi_spc_modepage_bus_inactivity_limit = -1;
516 static int hf_scsi_sbc_modepage_disable_pre_fetch_xfer_len = -1;
517 static int hf_scsi_spc_modepage_busy_timeout_period = -1;
518 static int hf_scsi_sbc_modepage_fsw = -1;
519 static int hf_scsi_ssc2_modepage_active_partition = -1;
520 static int hf_scsi_modesel_mode_data_length8 = -1;
521 static int hf_scsi_smc_modepage_st_dt = -1;
522 static int hf_scsi_sbc_modepage_number_of_cache_segments = -1;
523 static int hf_scsi_blockdescs_no_of_blocks24 = -1;
524 static int hf_scsi_sbc_modepage_data_strobe_offset_count = -1;
525 static int hf_scsi_modesel_medium_type = -1;
526 static int hf_scsi_sbc_modepage_device_step_rate = -1;
527 static int hf_scsi_mmc5_modepage_dvd_ram_write = -1;
528 static int hf_scsi_mmc5_modepage_track_mode = -1;
529 static int hf_scsi_smc_modepage_mt_ne_mt = -1;
530 static int hf_scsi_smc_modepage_dt_mt = -1;
531 static int hf_scsi_mmc5_modepage_eject = -1;
532 static int hf_scsi_mmc5_modepage_mode_2_form2 = -1;
533 static int hf_scsi_sbc_modepage_dra = -1;
534 static int hf_scsi_mmc5_modepage_dvd_rom_write = -1;
535 static int hf_scsi_sbc_modepage_eer = -1;
536 static int hf_scsi_mmc5_modepage_cd_da_cmds_supported = -1;
537 static int hf_scsi_smc_modepage_ie_ne_mt = -1;
538 static int hf_scsi_mmc5_modepage_rw_deinterleaved_corrected = -1;
539 static int hf_scsi_sbc_modepage_vendor_specific = -1;
540 static int hf_scsi_spc_modepage_report_log_exception_condition = -1;
541 static int hf_scsi_mmc5_modepage_c2_pointers_supported = -1;
542 static int hf_scsi_mmc5_modepage_ls_v = -1;
543 static int hf_scsi_sbc_modepage_tb = -1;
544 static int hf_scsi_sbc_modepage_write_retention_priority = -1;
545 static int hf_scsi_smc_modepage_mt_ne_ie = -1;
546 static int hf_scsi_ssc2_modepage_prmwp = -1;
547 static int hf_scsi_sbc_modepage_surf = -1;
548 static int hf_scsi_sns_ili = -1;
549 static int hf_scsi_smc_modepage_mt_ie = -1;
550 static int hf_scsi_sbc_modepage_rcd = -1;
551 static int hf_scsi_mmc5_modepage_composite = -1;
552 static int hf_scsi_sbc_modepage_wce = -1;
553 static int hf_scsi_mmc5_modepage_method_2 = -1;
554 static int hf_scsi_ssc2_modepage_clear = -1;
555 static int hf_scsi_sbc_modepage_lbcss = -1;
556 static int hf_scsi_mmc5_modepage_cd_r_read = -1;
557 static int hf_scsi_spc_modepage_test = -1;
558 static int hf_scsi_ssc2_modepage_rsmk = -1;
559 static int hf_scsi_spc_modepage_rha = -1;
560 static int hf_scsi_mmc5_modepage_lsbf = -1;
561 static int hf_scsi_mmc5_modepage_cd_rw_write = -1;
562 static int hf_scsi_mmc5_modepage_wrparam_test_write = -1;
563 static int hf_scsi_ssc2_modepage_eeg = -1;
564 static int hf_scsi_mmc5_modepage_digital_port2 = -1;
565 static int hf_scsi_mmc5_modepage_copy = -1;
566 static int hf_scsi_sbc_modepage_abpf = -1;
567 static int hf_scsi_spc_modepage_alwi = -1;
568 static int hf_scsi_mmc5_modepage_bckf = -1;
569 static int hf_scsi_ssc2_modepage_dsp = -1;
570 static int hf_scsi_mmc5_modepage_mode_2_form1 = -1;
571 static int hf_scsi_smc_modepage_stormt = -1;
572 static int hf_scsi_mmc5_modepage_mmcap_test_write = -1;
573 static int hf_scsi_smc_modepage_st_mt = -1;
574 static int hf_scsi_ssc2_modepage_sew = -1;
575 static int hf_scsi_ssc2_modepage_psum = -1;
576 static int hf_scsi_mmc5_modepage_dvd_r_read = -1;
577 static int hf_scsi_ssc2_modepage_asocwp = -1;
578 static int hf_scsi_smc_modepage_st_ie = -1;
579 static int hf_scsi_mmc5_modepage_cd_rw_read = -1;
580 static int hf_scsi_spc_modepage_standby = -1;
581 static int hf_scsi_spc_modepage_ewasc = -1;
582 static int hf_scsi_sbc_modepage_arre = -1;
583 static int hf_scsi_smc_modepage_st_st = -1;
584 static int hf_scsi_ssc2_modepage_swp = -1;
585 static int hf_scsi_smc_modepage_storie = -1;
586 static int hf_scsi_mmc5_modepage_fp = -1;
587 static int hf_scsi_ssc2_modepage_red = -1;
588 static int hf_scsi_ssc2_modepage_active_format = -1;
589 static int hf_scsi_mmc5_modepage_mmcap_multi_session = -1;
590 static int hf_scsi_mmc5_modepage_lock_state = -1;
591 static int hf_scsi_mmc5_modepage_side_change_capable = -1;
592 static int hf_scsi_mmc5_modepage_dvd_rom_read = -1;
593 static int hf_scsi_sns_eom = -1;
594 static int hf_scsi_sbc_modepage_rc = -1;
595 static int hf_scsi_mmc5_modepage_lock = -1;
596 static int hf_scsi_sbc_modepage_per = -1;
597 static int hf_scsi_ssc2_modepage_socf = -1;
598 static int hf_scsi_sbc_modepage_mf = -1;
599 static int hf_scsi_smc_modepage_ie_st = -1;
600 static int hf_scsi_mmc5_modepage_digital_port1 = -1;
601 static int hf_scsi_sbc_modepage_hsec = -1;
602 static int hf_scsi_sbc_modepage_cap = -1;
603 static int hf_scsi_smc_modepage_st_ne_ie = -1;
604 static int hf_scsi_spc_modepage_logerr = -1;
605 static int hf_scsi_sbc_modepage_rmb = -1;
606 static int hf_scsi_mmc5_modepage_prevent_jumper = -1;
607 static int hf_scsi_smc_modepage_ie_mt = -1;
608 static int hf_scsi_mmc5_modepage_changer_supports_disc_present = -1;
609 static int hf_scsi_mmc5_modepage_cd_r_write = -1;
610 static int hf_scsi_ssc2_modepage_addp = -1;
611 static int hf_scsi_mmc5_modepage_dvd_r_write = -1;
612 static int hf_scsi_spc_modepage_dexcpt = -1;
613 static int hf_scsi_spc_modepage_ebf = -1;
614 static int hf_scsi_mmc5_modepage_write_type = -1;
615 static int hf_scsi_spc_modepage_fab = -1;
616 static int hf_scsi_smc_modepage_ie_ne_st = -1;
617 static int hf_scsi_ssc2_modepage_baml = -1;
618 static int hf_scsi_smc_modepage_storst = -1;
619 static int hf_scsi_sbc_modepage_dte = -1;
620 static int hf_scsi_mmc5_modepage_separate_volume_levels = -1;
621 static int hf_scsi_mmc5_modepage_isrc = -1;
622 static int hf_scsi_smc_modepage_dt_ne_mt = -1;
623 static int hf_scsi_mmc5_modepage_audio_play = -1;
624 static int hf_scsi_mmc5_modepage_separate_channel_mute = -1;
625 static int hf_scsi_ssc2_modepage_rew = -1;
626 static int hf_scsi_sbc_modepage_dcr = -1;
627 static int hf_scsi_smc_modepage_dt_ie = -1;
628 static int hf_scsi_ssc2_modepage_avc = -1;
629 static int hf_scsi_sbc_modepage_size = -1;
630 static int hf_scsi_mmc5_modepage_rw_supported = -1;
631 static int hf_scsi_spc_modepage_dtipe = -1;
632 static int hf_scsi_mmc5_modepage_sw_slot_selection = -1;
633 static int hf_scsi_ssc2_modepage_pofm = -1;
634 static int hf_scsi_spc_modepage_dlm = -1;
635 static int hf_scsi_spc_modepage_plpb = -1;
636 static int hf_scsi_smc_modepage_st_ne_st = -1;
637 static int hf_scsi_smc_modepage_dt_ne_st = -1;
638 static int hf_scsi_smc_modepage_st_ne_mt = -1;
639 static int hf_scsi_ssc2_modepage_robo = -1;
640 static int hf_scsi_spc_modepage_faa = -1;
641 static int hf_scsi_spc_modepage_ddis = -1;
642 static int hf_scsi_mmc5_modepage_cd_da_stream_is_accurate = -1;
643 static int hf_scsi_ssc2_modepage_bam = -1;
644 static int hf_scsi_spc_modepage_fac = -1;
645 static int hf_scsi_smc_modepage_mt_st = -1;
646 static int hf_scsi_smc_modepage_ie_ie = -1;
647 static int hf_scsi_smc_modepage_dt_ne_ie = -1;
648 static int hf_scsi_ssc2_modepage_lois = -1;
649 static int hf_scsi_spc_modepage_dtoli = -1;
650 static int hf_scsi_sbc_modepage_disc = -1;
651 static int hf_scsi_smc_modepage_ie_ne_ie = -1;
652 static int hf_scsi_smc_modepage_mt_ne_st = -1;
653 static int hf_scsi_ssc2_modepage_dcc = -1;
654 static int hf_scsi_mmc5_modepage_rck = -1;
655 static int hf_scsi_smc_modepage_mt_mt = -1;
656 static int hf_scsi_smc_modepage_dt_st = -1;
657 static int hf_scsi_ssc2_modepage_rewind_on_reset = -1;
658 static int hf_scsi_mmc5_modepage_upc = -1;
659 static int hf_scsi_ssc2_modepage_idp = -1;
660 static int hf_scsi_ssc2_modepage_perswp = -1;
661 static int hf_scsi_spc_xcopy_service = -1;
662 static int hf_scsi_spc_recv_copy_service = -1;
663 static int hf_scsi_spc_xcopy_param_list_len = -1;
664 static int hf_scsi_spc_xcopy_param_list_format = -1;
665 static int hf_scsi_spc_xcopy_cscd_desc_list_len = -1;
666 static int hf_scsi_spc_xcopy_head_cscd_desc_list_len = -1;
667 static int hf_scsi_spc_xcopy_head_cscd_desc_type_code = -1;
668 static int hf_scsi_spc_xcopy_cscd_desc_type_code = -1;
669 static int hf_scsi_spc_xcopy_inline_data_len = -1;
670 static int hf_scsi_spc_xcopy_seg_desc_list_len = -1;
671 static int hf_scsi_spc_xcopy_list_id = -1;
672 static int hf_scsi_spc_xcopy_rel_init_port_id = -1;
673 static int hf_scsi_spc_xcopy_per_dev_type_byte = -1;
674 static int hf_scsi_spc_xcopy_per_dev_type = -1;
675 static int hf_scsi_spc_xcopy_lu_type = -1;
676 static int hf_scsi_spc_xcopy_disk_block_len = -1;
677 static int hf_scsi_spc_xcopy_cscd_desc_code_set = -1;
678 static int hf_scsi_spc_xcopy_cscd_desc_assoc = -1;
679 static int hf_scsi_spc_xcopy_cscd_desc_des_type = -1;
680 static int hf_scsi_spc_xcopy_cscd_desc_des_len = -1;
681 static int hf_scsi_spc_xcopy_seg_desc_type = -1;
682 static int hf_scsi_spc_xcopy_seg_desc_dc = -1;
683 static int hf_scsi_spc_xcopy_seg_desc_cat = -1;
684 static int hf_scsi_spc_xcopy_seg_des_src_desc_id = -1;
685 static int hf_scsi_spc_xcopy_seg_des_dest_desc_id = -1;
686 static int hf_scsi_spc_xcopy_num_of_blocks = -1;
687 static int hf_scsi_spc_xcopy_param_list_id_usage = -1;
688 static int hf_scsi_spc_xcopy_param_str = -1;
689 static int hf_scsi_spc_xcopy_param_priority = -1;
690 static int hf_scsi_spc_xcopy_param_byte = -1;
691 static int hf_scsi_spc_xcopy_source_lba = -1;
692 static int hf_scsi_spc_xcopy_dest_lba = -1;
693 static int hf_scsi_recv_copy_max_cscd_desc_count = -1;
694 static int hf_scsi_recv_copy_max_seg_desc_count = -1;
695 static int hf_scsi_recv_copy_max_desc_list_len = -1;
696 static int hf_scsi_recv_copy_max_seg_len = -1;
697 static int hf_scsi_recv_copy_max_inline_data_len = -1;
698 static int hf_scsi_recv_copy_held_data_limit = -1;
699 static int hf_scsi_recv_copy_max_stream_dev_trans_size = -1;
700 static int hf_scsi_recv_copy_snlid = -1;
701 static int hf_scsi_recv_copy_avail_data = -1;
702 static int hf_scsi_recv_copy_total_con_copies = -1;
703 static int hf_scsi_recv_copy_max_con_copies = -1;
704 static int hf_scsi_recv_copy_data_seg_gran = -1;
705 static int hf_scsi_recv_copy_inline_data_gran = -1;
706 static int hf_scsi_recv_copy_held_data_gran = -1;
707 static int hf_scsi_recv_copy_implemented_desc_list_len = -1;
708 static int hf_scsi_segment_descriptor_length = -1;
709 static int hf_scsi_designator = -1;
710 static int hf_scsi_inline_data = -1;
711 static int hf_scsi_reserved_8 = -1;
712 static int hf_scsi_reserved_16 = -1;
713 static int hf_scsi_reserved_24 = -1;
714 static int hf_scsi_reserved_32 = -1;
715 static int hf_scsi_reserved_64 = -1;
716 static int hf_scsi_naa_type = -1;
717 static int hf_scsi_naa_locally_assigned = -1;
718 static int hf_scsi_naa_ieee_company_id = -1;
719 static int hf_scsi_naa_vendor_specific = -1;
720 static int hf_scsi_naa_vendor_specific_extension = -1;
721 
722 static gint ett_scsi = -1;
723 static gint ett_scsi_page = -1;
724 gint ett_scsi_control = -1;
725 static gint ett_scsi_inq_control = -1;
726 static gint ett_scsi_inq_peripheral = -1;
727 static gint ett_scsi_inq_acaflags = -1;
728 static gint ett_scsi_inq_rmbflags = -1;
729 static gint ett_scsi_inq_sccsflags = -1;
730 static gint ett_scsi_inq_bqueflags = -1;
731 static gint ett_scsi_inq_reladrflags = -1;
732 static gint ett_scsi_log = -1;
733 static gint ett_scsi_log_ppc = -1;
734 static gint ett_scsi_log_pc = -1;
735 static gint ett_scsi_log_param = -1;
736 static gint ett_scsi_fragments = -1;
737 static gint ett_scsi_fragment = -1;
738 static gint ett_persresv_control = -1;
739 static gint ett_scsi_lun = -1;
740 static gint ett_scsi_lun_unit = -1;
741 static gint ett_scsi_prevent_allow = -1;
742 static gint ett_command_descriptor = -1;
743 static gint ett_timeout_descriptor = -1;
744 static gint ett_sense_descriptor = -1;
745 static gint ett_sense_osd_not_initiated = -1;
746 static gint ett_sense_osd_completed = -1;
747 static gint ett_xcopy_per_dev_type = -1;
748 static gint ett_xcopy_param_byte = -1;
749 static gint ett_scsi_xcopy_cscds = -1;
750 static gint ett_scsi_xcopy_cscd = -1;
751 static gint ett_scsi_xcopy_dev_params = -1;
752 static gint ett_scsi_xcopy_segs = -1;
753 static gint ett_scsi_xcopy_seg = -1;
754 static gint ett_scsi_xcopy_seg_param = -1;
755 static gint ett_scsi_cscd_desc = -1;
756 static gint ett_scsi_naa = -1;
757 static gint ett_scsi_designation_descriptor = -1;
758 
759 /* Generated from convert_proto_tree_add_text.pl */
760 static expert_field ei_scsi_unknown_scsi_exchange = EI_INIT;
761 static expert_field ei_scsi_product_data_goes_past_end_of_page = EI_INIT;
762 static expert_field ei_scsi_unknown_page = EI_INIT;
763 static expert_field ei_scsi_no_dissection_for_service_action = EI_INIT;
764 static expert_field ei_scsi_unknown_serv_action = EI_INIT;
765 
766 static int scsi_tap = -1;
767 
768 /* Defragment of SCSI DATA IN/OUT */
769 static gboolean scsi_defragment = FALSE;
770 
771 static reassembly_table scsi_reassembly_table;
772 
773 /*
774  * Required by all commands
775  */
776 int * const cdb_control_fields[6] = {
777     &hf_scsi_control_vendor_specific,
778     &hf_scsi_control_reserved,
779     &hf_scsi_control_naca,
780     &hf_scsi_control_obs1,
781     &hf_scsi_control_obs2,
782     NULL
783 };
784 
785 static const fragment_items scsi_frag_items = {
786     &ett_scsi_fragment,
787     &ett_scsi_fragments,
788     &hf_scsi_fragments,
789     &hf_scsi_fragment,
790     &hf_scsi_fragment_overlap,
791     &hf_scsi_fragment_overlap_conflict,
792     &hf_scsi_fragment_multiple_tails,
793     &hf_scsi_fragment_too_long_fragment,
794     &hf_scsi_fragment_error,
795     &hf_scsi_fragment_count,
796     &hf_scsi_reassembled_in,
797     &hf_scsi_reassembled_length,
798     /* Reassembled data field */
799     NULL,
800     "fragments"
801 };
802 
803 
804 typedef guint32 scsi_cmnd_type;
805 typedef guint32 scsi_device_type;
806 
807 /* Valid SCSI Command Types */
808 #define SCSI_CMND_SPC                    1
809 #define SCSI_CMND_SBC                    2
810 #define SCSI_CMND_SSC                    3
811 #define SCSI_CMND_SMC                    4
812 #define SCSI_CMND_MMC                    5
813 
814 /* SPC and SPC-2 Commands */
815 static const value_string scsi_spc_vals[] = {
816     /* 0x00 */    {SCSI_SPC_TESTUNITRDY        , "Test Unit Ready"},
817     /* 0x03 */    {SCSI_SPC_REQSENSE           , "Request Sense"},
818     /* 0x12 */    {SCSI_SPC_INQUIRY            , "Inquiry"},
819     /* 0x15 */    {SCSI_SPC_MODESELECT6        , "Mode Select(6)"},
820     /* 0x16 */    {SCSI_SPC_RESERVE6           , "Reserve(6)"},
821     /* 0x17 */    {SCSI_SPC_RELEASE6           , "Release(6)"},
822     /* 0x18 */    {SCSI_SPC_COPY               , "Copy"},
823     /* 0x1A */    {SCSI_SPC_MODESENSE6         , "Mode Sense(6)"},
824     /* 0x1C */    {SCSI_SPC_RCVDIAGRESULTS     , "Receive Diagnostics Results"},
825     /* 0x1D */    {SCSI_SPC_SENDDIAG           , "Send Diagnostic"},
826     /* 0x1E */    {SCSI_SPC_PREVMEDREMOVAL     , "Prevent/Allow Medium Removal"},
827     /* 0x39 */    {SCSI_SPC_COMPARE            , "Compare"},
828     /* 0x3A */    {SCSI_SPC_COPY_AND_VERIFY    , "Copy And Verify"},
829     /* 0x3B */    {SCSI_SPC_WRITEBUFFER        , "Write Buffer"},
830     /* 0x3C */    {SCSI_SPC_READBUFFER         , "Read Buffer"},
831     /* 0x40 */    {SCSI_SPC_CHANGE_DEFINITION  , "Change Definition"},
832     /* 0x4C */    {SCSI_SPC_LOGSELECT          , "Log Select"},
833     /* 0x4D */    {SCSI_SPC_LOGSENSE           , "Log Sense"},
834     /* 0x55 */    {SCSI_SPC_MODESELECT10       , "Mode Select(10)"},
835     /* 0x56 */    {SCSI_SPC_RESERVE10          , "Reserve(10)"},
836     /* 0x57 */    {SCSI_SPC_RELEASE10          , "Release(10)"},
837     /* 0x5A */    {SCSI_SPC_MODESENSE10        , "Mode Sense(10)"},
838     /* 0x5E */    {SCSI_SPC_PERSRESVIN         , "Persistent Reserve In"},
839     /* 0x5F */    {SCSI_SPC_PERSRESVOUT        , "Persistent Reserve Out"},
840     /* 0x7F */    {SCSI_SPC_VARLENCDB          , "Variable Length CDB"},
841     /* 0x83 */    {SCSI_SPC_EXTCOPY            , "Extended Copy"},
842     /* 0x84 */    {SCSI_SPC_RECVCOPY           , "Receive Copy"},
843     /* 0x86 */    {SCSI_SPC_ACCESS_CONTROL_IN  , "Access Control In"},
844     /* 0x87 */    {SCSI_SPC_ACCESS_CONTROL_OUT , "Access Control Out"},
845     /* 0xA0 */    {SCSI_SPC_REPORTLUNS         , "Report LUNs"},
846     /* 0xA3 */    {SCSI_SPC_MGMT_PROTOCOL_IN   , "Mgmt Protocol In"},
847     {0, NULL},
848 };
849 static value_string_ext scsi_spc_vals_ext = VALUE_STRING_EXT_INIT(scsi_spc_vals);
850 
851 static const value_string scsi_lun_address_mode_vals[] = {
852     { 0, "Peripheral Device Addressing Method" },
853     { 1, "Flat Space Addressing Method" },
854     { 2, "Logical Unit Addressing Method" },
855     { 3, "Extended Logical Unit Addressing" },
856     { 0, NULL }
857 };
858 
859 static const value_string provisioning_vals[] = {
860     {0, "No provisioning"},
861     {1, "Resource provisioned"},
862     {2, "Thin provisioned"},
863     {0, NULL},
864 };
865 
866 static const value_string log_flags_tmc_vals[] = {
867     {0, "Every update of the cumulative value"},
868     {1, "Cumulative value equal to threshold value"},
869     {2, "Cumulative value not equal to threshold value"},
870     {3, "Cumulative value greater than threshold value"},
871     {0, NULL},
872 };
873 
874 static const value_string scsi_select_report_val[] = {
875     {0, "Select All LUNs" },
876     {1, "Select Well-Known LUNs" },
877     {2, "Select All LUNs accessible to this I_T nexus" },
878     {0, NULL},
879 };
880 
881 #define SCSI_EVPD_SUPPPG          0x00
882 #define SCSI_EVPD_DEVSERNUM       0x80
883 #define SCSI_EVPD_OPER            0x81
884 #define SCSI_EVPD_ASCIIOPER       0x82
885 #define SCSI_EVPD_DEVID           0x83
886 #define SCSI_EVPD_BLKLIMITS       0xb0
887 #define SCSI_EVPD_BLKDEVCHAR      0xb1
888 #define SCSI_EVPD_LBP             0xb2
889 
890 static const value_string scsi_evpd_pagecode_val[] = {
891     {SCSI_EVPD_SUPPPG,    "Supported Vital Product Data Pages"},
892     {0x01,                "ASCII Information Page"},
893     {0x02,                "ASCII Information Page"},
894     {0x03,                "ASCII Information Page"},
895     {0x04,                "ASCII Information Page"},
896     {0x05,                "ASCII Information Page"},
897     {0x06,                "ASCII Information Page"},
898     {0x07,                "ASCII Information Page"},
899     /* XXX - 0x01 through 0x7F are all ASCII information pages */
900     {SCSI_EVPD_DEVSERNUM, "Unit Serial Number Page"},
901     {SCSI_EVPD_OPER,      "Implemented Operating Definition Page"},
902     {SCSI_EVPD_ASCIIOPER, "ASCII Implemented Operating Definition Page"},
903     {SCSI_EVPD_DEVID,     "Device Identification Page"},
904     {SCSI_EVPD_BLKLIMITS, "Block Limits Page"},
905     {SCSI_EVPD_BLKDEVCHAR,"Block Device Characteristics"},
906     {SCSI_EVPD_LBP,       "Logical Block Provisioning Page"},
907     {0, NULL},
908 };
909 
910 static const value_string mrr_val[] = {
911     {0x0,       "Media rotation speed not reported"},
912     {0x1,       "Non-rotating media"},
913     /* 0x2 - 0x400 - reserved */
914     {5400,      "5,400 RPM"},
915     {7200,      "7,200 RPM"},
916     {10000,     "10,000 RPM"},
917     {15000,     "15,000 RPM"},
918     {0, NULL},
919 };
920 static const value_string scsi_log_pc_val[] = {
921     {0, "Threshold Values"},
922     {1, "Cumulative Values"},
923     {2, "Default Threshold Values"},
924     {3, "Default Cumulative Values"},
925     {0, NULL},
926 };
927 
928 #define NAA_TYPE_IEEE_EXTENDED            2
929 #define NAA_TYPE_LOCALLY_ASSIGNED         3
930 #define NAA_TYPE_IEEE_REGISTERED          5
931 #define NAA_TYPE_IEEE_REGISTERED_EXTENDED 6
932 static const value_string scsi_naa_designator_type_val[] = {
933     {2, "IEEE Extended" },
934     {3, "Locally Assigned" },
935     {5, "IEEE Registered" },
936     {6, "IEEE Registered Extended" },
937     {0, NULL},
938 };
939 
940 static const unit_name_string units_100_milliseconds = { "100ms", NULL };
941 
942 #define SCSI_NUM_PROCEDURES 256
943 typedef struct scsistat_tap_data
944 {
945     guint8     cmdset;
946     const char *prog;
947     value_string_ext *cdbnames_ext;
948     const char *hf_name;
949 } scsistat_tap_data_t;
950 
951 static void
scsistat_init(struct register_srt * srt,GArray * srt_array)952 scsistat_init(struct register_srt* srt, GArray* srt_array)
953 {
954     scsistat_tap_data_t* tap_data = (scsistat_tap_data_t*)get_srt_table_param_data(srt);
955     srt_stat_table *scsi_srt_table;
956     guint32 i;
957 
958     DISSECTOR_ASSERT(tap_data);
959 
960     scsi_srt_table = init_srt_table(tap_data->prog, NULL, srt_array, SCSI_NUM_PROCEDURES, NULL, tap_data->hf_name, tap_data);
961     for (i = 0; i < SCSI_NUM_PROCEDURES; i++)
962     {
963         init_srt_table_row(scsi_srt_table, i, val_to_str_ext_const(i, tap_data->cdbnames_ext, "Unknown-0x%02x"));
964     }
965 }
966 
967 static tap_packet_status
scsistat_packet(void * pss,packet_info * pinfo,epan_dissect_t * edt _U_,const void * prv)968 scsistat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv)
969 {
970     guint i = 0;
971     srt_stat_table *scsi_srt_table;
972     srt_data_t *data = (srt_data_t *)pss;
973     const scsi_task_data_t *ri = (const scsi_task_data_t *)prv;
974     scsistat_tap_data_t* tap_data;
975 
976     scsi_srt_table = g_array_index(data->srt_array, srt_stat_table*, i);
977     tap_data = (scsistat_tap_data_t*)scsi_srt_table->table_specific_data;
978 
979     /* we are only interested in response packets */
980     if (ri->type != SCSI_PDU_TYPE_RSP) {
981         return TAP_PACKET_DONT_REDRAW;
982     }
983     /* we are only interested in a specific commandset */
984     if ( (!ri->itl) || ((ri->itl->cmdset&SCSI_CMDSET_MASK) != tap_data->cmdset) ) {
985         return TAP_PACKET_DONT_REDRAW;
986     }
987     /* check that the opcode looks sane */
988     if ( (!ri->itlq) || (ri->itlq->scsi_opcode > 255) ) {
989         return TAP_PACKET_DONT_REDRAW;
990     }
991 
992     add_srt_table_data(scsi_srt_table, ri->itlq->scsi_opcode, &ri->itlq->fc_time, pinfo);
993     return TAP_PACKET_REDRAW;
994 }
995 
996 guint
scsistat_param(register_srt_t * srt,const char * opt_arg,char ** err)997 scsistat_param(register_srt_t* srt, const char* opt_arg, char** err)
998 {
999     int pos = 0;
1000     int program;
1001     scsistat_tap_data_t* tap_data;
1002 
1003     if (sscanf(opt_arg, ",%d%n", &program, &pos) == 1)
1004     {
1005         tap_data = g_new0(scsistat_tap_data_t, 1);
1006         tap_data->cmdset = (guint8)program;
1007 
1008         switch(program){
1009         case SCSI_DEV_SBC:
1010             tap_data->prog = "SBC (disk)";
1011             tap_data->cdbnames_ext = &scsi_sbc_vals_ext;
1012             tap_data->hf_name = "scsi_sbc.opcode";
1013         break;
1014         case SCSI_DEV_SSC:
1015             tap_data->prog = "SSC (tape)";
1016             tap_data->cdbnames_ext = &scsi_ssc_vals_ext;
1017             tap_data->hf_name = "scsi_ssc.opcode";
1018         break;
1019         case SCSI_DEV_CDROM:
1020             tap_data->prog = "MMC (cd/dvd)";
1021             tap_data->cdbnames_ext = &scsi_mmc_vals_ext;
1022             tap_data->hf_name = "scsi_mmc.opcode";
1023         break;
1024         case SCSI_DEV_SMC:
1025             tap_data->prog = "SMC (tape robot)";
1026             tap_data->cdbnames_ext = &scsi_smc_vals_ext;
1027             tap_data->hf_name = "scsi_smc.opcode";
1028         break;
1029         case SCSI_DEV_OSD:
1030             tap_data->prog = "OSD (object based)";
1031             tap_data->cdbnames_ext = &scsi_osd_vals_ext;
1032             tap_data->hf_name = "scsi_osd.opcode";
1033         break;
1034         }
1035 
1036         set_srt_table_param_data(srt, tap_data);
1037     }
1038     else
1039     {
1040         *err = g_strdup("<cmdset>[,<filter>]");
1041     }
1042 
1043     return pos;
1044 }
1045 
1046 /* TapeAlert page : read warning flag */
1047 static void
log_parameter_2e_0001(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1048 log_parameter_2e_0001(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1049 {
1050     proto_tree_add_item(tree, hf_scsi_log_ta_rw, tvb, 0, 1, ENC_BIG_ENDIAN);
1051 }
1052 
1053 /* TapeAlert page : write warning flag */
1054 static void
log_parameter_2e_0002(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1055 log_parameter_2e_0002(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1056 {
1057     proto_tree_add_item(tree, hf_scsi_log_ta_ww, tvb, 0, 1, ENC_BIG_ENDIAN);
1058 }
1059 
1060 /* TapeAlert page : hard error flag */
1061 static void
log_parameter_2e_0003(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1062 log_parameter_2e_0003(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1063 {
1064     proto_tree_add_item(tree, hf_scsi_log_ta_he, tvb, 0, 1, ENC_BIG_ENDIAN);
1065 }
1066 
1067 /* TapeAlert page : media flag */
1068 static void
log_parameter_2e_0004(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1069 log_parameter_2e_0004(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1070 {
1071     proto_tree_add_item(tree, hf_scsi_log_ta_media, tvb, 0, 1, ENC_BIG_ENDIAN);
1072 }
1073 
1074 /* TapeAlert page : read failure flag */
1075 static void
log_parameter_2e_0005(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1076 log_parameter_2e_0005(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1077 {
1078     proto_tree_add_item(tree, hf_scsi_log_ta_rf, tvb, 0, 1, ENC_BIG_ENDIAN);
1079 }
1080 
1081 /* TapeAlert page : write failure flag */
1082 static void
log_parameter_2e_0006(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1083 log_parameter_2e_0006(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1084 {
1085     proto_tree_add_item(tree, hf_scsi_log_ta_wf, tvb, 0, 1, ENC_BIG_ENDIAN);
1086 }
1087 
1088 /* TapeAlert page : media life flag */
1089 static void
log_parameter_2e_0007(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1090 log_parameter_2e_0007(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1091 {
1092     proto_tree_add_item(tree, hf_scsi_log_ta_ml, tvb, 0, 1, ENC_BIG_ENDIAN);
1093 }
1094 
1095 /* TapeAlert page : not data grade flag */
1096 static void
log_parameter_2e_0008(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1097 log_parameter_2e_0008(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1098 {
1099     proto_tree_add_item(tree, hf_scsi_log_ta_ndg, tvb, 0, 1, ENC_BIG_ENDIAN);
1100 }
1101 
1102 /* TapeAlert page : write protect flag */
1103 static void
log_parameter_2e_0009(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1104 log_parameter_2e_0009(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1105 {
1106     proto_tree_add_item(tree, hf_scsi_log_ta_wp, tvb, 0, 1, ENC_BIG_ENDIAN);
1107 }
1108 
1109 /* TapeAlert page : no removal flag */
1110 static void
log_parameter_2e_000a(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1111 log_parameter_2e_000a(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1112 {
1113     proto_tree_add_item(tree, hf_scsi_log_ta_nr, tvb, 0, 1, ENC_BIG_ENDIAN);
1114 }
1115 
1116 /* TapeAlert page : cleaning media flag */
1117 static void
log_parameter_2e_000b(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1118 log_parameter_2e_000b(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1119 {
1120     proto_tree_add_item(tree, hf_scsi_log_ta_cm, tvb, 0, 1, ENC_BIG_ENDIAN);
1121 }
1122 
1123 /* TapeAlert page : unsupported format flag */
1124 static void
log_parameter_2e_000c(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1125 log_parameter_2e_000c(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1126 {
1127     proto_tree_add_item(tree, hf_scsi_log_ta_uf, tvb, 0, 1, ENC_BIG_ENDIAN);
1128 }
1129 
1130 /* TapeAlert page : removable mechanical cartridge failure flag */
1131 static void
log_parameter_2e_000d(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1132 log_parameter_2e_000d(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1133 {
1134     proto_tree_add_item(tree, hf_scsi_log_ta_rmcf, tvb, 0, 1, ENC_BIG_ENDIAN);
1135 }
1136 
1137 /* TapeAlert page : unrecoverable mechanical cartridge failure flag */
1138 static void
log_parameter_2e_000e(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1139 log_parameter_2e_000e(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1140 {
1141     proto_tree_add_item(tree, hf_scsi_log_ta_umcf, tvb, 0, 1, ENC_BIG_ENDIAN);
1142 }
1143 
1144 /* TapeAlert page : memory chip in cartridge failure flag */
1145 static void
log_parameter_2e_000f(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1146 log_parameter_2e_000f(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1147 {
1148     proto_tree_add_item(tree, hf_scsi_log_ta_mcicf, tvb, 0, 1, ENC_BIG_ENDIAN);
1149 }
1150 
1151 /* TapeAlert page : forced eject flag */
1152 static void
log_parameter_2e_0010(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1153 log_parameter_2e_0010(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1154 {
1155     proto_tree_add_item(tree, hf_scsi_log_ta_fe, tvb, 0, 1, ENC_BIG_ENDIAN);
1156 }
1157 
1158 /* TapeAlert page : read only format flag */
1159 static void
log_parameter_2e_0011(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1160 log_parameter_2e_0011(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1161 {
1162     proto_tree_add_item(tree, hf_scsi_log_ta_rof, tvb, 0, 1, ENC_BIG_ENDIAN);
1163 }
1164 
1165 /* TapeAlert page : tape directory corrupted on load flag */
1166 static void
log_parameter_2e_0012(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1167 log_parameter_2e_0012(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1168 {
1169     proto_tree_add_item(tree, hf_scsi_log_ta_tdcol, tvb, 0, 1, ENC_BIG_ENDIAN);
1170 }
1171 
1172 /* TapeAlert page : nearing media life flag */
1173 static void
log_parameter_2e_0013(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1174 log_parameter_2e_0013(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1175 {
1176     proto_tree_add_item(tree, hf_scsi_log_ta_nml, tvb, 0, 1, ENC_BIG_ENDIAN);
1177 }
1178 
1179 /* TapeAlert page : clean now flag */
1180 static void
log_parameter_2e_0014(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1181 log_parameter_2e_0014(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1182 {
1183     proto_tree_add_item(tree, hf_scsi_log_ta_cn, tvb, 0, 1, ENC_BIG_ENDIAN);
1184 }
1185 
1186 /* TapeAlert page : clean periodic flag */
1187 static void
log_parameter_2e_0015(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1188 log_parameter_2e_0015(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1189 {
1190     proto_tree_add_item(tree, hf_scsi_log_ta_cp, tvb, 0, 1, ENC_BIG_ENDIAN);
1191 }
1192 
1193 /* TapeAlert page : expired cleaning media flag */
1194 static void
log_parameter_2e_0016(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1195 log_parameter_2e_0016(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1196 {
1197     proto_tree_add_item(tree, hf_scsi_log_ta_ecm, tvb, 0, 1, ENC_BIG_ENDIAN);
1198 }
1199 
1200 /* TapeAlert page : invalid cleaning tape flag */
1201 static void
log_parameter_2e_0017(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1202 log_parameter_2e_0017(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1203 {
1204     proto_tree_add_item(tree, hf_scsi_log_ta_ict, tvb, 0, 1, ENC_BIG_ENDIAN);
1205 }
1206 
1207 /* TapeAlert page : retention requested flag */
1208 static void
log_parameter_2e_0018(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1209 log_parameter_2e_0018(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1210 {
1211     proto_tree_add_item(tree, hf_scsi_log_ta_rr, tvb, 0, 1, ENC_BIG_ENDIAN);
1212 }
1213 
1214 /* TapeAlert page : dual port interface error flag */
1215 static void
log_parameter_2e_0019(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1216 log_parameter_2e_0019(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1217 {
1218     proto_tree_add_item(tree, hf_scsi_log_ta_dpie, tvb, 0, 1, ENC_BIG_ENDIAN);
1219 }
1220 
1221 /* TapeAlert page : cooling fan failure flag */
1222 static void
log_parameter_2e_001a(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1223 log_parameter_2e_001a(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1224 {
1225     proto_tree_add_item(tree, hf_scsi_log_ta_cff, tvb, 0, 1, ENC_BIG_ENDIAN);
1226 }
1227 
1228 /* TapeAlert page : power supply failure flag */
1229 static void
log_parameter_2e_001b(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1230 log_parameter_2e_001b(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1231 {
1232     proto_tree_add_item(tree, hf_scsi_log_ta_psf, tvb, 0, 1, ENC_BIG_ENDIAN);
1233 }
1234 
1235 /* TapeAlert page : power consumption flag */
1236 static void
log_parameter_2e_001c(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1237 log_parameter_2e_001c(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1238 {
1239     proto_tree_add_item(tree, hf_scsi_log_ta_pc, tvb, 0, 1, ENC_BIG_ENDIAN);
1240 }
1241 
1242 /* TapeAlert page : drive maintenance flag */
1243 static void
log_parameter_2e_001d(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1244 log_parameter_2e_001d(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1245 {
1246     proto_tree_add_item(tree, hf_scsi_log_ta_dm, tvb, 0, 1, ENC_BIG_ENDIAN);
1247 }
1248 
1249 /* TapeAlert page : hardware a flag */
1250 static void
log_parameter_2e_001e(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1251 log_parameter_2e_001e(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1252 {
1253     proto_tree_add_item(tree, hf_scsi_log_ta_hwa, tvb, 0, 1, ENC_BIG_ENDIAN);
1254 }
1255 
1256 /* TapeAlert page : hardware b flag */
1257 static void
log_parameter_2e_001f(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1258 log_parameter_2e_001f(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1259 {
1260     proto_tree_add_item(tree, hf_scsi_log_ta_hwb, tvb, 0, 1, ENC_BIG_ENDIAN);
1261 }
1262 
1263 /* TapeAlert page : interface flag */
1264 static void
log_parameter_2e_0020(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1265 log_parameter_2e_0020(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1266 {
1267     proto_tree_add_item(tree, hf_scsi_log_ta_if, tvb, 0, 1, ENC_BIG_ENDIAN);
1268 }
1269 
1270 /* TapeAlert page : eject media flag */
1271 static void
log_parameter_2e_0021(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1272 log_parameter_2e_0021(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1273 {
1274     proto_tree_add_item(tree, hf_scsi_log_ta_em, tvb, 0, 1, ENC_BIG_ENDIAN);
1275 }
1276 
1277 /* TapeAlert page : download failed flag */
1278 static void
log_parameter_2e_0022(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1279 log_parameter_2e_0022(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1280 {
1281     proto_tree_add_item(tree, hf_scsi_log_ta_dwf, tvb, 0, 1, ENC_BIG_ENDIAN);
1282 }
1283 
1284 /* TapeAlert page : drive humidity flag */
1285 static void
log_parameter_2e_0023(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1286 log_parameter_2e_0023(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1287 {
1288     proto_tree_add_item(tree, hf_scsi_log_ta_drhu, tvb, 0, 1, ENC_BIG_ENDIAN);
1289 }
1290 
1291 /* TapeAlert page : drive temperature flag */
1292 static void
log_parameter_2e_0024(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1293 log_parameter_2e_0024(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1294 {
1295     proto_tree_add_item(tree, hf_scsi_log_ta_drtm, tvb, 0, 1, ENC_BIG_ENDIAN);
1296 }
1297 
1298 /* TapeAlert page : drive voltage flag */
1299 static void
log_parameter_2e_0025(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1300 log_parameter_2e_0025(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1301 {
1302     proto_tree_add_item(tree, hf_scsi_log_ta_drvo, tvb, 0, 1, ENC_BIG_ENDIAN);
1303 }
1304 
1305 /* TapeAlert page : periodic failure flag */
1306 static void
log_parameter_2e_0026(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1307 log_parameter_2e_0026(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1308 {
1309     proto_tree_add_item(tree, hf_scsi_log_ta_pefa, tvb, 0, 1, ENC_BIG_ENDIAN);
1310 }
1311 
1312 /* TapeAlert page : diagnostics required flag */
1313 static void
log_parameter_2e_0027(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1314 log_parameter_2e_0027(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1315 {
1316     proto_tree_add_item(tree, hf_scsi_log_ta_dire, tvb, 0, 1, ENC_BIG_ENDIAN);
1317 }
1318 
1319 /* TapeAlert page : lost statistics flag */
1320 static void
log_parameter_2e_0032(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1321 log_parameter_2e_0032(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1322 {
1323     proto_tree_add_item(tree, hf_scsi_log_ta_lost, tvb, 0, 1, ENC_BIG_ENDIAN);
1324 }
1325 
1326 /* TapeAlert page : tape directory invalid at unload flag */
1327 static void
log_parameter_2e_0033(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1328 log_parameter_2e_0033(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1329 {
1330     proto_tree_add_item(tree, hf_scsi_log_ta_tduau, tvb, 0, 1, ENC_BIG_ENDIAN);
1331 }
1332 
1333 /* TapeAlert page : tape system area write failure flag */
1334 static void
log_parameter_2e_0034(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1335 log_parameter_2e_0034(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1336 {
1337     proto_tree_add_item(tree, hf_scsi_log_ta_tsawf, tvb, 0, 1, ENC_BIG_ENDIAN);
1338 }
1339 
1340 /* TapeAlert page : tape system area read failure flag */
1341 static void
log_parameter_2e_0035(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1342 log_parameter_2e_0035(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1343 {
1344     proto_tree_add_item(tree, hf_scsi_log_ta_tsarf, tvb, 0, 1, ENC_BIG_ENDIAN);
1345 }
1346 
1347 /* TapeAlert page : no start of data flag */
1348 static void
log_parameter_2e_0036(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1349 log_parameter_2e_0036(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1350 {
1351     proto_tree_add_item(tree, hf_scsi_log_ta_nsod, tvb, 0, 1, ENC_BIG_ENDIAN);
1352 }
1353 
1354 /* TapeAlert page : loading failure flag */
1355 static void
log_parameter_2e_0037(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1356 log_parameter_2e_0037(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1357 {
1358     proto_tree_add_item(tree, hf_scsi_log_ta_lofa, tvb, 0, 1, ENC_BIG_ENDIAN);
1359 }
1360 
1361 /* TapeAlert page : unrecoverable unload failure flag */
1362 static void
log_parameter_2e_0038(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1363 log_parameter_2e_0038(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1364 {
1365     proto_tree_add_item(tree, hf_scsi_log_ta_uuf, tvb, 0, 1, ENC_BIG_ENDIAN);
1366 }
1367 
1368 /* TapeAlert page : automatic interface failure flag */
1369 static void
log_parameter_2e_0039(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1370 log_parameter_2e_0039(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1371 {
1372     proto_tree_add_item(tree, hf_scsi_log_ta_aif, tvb, 0, 1, ENC_BIG_ENDIAN);
1373 }
1374 
1375 /* TapeAlert page : firmware failure flag */
1376 static void
log_parameter_2e_003a(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1377 log_parameter_2e_003a(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1378 {
1379     proto_tree_add_item(tree, hf_scsi_log_ta_fwf, tvb, 0, 1, ENC_BIG_ENDIAN);
1380 }
1381 
1382 /* TapeAlert page : worm medium integrity check failed flag */
1383 static void
log_parameter_2e_003b(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1384 log_parameter_2e_003b(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1385 {
1386     proto_tree_add_item(tree, hf_scsi_log_ta_wmicf, tvb, 0, 1, ENC_BIG_ENDIAN);
1387 }
1388 
1389 /* TapeAlert page : worm medium overwrite attempted flag */
1390 static void
log_parameter_2e_003c(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree)1391 log_parameter_2e_003c(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1392 {
1393     proto_tree_add_item(tree, hf_scsi_log_ta_wmoa, tvb, 0, 1, ENC_BIG_ENDIAN);
1394 }
1395 
1396 
1397 typedef void (*log_parameter_dissector)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
1398 
1399 typedef struct _log_page_parameters_t {
1400     guint32 number;
1401     const char *name;
1402     log_parameter_dissector dissector;
1403 } log_page_parameters_t;
1404 static const log_page_parameters_t tape_alert_log_parameters[] = {
1405     {0x0001,    "Read Warning", log_parameter_2e_0001},
1406     {0x0002,    "write warning", log_parameter_2e_0002},
1407     {0x0003,    "hard error", log_parameter_2e_0003},
1408     {0x0004,    "media", log_parameter_2e_0004},
1409     {0x0005,    "read failure", log_parameter_2e_0005},
1410     {0x0006,    "write failure", log_parameter_2e_0006},
1411     {0x0007,    "media life", log_parameter_2e_0007},
1412     {0x0008,    "not data grade", log_parameter_2e_0008},
1413     {0x0009,    "write protect", log_parameter_2e_0009},
1414     {0x000a,    "no removal", log_parameter_2e_000a},
1415     {0x000b,    "cleaning media", log_parameter_2e_000b},
1416     {0x000c,    "unsupported format", log_parameter_2e_000c},
1417     {0x000d,    "removable mechanical cartridge failure", log_parameter_2e_000d},
1418     {0x000e,    "unrecoverable mechanical cartridge failure", log_parameter_2e_000e},
1419     {0x000f,    "memory chip in cartridge failure", log_parameter_2e_000f},
1420     {0x0010,    "forced eject", log_parameter_2e_0010},
1421     {0x0011,    "read only format", log_parameter_2e_0011},
1422     {0x0012,    "tape directory corrupted on load", log_parameter_2e_0012},
1423     {0x0013,    "nearing media life", log_parameter_2e_0013},
1424     {0x0014,    "clean now", log_parameter_2e_0014},
1425     {0x0015,    "clean periodic", log_parameter_2e_0015},
1426     {0x0016,    "expired cleaning media", log_parameter_2e_0016},
1427     {0x0017,    "invalid cleaning tape", log_parameter_2e_0017},
1428     {0x0018,    "retention requested", log_parameter_2e_0018},
1429     {0x0019,    "dual port interface error", log_parameter_2e_0019},
1430     {0x001a,    "cooling fan failure", log_parameter_2e_001a},
1431     {0x001b,    "power supply failure", log_parameter_2e_001b},
1432     {0x001c,    "power consumption", log_parameter_2e_001c},
1433     {0x001d,    "drive maintenance", log_parameter_2e_001d},
1434     {0x001e,    "hardware a", log_parameter_2e_001e},
1435     {0x001f,    "hardware b", log_parameter_2e_001f},
1436     {0x0020,    "interface", log_parameter_2e_0020},
1437     {0x0021,    "eject media", log_parameter_2e_0021},
1438     {0x0022,    "download failed", log_parameter_2e_0022},
1439     {0x0023,    "drive humidity", log_parameter_2e_0023},
1440     {0x0024,    "drive temperature", log_parameter_2e_0024},
1441     {0x0025,    "drive voltage", log_parameter_2e_0025},
1442     {0x0026,    "periodic failure", log_parameter_2e_0026},
1443     {0x0027,    "diagnostics required", log_parameter_2e_0027},
1444     {0x0032,    "lost statistics", log_parameter_2e_0032},
1445     {0x0033,    "tape directory invalid at unload", log_parameter_2e_0033},
1446     {0x0034,    "tape system area write failure", log_parameter_2e_0034},
1447     {0x0035,    "tape system area read failure", log_parameter_2e_0035},
1448     {0x0036,    "no start of data", log_parameter_2e_0036},
1449     {0x0037,    "loading failure", log_parameter_2e_0037},
1450     {0x0038,    "unrecoverable unload failure", log_parameter_2e_0038},
1451     {0x0039,    "automatic interface failure", log_parameter_2e_0039},
1452     {0x003a,    "firmware failure", log_parameter_2e_003a},
1453     {0x003b,    "worm medium integrity check failed", log_parameter_2e_003b},
1454     {0x003c,    "worm medium overwrite attempted", log_parameter_2e_003c},
1455     {0, NULL, NULL}
1456 };
1457 
1458 typedef struct _log_pages_t {
1459     guint32 page;
1460     const log_page_parameters_t *parameters;
1461 } log_pages_t;
1462 
1463 
1464 #define LOG_PAGE_TAPE_ALERT     0x2e
1465 static const value_string scsi_log_page_val[] = {
1466     {0x00, "Supported Log Pages"},
1467     {0x01, "Buffer Overrun/Underrun Page"},
1468     {0x02, "Error Counter (write) Page"},
1469     {0x03, "Error Counter (read) Page"},
1470     {0x04, "Error Counter (read reverse) Page"},
1471     {0x05, "Error Counter (verify) Page"},
1472     {0x06, "Non-medium Error Page"},
1473     {0x07, "Last n Error Events Page"},
1474     {0x08, "Format Status Log Page"},
1475     {0x0B, "Last n Deferred Errors or Async Events Page"},
1476     {0x0C, "Sequential-Access Device Log Page"},
1477     {0x0D, "Temperature Page"},
1478     {0x0E, "Start-Stop Cycle Counter Page"},
1479     {0x0F, "Application Client Page"},
1480     {0x10, "Self-test Results Page"},
1481     {0x11, "DTD Status Log Page"},
1482     {LOG_PAGE_TAPE_ALERT, "Tape-Alert Log Page (SSC)"},
1483     {0x2f, "Informational Exceptions Log Page"},
1484     {0, NULL},
1485 };
1486 
1487 static const log_pages_t log_pages[] = {
1488     {LOG_PAGE_TAPE_ALERT, tape_alert_log_parameters},
1489     {0, NULL}
1490 };
1491 
1492 
1493 
1494 
1495 static const value_string scsi_modesns_pc_val[] = {
1496     {0, "Current Values"},
1497     {1, "Changeable Values"},
1498     {2, "Default Values"},
1499     {3, "Saved Values"},
1500     {0, NULL},
1501 };
1502 
1503 #define SCSI_SPC_MODEPAGE_CTL      0x0A
1504 #define SCSI_SPC_MODEPAGE_DISCON   0x02
1505 #define SCSI_SCSI2_MODEPAGE_PERDEV  0x09  /* Obsolete in SPC-2; generic in SCSI-2 */
1506 #define SCSI_SPC_MODEPAGE_INFOEXCP 0x1C
1507 #define SCSI_SPC_MODEPAGE_PWR      0x1A
1508 #define SCSI_SPC_MODEPAGE_LUN      0x18
1509 #define SCSI_SPC_MODEPAGE_PORT     0x19
1510 #define SCSI_SPC_MODEPAGE_VEND     0x00
1511 
1512 static const value_string scsi_spc_modepage_val[] = {
1513     {SCSI_SPC_MODEPAGE_CTL,      "Control"},
1514     {SCSI_SPC_MODEPAGE_DISCON,   "Disconnect-Reconnect"},
1515     {SCSI_SCSI2_MODEPAGE_PERDEV, "Peripheral Device"},
1516     {SCSI_SPC_MODEPAGE_INFOEXCP, "Informational Exceptions Control"},
1517     {SCSI_SPC_MODEPAGE_PWR,      "Power Condition"},
1518     {SCSI_SPC_MODEPAGE_LUN,      "Protocol Specific LUN"},
1519     {SCSI_SPC_MODEPAGE_PORT,     "Protocol-Specific Port"},
1520     {SCSI_SPC_MODEPAGE_VEND,     "Vendor Specific Page"},
1521     {0x3F,                       "Return All Mode Pages"},
1522     {0, NULL},
1523 };
1524 
1525 #define SCSI_SBC_MODEPAGE_RDWRERR  0x01
1526 #define SCSI_SBC_MODEPAGE_FMTDEV   0x03
1527 #define SCSI_SBC_MODEPAGE_DISKGEOM 0x04
1528 #define SCSI_SBC_MODEPAGE_FLEXDISK 0x05
1529 #define SCSI_SBC_MODEPAGE_VERERR   0x07
1530 #define SCSI_SBC_MODEPAGE_CACHE    0x08
1531 #define SCSI_SBC_MODEPAGE_MEDTYPE  0x0B
1532 #define SCSI_SBC_MODEPAGE_NOTPART  0x0C
1533 #define SCSI_SBC_MODEPAGE_XORCTL   0x10
1534 
1535 static const value_string scsi_sbc_modepage_val[] = {
1536     {SCSI_SBC_MODEPAGE_RDWRERR,  "Read/Write Error Recovery"},
1537     {SCSI_SBC_MODEPAGE_FMTDEV,   "Format Device"},
1538     {SCSI_SBC_MODEPAGE_DISKGEOM, "Rigid Disk Geometry"},
1539     {SCSI_SBC_MODEPAGE_FLEXDISK, "Flexible Disk"},
1540     {SCSI_SBC_MODEPAGE_VERERR,   "Verify Error Recovery"},
1541     {SCSI_SBC_MODEPAGE_CACHE,    "Caching"},
1542     {SCSI_SBC_MODEPAGE_MEDTYPE,  "Medium Types Supported"},
1543     {SCSI_SBC_MODEPAGE_NOTPART,  "Notch & Partition"},
1544     {SCSI_SBC_MODEPAGE_XORCTL,   "XOR Control"},
1545     {0x3F,                        "Return All Mode Pages"},
1546     {0, NULL},
1547 };
1548 
1549 #define SCSI_SSC2_MODEPAGE_DATACOMP 0x0F  /* data compression */
1550 #define SCSI_SSC2_MODEPAGE_DEVCONF  0x10  /* device configuration */
1551 #define SCSI_SSC2_MODEPAGE_MEDPAR1  0x11  /* medium partition (1) */
1552 #define SCSI_SSC2_MODEPAGE_MEDPAR2  0x12  /* medium partition (2) */
1553 #define SCSI_SSC2_MODEPAGE_MEDPAR3  0x13  /* medium partition (3) */
1554 #define SCSI_SSC2_MODEPAGE_MEDPAR4  0x14  /* medium partition (4) */
1555 
1556 static const value_string scsi_ssc2_modepage_val[] = {
1557     {SCSI_SSC2_MODEPAGE_DATACOMP, "Data Compression"},
1558     {SCSI_SSC2_MODEPAGE_DEVCONF,  "Device Configuration"},
1559     {SCSI_SSC2_MODEPAGE_MEDPAR1,  "Medium Partition (1)"},
1560     {SCSI_SSC2_MODEPAGE_MEDPAR2,  "Medium Partition (2)"},
1561     {SCSI_SSC2_MODEPAGE_MEDPAR3,  "Medium Partition (3)"},
1562     {SCSI_SSC2_MODEPAGE_MEDPAR4,  "Medium Partition (4)"},
1563     {0x3F,                        "Return All Mode Pages"},
1564     {0, NULL},
1565 };
1566 
1567 #define SCSI_SMC_MODEPAGE_EAA      0x1D  /* element address assignment */
1568 #define SCSI_SMC_MODEPAGE_TRANGEOM 0x1E  /* transport geometry parameters */
1569 #define SCSI_SMC_MODEPAGE_DEVCAP   0x1F  /* device capabilities */
1570 
1571 static const value_string scsi_smc_modepage_val[] = {
1572     {SCSI_SMC_MODEPAGE_EAA,      "Element Address Assignment"},
1573     {SCSI_SMC_MODEPAGE_TRANGEOM, "Transport Geometry Parameters"},
1574     {SCSI_SMC_MODEPAGE_DEVCAP,   "Device Capabilities"},
1575     {0x3F,                        "Return All Mode Pages"},
1576     {0, NULL},
1577 };
1578 
1579 #define SCSI_MMC5_MODEPAGE_MRW     0x03  /* MRW */
1580 #define SCSI_MMC5_MODEPAGE_WRPARAM 0x05  /* Write Parameters */
1581 #define SCSI_MMC3_MODEPAGE_MMCAP   0x2A  /* device capabilities */
1582 
1583 static const value_string scsi_mmc5_modepage_val[] = {
1584     {SCSI_MMC5_MODEPAGE_MRW,      "MRW"},
1585     {SCSI_MMC5_MODEPAGE_WRPARAM,  "Write Parameters"},
1586     {SCSI_MMC3_MODEPAGE_MMCAP,    "MM Capabilities and Mechanical Status"},
1587     {0x3F,                        "Return All Mode Pages"},
1588     {0, NULL},
1589 };
1590 
1591 #define SCSI_SPC_RESVIN_SVCA_RDKEYS 0
1592 #define SCSI_SPC_RESVIN_SVCA_RDRESV 1
1593 #define SCSI_SPC_RESVIN_SVCA_RPTCAP 2
1594 #define SCSI_SPC_RESVIN_SVCA_FULL   3
1595 
1596 static const value_string scsi_persresvin_svcaction_val[] = {
1597     {SCSI_SPC_RESVIN_SVCA_RDKEYS, "Read Keys"},
1598     {SCSI_SPC_RESVIN_SVCA_RDRESV, "Read Reservation"},
1599     {SCSI_SPC_RESVIN_SVCA_RPTCAP, "Report Capabilities"},
1600     {SCSI_SPC_RESVIN_SVCA_FULL,   "Read Full Status"},
1601     {0, NULL},
1602 };
1603 
1604 #define SCSI_PR_REGISTER 0
1605 #define SCSI_PR_RESERVE 1
1606 #define SCSI_PR_RELEASE 2
1607 #define SCSI_PR_CLEAR 3
1608 #define SCSI_PR_PREEMPT 4
1609 #define SCSI_PR_PREEM_ABORT 5
1610 #define SCSI_PR_REG_IGNORE 6
1611 #define SCSI_PR_REG_MOVE 7
1612 #define SCSI_PR_REPLACE_LOST 8
1613 
1614 static const value_string scsi_persresvout_svcaction_val[] = {
1615     {SCSI_PR_REGISTER, "Register"},
1616     {SCSI_PR_RESERVE, "Reserve"},
1617     {SCSI_PR_RELEASE, "Release"},
1618     {SCSI_PR_CLEAR, "Clear"},
1619     {SCSI_PR_PREEMPT, "Preempt"},
1620     {SCSI_PR_PREEM_ABORT, "Preempt & Abort"},
1621     {SCSI_PR_REG_IGNORE, "Register & Ignore Existing Key"},
1622     {SCSI_PR_REG_MOVE, "Register & Move"},
1623     {SCSI_PR_REPLACE_LOST, "Replace Lost Reservation"},
1624     {0, NULL},
1625 };
1626 
1627 static const value_string scsi_persresv_scope_val[] = {
1628     {0, "LU Scope"},
1629     {1, "Obsolete"},
1630     {2, "Element Scope"},
1631     {0, NULL},
1632 };
1633 
1634 static const value_string scsi_persresv_type_val[] = {
1635     {1, "Write Excl"},
1636     {3, "Excl Access"},
1637     {5, "Write Excl, Registrants Only"},
1638     {6, "Excl Access, Registrants Only"},
1639     {7, "Write Excl, All Registrants"},
1640     {8, "Excl Access, All Registrants"},
1641     {0, NULL},
1642 };
1643 
1644 static const value_string scsi_qualifier_val[] = {
1645     {0x0, "Device type is connected to logical unit"},
1646     {0x1, "Device type is supported by server but is not connected to logical unit"},
1647     {0x3, "Device type is not supported by server"},
1648     { 0, NULL }
1649 };
1650 
1651 static const value_string scsi_devtype_val[] = {
1652     {SCSI_DEV_SBC   , "Direct Access Device"},
1653     {SCSI_DEV_SSC   , "Sequential Access Device"},
1654     {SCSI_DEV_PRNT  , "Printer"},
1655     {SCSI_DEV_PROC  , "Processor"},
1656     {SCSI_DEV_WORM  , "WORM"},
1657     {SCSI_DEV_CDROM , "CD-ROM"},
1658     {SCSI_DEV_SCAN  , "Scanner"},
1659     {SCSI_DEV_OPTMEM, "Optical Memory"},
1660     {SCSI_DEV_SMC   , "Medium Changer"},
1661     {SCSI_DEV_COMM  , "Communication"},
1662     {SCSI_DEV_RAID  , "Storage Array"},
1663     {SCSI_DEV_SES   , "Enclosure Services"},
1664     {SCSI_DEV_RBC   , "Simplified Block Device"},
1665     {SCSI_DEV_OCRW  , "Optical Card Reader/Writer"},
1666     {SCSI_DEV_OSD   , "Object-based Storage Device"},
1667     {SCSI_DEV_ADC   , "Automation/Drive Interface"},
1668     {0x1E           , "Well known logical unit"},
1669     {SCSI_DEV_NOLUN , "Unknown or no device type"},
1670     {0, NULL},
1671 };
1672 
1673 static const enum_val_t scsi_devtype_options[] = {
1674     {"block",         "Block Device",                SCSI_DEV_SBC},
1675     {"sequential",    "Sequential Device",           SCSI_DEV_SSC},
1676     {"objectbased",   "Object Based Storage Device", SCSI_DEV_OSD},
1677     {"mediumchanger", "Medium Changer Device",       SCSI_DEV_SMC},
1678     {"cdrom",         "Multimedia Device",           SCSI_DEV_CDROM},
1679     {NULL, NULL, -1},
1680 };
1681 
1682 static const value_string scsi_inquiry_vers_val[] = {
1683     {0x00, "No Compliance to any Standard"},
1684     {0x02, "Compliance to ANSI X3.131:1994"},
1685     {0x03, "Compliance to ANSI X3.301:1997"},
1686     {0x04, "Compliance to SPC-2"},
1687     {0x05, "Compliance to SPC-3"},
1688     {0x06, "Compliance to SPC-4"},
1689     {0x80, "Compliance to ISO/IEC 9316:1995"},
1690     {0x82, "Compliance to ISO/IEC 9316:1995 and to ANSI X3.131:1994"},
1691     {0x83, "Compliance to ISO/IEC 9316:1995 and to ANSI X3.301:1997"},
1692     {0x84, "Compliance to ISO/IEC 9316:1995 and SPC-2"},
1693     {0, NULL},
1694 };
1695 
1696 static const value_string scsi_modesense_medtype_sbc_val[] = {
1697     {0x00, "Default"},
1698     {0x01, "Flexible disk, single-sided; unspecified medium"},
1699     {0x02, "Flexible disk, double-sided; unspecified medium"},
1700     {0x05, "Flexible disk, single-sided, single density; 200mm/8in diameter"},
1701     {0x06, "Flexible disk, double-sided, single density; 200mm/8in diameter"},
1702     {0x09, "Flexible disk, single-sided, double density; 200mm/8in diameter"},
1703     {0x0A, "Flexible disk, double-sided, double density; 200mm/8in diameter"},
1704     {0x0D, "Flexible disk, single-sided, single density; 130mm/5.25in diameter"},
1705     {0x12, "Flexible disk, double-sided, single density; 130mm/5.25in diameter"},
1706     {0x16, "Flexible disk, single-sided, double density; 130mm/5.25in diameter"},
1707     {0x1A, "Flexible disk, double-sided, double density; 130mm/5.25in diameter"},
1708     {0x1E, "Flexible disk, double-sided; 90mm/3.5in diameter"},
1709     {0x40, "Direct-access magnetic tape, 12 tracks"},
1710     {0x44, "Direct-access magnetic tape, 24 tracks"},
1711     {0, NULL},
1712 };
1713 
1714 static const value_string scsi_verdesc_val[] = {
1715     {0x0000, "Version Descriptor Not Supported or No Standard Identified"},
1716     {0x0020, "SAM (no version claimed)"},
1717     {0x003B, "SAM T10/0994-D revision 18"},
1718     {0x003C, "SAM ANSI INCITS 270-1996"},
1719     {0x0040, "SAM-2 (no version claimed)"},
1720     {0x0054, "SAM-2 T10/1157-D revision 23"},
1721     {0x0055, "SAM-2 T10/1157-D revision 24"},
1722     {0x005C, "SAM-2 ANSI INCITS 366-2003"},
1723     {0x005E, "SAM-2 ISO/IEC 14776-412"},
1724     {0x0060, "SAM-3 (no version claimed)"},
1725     {0x0062, "SAM-3 T10/1561-D revision 7"},
1726     {0x0075, "SAM-3 T10/1561-D revision 13"},
1727     {0x0076, "SAM-3 T10/1561-D revision 14"},
1728     {0x0077, "SAM-3 ANSI INCITS 402-2005"},
1729     {0x0080, "SAM-4 (no version claimed)"},
1730     {0x0087, "SAM-4 T10/1683-D revision 13"},
1731     {0x008B, "SAM-4 T10/1683-D revision 14"},
1732     {0x0090, "SAM-4 ANSI INCITS 447-2008"},
1733     {0x0092, "SAM-4 ISO/IEC 14776-414"},
1734     {0x00A0, "SAM-5 (no version claimed)"},
1735     {0x00A2, "SAM-5 T10/2104-D revision 4"},
1736     {0x0120, "SPC (no version claimed)"},
1737     {0x013B, "SPC T10/0995-D revision 11a"},
1738     {0x013C, "SPC ANSI INCITS 301-1997"},
1739     {0x0140, "MMC (no version claimed)"},
1740     {0x015B, "MMC T10/1048-D revision 10a"},
1741     {0x015C, "MMC ANSI INCITS 304-1997"},
1742     {0x0160, "SCC (no version claimed)"},
1743     {0x017B, "SCC T10/1047-D revision 06c"},
1744     {0x017C, "SCC ANSI INCITS 276-1997"},
1745     {0x0180, "SBC (no version claimed)"},
1746     {0x019B, "SBC T10/0996-D revision 08c"},
1747     {0x019C, "SBC ANSI INCITS 306-1998"},
1748     {0x01A0, "SMC (no version claimed)"},
1749     {0x01BB, "SMC T10/0999-D revision 10a"},
1750     {0x01BC, "SMC ANSI INCITS 314-1998"},
1751     {0x01BE, "SMC ISO/IEC 14776-351"},
1752     {0x01C0, "SES (no version claimed)"},
1753     {0x01DB, "SES T10/1212-D revision 08b"},
1754     {0x01DC, "SES ANSI INCITS 305-1998"},
1755     {0x01DD, "SES T10/1212 revision 08b w/ Amendment ANSI INCITS.305/AM1-2000"},
1756     {0x01DE, "SES ANSI INCITS 305-1998 w/ Amendment ANSI INCITS.305/AM1-2000"},
1757     {0x01E0, "SCC-2 (no version claimed)"},
1758     {0x01FB, "SCC-2 T10/1125-D revision 4"},
1759     {0x01FC, "SCC-2 ANSI INCITS 318-1998"},
1760     {0x0200, "SSC (no version claimed)"},
1761     {0x0201, "SSC T10/0997-D revision 17"},
1762     {0x0207, "SSC T10/0997-D revision 22"},
1763     {0x021C, "SSC ANSI INCITS 335-2000"},
1764     {0x0220, "RBC (no version claimed)"},
1765     {0x0238, "RBC T10/1240-D revision 10a"},
1766     {0x023C, "RBC ANSI INCITS 330-2000"},
1767     {0x0240, "MMC-2 (no version claimed)"},
1768     {0x0255, "MMC-2 T10/1228-D revision 11"},
1769     {0x025B, "MMC-2 T10/1228-D revision 11a"},
1770     {0x025C, "MMC-2 ANSI INCITS 333-2000"},
1771     {0x0260, "SPC-2 (no version claimed)"},
1772     {0x0267, "SPC-2 T10/1236-D revision 12"},
1773     {0x0269, "SPC-2 T10/1236-D revision 18"},
1774     {0x0275, "SPC-2 T10/1236-D revision 19"},
1775     {0x0276, "SPC-2 T10/1236-D revision 20"},
1776     {0x0277, "SPC-2 ANSI INCITS 351-2001"},
1777     {0x0278, "SPC-2 ISO/IEC 14776-452"},
1778     {0x0280, "OCRW (no version claimed)"},
1779     {0x029E, "OCRW ISO/IEC 14776-381"},
1780     {0x02A0, "MMC-3 (no version claimed)"},
1781     {0x02B5, "MMC-3 T10/1363-D revision 9"},
1782     {0x02B6, "MMC-3 T10/1363-D revision 10g"},
1783     {0x02B8, "MMC-3 ANSI INCITS 360-2002"},
1784     {0x02E0, "SMC-2 (no version claimed)"},
1785     {0x02F5, "SMC-2 T10/1383-D revision 5"},
1786     {0x02FC, "SMC-2 T10/1383-D revision 6"},
1787     {0x02FD, "SMC-2 T10/1383-D revision 7"},
1788     {0x02FE, "SMC-2 ANSI INCITS 382-2004"},
1789     {0x0300, "SPC-3 (no version claimed)"},
1790     {0x0301, "SPC-3 T10/1416-D revision 7"},
1791     {0x0307, "SPC-3 T10/1416-D revision 21"},
1792     {0x030F, "SPC-3 T10/1416-D revision 22"},
1793     {0x0312, "SPC-3 T10/1416-D revision 23"},
1794     {0x0314, "SPC-3 ANSI INCITS 408-2005"},
1795     {0x0316, "SPC-3 ISO/IEC 14776-453"},
1796     {0x0320, "SBC-2 (no version claimed)"},
1797     {0x0322, "SBC-2 T10/1417-D revision 5a"},
1798     {0x0324, "SBC-2 T10/1417-D revision 15"},
1799     {0x033B, "SBC-2 T10/1417-D revision 16"},
1800     {0x033D, "SBC-2 ANSI INCITS 405-2005"},
1801     {0x033E, "SBC-2 ISO/IEC 14776-322"},
1802     {0x0340, "OSD (no version claimed)"},
1803     {0x0341, "OSD T10/1355-D revision 0"},
1804     {0x0342, "OSD T10/1355-D revision 7a"},
1805     {0x0343, "OSD T10/1355-D revision 8"},
1806     {0x0344, "OSD T10/1355-D revision 9"},
1807     {0x0355, "OSD T10/1355-D revision 10"},
1808     {0x0356, "OSD ANSI INCITS 400-2004"},
1809     {0x0360, "SSC-2 (no version claimed)"},
1810     {0x0374, "SSC-2 T10/1434-D revision 7"},
1811     {0x0375, "SSC-2 T10/1434-D revision 9"},
1812     {0x037D, "SSC-2 ANSI INCITS 380-2003"},
1813     {0x0380, "BCC (no version claimed)"},
1814     {0x03A0, "MMC-4 (no version claimed)"},
1815     {0x03B0, "MMC-4 T10/1545-D revision 5"},
1816     {0x03B1, "MMC-4 T10/1545-D revision 5a"},
1817     {0x03BD, "MMC-4 T10/1545-D revision 3"},
1818     {0x03BE, "MMC-4 T10/1545-D revision 3d"},
1819     {0x03BF, "MMC-4 ANSI INCITS 401-2005"},
1820     {0x03C0, "ADC (no version claimed)"},
1821     {0x03D5, "ADC T10/1558-D revision 6"},
1822     {0x03D6, "ADC T10/1558-D revision 7"},
1823     {0x03D7, "ADC ANSI INCITS 403-2005"},
1824     {0x03E0, "SES-2 (no version claimed)"},
1825     {0x03E1, "SES-2 T10/1559-D revision 16"},
1826     {0x03E7, "SES-2 T10/1559-D revision 19"},
1827     {0x03EB, "SES-2 T10/1559-D revision 20"},
1828     {0x03F0, "SES-2 ANSI INCITS 448-2008"},
1829     {0x03F2, "SES-2 ISO/IEC 14776-372"},
1830     {0x0400, "SSC-3 (no version claimed)"},
1831     {0x0403, "SSC-3 T10/1611-D revision 04a"},
1832     {0x0407, "SSC-3 T10/1611-D revision 5"},
1833     {0x0409, "SSC-3 ANSI INCITS 467-2011"},
1834     {0x0420, "MMC-5 (no version claimed)"},
1835     {0x042F, "MMC-5 T10/1675-D revision 3"},
1836     {0x0431, "MMC-5 T10/1675-D revision 03b"},
1837     {0x0432, "MMC-5 T10/1675-D revision 4"},
1838     {0x0434, "MMC-5 ANSI INCITS 430-2007"},
1839     {0x0440, "OSD-2 (no version claimed)"},
1840     {0x0444, "OSD-2 T10/1729-D revision 4"},
1841     {0x0446, "OSD-2 T10/1729-D revision 5"},
1842     {0x0448, "OSD-2 ANSI INCITS 458-2011"},
1843     {0x0460, "SPC-4 (no version claimed)"},
1844     {0x0461, "SPC-4 T10/BSR INCITS 513 revision 16"},
1845     {0x0462, "SPC-4 T10/BSR INCITS 513 revision 18"},
1846     {0x0463, "SPC-4 T10/BSR INCITS 513 revision 23"},
1847     {0x0466, "SPC-4 T10/BSR INCITS 513 revision 36"},
1848     {0x0480, "SMC-3 (no version claimed)"},
1849     {0x0482, "SMC-3 T10/1730-D revision 15"},
1850     {0x0484, "SMC-3 T10/1730-D revision 16"},
1851     {0x0486, "SMC-3 ANSI INCITS 484-2012"},
1852     {0x04A0, "ADC-2 (no version claimed)"},
1853     {0x04A7, "ADC-2 T10/1741-D revision 7"},
1854     {0x04AA, "ADC-2 T10/1741-D revision 8"},
1855     {0x04AC, "ADC-2 ANSI INCITS 441-2008"},
1856     {0x04C0, "SBC-3 (no version claimed)"},
1857     {0x04C3, "SBC-3 T10/BSR INCITS 514 revision 35"},
1858     {0x04E0, "MMC-6 (no version claimed)"},
1859     {0x04E3, "MMC-6 T10/1836-D revision 02b"},
1860     {0x04E5, "MMC-6 T10/1836-D revision 02g"},
1861     {0x04E6, "MMC-6 ANSI INCITS 468-2010"},
1862     {0x04E7, "MMC-6 ANSI INCITS 468-2010 + MMC-6/AM1 ANSI"},
1863     {0x0500, "ADC-3 (no version claimed)"},
1864     {0x0502, "ADC-3 T10/1895-D revision 4"},
1865     {0x0504, "ADC-3 T10/1895-D revision 5"},
1866     {0x0506, "ADC-3 T10/1895-D revision 05a"},
1867     {0x050A, "ADC-3 ANSI INCITS 497-2012"},
1868     {0x0520, "SSC-4 (no version claimed)"},
1869     {0x0523, "SSC-4 T10/BSR INCITS 516 revision 2"},
1870     {0x0560, "OSD-3 (no version claimed)"},
1871     {0x0580, "SES-3 (no version claimed)"},
1872     {0x05A0, "SSC-5 (no version claimed)"},
1873     {0x05C0, "SPC-5 (no version claimed)"},
1874     {0x05E0, "SFSC (no version claimed)"},
1875     {0x0600, "SBC-4 (no version claimed)"},
1876     {0x0820, "SSA-TL2 (no version claimed)"},
1877     {0x083B, "SSA-TL2 T10.1/1147-D revision 05b"},
1878     {0x083C, "SSA-TL2 ANSI INCITS 308-1998"},
1879     {0x0840, "SSA-TL1 (no version claimed)"},
1880     {0x085B, "SSA-TL1 T10.1/0989-D revision 10b"},
1881     {0x085C, "SSA-TL1 ANSI INCITS 295-1996"},
1882     {0x0860, "SSA-S3P (no version claimed)"},
1883     {0x087B, "SSA-S3P T10.1/1051-D revision 05b"},
1884     {0x087C, "SSA-S3P ANSI INCITS 309-1998"},
1885     {0x0880, "SSA-S2P (no version claimed)"},
1886     {0x089B, "SSA-S2P T10.1/1121-D revision 07b"},
1887     {0x089C, "SSA-S2P ANSI INCITS 294-1996"},
1888     {0x08A0, "SIP (no version claimed)"},
1889     {0x08BB, "SIP T10/0856-D revision 10"},
1890     {0x08BC, "SIP ANSI INCITS 292-1997"},
1891     {0x08C0, "FCP (no version claimed)"},
1892     {0x08DB, "FCP T10/0993-D revision 12"},
1893     {0x08DC, "FCP ANSI INCITS 269-1996"},
1894     {0x08E0, "SBP-2 (no version claimed)"},
1895     {0x08FB, "SBP-2 T10/1155-D revision 4"},
1896     {0x08FC, "SBP-2 ANSI INCITS 325-1998"},
1897     {0x0900, "FCP-2 (no version claimed)"},
1898     {0x0901, "FCP-2 T10/1144-D revision 4"},
1899     {0x0915, "FCP-2 T10/1144-D revision 7"},
1900     {0x0916, "FCP-2 T10/1144-D revision 7a"},
1901     {0x0917, "FCP-2 ANSI INCITS 350-2003"},
1902     {0x0918, "FCP-2 T10/1144-D revision 8"},
1903     {0x0920, "SST (no version claimed)"},
1904     {0x0935, "SST T10/1380-D revision 8b"},
1905     {0x0940, "SRP (no version claimed)"},
1906     {0x0954, "SRP T10/1415-D revision 10"},
1907     {0x0955, "SRP T10/1415-D revision 16a"},
1908     {0x095C, "SRP ANSI INCITS 365-2002"},
1909     {0x0960, "iSCSI (no version claimed)"},
1910     {0x0980, "SBP-3 (no version claimed)"},
1911     {0x0982, "SBP-3 T10/1467-D revision 1f"},
1912     {0x0994, "SBP-3 T10/1467-D revision 3"},
1913     {0x099A, "SBP-3 T10/1467-D revision 4"},
1914     {0x099B, "SBP-3 T10/1467-D revision 5"},
1915     {0x099C, "SBP-3 ANSI INCITS 375-2004"},
1916     {0x09C0, "ADP (no version claimed)"},
1917     {0x09E0, "ADT (no version claimed)"},
1918     {0x09F9, "ADT T10/1557-D revision 11"},
1919     {0x09FA, "ADT T10/1557-D revision 14"},
1920     {0x09FD, "ADT ANSI INCITS 406-2005"},
1921     {0x0A00, "FCP-3 (no version claimed)"},
1922     {0x0A07, "FCP-3 T10/1560-D revision 3f"},
1923     {0x0A0F, "FCP-3 T10/1560-D revision 4"},
1924     {0x0A11, "FCP-3 ANSI INCITS 416-2006"},
1925     {0x0A1C, "FCP-3 ISO/IEC 14776-223"},
1926     {0x0A20, "ADT-2 (no version claimed)"},
1927     {0x0A22, "ADT-2 T10/1742-D revision 6"},
1928     {0x0A27, "ADT-2 T10/1742-D revision 8"},
1929     {0x0A28, "ADT-2 T10/1742-D revision 9"},
1930     {0x0A2B, "ADT-2 ANSI INCITS 472-2011"},
1931     {0x0A40, "FCP-4 (no version claimed)"},
1932     {0x0A42, "FCP-4 T10/1828-D revision 1"},
1933     {0x0A44, "FCP-4 T10/1828-D revision 2"},
1934     {0x0A45, "FCP-4 T10/1828-D revision 02b"},
1935     {0x0A46, "FCP-4 ANSI INCITS 481-2012"},
1936     {0x0AA0, "SPI (no version claimed)"},
1937     {0x0AB9, "SPI T10/0855-D revision 15a"},
1938     {0x0ABA, "SPI ANSI INCITS 253-1995"},
1939     {0x0ABB, "SPI T10/0855-D revision 15a with SPI Amnd revision 3a"},
1940     {0x0ABC, "SPI ANSI INCITS 253-1995 with SPI Amnd ANSI INCITS 253/AM1-1998"},
1941     {0x0AC0, "Fast-20 (no version claimed)"},
1942     {0x0ADB, "Fast-20 T10/1071 revision 6"},
1943     {0x0ADC, "Fast-20 ANSI INCITS 277-1996"},
1944     {0x0AE0, "SPI-2 (no version claimed)"},
1945     {0x0AFB, "SPI-2 T10/1142-D revision 20b"},
1946     {0x0AFC, "SPI-2 ANSI INCITS 302-1999"},
1947     {0x0B00, "SPI-3 (no version claimed)"},
1948     {0x0B18, "SPI-3 T10/1302-D revision 10"},
1949     {0x0B19, "SPI-3 T10/1302-D revision 13a"},
1950     {0x0B1A, "SPI-3 T10/1302-D revision 14"},
1951     {0x0B1C, "SPI-3 ANSI INCITS 336-2000"},
1952     {0x0B20, "EPI (no version claimed)"},
1953     {0x0B3B, "EPI T10/1134 revision 16"},
1954     {0x0B3C, "EPI ANSI INCITS TR-23 1999"},
1955     {0x0B40, "SPI-4 (no version claimed)"},
1956     {0x0B54, "SPI-4 T10/1365-D revision 7"},
1957     {0x0B55, "SPI-4 T10/1365-D revision 9"},
1958     {0x0B56, "SPI-4 ANSI INCITS 362-2002"},
1959     {0x0B59, "SPI-4 T10/1365-D revision 10"},
1960     {0x0B60, "SPI-5 (no version claimed)"},
1961     {0x0B79, "SPI-5 T10/1525-D revision 3"},
1962     {0x0B7A, "SPI-5 T10/1525-D revision 5"},
1963     {0x0B7B, "SPI-5 T10/1525-D revision 6"},
1964     {0x0B7C, "SPI-5 ANSI INCITS 367-2003"},
1965     {0x0BE0, "SAS (no version claimed)"},
1966     {0x0BE1, "SAS T10/1562-D revision 1"},
1967     {0x0BF5, "SAS T10/1562-D revision 3"},
1968     {0x0BFA, "SAS T10/1562-D revision 4"},
1969     {0x0BFB, "SAS T10/1562-D revision 4"},
1970     {0x0BFC, "SAS T10/1562-D revision 5"},
1971     {0x0BFD, "SAS ANSI INCITS 376-2003"},
1972     {0x0C00, "SAS-1.1 (no version claimed)"},
1973     {0x0C07, "SAS-1.1 T10/1601-D revision 9"},
1974     {0x0C0F, "SAS-1.1 T10/1601-D revision 10"},
1975     {0x0C11, "SAS-1.1 ANSI INCITS 417-2006"},
1976     {0x0C12, "SAS-1.1 ISO/IEC 14776-151"},
1977     {0x0C20, "SAS-2 (no version claimed)"},
1978     {0x0C23, "SAS-2 T10/1760-D revision 14"},
1979     {0x0C27, "SAS-2 T10/1760-D revision 15"},
1980     {0x0C28, "SAS-2 T10/1760-D revision 16"},
1981     {0x0C2A, "SAS-2 ANSI INCITS 457-2010"},
1982     {0x0C40, "SAS-2.1 (no version claimed)"},
1983     {0x0C48, "SAS-2.1 T10/2125-D revision 4"},
1984     {0x0C4A, "SAS-2.1 T10/2125-D revision 6"},
1985     {0x0C4B, "SAS-2.1 T10/2125-D revision 7"},
1986     {0x0C4E, "SAS-2.1 ANSI INCITS 478-2011"},
1987     {0x0C60, "SAS-3 (no version claimed)"},
1988     {0x0C63, "SAS-3 T10/BSR INCITS 519 revision 05a"},
1989     {0x0D20, "FC-PH (no version claimed)"},
1990     {0x0D3B, "FC-PH ANSI INCITS 230-1994"},
1991     {0x0D3C, "FC-PH ANSI INCITS 230-1994 with Amnd 1 ANSI INCITS 230/AM1-1996"},
1992     {0x0D40, "FC-AL (no version claimed)"},
1993     {0x0D5C, "FC-AL ANSI INCITS 272-1996"},
1994     {0x0D60, "FC-AL-2 (no version claimed)"},
1995     {0x0D61, "FC-AL-2 T11/1133-D revision 7.0"},
1996     {0x0D63, "FC-AL-2 ANSI INCITS 332-1999 with AM1-2003 & AM2-2006"},
1997     {0x0D64, "FC-AL-2 ANSI INCITS 332-1999 with Amnd 2 AM2-2006"},
1998     {0x0D65, "FC-AL-2 ISO/IEC 14165-122 with AM1 & AM2"},
1999     {0x0D7C, "FC-AL-2 ANSI INCITS 332-1999"},
2000     {0x0D7D, "FC-AL-2 ANSI INCITS 332-1999 with Amnd 1 AM1-2003"},
2001     {0x0D80, "FC-PH-3 (no version claimed)"},
2002     {0x0D9C, "FC-PH-3 ANSI INCITS 303-1998"},
2003     {0x0DA0, "FC-FS (no version claimed)"},
2004     {0x0DB7, "FC-FS T11/1331-D revision 1.2"},
2005     {0x0DB8, "FC-FS T11/1331-D revision 1.7"},
2006     {0x0DBC, "FC-FS ANSI INCITS 373-2003"},
2007     {0x0DBD, "FC-FS ISO/IEC 14165-251"},
2008     {0x0DC0, "FC-PI (no version claimed)"},
2009     {0x0DDC, "FC-PI ANSI INCITS 352-2002"},
2010     {0x0DE0, "FC-PI-2 (no version claimed)"},
2011     {0x0DE2, "FC-PI-2 T11/1506-D revision 5.0"},
2012     {0x0DE4, "FC-PI-2 ANSI INCITS 404-2006"},
2013     {0x0E00, "FC-FS-2 (no version claimed)"},
2014     {0x0E02, "FC-FS-2 ANSI INCITS 242-2007"},
2015     {0x0E03, "FC-FS-2 ANSI INCITS 242-2007 with AM1 ANSI INCITS 242/AM1-2007"},
2016     {0x0E20, "FC-LS (no version claimed)"},
2017     {0x0E21, "FC-LS T11/1620-D revision 1.62"},
2018     {0x0E29, "FC-LS ANSI INCITS 433-2007"},
2019     {0x0E40, "FC-SP (no version claimed)"},
2020     {0x0E42, "FC-SP T11/1570-D revision 1.6"},
2021     {0x0E45, "FC-SP ANSI INCITS 426-2007"},
2022     {0x0E60, "FC-PI-3 (no version claimed)"},
2023     {0x0E62, "FC-PI-3 T11/1625-D revision 2.0"},
2024     {0x0E68, "FC-PI-3 T11/1625-D revision 2.1"},
2025     {0x0E6A, "FC-PI-3 T11/1625-D revision 4.0"},
2026     {0x0E6E, "FC-PI-3 ANSI INCITS 460-2011"},
2027     {0x0E80, "FC-PI-4 (no version claimed)"},
2028     {0x0E82, "FC-PI-4 T11/1647-D revision 8.0"},
2029     {0x0E88, "FC-PI-4 ANSI INCITS 450-2009"},
2030     {0x0EA0, "FC 10GFC (no version claimed)"},
2031     {0x0EA2, "FC 10GFC ANSI INCITS 364-2003"},
2032     {0x0EA3, "FC 10GFC ISO/IEC 14165-116"},
2033     {0x0EA5, "FC 10GFC ISO/IEC 14165-116 with AM1"},
2034     {0x0EA6, "FC 10GFC ANSI INCITS 364-2003 with AM1 ANSI INCITS 364/AM1-2007"},
2035     {0x0EC0, "FC-SP-2 (no version claimed)"},
2036     {0x0EE0, "FC-FS-3 (no version claimed)"},
2037     {0x0EE2, "FC-FS-3 T11/1861-D revision 0.9"},
2038     {0x0EE7, "FC-FS-3 T11/1861-D revision 1.0"},
2039     {0x0EE9, "FC-FS-3 T11/1861-D revision 1.10"},
2040     {0x0EEB, "FC-FS-3 ANSI INCITS 470-2011"},
2041     {0x0F00, "FC-LS-2 (no version claimed)"},
2042     {0x0F03, "FC-LS-2 T11/2103-D revision 2.11"},
2043     {0x0F05, "FC-LS-2 T11/2103-D revision 2.21"},
2044     {0x0F07, "FC-LS-2 ANSI INCITS 477-2011"},
2045     {0x0F20, "FC-PI-5 (no version claimed)"},
2046     {0x0F27, "FC-PI-5 T11/2118-D revision 2.00"},
2047     {0x0F28, "FC-PI-5 T11/2118-D revision 3.00"},
2048     {0x0F2A, "FC-PI-5 T11/2118-D revision 6.00"},
2049     {0x0F2B, "FC-PI-5 T11/2118-D revision 6.10"},
2050     {0x0F2E, "FC-PI-5 ANSI INCITS 479-2011"},
2051     {0x0F40, "FC-PI-6 (no version claimed)"},
2052     {0x0F60, "FC-FS-4 (no version claimed)"},
2053     {0x0F80, "FC-LS-3 (no version claimed)"},
2054     {0x12A0, "FC-SCM (no version claimed)"},
2055     {0x12A3, "FC-SCM T11/1824DT revision 1.0"},
2056     {0x12A5, "FC-SCM T11/1824DT revision 1.1"},
2057     {0x12A7, "FC-SCM T11/1824DT revision 1.4"},
2058     {0x12AA, "FC-SCM INCITS TR-47 2012"},
2059     {0x12C0, "FC-DA-2 (no version claimed)"},
2060     {0x12C3, "FC-DA-2 T11/1870DT revision 1.04"},
2061     {0x12C5, "FC-DA-2 T11/1870DT revision 1.06"},
2062     {0x12C9, "FC-DA-2 INCITS TR-49 2012"},
2063     {0x12E0, "FC-DA (no version claimed)"},
2064     {0x12E2, "FC-DA T11/1513-DT revision 3.1"},
2065     {0x12E8, "FC-DA ANSI INCITS TR-36 2004"},
2066     {0x12E9, "FC-DA ISO/IEC 14165-341"},
2067     {0x1300, "FC-Tape (no version claimed)"},
2068     {0x1301, "FC-Tape T11/1315 revision 1.16"},
2069     {0x131B, "FC-Tape T11/1315 revision 1.17"},
2070     {0x131C, "FC-Tape ANSI INCITS TR-24 1999"},
2071     {0x1320, "FC-FLA (no version claimed)"},
2072     {0x133B, "FC-FLA T11/1235 revision 7"},
2073     {0x133C, "FC-FLA ANSI INCITS TR-20 1998"},
2074     {0x1340, "FC-PLDA (no version claimed)"},
2075     {0x135B, "FC-PLDA T11/1162 revision 2.1"},
2076     {0x135C, "FC-PLDA ANSI INCITS TR-19 1998"},
2077     {0x1360, "SSA-PH2 (no version claimed)"},
2078     {0x137B, "SSA-PH2 T10.1/1145-D revision 09c"},
2079     {0x137C, "SSA-PH2 ANSI INCITS 293-1996"},
2080     {0x1380, "SSA-PH3 (no version claimed)"},
2081     {0x139B, "SSA-PH3 T10.1/1146-D revision 05b"},
2082     {0x139C, "SSA-PH3 ANSI INCITS 307-1998"},
2083     {0x14A0, "IEEE 1394 (no version claimed)"},
2084     {0x14BD, "ANSI IEEE 1394-1995"},
2085     {0x14C0, "IEEE 1394a (no version claimed)"},
2086     {0x14E0, "IEEE 1394b (no version claimed)"},
2087     {0x15E0, "ATA/ATAPI-6 (no version claimed)"},
2088     {0x15FD, "ATA/ATAPI-6 ANSI INCITS 361-2002"},
2089     {0x1600, "ATA/ATAPI-7 (no version claimed)"},
2090     {0x1602, "ATA/ATAPI-7 T13/1532-D revision 3"},
2091     {0x161C, "ATA/ATAPI-7 ANSI INCITS 397-2005"},
2092     {0x161E, "ATA/ATAPI-7 ISO/IEC 24739"},
2093     {0x1620, "ATA/ATAPI-8 ATA8-AAM (no version claimed)"},
2094     {0x1621, "ATA/ATAPI-8 ATA8-APT Parallel Transport (no version claimed)"},
2095     {0x1622, "ATA/ATAPI-8 ATA8-AST Serial Transport (no version claimed)"},
2096     {0x1623, "ATA/ATAPI-8 ATA8-ACS ATA/ATAPI Command Set (no version claimed)"},
2097     {0x1628, "ATA/ATAPI-8 ATA8-AAM ANSI INCITS 451-2008"},
2098     {0x162A, "ATA/ATAPI-8 ATA8-ACS ANSI INCITS 452-2009 w/Amendment 1"},
2099     {0x1728, "Universal Serial Bus Specification, Revision 1.1"},
2100     {0x1729, "Universal Serial Bus Specification, Revision 2.0"},
2101     {0x1730, "USB Mass Storage Class Bulk-Only Transport, Revision 1.0"},
2102     {0x1740, "UAS (no version claimed)"},
2103     {0x1743, "UAS T10/2095-D revision 2"},
2104     {0x1747, "UAS T10/2095-D revision 4"},
2105     {0x1748, "UAS ANSI INCITS 471-2010"},
2106     {0x1761, "ACS-2 (no version claimed)"},
2107     {0x1762, "ACS-2 ANSI INCITS 482-2013"},
2108     {0x1765, "ACS-3 (no version claimed)"},
2109     {0x1780, "UAS-2 (no version claimed)"},
2110     {0x1EA0, "SAT (no version claimed)"},
2111     {0x1EA7, "SAT T10/1711-D revision 8"},
2112     {0x1EAB, "SAT T10/1711-D revision 9"},
2113     {0x1EAD, "SAT ANSI INCITS 431-2007"},
2114     {0x1EC0, "SAT-2 (no version claimed)"},
2115     {0x1EC4, "SAT-2 T10/1826-D revision 6"},
2116     {0x1EC8, "SAT-2 T10/1826-D revision 9"},
2117     {0x1ECA, "SAT-2 ANSI INCITS 465-2010"},
2118     {0x1EE0, "SAT-3 (no version claimed)"},
2119     {0x1EE2, "SAT-3 T10/BSR INCITS 517 revision 4"},
2120     {0x1F00, "SAT-4 (no version claimed)"},
2121     {0x20A0, "SPL (no version claimed)"},
2122     {0x20A3, "SPL T10/2124-D revision 6a"},
2123     {0x20A5, "SPL T10/2124-D revision 7"},
2124     {0x20A7, "SPL ANSI INCITS 476-2011"},
2125     {0x20A8, "SPL ANSI INCITS 476-2011 + SPL AM1 INCITS 476/AM1 2012"},
2126     {0x20C0, "SPL-2 (no version claimed)"},
2127     {0x20C2, "SPL-2 T10/BSR INCITS 505 revision 4"},
2128     {0x20C4, "SPL-2 T10/BSR INCITS 505 revision 5"},
2129     {0x20E0, "SPL-3 (no version claimed)"},
2130     {0x21E0, "SOP (no version claimed)"},
2131     {0x21E4, "SOP T10/BSR INCITS 489 revision 4"},
2132     {0x2200, "PQI (no version claimed)"},
2133     {0x2204, "PQI T10/BSR INCITS 490 revision 6"},
2134     {0x2220, "SOP-2 (no version claimed)"},
2135     {0x2240, "PQI-2 (no version claimed)"},
2136     {0xFFC0, "IEEE 1667 (no version claimed)"},
2137     {0xFFC1, "IEEE 1667-2006"},
2138     {0xFFC2, "IEEE 1667-2009"},
2139     {0, NULL},
2140 };
2141 
2142 static value_string_ext scsi_verdesc_val_ext = VALUE_STRING_EXT_INIT(scsi_verdesc_val);
2143 
2144 /* Command Support Data "Support" field definitions */
2145 static const value_string scsi_cmdt_supp_val[] = {
2146     {0, "Data not currently available"},
2147     {1, "SCSI Command not supported"},
2148     {2, "Reserved"},
2149     {3, "SCSI Command supported in conformance with a SCSI standard"},
2150     {4, "Vendor Specific"},
2151     {5, "SCSI Command supported in a vendor specific manner"},
2152     {6, "Vendor Specific"},
2153     {7, "Reserved"},
2154     {0, NULL},
2155 };
2156 
2157 #define CODESET_BINARY  1
2158 #define CODESET_ASCII   2
2159 #define CODESET_UTF8    3
2160 
2161 const value_string scsi_devid_codeset_val[] = {
2162     {0,              "Reserved"},
2163     {CODESET_BINARY, "Identifier field contains binary values"},
2164     {CODESET_ASCII,  "Identifier field contains ASCII graphic codes"},
2165     {CODESET_UTF8,   "Identifier field contains UTF-8 codes"},
2166     {0,              NULL},
2167 };
2168 
2169 static const value_string scsi_devid_assoc_val[] = {
2170     {0, "Identifier is associated with addressed logical/physical device"},
2171     {1, "Identifier is associated with the port that received the request"},
2172     {2, "Identifier is associated with the SCSI target devices that contains the logical/physical device"},
2173     {0, NULL},
2174 };
2175 
2176 #define DEVID_TYPE_VEND_ID_VEND_SPEC_ID 1
2177 #define DEVID_TYPE_NAA                  3
2178 
2179 const value_string scsi_devid_idtype_val[] = {
2180     {0, "Vendor-specific ID (non-globally unique)"},
2181     {DEVID_TYPE_VEND_ID_VEND_SPEC_ID, "Vendor-ID + vendor-specific ID (globally unique)"},
2182     {2, "EUI-64 ID"},
2183     {DEVID_TYPE_NAA, "NAA"},
2184     {4, "4-byte Binary Number/Reserved"},
2185     {0, NULL},
2186 };
2187 
2188 static const value_string scsi_modesns_mrie_val[] = {
2189     {0, "No Reporting of Informational Exception Condition"},
2190     {1, "Asynchronous Error Reporting"},
2191     {2, "Generate Unit Attention"},
2192     {3, "Conditionally Generate Recovered Error"},
2193     {4, "Unconditionally Generate Recovered Error"},
2194     {5, "Generate No Sense"},
2195     {6, "Only Report Informational Exception Condition on Request"},
2196     {0, NULL},
2197 };
2198 
2199 static const value_string scsi_modesns_tst_val[] = {
2200     {0, "Task Set Per LU For All Initiators"},
2201     {1, "Task Set Per Initiator Per LU"},
2202     {0, NULL},
2203 };
2204 
2205 static const value_string scsi_modesns_qmod_val[] = {
2206     {0, "Restricted reordering"},
2207     {1, "Unrestricted reordering"},
2208     {0, NULL},
2209 };
2210 
2211 static const true_false_string scsi_modesns_qerr_val = {
2212     "All blocked tasks shall be aborted on CHECK CONDITION",
2213     "Blocked tasks shall resume after ACA/CA is cleared",
2214 };
2215 
2216 static const true_false_string scsi_spec_i_pt_tfs = {
2217     "Specify Initiator Ports is set",
2218     "Specify Initiator Ports is not set"
2219 };
2220 
2221 static const true_false_string scsi_all_tg_pt_tfs = {
2222     "All Target Ports is set",
2223     "All Target Ports is not set"
2224 };
2225 
2226 static const true_false_string scsi_aptpl_tfs = {
2227     "Active Persist Through Power Loss is set",
2228     "Active Persist Through Power Loss is not set"
2229 };
2230 
2231 static const true_false_string scsi_naca_tfs = {
2232     "Normal ACA is set",
2233     "Normal ACA is not set"
2234 };
2235 
2236 static const true_false_string normaca_tfs = {
2237     "NormACA is SUPPORTED",
2238     "Normaca is NOT supported",
2239 };
2240 
2241 static const true_false_string sccs_tfs = {
2242     "SCC is SUPPORTED",
2243     "Scc is NOT supported",
2244 };
2245 
2246 static const true_false_string acc_tfs = {
2247     "Access Control Coordinator is SUPPORTED",
2248     "Access control coordinator NOT supported",
2249 };
2250 
2251 static const true_false_string bque_tfs = {
2252     "BQUE is SUPPORTED",
2253     "Bque is NOT supported",
2254 };
2255 
2256 static const true_false_string encserv_tfs = {
2257     "Enclosed Services is SUPPORTED",
2258     "Enclosed services is NOT supported",
2259 };
2260 
2261 static const true_false_string reladr_tfs = {
2262     "Relative Addressing mode is SUPPORTED",
2263     "Relative addressing mode is NOT supported",
2264 };
2265 
2266 #if 0
2267 static const true_false_string sync_tfs = {
2268     "Synchronous data transfer is SUPPORTED",
2269     "Synchronous data transfer is NOT supported",
2270 };
2271 #endif
2272 
2273 static const true_false_string linked_tfs = {
2274     "Linked Commands are SUPPORTED",
2275     "Linked commands are NOT supported",
2276 };
2277 
2278 static const true_false_string cmdque_tfs = {
2279     "Command queuing is SUPPORTED",
2280     "Command queuing is NOT supported",
2281 };
2282 
2283 static const true_false_string multip_tfs = {
2284     "This is a MULTIPORT device",
2285     "This is NOT a multiport device",
2286 };
2287 
2288 static const true_false_string mchngr_tfs = {
2289     "This device is attached to a MEDIUMCHANGER",
2290     "This is a normal device",
2291 };
2292 
2293 static const true_false_string tpc_tfs = {
2294     "Third Party Copy is SUPPORTED",
2295     "Third party copy is NOT supported",
2296 };
2297 
2298 static const true_false_string protect_tfs = {
2299     "Protection Information is SUPPORTED",
2300     "Protection information NOT supported",
2301 };
2302 
2303 static const true_false_string hisup_tfs = {
2304     "Hierarchical Addressing Mode is SUPPORTED",
2305     "Hierarchical addressing mode is NOT supported",
2306 };
2307 
2308 static const true_false_string aerc_tfs = {
2309     "Async Event Reporting Capability is SUPPORTED",
2310     "Async event reporting capability is NOT supported",
2311 };
2312 
2313 static const true_false_string trmtsk_tfs = {
2314     "Terminate Task management functions are SUPPORTED",
2315     "Terminate task management functions are NOT supported",
2316 };
2317 
2318 static const true_false_string scsi_removable_val = {
2319     "This is a REMOVABLE device",
2320     "This device is NOT removable",
2321 };
2322 
2323 static const true_false_string scsi_modesns_tas_val = {
2324     "Terminated tasks aborted without informing initiators",
2325     "Tasks aborted by another initiator terminated with TASK ABORTED",
2326 };
2327 
2328 static const true_false_string scsi_modesns_rac_val = {
2329     "Report a CHECK CONDITION Instead of Long Busy Condition",
2330     "Long Busy Conditions Maybe Reported",
2331 };
2332 
2333 /* SCSI Transport Protocols */
2334 #define SCSI_PROTO_FCP          0
2335 #define SCSI_PROTO_iSCSI        5
2336 
2337 static const value_string scsi_proto_val[] = {
2338     {0, "FCP"},
2339     {5, "iSCSI"},
2340     {0, NULL},
2341 };
2342 
2343 static const value_string scsi_fcp_rrtov_val[] = {
2344     {0, "No Timer Specified"},
2345     {1, "0.001 secs"},
2346     {3, "0.1 secs"},
2347     {5, "10 secs"},
2348     {0, NULL},
2349 };
2350 
2351 static const value_string scsi_sensekey_val[] = {
2352     {0x0, "No Sense"},
2353     {0x1, "Recovered Error"},
2354     {0x2, "Not Ready"},
2355     {0x3, "Medium Error"},
2356     {0x4, "Hardware Error"},
2357     {0x5, "Illegal Request"},
2358     {0x6, "Unit Attention"},
2359     {0x7, "Data Protection"},
2360     {0x8, "Blank Check"},
2361     {0x9, "Vendor Specific"},
2362     {0xA, "Copy Aborted"},
2363     {0xB, "Command Aborted"},
2364     {0xC, "Obsolete Error Code"},
2365     {0xD, "Overflow Command"},
2366     {0xE, "Miscompare"},
2367     {0xF, "Reserved"},
2368     {0, NULL},
2369 };
2370 
2371 static const value_string scsi_sense_desc_type_val[] = {
2372     {0x00, "Information"},
2373     {0x01, "Command specific information"},
2374     {0x02, "Sense key specific"},
2375     {0x03, "Field replaceable unit"},
2376     {0x04, "Stream commands"},
2377     {0x05, "Block commands"},
2378     {0x06, "OSD object identification"},
2379     {0x07, "OSD response integrity check value"},
2380     {0x08, "OSD attribute identification"},
2381     {0x09, "ATA Status"},
2382     {0x0A, "Another progress indication"},
2383     {0x0B, "User data segment referral"},
2384     {0x0C, "Forwarded sense data"},
2385     {0, NULL},
2386 };
2387 
2388 static const value_string scsi_sense_sks_fp_cd_val[] = {
2389     {0, "illegal parameter in the Data-Out buffer"},
2390     {1, "illegal parameter in the CDB"},
2391     {0, NULL},
2392 };
2393 
2394 static const value_string scsi_sns_errtype_val[] = {
2395     {0x70, "Current Error"},
2396     {0x71, "Deferred Error"},
2397     {0x72, "Current Error"},
2398     {0x73, "Deferred Error"},
2399     {0x7F, "Vendor Specific"},
2400     {0, NULL},
2401 };
2402 
2403 /* All can be found @ http://www.t10.org/lists/asc-alph.txt or http://www.t10.org/lists/asc-num.txt */
2404 static const value_string scsi_asc_val[] = {
2405     {0x0000,  "No Additional Sense Information"},
2406     {0x0001,  "Filemark Detected"},
2407     {0x0002,  "End Of Partition/Medium Detected"},
2408     {0x0003,  "Setmark Detected"},
2409     {0x0004,  "Beginning Of Partition Detected"},
2410     {0x0005,  "End Of Data Detected"},
2411     {0x0006,  "I/O Process Terminated"},
2412     {0x0016,  "Operation In Progress"},
2413     {0x0017,  "Cleaning Requested"},
2414     {0x0018,  "Erase Operation In Progress"},
2415     {0x0019,  "Locate Operation In Progress"},
2416     {0x001A,  "Rewind Operation In Progress"},
2417     {0x001B,  "Set Capacity Operation In Progress"},
2418     {0x001C,  "Verify operation in progress"},
2419     {0x0100,  "No Index/Sector Signal"},
2420     {0x0200,  "No Seek Complete"},
2421     {0x0300,  "Peripheral Device Write Fault"},
2422     {0x0400,  "Logical Unit Not Ready, Cause Not Reportable"},
2423     {0x0401,  "Logical Unit Is In Process Of Becoming Ready"},
2424     {0x0402,  "Logical Unit Not Ready, Initializing Cmd. Required"},
2425     {0x0403,  "Logical Unit Not Ready, Manual Intervention Required"},
2426     {0x0404,  "Logical Unit Not Ready, Format In Progress"},
2427     {0x0405,  "Logical Unit Not Ready, Rebuild In Progress"},
2428     {0x0406,  "Logical Unit Not Ready, Recalculation In Progress"},
2429     {0x0407,  "Logical Unit Not Ready, Operation In Progress"},
2430     {0x0409,  "Logical Unit Not Ready, Self-Test In Progress"},
2431     {0x0500,  "Logical Unit Does Not Respond To Selection"},
2432     {0x0600,  "No Reference Position Found"},
2433     {0x0700,  "Multiple Peripheral Devices Selected"},
2434     {0x0800,  "Logical Unit Communication Failure"},
2435     {0x0801,  "Logical Unit Communication Time-Out"},
2436     {0x0802,  "Logical Unit Communication Parity Error"},
2437     {0x0803,  "Logical Unit Communication Crc Error (Ultra-Dma/32)"},
2438     {0x0804,  "Unreachable Copy Target"},
2439     {0x0900,  "Track Following Error"},
2440     {0x0904,  "Head Select Fault"},
2441     {0x0A00,  "Error Log Overflow"},
2442     {0x0B00,  "Warning"},
2443     {0x0B01,  "Warning - Specified Temperature Exceeded"},
2444     {0x0B02,  "Warning - Enclosure Degraded"},
2445     {0x0C02,  "Write Error - Auto Reallocation Failed"},
2446     {0x0C03,  "Write Error - Recommend Reassignment"},
2447     {0x0C04,  "Compression Check Miscompare Error"},
2448     {0x0C05,  "Data Expansion Occurred During Compression"},
2449     {0x0C06,  "Block Not Compressible"},
2450     {0x0D00,  "Error Detected By Third Party Temporary Initiator"},
2451     {0x0D01,  "Third Party Device Failure"},
2452     {0x0D02,  "Copy Target Device Not Reachable"},
2453     {0x0D03,  "Incorrect Copy Target Device Type"},
2454     {0x0D04,  "Copy Target Device Data Underrun"},
2455     {0x0D05,  "Copy Target Device Data Overrun"},
2456     {0x1000,  "Id Crc Or Ecc Error"},
2457     {0x1100,  "Unrecovered Read Error"},
2458     {0x1101,  "Read Retries Exhausted"},
2459     {0x1102,  "Error Too Long To Correct"},
2460     {0x1103,  "Multiple Read Errors"},
2461     {0x1104,  "Unrecovered Read Error - Auto Reallocate Failed"},
2462     {0x110A,  "Miscorrected Error"},
2463     {0x110B,  "Unrecovered Read Error - Recommend Reassignment"},
2464     {0x110C,  "Unrecovered Read Error - Recommend Rewrite The Data"},
2465     {0x110D,  "De-Compression Crc Error"},
2466     {0x110E,  "Cannot Decompress Using Declared Algorithm"},
2467     {0x1200,  "Address Mark Not Found For Id Field"},
2468     {0x1300,  "Address Mark Not Found For Data Field"},
2469     {0x1400,  "Recorded Entity Not Found"},
2470     {0x1401,  "Record Not Found"},
2471     {0x1405,  "Record Not Found - Recommend Reassignment"},
2472     {0x1406,  "Record Not Found - Data Auto-Reallocated"},
2473     {0x1500,  "Random Positioning Error"},
2474     {0x1501,  "Mechanical Positioning Error"},
2475     {0x1502,  "Positioning Error Detected By Read Of Medium"},
2476     {0x1600,  "Data Synchronization Mark Error"},
2477     {0x1601,  "Data Sync Error - Data Rewritten"},
2478     {0x1602,  "Data Sync Error - Recommend Rewrite"},
2479     {0x1603,  "Data Sync Error - Data Auto-Reallocated"},
2480     {0x1604,  "Data Sync Error - Recommend Reassignment"},
2481     {0x1700,  "Recovered Data With No Error Correction Applied"},
2482     {0x1701,  "Recovered Data With Retries"},
2483     {0x1702,  "Recovered Data With Positive Head Offset"},
2484     {0x1703,  "Recovered Data With Negative Head Offset"},
2485     {0x1705,  "Recovered Data Using Previous Sector Id"},
2486     {0x1706,  "Recovered Data Without Ecc - Data Auto-Reallocated"},
2487     {0x1707,  "Recovered Data Without Ecc - Recommend Reassignment"},
2488     {0x1708,  "Recovered Data Without Ecc - Recommend Rewrite"},
2489     {0x1709,  "Recovered Data Without Ecc - Data Rewritten"},
2490     {0x1800,  "Recovered Data With Error Correction Applied"},
2491     {0x1801,  "Recovered Data With Error Corr. & Retries Applied"},
2492     {0x1802,  "Recovered Data - Data Auto-Reallocated"},
2493     {0x1805,  "Recovered Data - Recommend Reassignment"},
2494     {0x1806,  "Recovered Data - Recommend Rewrite"},
2495     {0x1807,  "Recovered Data With Ecc - Data Rewritten"},
2496     {0x1900,  "List Error"},
2497     {0x1901,  "List Not Available"},
2498     {0x1902,  "List Error In Primary List"},
2499     {0x1903,  "List Error In Grown List"},
2500     {0x1A00,  "Parameter List Length Error"},
2501     {0x1B00,  "Synchronous Data Transfer Error"},
2502     {0x1C00,  "Defect List Not Found"},
2503     {0x1C01,  "Primary Defect List Not Found"},
2504     {0x1C02,  "Grown Defect List Not Found"},
2505     {0x1D00,  "Miscompare During Verify Operation"},
2506     {0x1E00,  "Recovered Id With Ecc Correction"},
2507     {0x1F00,  "Defect List Transfer"},
2508     {0x2000,  "Invalid Command Operation Code"},
2509     {0x2100,  "Logical Block Address Out Of Range"},
2510     {0x2101,  "Invalid Element Address"},
2511     {0x2400,  "Invalid Field In Cdb"},
2512     {0x2401,  "Cdb Decryption Error"},
2513     {0x2500,  "Logical Unit Not Supported"},
2514     {0x2600,  "Invalid Field In Parameter List"},
2515     {0x2601,  "Parameter Not Supported"},
2516     {0x2602,  "Parameter Value Invalid"},
2517     {0x2603,  "Threshold Parameters Not Supported"},
2518     {0x2604,  "Invalid Release Of Persistent Reservation"},
2519     {0x2605,  "Data Decryption Error"},
2520     {0x2606,  "Too Many Target Descriptors"},
2521     {0x2607,  "Unsupported Target Descriptor Type Code"},
2522     {0x2608,  "Too Many Segment Descriptors"},
2523     {0x2609,  "Unsupported Segment Descriptor Type Code"},
2524     {0x260A,  "Unexpected Inexact Segment"},
2525     {0x260B,  "Inline Data Length Exceeded"},
2526     {0x260C,  "Invalid Operation For Copy Source Or Destination"},
2527     {0x260D,  "Copy Segment Granularity Violation"},
2528     {0x2700,  "Write Protected"},
2529     {0x2701,  "Hardware Write Protected"},
2530     {0x2702,  "Logical Unit Software Write Protected"},
2531     {0x2800,  "Not Ready To Ready Change, Medium May Have Changed"},
2532     {0x2801,  "Import Or Export Element Accessed"},
2533     {0x2900,  "Power On, Reset, Or Bus Device Reset Occurred"},
2534     {0x2901,  "Power On Occurred"},
2535     {0x2902,  "Scsi Bus Reset Occurred"},
2536     {0x2903,  "Bus Device Reset Function Occurred"},
2537     {0x2904,  "Device Internal Reset"},
2538     {0x2905,  "Transceiver Mode Changed To Single-Ended"},
2539     {0x2906,  "Transceiver Mode Changed To Lvd"},
2540     {0x2A00,  "Parameters Changed"},
2541     {0x2A01,  "Mode Parameters Changed"},
2542     {0x2A02,  "Log Parameters Changed"},
2543     {0x2A03,  "Reservations Preempted"},
2544     {0x2A04,  "Reservations Released"},
2545     {0x2A05,  "Registrations Preempted"},
2546     {0x2B00,  "Copy Cannot Execute Since Host Cannot Disconnect"},
2547     {0x2C00,  "Command Sequence Error"},
2548     {0x2C0A,  "Partition or Collection Contains User Objects"},
2549     {0x2F00,  "Commands Cleared By Another Initiator"},
2550     {0x3000,  "Incompatible Medium Installed"},
2551     {0x3001,  "Cannot Read Medium - Unknown Format"},
2552     {0x3002,  "Cannot Read Medium - Incompatible Format"},
2553     {0x3003,  "Cleaning Cartridge Installed"},
2554     {0x3004,  "Cannot Write Medium - Unknown Format"},
2555     {0x3005,  "Cannot Write Medium - Incompatible Format"},
2556     {0x3006,  "Cannot Format Medium - Incompatible Medium"},
2557     {0x3007,  "Cleaning Failure"},
2558     {0x3100,  "Medium Format Corrupted"},
2559     {0x3101,  "Format Command Failed"},
2560     {0x3200,  "No Defect Spare Location Available"},
2561     {0x3201,  "Defect List Update Failure"},
2562     {0x3400,  "Enclosure Failure"},
2563     {0x3500,  "Enclosure Services Failure"},
2564     {0x3501,  "Unsupported Enclosure Function"},
2565     {0x3502,  "Enclosure Services Unavailable"},
2566     {0x3503,  "Enclosure Services Transfer Failure"},
2567     {0x3504,  "Enclosure Services Transfer Refused"},
2568     {0x3700,  "Rounded Parameter"},
2569     {0x3807,  "Thin Provisioning Soft Threshold Reached"},
2570     {0x3900,  "Saving Parameters Not Supported"},
2571     {0x3A00,  "Medium Not Present"},
2572     {0x3A01,  "Medium Not Present - Tray Closed"},
2573     {0x3A02,  "Medium Not Present - Tray Open"},
2574     {0x3A03,  "Medium Not Present - Loadable"},
2575     {0x3A04,  "Medium Not Present - Medium Auxiliary Memory Accessible"},
2576     {0x3B0D,  "Medium Destination Element Full"},
2577     {0x3B0E,  "Medium Source Element Empty"},
2578     {0x3B11,  "Medium Magazine Not Accessible"},
2579     {0x3B12,  "Medium Magazine Removed"},
2580     {0x3B13,  "Medium Magazine Inserted"},
2581     {0x3B14,  "Medium Magazine Locked"},
2582     {0x3B15,  "Medium Magazine Unlocked"},
2583     {0x3D00,  "Invalid Bits In Identify Message"},
2584     {0x3E00,  "Logical Unit Has Not Self-Configured Yet"},
2585     {0x3E01,  "Logical Unit Failure"},
2586     {0x3E02,  "Timeout On Logical Unit"},
2587     {0x3E03,  "Logical Unit Failed Self-Test"},
2588     {0x3E04,  "Logical Unit Unable To Update Self-Test Log"},
2589     {0x3F00,  "Target Operating Conditions Have Changed"},
2590     {0x3F01,  "Microcode Has Been Changed"},
2591     {0x3F02,  "Changed Operating Definition"},
2592     {0x3F03,  "Inquiry Data Has Changed"},
2593     {0x3F04,  "Component Device Attached"},
2594     {0x3F05,  "Device Identifier Changed"},
2595     {0x3F06,  "Redundancy Group Created Or Modified"},
2596     {0x3F07,  "Redundancy Group Deleted"},
2597     {0x3F08,  "Spare Created Or Modified"},
2598     {0x3F09,  "Spare Deleted"},
2599     {0x3F0A,  "Volume Set Created Or Modified"},
2600     {0x3F0B,  "Volume Set Deleted"},
2601     {0x3F0C,  "Volume Set Deassigned"},
2602     {0x3F0D,  "Volume Set Reassigned"},
2603     {0x3F0E,  "Reported Luns Data Has Changed"},
2604     {0x3F0F,  "Echo Buffer Overwritten"},
2605     {0x3F10,  "Medium Loadable"},
2606     {0x3F11,  "Medium Auxiliary Memory Accessible"},
2607     {0x4200,  "Self-Test Failure (Should Use 40 Nn)"},
2608     {0x4300,  "Message Error"},
2609     {0x4400,  "Internal Target Failure"},
2610     {0x4500,  "Select Or Reselect Failure"},
2611     {0x4600,  "Unsuccessful Soft Reset"},
2612     {0x4700,  "Scsi Parity Error"},
2613     {0x4701,  "Data Phase Crc Error Detected"},
2614     {0x4702,  "Scsi Parity Error Detected During St Data Phase"},
2615     {0x4703,  "Information Unit Crc Error Detected"},
2616     {0x4704,  "Asynchronous Information Protection Error Detected"},
2617     {0x4800,  "Initiator Detected Error Message Received"},
2618     {0x4900,  "Invalid Message Error"},
2619     {0x4A00,  "Command Phase Error"},
2620     {0x4B00,  "Data Phase Error"},
2621     {0x4C00,  "Logical Unit Failed Self-Configuration"},
2622     {0x4D00,  "Tagged Overlapped Commands (Nn = Queue Tag)"},
2623     {0x4E00,  "Overlapped Commands Attempted"},
2624     {0x5300,  "Media Load Or Eject Failed"},
2625     {0x5302,  "Medium Removal Prevented"},
2626     {0x5501,  "System Buffer Full"},
2627     {0x5502,  "Insufficient Reservation Resources"},
2628     {0x5503,  "Insufficient Resources"},
2629     {0x5504,  "Insufficient Registration Resources"},
2630     {0x5A00,  "Operator Request Or State Change Input"},
2631     {0x5A01,  "Operator Medium Removal Request"},
2632     {0x5A02,  "Operator Selected Write Protect"},
2633     {0x5A03,  "Operator Selected Write Permit"},
2634     {0x5B00,  "Log Exception"},
2635     {0x5B01,  "Threshold Condition Met"},
2636     {0x5B02,  "Log Counter At Maximum"},
2637     {0x5B03,  "Log List Codes Exhausted"},
2638     {0x5C00,  "Change"},
2639     {0x5C02,  "Synchronized"},
2640     {0x5D00,  "Failure Prediction Threshold Exceeded"},
2641     {0x5D10,  "Failure General Hard Drive Failure"},
2642     {0x5D11,  "Failure Drive Error Rate Too High"},
2643     {0x5D12,  "Failure Data Error Rate Too High"},
2644     {0x5D13,  "Failure Seek Error Rate Too High"},
2645     {0x5D14,  "Failure Too Many Block Reassigns"},
2646     {0x5D15,  "Failure Access Times Too High"},
2647     {0x5D16,  "Failure Start Unit Times Too High"},
2648     {0x5D17,  "Failure Channel Parametrics"},
2649     {0x5D18,  "Failure Controller Detected"},
2650     {0x5D19,  "Failure Throughput Performance"},
2651     {0x5D1A,  "Failure Seek Time Performance"},
2652     {0x5D1B,  "Failure Spin-Up Retry Count"},
2653     {0x5D1C,  "Failure Drive Calibration Retry"},
2654     {0x5D20,  "Failure General Hard Drive Failure"},
2655     {0x5D21,  "Failure Drive Error Rate Too High"},
2656     {0x5D22,  "Failure Data Error Rate Too High"},
2657     {0x5D23,  "Failure Seek Error Rate Too High"},
2658     {0x5D24,  "Failure Too Many Block Reassigns"},
2659     {0x5D25,  "Failure Access Times Too High"},
2660     {0x5D26,  "Failure Start Unit Times Too High"},
2661     {0x5D27,  "Failure Channel Parametrics"},
2662     {0x5D28,  "Failure Controller Detected"},
2663     {0x5D29,  "Failure Throughput Performance"},
2664     {0x5D2A,  "Failure Seek Time Performance"},
2665     {0x5D2B,  "Failure Spin-Up Retry Count"},
2666     {0x5D2C,  "Failure Drive Calibration Retry"},
2667     {0x5D30,  "Impending Failure General Hard Drive"},
2668     {0x5D31,  "Impending Failure Drive Error Rate Too High"},
2669     {0x5D32,  "Impending Failure Data Error Rate Too High"},
2670     {0x5D33,  "Impending Failure Seek Error Rate Too High"},
2671     {0x5D34,  "Impending Failure Too Many Block Reassigns"},
2672     {0x5D35,  "Impending Failure Access Times Too High"},
2673     {0x5D36,  "Impending Failure Start Unit Times Too High"},
2674     {0x5D37,  "Impending Failure Channel Parametrics"},
2675     {0x5D38,  "Impending Failure Controller Detected"},
2676     {0x5D39,  "Impending Failure Throughput Performance"},
2677     {0x5D3A,  "Impending Failure Seek Time Performance"},
2678     {0x5D3B,  "Impending Failure Spin-Up Retry Count"},
2679     {0x5D3C,  "Impending Failure Drive Calibration Retry"},
2680     {0x5D40,  "Failure General Hard Drive Failure"},
2681     {0x5D41,  "Failure Drive Error Rate Too High"},
2682     {0x5D42,  "Failure Data Error Rate Too High"},
2683     {0x5D43,  "Failure Seek Error Rate Too High"},
2684     {0x5D44,  "Failure Too Many Block Reassigns"},
2685     {0x5D45,  "Failure Access Times Too High"},
2686     {0x5D46,  "Failure Start Unit Times Too High"},
2687     {0x5D47,  "Failure Channel Parametrics"},
2688     {0x5D48,  "Failure Controller Detected"},
2689     {0x5D49,  "Failure Throughput Performance"},
2690     {0x5D4A,  "Failure Seek Time Performance"},
2691     {0x5D4B,  "Failure Spin-Up Retry Count"},
2692     {0x5D4C,  "Failure Drive Calibration Retry Count"},
2693     {0x5D50,  "Failure General Hard Drive Failure"},
2694     {0x5D51,  "Failure Drive Error Rate Too High"},
2695     {0x5D52,  "Failure Data Error Rate Too High"},
2696     {0x5D53,  "Failure Seek Error Rate Too High"},
2697     {0x5D54,  "Failure Too Many Block Reassigns"},
2698     {0x5D55,  "Failure Access Times Too High"},
2699     {0x5D56,  "Failure Start Unit Times Too High"},
2700     {0x5D57,  "Failure Channel Parametrics"},
2701     {0x5D58,  "Failure Controller Detected"},
2702     {0x5D59,  "Failure Throughput Performance"},
2703     {0x5D5A,  "Failure Seek Time Performance"},
2704     {0x5D5B,  "Failure Spin-Up Retry Count"},
2705     {0x5D5C,  "Failure Drive Calibration Retry Count"},
2706     {0x5D60,  "Failure General Hard Drive Failure"},
2707     {0x5D61,  "Failure Drive Error Rate Too High"},
2708     {0x5D62,  "Failure Data Error Rate Too High"},
2709     {0x5D63,  "Failure Seek Error Rate Too High"},
2710     {0x5D64,  "Failure Too Many Block Reassigns"},
2711     {0x5D65,  "Failure Access Times Too High"},
2712     {0x5D66,  "Failure Start Unit Times Too High"},
2713     {0x5D67,  "Failure Channel Parametrics"},
2714     {0x5D68,  "Failure Controller Detected"},
2715     {0x5D69,  "Failure Throughput Performance"},
2716     {0x5D6A,  "Failure Seek Time Performance"},
2717     {0x5D6B,  "Failure Spin-Up Retry Count"},
2718     {0x5D6C,  "Failure Drive Calibration Retry Count"},
2719     {0x5DFF,  "Failure Prediction Threshold Exceeded (False)"},
2720     {0x5E00,  "Low Power Condition On"},
2721     {0x5E01,  "Idle Condition Activated By Timer"},
2722     {0x5E02,  "Standby Condition Activated By Timer"},
2723     {0x5E03,  "Idle Condition Activated By Command"},
2724     {0x5E04,  "Standby Condition Activated By Command"},
2725     {0x6500,  "Voltage Fault"},
2726     {0, NULL},
2727 };
2728 value_string_ext scsi_asc_val_ext = VALUE_STRING_EXT_INIT(scsi_asc_val);
2729 
2730 /* SCSI Status Codes */
2731 const value_string scsi_status_val[] = {
2732     {0x00, "Good"},
2733     {0x02, "Check Condition"},
2734     {0x04, "Condition Met"},
2735     {0x08, "Busy"},
2736     {0x10, "Intermediate"},
2737     {0x14, "Intermediate Condition Met"},
2738     {0x18, "Reservation Conflict"},
2739     {0x28, "Task Set Full"},
2740     {0x30, "ACA Active"},
2741     {0x40, "Task Aborted"},
2742     {0, NULL},
2743 };
2744 
2745 
2746 static const value_string scsi_wb_mode_val[] = {
2747     {0x0, "Write combined header and data"},
2748     {0x1, "Vendor specific"},
2749     {0x2, "Write data"},
2750     {0x3, "Reserved"},
2751     {0x4, "Download microcode"},
2752     {0x5, "Download microcode and save"},
2753     {0x6, "Download microcode with offsets"},
2754     {0x7, "Download microcode with offsets and save"},
2755     {0x8, "Reserved"},
2756     {0x9, "Reserved"},
2757     {0xA, "Echo buffer"},
2758     {0, NULL},
2759 };
2760 
2761 static const value_string scsi_senddiag_st_code_val[] = {
2762     {0, ""},
2763     {0x1, "Start short self-test in background"},
2764     {0x2, "Start extended self-test in background"},
2765     {0x3, "Reserved"},
2766     {0x4, "Abort background self-test"},
2767     {0x5, "Foreground short self-test"},
2768     {0x6, "Foreground extended self-test"},
2769     {0x7, "Reserved"},
2770     {0, NULL},
2771 };
2772 
2773 static const true_false_string scsi_senddiag_pf_val = {
2774     "Standard Page Format",
2775     "Vendor-specific Page Format",
2776 };
2777 
2778 static gint scsi_def_devtype = SCSI_DEV_SBC;
2779 
2780 
2781 typedef struct _cmdset_t {
2782     int                 hf_opcode;
2783     value_string_ext   *cdb_vals_ext;
2784     scsi_cdb_table_t   *cdb_table;
2785 } cmdset_t;
2786 
2787 static cmdset_t *get_cmdset_data(wmem_allocator_t *pool, itlq_nexus_t *itlq, itl_nexus_t *itl);
2788 
2789 static void
dissect_naa_designator(proto_tree * tree,tvbuff_t * tvb,guint offset,guint len)2790 dissect_naa_designator(proto_tree *tree, tvbuff_t *tvb, guint offset, guint len)
2791 {
2792         proto_tree *naa_tree;
2793         guint8 naa_type;
2794         guint64 vs;
2795 
2796         naa_type = tvb_get_guint8(tvb, offset) >> 4;
2797 
2798         naa_tree = proto_tree_add_subtree_format(tree, tvb, offset, len,
2799                         ett_scsi_naa, NULL, "NAA Designator: %s",
2800                         val_to_str(naa_type,
2801                                    scsi_naa_designator_type_val,
2802                                    "Unknown (0x%08x)"));
2803 
2804         proto_tree_add_item(naa_tree, hf_scsi_naa_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2805         switch(naa_type) {
2806         case NAA_TYPE_IEEE_EXTENDED:
2807             vs = tvb_get_guint64(tvb, offset, ENC_BIG_ENDIAN);
2808             proto_tree_add_uint(naa_tree, hf_scsi_naa_vendor_specific, tvb, offset, 2, (guint)((vs >> 48) & 0x0fff));
2809             proto_tree_add_item(naa_tree, hf_scsi_naa_ieee_company_id, tvb, offset + 2, 3, ENC_BIG_ENDIAN);
2810             proto_tree_add_uint(naa_tree, hf_scsi_naa_vendor_specific, tvb, offset + 5, 3, (guint)(vs & 0x00ffffff));
2811             break;
2812         case NAA_TYPE_LOCALLY_ASSIGNED:
2813             proto_tree_add_item(naa_tree, hf_scsi_naa_locally_assigned, tvb, offset + 1, len - 1, ENC_NA);
2814             break;
2815         case NAA_TYPE_IEEE_REGISTERED:
2816             vs = tvb_get_guint64(tvb, offset, ENC_BIG_ENDIAN);
2817             proto_tree_add_uint(naa_tree, hf_scsi_naa_ieee_company_id, tvb, offset, 4, (guint)((vs >> 36) & 0x00ffffff));
2818             proto_tree_add_uint(naa_tree, hf_scsi_naa_vendor_specific, tvb, offset + 3, 4, (guint)(vs & 0x0fffffff));
2819             break;
2820         case NAA_TYPE_IEEE_REGISTERED_EXTENDED:
2821             vs = tvb_get_guint64(tvb, offset, ENC_BIG_ENDIAN);
2822             proto_tree_add_uint(naa_tree, hf_scsi_naa_ieee_company_id, tvb, offset, 4, (guint)((vs >> 36) & 0x00ffffff));
2823             proto_tree_add_uint(naa_tree, hf_scsi_naa_vendor_specific, tvb, offset + 3, 4, (guint)(vs & 0x0fffffff));
2824             proto_tree_add_item(naa_tree, hf_scsi_naa_vendor_specific_extension, tvb, offset + 8, 8, ENC_NA);
2825             break;
2826         }
2827 }
2828 
2829 
2830 static void
dissect_scsi_evpd(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,guint tot_len _U_)2831 dissect_scsi_evpd(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
2832                   guint offset, guint tot_len _U_)
2833 {
2834     proto_tree *evpd_tree;
2835     proto_item *ti;
2836     guint       pcode, plen, i, idlen;
2837     guint8      codeset, identifier_type;
2838     proto_tree *des_tree;
2839 
2840     if (tree) {
2841         pcode = tvb_get_guint8(tvb, offset+1);
2842         plen = tvb_get_guint8(tvb, offset+3);
2843         evpd_tree = proto_tree_add_subtree_format(tree, tvb, offset, plen+4,
2844                                  ett_scsi_page, NULL, "Page Code: %s",
2845                                  val_to_str(pcode, scsi_evpd_pagecode_val,
2846                                             "Unknown (0x%08x)"));
2847 
2848         proto_tree_add_item(evpd_tree, hf_scsi_inq_qualifier, tvb, offset,
2849                             1, ENC_BIG_ENDIAN);
2850         proto_tree_add_item(evpd_tree, hf_scsi_inq_devtype, tvb, offset,
2851                             1, ENC_BIG_ENDIAN);
2852         proto_tree_add_item(evpd_tree, hf_scsi_inquiry_evpd_page, tvb, offset+1, 1, ENC_BIG_ENDIAN);
2853         proto_tree_add_item(evpd_tree, hf_scsi_inq_evpd_page_length, tvb, offset+2, 2, ENC_BIG_ENDIAN);
2854         offset += 4;
2855         switch (pcode) {
2856         case SCSI_EVPD_SUPPPG:
2857             for (i = 0; i < plen; i++) {
2858                 proto_tree_add_item(evpd_tree, hf_scsi_inq_evpd_supported_page, tvb, offset+i, 1, ENC_BIG_ENDIAN);
2859             }
2860             break;
2861         case SCSI_EVPD_DEVID:
2862             i = 0;
2863             while (plen != 0) {
2864                 idlen = tvb_get_guint8(tvb, offset + 3);
2865 
2866                 des_tree = proto_tree_add_subtree_format(evpd_tree,
2867                         tvb, offset, idlen, ett_scsi_designation_descriptor,
2868                         NULL, "Designation Descriptor");
2869 
2870                 i++;
2871                 ti = proto_tree_add_uint(des_tree, hf_scsi_inq_evpd_identifier_number, tvb, offset, 0, i);
2872                 proto_item_set_generated(ti);
2873 
2874                 codeset = tvb_get_guint8(tvb, offset) & 0x0F;
2875                 ti = proto_tree_add_item(des_tree, hf_scsi_inq_evpd_devid_code_set, tvb, offset, 1, ENC_BIG_ENDIAN);
2876                 plen -= 1;
2877                 offset += 1;
2878 
2879                 if (plen < 1) {
2880                     expert_add_info(pinfo, ti, &ei_scsi_product_data_goes_past_end_of_page);
2881                     break;
2882                 }
2883 
2884                 proto_tree_add_item(des_tree, hf_scsi_inq_evpd_devid_association, tvb, offset, 1, ENC_BIG_ENDIAN);
2885                 identifier_type = tvb_get_guint8(tvb, offset);
2886                 ti = proto_tree_add_item(des_tree, hf_scsi_inq_evpd_devid_identifier_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2887                 plen -= 1;
2888                 offset += 1;
2889 
2890                 /* Skip reserved byte */
2891                 if (plen < 1) {
2892                     expert_add_info(pinfo, ti, &ei_scsi_product_data_goes_past_end_of_page);
2893                     break;
2894                 }
2895                 plen -= 1;
2896                 offset += 1;
2897 
2898                 if (plen < 1) {
2899                     expert_add_info(pinfo, ti, &ei_scsi_product_data_goes_past_end_of_page);
2900                     break;
2901                 }
2902                 ti = proto_tree_add_item(des_tree, hf_scsi_inq_evpd_devid_identifier_length, tvb, offset, 1, ENC_BIG_ENDIAN);
2903                 plen -= 1;
2904                 offset += 1;
2905 
2906                 if (idlen != 0) {
2907                     if (plen < idlen) {
2908                         expert_add_info(pinfo, ti, &ei_scsi_product_data_goes_past_end_of_page);
2909                         break;
2910                     }
2911                     if (codeset == CODESET_ASCII) {
2912                         if (identifier_type == DEVID_TYPE_VEND_ID_VEND_SPEC_ID) {
2913                             proto_tree_add_item(des_tree, hf_scsi_inq_vendor_id, tvb, offset, 8, ENC_ASCII|ENC_NA);
2914                             proto_tree_add_item(des_tree, hf_scsi_inq_evpd_devid_identifier_str, tvb, offset + 8, idlen - 8, ENC_NA|ENC_ASCII);
2915                         } else {
2916                             proto_tree_add_item(des_tree, hf_scsi_inq_evpd_devid_identifier_str, tvb, offset, idlen, ENC_NA|ENC_ASCII);
2917                         }
2918                     } else if (codeset == CODESET_BINARY && identifier_type == DEVID_TYPE_NAA) {
2919                         dissect_naa_designator(des_tree, tvb, offset, idlen);
2920                     } else {
2921                         /*
2922                          * XXX - decode this based on the identifier type,
2923                          * if the codeset is CODESET_BINARY?
2924                          */
2925                         proto_tree_add_item(des_tree, hf_scsi_inq_evpd_devid_identifier_bytes, tvb, offset, idlen, ENC_NA);
2926                     }
2927                     plen -= idlen;
2928                     offset += idlen;
2929                 }
2930             }
2931             break;
2932         case SCSI_EVPD_DEVSERNUM:
2933             if (plen > 0) {
2934                 proto_tree_add_item(evpd_tree, hf_scsi_inq_evpd_product_serial_number, tvb, offset, plen, ENC_NA|ENC_ASCII);
2935             }
2936             break;
2937         case SCSI_EVPD_BLKDEVCHAR:
2938             proto_tree_add_item(evpd_tree, hf_scsi_inquiry_bdc_mrr, tvb,
2939                 offset, 2, ENC_BIG_ENDIAN);
2940             offset += 2;
2941 
2942             proto_tree_add_item(evpd_tree, hf_scsi_inquiry_bdc_pt, tvb,
2943                 offset, 1, ENC_BIG_ENDIAN);
2944             offset += 1;
2945 
2946             proto_tree_add_item(evpd_tree, hf_scsi_inquiry_bdc_wabereq, tvb,
2947                 offset, 1, ENC_BIG_ENDIAN);
2948             proto_tree_add_item(evpd_tree, hf_scsi_inquiry_bdc_wacereq, tvb,
2949                 offset, 1, ENC_BIG_ENDIAN);
2950             proto_tree_add_item(evpd_tree, hf_scsi_inquiry_bdc_nff, tvb,
2951                 offset, 1, ENC_BIG_ENDIAN);
2952             offset += 1;
2953 
2954             proto_tree_add_item(evpd_tree, hf_scsi_inquiry_bdc_fuab, tvb,
2955                 offset, 1, ENC_BIG_ENDIAN);
2956             proto_tree_add_item(evpd_tree, hf_scsi_inquiry_bdc_vbuls, tvb,
2957                 offset, 1, ENC_BIG_ENDIAN);
2958             /*offset += 1;*/
2959         break;
2960         case SCSI_EVPD_BLKLIMITS:
2961             proto_tree_add_item(evpd_tree, hf_scsi_block_limits_wsnz, tvb, offset, 1, ENC_NA);
2962             offset += 1;
2963 
2964             proto_tree_add_item(evpd_tree, hf_scsi_block_limits_mcawl, tvb, offset, 1, ENC_BIG_ENDIAN);
2965             offset += 1;
2966 
2967             proto_tree_add_item(evpd_tree, hf_scsi_block_limits_otlg, tvb, offset, 2, ENC_BIG_ENDIAN);
2968             offset += 2;
2969 
2970             proto_tree_add_item(evpd_tree, hf_scsi_block_limits_mtl, tvb, offset, 4, ENC_BIG_ENDIAN);
2971             offset += 4;
2972 
2973             proto_tree_add_item(evpd_tree, hf_scsi_block_limits_otl, tvb, offset, 4, ENC_BIG_ENDIAN);
2974             offset += 4;
2975 
2976             proto_tree_add_item(evpd_tree, hf_scsi_block_limits_mpl, tvb, offset, 4, ENC_BIG_ENDIAN);
2977             offset += 4;
2978 
2979             proto_tree_add_item(evpd_tree, hf_scsi_block_limits_mulc, tvb, offset, 4, ENC_BIG_ENDIAN);
2980             offset += 4;
2981 
2982             proto_tree_add_item(evpd_tree, hf_scsi_block_limits_mubdc, tvb, offset, 4, ENC_BIG_ENDIAN);
2983             offset += 4;
2984 
2985             proto_tree_add_item(evpd_tree, hf_scsi_block_limits_oug, tvb, offset, 4, ENC_BIG_ENDIAN);
2986             offset += 4;
2987 
2988             proto_tree_add_item(evpd_tree, hf_scsi_block_limits_ugavalid, tvb, offset, 1, ENC_NA);
2989             proto_tree_add_item(evpd_tree, hf_scsi_block_limits_uga, tvb, offset, 4, ENC_BIG_ENDIAN);
2990             offset += 4;
2991 
2992             proto_tree_add_item(evpd_tree, hf_scsi_block_limits_mwsl, tvb, offset, 8, ENC_BIG_ENDIAN);
2993             offset += 8;
2994 
2995             proto_tree_add_item(evpd_tree, hf_scsi_block_limits_matl, tvb, offset, 4, ENC_BIG_ENDIAN);
2996             offset += 4;
2997 
2998             proto_tree_add_item(evpd_tree, hf_scsi_block_limits_aa, tvb, offset, 4, ENC_BIG_ENDIAN);
2999             offset += 4;
3000 
3001             proto_tree_add_item(evpd_tree, hf_scsi_block_limits_atlg, tvb, offset, 4, ENC_BIG_ENDIAN);
3002             /*offset += 4;*/
3003 
3004             break;
3005         case SCSI_EVPD_LBP:
3006             proto_tree_add_item(evpd_tree, hf_scsi_sbc_threshold_exponent, tvb, offset, 1, ENC_BIG_ENDIAN);
3007             offset += 1;
3008 
3009             proto_tree_add_item(evpd_tree, hf_scsi_sbc_lbpu, tvb, offset, 1, ENC_NA);
3010             proto_tree_add_item(evpd_tree, hf_scsi_sbc_lbpws, tvb, offset, 1, ENC_NA);
3011             proto_tree_add_item(evpd_tree, hf_scsi_sbc_lbpws10, tvb, offset, 1, ENC_NA);
3012             proto_tree_add_item(evpd_tree, hf_scsi_sbc_lbprz, tvb, offset, 1, ENC_NA);
3013             proto_tree_add_item(evpd_tree, hf_scsi_sbc_anc_sup, tvb, offset, 1, ENC_NA);
3014             proto_tree_add_item(evpd_tree, hf_scsi_sbc_dp, tvb, offset, 1, ENC_NA);
3015             offset += 1;
3016 
3017             proto_tree_add_item(evpd_tree, hf_scsi_sbc_ptype, tvb, offset, 1, ENC_BIG_ENDIAN);
3018             /*offset += 1;*/
3019 
3020             break;
3021         }
3022     }
3023 }
3024 
3025 static void
dissect_scsi_cmddt(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,guint tot_len _U_)3026 dissect_scsi_cmddt(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
3027                    guint offset, guint tot_len _U_)
3028 {
3029     proto_tree *cmdt_tree;
3030     guint       plen;
3031 
3032     if (tree) {
3033         plen = tvb_get_guint8(tvb, offset+5);
3034         cmdt_tree = proto_tree_add_subtree_format(tree, tvb, offset, plen, ett_scsi_page, NULL, "Command Data");
3035 
3036         proto_tree_add_item(cmdt_tree, hf_scsi_inq_qualifier, tvb, offset,
3037                             1, ENC_BIG_ENDIAN);
3038         proto_tree_add_item(cmdt_tree, hf_scsi_inq_devtype, tvb, offset,
3039                             1, ENC_BIG_ENDIAN);
3040         proto_tree_add_item(cmdt_tree, hf_scsi_inq_cmddt_support, tvb, offset+1, 1, ENC_BIG_ENDIAN);
3041         proto_tree_add_item(cmdt_tree, hf_scsi_inq_cmddt_version, tvb, offset+2, 1, ENC_BIG_ENDIAN);
3042         proto_tree_add_item(cmdt_tree, hf_scsi_inq_cmddt_cdb_size, tvb, offset+5, 1, ENC_BIG_ENDIAN);
3043     }
3044 }
3045 
3046 
3047 #define SCSI_INQ_ACAFLAGS_AERC      0x80
3048 #define SCSI_INQ_ACAFLAGS_TRMTSK    0x40
3049 #define SCSI_INQ_ACAFLAGS_NORMACA   0x20
3050 #define SCSI_INQ_ACAFLAGS_HISUP     0x10
3051 
3052 static const value_string inq_rdf_vals[] = {
3053     { 2, "SPC-2/SPC-3/SPC-4" },
3054     { 0, NULL }
3055 };
3056 
3057 
3058 #define SCSI_INQ_SCCSFLAGS_SCCS     0x80
3059 #define SCSI_INQ_SCCSFLAGS_ACC      0x40
3060 #define SCSI_INQ_SCCSFLAGS_TPC      0x08
3061 #define SCSI_INQ_SCCSFLAGS_PROTECT  0x01
3062 
3063 static const value_string inq_tpgs_vals[] = {
3064     { 0, "Asymmetric LU Access not supported" },
3065     { 1, "Implicit Asymmetric LU Access supported" },
3066     { 2, "Explicit LU Access supported" },
3067     { 3, "Both Implicit and Explicit LU Access supported" },
3068     { 0, NULL }
3069 };
3070 
3071 /* This dissects byte 5 of the SPC/SPC-2/SPC-3/SPC-4 standard INQ data */
3072 static int
dissect_spc_inq_sccsflags(tvbuff_t * tvb,int offset,proto_tree * tree,int version)3073 dissect_spc_inq_sccsflags(tvbuff_t *tvb, int offset, proto_tree *tree, int version)
3074 {
3075     static int * const sccs_fields_spc2[] = {
3076         &hf_scsi_inq_sccs,
3077         NULL
3078     };
3079     static int * const sccs_fields_spc3[] = {
3080         &hf_scsi_inq_sccs,
3081         &hf_scsi_inq_acc,
3082         &hf_scsi_inq_tpgs,
3083         &hf_scsi_inq_tpc,
3084         &hf_scsi_inq_protect,
3085         NULL
3086     };
3087 
3088     switch (version) {
3089     case 3: /* SPC */
3090         break;
3091     case 4: /* SPC-2 */
3092         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_inq_sccsflags, ett_scsi_inq_sccsflags,  sccs_fields_spc2, ENC_BIG_ENDIAN);
3093         break;
3094     case 5: /* SPC-3 */
3095     case 6: /* SPC-4 */
3096         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_inq_sccsflags, ett_scsi_inq_sccsflags,  sccs_fields_spc3, ENC_BIG_ENDIAN);
3097         break;
3098     default: /* including version 0 : claims conformance to no standard */
3099         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_inq_sccsflags, ett_scsi_inq_sccsflags,  sccs_fields_spc3, ENC_BIG_ENDIAN);
3100     }
3101 
3102     offset += 1;
3103     return offset;
3104 }
3105 
3106 
3107 #define SCSI_INQ_BQUEFLAGS_BQUE     0x80
3108 #define SCSI_INQ_BQUEFLAGS_ENCSERV  0x40
3109 #define SCSI_INQ_BQUEFLAGS_MULTIP   0x10
3110 #define SCSI_INQ_BQUEFLAGS_MCHNGR   0x08
3111 #define SCSI_INQ_BQUEFLAGS_ACKREQQ  0x04
3112 
3113 /* This dissects byte 6 of the SPC/SPC-2/SPC-3/SPC-4 standard INQ data */
3114 static int
dissect_spc_inq_bqueflags(tvbuff_t * tvb,int offset,proto_tree * tree,int version)3115 dissect_spc_inq_bqueflags(tvbuff_t *tvb, int offset, proto_tree *tree, int version)
3116 {
3117     static int * const bqe_fields_spc[] = {
3118         &hf_scsi_inq_encserv,
3119         &hf_scsi_inq_multip,
3120         &hf_scsi_inq_mchngr,
3121         &hf_scsi_inq_ackreqq,
3122         NULL
3123     };
3124     static int * const bqe_fields_spc2[] = {
3125         &hf_scsi_inq_bque,
3126         &hf_scsi_inq_encserv,
3127         &hf_scsi_inq_multip,
3128         &hf_scsi_inq_mchngr,
3129         NULL
3130     };
3131     static int * const bqe_fields_spc4[] = {
3132         &hf_scsi_inq_bque,
3133         &hf_scsi_inq_encserv,
3134         &hf_scsi_inq_multip,
3135         NULL
3136     };
3137 
3138     switch (version) {
3139     case 3: /* SPC */
3140         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_inq_bqueflags, ett_scsi_inq_bqueflags,  bqe_fields_spc, ENC_BIG_ENDIAN);
3141         break;
3142     case 4: /* SPC-2 */
3143     case 5: /* SPC-3 */
3144         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_inq_bqueflags, ett_scsi_inq_bqueflags,  bqe_fields_spc2, ENC_BIG_ENDIAN);
3145         break;
3146     case 6: /* SPC-4 */
3147         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_inq_bqueflags, ett_scsi_inq_bqueflags,  bqe_fields_spc4, ENC_BIG_ENDIAN);
3148         break;
3149     default: /* including version 0 : claims conformance to no standard */
3150         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_inq_bqueflags, ett_scsi_inq_bqueflags,  bqe_fields_spc4, ENC_BIG_ENDIAN);
3151         break;
3152     }
3153 
3154     offset+=1;
3155     return offset;
3156 }
3157 
3158 #define SCSI_INQ_RELADRFLAGS_RELADR     0x80
3159 #define SCSI_INQ_RELADRFLAGS_LINKED     0x08
3160 #define SCSI_INQ_RELADRFLAGS_TRANDIS    0x04
3161 #define SCSI_INQ_RELADRFLAGS_CMDQUE     0x02
3162 
3163 /* This dissects byte 7 of the SPC/SPC-2/SPC-3/SPC-4 standard INQ data */
3164 static int
dissect_spc_inq_reladrflags(tvbuff_t * tvb,int offset,proto_tree * tree,int version)3165 dissect_spc_inq_reladrflags(tvbuff_t *tvb, int offset, proto_tree *tree, int version)
3166 {
3167     static int * const reladr_fields_spc[] = {
3168         &hf_scsi_inq_reladr,
3169         &hf_scsi_inq_linked,
3170         &hf_scsi_inq_trandis,
3171         &hf_scsi_inq_cmdque,
3172         NULL
3173     };
3174     static int * const reladr_fields_spc2[] = {
3175         &hf_scsi_inq_reladr,
3176         &hf_scsi_inq_linked,
3177         &hf_scsi_inq_cmdque,
3178         NULL
3179     };
3180     static int * const reladr_fields_spc3[] = {
3181         &hf_scsi_inq_linked,
3182         &hf_scsi_inq_cmdque,
3183         NULL
3184     };
3185     static int * const reladr_fields_spc4[] = {
3186         &hf_scsi_inq_cmdque,
3187         NULL
3188     };
3189 
3190 
3191     switch (version) {
3192     case 3: /* SPC */
3193         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_inq_reladrflags, ett_scsi_inq_reladrflags,  reladr_fields_spc, ENC_BIG_ENDIAN);
3194         break;
3195     case 4: /* SPC-2 */
3196         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_inq_reladrflags, ett_scsi_inq_reladrflags,  reladr_fields_spc2, ENC_BIG_ENDIAN);
3197         break;
3198     case 5: /* SPC-3 */
3199         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_inq_reladrflags, ett_scsi_inq_reladrflags,  reladr_fields_spc3, ENC_BIG_ENDIAN);
3200         break;
3201     case 6: /* SPC-4 */
3202         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_inq_reladrflags, ett_scsi_inq_reladrflags,  reladr_fields_spc4, ENC_BIG_ENDIAN);
3203         break;
3204     default: /* including version 0 : claims conformance to no standard */
3205         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_inq_reladrflags, ett_scsi_inq_reladrflags,  reladr_fields_spc4, ENC_BIG_ENDIAN);
3206     }
3207 
3208     offset+=1;
3209     return offset;
3210 }
3211 
3212 static int * const peripheral_fields[] = {
3213     &hf_scsi_inq_qualifier,
3214     &hf_scsi_inq_devtype,
3215     NULL
3216 };
3217 
3218 
3219 void
dissect_spc_inquiry(tvbuff_t * tvb_a,packet_info * pinfo,proto_tree * tree,guint offset_a,gboolean isreq,gboolean iscdb,guint32 payload_len,scsi_task_data_t * cdata)3220 dissect_spc_inquiry(tvbuff_t *tvb_a, packet_info *pinfo,
3221                     proto_tree *tree, guint offset_a, gboolean isreq,
3222                     gboolean iscdb, guint32 payload_len,
3223                     scsi_task_data_t *cdata)
3224 {
3225     guint8             flags, i, version;
3226 
3227     static int * const inq_control_fields[] = {
3228         &hf_scsi_inq_control_vendor_specific,
3229         &hf_scsi_inq_control_reserved,
3230         &hf_scsi_inq_control_naca,
3231         &hf_scsi_inq_control_obs1,
3232         &hf_scsi_inq_control_obs2,
3233         NULL
3234     };
3235     static int * const aca_fields_spc[] = {
3236         &hf_scsi_inq_aerc,  /* obsolete in spc3 and forward */
3237         &hf_scsi_inq_trmtsk,/* obsolete in spc2 and forward */
3238         &hf_scsi_inq_normaca,
3239         &hf_scsi_inq_hisup,
3240         &hf_scsi_inq_rdf,
3241         NULL
3242     };
3243     static int * const aca_fields_spc2[] = {
3244         &hf_scsi_inq_aerc,      /* obsolete in spc3 and forward */
3245         &hf_scsi_inq_normaca,
3246         &hf_scsi_inq_hisup,
3247         &hf_scsi_inq_rdf,
3248         NULL
3249     };
3250     static int * const aca_fields_spc3[] = {
3251         &hf_scsi_inq_normaca,
3252         &hf_scsi_inq_hisup,
3253         &hf_scsi_inq_rdf,
3254         NULL
3255     };
3256     static int * const rmb_fields[] = {
3257         &hf_scsi_inq_rmb,
3258         NULL
3259     };
3260 
3261     if (!isreq && ((cdata == NULL) || !(cdata->itlq->flags & 0x3))
3262         && (tvb_reported_length_remaining(tvb_a, offset_a) >= 1) ) {
3263         /*
3264          * INQUIRY response with device type information; add device type
3265          * to list of known devices & their types if not already known.
3266          */
3267         if (cdata && cdata->itl) {
3268             cdata->itl->cmdset = tvb_get_guint8(tvb_a, offset_a)&SCSI_DEV_BITS;
3269         }
3270     }
3271 
3272     if (isreq && iscdb) {
3273         flags = tvb_get_guint8(tvb_a, offset_a);
3274         if (cdata) {
3275             cdata->itlq->flags = flags;
3276         }
3277 
3278         proto_tree_add_uint_format(tree, hf_scsi_inquiry_flags, tvb_a, offset_a, 1,
3279                                    flags, "CMDT = %u, EVPD = %u",
3280                                    flags & 0x2, flags & 0x1);
3281         if (flags & 0x1) {
3282             proto_tree_add_item(tree, hf_scsi_inquiry_evpd_page, tvb_a, offset_a+1,
3283                                 1, ENC_BIG_ENDIAN);
3284 
3285         col_add_fstr(pinfo->cinfo, COL_INFO, " %s",
3286              val_to_str(tvb_get_guint8(tvb_a, offset_a+1),
3287                     scsi_evpd_pagecode_val,
3288                     "Unknown VPD 0x%02x"));
3289         } else if (flags & 0x2) {
3290             proto_tree_add_item(tree, hf_scsi_inquiry_cmdt_page, tvb_a, offset_a+1,
3291                                 1, ENC_BIG_ENDIAN);
3292         }
3293 
3294         proto_tree_add_item(tree, hf_scsi_alloclen16, tvb_a, offset_a+2, 2, ENC_BIG_ENDIAN);
3295         /* we need the alloc_len in the response */
3296         if (cdata) {
3297             cdata->itlq->alloc_len = tvb_get_ntohs(tvb_a, offset_a+2);
3298         }
3299         proto_tree_add_bitmask(tree, tvb_a, offset_a+4, hf_scsi_inq_control,
3300                                ett_scsi_inq_control, inq_control_fields, ENC_BIG_ENDIAN);
3301     } else if (!isreq) {
3302         if (!cdata) {
3303             return;
3304         }
3305 
3306         if (cdata->itlq->flags & 0x1) {
3307             dissect_scsi_evpd(tvb_a, pinfo, tree, offset_a, payload_len);
3308             return;
3309         }
3310         if (cdata->itlq->flags & 0x2) {
3311             dissect_scsi_cmddt(tvb_a, pinfo, tree, offset_a, payload_len);
3312             return;
3313         }
3314 
3315         /* These pdus are sometimes truncated by SCSI allocation length
3316          * in the CDB
3317          */
3318         TRY_SCSI_CDB_ALLOC_LEN(cdata->itlq->alloc_len);  /* (defines/initializes try_tvb & try_offset) */
3319 
3320         /* Qualifier and DeviceType */
3321         proto_tree_add_bitmask(tree, try_tvb, try_offset, hf_scsi_inq_peripheral, ett_scsi_inq_peripheral, peripheral_fields, ENC_BIG_ENDIAN);
3322         try_offset+=1;
3323 
3324         /* RMB */
3325         proto_tree_add_bitmask(tree, try_tvb, try_offset, hf_scsi_inq_rmbflags, ett_scsi_inq_rmbflags, rmb_fields, ENC_BIG_ENDIAN);
3326         try_offset+=1;
3327 
3328         /* Version */
3329         version = tvb_get_guint8(try_tvb, try_offset);
3330         proto_tree_add_item(tree, hf_scsi_inq_version, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
3331         try_offset+=1;
3332 
3333         /* aca flags */
3334         switch (version) {
3335         case 3: /* SPC */
3336             proto_tree_add_bitmask(tree, try_tvb, try_offset, hf_scsi_inq_acaflags, ett_scsi_inq_acaflags, aca_fields_spc, ENC_BIG_ENDIAN);
3337             break;
3338         case 4: /* SPC-2 */
3339             proto_tree_add_bitmask(tree, try_tvb, try_offset, hf_scsi_inq_acaflags, ett_scsi_inq_acaflags, aca_fields_spc2, ENC_BIG_ENDIAN);
3340             break;
3341         case 5: /* SPC-3 */
3342         case 6: /* SPC-4 */
3343             proto_tree_add_bitmask(tree, try_tvb, try_offset, hf_scsi_inq_acaflags, ett_scsi_inq_acaflags, aca_fields_spc3, ENC_BIG_ENDIAN);
3344             break;
3345         default: /* including version 0 : claims conformance to no standard */
3346             proto_tree_add_bitmask(tree, try_tvb, try_offset, hf_scsi_inq_acaflags, ett_scsi_inq_acaflags, aca_fields_spc3, ENC_BIG_ENDIAN);
3347         }
3348         try_offset+=1;
3349 
3350         /* Additional Length */
3351         SET_SCSI_DATA_END(tvb_get_guint8(try_tvb, try_offset)+try_offset);
3352         proto_tree_add_item(tree, hf_scsi_inq_add_len, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
3353         try_offset+=1;
3354 
3355         /* sccs flags */
3356         try_offset = dissect_spc_inq_sccsflags(try_tvb, try_offset, tree, version);
3357 
3358         /* bque flags */
3359         try_offset = dissect_spc_inq_bqueflags(try_tvb, try_offset, tree, version);
3360 
3361         /* reladdr flags */
3362         try_offset = dissect_spc_inq_reladrflags(try_tvb, try_offset, tree, version);
3363 
3364         /* vendor id */
3365         proto_tree_add_item(tree, hf_scsi_inq_vendor_id, try_tvb, try_offset, 8, ENC_ASCII|ENC_NA);
3366         try_offset+=8;
3367 
3368         /* product id */
3369         proto_tree_add_item(tree, hf_scsi_inq_product_id, try_tvb, try_offset, 16, ENC_ASCII|ENC_NA);
3370         try_offset+=16;
3371 
3372         /* product revision level */
3373         proto_tree_add_item(tree, hf_scsi_inq_product_rev, try_tvb, try_offset, 4, ENC_ASCII|ENC_NA);
3374         try_offset+=4;
3375 
3376         /* vendor specific, 20 bytes */
3377         proto_tree_add_item(tree, hf_scsi_inq_vendor_specific, try_tvb, try_offset, 20, ENC_NA);
3378         try_offset+=20;
3379 
3380         /* reserved */
3381         try_offset += 2;
3382 
3383         /* version descriptors */
3384         for(i = 0;i<8;i++) {
3385             proto_tree_add_item(tree, hf_scsi_inq_version_desc, try_tvb, try_offset, 2, ENC_BIG_ENDIAN);
3386             try_offset+=2;
3387         }
3388 
3389         END_TRY_SCSI_CDB_ALLOC_LEN;
3390     }
3391 }
3392 
3393 #define XCOPY_LID1 0
3394 #define XCOPY_LID4 1
3395 static const value_string extcopy_service_vals[] = {
3396        { XCOPY_LID1, "Extended Copy (LID1)" },
3397         { XCOPY_LID4, "Extended Copy (LID4)" },
3398         { 0, NULL }
3399 };
3400 
3401 #define RECV_COPY_PARAMS 0x3
3402 static const value_string recv_copy_service_vals[] = {
3403         { 0x6, "Receive Copy Data (LID4)" },
3404         { 0x1, "Receive Copy Data (LID1)" },
3405         { RECV_COPY_PARAMS, "Receive Copy Parameters" },
3406         { 0x4, "Receive Copy Failure details" },
3407         { 0x5, "Receive Copy Status (LID4)" },
3408         { 0x0, "Receive Copy Status (LID1)" },
3409         { 0, NULL }
3410 };
3411 
3412 
3413 #if 0
3414 static const value_string cscd_desc_type_code_vals[] = {
3415         { 0xE0, "Fibre Channel N_Port_Name CSCD descriptor" },
3416         { 0xE1, "Fibre Channel N_Port_ID CSCD descriptor" },
3417         { 0xE2, "Fibre Channel N_Port_ID With N_Port_Name Checking CSCD descriptor" },
3418         { 0xE3, "Parallel Interface T_L CSCD descriptor" },
3419         { 0xE4, "Identification Descriptor CSCD descriptor" },
3420         { 0xFF, "Extension descriptor" },
3421         { 0, NULL }
3422 };
3423 #endif
3424 
3425 static int * const per_dev_type_bitmask_fields[] = {
3426         &hf_scsi_spc_xcopy_lu_type,
3427         &hf_scsi_spc_xcopy_per_dev_type,
3428         NULL
3429 };
3430 
3431 static int * const xcopy_param_list_bits[] = {
3432         &hf_scsi_spc_xcopy_param_str,
3433         &hf_scsi_spc_xcopy_param_list_id_usage,
3434         &hf_scsi_spc_xcopy_param_priority,
3435         NULL
3436 };
3437 
3438 #define BLOCK_DEV_0 0x0
3439 #define BLOCK_DEV_4 0x4
3440 #define BLOCK_DEV_5 0x5
3441 #define BLOCK_DEV_7 0x7
3442 #define BLOCK_DEV_E 0xE
3443 
3444 static const value_string per_dev_type_vals[] = {
3445         { BLOCK_DEV_0, "Block devices" },
3446         { 0x1, "Sequential access devices" },
3447         { 0x3, "Processor devices" },
3448         { BLOCK_DEV_4, "Block devices" },
3449         { BLOCK_DEV_5, "Block devices" },
3450         { BLOCK_DEV_7, "Block devices" },
3451         { BLOCK_DEV_E, "Block devices" },
3452         { 0, NULL }
3453 };
3454 
3455 static const value_string lu_type_vals[] = {
3456         { 0, "Logical Unit Number" },
3457         { 1, "Proxy Token" },
3458         { 2, "Reserved" },
3459         { 3, "Reserved" },
3460         { 0, NULL }
3461 };
3462 
3463 #define BLOCK_TO_BLOCK 2
3464 
3465 static const range_string desc_type_rval[] = {
3466         { 0x0, 0x0, "Block to stream" },
3467         { 0x1, 0x1, "Stream to block" },
3468         { BLOCK_TO_BLOCK, BLOCK_TO_BLOCK, "Block to block" },
3469         { 0x3, 0x3, "Stream to stream" },
3470         { 0x4, 0x4, "Inline to stream" },
3471         { 0x5, 0x5, "Embedded to strem" },
3472         { 0x6, 0x6, "Stream to discard" },
3473         { 0x7, 0x7, "Verify CSCD" },
3474         { 0x0, 0xBF, "Segment descriptors" },
3475         { 0xC, 0xDF, "Vendor-specific descriptors" },
3476         { 0xE0, 0xE0, "Fibre Channel N_Port_Name CSCD descriptor" },
3477         { 0xE1,  0xE1, "Fibre Channel N_Port_ID CSCD descriptor" },
3478         { 0xE2, 0xE2, "Fibre Channel N_Port_ID With N_Port_Name Checking CSCD descriptor" },
3479         { 0xE3, 0xE3, "Parallel Interface T_L CSCD descriptor" },
3480         { 0xE4, 0xE4, "Identification Descriptor CSCD descriptor" },
3481         { 0xE5, 0xFE, "CSCD descriptors" },
3482         { 0xFF, 0xFF, "CSCD descriptor extension" },
3483         { 0, 0, NULL }
3484 };
3485 
3486 void
dissect_spc_extcopy(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,gboolean isreq,gboolean iscdb,guint payload_len _U_,scsi_task_data_t * cdata)3487 dissect_spc_extcopy(tvbuff_t *tvb, packet_info *pinfo _U_,
3488                     proto_tree *tree, guint offset,
3489                     gboolean isreq, gboolean iscdb,
3490                     guint payload_len _U_, scsi_task_data_t *cdata)
3491 {
3492         guint16 serv_action;
3493         guint8 cscd_desc_type, dev_type, des_len, code_set, des_type, seg_type;
3494         guint16 cscd_desc_list_len, seg_desc_len;
3495         guint32 /*param_list_len,*/ seg_desc_list_len, inline_data_len, i;
3496         proto_tree *cscds_tree = NULL, *dev_tree = NULL, *cscd_tree = NULL, *segs_tree = NULL,
3497                    *seg_tree = NULL, *seg_param_tree = NULL, *cscd_desc_tree;
3498 
3499         if (isreq && iscdb) {
3500                proto_tree_add_item(tree, hf_scsi_spc_xcopy_service, tvb, offset, 1, ENC_BIG_ENDIAN);
3501                serv_action = tvb_get_guint8(tvb, offset) & 0x1F;
3502                if (cdata) {
3503                    cdata->itlq->flags = serv_action;
3504                }
3505                offset += 1;
3506 
3507                proto_tree_add_item(tree, hf_scsi_reserved_64, tvb, offset, 8, ENC_BIG_ENDIAN);
3508                offset += 8;
3509                proto_tree_add_item(tree, hf_scsi_spc_xcopy_param_list_len, tvb, offset, 4, ENC_BIG_ENDIAN);
3510                /*param_list_len = tvb_get_ntohl(tvb, offset); */
3511                offset += 4;
3512 
3513                proto_tree_add_item(tree, hf_scsi_reserved_8, tvb, offset, 1, ENC_BIG_ENDIAN);
3514                offset+= 1;
3515                proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_control,
3516                         ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
3517                /*offset += 1;*/
3518                /*offset += (param_list_len - 15);*/
3519         } else {
3520                if (cdata) {
3521                         serv_action = cdata->itlq->flags;
3522                }
3523                else {
3524                         return;
3525                }
3526                if (serv_action == XCOPY_LID1){
3527                         proto_tree_add_item(tree, hf_scsi_spc_xcopy_list_id, tvb, offset, 1, ENC_BIG_ENDIAN);
3528                         offset += 1;
3529                         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_spc_xcopy_param_byte, ett_xcopy_param_byte, xcopy_param_list_bits, ENC_NA);
3530                         offset += 1;
3531                         proto_tree_add_item(tree, hf_scsi_spc_xcopy_cscd_desc_list_len, tvb, offset, 2, ENC_BIG_ENDIAN);
3532                         cscd_desc_list_len = tvb_get_ntohs(tvb, offset);
3533                         offset += 2;
3534                         proto_tree_add_item(tree, hf_scsi_reserved_32, tvb, offset, 4, ENC_BIG_ENDIAN);
3535                         offset += 4;
3536                         proto_tree_add_item(tree, hf_scsi_spc_xcopy_seg_desc_list_len, tvb, offset, 4, ENC_BIG_ENDIAN);
3537                         seg_desc_list_len = tvb_get_ntohl(tvb, offset);
3538                         offset += 4;
3539                         proto_tree_add_item(tree, hf_scsi_spc_xcopy_inline_data_len, tvb, offset, 4, ENC_BIG_ENDIAN);
3540                         inline_data_len = tvb_get_ntohl(tvb, offset);
3541                         offset += 4;
3542                         if (cscd_desc_list_len > 0) {
3543                                 cscds_tree = proto_tree_add_subtree_format(tree, tvb, offset, cscd_desc_list_len, ett_scsi_xcopy_cscds, NULL,
3544                                                         "CSCD (Copy Source and Copy Destination) descriptors (%u bytes)", cscd_desc_list_len);
3545                                 i = 1;
3546                                 while(cscd_desc_list_len > 0) {
3547                                         cscd_desc_type = tvb_get_guint8(tvb, offset);
3548                                         if (cscd_desc_type == 0xEA || cscd_desc_type == 0xEB) { /* both types occupy 64 bytes overall, everything else is 32 bytes */
3549                                                 cscd_tree = proto_tree_add_subtree_format(cscds_tree, tvb, offset, 64, ett_scsi_xcopy_cscd, NULL, "CSCD descriptor #%u", i);
3550                                         } else {
3551                                                 cscd_tree = proto_tree_add_subtree_format(cscds_tree, tvb, offset, 32, ett_scsi_xcopy_cscd, NULL, "CSCD descriptor #%u", i);
3552                                         }
3553                                         i++;
3554                                         proto_tree_add_item(cscd_tree, hf_scsi_spc_xcopy_cscd_desc_type_code, tvb, offset, 1, ENC_BIG_ENDIAN);
3555                                         offset += 1;
3556                                         proto_tree_add_bitmask(cscd_tree, tvb, offset, hf_scsi_spc_xcopy_per_dev_type_byte, ett_xcopy_per_dev_type,  per_dev_type_bitmask_fields, ENC_NA);
3557                                         dev_type = tvb_get_guint8(tvb, offset) & 0x1F;
3558                                         offset += 1;
3559                                         proto_tree_add_item(cscd_tree, hf_scsi_spc_xcopy_rel_init_port_id, tvb, offset, 2, ENC_BIG_ENDIAN);
3560                                         offset += 2;
3561                                         cscd_desc_tree = proto_tree_add_subtree(cscd_tree, tvb, offset, 24, ett_scsi_cscd_desc, NULL, "CSCD descriptor parameters");
3562                                         proto_tree_add_item(cscd_desc_tree, hf_scsi_spc_xcopy_cscd_desc_code_set, tvb, offset, 1, ENC_BIG_ENDIAN);
3563                                         code_set = tvb_get_guint8(tvb, offset) & 0x0F;
3564                                         offset += 1;
3565                                         proto_tree_add_item(cscd_desc_tree, hf_scsi_spc_xcopy_cscd_desc_assoc, tvb, offset, 1, ENC_BIG_ENDIAN);
3566                                         proto_tree_add_item(cscd_desc_tree, hf_scsi_spc_xcopy_cscd_desc_des_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3567                                         des_type = tvb_get_guint8(tvb, offset) & 0x0F;
3568                                         offset += 1;
3569                                         proto_tree_add_item(cscd_desc_tree, hf_scsi_reserved_8, tvb, offset, 1, ENC_BIG_ENDIAN);
3570                                         offset += 1;
3571                                         proto_tree_add_item(cscd_desc_tree, hf_scsi_spc_xcopy_cscd_desc_des_len, tvb, offset, 1, ENC_BIG_ENDIAN);
3572                                         des_len = tvb_get_guint8(tvb, offset);
3573                                         offset += 1;
3574                                         proto_tree_add_bytes_format(cscd_desc_tree, hf_scsi_designator, tvb, offset, 20, NULL, "Designator (20 bytes, zero padded, used length %u)", des_len);
3575                                         if (code_set == CODESET_BINARY && des_type == DEVID_TYPE_NAA) { /* des_type 3 = NAA */
3576                                             dissect_naa_designator(cscd_tree, tvb, offset, des_len);
3577                                         }
3578                                         offset += 20;
3579                                         dev_tree = proto_tree_add_subtree(cscd_tree, tvb, offset, 4, ett_scsi_xcopy_dev_params, NULL, "Device type specific parameters");
3580                                         if (dev_type == BLOCK_DEV_0 || dev_type == BLOCK_DEV_4 || dev_type == BLOCK_DEV_5 || dev_type == BLOCK_DEV_7 || dev_type == BLOCK_DEV_E) {
3581                                                 proto_tree_add_item(dev_tree, hf_scsi_reserved_8, tvb, offset, 1, ENC_BIG_ENDIAN);
3582                                                 offset += 1; /*TODO: dissect this byte */
3583                                                 proto_tree_add_item(dev_tree, hf_scsi_spc_xcopy_disk_block_len, tvb, offset, 3, ENC_BIG_ENDIAN);
3584                                                 offset += 3;
3585                                         } else {
3586                                                 offset += 4;
3587                                         }
3588                                         cscd_desc_list_len -= 32;
3589                                         if (cscd_desc_type == 0xEA || cscd_desc_type == 0xEB) { /* both types occupy 64 bytes overall, everything else is 32 bytes */
3590                                                 offset += 32;
3591                                                 cscd_desc_list_len -= 32;
3592                                         }
3593                                 }
3594                         }
3595                         if (seg_desc_list_len > 0) {
3596                                 segs_tree = proto_tree_add_subtree_format(tree, tvb, offset, seg_desc_list_len,
3597                                         ett_scsi_xcopy_segs, NULL, "Segment descriptor list (%u bytes)", seg_desc_list_len);
3598                                 i = 1;
3599                                 while(seg_desc_list_len > 0) {
3600                                         seg_desc_len = tvb_get_ntohs(tvb, offset + 2);
3601                                         seg_tree = proto_tree_add_subtree_format(segs_tree, tvb, offset, seg_desc_len + 4,
3602                                                             ett_scsi_xcopy_seg, NULL, "Segment descriptor #%u", i);
3603                                         i++;
3604                                         proto_tree_add_item(seg_tree, hf_scsi_spc_xcopy_seg_desc_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3605                                         seg_type = tvb_get_guint8(tvb, offset);
3606                                         offset += 1;
3607                                         proto_tree_add_item(seg_tree, hf_scsi_spc_xcopy_seg_desc_dc, tvb, offset, 1, ENC_BIG_ENDIAN);
3608                                         proto_tree_add_item(seg_tree, hf_scsi_spc_xcopy_seg_desc_cat, tvb, offset, 1, ENC_BIG_ENDIAN);
3609                                         offset += 1;
3610                                         proto_tree_add_item(seg_tree, hf_scsi_segment_descriptor_length, tvb, offset, 2, ENC_BIG_ENDIAN);
3611                                         offset += 2;
3612                                         proto_tree_add_item(seg_tree, hf_scsi_spc_xcopy_seg_des_src_desc_id, tvb, offset, 2, ENC_BIG_ENDIAN);
3613                                         offset += 2;
3614                                         proto_tree_add_item(seg_tree, hf_scsi_spc_xcopy_seg_des_dest_desc_id, tvb, offset, 2, ENC_BIG_ENDIAN);
3615                                         offset += 2;
3616                                         seg_param_tree = proto_tree_add_subtree(seg_tree, tvb, offset, seg_desc_len - 4,
3617                                                             ett_scsi_xcopy_seg_param, NULL, "Segment descriptor parameters");
3618                                         seg_desc_list_len -= (seg_desc_len + 4);
3619                                         if (seg_type == BLOCK_TO_BLOCK) {
3620                                                 proto_tree_add_item(seg_param_tree, hf_scsi_reserved_16, tvb, offset, 2, ENC_BIG_ENDIAN);
3621                                                 offset += 2;
3622                                                 proto_tree_add_item(seg_param_tree, hf_scsi_spc_xcopy_num_of_blocks, tvb, offset, 2, ENC_BIG_ENDIAN);
3623                                                 offset += 2;
3624                                                 proto_tree_add_item(seg_param_tree, hf_scsi_spc_xcopy_source_lba, tvb, offset, 8, ENC_BIG_ENDIAN);
3625                                                 offset += 8;
3626                                                 proto_tree_add_item(seg_param_tree, hf_scsi_spc_xcopy_dest_lba, tvb, offset, 8, ENC_BIG_ENDIAN);
3627                                                 offset += 8;
3628                                         } else {
3629                                                 offset += (seg_desc_len - 4);
3630                                         }
3631                                 }
3632                         }
3633                         if (inline_data_len > 0) {
3634                                 proto_tree_add_item(tree, hf_scsi_inline_data, tvb, offset, inline_data_len, ENC_NA);
3635                                 /*offset += inline_data_len;*/
3636                         }
3637               } else if (serv_action == XCOPY_LID4) {
3638                         proto_tree_add_item(tree, hf_scsi_spc_xcopy_param_list_format, tvb, offset, 1, ENC_BIG_ENDIAN);
3639                         offset += 1;
3640                         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_spc_xcopy_param_byte, ett_xcopy_param_byte, xcopy_param_list_bits, ENC_NA);
3641                         offset += 1;
3642                         proto_tree_add_item(tree, hf_scsi_spc_xcopy_head_cscd_desc_list_len, tvb, offset, 2, ENC_BIG_ENDIAN);
3643                         offset += 2;
3644                         proto_tree_add_item(tree, hf_scsi_spc_xcopy_head_cscd_desc_type_code, tvb, offset, 1, ENC_BIG_ENDIAN);
3645                         /*offset += 1;*/
3646                }
3647        }
3648 
3649 }
3650 
dissect_spc_recvcopy(tvbuff_t * tvb _U_,packet_info * pinfo _U_,proto_tree * tree _U_,guint offset _U_,gboolean isreq _U_,gboolean iscdb _U_,guint payload_len _U_,scsi_task_data_t * cdata _U_)3651 void dissect_spc_recvcopy(tvbuff_t *tvb _U_, packet_info *pinfo _U_,
3652                     proto_tree *tree _U_, guint offset _U_,
3653                     gboolean isreq _U_, gboolean iscdb _U_,
3654                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
3655 {
3656         guint16 serv_action;
3657         guint8  imp_desc_list_len;
3658 
3659         if (isreq && iscdb) {
3660                 proto_tree_add_item(tree, hf_scsi_spc_recv_copy_service, tvb, offset, 1, ENC_BIG_ENDIAN);
3661                 serv_action = tvb_get_guint8(tvb, offset) & 0x1F;
3662                 if (cdata) {
3663                         cdata->itlq->flags = serv_action;
3664                 }
3665                 offset += 1;
3666                 proto_tree_add_item(tree, hf_scsi_reserved_64, tvb, offset, 8, ENC_BIG_ENDIAN);
3667                 offset += 8;
3668                 proto_tree_add_item(tree, hf_scsi_alloclen32, tvb, offset, 4, ENC_BIG_ENDIAN);
3669                 offset += 4;
3670                 proto_tree_add_item(tree, hf_scsi_reserved_8, tvb, offset, 1, ENC_BIG_ENDIAN);
3671                 offset += 1;
3672                 proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_control,
3673                                ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
3674                 offset += 1;
3675 
3676         } else {
3677                 if (cdata) {
3678                         serv_action = cdata->itlq->flags;
3679                 }
3680                 else {
3681                         return;
3682                 }
3683                 if (serv_action == RECV_COPY_PARAMS) {
3684                         proto_tree_add_item(tree, hf_scsi_recv_copy_avail_data, tvb, offset, 4, ENC_BIG_ENDIAN);
3685                         offset += 4;
3686                         proto_tree_add_item(tree, hf_scsi_recv_copy_snlid, tvb, offset, 1, ENC_BIG_ENDIAN);
3687                         offset += 1;
3688                         proto_tree_add_item(tree, hf_scsi_reserved_24, tvb, offset, 3, ENC_BIG_ENDIAN);
3689                         offset += 3;
3690                         proto_tree_add_item(tree, hf_scsi_recv_copy_max_cscd_desc_count, tvb, offset, 2, ENC_BIG_ENDIAN);
3691                         offset += 2;
3692                         proto_tree_add_item(tree, hf_scsi_recv_copy_max_seg_desc_count, tvb, offset, 2, ENC_BIG_ENDIAN);
3693                         offset += 2;
3694                         proto_tree_add_item(tree, hf_scsi_recv_copy_max_desc_list_len, tvb, offset, 4, ENC_BIG_ENDIAN);
3695                         offset += 4;
3696                         proto_tree_add_item(tree, hf_scsi_recv_copy_max_seg_len, tvb, offset, 4, ENC_BIG_ENDIAN);
3697                         offset += 4;
3698                         proto_tree_add_item(tree, hf_scsi_recv_copy_max_inline_data_len, tvb, offset, 4, ENC_BIG_ENDIAN);
3699                         offset += 4;
3700                         proto_tree_add_item(tree, hf_scsi_recv_copy_held_data_limit, tvb, offset, 4, ENC_BIG_ENDIAN);
3701                         offset += 4;
3702                         proto_tree_add_item(tree, hf_scsi_recv_copy_max_stream_dev_trans_size, tvb, offset, 4, ENC_BIG_ENDIAN);
3703                         offset += 4;
3704                         proto_tree_add_item(tree, hf_scsi_reserved_16, tvb, offset, 2, ENC_BIG_ENDIAN);
3705                         offset += 2;
3706                         proto_tree_add_item(tree, hf_scsi_recv_copy_total_con_copies, tvb, offset, 2, ENC_BIG_ENDIAN);
3707                         offset += 2;
3708                         proto_tree_add_item(tree, hf_scsi_recv_copy_max_con_copies, tvb, offset, 1, ENC_BIG_ENDIAN);
3709                         offset += 1;
3710                         proto_tree_add_item(tree, hf_scsi_recv_copy_data_seg_gran, tvb, offset, 1, ENC_BIG_ENDIAN);
3711                         offset += 1;
3712                         proto_tree_add_item(tree, hf_scsi_recv_copy_inline_data_gran, tvb, offset, 1, ENC_BIG_ENDIAN);
3713                         offset += 1;
3714                         proto_tree_add_item(tree, hf_scsi_recv_copy_held_data_gran, tvb, offset, 1, ENC_BIG_ENDIAN);
3715                         offset += 1;
3716                         proto_tree_add_item(tree, hf_scsi_reserved_24, tvb, offset, 3, ENC_BIG_ENDIAN);
3717                         offset += 3;
3718                         proto_tree_add_item(tree, hf_scsi_recv_copy_implemented_desc_list_len, tvb, offset, 1, ENC_BIG_ENDIAN);
3719                         imp_desc_list_len = tvb_get_guint8(tvb, offset);
3720                         offset += 1;
3721                         while (imp_desc_list_len > 0) {
3722                                 proto_tree_add_item(tree, hf_scsi_spc_xcopy_cscd_desc_type_code, tvb, offset, 1, ENC_BIG_ENDIAN);
3723                                 offset += 1;
3724                                 imp_desc_list_len--;
3725                         }
3726                 } else {
3727                         proto_tree_add_expert_format(tree, pinfo, &ei_scsi_unknown_serv_action, tvb, offset, 0, "Unknown serv_action %u", serv_action);
3728                 }
3729         }
3730 }
3731 
3732 
3733 static int
dissect_scsi_log_page(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset)3734 dissect_scsi_log_page(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
3735                       guint offset)
3736 {
3737     static int * const pcflags_fields[] = {
3738         &hf_scsi_log_pagecode,
3739         NULL
3740     };
3741     static int * const paramflags_fields[] = {
3742         &hf_scsi_log_pf_du,
3743         &hf_scsi_log_pf_ds,
3744         &hf_scsi_log_pf_tsd,
3745         &hf_scsi_log_pf_etc,
3746         &hf_scsi_log_pf_tmc,
3747         &hf_scsi_log_pf_lbin,
3748         &hf_scsi_log_pf_lp,
3749         NULL
3750     };
3751     guint16 pagelen, pagecode;
3752     guint8 paramlen;
3753     proto_tree *log_tree;
3754     proto_item *ti;
3755     guint old_offset = offset;
3756     const log_pages_t *log_page;
3757 
3758     pagecode = tvb_get_guint8(tvb, offset) & 0x3f;
3759 
3760     log_tree = proto_tree_add_subtree_format(tree, tvb, offset, -1, ett_scsi_log, &ti,
3761                                 "Log Page: %s", val_to_str(pagecode, scsi_log_page_val, "Unknown (0x%04x)"));
3762 
3763     /* page code */
3764     proto_tree_add_bitmask(log_tree, tvb, offset, hf_scsi_log_pc_flags, ett_scsi_log_pc, pcflags_fields, ENC_BIG_ENDIAN);
3765     offset+=1;
3766 
3767     /* reserved byte */
3768     offset+=1;
3769 
3770     /* page length */
3771     pagelen = tvb_get_ntohs(tvb, offset);
3772     proto_tree_add_item(log_tree, hf_scsi_log_page_length, tvb, offset, 2, ENC_BIG_ENDIAN);
3773     offset+=2;
3774 
3775 
3776     /* find the appropriate log page */
3777     for(log_page = log_pages;log_page;log_page++) {
3778         if (log_page->parameters == NULL) {
3779             log_page = NULL;
3780             break;
3781         }
3782         if (log_page->page == pagecode) {
3783             break;
3784         }
3785     }
3786 
3787     /* loop over all parameters */
3788     while( offset<(old_offset+4+pagelen) ) {
3789         const log_page_parameters_t *log_parameter = NULL;
3790         guint16 log_param;
3791 
3792         /* parameter code */
3793         log_param = tvb_get_ntohs(tvb, offset);
3794         proto_tree_add_item(log_tree, hf_scsi_log_parameter_code, tvb, offset, 2, ENC_BIG_ENDIAN);
3795         offset+=2;
3796 
3797         /* flags */
3798         proto_tree_add_bitmask(log_tree, tvb, offset, hf_scsi_log_param_flags, ett_scsi_log_param, paramflags_fields, ENC_BIG_ENDIAN);
3799         offset+=1;
3800 
3801         /* parameter length */
3802         paramlen = tvb_get_guint8(tvb, offset);
3803         proto_tree_add_item(log_tree, hf_scsi_log_param_len, tvb, offset, 1, ENC_BIG_ENDIAN);
3804         offset+=1;
3805 
3806         /* find the log parameter */
3807         if (log_page) {
3808             for(log_parameter = log_page->parameters;log_parameter;log_parameter++) {
3809                 if (log_parameter->dissector == NULL) {
3810                     log_parameter = NULL;
3811                     break;
3812                 }
3813                 if (log_parameter->number == log_param) {
3814                     break;
3815                 }
3816             }
3817         }
3818 
3819         /* parameter data */
3820         if (paramlen) {
3821             if (log_parameter && log_parameter->dissector) {
3822                 tvbuff_t *param_tvb;
3823 
3824                 param_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN(tvb_reported_length_remaining(tvb, offset),paramlen), paramlen);
3825                 log_parameter->dissector(param_tvb, pinfo, log_tree);
3826             } else {
3827                 /* We did not have a dissector for this page/parameter so
3828                  * just display it as data.
3829                  */
3830                 proto_tree_add_item(log_tree, hf_scsi_log_param_data, tvb, offset, paramlen, ENC_NA);
3831             }
3832             offset+=paramlen;
3833         }
3834     }
3835 
3836     proto_item_set_len(ti, offset-old_offset);
3837     return offset;
3838 }
3839 
3840 void
dissect_spc_logselect(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,gboolean isreq,gboolean iscdb,guint payload_len _U_,scsi_task_data_t * cdata _U_)3841 dissect_spc_logselect(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
3842                       guint offset, gboolean isreq, gboolean iscdb,
3843                       guint payload_len _U_, scsi_task_data_t *cdata _U_)
3844 {
3845     static int * const ppcflags_fields[] = {
3846         &hf_scsi_log_pcr,
3847         &hf_scsi_log_sp,
3848         NULL
3849     };
3850     static int * const pcflags_fields[] = {
3851         &hf_scsi_log_pc,
3852         NULL
3853     };
3854 
3855     if (!tree)
3856         return;
3857 
3858     if (isreq && iscdb) {
3859         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_log_ppc_flags,
3860                                ett_scsi_log_ppc, ppcflags_fields, ENC_BIG_ENDIAN);
3861         proto_tree_add_bitmask(tree, tvb, offset+1, hf_scsi_log_pc_flags, ett_scsi_log_pc, pcflags_fields, ENC_BIG_ENDIAN);
3862         proto_tree_add_item(tree, hf_scsi_paramlen16, tvb, offset+6, 2, ENC_BIG_ENDIAN);
3863         proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control,
3864                                ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
3865     }
3866     else {
3867     }
3868 }
3869 
3870 static const true_false_string scsi_log_pcr_tfs = {
3871     "Reset all parameters to default values",
3872     "Do not reset log parameters"
3873 };
3874 static const true_false_string scsi_log_ppc_tfs = {
3875     "Return only parameters that have changed since last LOG SELECT/SENSE",
3876     "Return parameters even if they are unchanged"
3877 };
3878 static const true_false_string scsi_log_sp_tfs = {
3879     "Device shall save all log parameters",
3880     "Device should not save any of the logged parameters"
3881 };
3882 
3883 void
dissect_spc_logsense(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,guint offset,gboolean isreq,gboolean iscdb,guint payload_len _U_,scsi_task_data_t * cdata _U_)3884 dissect_spc_logsense(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
3885                      guint offset, gboolean isreq, gboolean iscdb,
3886                      guint payload_len _U_, scsi_task_data_t *cdata _U_)
3887 {
3888     static int * const ppcflags_fields[] = {
3889         &hf_scsi_log_ppc,
3890         &hf_scsi_log_sp,
3891         NULL
3892     };
3893     static int * const pcflags_fields[] = {
3894         &hf_scsi_log_pc,
3895         &hf_scsi_log_pagecode,
3896         NULL
3897     };
3898 
3899     if (!tree)
3900         return;
3901 
3902     if (isreq && iscdb) {
3903         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_log_ppc_flags,
3904                                ett_scsi_log_ppc, ppcflags_fields, ENC_BIG_ENDIAN);
3905         proto_tree_add_bitmask(tree, tvb, offset+1, hf_scsi_log_pc_flags,
3906                                ett_scsi_log_pc, pcflags_fields, ENC_BIG_ENDIAN);
3907         proto_tree_add_item(tree, hf_scsi_log_parameter_ptr, tvb, offset+4,
3908                             2, ENC_BIG_ENDIAN);
3909         proto_tree_add_item(tree, hf_scsi_alloclen16, tvb, offset+6, 2, ENC_BIG_ENDIAN);
3910         proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control,
3911                                ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
3912     } else if (!isreq) {
3913         if (!cdata) {
3914             return;
3915         }
3916         dissect_scsi_log_page(tvb, pinfo, tree, offset);
3917     }
3918 }
3919 
3920 static void
dissect_scsi_blockdescs(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * scsi_tree,scsi_task_data_t * cdata,gboolean longlba)3921 dissect_scsi_blockdescs(tvbuff_t *tvb, packet_info *pinfo _U_,
3922                         proto_tree *scsi_tree,
3923                         scsi_task_data_t *cdata, gboolean longlba)
3924 {
3925     int offset = 0;
3926 
3927     /* without cdata there is no point in continuing */
3928     if (!cdata)
3929         return;
3930 
3931     while (tvb_reported_length_remaining(tvb, offset) > 0) {
3932         if (longlba) {
3933             if (tvb_reported_length_remaining(tvb, offset)<8)
3934                 return;
3935             proto_tree_add_item(scsi_tree, hf_scsi_blockdescs_no_of_blocks64, tvb, offset, 8, ENC_BIG_ENDIAN);
3936             offset += 8;
3937 
3938             if (tvb_reported_length_remaining(tvb, offset)<1)
3939                 return;
3940             proto_tree_add_item(scsi_tree, hf_scsi_blockdescs_density_code, tvb, offset, 1, ENC_BIG_ENDIAN);
3941             offset += 1;
3942 
3943             /* 3 reserved bytes */
3944             offset += 3;
3945 
3946             if (tvb_reported_length_remaining(tvb, offset)<4)
3947                 return;
3948             proto_tree_add_item(scsi_tree, hf_scsi_blockdescs_block_length32, tvb, offset, 4, ENC_BIG_ENDIAN);
3949             offset += 4;
3950         } else {
3951             if ((cdata->itl->cmdset&SCSI_CMDSET_MASK) == SCSI_DEV_SBC) {
3952                 if (tvb_reported_length_remaining(tvb, offset)<4)
3953                     return;
3954                 proto_tree_add_item(scsi_tree, hf_scsi_blockdescs_no_of_blocks32, tvb, offset, 4, ENC_BIG_ENDIAN);
3955                 offset += 4;
3956 
3957                 offset++;  /* reserved */
3958 
3959                 if (tvb_reported_length_remaining(tvb, offset)<3)
3960                     return;
3961                 proto_tree_add_item(scsi_tree, hf_scsi_blockdescs_block_length24, tvb, offset, 3, ENC_BIG_ENDIAN);
3962                 offset += 3;
3963             } else {
3964                 if (tvb_reported_length_remaining(tvb, offset)<1)
3965                     return;
3966                 proto_tree_add_item(scsi_tree, hf_scsi_blockdescs_density_code, tvb, offset, 1, ENC_BIG_ENDIAN);
3967                 offset += 1;
3968 
3969                 if (tvb_reported_length_remaining(tvb, offset)<3)
3970                     return;
3971                 proto_tree_add_item(scsi_tree, hf_scsi_blockdescs_no_of_blocks24, tvb, offset, 3, ENC_BIG_ENDIAN);
3972                 offset += 3;
3973 
3974                 offset++; /* reserved */
3975 
3976                 if (tvb_reported_length_remaining(tvb, offset)<3)
3977                     return;
3978                 proto_tree_add_item(scsi_tree, hf_scsi_blockdescs_block_length24, tvb, offset, 3, ENC_BIG_ENDIAN);
3979                 offset += 3;
3980             }
3981         }
3982     }
3983 }
3984 
3985 static gboolean
dissect_scsi_spc_modepage(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,guint8 pcode,guint8 spf,guint8 subpcode)3986 dissect_scsi_spc_modepage(tvbuff_t *tvb, packet_info *pinfo _U_,
3987                           proto_tree *tree, guint offset, guint8 pcode, guint8 spf, guint8 subpcode)
3988 {
3989     guint8 flags, proto;
3990     guint32 burst_size, condition_timer;
3991 
3992     switch (pcode) {
3993     case SCSI_SPC_MODEPAGE_CTL:
3994         if (!spf) {
3995             guint32 timeout_period;
3996 
3997             /* standard page for control */
3998             proto_tree_add_item(tree, hf_scsi_modesns_tst, tvb, offset+2, 1, ENC_BIG_ENDIAN);
3999             proto_tree_add_item(tree, hf_scsi_spc_modepage_gltsd, tvb, offset+2, 1, ENC_BIG_ENDIAN);
4000             proto_tree_add_item(tree, hf_scsi_spc_modepage_report_log_exception_condition, tvb, offset+2, 1, ENC_NA);
4001             proto_tree_add_item(tree, hf_scsi_modesns_qmod, tvb, offset+3, 1, ENC_BIG_ENDIAN);
4002             proto_tree_add_item(tree, hf_scsi_modesns_qerr, tvb, offset+3, 1, ENC_BIG_ENDIAN);
4003             proto_tree_add_item(tree, hf_scsi_spc_modepage_disable_queuing, tvb, offset+3, 1, ENC_NA);
4004             proto_tree_add_item(tree, hf_scsi_modesns_rac, tvb, offset+4, 1, ENC_BIG_ENDIAN);
4005             proto_tree_add_item(tree, hf_scsi_modesns_tas, tvb, offset+4, 1, ENC_BIG_ENDIAN);
4006             proto_tree_add_item(tree, hf_scsi_spc_modepage_swp, tvb, offset+4, 1, ENC_NA);
4007             proto_tree_add_item(tree, hf_scsi_spc_modepage_autoload_mode, tvb, offset+5, 1, ENC_BIG_ENDIAN);
4008             proto_tree_add_item(tree, hf_scsi_spc_modepage_ready_aer_holdoff_period, tvb, offset+6, 2, ENC_BIG_ENDIAN);
4009             timeout_period = tvb_get_ntohs(tvb, offset+8)*100;
4010             proto_tree_add_uint(tree, hf_scsi_spc_modepage_busy_timeout_period, tvb, offset+8, 2, timeout_period);
4011             proto_tree_add_item(tree, hf_scsi_spc_modepage_extended_self_test_completion_time, tvb, offset+10, 2, ENC_BIG_ENDIAN);
4012         } else {
4013             switch (subpcode) {
4014             case 1:
4015                 /* control extension subpage */
4016                 proto_item_append_text(tree, " Control Extension");
4017 
4018                 /* TCMOS SCSIP IALUAE */
4019                 proto_tree_add_item(tree, hf_scsi_modepage_tcmos, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
4020                 proto_tree_add_item(tree, hf_scsi_modepage_scsip, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
4021                 proto_tree_add_item(tree, hf_scsi_modepage_ialuae, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
4022 
4023                 /* Initial Command Priority */
4024                 proto_tree_add_item(tree, hf_scsi_modepage_icp, tvb, offset + 5, 1, ENC_BIG_ENDIAN);
4025 
4026                 /* Maximum Sense Data Length */
4027                 proto_tree_add_item(tree, hf_scsi_modepage_msdl, tvb, offset + 6, 1, ENC_BIG_ENDIAN);
4028 
4029                 break;
4030             }
4031         }
4032         break;
4033     case SCSI_SPC_MODEPAGE_DISCON:
4034         proto_tree_add_item(tree, hf_scsi_spc_modepage_buffer_full_ratio, tvb, offset+2, 1, ENC_BIG_ENDIAN);
4035         proto_tree_add_item(tree, hf_scsi_spc_modepage_buffer_empty_ratio, tvb, offset+3, 1, ENC_BIG_ENDIAN);
4036         proto_tree_add_item(tree, hf_scsi_spc_modepage_bus_inactivity_limit, tvb, offset+4, 2, ENC_BIG_ENDIAN);
4037         proto_tree_add_item(tree, hf_scsi_spc_modepage_disconnect_time_limit, tvb, offset+6, 2, ENC_BIG_ENDIAN);
4038         proto_tree_add_item(tree, hf_scsi_spc_modepage_connect_time_limit, tvb, offset+8, 2, ENC_BIG_ENDIAN);
4039         burst_size = tvb_get_ntohs(tvb, offset+10)*512;
4040         proto_tree_add_uint(tree, hf_scsi_spc_modepage_maximum_burst_size, tvb, offset+10, 2, burst_size);
4041         proto_tree_add_item(tree, hf_scsi_spc_modepage_emdp, tvb, offset+12, 1, ENC_NA);
4042         proto_tree_add_item(tree, hf_scsi_spc_modepage_faa, tvb, offset+12, 1, ENC_NA);
4043         proto_tree_add_item(tree, hf_scsi_spc_modepage_fab, tvb, offset+12, 1, ENC_NA);
4044         proto_tree_add_item(tree, hf_scsi_spc_modepage_fac, tvb, offset+12, 1, ENC_NA);
4045         burst_size = tvb_get_ntohs(tvb, offset+14)*512;
4046         proto_tree_add_uint(tree, hf_scsi_spc_modepage_first_burst_size, tvb, offset+14, 2, burst_size);
4047         break;
4048     case SCSI_SPC_MODEPAGE_INFOEXCP:
4049         flags = tvb_get_guint8(tvb, offset+2);
4050         proto_tree_add_item(tree, hf_scsi_spc_modepage_perf, tvb, offset+2, 1, ENC_NA);
4051         proto_tree_add_item(tree, hf_scsi_spc_modepage_ebf, tvb, offset+2, 1, ENC_NA);
4052         proto_tree_add_item(tree, hf_scsi_spc_modepage_ewasc, tvb, offset+2, 1, ENC_NA);
4053         proto_tree_add_item(tree, hf_scsi_spc_modepage_dexcpt, tvb, offset+2, 1, ENC_NA);
4054         proto_tree_add_item(tree, hf_scsi_spc_modepage_test, tvb, offset+2, 1, ENC_NA);
4055         proto_tree_add_item(tree, hf_scsi_spc_modepage_logerr, tvb, offset+2, 1, ENC_NA);
4056         if (!((flags & 0x10) >> 4) && ((flags & 0x08) >> 3)) {
4057             proto_item *hidden_item;
4058             hidden_item = proto_tree_add_item(tree, hf_scsi_modesns_errrep, tvb,
4059                                               offset+3, 1, ENC_BIG_ENDIAN);
4060             proto_item_set_hidden(hidden_item);
4061         }
4062         else {
4063             proto_tree_add_item(tree, hf_scsi_modesns_errrep, tvb, offset+3, 1, ENC_BIG_ENDIAN);
4064         }
4065         proto_tree_add_item(tree, hf_scsi_spc_modepage_interval_timer, tvb, offset+4, 4, ENC_BIG_ENDIAN);
4066         proto_tree_add_item(tree, hf_scsi_spc_modepage_report_count, tvb, offset+8, 4, ENC_BIG_ENDIAN);
4067         break;
4068     case SCSI_SPC_MODEPAGE_PWR:
4069         proto_tree_add_item(tree, hf_scsi_spc_modepage_idle, tvb, offset+3, 1, ENC_NA);
4070         proto_tree_add_item(tree, hf_scsi_spc_modepage_standby, tvb, offset+3, 1, ENC_NA);
4071         condition_timer = tvb_get_ntohs(tvb, offset+4) * 100;
4072         proto_tree_add_uint(tree, hf_scsi_spc_modepage_idle_condition_timer, tvb, offset+4, 2, condition_timer);
4073         condition_timer = tvb_get_ntohs(tvb, offset+6) * 100;
4074         proto_tree_add_uint(tree, hf_scsi_spc_modepage_standby_condition_timer, tvb, offset+6, 2, condition_timer);
4075         break;
4076     case SCSI_SPC_MODEPAGE_LUN:
4077         return FALSE;
4078     case SCSI_SPC_MODEPAGE_PORT:
4079         proto = tvb_get_guint8(tvb, offset+2) & 0x0F;
4080         proto_tree_add_item(tree, hf_scsi_protocol, tvb, offset+2, 1, ENC_BIG_ENDIAN);
4081         if (proto == SCSI_PROTO_FCP) {
4082             proto_tree_add_item(tree, hf_scsi_spc_modepage_dtfd, tvb, offset+3, 1, ENC_NA);
4083             proto_tree_add_item(tree, hf_scsi_spc_modepage_plpb, tvb, offset+3, 1, ENC_NA);
4084             proto_tree_add_item(tree, hf_scsi_spc_modepage_ddis, tvb, offset+3, 1, ENC_NA);
4085             proto_tree_add_item(tree, hf_scsi_spc_modepage_dlm, tvb, offset+3, 1, ENC_NA);
4086             proto_tree_add_item(tree, hf_scsi_spc_modepage_rha, tvb, offset+3, 1, ENC_NA);
4087             proto_tree_add_item(tree, hf_scsi_spc_modepage_alwi, tvb, offset+3, 1, ENC_NA);
4088             proto_tree_add_item(tree, hf_scsi_spc_modepage_dtipe, tvb, offset+3, 1, ENC_NA);
4089             proto_tree_add_item(tree, hf_scsi_spc_modepage_dtoli, tvb, offset+3, 1, ENC_NA);
4090             proto_tree_add_item(tree, hf_scsi_spc_modepage_rr_tov_units, tvb, offset+6, 1, ENC_BIG_ENDIAN);
4091             proto_tree_add_item(tree, hf_scsi_spc_modepage_rr_tov, tvb, offset+7, 1, ENC_BIG_ENDIAN);
4092         }
4093         else if (proto == SCSI_PROTO_iSCSI) {
4094             return FALSE;
4095         }
4096         else {
4097             return FALSE;
4098         }
4099         break;
4100     case SCSI_SCSI2_MODEPAGE_PERDEV:
4101         return FALSE;
4102     default:
4103         return FALSE;
4104     }
4105     return TRUE;
4106 }
4107 
4108 static gboolean
dissect_scsi_sbc_modepage(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,guint8 pcode,guint8 spf _U_,guint8 subpcode _U_)4109 dissect_scsi_sbc_modepage(tvbuff_t *tvb, packet_info *pinfo _U_,
4110                           proto_tree *tree, guint offset, guint8 pcode, guint8 spf _U_, guint8 subpcode _U_)
4111 {
4112     switch (pcode) {
4113     case SCSI_SBC_MODEPAGE_FMTDEV:
4114         proto_tree_add_item(tree, hf_scsi_sbc_modepage_tracks_per_zone, tvb, offset+2, 2, ENC_BIG_ENDIAN);
4115         proto_tree_add_item(tree, hf_scsi_sbc_modepage_alternate_sectors_per_zone, tvb, offset+4, 2, ENC_BIG_ENDIAN);
4116         proto_tree_add_item(tree, hf_scsi_sbc_modepage_alternate_tracks_per_zone, tvb, offset+6, 2, ENC_BIG_ENDIAN);
4117         proto_tree_add_item(tree, hf_scsi_sbc_modepage_alternate_tracks_per_lu, tvb, offset+8, 2, ENC_BIG_ENDIAN);
4118         proto_tree_add_item(tree, hf_scsi_sbc_modepage_sectors_per_track, tvb, offset+10, 2, ENC_BIG_ENDIAN);
4119         proto_tree_add_item(tree, hf_scsi_sbc_modepage_data_bytes_per_physical_sector, tvb, offset+12, 2, ENC_BIG_ENDIAN);
4120         proto_tree_add_item(tree, hf_scsi_sbc_modepage_interleave, tvb, offset+14, 2, ENC_BIG_ENDIAN);
4121         proto_tree_add_item(tree, hf_scsi_sbc_modepage_track_skew_factor, tvb, offset+16, 2, ENC_BIG_ENDIAN);
4122         proto_tree_add_item(tree, hf_scsi_sbc_modepage_cylinder_skew_factor, tvb, offset+18, 2, ENC_BIG_ENDIAN);
4123         proto_tree_add_item(tree, hf_scsi_sbc_modepage_ssec, tvb, offset+20, 1, ENC_NA);
4124         proto_tree_add_item(tree, hf_scsi_sbc_modepage_hsec, tvb, offset+20, 1, ENC_NA);
4125         proto_tree_add_item(tree, hf_scsi_sbc_modepage_rmb, tvb, offset+20, 1, ENC_NA);
4126         proto_tree_add_item(tree, hf_scsi_sbc_modepage_surf, tvb, offset+20, 1, ENC_NA);
4127         break;
4128     case SCSI_SBC_MODEPAGE_RDWRERR:
4129         proto_tree_add_item(tree, hf_scsi_sbc_modepage_awre, tvb, offset+2, 1, ENC_NA);
4130         proto_tree_add_item(tree, hf_scsi_sbc_modepage_arre, tvb, offset+2, 1, ENC_NA);
4131         proto_tree_add_item(tree, hf_scsi_sbc_modepage_tb, tvb, offset+2, 1, ENC_NA);
4132         proto_tree_add_item(tree, hf_scsi_sbc_modepage_rc, tvb, offset+2, 1, ENC_NA);
4133         proto_tree_add_item(tree, hf_scsi_sbc_modepage_eer, tvb, offset+2, 1, ENC_NA);
4134         proto_tree_add_item(tree, hf_scsi_sbc_modepage_per, tvb, offset+2, 1, ENC_NA);
4135         proto_tree_add_item(tree, hf_scsi_sbc_modepage_dte, tvb, offset+2, 1, ENC_NA);
4136         proto_tree_add_item(tree, hf_scsi_sbc_modepage_dcr, tvb, offset+2, 1, ENC_NA);
4137         proto_tree_add_item(tree, hf_scsi_sbc_modepage_read_retry_count, tvb, offset+3, 1, ENC_BIG_ENDIAN);
4138         proto_tree_add_item(tree, hf_scsi_sbc_modepage_correction_span, tvb, offset+4, 1, ENC_BIG_ENDIAN);
4139         proto_tree_add_item(tree, hf_scsi_sbc_modepage_head_offset_count, tvb, offset+5, 1, ENC_BIG_ENDIAN);
4140         proto_tree_add_item(tree, hf_scsi_sbc_modepage_data_strobe_offset_count, tvb, offset+6, 1, ENC_BIG_ENDIAN);
4141         proto_tree_add_item(tree, hf_scsi_sbc_modepage_write_retry_count, tvb, offset+8, 1, ENC_BIG_ENDIAN);
4142         proto_tree_add_item(tree, hf_scsi_sbc_modepage_recovery_time_limit, tvb, offset+10, 2, ENC_BIG_ENDIAN);
4143         break;
4144     case SCSI_SBC_MODEPAGE_DISKGEOM:
4145         proto_tree_add_item(tree, hf_scsi_sbc_modepage_number_of_cylinders, tvb, offset+2, 3, ENC_BIG_ENDIAN);
4146         proto_tree_add_item(tree, hf_scsi_sbc_modepage_number_of_heads, tvb, offset+5, 1, ENC_BIG_ENDIAN);
4147         proto_tree_add_item(tree, hf_scsi_sbc_modepage_starting_cyl_pre_compensation, tvb, offset+6, 3, ENC_BIG_ENDIAN);
4148         proto_tree_add_item(tree, hf_scsi_sbc_modepage_starting_cyl_reduced_write_current, tvb, offset+9, 3, ENC_BIG_ENDIAN);
4149         proto_tree_add_item(tree, hf_scsi_sbc_modepage_device_step_rate, tvb, offset+12, 2, ENC_BIG_ENDIAN);
4150         proto_tree_add_item(tree, hf_scsi_sbc_modepage_landing_zone_cyl, tvb, offset+14, 3, ENC_BIG_ENDIAN);
4151         proto_tree_add_item(tree, hf_scsi_sbc_modepage_rotational_offset, tvb, offset+18, 1, ENC_BIG_ENDIAN);
4152         proto_tree_add_item(tree, hf_scsi_sbc_modepage_medium_rotation_rate, tvb, offset+20, 2, ENC_BIG_ENDIAN);
4153         break;
4154     case SCSI_SBC_MODEPAGE_FLEXDISK:
4155         return FALSE;
4156     case SCSI_SBC_MODEPAGE_VERERR:
4157         return FALSE;
4158     case SCSI_SBC_MODEPAGE_CACHE:
4159         proto_tree_add_item(tree, hf_scsi_sbc_modepage_ic, tvb, offset+2, 1, ENC_NA);
4160         proto_tree_add_item(tree, hf_scsi_sbc_modepage_abpf, tvb, offset+2, 1, ENC_NA);
4161         proto_tree_add_item(tree, hf_scsi_sbc_modepage_cap, tvb, offset+2, 1, ENC_NA);
4162         proto_tree_add_item(tree, hf_scsi_sbc_modepage_disc, tvb, offset+2, 1, ENC_NA);
4163         proto_tree_add_item(tree, hf_scsi_sbc_modepage_size, tvb, offset+2, 1, ENC_NA);
4164         proto_tree_add_item(tree, hf_scsi_sbc_modepage_wce, tvb, offset+2, 1, ENC_NA);
4165         proto_tree_add_item(tree, hf_scsi_sbc_modepage_mf, tvb, offset+2, 1, ENC_NA);
4166         proto_tree_add_item(tree, hf_scsi_sbc_modepage_rcd, tvb, offset+2, 1, ENC_NA);
4167         proto_tree_add_item(tree, hf_scsi_sbc_modepage_demand_read_retention_priority, tvb, offset+3, 1, ENC_BIG_ENDIAN);
4168         proto_tree_add_item(tree, hf_scsi_sbc_modepage_write_retention_priority, tvb, offset+3, 1, ENC_BIG_ENDIAN);
4169         proto_tree_add_item(tree, hf_scsi_sbc_modepage_disable_pre_fetch_xfer_len, tvb, offset+4, 2, ENC_BIG_ENDIAN);
4170         proto_tree_add_item(tree, hf_scsi_sbc_modepage_minimum_pre_fetch, tvb, offset+6, 2, ENC_BIG_ENDIAN);
4171         proto_tree_add_item(tree, hf_scsi_sbc_modepage_maximum_pre_fetch, tvb, offset+8, 2, ENC_BIG_ENDIAN);
4172         proto_tree_add_item(tree, hf_scsi_sbc_modepage_maximum_pre_fetch_ceiling, tvb, offset+10, 2, ENC_BIG_ENDIAN);
4173         proto_tree_add_item(tree, hf_scsi_sbc_modepage_fsw, tvb, offset+12, 1, ENC_NA);
4174         proto_tree_add_item(tree, hf_scsi_sbc_modepage_lbcss, tvb, offset+12, 1, ENC_NA);
4175         proto_tree_add_item(tree, hf_scsi_sbc_modepage_dra, tvb, offset+12, 1, ENC_NA);
4176         proto_tree_add_item(tree, hf_scsi_sbc_modepage_vendor_specific, tvb, offset+12, 1, ENC_BIG_ENDIAN);
4177         proto_tree_add_item(tree, hf_scsi_sbc_modepage_number_of_cache_segments, tvb, offset+13, 1, ENC_BIG_ENDIAN);
4178         proto_tree_add_item(tree, hf_scsi_sbc_modepage_cache_segment_size, tvb, offset+14, 2, ENC_BIG_ENDIAN);
4179         proto_tree_add_item(tree, hf_scsi_sbc_modepage_non_cache_segment_size, tvb, offset+17, 3, ENC_BIG_ENDIAN);
4180         break;
4181     case SCSI_SBC_MODEPAGE_MEDTYPE:
4182         return FALSE;
4183     case SCSI_SBC_MODEPAGE_NOTPART:
4184         return FALSE;
4185     case SCSI_SBC_MODEPAGE_XORCTL:
4186         return FALSE;
4187     default:
4188         return FALSE;
4189     }
4190     return TRUE;
4191 }
4192 
4193 static const value_string compression_algorithm_vals[] = {
4194     {0x00, "No algorithm selected"},
4195     {0x01, "Default algorithm"},
4196     {0x03, "IBM ALDC with 512-byte buffer"},
4197     {0x04, "IBM ALDC with 1024-byte buffer"},
4198     {0x05, "IBM ALDC with 2048-byte buffer"},
4199     {0x10, "IBM IDRC"},
4200     {0x20, "DCLZ"},
4201     {0xFF, "Unregistered algorithm"},
4202     {0, NULL}
4203 };
4204 
4205 static gboolean
dissect_scsi_ssc2_modepage(tvbuff_t * tvb _U_,packet_info * pinfo _U_,proto_tree * tree _U_,guint offset _U_,guint8 pcode,guint8 spf _U_,guint8 subpcode _U_)4206 dissect_scsi_ssc2_modepage(tvbuff_t *tvb _U_, packet_info *pinfo _U_,
4207                            proto_tree *tree _U_, guint offset _U_,
4208                            guint8 pcode, guint8 spf _U_, guint8 subpcode _U_)
4209 {
4210     switch (pcode) {
4211     case SCSI_SSC2_MODEPAGE_DATACOMP:
4212         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_dce, tvb, offset+2, 1, ENC_NA);
4213         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_dcc, tvb, offset+2, 1, ENC_NA);
4214         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_dde, tvb, offset+3, 1, ENC_NA);
4215         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_red, tvb, offset+3, 1, ENC_BIG_ENDIAN);
4216         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_compression_algorithm, tvb, offset+4, 4, ENC_BIG_ENDIAN);
4217         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_decompression_algorithm, tvb, offset+8, 4, ENC_BIG_ENDIAN);
4218         break;
4219     case SCSI_SSC2_MODEPAGE_DEVCONF:
4220         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_caf, tvb, offset+2, 1, ENC_NA);
4221         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_active_format, tvb, offset+2, 1, ENC_BIG_ENDIAN);
4222         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_active_partition, tvb, offset+3, 1, ENC_BIG_ENDIAN);
4223         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_write_object_buffer_full_ratio, tvb, offset+4, 1, ENC_BIG_ENDIAN);
4224         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_read_object_buffer_empty_ratio, tvb, offset+5, 1, ENC_BIG_ENDIAN);
4225         proto_tree_add_uint_format_value(tree, hf_scsi_ssc2_modepage_write_delay_time, tvb, offset+6, 2,
4226                             tvb_get_ntohs(tvb, offset+6), "%u 100ms",
4227                             tvb_get_ntohs(tvb, offset+6));
4228         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_obr, tvb, offset+8, 1, ENC_NA);
4229         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_lois, tvb, offset+8, 1, ENC_NA);
4230         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_rsmk, tvb, offset+8, 1, ENC_NA);
4231         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_avc, tvb, offset+8, 1, ENC_NA);
4232         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_socf, tvb, offset+8, 1, ENC_BIG_ENDIAN);
4233         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_robo, tvb, offset+8, 1, ENC_NA);
4234         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_rew, tvb, offset+8, 1, ENC_NA);
4235         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_gap_size, tvb, offset+9, 1, ENC_BIG_ENDIAN);
4236         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_eod_defined, tvb, offset+10, 1, ENC_BIG_ENDIAN);
4237         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_eeg, tvb, offset+10, 1, ENC_NA);
4238         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_sew, tvb, offset+10, 1, ENC_NA);
4239         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_swp, tvb, offset+10, 1, ENC_NA);
4240         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_baml, tvb, offset+10, 1, ENC_NA);
4241         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_bam, tvb, offset+10, 1, ENC_NA);
4242         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_object_buffer_size_at_early_warning, tvb, offset+11, 3, ENC_BIG_ENDIAN);
4243         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_select_data_compression_algorithm, tvb, offset+14, 1, ENC_BIG_ENDIAN);
4244         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_oir, tvb, offset+15, 1, ENC_NA);
4245         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_rewind_on_reset, tvb, offset+15, 1, ENC_BIG_ENDIAN);
4246         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_asocwp, tvb, offset+15, 1, ENC_NA);
4247         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_perswp, tvb, offset+15, 1, ENC_NA);
4248         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_prmwp, tvb, offset+15, 1, ENC_NA);
4249         break;
4250     case SCSI_SSC2_MODEPAGE_MEDPAR1:
4251         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_maximum_additional_partitions, tvb, offset+2, 1, ENC_BIG_ENDIAN);
4252         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_additional_partitions_defined, tvb, offset+3, 1, ENC_BIG_ENDIAN);
4253         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_fdp, tvb, offset+4, 1, ENC_NA);
4254         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_dsp, tvb, offset+4, 1, ENC_NA);
4255         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_idp, tvb, offset+4, 1, ENC_NA);
4256         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_psum, tvb, offset+4, 1, ENC_BIG_ENDIAN);
4257         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_pofm, tvb, offset+4, 1, ENC_NA);
4258         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_clear, tvb, offset+4, 1, ENC_NA);
4259         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_addp, tvb, offset+4, 1, ENC_NA);
4260         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_media_format_recognition, tvb, offset+5, 1, ENC_BIG_ENDIAN);
4261         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_partition_units, tvb, offset+6, 1, ENC_BIG_ENDIAN);
4262         proto_tree_add_item(tree, hf_scsi_ssc2_modepage_partition_size, tvb, offset+8, 2, ENC_BIG_ENDIAN);
4263         break;
4264     case SCSI_SSC2_MODEPAGE_MEDPAR2:
4265         return FALSE;
4266     case SCSI_SSC2_MODEPAGE_MEDPAR3:
4267         return FALSE;
4268     case SCSI_SSC2_MODEPAGE_MEDPAR4:
4269         return FALSE;
4270     default:
4271         return FALSE;
4272     }
4273     return TRUE;
4274 }
4275 
4276 static gboolean
dissect_scsi_mmc5_modepage(tvbuff_t * tvb _U_,packet_info * pinfo _U_,proto_tree * tree _U_,guint offset _U_,guint8 pcode,guint8 spf _U_,guint8 subpcode _U_)4277 dissect_scsi_mmc5_modepage(tvbuff_t *tvb _U_, packet_info *pinfo _U_,
4278                            proto_tree *tree _U_, guint offset _U_, guint8 pcode, guint8 spf _U_, guint8 subpcode _U_)
4279 {
4280     guint8  flags;
4281     guint8  i;
4282 
4283     switch (pcode) {
4284     case SCSI_MMC5_MODEPAGE_MRW:
4285         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_lba_space, tvb, offset+3, 1, ENC_BIG_ENDIAN);
4286         break;
4287     case SCSI_MMC5_MODEPAGE_WRPARAM:
4288         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_bufe, tvb, offset+2, 1, ENC_NA);
4289         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_ls_v, tvb, offset+2, 1, ENC_NA);
4290         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_wrparam_test_write, tvb, offset+2, 1, ENC_NA);
4291         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_write_type, tvb, offset+2, 1, ENC_BIG_ENDIAN);
4292         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_wrparam_multi_session, tvb, offset+3, 1, ENC_BIG_ENDIAN);
4293         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_fp, tvb, offset+3, 1, ENC_NA);
4294         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_copy, tvb, offset+3, 1, ENC_NA);
4295         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_track_mode, tvb, offset+3, 1, ENC_BIG_ENDIAN);
4296         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_data_block_type, tvb, offset+4, 1, ENC_BIG_ENDIAN);
4297         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_link_size, tvb, offset+5, 1, ENC_BIG_ENDIAN);
4298         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_initiator_application_code, tvb, offset+7, 1, ENC_BIG_ENDIAN);
4299         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_session_format, tvb, offset+8, 1, ENC_BIG_ENDIAN);
4300         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_packet_size, tvb, offset+10, 4, ENC_BIG_ENDIAN);
4301         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_audio_pause_length, tvb, offset+14, 2, ENC_BIG_ENDIAN);
4302         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_media_catalog_number, tvb, offset+16, 16, ENC_NA|ENC_ASCII);
4303         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_international_standard_recording_code, tvb, offset+32, 16, ENC_NA|ENC_ASCII);
4304         for (i = 0; i < 4; i++) {
4305             flags = tvb_get_guint8(tvb, offset+48+i);
4306             proto_tree_add_uint_format(tree, hf_scsi_mmc5_modepage_sub_header_byte, tvb, offset+48+i, 1, flags,
4307                                 "Sub-header Byte %u: %u", i, flags);
4308         }
4309         if (0x36 == tvb_get_guint8(tvb, offset+1))
4310             proto_tree_add_item(tree, hf_scsi_mmc5_modepage_vendor_specific, tvb, offset+52, 4, ENC_BIG_ENDIAN);
4311         break;
4312     case SCSI_MMC3_MODEPAGE_MMCAP:
4313         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_dvd_ram_read, tvb, offset+2, 1, ENC_NA);
4314         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_dvd_r_read, tvb, offset+2, 1, ENC_NA);
4315         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_dvd_rom_read, tvb, offset+2, 1, ENC_NA);
4316         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_method_2, tvb, offset+2, 1, ENC_NA);
4317         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_cd_rw_read, tvb, offset+2, 1, ENC_NA);
4318         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_cd_r_read, tvb, offset+2, 1, ENC_NA);
4319         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_dvd_ram_write, tvb, offset+3, 1, ENC_NA);
4320         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_dvd_r_write, tvb, offset+3, 1, ENC_NA);
4321         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_dvd_rom_write, tvb, offset+3, 1, ENC_NA);
4322         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_mmcap_test_write, tvb, offset+3, 1, ENC_NA);
4323         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_cd_rw_write, tvb, offset+3, 1, ENC_NA);
4324         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_cd_r_write, tvb, offset+3, 1, ENC_NA);
4325         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_buf, tvb, offset+4, 1, ENC_NA);
4326         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_mmcap_multi_session, tvb, offset+4, 1, ENC_NA);
4327         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_mode_2_form2, tvb, offset+4, 1, ENC_NA);
4328         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_mode_2_form1, tvb, offset+4, 1, ENC_NA);
4329         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_digital_port2, tvb, offset+4, 1, ENC_NA);
4330         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_digital_port1, tvb, offset+4, 1, ENC_NA);
4331         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_composite, tvb, offset+4, 1, ENC_NA);
4332         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_audio_play, tvb, offset+4, 1, ENC_NA);
4333         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_read_bar_code, tvb, offset+5, 1, ENC_NA);
4334         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_upc, tvb, offset+5, 1, ENC_NA);
4335         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_isrc, tvb, offset+5, 1, ENC_NA);
4336         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_c2_pointers_supported, tvb, offset+5, 1, ENC_NA);
4337         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_rw_deinterleaved_corrected, tvb, offset+5, 1, ENC_NA);
4338         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_rw_supported, tvb, offset+5, 1, ENC_NA);
4339         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_cd_da_stream_is_accurate, tvb, offset+5, 1, ENC_NA);
4340         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_cd_da_cmds_supported, tvb, offset+5, 1, ENC_NA);
4341         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_loading_mechanism_type, tvb, offset+6, 1, ENC_BIG_ENDIAN);
4342         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_eject, tvb, offset+6, 1, ENC_NA);
4343         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_prevent_jumper, tvb, offset+6, 1, ENC_NA);
4344         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_lock_state, tvb, offset+6, 1, ENC_NA);
4345         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_lock, tvb, offset+6, 1, ENC_NA);
4346         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_rw_in_lead_in, tvb, offset+7, 1, ENC_NA);
4347         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_side_change_capable, tvb, offset+7, 1, ENC_NA);
4348         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_sw_slot_selection, tvb, offset+7, 1, ENC_NA);
4349         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_changer_supports_disc_present, tvb, offset+7, 1, ENC_NA);
4350         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_separate_channel_mute, tvb, offset+7, 1, ENC_NA);
4351         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_separate_volume_levels, tvb, offset+7, 1, ENC_NA);
4352         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_number_of_volume_levels_supported, tvb, offset+10, 2, ENC_BIG_ENDIAN);
4353         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_buffer_size_supported, tvb, offset+12, 2, ENC_BIG_ENDIAN);
4354         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_length, tvb, offset+17, 1, ENC_BIG_ENDIAN);
4355         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_lsbf, tvb, offset+17, 1, ENC_BIG_ENDIAN);
4356         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_rck, tvb, offset+17, 1, ENC_NA);
4357         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_bckf, tvb, offset+17, 1, ENC_NA);
4358         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_copy_management_revision_support, tvb, offset+22, 2, ENC_BIG_ENDIAN);
4359         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_rotation_control_selected, tvb, offset+27, 1, ENC_BIG_ENDIAN);
4360         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_current_write_speed_selected, tvb, offset+28, 2, ENC_BIG_ENDIAN);
4361         proto_tree_add_item(tree, hf_scsi_mmc5_modepage_num_write_speed_performance, tvb, offset+30, 2, ENC_BIG_ENDIAN);
4362         break;
4363     default:
4364         return FALSE;
4365     }
4366     return TRUE;
4367 }
4368 
4369 static gboolean
dissect_scsi_smc_modepage(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,guint8 pcode,guint8 spf _U_,guint8 subpcode _U_)4370 dissect_scsi_smc_modepage(tvbuff_t *tvb, packet_info *pinfo _U_,
4371                           proto_tree *tree, guint offset, guint8 pcode, guint8 spf _U_, guint8 subpcode _U_)
4372 {
4373     guint8 param_list_len;
4374 
4375     switch (pcode) {
4376     case SCSI_SMC_MODEPAGE_EAA:
4377         param_list_len = tvb_get_guint8(tvb, offset+1);
4378         if (param_list_len < 2)
4379             break;
4380         proto_tree_add_item(tree, hf_scsi_smc_modepage_first_medium_transport_element_address, tvb, offset+2, 2, ENC_BIG_ENDIAN);
4381         param_list_len -= 2;
4382         if (param_list_len < 2)
4383             break;
4384         proto_tree_add_item(tree, hf_scsi_smc_modepage_number_of_medium_transport_elements, tvb, offset+4, 2, ENC_BIG_ENDIAN);
4385         param_list_len -= 2;
4386         if (param_list_len < 2)
4387             break;
4388         proto_tree_add_item(tree, hf_scsi_smc_modepage_first_storage_element_address, tvb, offset+6, 2, ENC_BIG_ENDIAN);
4389         param_list_len -= 2;
4390         if (param_list_len < 2)
4391             break;
4392         proto_tree_add_item(tree, hf_scsi_smc_modepage_number_of_storage_elements, tvb, offset+8, 2, ENC_BIG_ENDIAN);
4393         param_list_len -= 2;
4394         if (param_list_len < 2)
4395             break;
4396         proto_tree_add_item(tree, hf_scsi_smc_modepage_first_import_export_element_address, tvb, offset+10, 2, ENC_BIG_ENDIAN);
4397         param_list_len -= 2;
4398         if (param_list_len < 2)
4399             break;
4400         proto_tree_add_item(tree, hf_scsi_smc_modepage_number_of_import_export_elements, tvb, offset+12, 2, ENC_BIG_ENDIAN);
4401         param_list_len -= 2;
4402         if (param_list_len < 2)
4403             break;
4404         proto_tree_add_item(tree, hf_scsi_smc_modepage_first_data_transfer_element_address, tvb, offset+14, 2, ENC_BIG_ENDIAN);
4405         param_list_len -= 2;
4406         if (param_list_len < 2)
4407             break;
4408         proto_tree_add_item(tree, hf_scsi_smc_modepage_number_of_data_transfer_elements, tvb, offset+16, 2, ENC_BIG_ENDIAN);
4409         break;
4410     case SCSI_SMC_MODEPAGE_TRANGEOM:
4411         return FALSE;
4412     case SCSI_SMC_MODEPAGE_DEVCAP:
4413         proto_tree_add_item(tree, hf_scsi_smc_modepage_stordt, tvb, offset+2, 1, ENC_NA);
4414         proto_tree_add_item(tree, hf_scsi_smc_modepage_storie, tvb, offset+2, 1, ENC_NA);
4415         proto_tree_add_item(tree, hf_scsi_smc_modepage_storst, tvb, offset+2, 1, ENC_NA);
4416         proto_tree_add_item(tree, hf_scsi_smc_modepage_stormt, tvb, offset+2, 1, ENC_NA);
4417         proto_tree_add_item(tree, hf_scsi_smc_modepage_mt_dt, tvb, offset+4, 1, ENC_NA);
4418         proto_tree_add_item(tree, hf_scsi_smc_modepage_mt_ie, tvb, offset+4, 1, ENC_NA);
4419         proto_tree_add_item(tree, hf_scsi_smc_modepage_mt_st, tvb, offset+4, 1, ENC_NA);
4420         proto_tree_add_item(tree, hf_scsi_smc_modepage_mt_mt, tvb, offset+4, 1, ENC_NA);
4421         proto_tree_add_item(tree, hf_scsi_smc_modepage_st_dt, tvb, offset+5, 1, ENC_NA);
4422         proto_tree_add_item(tree, hf_scsi_smc_modepage_st_ie, tvb, offset+5, 1, ENC_NA);
4423         proto_tree_add_item(tree, hf_scsi_smc_modepage_st_st, tvb, offset+5, 1, ENC_NA);
4424         proto_tree_add_item(tree, hf_scsi_smc_modepage_st_mt, tvb, offset+5, 1, ENC_NA);
4425         proto_tree_add_item(tree, hf_scsi_smc_modepage_ie_dt, tvb, offset+6, 1, ENC_NA);
4426         proto_tree_add_item(tree, hf_scsi_smc_modepage_ie_ie, tvb, offset+6, 1, ENC_NA);
4427         proto_tree_add_item(tree, hf_scsi_smc_modepage_ie_st, tvb, offset+6, 1, ENC_NA);
4428         proto_tree_add_item(tree, hf_scsi_smc_modepage_ie_mt, tvb, offset+6, 1, ENC_NA);
4429         proto_tree_add_item(tree, hf_scsi_smc_modepage_dt_dt, tvb, offset+7, 1, ENC_NA);
4430         proto_tree_add_item(tree, hf_scsi_smc_modepage_dt_ie, tvb, offset+7, 1, ENC_NA);
4431         proto_tree_add_item(tree, hf_scsi_smc_modepage_dt_st, tvb, offset+7, 1, ENC_NA);
4432         proto_tree_add_item(tree, hf_scsi_smc_modepage_dt_mt, tvb, offset+7, 1, ENC_NA);
4433         proto_tree_add_item(tree, hf_scsi_smc_modepage_mt_ne_dt, tvb, offset+12, 1, ENC_NA);
4434         proto_tree_add_item(tree, hf_scsi_smc_modepage_mt_ne_ie, tvb, offset+12, 1, ENC_NA);
4435         proto_tree_add_item(tree, hf_scsi_smc_modepage_mt_ne_st, tvb, offset+12, 1, ENC_NA);
4436         proto_tree_add_item(tree, hf_scsi_smc_modepage_mt_ne_mt, tvb, offset+12, 1, ENC_NA);
4437         proto_tree_add_item(tree, hf_scsi_smc_modepage_st_ne_dt, tvb, offset+13, 1, ENC_NA);
4438         proto_tree_add_item(tree, hf_scsi_smc_modepage_st_ne_ie, tvb, offset+13, 1, ENC_NA);
4439         proto_tree_add_item(tree, hf_scsi_smc_modepage_st_ne_st, tvb, offset+13, 1, ENC_NA);
4440         proto_tree_add_item(tree, hf_scsi_smc_modepage_st_ne_mt, tvb, offset+13, 1, ENC_NA);
4441         proto_tree_add_item(tree, hf_scsi_smc_modepage_ie_ne_dt, tvb, offset+14, 1, ENC_NA);
4442         proto_tree_add_item(tree, hf_scsi_smc_modepage_ie_ne_ie, tvb, offset+14, 1, ENC_NA);
4443         proto_tree_add_item(tree, hf_scsi_smc_modepage_ie_ne_st, tvb, offset+14, 1, ENC_NA);
4444         proto_tree_add_item(tree, hf_scsi_smc_modepage_ie_ne_mt, tvb, offset+14, 1, ENC_NA);
4445         proto_tree_add_item(tree, hf_scsi_smc_modepage_dt_ne_dt, tvb, offset+15, 1, ENC_NA);
4446         proto_tree_add_item(tree, hf_scsi_smc_modepage_dt_ne_ie, tvb, offset+15, 1, ENC_NA);
4447         proto_tree_add_item(tree, hf_scsi_smc_modepage_dt_ne_st, tvb, offset+15, 1, ENC_NA);
4448         proto_tree_add_item(tree, hf_scsi_smc_modepage_dt_ne_mt, tvb, offset+15, 1, ENC_NA);
4449         break;
4450     default:
4451         return FALSE;
4452     }
4453     return TRUE;
4454 }
4455 
4456 static guint
dissect_scsi_modepage(tvbuff_t * tvb,packet_info * pinfo,proto_tree * scsi_tree,guint offset,scsi_device_type devtype)4457 dissect_scsi_modepage(tvbuff_t *tvb, packet_info *pinfo,
4458                       proto_tree *scsi_tree, guint offset,
4459                       scsi_device_type devtype)
4460 {
4461     guint16             plen;
4462     guint8              pcode, spf, subpcode = 0;
4463     proto_tree         *tree;
4464     const value_string *modepage_val;
4465     int                 hf_pagecode;
4466     gboolean (*dissect_modepage)(tvbuff_t *, packet_info *, proto_tree *,
4467                                  guint, guint8, guint8, guint8);
4468 
4469     pcode = tvb_get_guint8(tvb, offset) & SCSI_MS_PCODE_BITS;
4470     spf   = tvb_get_guint8(tvb, offset) & 0x40;
4471     if (spf) {
4472         subpcode = tvb_get_guint8(tvb, offset + 1);
4473         plen = tvb_get_ntohs(tvb, offset + 2);
4474     } else {
4475         plen = tvb_get_guint8(tvb, offset + 1);
4476     }
4477 
4478     if (try_val_to_str(pcode & SCSI_MS_PCODE_BITS,
4479                      scsi_spc_modepage_val) == NULL) {
4480         /*
4481          * This isn't a generic mode page that applies to all SCSI
4482          * device types; try to interpret it based on what we deduced,
4483          * or were told, the device type is.
4484          */
4485         switch (devtype) {
4486         case SCSI_DEV_SBC:
4487             modepage_val = scsi_sbc_modepage_val;
4488             hf_pagecode = hf_scsi_sbcpagecode;
4489             dissect_modepage = dissect_scsi_sbc_modepage;
4490             break;
4491 
4492         case SCSI_DEV_SSC:
4493             modepage_val = scsi_ssc2_modepage_val;
4494             hf_pagecode = hf_scsi_sscpagecode;
4495             dissect_modepage = dissect_scsi_ssc2_modepage;
4496             break;
4497 
4498         case SCSI_DEV_SMC:
4499             modepage_val = scsi_smc_modepage_val;
4500             hf_pagecode = hf_scsi_smcpagecode;
4501             dissect_modepage = dissect_scsi_smc_modepage;
4502             break;
4503 
4504         case SCSI_DEV_CDROM:
4505             modepage_val = scsi_mmc5_modepage_val;
4506             hf_pagecode = hf_scsi_mmcpagecode;
4507             dissect_modepage = dissect_scsi_mmc5_modepage;
4508             break;
4509 
4510         default:
4511             /*
4512              * The "val_to_str()" lookup will fail in this table
4513              * (it failed in "try_val_to_str()"), so it'll return
4514              * "Unknown (XXX)", which is what we want.
4515              */
4516             modepage_val = scsi_spc_modepage_val;
4517             hf_pagecode = hf_scsi_spc_pagecode;
4518             dissect_modepage = dissect_scsi_spc_modepage;
4519             break;
4520         }
4521     } else {
4522         modepage_val = scsi_spc_modepage_val;
4523         hf_pagecode = hf_scsi_spc_pagecode;
4524         dissect_modepage = dissect_scsi_spc_modepage;
4525     }
4526 
4527     tree = proto_tree_add_subtree_format(scsi_tree, tvb, offset, plen + (spf ? 4 : 2),
4528                              ett_scsi_page, NULL, "%s Mode Page",
4529                              val_to_str(pcode & SCSI_MS_PCODE_BITS,
4530                                         modepage_val, "Unknown (0x%08x)"));
4531     proto_tree_add_item(tree, hf_scsi_modepage_ps, tvb, offset, 1, ENC_BIG_ENDIAN);
4532     proto_tree_add_item(tree, hf_scsi_modepage_spf, tvb, offset, 1, ENC_BIG_ENDIAN);
4533     proto_tree_add_item(tree, hf_pagecode, tvb, offset, 1, ENC_BIG_ENDIAN);
4534 
4535     if (spf) {
4536         proto_tree_add_item(tree, hf_scsi_spc_subpagecode, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
4537         proto_tree_add_item(tree, hf_scsi_modepage_plen, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
4538     } else {
4539         proto_tree_add_item(tree, hf_scsi_modepage_plen, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
4540     }
4541 
4542     if (!tvb_bytes_exist(tvb, offset, plen)) {
4543         /* XXX - why not just drive on and throw an exception? */
4544         return (plen + 2);
4545     }
4546 
4547     if (!(*dissect_modepage)(tvb, pinfo, tree, offset,
4548                              pcode, spf, subpcode)) {
4549         proto_tree_add_expert(tree, pinfo, &ei_scsi_unknown_page, tvb, offset+2, plen);
4550     }
4551     return (plen+2);
4552 }
4553 
4554 void
dissect_spc_modeselect6(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,guint offset,gboolean isreq,gboolean iscdb,guint payload_len,scsi_task_data_t * cdata)4555 dissect_spc_modeselect6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
4556                         guint offset, gboolean isreq, gboolean iscdb,
4557                         guint payload_len, scsi_task_data_t *cdata)
4558 {
4559     guint8    flags;
4560     guint     plen;
4561     gint      desclen;
4562     tvbuff_t *blockdesc_tvb;
4563 
4564     if (!tree)
4565         return;
4566 
4567     if (isreq && iscdb) {
4568         flags = tvb_get_guint8(tvb, offset);
4569         proto_tree_add_uint_format(tree, hf_scsi_modesel_flags, tvb, offset, 1,
4570                                    flags, "PF = %u, SP = %u", flags & 0x10,
4571                                    flags & 0x1);
4572         proto_tree_add_item(tree, hf_scsi_paramlen, tvb, offset+3, 1, ENC_BIG_ENDIAN);
4573         proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control,
4574                                ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
4575     }
4576     else {
4577         /* Mode Parameter has the following format:
4578          * Mode Parameter Header
4579          *    - Mode Data Len, Medium Type, Dev Specific Parameter,
4580          *      Blk Desc Len
4581          * Block Descriptor (s)
4582          *    - Number of blocks, density code, block length
4583          * Page (s)
4584          *    - Page code, Page length, Page Parameters
4585          */
4586         if (payload_len < 1)
4587             return;
4588         proto_tree_add_item(tree, hf_scsi_modesel_mode_data_length8, tvb, offset, 1, ENC_BIG_ENDIAN);
4589         offset += 1;
4590         payload_len -= 1;
4591         /* The mode data length is reserved for MODE SELECT, so we just
4592            use the payload length. */
4593 
4594         if (payload_len < 1)
4595             return;
4596         switch (cdata->itl->cmdset&SCSI_CMDSET_MASK) {
4597 
4598         case SCSI_DEV_SBC:
4599             proto_tree_add_item(tree, hf_scsi_modesel_dev_sbc_medium_type, tvb, offset, 1, ENC_BIG_ENDIAN);
4600             break;
4601 
4602         default:
4603             proto_tree_add_item(tree, hf_scsi_modesel_medium_type, tvb, offset, 1, ENC_BIG_ENDIAN);
4604             break;
4605         }
4606         offset += 1;
4607         payload_len -= 1;
4608 
4609         if (payload_len < 1)
4610             return;
4611         proto_tree_add_item(tree, hf_scsi_modesel_device_specific_parameter, tvb, offset, 1, ENC_BIG_ENDIAN);
4612         offset += 1;
4613         payload_len -= 1;
4614 
4615         if (payload_len < 1)
4616             return;
4617         desclen = tvb_get_guint8(tvb, offset);
4618         proto_tree_add_item(tree, hf_scsi_modesel_block_descriptor_length8, tvb, offset, 1, ENC_BIG_ENDIAN);
4619         offset += 1;
4620         payload_len -= 1;
4621 
4622         if (tvb_reported_length_remaining(tvb, offset)>0) {
4623             blockdesc_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN(tvb_reported_length_remaining(tvb, offset),desclen), desclen);
4624             dissect_scsi_blockdescs(blockdesc_tvb, pinfo, tree, cdata, FALSE);
4625         }
4626         offset += desclen;
4627         payload_len -= desclen;
4628 
4629         /* offset points to the start of the mode page */
4630         while ((payload_len > 0) && tvb_bytes_exist(tvb, offset, 2)) {
4631             plen = dissect_scsi_modepage(tvb, pinfo, tree, offset, cdata->itl->cmdset&SCSI_CMDSET_MASK);
4632             offset += plen;
4633             payload_len -= plen;
4634         }
4635     }
4636 }
4637 
4638 void
dissect_spc_modeselect10(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,guint offset,gboolean isreq,gboolean iscdb,guint payload_len,scsi_task_data_t * cdata)4639 dissect_spc_modeselect10(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
4640                          guint offset, gboolean isreq, gboolean iscdb,
4641                          guint payload_len, scsi_task_data_t *cdata)
4642 {
4643     guint8    flags;
4644     gboolean  longlba;
4645     gint      desclen;
4646     guint     plen;
4647     tvbuff_t *blockdesc_tvb;
4648 
4649     if (!tree)
4650         return;
4651 
4652     if (isreq && iscdb) {
4653         flags = tvb_get_guint8(tvb, offset);
4654         proto_tree_add_uint_format(tree, hf_scsi_modesel_flags, tvb, offset, 1,
4655                                    flags, "PF = %u, SP = %u", flags & 0x10,
4656                                    flags & 0x1);
4657         proto_tree_add_item(tree, hf_scsi_paramlen16, tvb, offset+6, 2, ENC_BIG_ENDIAN);
4658         proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control,
4659                                ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
4660     }
4661     else {
4662         /* Mode Parameter has the following format:
4663          * Mode Parameter Header
4664          *    - Mode Data Len, Medium Type, Dev Specific Parameter,
4665          *      Blk Desc Len
4666          * Block Descriptor (s)
4667          *    - Number of blocks, density code, block length
4668          * Page (s)
4669          *    - Page code, Page length, Page Parameters
4670          */
4671         if (payload_len < 1)
4672             return;
4673         proto_tree_add_item(tree, hf_scsi_modesel_mode_data_length16, tvb, offset, 2, ENC_BIG_ENDIAN);
4674         offset += 2;
4675         payload_len -= 2;
4676         /* The mode data length is reserved for MODE SELECT, so we just
4677            use the payload length. */
4678 
4679         if (payload_len < 1)
4680             return;
4681         if (!cdata->itl)
4682             return;
4683         switch (cdata->itl->cmdset&SCSI_CMDSET_MASK) {
4684 
4685         case SCSI_DEV_SBC:
4686             proto_tree_add_item(tree, hf_scsi_modesel_dev_sbc_medium_type, tvb, offset, 1, ENC_BIG_ENDIAN);
4687             break;
4688 
4689         default:
4690             proto_tree_add_item(tree, hf_scsi_modesel_medium_type, tvb, offset, 1, ENC_BIG_ENDIAN);
4691             break;
4692         }
4693         offset += 1;
4694         payload_len -= 1;
4695 
4696         if (payload_len < 1)
4697             return;
4698         proto_tree_add_item(tree, hf_scsi_modesel_device_specific_parameter, tvb, offset, 1, ENC_BIG_ENDIAN);
4699         offset += 1;
4700         payload_len -= 1;
4701 
4702         if (payload_len < 1)
4703             return;
4704         longlba = tvb_get_guint8(tvb, offset) & 0x1;
4705         proto_tree_add_item(tree, hf_scsi_modesel_longlba, tvb, offset, 1, ENC_BIG_ENDIAN);
4706         offset += 2;    /* skip LongLBA byte and reserved byte */
4707         payload_len -= 2;
4708 
4709         if (payload_len < 1)
4710             return;
4711         desclen = tvb_get_ntohs(tvb, offset);
4712         proto_tree_add_item(tree, hf_scsi_modesel_block_descriptor_length16, tvb, offset, 2, ENC_BIG_ENDIAN);
4713         offset += 2;
4714         payload_len -= 2;
4715 
4716         if (tvb_reported_length_remaining(tvb, offset)>0) {
4717             blockdesc_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN(tvb_reported_length_remaining(tvb, offset),desclen), desclen);
4718             dissect_scsi_blockdescs(blockdesc_tvb, pinfo, tree, cdata, longlba);
4719         }
4720         offset += desclen;
4721         payload_len -= desclen;
4722 
4723         /* offset points to the start of the mode page */
4724         while ((payload_len > 0) && tvb_bytes_exist(tvb, offset, 2)) {
4725             plen = dissect_scsi_modepage(tvb, pinfo, tree, offset, cdata->itl->cmdset&SCSI_CMDSET_MASK);
4726             offset += plen;
4727             payload_len -= plen;
4728         }
4729     }
4730 }
4731 
4732 static void
dissect_scsi_pagecode(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,scsi_task_data_t * cdata)4733 dissect_scsi_pagecode(tvbuff_t *tvb, packet_info *pinfo _U_,
4734                       proto_tree *tree, guint offset,
4735                       scsi_task_data_t *cdata)
4736 {
4737     guint8 pcode;
4738     int    hf_pagecode;
4739 
4740     /* unless we have cdata there is not much point in continuing */
4741     if (!cdata)
4742         return;
4743 
4744     pcode = tvb_get_guint8(tvb, offset);
4745     if (try_val_to_str(pcode & SCSI_MS_PCODE_BITS,
4746                      scsi_spc_modepage_val) == NULL) {
4747         /*
4748          * This isn't a generic mode page that applies to all SCSI
4749          * device types; try to interpret it based on what we deduced,
4750          * or were told, the device type is.
4751          */
4752         switch (cdata->itl->cmdset&SCSI_CMDSET_MASK) {
4753         case SCSI_DEV_SBC:
4754             hf_pagecode = hf_scsi_sbcpagecode;
4755             break;
4756 
4757         case SCSI_DEV_SSC:
4758             hf_pagecode = hf_scsi_sscpagecode;
4759             break;
4760 
4761         case SCSI_DEV_SMC:
4762             hf_pagecode = hf_scsi_smcpagecode;
4763             break;
4764 
4765         case SCSI_DEV_CDROM:
4766             hf_pagecode = hf_scsi_mmcpagecode;
4767             break;
4768 
4769         default:
4770             hf_pagecode = hf_scsi_spc_pagecode;
4771             break;
4772         }
4773     } else {
4774         hf_pagecode = hf_scsi_spc_pagecode;
4775     }
4776     proto_tree_add_uint(tree, hf_pagecode, tvb, offset, 1, pcode);
4777 }
4778 
4779 void
dissect_spc_modesense6(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,guint offset,gboolean isreq,gboolean iscdb,guint payload_len,scsi_task_data_t * cdata)4780 dissect_spc_modesense6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
4781                        guint offset, gboolean isreq, gboolean iscdb,
4782                        guint payload_len, scsi_task_data_t *cdata)
4783 {
4784     guint8    flags;
4785     guint     plen;
4786     gint      tot_len, desclen;
4787     tvbuff_t *blockdesc_tvb;
4788 
4789     if (!tree)
4790         return;
4791 
4792     if (isreq && iscdb) {
4793         flags = tvb_get_guint8(tvb, offset);
4794         proto_tree_add_uint_format(tree, hf_scsi_modesns_flags, tvb, offset, 1,
4795                                    flags, "DBD = %u", flags & 0x8);
4796         proto_tree_add_item(tree, hf_scsi_modesns_pc, tvb, offset+1, 1, ENC_BIG_ENDIAN);
4797         dissect_scsi_pagecode(tvb, pinfo, tree, offset+1, cdata);
4798         proto_tree_add_item(tree, hf_scsi_alloclen, tvb, offset+3, 1, ENC_BIG_ENDIAN);
4799         proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control,
4800                                ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
4801     }
4802     else {
4803         /* Mode sense response has the following format:
4804          * Mode Parameter Header
4805          *    - Mode Data Len, Medium Type, Dev Specific Parameter,
4806          *      Blk Desc Len
4807          * Block Descriptor (s)
4808          *    - Number of blocks, density code, block length
4809          * Page (s)
4810          *    - Page code, Page length, Page Parameters
4811          */
4812         tot_len = tvb_get_guint8(tvb, offset);
4813         proto_tree_add_item(tree, hf_scsi_modesel_mode_data_length8, tvb, offset, 1, ENC_BIG_ENDIAN);
4814         offset += 1;
4815 
4816         /* The actual payload is the min of the length in the response & the
4817          * space allocated by the initiator as specified in the request.
4818          *
4819          * XXX - the payload length includes the length field, so we
4820          * really should subtract the length of the length field from
4821          * the payload length - but can it really be zero here?
4822          */
4823         if (payload_len && (tot_len > (gint)payload_len))
4824             tot_len = payload_len;
4825 
4826         if (tot_len < 1)
4827             return;
4828         proto_tree_add_item(tree, hf_scsi_modesel_medium_type, tvb, offset, 1, ENC_BIG_ENDIAN);
4829         offset += 1;
4830         tot_len -= 1;
4831 
4832         if (tot_len < 1)
4833             return;
4834         proto_tree_add_item(tree, hf_scsi_modesel_device_specific_parameter, tvb, offset, 1, ENC_BIG_ENDIAN);
4835         offset += 1;
4836         tot_len -= 1;
4837 
4838         if (tot_len < 1)
4839             return;
4840         desclen = tvb_get_guint8(tvb, offset);
4841         proto_tree_add_item(tree, hf_scsi_modesel_block_descriptor_length8, tvb, offset, 1, ENC_BIG_ENDIAN);
4842         offset += 1;
4843         tot_len -= 1;
4844 
4845 
4846         if (tvb_reported_length_remaining(tvb, offset)>0) {
4847             blockdesc_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN(tvb_reported_length_remaining(tvb, offset),desclen), desclen);
4848             dissect_scsi_blockdescs(blockdesc_tvb, pinfo, tree, cdata, FALSE);
4849         }
4850         offset += desclen;
4851         tot_len -= desclen;
4852 
4853         /* offset points to the start of the mode page */
4854         while ((tot_len > 0) && tvb_bytes_exist(tvb, offset, 2)) {
4855             plen = dissect_scsi_modepage(tvb, pinfo, tree, offset, cdata->itl->cmdset&SCSI_CMDSET_MASK);
4856             offset += plen;
4857             tot_len -= plen;
4858         }
4859     }
4860 }
4861 
4862 void
dissect_spc_modesense10(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,guint offset,gboolean isreq,gboolean iscdb,guint payload_len,scsi_task_data_t * cdata)4863 dissect_spc_modesense10(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
4864                         guint offset, gboolean isreq, gboolean iscdb,
4865                         guint payload_len, scsi_task_data_t *cdata)
4866 {
4867     guint8    flags;
4868     gboolean  longlba;
4869     gint      tot_len, desclen;
4870     guint     plen;
4871     tvbuff_t *blockdesc_tvb;
4872 
4873     if (!tree)
4874         return;
4875 
4876     if (isreq && iscdb) {
4877         flags = tvb_get_guint8(tvb, offset);
4878         proto_tree_add_uint_format(tree, hf_scsi_modesns_flags, tvb, offset, 1,
4879                                    flags, "LLBAA = %u, DBD = %u", flags & 0x10,
4880                                    flags & 0x8);
4881         proto_tree_add_item(tree, hf_scsi_modesns_pc, tvb, offset+1, 1, ENC_BIG_ENDIAN);
4882         dissect_scsi_pagecode(tvb, pinfo, tree, offset+1, cdata);
4883         proto_tree_add_item(tree, hf_scsi_alloclen16, tvb, offset+6, 2, ENC_BIG_ENDIAN);
4884         proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control,
4885                                ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
4886     }
4887     else {
4888         /* Mode sense response has the following format:
4889          * Mode Parameter Header
4890          *    - Mode Data Len, Medium Type, Dev Specific Parameter,
4891          *      Blk Desc Len
4892          * Block Descriptor (s)
4893          *    - Number of blocks, density code, block length
4894          * Page (s)
4895          *    - Page code, Page length, Page Parameters
4896          */
4897         tot_len = tvb_get_ntohs(tvb, offset);
4898         proto_tree_add_item(tree, hf_scsi_modesel_mode_data_length16, tvb, offset, 2, ENC_BIG_ENDIAN);
4899         offset += 2;
4900         /* The actual payload is the min of the length in the response & the
4901          * space allocated by the initiator as specified in the request.
4902          *
4903          * XXX - the payload length includes the length field, so we
4904          * really should subtract the length of the length field from
4905          * the payload length - but can it really be zero here?
4906          */
4907         if (payload_len && (tot_len > (gint)payload_len))
4908             tot_len = payload_len;
4909 
4910         if (tot_len < 1)
4911             return;
4912         proto_tree_add_item(tree, hf_scsi_modesel_medium_type, tvb, offset, 1, ENC_BIG_ENDIAN);
4913         offset += 1;
4914         tot_len -= 1;
4915 
4916         if (tot_len < 1)
4917             return;
4918         proto_tree_add_item(tree, hf_scsi_modesel_device_specific_parameter, tvb, offset, 1, ENC_BIG_ENDIAN);
4919         offset += 1;
4920         tot_len -= 1;
4921 
4922         if (tot_len < 1)
4923             return;
4924         longlba = tvb_get_guint8(tvb, offset) & 0x1;
4925         proto_tree_add_item(tree, hf_scsi_modesel_longlba, tvb, offset, 1, ENC_BIG_ENDIAN);
4926         offset += 2;    /* skip LongLBA byte and reserved byte */
4927         tot_len -= 2;
4928 
4929         if (tot_len < 2)
4930             return;
4931         desclen = tvb_get_ntohs(tvb, offset);
4932         proto_tree_add_item(tree, hf_scsi_modesel_block_descriptor_length16, tvb, offset, 2, ENC_BIG_ENDIAN);
4933         offset += 2;
4934         tot_len -= 2;
4935 
4936         if (tvb_reported_length_remaining(tvb, offset)>0) {
4937             blockdesc_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN(tvb_reported_length_remaining(tvb, offset),desclen), desclen);
4938             dissect_scsi_blockdescs(blockdesc_tvb, pinfo, tree, cdata, longlba);
4939         }
4940         offset += desclen;
4941         tot_len -= desclen;
4942 
4943         /* offset points to the start of the mode page */
4944         while ((tot_len > 0) && tvb_bytes_exist(tvb, offset, 2)) {
4945             plen = dissect_scsi_modepage(tvb, pinfo, tree, offset, cdata->itl->cmdset&SCSI_CMDSET_MASK);
4946             offset += plen;
4947             tot_len -= plen;
4948         }
4949     }
4950 }
4951 
4952 void
dissect_spc_preventallowmediaremoval(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,gboolean isreq,gboolean iscdb,guint payload_len _U_,scsi_task_data_t * cdata _U_)4953 dissect_spc_preventallowmediaremoval(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
4954                                      guint offset, gboolean isreq, gboolean iscdb,
4955                                      guint payload_len _U_, scsi_task_data_t *cdata _U_)
4956 {
4957     if (isreq && iscdb) {
4958         static int * const prevent_allow_fields[] = {
4959             &hf_scsi_prevent_allow_prevent,
4960             NULL
4961         };
4962         guint8 flags;
4963 
4964         proto_tree_add_bitmask(tree, tvb, offset + 3, hf_scsi_prevent_allow_flags,
4965             ett_scsi_prevent_allow, prevent_allow_fields, ENC_BIG_ENDIAN);
4966 
4967         flags = tvb_get_guint8(tvb, offset + 3);
4968         if (flags & 0x01) {
4969             col_append_str(pinfo->cinfo, COL_INFO, " PREVENT");
4970         } else {
4971             col_append_str(pinfo->cinfo, COL_INFO, " ALLOW");
4972         }
4973 
4974         proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control,
4975                                ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
4976     }
4977 }
4978 
4979 void
dissect_spc_persistentreservein(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,gboolean isreq,gboolean iscdb,guint payload_len,scsi_task_data_t * cdata)4980 dissect_spc_persistentreservein(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
4981                                 guint offset, gboolean isreq, gboolean iscdb,
4982                                 guint payload_len, scsi_task_data_t *cdata)
4983 {
4984     guint16 flags;
4985     int     numrec, i;
4986     guint   len;
4987 
4988     if (!tree)
4989         return;
4990 
4991     if (isreq && iscdb) {
4992         proto_tree_add_item(tree, hf_scsi_persresvin_svcaction, tvb, offset, 1, ENC_BIG_ENDIAN);
4993         proto_tree_add_item(tree, hf_scsi_alloclen16, tvb, offset+6, 2, ENC_BIG_ENDIAN);
4994         proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control,
4995                                ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
4996         /* We store the service action since we want to interpret the data */
4997         cdata->itlq->flags = tvb_get_guint8(tvb, offset);
4998     }
4999     else {
5000         if (cdata) {
5001             flags = cdata->itlq->flags;
5002         }
5003         else {
5004             flags = 0xFF;
5005         }
5006         proto_tree_add_item(tree, hf_scsi_persresvin_generation_number, tvb, offset, 4, ENC_BIG_ENDIAN);
5007         len = tvb_get_ntohl(tvb, offset+4);
5008         proto_tree_add_item(tree, hf_scsi_persresvin_additional_length, tvb, offset+4, 4, ENC_BIG_ENDIAN);
5009         len = (payload_len > len) ? len : payload_len;
5010 
5011         if ((flags & 0x1F) == SCSI_SPC_RESVIN_SVCA_RDKEYS) {
5012             /* XXX - what if len is < 8?  That may be illegal, but
5013                that doesn't make it impossible.... */
5014             numrec = len / 8;
5015             offset += 8;
5016 
5017             for (i = 0; i < numrec; i++) {
5018                 proto_tree_add_item(tree, hf_scsi_persresv_key, tvb, offset,
5019                                     8, ENC_NA);
5020                 offset += 8;
5021             }
5022         }
5023         else if ((flags & 0x1F) == SCSI_SPC_RESVIN_SVCA_RDRESV && len) {
5024             proto_tree_add_item(tree, hf_scsi_persresv_key, tvb, offset+8,
5025                                 8, ENC_NA);
5026             proto_tree_add_item(tree, hf_scsi_persresv_scopeaddr, tvb,
5027                                 offset+16, 4, ENC_NA);
5028             proto_tree_add_item(tree, hf_scsi_persresv_scope, tvb, offset+21,
5029                                 1, ENC_BIG_ENDIAN);
5030             proto_tree_add_item(tree, hf_scsi_persresv_type, tvb, offset+21,
5031                                 1, ENC_BIG_ENDIAN);
5032         }
5033     }
5034 }
5035 
5036 void
dissect_spc_persistentreserveout(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,gboolean isreq,gboolean iscdb,guint payload_len _U_,scsi_task_data_t * cdata _U_)5037 dissect_spc_persistentreserveout(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
5038                                  guint offset, gboolean isreq, gboolean iscdb,
5039                                  guint payload_len _U_, scsi_task_data_t *cdata _U_)
5040 {
5041     guint8 svcaction;
5042 
5043     if (!tree)
5044         return;
5045 
5046     if (isreq && iscdb) {
5047         svcaction = tvb_get_guint8(tvb, offset) & 0x1F;
5048         proto_tree_add_item(tree, hf_scsi_persresvout_svcaction, tvb, offset, 1, ENC_BIG_ENDIAN);
5049         /* type and scope are ignored for REGISTER, REGISTER AND IGNORE EXISTING KEY, CLEAR service actions */
5050         if (svcaction != SCSI_PR_REGISTER && svcaction != SCSI_PR_REG_IGNORE && svcaction != SCSI_PR_CLEAR) {
5051             proto_tree_add_item(tree, hf_scsi_persresv_scope, tvb, offset+1, 1, ENC_BIG_ENDIAN);
5052             proto_tree_add_item(tree, hf_scsi_persresv_type, tvb, offset+1, 1, ENC_BIG_ENDIAN);
5053         }
5054         proto_tree_add_item(tree, hf_scsi_paramlen16, tvb, offset+4, 4, ENC_BIG_ENDIAN);
5055         proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control,
5056                                ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
5057         /* We store the service action since we want to interpret the params */
5058         cdata->itlq->flags = tvb_get_guint8(tvb, offset);
5059     }
5060     else if (isreq && !iscdb) {
5061         proto_tree_add_item(tree, hf_scsi_persresvout_reskey, tvb, offset,
5062                             8, ENC_NA);
5063         proto_tree_add_item(tree, hf_scsi_persresvout_sareskey, tvb,
5064                             offset +8, 8, ENC_NA);
5065         if (cdata->itlq->flags == 0x07) {
5066             /* Service action REGISTER AND MOVE */
5067             static int * const persresv_fields[] = {
5068                 &hf_scsi_persresv_control_rsvd,
5069                 &hf_scsi_persresv_control_unreg,
5070                 &hf_scsi_persresv_control_aptpl,
5071                 NULL
5072             };
5073             guint32 tid_len = tvb_get_ntohl(tvb, offset+20);
5074 
5075             proto_tree_add_item(tree, hf_scsi_persresvout_obsolete, tvb,
5076                                 offset+16, 1, ENC_NA);
5077             proto_tree_add_bitmask(tree, tvb, offset+17,
5078                                    hf_scsi_persresvout_control, ett_persresv_control,
5079                                    persresv_fields, ENC_BIG_ENDIAN);
5080             proto_tree_add_item(tree, hf_scsi_persresvout_rel_tpi, tvb,
5081                                 offset+18, 2, ENC_BIG_ENDIAN);
5082             proto_tree_add_item(tree, hf_scsi_persresvout_transportid_len, tvb,
5083                                 offset+20, 4, ENC_BIG_ENDIAN);
5084             proto_tree_add_item(tree, hf_scsi_persresvout_transportid, tvb,
5085                                 offset+24, tid_len, ENC_NA);
5086         }
5087         else {
5088             /* Other service actions than REGISTER AND MOVE. */
5089             static int * const persresv_fields[] = {
5090                 &hf_scsi_persresv_control_rsvd1,
5091                 &hf_scsi_persresv_control_spec_i_pt,
5092                 &hf_scsi_persresv_control_all_tg_pt,
5093                 &hf_scsi_persresv_control_rsvd2,
5094                 &hf_scsi_persresv_control_aptpl,
5095                 NULL
5096             };
5097 
5098             proto_tree_add_item(tree, hf_scsi_persresvout_obsolete, tvb,
5099                                 offset+16, 4, ENC_NA);
5100             proto_tree_add_bitmask(tree, tvb, offset+20,
5101                                    hf_scsi_persresvout_control, ett_persresv_control,
5102                                    persresv_fields, ENC_BIG_ENDIAN);
5103         }
5104     }
5105     else {
5106     }
5107 }
5108 
5109 void
dissect_spc_release6(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,gboolean isreq,gboolean iscdb,guint payload_len _U_,scsi_task_data_t * cdata _U_)5110 dissect_spc_release6(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
5111                      guint offset, gboolean isreq, gboolean iscdb,
5112                      guint payload_len _U_, scsi_task_data_t *cdata _U_)
5113 {
5114     if (!tree)
5115         return;
5116 
5117     if (isreq && iscdb) {
5118         proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control,
5119                                ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
5120     }
5121 }
5122 
5123 void
dissect_spc_release10(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,gboolean isreq,gboolean iscdb,guint payload_len _U_,scsi_task_data_t * cdata _U_)5124 dissect_spc_release10(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
5125                       guint offset, gboolean isreq, gboolean iscdb,
5126                       guint payload_len _U_, scsi_task_data_t *cdata _U_)
5127 {
5128     guint8 flags;
5129 
5130     if (!tree)
5131         return;
5132 
5133     if (isreq && iscdb) {
5134         flags = tvb_get_guint8(tvb, offset);
5135         proto_tree_add_uint_format(tree, hf_scsi_release_flags, tvb, offset, 1,
5136                                    flags,
5137                                    "Flags: 3rd Party ID = %u, LongID = %u",
5138                                    flags & 0x10, flags & 0x2);
5139         if ((flags & 0x12) == 0x10) {
5140             proto_tree_add_item(tree, hf_scsi_release_thirdpartyid, tvb,
5141                                 offset+2, 1, ENC_NA);
5142         }
5143         proto_tree_add_item(tree, hf_scsi_paramlen16, tvb, offset+6, 2, ENC_BIG_ENDIAN);
5144         proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control,
5145                                ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
5146     }
5147 }
5148 
5149 static void
dissect_spc_reportdeviceidentifier(tvbuff_t * tvb _U_,packet_info * pinfo _U_,proto_tree * tree _U_,guint offset _U_,gboolean isreq _U_,gboolean iscdb _U_,guint payload_len _U_,scsi_task_data_t * cdata _U_)5150 dissect_spc_reportdeviceidentifier(tvbuff_t *tvb _U_, packet_info *pinfo _U_,
5151                                    proto_tree *tree _U_,
5152                                    guint offset _U_, gboolean isreq _U_, gboolean iscdb _U_,
5153                                    guint payload_len _U_, scsi_task_data_t *cdata _U_)
5154 {
5155 
5156 }
5157 
5158 void
dissect_scsi_lun(proto_tree * tree,tvbuff_t * tvb,guint offset)5159 dissect_scsi_lun(proto_tree *tree, tvbuff_t *tvb, guint offset) {
5160     proto_item *ti;
5161     proto_tree *tt, *tl = proto_tree_add_subtree(tree, tvb, offset, 8, ett_scsi_lun, &ti, "LUN");
5162     guint8 address_mode, lun_len = 0, ea_code = 0, len_code = 0, lun_count = 0, complex_lun = 0;
5163     guint16 lun = 0;
5164     const gchar *str = NULL;
5165 
5166     if (tvb_get_ntoh48(tvb, offset) << 16) {
5167         /* Pedantically change LUN to LUNs */
5168         proto_item_append_text(tl, "s");
5169         complex_lun = 1;
5170     }
5171 
5172     while (lun_len < 8) {
5173         lun = tvb_get_ntohs(tvb, offset + lun_len);
5174         /* Don't skip the first non-zero LUN */
5175         if (lun_len && !lun)
5176             break;
5177 
5178         address_mode = tvb_get_guint8(tvb, offset + lun_len);
5179         if ((address_mode >> 6) < 0x3)
5180             len_code = 2;
5181         else {
5182             len_code = (address_mode & 0x30) >> 4;
5183             len_code = 2 + (len_code * 2);
5184         }
5185 
5186         if (complex_lun) {
5187             /* Add lun subtrees only for complex luns */
5188             tt = proto_tree_add_subtree(tl, tvb, offset + lun_len, len_code, ett_scsi_lun_unit, &ti, "LUN");
5189             proto_item_append_text(tt, " %d", lun_count++);
5190         } else
5191             tt = tl;
5192 
5193         /* Peripheral and Simple logical unit addressing share the same identifier, with bus defining the difference */
5194         if (!address_mode)
5195             proto_tree_add_uint_format_value(tt, hf_scsi_lun_address_mode, tvb, offset + lun_len, 1, (address_mode >> 6),
5196                                              "Simple logical unit addressing (0x0%x)", address_mode >> 6);
5197         else
5198             proto_tree_add_item(tt, hf_scsi_lun_address_mode, tvb, offset + lun_len, 1, ENC_BIG_ENDIAN);
5199 
5200         switch (address_mode >> 6) {
5201         case 0:
5202             /*  Simple logical unit addressing method has no bus id */
5203             if (address_mode) {
5204                 proto_tree_add_bits_item(tt, hf_scsi_bus, tvb, (offset + lun_len) * 8 + 2, 0x6, ENC_BIG_ENDIAN);
5205                 lun = tvb_get_guint8(tvb, offset + lun_len + 1);
5206                 proto_tree_add_uint(tt, hf_scsi_lun, tvb, offset + lun_len + 1, 1, lun);
5207             } else {
5208                 proto_tree_add_bits_item(tt, hf_scsi_lun, tvb, (offset + lun_len) * 8 + 2, 0xe, ENC_BIG_ENDIAN);
5209             }
5210             lun_len += len_code;
5211             break;
5212 
5213         case 1:
5214             proto_tree_add_bits_item(tt, hf_scsi_lun, tvb, (offset + lun_len) * 8 + 2, 0xe, ENC_BIG_ENDIAN);
5215             lun_len += len_code;
5216             break;
5217         case 2:
5218             proto_tree_add_item(tt, hf_scsi_target, tvb, offset + lun_len, 1, ENC_BIG_ENDIAN);
5219             proto_tree_add_bits_item(tt, hf_scsi_bus, tvb, (offset + lun_len + 1) * 8, 0x3, ENC_BIG_ENDIAN);
5220             proto_tree_add_bits_item(tt, hf_scsi_lun, tvb, (offset + lun_len + 1) * 8 + 3, 0x5, ENC_BIG_ENDIAN);
5221             lun_len += len_code;
5222             break;
5223         case 3:
5224             ea_code = address_mode & 0xf;
5225             lun = len_code;
5226             len_code = (address_mode & 0x30) >> 4;
5227 
5228             ti = proto_tree_add_item(tt, hf_scsi_extended_add_method_len, tvb, offset + lun_len, 1, ENC_BIG_ENDIAN);
5229             proto_item_append_text(ti, " (%d bytes)", lun);
5230 
5231             ti = proto_tree_add_item(tt, hf_scsi_extended_add_method, tvb, offset + lun_len, 1, ENC_BIG_ENDIAN);
5232 
5233             str = NULL;
5234             switch(ea_code) {
5235             case 0x1:
5236                 if (!len_code) {
5237                     str = "Well known logical unit";
5238                     proto_tree_add_item(tt, hf_scsi_lun, tvb, offset + lun_len + 1, 1, ENC_BIG_ENDIAN);
5239                 }
5240                 break;
5241             case 0x2:
5242                 if (len_code == 0x1)
5243                     str = "Extended flat space addressing";
5244                 else if (len_code == 0x2)
5245                     str = "Long extended flat space addressing";
5246                 if (str)
5247                     proto_tree_add_item(tt, hf_scsi_lun_extended, tvb, offset + lun_len + 1, lun - 1, ENC_BIG_ENDIAN);
5248                 break;
5249             case 0xe:
5250                 if (len_code == 0x3)
5251                     str = "Reserved for FC-SB-5";
5252                 break;
5253             case 0xf:
5254                 /* The contents of all hierarchical LUN structure addressing fields following a logical unit not specified addressing
5255                  * method addressing field shall be ignored. [SAM5] 4.7.7.5.4 */
5256                 if (len_code == 0x3) {
5257                     proto_item_append_text(ti, " (Logical unit not specified)");
5258                     return;
5259                 }
5260                 break;
5261             default:
5262                 str = "Reserved";
5263                 break;
5264             }
5265 
5266             len_code = (guint8)lun;
5267             if (!str)
5268                 str = "Reserved";
5269 
5270             proto_item_append_text(ti, " (%s)", str);
5271             lun_len += len_code;
5272             break;
5273 
5274         default:
5275             break;
5276         }
5277     }
5278 }
5279 
5280 void
dissect_spc_reportluns(tvbuff_t * tvb_a,packet_info * pinfo _U_,proto_tree * tree,guint offset_a,gboolean isreq,gboolean iscdb,guint payload_len _U_,scsi_task_data_t * cdata _U_)5281 dissect_spc_reportluns(tvbuff_t *tvb_a, packet_info *pinfo _U_,
5282                        proto_tree *tree, guint offset_a,
5283                        gboolean isreq, gboolean iscdb, guint payload_len _U_,
5284                        scsi_task_data_t *cdata _U_)
5285 {
5286     gint               listlen;
5287 
5288     if (isreq && iscdb) {
5289         proto_tree_add_item(tree, hf_scsi_select_report, tvb_a, offset_a+1, 1, ENC_BIG_ENDIAN);
5290         proto_tree_add_item(tree, hf_scsi_alloclen32, tvb_a, offset_a+5, 4, ENC_BIG_ENDIAN);
5291         if (cdata) {
5292             cdata->itlq->alloc_len = tvb_get_ntohl(tvb_a, offset_a+5);
5293         }
5294         proto_tree_add_bitmask(tree, tvb_a, offset_a+10, hf_scsi_control,
5295                                ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
5296     } else if (!isreq) {
5297         if (!cdata) {
5298             return;
5299         }
5300 
5301         TRY_SCSI_CDB_ALLOC_LEN(cdata->itlq->alloc_len);  /* (defines/initializes try_tvb & try_offset) */
5302         listlen = tvb_get_ntohl(try_tvb, try_offset);
5303         proto_tree_add_item(tree, hf_scsi_reportluns_lun_list_length, try_tvb, try_offset, 4, ENC_BIG_ENDIAN);
5304         try_offset += 8;
5305 
5306         while(listlen>0) {
5307             dissect_scsi_lun(tree, try_tvb, try_offset);
5308             try_offset+=8;
5309             listlen-=8;
5310         }
5311         END_TRY_SCSI_CDB_ALLOC_LEN;
5312     }
5313 }
5314 
5315 static const value_string mpi_action_vals[] = {
5316     {MPI_MANAGEMENT_PROTOCOL_IN           , "Management Protocol In"},
5317     {MPI_REPORT_SUPPORTED_OPERATION_CODES , "Report Supported Opcodes"},
5318     {0, NULL}
5319 };
5320 
5321 static const value_string report_opcodes_options_vals[] = {
5322     {0, "Report ALL opcodes"},
5323     {1, "Report ONE opcode, NO service action"},
5324     {2, "Report ONE opcode, WITH service action"},
5325     {0, NULL}
5326 };
5327 
5328 void
dissect_spc_mgmt_protocol_in(tvbuff_t * tvb_a,packet_info * pinfo _U_,proto_tree * tree,guint offset_a,gboolean isreq,gboolean iscdb,guint payload_len _U_,scsi_task_data_t * cdata _U_)5329 dissect_spc_mgmt_protocol_in(tvbuff_t *tvb_a, packet_info *pinfo _U_,
5330                  proto_tree *tree, guint offset_a,
5331                  gboolean isreq, gboolean iscdb,
5332                  guint payload_len _U_,
5333                  scsi_task_data_t *cdata _U_)
5334 {
5335     guint8             service_action;
5336 
5337     if (isreq && iscdb) {
5338         service_action = tvb_get_guint8 (tvb_a, offset_a) & 0x1F;
5339     if (cdata) {
5340         cdata->itlq->flags=service_action;
5341     }
5342     col_append_str(pinfo->cinfo, COL_INFO,
5343             val_to_str(service_action, mpi_action_vals, "Unknown"));
5344 
5345     proto_tree_add_item(tree, hf_scsi_mpi_service_action, tvb_a,
5346             offset_a, 1, ENC_BIG_ENDIAN);
5347 
5348     switch(service_action){
5349         case MPI_REPORT_SUPPORTED_OPERATION_CODES:
5350             proto_tree_add_item(tree, hf_scsi_report_opcodes_rctd,
5351                     tvb_a, offset_a+1, 1, ENC_BIG_ENDIAN);
5352             proto_tree_add_item(tree, hf_scsi_report_opcodes_options,
5353                     tvb_a, offset_a+1, 1, ENC_BIG_ENDIAN);
5354             if (cdata && (tvb_get_guint8(tvb_a, offset_a+1) & 0x07)) {
5355                 /* Need the one-command parameter format */
5356                 cdata->itlq->flags|=0x80;
5357             }
5358 
5359             proto_tree_add_item(tree, hf_scsi_report_opcodes_requested_o,
5360                     tvb_a, offset_a+2, 1, ENC_BIG_ENDIAN);
5361             proto_tree_add_item(tree, hf_scsi_report_opcodes_requested_sa,
5362                     tvb_a, offset_a+3, 2, ENC_BIG_ENDIAN);
5363 
5364             proto_tree_add_item(tree, hf_scsi_alloclen32, tvb_a,
5365                     offset_a+5, 4, ENC_BIG_ENDIAN);
5366             if (cdata) {
5367                 cdata->itlq->alloc_len = tvb_get_ntohl(tvb_a, offset_a+5);
5368             }
5369             break;
5370         default:
5371             proto_tree_add_expert(tree, pinfo, &ei_scsi_no_dissection_for_service_action, tvb_a, offset_a+1, 8);
5372     }
5373 
5374     proto_tree_add_bitmask(tree, tvb_a, offset_a+10, hf_scsi_control,
5375             ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
5376 
5377     } else if (!isreq) {
5378         proto_item *it;
5379         int length;
5380         cmdset_t *csdata;
5381         int ctdp;
5382 
5383         if (!cdata || !cdata->itlq || !cdata->itl) {
5384             return;
5385         }
5386 
5387         csdata = get_cmdset_data(pinfo->pool, cdata->itlq, cdata->itl);
5388 
5389         it = proto_tree_add_uint(tree, hf_scsi_mpi_service_action, tvb_a, 0, 0, cdata->itlq->flags & 0x7f);
5390         proto_item_set_generated(it);
5391 
5392         TRY_SCSI_CDB_ALLOC_LEN(cdata->itlq->alloc_len);  /* (defines/initializes try_tvb & try_offset) */
5393 
5394         switch (cdata->itlq->flags & 0x7f) {
5395             case MPI_REPORT_SUPPORTED_OPERATION_CODES:
5396                 if (cdata->itlq->flags & 0x80) {
5397                     /* one-command format */
5398                     proto_tree_add_item(tree, hf_scsi_report_opcodes_ctdp_one,
5399                             try_tvb, try_offset+1, 1, ENC_BIG_ENDIAN);
5400                     ctdp = tvb_get_guint8(try_tvb, try_offset+1) & 0x80;
5401 
5402                     proto_tree_add_item(tree, hf_scsi_report_opcodes_support,
5403                             try_tvb, try_offset+1, 1, ENC_BIG_ENDIAN);
5404 
5405                     proto_tree_add_item(tree, hf_scsi_report_opcodes_cdb_length,
5406                             try_tvb, try_offset+2, 2, ENC_BIG_ENDIAN);
5407                     length = tvb_get_ntohs(try_tvb, try_offset+2);
5408 
5409                     proto_tree_add_item(tree, hf_scsi_report_opcodes_cdb_usage_data,
5410                             try_tvb, try_offset+4, length, ENC_NA);
5411 
5412                     if (ctdp) {
5413                         proto_tree *tr;
5414 
5415                         tr = proto_tree_add_subtree(tree, try_tvb, try_offset,
5416                                 12, ett_timeout_descriptor, NULL, "Timeout Descriptor");
5417 
5418                         proto_tree_add_item(tr, hf_scsi_report_opcodes_tdl,
5419                                 try_tvb, try_offset, 2, ENC_BIG_ENDIAN);
5420 
5421                         proto_tree_add_item(tr, hf_scsi_report_opcodes_npt,
5422                                 try_tvb, try_offset + 4, 4, ENC_BIG_ENDIAN);
5423 
5424                         proto_tree_add_item(tr, hf_scsi_report_opcodes_rct,
5425                                 try_tvb, try_offset + 8, 4, ENC_BIG_ENDIAN);
5426                     }
5427                 } else {
5428                     /* all commands format */
5429                     proto_tree_add_item(tree, hf_scsi_report_opcodes_cdl,
5430                             try_tvb, try_offset+0, 4, ENC_BIG_ENDIAN);
5431                     length = tvb_get_ntohl(try_tvb, try_offset);
5432                     try_offset += 4;
5433 
5434                     while (length >= 20) {
5435                         proto_tree *tr;
5436 
5437                         tr = proto_tree_add_subtree_format(tree, try_tvb, try_offset,
5438                                 20, ett_command_descriptor, NULL, "Command Descriptor: %s",
5439                                 val_to_str_ext_const(tvb_get_guint8(try_tvb, try_offset+0), csdata->cdb_vals_ext, "Unknown"));
5440 
5441                         proto_tree_add_item(tr, csdata->hf_opcode,
5442                                 try_tvb, try_offset+0, 1, ENC_BIG_ENDIAN);
5443 
5444                         proto_tree_add_item(tr, hf_scsi_report_opcodes_sa,
5445                                 try_tvb, try_offset+2, 2, ENC_BIG_ENDIAN);
5446 
5447                         proto_tree_add_item(tr, hf_scsi_report_opcodes_ctdp,
5448                                 try_tvb, try_offset+5, 1, ENC_BIG_ENDIAN);
5449                         ctdp = tvb_get_guint8(try_tvb, try_offset+5) & 0x02;
5450 
5451                         proto_tree_add_item(tr, hf_scsi_report_opcodes_servactv,
5452                                 try_tvb, try_offset+5, 1, ENC_BIG_ENDIAN);
5453 
5454                         proto_tree_add_item(tr, hf_scsi_report_opcodes_cdb_length,
5455                                 try_tvb, try_offset+6, 2, ENC_BIG_ENDIAN);
5456 
5457                         try_offset += 8;
5458                         length -= 8;
5459 
5460                         if (!ctdp) {
5461                             continue;
5462                         }
5463 
5464                         tr = proto_tree_add_subtree(tree, try_tvb, try_offset,
5465                                 12, ett_timeout_descriptor, NULL, "Timeout Descriptor");
5466 
5467                         proto_tree_add_item(tr, hf_scsi_report_opcodes_tdl,
5468                                 try_tvb, try_offset, 2, ENC_BIG_ENDIAN);
5469 
5470                         proto_tree_add_item(tr, hf_scsi_report_opcodes_npt,
5471                                 try_tvb, try_offset + 4, 4, ENC_BIG_ENDIAN);
5472 
5473                         proto_tree_add_item(tr, hf_scsi_report_opcodes_rct,
5474                                 try_tvb, try_offset + 8, 4, ENC_BIG_ENDIAN);
5475 
5476                         try_offset += 12;
5477                         length -= 12;
5478 
5479                     }
5480                 }
5481                 break;
5482             default:
5483                 proto_tree_add_expert(tree, pinfo, &ei_scsi_no_dissection_for_service_action, try_tvb, try_offset+1, 8);
5484         }
5485 
5486         END_TRY_SCSI_CDB_ALLOC_LEN;
5487     }
5488 }
5489 
5490 static void
dissect_scsi_sns_specific_info(tvbuff_t * tvb,proto_tree * sns_tree,guint offset,guint8 sense_key)5491 dissect_scsi_sns_specific_info(tvbuff_t *tvb, proto_tree *sns_tree, guint offset, guint8 sense_key) {
5492  guint8 valid = tvb_get_guint8(tvb, offset)&0x80;
5493  proto_tree_add_item(sns_tree, hf_scsi_sksv, tvb, offset, 1, ENC_BIG_ENDIAN);
5494  proto_tree_add_item(sns_tree, hf_scsi_sks_info, tvb, offset, 3, ENC_BIG_ENDIAN);
5495 
5496  if (sense_key==5&&valid) {
5497     /*illegal request*/
5498     proto_tree_add_item(sns_tree, hf_scsi_sks_fp_cd, tvb, offset, 3, ENC_BIG_ENDIAN);
5499     proto_tree_add_item(sns_tree, hf_scsi_sks_fp_bpv, tvb, offset, 3, ENC_BIG_ENDIAN);
5500     proto_tree_add_item(sns_tree, hf_scsi_sks_fp_bit, tvb, offset, 3, ENC_BIG_ENDIAN);
5501     proto_tree_add_item(sns_tree, hf_scsi_sks_fp_field,  tvb, offset, 3, ENC_BIG_ENDIAN);
5502  }
5503 }
5504 
5505 static void
dissect_scsi_fix_snsinfo(tvbuff_t * tvb,proto_tree * sns_tree,guint offset)5506 dissect_scsi_fix_snsinfo(tvbuff_t *tvb, proto_tree *sns_tree, guint offset) {
5507     proto_item *hidden_item;
5508     guint8      flags;
5509 
5510     proto_tree_add_item(sns_tree, hf_scsi_sns_valid, tvb, offset, 1, ENC_BIG_ENDIAN);
5511 
5512     flags = tvb_get_guint8(tvb, offset+2);
5513     proto_tree_add_item(sns_tree, hf_scsi_sns_filemark, tvb, offset+2, 1, ENC_NA);
5514     proto_tree_add_item(sns_tree, hf_scsi_sns_eom, tvb, offset+2, 1, ENC_NA);
5515     proto_tree_add_item(sns_tree, hf_scsi_sns_ili, tvb, offset+2, 1, ENC_NA);
5516     proto_tree_add_item(sns_tree, hf_scsi_snskey, tvb, offset+2, 1, ENC_BIG_ENDIAN);
5517     proto_tree_add_item(sns_tree, hf_scsi_snsinfo, tvb, offset+3, 4, ENC_BIG_ENDIAN);
5518     proto_tree_add_item(sns_tree, hf_scsi_addlsnslen, tvb, offset+7, 1, ENC_BIG_ENDIAN);
5519     proto_tree_add_item(sns_tree, hf_scsi_sns_command_specific_information, tvb, offset+8, 4, ENC_NA);
5520     proto_tree_add_item(sns_tree, hf_scsi_ascascq, tvb, offset+12, 2, ENC_BIG_ENDIAN);
5521     hidden_item = proto_tree_add_item(sns_tree, hf_scsi_asc, tvb, offset+12, 1, ENC_BIG_ENDIAN);
5522     proto_item_set_hidden(hidden_item);
5523     hidden_item = proto_tree_add_item(sns_tree, hf_scsi_ascq, tvb, offset+13, 1, ENC_BIG_ENDIAN);
5524     proto_item_set_hidden(hidden_item);
5525     proto_tree_add_item(sns_tree, hf_scsi_fru, tvb, offset+14, 1, ENC_BIG_ENDIAN);
5526     dissect_scsi_sns_specific_info(tvb,sns_tree,offset+15,flags&0x0F);
5527 }
5528 
5529 static void
dissect_scsi_descriptor_snsinfo(tvbuff_t * tvb,proto_tree * sns_tree,guint offset)5530 dissect_scsi_descriptor_snsinfo(tvbuff_t *tvb, proto_tree *sns_tree, guint offset)
5531 {
5532     guint8  additional_length, sense_key;
5533     guint   end;
5534 
5535     proto_tree_add_item(sns_tree, hf_scsi_snskey, tvb, offset+1, 1, ENC_BIG_ENDIAN);
5536     proto_tree_add_item(sns_tree, hf_scsi_ascascq, tvb, offset+2, 2, ENC_BIG_ENDIAN);
5537     proto_tree_add_item(sns_tree, hf_scsi_addlsnslen, tvb, offset+7, 1, ENC_BIG_ENDIAN);
5538     sense_key = tvb_get_guint8(tvb, offset+1)&0xF;
5539     additional_length = tvb_get_guint8(tvb, offset+7);
5540     end = offset+7+additional_length;
5541     offset+=8;
5542     while (offset<end-2) {
5543        guint8      desc_type, desc_length, desc_end;
5544        proto_item *item;
5545        proto_tree *desc_tree;
5546 
5547        desc_type   = tvb_get_guint8(tvb, offset);
5548        desc_length = tvb_get_guint8(tvb, offset+1);
5549        desc_end    = offset+desc_length+2;
5550        desc_tree = proto_tree_add_subtree(sns_tree, tvb, offset, desc_length+2, ett_sense_descriptor, NULL,
5551                   val_to_str(desc_type, scsi_sense_desc_type_val, "Unknown (0x%02x)"));
5552        proto_tree_add_item(desc_tree, hf_scsi_sns_desc_type, tvb, offset, 1, ENC_BIG_ENDIAN);
5553        proto_tree_add_item(desc_tree, hf_scsi_sns_desc_length, tvb, offset+1, 1, ENC_BIG_ENDIAN);
5554        switch (desc_type) {
5555           case 2:
5556              /*sense key specific*/
5557              if (desc_length==6) {
5558                     dissect_scsi_sns_specific_info(tvb,desc_tree,offset+4,sense_key);
5559              }
5560              break;
5561           case 6:
5562              /*OSD object identification*/
5563              if (desc_length==0x1e) {
5564                  static int * const command_functions[] = {
5565                      &hf_scsi_sns_osd_object_validation,
5566                      &hf_scsi_sns_osd_object_cmd_cap_v,
5567                      &hf_scsi_sns_osd_object_command,
5568                      &hf_scsi_sns_osd_object_imp_st_att,
5569                      &hf_scsi_sns_osd_object_sa_cap_v,
5570                      &hf_scsi_sns_osd_object_set_att,
5571                      &hf_scsi_sns_osd_object_ga_cap_v,
5572                      &hf_scsi_sns_osd_object_get_att,
5573                      NULL
5574                  };
5575                  proto_tree_add_bitmask(desc_tree, tvb, offset+8, hf_scsi_sns_osd_object_not_initiated, ett_sense_osd_not_initiated, command_functions, ENC_BIG_ENDIAN);
5576                  proto_tree_add_bitmask(desc_tree, tvb, offset+12, hf_scsi_sns_osd_object_completed, ett_sense_osd_completed, command_functions, ENC_BIG_ENDIAN);
5577                  proto_tree_add_item(desc_tree, hf_scsi_sns_osd_partition_id, tvb, offset+16, 8, ENC_BIG_ENDIAN);
5578                  proto_tree_add_item(desc_tree, hf_scsi_sns_osd_object_id, tvb, offset+24, 8, ENC_BIG_ENDIAN);
5579              }
5580              break;
5581           case 8:
5582             /*OSD attribute identification*/
5583             offset+=4;
5584             while (offset+8<=desc_end) {
5585                 const attribute_page_numbers_t *apn;
5586                 guint32 page,number;
5587                 page=tvb_get_ntohl(tvb, offset);
5588                 proto_tree_add_item(desc_tree, hf_scsi_sns_osd_attr_page,   tvb, offset, 4, ENC_BIG_ENDIAN);
5589                 offset+=4;
5590                 number=tvb_get_ntohl(tvb, offset);
5591                 item=proto_tree_add_item(desc_tree, hf_scsi_sns_osd_attr_number, tvb, offset, 4, ENC_BIG_ENDIAN);
5592                 apn=osd_lookup_attribute(page,number);
5593                 offset+=4;
5594                 if (apn) {
5595                     proto_item_append_text(item, " (%s)", apn->name);
5596                 } else {
5597                     proto_item_append_text(item, " (Unknown)");
5598                 }
5599             }
5600           default:
5601              break;
5602        }
5603        offset += desc_length+2;
5604     }
5605 }
5606 
5607 static void
dissect_scsi_sense(tvbuff_t * tvb,proto_tree * sns_tree,guint offset)5608 dissect_scsi_sense(tvbuff_t *tvb, proto_tree *sns_tree, guint offset)
5609 {
5610     guint8 sense_type;
5611 
5612     proto_tree_add_item(sns_tree, hf_scsi_sns_errtype, tvb, offset, 1, ENC_BIG_ENDIAN);
5613     sense_type = tvb_get_guint8(tvb, offset) & 0x7f;
5614 
5615     switch (sense_type) {
5616     case 0x70:
5617     case 0x71:
5618         dissect_scsi_fix_snsinfo(tvb, sns_tree, offset);
5619         break;
5620     case 0x72:
5621     case 0x73:
5622         dissect_scsi_descriptor_snsinfo(tvb, sns_tree, offset);
5623         break;
5624     }
5625 }
5626 
5627 void
dissect_spc_requestsense(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,gboolean isreq,gboolean iscdb,guint payload_len _U_,scsi_task_data_t * cdata _U_)5628 dissect_spc_requestsense(tvbuff_t * tvb, packet_info *pinfo _U_, proto_tree *tree,
5629                          guint offset, gboolean isreq, gboolean iscdb,
5630                          guint payload_len _U_, scsi_task_data_t *cdata _U_)
5631 {
5632     if (!tree)
5633         return;
5634 
5635     if (isreq && iscdb) {
5636         proto_tree_add_item(tree, hf_scsi_alloclen, tvb, offset+3, 1, ENC_BIG_ENDIAN);
5637         proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control,
5638                                ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
5639     } else if (!isreq) {
5640         dissect_scsi_sense(tvb, tree, offset);
5641     }
5642 }
5643 
5644 void
dissect_spc_reserve6(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,gboolean isreq,gboolean iscdb,guint payload_len _U_,scsi_task_data_t * cdata _U_)5645 dissect_spc_reserve6(tvbuff_t * tvb, packet_info *pinfo _U_, proto_tree *tree,
5646                      guint offset, gboolean isreq, gboolean iscdb,
5647                      guint payload_len _U_, scsi_task_data_t *cdata _U_)
5648 {
5649     if (!tree)
5650         return;
5651 
5652     if (isreq && iscdb) {
5653         proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control,
5654                                ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
5655     }
5656 }
5657 
5658 void
dissect_spc_reserve10(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,gboolean isreq,gboolean iscdb,guint payload_len _U_,scsi_task_data_t * cdata _U_)5659 dissect_spc_reserve10(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
5660                       guint offset, gboolean isreq, gboolean iscdb,
5661                       guint payload_len _U_, scsi_task_data_t *cdata _U_)
5662 {
5663     guint8 flags;
5664 
5665     if (!tree)
5666         return;
5667 
5668     if (isreq && iscdb) {
5669         flags = tvb_get_guint8(tvb, offset);
5670         proto_tree_add_uint_format(tree, hf_scsi_release_flags, tvb, offset, 1,
5671                                    flags,
5672                                    "Flags: 3rd Party ID = %u, LongID = %u",
5673                                    flags & 0x10, flags & 0x2);
5674         if ((flags & 0x12) == 0x10) {
5675             proto_tree_add_item(tree, hf_scsi_release_thirdpartyid, tvb,
5676                                 offset+2, 1, ENC_NA);
5677         }
5678         proto_tree_add_item(tree, hf_scsi_paramlen16, tvb, offset+6, 2, ENC_BIG_ENDIAN);
5679         proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control,
5680                                ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
5681     }
5682 }
5683 
5684 void
dissect_spc_testunitready(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,gboolean isreq,gboolean iscdb,guint payload_len _U_,scsi_task_data_t * cdata _U_)5685 dissect_spc_testunitready(tvbuff_t * tvb, packet_info *pinfo _U_, proto_tree *tree,
5686                           guint offset, gboolean isreq, gboolean iscdb,
5687                           guint payload_len _U_, scsi_task_data_t *cdata _U_)
5688 {
5689 
5690     if (!tree)
5691         return;
5692 
5693     if (isreq && iscdb) {
5694         proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control,
5695                                ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
5696     }
5697 }
5698 
5699 
5700 
5701 
5702 
5703 
5704 void
dissect_spc_senddiagnostic(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,gboolean isreq,gboolean iscdb _U_,guint payload_len _U_,scsi_task_data_t * cdata _U_)5705 dissect_spc_senddiagnostic(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
5706                            guint offset, gboolean isreq, gboolean iscdb _U_,
5707                            guint payload_len _U_, scsi_task_data_t *cdata _U_)
5708 {
5709     if (!tree && !isreq)
5710         return;
5711 
5712     proto_tree_add_item(tree, hf_scsi_senddiag_st_code, tvb, offset, 1, ENC_BIG_ENDIAN);
5713     proto_tree_add_item(tree, hf_scsi_senddiag_pf, tvb, offset, 1, ENC_BIG_ENDIAN);
5714     proto_tree_add_item(tree, hf_scsi_senddiag_st, tvb, offset, 1, ENC_BIG_ENDIAN);
5715     proto_tree_add_item(tree, hf_scsi_senddiag_devoff, tvb, offset, 1, ENC_BIG_ENDIAN);
5716     proto_tree_add_item(tree, hf_scsi_senddiag_unitoff, tvb, offset, 1, ENC_BIG_ENDIAN);
5717     proto_tree_add_item(tree, hf_scsi_paramlen16, tvb, offset+2, 2, ENC_BIG_ENDIAN);
5718     proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control,
5719                            ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
5720 }
5721 
5722 void
dissect_spc_writebuffer(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,gboolean isreq,gboolean iscdb _U_,guint payload_len _U_,scsi_task_data_t * cdata _U_)5723 dissect_spc_writebuffer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
5724                         guint offset, gboolean isreq, gboolean iscdb _U_,
5725                         guint payload_len _U_, scsi_task_data_t *cdata _U_)
5726 {
5727     if (!tree && !isreq)
5728         return;
5729 
5730     proto_tree_add_item(tree, hf_scsi_wb_mode, tvb, offset, 1, ENC_BIG_ENDIAN);
5731     proto_tree_add_item(tree, hf_scsi_wb_bufferid, tvb, offset+1, 1, ENC_BIG_ENDIAN);
5732     proto_tree_add_item(tree, hf_scsi_wb_bufoffset, tvb, offset+2, 3, ENC_BIG_ENDIAN);
5733     proto_tree_add_item(tree, hf_scsi_paramlen24, tvb, offset+5, 3, ENC_BIG_ENDIAN);
5734     proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control,
5735                            ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
5736 }
5737 
5738 static void
dissect_scsi_varlencdb(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,guint offset,gboolean isreq,gboolean iscdb,guint payload_len _U_,scsi_task_data_t * cdata _U_)5739 dissect_scsi_varlencdb(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
5740                        guint offset, gboolean isreq, gboolean iscdb,
5741                        guint payload_len _U_, scsi_task_data_t *cdata _U_)
5742 {
5743     if (!tree)
5744         return;
5745 
5746     if (isreq && iscdb) {
5747         proto_tree_add_item(tree, hf_scsi_control, tvb, offset, 1, ENC_BIG_ENDIAN);
5748         proto_tree_add_item(tree, hf_scsi_add_cdblen, tvb, offset+6, 1, ENC_BIG_ENDIAN);
5749         proto_tree_add_item(tree, hf_scsi_svcaction, tvb, offset+7, 2, ENC_BIG_ENDIAN);
5750 
5751     }
5752 }
5753 
5754 void
dissect_scsi_rsp(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,itlq_nexus_t * itlq,itl_nexus_t * itl,guint8 scsi_status)5755 dissect_scsi_rsp(tvbuff_t *tvb, packet_info *pinfo,
5756                  proto_tree *tree, itlq_nexus_t *itlq, itl_nexus_t *itl,
5757                  guint8 scsi_status)
5758 {
5759     proto_item       *ti;
5760     proto_tree       *scsi_tree = NULL;
5761     cmdset_t         *csdata;
5762     scsi_task_data_t *cdata;
5763 
5764     cdata = wmem_new(pinfo->pool, scsi_task_data_t);
5765     cdata->itl = itl;
5766     cdata->itlq = itlq;
5767     cdata->type = SCSI_PDU_TYPE_RSP;
5768     tap_queue_packet(scsi_tap, pinfo, cdata);
5769 
5770     csdata = get_cmdset_data(pinfo->pool, itlq, itl);
5771 
5772     /* Nothing really to do here, just print some stuff passed to us
5773      */
5774     if (tree) {
5775         ti = proto_tree_add_protocol_format(tree, proto_scsi, tvb, 0,
5776                                             0, "SCSI Response (%s)",
5777                                             val_to_str_ext(itlq->scsi_opcode,
5778                                                            csdata->cdb_vals_ext,
5779                                                            "CDB:0x%02x"));
5780         scsi_tree = proto_item_add_subtree(ti, ett_scsi);
5781     }
5782 
5783     ti = proto_tree_add_uint(scsi_tree, hf_scsi_lun, tvb, 0, 0, itlq->lun);
5784     proto_item_set_generated(ti);
5785 
5786 
5787     if (itl) {
5788         ti = proto_tree_add_uint_format(scsi_tree, hf_scsi_inq_devtype, tvb, 0, 0, itl->cmdset&SCSI_CMDSET_MASK, "Command Set:%s (0x%02x) %s", val_to_str(itl->cmdset&SCSI_CMDSET_MASK, scsi_devtype_val, "Unknown (%d)"), itl->cmdset&SCSI_CMDSET_MASK,itl->cmdset&SCSI_CMDSET_DEFAULT?"(Using default commandset)":"");
5789         proto_item_set_generated(ti);
5790 
5791         if (itlq->scsi_opcode != 0xffff) {
5792             ti = proto_tree_add_uint(scsi_tree, csdata->hf_opcode, tvb, 0, 0, itlq->scsi_opcode);
5793             proto_item_set_generated(ti);
5794         }
5795     }
5796 
5797     if (itlq->first_exchange_frame) {
5798         nstime_t delta_time;
5799         ti = proto_tree_add_uint(scsi_tree, hf_scsi_request_frame, tvb, 0, 0, itlq->first_exchange_frame);
5800         proto_item_set_generated(ti);
5801         nstime_delta(&delta_time, &pinfo->abs_ts, &itlq->fc_time);
5802         ti = proto_tree_add_time(scsi_tree, hf_scsi_time, tvb, 0, 0, &delta_time);
5803         proto_item_set_generated(ti);
5804     }
5805 
5806     ti = proto_tree_add_uint(scsi_tree, hf_scsi_status, tvb, 0, 0, scsi_status);
5807     proto_item_set_generated(ti);
5808     col_add_fstr(pinfo->cinfo, COL_INFO, "SCSI: Response LUN: 0x%02x (%s) (%s)", itlq->lun,
5809                      val_to_str_ext(itlq->scsi_opcode, csdata->cdb_vals_ext, "CDB:0x%02x"),
5810                      val_to_str(scsi_status, scsi_status_val, "Unknown (0x%08x)"));
5811 
5812     col_set_fence(pinfo->cinfo, COL_INFO);
5813 }
5814 
5815 void
dissect_scsi_snsinfo(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,guint offset,guint snslen,itlq_nexus_t * itlq,itl_nexus_t * itl)5816 dissect_scsi_snsinfo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
5817                      guint offset, guint snslen, itlq_nexus_t *itlq, itl_nexus_t *itl)
5818 {
5819     proto_item       *ti;
5820     proto_tree       *sns_tree = NULL;
5821     const char       *old_proto;
5822     scsi_task_data_t *cdata;
5823 
5824     cdata = wmem_new(pinfo->pool, scsi_task_data_t);
5825     cdata->itl = itl;
5826     cdata->itlq = itlq;
5827     cdata->type = SCSI_PDU_TYPE_SNS;
5828     tap_queue_packet(scsi_tap, pinfo, cdata);
5829 
5830 
5831     old_proto = pinfo->current_proto;
5832     pinfo->current_proto="SCSI";
5833 
5834     if (tree) {
5835         ti = proto_tree_add_protocol_format(tree, proto_scsi, tvb, offset,
5836                                             snslen, "SCSI: SNS Info");
5837         sns_tree = proto_item_add_subtree(ti, ett_scsi);
5838     }
5839 
5840 
5841     ti = proto_tree_add_uint(sns_tree, hf_scsi_lun, tvb, 0, 0, itlq->lun);
5842     proto_item_set_generated(ti);
5843     col_append_fstr(pinfo->cinfo, COL_INFO, " LUN:0x%02x ", itlq->lun);
5844 
5845     col_set_fence(pinfo->cinfo, COL_INFO);
5846 
5847     dissect_scsi_sense(tvb, sns_tree, offset);
5848 
5849     pinfo->current_proto = old_proto;
5850 }
5851 
5852 
5853 static scsi_cdb_table_t spc[256] = {
5854     /*SPC 0x00*/{dissect_spc_testunitready},
5855     /*SPC 0x01*/{NULL},
5856     /*SPC 0x02*/{NULL},
5857     /*SPC 0x03*/{dissect_spc_requestsense},
5858     /*SPC 0x04*/{NULL},
5859     /*SPC 0x05*/{NULL},
5860     /*SPC 0x06*/{NULL},
5861     /*SPC 0x07*/{NULL},
5862     /*SPC 0x08*/{NULL},
5863     /*SPC 0x09*/{NULL},
5864     /*SPC 0x0a*/{NULL},
5865     /*SPC 0x0b*/{NULL},
5866     /*SPC 0x0c*/{NULL},
5867     /*SPC 0x0d*/{NULL},
5868     /*SPC 0x0e*/{NULL},
5869     /*SPC 0x0f*/{NULL},
5870     /*SPC 0x10*/{NULL},
5871     /*SPC 0x11*/{NULL},
5872     /*SPC 0x12*/{dissect_spc_inquiry},
5873     /*SPC 0x13*/{NULL},
5874     /*SPC 0x14*/{NULL},
5875     /*SPC 0x15*/{dissect_spc_modeselect6},
5876     /*SPC 0x16*/{dissect_spc_reserve6},
5877     /*SPC 0x17*/{dissect_spc_release6},
5878     /*SPC 0x18*/{NULL},
5879     /*SPC 0x19*/{NULL},
5880     /*SPC 0x1a*/{dissect_spc_modesense6},
5881     /*SPC 0x1b*/{NULL},
5882     /*SPC 0x1c*/{NULL},
5883     /*SPC 0x1d*/{dissect_spc_senddiagnostic},
5884     /*SPC 0x1e*/{dissect_spc_preventallowmediaremoval},
5885     /*SPC 0x1f*/{NULL},
5886     /*SPC 0x20*/{NULL},
5887     /*SPC 0x21*/{NULL},
5888     /*SPC 0x22*/{NULL},
5889     /*SPC 0x23*/{NULL},
5890     /*SPC 0x24*/{NULL},
5891     /*SPC 0x25*/{NULL},
5892     /*SPC 0x26*/{NULL},
5893     /*SPC 0x27*/{NULL},
5894     /*SPC 0x28*/{NULL},
5895     /*SPC 0x29*/{NULL},
5896     /*SPC 0x2a*/{NULL},
5897     /*SPC 0x2b*/{NULL},
5898     /*SPC 0x2c*/{NULL},
5899     /*SPC 0x2d*/{NULL},
5900     /*SPC 0x2e*/{NULL},
5901     /*SPC 0x2f*/{NULL},
5902     /*SPC 0x30*/{NULL},
5903     /*SPC 0x31*/{NULL},
5904     /*SPC 0x32*/{NULL},
5905     /*SPC 0x33*/{NULL},
5906     /*SPC 0x34*/{NULL},
5907     /*SPC 0x35*/{NULL},
5908     /*SPC 0x36*/{NULL},
5909     /*SPC 0x37*/{NULL},
5910     /*SPC 0x38*/{NULL},
5911     /*SPC 0x39*/{NULL},
5912     /*SPC 0x3a*/{NULL},
5913     /*SPC 0x3b*/{dissect_spc_writebuffer},
5914     /*SPC 0x3c*/{NULL},
5915     /*SPC 0x3d*/{NULL},
5916     /*SPC 0x3e*/{NULL},
5917     /*SPC 0x3f*/{NULL},
5918     /*SPC 0x40*/{NULL},
5919     /*SPC 0x41*/{NULL},
5920     /*SPC 0x42*/{NULL},
5921     /*SPC 0x43*/{NULL},
5922     /*SPC 0x44*/{NULL},
5923     /*SPC 0x45*/{NULL},
5924     /*SPC 0x46*/{NULL},
5925     /*SPC 0x47*/{NULL},
5926     /*SPC 0x48*/{NULL},
5927     /*SPC 0x49*/{NULL},
5928     /*SPC 0x4a*/{NULL},
5929     /*SPC 0x4b*/{NULL},
5930     /*SPC 0x4c*/{dissect_spc_logselect},
5931     /*SPC 0x4d*/{dissect_spc_logsense},
5932     /*SPC 0x4e*/{NULL},
5933     /*SPC 0x4f*/{NULL},
5934     /*SPC 0x50*/{NULL},
5935     /*SPC 0x51*/{NULL},
5936     /*SPC 0x52*/{NULL},
5937     /*SPC 0x53*/{NULL},
5938     /*SPC 0x54*/{NULL},
5939     /*SPC 0x55*/{dissect_spc_modeselect10},
5940     /*SPC 0x56*/{dissect_spc_reserve10},
5941     /*SPC 0x57*/{dissect_spc_release10},
5942     /*SPC 0x58*/{NULL},
5943     /*SPC 0x59*/{NULL},
5944     /*SPC 0x5a*/{dissect_spc_modesense10},
5945     /*SPC 0x5b*/{NULL},
5946     /*SPC 0x5c*/{NULL},
5947     /*SPC 0x5d*/{NULL},
5948     /*SPC 0x5e*/{dissect_spc_persistentreservein},
5949     /*SPC 0x5f*/{dissect_spc_persistentreserveout},
5950     /*SPC 0x60*/{NULL},
5951     /*SPC 0x61*/{NULL},
5952     /*SPC 0x62*/{NULL},
5953     /*SPC 0x63*/{NULL},
5954     /*SPC 0x64*/{NULL},
5955     /*SPC 0x65*/{NULL},
5956     /*SPC 0x66*/{NULL},
5957     /*SPC 0x67*/{NULL},
5958     /*SPC 0x68*/{NULL},
5959     /*SPC 0x69*/{NULL},
5960     /*SPC 0x6a*/{NULL},
5961     /*SPC 0x6b*/{NULL},
5962     /*SPC 0x6c*/{NULL},
5963     /*SPC 0x6d*/{NULL},
5964     /*SPC 0x6e*/{NULL},
5965     /*SPC 0x6f*/{NULL},
5966     /*SPC 0x70*/{NULL},
5967     /*SPC 0x71*/{NULL},
5968     /*SPC 0x72*/{NULL},
5969     /*SPC 0x73*/{NULL},
5970     /*SPC 0x74*/{NULL},
5971     /*SPC 0x75*/{NULL},
5972     /*SPC 0x76*/{NULL},
5973     /*SPC 0x77*/{NULL},
5974     /*SPC 0x78*/{NULL},
5975     /*SPC 0x79*/{NULL},
5976     /*SPC 0x7a*/{NULL},
5977     /*SPC 0x7b*/{NULL},
5978     /*SPC 0x7c*/{NULL},
5979     /*SPC 0x7d*/{NULL},
5980     /*SPC 0x7e*/{NULL},
5981     /*SPC 0x7f*/{dissect_scsi_varlencdb},
5982     /*SPC 0x80*/{NULL},
5983     /*SPC 0x81*/{NULL},
5984     /*SPC 0x82*/{NULL},
5985     /*SPC 0x83*/{dissect_spc_extcopy},
5986     /*SPC 0x84*/{dissect_spc_recvcopy},
5987     /*SPC 0x85*/{NULL},
5988     /*SPC 0x86*/{NULL},
5989     /*SPC 0x87*/{NULL},
5990     /*SPC 0x88*/{NULL},
5991     /*SPC 0x89*/{NULL},
5992     /*SPC 0x8a*/{NULL},
5993     /*SPC 0x8b*/{NULL},
5994     /*SPC 0x8c*/{NULL},
5995     /*SPC 0x8d*/{NULL},
5996     /*SPC 0x8e*/{NULL},
5997     /*SPC 0x8f*/{NULL},
5998     /*SPC 0x90*/{NULL},
5999     /*SPC 0x91*/{NULL},
6000     /*SPC 0x92*/{NULL},
6001     /*SPC 0x93*/{NULL},
6002     /*SPC 0x94*/{NULL},
6003     /*SPC 0x95*/{NULL},
6004     /*SPC 0x96*/{NULL},
6005     /*SPC 0x97*/{NULL},
6006     /*SPC 0x98*/{NULL},
6007     /*SPC 0x99*/{NULL},
6008     /*SPC 0x9a*/{NULL},
6009     /*SPC 0x9b*/{NULL},
6010     /*SPC 0x9c*/{NULL},
6011     /*SPC 0x9d*/{NULL},
6012     /*SPC 0x9e*/{NULL},
6013     /*SPC 0x9f*/{NULL},
6014     /*SPC 0xa0*/{dissect_spc_reportluns},
6015     /*SPC 0xa1*/{NULL},
6016     /*SPC 0xa2*/{NULL},
6017     /*SPC 0xa3*/{dissect_spc_reportdeviceidentifier},
6018     /*SPC 0xa4*/{NULL},
6019     /*SPC 0xa5*/{NULL},
6020     /*SPC 0xa6*/{NULL},
6021     /*SPC 0xa7*/{NULL},
6022     /*SPC 0xa8*/{NULL},
6023     /*SPC 0xa9*/{NULL},
6024     /*SPC 0xaa*/{NULL},
6025     /*SPC 0xab*/{NULL},
6026     /*SPC 0xac*/{NULL},
6027     /*SPC 0xad*/{NULL},
6028     /*SPC 0xae*/{NULL},
6029     /*SPC 0xaf*/{NULL},
6030     /*SPC 0xb0*/{NULL},
6031     /*SPC 0xb1*/{NULL},
6032     /*SPC 0xb2*/{NULL},
6033     /*SPC 0xb3*/{NULL},
6034     /*SPC 0xb4*/{NULL},
6035     /*SPC 0xb5*/{NULL},
6036     /*SPC 0xb6*/{NULL},
6037     /*SPC 0xb7*/{NULL},
6038     /*SPC 0xb8*/{NULL},
6039     /*SPC 0xb9*/{NULL},
6040     /*SPC 0xba*/{NULL},
6041     /*SPC 0xbb*/{NULL},
6042     /*SPC 0xbc*/{NULL},
6043     /*SPC 0xbd*/{NULL},
6044     /*SPC 0xbe*/{NULL},
6045     /*SPC 0xbf*/{NULL},
6046     /*SPC 0xc0*/{NULL},
6047     /*SPC 0xc1*/{NULL},
6048     /*SPC 0xc2*/{NULL},
6049     /*SPC 0xc3*/{NULL},
6050     /*SPC 0xc4*/{NULL},
6051     /*SPC 0xc5*/{NULL},
6052     /*SPC 0xc6*/{NULL},
6053     /*SPC 0xc7*/{NULL},
6054     /*SPC 0xc8*/{NULL},
6055     /*SPC 0xc9*/{NULL},
6056     /*SPC 0xca*/{NULL},
6057     /*SPC 0xcb*/{NULL},
6058     /*SPC 0xcc*/{NULL},
6059     /*SPC 0xcd*/{NULL},
6060     /*SPC 0xce*/{NULL},
6061     /*SPC 0xcf*/{NULL},
6062     /*SPC 0xd0*/{NULL},
6063     /*SPC 0xd1*/{NULL},
6064     /*SPC 0xd2*/{NULL},
6065     /*SPC 0xd3*/{NULL},
6066     /*SPC 0xd4*/{NULL},
6067     /*SPC 0xd5*/{NULL},
6068     /*SPC 0xd6*/{NULL},
6069     /*SPC 0xd7*/{NULL},
6070     /*SPC 0xd8*/{NULL},
6071     /*SPC 0xd9*/{NULL},
6072     /*SPC 0xda*/{NULL},
6073     /*SPC 0xdb*/{NULL},
6074     /*SPC 0xdc*/{NULL},
6075     /*SPC 0xdd*/{NULL},
6076     /*SPC 0xde*/{NULL},
6077     /*SPC 0xdf*/{NULL},
6078     /*SPC 0xe0*/{NULL},
6079     /*SPC 0xe1*/{NULL},
6080     /*SPC 0xe2*/{NULL},
6081     /*SPC 0xe3*/{NULL},
6082     /*SPC 0xe4*/{NULL},
6083     /*SPC 0xe5*/{NULL},
6084     /*SPC 0xe6*/{NULL},
6085     /*SPC 0xe7*/{NULL},
6086     /*SPC 0xe8*/{NULL},
6087     /*SPC 0xe9*/{NULL},
6088     /*SPC 0xea*/{NULL},
6089     /*SPC 0xeb*/{NULL},
6090     /*SPC 0xec*/{NULL},
6091     /*SPC 0xed*/{NULL},
6092     /*SPC 0xee*/{NULL},
6093     /*SPC 0xef*/{NULL},
6094     /*SPC 0xf0*/{NULL},
6095     /*SPC 0xf1*/{NULL},
6096     /*SPC 0xf2*/{NULL},
6097     /*SPC 0xf3*/{NULL},
6098     /*SPC 0xf4*/{NULL},
6099     /*SPC 0xf5*/{NULL},
6100     /*SPC 0xf6*/{NULL},
6101     /*SPC 0xf7*/{NULL},
6102     /*SPC 0xf8*/{NULL},
6103     /*SPC 0xf9*/{NULL},
6104     /*SPC 0xfa*/{NULL},
6105     /*SPC 0xfb*/{NULL},
6106     /*SPC 0xfc*/{NULL},
6107     /*SPC 0xfd*/{NULL},
6108     /*SPC 0xfe*/{NULL},
6109     /*SPC 0xff*/{NULL}
6110 };
6111 
6112 
6113 /* This function must be called with valid pointers for both itlq and itl */
6114 void
dissect_scsi_cdb(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,gint devtype_arg _U_,itlq_nexus_t * itlq,itl_nexus_t * itl)6115 dissect_scsi_cdb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
6116                  gint devtype_arg _U_, itlq_nexus_t *itlq, itl_nexus_t *itl)
6117 {
6118     int               offset    = 0;
6119     proto_item       *ti;
6120     proto_tree       *scsi_tree = NULL;
6121     guint8            opcode;
6122 #if 0
6123     scsi_device_type  devtype;
6124 #endif
6125     const gchar      *valstr;
6126     scsi_task_data_t *cdata;
6127     const char       *old_proto;
6128     cmdset_t         *csdata;
6129 
6130 
6131     old_proto = pinfo->current_proto;
6132     pinfo->current_proto="SCSI";
6133 
6134     if (!itlq) {
6135         DISSECTOR_ASSERT_NOT_REACHED();
6136     }
6137     if (!itl) {
6138         DISSECTOR_ASSERT_NOT_REACHED();
6139     }
6140 
6141     opcode = tvb_get_guint8(tvb, offset);
6142     itlq->scsi_opcode = opcode;
6143     csdata = get_cmdset_data(pinfo->pool, itlq, itl);
6144 
6145 #if 0 /* XXX: devtype never actually used ?? */
6146     if (devtype_arg != SCSI_DEV_UNKNOWN) {
6147         devtype = devtype_arg;
6148     } else {
6149         if (itl) {
6150             devtype = itl->cmdset;
6151         } else {
6152             devtype = (scsi_device_type)scsi_def_devtype;
6153         }
6154     }
6155 #endif
6156 
6157     if ((valstr = try_val_to_str_ext(opcode, &scsi_spc_vals_ext)) == NULL) {
6158         valstr = try_val_to_str_ext(opcode, csdata->cdb_vals_ext);
6159     }
6160 
6161     if (valstr != NULL) {
6162         col_add_fstr(pinfo->cinfo, COL_INFO, "SCSI: %s LUN: 0x%02x ", valstr, itlq->lun);
6163     } else {
6164         col_add_fstr(pinfo->cinfo, COL_INFO, "SCSI Command: 0x%02x LUN:0x%02x ", opcode, itlq->lun);
6165     }
6166     /* make sure no one will overwrite this in the info column */
6167     col_set_fence(pinfo->cinfo, COL_INFO);
6168 
6169     cdata = wmem_new(pinfo->pool, scsi_task_data_t);
6170     cdata->itl = itl;
6171     cdata->itlq = itlq;
6172     cdata->type = SCSI_PDU_TYPE_CDB;
6173     tap_queue_packet(scsi_tap, pinfo, cdata);
6174 
6175     if (tree) {
6176         ti = proto_tree_add_protocol_format(tree, proto_scsi, tvb, 0,
6177                                             -1, "SCSI CDB %s",
6178                                             val_to_str_ext(opcode,
6179                                                            csdata->cdb_vals_ext,
6180                                                            "0x%02x")
6181             );
6182         scsi_tree = proto_item_add_subtree(ti, ett_scsi);
6183     }
6184 
6185     ti = proto_tree_add_uint(scsi_tree, hf_scsi_lun, tvb, 0, 0, itlq->lun);
6186     proto_item_set_generated(ti);
6187 
6188     if (itl) {
6189         ti = proto_tree_add_uint_format(scsi_tree, hf_scsi_inq_devtype, tvb, 0, 0, itl->cmdset&SCSI_CMDSET_MASK, "Command Set:%s (0x%02x) %s", val_to_str(itl->cmdset&SCSI_CMDSET_MASK, scsi_devtype_val, "Unknown (%d)"), itl->cmdset&SCSI_CMDSET_MASK,itl->cmdset&SCSI_CMDSET_DEFAULT?"(Using default commandset)":"");
6190         proto_item_set_generated(ti);
6191     }
6192 
6193     if (itlq->last_exchange_frame) {
6194         ti = proto_tree_add_uint(scsi_tree, hf_scsi_response_frame, tvb, 0, 0, itlq->last_exchange_frame);
6195         proto_item_set_generated(ti);
6196     }
6197 
6198 
6199     if (valstr != NULL) {
6200         proto_tree_add_uint_format(scsi_tree, csdata->hf_opcode, tvb,
6201                                    offset, 1,
6202                                    tvb_get_guint8(tvb, offset),
6203                                    "Opcode: %s (0x%02x)", valstr,
6204                                    opcode);
6205     } else {
6206         proto_tree_add_item(scsi_tree, hf_scsi_spcopcode, tvb, offset, 1, ENC_BIG_ENDIAN);
6207     }
6208 
6209     if (csdata->cdb_table[opcode].func) {
6210         csdata->cdb_table[opcode].func(tvb, pinfo, scsi_tree, offset+1,
6211                                        TRUE, TRUE, 0, cdata);
6212     } else if (spc[opcode].func) {
6213         spc[opcode].func(tvb, pinfo, scsi_tree, offset+1,
6214                          TRUE, TRUE, 0, cdata);
6215     } else {
6216         call_data_dissector(tvb, pinfo, scsi_tree);
6217     }
6218 
6219     pinfo->current_proto = old_proto;
6220 }
6221 
6222 void
dissect_scsi_payload(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,gboolean isreq,itlq_nexus_t * itlq,itl_nexus_t * itl,guint32 relative_offset)6223 dissect_scsi_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
6224                      gboolean isreq, itlq_nexus_t *itlq, itl_nexus_t *itl,
6225                      guint32 relative_offset)
6226 {
6227     int               offset          = 0;
6228     proto_item       *ti;
6229     proto_tree       *scsi_tree       = NULL;
6230     guint8            opcode;
6231     scsi_task_data_t *cdata;
6232     int               payload_len;
6233     const char       *old_proto;
6234     cmdset_t         *csdata;
6235     guint32           expected_length;
6236     fragment_head    *ipfd_head;
6237     tvbuff_t         *next_tvb        = tvb;
6238     gboolean          update_col_info = TRUE;
6239     gboolean          more_frags      = FALSE;
6240 
6241     if (!itlq || !itl) {
6242         /* we have no record of this exchange and so we can't dissect the
6243          * payload
6244          */
6245         expert_add_info(pinfo, tree, &ei_scsi_unknown_scsi_exchange);
6246         return;
6247     }
6248 
6249     payload_len = tvb_reported_length(tvb);
6250     cdata = wmem_new(pinfo->pool, scsi_task_data_t);
6251     cdata->itl = itl;
6252     cdata->itlq = itlq;
6253     cdata->type = SCSI_PDU_TYPE_CDB;
6254     tap_queue_packet(scsi_tap, pinfo, cdata);
6255 
6256     csdata = get_cmdset_data(pinfo->pool, itlq, itl);
6257 
6258     old_proto = pinfo->current_proto;
6259     pinfo->current_proto="SCSI";
6260 
6261     opcode = (guint8) cdata->itlq->scsi_opcode;
6262 
6263     if (tree) {
6264         ti = proto_tree_add_protocol_format(tree, proto_scsi, tvb, offset,
6265                                             payload_len,
6266                                             "SCSI Payload (%s %s)",
6267                                             val_to_str_ext(opcode,
6268                                                            csdata->cdb_vals_ext,
6269                                                            "CDB:0x%02x"),
6270                                             isreq ? "Request Data" : "Response Data");
6271         scsi_tree = proto_item_add_subtree(ti, ett_scsi);
6272     }
6273 
6274     col_add_fstr(pinfo->cinfo, COL_INFO,
6275                     "SCSI: Data %s LUN: 0x%02x (%s %s) ",
6276                     isreq ? "Out" : "In",
6277                     itlq->lun,
6278                     val_to_str_ext(opcode, csdata->cdb_vals_ext, "0x%02x"),
6279                     isreq ? "Request Data" : "Response Data");
6280 
6281     col_set_fence(pinfo->cinfo, COL_INFO);
6282 
6283     ti = proto_tree_add_uint(scsi_tree, hf_scsi_lun, tvb, 0, 0, itlq->lun);
6284     proto_item_set_generated(ti);
6285 
6286     if (itl) {
6287         ti = proto_tree_add_uint_format(scsi_tree, hf_scsi_inq_devtype, tvb, 0, 0, itl->cmdset&SCSI_CMDSET_MASK,
6288                                         "Command Set:%s (0x%02x) %s",
6289                                         val_to_str(itl->cmdset&SCSI_CMDSET_MASK, scsi_devtype_val, "Unknown (%d)"),
6290                                         itl->cmdset&SCSI_CMDSET_MASK,
6291                                         itl->cmdset&SCSI_CMDSET_DEFAULT ? "(Using default commandset)" : "");
6292         proto_item_set_generated(ti);
6293 
6294         if (itlq && (itlq->scsi_opcode != 0xffff)) {
6295             ti = proto_tree_add_uint(scsi_tree, csdata->hf_opcode, tvb, 0, 0, itlq->scsi_opcode);
6296             proto_item_set_generated(ti);
6297         }
6298     }
6299 
6300     if (itlq->first_exchange_frame) {
6301         ti = proto_tree_add_uint(scsi_tree, hf_scsi_request_frame, tvb, 0, 0, itlq->first_exchange_frame);
6302         proto_item_set_generated(ti);
6303     }
6304 
6305     if (itlq->last_exchange_frame) {
6306         ti = proto_tree_add_uint(scsi_tree, hf_scsi_response_frame, tvb, 0, 0, itlq->last_exchange_frame);
6307         proto_item_set_generated(ti);
6308     }
6309 
6310 
6311     /* If we don't know the CDB opcode there is no point in trying to
6312      * dissect the data.
6313      */
6314     if ( !itlq->first_exchange_frame ) {
6315         call_data_dissector(tvb, pinfo, scsi_tree);
6316         goto end_of_payload;
6317     }
6318 
6319     /* If we are not doing data reassembly we only call the dissector
6320      * for the very first data in/out pdu in each transfer
6321      */
6322     if (!scsi_defragment) {
6323         if (relative_offset) {
6324             call_data_dissector(tvb, pinfo, scsi_tree);
6325             goto end_of_payload;
6326         } else {
6327             goto dissect_the_payload;
6328         }
6329     }
6330 
6331     /* If we don't have the entire PDU there is no point in even trying
6332      * reassembly
6333      */
6334     if (tvb_captured_length_remaining(tvb, offset) != tvb_reported_length_remaining(tvb, offset)) {
6335         if (relative_offset) {
6336             call_data_dissector(tvb, pinfo, scsi_tree);
6337             goto end_of_payload;
6338         } else {
6339             goto dissect_the_payload;
6340         }
6341     }
6342 
6343 
6344     /* What is the expected data length for this transfer */
6345     if ( (itlq->task_flags&(SCSI_DATA_READ|SCSI_DATA_WRITE)) == (SCSI_DATA_READ|SCSI_DATA_WRITE) ) {
6346         /* This is a bidirectional transfer */
6347         if (isreq) {
6348             expected_length = itlq->data_length;
6349         } else {
6350             expected_length = itlq->bidir_data_length;
6351         }
6352     } else {
6353         /* This is a unidirectional transfer */
6354         expected_length = itlq->data_length;
6355     }
6356 
6357     /* If this PDU already contains all the expected data we don't have to do
6358      * reassembly.
6359      */
6360     if ( (!relative_offset) && ((guint32)tvb_reported_length_remaining(tvb, offset) == expected_length) ) {
6361         goto dissect_the_payload;
6362     }
6363 
6364 
6365     /* Start reassembly */
6366 
6367     if (tvb_reported_length_remaining(tvb, offset) < 0) {
6368         goto end_of_payload;
6369     }
6370     if ((tvb_reported_length_remaining(tvb,offset) + relative_offset) != expected_length) {
6371         more_frags = TRUE;
6372     }
6373     ipfd_head = fragment_add_check(&scsi_reassembly_table, tvb, offset,
6374                                    pinfo,
6375                                    itlq->first_exchange_frame, /* key */
6376                                    NULL,
6377                                    relative_offset,
6378                                    tvb_reported_length_remaining(tvb, offset),
6379                                    more_frags);
6380     next_tvb = process_reassembled_data(tvb, offset, pinfo, "Reassembled SCSI DATA", ipfd_head, &scsi_frag_items, &update_col_info, tree);
6381 
6382     if ( ipfd_head && (ipfd_head->reassembled_in != pinfo->num) ) {
6383         col_prepend_fstr(pinfo->cinfo, COL_INFO, "[Reassembled in #%u] ",
6384                              ipfd_head->reassembled_in);
6385     }
6386 
6387 
6388 dissect_the_payload:
6389     if (!next_tvb) {
6390         /* reassembly has not yet finished so we don't have a tvb yet */
6391         goto end_of_payload;
6392     }
6393     if (tree == NULL) {
6394         /*
6395          * We have to dissect INQUIRY responses, in order to determine the
6396          * types of devices.
6397          *
6398          * We don't bother dissecting other payload if we're not building
6399          * a protocol tree.
6400          *
6401          * We assume opcode 0x12 is always INQUIRY regardless of the
6402          * commandset used.
6403          */
6404         if (opcode == SCSI_SPC_INQUIRY) {
6405             dissect_spc_inquiry(next_tvb, pinfo, scsi_tree, offset, isreq,
6406                                 FALSE, payload_len, cdata);
6407         }
6408     } else {
6409         /*
6410           All commandsets support SPC?
6411         */
6412         if (csdata->cdb_table && (csdata->cdb_table)[opcode].func) {
6413             (csdata->cdb_table)[opcode].func(next_tvb, pinfo, scsi_tree, offset,
6414                                              isreq, FALSE, payload_len, cdata);
6415         } else if (spc[opcode].func) {
6416             spc[opcode].func(next_tvb, pinfo, scsi_tree, offset,
6417                              isreq, FALSE, payload_len, cdata);
6418         } else { /* don't know this CDB */
6419             call_data_dissector(next_tvb, pinfo, scsi_tree);
6420         }
6421     }
6422 
6423 end_of_payload:
6424     pinfo->current_proto = old_proto;
6425 }
6426 
6427 static cmdset_t *
get_cmdset_data(wmem_allocator_t * pool,itlq_nexus_t * itlq,itl_nexus_t * itl)6428 get_cmdset_data(wmem_allocator_t *pool, itlq_nexus_t *itlq, itl_nexus_t *itl)
6429 {
6430     cmdset_t *csdata;
6431     guint8    cmdset;
6432 
6433     /* we must have an itlq structure */
6434     if (!itlq) {
6435         DISSECTOR_ASSERT_NOT_REACHED();
6436     }
6437 
6438     if (itl) {
6439         if (itl->cmdset == 0xff) {
6440             itl->cmdset = scsi_def_devtype|SCSI_CMDSET_DEFAULT;
6441         }
6442         cmdset = itl->cmdset;
6443     } else {
6444         cmdset = scsi_def_devtype;
6445     }
6446 
6447     csdata = wmem_new(pool, cmdset_t);
6448 
6449     switch(cmdset&SCSI_CMDSET_MASK) {
6450     case SCSI_DEV_SBC:
6451         csdata->hf_opcode    = hf_scsi_sbc_opcode;
6452         csdata->cdb_vals_ext = &scsi_sbc_vals_ext;
6453         csdata->cdb_table    = scsi_sbc_table;
6454         break;
6455     case SCSI_DEV_CDROM:
6456         csdata->hf_opcode    = hf_scsi_mmc_opcode;
6457         csdata->cdb_vals_ext = &scsi_mmc_vals_ext;
6458         csdata->cdb_table    = scsi_mmc_table;
6459         break;
6460     case SCSI_DEV_SSC:
6461         csdata->hf_opcode    = hf_scsi_ssc_opcode;
6462         csdata->cdb_vals_ext = &scsi_ssc_vals_ext;
6463         csdata->cdb_table    = scsi_ssc_table;
6464         break;
6465     case SCSI_DEV_SMC:
6466         csdata->hf_opcode    = hf_scsi_smc_opcode;
6467         csdata->cdb_vals_ext = &scsi_smc_vals_ext;
6468         csdata->cdb_table    = scsi_smc_table;
6469         break;
6470     case SCSI_DEV_OSD:
6471         csdata->hf_opcode    = hf_scsi_osd_opcode;
6472         csdata->cdb_vals_ext = &scsi_osd_vals_ext;
6473         csdata->cdb_table    = scsi_osd_table;
6474         break;
6475     default:
6476         csdata->hf_opcode    = hf_scsi_spcopcode;
6477         csdata->cdb_vals_ext = &scsi_spc_vals_ext;
6478         csdata->cdb_table    = spc;
6479         break;
6480     }
6481 
6482     return csdata;
6483 }
6484 
6485 
6486 void
proto_register_scsi(void)6487 proto_register_scsi(void)
6488 {
6489     static hf_register_info hf[] = {
6490         { &hf_scsi_status,
6491           { "Status", "scsi.status", FT_UINT8, BASE_HEX,
6492             VALS(scsi_status_val), 0, "SCSI command status value", HFILL }},
6493         { &hf_scsi_spcopcode,
6494           {"SPC-2 Opcode", "scsi.spc.opcode", FT_UINT8, BASE_HEX | BASE_EXT_STRING,
6495            &scsi_spc_vals_ext, 0x0, NULL, HFILL}},
6496         { &hf_scsi_control,
6497           {"Control", "scsi.cdb.control", FT_UINT8, BASE_HEX, NULL, 0x0, NULL,
6498            HFILL}},
6499         { &hf_scsi_control_vendor_specific,
6500           {"Vendor specific", "scsi.cdb.control.vendorspecific", FT_UINT8,
6501            BASE_HEX, NULL, 0xC0, NULL, HFILL}},
6502         { &hf_scsi_control_reserved,
6503           {"Reserved", "scsi.cdb.control.reserved", FT_UINT8, BASE_HEX, NULL,
6504            0x38, NULL, HFILL}},
6505         { &hf_scsi_control_naca,
6506           {"NACA", "scsi.cdb.control.naca", FT_BOOLEAN, 8,
6507            TFS(&scsi_naca_tfs), 0x04, NULL, HFILL}},
6508         { &hf_scsi_control_obs1,
6509           {"Obsolete", "scsi.cdb.control.obs1", FT_UINT8, BASE_HEX,
6510            NULL, 0x02, NULL, HFILL}},
6511         { &hf_scsi_control_obs2,
6512           {"Obsolete", "scsi.cdb.control.obs2", FT_UINT8, BASE_HEX,
6513            NULL, 0x01, NULL, HFILL}},
6514         { &hf_scsi_inq_control,
6515           {"Control", "scsi.cdb.inq.control", FT_UINT8, BASE_HEX, NULL, 0x0,
6516            NULL, HFILL}},
6517         { &hf_scsi_inquiry_flags,
6518           {"Inquiry Flags", "scsi.inquiry.flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL,
6519            HFILL}},
6520         { &hf_scsi_inquiry_evpd_page,
6521           {"EVPD Page Code", "scsi.inquiry.evpd.pagecode", FT_UINT8, BASE_HEX,
6522            VALS(scsi_evpd_pagecode_val), 0x0, NULL, HFILL}},
6523         { &hf_scsi_inquiry_cmdt_page,
6524           {"CMDT Page Code", "scsi.inquiry.cmdt.pagecode", FT_UINT8, BASE_HEX,
6525            NULL, 0x0, NULL, HFILL}},
6526         { &hf_scsi_alloclen,
6527           {"Allocation Length", "scsi.cdb.alloclen", FT_UINT8, BASE_DEC, NULL,
6528            0x0, NULL, HFILL}},
6529         { &hf_scsi_paramlen,
6530           {"Parameter Length", "scsi.cdb.paramlen", FT_UINT8, BASE_DEC, NULL,
6531            0x0, NULL, HFILL}},
6532         { &hf_scsi_log_pc,
6533           {"Page Control", "scsi.log.pc", FT_UINT8, BASE_DEC,
6534            VALS(scsi_log_pc_val), 0xC0, NULL, HFILL}},
6535         { &hf_scsi_log_pagecode,
6536           {"Page Code", "scsi.log.pagecode", FT_UINT8, BASE_HEX,
6537            VALS(scsi_log_page_val), 0x3F, NULL, HFILL}},
6538         { &hf_scsi_paramlen16,
6539           {"Parameter Length", "scsi.cdb.paramlen16", FT_UINT16, BASE_DEC, NULL,
6540            0x0, NULL, HFILL}},
6541         { &hf_scsi_modesel_flags,
6542           {"Mode Sense/Select Flags", "scsi.cdb.mode.flags", FT_UINT8, BASE_HEX,
6543            NULL, 0x0, NULL, HFILL}},
6544         { &hf_scsi_alloclen16,
6545           {"Allocation Length", "scsi.cdb.alloclen16", FT_UINT16, BASE_DEC,
6546            NULL, 0x0, NULL, HFILL}},
6547         { &hf_scsi_modesns_pc,
6548           {"Page Control", "scsi.mode.pc", FT_UINT8, BASE_DEC,
6549            VALS(scsi_modesns_pc_val), 0xC0, NULL, HFILL}},
6550         { &hf_scsi_spc_subpagecode,
6551           {"SubPage Code", "scsi.mode.spc.subpagecode", FT_UINT8, BASE_HEX,
6552            NULL, 0, NULL, HFILL}},
6553         { &hf_scsi_spc_pagecode,
6554           {"SPC-2 Page Code", "scsi.mode.spc.pagecode", FT_UINT8, BASE_HEX,
6555            VALS(scsi_spc_modepage_val), 0x3F, NULL, HFILL}},
6556         { &hf_scsi_sbcpagecode,
6557           {"SBC-2 Page Code", "scsi.mode.sbc.pagecode", FT_UINT8, BASE_HEX,
6558            VALS(scsi_sbc_modepage_val), 0x3F, NULL, HFILL}},
6559         { &hf_scsi_sscpagecode,
6560           {"SSC-2 Page Code", "scsi.mode.ssc.pagecode", FT_UINT8, BASE_HEX,
6561            VALS(scsi_ssc2_modepage_val), 0x3F, NULL, HFILL}},
6562         { &hf_scsi_mmcpagecode,
6563           {"MMC-5 Page Code", "scsi.mode.mmc.pagecode", FT_UINT8, BASE_HEX,
6564            VALS(scsi_mmc5_modepage_val), 0x3F, NULL, HFILL}},
6565         { &hf_scsi_smcpagecode,
6566           {"SMC-2 Page Code", "scsi.mode.smc.pagecode", FT_UINT8, BASE_HEX,
6567            VALS(scsi_smc_modepage_val), 0x3F, NULL, HFILL}},
6568         { &hf_scsi_modesns_flags,
6569           {"Mode Sense Flags", "scsi.mode.flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL,
6570            HFILL}},
6571         { &hf_scsi_persresvin_svcaction,
6572           {"Service Action", "scsi.persresvin.svcaction", FT_UINT8, BASE_HEX,
6573            VALS(scsi_persresvin_svcaction_val), 0x1F, NULL, HFILL}},
6574         { &hf_scsi_persresvout_svcaction,
6575           {"Service Action", "scsi.persresvout.svcaction", FT_UINT8, BASE_HEX,
6576            VALS(scsi_persresvout_svcaction_val), 0x1F, NULL, HFILL}},
6577         { &hf_scsi_persresv_scope,
6578           {"Reservation Scope", "scsi.persresv.scope", FT_UINT8, BASE_HEX,
6579            VALS(scsi_persresv_scope_val), 0xF0, NULL, HFILL}},
6580         { &hf_scsi_persresv_type,
6581           {"Reservation Type", "scsi.persresv.type", FT_UINT8, BASE_HEX,
6582            VALS(scsi_persresv_type_val), 0x0F, NULL, HFILL}},
6583         { &hf_scsi_persresvout_reskey,
6584           {"Reservation Key", "scsi.persresv.reskey", FT_BYTES, BASE_NONE,
6585            NULL, 0x0, NULL, HFILL}},
6586         { &hf_scsi_persresvout_sareskey,
6587           {"Service Action Reservation Key", "scsi.persresv.sareskey", FT_BYTES,
6588            BASE_NONE, NULL, 0x0, NULL, HFILL}},
6589         { &hf_scsi_persresvout_obsolete,
6590           {"Obsolete", "scsi.presresv.obs", FT_BYTES, BASE_NONE, NULL, 0x0,
6591            NULL, HFILL}},
6592         { &hf_scsi_persresvout_control,
6593           {"Control", "scsi.presresv.control", FT_UINT8, BASE_HEX, NULL, 0x0,
6594            NULL, HFILL}},
6595         /* Service action REGISTER AND MOVE */
6596         { &hf_scsi_persresv_control_rsvd,
6597           {"Reserved", "scsi.persresv.control.reserved", FT_UINT8, BASE_HEX,
6598            NULL, 0xFC, NULL, HFILL}},
6599         { &hf_scsi_persresv_control_unreg,
6600           {"unreg", "scsi.persresv.control.unreg", FT_BOOLEAN, 8,
6601            NULL, 0x02, NULL, HFILL}},
6602         /* Other service actions than REGISTER AND MOVE */
6603         { &hf_scsi_persresv_control_rsvd1,
6604           {"Reserved", "scsi.persresv.control.reserved1", FT_UINT8, BASE_HEX,
6605            NULL, 0xF0, NULL, HFILL}},
6606         { &hf_scsi_persresv_control_rsvd2,
6607           {"Reserved", "scsi.persresv.control.reserved2", FT_UINT8, BASE_HEX,
6608            NULL, 0x02, NULL, HFILL}},
6609         { &hf_scsi_persresv_control_spec_i_pt,
6610           {"SPEC_I_PT", "scsi.persresv.control.spec_i_pt", FT_BOOLEAN, 8,
6611            TFS(&scsi_spec_i_pt_tfs), 0x08, NULL, HFILL}},
6612         { &hf_scsi_persresv_control_all_tg_pt,
6613           {"ALL_TG_PT", "scsi.persresv.control.all_tg_pt", FT_BOOLEAN, 8,
6614            TFS(&scsi_all_tg_pt_tfs), 0x04, NULL, HFILL}},
6615         { &hf_scsi_persresv_control_aptpl,
6616           {"aptpl", "scsi.persresv.control.aptpl", FT_BOOLEAN, 8,
6617            TFS(&scsi_aptpl_tfs), 0x01, NULL, HFILL}},
6618         { &hf_scsi_persresvout_rel_tpi,
6619           {"rel_tpi", "scsi.persresv.rel_tpi", FT_UINT16, BASE_DEC,
6620            NULL, 0x0, NULL, HFILL}},
6621         { &hf_scsi_persresvout_transportid_len,
6622           {"transportid_len", "scsi.persresv.transportid_len",
6623            FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}},
6624         { &hf_scsi_persresvout_transportid,
6625           {"transportid_len", "scsi.persresv.transportid",
6626            FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}},
6627         { &hf_scsi_release_flags,
6628           {"Release Flags", "scsi.release.flags", FT_UINT8, BASE_HEX, NULL,
6629            0x0, NULL, HFILL}},
6630         { &hf_scsi_release_thirdpartyid,
6631           {"Third-Party ID", "scsi.release.thirdpartyid", FT_BYTES, BASE_NONE,
6632            NULL, 0x0, NULL, HFILL}},
6633         { &hf_scsi_alloclen32,
6634           {"Allocation Length", "scsi.cdb.alloclen32", FT_UINT32, BASE_DEC,
6635            NULL, 0x0, NULL, HFILL}},
6636         { &hf_scsi_inq_add_len,
6637           {"Additional Length", "scsi.inquiry.add_len", FT_UINT8, BASE_DEC,
6638            NULL, 0, NULL, HFILL}},
6639         { &hf_scsi_inq_qualifier,
6640           {"Qualifier", "scsi.inquiry.qualifier", FT_UINT8, BASE_HEX,
6641            VALS(scsi_qualifier_val), 0xE0, NULL, HFILL}},
6642         { &hf_scsi_inq_peripheral,
6643           {"Peripheral", "scsi.inquiry.peripheral", FT_UINT8, BASE_HEX,
6644            NULL, 0, NULL, HFILL}},
6645         { &hf_scsi_inq_vendor_id,
6646           {"Vendor Id", "scsi.inquiry.vendor_id", FT_STRING, BASE_NONE,
6647            NULL, 0, NULL, HFILL}},
6648         { &hf_scsi_inq_product_id,
6649           {"Product Id", "scsi.inquiry.product_id", FT_STRING, BASE_NONE,
6650            NULL, 0, NULL, HFILL}},
6651         { &hf_scsi_inq_product_rev,
6652           {"Product Revision Level", "scsi.inquiry.product_rev", FT_STRING, BASE_NONE,
6653            NULL, 0, NULL, HFILL}},
6654         { &hf_scsi_inq_vendor_specific,
6655           {"Vendor Specific", "scsi.inquiry.vendor_specific", FT_BYTES, BASE_NONE,
6656            NULL, 0, NULL, HFILL}},
6657         { &hf_scsi_inq_version_desc,
6658           {"Version Description", "scsi.inquiry.version_desc", FT_UINT16, BASE_HEX|BASE_EXT_STRING,
6659            &scsi_verdesc_val_ext, 0, NULL, HFILL}},
6660         { &hf_scsi_inq_devtype,
6661           {"Device Type", "scsi.inquiry.devtype", FT_UINT8, BASE_HEX,
6662            VALS(scsi_devtype_val), SCSI_DEV_BITS, NULL, HFILL}},
6663         { &hf_scsi_inq_rmb,
6664           {"Removable", "scsi.inquiry.removable", FT_BOOLEAN, 8,
6665            TFS(&scsi_removable_val), 0x80, NULL, HFILL}},
6666         { & hf_scsi_inq_version,
6667           {"Version", "scsi.inquiry.version", FT_UINT8, BASE_HEX,
6668            VALS(scsi_inquiry_vers_val), 0x0, NULL, HFILL}},
6669         { &hf_scsi_inq_reladrflags,
6670           {"Inquiry RelAdr Flags", "scsi.inquiry.reladrflags", FT_UINT8, BASE_HEX, NULL, 0,
6671            NULL, HFILL}},
6672         { &hf_scsi_inq_reladr,
6673           {"RelAdr", "scsi.inquiry.reladr", FT_BOOLEAN, 8, TFS(&reladr_tfs), SCSI_INQ_RELADRFLAGS_RELADR,
6674            NULL, HFILL}},
6675         { &hf_scsi_inq_linked,
6676           {"Linked", "scsi.inquiry.linked", FT_BOOLEAN, 8, TFS(&linked_tfs), SCSI_INQ_RELADRFLAGS_LINKED,
6677            NULL, HFILL}},
6678         { &hf_scsi_inq_trandis,
6679           {"TranDis", "scsi.inquiry.trandis", FT_BOOLEAN, 8, NULL, SCSI_INQ_RELADRFLAGS_TRANDIS,
6680            NULL, HFILL}},
6681         { &hf_scsi_inq_cmdque,
6682           {"CmdQue", "scsi.inquiry.cmdque", FT_BOOLEAN, 8, TFS(&cmdque_tfs), SCSI_INQ_RELADRFLAGS_CMDQUE,
6683            NULL, HFILL}},
6684         { &hf_scsi_inq_bqueflags,
6685           {"Inquiry BQue Flags", "scsi.inquiry.bqueflags", FT_UINT8, BASE_HEX, NULL, 0,
6686            NULL, HFILL}},
6687         { &hf_scsi_inq_bque,
6688           {"BQue", "scsi.inquiry.bque", FT_BOOLEAN, 8, TFS(&bque_tfs), SCSI_INQ_BQUEFLAGS_BQUE,
6689            NULL, HFILL}},
6690         { &hf_scsi_inq_encserv,
6691           {"EncServ", "scsi.inquiry.encserv", FT_BOOLEAN, 8, TFS(&encserv_tfs), SCSI_INQ_BQUEFLAGS_ENCSERV,
6692            NULL, HFILL}},
6693         { &hf_scsi_inq_multip,
6694           {"MultiP", "scsi.inquiry.multip", FT_BOOLEAN, 8, TFS(&multip_tfs), SCSI_INQ_BQUEFLAGS_MULTIP,
6695            NULL, HFILL}},
6696         { &hf_scsi_inq_mchngr,
6697           {"MChngr", "scsi.inquiry.mchngr", FT_BOOLEAN, 8, TFS(&mchngr_tfs), SCSI_INQ_BQUEFLAGS_MCHNGR,
6698            NULL, HFILL}},
6699         { &hf_scsi_inq_ackreqq,
6700           {"ACKREQQ", "scsi.inquiry.ackreqq", FT_BOOLEAN, 8, NULL, SCSI_INQ_BQUEFLAGS_ACKREQQ,
6701            NULL, HFILL}},
6702         { &hf_scsi_inq_sccsflags,
6703           {"Inquiry SCCS Flags", "scsi.inquiry.sccsflags", FT_UINT8, BASE_HEX, NULL, 0,
6704            NULL, HFILL}},
6705         { &hf_scsi_inq_sccs,
6706           {"SCCS", "scsi.inquiry.sccs", FT_BOOLEAN, 8, TFS(&sccs_tfs), SCSI_INQ_SCCSFLAGS_SCCS,
6707            NULL, HFILL}},
6708         { &hf_scsi_inq_acc,
6709           {"ACC", "scsi.inquiry.acc", FT_BOOLEAN, 8, TFS(&acc_tfs), SCSI_INQ_SCCSFLAGS_ACC,
6710            NULL, HFILL}},
6711         { &hf_scsi_inq_tpc,
6712           {"3PC", "scsi.inquiry.tpc", FT_BOOLEAN, 8, TFS(&tpc_tfs), SCSI_INQ_SCCSFLAGS_TPC,
6713            NULL, HFILL}},
6714         { &hf_scsi_inq_protect,
6715           {"Protect", "scsi.inquiry.protect", FT_BOOLEAN, 8, TFS(&protect_tfs), SCSI_INQ_SCCSFLAGS_PROTECT,
6716            NULL, HFILL}},
6717         { &hf_scsi_inq_tpgs,
6718           {"TPGS", "scsi.inquiry.tpgs", FT_UINT8, BASE_DEC, VALS(inq_tpgs_vals), 0x30,
6719            NULL, HFILL}},
6720         { &hf_scsi_inq_acaflags,
6721           {"Inquiry ACA Flags", "scsi.inquiry.acaflags", FT_UINT8, BASE_HEX, NULL, 0,
6722            NULL, HFILL}},
6723         { &hf_scsi_inq_control_vendor_specific,
6724           {"Vendor specific", "scsi.inquiry.control.vendorspecific", FT_UINT8,
6725            BASE_HEX, NULL, 0xC0, NULL, HFILL}},
6726         { &hf_scsi_inq_control_reserved,
6727           {"Reserved", "scsi.inquiry.control.reserved", FT_UINT8, BASE_HEX,
6728            NULL, 0x38, NULL, HFILL}},
6729         { &hf_scsi_inq_control_naca,
6730           {"NACA", "scsi.inquiry.control.naca", FT_BOOLEAN, 8,
6731            TFS(&scsi_naca_tfs), 0x04, NULL, HFILL}},
6732         { &hf_scsi_inq_control_obs1,
6733           {"Obsolete", "scsi.inquiry.control.obs1", FT_UINT8, BASE_HEX,
6734            NULL, 0x02, NULL, HFILL}},
6735         { &hf_scsi_inq_control_obs2,
6736           {"Obsolete", "scsi.inquiry.control.obs2", FT_UINT8, BASE_HEX,
6737            NULL, 0x01, NULL, HFILL}},
6738         { &hf_scsi_inq_rmbflags,
6739           {"Inquiry RMB Flags", "scsi.inquiry.rmbflags", FT_UINT8, BASE_HEX, NULL, 0,
6740            NULL, HFILL}},
6741         { &hf_scsi_inq_normaca,
6742           {"NormACA", "scsi.inquiry.normaca", FT_BOOLEAN, 8, TFS(&normaca_tfs), SCSI_INQ_ACAFLAGS_NORMACA,
6743            NULL, HFILL}},
6744         { &hf_scsi_inq_hisup,
6745           {"HiSup", "scsi.inquiry.hisup", FT_BOOLEAN, 8, TFS(&hisup_tfs), SCSI_INQ_ACAFLAGS_HISUP,
6746            NULL, HFILL}},
6747         { &hf_scsi_inq_aerc,
6748           {"AERC", "scsi.inquiry.aerc", FT_BOOLEAN, 8, TFS(&aerc_tfs), SCSI_INQ_ACAFLAGS_AERC,
6749            "AERC is obsolete from SPC-3 and forward", HFILL}},
6750         { &hf_scsi_inq_trmtsk,
6751           {"TrmTsk", "scsi.inquiry.trmtsk", FT_BOOLEAN, 8, TFS(&trmtsk_tfs), SCSI_INQ_ACAFLAGS_TRMTSK,
6752            "TRMTSK is obsolete from SPC-2 and forward", HFILL}},
6753         { &hf_scsi_inq_rdf,
6754           {"Response Data Format", "scsi.inquiry.rdf", FT_UINT8, BASE_DEC, VALS(inq_rdf_vals), 0x0f,
6755            NULL, HFILL}},
6756         { &hf_scsi_modesns_errrep,
6757           {"MRIE", "scsi.mode.mrie", FT_UINT8, BASE_HEX,
6758            VALS(scsi_modesns_mrie_val), 0x0F, NULL, HFILL}},
6759         { &hf_scsi_modesns_tst,
6760           {"Task Set Type", "scsi.mode.tst", FT_UINT8, BASE_DEC,
6761            VALS(scsi_modesns_tst_val), 0xE0, NULL, HFILL}},
6762         { &hf_scsi_modesns_qmod,
6763           {"Queue Algorithm Modifier", "scsi.mode.qmod", FT_UINT8, BASE_HEX,
6764            VALS(scsi_modesns_qmod_val), 0xF0, NULL, HFILL}},
6765         { &hf_scsi_modesns_qerr,
6766           {"Queue Error Management", "scsi.mode.qerr", FT_BOOLEAN, 8,
6767            TFS(&scsi_modesns_qerr_val), 0x2, NULL, HFILL}},
6768         { &hf_scsi_modesns_tas,
6769           {"Task Aborted Status", "scsi.mode.tac", FT_BOOLEAN, 8,
6770            TFS(&scsi_modesns_tas_val), 0x80, NULL, HFILL}},
6771         { &hf_scsi_modesns_rac,
6772           {"Report a Check", "scsi.mode.rac", FT_BOOLEAN, 8,
6773            TFS(&scsi_modesns_rac_val), 0x40, NULL, HFILL}},
6774         { &hf_scsi_protocol,
6775           {"Protocol", "scsi.proto", FT_UINT8, BASE_DEC, VALS(scsi_proto_val),
6776            0x0F, NULL, HFILL}},
6777         { &hf_scsi_sns_errtype,
6778           {"SNS Error Type", "scsi.sns.errtype", FT_UINT8, BASE_HEX,
6779            VALS(scsi_sns_errtype_val), 0x7F, NULL, HFILL}},
6780         { &hf_scsi_snskey,
6781           {"Sense Key", "scsi.sns.key", FT_UINT8, BASE_HEX,
6782            VALS(scsi_sensekey_val), 0x0F, NULL, HFILL}},
6783         { &hf_scsi_snsinfo,
6784           {"Sense Info", "scsi.sns.info", FT_UINT32, BASE_HEX, NULL, 0x0, NULL,
6785            HFILL}},
6786         { &hf_scsi_addlsnslen,
6787           {"Additional Sense Length", "scsi.sns.addlen", FT_UINT8, BASE_DEC,
6788            NULL, 0x0, NULL, HFILL}},
6789         { &hf_scsi_asc,
6790           {"Additional Sense Code", "scsi.sns.asc", FT_UINT8, BASE_HEX, NULL,
6791            0x0, NULL, HFILL}},
6792         { &hf_scsi_ascq,
6793           {"Additional Sense Code Qualifier", "scsi.sns.ascq", FT_UINT8,
6794            BASE_HEX, NULL, 0x0, NULL, HFILL}},
6795         { &hf_scsi_ascascq,
6796           {"Additional Sense Code+Qualifier", "scsi.sns.ascascq", FT_UINT16,
6797            BASE_HEX|BASE_EXT_STRING, &scsi_asc_val_ext, 0x0, NULL, HFILL}},
6798         { &hf_scsi_fru,
6799           {"Field Replaceable Unit Code", "scsi.sns.fru", FT_UINT8, BASE_HEX,
6800            NULL, 0x0, NULL, HFILL}},
6801         { &hf_scsi_sksv,
6802           {"SKSV", "scsi.sns.sksv", FT_BOOLEAN, 8, NULL, 0x80, NULL,
6803            HFILL}},
6804         { &hf_scsi_sks_info,
6805           {"Sense Key Specific", "scsi.sns.sks_info", FT_UINT24, BASE_HEX, NULL, 0x7FFFFF, NULL, HFILL}},
6806         { &hf_scsi_sks_fp_cd,
6807           {"Command/Data", "scsi.sns.sks.fp.cd", FT_UINT24, BASE_HEX, VALS(scsi_sense_sks_fp_cd_val), 0x400000, NULL, HFILL}},
6808         { &hf_scsi_sks_fp_bpv,
6809           {"Bit pointer valid", "scsi.sns.sks.fp.bpv", FT_BOOLEAN, 24, NULL, 0x080000, NULL, HFILL}},
6810         { &hf_scsi_sks_fp_bit,
6811           {"Bit pointer", "scsi.sns.sks.fp.bit", FT_UINT24, BASE_DEC, NULL, 0x070000, NULL, HFILL}},
6812         { &hf_scsi_sks_fp_field,
6813           {"Field pointer", "scsi.sns.sks.fp.field", FT_UINT24, BASE_DEC, NULL, 0x00FFFF, NULL, HFILL}},
6814         { &hf_scsi_sns_desc_type,
6815           {"Sense data descriptor type", "scsi.sns.desc.type", FT_UINT8, BASE_HEX, VALS(scsi_sense_desc_type_val), 0, NULL, HFILL}},
6816         { &hf_scsi_sns_desc_length,
6817             {"Sense data descriptor length", "scsi.sns.desc.length", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL}},
6818         { &hf_scsi_sns_osd_object_not_initiated,
6819             {"Not initiated", "scsi.sns.desc.osd_object.not_initiated", FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL}},
6820         { &hf_scsi_sns_osd_object_completed,
6821             {"Completed", "scsi.sns.desc.osd_object.completed", FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL}},
6822         { &hf_scsi_sns_osd_object_validation,
6823             {"VALIDATION", "scsi.sns.desc.osd_object.validation", FT_BOOLEAN, 32, NULL, 0x80000000, NULL, HFILL}},
6824         { &hf_scsi_sns_osd_object_cmd_cap_v,
6825             {"CMD_CAP_V", "scsi.sns.desc.osd_object.cmd_cap_v",   FT_BOOLEAN, 32, NULL, 0x20000000, NULL, HFILL}},
6826         { &hf_scsi_sns_osd_object_command,
6827             {"COMMAND", "scsi.sns.desc.osd_object.command",       FT_BOOLEAN, 32, NULL, 0x10000000, NULL, HFILL}},
6828         { &hf_scsi_sns_osd_object_imp_st_att,
6829             {"IMP_ST_ATT", "scsi.sns.desc.osd_object.imp_st_att", FT_BOOLEAN, 32, NULL, 0x00100000, NULL, HFILL}},
6830         { &hf_scsi_sns_osd_object_sa_cap_v,
6831             {"SA_CAP_V", "scsi.sns.desc.osd_object.sa_cap_v",     FT_BOOLEAN, 32, NULL, 0x00002000, NULL, HFILL}},
6832         { &hf_scsi_sns_osd_object_set_att,
6833             {"SET_ATT", "scsi.sns.desc.osd_object.set_att",       FT_BOOLEAN, 32, NULL, 0x00001000, NULL, HFILL}},
6834         { &hf_scsi_sns_osd_object_ga_cap_v,
6835             {"GA_CAP_V", "scsi.sns.desc.osd_object.ga_cap_v",     FT_BOOLEAN, 32, NULL, 0x00000020, NULL, HFILL}},
6836         { &hf_scsi_sns_osd_object_get_att,
6837             {"GET_ATT", "scsi.sns.desc.osd_object.get_att",       FT_BOOLEAN, 32, NULL, 0x00000010, NULL, HFILL}},
6838         { &hf_scsi_sns_osd_partition_id,
6839             {"Partition ID", "scsi.sns.desc.osd_object.partition_id", FT_UINT64, BASE_HEX,  NULL, 0, NULL, HFILL}},
6840         { &hf_scsi_sns_osd_object_id,
6841             {"Object ID", "scsi.sns.desc.osd_object.object_id",  FT_UINT64, BASE_HEX,  NULL, 0, NULL, HFILL}},
6842         { &hf_scsi_sns_osd_attr_page,
6843             {"Attribute page", "scsi.sns.desc.osd_attr.page",      FT_UINT32, BASE_HEX | BASE_EXT_STRING,  &attributes_page_vals_ext, 0, NULL, HFILL}},
6844         { &hf_scsi_sns_osd_attr_number,
6845             {"Attribute number", "scsi.sns.desc.osd_attr.number",  FT_UINT32, BASE_HEX,  NULL, 0, NULL, HFILL}},
6846         { &hf_scsi_persresv_key,
6847             {"Reservation Key", "scsi.spc.resv.key", FT_BYTES, BASE_NONE, NULL,
6848            0x0, NULL, HFILL}},
6849         { &hf_scsi_persresv_scopeaddr,
6850           {"Scope Address", "scsi.spc.resv.scopeaddr", FT_BYTES, BASE_NONE, NULL,
6851            0x0, NULL, HFILL}},
6852         { &hf_scsi_add_cdblen,
6853           {"Additional CDB Length", "scsi.spc.addcdblen", FT_UINT8, BASE_DEC,
6854            NULL, 0x0, NULL, HFILL}},
6855         { &hf_scsi_svcaction,
6856           {"Service Action", "scsi.spc.svcaction", FT_UINT16, BASE_HEX, NULL,
6857            0x0, NULL, HFILL}},
6858         { &hf_scsi_wb_mode,
6859           {"Mode", "scsi.spc.wb.mode", FT_UINT8, BASE_HEX,
6860            VALS(scsi_wb_mode_val), 0xF, NULL, HFILL}},
6861         { &hf_scsi_wb_bufferid,
6862           {"Buffer ID", "scsi.spc.sb.bufid", FT_UINT8, BASE_DEC, NULL, 0x0,
6863            NULL, HFILL}},
6864         { &hf_scsi_wb_bufoffset,
6865           {"Buffer Offset", "scsi.spc.wb.bufoff", FT_UINT24, BASE_HEX, NULL,
6866            0x0, NULL, HFILL}},
6867         { &hf_scsi_paramlen24,
6868           {"Parameter List Length", "scsi.cdb.paramlen24", FT_UINT24, BASE_DEC_HEX,
6869            NULL, 0x0, NULL, HFILL}},
6870         { &hf_scsi_senddiag_st_code,
6871           {"Self-Test Code", "scsi.spc.senddiag.code", FT_UINT8, BASE_HEX,
6872            VALS(scsi_senddiag_st_code_val), 0xE0, NULL, HFILL}},
6873         { &hf_scsi_select_report,
6874           {"Select Report", "scsi.spc.select_report", FT_UINT8, BASE_HEX,
6875            VALS(scsi_select_report_val), 0x00, NULL, HFILL}},
6876         { &hf_scsi_senddiag_pf,
6877           {"PF", "scsi.spc.senddiag.pf", FT_BOOLEAN, 8,
6878            TFS(&scsi_senddiag_pf_val), 0x10, NULL, HFILL}},
6879         { &hf_scsi_senddiag_st,
6880           {"Self Test", "scsi.spc.senddiag.st", FT_BOOLEAN, 8, NULL,
6881            0x4, NULL, HFILL}},
6882         { &hf_scsi_senddiag_devoff,
6883           {"Device Offline", "scsi.spc.senddiag.devoff", FT_BOOLEAN, 8,
6884            NULL, 0x2, NULL, HFILL}},
6885         { &hf_scsi_senddiag_unitoff,
6886           {"Unit Offline", "scsi.spc.senddiag.unitoff", FT_BOOLEAN, 8,
6887            NULL, 0x1, NULL, HFILL}},
6888         { &hf_scsi_request_frame,
6889           { "Request in", "scsi.request_frame", FT_FRAMENUM, BASE_NONE, NULL, 0,
6890             "The request to this transaction is in this frame", HFILL }},
6891         { &hf_scsi_time,
6892           { "Time from request", "scsi.time", FT_RELATIVE_TIME, BASE_NONE, NULL, 0,
6893             "Time between the Command and the Response", HFILL }},
6894         { &hf_scsi_response_frame,
6895           { "Response in", "scsi.response_frame", FT_FRAMENUM, BASE_NONE, NULL, 0,
6896             "The response to this transaction is in this frame", HFILL }},
6897         { &hf_scsi_fragments,
6898           { "SCSI Fragments", "scsi.fragments", FT_NONE, BASE_NONE, NULL, 0x0,
6899             NULL, HFILL }},
6900         { &hf_scsi_fragment_overlap,
6901           { "Fragment overlap", "scsi.fragment.overlap", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
6902             "Fragment overlaps with other fragments", HFILL }},
6903         { &hf_scsi_fragment_overlap_conflict,
6904           { "Conflicting data in fragment overlap", "scsi.fragment.overlap.conflict", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
6905             "Overlapping fragments contained conflicting data", HFILL }},
6906         { &hf_scsi_fragment_multiple_tails,
6907           { "Multiple tail fragments found", "scsi.fragment.multipletails", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
6908             "Several tails were found when defragmenting the packet", HFILL }},
6909         { &hf_scsi_fragment_too_long_fragment,
6910           { "Fragment too long", "scsi.fragment.toolongfragment", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
6911             "Fragment contained data past end of packet", HFILL }},
6912         { &hf_scsi_fragment_error,
6913           { "Defragmentation error", "scsi.fragment.error", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
6914             "Defragmentation error due to illegal fragments", HFILL }},
6915         { &hf_scsi_fragment_count,
6916           { "Fragment count", "scsi.fragment.count", FT_UINT32, BASE_DEC, NULL, 0x0,
6917             NULL, HFILL }},
6918         { &hf_scsi_fragment,
6919           { "SCSI DATA Fragment", "scsi.fragment", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
6920             NULL, HFILL }},
6921         { &hf_scsi_reassembled_in,
6922           { "Reassembled SCSI DATA in frame", "scsi.reassembled_in", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
6923             "This SCSI DATA packet is reassembled in this frame", HFILL }},
6924         { &hf_scsi_reassembled_length,
6925           { "Reassembled SCSI DATA length", "scsi.reassembled.length", FT_UINT32, BASE_DEC, NULL, 0x0,
6926             "The total length of the reassembled payload", HFILL }},
6927         { &hf_scsi_log_ppc_flags,
6928           {"PPC Flags", "scsi.log.ppc.flags", FT_UINT8, BASE_HEX, NULL, 0,
6929            NULL, HFILL}},
6930         { &hf_scsi_log_ppc,
6931           {"PPC", "scsi.log.ppc", FT_BOOLEAN, 8,
6932            TFS(&scsi_log_ppc_tfs), 0x02, NULL, HFILL}},
6933         { &hf_scsi_log_pcr,
6934           {"PCR", "scsi.log.pcr", FT_BOOLEAN, 8,
6935            TFS(&scsi_log_pcr_tfs), 0x02, NULL, HFILL}},
6936         { &hf_scsi_log_sp,
6937           {"SP", "scsi.log.sp", FT_BOOLEAN, 8,
6938            TFS(&scsi_log_sp_tfs), 0x01, NULL, HFILL}},
6939         { &hf_scsi_log_pc_flags,
6940           {"PC Flags", "scsi.log.pc.flags", FT_UINT8, BASE_HEX, NULL, 0,
6941            NULL, HFILL}},
6942         { &hf_scsi_log_parameter_ptr,
6943           {"Parameter Pointer", "scsi.log.param_ptr", FT_UINT8, BASE_HEX, NULL,
6944            0, NULL, HFILL}},
6945         { &hf_scsi_log_page_length,
6946           {"Page Length", "scsi.log.page_length", FT_UINT16, BASE_DEC, NULL, 0,
6947            NULL, HFILL}},
6948         { &hf_scsi_log_parameter_code,
6949           {"Parameter Code", "scsi.log.parameter_code", FT_UINT16, BASE_HEX, NULL, 0,
6950            NULL, HFILL}},
6951         { &hf_scsi_log_param_flags,
6952           {"Param Flags", "scsi.log.param.flags", FT_UINT8, BASE_HEX, NULL, 0,
6953            NULL, HFILL}},
6954         { &hf_scsi_log_param_len,
6955           {"Parameter Len", "scsi.log.param_len", FT_UINT8, BASE_DEC, NULL, 0,
6956            NULL, HFILL}},
6957         { &hf_scsi_log_param_data,
6958           {"Parameter Data", "scsi.log.param_data", FT_BYTES, BASE_NONE, NULL, 0,
6959            NULL, HFILL}},
6960         { &hf_scsi_log_pf_du,
6961           {"DU", "scsi.log.pf.du", FT_BOOLEAN, 8, NULL, 0x80,
6962            NULL, HFILL}},
6963         { &hf_scsi_log_pf_ds,
6964           {"DS", "scsi.log.pf.ds", FT_BOOLEAN, 8, NULL, 0x40,
6965            NULL, HFILL}},
6966         { &hf_scsi_log_pf_tsd,
6967           {"TSD", "scsi.log.pf.tsd", FT_BOOLEAN, 8, NULL, 0x20,
6968            NULL, HFILL}},
6969         { &hf_scsi_log_pf_etc,
6970           {"ETC", "scsi.log.pf.etc", FT_BOOLEAN, 8, NULL, 0x10,
6971            NULL, HFILL}},
6972         { &hf_scsi_log_pf_tmc,
6973           {"TMC", "scsi.log.pf.tmc", FT_UINT8, BASE_HEX, VALS(log_flags_tmc_vals), 0x0c,
6974            NULL, HFILL}},
6975         { &hf_scsi_log_pf_lbin,
6976           {"LBIN", "scsi.log.pf.lbin", FT_BOOLEAN, 8, NULL, 0x02,
6977            NULL, HFILL}},
6978         { &hf_scsi_log_pf_lp,
6979           {"LP", "scsi.log.pf.lp", FT_BOOLEAN, 8, NULL, 0x01,
6980            NULL, HFILL}},
6981         { &hf_scsi_log_ta_rw,
6982           {"Read Warning", "scsi.log.ta.rw", FT_BOOLEAN, 8, NULL, 0x01,
6983            NULL, HFILL}},
6984         { &hf_scsi_log_ta_ww,
6985           {"write warning", "scsi.log.ta.ww", FT_BOOLEAN, 8, NULL, 0x01,
6986            NULL, HFILL}},
6987         { &hf_scsi_log_ta_he,
6988           {"hard error", "scsi.log.ta.he", FT_BOOLEAN, 8, NULL, 0x01,
6989            NULL, HFILL}},
6990         { &hf_scsi_log_ta_media,
6991           {"media", "scsi.log.ta.media", FT_BOOLEAN, 8, NULL, 0x01,
6992            NULL, HFILL}},
6993         { &hf_scsi_log_ta_rf,
6994           {"read failure", "scsi.log.ta.rf", FT_BOOLEAN, 8, NULL, 0x01,
6995            NULL, HFILL}},
6996         { &hf_scsi_log_ta_wf,
6997           {"write failure", "scsi.log.ta.wf", FT_BOOLEAN, 8, NULL, 0x01,
6998            NULL, HFILL}},
6999         { &hf_scsi_log_ta_ml,
7000           {"media life", "scsi.log.ta.ml", FT_BOOLEAN, 8, NULL, 0x01,
7001            NULL, HFILL}},
7002         { &hf_scsi_log_ta_ndg,
7003           {"not data grade", "scsi.log.ta.ndg", FT_BOOLEAN, 8, NULL, 0x01,
7004            NULL, HFILL}},
7005         { &hf_scsi_log_ta_wp,
7006           {"write protect", "scsi.log.ta.wp", FT_BOOLEAN, 8, NULL, 0x01,
7007            NULL, HFILL}},
7008         { &hf_scsi_log_ta_nr,
7009           {"no removal", "scsi.log.ta.nr", FT_BOOLEAN, 8, NULL, 0x01,
7010            NULL, HFILL}},
7011         { &hf_scsi_log_ta_cm,
7012           {"cleaning media", "scsi.log.ta.cm", FT_BOOLEAN, 8, NULL, 0x01,
7013            NULL, HFILL}},
7014         { &hf_scsi_log_ta_uf,
7015           {"unsupported format", "scsi.log.ta.uf", FT_BOOLEAN, 8, NULL, 0x01,
7016            NULL, HFILL}},
7017         { &hf_scsi_log_ta_rmcf,
7018           {"removable mechanical cartridge failure", "scsi.log.ta.rmcf", FT_BOOLEAN, 8, NULL, 0x01,
7019            NULL, HFILL}},
7020         { &hf_scsi_log_ta_umcf,
7021           {"unrecoverable mechanical cartridge failure", "scsi.log.ta.umcf", FT_BOOLEAN, 8, NULL, 0x01,
7022            NULL, HFILL}},
7023         { &hf_scsi_log_ta_mcicf,
7024           {"memory chip in cartridge failure", "scsi.log.ta.mcicf", FT_BOOLEAN, 8, NULL, 0x01,
7025            NULL, HFILL}},
7026         { &hf_scsi_log_ta_fe,
7027           {"forced eject", "scsi.log.ta.fe", FT_BOOLEAN, 8, NULL, 0x01,
7028            NULL, HFILL}},
7029         { &hf_scsi_log_ta_rof,
7030           {"read only format", "scsi.log.ta.rof", FT_BOOLEAN, 8, NULL, 0x01,
7031            NULL, HFILL}},
7032         { &hf_scsi_log_ta_tdcol,
7033           {"tape directory corrupted on load", "scsi.log.ta.tdcol", FT_BOOLEAN, 8, NULL, 0x01,
7034            NULL, HFILL}},
7035         { &hf_scsi_log_ta_nml,
7036           {"nearing media life", "scsi.log.ta.nml", FT_BOOLEAN, 8, NULL, 0x01,
7037            NULL, HFILL}},
7038         { &hf_scsi_log_ta_cn,
7039           {"clean now", "scsi.log.ta.cn", FT_BOOLEAN, 8, NULL, 0x01,
7040            NULL, HFILL}},
7041         { &hf_scsi_log_ta_cp,
7042           {"clean periodic", "scsi.log.ta.cp", FT_BOOLEAN, 8, NULL, 0x01,
7043            NULL, HFILL}},
7044         { &hf_scsi_log_ta_ecm,
7045           {"expired cleaning media", "scsi.log.ta.ecm", FT_BOOLEAN, 8, NULL, 0x01,
7046            NULL, HFILL}},
7047         { &hf_scsi_log_ta_ict,
7048           {"invalid cleaning tape", "scsi.log.ta.ict", FT_BOOLEAN, 8, NULL, 0x01,
7049            NULL, HFILL}},
7050         { &hf_scsi_log_ta_rr,
7051           {"retention requested", "scsi.log.ta.rr", FT_BOOLEAN, 8, NULL, 0x01,
7052            NULL, HFILL}},
7053         { &hf_scsi_log_ta_dpie,
7054           {"dual port interface error", "scsi.log.ta.dpie", FT_BOOLEAN, 8, NULL, 0x01,
7055            NULL, HFILL}},
7056         { &hf_scsi_log_ta_cff,
7057           {"cooling fan failure", "scsi.log.ta.cff", FT_BOOLEAN, 8, NULL, 0x01,
7058            NULL, HFILL}},
7059         { &hf_scsi_log_ta_psf,
7060           {"power supply failure", "scsi.log.ta.psf", FT_BOOLEAN, 8, NULL, 0x01,
7061            NULL, HFILL}},
7062         { &hf_scsi_log_ta_pc,
7063           {"power consumption", "scsi.log.ta.pc", FT_BOOLEAN, 8, NULL, 0x01,
7064            NULL, HFILL}},
7065         { &hf_scsi_log_ta_dm,
7066           {"drive maintenance", "scsi.log.ta.dm", FT_BOOLEAN, 8, NULL, 0x01,
7067            NULL, HFILL}},
7068         { &hf_scsi_log_ta_hwa,
7069           {"hardware a", "scsi.log.ta.hwa", FT_BOOLEAN, 8, NULL, 0x01,
7070            NULL, HFILL}},
7071         { &hf_scsi_log_ta_hwb,
7072           {"hardware b", "scsi.log.ta.hwb", FT_BOOLEAN, 8, NULL, 0x01,
7073            NULL, HFILL}},
7074         { &hf_scsi_log_ta_if,
7075           {"interface", "scsi.log.ta.if", FT_BOOLEAN, 8, NULL, 0x01,
7076            NULL, HFILL}},
7077         { &hf_scsi_log_ta_em,
7078           {"eject media", "scsi.log.ta.em", FT_BOOLEAN, 8, NULL, 0x01,
7079            NULL, HFILL}},
7080         { &hf_scsi_log_ta_dwf,
7081           {"download failed", "scsi.log.ta.dwf", FT_BOOLEAN, 8, NULL, 0x01,
7082            NULL, HFILL}},
7083         { &hf_scsi_log_ta_drhu,
7084           {"drive humidity", "scsi.log.ta.drhu", FT_BOOLEAN, 8, NULL, 0x01,
7085            NULL, HFILL}},
7086         { &hf_scsi_log_ta_drtm,
7087           {"drive temperature", "scsi.log.ta.drtm", FT_BOOLEAN, 8, NULL, 0x01,
7088            NULL, HFILL}},
7089         { &hf_scsi_log_ta_drvo,
7090           {"drive voltage", "scsi.log.ta.drvo", FT_BOOLEAN, 8, NULL, 0x01,
7091            NULL, HFILL}},
7092         { &hf_scsi_log_ta_pefa,
7093           {"periodic failure", "scsi.log.ta.pefa", FT_BOOLEAN, 8, NULL, 0x01,
7094            NULL, HFILL}},
7095         { &hf_scsi_log_ta_dire,
7096           {"diagnostics required", "scsi.log.ta.dire", FT_BOOLEAN, 8, NULL, 0x01,
7097            NULL, HFILL}},
7098         { &hf_scsi_log_ta_lost,
7099           {"lost statistics", "scsi.log.ta.lost", FT_BOOLEAN, 8, NULL, 0x01,
7100            NULL, HFILL}},
7101         { &hf_scsi_log_ta_tduau,
7102           {"tape directory invalid at unload", "scsi.log.ta.tduau", FT_BOOLEAN, 8, NULL, 0x01,
7103            NULL, HFILL}},
7104         { &hf_scsi_log_ta_tsawf,
7105           {"tape system area write failure", "scsi.log.ta.tsawf", FT_BOOLEAN, 8, NULL, 0x01,
7106            NULL, HFILL}},
7107         { &hf_scsi_log_ta_tsarf,
7108           {"tape system area read failure", "scsi.log.ta.tsarf", FT_BOOLEAN, 8, NULL, 0x01,
7109            NULL, HFILL}},
7110         { &hf_scsi_log_ta_nsod,
7111           {"no start of data", "scsi.log.ta.nsod", FT_BOOLEAN, 8, NULL, 0x01,
7112            NULL, HFILL}},
7113         { &hf_scsi_log_ta_lofa,
7114           {"loading failure", "scsi.log.ta.lofa", FT_BOOLEAN, 8, NULL, 0x01,
7115            NULL, HFILL}},
7116         { &hf_scsi_log_ta_uuf,
7117           {"unrecoverable unload failure", "scsi.log.ta.uuf", FT_BOOLEAN, 8, NULL, 0x01,
7118            NULL, HFILL}},
7119         { &hf_scsi_log_ta_aif,
7120           {"automatic interface failure", "scsi.log.ta.aif", FT_BOOLEAN, 8, NULL, 0x01,
7121            NULL, HFILL}},
7122         { &hf_scsi_log_ta_fwf,
7123           {"firmware failure", "scsi.log.ta.fwf", FT_BOOLEAN, 8, NULL, 0x01,
7124            NULL, HFILL}},
7125         { &hf_scsi_log_ta_wmicf,
7126           {"worm medium integrity check failed", "scsi.log.ta.wmicf", FT_BOOLEAN, 8, NULL, 0x01,
7127            NULL, HFILL}},
7128         { &hf_scsi_log_ta_wmoa,
7129           {"worm medium overwrite attempted", "scsi.log.ta.wmoa", FT_BOOLEAN, 8, NULL, 0x01,
7130            NULL, HFILL}},
7131         { &hf_scsi_sbc_threshold_exponent,
7132           {"Threshold Exponent", "scsi_sbc.threshold_exponent", FT_UINT8, BASE_DEC, NULL, 0,
7133            NULL, HFILL}},
7134         { &hf_scsi_sbc_lbpu,
7135           {"LBPU (logical block provisioning UNMAP)", "scsi_sbc.lbpu", FT_BOOLEAN, 8, NULL, 0x80,
7136            NULL, HFILL}},
7137         { &hf_scsi_sbc_lbpws,
7138           {"LBPWS (logical block provisioning WRITE SAME)", "scsi_sbc.lbpws", FT_BOOLEAN, 8, NULL, 0x40,
7139            NULL, HFILL}},
7140         { &hf_scsi_sbc_lbpws10,
7141           {"LBPWS10 (logical block provisioning WRITE SAME (10) )", "scsi_sbc.lbpws10", FT_BOOLEAN, 8, NULL, 0x20,
7142            NULL, HFILL}},
7143         { &hf_scsi_sbc_lbprz,
7144           {"LBPRZ (logical block provisioning read zeros)", "scsi_sbc.lbprz", FT_BOOLEAN, 8, NULL, 0x04,
7145            NULL, HFILL}},
7146         { &hf_scsi_sbc_anc_sup,
7147           {"ANC_SUP (anchor supported)", "scsi_sbc.anc_sup", FT_BOOLEAN, 8, NULL, 0x02,
7148            NULL, HFILL}},
7149         { &hf_scsi_sbc_dp,
7150           {"DP (descriptor present)", "scsi_sbc.dp", FT_BOOLEAN, 8, NULL, 0x01,
7151            NULL, HFILL}},
7152         { &hf_scsi_sbc_ptype,
7153           {"Provisioning Type", "scsi_sbc.ptype", FT_UINT8, BASE_DEC, VALS(provisioning_vals), 0x07,
7154            NULL, HFILL}},
7155         { &hf_scsi_block_limits_wsnz,
7156           {"WSNZ (write same non-zero)", "scsi_sbc.bl.wsnz", FT_BOOLEAN, 8, NULL, 0x01,
7157            NULL, HFILL}},
7158         { &hf_scsi_block_limits_mcawl,
7159           {"Maximum Compare And Write Length", "scsi_sbc.bl.mcawl", FT_UINT8, BASE_DEC, NULL, 0,
7160            NULL, HFILL}},
7161         { &hf_scsi_block_limits_otlg,
7162           {"Optimal Transfer Length Granularity", "scsi_sbc.bl.otlg", FT_UINT16, BASE_DEC, NULL, 0,
7163            NULL, HFILL}},
7164         { &hf_scsi_block_limits_mtl,
7165           {"Maximum Transfer Length", "scsi_sbc.bl.mtl", FT_UINT32, BASE_DEC, NULL, 0,
7166            NULL, HFILL}},
7167         { &hf_scsi_block_limits_otl,
7168           {"Optimal Transfer Length", "scsi_sbc.bl.otl", FT_UINT32, BASE_DEC, NULL, 0,
7169            NULL, HFILL}},
7170         { &hf_scsi_block_limits_mpl,
7171           {"Optimal Prefetch/Xdread/Xdwrite Transfer Length", "scsi_sbc.bl.mpl", FT_UINT32, BASE_DEC, NULL, 0,
7172            NULL, HFILL}},
7173         { &hf_scsi_block_limits_mulc,
7174           {"Maximum Unmap LBA Count", "scsi_sbc.bl.mulc", FT_UINT32, BASE_DEC, NULL, 0,
7175            NULL, HFILL}},
7176         { &hf_scsi_block_limits_mubdc,
7177           {"Maximum Unmap Block Descriptor Count", "scsi_sbc.bl.mubdc", FT_UINT32, BASE_DEC, NULL, 0,
7178            NULL, HFILL}},
7179         { &hf_scsi_block_limits_oug,
7180           {"Optimal Unmap Block Granularity", "scsi_sbc.bl.oug", FT_UINT32, BASE_DEC, NULL, 0,
7181            NULL, HFILL}},
7182         { &hf_scsi_block_limits_ugavalid,
7183           {"UGAVALID", "scsi_sbc.bl.ugavalid", FT_BOOLEAN, 8, NULL, 0x80,
7184            NULL, HFILL}},
7185         { &hf_scsi_block_limits_uga,
7186           {"Unmap Granularity Alignment", "scsi_sbc.bl.uga", FT_UINT32, BASE_DEC, NULL, 0x7fffffff,
7187            NULL, HFILL}},
7188         { &hf_scsi_block_limits_mwsl,
7189           {"Maximum Write Same Length", "scsi_sbc.bl.mwsl", FT_UINT64, BASE_DEC, NULL, 0,
7190            NULL, HFILL}},
7191         { &hf_scsi_block_limits_matl,
7192           {"Maximum Atomic Transfer Length", "scsi_sbc.bl.matl", FT_UINT32, BASE_DEC, NULL, 0,
7193            NULL, HFILL}},
7194         { &hf_scsi_block_limits_aa,
7195           {"Atomic Alignment", "scsi_sbc.bl.aa", FT_UINT32, BASE_DEC, NULL, 0,
7196            NULL, HFILL}},
7197         { &hf_scsi_block_limits_atlg,
7198           {"Atomic Transfer Length Granularity", "scsi_sbc.bl.atlg", FT_UINT32, BASE_DEC, NULL, 0,
7199            NULL, HFILL}},
7200         { &hf_scsi_modepage_ps,
7201           {"PS", "scsi.spc.modepage.ps", FT_BOOLEAN, 8, NULL, 0x80,
7202            NULL, HFILL}},
7203         { &hf_scsi_modepage_spf,
7204           {"SPF", "scsi.spc.modepage.spf", FT_BOOLEAN, 8, NULL, 0x40,
7205            NULL, HFILL}},
7206         { &hf_scsi_modepage_plen,
7207           {"Page Length", "scsi.spc.modepage.plen", FT_UINT16, BASE_DEC, NULL, 0,
7208            NULL, HFILL}},
7209         { &hf_scsi_modepage_tcmos,
7210           {"TCMOS", "scsi.spc.modepage.tcmos", FT_BOOLEAN, 8, NULL, 0x04,
7211            NULL, HFILL}},
7212         { &hf_scsi_modepage_scsip,
7213           {"SCSIP", "scsi.spc.modepage.scsip", FT_BOOLEAN, 8, NULL, 0x02,
7214            NULL, HFILL}},
7215         { &hf_scsi_modepage_ialuae,
7216           {"IALUAE", "scsi.spc.modepage.ialuae", FT_BOOLEAN, 8, NULL, 0x01,
7217            NULL, HFILL}},
7218         { &hf_scsi_modepage_icp,
7219           {"Initial Command Priority", "scsi.spc.modepage.icp", FT_UINT8, BASE_DEC,
7220            NULL, 0x0f, NULL, HFILL}},
7221         { &hf_scsi_modepage_msdl,
7222           {"Maximum Sense Data Length", "scsi.spc.modepage.msdl", FT_UINT8, BASE_DEC,
7223            NULL, 0, NULL, HFILL}},
7224         { &hf_scsi_lun,
7225           { "LUN", "scsi.lun", FT_UINT16, BASE_HEX,
7226            NULL, 0, "Logical Unit Number", HFILL }},
7227         { &hf_scsi_lun_extended,
7228           { "LUN", "scsi.lun_long", FT_UINT64, BASE_HEX,
7229            NULL, 0, "Logical Unit Number", HFILL }},
7230         /* hf_scsi_bus has length of 0x6 with 2bit offset, or 0x3 with no offset
7231            so we handle it with add_bits_item */
7232         { &hf_scsi_bus,
7233           { "BUS", "scsi.bus", FT_UINT8, BASE_HEX,
7234            NULL, 0, NULL, HFILL }},
7235         { &hf_scsi_target,
7236           { "Target", "scsi.target", FT_UINT8, BASE_HEX,
7237            NULL, 0x3f, NULL, HFILL }},
7238         { &hf_scsi_lun_address_mode,
7239           { "Address Mode", "scsi.lun.address_mode", FT_UINT8, BASE_HEX,
7240           VALS(scsi_lun_address_mode_vals), 0xc0, "Addressing mode for the LUN", HFILL }},
7241         { &hf_scsi_extended_add_method_len,
7242           { "Extended Address Method Length", "scsi.lun.extended_address_method.len", FT_UINT8, BASE_DEC_HEX,
7243           NULL, 0x30, "Extended Address Method Specific Field", HFILL }},
7244         { &hf_scsi_extended_add_method,
7245           { "Extended Address Method", "scsi.lun.extended_address_method", FT_UINT8, BASE_HEX,
7246           NULL, 0xf, "Extended Logical Unit Addressing", HFILL }},
7247         { &hf_scsi_prevent_allow_flags,
7248           {"Prevent Allow Flags", "scsi.prevent_allow.flags", FT_UINT8, BASE_HEX, NULL, 0,
7249            NULL, HFILL}},
7250         { &hf_scsi_prevent_allow_prevent,
7251           { "PREVENT", "scsi.prevent_allow.prevent", FT_BOOLEAN, 8,
7252             NULL, 0x01, NULL, HFILL}},
7253         { &hf_scsi_mpi_service_action,
7254           { "Service Action", "scsi.mpi.service_action", FT_UINT8, BASE_HEX,
7255           VALS(mpi_action_vals), 0x1f, "Management Protocol In Service Action", HFILL }},
7256         { &hf_scsi_report_opcodes_rctd,
7257           { "RCTD", "scsi.report_opcodes.rctd", FT_BOOLEAN, 8,
7258             NULL, 0x80, NULL, HFILL}},
7259         { &hf_scsi_report_opcodes_options,
7260           { "Reporting Options", "scsi.report_opcodes.options", FT_UINT8, BASE_HEX,
7261             VALS(report_opcodes_options_vals), 0x07, NULL, HFILL}},
7262         { &hf_scsi_report_opcodes_requested_o,
7263           { "Requested Operation Code", "scsi.report_opcodes.requested_operation_code", FT_UINT8, BASE_HEX,
7264             NULL, 0, NULL, HFILL}},
7265         { &hf_scsi_report_opcodes_requested_sa,
7266           { "Requested Service Action", "scsi.report_opcodes.requested_service_action", FT_UINT16, BASE_HEX,
7267             NULL, 0, NULL, HFILL}},
7268         { &hf_scsi_report_opcodes_cdl,
7269           { "Command Data Length", "scsi.report_opcodes.command_data_length", FT_UINT32, BASE_DEC,
7270             NULL, 0, NULL, HFILL}},
7271         { &hf_scsi_report_opcodes_sa,
7272           { "Service Action", "scsi.report_opcodes.service_action", FT_UINT16, BASE_DEC,
7273             NULL, 0, NULL, HFILL}},
7274         { &hf_scsi_report_opcodes_ctdp,
7275           { "CTDP", "scsi.report_opcodes.ctdp", FT_BOOLEAN, 8,
7276             NULL, 0x02, NULL, HFILL}},
7277         { &hf_scsi_report_opcodes_ctdp_one,
7278           { "CTDP", "scsi.report_opcodes_one.ctdp", FT_BOOLEAN, 8,
7279             NULL, 0x80, NULL, HFILL}},
7280         { &hf_scsi_report_opcodes_servactv,
7281           { "SERVACTV", "scsi.report_opcodes.servactv", FT_BOOLEAN, 8,
7282             NULL, 0x01, NULL, HFILL}},
7283         { &hf_scsi_report_opcodes_cdb_length,
7284           { "CDB Length", "scsi.report_opcodes.cdb_length", FT_UINT16, BASE_DEC,
7285             NULL, 0, NULL, HFILL}},
7286         { &hf_scsi_report_opcodes_support,
7287           { "Support", "scsi.report_opcodes.support", FT_UINT8, BASE_DEC,
7288             NULL, 0x07, NULL, HFILL}},
7289         { &hf_scsi_report_opcodes_cdb_usage_data,
7290           {"CDB Usage Data", "scsi.report_opcodes.cdb_usage_data", FT_BYTES, BASE_NONE,
7291        NULL, 0, NULL, HFILL}},
7292         { &hf_scsi_report_opcodes_tdl,
7293           { "Timeout Descriptor Length", "scsi.report_opcodes.timeout_descriptor_length", FT_UINT16, BASE_DEC,
7294             NULL, 0, NULL, HFILL}},
7295         { &hf_scsi_report_opcodes_npt,
7296             { "Nominal Command Processing Timeout", "scsi.report_opcodes.ncpt", FT_UINT32, BASE_DEC,
7297                 NULL, 0, NULL, HFILL}},
7298         { &hf_scsi_report_opcodes_rct,
7299             { "Recommended Command Timeout", "scsi.report_opcodes.rct", FT_UINT32, BASE_DEC,
7300                 NULL, 0, NULL, HFILL}},
7301         { &hf_scsi_inquiry_bdc_mrr,
7302             { "Medium Rotation Rate", "scsi.inquiry.bdc.mrr", FT_UINT16, BASE_DEC,
7303                 VALS(mrr_val), 0, NULL, HFILL}},
7304         { &hf_scsi_inquiry_bdc_pt,
7305             { "Product Type", "scsi.inquiry.bdc.pt", FT_UINT8, BASE_DEC,
7306                 NULL, 0, NULL, HFILL}},
7307         { &hf_scsi_inquiry_bdc_wabereq,
7308             { "WABEREQ", "scsi.inquiry.bdc.wabereq", FT_UINT8, BASE_DEC,
7309                 NULL, 0xc0, NULL, HFILL}},
7310         { &hf_scsi_inquiry_bdc_wacereq,
7311             { "WACEREQ", "scsi.inquiry.bdc.wacereq", FT_UINT8, BASE_DEC,
7312                 NULL, 0x30, NULL, HFILL}},
7313         { &hf_scsi_inquiry_bdc_nff,
7314           { "Nominal Form factor", "scsi.inquiry.bdc.nff", FT_UINT8, BASE_DEC,
7315               NULL, 0x0f, NULL, HFILL}},
7316         { &hf_scsi_inquiry_bdc_fuab,
7317             { "FUAB", "scsi.inquiry.bdc.fuab", FT_BOOLEAN, 8,
7318                 NULL, 0x02, NULL, HFILL}},
7319         { &hf_scsi_inquiry_bdc_vbuls,
7320             { "VBULS", "scsi.inquiry.bdc.vbuls", FT_BOOLEAN, 8,
7321                 NULL, 0x01, NULL, HFILL}},
7322 
7323       /* Generated from convert_proto_tree_add_text.pl */
7324       { &hf_scsi_inq_evpd_page_length, { "Page Length", "scsi.inquiry.evpd.pagelength", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7325       { &hf_scsi_inq_evpd_supported_page, { "Supported Page", "scsi.inquiry.evpd.supported_page", FT_UINT8, BASE_HEX, VALS(scsi_evpd_pagecode_val), 0x0, NULL, HFILL }},
7326       { &hf_scsi_inq_evpd_devid_code_set, { "Code Set", "scsi.inquiry.evpd.devid.code_set", FT_UINT8, BASE_HEX, VALS(scsi_devid_codeset_val), 0x0F, NULL, HFILL }},
7327       { &hf_scsi_inq_evpd_devid_association, { "Association", "scsi.inquiry.evpd.devid.association", FT_UINT8, BASE_HEX, VALS(scsi_devid_assoc_val), 0x30, NULL, HFILL }},
7328       { &hf_scsi_inq_evpd_devid_identifier_type, { "Identifier Type", "scsi.inquiry.evpd.devid.identifier_type", FT_UINT8, BASE_HEX, VALS(scsi_devid_idtype_val), 0x0F, NULL, HFILL }},
7329       { &hf_scsi_inq_evpd_identifier_number, { "Identifier Number", "scsi.inquiry.evpd.identifier_number", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7330       { &hf_scsi_inq_evpd_devid_identifier_length, { "Identifier Length", "scsi.inquiry.evpd.devid.identifier_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7331       { &hf_scsi_inq_evpd_devid_identifier_str, { "Identifier", "scsi.inquiry.evpd.devid.identifier_str", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
7332       { &hf_scsi_inq_evpd_devid_identifier_bytes, { "Identifier", "scsi.inquiry.evpd.devid.identifier_bytes", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
7333       { &hf_scsi_inq_evpd_product_serial_number, { "Product Serial Number", "scsi.inquiry.evpd.product_serial_number", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
7334       { &hf_scsi_inq_cmddt_support, { "Support", "scsi.inquiry.cmddt.support", FT_UINT8, BASE_DEC, VALS(scsi_cmdt_supp_val), 0x07, NULL, HFILL }},
7335       { &hf_scsi_inq_cmddt_version, { "Version", "scsi.inquiry.cmddt.version", FT_UINT8, BASE_HEX|BASE_EXT_STRING, &scsi_verdesc_val_ext, 0x0, NULL, HFILL }},
7336       { &hf_scsi_inq_cmddt_cdb_size, { "CDB Size", "scsi.inquiry.cmddt.cdb_size", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7337       { &hf_scsi_blockdescs_no_of_blocks64, { "No. of Blocks", "scsi.blockdescs.no_of_blocks64", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7338       { &hf_scsi_blockdescs_density_code, { "Density Code", "scsi.blockdescs.density_code", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
7339       { &hf_scsi_blockdescs_block_length32, { "Block Length", "scsi.blockdescs.block_length", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7340       { &hf_scsi_blockdescs_no_of_blocks32, { "No. of Blocks", "scsi.blockdescs.no_of_blocks", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7341       { &hf_scsi_blockdescs_block_length24, { "Block Length", "scsi.blockdescs.block_length", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7342       { &hf_scsi_blockdescs_no_of_blocks24, { "No. of Blocks", "scsi.blockdescs.no_of_blocks", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7343       { &hf_scsi_spc_modepage_gltsd, { "Global Logging Target Save Disable", "scsi.spc.modepage.gltsd", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7344       { &hf_scsi_spc_modepage_disable_queuing, { "Disable Queuing", "scsi.spc.modepage.disable_queuing", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7345       { &hf_scsi_spc_modepage_swp, { "SWP", "scsi.spc.modepage.swp", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7346       { &hf_scsi_spc_modepage_autoload_mode, { "Autoload Mode", "scsi.spc.modepage.autoload_mode", FT_UINT8, BASE_HEX, NULL, 0x07, NULL, HFILL }},
7347       { &hf_scsi_spc_modepage_ready_aer_holdoff_period, { "Ready AER Holdoff Period (ms)", "scsi.spc.modepage.ready_aer_holdoff_period", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7348       { &hf_scsi_spc_modepage_busy_timeout_period, { "Busy Timeout Period (ms)", "scsi.spc.modepage.busy_timeout_period", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7349       { &hf_scsi_spc_modepage_extended_self_test_completion_time, { "Extended Self-Test Completion Time", "scsi.spc.modepage.extended_self_test_completion_time", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7350       { &hf_scsi_spc_modepage_buffer_full_ratio, { "Buffer Full Ratio", "scsi.spc.modepage.buffer_full_ratio", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7351       { &hf_scsi_spc_modepage_buffer_empty_ratio, { "Buffer Empty Ratio", "scsi.spc.modepage.buffer_empty_ratio", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7352       { &hf_scsi_spc_modepage_bus_inactivity_limit, { "Bus Inactivity Limit", "scsi.spc.modepage.bus_inactivity_limit", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7353       { &hf_scsi_spc_modepage_disconnect_time_limit, { "Disconnect Time Limit", "scsi.spc.modepage.disconnect_time_limit", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7354       { &hf_scsi_spc_modepage_connect_time_limit, { "Connect Time Limit", "scsi.spc.modepage.connect_time_limit", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7355       { &hf_scsi_spc_modepage_maximum_burst_size, { "Maximum Burst Size (bytes)", "scsi.spc.modepage.maximum_burst_size", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7356       { &hf_scsi_spc_modepage_emdp, { "EMDP", "scsi.spc.modepage.emdp", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
7357       { &hf_scsi_spc_modepage_first_burst_size, { "First Burst Size (bytes)", "scsi.spc.modepage.first_burst_size", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7358       { &hf_scsi_spc_modepage_perf, { "Perf", "scsi.spc.modepage.perf", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
7359       { &hf_scsi_spc_modepage_interval_timer, { "Interval Timer", "scsi.spc.modepage.interval_timer", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7360       { &hf_scsi_spc_modepage_report_count, { "Report Count", "scsi.spc.modepage.report_count", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7361       { &hf_scsi_spc_modepage_idle, { "Idle", "scsi.spc.modepage.idle", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7362       { &hf_scsi_spc_modepage_idle_condition_timer, { "Idle Condition Timer (ms)", "scsi.spc.modepage.idle_condition_timer", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7363       { &hf_scsi_spc_modepage_standby_condition_timer, { "Standby Condition Timer (ms)", "scsi.spc.modepage.standby_condition_timer", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7364       { &hf_scsi_spc_modepage_dtfd, { "DTFD", "scsi.spc.modepage.dtfd", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
7365       { &hf_scsi_spc_modepage_rr_tov_units, { "RR_TOV Units", "scsi.spc.modepage.rr_tov_units", FT_UINT8, BASE_DEC, VALS(scsi_fcp_rrtov_val), 0x07, NULL, HFILL }},
7366       { &hf_scsi_spc_modepage_rr_tov, { "RR_TOV", "scsi.spc.modepage.rr_tov", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7367       { &hf_scsi_sbc_modepage_tracks_per_zone, { "Tracks Per Zone", "scsi.sbc.modepage.tracks_per_zone", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7368       { &hf_scsi_sbc_modepage_alternate_sectors_per_zone, { "Alternate Sectors Per Zone", "scsi.sbc.modepage.alternate_sectors_per_zone", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7369       { &hf_scsi_sbc_modepage_alternate_tracks_per_zone, { "Alternate Tracks Per Zone", "scsi.sbc.modepage.alternate_tracks_per_zone", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7370       { &hf_scsi_sbc_modepage_alternate_tracks_per_lu, { "Alternate Tracks Per LU", "scsi.sbc.modepage.alternate_tracks_per_lu", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7371       { &hf_scsi_sbc_modepage_sectors_per_track, { "Sectors Per Track", "scsi.sbc.modepage.sectors_per_track", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7372       { &hf_scsi_sbc_modepage_data_bytes_per_physical_sector, { "Data Bytes Per Physical Sector", "scsi.sbc.modepage.data_bytes_per_physical_sector", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7373       { &hf_scsi_sbc_modepage_interleave, { "Interleave", "scsi.sbc.modepage.interleave", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7374       { &hf_scsi_sbc_modepage_track_skew_factor, { "Track Skew Factor", "scsi.sbc.modepage.track_skew_factor", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7375       { &hf_scsi_sbc_modepage_cylinder_skew_factor, { "Cylinder Skew Factor", "scsi.sbc.modepage.cylinder_skew_factor", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7376       { &hf_scsi_sbc_modepage_ssec, { "SSEC", "scsi.sbc.modepage.ssec", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
7377       { &hf_scsi_sbc_modepage_awre, { "AWRE", "scsi.sbc.modepage.awre", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
7378       { &hf_scsi_sbc_modepage_read_retry_count, { "Read Retry Count", "scsi.sbc.modepage.read_retry_count", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7379       { &hf_scsi_sbc_modepage_correction_span, { "Correction Span", "scsi.sbc.modepage.correction_span", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7380       { &hf_scsi_sbc_modepage_head_offset_count, { "Head Offset Count", "scsi.sbc.modepage.head_offset_count", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7381       { &hf_scsi_sbc_modepage_data_strobe_offset_count, { "Data Strobe Offset Count", "scsi.sbc.modepage.data_strobe_offset_count", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7382       { &hf_scsi_sbc_modepage_write_retry_count, { "Write Retry Count", "scsi.sbc.modepage.write_retry_count", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7383       { &hf_scsi_sbc_modepage_recovery_time_limit, { "Recovery Time Limit (ms)", "scsi.sbc.modepage.recovery_time_limit", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7384       { &hf_scsi_sbc_modepage_number_of_cylinders, { "Number of Cylinders", "scsi.sbc.modepage.number_of_cylinders", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7385       { &hf_scsi_sbc_modepage_number_of_heads, { "Number of Heads", "scsi.sbc.modepage.number_of_heads", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7386       { &hf_scsi_sbc_modepage_starting_cyl_pre_compensation, { "Starting Cyl Pre-compensation", "scsi.sbc.modepage.starting_cyl_pre_compensation", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7387       { &hf_scsi_sbc_modepage_starting_cyl_reduced_write_current, { "Starting Cyl-reduced Write Current", "scsi.sbc.modepage.starting_cyl_reduced_write_current", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7388       { &hf_scsi_sbc_modepage_device_step_rate, { "Device Step Rate", "scsi.sbc.modepage.device_step_rate", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7389       { &hf_scsi_sbc_modepage_landing_zone_cyl, { "Landing Zone Cyl", "scsi.sbc.modepage.landing_zone_cyl", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7390       { &hf_scsi_sbc_modepage_rotational_offset, { "Rotational Offset", "scsi.sbc.modepage.rotational_offset", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7391       { &hf_scsi_sbc_modepage_medium_rotation_rate, { "Medium Rotation Rate", "scsi.sbc.modepage.medium_rotation_rate", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7392       { &hf_scsi_sbc_modepage_ic, { "IC", "scsi.sbc.modepage.ic", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
7393       { &hf_scsi_sbc_modepage_demand_read_retention_priority, { "Demand Read Retention Priority", "scsi.sbc.modepage.demand_read_retention_priority", FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL }},
7394       { &hf_scsi_sbc_modepage_disable_pre_fetch_xfer_len, { "Disable Pre-fetch Xfer Len", "scsi.sbc.modepage.disable_pre_fetch_xfer_len", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7395       { &hf_scsi_sbc_modepage_minimum_pre_fetch, { "Minimum Pre-Fetch", "scsi.sbc.modepage.minimum_pre_fetch", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7396       { &hf_scsi_sbc_modepage_maximum_pre_fetch, { "Maximum Pre-Fetch", "scsi.sbc.modepage.maximum_pre_fetch", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7397       { &hf_scsi_sbc_modepage_maximum_pre_fetch_ceiling, { "Maximum Pre-Fetch Ceiling", "scsi.sbc.modepage.maximum_pre_fetch_ceiling", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7398       { &hf_scsi_sbc_modepage_fsw, { "FSW", "scsi.sbc.modepage.fsw", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
7399       { &hf_scsi_sbc_modepage_number_of_cache_segments, { "Number of Cache Segments", "scsi.sbc.modepage.number_of_cache_segments", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7400       { &hf_scsi_sbc_modepage_cache_segment_size, { "Cache Segment Size", "scsi.sbc.modepage.cache_segment_size", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7401       { &hf_scsi_sbc_modepage_non_cache_segment_size, { "Non-Cache Segment Size", "scsi.sbc.modepage.non_cache_segment_size", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7402       { &hf_scsi_ssc2_modepage_dce, { "DCE", "scsi.ssc2.modepage.dce", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
7403       { &hf_scsi_ssc2_modepage_dde, { "DDE", "scsi.ssc2.modepage.dde", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
7404       { &hf_scsi_ssc2_modepage_compression_algorithm, { "Compression algorithm", "scsi.ssc2.modepage.compression_algorithm", FT_UINT32, BASE_HEX, VALS(compression_algorithm_vals), 0x0, NULL, HFILL }},
7405       { &hf_scsi_ssc2_modepage_decompression_algorithm, { "Decompression algorithm", "scsi.ssc2.modepage.decompression_algorithm", FT_UINT32, BASE_HEX, VALS(compression_algorithm_vals), 0x0, NULL, HFILL }},
7406       { &hf_scsi_ssc2_modepage_caf, { "CAF", "scsi.ssc2.modepage.caf", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
7407       { &hf_scsi_ssc2_modepage_active_partition, { "Active Partition", "scsi.ssc2.modepage.active_partition", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7408       { &hf_scsi_ssc2_modepage_write_object_buffer_full_ratio, { "Write Object Buffer Full Ratio", "scsi.ssc2.modepage.write_object_buffer_full_ratio", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7409       { &hf_scsi_ssc2_modepage_read_object_buffer_empty_ratio, { "Read Object Buffer Empty Ratio", "scsi.ssc2.modepage.read_object_buffer_empty_ratio", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7410       { &hf_scsi_ssc2_modepage_write_delay_time, { "Write Delay time", "scsi.ssc2.modepage.write_delay_time", FT_UINT16, BASE_DEC|BASE_UNIT_STRING, &units_100_milliseconds, 0x0, NULL, HFILL }},
7411       { &hf_scsi_ssc2_modepage_obr, { "OBR", "scsi.ssc2.modepage.obr", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
7412       { &hf_scsi_ssc2_modepage_gap_size, { "Gap Size", "scsi.ssc2.modepage.gap_size", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7413       { &hf_scsi_ssc2_modepage_eod_defined, { "EOD Defined", "scsi.ssc2.modepage.eod_defined", FT_UINT8, BASE_DEC, NULL, 0xE0, NULL, HFILL }},
7414       { &hf_scsi_ssc2_modepage_object_buffer_size_at_early_warning, { "Object Buffer Size At Early Warning", "scsi.ssc2.modepage.object_buffer_size_at_early_warning", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7415       { &hf_scsi_ssc2_modepage_select_data_compression_algorithm, { "Select Data Compression Algorithm", "scsi.ssc2.modepage.select_data_compression_algorithm", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7416       { &hf_scsi_ssc2_modepage_oir, { "OIR", "scsi.ssc2.modepage.oir", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
7417       { &hf_scsi_ssc2_modepage_maximum_additional_partitions, { "Maximum Additional Partitions", "scsi.ssc2.modepage.maximum_additional_partitions", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7418       { &hf_scsi_ssc2_modepage_additional_partitions_defined, { "Additional Partitions Defined", "scsi.ssc2.modepage.additional_partitions_defined", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7419       { &hf_scsi_ssc2_modepage_fdp, { "FDP", "scsi.ssc2.modepage.fdp", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
7420       { &hf_scsi_ssc2_modepage_media_format_recognition, { "Media Format Recognition", "scsi.ssc2.modepage.media_format_recognition", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7421       { &hf_scsi_ssc2_modepage_partition_units, { "Partition Units", "scsi.ssc2.modepage.partition_units", FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL }},
7422       { &hf_scsi_ssc2_modepage_partition_size, { "Partition Size", "scsi.ssc2.modepage.partition_size", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7423       { &hf_scsi_mmc5_modepage_lba_space, { "LBA Space", "scsi.mmc5.modepage.lba_space", FT_UINT8, BASE_DEC, NULL, 0x01, NULL, HFILL }},
7424       { &hf_scsi_mmc5_modepage_bufe, { "BUFE", "scsi.mmc5.modepage.bufe", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
7425       { &hf_scsi_mmc5_modepage_wrparam_multi_session, { "Multi-session", "scsi.mmc5.modepage.wrparam_multi_session", FT_UINT8, BASE_DEC, NULL, 0xC0, NULL, HFILL }},
7426       { &hf_scsi_mmc5_modepage_data_block_type, { "Data Block Type", "scsi.mmc5.modepage.data_block_type", FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL }},
7427       { &hf_scsi_mmc5_modepage_link_size, { "Link Size", "scsi.mmc5.modepage.link_size", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7428       { &hf_scsi_mmc5_modepage_initiator_application_code, { "Initiator Application Code", "scsi.mmc5.modepage.initiator_application_code", FT_UINT8, BASE_DEC, NULL, 0x3F, NULL, HFILL }},
7429       { &hf_scsi_mmc5_modepage_session_format, { "Session Format", "scsi.mmc5.modepage.session_format", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7430       { &hf_scsi_mmc5_modepage_packet_size, { "Packet Size", "scsi.mmc5.modepage.packet_size", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7431       { &hf_scsi_mmc5_modepage_audio_pause_length, { "Audio Pause Length", "scsi.mmc5.modepage.audio_pause_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7432       { &hf_scsi_mmc5_modepage_media_catalog_number, { "Media Catalog Number", "scsi.mmc5.modepage.media_catalog_number", FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
7433       { &hf_scsi_mmc5_modepage_international_standard_recording_code, { "International Standard Recording Code", "scsi.mmc5.modepage.international_standard_recording_code", FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
7434       { &hf_scsi_mmc5_modepage_sub_header_byte, { "Sub-header Byte", "scsi.mmc5.modepage.sub_header_byte", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7435       { &hf_scsi_mmc5_modepage_vendor_specific, { "Vendor Specific", "scsi.mmc5.modepage.vendor_specific", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7436       { &hf_scsi_mmc5_modepage_dvd_ram_read, { "DVD-RAM Read", "scsi.mmc5.modepage.dvd_ram_read", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
7437       { &hf_scsi_mmc5_modepage_dvd_ram_write, { "DVD-RAM Write", "scsi.mmc5.modepage.dvd_ram_write", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
7438       { &hf_scsi_mmc5_modepage_buf, { "BUF", "scsi.mmc5.modepage.buf", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
7439       { &hf_scsi_mmc5_modepage_read_bar_code, { "Read Bar Code", "scsi.mmc5.modepage.read_bar_code", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
7440       { &hf_scsi_mmc5_modepage_loading_mechanism_type, { "Loading Mechanism Type", "scsi.mmc5.modepage.loading_mechanism_type", FT_UINT8, BASE_DEC, NULL, 0xE0, NULL, HFILL }},
7441       { &hf_scsi_mmc5_modepage_rw_in_lead_in, { "R-W in Lead-in", "scsi.mmc5.modepage.rw_in_lead_in", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
7442       { &hf_scsi_mmc5_modepage_number_of_volume_levels_supported, { "Number of Volume Levels Supported", "scsi.mmc5.modepage.number_of_volume_levels_supported", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7443       { &hf_scsi_mmc5_modepage_buffer_size_supported, { "Buffer Size Supported", "scsi.mmc5.modepage.buffer_size_supported", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7444       { &hf_scsi_mmc5_modepage_length, { "Length", "scsi.mmc5.modepage.length", FT_UINT8, BASE_DEC, NULL, 0x30, NULL, HFILL }},
7445       { &hf_scsi_mmc5_modepage_copy_management_revision_support, { "Copy Management Revision Support", "scsi.mmc5.modepage.copy_management_revision_support", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7446       { &hf_scsi_mmc5_modepage_rotation_control_selected, { "Rotation Control Selected", "scsi.mmc5.modepage.rotation_control_selected", FT_UINT8, BASE_DEC, NULL, 0x03, NULL, HFILL }},
7447       { &hf_scsi_mmc5_modepage_current_write_speed_selected, { "Current Write Speed Selected", "scsi.mmc5.modepage.current_write_speed_selected", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7448       { &hf_scsi_mmc5_modepage_num_write_speed_performance, { "Number of Logical Unit Write Speed Performance Descriptor Tables", "scsi.mmc5.modepage.num_write_speed_performance", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7449       { &hf_scsi_smc_modepage_first_medium_transport_element_address, { "First Medium Transport Element Address", "scsi.mode.smc.first_medium_transport_element_address", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7450       { &hf_scsi_smc_modepage_number_of_medium_transport_elements, { "Number of Medium Transport Elements", "scsi.mode.smc.number_of_medium_transport_elements", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7451       { &hf_scsi_smc_modepage_first_storage_element_address, { "First Storage Element Address", "scsi.mode.smc.first_storage_element_address", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7452       { &hf_scsi_smc_modepage_number_of_storage_elements, { "Number of Storage Elements", "scsi.mode.smc.number_of_storage_elements", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7453       { &hf_scsi_smc_modepage_first_import_export_element_address, { "First Import/Export Element Address", "scsi.mode.smc.first_import_export_element_address", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7454       { &hf_scsi_smc_modepage_number_of_import_export_elements, { "Number of Import/Export Elements", "scsi.mode.smc.number_of_import_export_elements", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7455       { &hf_scsi_smc_modepage_first_data_transfer_element_address, { "First Data Transfer Element Address", "scsi.mode.smc.first_data_transfer_element_address", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7456       { &hf_scsi_smc_modepage_number_of_data_transfer_elements, { "Number of Data Transfer Elements", "scsi.mode.smc.number_of_data_transfer_elements", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7457       { &hf_scsi_smc_modepage_stordt, { "STORDT", "scsi.mode.smc.stordt", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7458       { &hf_scsi_smc_modepage_mt_dt, { "MT->DT", "scsi.mode.smc.mt_dt", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7459       { &hf_scsi_smc_modepage_st_dt, { "ST->DT", "scsi.mode.smc.st_dt", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7460       { &hf_scsi_smc_modepage_ie_dt, { "I/E->DT", "scsi.mode.smc.ie_dt", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7461       { &hf_scsi_smc_modepage_dt_dt, { "DT->DT", "scsi.mode.smc.dt_dt", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7462       { &hf_scsi_smc_modepage_mt_ne_dt, { "MT<>DT", "scsi.mode.smc.mt_ne_dt", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7463       { &hf_scsi_smc_modepage_st_ne_dt, { "ST<>DT", "scsi.mode.smc.st_ne_dt", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7464       { &hf_scsi_smc_modepage_ie_ne_dt, { "I/E<>DT", "scsi.mode.smc.ie_ne_dt", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7465       { &hf_scsi_smc_modepage_dt_ne_dt, { "DT<>DT", "scsi.mode.smc.dt_ne_dt", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7466       { &hf_scsi_modesel_mode_data_length8, { "Mode Data Length", "scsi.cdb.mode.mode_data_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7467       { &hf_scsi_modesel_dev_sbc_medium_type, { "Medium Type", "scsi.cdb.mode.medium_type", FT_UINT8, BASE_HEX, VALS(scsi_modesense_medtype_sbc_val), 0x0, NULL, HFILL }},
7468       { &hf_scsi_modesel_medium_type, { "Medium Type", "scsi.cdb.mode.medium_type", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
7469       { &hf_scsi_modesel_device_specific_parameter, { "Device-Specific Parameter", "scsi.cdb.mode.device_specific_parameter", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
7470       { &hf_scsi_modesel_block_descriptor_length8, { "Block Descriptor Length", "scsi.cdb.mode.block_descriptor_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7471       { &hf_scsi_modesel_mode_data_length16, { "Mode Data Length", "scsi.cdb.mode.mode_data_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7472       { &hf_scsi_modesel_longlba, { "LongLBA", "scsi.cdb.mode.longlba", FT_UINT8, BASE_DEC, NULL, 0x01, NULL, HFILL }},
7473       { &hf_scsi_modesel_block_descriptor_length16, { "Block Descriptor Length", "scsi.cdb.mode.block_descriptor_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7474       { &hf_scsi_persresvin_generation_number, { "Generation Number", "scsi.persresvin.generation_number", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
7475       { &hf_scsi_persresvin_additional_length, { "Additional Length", "scsi.persresvin.additional_length", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7476       { &hf_scsi_reportluns_lun_list_length, { "LUN List Length", "scsi.reportluns.lun_list_length", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7477       { &hf_scsi_sns_valid, { "Valid", "scsi.sns.valid", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7478       { &hf_scsi_sns_filemark, { "Filemark", "scsi.sns.filemark", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
7479       { &hf_scsi_sns_command_specific_information, { "Command-Specific Information", "scsi.sns.command_specific_information", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
7480       { &hf_scsi_spc_modepage_report_log_exception_condition, { "Report Log Exception Condition", "scsi.spc.modepage.report_log_exception_condition", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7481       { &hf_scsi_spc_modepage_faa, { "FAA", "scsi.spc.modepage.faa", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
7482       { &hf_scsi_spc_modepage_fab, { "FAB", "scsi.spc.modepage.fab", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
7483       { &hf_scsi_spc_modepage_fac, { "FAC", "scsi.spc.modepage.fac", FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
7484       { &hf_scsi_spc_modepage_ebf, { "EBF", "scsi.spc.modepage.ebf", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
7485       { &hf_scsi_spc_modepage_ewasc, { "EWasc", "scsi.spc.modepage.ewasc", FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
7486       { &hf_scsi_spc_modepage_dexcpt, { "DExcpt", "scsi.spc.modepage.dexcpt", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7487       { &hf_scsi_spc_modepage_test, { "Test", "scsi.spc.modepage.test", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7488       { &hf_scsi_spc_modepage_logerr, { "LogErr", "scsi.spc.modepage.logerr", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7489       { &hf_scsi_spc_modepage_standby, { "Standby", "scsi.spc.modepage.standby", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7490       { &hf_scsi_spc_modepage_plpb, { "PLPB", "scsi.spc.modepage.plpb", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
7491       { &hf_scsi_spc_modepage_ddis, { "DDIS", "scsi.spc.modepage.ddis", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
7492       { &hf_scsi_spc_modepage_dlm, { "DLM", "scsi.spc.modepage.dlm", FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
7493       { &hf_scsi_spc_modepage_rha, { "RHA", "scsi.spc.modepage.rha", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7494       { &hf_scsi_spc_modepage_alwi, { "ALWI", "scsi.spc.modepage.alwi", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7495       { &hf_scsi_spc_modepage_dtipe, { "DTIPE", "scsi.spc.modepage.dtipe", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7496       { &hf_scsi_spc_modepage_dtoli, { "DTOLI", "scsi.spc.modepage.dtoli", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7497       { &hf_scsi_sbc_modepage_hsec, { "HSEC", "scsi.sbc.modepage.hsec", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
7498       { &hf_scsi_sbc_modepage_rmb, { "RMB", "scsi.sbc.modepage.rmb", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
7499       { &hf_scsi_sbc_modepage_surf, { "SURF", "scsi.sbc.modepage.surf", FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
7500       { &hf_scsi_sbc_modepage_arre, { "ARRE", "scsi.sbc.modepage.arre", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
7501       { &hf_scsi_sbc_modepage_tb, { "TB", "scsi.sbc.modepage.tb", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
7502       { &hf_scsi_sbc_modepage_rc, { "RC", "scsi.sbc.modepage.rc", FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
7503       { &hf_scsi_sbc_modepage_eer, { "EER", "scsi.sbc.modepage.eer", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7504       { &hf_scsi_sbc_modepage_per, { "PER", "scsi.sbc.modepage.per", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7505       { &hf_scsi_sbc_modepage_dte, { "DTE", "scsi.sbc.modepage.dte", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7506       { &hf_scsi_sbc_modepage_dcr, { "DCR", "scsi.sbc.modepage.dcr", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7507       { &hf_scsi_sbc_modepage_abpf, { "ABPF", "scsi.sbc.modepage.abpf", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
7508       { &hf_scsi_sbc_modepage_cap, { "CAP", "scsi.sbc.modepage.cap", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
7509       { &hf_scsi_sbc_modepage_disc, { "Disc", "scsi.sbc.modepage.disc", FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
7510       { &hf_scsi_sbc_modepage_size, { "Size", "scsi.sbc.modepage.size", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7511       { &hf_scsi_sbc_modepage_wce, { "WCE", "scsi.sbc.modepage.wce", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7512       { &hf_scsi_sbc_modepage_mf, { "MF", "scsi.sbc.modepage.mf", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7513       { &hf_scsi_sbc_modepage_rcd, { "RCD", "scsi.sbc.modepage.rcd", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7514       { &hf_scsi_sbc_modepage_write_retention_priority, { "Write Retention Priority", "scsi.sbc.modepage.write_retention_priority", FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL }},
7515       { &hf_scsi_sbc_modepage_lbcss, { "LBCSS", "scsi.sbc.modepage.lbcss", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
7516       { &hf_scsi_sbc_modepage_dra, { "DRA", "scsi.sbc.modepage.dra", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
7517       { &hf_scsi_sbc_modepage_vendor_specific, { "Vendor Specific", "scsi.sbc.modepage.vendor_specific", FT_UINT8, BASE_DEC, NULL, 0x1F, NULL, HFILL }},
7518       { &hf_scsi_ssc2_modepage_dcc, { "DCC", "scsi.ssc2.modepage.dcc", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
7519       { &hf_scsi_ssc2_modepage_red, { "RED", "scsi.ssc2.modepage.red", FT_UINT8, BASE_DEC, NULL, 0x60, NULL, HFILL }},
7520       { &hf_scsi_ssc2_modepage_active_format, { "Active Format", "scsi.ssc2.modepage.active_format", FT_UINT8, BASE_DEC, NULL, 0x1F, NULL, HFILL }},
7521       { &hf_scsi_ssc2_modepage_lois, { "LOIS", "scsi.ssc2.modepage.lois", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
7522       { &hf_scsi_ssc2_modepage_rsmk, { "RSMK", "scsi.ssc2.modepage.rsmk", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
7523       { &hf_scsi_ssc2_modepage_avc, { "AVC", "scsi.ssc2.modepage.avc", FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
7524       { &hf_scsi_ssc2_modepage_socf, { "SOCF", "scsi.ssc2.modepage.socf", FT_UINT8, BASE_DEC, NULL, 0x0C, NULL, HFILL }},
7525       { &hf_scsi_ssc2_modepage_robo, { "ROBO", "scsi.ssc2.modepage.robo", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7526       { &hf_scsi_ssc2_modepage_rew, { "REW", "scsi.ssc2.modepage.rew", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7527       { &hf_scsi_ssc2_modepage_eeg, { "EEG", "scsi.ssc2.modepage.eeg", FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
7528       { &hf_scsi_ssc2_modepage_sew, { "SEW", "scsi.ssc2.modepage.sew", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7529       { &hf_scsi_ssc2_modepage_swp, { "SWP", "scsi.ssc2.modepage.swp", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7530       { &hf_scsi_ssc2_modepage_baml, { "BAML", "scsi.ssc2.modepage.baml", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7531       { &hf_scsi_ssc2_modepage_bam, { "BAM", "scsi.ssc2.modepage.bam", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7532       { &hf_scsi_ssc2_modepage_rewind_on_reset, { "ReWind on Reset", "scsi.ssc2.modepage.rewind_on_reset", FT_UINT8, BASE_DEC, NULL, 0x18, NULL, HFILL }},
7533       { &hf_scsi_ssc2_modepage_asocwp, { "ASOCWP", "scsi.ssc2.modepage.asocwp", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7534       { &hf_scsi_ssc2_modepage_perswp, { "PERSWP", "scsi.ssc2.modepage.perswp", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7535       { &hf_scsi_ssc2_modepage_prmwp, { "PRMWP", "scsi.ssc2.modepage.prmwp", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7536       { &hf_scsi_ssc2_modepage_dsp, { "DSP", "scsi.ssc2.modepage.dsp", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
7537       { &hf_scsi_ssc2_modepage_idp, { "IDP", "scsi.ssc2.modepage.idp", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
7538       { &hf_scsi_ssc2_modepage_psum, { "PSUM", "scsi.ssc2.modepage.psum", FT_UINT8, BASE_DEC, NULL, 0x18, NULL, HFILL }},
7539       { &hf_scsi_ssc2_modepage_pofm, { "POFM", "scsi.ssc2.modepage.pofm", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7540       { &hf_scsi_ssc2_modepage_clear, { "CLEAR", "scsi.ssc2.modepage.clear", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7541       { &hf_scsi_ssc2_modepage_addp, { "ADDP", "scsi.ssc2.modepage.addp", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7542       { &hf_scsi_mmc5_modepage_ls_v, { "LS_V", "scsi.mmc5.modepage.ls_v", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
7543       { &hf_scsi_mmc5_modepage_wrparam_test_write, { "Test Write", "scsi.mmc5.modepage.wrparam_test_write", FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
7544       { &hf_scsi_mmc5_modepage_write_type, { "Write Type", "scsi.mmc5.modepage.write_type", FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL }},
7545       { &hf_scsi_mmc5_modepage_fp, { "FP", "scsi.mmc5.modepage.fp", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
7546       { &hf_scsi_mmc5_modepage_copy, { "Copy", "scsi.mmc5.modepage.copy", FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
7547       { &hf_scsi_mmc5_modepage_track_mode, { "Track Mode", "scsi.mmc5.modepage.track_mode", FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL }},
7548       { &hf_scsi_mmc5_modepage_dvd_r_read, { "DVD-R Read", "scsi.mmc5.modepage.dvd_r_read", FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
7549       { &hf_scsi_mmc5_modepage_dvd_rom_read, { "DVD-ROM Read", "scsi.mmc5.modepage.dvd_rom_read", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7550       { &hf_scsi_mmc5_modepage_method_2, { "Method 2", "scsi.mmc5.modepage.method_2", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7551       { &hf_scsi_mmc5_modepage_cd_rw_read, { "CD-RW Read", "scsi.mmc5.modepage.cd_rw_read", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7552       { &hf_scsi_mmc5_modepage_cd_r_read, { "CD-R Read", "scsi.mmc5.modepage.cd_r_read", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7553       { &hf_scsi_mmc5_modepage_dvd_r_write, { "DVD-R Write", "scsi.mmc5.modepage.dvd_r_write", FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
7554       { &hf_scsi_mmc5_modepage_dvd_rom_write, { "DVD-ROM Write", "scsi.mmc5.modepage.dvd_rom_write", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7555       { &hf_scsi_mmc5_modepage_mmcap_test_write, { "Test Write", "scsi.mmc5.modepage.mmcap_test_write", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7556       { &hf_scsi_mmc5_modepage_cd_rw_write, { "CD-RW Write", "scsi.mmc5.modepage.cd_rw_write", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7557       { &hf_scsi_mmc5_modepage_cd_r_write, { "CD-R Write", "scsi.mmc5.modepage.cd_r_write", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7558       { &hf_scsi_mmc5_modepage_mmcap_multi_session, { "Multi Session", "scsi.mmc5.modepage.mmcap_multi_session", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
7559       { &hf_scsi_mmc5_modepage_mode_2_form2, { "Mode 2 Form 2", "scsi.mmc5.modepage.mode_2_form2", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
7560       { &hf_scsi_mmc5_modepage_mode_2_form1, { "Mode 2 Form 1", "scsi.mmc5.modepage.mode_2_form1", FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
7561       { &hf_scsi_mmc5_modepage_digital_port2, { "Digital Port (2)", "scsi.mmc5.modepage.digital_port2", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7562       { &hf_scsi_mmc5_modepage_digital_port1, { "Digital Port (1)", "scsi.mmc5.modepage.digital_port1", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7563       { &hf_scsi_mmc5_modepage_composite, { "Composite", "scsi.mmc5.modepage.composite", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7564       { &hf_scsi_mmc5_modepage_audio_play, { "Audio Play", "scsi.mmc5.modepage.audio_play", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7565       { &hf_scsi_mmc5_modepage_upc, { "UPC", "scsi.mmc5.modepage.upc", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
7566       { &hf_scsi_mmc5_modepage_isrc, { "ISRC", "scsi.mmc5.modepage.isrc", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
7567       { &hf_scsi_mmc5_modepage_c2_pointers_supported, { "C2 Pointers supported", "scsi.mmc5.modepage.c2_pointers_supported", FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
7568       { &hf_scsi_mmc5_modepage_rw_deinterleaved_corrected, { "R-W Deinterleaved & corrected", "scsi.mmc5.modepage.rw_deinterleaved_corrected", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7569       { &hf_scsi_mmc5_modepage_rw_supported, { "R-W Supported", "scsi.mmc5.modepage.rw_supported", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7570       { &hf_scsi_mmc5_modepage_cd_da_stream_is_accurate, { "CD-DA Stream is Accurate", "scsi.mmc5.modepage.cd_da_stream_is_accurate", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7571       { &hf_scsi_mmc5_modepage_cd_da_cmds_supported, { "CD-DA Cmds Supported", "scsi.mmc5.modepage.cd_da_cmds_supported", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7572       { &hf_scsi_mmc5_modepage_eject, { "Eject", "scsi.mmc5.modepage.eject", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7573       { &hf_scsi_mmc5_modepage_prevent_jumper, { "Prevent Jumper", "scsi.mmc5.modepage.prevent_jumper", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7574       { &hf_scsi_mmc5_modepage_lock_state, { "Lock State", "scsi.mmc5.modepage.lock_state", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7575       { &hf_scsi_mmc5_modepage_lock, { "Lock", "scsi.mmc5.modepage.lock", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7576       { &hf_scsi_mmc5_modepage_side_change_capable, { "Side Change Capable", "scsi.mmc5.modepage.side_change_capable", FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
7577       { &hf_scsi_mmc5_modepage_sw_slot_selection, { "S/W Slot Selection", "scsi.mmc5.modepage.sw_slot_selection", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
7578       { &hf_scsi_mmc5_modepage_changer_supports_disc_present, { "Changer Supports Disc Present", "scsi.mmc5.modepage.changer_supports_disc_present", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7579       { &hf_scsi_mmc5_modepage_separate_channel_mute, { "Separate Channel Mute", "scsi.mmc5.modepage.separate_channel_mute", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7580       { &hf_scsi_mmc5_modepage_separate_volume_levels, { "Separate volume levels", "scsi.mmc5.modepage.separate_volume_levels", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7581       { &hf_scsi_mmc5_modepage_lsbf, { "LSBF", "scsi.mmc5.modepage.lsbf", FT_UINT8, BASE_DEC, NULL, 0x30, NULL, HFILL }},
7582       { &hf_scsi_mmc5_modepage_rck, { "RCK", "scsi.mmc5.modepage.rck", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7583       { &hf_scsi_mmc5_modepage_bckf, { "BCKF", "scsi.mmc5.modepage.bckf", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7584       { &hf_scsi_smc_modepage_storie, { "STORI/E", "scsi.mode.smc.storie", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7585       { &hf_scsi_smc_modepage_storst, { "STORST", "scsi.mode.smc.storst", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7586       { &hf_scsi_smc_modepage_stormt, { "STORMT", "scsi.mode.smc.stormt", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7587       { &hf_scsi_smc_modepage_mt_ie, { "MT->I/E", "scsi.mode.smc.mt_ie", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7588       { &hf_scsi_smc_modepage_mt_st, { "MT->ST", "scsi.mode.smc.mt_st", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7589       { &hf_scsi_smc_modepage_mt_mt, { "MT->MT", "scsi.mode.smc.mt_mt", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7590       { &hf_scsi_smc_modepage_st_ie, { "ST->I/E", "scsi.mode.smc.st_ie", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7591       { &hf_scsi_smc_modepage_st_st, { "ST->ST", "scsi.mode.smc.st_st", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7592       { &hf_scsi_smc_modepage_st_mt, { "ST->MT", "scsi.mode.smc.st_mt", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7593       { &hf_scsi_smc_modepage_ie_ie, { "I/E->I/E", "scsi.mode.smc.ie_ie", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7594       { &hf_scsi_smc_modepage_ie_st, { "I/E->ST", "scsi.mode.smc.ie_st", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7595       { &hf_scsi_smc_modepage_ie_mt, { "I/E->MT", "scsi.mode.smc.ie_mt", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7596       { &hf_scsi_smc_modepage_dt_ie, { "DT->I/E", "scsi.mode.smc.dt_ie", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7597       { &hf_scsi_smc_modepage_dt_st, { "DT->ST", "scsi.mode.smc.dt_st", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7598       { &hf_scsi_smc_modepage_dt_mt, { "DT->MT", "scsi.mode.smc.dt_mt", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7599       { &hf_scsi_smc_modepage_mt_ne_ie, { "MT<>I/E", "scsi.mode.smc.mt_ne_ie", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7600       { &hf_scsi_smc_modepage_mt_ne_st, { "MT<>ST", "scsi.mode.smc.mt_ne_st", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7601       { &hf_scsi_smc_modepage_mt_ne_mt, { "MT<>MT", "scsi.mode.smc.mt_ne_mt", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7602       { &hf_scsi_smc_modepage_st_ne_ie, { "ST<>I/E", "scsi.mode.smc.st_ne_ie", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7603       { &hf_scsi_smc_modepage_st_ne_st, { "ST<>ST", "scsi.mode.smc.st_ne_st", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7604       { &hf_scsi_smc_modepage_st_ne_mt, { "ST<>MT", "scsi.mode.smc.st_ne_mt", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7605       { &hf_scsi_smc_modepage_ie_ne_ie, { "I/E<>I/E", "scsi.mode.smc.ie_ne_ie", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7606       { &hf_scsi_smc_modepage_ie_ne_st, { "I/E<>ST", "scsi.mode.smc.ie_ne_st", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7607       { &hf_scsi_smc_modepage_ie_ne_mt, { "I/E<>MT", "scsi.mode.smc.ie_ne_mt", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7608       { &hf_scsi_smc_modepage_dt_ne_ie, { "DT<>I/E", "scsi.mode.smc.dt_ne_ie", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7609       { &hf_scsi_smc_modepage_dt_ne_st, { "DT<>ST", "scsi.mode.smc.dt_ne_st", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7610       { &hf_scsi_smc_modepage_dt_ne_mt, { "DT<>MT", "scsi.mode.smc.dt_ne_mt", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7611       { &hf_scsi_sns_eom, { "EOM", "scsi.sns.eom", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
7612       { &hf_scsi_sns_ili, { "ILI", "scsi.sns.ili", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
7613       { &hf_scsi_spc_xcopy_service, { "Service action", "scsi.extcopy.service_action", FT_UINT8, BASE_HEX, VALS(extcopy_service_vals), 0x0, NULL, HFILL }},
7614       { &hf_scsi_spc_recv_copy_service, { "Service action", "scsi.recv_copy.service_action", FT_UINT8, BASE_HEX, VALS(recv_copy_service_vals), 0x1F, NULL, HFILL }},
7615       { &hf_scsi_spc_xcopy_param_list_len, { "Parameter list length (bytes)", "scsi.extcopy.param_list_len", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7616       { &hf_scsi_spc_xcopy_param_list_format, { "List format", "scsi.extcopy.list_format", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7617       { &hf_scsi_spc_xcopy_head_cscd_desc_list_len, { "Header cscd descriptor list length", "scsi.extcopy.hdr_cscd_list_len", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7618       { &hf_scsi_spc_xcopy_cscd_desc_list_len, { "CSCD descriptor list length", "scsi.extcopy.cscd_list_len", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7619       { &hf_scsi_spc_xcopy_inline_data_len, { "Inline data length", "scsi.extcopy.inline_data_len", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7620       { &hf_scsi_spc_xcopy_seg_desc_list_len, { "Segment descriptor list length", "scsi.extcopy.seg_desc_list_len", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7621       { &hf_scsi_spc_xcopy_list_id, { "List ID", "scsi.extcopy.list_id", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7622       { &hf_scsi_spc_xcopy_head_cscd_desc_type_code, { "Header CSCD description type code", "scsi.extcopy.head_cscd_desc_type_code", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7623       { &hf_scsi_spc_xcopy_cscd_desc_type_code, { "CSCD description type code", "scsi.cscd_desc_type_code", FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(desc_type_rval), 0x0, NULL, HFILL}},
7624       { &hf_scsi_spc_xcopy_rel_init_port_id, { "Relative Initiator Port ID", "scsi.extcopy.rel_init_port_id", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7625       { &hf_scsi_spc_xcopy_per_dev_type, { "Peripheral Device Type", "scsi.extcopy.per_dev_type", FT_UINT8, BASE_DEC, VALS(per_dev_type_vals), 0x1F, NULL, HFILL }},
7626       { &hf_scsi_spc_xcopy_lu_type, { "LU type", "scsi.extcopy.lu_type", FT_UINT8, BASE_DEC, VALS(lu_type_vals), 0xC0, NULL, HFILL }},
7627       { &hf_scsi_spc_xcopy_per_dev_type_byte, { "Peripheral Device Type bits", "scsi.extcopy.per_dev_type_byte", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
7628       { &hf_scsi_spc_xcopy_disk_block_len, { "Disk block length", "scsi.extcopy.disk_block_len", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7629       { &hf_scsi_spc_xcopy_cscd_desc_code_set, { "CSCD descriptor code set", "scsi.extcopy.cscd_code_set", FT_UINT8, BASE_DEC, VALS(scsi_devid_codeset_val), 0x0F, NULL, HFILL }},
7630       { &hf_scsi_spc_xcopy_cscd_desc_assoc, { "CSCD descriptor association", "scsi.extcopy.cscd_assoc", FT_UINT8, BASE_DEC, VALS(scsi_devid_assoc_val), 0x30, NULL, HFILL }},
7631       { &hf_scsi_spc_xcopy_cscd_desc_des_type, { "CSCD descriptor designator type", "scsi.extcopy.cscd_des_type", FT_UINT8, BASE_DEC, VALS(scsi_devid_idtype_val), 0x0F, NULL, HFILL }},
7632       { &hf_scsi_spc_xcopy_cscd_desc_des_len, { "CSCD descriptor designator length", "scsi.extcopy.cscd_des_len", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7633       { &hf_scsi_spc_xcopy_seg_desc_type, { "Segment descriptor type code", "scsi.extcopy.seg_desc_type", FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(desc_type_rval), 0x0, NULL, HFILL }},
7634       { &hf_scsi_spc_xcopy_seg_desc_dc, { "Segment descriptor designation count bit", "scsi.extcopy.seg_desc_dc", FT_UINT8, BASE_DEC, NULL, 0x2, NULL, HFILL }},
7635       { &hf_scsi_spc_xcopy_seg_desc_cat, { "Segment descriptor CAT bit", "scsi.extcopy.seg_desc_cat", FT_UINT8, BASE_DEC, NULL, 0x1, NULL, HFILL }},
7636       { &hf_scsi_spc_xcopy_seg_des_src_desc_id, { "Segment descriptor source ID", "scsi.extcopy.seg_desc_src_id", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
7637       { &hf_scsi_spc_xcopy_seg_des_dest_desc_id, { "Segment descriptor destination ID", "scsi.extcopy.seg_desc_dest_id", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
7638       { &hf_scsi_spc_xcopy_num_of_blocks, { "Number of blocks", "scsi.extcopy.seg_desc_num_of_blocks", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7639       { &hf_scsi_spc_xcopy_param_list_id_usage, { "List ID usage", "scsi.extcopy.xcopy_param_list_id_usage", FT_UINT8, BASE_HEX, NULL, 0x18, NULL, HFILL }},
7640       { &hf_scsi_spc_xcopy_param_str, { "Sequential strip bit (str)", "scsi.extcopy.xcopy_param_str", FT_UINT8, BASE_HEX, NULL, 0x20, NULL, HFILL }},
7641       { &hf_scsi_spc_xcopy_param_priority, { "Priority", "scsi.extcopy.xcopy_param_priority", FT_UINT8, BASE_HEX, NULL, 0x7, NULL, HFILL }},
7642       { &hf_scsi_spc_xcopy_param_byte, { "Extended copy Parameters: str, list ID usage, priority", "scsi.extcopy.xcopy_params_byte", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
7643       { &hf_scsi_spc_xcopy_source_lba, { "Source LBA", "scsi.extcopy.source_lba", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
7644       { &hf_scsi_spc_xcopy_dest_lba, { "Destination LBA", "scsi.extcopy.dest_lba", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
7645       { &hf_scsi_recv_copy_max_cscd_desc_count, { "Max. CSCD descriptors count", "scsi.recv_copy.max_cscd_desc_count", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7646       { &hf_scsi_recv_copy_max_seg_desc_count, { "Max. segment descriptors count", "scsi.recv_copy.max_seg_desc_count", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7647       { &hf_scsi_recv_copy_max_desc_list_len, { "Max. descriptor list length", "scsi.recv_copy.max_desc_list_len", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7648       { &hf_scsi_recv_copy_max_seg_len, { "Max. segment length", "scsi.recv_copy.max_seg_len", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7649       { &hf_scsi_recv_copy_max_inline_data_len, { "Max. inline data length",  "scsi.recv_copy.max_inline_data_len", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7650       { &hf_scsi_recv_copy_held_data_limit, { "Held data limit", "scsi.recv_copy.max_held_data_limit", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7651       { &hf_scsi_recv_copy_max_stream_dev_trans_size, { "Max. stream device transfer size", "scsi.recv_copy.max_stream_dev_trans_size", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7652       { &hf_scsi_recv_copy_snlid, { "SNLID bit", "scsi.recv_copy.snlid", FT_UINT8, BASE_DEC, NULL, 0x1, NULL, HFILL }},
7653       { &hf_scsi_recv_copy_avail_data, { "Available data", "scsi.recv_copy.avail_data", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7654       { &hf_scsi_recv_copy_total_con_copies, { "Total number of concurrent copies", "scsi.recv_copy.total_con_copies", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7655       { &hf_scsi_recv_copy_max_con_copies, { "Max. number of concurrent copies", "scsi.recv_copy.max_con_copies", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7656       { &hf_scsi_recv_copy_data_seg_gran, { "Data segment granularity", "scsi.recv_copy.data_seg_gran", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7657       { &hf_scsi_recv_copy_inline_data_gran, { "Inline data granularity", "scsi.recv_copy.inline_data_gran", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7658       { &hf_scsi_recv_copy_held_data_gran, { "Held data granularity", "scsi.recv_copy.held_data_gran", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7659       { &hf_scsi_recv_copy_implemented_desc_list_len, { "Implemented description list length", "scsi.recv_copy.implemented_desc_list_len", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7660       { &hf_scsi_designator, { "Designator", "scsi.designator", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
7661       { &hf_scsi_segment_descriptor_length, { "Segment descriptor length (bytes)", "scsi.segment_descriptor_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7662       { &hf_scsi_inline_data, { "Inline data", "scsi.inline_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
7663       { &hf_scsi_reserved_8, { "Reserved (1 byte)", "scsi.reserved", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7664       { &hf_scsi_reserved_16, { "Reserved (2 bytes)", "scsi.reserved2", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7665       { &hf_scsi_reserved_24, { "Reserved (3 bytes)", "scsi.reserved3", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7666       { &hf_scsi_reserved_32, { "Reserved (4 bytes)", "scsi.reserved4", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7667       { &hf_scsi_reserved_64, { "Reserved (8 bytes)", "scsi.reserved8", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7668       { &hf_scsi_naa_type, { "NAA Designator Type", "scsi.naa.type", FT_UINT8, BASE_DEC, VALS(scsi_naa_designator_type_val), 0xF0, NULL, HFILL }},
7669       { &hf_scsi_naa_locally_assigned, { "Locally Assigned", "scsi.naa.locally_assigned", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
7670       { &hf_scsi_naa_ieee_company_id, { "IEEE Company ID", "scsi.naa.ieee_company_id", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
7671       { &hf_scsi_naa_vendor_specific, { "Vendor Specific Identifier", "scsi.naa.vendor_specific", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
7672       { &hf_scsi_naa_vendor_specific_extension, { "Vendor Specific Identifier Extension", "scsi.naa.vendor_specific.extension", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}
7673     };
7674 
7675     /* Setup protocol subtree array */
7676     static gint *ett[] = {
7677         &ett_scsi,
7678         &ett_scsi_page,
7679         &ett_scsi_control,
7680         &ett_scsi_inq_control,
7681         &ett_scsi_inq_peripheral,
7682         &ett_scsi_inq_acaflags,
7683         &ett_scsi_inq_rmbflags,
7684         &ett_scsi_inq_sccsflags,
7685         &ett_scsi_inq_bqueflags,
7686         &ett_scsi_inq_reladrflags,
7687         &ett_scsi_log,
7688         &ett_scsi_log_ppc,
7689         &ett_scsi_log_pc,
7690         &ett_scsi_log_param,
7691         &ett_scsi_fragments,
7692         &ett_scsi_fragment,
7693         &ett_persresv_control,
7694         &ett_scsi_lun,
7695         &ett_scsi_lun_unit,
7696         &ett_scsi_prevent_allow,
7697         &ett_command_descriptor,
7698         &ett_timeout_descriptor,
7699         &ett_sense_descriptor,
7700         &ett_sense_osd_not_initiated,
7701         &ett_sense_osd_completed,
7702         &ett_xcopy_per_dev_type,
7703         &ett_scsi_xcopy_dev_params,
7704         &ett_scsi_xcopy_cscds,
7705         &ett_scsi_xcopy_cscd,
7706         &ett_scsi_xcopy_segs,
7707         &ett_scsi_xcopy_seg,
7708         &ett_scsi_xcopy_seg_param,
7709         &ett_xcopy_param_byte,
7710         &ett_scsi_cscd_desc,
7711         &ett_scsi_designation_descriptor,
7712         &ett_scsi_naa,
7713     };
7714 
7715     static ei_register_info ei[] = {
7716         { &ei_scsi_product_data_goes_past_end_of_page, { "scsi.product_data_goes_past_end_of_page", PI_MALFORMED, PI_WARN, "Product data goes past end of page", EXPFILL }},
7717         { &ei_scsi_unknown_page, { "scsi.unknown_page", PI_UNDECODED, PI_WARN, "Unknown Page", EXPFILL }},
7718         { &ei_scsi_no_dissection_for_service_action, { "scsi.no_dissection_for_service_action", PI_UNDECODED, PI_WARN, "No dissection for this service action yet", EXPFILL }},
7719         { &ei_scsi_unknown_scsi_exchange, { "scsi.unknown_scsi_exchange", PI_PROTOCOL, PI_WARN, "Unknown SCSI exchange, can not decode SCSI data", EXPFILL }},
7720         { &ei_scsi_unknown_serv_action, { "scsi.unknown_serv_action", PI_PROTOCOL, PI_WARN, "Unknown serv_action", EXPFILL }},
7721     };
7722 
7723     module_t *scsi_module;
7724     expert_module_t* expert_scsi;
7725 
7726     /* Register the protocol name and description */
7727     proto_scsi = proto_register_protocol("SCSI", "SCSI", "scsi");
7728 
7729     /* Required function calls to register the header fields and subtrees used */
7730     proto_register_field_array(proto_scsi, hf, array_length(hf));
7731     proto_register_subtree_array(ett, array_length(ett));
7732     expert_scsi = expert_register_protocol(proto_scsi);
7733     expert_register_field_array(expert_scsi, ei, array_length(ei));
7734 
7735     /* add preferences to decode SCSI message */
7736     scsi_module = prefs_register_protocol(proto_scsi, NULL);
7737     prefs_register_enum_preference(scsi_module, "decode_scsi_messages_as",
7738                                    "Decode SCSI Messages As",
7739                                    "When Target Cannot Be Identified, Decode SCSI Messages As",
7740                                    &scsi_def_devtype,
7741                                    scsi_devtype_options,
7742                                    FALSE);
7743 
7744     prefs_register_bool_preference(scsi_module, "defragment",
7745                                    "Reassemble fragmented SCSI DATA IN/OUT transfers",
7746                                    "Whether fragmented SCSI DATA IN/OUT transfers should be reassembled",
7747                                    &scsi_defragment);
7748     reassembly_table_register(&scsi_reassembly_table,
7749                           &addresses_reassembly_table_functions);
7750 
7751     register_srt_table(proto_scsi, NULL, 1, scsistat_packet, scsistat_init, scsistat_param);
7752 
7753     scsi_tap    = register_tap("scsi");
7754 }
7755 
7756 /*
7757  * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
7758  *
7759  * Local variables:
7760  * c-basic-offset: 4
7761  * tab-width: 8
7762  * indent-tabs-mode: nil
7763  * End:
7764  *
7765  * vi: set shiftwidth=4 tabstop=8 expandtab:
7766  * :indentSize=4:tabSize=8:noTabs=true:
7767  */
7768