Java Code Examples for com.sun.jmx.snmp.SnmpDefinitions#snmpRspNoError()

The following examples show how to use com.sun.jmx.snmp.SnmpDefinitions#snmpRspNoError() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SnmpRequestHandler.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Make a response pdu with the specified error status and index.
 * NOTE: the response pdu share its varBindList with the request pdu.
 */
private SnmpPduRequest newValidResponsePdu(SnmpPduPacket reqPdu,
                                           SnmpVarBind[] varBindList) {
    SnmpPduRequest result = new SnmpPduRequest() ;

    result.address = reqPdu.address ;
    result.port = reqPdu.port ;
    result.version = reqPdu.version ;
    result.community = reqPdu.community ;
    result.type = SnmpPduRequest.pduGetResponsePdu ;
    result.requestId = reqPdu.requestId ;
    result.errorStatus = SnmpDefinitions.snmpRspNoError ;
    result.errorIndex = 0 ;
    result.varBindList = varBindList ;

    ((SnmpAdaptorServer)adaptorServer).
        updateErrorCounters(result.errorStatus) ;

    return result ;
}
 
Example 2
Source File: SnmpSubRequestHandler.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
static final int mapErrorStatus(int errorStatus,
                                int protocolVersion,
                                int reqPduType) {
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    // Too bad, an error occurs ... we need to translate it ...
    //
    if (protocolVersion == SnmpDefinitions.snmpVersionOne)
        return mapErrorStatusToV1(errorStatus,reqPduType);
    if (protocolVersion == SnmpDefinitions.snmpVersionTwo ||
        protocolVersion == SnmpDefinitions.snmpVersionThree)
        return mapErrorStatusToV2(errorStatus,reqPduType);

    return SnmpDefinitions.snmpRspGenErr;
}
 
Example 3
Source File: SnmpRequestHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Make a response pdu with the specified error status and index.
 * NOTE: the response pdu share its varBindList with the request pdu.
 */
private SnmpPduRequest newValidResponsePdu(SnmpPduPacket reqPdu,
                                           SnmpVarBind[] varBindList) {
    SnmpPduRequest result = new SnmpPduRequest() ;

    result.address = reqPdu.address ;
    result.port = reqPdu.port ;
    result.version = reqPdu.version ;
    result.community = reqPdu.community ;
    result.type = SnmpPduRequest.pduGetResponsePdu ;
    result.requestId = reqPdu.requestId ;
    result.errorStatus = SnmpDefinitions.snmpRspNoError ;
    result.errorIndex = 0 ;
    result.varBindList = varBindList ;

    ((SnmpAdaptorServer)adaptorServer).
        updateErrorCounters(result.errorStatus) ;

    return result ;
}
 
Example 4
Source File: SnmpSubRequestHandler.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static final int mapErrorStatus(int errorStatus,
                                int protocolVersion,
                                int reqPduType) {
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    // Too bad, an error occurs ... we need to translate it ...
    //
    if (protocolVersion == SnmpDefinitions.snmpVersionOne)
        return mapErrorStatusToV1(errorStatus,reqPduType);
    if (protocolVersion == SnmpDefinitions.snmpVersionTwo ||
        protocolVersion == SnmpDefinitions.snmpVersionThree)
        return mapErrorStatusToV2(errorStatus,reqPduType);

    return SnmpDefinitions.snmpRspGenErr;
}
 
Example 5
Source File: SnmpRequestHandler.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Make a response pdu with the specified error status and index.
 * NOTE: the response pdu share its varBindList with the request pdu.
 */
private SnmpPduRequest newValidResponsePdu(SnmpPduPacket reqPdu,
                                           SnmpVarBind[] varBindList) {
    SnmpPduRequest result = new SnmpPduRequest() ;

    result.address = reqPdu.address ;
    result.port = reqPdu.port ;
    result.version = reqPdu.version ;
    result.community = reqPdu.community ;
    result.type = SnmpPduRequest.pduGetResponsePdu ;
    result.requestId = reqPdu.requestId ;
    result.errorStatus = SnmpDefinitions.snmpRspNoError ;
    result.errorIndex = 0 ;
    result.varBindList = varBindList ;

    ((SnmpAdaptorServer)adaptorServer).
        updateErrorCounters(result.errorStatus) ;

    return result ;
}
 
