summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-scsi-osd.c
blob: 489343164062327e7c88ae810e0647d2ff6e6131 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
/* packet-scsi-osd.c
 * Dissector for the SCSI OSD (object based storage) commandset
 *
 * Ronnie sahlberg 2006
 * Joe Breher 2006
 * Javier Godoy 2013 (OSD-2 dissector)
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 2002 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include "config.h"

#include <epan/packet.h>
#include <epan/conversation.h>
#include <epan/expert.h>
#include "packet-scsi.h"
#include "packet-scsi-osd.h"

void proto_register_scsi_osd(void);

static int proto_scsi_osd                               = -1;
int hf_scsi_osd_opcode                                  = -1;
static int hf_scsi_osd_add_cdblen                       = -1;
static int hf_scsi_osd_svcaction                        = -1;
static int hf_scsi_osd_option                           = -1;
static int hf_scsi_osd_option_dpo                       = -1;
static int hf_scsi_osd_option_fua                       = -1;
static int hf_scsi_osd_getsetattrib                     = -1;
static int hf_scsi_osd_timestamps_control               = -1;
static int hf_scsi_osd_formatted_capacity               = -1;
static int hf_scsi_osd_get_attributes_page              = -1;
static int hf_scsi_osd_get_attributes_allocation_length = -1;
static int hf_scsi_osd_get_attributes_list_length       = -1;
static int hf_scsi_osd_get_attributes_list_offset       = -1;
static int hf_scsi_osd_retrieved_attributes_offset      = -1;
static int hf_scsi_osd_set_attributes_page              = -1;
static int hf_scsi_osd_set_attribute_length             = -1;
static int hf_scsi_osd_set_attribute_number             = -1;
static int hf_scsi_osd_set_attributes_offset            = -1;
static int hf_scsi_osd_set_attributes_list_length       = -1;
static int hf_scsi_osd_set_attributes_list_offset       = -1;
static int hf_scsi_osd_capability_format                = -1;
static int hf_scsi_osd_key_version                      = -1;
static int hf_scsi_osd_icva                             = -1;
static int hf_scsi_osd_security_method                  = -1;
static int hf_scsi_osd_capability_expiration_time       = -1;
static int hf_scsi_osd_audit                            = -1;
static int hf_scsi_osd_capability_discriminator         = -1;
static int hf_scsi_osd_object_created_time              = -1;
static int hf_scsi_osd_object_type                      = -1;
static int hf_scsi_osd_permissions                      = -1;
static int hf_scsi_osd_permissions_read                 = -1;
static int hf_scsi_osd_permissions_write                = -1;
static int hf_scsi_osd_permissions_get_attr             = -1;
static int hf_scsi_osd_permissions_set_attr             = -1;
static int hf_scsi_osd_permissions_create               = -1;
static int hf_scsi_osd_permissions_remove               = -1;
static int hf_scsi_osd_permissions_obj_mgmt             = -1;
static int hf_scsi_osd_permissions_append               = -1;
static int hf_scsi_osd_permissions_dev_mgmt             = -1;
static int hf_scsi_osd_permissions_global               = -1;
static int hf_scsi_osd_permissions_pol_sec              = -1;
static int hf_scsi_osd_object_descriptor_type           = -1;
static int hf_scsi_osd_object_descriptor                = -1;
static int hf_scsi_osd_ricv                             = -1;
static int hf_scsi_osd_request_nonce                    = -1;
static int hf_scsi_osd_diicvo                           = -1;
static int hf_scsi_osd_doicvo                           = -1;
static int hf_scsi_osd_requested_partition_id           = -1;
static int hf_scsi_osd_sortorder                        = -1;
static int hf_scsi_osd_partition_id                     = -1;
static int hf_scsi_osd_list_identifier                  = -1;
static int hf_scsi_osd_allocation_length                = -1;
static int hf_scsi_osd_length                           = -1;
static int hf_scsi_osd_starting_byte_address            = -1;
static int hf_scsi_osd_initial_object_id                = -1;
static int hf_scsi_osd_additional_length                = -1;
static int hf_scsi_osd_continuation_object_id           = -1;
static int hf_scsi_osd_list_flags_lstchg                = -1;
static int hf_scsi_osd_list_flags_root                  = -1;
static int hf_scsi_osd_list_collection_flags_coltn      = -1;
static int hf_scsi_osd_user_object_id                   = -1;
static int hf_scsi_osd_requested_user_object_id         = -1;
static int hf_scsi_osd_number_of_user_objects           = -1;
static int hf_scsi_osd_key_to_set                       = -1;
static int hf_scsi_osd_set_key_version                  = -1;
static int hf_scsi_osd_key_identifier                   = -1;
static int hf_scsi_osd_seed                             = -1;
static int hf_scsi_osd_collection_fcr                   = -1;
static int hf_scsi_osd_collection_object_id             = -1;
static int hf_scsi_osd_requested_collection_object_id   = -1;
static int hf_scsi_osd_partition_created_in             = -1;
static int hf_scsi_osd_partition_removed_in             = -1;
static int hf_scsi_osd_flush_scope                      = -1;
static int hf_scsi_osd_flush_collection_scope           = -1;
static int hf_scsi_osd_flush_partition_scope            = -1;
static int hf_scsi_osd_flush_osd_scope                  = -1;
static int hf_scsi_osd_attributes_list_type             = -1;
static int hf_scsi_osd_attributes_list_length           = -1;
static int hf_scsi_osd_attributes_page                  = -1;
static int hf_scsi_osd_attribute_number                 = -1;
static int hf_scsi_osd_attribute_length                 = -1;
static int hf_scsi_osd_attrval_user_object_logical_length = -1;
static int hf_scsi_osd_attrval_object_type              = -1;
static int hf_scsi_osd_attrval_partition_id             = -1;
static int hf_scsi_osd_attrval_object_id                = -1;
static int hf_scsi_osd2_query_type = -1;
static int hf_scsi_osd2_query_entry_length = -1;
static int hf_scsi_osd2_query_attributes_page = -1;
static int hf_scsi_osd2_query_attribute_number = -1;
static int hf_scsi_osd2_query_minimum_attribute_value_length = -1;
static int hf_scsi_osd2_query_maximum_attribute_value_length = -1;

/* Fields that are defined in OSD-2 are prefixed with hf_scsi_osd2_ */
static int hf_scsi_osd2_attributes_list_length      = -1;
static int hf_scsi_osd2_set_attribute_value         = -1;
static int hf_scsi_osd2_isolation                   = -1;
static int hf_scsi_osd2_immed_tr                    = -1;
static int hf_scsi_osd2_list_attr                   = -1;
static int hf_scsi_osd2_object_descriptor_format    = -1;
static int hf_scsi_osd2_matches_collection_object_id = -1;
static int hf_scsi_osd2_source_collection_object_id = -1;
static int hf_scsi_osd2_cdb_continuation_length     = -1;
static int hf_scsi_osd2_cdb_continuation_format     = -1;
static int hf_scsi_osd2_continued_service_action    = -1;
static int hf_scsi_osd2_cdb_continuation_descriptor_type = -1;
static int hf_scsi_osd2_cdb_continuation_descriptor_pad_length = -1;
static int hf_scsi_osd2_cdb_continuation_descriptor_length = -1;
static int hf_scsi_osd2_remove_scope                       = -1;

static gint ett_osd_option                  = -1;
static gint ett_osd_partition               = -1;
static gint ett_osd_attribute_parameters    = -1;
static gint ett_osd_capability              = -1;
static gint ett_osd_permission_bitmask      = -1;
static gint ett_osd_security_parameters     = -1;
static gint ett_osd_get_attributes          = -1;
static gint ett_osd_set_attributes          = -1;
static gint ett_osd_multi_object            = -1;
static gint ett_osd_attribute               = -1;
static gint ett_osd2_query_criteria_entry   = -1;

static expert_field ei_osd_attr_unknown = EI_INIT;
static expert_field ei_osd2_invalid_offset = EI_INIT;
static expert_field ei_osd2_invalid_object_descriptor_format = EI_INIT;
static expert_field ei_osd_unknown_attributes_list_type = EI_INIT;
static expert_field ei_osd2_cdb_continuation_format_unknown = EI_INIT;
static expert_field ei_osd2_continued_service_action_mismatch = EI_INIT;
static expert_field ei_osd2_cdb_continuation_descriptor_type_unknown = EI_INIT;
static expert_field ei_osd2_cdb_continuation_descriptor_length_invalid = EI_INIT;
static expert_field ei_osd2_cdb_continuation_length_invalid = EI_INIT;
static expert_field ei_osd_attr_length_invalid = EI_INIT;
static expert_field ei_osd2_query_values_equal= EI_INIT;

#define PAGE_NUMBER_OBJECT          0x00000000
#define PAGE_NUMBER_PARTITION       0x30000000
#define PAGE_NUMBER_COLLECTION      0x60000000
#define PAGE_NUMBER_ROOT            0x90000000


/* There will be one such structure create for each conversation ontop of which
 * there is an OSD session
 */
typedef struct _scsi_osd_conv_info_t {
    wmem_tree_t *luns;
} scsi_osd_conv_info_t;

/* there will be one such structure created for each lun for each conversation
 * that is handled by the OSD dissector
 */
struct _scsi_osd_lun_info_t {
    wmem_tree_t *partitions;
};

typedef void (*scsi_osd_dissector_t)(tvbuff_t *tvb, packet_info *pinfo,
        proto_tree *tree, guint offset,
        gboolean isreq, gboolean iscdb,
         guint32 payload_len, scsi_task_data_t *cdata,
        scsi_osd_conv_info_t *conv_info,
        scsi_osd_lun_info_t *lun_info
        );

/* One such structure is created per conversation/lun/partition to
 * keep track of when partitions are created/used/destroyed
 */
typedef struct _partition_info_t {
    int created_in;
    int removed_in;
} partition_info_t;


/* This is a set of extra data specific to OSD that we need to attach to every
 * task.
 */
typedef struct _scsi_osd_extra_data_t {
    guint16 svcaction;
    guint8  gsatype;
    union {
        struct {    /* gsatype: attribute list */
            guint32 get_list_length;
            guint32 get_list_offset;
            guint32 get_list_allocation_length;
            guint32 retrieved_list_offset;
            guint32 set_list_length;
            guint32 set_list_offset;
        } al;
    } u;
    guint32 continuation_length;
    gboolean osd2;
} scsi_osd_extra_data_t;

static proto_item*
dissect_osd_user_object_id(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    /* user object id */
    proto_item *item;
    item = proto_tree_add_item(tree, hf_scsi_osd_user_object_id, tvb, offset, 8, ENC_NA);
    return item;
}


/*dissects an attribute that is defined as a pair of hf_index, length*/
static void
generic_attribute_dissector(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
                            scsi_osd_lun_info_t *lun_info _U_, const attribute_page_numbers_t *att)
{
    proto_tree_add_item(tree, *att->hf_index, tvb, 0, att->expected_length, ENC_BIG_ENDIAN);
}

static proto_item *
dissect_osd_partition_id(packet_info *pinfo, tvbuff_t *tvb, int offset,
                         proto_tree *tree, int hf_index,
                         scsi_osd_lun_info_t *lun_info, gboolean is_created,
                         gboolean is_removed);

static void
partition_id_attribute_dissector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
                                 scsi_osd_lun_info_t *lun_info, const attribute_page_numbers_t *att)
{
    dissect_osd_partition_id(pinfo, tvb, 0, tree, *att->hf_index, lun_info, FALSE, FALSE);
}

static const attribute_page_numbers_t user_object_info_attributes[] = {
    {0x82, "User object logical length", generic_attribute_dissector, &hf_scsi_osd_attrval_user_object_logical_length, 8},
    {0, NULL, NULL, NULL, 0}
};

static const attribute_page_numbers_t current_command_attributes[] = {
    {0x02, "Object Type",                            generic_attribute_dissector,      &hf_scsi_osd_attrval_object_type, 1},
    {0x03, "Partition ID",                           partition_id_attribute_dissector, &hf_scsi_osd_attrval_partition_id, 8},
    {0x04, "Collection Object ID or User Object ID", generic_attribute_dissector,      &hf_scsi_osd_attrval_object_id, 8},
    {0, NULL, NULL, NULL, 0}
};

typedef struct _attribute_pages_t {
    guint32 page;
    const attribute_page_numbers_t *attributes;
} attribute_pages_t;

static const attribute_pages_t attribute_pages[] = {
    {PAGE_NUMBER_OBJECT+1, user_object_info_attributes},
    {0xFFFFFFFE,           current_command_attributes},
    {0, NULL}
};

static const value_string attributes_page_vals[] = {
    {PAGE_NUMBER_OBJECT+0,     "User Object Directory"},
    {PAGE_NUMBER_OBJECT+1,     "User Object Information"},
    {PAGE_NUMBER_OBJECT+2,     "User Object Quotas"},
    {PAGE_NUMBER_OBJECT+3,     "User Object Timestamps"},
    {PAGE_NUMBER_OBJECT+4,     "User Object Collections"},
    {PAGE_NUMBER_OBJECT+5,     "User Object Policy/Security"},
    {PAGE_NUMBER_PARTITION,    "Partition Directory"},
    {PAGE_NUMBER_PARTITION+1,  "Partition Information"},
    {PAGE_NUMBER_PARTITION+2,  "Partition Quotas"},
    {PAGE_NUMBER_PARTITION+3,  "Partition Timestamps"},
    {PAGE_NUMBER_PARTITION+5,  "Partition Policy/Security"},
    {PAGE_NUMBER_COLLECTION,   "Collection Directory"},
    {PAGE_NUMBER_COLLECTION+1, "Collection Information"},
    {PAGE_NUMBER_COLLECTION+2, "Collection Quotas"},
    {PAGE_NUMBER_COLLECTION+4, "Collection Command Tracking"},
    {PAGE_NUMBER_COLLECTION+5, "Collection Policy/Security"},
    {PAGE_NUMBER_ROOT,         "Root Directory"},
    {PAGE_NUMBER_ROOT+1,       "Root Information"},
    {PAGE_NUMBER_ROOT+2,       "Root Quotas"},
    {PAGE_NUMBER_ROOT+3,       "Root Timestamps"},
    {PAGE_NUMBER_ROOT+5,       "Root Policy/Security"},
    {0xFFFFFFFE,               "Current Command"},
    {0xFFFFFFFF,               "All attribute pages"},
    {0, NULL}
};
value_string_ext attributes_page_vals_ext = VALUE_STRING_EXT_INIT(attributes_page_vals);

static const value_string attributes_list_type_vals[] = {
    {0x01, "Retrieve attributes for this OSD object"},
    {0x09, "Retrieve/Set attributes for this OSD object"},
    {0x0f, "Retrieve attributes for a CREATE command"},
    {0, NULL}
};

static const value_string scsi_osd2_isolation_val[] = {
    {0x00, "Default"},
    {0x01, "None"},
    {0x02, "Strict"},
    {0x04, "Range"},
    {0x05, "Functional"},
    {0x07, "Vendor specific"},
    {0, NULL}
};

static const value_string scsi_osd2_object_descriptor_format_val[] = {
    {0x01, "Partition ID"},
    {0x02, "Partition ID followed by attribute parameters"},
    {0x11, "Collection ID"},
    {0x12, "Collection ID followed by attribute parameters"},
    {0x21, "User Object ID"},
    {0x22, "User Object ID followed by attribute parameters"},
    {0, NULL}
};

static const value_string scsi_osd2_remove_scope[] = {
    {0x00, "Fail if there are collections or user objects in the partition"},
    {0x01, "Remove collections and user objects in the partition"},
    {0, NULL}
};

static const value_string scsi_osd2_cdb_continuation_format_val[] = {
    {0x01, "OSD2"},
    {0, NULL}
};

static const value_string  scsi_osd2_cdb_continuation_descriptor_type_val[] = {
    {0x0000, "No more continuation descriptors"},
    {0x0001, "Scatter/gather list"},
    {0x0002, "Query list"},
    {0x0100, "User object"},
    {0x0101, "Copy user object source"},
    {0xFFEE, "Extension capabilities"},
    {0, NULL}
};

static const value_string scsi_osd2_query_type_vals[] = {
    {0x00, "Match any query criteria"},
    {0x01, "Match all query criteria"},
    {0, NULL}
};

/* OSD2/3 helper functions */

static void
dissect_osd2_isolation(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    /* isolation */
    proto_tree_add_item(tree, hf_scsi_osd2_isolation, tvb, offset, 1, ENC_BIG_ENDIAN);
}

static void
dissect_osd2_list_attr(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    /* list_attr */
    proto_tree_add_item(tree, hf_scsi_osd2_list_attr, tvb, offset, 1, ENC_BIG_ENDIAN);
}


