pdu = connection.receivePdu();
bhs = pdu.getBasicHeaderSegment();
checkDataOutParser(bhs.getParser());
final DataOutParser dataOutParser = (DataOutParser) bhs.getParser();
session.getStorageModule().write(pdu.getDataSegment().array(), storageIndex + dataOutParser.getBufferOffset());
;
bytesReceived += bhs.getDataSegmentLength();
if (bhs.isFinalFlag()) firstBurstOver = true;
}
}
// *** receive solicited data ***
if (bytesReceived < transferLengthInBytes) {
if (LOGGER.isDebugEnabled()) LOGGER.debug(bytesReceived + "<" + transferLengthInBytes);
int readyToTransferSequenceNumber = 0;
int desiredDataTransferLength;
while (bytesReceived < transferLengthInBytes) {
desiredDataTransferLength = Math.min(maxBurstLength, transferLengthInBytes - bytesReceived);
// send R2T
pdu = TargetPduFactory.createReadyToTransferPdu(0,// logicalUnitNumber
initiatorTaskTag, TargetServer.getNextTargetTransferTag(),// targetTransferTag
readyToTransferSequenceNumber++, bytesReceived,// bufferOffset
desiredDataTransferLength);
connection.sendPdu(pdu);
// receive DataOut PDUs
expectedDataSequenceNumber = 0;// reset sequence counter//FIXME
// fix in jSCSI Initiator
boolean solicitedDataCycleOver = false;
int bytesReceivedThisCycle = 0;
while (!solicitedDataCycleOver) {
// receive and check PDU
pdu = connection.receivePdu();
bhs = pdu.getBasicHeaderSegment();
checkDataOutParser(bhs.getParser());
if (bhs.getParser() instanceof NOPOutParser) {
/* send SCSI Response PDU */
pdu = TargetPduFactory.createSCSIResponsePdu(false,// bidirectionalReadResidualOverflow
false,// bidirectionalReadResidualUnderflow
false,// residualOverflow
false,// residualUnderflow
SCSIResponseParser.ServiceResponse.COMMAND_COMPLETED_AT_TARGET,// response
SCSIStatus.GOOD,// status
initiatorTaskTag, 0,// snackTag
0,// (ExpDataSN or) Reserved
0,// bidirectionalReadResidualCount
0,// residualCount
ScsiResponseDataSegment.EMPTY_DATA_SEGMENT);// dataSegment
connection.sendPdu(pdu);
return;
} else if (bhs.getParser() instanceof DataOutParser) {
final DataOutParser dataOutParser = (DataOutParser) bhs.getParser();
session.getStorageModule().write(pdu.getDataSegment().array(), storageIndex + dataOutParser.getBufferOffset());
bytesReceivedThisCycle += bhs.getDataSegmentLength();
/*
* Checking the final flag should be enough, but is not, when dealing with the jSCSI Initiator.