Package org.jscsi.parser.data

Examples of org.jscsi.parser.data.DataInParser


        do {
            protocolDataUnit = connection.receive();
            boolean dataWasRead = false;
            if (protocolDataUnit.getBasicHeaderSegment().getParser() instanceof DataInParser) {
                final DataInParser parser = (DataInParser) protocolDataUnit.getBasicHeaderSegment().getParser();

                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("Remaining, DataSegmentLength: " + buffer.remaining() + ", " + protocolDataUnit.getBasicHeaderSegment().getDataSegmentLength());
                }

                final ByteBuffer dataSegment = protocolDataUnit.getDataSegment();
                while (buffer.hasRemaining() && dataSegment.hasRemaining()) {
                    buffer.put(dataSegment.get());
                }
                dataWasRead = true;
                // last message with the status flag set
                if (parser.isStatusFlag() && parser.getStatus() == SCSIStatus.GOOD) {
                    // return false;
                    return;
                } else if (connection.getSettingAsInt(OperationalTextKey.ERROR_RECOVERY_LEVEL) > 0 && parser.isAcknowledgeFlag()) {
                    // TODO: Test this case
                    // send a DataAck
                    connection.nextState(new SNACKRequestState(connection, this, parser.getTargetTaskTag()));
                    // return true;
                    return;
                } else if (protocolDataUnit.getBasicHeaderSegment().getParser() instanceof SCSIResponseParser && !dataWasRead) {
                    readHandleImmediateData(protocolDataUnit);
                }
View Full Code Here


        final AbstractMessageParser parser = protocolDataUnit.getBasicHeaderSegment().getParser();

        if (parser instanceof DataInParser) {

            final DataInParser dataParser = (DataInParser) parser;
            try {
                if (connection.getSettingAsBoolean(OperationalTextKey.DATA_PDU_IN_ORDER) && connection.getSettingAsBoolean(OperationalTextKey.DATA_SEQUENCE_IN_ORDER)) {
                    if (dataParser.getBufferOffset() < bufferOffset) { return new IllegalStateException(new StringBuilder("This buffer offsets must be in increasing order and overlays are forbidden.").append(" The parserOffset here is ").append(dataParser.getBufferOffset()).append(" and the bufferOffset is ").append(bufferOffset).toString()); }
                    bufferOffset = dataParser.getBufferOffset();
                }
            } catch (OperationalTextKeyException e) {
                return e;
            }

            if (dataParser.getDataSequenceNumber() != expectedDataSequenceNumber) { return new IllegalStateException(new StringBuilder("Data Sequence Number Mismatch (received, expected): " + dataParser.getDataSequenceNumber() + ", " + expectedDataSequenceNumber).toString());

            }

            incrementExpectedDataSequenceNumber();

            if (dataParser.isStatusFlag()) {
                incrementExpectedDataSequenceNumber();
                return super.isCorrect(protocolDataUnit);
            } else if (dataParser.getStatusSequenceNumber() != 0) { return new IllegalStateException(new StringBuilder("Status Sequence Number must be zero.").toString()); }
            return null;
        } else if (parser instanceof SCSIResponseParser) {
            try {
                if (connection.getSettingAsBoolean(OperationalTextKey.IMMEDIATE_DATA)) { return new IllegalStateException(new StringBuilder("Parser ").append("should not be instance of SCSIResponseParser because of ImmendiateData-Flag \"no\" in config!").toString()); }
            } catch (OperationalTextKeyException e) {
View Full Code Here

            case TEXT_RESPONSE :
                return new TextResponseParser(protocolDataUnit);
            case SCSI_DATA_OUT :
                return new DataOutParser(protocolDataUnit);
            case SCSI_DATA_IN :
                return new DataInParser(protocolDataUnit);
            case NOP_OUT :
                return new NOPOutParser(protocolDataUnit);
            case NOP_IN :
                return new NOPInParser(protocolDataUnit);
            case R2T :
View Full Code Here

            } else {
                throw new InternetSCSIException(protocolDataUnit.getBasicHeaderSegment().getParser().getClass().getSimpleName() + " is not the expected type of PDU.");
            }
        }

        /**
         * The server responded using the data-in-parser.
         */
        final DataInParser parser = (DataInParser) protocolDataUnit.getBasicHeaderSegment().getParser();

        capacityInformation.deserialize(protocolDataUnit.getDataSegment());

        if (!parser.isStatusFlag() || parser.getStatus() != SCSIStatus.GOOD) {
            // receive SCSI Response PDU and check status (no phase
            // collapse)
            final ProtocolDataUnit scsiPdu = connection.receive();
            if (scsiPdu.getBasicHeaderSegment().getOpCode() == OperationCode.SCSI_RESPONSE) {
                final SCSIResponseParser scsiParser = (SCSIResponseParser) scsiPdu.getBasicHeaderSegment().getParser();
View Full Code Here

    public static final ProtocolDataUnit createDataInPdu (boolean finalFlag, boolean acknowledgeFlag, boolean residualOverflowFlag, boolean residualUnderflowFlag, boolean statusFlag, SCSIStatus status, long logicalUnitNumber, int initiatorTaskTag, int targetTransferTag, int dataSequenceNumber,//
            int bufferOffset, int residualCount, ByteBuffer dataSegment) {
        final ProtocolDataUnit pdu = factory.create(false, finalFlag, OperationCode.SCSI_DATA_IN, "None", "None");
        final BasicHeaderSegment bhs = pdu.getBasicHeaderSegment();
        final DataInParser parser = (DataInParser) bhs.getParser();
        parser.setAcknowledgeFlag(acknowledgeFlag);
        parser.setResidualOverflowFlag(residualOverflowFlag);
        parser.setResidualUnderflowFlag(residualUnderflowFlag);
        parser.setStatusFlag(statusFlag);
        parser.setStatus(status);
        parser.setLogicalUnitNumber(logicalUnitNumber);
        bhs.setInitiatorTaskTag(initiatorTaskTag);
        parser.setTargetTransferTag(targetTransferTag);
        parser.setDataSequenceNumber(dataSequenceNumber);
        parser.setBufferOffset(bufferOffset);
        parser.setResidualCount(residualCount);
        pdu.setDataSegment(dataSegment);
        return pdu;
    }
View Full Code Here

TOP

Related Classes of org.jscsi.parser.data.DataInParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.