/* used by dissect_osd_attributes_list, dissect_osd2_attribute_list_entry
and dissect_scsi_descriptor_snsinfo from packet-scsi.c*/
const attribute_page_numbers_t *
osd_lookup_attribute(guint32 page, guint32 number)
{
    const attribute_pages_t        *ap;
    const attribute_page_numbers_t *apn;

    /* find the proper attributes page */
    apn = NULL;
    for (ap=attribute_pages;ap->attributes;ap++) {
        if (ap->page == page) {
            apn = ap->attributes;
            break;
        }
    }
    if (!apn) return NULL;

    /* find the specific attribute */
    for (;apn->name;apn++) {
        if (apn->number == number) {
            break;
        }
    }
    if (!apn->name) return NULL;

    /* found it */
    return apn;
}

/* OSD-1: 7.1.3.3, OSD2 7.1.4.3 list entry format */
static guint32
dissect_osd_attribute_list_entry(packet_info *pinfo, tvbuff_t *tvb,
                                 proto_tree *tree, proto_item *item,
                                 guint32 offset, scsi_osd_lun_info_t *lun_info,
                                 gboolean osd2)
{
    guint16 attribute_length;
    guint32 page, number;
    const attribute_page_numbers_t *apn;

    /* attributes page */
    page = tvb_get_ntohl(tvb, offset);
    proto_tree_add_item(tree, hf_scsi_osd_attributes_page, tvb, offset, 4, ENC_BIG_ENDIAN);
    offset += 4;

    /* attribute number */
    number = tvb_get_ntohl(tvb, offset);
    proto_tree_add_item(tree, hf_scsi_osd_attribute_number, tvb, offset, 4, ENC_BIG_ENDIAN);
    offset += 4;

    if (osd2) {
        /*6 reserved bytes*/
        offset += 6;
    }

    /* attribute length */
    attribute_length = tvb_get_ntohs(tvb, offset);
    proto_tree_add_item(tree, hf_scsi_osd_attribute_length, tvb, offset, 2, ENC_BIG_ENDIAN);
    offset += 2;

    proto_item_append_text(item, " 0x%08x (%s)", page,  val_to_str_ext_const(page, &attributes_page_vals_ext, "Unknown"));
    proto_item_append_text(item, " 0x%08x", number);
    apn= osd_lookup_attribute(page, number);

    if (!apn) {
        expert_add_info(pinfo, item, &ei_osd_attr_unknown);
        proto_item_append_text(item, " (Unknown)");
    } else {
        proto_item_append_text(item, " (%s)", apn->name);

        /* attribute value */
        if (attribute_length) {
            if (attribute_length != apn->expected_length) {
                proto_tree_add_expert_format(tree, pinfo, &ei_osd_attr_length_invalid,
                                             tvb, 0, attribute_length, "%s", apn->name);
            } else {
                tvbuff_t *next_tvb = tvb_new_subset_length(tvb, offset, attribute_length);
                apn->dissector(next_tvb, pinfo, tree, lun_info, apn);
            }
        }
    }

    offset += attribute_length;
    if (osd2 && (attribute_length&7)) {
        /* 8-bit padding */
        offset += 8-(attribute_length&7);
    }

    return offset;
}

/* OSD1: 7.1.3.1
   OSD2: 7.1.4.1*/
static void
dissect_osd_attributes_list(packet_info *pinfo, tvbuff_t *tvb, int offset,
                            proto_tree *tree, scsi_osd_lun_info_t *lun_info,
                            gboolean osd2)
{
    guint8      type;
    guint32     length;
    guint32     page, number;
    int         start_offset = offset;
    proto_item *item, *list_type_item;
    const attribute_page_numbers_t *apn;

    /* list type */
    type = tvb_get_guint8(tvb, offset)&0x0f;
    list_type_item = proto_tree_add_item(tree, hf_scsi_osd_attributes_list_type, tvb, offset, 1, ENC_BIG_ENDIAN);
    offset += 1;

    /* OSD-1: a reserved byte */
    /* OSD-2: 3 reserved bytes */
    offset += (osd2?3:1);

    /* OSD-1: length (16 bit)
       OSD-2: length (32 bit) */
    if (osd2) {
        length = tvb_get_ntohl(tvb, offset);
        proto_tree_add_item(tree, hf_scsi_osd2_attributes_list_length, tvb, offset, 4, ENC_BIG_ENDIAN);
        offset += 4;
    } else {
        length = tvb_get_ntohs(tvb, offset);
        proto_tree_add_item(tree, hf_scsi_osd_attributes_list_length, tvb, offset, 2, ENC_BIG_ENDIAN);
        offset += 2;
    }

    /* if type is 1 length will be zero and we have to cycle over
     * all remaining bytes.   7.1.3.1
     */
    if (!osd2 && type == 1) {
        length = tvb_reported_length_remaining(tvb, offset);
    }

    length += (osd2?8:4);

    while ( (guint32)(offset-start_offset)<length ) {
        proto_item *ti;
        proto_tree *tt;
        guint32     attribute_entry_length;

        switch (type) {
            case 0x01:
                attribute_entry_length = 8;
                break;
            case 0x0f:
                attribute_entry_length = 18+tvb_get_ntohs(tvb, offset+16);
                break;
            case 0x09:
                if (osd2) {
                    attribute_entry_length = 16+tvb_get_ntohs(tvb, offset+14);
                } else {
                    attribute_entry_length = 10+tvb_get_ntohs(tvb, offset+8);
                }
                break;
            default:
                expert_add_info(pinfo, list_type_item, &ei_osd_unknown_attributes_list_type);
                return;
        }

        if ((guint32)(offset-start_offset)+attribute_entry_length>length) break;
        tt = proto_tree_add_subtree(tree, tvb, offset, attribute_entry_length, ett_osd_attribute, &ti, "Attribute:");

        switch (type) {
        case 0x01: /* retrieving attributes 7.1.3.2 */
            /* attributes page */
            page = tvb_get_ntohl(tvb, offset);
            proto_tree_add_item(tt, hf_scsi_osd_attributes_page, tvb, offset, 4, ENC_BIG_ENDIAN);
            offset += 4;

            /* attribute number */
            number = tvb_get_ntohl(tvb, offset);
            item = proto_tree_add_item(tt, hf_scsi_osd_attribute_number, tvb, offset, 4, ENC_BIG_ENDIAN);
            offset += 4;

            proto_item_append_text(ti, " 0x%08x (%s)", page,  val_to_str_ext_const(page, &attributes_page_vals_ext, "Unknown"));
            proto_item_append_text(ti, " 0x%08x", number);

            /* find the proper attributes page */
            apn = osd_lookup_attribute(page, number);
            if (!apn) {
                proto_item_append_text(ti, " (Unknown)");
                proto_item_append_text(item, " (Unknown)");
            } else {
                proto_item_append_text(ti, " (%s)", apn->name);
                proto_item_append_text(item, " (%s)", apn->name);
            }
            break;
        case 0x0f: /* create attributes 7.1.3.4 */
            /* user object id */
            dissect_osd_user_object_id(tvb, offset, tt);
            offset += 8;
            /* fallthrough */
        case 0x09: /* retrieved/set attributes OSD-1: 7.1.3.3  OSD-2: 7.1.4.3*/
            offset = dissect_osd_attribute_list_entry(pinfo, tvb, tt, ti, offset, lun_info, osd2);
            break;
        }
    }
}


/* OSD2 5.2.4 */
static void
dissect_osd_option(tvbuff_t *tvb, int offset, proto_tree *parent_tree)
{
    proto_tree *tree;
    proto_item *it;
    guint8      option;

    option = tvb_get_guint8(tvb, offset);

    it = proto_tree_add_item(parent_tree, hf_scsi_osd_option, tvb, offset, 1, ENC_BIG_ENDIAN);
    tree = proto_item_add_subtree(it, ett_osd_option);

    proto_tree_add_item(tree, hf_scsi_osd_option_dpo, tvb, offset, 1, ENC_BIG_ENDIAN);
    if (option&0x10) {
        proto_item_append_text(tree, " DPO");
    }

    proto_tree_add_item(tree, hf_scsi_osd_option_fua, tvb, offset, 1, ENC_BIG_ENDIAN);
    if (option&0x08) {
        proto_item_append_text(tree, " FUA");
    }
}


static const value_string scsi_osd_getsetattrib_vals[] = {
    {1, "Set one attribute using CDB fields (OSD-2)"},
    {2, "Get an attributes page and set an attribute value"},
    {3, "Get and set attributes using a list"},
    {0, NULL},
};

/* OSD2 5.2.2.1 */
static void
dissect_osd_getsetattrib(tvbuff_t *tvb, int offset, proto_tree *tree, scsi_task_data_t *cdata)
{
    if (cdata && cdata->itlq && cdata->itlq->extra_data) {
        scsi_osd_extra_data_t *extra_data = (scsi_osd_extra_data_t *)cdata->itlq->extra_data;
        extra_data->gsatype = (tvb_get_guint8(tvb, offset)>>4)&0x03;
    }
    proto_tree_add_item(tree, hf_scsi_osd_getsetattrib, tvb, offset, 1, ENC_BIG_ENDIAN);
}

static const value_string scsi_osd_timestamps_control_vals[] = {
    {0x00, "Timestamps shall be updated"},
    {0x7f, "Timestamps shall not be updated"},
    {0, NULL},
};

/* OSD2 5.2.8 */
static void
dissect_osd_timestamps_control(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    proto_tree_add_item(tree, hf_scsi_osd_timestamps_control, tvb, offset, 1, ENC_BIG_ENDIAN);
}


static void
dissect_osd_formatted_capacity(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    proto_tree_add_item(tree, hf_scsi_osd_formatted_capacity, tvb, offset, 8, ENC_BIG_ENDIAN);
}

static void
dissect_osd_offset(packet_info *pinfo, tvbuff_t *tvb, int offset,
                   proto_tree *tree, int field, guint32 *raw_value_ptr,
                   gboolean osd2)
{
    /* dissects an OSD offset value, add proto item and updates *raw_value_ptr */
    guint32 value = *raw_value_ptr;

    if (value != 0xFFFFFFFF) {
        if (!osd2) {
            /*OSD-1: the exponent is an unsigned value (4.12.5)*/
            value = (value & 0x0fffffff) << ((value>>28) & 0x0f);
            value <<= 8;
        } else {
            /*OSD-2: the exponent is a signed value (4.15.5)*/
            int  exponent = (value>>28);
            guint32 mantissa = (value&0x0FFFFFFF);

            if (exponent&0x8) {
                exponent = -(((~exponent)&7)+1);
                if (exponent <=- 6 && mantissa != 0xFFFFFFF) {
                    proto_item *item;
                    item = proto_tree_add_uint(tree, field, tvb, offset, 4, value);
                    expert_add_info(pinfo, item, &ei_osd2_invalid_offset);
                    *raw_value_ptr = 0xFFFFFFFF;
                    return;
                }
            }
            value = mantissa << (exponent+8);
        }
    }
    proto_tree_add_uint(tree, field, tvb, offset, 4, value);
    *raw_value_ptr = value;
}

static int
dissect_osd_attribute_parameters(packet_info *pinfo, tvbuff_t *tvb, int offset, proto_tree *parent_tree, scsi_task_data_t *cdata)
{
    guint8      gsatype = 0;
    proto_tree *tree;
    scsi_osd_extra_data_t *extra_data = NULL;
    gboolean osd2;

    tree = proto_tree_add_subtree(parent_tree, tvb, offset, 28,
        ett_osd_attribute_parameters, NULL, "Attribute Parameters");

    if (cdata && cdata->itlq && cdata->itlq->extra_data) {
        extra_data = (scsi_osd_extra_data_t *)cdata->itlq->extra_data;
        gsatype = extra_data->gsatype;
        osd2 = extra_data->osd2;
    } else {
        return offset;
    }

    switch (gsatype) {
    case 1: /* OSD-2 5.2.6.2 Set one attribute using CDB fields*/
    if (osd2) {
        proto_tree_add_item(tree, hf_scsi_osd_set_attributes_page, tvb, offset, 4, ENC_BIG_ENDIAN);
        offset += 4;
        proto_tree_add_item(tree, hf_scsi_osd_set_attribute_number, tvb, offset, 4, ENC_BIG_ENDIAN);
        offset += 4;
        proto_tree_add_item(tree, hf_scsi_osd_set_attribute_length, tvb, offset, 4, ENC_BIG_ENDIAN);
        offset += 4;
        proto_tree_add_item(tree, hf_scsi_osd2_set_attribute_value, tvb, offset, 18, ENC_NA);
        offset += 18;
    }
    break;
    case 2: /* 5.2.2.2  attribute page */
        proto_tree_add_item(tree, hf_scsi_osd_get_attributes_page, tvb, offset, 4, ENC_BIG_ENDIAN);
        offset += 4;
        proto_tree_add_item(tree, hf_scsi_osd_get_attributes_allocation_length, tvb, offset, 4, ENC_BIG_ENDIAN);
        offset += 4;
        proto_tree_add_item(tree, hf_scsi_osd_retrieved_attributes_offset, tvb, offset, 4, ENC_BIG_ENDIAN);
        offset += 4;
        proto_tree_add_item(tree, hf_scsi_osd_set_attributes_page, tvb, offset, 4, ENC_BIG_ENDIAN);
        offset += 4;
        proto_tree_add_item(tree, hf_scsi_osd_set_attribute_number, tvb, offset, 4, ENC_BIG_ENDIAN);
        offset += 4;
        proto_tree_add_item(tree, hf_scsi_osd_set_attribute_length, tvb, offset, 4, ENC_BIG_ENDIAN);
        offset += 4;
        proto_tree_add_item(tree, hf_scsi_osd_set_attributes_offset, tvb, offset, 4, ENC_BIG_ENDIAN);
        offset += 4;
        break;
    case 3: /* 5.2.2.3  attribute list */
        proto_tree_add_item(tree, hf_scsi_osd_get_attributes_list_length, tvb, offset, 4, ENC_BIG_ENDIAN);
        extra_data->u.al.get_list_length = tvb_get_ntohl(tvb, offset);
        offset += 4;

        /* 4.12.5 */
        extra_data->u.al.get_list_offset = tvb_get_ntohl(tvb, offset);
        dissect_osd_offset(pinfo, tvb, offset, tree, hf_scsi_osd_get_attributes_list_offset,
                           &extra_data->u.al.get_list_offset, osd2);
        if (extra_data->u.al.get_list_offset == 0xFFFFFFFF) {
            extra_data->u.al.get_list_length = 0;
        }
        offset += 4;

        proto_tree_add_item(tree, hf_scsi_osd_get_attributes_allocation_length, tvb, offset, 4, ENC_BIG_ENDIAN);
        extra_data->u.al.get_list_allocation_length = tvb_get_ntohl(tvb, offset);
        offset += 4;

        /* 4.12.5 */
        extra_data->u.al.retrieved_list_offset = tvb_get_ntohl(tvb, offset);
        dissect_osd_offset(pinfo, tvb, offset, tree, hf_scsi_osd_retrieved_attributes_offset,
                           &extra_data->u.al.retrieved_list_offset, osd2);
        if (extra_data->u.al.retrieved_list_offset == 0xFFFFFFFF) {
            extra_data->u.al.get_list_allocation_length = 0;
        }
        offset += 4;

        proto_tree_add_item(tree, hf_scsi_osd_set_attributes_list_length, tvb, offset, 4, ENC_BIG_ENDIAN);
        extra_data->u.al.set_list_length = tvb_get_ntohl(tvb, offset);
        offset += 4;

        extra_data->u.al.set_list_offset = tvb_get_ntohl(tvb, offset);
        dissect_osd_offset(pinfo, tvb, offset, tree, hf_scsi_osd_set_attributes_list_offset,
                           &extra_data->u.al.set_list_offset, osd2);
        if (extra_data->u.al.set_list_offset == 0xFFFFFFFF) {
            extra_data->u.al.set_list_length = 0;
        }
        offset += 4;

        /* 4 reserved bytes */
        offset += 4;

        break;
    }
    return offset;
}


static void
dissect_osd_attribute_data_out(packet_info *pinfo, tvbuff_t *tvb, int offset _U_,
                               proto_tree *tree, scsi_task_data_t *cdata,
                               scsi_osd_lun_info_t *lun_info)
{
    guint8      gsatype = 0;
    proto_tree *subtree;
    scsi_osd_extra_data_t *extra_data = NULL;

    if (cdata && cdata->itlq && cdata->itlq->extra_data) {
        extra_data = (scsi_osd_extra_data_t *)cdata->itlq->extra_data;
        gsatype = extra_data->gsatype;
    } else {
        return;
    }

    switch (gsatype) {
    case 2: /* 5.2.2.2  attribute page */
/*qqq*/
        break;
    case 3: /* 5.2.2.3  attribute list */
        if (extra_data->u.al.get_list_length) {
            subtree = proto_tree_add_subtree(tree, tvb, extra_data->u.al.get_list_offset, extra_data->u.al.get_list_length,
                                                ett_osd_get_attributes, NULL, "Get Attributes Segment");
            dissect_osd_attributes_list(pinfo, tvb, extra_data->u.al.get_list_offset, subtree, lun_info, extra_data->osd2);
        }
        if (extra_data->u.al.set_list_length) {
            subtree = proto_tree_add_subtree(tree, tvb, extra_data->u.al.set_list_offset, extra_data->u.al.set_list_length,
                                                ett_osd_get_attributes, NULL, "Set Attributes Segment");
            dissect_osd_attributes_list(pinfo, tvb, extra_data->u.al.set_list_offset, subtree, lun_info, extra_data->osd2);
        }
        break;
    }
}


