Coverage Report - org.jscsi.target.connection.stage.fullfeature.TestUnitReadyStage
 
Classes in this File Line Coverage Branch Coverage Complexity
TestUnitReadyStage
0%
0/11
0%
0/2
1.5
 
 1  
 package org.jscsi.target.connection.stage.fullfeature;
 2  
 
 3  
 
 4  
 import java.io.IOException;
 5  
 import java.security.DigestException;
 6  
 
 7  
 import org.jscsi.exception.InternetSCSIException;
 8  
 import org.jscsi.parser.BasicHeaderSegment;
 9  
 import org.jscsi.parser.ProtocolDataUnit;
 10  
 import org.jscsi.parser.scsi.SCSICommandParser;
 11  
 import org.jscsi.parser.scsi.SCSIResponseParser;
 12  
 import org.jscsi.parser.scsi.SCSIStatus;
 13  
 import org.jscsi.target.connection.TargetPduFactory;
 14  
 import org.jscsi.target.connection.phase.TargetFullFeaturePhase;
 15  
 import org.jscsi.target.scsi.ScsiResponseDataSegment;
 16  
 import org.jscsi.target.scsi.cdb.TestUnitReadyCdb;
 17  
 import org.jscsi.target.scsi.sense.senseDataDescriptor.senseKeySpecific.FieldPointerSenseKeySpecificData;
 18  
 import org.jscsi.target.settings.SettingsException;
 19  
 
 20  
 
 21  
 /**
 22  
  * A stage for processing <code>TEST UNIT READY</code> SCSI commands.
 23  
  * 
 24  
  * @author Andreas Ergenzinger
 25  
  */
 26  
 public class TestUnitReadyStage extends TargetFullFeatureStage {
 27  
 
 28  
     public TestUnitReadyStage (TargetFullFeaturePhase targetFullFeaturePhase) {
 29  0
         super(targetFullFeaturePhase);
 30  0
     }
 31  
 
 32  
     @Override
 33  
     public void execute (ProtocolDataUnit pdu) throws IOException , InterruptedException , InternetSCSIException , DigestException , SettingsException {
 34  
 
 35  0
         final BasicHeaderSegment bhs = pdu.getBasicHeaderSegment();
 36  0
         final SCSICommandParser parser = (SCSICommandParser) bhs.getParser();
 37  
 
 38  
         ProtocolDataUnit responsePdu;// the response PDU
 39  
 
 40  
         // get command details in CDB
 41  0
         final TestUnitReadyCdb cdb = new TestUnitReadyCdb(parser.getCDB());
 42  0
         final FieldPointerSenseKeySpecificData[] illegalFieldPointers = cdb.getIllegalFieldPointers();
 43  
 
 44  0
         if (illegalFieldPointers != null) {
 45  
             // an illegal request has been made
 46  
 
 47  0
             responsePdu = createFixedFormatErrorPdu(illegalFieldPointers,// senseKeySpecificData,
 48  
                     bhs.getInitiatorTaskTag(),// initiatorTaskTag,
 49  
                     parser.getExpectedDataTransferLength());// expDataTransferLength
 50  
 
 51  
         } else {
 52  
             // PDU is okay
 53  
             // carry out command
 54  
             // the logical unit is always ready
 55  0
             responsePdu = TargetPduFactory.createSCSIResponsePdu(false,// bidirectionalReadResidualOverflow
 56  
                     false,// bidirectionalReadResidualUnderflow
 57  
                     false,// residualOverflow
 58  
                     false,// residualUnderflow,
 59  
                     SCSIResponseParser.ServiceResponse.COMMAND_COMPLETED_AT_TARGET,// response,
 60  
                     SCSIStatus.GOOD,// status,
 61  
                     bhs.getInitiatorTaskTag(),// initiatorTaskTag,
 62  
                     0,// snackTag
 63  
                     0,// expectedDataSequenceNumber
 64  
                     0,// bidirectionalReadResidualCount
 65  
                     0,// residualCount
 66  
                     ScsiResponseDataSegment.EMPTY_DATA_SEGMENT);// data
 67  
                                                                 // segment
 68  
         }
 69  
 
 70  
         // send response
 71  0
         connection.sendPdu(responsePdu);
 72  0
     }
 73  
 
 74  
 }