Coverage Report - org.jscsi.target.scsi.cdb.ModeSense6Cdb
 
Classes in this File Line Coverage Branch Coverage Complexity
ModeSense6Cdb
0%
0/14
N/A
1
 
 1  
 package org.jscsi.target.scsi.cdb;
 2  
 
 3  
 
 4  
 import java.nio.ByteBuffer;
 5  
 
 6  
 import org.jscsi.target.scsi.modeSense.ModePageCode;
 7  
 import org.jscsi.target.scsi.modeSense.PageControl;
 8  
 import org.jscsi.target.util.BitManip;
 9  
 import org.jscsi.target.util.ReadWrite;
 10  
 
 11  
 
 12  
 /**
 13  
  * This class represents Command Descriptor Blocks for the <code>MODE SENSE (6)</code> SCSI command.
 14  
  * 
 15  
  * @author Andreas Ergenzinger
 16  
  */
 17  
 public final class ModeSense6Cdb extends CommandDescriptorBlock {
 18  
 
 19  
     /**
 20  
      * A disable block descriptors (DBD) bit set to zero specifies that the device server may return zero or more block
 21  
      * descriptors in the returned MODE SENSE data (see 7.4). A DBD bit set to one specifies that the device server
 22  
      * shall not return any block descriptors in the returned MODE SENSE data.
 23  
      */
 24  
     private final boolean disableBlockDescriptors;
 25  
 
 26  
     /**
 27  
      * The page control (PC) field specifies the type of mode parameter values to be returned in the mode pages.
 28  
      */
 29  
     private final PageControl pageControl;
 30  
 
 31  
     /**
 32  
      * The PAGE CODE and SUBPAGE CODE fields specify which mode pages and subpages to return.
 33  
      * 
 34  
      * @see #subpageCode
 35  
      */
 36  
     private final int pageCode;
 37  
 
 38  
     /**
 39  
      * The PAGE CODE and SUBPAGE CODE fields specify which mode pages and subpages to return
 40  
      * 
 41  
      * @see #pageCode
 42  
      */
 43  
     private final int subpageCode;
 44  
 
 45  
     /**
 46  
      * The ALLOCATION LENGTH field specifies the maximum number of bytes that an application client has allocated in the
 47  
      * Data-In Buffer. An allocation length of zero specifies that no data shall be transferred.
 48  
      */
 49  
     private final int allocationLength;
 50  
 
 51  
     public ModeSense6Cdb (ByteBuffer buffer) {
 52  0
         super(buffer);// SCSI Operation Code + Control
 53  
 
 54  
         // DBD
 55  0
         disableBlockDescriptors = BitManip.getBit(buffer.get(1),// byte
 56  
                 3);// bit number
 57  
 
 58  
         // PC
 59  0
         int i = (buffer.get(2) >> 6) & 3;
 60  0
         pageControl = PageControl.getPageControl(i);
 61  
 
 62  
         // PAGE CODE
 63  0
         pageCode = buffer.get(2) & 63;
 64  
 
 65  
         // SUBPAGE CODE
 66  0
         subpageCode = ReadWrite.readOneByteInt(buffer, 3);
 67  
 
 68  
         // ALLOCATION LENGTH
 69  0
         allocationLength = ReadWrite.readOneByteInt(buffer, 4);
 70  0
     }
 71  
 
 72  
     public boolean getDisableBlockDescriptors () {
 73  0
         return disableBlockDescriptors;
 74  
     }
 75  
 
 76  
     public PageControl getPageControl () {
 77  0
         return pageControl;
 78  
     }
 79  
 
 80  
     public int getPageCode () {
 81  0
         return pageCode;
 82  
     }
 83  
 
 84  
     public int getSubpageCode () {
 85  0
         return subpageCode;
 86  
     }
 87  
 
 88  
     public int getAllocationLength () {
 89  0
         return allocationLength;
 90  
     }
 91  
 
 92  
     public ModePageCode getModePage () {
 93  0
         return ModePageCode.getModePage(pageCode, subpageCode);
 94  
     }
 95  
 }