static void
dissect_osd_attribute_data_in(packet_info *pinfo, tvbuff_t *tvb, int offset _U_, proto_tree *tree, scsi_task_data_t *cdata, scsi_osd_lun_info_t *lun_info)
{
    guint8 gsatype = 0;
    scsi_osd_extra_data_t *extra_data = NULL;

    if (cdata && cdata->itlq && cdata->itlq->extra_data) {
        extra_data = (scsi_osd_extra_data_t *)cdata->itlq->extra_data;
        gsatype = extra_data->gsatype;
    } else {
        return;
    }

    switch (gsatype) {
    case 2: /* 5.2.2.2  attribute page */
/*qqq*/
        break;
    case 3: /* 5.2.2.3  attribute list */
        if (extra_data->u.al.get_list_allocation_length) {
            dissect_osd_attributes_list(pinfo, tvb, extra_data->u.al.retrieved_list_offset, tree, lun_info, extra_data->osd2);
        }
        break;
    }
}

static void
dissect_osd2_cdb_continuation_length(packet_info *pinfo, tvbuff_t *tvb,
                                     guint32 offset, proto_tree *tree,
                                     scsi_task_data_t *cdata)
{
    scsi_osd_extra_data_t *extra_data;
    guint32     continuation_length;
    proto_item *item;

    continuation_length = tvb_get_ntohl(tvb, offset);
    item = proto_tree_add_item(tree, hf_scsi_osd2_cdb_continuation_length, tvb, offset, 4, ENC_BIG_ENDIAN);
    if (cdata && cdata->itlq && cdata->itlq->extra_data) {
        extra_data = (scsi_osd_extra_data_t *)cdata->itlq->extra_data;
        extra_data->continuation_length = continuation_length;
    }
    if (continuation_length>0 && continuation_length<40) {
        expert_add_info(pinfo, item, &ei_osd2_cdb_continuation_length_invalid);
    }
}

static void dissect_osd2_query_list_descriptor(packet_info *pinfo, tvbuff_t *tvb, guint32 offset, proto_tree *tree, guint32 length) {
    guint32 end = offset+length;

    /* query type */
    proto_tree_add_item(tree, hf_scsi_osd2_query_type, tvb, offset, 1, ENC_BIG_ENDIAN);
    offset += 1;

    /* 3 reserved bytes */
    offset += 3;

    /*query criteria entry*/
    while (offset<end) {
        guint32     page, number;
        guint32     min_value_length, max_value_length;
        guint32     min_value_offset, max_value_offset;
        proto_item *item;
        const attribute_page_numbers_t *apn;

        /* 2 reserved bytes */
        offset += 2;

        /* query entry length */
        proto_tree_add_item(tree, hf_scsi_osd2_query_entry_length, tvb, offset, 2, ENC_BIG_ENDIAN);
        offset += 2;

        /* query attributes page */
        page = tvb_get_ntohl(tvb, offset);
        proto_tree_add_item(tree, hf_scsi_osd2_query_attributes_page, tvb, offset, 4, ENC_BIG_ENDIAN);
        offset += 4;

        /* query attributes number */
        number = tvb_get_ntohl(tvb, offset);
        item = proto_tree_add_item(tree, hf_scsi_osd2_query_attribute_number, tvb, offset, 4, ENC_BIG_ENDIAN);
        offset += 4;

        apn = osd_lookup_attribute(page, number);

        if (!apn) {
            expert_add_info(pinfo, item, &ei_osd_attr_unknown);
            proto_item_append_text(item, " (Unknown)");
        } else {
            proto_item_append_text(item, " (%s)", apn->name);
        }

        /* query minimum attribute value length */
        proto_tree_add_item(tree, hf_scsi_osd2_query_minimum_attribute_value_length, tvb, offset, 2, ENC_BIG_ENDIAN);
        min_value_length = tvb_get_ntohs(tvb, offset);
        offset += 2;

        /* query minimum attribute value */
        /* if (apn && min_value_length) {
            call_apn_dissector(tvb, pinfo, tree, lun_info, apn, offset, min_value_length);
        } */
        max_value_offset = offset;
        offset += min_value_length;

        /* query maximum attribute value length */
        item = proto_tree_add_item(tree, hf_scsi_osd2_query_maximum_attribute_value_length, tvb, offset, 2, ENC_BIG_ENDIAN);
        max_value_length = tvb_get_ntohs(tvb, offset);
        offset += 2;

        /* xxx query maximum attribute value */
        /* if (apn && max_value_length) {
            call_apn_dissector(tvb, pinfo, tree, lun_info, apn, offset, max_value_length);
        } */
        min_value_offset = offset;
        offset += max_value_length;

        /* test if min and max values are equal */
        if (max_value_length == min_value_length) {
            unsigned int i;
            for (i=0; i<max_value_length; i++) {
                if (tvb_get_guint8(tvb, max_value_offset+i) != tvb_get_guint8(tvb, min_value_offset+i)) return;
            }
            expert_add_info(pinfo, item, &ei_osd2_query_values_equal);
        }
    }
}

static void
dissect_osd2_cdb_continuation(packet_info *pinfo, tvbuff_t *tvb, guint32 offset,
                              proto_tree *tree, scsi_task_data_t *cdata)
{
    scsi_osd_extra_data_t *extra_data = NULL;
    proto_item            *item;
    guint8                 format;
    guint16                sa;
    if (cdata && cdata->itlq && cdata->itlq->extra_data) {
        extra_data = (scsi_osd_extra_data_t *)cdata->itlq->extra_data;
    }
    if (!extra_data || extra_data->continuation_length<40) return;

    /* cdb continuation format */
    item = proto_tree_add_item(tree, hf_scsi_osd2_cdb_continuation_format, tvb, offset, 1, ENC_BIG_ENDIAN);
    format = tvb_get_guint8(tvb, offset);
    if (format != 0x01) {
        expert_add_info(pinfo, item, &ei_osd2_cdb_continuation_format_unknown);
        return;
    }
    offset += 1;

    /* 1 reserved byte */
    offset += 1;

    /* continued service action */
    item = proto_tree_add_item(tree, hf_scsi_osd2_continued_service_action, tvb, offset, 2, ENC_BIG_ENDIAN);
    sa = tvb_get_ntohs(tvb, offset);
    if (sa != extra_data->svcaction) {
        expert_add_info(pinfo, item, &ei_osd2_continued_service_action_mismatch);
    }
    offset += 2;

    /*4 reserved bytes and continuation integrity check value (32 bytes, not dissected)*/
    offset += 36;


    /* CDB continuation descriptors */
    while (offset<extra_data->continuation_length) {
        guint16 type;
        guint32 length, padlen;
        proto_item *item_type, *item_length;

        /* descriptor type */
        item_type= proto_tree_add_item(tree, hf_scsi_osd2_cdb_continuation_descriptor_type, tvb, offset, 2, ENC_BIG_ENDIAN);
        type = tvb_get_ntohs(tvb, offset);
        offset += 2;

        /* 1 reserved byte*/
        offset += 1;

        /* descriptor pad length */
        proto_tree_add_item(tree, hf_scsi_osd2_cdb_continuation_descriptor_pad_length, tvb, offset, 1, ENC_BIG_ENDIAN);
        padlen = tvb_get_guint8(tvb, offset)&7;
        offset += 1;

        /* descriptor length */
        item_length = proto_tree_add_item(tree, hf_scsi_osd2_cdb_continuation_descriptor_length, tvb, offset, 4, ENC_BIG_ENDIAN);
        length = tvb_get_ntohl(tvb, offset);
        offset += 4;

        switch (type) {
            case 0x0000: break;
            case 0x0001: break;
            case 0x0002: dissect_osd2_query_list_descriptor(pinfo, tvb, offset, tree, length);
            case 0x0100: break;
            case 0x0101: break;
            case 0xFFEE: break;
            default: expert_add_info(pinfo, item_type, &ei_osd2_cdb_continuation_descriptor_type_unknown);
        }

        if ((length+padlen)%8) {
            expert_add_info(pinfo, item_length, &ei_osd2_cdb_continuation_descriptor_length_invalid);
            return;
        }
        /* check for overflow */
        if (offset + length + padlen > offset) {
            offset += length+padlen;
        }
    }

}


static const value_string scsi_osd_capability_format_vals[] = {
    {0x00, "No Capability"},
    {0x01, "SCSI OSD Capabilities"},
    {0, NULL},
};
static const value_string scsi_osd_object_type_vals[] = {
    {0x01, "ROOT"},
    {0x02, "PARTITION"},
    {0x40, "COLLECTION"},
    {0x80, "USER"},
    {0, NULL},
};
static const value_string scsi_osd_object_descriptor_type_vals[] = {
    {0, "NONE: the object descriptor field shall be ignored"},
    {1, "U/C: a single collection or user object"},
    {2, "PAR: a single partition, including partition zero"},
    {0, NULL},
};


/* OSD 4.9.2.2.1 */
static void
dissect_osd_permissions(tvbuff_t *tvb, int offset, proto_tree *parent_tree)
{
    proto_tree *tree = NULL;
    proto_item *it   = NULL;
    guint16     permissions;

    permissions = tvb_get_ntohs(tvb, offset);

    if (parent_tree) {
        it = proto_tree_add_item(parent_tree, hf_scsi_osd_permissions, tvb, offset, 2, ENC_BIG_ENDIAN);
        tree = proto_item_add_subtree(it, ett_osd_permission_bitmask);
    }

    proto_tree_add_item(tree, hf_scsi_osd_permissions_read, tvb, offset, 2, ENC_BIG_ENDIAN);
    if (permissions&0x8000) {
        proto_item_append_text(tree, " READ");
    }
    proto_tree_add_item(tree, hf_scsi_osd_permissions_write, tvb, offset, 2, ENC_BIG_ENDIAN);
    if (permissions&0x4000) {
        proto_item_append_text(tree, " WRITE");
    }
    proto_tree_add_item(tree, hf_scsi_osd_permissions_get_attr, tvb, offset, 2, ENC_BIG_ENDIAN);
    if (permissions&0x2000) {
        proto_item_append_text(tree, " GET_ATTR");
    }
    proto_tree_add_item(tree, hf_scsi_osd_permissions_set_attr, tvb, offset, 2, ENC_BIG_ENDIAN);
    if (permissions&0x1000) {
        proto_item_append_text(tree, " SET_ATTR");
    }
    proto_tree_add_item(tree, hf_scsi_osd_permissions_create, tvb, offset, 2, ENC_BIG_ENDIAN);
    if (permissions&0x0800) {
        proto_item_append_text(tree, " CREATE");
    }
    proto_tree_add_item(tree, hf_scsi_osd_permissions_remove, tvb, offset, 2, ENC_BIG_ENDIAN);
    if (permissions&0x0400) {
        proto_item_append_text(tree, " REMOVE");
    }
    proto_tree_add_item(tree, hf_scsi_osd_permissions_obj_mgmt, tvb, offset, 2, ENC_BIG_ENDIAN);
    if (permissions&0x0200) {
        proto_item_append_text(tree, " OBJ_MGMT");
    }
    proto_tree_add_item(tree, hf_scsi_osd_permissions_append, tvb, offset, 2, ENC_BIG_ENDIAN);
    if (permissions&0x0100) {
        proto_item_append_text(tree, " APPEND");
    }
    proto_tree_add_item(tree, hf_scsi_osd_permissions_dev_mgmt, tvb, offset, 2, ENC_BIG_ENDIAN);
    if (permissions&0x0080) {
        proto_item_append_text(tree, " DEV_MGMT");
    }
    proto_tree_add_item(tree, hf_scsi_osd_permissions_global, tvb, offset, 2, ENC_BIG_ENDIAN);
    if (permissions&0x0040) {
        proto_item_append_text(tree, " GLOBAL");
    }
    proto_tree_add_item(tree, hf_scsi_osd_permissions_pol_sec, tvb, offset, 2, ENC_BIG_ENDIAN);
    if (permissions&0x0020) {
        proto_item_append_text(tree, " POL/SEC");
    }
}

/* OSD-1 4.9.2.2
   OSD-2 4.11.2.2 */
static void
dissect_osd_capability(tvbuff_t *tvb, int offset, proto_tree *parent_tree)
{
    proto_tree *tree;
    guint8 format;

    tree = proto_tree_add_subtree(parent_tree, tvb, offset, 80,
            ett_osd_capability, NULL, "Capability");

    /* capability format */
    proto_tree_add_item(tree, hf_scsi_osd_capability_format, tvb, offset, 1, ENC_BIG_ENDIAN);
    format = tvb_get_guint8(tvb, offset)&0x0F;
    offset += 1;

    if (format != 1) return;

    /* key version and icva */
    proto_tree_add_item(tree, hf_scsi_osd_key_version, tvb, offset, 1, ENC_BIG_ENDIAN);
    proto_tree_add_item(tree, hf_scsi_osd_icva, tvb, offset, 1, ENC_BIG_ENDIAN);
    offset += 1;

    /* security method */
    proto_tree_add_item(tree, hf_scsi_osd_security_method, tvb, offset, 1, ENC_BIG_ENDIAN);
    offset += 1;

    /* a reserved byte */
    offset += 1;

    /* capability expiration time */
    proto_tree_add_item(tree, hf_scsi_osd_capability_expiration_time, tvb, offset, 6, ENC_NA);
    offset += 6;

    /* audit */
    proto_tree_add_item(tree, hf_scsi_osd_audit, tvb, offset, 20, ENC_NA);
    offset += 20;

    /* capability discriminator */
    proto_tree_add_item(tree, hf_scsi_osd_capability_discriminator, tvb, offset, 12, ENC_NA);
    offset += 12;

    /* object created time */
    proto_tree_add_item(tree, hf_scsi_osd_object_created_time, tvb, offset, 6, ENC_NA);
    offset += 6;

    /* object type */
    proto_tree_add_item(tree, hf_scsi_osd_object_type, tvb, offset, 1, ENC_BIG_ENDIAN);
    offset += 1;

    /* permission bitmask */
    dissect_osd_permissions(tvb, offset, tree);
    offset += 5;

    /* a reserved byte */
    offset += 1;

    /* object descriptor type */
    proto_tree_add_item(tree, hf_scsi_osd_object_descriptor_type, tvb, offset, 1, ENC_BIG_ENDIAN);
    offset += 1;

    /* object descriptor */
    proto_tree_add_item(tree, hf_scsi_osd_object_descriptor, tvb, offset, 24, ENC_NA);
    /*offset += 24;*/

    return;
}



/* 5.2.6 */
static int
dissect_osd_security_parameters(tvbuff_t *tvb, int offset, proto_tree *parent_tree)
{
    proto_tree *tree;

    tree = proto_tree_add_subtree(parent_tree, tvb, offset, 40,
        ett_osd_security_parameters, NULL, "Security Parameters");

    /* request integrity check value */
    proto_tree_add_item(tree, hf_scsi_osd_ricv, tvb, offset, 20, ENC_NA);
    offset += 20;

    /* request nonce */
    proto_tree_add_item(tree, hf_scsi_osd_request_nonce, tvb, offset, 12, ENC_NA);
    offset += 12;

    /* data in integrity check value offset */
    proto_tree_add_item(tree, hf_scsi_osd_diicvo, tvb, offset, 4, ENC_BIG_ENDIAN);
    offset += 4;

    /* data out integrity check value offset */
    proto_tree_add_item(tree, hf_scsi_osd_doicvo, tvb, offset, 4, ENC_BIG_ENDIAN);
    offset += 4;

    return offset;
}

static void
dissect_osd_format_osd(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_,
                       scsi_osd_conv_info_t *conv_info _U_,
                       scsi_osd_lun_info_t *lun_info _U_)
{
    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {
        /* options byte */
        dissect_osd_option(tvb, offset, tree);
        offset += 1;

        /* getset attributes byte */
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 23 reserved bytes */
        offset += 23;

        /* formatted capacity */
        dissect_osd_formatted_capacity(tvb, offset, tree);
        offset += 8;

        /* 8 reserved bytes */
        offset += 8;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += 80;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += 40;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data out for format osd */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data in for format osd */
    }

}


