View Javadoc

1   package org.jscsi.target.scsi.cdb;
2   
3   
4   import java.nio.ByteBuffer;
5   
6   import org.jscsi.target.util.BitManip;
7   
8   
9   /**
10   * This class represents Command Descriptor Blocks for the <code>REQUEST SENSE</code> SCSI command, which requests that
11   * the device server transfers sense data to the application client.
12   * 
13   * @author Andreas Ergenzinger
14   */
15  public final class RequestSenseCdb extends CommandDescriptorBlock {
16  
17      /**
18       * The descriptor format (DESC) bit specifies which sense data format shall be returned. If DESC is set to zero,
19       * fixed format sense data shall be returned. If DESC is set to one and descriptor format sense data is supported,
20       * descriptor format sense data shall be returned.
21       */
22      private final boolean descriptorFormat;
23  
24      /**
25       * The ALLOCATION LENGTH field specifies the maximum number of bytes that an application client has allocated in the
26       * Data-In Buffer.
27       */
28      private final int allocationLength;
29  
30      public RequestSenseCdb (ByteBuffer buffer) {
31          super(buffer);
32  
33          // descriptor format
34          descriptorFormat = BitManip.getBit(buffer.get(1), 0);
35  
36          // allocation length
37          allocationLength = buffer.get(4) & 255;
38      }
39  
40      public final boolean getDescriptorFormat () {
41          return descriptorFormat;
42      }
43  
44      public final int getAllocationLength () {
45          return allocationLength;
46      }
47  }