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

The following examples show how to use com.sun.jmx.snmp.SnmpDefinitions#snmpVersionOne() . 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: JvmMemoryMeta.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public boolean  skipVariable(long var, Object data, int pduVersion) {
    switch((int)var) {
        case 23:
        case 22:
        case 21:
        case 20:
        case 13:
        case 12:
        case 11:
        case 10:
            if (pduVersion==SnmpDefinitions.snmpVersionOne) return true;
            break;
        default:
            break;
    }
    return super.skipVariable(var,data,pduVersion);
}
 
Example 2
Source File: SnmpRequestTree.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static int mapSetException(int errorStatus, int version)
    throws SnmpStatusException {

    final int errorCode = errorStatus;

    if (version == SnmpDefinitions.snmpVersionOne)
        return errorCode;

    int mappedErrorCode = errorCode;

    // Now take care of V2 errorCodes that can be stored
    // in the varbind itself:
    if (errorCode == SnmpStatusException.noSuchObject)
        // noSuchObject => notWritable
        mappedErrorCode = SnmpStatusException.snmpRspNotWritable;

    else if (errorCode == SnmpStatusException.noSuchInstance)
        // noSuchInstance => notWritable
        mappedErrorCode = SnmpStatusException.snmpRspNotWritable;

    return mappedErrorCode;
}
 
Example 3
Source File: SnmpRequestTree.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static int mapSetException(int errorStatus, int version)
    throws SnmpStatusException {

    final int errorCode = errorStatus;

    if (version == SnmpDefinitions.snmpVersionOne)
        return errorCode;

    int mappedErrorCode = errorCode;

    // Now take care of V2 errorCodes that can be stored
    // in the varbind itself:
    if (errorCode == SnmpStatusException.noSuchObject)
        // noSuchObject => notWritable
        mappedErrorCode = SnmpStatusException.snmpRspNotWritable;

    else if (errorCode == SnmpStatusException.noSuchInstance)
        // noSuchInstance => notWritable
        mappedErrorCode = SnmpStatusException.snmpRspNotWritable;

    return mappedErrorCode;
}
 
Example 4
Source File: SnmpErrorHandlerAgent.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Processes a <CODE>getNext</CODE> operation. It will throw an exception for V1 requests or it will set exceptions within the list for V2 requests..
 *
 * @param inRequest The SnmpMibRequest object holding the list of variables to be retrieved.
 *
 * @exception SnmpStatusException An error occurred during the operation.
 */

@Override
public void getNext(SnmpMibRequest inRequest) throws SnmpStatusException {

    SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
            SnmpErrorHandlerAgent.class.getName(),
            "getNext", "GetNext in Exception");

    if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne)
        throw new SnmpStatusException(SnmpStatusException.noSuchName);

    Enumeration<SnmpVarBind> l = inRequest.getElements();
    while(l.hasMoreElements()) {
        SnmpVarBind varbind = l.nextElement();
        varbind.setEndOfMibView();
    }
}
 
Example 5
Source File: SnmpErrorHandlerAgent.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Processes a <CODE>get</CODE> operation. It will throw an exception for V1 requests or it will set exceptions within the list for V2 requests.
 *
 * @param inRequest The SnmpMibRequest object holding the list of variable to be retrieved.
 *
 * @exception SnmpStatusException An error occurred during the operation.
 */

@Override
public void get(SnmpMibRequest inRequest) throws SnmpStatusException {

    SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
            SnmpErrorHandlerAgent.class.getName(),
            "get", "Get in Exception");

    if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne)
        throw new SnmpStatusException(SnmpStatusException.noSuchName);

    Enumeration<SnmpVarBind> l = inRequest.getElements();
    while(l.hasMoreElements()) {
        SnmpVarBind varbind = l.nextElement();
        varbind.setNoSuchObject();
    }
}
 
Example 6
Source File: JvmThreadInstanceEntryMeta.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public boolean  skipVariable(long var, Object data, int pduVersion) {
    switch((int)var) {
        case 8:
        case 7:
        case 6:
        case 5:
        case 4:
        case 2:
            if (pduVersion==SnmpDefinitions.snmpVersionOne) return true;
            break;
        case 1:
            return true;
        default:
            break;
    }
    return super.skipVariable(var,data,pduVersion);
}
 
Example 7
Source File: JvmMemoryMeta.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public boolean  skipVariable(long var, Object data, int pduVersion) {
    switch((int)var) {
        case 23:
        case 22:
        case 21:
        case 20:
        case 13:
        case 12:
        case 11:
        case 10:
            if (pduVersion==SnmpDefinitions.snmpVersionOne) return true;
            break;
        default:
            break;
    }
    return super.skipVariable(var,data,pduVersion);
}
 
Example 8
Source File: SnmpErrorHandlerAgent.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Processes a <CODE>getBulk</CODE> operation. It will throw an exception if the request is a V1 one or it will set exceptions within the list for V2 ones.
 *
 * @param inRequest The SnmpMibRequest object holding the list of variable to be retrieved.
 *
 * @exception SnmpStatusException An error occurred during the operation.
 */