static proto_item*
dissect_osd_partition_id(packet_info *pinfo, tvbuff_t *tvb, int offset,
                         proto_tree *tree, int hf_index,
                         scsi_osd_lun_info_t *lun_info, gboolean is_created,
                         gboolean is_removed)
{
    proto_item *item = NULL;
    guint32     partition_id[2];

    /* partition id */
    item = proto_tree_add_item(tree, hf_index, tvb, offset, 8, ENC_BIG_ENDIAN);
    partition_id[0] = tvb_get_ntohl(tvb, offset);
    partition_id[1] = tvb_get_ntohl(tvb, offset+4);
    if (!partition_id[0] && !partition_id[1]) {
        proto_item_append_text(item, " (ROOT partition)");
    } else {
        partition_info_t *part_info;
        wmem_tree_key_t pikey[2];
        proto_tree *partition_tree = NULL;

        pikey[0].length = 2;
        pikey[0].key = partition_id;
        pikey[1].length = 0;
        part_info = (partition_info_t *)wmem_tree_lookup32_array(lun_info->partitions, &pikey[0]);
        if (!part_info) {
            part_info = wmem_new(wmem_file_scope(), partition_info_t);
            part_info->created_in = 0;
            part_info->removed_in = 0;

            pikey[0].length = 2;
            pikey[0].key = partition_id;
            pikey[1].length = 0;
            wmem_tree_insert32_array(lun_info->partitions, &pikey[0], part_info);
        }
        if (is_created) {
            part_info->created_in = pinfo->num;
        }
        if (is_removed) {
            part_info->removed_in = pinfo->num;
        }
        if (item) {
            partition_tree = proto_item_add_subtree(item, ett_osd_partition);
        }
        if (part_info->created_in) {
            proto_item *tmp_item;
            tmp_item = proto_tree_add_uint(partition_tree, hf_scsi_osd_partition_created_in, tvb, 0, 0, part_info->created_in);
            proto_item_set_generated(tmp_item);
        }
        if (part_info->removed_in) {
            proto_item *tmp_item;
            tmp_item = proto_tree_add_uint(partition_tree, hf_scsi_osd_partition_removed_in, tvb, 0, 0, part_info->removed_in);
            proto_item_set_generated(tmp_item);
        }
    }

    return item;
}



static void
dissect_osd_create_partition(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_,
                             scsi_osd_conv_info_t *conv_info _U_,
                             scsi_osd_lun_info_t *lun_info)
{
    gboolean osd2 = ((scsi_osd_extra_data_t *)cdata->itlq->extra_data)->svcaction&0x80;
    ((scsi_osd_extra_data_t *)cdata->itlq->extra_data)->osd2 = osd2;

    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {
        /* options byte */
        if (osd2) dissect_osd2_isolation(tvb, offset, tree);
        dissect_osd_option(tvb, offset, tree);
        offset += 1;

        /* getset attributes byte */
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 3 reserved bytes */
        offset += 3;

        /* requested partiton id */
        dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_requested_partition_id, lun_info, TRUE, FALSE);
        offset += 8;

        /* 24 reserved bytes */
        offset += 24;

        if (osd2) {
            dissect_osd2_cdb_continuation_length(pinfo, tvb, offset, tree, cdata);
        } else {
            /* 4 reserved bytes */
        }
        offset += 4;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += osd2?104:80;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += osd2?52:40;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* CDB continuation */
        dissect_osd2_cdb_continuation(pinfo, tvb, offset, tree, cdata);

        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data out for create partition */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data in for create partition */
    }

}

static const value_string scsi_osd_sort_order_vals[] = {
    {0x00, "Ascending numeric value"},
    {0, NULL},
};
static int
dissect_osd_sortorder(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    /* sort order */
    proto_tree_add_item(tree, hf_scsi_osd_sortorder, tvb, offset, 1, ENC_BIG_ENDIAN);
    offset += 1;

    return offset;
}

static int
dissect_osd_list_identifier(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    /* list identifier */
    proto_tree_add_item(tree, hf_scsi_osd_list_identifier, tvb, offset, 4, ENC_BIG_ENDIAN);
    offset += 4;

    return offset;
}

static void
dissect_osd_allocation_length(tvbuff_t *tvb, int offset, proto_tree *tree, scsi_task_data_t *cdata)
{
    /* allocation length */
    proto_tree_add_item(tree, hf_scsi_osd_allocation_length, tvb, offset, 8, ENC_BIG_ENDIAN);

    if (cdata) {
        guint64 alloc_len = tvb_get_ntoh64(tvb, offset);
        if (alloc_len>G_GINT64_CONSTANT(0xFFFFFFFF)) {
            alloc_len = G_GINT64_CONSTANT(0xFFFFFFFF);
        }
        cdata->itlq->alloc_len = (guint32)alloc_len;
    }
}

static int
dissect_osd_initial_object_id(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    /* initial object id */
    proto_tree_add_item(tree, hf_scsi_osd_initial_object_id, tvb, offset, 8, ENC_NA);
    offset += 8;

    return offset;
}

static int
dissect_osd_additional_length(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    /* additional length */
    proto_tree_add_item(tree, hf_scsi_osd_additional_length, tvb, offset, 8, ENC_BIG_ENDIAN);
    offset += 8;

    return offset;
}


static int
dissect_osd_continuation_object_id(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    /* continuation object id */
    proto_tree_add_item(tree, hf_scsi_osd_continuation_object_id, tvb, offset, 8, ENC_NA);
    offset += 8;

    return offset;
}

static const true_false_string list_lstchg_tfs = {
    "List has CHANGED since the first List command",
    "List has NOT changed since first command"
};
static const true_false_string list_root_tfs = {
    "Objects are from root and are PARTITION IDs",
    "Objects are from the partition and are USER OBJECTs"
};
static const true_false_string list_coltn_tfs = {
    "Objects are from the partition and are COLLECTION IDs",
    "Objects are from the collection and are USER OBJECTs"
};

static proto_item*
dissect_osd_collection_object_id(tvbuff_t *tvb, int offset, proto_tree *tree, const int hfindex)
{
    /* collection object id */
    proto_item *item;
    item = proto_tree_add_item(tree, hfindex, tvb, offset, 8, ENC_NA);
    return item;
}

static void
dissect_osd_list(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_,
                 scsi_osd_conv_info_t *conv_info _U_,
                 scsi_osd_lun_info_t *lun_info)
{
    guint    svcaction       = ((scsi_osd_extra_data_t *)cdata->itlq->extra_data)->svcaction;
    gboolean list_collection = (svcaction == 0x8817) || (svcaction == 0x8897);
    gboolean osd2            = svcaction&0x80;
    ((scsi_osd_extra_data_t *)cdata->itlq->extra_data)->osd2 = osd2;

    /* dissecting the CDB   dissection starts at byte 10 of the CDB */

    if (isreq && iscdb) {
        /*byte 10*/
        if (osd2) dissect_osd2_isolation(tvb, offset, tree);
        offset += 1;

        /* getset attributes byte / sort order */
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        if (!list_collection) dissect_osd_sortorder(tvb, offset, tree);
        if (osd2) dissect_osd2_list_attr(tvb, offset, tree);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 3 reserved bytes */
        offset += 3;

        /* partiton id */
        dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_partition_id, lun_info, FALSE, FALSE);
        offset += 8;

        if (list_collection) {
            /* collection id */
             dissect_osd_collection_object_id(tvb, offset, tree, hf_scsi_osd_collection_object_id);
        } else {
           /* 8 reserved bytes */
        }
        offset += 8;

        if (osd2) {
            /* allocation length */
            dissect_osd_allocation_length(tvb, offset, tree, cdata);
            offset += 8;

            /* initial object id */
            dissect_osd_initial_object_id(tvb, offset, tree);
            offset += 8;

            /* list identifier */
            dissect_osd_list_identifier(tvb, offset, tree);
            offset += 4;
        } else {
            /* list identifier */
            dissect_osd_list_identifier(tvb, offset, tree);
            offset += 4;

            /* allocation length */
            dissect_osd_allocation_length(tvb, offset, tree, cdata);
            offset += 8;

            /* initial object id */
            dissect_osd_initial_object_id(tvb, offset, tree);
            offset += 8;
        }


        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += osd2?104:80;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += osd2?52:40;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data out for LIST or LIST COLLECTION */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {

        guint64  additional_length;
        guint64  allocation_length;
        guint64  remaining_length;
        gboolean is_root_or_coltn;
        guint8   format = 0;

        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        allocation_length = cdata->itlq->alloc_len;
        remaining_length = tvb_captured_length_remaining(tvb, offset);
        if (remaining_length<allocation_length) allocation_length = remaining_length;
        if (allocation_length<24) return;

        /* dissection of the LIST or LIST COLLECTION DATA-IN */
        /* additional length */
        additional_length = tvb_get_ntoh64(tvb, offset);
        if (allocation_length<additional_length) additional_length = allocation_length;

        dissect_osd_additional_length(tvb, offset, tree);

        offset += 8;
        /* continuation object id */
        dissect_osd_continuation_object_id(tvb, offset, tree);
        offset += 8;
        /* list identifier */
        dissect_osd_list_identifier(tvb, offset, tree);
        offset += 4;
        /* 3 reserved bytes */
        offset += 3;

        /* OSD:  LSTCHG and ROOT flags
           OSD2: LSTCHG and OBJECT DESCRIPTOR FORMAT*/
        proto_tree_add_item(tree, hf_scsi_osd_list_flags_lstchg, tvb, offset, 1, ENC_BIG_ENDIAN);
        if (osd2) {
            proto_item *item;
            item = proto_tree_add_item(tree, hf_scsi_osd2_object_descriptor_format, tvb, offset, 1, ENC_BIG_ENDIAN);
            format = tvb_get_guint8(tvb, offset)>>2;
            if (format == 0x01 || format == 0x02) {
                is_root_or_coltn = TRUE;
                if (list_collection) format = 0;
            } else if (format == 0x11 || format == 0x12) {
                is_root_or_coltn = TRUE;
                if (!list_collection) format = 0;
            } else if (format == 0x21 || format == 0x22) {
                is_root_or_coltn = FALSE;
            } else format = 0;
            if (!format) {
                expert_add_info(pinfo, item, &ei_osd2_invalid_object_descriptor_format);
                return;
            }
        } else {
            if (list_collection) {
                proto_tree_add_item(tree, hf_scsi_osd_list_collection_flags_coltn, tvb, offset, 1, ENC_BIG_ENDIAN);
            } else {
                proto_tree_add_item(tree, hf_scsi_osd_list_flags_root, tvb, offset, 1, ENC_BIG_ENDIAN);
            }
            is_root_or_coltn = tvb_get_guint8(tvb, offset)&0x01;
        }

        offset += 1;

        while (additional_length > (offset-8)) {
            proto_item *ti;
            /* list of 8-byte IDs; the type of ID is given by is_root_or_coltn and list_collection*/
            if (is_root_or_coltn) {
                if (list_collection) {
                    ti = dissect_osd_collection_object_id(tvb, offset, tree, hf_scsi_osd_collection_object_id);
                } else {
                    ti = dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_partition_id, lun_info, FALSE, FALSE);
                }
            } else {
                ti = dissect_osd_user_object_id(tvb, offset, tree);
            }
            offset += 8;

            /* for OSD-2 if format is 0x02, 0x12 or 0x22: sub-list of attributes*/
            if (osd2 && (format&0x02)) {
                guint32 attr_list_end;
                proto_tree *subtree;

                if (offset+8>additional_length) break;
                subtree = proto_item_add_subtree(ti, ett_osd_multi_object);

                /*object type*/
                proto_tree_add_item(subtree, hf_scsi_osd_object_type, tvb, offset, 1, ENC_BIG_ENDIAN);
                offset += 1;
                /* 5 reserved bytes */
                offset += 5;
                /* attribute list length*/
                attr_list_end = offset+2+tvb_get_ntohs(tvb, offset);
                offset += 2;
                if (attr_list_end>additional_length+8) break;
                while (offset+16<attr_list_end) {
                    guint32 attribute_length = tvb_get_ntohs(tvb, offset+14);
                    proto_item *att_item;
                    proto_tree *att_tree = proto_tree_add_subtree(subtree, tvb, offset, 16+attribute_length, ett_osd_attribute, &att_item, "Attribute:");
                    offset = dissect_osd_attribute_list_entry(pinfo, tvb, att_tree, att_item, offset, lun_info, TRUE);
                }
                offset = attr_list_end;
            }

        }
    }

}

static int
dissect_osd_requested_user_object_id(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    /* request user object id */
    proto_tree_add_item(tree, hf_scsi_osd_requested_user_object_id, tvb, offset, 8, ENC_NA);
    offset += 8;

    return offset;
}

static int
dissect_osd_number_of_user_objects(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    /* number_of_user_objects */
    proto_tree_add_item(tree, hf_scsi_osd_number_of_user_objects, tvb, offset, 2, ENC_BIG_ENDIAN);
    offset += 2;

    return offset;
}

static void
dissect_osd_create(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_,
                   scsi_osd_conv_info_t *conv_info _U_,
                   scsi_osd_lun_info_t *lun_info)
{
    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {
        /* options byte */
        dissect_osd_option(tvb, offset, tree);
        offset += 1;

        /* getset attributes byte */
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 3 reserved bytes */
        offset += 3;

        /* partiton id */
        dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_partition_id, lun_info, FALSE, FALSE);
        offset += 8;

        /* requested user_object id */
        dissect_osd_requested_user_object_id(tvb, offset, tree);
        offset += 8;

        /* 4 reserved bytes */
        offset += 4;

        /* number of user objects */
        dissect_osd_number_of_user_objects(tvb, offset, tree);
        offset += 2;

        /* 14 reserved bytes */
        offset += 14;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += 80;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += 40;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data out for create */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data in for create */
    }

}


static void
dissect_osd_remove_partition(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_,
                             scsi_osd_conv_info_t *conv_info _U_,
                             scsi_osd_lun_info_t *lun_info)
{
    gboolean osd2 = ((scsi_osd_extra_data_t *)cdata->itlq->extra_data)->svcaction&0x80;
    ((scsi_osd_extra_data_t *)cdata->itlq->extra_data)->osd2 = osd2;

    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {
        /* options byte */
        if (osd2) dissect_osd2_isolation(tvb, offset, tree);
        dissect_osd_option(tvb, offset, tree);
        offset += 1;

        /* getset attributes byte */
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        if (osd2) proto_tree_add_item(tree, hf_scsi_osd2_remove_scope, tvb, offset, 1, ENC_BIG_ENDIAN);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 3 reserved bytes */
        offset += 3;

        /* partiton id */
        dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_partition_id, lun_info, FALSE, TRUE);
        offset += 8;

        /* 24 reserved bytes */
        offset += 24;

        if (osd2) {
            dissect_osd2_cdb_continuation_length(pinfo, tvb, offset, tree, cdata);
        } else {
            /* 4 reserved bytes */
        }
        offset += 4;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += osd2?104:80;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += osd2?52:40;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* CDB continuation */
        dissect_osd2_cdb_continuation(pinfo, tvb, offset, tree, cdata);

        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data out for remove partition */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data in for remove partition */
    }

}

static const value_string key_to_set_vals[] = {
    {1, "Root"},
    {2, "Partition"},
    {3, "Working"},
    {0, NULL},
};
static void
dissect_osd_key_to_set(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    proto_tree_add_item(tree, hf_scsi_osd_key_to_set, tvb, offset, 1, ENC_BIG_ENDIAN);
}

static void
dissect_osd_set_key_version(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    proto_tree_add_item(tree, hf_scsi_osd_set_key_version, tvb, offset, 1, ENC_BIG_ENDIAN);
}

static void
dissect_osd_key_identifier(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    proto_tree_add_item(tree, hf_scsi_osd_key_identifier, tvb, offset, 7, ENC_NA);
}

static void
dissect_osd_seed(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    proto_tree_add_item(tree, hf_scsi_osd_seed, tvb, offset, 20, ENC_NA);
}

static void
dissect_osd_set_key(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_,
                    scsi_osd_conv_info_t *conv_info _U_,
                    scsi_osd_lun_info_t *lun_info)
{
    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {
        /* a reserved byte */
        offset += 1;

        /* getset attributes byte and key to set*/
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        dissect_osd_key_to_set(tvb, offset, tree);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 3 reserved bytes */
        offset += 3;

        /* partiton id */
        dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_partition_id, lun_info, FALSE, FALSE);
        offset += 8;

        /* key version */
        dissect_osd_set_key_version(tvb, offset, tree);
        offset += 1;

        /* key identifier */
        dissect_osd_key_identifier(tvb, offset, tree);
        offset += 7;

        /* seed */
        dissect_osd_seed(tvb, offset, tree);
        offset += 20;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += 80;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += 40;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data out for set key */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data in for set key */
    }

}

