Package org.jscsi.exception

Examples of org.jscsi.exception.InternetSCSIException


            /*
             * The initiator has requested a mode sense page which the jSCSI Target cannot provide. This could be
             * answered with an Illegal field in CDB message but, there is no good way to identify the exact field at
             * fault.
             */
            throw new InternetSCSIException();
        }

    }
View Full Code Here


        if (parser.getStatus() == SCSIStatus.GOOD) {
            // return false;
            super.stateFollowing = false;
            return;
        } else {
            throw new InternetSCSIException();
        }
    }
View Full Code Here

     * @throws InternetSCSIException if an unexpected PDU has been received
     */
    private void checkDataOutParser (final AbstractMessageParser parser) throws InternetSCSIException {
        if (parser instanceof DataOutParser) {
            final DataOutParser p = (DataOutParser) parser;
            if (p.getDataSequenceNumber() != expectedDataSequenceNumber++) { throw new InternetSCSIException("received erroneous PDU in data-out sequence, expected " + (expectedDataSequenceNumber - 1)); }
        } else if (parser instanceof NOPOutParser || parser instanceof SCSICommandParser) {

        } else {
            if (parser != null) {
                throw new InternetSCSIException("received erroneous PDU in data-out sequence, " + parser.getClass().getName());
            } else {
                throw new InternetSCSIException("received erroneous PDU in data-out sequence, parser is null");
            }
        }

    }
View Full Code Here

        else if (scsiOpCode == ScsiOperationCode.WRITE_6)
            cdb = new Write6Cdb(parser.getCDB());
        else {
            // anything else wouldn't be good (programmer error)
            // close connection
            throw new InternetSCSIException("wrong SCSI Operation Code " + scsiOpCode + " in WriteStage");
        }
        final int transferLength = cdb.getTransferLength();
        final long logicalBlockAddress = cdb.getLogicalBlockAddress();

        // transform to from block units to byte units
View Full Code Here

        else if (scsiOpCode == ScsiOperationCode.READ_6)
            cdb = new Read6Cdb(parser.getCDB());
        else {
            // anything else wouldn't be good (programmer error)
            // close connection
            throw new InternetSCSIException("wrong SCSI Operation Code " + scsiOpCode + " in ReadStage");
        }

        // check if requested blocks are out of bounds
        checkOverAndUnderflow(cdb);
View Full Code Here

            final int desiredDataTransferLength = parser.getDesiredDataTransferLength();
            if (desiredDataTransferLength > connection.getSettingAsInt(OperationalTextKey.MAX_BURST_LENGTH)) {
                if (LOGGER.isErrorEnabled()) {
                    LOGGER.error("MaxBurstLength limit is exceed.");
                }
                throw new InternetSCSIException("MaxBurstLength limit is exceed.");
            }

            connection.nextState(new WriteSecondBurstState(connection, iterator, targetTransferTag, desiredDataTransferLength, dataSequenceNumber, bufferOffset));
            super.stateFollowing = true;
            // return true;
View Full Code Here

            if (!authenticated) {// authentication part one
                for (int i = 0; i < requestKeyValuePairs.size(); ++i) {
                    final String[] split = TextParameter.splitKeyValuePair(requestKeyValuePairs.get(i));
                    if (split == null) {
                        sendRejectPdu(LoginStatus.INITIATOR_ERROR);
                        throw new InternetSCSIException("key=value format error: " + requestKeyValuePairs.get(i));
                    }
                    if (TextKeyword.AUTH_METHOD.equals(split[0])) {
                        authMethodValues = split[1];
                        // remove key-value pair from Vector
                        requestKeyValuePairs.remove(i--);// correct for shifted
                                                         // indices
                        // no break here to catch all authMethodKeyValuePairs in
                        // else block
                    } else if (isAuthenticationKey(split[0])) {
                        // move key-value pair to authMethodKeyValuePairs
                        authMethodKeyValuePairs.add(requestKeyValuePairs.remove(i--));// correct for shifted
                                                                                      // indices
                    }
                }
                if (authMethodValues == null) {// missing AuthMethod key
                    sendRejectPdu(LoginStatus.MISSING_PARAMETER);// require
                                                                 // AuthMethod
                                                                 // to be
                                                                 // specified in
                                                                 // first PDU
                                                                 // sequence
                    // close connection
                    throw new InternetSCSIException("Missing AuthMethod key-value pair");
                }
            }

            // negotiate remaining parameters
            final Vector<String> responseKeyValuePairs = new Vector<String>();// these
                                                                              // will
                                                                              // be
                                                                              // sent
                                                                              // back
            if (!negotiator.negotiate(session.getTargetServer(), stageNumber, connection.isLeadingConnection(), ((TargetLoginPhase) targetPhase).getFirstPduAndSetToFalse(), requestKeyValuePairs, responseKeyValuePairs)) {
                // negotiation error
                sendRejectPdu(LoginStatus.INITIATOR_ERROR);
                throw new InternetSCSIException("negotiation failure");
            }

            // ** authentication ** (part two)
            if (!authenticated) {
                if (authMethodValues.contains(TextKeyword.NONE)) {
View Full Code Here

            // check PDU
            if (!checkPdu(pdu)) {
                // send login reject and leave stage
                sendRejectPdu(LoginStatus.INVALID_DURING_LOGIN);
                throw new InternetSCSIException("Wrong PDU in TargetLoginStage");
            }

            // PDU is okay, so append text data segment to stringBuilder
            ReadWrite.appendTextDataSegmentToStringBuffer(pdu.getDataSegment(), stringBuilder);

            // remember what stage the initiator wants to transition to
            requestedNextStageNumber = parser.getNextStageNumber();

            // continue?
            if (parser.isContinueFlag()) {
                // send reception confirmation
                pdu = TargetPduFactory.createLoginResponsePdu(false,// transitFlag
                        false,// continueFlag
                        stageNumber,// currentStage
                        stageNumber,// nextStage
                        session.getInitiatorSessionID(),// initiatorSessionID
                        session.getTargetSessionIdentifyingHandle(),// targetSessionIdentifyingHandle
                        initiatorTaskTag, LoginStatus.SUCCESS,// status
                        ByteBuffer.allocate(0));// dataSegment
                connection.sendPdu(pdu);

                // receive the next pdu
                pdu = connection.receivePdu();
            } else
                // sequence is over
                return stringBuilder.toString();
        }

        // initiator's text PDU sequence was too long
        // send login reject and leave stage
        sendRejectPdu(LoginStatus.OUT_OF_RESOURCES);
        throw new InternetSCSIException("Wrong PDU in TargetLoginStage");
    }
View Full Code Here

                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();
                }
            }
        }
    }
View Full Code Here

        // make sure that initiator wants to proceed to FFP, leave if it does
        // not
        if (requestedNextStageNumber != LoginStage.FULL_FEATURE_PHASE) {
            sendRejectPdu(LoginStatus.INITIATOR_ERROR);
            throw new InternetSCSIException();
        }

        // concatenate key-value pairs to null char-separated string
        final String keyValuePairReply = TextParameter.concatenateKeyValuePairs(responseKeyValuePairs);
View Full Code Here

TOP

Related Classes of org.jscsi.exception.InternetSCSIException

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.