@Override
public void getBulk(SnmpMibRequest inRequest, int nonRepeat, int maxRepeat)
    throws SnmpStatusException {

    SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
            SnmpErrorHandlerAgent.class.getName(),
            "getBulk", "GetBulk in Exception");

    if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne)
        throw new SnmpStatusException(SnmpDefinitions.snmpRspGenErr, 0);

    Enumeration<SnmpVarBind> l = inRequest.getElements();
    while(l.hasMoreElements()) {
        SnmpVarBind varbind = l.nextElement();
        varbind.setEndOfMibView();
    }
}
 
Example 9
Source File: SnmpErrorHandlerAgent.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Processes a <CODE>get</CODE> operation. It will throw an exception for V1 requests or it will set exceptions within the list for V2 requests.
 *
 * @param inRequest The SnmpMibRequest object holding the list of variable to be retrieved.
 *
 * @exception SnmpStatusException An error occurred during the operation.
 */

@Override
public void get(SnmpMibRequest inRequest) throws SnmpStatusException {

    SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
            SnmpErrorHandlerAgent.class.getName(),
            "get", "Get in Exception");

    if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne)
        throw new SnmpStatusException(SnmpStatusException.noSuchName);

    Enumeration<SnmpVarBind> l = inRequest.getElements();
    while(l.hasMoreElements()) {
        SnmpVarBind varbind = l.nextElement();
        varbind.setNoSuchObject();
    }
}
 
Example 10
Source File: SnmpErrorHandlerAgent.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Processes a <CODE>getNext</CODE> operation. It will throw an exception for V1 requests or it will set exceptions within the list for V2 requests..
 *
 * @param inRequest The SnmpMibRequest object holding the list of variables to be retrieved.
 *
 * @exception SnmpStatusException An error occurred during the operation.
 */

@Override
public void getNext(SnmpMibRequest inRequest) throws SnmpStatusException {

    SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
            SnmpErrorHandlerAgent.class.getName(),
            "getNext", "GetNext in Exception");

    if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne)
        throw new SnmpStatusException(SnmpStatusException.noSuchName);

    Enumeration<SnmpVarBind> l = inRequest.getElements();
    while(l.hasMoreElements()) {
        SnmpVarBind varbind = l.nextElement();
        varbind.setEndOfMibView();
    }
}
 
Example 11
Source File: JvmMemPoolEntryMeta.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public boolean  skipVariable(long var, Object data, int pduVersion) {
    switch((int)var) {
        case 33:
        case 32:
        case 31:
        case 132:
        case 131:
        case 13:
        case 12:
        case 11:
        case 10:
        case 111:
        case 110:
        case 5:
        case 23:
            if (pduVersion==SnmpDefinitions.snmpVersionOne) return true;
            break;
        case 1:
            return true;
        case 22:
        case 21:
            if (pduVersion==SnmpDefinitions.snmpVersionOne) return true;
            break;
        default:
            break;
    }
    return super.skipVariable(var,data,pduVersion);
}
 
Example 12
Source File: SnmpMibAgent.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static int getSecurityModel(int version) {
    switch(version) {
    case SnmpDefinitions.snmpVersionOne:
        return SnmpDefinitions.snmpV1SecurityModel;
    default:
        return SnmpDefinitions.snmpV2SecurityModel;
    }
}
 
Example 13
Source File: JvmThreadingMeta.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public boolean  skipVariable(long var, Object data, int pduVersion) {
    switch((int)var) {
        case 4:
        case 7:
            if (pduVersion==SnmpDefinitions.snmpVersionOne) return true;
            break;
        default:
            break;
    }
    return super.skipVariable(var,data,pduVersion);
}
 
Example 14
Source File: JvmRuntimeMeta.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public boolean  skipVariable(long var, Object data, int pduVersion) {
    switch((int)var) {
        case 12:
        case 11:
            if (pduVersion==SnmpDefinitions.snmpVersionOne) return true;
            break;
        default:
            break;
    }
    return super.skipVariable(var,data,pduVersion);
}
 
Example 15
Source File: SnmpRequestHandler.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
SnmpPduPacket makeNoMibErrorPdu(SnmpPduRequest req, Object userData) {
    // There is no agent registered
    //
    if (req.version == SnmpDefinitions.snmpVersionOne) {
        // Version 1: => NoSuchName
        return
            newErrorResponsePdu(req,snmpRspNoSuchName,1);
    } else if (req.version == SnmpDefinitions.snmpVersionTwo) {
        // Version 2: => depends on PDU type
        switch (req.type) {
        case pduSetRequestPdu :
        case pduWalkRequest :
            // SET request => NoAccess
            return
                newErrorResponsePdu(req,snmpRspNoAccess,1);
        case pduGetRequestPdu :
            // GET request => NoSuchObject
            return
                makeErrorVarbindPdu(req,SnmpDataTypeEnums.
                                    errNoSuchObjectTag);
        case pduGetNextRequestPdu :
        case pduGetBulkRequestPdu :
            // GET-NEXT or GET-BULK => EndOfMibView
            return
                makeErrorVarbindPdu(req,SnmpDataTypeEnums.
                                    errEndOfMibViewTag);
        default:
        }
    }
    // Something wrong here: => snmpRspGenErr
    return newErrorResponsePdu(req,snmpRspGenErr,1);
}
 