static void
dissect_osd_remove(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_,
                   scsi_osd_conv_info_t *conv_info _U_,
                   scsi_osd_lun_info_t *lun_info)
{
    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {
        /* options byte */
        dissect_osd_option(tvb, offset, tree);
        offset += 1;

        /* getset attributes byte */
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 3 reserved bytes */
        offset += 3;

        /* partiton id */
        dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_partition_id, lun_info, FALSE, FALSE);
        offset += 8;

        /* user object id */
        dissect_osd_user_object_id(tvb, offset, tree);
        offset += 8;

        /* 20 reserved bytes */
        offset += 20;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += 80;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += 40;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data out for remove */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data in for remove */
    }

}

static void
dissect_osd_collection_fcr(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    proto_tree_add_item(tree, hf_scsi_osd_collection_fcr, tvb, offset, 1, ENC_BIG_ENDIAN);
}

static void
dissect_osd_remove_collection(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_,
                              scsi_osd_conv_info_t *conv_info _U_,
                              scsi_osd_lun_info_t *lun_info)
{
    gboolean osd2 = ((scsi_osd_extra_data_t *)cdata->itlq->extra_data)->svcaction&0x80;
    ((scsi_osd_extra_data_t *)cdata->itlq->extra_data)->osd2 = osd2;

    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {
        /* options byte */
        dissect_osd_option(tvb, offset, tree);
        offset += 1;

        /* getset attributes byte */
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        dissect_osd_collection_fcr(tvb, offset, tree);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 3 reserved bytes */
        offset += 3;

        /* partiton id */
        dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_partition_id, lun_info, FALSE, FALSE);
        offset += 8;

        /* collection object id */
        dissect_osd_collection_object_id(tvb, offset, tree, hf_scsi_osd_collection_object_id);
        offset += 8;

        /* 16 reserved bytes */
        offset += 16;

        if (osd2) {
            dissect_osd2_cdb_continuation_length(pinfo, tvb, offset, tree, cdata);
        } else {
            /* 4 reserved bytes */
        }
        offset += 4;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += osd2?104:80;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += osd2?52:40;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* CDB continuation */
        dissect_osd2_cdb_continuation(pinfo, tvb, offset, tree, cdata);

        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data out for remove collection */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data in for remove collection */
    }

}


static int
dissect_osd_length(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    /* length */
    proto_tree_add_item(tree, hf_scsi_osd_length, tvb, offset, 8, ENC_BIG_ENDIAN);
    offset += 8;

    return offset;
}

static int
dissect_osd_starting_byte_address(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    /* starting_byte_address */
    proto_tree_add_item(tree, hf_scsi_osd_starting_byte_address, tvb, offset, 8, ENC_BIG_ENDIAN);
    offset += 8;

    return offset;
}


static void
dissect_osd_write(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_,
                  scsi_osd_conv_info_t *conv_info _U_,
                  scsi_osd_lun_info_t *lun_info)
{
    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {
        /* options byte */
        dissect_osd_option(tvb, offset, tree);
        offset += 1;

        /* getset attributes byte / sort order */
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 3 reserved bytes */
        offset += 3;

        /* partiton id */
        dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_partition_id, lun_info, FALSE, FALSE);
        offset += 8;

        /* user object id */
        dissect_osd_user_object_id(tvb, offset, tree);
        offset += 8;

        /* 4 reserved bytes */
        offset += 4;

        /* length */
        dissect_osd_length(tvb, offset, tree);
        offset += 8;

        /* starting byte address */
        dissect_osd_starting_byte_address(tvb, offset, tree);
        offset += 8;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += 80;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += 40;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* xxx should dissect the data ? */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data in for WRITE */
    }

}

static void
dissect_osd_create_collection(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_,
                              scsi_osd_conv_info_t *conv_info _U_,
                              scsi_osd_lun_info_t *lun_info)
{
    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {
        /* options byte */
        dissect_osd_option(tvb, offset, tree);
        offset += 1;

        /* getset attributes byte */
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        dissect_osd_collection_fcr(tvb, offset, tree);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 3 reserved bytes */
        offset += 3;

        /* partiton id */
        dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_partition_id, lun_info, FALSE, FALSE);
        offset += 8;

        /* requested collection object id */
        dissect_osd_collection_object_id(tvb, offset, tree, hf_scsi_osd_requested_collection_object_id);
        offset += 8;

        /* 20 reserved bytes */
        offset += 20;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += 80;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += 40;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data out for create collection */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data in for create collection */
    }

}


static const value_string flush_scope_vals[] = {
    {0, "User object data and attributes"},
    {1, "User object attributes only"},
    {0, NULL}
};

static int
dissect_osd_flush_scope(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    /* flush scope */
    proto_tree_add_item(tree, hf_scsi_osd_flush_scope, tvb, offset, 1, ENC_BIG_ENDIAN);
    offset += 1;

    return offset;
}

static void
dissect_osd_flush(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_,
                  scsi_osd_conv_info_t *conv_info _U_,
                  scsi_osd_lun_info_t *lun_info)
{
    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {
        /* options byte */
        dissect_osd_flush_scope(tvb, offset, tree);
        offset += 1;

        /* getset attributes byte */
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 3 reserved bytes */
        offset += 3;

        /* partiton id */
        dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_partition_id, lun_info, FALSE, FALSE);
        offset += 8;

        /* user object id */
        dissect_osd_user_object_id(tvb, offset, tree);
        offset += 8;

        /* 20 reserved bytes */
        offset += 20;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += 80;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += 40;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data out for flush */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data in for flush */
    }

}


static const value_string flush_collection_scope_vals[] = {
    {0, "List of user objects contained in the collection"},
    {1, "Collection attributes only"},
    {2, "List of user objects and collection attributes"},
    {0, NULL}
};

static int
dissect_osd_flush_collection_scope(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    /* flush collection scope */
    proto_tree_add_item(tree, hf_scsi_osd_flush_collection_scope, tvb, offset, 1, ENC_BIG_ENDIAN);
    offset += 1;

    return offset;
}

static void
dissect_osd_flush_collection(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_,
                             scsi_osd_conv_info_t *conv_info _U_,
                             scsi_osd_lun_info_t *lun_info)
{
    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {
        /* options byte */
        dissect_osd_flush_collection_scope(tvb, offset, tree);
        offset += 1;

        /* getset attributes byte */
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        dissect_osd_collection_fcr(tvb, offset, tree);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 3 reserved bytes */
        offset += 3;

        /* partiton id */
        dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_partition_id, lun_info, FALSE, FALSE);
        offset += 8;

        /* collection object id */
        dissect_osd_collection_object_id(tvb, offset, tree, hf_scsi_osd_collection_object_id);
        offset += 8;

        /* 20 reserved bytes */
        offset += 20;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += 80;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += 40;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data out for flush collection */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data in for flush collection */
    }

}


static void
dissect_osd_append(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_,
                   scsi_osd_conv_info_t *conv_info _U_,
                   scsi_osd_lun_info_t *lun_info)
{
    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {
        /* options byte */
        dissect_osd_option(tvb, offset, tree);
        offset += 1;

        /* getset attributes byte */
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 3 reserved bytes */
        offset += 3;

        /* partiton id */
        dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_partition_id, lun_info, FALSE, FALSE);
        offset += 8;

        /* user object id */
        dissect_osd_user_object_id(tvb, offset, tree);
        offset += 8;

        /* 4 reserved bytes */
        offset += 4;

        /* length */
        dissect_osd_length(tvb, offset, tree);
        offset += 8;

        /* 8 reserved bytes */
        offset += 8;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += 80;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += 40;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* xxx should dissect the data ? */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data in for append */
    }

}

static void
dissect_osd_create_and_write(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_,
                             scsi_osd_conv_info_t *conv_info _U_,
                             scsi_osd_lun_info_t *lun_info)
{
    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {
        /* options byte */
        dissect_osd_option(tvb, offset, tree);
        offset += 1;

        /* getset attributes byte */
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 3 reserved bytes */
        offset += 3;

        /* partiton id */
        dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_partition_id, lun_info, FALSE, FALSE);
        offset += 8;

        /* requested user_object id */
        dissect_osd_requested_user_object_id(tvb, offset, tree);
        offset += 8;

        /* 4 reserved bytes */
        offset += 4;

        /* length */
        dissect_osd_length(tvb, offset, tree);
        offset += 8;

        /* starting byte address */
        dissect_osd_starting_byte_address(tvb, offset, tree);
        offset += 8;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += 80;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += 40;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* should we dissect the data? */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data in for create and write*/
    }

}


static const value_string flush_osd_scope_vals[] = {
    {0, "List of partitions contained in the OSD logical unit"},
    {1, "Root object attributes only"},
    {2, "Everything"},
    {0, NULL}
};

static int
dissect_osd_flush_osd_scope(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    /* flush osd scope */
    proto_tree_add_item(tree, hf_scsi_osd_flush_osd_scope, tvb, offset, 1, ENC_BIG_ENDIAN);
    offset += 1;

    return offset;
}

static void
dissect_osd_flush_osd(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_,
                      scsi_osd_conv_info_t *conv_info _U_,
                      scsi_osd_lun_info_t *lun_info _U_)
{
    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {
        /* options byte */
        dissect_osd_flush_osd_scope(tvb, offset, tree);
        offset += 1;

        /* getset attributes byte */
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 39 reserved bytes */
        offset += 39;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += 80;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += 40;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data out for flush osd */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data in for flush osd */
    }

}


static const value_string flush_partition_scope_vals[] = {
    {0, "List of user objects and collections in the partition"},
    {1, "Partition attributes only"},
    {2, "Everything"},
    {0, NULL}
};

static int
dissect_osd_flush_partition_scope(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    /* flush partition scope */
    proto_tree_add_item(tree, hf_scsi_osd_flush_partition_scope, tvb, offset, 1, ENC_BIG_ENDIAN);
    offset += 1;

    return offset;
}


static void
dissect_osd_flush_partition(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_,
                            scsi_osd_conv_info_t *conv_info _U_,
                            scsi_osd_lun_info_t *lun_info)
{
    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {
        /* options byte */
        dissect_osd_flush_partition_scope(tvb, offset, tree);
        offset += 1;

        /* getset attributes byte */
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 3 reserved bytes */
        offset += 3;

        /* partiton id */
        dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_partition_id, lun_info, FALSE, FALSE);
        offset += 8;

        /* 28 reserved bytes */
        offset += 28;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += 80;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += 40;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data out for flush partition */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data in for flush partition */
    }

}


static void
dissect_osd_get_attributes(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_,
                           scsi_osd_conv_info_t *conv_info _U_,
                           scsi_osd_lun_info_t *lun_info)
{
    gboolean osd2 = ((scsi_osd_extra_data_t *)cdata->itlq->extra_data)->svcaction&0x80;
    ((scsi_osd_extra_data_t *)cdata->itlq->extra_data)->osd2 = osd2;

    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {
        /* options byte */
        dissect_osd_option(tvb, offset, tree);
        offset += 1;

        /* getset attributes byte */
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 3 reserved bytes */
        offset += 3;

        /* partiton id */
        dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_partition_id, lun_info, FALSE, FALSE);
        offset += 8;

        /* user_object id */
        dissect_osd_user_object_id(tvb, offset, tree);
        offset += 8;

        /* 16 reserved bytes */
        offset += 16;

        if (osd2) {
            dissect_osd2_cdb_continuation_length(pinfo, tvb, offset, tree, cdata);
        } else {
            /* 4 reserved bytes */
        }
        offset += 4;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += osd2?104:80;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += osd2?52:40;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data out for get attributes */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data in for get attributes */
    }

}


static void
dissect_osd_read(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_,
                 scsi_osd_conv_info_t *conv_info _U_,
                 scsi_osd_lun_info_t *lun_info)
{
    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {
        /* options byte */
        dissect_osd_option(tvb, offset, tree);
        offset += 1;

        /* getset attributes byte / sort order */
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 3 reserved bytes */
        offset += 3;

        /* partiton id */
        dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_partition_id, lun_info, FALSE, FALSE);
        offset += 8;

        /* user object id */
        dissect_osd_user_object_id(tvb, offset, tree);
        offset += 8;

        /* 4 reserved bytes */
        offset += 4;

        /* length */
        dissect_osd_length(tvb, offset, tree);
        offset += 8;

        /* starting byte address */
        dissect_osd_starting_byte_address(tvb, offset, tree);
        offset += 8;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += 80;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += 40;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data out for READ */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

/* xxx should dissect the data ? */
    }

}


static void
dissect_osd_set_attributes(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_,
                           scsi_osd_conv_info_t *conv_info _U_,
                           scsi_osd_lun_info_t *lun_info)
{
    gboolean osd2 = ((scsi_osd_extra_data_t *)cdata->itlq->extra_data)->svcaction&0x80;
    ((scsi_osd_extra_data_t *)cdata->itlq->extra_data)->osd2 = osd2;

    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {
        /* options byte */
        dissect_osd_option(tvb, offset, tree);
        offset += 1;

        /* getset attributes byte */
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 3 reserved bytes */
        offset += 3;

        /* partiton id */
        dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_partition_id, lun_info, FALSE, FALSE);
        offset += 8;

        /* user_object id */
        dissect_osd_user_object_id(tvb, offset, tree);
        offset += 8;

        /* 16 reserved bytes */
        offset += 16;

        if (osd2) {
            dissect_osd2_cdb_continuation_length(pinfo, tvb, offset, tree, cdata);
        } else {
            /* 4 reserved bytes */
        }
        offset += 4;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += osd2?104:80;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += osd2?52:40;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data out for set attributes */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data in for set attributes */
    }

}


static void
dissect_osd2_create_user_tracking_collection(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_,
                        scsi_osd_conv_info_t *conv_info _U_,
                        scsi_osd_lun_info_t *lun_info)
{
    ((scsi_osd_extra_data_t *)cdata->itlq->extra_data)->osd2 = TRUE;

    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {

        /* options byte */
        dissect_osd2_isolation(tvb, offset, tree);
        dissect_osd_option(tvb, offset, tree);
        offset += 1;

        /* getset attributes byte */
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 3 reserved bytes */
        offset += 3;

        /* partition id */
        dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_partition_id, lun_info, FALSE, FALSE);
        offset += 8;

        /* user_object id */
        dissect_osd_collection_object_id(tvb, offset, tree, hf_scsi_osd_requested_collection_object_id);
        offset += 8;

        /* 8 reserved bytes */
        offset += 8;

        /* source collection id */
        dissect_osd_collection_object_id(tvb, offset, tree, hf_scsi_osd2_source_collection_object_id);
        offset += 8;

        /*cdb continuation length*/
        dissect_osd2_cdb_continuation_length(pinfo, tvb, offset, tree, cdata);
        offset += 4;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += 104;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += 52;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* CDB continuation */
        dissect_osd2_cdb_continuation(pinfo, tvb, offset, tree, cdata);

        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data out for create user tracking collection */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data in for create user tracking collection */
    }

}

static void
dissect_osd2_query(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_,
                        scsi_osd_conv_info_t *conv_info _U_,
                        scsi_osd_lun_info_t *lun_info)
{
    ((scsi_osd_extra_data_t *)cdata->itlq->extra_data)->osd2 = TRUE;

    /* dissecting the CDB   dissection starts at byte 10 of the CDB */
    if (isreq && iscdb) {

        /* isolation field */
        dissect_osd2_isolation(tvb, offset, tree);
        offset += 1;

        /* immed_tr, getset attributes*/
        proto_tree_add_item(tree, hf_scsi_osd2_immed_tr, tvb, offset, 1, ENC_BIG_ENDIAN);
        dissect_osd_getsetattrib(tvb, offset, tree, cdata);
        offset += 1;

        /* timestamps control */
        dissect_osd_timestamps_control(tvb, offset, tree);
        offset += 1;

        /* 3 reserved bytes */
        offset += 3;

        /* partition id */
        dissect_osd_partition_id(pinfo, tvb, offset, tree, hf_scsi_osd_partition_id, lun_info, FALSE, FALSE);
        offset += 8;

        /* collection_object id */
        dissect_osd_collection_object_id(tvb, offset, tree, hf_scsi_osd_collection_object_id);
        offset += 8;

        /* allocation_length */
        dissect_osd_allocation_length(tvb, offset, tree, cdata);
        offset += 8;

        /* matches collection id */
        dissect_osd_collection_object_id(tvb, offset, tree, hf_scsi_osd2_matches_collection_object_id);
        offset += 8;

        /*cdb continuation length*/
        dissect_osd2_cdb_continuation_length(pinfo, tvb, offset, tree, cdata);
        offset += 4;

        /* attribute parameters */
        dissect_osd_attribute_parameters(pinfo, tvb, offset, tree, cdata);
        offset += 28;

        /* capability */
        dissect_osd_capability(tvb, offset, tree);
        offset += 104;

        /* security parameters */
        dissect_osd_security_parameters(tvb, offset, tree);
        offset += 52;
    }

    /* dissecting the DATA OUT */
    if (isreq && !iscdb) {
        /* CDB continuation */
        dissect_osd2_cdb_continuation(pinfo, tvb, offset, tree, cdata);

        /* attribute data out */
        dissect_osd_attribute_data_out(pinfo, tvb, offset, tree, cdata, lun_info);

        /* no data out for query */
    }

    /* dissecting the DATA IN */
    if (!isreq && !iscdb) {
        guint64  additional_length;
        guint64  allocation_length;
        guint64  remaining_length;
        guint8   format;
        proto_item *item;

        /* attribute data in */
        dissect_osd_attribute_data_in(pinfo, tvb, offset, tree, cdata, lun_info);

        allocation_length = cdata->itlq->alloc_len;
        remaining_length = tvb_captured_length_remaining(tvb, offset);
        if (remaining_length<allocation_length) allocation_length = remaining_length;
        if (allocation_length<12) return;

        /* dissection of the LIST or LIST COLLECTION DATA-IN */
        /* additional length */
        additional_length = tvb_get_ntoh64(tvb, offset);
        if ((guint32)(allocation_length-8)<additional_length) additional_length = (guint32)(allocation_length-8);

        dissect_osd_additional_length(tvb, offset, tree);
        offset += 8;

        /* 3 reserved bytes */
        offset += 3;
        item = proto_tree_add_item(tree, hf_scsi_osd2_object_descriptor_format, tvb, offset, 1, ENC_BIG_ENDIAN);
        format = tvb_get_guint8(tvb, offset)>>2;
        offset += 1;
        if (format != 0x21) {
            expert_add_info(pinfo, item, &ei_osd2_invalid_object_descriptor_format);
            return;
        }

        while (additional_length > (offset-4)) {
            dissect_osd_user_object_id(tvb, offset, tree);
            offset += 8;
        }
    }

}