Example 6
Source File: SnmpSubRequestHandler.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
static final int mapErrorStatus(int errorStatus,
                                int protocolVersion,
                                int reqPduType) {
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    // Too bad, an error occurs ... we need to translate it ...
    //
    if (protocolVersion == SnmpDefinitions.snmpVersionOne)
        return mapErrorStatusToV1(errorStatus,reqPduType);
    if (protocolVersion == SnmpDefinitions.snmpVersionTwo ||
        protocolVersion == SnmpDefinitions.snmpVersionThree)
        return mapErrorStatusToV2(errorStatus,reqPduType);

    return SnmpDefinitions.snmpRspGenErr;
}
 
Example 7
Source File: SnmpRequestHandler.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Make a response pdu with the specified error status and index.
 * NOTE: the response pdu share its varBindList with the request pdu.
 */
private SnmpPduRequest newValidResponsePdu(SnmpPduPacket reqPdu,
                                           SnmpVarBind[] varBindList) {
    SnmpPduRequest result = new SnmpPduRequest() ;

    result.address = reqPdu.address ;
    result.port = reqPdu.port ;
    result.version = reqPdu.version ;
    result.community = reqPdu.community ;
    result.type = SnmpPduRequest.pduGetResponsePdu ;
    result.requestId = reqPdu.requestId ;
    result.errorStatus = SnmpDefinitions.snmpRspNoError ;
    result.errorIndex = 0 ;
    result.varBindList = varBindList ;

    ((SnmpAdaptorServer)adaptorServer).
        updateErrorCounters(result.errorStatus) ;

    return result ;
}
 
Example 8
Source File: SnmpSubRequestHandler.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
static final int mapErrorStatus(int errorStatus,
                                int protocolVersion,
                                int reqPduType) {
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    // Too bad, an error occurs ... we need to translate it ...
    //
    if (protocolVersion == SnmpDefinitions.snmpVersionOne)
        return mapErrorStatusToV1(errorStatus,reqPduType);
    if (protocolVersion == SnmpDefinitions.snmpVersionTwo ||
        protocolVersion == SnmpDefinitions.snmpVersionThree)
        return mapErrorStatusToV2(errorStatus,reqPduType);

    return SnmpDefinitions.snmpRspGenErr;
}
 
Example 9
Source File: SnmpRequestHandler.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Optimize when there is only one sub request
 */
private SnmpPduPacket turboProcessingGetSet(SnmpPduRequest req,
                                            Object userData) {

    int errorStatus;
    SnmpSubRequestHandler sub = subs.elements().nextElement();
    sub.setUserData(userData);

    // Indicate to the sub request that a check must be invoked ...
    // OK we should have defined out own tag for that !
    //
    if (req.type == SnmpDefinitions.pduSetRequestPdu) {
        sub.type= pduWalkRequest;
        sub.run();
        sub.type= pduSetRequestPdu;

        // Check the error status.
        //
        errorStatus= sub.getErrorStatus();
        if (errorStatus != SnmpDefinitions.snmpRspNoError) {
            // No point to go any further.
            //
            return newErrorResponsePdu(req, errorStatus,
                                       sub.getErrorIndex() + 1) ;
        }
    }

    // process the operation
    //

    sub.run();
    errorStatus= sub.getErrorStatus();
    if (errorStatus != SnmpDefinitions.snmpRspNoError) {
        // No point to go any further.
        //
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
            SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,
               "turboProcessingGetSet", "an error occurs");
        }
        int realIndex= sub.getErrorIndex() + 1;
        return newErrorResponsePdu(req, errorStatus, realIndex) ;
    }

    // So far so good. So we need to concatenate all the answers.
    //

    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
        SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag,
           "turboProcessingGetSet",  "build the unified response for request "
            + req.requestId);
    }
    return mergeResponses(req);
}
 
