| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ReportLunsCDB |
|
| 1.6666666666666667;1.667 |
| 1 | package org.jscsi.target.scsi.cdb; | |
| 2 | ||
| 3 | ||
| 4 | import java.nio.ByteBuffer; | |
| 5 | ||
| 6 | import org.jscsi.target.util.ReadWrite; | |
| 7 | ||
| 8 | ||
| 9 | /** | |
| 10 | * This class represents Command Descriptor Blocks for the <code>REPORT LUNS</code> SCSI command. | |
| 11 | * | |
| 12 | * @author Andreas Ergenzinger | |
| 13 | */ | |
| 14 | public class ReportLunsCDB extends CommandDescriptorBlock { | |
| 15 | ||
| 16 | /** | |
| 17 | * The SELECT REPORT field specifies the types of logical unit addresses that shall be reported. | |
| 18 | * | |
| 19 | * @see SelectReport | |
| 20 | */ | |
| 21 | private final SelectReport selectReport; | |
| 22 | ||
| 23 | /** | |
| 24 | * The ALLOCATION LENGTH field specifies the maximum number of bytes that an application client has allocated in the | |
| 25 | * Data-In Buffer. An allocation length of zero specifies that no data shall be transferred. This condition shall | |
| 26 | * not be considered as an error. The device server shall terminate transfers to the Data-In Buffer when the number | |
| 27 | * of bytes specified by the ALLOCATION LENGTH field have been transferred or when all available data have been | |
| 28 | * transferred, whichever is less. | |
| 29 | * <p> | |
| 30 | * The allocation length is used to limit the maximum amount of variable length data (e.g., mode data, log data, | |
| 31 | * diagnostic data) returned to an application client. If the information being transferred to the Data-In Buffer | |
| 32 | * includes fields containing counts of the number of bytes in some or all of the data, then the contents of these | |
| 33 | * fields shall not be altered to reflect the truncation, if any, that results from an insufficient ALLOCATION | |
| 34 | * LENGTH value, unless the standard that describes the Data-In Buffer format states otherwise. | |
| 35 | * <p> | |
| 36 | * If the amount of information to be transferred exceeds the maximum value that the ALLOCATION LENGTH field is | |
| 37 | * capable of specifying, the device server shall transfer no data and terminate the command with CHECK CONDITION | |
| 38 | * status, with the sense key set to ILLEGAL REQUEST, and the additional sense code set to INVALID FIELD IN CDB. | |
| 39 | * <p> | |
| 40 | * If EVPD is set to zero, the allocation length should be at least five, so that the ADDITIONAL LENGTH field in the | |
| 41 | * parameter data is returned. If EVPD is set to one, the allocation length should be should be at least four, so | |
| 42 | * that the PAGE LENGTH field in the parameter data is returned. | |
| 43 | */ | |
| 44 | private final int allocationLength; | |
| 45 | ||
| 46 | public ReportLunsCDB (ByteBuffer buffer) { | |
| 47 | 0 | super(buffer); |
| 48 | ||
| 49 | // select report | |
| 50 | 0 | selectReport = SelectReport.getValue(buffer.get(2)); |
| 51 | 0 | if (selectReport == null) addIllegalFieldPointer(2);// reserved select report value |
| 52 | ||
| 53 | // allocation length | |
| 54 | 0 | allocationLength = ReadWrite.readFourByteInt(buffer, 6); |
| 55 | 0 | if (allocationLength < 16) addIllegalFieldPointer(6);// The allocation length should be at |
| 56 | // least 16. | |
| 57 | 0 | } |
| 58 | ||
| 59 | public final int getAllocationLength () { | |
| 60 | 0 | return allocationLength; |
| 61 | } | |
| 62 | ||
| 63 | public final SelectReport getSelectReport () { | |
| 64 | 0 | return selectReport; |
| 65 | } | |
| 66 | } |