/* OSD Service Actions */
#define OSD_FORMAT_OSD                        0x8801
#define OSD_CREATE                            0x8802
#define OSD_LIST                              0x8803
#define OSD_READ                              0x8805
#define OSD_WRITE                             0x8806
#define OSD_APPEND                            0x8807
#define OSD_FLUSH                             0x8808
#define OSD_REMOVE                            0x880a
#define OSD_CREATE_PARTITION                  0x880b
#define OSD_REMOVE_PARTITION                  0x880c
#define OSD_GET_ATTRIBUTES                    0x880e
#define OSD_SET_ATTRIBUTES                    0x880f
#define OSD_CREATE_AND_WRITE                  0x8812
#define OSD_CREATE_COLLECTION                 0x8815
#define OSD_REMOVE_COLLECTION                 0x8816
#define OSD_LIST_COLLECTION                   0x8817
#define OSD_SET_KEY                           0x8818
#define OSD_FLUSH_COLLECTION                  0x881a
#define OSD_FLUSH_PARTITION                   0x881b
#define OSD_FLUSH_OSD                         0x881c

#define OSD_2_CREATE                          0x8882
#define OSD_2_LIST                            0x8883
#define OSD_2_READ                            0x8885
#define OSD_2_WRITE                           0x8886
#define OSD_2_APPEND                          0x8887
#define OSD_2_CLEAR                           0x8889
#define OSD_2_REMOVE                          0x888a
#define OSD_2_CREATE_PARTITION                0x888b
#define OSD_2_REMOVE_PARTITION                0x888c
#define OSD_2_GET_ATTRIBUTES                  0x888e
#define OSD_2_SET_ATTRIBUTES                  0x888f
#define OSD_2_CREATE_AND_WRITE                0x8892
#define OSD_2_COPY_USER_OBJECTS               0x8893
#define OSD_2_CREATE_USER_TRACKING_COLLECTION 0x8894
#define OSD_2_REMOVE_COLLECTION               0x8896
#define OSD_2_LIST_COLLECTION                 0x8897
#define OSD_2_QUERY                           0x88a0
#define OSD_2_REMOVE_MEMBER_OBJECTS           0x88a1
#define OSD_2_GET_MEMBER_ATTRIBUTES           0x88a2
#define OSD_2_SET_MEMBER_ATTRIBUTES           0x88a3

static const value_string scsi_osd_svcaction_vals[] = {
    {OSD_FORMAT_OSD,                        "Format OSD"},
    {OSD_CREATE,                            "Create"},
    {OSD_LIST,                              "List"},
    {OSD_READ,                              "Read"},
    {OSD_WRITE,                             "Write"},
    {OSD_APPEND,                            "Append"},
    {OSD_FLUSH,                             "Flush"},
    {OSD_REMOVE,                            "Remove"},
    {OSD_CREATE_PARTITION,                  "Create Partition"},
    {OSD_REMOVE_PARTITION,                  "Remove Partition"},
    {OSD_GET_ATTRIBUTES,                    "Get Attributes"},
    {OSD_SET_ATTRIBUTES,                    "Set Attributes"},
    {OSD_CREATE_AND_WRITE,                  "Create And Write"},
    {OSD_CREATE_COLLECTION,                 "Create Collection"},
    {OSD_REMOVE_COLLECTION,                 "Remove Collection"},
    {OSD_LIST_COLLECTION,                   "List Collection"},
    {OSD_SET_KEY,                           "Set Key"},
    {OSD_FLUSH_COLLECTION,                  "Flush Collection"},
    {OSD_FLUSH_PARTITION,                   "Flush Partition"},
    {OSD_FLUSH_OSD,                         "Flush OSD"},

    {OSD_2_CREATE,                          "Create (OSD-2)"},
    {OSD_2_LIST,                            "List (OSD-2)"},
    {OSD_2_READ,                            "Read (OSD-2)"},
    {OSD_2_WRITE,                           "Write (OSD-2)"},
    {OSD_2_APPEND,                          "Append (OSD-2)"},
    {OSD_2_CLEAR,                           "Clear (OSD-2)"},
    {OSD_2_REMOVE,                          "Remove (OSD-2)"},
    {OSD_2_CREATE_PARTITION,                "Create Partition (OSD-2)"},
    {OSD_2_REMOVE_PARTITION,                "Remove Partition (OSD-2)"},
    {OSD_2_GET_ATTRIBUTES,                  "Get Attributes (OSD-2)"},
    {OSD_2_SET_ATTRIBUTES,                  "Set Attributes (OSD-2)"},
    {OSD_2_CREATE_AND_WRITE,                "Create And Write (OSD-2)"},
    {OSD_2_COPY_USER_OBJECTS,               "Copy User Objects (OSD-2)"},
    {OSD_2_CREATE_USER_TRACKING_COLLECTION, "Create User Tracking Collection  (OSD-2)"},
    {OSD_2_REMOVE_COLLECTION,               "Remove Collection (OSD-2)"},
    {OSD_2_LIST_COLLECTION,                 "List Collection (OSD-2)"},
    {OSD_2_QUERY,                           "Query (OSD-2)"},
    {OSD_2_REMOVE_MEMBER_OBJECTS,           "Remove Member Objects (OSD-2)"},
    {OSD_2_GET_MEMBER_ATTRIBUTES,           "Get Member Attributes (OSD-2)"},
    {OSD_2_SET_MEMBER_ATTRIBUTES,           "Set Member Attributes (OSD-2)"},
    {0, NULL},
};
static value_string_ext scsi_osd_svcaction_vals_ext = VALUE_STRING_EXT_INIT(scsi_osd_svcaction_vals);

/* OSD Service Action dissectors */
typedef struct _scsi_osd_svcaction_t {
    guint16              svcaction;
    scsi_osd_dissector_t dissector;
} scsi_osd_svcaction_t;

static const scsi_osd_svcaction_t scsi_osd_svcaction[] = {
    {OSD_FORMAT_OSD,                        dissect_osd_format_osd},
    {OSD_CREATE,                            dissect_osd_create},
    {OSD_LIST,                              dissect_osd_list},
    {OSD_READ,                              dissect_osd_read},
    {OSD_WRITE,                             dissect_osd_write},
    {OSD_APPEND,                            dissect_osd_append},
    {OSD_FLUSH,                             dissect_osd_flush},
    {OSD_REMOVE,                            dissect_osd_remove},
    {OSD_CREATE_PARTITION,                  dissect_osd_create_partition},
    {OSD_REMOVE_PARTITION,                  dissect_osd_remove_partition},
    {OSD_GET_ATTRIBUTES,                    dissect_osd_get_attributes},
    {OSD_SET_ATTRIBUTES,                    dissect_osd_set_attributes},
    {OSD_CREATE_AND_WRITE,                  dissect_osd_create_and_write},
    {OSD_CREATE_COLLECTION,                 dissect_osd_create_collection},
    {OSD_REMOVE_COLLECTION,                 dissect_osd_remove_collection},
    {OSD_LIST_COLLECTION,                   dissect_osd_list},
    {OSD_SET_KEY,                           dissect_osd_set_key},
    {OSD_FLUSH_COLLECTION,                  dissect_osd_flush_collection},
    {OSD_FLUSH_PARTITION,                   dissect_osd_flush_partition},
    {OSD_FLUSH_OSD,                         dissect_osd_flush_osd},
    {OSD_2_LIST,                            dissect_osd_list},
    {OSD_2_CREATE_PARTITION,                dissect_osd_create_partition},
    {OSD_2_CREATE_USER_TRACKING_COLLECTION, dissect_osd2_create_user_tracking_collection},
    {OSD_2_REMOVE_PARTITION,                dissect_osd_remove_partition},
    {OSD_2_LIST_COLLECTION,                 dissect_osd_list},
    {OSD_2_CREATE_USER_TRACKING_COLLECTION, dissect_osd2_create_user_tracking_collection},
    {OSD_2_REMOVE_COLLECTION,               dissect_osd_remove_collection},
    {OSD_2_GET_ATTRIBUTES,                  dissect_osd_get_attributes},
    {OSD_2_SET_ATTRIBUTES,                  dissect_osd_set_attributes},
    {OSD_2_QUERY,                           dissect_osd2_query},
    {0, NULL},
};

static scsi_osd_dissector_t
find_svcaction_dissector(guint16 svcaction)
{
    const scsi_osd_svcaction_t *sa = scsi_osd_svcaction;

    while (sa && sa->dissector) {
        if (sa->svcaction == svcaction) {
            return sa->dissector;
        }
        sa++;
    }
    return NULL;
}



static void
dissect_osd_opcode(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
                   guint offset, gboolean isreq, gboolean iscdb,
                   guint payload_len, scsi_task_data_t *cdata)
{
    guint16               svcaction = 0;
    scsi_osd_dissector_t  dissector;
    scsi_osd_conv_info_t *conv_info;
    scsi_osd_lun_info_t  *lun_info;

    if (!tree) {
        return;
    }

    /* We must have an itl an itlq and a conversation */
    if (!cdata || !cdata->itl || !cdata->itl->conversation || !cdata->itlq) {
        return;
    }
    /* make sure we have a conversation info for this */
    conv_info = (scsi_osd_conv_info_t *)conversation_get_proto_data(cdata->itl->conversation, proto_scsi_osd);
    if (!conv_info) {
        conv_info = wmem_new(wmem_file_scope(), scsi_osd_conv_info_t);
        conv_info->luns = wmem_tree_new(wmem_file_scope());
        conversation_add_proto_data(cdata->itl->conversation, proto_scsi_osd, conv_info);
    }
    /* make sure we have a lun_info structure for this */
    lun_info = (scsi_osd_lun_info_t *)wmem_tree_lookup32(conv_info->luns, cdata->itlq->lun);
    if (!lun_info) {
        lun_info = wmem_new(wmem_file_scope(), scsi_osd_lun_info_t);
        lun_info->partitions = wmem_tree_new(wmem_file_scope());
        wmem_tree_insert32(conv_info->luns, cdata->itlq->lun, (void *)lun_info);
    }

    /* dissecting the CDB */
    if (isreq && iscdb) {
        proto_tree_add_item (tree, hf_scsi_control, tvb, offset, 1, ENC_BIG_ENDIAN);
        offset += 1;

        /* 5 reserved bytes */
        offset += 5;

        proto_tree_add_item (tree, hf_scsi_osd_add_cdblen, tvb, offset, 1, ENC_BIG_ENDIAN);
        offset += 1;

        svcaction = tvb_get_ntohs(tvb, offset);
        if (cdata && cdata->itlq) {
            /* We must store the service action for this itlq
             * so we can identify what the data contains
             */
            if ((!pinfo->fd->visited) || (!cdata->itlq->extra_data)) {
                scsi_osd_extra_data_t *extra_data;

                extra_data = wmem_new0(wmem_file_scope(), scsi_osd_extra_data_t);
                extra_data->svcaction = svcaction;
                cdata->itlq->extra_data = extra_data;
            }
        }
        proto_tree_add_item (tree, hf_scsi_osd_svcaction, tvb, offset, 2, ENC_BIG_ENDIAN);
        offset += 2;


        col_append_str(pinfo->cinfo, COL_INFO,
                val_to_str_ext_const(svcaction, &scsi_osd_svcaction_vals_ext, "Unknown OSD Service Action"));

        dissector = find_svcaction_dissector(svcaction);
        if (dissector) {
            (*dissector)(tvb, pinfo, tree, offset, isreq, iscdb, payload_len, cdata, conv_info, lun_info);
        }
        return;
    }

    /* If it was not a CDB, try to find the service action and pass it
     * off to the service action dissector
     */
    if (cdata && cdata->itlq && cdata->itlq->extra_data) {
        scsi_osd_extra_data_t *extra_data = (scsi_osd_extra_data_t *)cdata->itlq->extra_data;
        svcaction = extra_data->svcaction;
    }
    col_append_str(pinfo->cinfo, COL_INFO,
        val_to_str_ext_const(svcaction, &scsi_osd_svcaction_vals_ext, "Unknown OSD Service Action"));
    if (svcaction) {
        proto_item *it;
        it = proto_tree_add_uint_format_value(tree, hf_scsi_osd_svcaction, tvb, 0, 0, svcaction, "0x%04x", svcaction);
        proto_item_set_generated(it);
    }
    dissector = find_svcaction_dissector(svcaction);
    if (dissector) {
        (*dissector)(tvb, pinfo, tree, offset, isreq, iscdb, payload_len, cdata, conv_info, lun_info);
    }

}


/* OSD Commands */
static const value_string scsi_osd_vals[] = {
    /* 0x12 */    {SCSI_SPC_INQUIRY,          "Inquiry"},
    /* 0x4C */    {SCSI_SPC_LOGSELECT,        "Log Select"},
    /* 0x4D */    {SCSI_SPC_LOGSENSE,         "Log Sense"},
    /* 0x55 */    {SCSI_SPC_MODESELECT10,     "Mode Select(10)"},
    /* 0x5A */    {SCSI_SPC_MODESENSE10,      "Mode Sense(10)"},
    /* 0x5E */    {SCSI_SPC_PERSRESVIN,       "Persistent Reserve In"},
    /* 0x5F */    {SCSI_SPC_PERSRESVOUT,      "Persistent Reserve Out"},
    /* 0x7f */    {SCSI_OSD_OPCODE,           "OSD Command" },
    /* 0xA0 */    {SCSI_SPC_REPORTLUNS,       "Report LUNs"},
    /* 0xA3 */    {SCSI_SPC_MGMT_PROTOCOL_IN, "Mgmt Protocol In"},
    {0, NULL},
};
value_string_ext scsi_osd_vals_ext = VALUE_STRING_EXT_INIT(scsi_osd_vals);