Example 10
Source File: SnmpSubRequestHandler.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
static final int mapErrorStatusToV1(int errorStatus, int reqPduType) {
    // Map v2 codes onto v1 codes
    //
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    if (errorStatus == SnmpDefinitions.snmpRspGenErr)
        return SnmpDefinitions.snmpRspGenErr;

    if (errorStatus == SnmpDefinitions.snmpRspNoSuchName)
        return SnmpDefinitions.snmpRspNoSuchName;

    if ((errorStatus == SnmpStatusException.noSuchInstance) ||
        (errorStatus == SnmpStatusException.noSuchObject)   ||
        (errorStatus == SnmpDefinitions.snmpRspNoAccess)    ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentName) ||
        (errorStatus == SnmpDefinitions.snmpRspAuthorizationError)){

        return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus ==
                SnmpDefinitions.snmpRspAuthorizationError)         ||
               (errorStatus == SnmpDefinitions.snmpRspNotWritable)) {

        if (reqPduType == SnmpDefinitions.pduWalkRequest)
            return SnmpDefinitions.snmpRspReadOnly;
        else
            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus == SnmpDefinitions.snmpRspNoCreation)) {

            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus == SnmpDefinitions.snmpRspWrongType)      ||
               (errorStatus == SnmpDefinitions.snmpRspWrongLength)    ||
               (errorStatus == SnmpDefinitions.snmpRspWrongEncoding)  ||
               (errorStatus == SnmpDefinitions.snmpRspWrongValue)     ||
               (errorStatus == SnmpDefinitions.snmpRspWrongLength)    ||
               (errorStatus ==
                SnmpDefinitions.snmpRspInconsistentValue)) {

        if ((reqPduType == SnmpDefinitions.pduSetRequestPdu) ||
            (reqPduType == SnmpDefinitions.pduWalkRequest))
            return SnmpDefinitions.snmpRspBadValue;
        else
            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus ==
                SnmpDefinitions.snmpRspResourceUnavailable) ||
               (errorStatus ==
                SnmpDefinitions.snmpRspCommitFailed)        ||
               (errorStatus == SnmpDefinitions.snmpRspUndoFailed)) {

        return SnmpDefinitions.snmpRspGenErr;

    }

    // At this point we should have a V1 error code
    //
    if (errorStatus == SnmpDefinitions.snmpRspTooBig)
        return SnmpDefinitions.snmpRspTooBig;

    if( (errorStatus == SnmpDefinitions.snmpRspBadValue) ||
        (errorStatus == SnmpDefinitions.snmpRspReadOnly)) {
        if ((reqPduType == SnmpDefinitions.pduSetRequestPdu) ||
            (reqPduType == SnmpDefinitions.pduWalkRequest))
            return errorStatus;
        else
            return SnmpDefinitions.snmpRspNoSuchName;
    }

    // We have a snmpRspGenErr, or something which is not defined
    // in RFC1905 => return a snmpRspGenErr
    //
    return SnmpDefinitions.snmpRspGenErr;

}
 
Example 11
Source File: SnmpSubRequestHandler.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
static final int mapErrorStatusToV1(int errorStatus, int reqPduType) {
    // Map v2 codes onto v1 codes
    //
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    if (errorStatus == SnmpDefinitions.snmpRspGenErr)
        return SnmpDefinitions.snmpRspGenErr;

    if (errorStatus == SnmpDefinitions.snmpRspNoSuchName)
        return SnmpDefinitions.snmpRspNoSuchName;

    if ((errorStatus == SnmpStatusException.noSuchInstance) ||
        (errorStatus == SnmpStatusException.noSuchObject)   ||
        (errorStatus == SnmpDefinitions.snmpRspNoAccess)    ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentName) ||
        (errorStatus == SnmpDefinitions.snmpRspAuthorizationError)){

        return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus ==
                SnmpDefinitions.snmpRspAuthorizationError)         ||
               (errorStatus == SnmpDefinitions.snmpRspNotWritable)) {

        if (reqPduType == SnmpDefinitions.pduWalkRequest)
            return SnmpDefinitions.snmpRspReadOnly;
        else
            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus == SnmpDefinitions.snmpRspNoCreation)) {

            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus == SnmpDefinitions.snmpRspWrongType)      ||
               (errorStatus == SnmpDefinitions.snmpRspWrongLength)    ||
               (errorStatus == SnmpDefinitions.snmpRspWrongEncoding)  ||
               (errorStatus == SnmpDefinitions.snmpRspWrongValue)     ||
               (errorStatus == SnmpDefinitions.snmpRspWrongLength)    ||
               (errorStatus ==
                SnmpDefinitions.snmpRspInconsistentValue)) {

        if ((reqPduType == SnmpDefinitions.pduSetRequestPdu) ||
            (reqPduType == SnmpDefinitions.pduWalkRequest))
            return SnmpDefinitions.snmpRspBadValue;
        else
            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus ==
                SnmpDefinitions.snmpRspResourceUnavailable) ||
               (errorStatus ==
                SnmpDefinitions.snmpRspCommitFailed)        ||
               (errorStatus == SnmpDefinitions.snmpRspUndoFailed)) {

        return SnmpDefinitions.snmpRspGenErr;

    }

    // At this point we should have a V1 error code
    //
    if (errorStatus == SnmpDefinitions.snmpRspTooBig)
        return SnmpDefinitions.snmpRspTooBig;

    if( (errorStatus == SnmpDefinitions.snmpRspBadValue) ||
        (errorStatus == SnmpDefinitions.snmpRspReadOnly)) {
        if ((reqPduType == SnmpDefinitions.pduSetRequestPdu) ||
            (reqPduType == SnmpDefinitions.pduWalkRequest))
            return errorStatus;
        else
            return SnmpDefinitions.snmpRspNoSuchName;
    }

    // We have a snmpRspGenErr, or something which is not defined
    // in RFC1905 => return a snmpRspGenErr
    //
    return SnmpDefinitions.snmpRspGenErr;

}
 