Example 16
Source File: SnmpRequestTree.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void registerGetException(SnmpVarBind var,
                                 SnmpStatusException exception)
    throws SnmpStatusException {
    // The index in the exception must correspond to
    // the SNMP index ...
    //
    if (version == SnmpDefinitions.snmpVersionOne)
        throw new SnmpStatusException(exception, getVarIndex(var)+1);

    if (var == null)
        throw exception;

    // If we're doing a getnext ==> endOfMibView
    if (getnextflag) {
        var.value = SnmpVarBind.endOfMibView;
        return;
    }

    final int errorCode = mapGetException(exception.getStatus(),
                                          version);

    // Now take care of V2 errorCodes that can be stored
    // in the varbind itself:
    if (errorCode ==
        SnmpStatusException.noSuchObject)
        // noSuchObject => noSuchObject
        var.value= SnmpVarBind.noSuchObject;

    else if (errorCode ==
             SnmpStatusException.noSuchInstance)
        // noSuchInstance => noSuchInstance
        var.value= SnmpVarBind.noSuchInstance;

    else
        throw new SnmpStatusException(errorCode, getVarIndex(var)+1);

}
 
Example 17
Source File: JvmThreadingMeta.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public boolean  skipVariable(long var, Object data, int pduVersion) {
    switch((int)var) {
        case 4:
        case 7:
            if (pduVersion==SnmpDefinitions.snmpVersionOne) return true;
            break;
        default:
            break;
    }
    return super.skipVariable(var,data,pduVersion);
}
 
Example 18
Source File: JvmThreadingMeta.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public boolean  skipVariable(long var, Object data, int pduVersion) {
    switch((int)var) {
        case 4:
        case 7:
            if (pduVersion==SnmpDefinitions.snmpVersionOne) return true;
            break;
        default:
            break;
    }
    return super.skipVariable(var,data,pduVersion);
}
 
Example 19
Source File: SnmpRequestTree.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void registerGetException(SnmpVarBind var,
                                 SnmpStatusException exception)
    throws SnmpStatusException {
    // The index in the exception must correspond to
    // the SNMP index ...
    //
    if (version == SnmpDefinitions.snmpVersionOne)
        throw new SnmpStatusException(exception, getVarIndex(var)+1);

    if (var == null)
        throw exception;

    // If we're doing a getnext ==> endOfMibView
    if (getnextflag) {
        var.value = SnmpVarBind.endOfMibView;
        return;
    }

    final int errorCode = mapGetException(exception.getStatus(),
                                          version);

    // Now take care of V2 errorCodes that can be stored
    // in the varbind itself:
    if (errorCode ==
        SnmpStatusException.noSuchObject)
        // noSuchObject => noSuchObject
        var.value= SnmpVarBind.noSuchObject;

    else if (errorCode ==
             SnmpStatusException.noSuchInstance)
        // noSuchInstance => noSuchInstance
        var.value= SnmpVarBind.noSuchInstance;

    else
        throw new SnmpStatusException(errorCode, getVarIndex(var)+1);

}
 
Example 20
Source File: SnmpRequestHandler.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
SnmpPduPacket makeNoMibErrorPdu(SnmpPduRequest req, Object userData) {
    // There is no agent registered
    //
    if (req.version == SnmpDefinitions.snmpVersionOne) {
        // Version 1: => NoSuchName
        return
            newErrorResponsePdu(req,snmpRspNoSuchName,1);
    } else if (req.version == SnmpDefinitions.snmpVersionTwo) {
        // Version 2: => depends on PDU type
        switch (req.type) {
        case pduSetRequestPdu :
        case pduWalkRequest :
            // SET request => NoAccess
            return
                newErrorResponsePdu(req,snmpRspNoAccess,1);
        case pduGetRequestPdu :
            // GET request => NoSuchObject
            return
                makeErrorVarbindPdu(req,SnmpDataTypeEnums.
                                    errNoSuchObjectTag);
        case pduGetNextRequestPdu :
        case pduGetBulkRequestPdu :
            // GET-NEXT or GET-BULK => EndOfMibView
            return
                makeErrorVarbindPdu(req,SnmpDataTypeEnums.
                                    errEndOfMibViewTag);
        default:
        }
    }
    // Something wrong here: => snmpRspGenErr
    return newErrorResponsePdu(req,snmpRspGenErr,1);
}