Coverage Report - org.jscsi.target.connection.stage.fullfeature.UnsupportedOpCodeStage
 
Classes in this File Line Coverage Branch Coverage Complexity
UnsupportedOpCodeStage
0%
0/12
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.InitiatorMessageParser;
 10  
 import org.jscsi.parser.ProtocolDataUnit;
 11  
 import org.jscsi.target.connection.phase.TargetFullFeaturePhase;
 12  
 import org.jscsi.target.scsi.cdb.ScsiOperationCode;
 13  
 import org.jscsi.target.scsi.sense.senseDataDescriptor.senseKeySpecific.FieldPointerSenseKeySpecificData;
 14  
 import org.jscsi.target.settings.SettingsException;
 15  
 
 16  
 
 17  
 /**
 18  
  * Unlike the other subclasses of {@link TargetFullFeatureStage}, this class is not associated with a single
 19  
  * {@link ScsiOperationCode}. All SCSI Command PDUs containing a SCSI OpCode not supported by the jSCSI Target (i.e.
 20  
  * without a dedicated FullFeatureStage to process them) shall be passed to the {@link #execute(ProtocolDataUnit)}
 21  
  * method of this class, which will dispatch a standard SCSI Response PDU stating that the given
 22  
  * {@link ScsiOperationCode} is not supported by this target.
 23  
  * 
 24  
  * @author Andreas Ergenzinger
 25  
  */
 26  
 public class UnsupportedOpCodeStage extends TargetFullFeatureStage {
 27  
 
 28  
     public UnsupportedOpCodeStage (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 InitiatorMessageParser parser = (InitiatorMessageParser) bhs.getParser();
 37  
 
 38  
         // the SCSI OpCode is not supported, tell the initiator
 39  
 
 40  0
         final FieldPointerSenseKeySpecificData fp = new FieldPointerSenseKeySpecificData(true,// senseKeySpecificDataValid
 41  
         true,// commandData (i.e. invalid field in CDB)
 42  
         false,// bitPointerValid
 43  
         0,// bitPointer, reserved since invalid
 44  
         0);// fieldPointer to the SCSI OpCode field
 45  
 
 46  0
         final FieldPointerSenseKeySpecificData[] fpArray = new FieldPointerSenseKeySpecificData[] { fp };
 47  
 
 48  
         // If the parser is null..
 49  0
         int essn = -1;
 50  
 
 51  0
         if (parser != null) {
 52  0
             essn = parser.getExpectedStatusSequenceNumber();
 53  
         }
 54  
 
 55  0
         final ProtocolDataUnit responsePdu = createFixedFormatErrorPdu(fpArray,// senseKeySpecificData
 56  
                 bhs.getInitiatorTaskTag(),// initiatorTaskTag
 57  
                 essn);// expectedDataTransferLength
 58  
 
 59  
         // send response
 60  0
         connection.sendPdu(responsePdu);
 61  0
     }
 62  
 
 63  
 }