Example 12
Source File: SnmpRequestHandler.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Optimize when there is only one sub request
 */
private SnmpPduPacket turboProcessingGetSet(SnmpPduRequest req,
                                            Object userData) {

    int errorStatus;
    SnmpSubRequestHandler sub = subs.elements().nextElement();
    sub.setUserData(userData);

    // Indicate to the sub request that a check must be invoked ...
    // OK we should have defined out own tag for that !
    //
    if (req.type == SnmpDefinitions.pduSetRequestPdu) {
        sub.type= pduWalkRequest;
        sub.run();
        sub.type= pduSetRequestPdu;

        // Check the error status.
        //
        errorStatus= sub.getErrorStatus();
        if (errorStatus != SnmpDefinitions.snmpRspNoError) {
            // No point to go any further.
            //
            return newErrorResponsePdu(req, errorStatus,
                                       sub.getErrorIndex() + 1) ;
        }
    }

    // process the operation
    //

    sub.run();
    errorStatus= sub.getErrorStatus();
    if (errorStatus != SnmpDefinitions.snmpRspNoError) {
        // No point to go any further.
        //
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
            SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,
               "turboProcessingGetSet", "an error occurs");
        }
        int realIndex= sub.getErrorIndex() + 1;
        return newErrorResponsePdu(req, errorStatus, realIndex) ;
    }

    // So far so good. So we need to concatenate all the answers.
    //

    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
        SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag,
           "turboProcessingGetSet",  "build the unified response for request "
            + req.requestId);
    }
    return mergeResponses(req);
}
 
Example 13
Source File: SnmpSubRequestHandler.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
static final int mapErrorStatusToV1(int errorStatus, int reqPduType) {
    // Map v2 codes onto v1 codes
    //
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    if (errorStatus == SnmpDefinitions.snmpRspGenErr)
        return SnmpDefinitions.snmpRspGenErr;

    if (errorStatus == SnmpDefinitions.snmpRspNoSuchName)
        return SnmpDefinitions.snmpRspNoSuchName;

    if ((errorStatus == SnmpStatusException.noSuchInstance) ||
        (errorStatus == SnmpStatusException.noSuchObject)   ||
        (errorStatus == SnmpDefinitions.snmpRspNoAccess)    ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentName) ||
        (errorStatus == SnmpDefinitions.snmpRspAuthorizationError)){

        return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus ==
                SnmpDefinitions.snmpRspAuthorizationError)         ||
               (errorStatus == SnmpDefinitions.snmpRspNotWritable)) {

        if (reqPduType == SnmpDefinitions.pduWalkRequest)
            return SnmpDefinitions.snmpRspReadOnly;
        else
            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus == SnmpDefinitions.snmpRspNoCreation)) {

            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus == SnmpDefinitions.snmpRspWrongType)      ||
               (errorStatus == SnmpDefinitions.snmpRspWrongLength)    ||
               (errorStatus == SnmpDefinitions.snmpRspWrongEncoding)  ||
               (errorStatus == SnmpDefinitions.snmpRspWrongValue)     ||
               (errorStatus == SnmpDefinitions.snmpRspWrongLength)    ||
               (errorStatus ==
                SnmpDefinitions.snmpRspInconsistentValue)) {

        if ((reqPduType == SnmpDefinitions.pduSetRequestPdu) ||
            (reqPduType == SnmpDefinitions.pduWalkRequest))
            return SnmpDefinitions.snmpRspBadValue;
        else
            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus ==
                SnmpDefinitions.snmpRspResourceUnavailable) ||
               (errorStatus ==
                SnmpDefinitions.snmpRspCommitFailed)        ||
               (errorStatus == SnmpDefinitions.snmpRspUndoFailed)) {

        return SnmpDefinitions.snmpRspGenErr;

    }

    // At this point we should have a V1 error code
    //
    if (errorStatus == SnmpDefinitions.snmpRspTooBig)
        return SnmpDefinitions.snmpRspTooBig;

    if( (errorStatus == SnmpDefinitions.snmpRspBadValue) ||
        (errorStatus == SnmpDefinitions.snmpRspReadOnly)) {
        if ((reqPduType == SnmpDefinitions.pduSetRequestPdu) ||
            (reqPduType == SnmpDefinitions.pduWalkRequest))
            return errorStatus;
        else
            return SnmpDefinitions.snmpRspNoSuchName;
    }

    // We have a snmpRspGenErr, or something which is not defined
    // in RFC1905 => return a snmpRspGenErr
    //
    return SnmpDefinitions.snmpRspGenErr;

}
 
