1 package org.jscsi.target.scsi.lun;
2
3
4 import java.nio.ByteBuffer;
5
6 import org.jscsi.target.scsi.IResponseData;
7 import org.jscsi.target.util.ReadWrite;
8
9
10
11
12
13
14
15
16
17
18 public final class ReportLunsParameterData implements IResponseData {
19
20
21
22
23 private static final int HEADER_LENGTH = 8;
24
25
26
27
28 private int lunListLength = 0;
29
30
31
32
33 private LogicalUnitNumber[] luns;
34
35
36
37
38
39
40 public ReportLunsParameterData (LogicalUnitNumber... luns) {
41 this.luns = luns;
42 if (luns != null) lunListLength = LogicalUnitNumber.SIZE * luns.length;
43 }
44
45 public void serialize (ByteBuffer byteBuffer, int index) {
46
47
48 ReadWrite.writeInt(lunListLength, byteBuffer, index);
49
50
51 int lunIndex = index + HEADER_LENGTH;
52 for (int i = 0; i < luns.length; ++i) {
53 luns[i].serialize(byteBuffer, lunIndex);
54 lunIndex += luns[i].size();
55 }
56 }
57
58 public int size () {
59 return HEADER_LENGTH + lunListLength;
60 }
61 }