Package org.jscsi.parser.datasegment

Examples of org.jscsi.parser.datasegment.IDataSegmentIterator


        final int maxRecvDataSegmentLength = connection.getSettingAsInt(OperationalTextKey.MAX_RECV_DATA_SEGMENT_LENGTH);
        scsi.setCommandDescriptorBlock(SCSICommandDescriptorBlockParser.createWriteMessage(logicalBlockAddress, transferLength));

        final IDataSegment dataSegment = DataSegmentFactory.create(buffer, bufferPosition, expectedDataTransferLength, DataSegmentFormat.BINARY, maxRecvDataSegmentLength);
        final IDataSegmentIterator iterator = dataSegment.iterator();
        int bufferOffset = 0;

        if (connection.getSettingAsBoolean(OperationalTextKey.IMMEDIATE_DATA)) {
            final int min = Math.min(maxRecvDataSegmentLength, connection.getSettingAsInt(OperationalTextKey.FIRST_BURST_LENGTH));
            protocolDataUnit.setDataSegment(iterator.next(min));
            bufferOffset += min;
        }

        connection.send(protocolDataUnit);

        if (!connection.getSettingAsBoolean(OperationalTextKey.INITIAL_R2T) && iterator.hasNext()) {
            connection.nextState(new WriteFirstBurstState(connection, iterator, 0xFFFFFFFF, 0, bufferOffset));
        } else {
            connection.nextState(new WriteSecondResponseState(connection, iterator, 0, bufferOffset));
        }
        super.stateFollowing = true;
View Full Code Here


        LoginRequestParser loginRequest;
        boolean continueFlag;
        // here the finalFlag represents the transitFlag
        boolean finalFlag;
        final IDataSegment dataSegment = DataSegmentFactory.create(loginParameters.asByteBuffer(), DataSegmentFormat.TEXT, maxRecvDataSegmentLength);
        final IDataSegmentIterator iterator = dataSegment.iterator();
        final Queue<ProtocolDataUnit> protocolDataUnits = new LinkedList<ProtocolDataUnit>();

        IDataSegmentChunk dataSegmentChunk;
        ProtocolDataUnit protocolDataUnit;
        int bytes2Transfer = dataSegment.getLength();

        while (bytes2Transfer > 0 && iterator.hasNext()) {

            if (bytes2Transfer <= maxRecvDataSegmentLength) {
                // last PDU to send...
                dataSegmentChunk = iterator.next(bytes2Transfer);
                continueFlag = false;
            } else {
                dataSegmentChunk = iterator.next(maxRecvDataSegmentLength);
                continueFlag = true;
            }

            finalFlag = !continueFlag;
            protocolDataUnit = protocolDataUnitFactory.create(true, finalFlag, OperationCode.LOGIN_REQUEST, "None", "None");
View Full Code Here

TOP

Related Classes of org.jscsi.parser.datasegment.IDataSegmentIterator

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.