scsi_cdb_table_t scsi_osd_table[256] = {
/*OSD 0x00*/{NULL},
/*OSD 0x01*/{NULL},
/*OSD 0x02*/{NULL},
/*OSD 0x03*/{NULL},
/*OSD 0x04*/{NULL},
/*OSD 0x05*/{NULL},
/*OSD 0x06*/{NULL},
/*OSD 0x07*/{NULL},
/*OSD 0x08*/{NULL},
/*OSD 0x09*/{NULL},
/*OSD 0x0a*/{NULL},
/*OSD 0x0b*/{NULL},
/*OSD 0x0c*/{NULL},
/*OSD 0x0d*/{NULL},
/*OSD 0x0e*/{NULL},
/*OSD 0x0f*/{NULL},
/*OSD 0x10*/{NULL},
/*OSD 0x11*/{NULL},
/*OSD 0x12*/{dissect_spc_inquiry},
/*OSD 0x13*/{NULL},
/*OSD 0x14*/{NULL},
/*OSD 0x15*/{NULL},
/*OSD 0x16*/{NULL},
/*OSD 0x17*/{NULL},
/*OSD 0x18*/{NULL},
/*OSD 0x19*/{NULL},
/*OSD 0x1a*/{NULL},
/*OSD 0x1b*/{NULL},
/*OSD 0x1c*/{NULL},
/*OSD 0x1d*/{NULL},
/*OSD 0x1e*/{NULL},
/*OSD 0x1f*/{NULL},
/*OSD 0x20*/{NULL},
/*OSD 0x21*/{NULL},
/*OSD 0x22*/{NULL},
/*OSD 0x23*/{NULL},
/*OSD 0x24*/{NULL},
/*OSD 0x25*/{NULL},
/*OSD 0x26*/{NULL},
/*OSD 0x27*/{NULL},
/*OSD 0x28*/{NULL},
/*OSD 0x29*/{NULL},
/*OSD 0x2a*/{NULL},
/*OSD 0x2b*/{NULL},
/*OSD 0x2c*/{NULL},
/*OSD 0x2d*/{NULL},
/*OSD 0x2e*/{NULL},
/*OSD 0x2f*/{NULL},
/*OSD 0x30*/{NULL},
/*OSD 0x31*/{NULL},
/*OSD 0x32*/{NULL},
/*OSD 0x33*/{NULL},
/*OSD 0x34*/{NULL},
/*OSD 0x35*/{NULL},
/*OSD 0x36*/{NULL},
/*OSD 0x37*/{NULL},
/*OSD 0x38*/{NULL},
/*OSD 0x39*/{NULL},
/*OSD 0x3a*/{NULL},
/*OSD 0x3b*/{NULL},
/*OSD 0x3c*/{NULL},
/*OSD 0x3d*/{NULL},
/*OSD 0x3e*/{NULL},
/*OSD 0x3f*/{NULL},
/*OSD 0x40*/{NULL},
/*OSD 0x41*/{NULL},
/*OSD 0x42*/{NULL},
/*OSD 0x43*/{NULL},
/*OSD 0x44*/{NULL},
/*OSD 0x45*/{NULL},
/*OSD 0x46*/{NULL},
/*OSD 0x47*/{NULL},
/*OSD 0x48*/{NULL},
/*OSD 0x49*/{NULL},
/*OSD 0x4a*/{NULL},
/*OSD 0x4b*/{NULL},
/*OSD 0x4c*/{dissect_spc_logselect},
/*OSD 0x4d*/{dissect_spc_logsense},
/*OSD 0x4e*/{NULL},
/*OSD 0x4f*/{NULL},
/*OSD 0x50*/{NULL},
/*OSD 0x51*/{NULL},
/*OSD 0x52*/{NULL},
/*OSD 0x53*/{NULL},
/*OSD 0x54*/{NULL},
/*OSD 0x55*/{dissect_spc_modeselect10},
/*OSD 0x56*/{NULL},
/*OSD 0x57*/{NULL},
/*OSD 0x58*/{NULL},
/*OSD 0x59*/{NULL},
/*OSD 0x5a*/{dissect_spc_modesense10},
/*OSD 0x5b*/{NULL},
/*OSD 0x5c*/{NULL},
/*OSD 0x5d*/{NULL},
/*OSD 0x5e*/{dissect_spc_persistentreservein},
/*OSD 0x5f*/{dissect_spc_persistentreserveout},
/*OSD 0x60*/{NULL},
/*OSD 0x61*/{NULL},
/*OSD 0x62*/{NULL},
/*OSD 0x63*/{NULL},
/*OSD 0x64*/{NULL},
/*OSD 0x65*/{NULL},
/*OSD 0x66*/{NULL},
/*OSD 0x67*/{NULL},
/*OSD 0x68*/{NULL},
/*OSD 0x69*/{NULL},
/*OSD 0x6a*/{NULL},
/*OSD 0x6b*/{NULL},
/*OSD 0x6c*/{NULL},
/*OSD 0x6d*/{NULL},
/*OSD 0x6e*/{NULL},
/*OSD 0x6f*/{NULL},
/*OSD 0x70*/{NULL},
/*OSD 0x71*/{NULL},
/*OSD 0x72*/{NULL},
/*OSD 0x73*/{NULL},
/*OSD 0x74*/{NULL},
/*OSD 0x75*/{NULL},
/*OSD 0x76*/{NULL},
/*OSD 0x77*/{NULL},
/*OSD 0x78*/{NULL},
/*OSD 0x79*/{NULL},
/*OSD 0x7a*/{NULL},
/*OSD 0x7b*/{NULL},
/*OSD 0x7c*/{NULL},
/*OSD 0x7d*/{NULL},
/*OSD 0x7e*/{NULL},
/*OSD 0x7f*/{dissect_osd_opcode},
/*OSD 0x80*/{NULL},
/*OSD 0x81*/{NULL},
/*OSD 0x82*/{NULL},
/*OSD 0x83*/{NULL},
/*OSD 0x84*/{NULL},
/*OSD 0x85*/{NULL},
/*OSD 0x86*/{NULL},
/*OSD 0x87*/{NULL},
/*OSD 0x88*/{NULL},
/*OSD 0x89*/{NULL},
/*OSD 0x8a*/{NULL},
/*OSD 0x8b*/{NULL},
/*OSD 0x8c*/{NULL},
/*OSD 0x8d*/{NULL},
/*OSD 0x8e*/{NULL},
/*OSD 0x8f*/{NULL},
/*OSD 0x90*/{NULL},
/*OSD 0x91*/{NULL},
/*OSD 0x92*/{NULL},
/*OSD 0x93*/{NULL},
/*OSD 0x94*/{NULL},
/*OSD 0x95*/{NULL},
/*OSD 0x96*/{NULL},
/*OSD 0x97*/{NULL},
/*OSD 0x98*/{NULL},
/*OSD 0x99*/{NULL},
/*OSD 0x9a*/{NULL},
/*OSD 0x9b*/{NULL},
/*OSD 0x9c*/{NULL},
/*OSD 0x9d*/{NULL},
/*OSD 0x9e*/{NULL},
/*OSD 0x9f*/{NULL},
/*OSD 0xa0*/{dissect_spc_reportluns},
/*OSD 0xa1*/{NULL},
/*OSD 0xa2*/{NULL},
/*SPC 0xa3*/{dissect_spc_mgmt_protocol_in},
/*OSD 0xa4*/{NULL},
/*OSD 0xa5*/{NULL},
/*OSD 0xa6*/{NULL},
/*OSD 0xa7*/{NULL},
/*OSD 0xa8*/{NULL},
/*OSD 0xa9*/{NULL},
/*OSD 0xaa*/{NULL},
/*OSD 0xab*/{NULL},
/*OSD 0xac*/{NULL},
/*OSD 0xad*/{NULL},
/*OSD 0xae*/{NULL},
/*OSD 0xaf*/{NULL},
/*OSD 0xb0*/{NULL},
/*OSD 0xb1*/{NULL},
/*OSD 0xb2*/{NULL},
/*OSD 0xb3*/{NULL},
/*OSD 0xb4*/{NULL},
/*OSD 0xb5*/{NULL},
/*OSD 0xb6*/{NULL},
/*OSD 0xb7*/{NULL},
/*OSD 0xb8*/{NULL},
/*OSD 0xb9*/{NULL},
/*OSD 0xba*/{NULL},
/*OSD 0xbb*/{NULL},
/*OSD 0xbc*/{NULL},
/*OSD 0xbd*/{NULL},
/*OSD 0xbe*/{NULL},
/*OSD 0xbf*/{NULL},
/*OSD 0xc0*/{NULL},
/*OSD 0xc1*/{NULL},
/*OSD 0xc2*/{NULL},
/*OSD 0xc3*/{NULL},
/*OSD 0xc4*/{NULL},
/*OSD 0xc5*/{NULL},
/*OSD 0xc6*/{NULL},
/*OSD 0xc7*/{NULL},
/*OSD 0xc8*/{NULL},
/*OSD 0xc9*/{NULL},
/*OSD 0xca*/{NULL},
/*OSD 0xcb*/{NULL},
/*OSD 0xcc*/{NULL},
/*OSD 0xcd*/{NULL},
/*OSD 0xce*/{NULL},
/*OSD 0xcf*/{NULL},
/*OSD 0xd0*/{NULL},
/*OSD 0xd1*/{NULL},
/*OSD 0xd2*/{NULL},
/*OSD 0xd3*/{NULL},
/*OSD 0xd4*/{NULL},
/*OSD 0xd5*/{NULL},
/*OSD 0xd6*/{NULL},
/*OSD 0xd7*/{NULL},
/*OSD 0xd8*/{NULL},
/*OSD 0xd9*/{NULL},
/*OSD 0xda*/{NULL},
/*OSD 0xdb*/{NULL},
/*OSD 0xdc*/{NULL},
/*OSD 0xdd*/{NULL},
/*OSD 0xde*/{NULL},
/*OSD 0xdf*/{NULL},
/*OSD 0xe0*/{NULL},
/*OSD 0xe1*/{NULL},
/*OSD 0xe2*/{NULL},
/*OSD 0xe3*/{NULL},
/*OSD 0xe4*/{NULL},
/*OSD 0xe5*/{NULL},
/*OSD 0xe6*/{NULL},
/*OSD 0xe7*/{NULL},
/*OSD 0xe8*/{NULL},
/*OSD 0xe9*/{NULL},
/*OSD 0xea*/{NULL},
/*OSD 0xeb*/{NULL},
/*OSD 0xec*/{NULL},
/*OSD 0xed*/{NULL},
/*OSD 0xee*/{NULL},
/*OSD 0xef*/{NULL},
/*OSD 0xf0*/{NULL},
/*OSD 0xf1*/{NULL},
/*OSD 0xf2*/{NULL},
/*OSD 0xf3*/{NULL},
/*OSD 0xf4*/{NULL},
/*OSD 0xf5*/{NULL},
/*OSD 0xf6*/{NULL},
/*OSD 0xf7*/{NULL},
/*OSD 0xf8*/{NULL},
/*OSD 0xf9*/{NULL},
/*OSD 0xfa*/{NULL},
/*OSD 0xfb*/{NULL},
/*OSD 0xfc*/{NULL},
/*OSD 0xfd*/{NULL},
/*OSD 0xfe*/{NULL},
/*OSD 0xff*/{NULL}
};