Example 14
Source File: SnmpSubRequestHandler.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
static final int mapErrorStatusToV2(int errorStatus, int reqPduType) {
    // Map v1 codes onto v2 codes
    //
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    if (errorStatus == SnmpDefinitions.snmpRspGenErr)
        return SnmpDefinitions.snmpRspGenErr;

    if (errorStatus == SnmpDefinitions.snmpRspTooBig)
        return SnmpDefinitions.snmpRspTooBig;

    // For get / getNext / getBulk the only global error
    // (PDU-level) possible is genErr.
    //
    if ((reqPduType != SnmpDefinitions.pduSetRequestPdu) &&
        (reqPduType != SnmpDefinitions.pduWalkRequest)) {
        if(errorStatus == SnmpDefinitions.snmpRspAuthorizationError)
            return errorStatus;
        else
            return SnmpDefinitions.snmpRspGenErr;
    }

    // Map to noSuchName
    //      if ((errorStatus == SnmpDefinitions.snmpRspNoSuchName) ||
    //   (errorStatus == SnmpStatusException.noSuchInstance) ||
    //  (errorStatus == SnmpStatusException.noSuchObject))
    //  return SnmpDefinitions.snmpRspNoSuchName;

    // SnmpStatusException.noSuchInstance and
    // SnmpStatusException.noSuchObject can't happen...

    if (errorStatus == SnmpDefinitions.snmpRspNoSuchName)
        return SnmpDefinitions.snmpRspNoAccess;

    // Map to notWritable
    if (errorStatus == SnmpDefinitions.snmpRspReadOnly)
            return SnmpDefinitions.snmpRspNotWritable;

    // Map to wrongValue
    if (errorStatus == SnmpDefinitions.snmpRspBadValue)
        return SnmpDefinitions.snmpRspWrongValue;

    // Other valid V2 codes
    if ((errorStatus == SnmpDefinitions.snmpRspNoAccess) ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentName) ||
        (errorStatus == SnmpDefinitions.snmpRspAuthorizationError) ||
        (errorStatus == SnmpDefinitions.snmpRspNotWritable) ||
        (errorStatus == SnmpDefinitions.snmpRspNoCreation) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongType) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongLength) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongEncoding) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongValue) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongLength) ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentValue) ||
        (errorStatus == SnmpDefinitions.snmpRspResourceUnavailable) ||
        (errorStatus == SnmpDefinitions.snmpRspCommitFailed) ||
        (errorStatus == SnmpDefinitions.snmpRspUndoFailed))
        return errorStatus;

    // Ivalid V2 code => genErr
    return SnmpDefinitions.snmpRspGenErr;
}
 
Example 15
Source File: SnmpSubRequestHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
static final int mapErrorStatusToV2(int errorStatus, int reqPduType) {
    // Map v1 codes onto v2 codes
    //
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    if (errorStatus == SnmpDefinitions.snmpRspGenErr)
        return SnmpDefinitions.snmpRspGenErr;

    if (errorStatus == SnmpDefinitions.snmpRspTooBig)
        return SnmpDefinitions.snmpRspTooBig;

    // For get / getNext / getBulk the only global error
    // (PDU-level) possible is genErr.
    //
    if ((reqPduType != SnmpDefinitions.pduSetRequestPdu) &&
        (reqPduType != SnmpDefinitions.pduWalkRequest)) {
        if(errorStatus == SnmpDefinitions.snmpRspAuthorizationError)
            return errorStatus;
        else
            return SnmpDefinitions.snmpRspGenErr;
    }

    // Map to noSuchName
    //      if ((errorStatus == SnmpDefinitions.snmpRspNoSuchName) ||
    //   (errorStatus == SnmpStatusException.noSuchInstance) ||
    //  (errorStatus == SnmpStatusException.noSuchObject))
    //  return SnmpDefinitions.snmpRspNoSuchName;

    // SnmpStatusException.noSuchInstance and
    // SnmpStatusException.noSuchObject can't happen...

    if (errorStatus == SnmpDefinitions.snmpRspNoSuchName)
        return SnmpDefinitions.snmpRspNoAccess;

    // Map to notWritable
    if (errorStatus == SnmpDefinitions.snmpRspReadOnly)
            return SnmpDefinitions.snmpRspNotWritable;

    // Map to wrongValue
    if (errorStatus == SnmpDefinitions.snmpRspBadValue)
        return SnmpDefinitions.snmpRspWrongValue;

    // Other valid V2 codes
    if ((errorStatus == SnmpDefinitions.snmpRspNoAccess) ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentName) ||
        (errorStatus == SnmpDefinitions.snmpRspAuthorizationError) ||
        (errorStatus == SnmpDefinitions.snmpRspNotWritable) ||
        (errorStatus == SnmpDefinitions.snmpRspNoCreation) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongType) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongLength) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongEncoding) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongValue) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongLength) ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentValue) ||
        (errorStatus == SnmpDefinitions.snmpRspResourceUnavailable) ||
        (errorStatus == SnmpDefinitions.snmpRspCommitFailed) ||
        (errorStatus == SnmpDefinitions.snmpRspUndoFailed))
        return errorStatus;

    // Ivalid V2 code => genErr
    return SnmpDefinitions.snmpRspGenErr;
}
 
