* @throws DigestException
*/
protected final void sendPduSequence (final String keyValuePairs, final LoginStage nextStage) throws SettingsException , InterruptedException , IOException , InternetSCSIException , DigestException {
// some variables
ProtocolDataUnit pdu;
BasicHeaderSegment bhs;
LoginRequestParser parser;
boolean continueFlag = true;
boolean transitFlag = false;
// split input string into text data segments
final ByteBuffer[] dataSegments = ReadWrite.stringToTextDataSegments(keyValuePairs,// string
settings.getMaxRecvDataSegmentLength());// bufferSize
// send all data segments (and receive confirmations)
for (int i = 0; i < dataSegments.length; ++i) {
// adjust flags
if (i == dataSegments.length - 1) {
continueFlag = false;
if (stageNumber != nextStage) transitFlag = true;
}
// create and send PDU
pdu = TargetPduFactory.createLoginResponsePdu(transitFlag,// transitFlag
continueFlag,// continueFlag
stageNumber,// currentStage
nextStage,// nextStage
session.getInitiatorSessionID(),// initiatorSessionID
session.getTargetSessionIdentifyingHandle(),// targetSessionIdentifyingHandle
initiatorTaskTag, LoginStatus.SUCCESS,// status
dataSegments[i]);// dataSegment
connection.sendPdu(pdu);
// receive confirmation
if (continueFlag) {
// receive and check
pdu = connection.receivePdu();
bhs = pdu.getBasicHeaderSegment();
parser = (LoginRequestParser) bhs.getParser();
if (!checkPdu(pdu) || parser.isContinueFlag()) {
// send login reject and leave stage
sendRejectPdu(LoginStatus.INITIATOR_ERROR);
throw new InternetSCSIException();