void
proto_register_scsi_osd(void)
{
    expert_module_t *expert_scsi_osd;

    static hf_register_info hf[] = {
        { &hf_scsi_osd_opcode,
          {"OSD Opcode", "scsi_osd.opcode", FT_UINT8, BASE_HEX | BASE_EXT_STRING,
           &scsi_osd_vals_ext, 0x0, NULL, HFILL}},
        { &hf_scsi_osd_add_cdblen,
          {"Additional CDB Length", "scsi_osd.addcdblen", FT_UINT8, BASE_DEC,
           NULL, 0x0, NULL, HFILL}},
        { &hf_scsi_osd_svcaction,
          {"Service Action", "scsi_osd.svcaction", FT_UINT16, BASE_HEX | BASE_EXT_STRING,
           &scsi_osd_svcaction_vals_ext, 0x0, NULL, HFILL}},
        { &hf_scsi_osd_option,
          {"Options Byte", "scsi_osd.option", FT_UINT8, BASE_HEX,
           NULL, 0x0, NULL, HFILL}},
        { &hf_scsi_osd_option_dpo,
          {"DPO", "scsi_osd.option.dpo", FT_BOOLEAN, 8,
           TFS(&tfs_set_notset), 0x10, NULL, HFILL}},
        { &hf_scsi_osd_option_fua,
          {"FUA", "scsi_osd.option.fua", FT_BOOLEAN, 8,
           TFS(&tfs_set_notset), 0x08, NULL, HFILL}},
        { &hf_scsi_osd_getsetattrib,
          {"GET/SET CDBFMT", "scsi_osd.getset", FT_UINT8, BASE_HEX,
           VALS(scsi_osd_getsetattrib_vals), 0x30, NULL, HFILL}},
        { &hf_scsi_osd_timestamps_control,
          {"Timestamps Control", "scsi_osd.timestamps_control", FT_UINT8, BASE_HEX,
           VALS(scsi_osd_timestamps_control_vals), 0x0, NULL, HFILL}},
        { &hf_scsi_osd_formatted_capacity,
          {"Formatted Capacity", "scsi_osd.formatted_capacity", FT_UINT64, BASE_DEC,
           NULL, 0x0, NULL, HFILL}},
        { &hf_scsi_osd_get_attributes_page,
          {"Get Attributes Page", "scsi_osd.get_attributes_page", FT_UINT32, BASE_HEX,
           NULL, 0x0, NULL, HFILL}},
        { &hf_scsi_osd_get_attributes_list_length,
          {"Get Attributes List Length", "scsi_osd.get_attributes_list_length", FT_UINT32, BASE_DEC_HEX,
           NULL, 0x0, NULL, HFILL}},
        { &hf_scsi_osd_get_attributes_list_offset,
          {"Get Attributes List Offset", "scsi_osd.get_attributes_list_offset", FT_UINT32, BASE_HEX,
           NULL, 0x0, NULL, HFILL}},
        { &hf_scsi_osd_set_attributes_list_length,
          {"Set Attributes List Length", "scsi_osd.set_attributes_list_length", FT_UINT32, BASE_DEC_HEX,
           NULL, 0x0, NULL, HFILL}},
        { &hf_scsi_osd_set_attributes_list_offset,
          {"Set Attributes List Offset", "scsi_osd.set_attributes_list_offset", FT_UINT32, BASE_HEX,
           NULL, 0x0, NULL, HFILL}},
        { &hf_scsi_osd_get_attributes_allocation_length,
          {"Get Attributes Allocation Length", "scsi_osd.get_attributes_allocation_length", FT_UINT32, BASE_DEC_HEX,
           NULL, 0x0, NULL, HFILL}},
        { &hf_scsi_osd_retrieved_attributes_offset,
          {"Retrieved Attributes Offset", "scsi_osd.retrieved_attributes_offset", FT_UINT32, BASE_HEX,
           NULL, 0x0, NULL, HFILL}},
        { &hf_scsi_osd_set_attributes_page,
          {"Set Attributes Page", "scsi_osd.set_attributes_page", FT_UINT32, BASE_HEX,
           NULL, 0x0, NULL, HFILL}},
        { &hf_scsi_osd_set_attribute_length,
          {"Set Attribute Length", "scsi_osd.set_attribute_length", FT_UINT32, BASE_DEC_HEX,
           NULL, 0x0, NULL, HFILL}},
        { &hf_scsi_osd_set_attribute_number,
          {"Set Attribute Number", "scsi_osd.set_attribute_number", FT_UINT32, BASE_HEX,
           NULL, 0x0, NULL, HFILL}},
        { &hf_scsi_osd_set_attributes_offset,
          {"Set Attributes Offset", "scsi_osd.set_attributes_offset", FT_UINT32, BASE_HEX,
           NULL, 0x0, NULL, HFILL}},
        { &hf_scsi_osd_capability_format,
          {"Capability Format", "scsi_osd.capability_format", FT_UINT8, BASE_HEX,
           VALS(scsi_osd_capability_format_vals), 0x0f, NULL, HFILL}},
        { &hf_scsi_osd_key_version,
          {"Key Version", "scsi_osd.key_version", FT_UINT8, BASE_HEX,
           NULL, 0xf0, NULL, HFILL}},
        { &hf_scsi_osd_icva,
          {"Integrity Check Value Algorithm", "scsi_osd.icva", FT_UINT8, BASE_HEX,
           NULL, 0x0f, NULL, HFILL}},
        { &hf_scsi_osd_security_method,
          {"Security Method", "scsi_osd.security_method", FT_UINT8, BASE_HEX,
           NULL, 0x0f, NULL, HFILL}},
        { &hf_scsi_osd_capability_expiration_time,
          {"Capability Expiration Time", "scsi_osd.capability_expiration_time", FT_BYTES, BASE_NONE,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_audit,
          {"Audit", "scsi_osd.audit", FT_BYTES, BASE_NONE,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_capability_discriminator,
          {"Capability Discriminator", "scsi_osd.capability_discriminator", FT_BYTES, BASE_NONE,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_object_created_time,
          {"Object Created Time", "scsi_osd.object_created_time", FT_BYTES, BASE_NONE,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_object_type,
          {"Object Type", "scsi_osd.object_type", FT_UINT8, BASE_HEX,
           VALS(scsi_osd_object_type_vals), 0, NULL, HFILL}},
        { &hf_scsi_osd_permissions,
          {"Permissions", "scsi_osd.permissions", FT_UINT16, BASE_HEX,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_permissions_read,
          {"READ", "scsi_osd.permissions.read", FT_BOOLEAN, 16,
           TFS(&tfs_set_notset), 0x8000, NULL, HFILL}},
        { &hf_scsi_osd_permissions_write,
          {"WRITE", "scsi_osd.permissions.write", FT_BOOLEAN, 16,
           TFS(&tfs_set_notset), 0x4000, NULL, HFILL}},
        { &hf_scsi_osd_permissions_get_attr,
          {"GET_ATTR", "scsi_osd.permissions.get_attr", FT_BOOLEAN, 16,
           TFS(&tfs_set_notset), 0x2000, NULL, HFILL}},
        { &hf_scsi_osd_permissions_set_attr,
          {"SET_ATTR", "scsi_osd.permissions.set_attr", FT_BOOLEAN, 16,
           TFS(&tfs_set_notset), 0x1000, NULL, HFILL}},
        { &hf_scsi_osd_permissions_create,
          {"CREATE", "scsi_osd.permissions.create", FT_BOOLEAN, 16,
           TFS(&tfs_set_notset), 0x0800, NULL, HFILL}},
        { &hf_scsi_osd_permissions_remove,
          {"REMOVE", "scsi_osd.permissions.remove", FT_BOOLEAN, 16,
           TFS(&tfs_set_notset), 0x0400, NULL, HFILL}},
        { &hf_scsi_osd_permissions_obj_mgmt,
          {"OBJ_MGMT", "scsi_osd.permissions.obj_mgmt", FT_BOOLEAN, 16,
           TFS(&tfs_set_notset), 0x0200, NULL, HFILL}},
        { &hf_scsi_osd_permissions_append,
          {"APPEND", "scsi_osd.permissions.append", FT_BOOLEAN, 16,
           TFS(&tfs_set_notset), 0x0100, NULL, HFILL}},
        { &hf_scsi_osd_permissions_dev_mgmt,
          {"DEV_MGMT", "scsi_osd.permissions.dev_mgmt", FT_BOOLEAN, 16,
           TFS(&tfs_set_notset), 0x0080, NULL, HFILL}},
        { &hf_scsi_osd_permissions_global,
          {"GLOBAL", "scsi_osd.permissions.global", FT_BOOLEAN, 16,
           TFS(&tfs_set_notset), 0x0040, NULL, HFILL}},
        { &hf_scsi_osd_permissions_pol_sec,
          {"POL/SEC", "scsi_osd.permissions.pol_sec", FT_BOOLEAN, 16,
           TFS(&tfs_set_notset), 0x0020, NULL, HFILL}},

        { &hf_scsi_osd_object_descriptor_type,
          {"Object Descriptor Type", "scsi_osd.object_descriptor_type", FT_UINT8, BASE_HEX,
           VALS(scsi_osd_object_descriptor_type_vals), 0xf0, NULL, HFILL}},
        { &hf_scsi_osd_object_descriptor,
          {"Object Descriptor", "scsi_osd.object_descriptor", FT_BYTES, BASE_NONE,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_ricv,
          {"Request Integrity Check value", "scsi_osd.ricv", FT_BYTES, BASE_NONE,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_request_nonce,
          {"Request Nonce", "scsi_osd.request_nonce", FT_BYTES, BASE_NONE,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_diicvo,
          {"Data-In Integrity Check Value Offset", "scsi_osd.diicvo", FT_UINT32, BASE_DEC,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_doicvo,
          {"Data-Out Integrity Check Value Offset", "scsi_osd.doicvo", FT_UINT32, BASE_DEC,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_requested_partition_id,
          {"Requested Partition Id", "scsi_osd.requested_partition_id", FT_UINT64, BASE_HEX,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_sortorder,
          {"Sort Order", "scsi_osd.sort_order", FT_UINT8, BASE_DEC,
           VALS(scsi_osd_sort_order_vals), 0x0f, NULL, HFILL}},
        { &hf_scsi_osd_partition_id,
          {"Partition Id", "scsi_osd.partition_id", FT_UINT64, BASE_HEX,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_list_identifier,
          {"List Identifier", "scsi_osd.list_identifier", FT_UINT32, BASE_DEC,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_allocation_length,
          {"Allocation Length", "scsi_osd.allocation_length", FT_UINT64, BASE_DEC,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_length,
          {"Length", "scsi_osd.length", FT_UINT64, BASE_DEC,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_starting_byte_address,
          {"Starting Byte Address", "scsi_osd.starting_byte_address", FT_UINT64, BASE_DEC,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_initial_object_id,
          {"Initial Object Id", "scsi_osd.initial_object_id", FT_BYTES, BASE_NONE,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_additional_length,
          {"Additional Length", "scsi_osd.additional_length", FT_UINT64, BASE_DEC,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_continuation_object_id,
          {"Continuation Object Id", "scsi_osd.continuation_object_id", FT_BYTES, BASE_NONE,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_user_object_id,
          {"User Object Id", "scsi_osd.user_object_id", FT_BYTES, BASE_NONE,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_list_flags_lstchg,
          {"LSTCHG", "scsi_osd.list.lstchg", FT_BOOLEAN, 8,
           TFS(&list_lstchg_tfs), 0x02, NULL, HFILL}},
        { &hf_scsi_osd_list_flags_root,
          {"ROOT", "scsi_osd.list.root", FT_BOOLEAN, 8,
           TFS(&list_root_tfs), 0x01, NULL, HFILL}},
        { &hf_scsi_osd_list_collection_flags_coltn,
          {"COLTN", "scsi_osd.list_collection.coltn", FT_BOOLEAN, 8,
           TFS(&list_coltn_tfs), 0x01, NULL, HFILL}},
        { &hf_scsi_osd_requested_user_object_id,
          {"Requested User Object Id", "scsi_osd.requested_user_object_id", FT_BYTES, BASE_NONE,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_number_of_user_objects,
          {"Number Of User Objects", "scsi_osd.number_of_user_objects", FT_UINT16, BASE_DEC,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_key_to_set,
          {"Key to Set", "scsi_osd.key_to_set", FT_UINT8, BASE_DEC,
           VALS(key_to_set_vals), 0x03, NULL, HFILL}},
        { &hf_scsi_osd_set_key_version,
          {"Key Version", "scsi_osd.set_key_version", FT_UINT8, BASE_DEC,
           NULL, 0x0f, NULL, HFILL}},
        { &hf_scsi_osd_key_identifier,
          {"Key Identifier", "scsi_osd.key_identifier", FT_BYTES, BASE_NONE,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_seed,
          {"Seed", "scsi_osd.seed", FT_BYTES, BASE_NONE,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_collection_fcr,
          {"FCR", "scsi_osd.collection.fcr", FT_BOOLEAN, 8,
           TFS(&tfs_set_notset), 0x01, NULL, HFILL}},
        { &hf_scsi_osd_collection_object_id,
          {"Collection Object Id", "scsi_osd.collection_object_id", FT_BYTES, BASE_NONE,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_requested_collection_object_id,
          {"Requested Collection Object Id", "scsi_osd.requested_collection_object_id", FT_BYTES, BASE_NONE,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_partition_created_in,
          { "Created In", "scsi_osd.partition.created_in", FT_FRAMENUM, BASE_NONE,
          NULL, 0x0, "The frame this partition was created", HFILL }},

        { &hf_scsi_osd_partition_removed_in,
          { "Removed In", "scsi_osd.partition.removed_in", FT_FRAMENUM, BASE_NONE,
          NULL, 0x0, "The frame this partition was removed", HFILL }},

        { &hf_scsi_osd_flush_scope,
          {"Flush Scope", "scsi_osd.flush.scope", FT_UINT8, BASE_DEC,
           VALS(flush_scope_vals), 0x03, NULL, HFILL}},

        { &hf_scsi_osd_flush_collection_scope,
          {"Flush Collection Scope", "scsi_osd.flush_collection.scope", FT_UINT8, BASE_DEC,
           VALS(flush_collection_scope_vals), 0x03, NULL, HFILL}},

        { &hf_scsi_osd_flush_partition_scope,
          {"Flush Partition Scope", "scsi_osd.flush_partition.scope", FT_UINT8, BASE_DEC,
           VALS(flush_partition_scope_vals), 0x03, NULL, HFILL}},

        { &hf_scsi_osd_flush_osd_scope,
          {"Flush OSD Scope", "scsi_osd.flush_osd.scope", FT_UINT8, BASE_DEC,
           VALS(flush_osd_scope_vals), 0x03, NULL, HFILL}},
        { &hf_scsi_osd_attributes_list_type,
          {"Attributes List Type", "scsi_osd.attributes_list.type", FT_UINT8, BASE_HEX,
           VALS(attributes_list_type_vals), 0x0f, NULL, HFILL}},
        { &hf_scsi_osd_attributes_list_length,
          {"Attributes List Length", "scsi_osd.attributes_list.length", FT_UINT16, BASE_DEC,
           NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_attributes_page,
          {"Attributes Page", "scsi_osd.attributes.page", FT_UINT32, BASE_HEX | BASE_EXT_STRING,
          &attributes_page_vals_ext, 0, NULL, HFILL}},
        { &hf_scsi_osd_attribute_number,
          {"Attribute Number", "scsi_osd.attribute.number", FT_UINT32, BASE_HEX,
          NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_attribute_length,
          {"Attribute Length", "scsi_osd.attribute.length", FT_UINT16, BASE_DEC,
          NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd2_attributes_list_length,
         {"Attributes List Length", "scsi_osd2.attributes_list.length", FT_UINT32, BASE_DEC,
          NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_attrval_user_object_logical_length,
         {"User Object Logical Length", "scsi_osd.user_object.logical_length", FT_UINT64, BASE_DEC,
          NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_attrval_object_type,
         {"Object Type", "scsi_osd.attr.object_type",  FT_UINT8, BASE_HEX, VALS(scsi_osd_object_type_vals), 0, NULL, HFILL}},
        { &hf_scsi_osd_attrval_partition_id,
         {"Partition ID", "scsi_osd.attr.partition_id", FT_UINT64, BASE_HEX,
          NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd_attrval_object_id,
         {"Object ID", "scsi_osd.attr.object_id", FT_UINT64, BASE_HEX,
          NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd2_set_attribute_value,
         {"Set Attributes Value", "scsi_osd.set_attribute_value", FT_BYTES, BASE_NONE, 0, 0, NULL, HFILL}},
        { &hf_scsi_osd2_isolation,
         {"Isolation", "scsi_osd2.isolation", FT_UINT8, BASE_HEX, VALS(scsi_osd2_isolation_val), 0x0F, NULL, HFILL}},
        { &hf_scsi_osd2_list_attr,
         {"LIST ATTR flag", "scsi_osd2.list_attr", FT_BOOLEAN, 8, 0, 0x40, NULL, HFILL}},
        { &hf_scsi_osd2_object_descriptor_format,
         {"Object Descriptor Format", "scsi_osd2.object_descriptor_format", FT_UINT8, BASE_HEX, VALS(scsi_osd2_object_descriptor_format_val), 0xFC, NULL, HFILL}},
        { &hf_scsi_osd2_immed_tr,
         {"Immed TR", "scsi_osd2.immed_tr", FT_UINT8, BASE_DEC, 0, 0x80, NULL, HFILL}},
        { &hf_scsi_osd2_remove_scope,
        {"Remove scope", "scsi_osd2.remove_scope", FT_UINT8, BASE_HEX, VALS(scsi_osd2_remove_scope), 0x07, NULL, HFILL}},
        { &hf_scsi_osd2_source_collection_object_id,
         {"Source Collection Object ID", "scsi_osd2.source_collection_object_id", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd2_matches_collection_object_id,
         {"Matches Collection Object ID", "scsi_osd2.matches_collection_object_id", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd2_cdb_continuation_length,
         {"CDB Continuation Length", "scsi_osd2.cdb_continuation.length", FT_UINT32, BASE_DEC, 0, 0, NULL, HFILL}},
        { &hf_scsi_osd2_cdb_continuation_format,
         {"CDB Continuation Format", "scsi_osd2.cdb_continuation.format", FT_UINT8, BASE_HEX, VALS(scsi_osd2_cdb_continuation_format_val), 0, NULL, HFILL}},
        { &hf_scsi_osd2_continued_service_action,
         {"Continued Service Action", "scsi_osd2.cdb_continuation.sa", FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd2_cdb_continuation_descriptor_type,
         {"Descriptor Type", "scsi_osd2.cdb_continuation.desc.type", FT_UINT16, BASE_HEX, VALS(scsi_osd2_cdb_continuation_descriptor_type_val), 0, NULL, HFILL}},
        { &hf_scsi_osd2_cdb_continuation_descriptor_pad_length,
         {"Descriptor Pad Length", "scsi_osd2.cdb_continuation.desc.padlen", FT_UINT8, BASE_DEC, NULL, 0x7, NULL, HFILL}},
        { &hf_scsi_osd2_cdb_continuation_descriptor_length,
         {"Descriptor Length", "scsi_osd2.cdb_continuation.desc.length", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd2_query_type,
         {"Query Type", "scsi_osd2.query.type", FT_UINT8, BASE_HEX, VALS(scsi_osd2_query_type_vals), 0x0f, NULL, HFILL}},
        { &hf_scsi_osd2_query_entry_length,
         {"Entry Length", "scsi_osd2.query.entry.length", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd2_query_attributes_page,
         {"Attributes Page", "scsi_osd2.query.entry.page", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &attributes_page_vals_ext, 0, NULL, HFILL}},
        { &hf_scsi_osd2_query_attribute_number,
         {"Attribute Number", "scsi_osd2.query.entry.number", FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd2_query_minimum_attribute_value_length,
         {"Minimum Attribute Value Length", "scsi_osd2.query.entry.min_length", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL}},
        { &hf_scsi_osd2_query_maximum_attribute_value_length,
         {"Maximum Attribute Value Length", "scsi_osd2.query.entry.max_length", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL}},
    };

    /* Setup protocol subtree array */
    static gint *ett[] = {
        &ett_osd_option,
        &ett_osd_partition,
        &ett_osd_attribute_parameters,
        &ett_osd_capability,
        &ett_osd_permission_bitmask,
        &ett_osd_security_parameters,
        &ett_osd_get_attributes,
        &ett_osd_set_attributes,
        &ett_osd_multi_object,
        &ett_osd_attribute,
        &ett_osd2_query_criteria_entry,
    };

    /* Setup expert info */
    static ei_register_info ei[] = {
        { &ei_osd_attr_unknown,    { "scsi_osd.attr_unknown",    PI_UNDECODED, PI_NOTE,  "Unknown attribute, cannot decode attribute value", EXPFILL }},
        { &ei_osd2_invalid_offset, { "scsi_osd2.invalid_offset", PI_UNDECODED, PI_ERROR, "Invalid offset exponent", EXPFILL }},
        { &ei_osd2_invalid_object_descriptor_format, { "scsi_osd2.object_descriptor_format.invalid", PI_UNDECODED, PI_ERROR, "Invalid list format", EXPFILL }},
        { &ei_osd_unknown_attributes_list_type, { "scsi_osd.attributes_list.type.invalid", PI_UNDECODED, PI_ERROR, "Unknown attribute list type", EXPFILL }},
        { &ei_osd2_cdb_continuation_format_unknown, { "scsi_osd2.cdb_continuation.format.unknown", PI_UNDECODED, PI_ERROR, "Unknown CDB Continuation Format", EXPFILL }},
        { &ei_osd2_continued_service_action_mismatch, { "scsi_osd2.cdb_continuation.sa.mismatch", PI_PROTOCOL, PI_WARN, "CONTINUED SERVICE ACTION and SERVICE ACTION do not match", EXPFILL }},
        { &ei_osd2_cdb_continuation_descriptor_type_unknown, { "scsi_osd2.cdb_continuation.desc.type.unknown", PI_UNDECODED, PI_WARN, "Unknown descriptor type", EXPFILL }},
        { &ei_osd2_cdb_continuation_descriptor_length_invalid, { "scsi_osd2.cdb_continuation.desc.length.invalid", PI_PROTOCOL, PI_ERROR, "Invalid descriptor length (not a multiple of 8)", EXPFILL }},
        { &ei_osd2_cdb_continuation_length_invalid, { "scsi_osd2.cdb_continuation.length.invalid", PI_PROTOCOL, PI_ERROR, "Invalid CDB continuation length", EXPFILL }},
        { &ei_osd_attr_length_invalid, { "scsi_osd.attribute_length.invalid", PI_PROTOCOL, PI_ERROR, "Invalid Attribute Length", EXPFILL }},
        { &ei_osd2_query_values_equal, { "scsi_osd2.query.entry.equal", PI_PROTOCOL, PI_NOTE, "The minimum and maximum values are equal", EXPFILL }},
    };

    /* Register the protocol name and description */
    proto_scsi_osd = proto_register_protocol("SCSI_OSD", "SCSI_OSD", "scsi_osd");

    /* Required function calls to register the header fields and subtrees used */
    proto_register_field_array(proto_scsi_osd, hf, array_length(hf));
    proto_register_subtree_array(ett, array_length(ett));

    /* Register expert info */
    expert_scsi_osd = expert_register_protocol(proto_scsi_osd);
    expert_register_field_array(expert_scsi_osd, ei, array_length(ei));
}

/*
 * Editor modelines
 *
 * Local Variables:
 * c-basic-offset: 4
 * tab-width: 8
 * indent-tabs-mode: nil
 * End:
 *
 * ex: set shiftwidth=4 tabstop=8 expandtab:
 * :indentSize=4:tabSize=8:noTabs=true:
 */