Example 16
Source File: SnmpSubRequestHandler.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
static final int mapErrorStatusToV1(int errorStatus, int reqPduType) {
    // Map v2 codes onto v1 codes
    //
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    if (errorStatus == SnmpDefinitions.snmpRspGenErr)
        return SnmpDefinitions.snmpRspGenErr;

    if (errorStatus == SnmpDefinitions.snmpRspNoSuchName)
        return SnmpDefinitions.snmpRspNoSuchName;

    if ((errorStatus == SnmpStatusException.noSuchInstance) ||
        (errorStatus == SnmpStatusException.noSuchObject)   ||
        (errorStatus == SnmpDefinitions.snmpRspNoAccess)    ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentName) ||
        (errorStatus == SnmpDefinitions.snmpRspAuthorizationError)){

        return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus ==
                SnmpDefinitions.snmpRspAuthorizationError)         ||
               (errorStatus == SnmpDefinitions.snmpRspNotWritable)) {

        if (reqPduType == SnmpDefinitions.pduWalkRequest)
            return SnmpDefinitions.snmpRspReadOnly;
        else
            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus == SnmpDefinitions.snmpRspNoCreation)) {

            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus == SnmpDefinitions.snmpRspWrongType)      ||
               (errorStatus == SnmpDefinitions.snmpRspWrongLength)    ||
               (errorStatus == SnmpDefinitions.snmpRspWrongEncoding)  ||
               (errorStatus == SnmpDefinitions.snmpRspWrongValue)     ||
               (errorStatus == SnmpDefinitions.snmpRspWrongLength)    ||
               (errorStatus ==
                SnmpDefinitions.snmpRspInconsistentValue)) {

        if ((reqPduType == SnmpDefinitions.pduSetRequestPdu) ||
            (reqPduType == SnmpDefinitions.pduWalkRequest))
            return SnmpDefinitions.snmpRspBadValue;
        else
            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus ==
                SnmpDefinitions.snmpRspResourceUnavailable) ||
               (errorStatus ==
                SnmpDefinitions.snmpRspCommitFailed)        ||
               (errorStatus == SnmpDefinitions.snmpRspUndoFailed)) {

        return SnmpDefinitions.snmpRspGenErr;

    }

    // At this point we should have a V1 error code
    //
    if (errorStatus == SnmpDefinitions.snmpRspTooBig)
        return SnmpDefinitions.snmpRspTooBig;

    if( (errorStatus == SnmpDefinitions.snmpRspBadValue) ||
        (errorStatus == SnmpDefinitions.snmpRspReadOnly)) {
        if ((reqPduType == SnmpDefinitions.pduSetRequestPdu) ||
            (reqPduType == SnmpDefinitions.pduWalkRequest))
            return errorStatus;
        else
            return SnmpDefinitions.snmpRspNoSuchName;
    }

    // We have a snmpRspGenErr, or something which is not defined
    // in RFC1905 => return a snmpRspGenErr
    //
    return SnmpDefinitions.snmpRspGenErr;

}
 
