Enable Lua tcp tap userdata.
[obnox/wireshark/wip.git] / epan / dissectors / packet-scsi-ssc.c
1 /* based on SSC3 spec */
2 /* TODO:
3  * dissect READPOSITION data
4  * dissect REPORTDENSITYSUPPORT data
5  */
6 /* packet-scsi-ssc.c
7  * Dissector for the SCSI SSC commandset
8  * Extracted from packet-scsi.c
9  *
10  * Dinesh G Dutt (ddutt@cisco.com)
11  * Ronnie sahlberg 2006
12  *
13  * $Id$
14  *
15  * Wireshark - Network traffic analyzer
16  * By Gerald Combs <gerald@wireshark.org>
17  * Copyright 2002 Gerald Combs
18  *
19  * This program is free software; you can redistribute it and/or
20  * modify it under the terms of the GNU General Public License
21  * as published by the Free Software Foundation; either version 2
22  * of the License, or (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program; if not, write to the Free Software
31  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
32  */
33
34 #ifdef HAVE_CONFIG_H
35 # include "config.h"
36 #endif
37
38 #include <glib.h>
39 #include <string.h>
40 #include <epan/strutil.h>
41 #include <epan/packet.h>
42 #include <epan/conversation.h>
43 #include <epan/tap.h>
44 #include "packet-scsi.h"
45 #include "packet-fc.h"
46 #include "packet-scsi-ssc.h"
47 #include "packet-scsi-smc.h"
48
49
50 static int proto_scsi_ssc               = -1;
51 int hf_scsi_ssc_opcode                  = -1;
52 static int hf_scsi_ssc_rdwr6_xferlen    = -1;
53 static int hf_scsi_ssc_ver16_verlen     = -1;
54 static int hf_scsi_ssc_locate10_loid    = -1;
55 static int hf_scsi_ssc_locate16_loid    = -1;
56 static int hf_scsi_ssc_space6_code      = -1;
57 static int hf_scsi_ssc_space6_count     = -1;
58 static int hf_scsi_ssc_space16_count    = -1;
59 static int hf_scsi_ssc_erase_flags              = -1;
60 static int hf_scsi_ssc_fcs                      = -1;
61 static int hf_scsi_ssc_lcs                      = -1;
62 static int hf_scsi_ssc_erase_immed              = -1;
63 static int hf_scsi_ssc_long                     = -1;
64 static int hf_scsi_ssc_partition                = -1;
65 static int hf_scsi_ssc_lbi                      = -1;
66 static int hf_scsi_ssc_verify                   = -1;
67 static int hf_scsi_ssc_immed                    = -1;
68 static int hf_scsi_ssc_formatmedium_flags       = -1;
69 static int hf_scsi_ssc_format                   = -1;
70 static int hf_scsi_ssc_rdwr10_xferlen           = -1;
71 static int hf_scsi_ssc_loadunload_immed_flags   = -1;
72 static int hf_scsi_ssc_loadunload_flags         = -1;
73 static int hf_scsi_ssc_hold                     = -1;
74 static int hf_scsi_ssc_eot                      = -1;
75 static int hf_scsi_ssc_reten                    = -1;
76 static int hf_scsi_ssc_load                     = -1;
77 static int hf_scsi_ssc_locate_flags             = -1;
78 static int hf_scsi_ssc_bt                       = -1;
79 static int hf_scsi_ssc_cp                       = -1;
80 static int hf_scsi_ssc_dest_type                = -1;
81 static int hf_scsi_ssc_bam_flags                = -1;
82 static int hf_scsi_ssc_bam                      = -1;
83 static int hf_scsi_ssc_read6_flags              = -1;
84 static int hf_scsi_ssc_sili                     = -1;
85 static int hf_scsi_ssc_fixed                    = -1;
86 static int hf_scsi_ssc_bytord                   = -1;
87 static int hf_scsi_ssc_bytcmp                   = -1;
88 static int hf_scsi_ssc_verify16_immed           = -1;
89 static int hf_scsi_ssc_medium_type              = -1;
90 static int hf_scsi_ssc_media                    = -1;
91 static int hf_scsi_ssc_capacity_prop_value      = -1;
92
93 static gint ett_scsi_erase                      = -1;
94 static gint ett_scsi_formatmedium               = -1;
95 static gint ett_scsi_loadunload_immed           = -1;
96 static gint ett_scsi_loadunload                 = -1;
97 static gint ett_scsi_locate                     = -1;
98 static gint ett_scsi_bam                        = -1;
99 static gint ett_scsi_read6                      = -1;
100
101
102 static void
103 dissect_ssc_read6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
104                     guint offset, gboolean isreq, gboolean iscdb,
105                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
106 {
107     guint8 flags;
108     static const int *read6_fields[] = {
109         &hf_scsi_ssc_sili,
110         &hf_scsi_ssc_fixed,
111         NULL
112     };
113
114     if (isreq) {
115         if (check_col (pinfo->cinfo, COL_INFO))
116             col_append_fstr (pinfo->cinfo, COL_INFO, "(Len: %u)",
117                              tvb_get_ntoh24 (tvb, offset+1));
118     }
119
120     if (tree && isreq && iscdb) {
121         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, read6_fields, FALSE);
122
123         proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+1, 3, 0);
124         flags = tvb_get_guint8 (tvb, offset+4);
125         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
126                                     flags,
127                                     "Vendor Unique = %u, NACA = %u, Link = %u",
128                                     flags & 0xC0, flags & 0x4, flags & 0x1);
129     }
130 }
131
132 static void
133 dissect_ssc_recoverbuffereddata (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
134                     guint offset, gboolean isreq, gboolean iscdb,
135                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
136 {
137     guint8 flags;
138     static const int *recover_fields[] = {
139         &hf_scsi_ssc_sili,
140         &hf_scsi_ssc_fixed,
141         NULL
142     };
143
144     if (isreq) {
145         if (check_col (pinfo->cinfo, COL_INFO))
146             col_append_fstr (pinfo->cinfo, COL_INFO, "(Len: %u)",
147                              tvb_get_ntoh24 (tvb, offset+1));
148     }
149
150     if (tree && isreq && iscdb) {
151         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, recover_fields, FALSE);
152
153         proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+1, 3, 0);
154         flags = tvb_get_guint8 (tvb, offset+4);
155         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
156                                     flags,
157                                     "Vendor Unique = %u, NACA = %u, Link = %u",
158                                     flags & 0xC0, flags & 0x4, flags & 0x1);
159     }
160 }
161
162 static void
163 dissect_ssc_reportdensitysupport (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
164                     guint offset, gboolean isreq, gboolean iscdb,
165                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
166 {
167     guint8 flags;
168     static const int *rd_fields[] = {
169         &hf_scsi_ssc_medium_type,
170         &hf_scsi_ssc_media,
171         NULL
172     };
173
174     if (isreq) {
175         if (check_col (pinfo->cinfo, COL_INFO))
176             col_append_fstr (pinfo->cinfo, COL_INFO, "(Len: %u)",
177                              tvb_get_ntoh24 (tvb, offset+1));
178     }
179
180     if(!tree)
181         return;
182
183     if (isreq && iscdb) {
184         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, rd_fields, FALSE);
185
186         proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+6, 2, 0);
187         flags = tvb_get_guint8 (tvb, offset+8);
188         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1,
189                                     flags,
190                                     "Vendor Unique = %u, NACA = %u, Link = %u",
191                                     flags & 0xC0, flags & 0x4, flags & 0x1);
192     } else {
193         /* XXX decode the data */
194     }
195 }
196
197 static void
198 dissect_ssc_readreverse6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
199                     guint offset, gboolean isreq, gboolean iscdb,
200                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
201 {
202     guint8 flags;
203     static const int *rr6_fields[] = {
204         &hf_scsi_ssc_bytord,
205         &hf_scsi_ssc_sili,
206         &hf_scsi_ssc_fixed,
207         NULL
208     };
209
210     if (isreq) {
211         if (check_col (pinfo->cinfo, COL_INFO))
212             col_append_fstr (pinfo->cinfo, COL_INFO, "(Len: %u)",
213                              tvb_get_ntoh24 (tvb, offset+1));
214     }
215
216     if (tree && isreq && iscdb) {
217         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, rr6_fields, FALSE);
218
219         proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+1, 3, 0);
220         flags = tvb_get_guint8 (tvb, offset+4);
221         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
222                                     flags,
223                                     "Vendor Unique = %u, NACA = %u, Link = %u",
224                                     flags & 0xC0, flags & 0x4, flags & 0x1);
225     }
226 }
227
228 static void
229 dissect_ssc_read16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
230                     guint offset, gboolean isreq, gboolean iscdb,
231                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
232 {
233     guint8 flags;
234     static const int *read6_fields[] = {
235         &hf_scsi_ssc_sili,
236         &hf_scsi_ssc_fixed,
237         NULL
238     };
239
240     if (isreq) {
241         if (check_col (pinfo->cinfo, COL_INFO))
242             col_append_fstr (pinfo->cinfo, COL_INFO, "(Len: %u)",
243                              tvb_get_ntoh24 (tvb, offset+1));
244     }
245
246     if (tree && isreq && iscdb) {
247         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, read6_fields, FALSE);
248
249         proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset+2, 1, 0);
250
251         proto_tree_add_item (tree, hf_scsi_ssc_locate16_loid, tvb, offset+3, 8, 0);
252
253         proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+11, 3, 0);
254
255         flags = tvb_get_guint8 (tvb, offset+14);
256         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1,
257                                     flags,
258                                     "Vendor Unique = %u, NACA = %u, Link = %u",
259                                     flags & 0xC0, flags & 0x4, flags & 0x1);
260     }
261 }
262
263 static void
264 dissect_ssc_write16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
265                     guint offset, gboolean isreq, gboolean iscdb,
266                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
267 {
268     guint8 flags;
269     static const int *write16_fields[] = {
270         &hf_scsi_ssc_fcs,
271         &hf_scsi_ssc_lcs,
272         &hf_scsi_ssc_fixed,
273         NULL
274     };
275
276     if (isreq) {
277         if (check_col (pinfo->cinfo, COL_INFO))
278             col_append_fstr (pinfo->cinfo, COL_INFO, "(Len: %u)",
279                              tvb_get_ntoh24 (tvb, offset+1));
280     }
281
282     if (tree && isreq && iscdb) {
283         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, write16_fields, FALSE);
284
285         proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset+2, 1, 0);
286
287         proto_tree_add_item (tree, hf_scsi_ssc_locate16_loid, tvb, offset+3, 8, 0);
288
289         proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+11, 3, 0);
290
291         flags = tvb_get_guint8 (tvb, offset+14);
292         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1,
293                                     flags,
294                                     "Vendor Unique = %u, NACA = %u, Link = %u",
295                                     flags & 0xC0, flags & 0x4, flags & 0x1);
296     }
297 }
298
299 static void
300 dissect_ssc_writefilemarks16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
301                     guint offset, gboolean isreq, gboolean iscdb,
302                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
303 {
304     guint8 flags;
305     static const int *wf16_fields[] = {
306         &hf_scsi_ssc_fcs,
307         &hf_scsi_ssc_lcs,
308         &hf_scsi_ssc_immed,
309         NULL
310     };
311
312     if (isreq) {
313         if (check_col (pinfo->cinfo, COL_INFO))
314             col_append_fstr (pinfo->cinfo, COL_INFO, "(Len: %u)",
315                              tvb_get_ntoh24 (tvb, offset+1));
316     }
317
318     if (tree && isreq && iscdb) {
319         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, wf16_fields, FALSE);
320
321         proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset+2, 1, 0);
322
323         proto_tree_add_item (tree, hf_scsi_ssc_locate16_loid, tvb, offset+3, 8, 0);
324
325         proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+11, 3, 0);
326
327         flags = tvb_get_guint8 (tvb, offset+14);
328         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1,
329                                     flags,
330                                     "Vendor Unique = %u, NACA = %u, Link = %u",
331                                     flags & 0xC0, flags & 0x4, flags & 0x1);
332     }
333 }
334
335 static void
336 dissect_ssc_verify16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
337                     guint offset, gboolean isreq, gboolean iscdb,
338                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
339 {
340     guint8 flags;
341     static const int *verify16_fields[] = {
342         &hf_scsi_ssc_verify16_immed,
343         &hf_scsi_ssc_bytcmp,
344         &hf_scsi_ssc_fixed,
345         NULL
346     };
347
348     if (isreq) {
349         if (check_col (pinfo->cinfo, COL_INFO))
350             col_append_fstr (pinfo->cinfo, COL_INFO, "(Len: %u)",
351                              tvb_get_ntoh24 (tvb, offset+1));
352     }
353
354     if (tree && isreq && iscdb) {
355         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, verify16_fields, FALSE);
356
357         proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset+2, 1, 0);
358
359         proto_tree_add_item (tree, hf_scsi_ssc_locate16_loid, tvb, offset+3, 8, 0);
360
361         proto_tree_add_item (tree, hf_scsi_ssc_ver16_verlen, tvb, offset+11, 3, 0);
362
363         flags = tvb_get_guint8 (tvb, offset+14);
364         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1,
365                                     flags,
366                                     "Vendor Unique = %u, NACA = %u, Link = %u",
367                                     flags & 0xC0, flags & 0x4, flags & 0x1);
368     }
369 }
370
371 static void
372 dissect_ssc_verify6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
373                     guint offset, gboolean isreq, gboolean iscdb,
374                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
375 {
376     guint8 flags;
377     static const int *verify6_fields[] = {
378         &hf_scsi_ssc_verify16_immed,
379         &hf_scsi_ssc_bytcmp,
380         &hf_scsi_ssc_fixed,
381         NULL
382     };
383
384     if (isreq) {
385         if (check_col (pinfo->cinfo, COL_INFO))
386             col_append_fstr (pinfo->cinfo, COL_INFO, "(Len: %u)",
387                              tvb_get_ntoh24 (tvb, offset+1));
388     }
389
390     if (tree && isreq && iscdb) {
391         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, verify6_fields, FALSE);
392
393         proto_tree_add_item (tree, hf_scsi_ssc_ver16_verlen, tvb, offset+1, 3, 0);
394
395         flags = tvb_get_guint8 (tvb, offset+4);
396         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
397                                     flags,
398                                     "Vendor Unique = %u, NACA = %u, Link = %u",
399                                     flags & 0xC0, flags & 0x4, flags & 0x1);
400     }
401 }
402
403 static void
404 dissect_ssc_readreverse16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
405                     guint offset, gboolean isreq, gboolean iscdb,
406                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
407 {
408     guint8 flags;
409     static const int *rr16_fields[] = {
410         &hf_scsi_ssc_bytord,
411         &hf_scsi_ssc_sili,
412         &hf_scsi_ssc_fixed,
413         NULL
414     };
415
416     if (isreq) {
417         if (check_col (pinfo->cinfo, COL_INFO))
418             col_append_fstr (pinfo->cinfo, COL_INFO, "(Len: %u)",
419                              tvb_get_ntoh24 (tvb, offset+1));
420     }
421
422     if (tree && isreq && iscdb) {
423         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, rr16_fields, FALSE);
424
425         proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset+2, 1, 0);
426
427         proto_tree_add_item (tree, hf_scsi_ssc_locate16_loid, tvb, offset+3, 8, 0);
428
429         proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+11, 3, 0);
430
431         flags = tvb_get_guint8 (tvb, offset+14);
432         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1,
433                                     flags,
434                                     "Vendor Unique = %u, NACA = %u, Link = %u",
435                                     flags & 0xC0, flags & 0x4, flags & 0x1);
436     }
437 }
438
439 static void
440 dissect_ssc_write6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
441                     guint offset, gboolean isreq, gboolean iscdb,
442                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
443 {
444     guint8 flags;
445     static const int *write6_fields[] = {
446         &hf_scsi_ssc_immed,
447         NULL
448     };
449
450     if (isreq && iscdb) {
451         if (check_col (pinfo->cinfo, COL_INFO))
452             col_append_fstr (pinfo->cinfo, COL_INFO, "(Len: %u)",
453                              tvb_get_ntoh24 (tvb, offset+1));
454     }
455
456     if (tree && isreq && iscdb) {
457         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, write6_fields, FALSE);
458
459         proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+1, 3,
460                              FALSE);
461
462         flags = tvb_get_guint8 (tvb, offset+4);
463         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
464                                     flags,
465                                     "Vendor Unique = %u, NACA = %u, Link = %u",
466                                     flags & 0xC0, flags & 0x4, flags & 0x1);
467     }
468 }
469
470 static void
471 dissect_ssc_writefilemarks6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
472                     guint offset, gboolean isreq, gboolean iscdb,
473                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
474 {
475     guint8 flags;
476     static const int *wf6_fields[] = {
477         &hf_scsi_ssc_immed,
478         NULL
479     };
480
481     if (isreq) {
482         if (check_col (pinfo->cinfo, COL_INFO))
483             col_append_fstr (pinfo->cinfo, COL_INFO, "(Len: %u)",
484                              tvb_get_ntoh24 (tvb, offset+1));
485     }
486
487     if (tree && isreq && iscdb) {
488         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, wf6_fields, FALSE);
489
490         proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+1, 3,
491                              FALSE);
492
493         flags = tvb_get_guint8 (tvb, offset+4);
494         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
495                                     flags,
496                                     "Vendor Unique = %u, NACA = %u, Link = %u",
497                                     flags & 0xC0, flags & 0x4, flags & 0x1);
498     }
499 }
500
501 static void
502 dissect_ssc_loadunload (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
503                     guint offset, gboolean isreq, gboolean iscdb,
504                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
505 {
506     guint8 flags;
507     static const int *loadunload_immed_fields[] = {
508         &hf_scsi_ssc_immed,
509         NULL
510     };
511     static const int *loadunload_fields[] = {
512         &hf_scsi_ssc_hold,
513         &hf_scsi_ssc_eot,
514         &hf_scsi_ssc_reten,
515         &hf_scsi_ssc_load,
516         NULL
517     };
518
519     if (isreq && iscdb) {
520         if (check_col (pinfo->cinfo, COL_INFO))
521             col_append_fstr (pinfo->cinfo, COL_INFO, "(Immed: %u)",
522                              tvb_get_guint8 (tvb, offset) & 0x01);
523     }
524
525     if (!tree)
526         return;
527
528
529     if (isreq && iscdb) {
530         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_loadunload_immed_flags, ett_scsi_loadunload_immed, loadunload_immed_fields, FALSE);
531
532         proto_tree_add_bitmask(tree, tvb, offset+3, hf_scsi_ssc_loadunload_flags, ett_scsi_loadunload, loadunload_fields, FALSE);
533
534         flags = tvb_get_guint8 (tvb, offset+4);
535         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
536                                     flags,
537                                     "Vendor Unique = %u, NACA = %u, Link = %u",
538                                     flags & 0xC0, flags & 0x4, flags & 0x1);
539     }
540 }
541
542
543 static void
544 dissect_ssc_readblocklimits (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
545                     guint offset, gboolean isreq, gboolean iscdb,
546                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
547 {
548     guint8 flags, granularity;
549
550     if (!tree)
551         return;
552
553     if (isreq && iscdb) {
554         flags = tvb_get_guint8 (tvb, offset+4);
555         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
556                                     flags,
557                                     "Vendor Unique = %u, NACA = %u, Link = %u",
558                                     flags & 0xC0, flags & 0x4, flags & 0x1);
559     }
560     else if (!iscdb) {
561         granularity = tvb_get_guint8 (tvb, offset);
562         proto_tree_add_text (tree, tvb, offset, 1, "Granularity: %u (%u %s)",
563                              granularity, 1 << granularity,
564                              plurality(1 << granularity, "byte", "bytes"));
565         proto_tree_add_text (tree, tvb, offset+1, 3, "Maximum Block Length Limit: %u bytes",
566                              tvb_get_ntoh24 (tvb, offset+1));
567         proto_tree_add_text (tree, tvb, offset+4, 2, "Minimum Block Length Limit: %u bytes",
568                              tvb_get_ntohs (tvb, offset+4));
569     }
570 }
571
572 static void
573 dissect_ssc_rewind (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
574                     guint offset, gboolean isreq, gboolean iscdb,
575                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
576 {
577     guint8 flags;
578     static const int *rewind_fields[] = {
579         &hf_scsi_ssc_immed,
580         NULL
581     };
582
583     if (!tree)
584         return;
585
586     if (isreq && iscdb) {
587         if (check_col (pinfo->cinfo, COL_INFO))
588             col_append_fstr (pinfo->cinfo, COL_INFO, "(Immed: %u)",
589                              tvb_get_guint8 (tvb, offset) & 0x01);
590
591         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, rewind_fields, FALSE);
592
593         flags = tvb_get_guint8 (tvb, offset+4);
594         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
595                                     flags,
596                                     "Vendor Unique = %u, NACA = %u, Link = %u",
597                                     flags & 0xC0, flags & 0x4, flags & 0x1);
598     }
599 }
600
601 static void
602 dissect_ssc_setcapacity (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
603                     guint offset, gboolean isreq, gboolean iscdb,
604                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
605 {
606     guint8 flags;
607     static const int *sc_fields[] = {
608         &hf_scsi_ssc_immed,
609         NULL
610     };
611
612     if (!tree)
613         return;
614
615     if (isreq && iscdb) {
616         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, sc_fields, FALSE);
617
618         proto_tree_add_item (tree, hf_scsi_ssc_capacity_prop_value, tvb, offset+2, 2, 0);
619
620         flags = tvb_get_guint8 (tvb, offset+4);
621         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
622                                     flags,
623                                     "Vendor Unique = %u, NACA = %u, Link = %u",
624                                     flags & 0xC0, flags & 0x4, flags & 0x1);
625     }
626 }
627
628
629 static void
630 dissect_ssc_locate10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
631                     guint offset, gboolean isreq, gboolean iscdb,
632                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
633 {
634     guint8 flags;
635     static const int *locate_fields[] = {
636         &hf_scsi_ssc_bt,
637         &hf_scsi_ssc_cp,
638         &hf_scsi_ssc_immed,
639         NULL
640     };
641
642     if (!tree)
643         return;
644
645     if (isreq && iscdb) {
646         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_locate_flags, ett_scsi_locate, locate_fields, FALSE);
647
648         proto_tree_add_item (tree, hf_scsi_ssc_locate10_loid, tvb, offset+2, 4, 0);
649
650         proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset+7, 1, 0);
651
652         flags = tvb_get_guint8 (tvb, offset+8);
653         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1,
654                                     flags,
655                                     "Vendor Unique = %u, NACA = %u, Link = %u",
656                                     flags & 0xC0, flags & 0x4, flags & 0x1);
657     }
658 }
659
660
661 static void
662 dissect_ssc_locate16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
663                     guint offset, gboolean isreq, gboolean iscdb,
664                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
665 {
666     guint8 flags;
667     static const int *locate_fields[] = {
668         &hf_scsi_ssc_dest_type,
669         &hf_scsi_ssc_cp,
670         &hf_scsi_ssc_immed,
671         NULL
672     };
673     static const int *bam_fields[] = {
674         &hf_scsi_ssc_bam,
675         NULL
676     };
677
678     if (!tree)
679         return;
680
681     if (isreq && iscdb) {
682         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_locate_flags, ett_scsi_locate, locate_fields, FALSE);
683
684         proto_tree_add_bitmask(tree, tvb, offset+1, hf_scsi_ssc_bam_flags, ett_scsi_bam, bam_fields, FALSE);
685
686         proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset+2, 1, 0);
687
688         proto_tree_add_item (tree, hf_scsi_ssc_locate16_loid, tvb, offset+3, 8, 0);
689
690         flags = tvb_get_guint8 (tvb, offset+14);
691         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1,
692                                     flags,
693                                     "Vendor Unique = %u, NACA = %u, Link = %u",
694                                     flags & 0xC0, flags & 0x4, flags & 0x1);
695     }
696 }
697
698
699 static void
700 dissect_ssc_erase6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
701                     guint offset, gboolean isreq, gboolean iscdb,
702                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
703 {
704     guint8 flags;
705
706     if (isreq && iscdb) {
707         if (!tree)
708             return;
709
710         flags = tvb_get_guint8 (tvb, offset);
711         proto_tree_add_text (tree, tvb, offset, 1,
712                              "IMMED: %u, LONG: %u",
713                              (flags & 0x02) >> 1,
714                              flags & 0x01);
715
716         flags = tvb_get_guint8 (tvb, offset+4);
717         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
718                                     flags,
719                                     "Vendor Unique = %u, NACA = %u, Link = %u",
720                                     flags & 0xC0, flags & 0x4, flags & 0x1);
721     }
722 }
723
724
725 static void
726 dissect_ssc_erase16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
727                     guint offset, gboolean isreq, gboolean iscdb,
728                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
729 {
730     guint8 flags;
731     static const int *erase16_fields[] = {
732         &hf_scsi_ssc_fcs,
733         &hf_scsi_ssc_lcs,
734         &hf_scsi_ssc_erase_immed,
735         &hf_scsi_ssc_long,
736         NULL
737     };
738
739     if (!tree)
740         return;
741
742     if (isreq && iscdb) {
743         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_erase_flags, ett_scsi_erase, erase16_fields, FALSE);
744
745         proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset+2, 1, 0);
746
747         proto_tree_add_item (tree, hf_scsi_ssc_lbi, tvb, offset+3, 8, 0);
748
749         flags = tvb_get_guint8 (tvb, offset+14);
750         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1,
751                                     flags,
752                                     "Vendor Unique = %u, NACA = %u, Link = %u",
753                                     flags & 0xC0, flags & 0x4, flags & 0x1);
754     }
755 }
756
757
758 static void
759 dissect_ssc_space6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
760                     guint offset, gboolean isreq, gboolean iscdb,
761                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
762 {
763     guint8 flags;
764
765     if (!tree)
766         return;
767
768     if (isreq && iscdb) {
769         proto_tree_add_item (tree, hf_scsi_ssc_space6_code, tvb, offset, 1, 0);
770
771         proto_tree_add_item (tree, hf_scsi_ssc_space6_count, tvb, offset+1, 3, 0);
772
773         flags = tvb_get_guint8 (tvb, offset+4);
774         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
775                                     flags,
776                                     "Vendor Unique = %u, NACA = %u, Link = %u",
777                                     flags & 0xC0, flags & 0x4, flags & 0x1);
778     }
779 }
780
781 static void
782 dissect_ssc_space16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
783                     guint offset, gboolean isreq, gboolean iscdb,
784                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
785 {
786     guint8 flags;
787
788     if (!tree)
789         return;
790
791     if (isreq && iscdb) {
792         proto_tree_add_item (tree, hf_scsi_ssc_space6_code, tvb, offset, 1, 0);
793
794         proto_tree_add_item (tree, hf_scsi_ssc_space16_count, tvb, offset+3, 8, 0);
795
796         proto_tree_add_text (tree, tvb, offset+11, 2,
797                              "Parameter Len: %u",
798                              tvb_get_ntohs (tvb, offset+11));
799
800         flags = tvb_get_guint8 (tvb, offset+14);
801         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1,
802                                     flags,
803                                     "Vendor Unique = %u, NACA = %u, Link = %u",
804                                     flags & 0xC0, flags & 0x4, flags & 0x1);
805     }
806 }
807
808 static const value_string space6_code_vals[] = {
809     {0, "Logical Blocks"},
810     {1, "Filemarks"},
811     {2, "Sequential Filemarks"},
812     {3, "End-Of-Data"},
813     {0, NULL}
814 };
815
816 static const value_string format_vals[] = {
817     {0x0, "Use default format"},
818     {0x1, "Partition medium"},
819     {0x2, "Default format then partition"},
820     {0, NULL}
821 };
822
823 static const value_string dest_type_vals[] = {
824     {0, "Logical Object Identifier"},
825     {1, "Logical File Identifier"},
826     {0, NULL}
827 };
828
829 static void
830 dissect_ssc_formatmedium (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
831                     guint offset, gboolean isreq, gboolean iscdb,
832                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
833 {
834     guint8 flags;
835     static const int *formatmedium_fields[] = {
836         &hf_scsi_ssc_verify,
837         &hf_scsi_ssc_immed,
838         NULL
839     };
840
841     if (!tree)
842         return;
843
844     if (isreq && iscdb) {
845         proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_formatmedium_flags, ett_scsi_formatmedium, formatmedium_fields, FALSE);
846
847         proto_tree_add_item (tree, hf_scsi_ssc_format, tvb, offset+1, 1, 0);
848
849         proto_tree_add_item (tree, hf_scsi_ssc_rdwr10_xferlen, tvb, offset+2, 2, 0);
850
851         flags = tvb_get_guint8 (tvb, offset+4);
852         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1,
853                                     flags,
854                                     "Vendor Unique = %u, NACA = %u, Link = %u",
855                                     flags & 0xC0, flags & 0x4, flags & 0x1);
856     }
857 }
858
859
860 #define BCU  0x20
861 #define BYCU 0x10
862 #define MPU  0x08
863 #define BPU  0x04
864
865 static void
866 dissect_ssc_readposition (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
867                     guint offset, gboolean isreq, gboolean iscdb,
868                     guint payload_len _U_, scsi_task_data_t *cdata)
869 {
870     gint service_action;
871     guint8 flags;
872
873     if (!tree)
874         return;
875
876     if (isreq && iscdb) {
877         service_action = tvb_get_guint8 (tvb, offset) & 0x1F;
878         proto_tree_add_text (tree, tvb, offset, 1,
879                              "Service Action: %s",
880                              val_to_str (service_action,
881                                          service_action_vals,
882                                          "Unknown (0x%02x)"));
883         /* Remember the service action so we can decode the reply */
884         if (cdata != NULL) {
885             cdata->itlq->flags = service_action;
886         }
887         proto_tree_add_text (tree, tvb, offset+6, 2,
888                              "Parameter Len: %u",
889                              tvb_get_ntohs (tvb, offset+6));
890         flags = tvb_get_guint8 (tvb, offset+8);
891         proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1,
892                                     flags,
893                                     "Vendor Unique = %u, NACA = %u, Link = %u",
894                                     flags & 0xC0, flags & 0x4, flags & 0x1);
895     }
896     else if (!isreq) {
897         if (cdata)
898             service_action = cdata->itlq->flags;
899         else
900             service_action = -1; /* unknown */
901         switch (service_action) {
902         case SHORT_FORM_BLOCK_ID:
903         case SHORT_FORM_VENDOR_SPECIFIC:
904             flags = tvb_get_guint8 (tvb, offset);
905             proto_tree_add_text (tree, tvb, offset, 1,
906                              "BOP: %u, EOP: %u, BCU: %u, BYCU: %u, BPU: %u, PERR: %u",
907                              (flags & 0x80) >> 7, (flags & 0x40) >> 6,
908                              (flags & BCU) >> 5, (flags & BYCU) >> 4,
909                              (flags & BPU) >> 2, (flags & 0x02) >> 1);
910             offset += 1;
911
912             proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset, 1, 0);
913             offset += 1;
914
915             offset += 2; /* reserved */
916
917             if (!(flags & BPU)) {
918                 proto_tree_add_text (tree, tvb, offset, 4,
919                                      "First Block Location: %u",
920                                      tvb_get_ntohl (tvb, offset));
921                 offset += 4;
922
923                 proto_tree_add_text (tree, tvb, offset, 4,
924                                      "Last Block Location: %u",
925                                      tvb_get_ntohl (tvb, offset));
926                 offset += 4;
927             } else
928                 offset += 8;
929
930             offset += 1; /* reserved */
931
932             if (!(flags & BCU)) {
933                 proto_tree_add_text (tree, tvb, offset, 3,
934                                      "Number of Blocks in Buffer: %u",
935                                      tvb_get_ntoh24 (tvb, offset));
936             }
937             offset += 3;
938
939             if (!(flags & BYCU)) {
940                 proto_tree_add_text (tree, tvb, offset, 4,
941                                      "Number of Bytes in Buffer: %u",
942                                      tvb_get_ntohl (tvb, offset));
943             }
944             offset += 4;
945             break;
946
947         case LONG_FORM:
948             flags = tvb_get_guint8 (tvb, offset);
949             proto_tree_add_text (tree, tvb, offset, 1,
950                              "BOP: %u, EOP: %u, MPU: %u, BPU: %u",
951                              (flags & 0x80) >> 7, (flags & 0x40) >> 6,
952                              (flags & MPU) >> 3, (flags & BPU) >> 2);
953             offset += 1;
954
955             offset += 3; /* reserved */
956
957             if (!(flags & BPU)) {
958                 proto_tree_add_text (tree, tvb, offset, 4,
959                                      "Partition Number: %u",
960                                      tvb_get_ntohl (tvb, offset));
961                 offset += 4;
962
963                 proto_tree_add_text (tree, tvb, offset, 8,
964                                      "Block Number: %" G_GINT64_MODIFIER "u",
965                                      tvb_get_ntoh64 (tvb, offset));
966                  offset += 8;
967             } else
968                 offset += 12;
969
970             if (!(flags & MPU)) {
971                 proto_tree_add_text (tree, tvb, offset, 8,
972                                      "File Number: %" G_GINT64_MODIFIER "u",
973                                      tvb_get_ntoh64 (tvb, offset));
974                 offset += 8;
975
976                 proto_tree_add_text (tree, tvb, offset, 8,
977                                      "Set Number: %" G_GINT64_MODIFIER "u",
978                                      tvb_get_ntoh64 (tvb, offset));
979                 offset += 8;
980             } else
981                 offset += 16;
982             break;
983
984         case EXTENDED_FORM:
985             flags = tvb_get_guint8 (tvb, offset);
986             proto_tree_add_text (tree, tvb, offset, 1,
987                              "BOP: %u, EOP: %u, BCU: %u, BYCU: %u, MPU: %u, BPU: %u, PERR: %u",
988                              (flags & 0x80) >> 7, (flags & 0x40) >> 6,
989                              (flags & BCU) >> 5, (flags & BYCU) >> 4,
990                              (flags & MPU) >> 3, (flags & BPU) >> 2,
991                              (flags & 0x02) >> 1);
992             offset += 1;
993
994             proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset, 1, 0);
995             offset += 1;
996
997             proto_tree_add_text (tree, tvb, offset, 2,
998                                  "Additional Length: %u",
999                                  tvb_get_ntohs (tvb, offset));
1000             offset += 2;
1001
1002             offset += 1; /* reserved */
1003
1004             if (!(flags & BCU)) {
1005                 proto_tree_add_text (tree, tvb, offset, 3,
1006                                      "Number of Blocks in Buffer: %u",
1007                                      tvb_get_ntoh24 (tvb, offset));
1008             }
1009             offset += 3;
1010
1011             if (!(flags & BPU)) {
1012                 proto_tree_add_text (tree, tvb, offset, 8,
1013                                      "First Block Location: %" G_GINT64_MODIFIER "u",
1014                                      tvb_get_ntoh64 (tvb, offset));
1015                 offset += 8;
1016
1017                 proto_tree_add_text (tree, tvb, offset, 8,
1018                                      "Last Block Location: %" G_GINT64_MODIFIER "u",
1019                                      tvb_get_ntoh64 (tvb, offset));
1020                 offset += 8;
1021             } else
1022                 offset += 16;
1023
1024             offset += 1; /* reserved */
1025
1026             if (!(flags & BYCU)) {
1027                 proto_tree_add_text (tree, tvb, offset, 8,
1028                                      "Number of Bytes in Buffer: %" G_GINT64_MODIFIER "u",
1029                                      tvb_get_ntoh64 (tvb, offset));
1030             }
1031             offset += 8;
1032             break;
1033
1034         default:
1035             break;
1036         }
1037     }
1038 }
1039
1040
1041
1042
1043
1044 /* SSC Commands */
1045 const value_string scsi_ssc_vals[] = {
1046     {SCSI_SSC_ERASE_6                      , "Erase(6)"},
1047     {SCSI_SSC_ERASE_16                     , "Erase(16)"},
1048     {SCSI_SPC_EXTCOPY                      , "Extended Copy"},
1049     {SCSI_SSC_FORMAT_MEDIUM                , "Format Medium"},
1050     {SCSI_SPC_INQUIRY                      , "Inquiry"},
1051     {SCSI_SSC_LOAD_UNLOAD                  , "Load Unload"},
1052     {SCSI_SSC_LOCATE_10                    , "Locate(10)"},
1053     {SCSI_SSC_LOCATE_16                    , "Locate(16)"},
1054     {SCSI_SPC_LOGSELECT                    , "Log Select"},
1055     {SCSI_SPC_LOGSENSE                     , "Log Sense"},
1056     {SCSI_SPC_MODESELECT6                  , "Mode Select(6)"},
1057     {SCSI_SPC_RESERVE6                     , "Reserve(6)"},
1058     {SCSI_SPC_RELEASE6                     , "Release(6)"},
1059     {SCSI_SPC_MODESELECT10                 , "Mode Select(10)"},
1060     {SCSI_SPC_MODESENSE6                   , "Mode Sense(6)"},
1061     {SCSI_SPC_MODESENSE10                  , "Mode Sense(10)"},
1062     {SCSI_SMC_MOVE_MEDIUM                  , "Move Medium"},
1063     {SCSI_SMC_MOVE_MEDIUM_ATTACHED         , "Move Medium Attached"},
1064     {SCSI_SPC_PERSRESVIN                   , "Persistent Reserve In"},
1065     {SCSI_SPC_PERSRESVOUT                  , "Persistent Reserve Out"},
1066     {SCSI_SPC_PREVMEDREMOVAL               , "Prevent/Allow Medium Removal"},
1067     {SCSI_SSC_READ6                        , "Read(6)"},
1068     {SCSI_SSC_READ_16                      , "Read(16)"},
1069     {SCSI_SSC_READ_BLOCK_LIMITS            , "Read Block Limits"},
1070     {SCSI_SMC_READ_ELEMENT_STATUS          , "Read Element Status"},
1071     {SCSI_SMC_READ_ELEMENT_STATUS_ATTACHED , "Read Element Status Attached"},
1072     {SCSI_SSC_READ_POSITION                , "Read Position"},
1073     {SCSI_SSC_READ_REVERSE_6               , "Read Reverse(6)"},
1074     {SCSI_SSC_READ_REVERSE_16              , "Read Reverse(16)"},
1075     {SCSI_SSC_RECOVER_BUFFERED_DATA        , "Recover Buffered Data"},
1076     {SCSI_SSC_REPORT_DENSITY_SUPPORT       , "Report Density Support"},
1077     {SCSI_SPC_REPORTLUNS                   , "Report LUNs"},
1078     {SCSI_SPC_REQSENSE                     , "Request Sense"},
1079     {SCSI_SSC_REWIND                       , "Rewind"},
1080     {SCSI_SPC_SENDDIAG                     , "Send Diagnostic"},
1081     {SCSI_SSC_SET_CAPACITY                 , "Set Capacity"},
1082     {SCSI_SSC_SPACE_6                      , "Space(6)"},
1083     {SCSI_SSC_SPACE_16                     , "Space(16)"},
1084     {SCSI_SPC_TESTUNITRDY                  , "Test Unit Ready"},
1085     {SCSI_SSC_VERIFY_6                     , "Verify(6)"},
1086     {SCSI_SSC_VERIFY_16                    , "Verify(16)"},
1087     {SCSI_SSC_WRITE6                       , "Write(6)"},
1088     {SCSI_SSC_WRITE_16                     , "Write(16)"},
1089     {SCSI_SPC_WRITEBUFFER                  , "Write Buffer"},
1090     {SCSI_SSC_WRITE_FILEMARKS_16           , "Write Filemarks(16)"},
1091     {SCSI_SSC_WRITE_FILEMARKS_6            , "Write Filemarks(6)"},
1092     {0, NULL}
1093 };
1094
1095
1096 scsi_cdb_table_t scsi_ssc_table[256] = {
1097 /*SPC 0x00*/{dissect_spc_testunitready},
1098 /*SSC 0x01*/{dissect_ssc_rewind},
1099 /*SSC 0x02*/{NULL},
1100 /*SPC 0x03*/{dissect_spc_requestsense},
1101 /*SSC 0x04*/{dissect_ssc_formatmedium},
1102 /*SSC 0x05*/{dissect_ssc_readblocklimits},
1103 /*SSC 0x06*/{NULL},
1104 /*SSC 0x07*/{NULL},
1105 /*SSC 0x08*/{dissect_ssc_read6},
1106 /*SSC 0x09*/{NULL},
1107 /*SSC 0x0a*/{dissect_ssc_write6},
1108 /*SSC 0x0b*/{dissect_ssc_setcapacity},
1109 /*SSC 0x0c*/{NULL},
1110 /*SSC 0x0d*/{NULL},
1111 /*SSC 0x0e*/{NULL},
1112 /*SSC 0x0f*/{dissect_ssc_readreverse6},
1113 /*SSC 0x10*/{dissect_ssc_writefilemarks6},
1114 /*SSC 0x11*/{dissect_ssc_space6},
1115 /*SPC 0x12*/{dissect_spc_inquiry},
1116 /*SSC 0x13*/{dissect_ssc_verify6},
1117 /*SSC 0x14*/{dissect_ssc_recoverbuffereddata},
1118 /*SPC 0x15*/{dissect_spc_modeselect6},
1119 /*SSC 0x16*/{dissect_spc_reserve6},
1120 /*SSC 0x17*/{dissect_spc_release6},
1121 /*SSC 0x18*/{NULL},
1122 /*SSC 0x19*/{dissect_ssc_erase6},
1123 /*SPC 0x1a*/{dissect_spc_modesense6},
1124 /*SSC 0x1b*/{dissect_ssc_loadunload},
1125 /*SSC 0x1c*/{NULL},
1126 /*SPC 0x1d*/{dissect_spc_senddiagnostic},
1127 /*SSC 0x1e*/{dissect_spc_preventallowmediaremoval},
1128 /*SSC 0x1f*/{NULL},
1129 /*SSC 0x20*/{NULL},
1130 /*SSC 0x21*/{NULL},
1131 /*SSC 0x22*/{NULL},
1132 /*SSC 0x23*/{NULL},
1133 /*SSC 0x24*/{NULL},
1134 /*SSC 0x25*/{NULL},
1135 /*SSC 0x26*/{NULL},
1136 /*SSC 0x27*/{NULL},
1137 /*SSC 0x28*/{NULL},
1138 /*SSC 0x29*/{NULL},
1139 /*SSC 0x2a*/{NULL},
1140 /*SSC 0x2b*/{dissect_ssc_locate10},
1141 /*SSC 0x2c*/{NULL},
1142 /*SSC 0x2d*/{NULL},
1143 /*SSC 0x2e*/{NULL},
1144 /*SSC 0x2f*/{NULL},
1145 /*SSC 0x30*/{NULL},
1146 /*SSC 0x31*/{NULL},
1147 /*SSC 0x32*/{NULL},
1148 /*SSC 0x33*/{NULL},
1149 /*SSC 0x34*/{dissect_ssc_readposition},
1150 /*SSC 0x35*/{NULL},
1151 /*SSC 0x36*/{NULL},
1152 /*SSC 0x37*/{NULL},
1153 /*SSC 0x38*/{NULL},
1154 /*SSC 0x39*/{NULL},
1155 /*SSC 0x3a*/{NULL},
1156 /*SPC 0x3b*/{dissect_spc_writebuffer},
1157 /*SSC 0x3c*/{NULL},
1158 /*SSC 0x3d*/{NULL},
1159 /*SSC 0x3e*/{NULL},
1160 /*SSC 0x3f*/{NULL},
1161 /*SSC 0x40*/{NULL},
1162 /*SSC 0x41*/{NULL},
1163 /*SSC 0x42*/{NULL},
1164 /*SSC 0x43*/{NULL},
1165 /*SSC 0x44*/{dissect_ssc_reportdensitysupport},
1166 /*SSC 0x45*/{NULL},
1167 /*SSC 0x46*/{NULL},
1168 /*SSC 0x47*/{NULL},
1169 /*SSC 0x48*/{NULL},
1170 /*SSC 0x49*/{NULL},
1171 /*SSC 0x4a*/{NULL},
1172 /*SSC 0x4b*/{NULL},
1173 /*SPC 0x4c*/{dissect_spc_logselect},
1174 /*SPC 0x4d*/{dissect_spc_logsense},
1175 /*SSC 0x4e*/{NULL},
1176 /*SSC 0x4f*/{NULL},
1177 /*SSC 0x50*/{NULL},
1178 /*SSC 0x51*/{NULL},
1179 /*SSC 0x52*/{NULL},
1180 /*SSC 0x53*/{NULL},
1181 /*SSC 0x54*/{NULL},
1182 /*SPC 0x55*/{dissect_spc_modeselect10},
1183 /*SSC 0x56*/{NULL},
1184 /*SSC 0x57*/{NULL},
1185 /*SSC 0x58*/{NULL},
1186 /*SSC 0x59*/{NULL},
1187 /*SPC 0x5a*/{dissect_spc_modesense10},
1188 /*SSC 0x5b*/{NULL},
1189 /*SSC 0x5c*/{NULL},
1190 /*SSC 0x5d*/{NULL},
1191 /*SPC 0x5e*/{dissect_spc_persistentreservein},
1192 /*SPC 0x5f*/{dissect_spc_persistentreserveout},
1193 /*SSC 0x60*/{NULL},
1194 /*SSC 0x61*/{NULL},
1195 /*SSC 0x62*/{NULL},
1196 /*SSC 0x63*/{NULL},
1197 /*SSC 0x64*/{NULL},
1198 /*SSC 0x65*/{NULL},
1199 /*SSC 0x66*/{NULL},
1200 /*SSC 0x67*/{NULL},
1201 /*SSC 0x68*/{NULL},
1202 /*SSC 0x69*/{NULL},
1203 /*SSC 0x6a*/{NULL},
1204 /*SSC 0x6b*/{NULL},
1205 /*SSC 0x6c*/{NULL},
1206 /*SSC 0x6d*/{NULL},
1207 /*SSC 0x6e*/{NULL},
1208 /*SSC 0x6f*/{NULL},
1209 /*SSC 0x70*/{NULL},
1210 /*SSC 0x71*/{NULL},
1211 /*SSC 0x72*/{NULL},
1212 /*SSC 0x73*/{NULL},
1213 /*SSC 0x74*/{NULL},
1214 /*SSC 0x75*/{NULL},
1215 /*SSC 0x76*/{NULL},
1216 /*SSC 0x77*/{NULL},
1217 /*SSC 0x78*/{NULL},
1218 /*SSC 0x79*/{NULL},
1219 /*SSC 0x7a*/{NULL},
1220 /*SSC 0x7b*/{NULL},
1221 /*SSC 0x7c*/{NULL},
1222 /*SSC 0x7d*/{NULL},
1223 /*SSC 0x7e*/{NULL},
1224 /*SSC 0x7f*/{NULL},
1225 /*SSC 0x80*/{dissect_ssc_writefilemarks16},
1226 /*SSC 0x81*/{dissect_ssc_readreverse16},
1227 /*SSC 0x82*/{NULL},
1228 /*SPC 0x83*/{dissect_spc_extcopy},
1229 /*SSC 0x84*/{NULL},
1230 /*SSC 0x85*/{NULL},
1231 /*SSC 0x86*/{NULL},
1232 /*SSC 0x87*/{NULL},
1233 /*SSC 0x88*/{dissect_ssc_read16},
1234 /*SSC 0x89*/{NULL},
1235 /*SSC 0x8a*/{dissect_ssc_write16},
1236 /*SSC 0x8b*/{NULL},
1237 /*SSC 0x8c*/{NULL},
1238 /*SSC 0x8d*/{NULL},
1239 /*SSC 0x8e*/{NULL},
1240 /*SSC 0x8f*/{dissect_ssc_verify16},
1241 /*SSC 0x90*/{NULL},
1242 /*SSC 0x91*/{dissect_ssc_space16},
1243 /*SSC 0x92*/{dissect_ssc_locate16},
1244 /*SSC 0x93*/{dissect_ssc_erase16},
1245 /*SSC 0x94*/{NULL},
1246 /*SSC 0x95*/{NULL},
1247 /*SSC 0x96*/{NULL},
1248 /*SSC 0x97*/{NULL},
1249 /*SSC 0x98*/{NULL},
1250 /*SSC 0x99*/{NULL},
1251 /*SSC 0x9a*/{NULL},
1252 /*SSC 0x9b*/{NULL},
1253 /*SSC 0x9c*/{NULL},
1254 /*SSC 0x9d*/{NULL},
1255 /*SSC 0x9e*/{NULL},
1256 /*SSC 0x9f*/{NULL},
1257 /*SPC 0xa0*/{dissect_spc_reportluns},
1258 /*SSC 0xa1*/{NULL},
1259 /*SSC 0xa2*/{NULL},
1260 /*SSC 0xa3*/{NULL},
1261 /*SSC 0xa4*/{NULL},
1262 /*SSC 0xa5*/{dissect_smc_movemedium},
1263 /*SSC 0xa6*/{NULL},
1264 /*SSC 0xa7*/{dissect_smc_movemedium},
1265 /*SSC 0xa8*/{NULL},
1266 /*SSC 0xa9*/{NULL},
1267 /*SSC 0xaa*/{NULL},
1268 /*SSC 0xab*/{NULL},
1269 /*SSC 0xac*/{NULL},
1270 /*SSC 0xad*/{NULL},
1271 /*SSC 0xae*/{NULL},
1272 /*SSC 0xaf*/{NULL},
1273 /*SSC 0xb0*/{NULL},
1274 /*SSC 0xb1*/{NULL},
1275 /*SSC 0xb2*/{NULL},
1276 /*SSC 0xb3*/{NULL},
1277 /*SSC 0xb4*/{dissect_smc_readelementstatus},
1278 /*SSC 0xb5*/{NULL},
1279 /*SSC 0xb6*/{NULL},
1280 /*SSC 0xb7*/{NULL},
1281 /*SSC 0xb8*/{dissect_smc_readelementstatus},
1282 /*SSC 0xb9*/{NULL},
1283 /*SSC 0xba*/{NULL},
1284 /*SSC 0xbb*/{NULL},
1285 /*SSC 0xbc*/{NULL},
1286 /*SSC 0xbd*/{NULL},
1287 /*SSC 0xbe*/{NULL},
1288 /*SSC 0xbf*/{NULL},
1289 /*SSC 0xc0*/{NULL},
1290 /*SSC 0xc1*/{NULL},
1291 /*SSC 0xc2*/{NULL},
1292 /*SSC 0xc3*/{NULL},
1293 /*SSC 0xc4*/{NULL},
1294 /*SSC 0xc5*/{NULL},
1295 /*SSC 0xc6*/{NULL},
1296 /*SSC 0xc7*/{NULL},
1297 /*SSC 0xc8*/{NULL},
1298 /*SSC 0xc9*/{NULL},
1299 /*SSC 0xca*/{NULL},
1300 /*SSC 0xcb*/{NULL},
1301 /*SSC 0xcc*/{NULL},
1302 /*SSC 0xcd*/{NULL},
1303 /*SSC 0xce*/{NULL},
1304 /*SSC 0xcf*/{NULL},
1305 /*SSC 0xd0*/{NULL},
1306 /*SSC 0xd1*/{NULL},
1307 /*SSC 0xd2*/{NULL},
1308 /*SSC 0xd3*/{NULL},
1309 /*SSC 0xd4*/{NULL},
1310 /*SSC 0xd5*/{NULL},
1311 /*SSC 0xd6*/{NULL},
1312 /*SSC 0xd7*/{NULL},
1313 /*SSC 0xd8*/{NULL},
1314 /*SSC 0xd9*/{NULL},
1315 /*SSC 0xda*/{NULL},
1316 /*SSC 0xdb*/{NULL},
1317 /*SSC 0xdc*/{NULL},
1318 /*SSC 0xdd*/{NULL},
1319 /*SSC 0xde*/{NULL},
1320 /*SSC 0xdf*/{NULL},
1321 /*SSC 0xe0*/{NULL},
1322 /*SSC 0xe1*/{NULL},
1323 /*SSC 0xe2*/{NULL},
1324 /*SSC 0xe3*/{NULL},
1325 /*SSC 0xe4*/{NULL},
1326 /*SSC 0xe5*/{NULL},
1327 /*SSC 0xe6*/{NULL},
1328 /*SSC 0xe7*/{NULL},
1329 /*SSC 0xe8*/{NULL},
1330 /*SSC 0xe9*/{NULL},
1331 /*SSC 0xea*/{NULL},
1332 /*SSC 0xeb*/{NULL},
1333 /*SSC 0xec*/{NULL},
1334 /*SSC 0xed*/{NULL},
1335 /*SSC 0xee*/{NULL},
1336 /*SSC 0xef*/{NULL},
1337 /*SSC 0xf0*/{NULL},
1338 /*SSC 0xf1*/{NULL},
1339 /*SSC 0xf2*/{NULL},
1340 /*SSC 0xf3*/{NULL},
1341 /*SSC 0xf4*/{NULL},
1342 /*SSC 0xf5*/{NULL},
1343 /*SSC 0xf6*/{NULL},
1344 /*SSC 0xf7*/{NULL},
1345 /*SSC 0xf8*/{NULL},
1346 /*SSC 0xf9*/{NULL},
1347 /*SSC 0xfa*/{NULL},
1348 /*SSC 0xfb*/{NULL},
1349 /*SSC 0xfc*/{NULL},
1350 /*SSC 0xfd*/{NULL},
1351 /*SSC 0xfe*/{NULL},
1352 /*SSC 0xff*/{NULL}
1353 };
1354
1355
1356
1357 void
1358 proto_register_scsi_ssc(void)
1359 {
1360         static hf_register_info hf[] = {
1361         { &hf_scsi_ssc_opcode,
1362           {"SSC Opcode", "scsi.ssc.opcode", FT_UINT8, BASE_HEX,
1363            VALS (scsi_ssc_vals), 0x0, "", HFILL}},
1364         { &hf_scsi_ssc_rdwr6_xferlen,
1365           {"Transfer Length", "scsi.ssc.rdwr6.xferlen", FT_UINT24, BASE_DEC, NULL, 0x0,
1366            "", HFILL}},
1367         { &hf_scsi_ssc_ver16_verlen,
1368           {"Verification Length", "scsi.ssc.verify16.verify_len", FT_UINT24, BASE_DEC, NULL, 0x0,
1369            "", HFILL}},
1370         { &hf_scsi_ssc_locate10_loid,
1371           {"Logical Object Identifier", "scsi.ssc.locate10.loid", FT_UINT32, BASE_DEC, NULL, 0x0,
1372            "", HFILL}},
1373         { &hf_scsi_ssc_locate16_loid,
1374           {"Logical Identifier", "scsi.ssc.locate16.loid", FT_UINT64, BASE_DEC, NULL, 0x0,
1375            "", HFILL}},
1376         { &hf_scsi_ssc_space6_count,
1377           {"Count", "scsi.ssc.space6.count", FT_INT24, BASE_DEC, NULL, 0x0,
1378            "", HFILL}},
1379         { &hf_scsi_ssc_space6_code,
1380           {"Code", "scsi.ssc.space6.code", FT_UINT8, BASE_HEX,
1381           VALS(space6_code_vals), 0x0f,
1382            "", HFILL}},
1383         { &hf_scsi_ssc_space16_count,
1384           {"Count", "scsi.ssc.space16.count", FT_UINT64, BASE_DEC, NULL, 0x0,
1385            "", HFILL}},
1386         { &hf_scsi_ssc_rdwr10_xferlen,
1387           {"Transfer Length", "scsi.ssc.rdwr10.xferlen", FT_UINT16, BASE_DEC, NULL,
1388            0x0, "", HFILL}},
1389         { &hf_scsi_ssc_erase_flags,
1390           {"Flags", "scsi.ssc.erase_flags", FT_UINT8, BASE_HEX,
1391            NULL, 0x0, "", HFILL}},
1392         { &hf_scsi_ssc_fcs,
1393           {"FCS", "scsi.ssc.fcs", FT_BOOLEAN, 8,
1394            NULL, 0x08, "", HFILL}},
1395         { &hf_scsi_ssc_lcs,
1396           {"LCS", "scsi.ssc.lcs", FT_BOOLEAN, 8,
1397            NULL, 0x04, "", HFILL}},
1398         { &hf_scsi_ssc_erase_immed,
1399           {"IMMED", "scsi.ssc.erase_immed", FT_BOOLEAN, 8,
1400            NULL, 0x02, "", HFILL}},
1401         { &hf_scsi_ssc_long,
1402           {"LONG", "scsi.ssc.long", FT_BOOLEAN, 8,
1403            NULL, 0x01, "", HFILL}},
1404         { &hf_scsi_ssc_partition,
1405           {"Partition", "scsi.ssc.partition", FT_UINT8, BASE_HEX,
1406            NULL, 0x0, "", HFILL}},
1407         { &hf_scsi_ssc_lbi,
1408           {"Logical Block Identifier", "scsi.ssc.lbi", FT_UINT64, BASE_HEX,
1409            NULL, 0x0, "", HFILL}},
1410         { &hf_scsi_ssc_verify,
1411           {"VERIFY", "scsi.ssc.verify", FT_BOOLEAN, 8,
1412            NULL, 0x02, "", HFILL}},
1413         { &hf_scsi_ssc_immed,
1414           {"IMMED", "scsi.ssc.immed", FT_BOOLEAN, 8,
1415            NULL, 0x01, "", HFILL}},
1416         { &hf_scsi_ssc_formatmedium_flags,
1417           {"Flags", "scsi.ssc.formatmedium_flags", FT_UINT8, BASE_HEX,
1418            NULL, 0x0, "", HFILL}},
1419         { &hf_scsi_ssc_format,
1420           {"Format", "scsi.ssc.format", FT_UINT8, BASE_HEX,
1421            VALS(format_vals), 0x0f, "", HFILL}},
1422         { &hf_scsi_ssc_loadunload_immed_flags,
1423           {"Immed", "scsi.ssc.loadunload_immed_flags", FT_UINT8, BASE_HEX,
1424            NULL, 0x0, "", HFILL}},
1425         { &hf_scsi_ssc_loadunload_flags,
1426           {"Flags", "scsi.ssc.loadunload_flags", FT_UINT8, BASE_HEX,
1427            NULL, 0x0, "", HFILL}},
1428         { &hf_scsi_ssc_hold,
1429           {"HOLD", "scsi.ssc.hold", FT_BOOLEAN, 8,
1430            NULL, 0x08, "", HFILL}},
1431         { &hf_scsi_ssc_eot,
1432           {"EOT", "scsi.ssc.eot", FT_BOOLEAN, 8,
1433            NULL, 0x04, "", HFILL}},
1434         { &hf_scsi_ssc_reten,
1435           {"RETEN", "scsi.ssc.reten", FT_BOOLEAN, 8,
1436            NULL, 0x02, "", HFILL}},
1437         { &hf_scsi_ssc_load,
1438           {"LOAD", "scsi.ssc.load", FT_BOOLEAN, 8,
1439            NULL, 0x01, "", HFILL}},
1440         { &hf_scsi_ssc_locate_flags,
1441           {"Flags", "scsi.ssc.locate_flags", FT_UINT8, BASE_HEX,
1442            NULL, 0x0, "", HFILL}},
1443         { &hf_scsi_ssc_bt,
1444           {"BT", "scsi.ssc.bt", FT_BOOLEAN, 8,
1445            NULL, 0x04, "", HFILL}},
1446         { &hf_scsi_ssc_cp,
1447           {"CP", "scsi.ssc.cp", FT_BOOLEAN, 8,
1448            NULL, 0x02, "", HFILL}},
1449         { &hf_scsi_ssc_dest_type,
1450           {"Dest Type", "scsi.ssc.dest_type", FT_UINT8, BASE_HEX,
1451            VALS(dest_type_vals), 0x18, "", HFILL}},
1452         { &hf_scsi_ssc_bam_flags,
1453           {"Flags", "scsi.ssc.bam_flags", FT_UINT8, BASE_HEX,
1454            NULL, 0x0, "", HFILL}},
1455         { &hf_scsi_ssc_bam,
1456           {"BAM", "scsi.ssc.bam", FT_BOOLEAN, 8,
1457            NULL, 0x01, "", HFILL}},
1458         { &hf_scsi_ssc_read6_flags,
1459           {"Flags", "scsi.ssc.read6_flags", FT_UINT8, BASE_HEX,
1460            NULL, 0x0, "", HFILL}},
1461         { &hf_scsi_ssc_sili,
1462           {"SILI", "scsi.ssc.sili", FT_BOOLEAN, 8,
1463            NULL, 0x02, "", HFILL}},
1464         { &hf_scsi_ssc_fixed,
1465           {"FIXED", "scsi.ssc.fixed", FT_BOOLEAN, 8,
1466            NULL, 0x01, "", HFILL}},
1467         { &hf_scsi_ssc_bytord,
1468           {"BYTORD", "scsi.ssc.bytord", FT_BOOLEAN, 8,
1469            NULL, 0x04, "", HFILL}},
1470         { &hf_scsi_ssc_bytcmp,
1471           {"BYTCMP", "scsi.ssc.bytcmp", FT_BOOLEAN, 8,
1472            NULL, 0x02, "", HFILL}},
1473         { &hf_scsi_ssc_verify16_immed,
1474           {"IMMED", "scsi.ssc.verify16_immed", FT_BOOLEAN, 8,
1475            NULL, 0x04, "", HFILL}},
1476         { &hf_scsi_ssc_medium_type,
1477           {"Medium Type", "scsi.ssc.medium_type", FT_BOOLEAN, 8,
1478            NULL, 0x02, "", HFILL}},
1479         { &hf_scsi_ssc_media,
1480           {"Media", "scsi.ssc.media", FT_BOOLEAN, 8,
1481            NULL, 0x01, "", HFILL}},
1482         { &hf_scsi_ssc_capacity_prop_value,
1483           {"Capacity Proportion Value", "scsi.ssc.cpv", FT_UINT16, BASE_DEC,
1484            NULL, 0, "", HFILL}},
1485         };
1486
1487
1488         /* Setup protocol subtree array */
1489         static gint *ett[] = {
1490                 &ett_scsi_erase,
1491                 &ett_scsi_formatmedium,
1492                 &ett_scsi_loadunload_immed,
1493                 &ett_scsi_loadunload,
1494                 &ett_scsi_locate,
1495                 &ett_scsi_bam,
1496                 &ett_scsi_read6
1497         };
1498
1499
1500         /* Register the protocol name and description */
1501         proto_scsi_ssc = proto_register_protocol("SCSI_SSC", "SCSI_SSC", "scsi_ssc");
1502
1503         /* Required function calls to register the header fields and subtrees used */
1504         proto_register_field_array(proto_scsi_ssc, hf, array_length(hf));
1505
1506         proto_register_subtree_array(ett, array_length(ett));
1507
1508 }
1509
1510 void
1511 proto_reg_handoff_scsi_ssc(void)
1512 {
1513 }
1514