| 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 | 0 | private int lunListLength = 0; |
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
private LogicalUnitNumber[] luns; |
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | 0 | public ReportLunsParameterData (LogicalUnitNumber... luns) { |
| 41 | 0 | this.luns = luns; |
| 42 | 0 | if (luns != null) lunListLength = LogicalUnitNumber.SIZE * luns.length; |
| 43 | 0 | } |
| 44 | |
|
| 45 | |
public void serialize (ByteBuffer byteBuffer, int index) { |
| 46 | |
|
| 47 | |
|
| 48 | 0 | ReadWrite.writeInt(lunListLength, byteBuffer, index); |
| 49 | |
|
| 50 | |
|
| 51 | 0 | int lunIndex = index + HEADER_LENGTH; |
| 52 | 0 | for (int i = 0; i < luns.length; ++i) { |
| 53 | 0 | luns[i].serialize(byteBuffer, lunIndex); |
| 54 | 0 | lunIndex += luns[i].size(); |
| 55 | |
} |
| 56 | 0 | } |
| 57 | |
|
| 58 | |
public int size () { |
| 59 | 0 | return HEADER_LENGTH + lunListLength; |
| 60 | |
} |
| 61 | |
} |