Example 17
Source File: SnmpSubRequestHandler.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
static final int mapErrorStatusToV2(int errorStatus, int reqPduType) {
    // Map v1 codes onto v2 codes
    //
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    if (errorStatus == SnmpDefinitions.snmpRspGenErr)
        return SnmpDefinitions.snmpRspGenErr;

    if (errorStatus == SnmpDefinitions.snmpRspTooBig)
        return SnmpDefinitions.snmpRspTooBig;

    // For get / getNext / getBulk the only global error
    // (PDU-level) possible is genErr.
    //
    if ((reqPduType != SnmpDefinitions.pduSetRequestPdu) &&
        (reqPduType != SnmpDefinitions.pduWalkRequest)) {
        if(errorStatus == SnmpDefinitions.snmpRspAuthorizationError)
            return errorStatus;
        else
            return SnmpDefinitions.snmpRspGenErr;
    }

    // Map to noSuchName
    //      if ((errorStatus == SnmpDefinitions.snmpRspNoSuchName) ||
    //   (errorStatus == SnmpStatusException.noSuchInstance) ||
    //  (errorStatus == SnmpStatusException.noSuchObject))
    //  return SnmpDefinitions.snmpRspNoSuchName;

    // SnmpStatusException.noSuchInstance and
    // SnmpStatusException.noSuchObject can't happen...

    if (errorStatus == SnmpDefinitions.snmpRspNoSuchName)
        return SnmpDefinitions.snmpRspNoAccess;

    // Map to notWritable
    if (errorStatus == SnmpDefinitions.snmpRspReadOnly)
            return SnmpDefinitions.snmpRspNotWritable;

    // Map to wrongValue
    if (errorStatus == SnmpDefinitions.snmpRspBadValue)
        return SnmpDefinitions.snmpRspWrongValue;

    // Other valid V2 codes
    if ((errorStatus == SnmpDefinitions.snmpRspNoAccess) ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentName) ||
        (errorStatus == SnmpDefinitions.snmpRspAuthorizationError) ||
        (errorStatus == SnmpDefinitions.snmpRspNotWritable) ||
        (errorStatus == SnmpDefinitions.snmpRspNoCreation) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongType) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongLength) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongEncoding) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongValue) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongLength) ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentValue) ||
        (errorStatus == SnmpDefinitions.snmpRspResourceUnavailable) ||
        (errorStatus == SnmpDefinitions.snmpRspCommitFailed) ||
        (errorStatus == SnmpDefinitions.snmpRspUndoFailed))
        return errorStatus;

    // Ivalid V2 code => genErr
    return SnmpDefinitions.snmpRspGenErr;
}
 
Example 18
Source File: SnmpRequestHandler.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Optimize when there is only one sub request
 */
private SnmpPduPacket turboProcessingGetSet(SnmpPduRequest req,
                                            Object userData) {

    int errorStatus;
    SnmpSubRequestHandler sub = subs.elements().nextElement();
    sub.setUserData(userData);

    // Indicate to the sub request that a check must be invoked ...
    // OK we should have defined out own tag for that !
    //
    if (req.type == SnmpDefinitions.pduSetRequestPdu) {
        sub.type= pduWalkRequest;
        sub.run();
        sub.type= pduSetRequestPdu;

        // Check the error status.
        //
        errorStatus= sub.getErrorStatus();
        if (errorStatus != SnmpDefinitions.snmpRspNoError) {
            // No point to go any further.
            //
            return newErrorResponsePdu(req, errorStatus,
                                       sub.getErrorIndex() + 1) ;
        }
    }

    // process the operation
    //

    sub.run();
    errorStatus= sub.getErrorStatus();
    if (errorStatus != SnmpDefinitions.snmpRspNoError) {
        // No point to go any further.
        //
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
            SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,
               "turboProcessingGetSet", "an error occurs");
        }
        int realIndex= sub.getErrorIndex() + 1;
        return newErrorResponsePdu(req, errorStatus, realIndex) ;
    }

    // So far so good. So we need to concatenate all the answers.
    //

    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
        SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag,
           "turboProcessingGetSet",  "build the unified response for request "
            + req.requestId);
    }
    return mergeResponses(req);
}
 
Example 19
Source File: SnmpSubRequestHandler.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
static final int mapErrorStatusToV1(int errorStatus, int reqPduType) {
    // Map v2 codes onto v1 codes
    //
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    if (errorStatus == SnmpDefinitions.snmpRspGenErr)
        return SnmpDefinitions.snmpRspGenErr;

    if (errorStatus == SnmpDefinitions.snmpRspNoSuchName)
        return SnmpDefinitions.snmpRspNoSuchName;

    if ((errorStatus == SnmpStatusException.noSuchInstance) ||
        (errorStatus == SnmpStatusException.noSuchObject)   ||
        (errorStatus == SnmpDefinitions.snmpRspNoAccess)    ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentName) ||
        (errorStatus == SnmpDefinitions.snmpRspAuthorizationError)){

        return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus ==
                SnmpDefinitions.snmpRspAuthorizationError)         ||
               (errorStatus == SnmpDefinitions.snmpRspNotWritable)) {

        if (reqPduType == SnmpDefinitions.pduWalkRequest)
            return SnmpDefinitions.snmpRspReadOnly;
        else
            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus == SnmpDefinitions.snmpRspNoCreation)) {

            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus == SnmpDefinitions.snmpRspWrongType)      ||
               (errorStatus == SnmpDefinitions.snmpRspWrongLength)    ||
               (errorStatus == SnmpDefinitions.snmpRspWrongEncoding)  ||
               (errorStatus == SnmpDefinitions.snmpRspWrongValue)     ||
               (errorStatus == SnmpDefinitions.snmpRspWrongLength)    ||
               (errorStatus ==
                SnmpDefinitions.snmpRspInconsistentValue)) {

        if ((reqPduType == SnmpDefinitions.pduSetRequestPdu) ||
            (reqPduType == SnmpDefinitions.pduWalkRequest))
            return SnmpDefinitions.snmpRspBadValue;
        else
            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus ==
                SnmpDefinitions.snmpRspResourceUnavailable) ||
               (errorStatus ==
                SnmpDefinitions.snmpRspCommitFailed)        ||
               (errorStatus == SnmpDefinitions.snmpRspUndoFailed)) {

        return SnmpDefinitions.snmpRspGenErr;

    }

    // At this point we should have a V1 error code
    //
    if (errorStatus == SnmpDefinitions.snmpRspTooBig)
        return SnmpDefinitions.snmpRspTooBig;

    if( (errorStatus == SnmpDefinitions.snmpRspBadValue) ||
        (errorStatus == SnmpDefinitions.snmpRspReadOnly)) {
        if ((reqPduType == SnmpDefinitions.pduSetRequestPdu) ||
            (reqPduType == SnmpDefinitions.pduWalkRequest))
            return errorStatus;
        else
            return SnmpDefinitions.snmpRspNoSuchName;
    }

    // We have a snmpRspGenErr, or something which is not defined
    // in RFC1905 => return a snmpRspGenErr
    //
    return SnmpDefinitions.snmpRspGenErr;

}
 
Example 20
Source File: SnmpSubRequestHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
static final int mapErrorStatusToV2(int errorStatus, int reqPduType) {
    // Map v1 codes onto v2 codes
    //
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    if (errorStatus == SnmpDefinitions.snmpRspGenErr)
        return SnmpDefinitions.snmpRspGenErr;

    if (errorStatus == SnmpDefinitions.snmpRspTooBig)
        return SnmpDefinitions.snmpRspTooBig;

    // For get / getNext / getBulk the only global error
    // (PDU-level) possible is genErr.
    //
    if ((reqPduType != SnmpDefinitions.pduSetRequestPdu) &&
        (reqPduType != SnmpDefinitions.pduWalkRequest)) {
        if(errorStatus == SnmpDefinitions.snmpRspAuthorizationError)
            return errorStatus;
        else
            return SnmpDefinitions.snmpRspGenErr;
    }

    // Map to noSuchName
    //      if ((errorStatus == SnmpDefinitions.snmpRspNoSuchName) ||
    //   (errorStatus == SnmpStatusException.noSuchInstance) ||
    //  (errorStatus == SnmpStatusException.noSuchObject))
    //  return SnmpDefinitions.snmpRspNoSuchName;

    // SnmpStatusException.noSuchInstance and
    // SnmpStatusException.noSuchObject can't happen...

    if (errorStatus == SnmpDefinitions.snmpRspNoSuchName)
        return SnmpDefinitions.snmpRspNoAccess;

    // Map to notWritable
    if (errorStatus == SnmpDefinitions.snmpRspReadOnly)
            return SnmpDefinitions.snmpRspNotWritable;

    // Map to wrongValue
    if (errorStatus == SnmpDefinitions.snmpRspBadValue)
        return SnmpDefinitions.snmpRspWrongValue;

    // Other valid V2 codes
    if ((errorStatus == SnmpDefinitions.snmpRspNoAccess) ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentName) ||
        (errorStatus == SnmpDefinitions.snmpRspAuthorizationError) ||
        (errorStatus == SnmpDefinitions.snmpRspNotWritable) ||
        (errorStatus == SnmpDefinitions.snmpRspNoCreation) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongType) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongLength) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongEncoding) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongValue) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongLength) ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentValue) ||
        (errorStatus == SnmpDefinitions.snmpRspResourceUnavailable) ||
        (errorStatus == SnmpDefinitions.snmpRspCommitFailed) ||
        (errorStatus == SnmpDefinitions.snmpRspUndoFailed))
        return errorStatus;

    // Ivalid V2 code => genErr
    return SnmpDefinitions.snmpRspGenErr;
}