com.sun.jmx.snmp.SnmpDefinitions Java Examples
The following examples show how to use
com.sun.jmx.snmp.SnmpDefinitions.
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 JDKSourceCode1.8 with MIT License | 7 votes |
/** * Check the type of the pdu: only the get/set/bulk request * are accepted. */ private boolean checkPduType(SnmpPduPacket pdu) { boolean result; switch(pdu.type) { case SnmpDefinitions.pduGetRequestPdu: case SnmpDefinitions.pduGetNextRequestPdu: case SnmpDefinitions.pduSetRequestPdu: case SnmpDefinitions.pduGetBulkRequestPdu: result = true ; break; default: if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "checkPduType", "cannot respond to this kind of PDU"); } result = false ; break; } return result ; }
Example #2
Source File: SnmpRequestTree.java From JDKSourceCode1.8 with MIT License | 6 votes |
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: SnmpRequestHandler.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * 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: SnmpErrorHandlerAgent.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * 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 #5
Source File: JvmMemoryMeta.java From hottub with GNU General Public License v2.0 | 6 votes |
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 #6
Source File: SnmpRequestTree.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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 #7
Source File: SnmpSubRequestHandler.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
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 #8
Source File: SnmpMibAgent.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * This is a factory method for creating new SnmpMibRequest objects. * @param reqPdu The received PDU. * @param vblist The vector of SnmpVarBind objects in which the * MIB concerned by this request is involved. * @param version The protocol version of the SNMP request. * @param userData User allocated contextual data. * * @return A new SnmpMibRequest object. * * @since 1.5 **/ public static SnmpMibRequest newMibRequest(SnmpPdu reqPdu, Vector<SnmpVarBind> vblist, int version, Object userData) { return new SnmpMibRequestImpl(null, reqPdu, vblist, version, userData, null, SnmpDefinitions.noAuthNoPriv, getSecurityModel(version), null,null); }
Example #9
Source File: SnmpSubRequestHandler.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
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 #10
Source File: SnmpRequestTree.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
@Override public void registerSetException(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); // Although the first pass of check() did not fail, // the set() phase could not be carried out correctly. // Since we don't know how to make an "undo", and some // assignation may already have been performed, we're going // to throw an snmpRspUndoFailed. // throw new SnmpStatusException(SnmpDefinitions.snmpRspUndoFailed, getVarIndex(var)+1); }
Example #11
Source File: SnmpRequestHandler.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * 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 #12
Source File: SnmpMibAgent.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * This is a factory method for creating new SnmpMibRequest objects. * @param reqPdu The received PDU. * @param vblist The vector of SnmpVarBind objects in which the * MIB concerned by this request is involved. * @param version The protocol version of the SNMP request. * @param userData User allocated contextual data. * * @return A new SnmpMibRequest object. * * @since 1.5 **/ public static SnmpMibRequest newMibRequest(SnmpPdu reqPdu, Vector<SnmpVarBind> vblist, int version, Object userData) { return new SnmpMibRequestImpl(null, reqPdu, vblist, version, userData, null, SnmpDefinitions.noAuthNoPriv, getSecurityModel(version), null,null); }
Example #13
Source File: JvmMemoryMeta.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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 #14
Source File: SnmpErrorHandlerAgent.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * 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 #15
Source File: SnmpRequestHandler.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * 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 #16
Source File: JvmMemoryImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Setter for the "JvmMemoryGCCall" variable. */ public void setJvmMemoryGCCall(EnumJvmMemoryGCCall x) throws SnmpStatusException { if (x.intValue() == JvmMemoryGCCallStart.intValue()) { final Map<Object, Object> m = JvmContextFactory.getUserData(); try { ManagementFactory.getMemoryMXBean().gc(); if (m != null) m.put("jvmMemory.getJvmMemoryGCCall", JvmMemoryGCCallStarted); } catch (Exception ex) { if (m != null) m.put("jvmMemory.getJvmMemoryGCCall", JvmMemoryGCCallFailed); } return; } throw new SnmpStatusException(SnmpDefinitions.snmpRspWrongValue); }
Example #17
Source File: SnmpErrorHandlerAgent.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * 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 #18
Source File: SnmpRequestHandler.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * 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 #19
Source File: SnmpMibAgent.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static int getSecurityModel(int version) { switch(version) { case SnmpDefinitions.snmpVersionOne: return SnmpDefinitions.snmpV1SecurityModel; default: return SnmpDefinitions.snmpV2SecurityModel; } }
Example #20
Source File: JvmMemPoolEntryMeta.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
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 #21
Source File: SnmpEngineImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Checks the passed msg flags according to the rules specified in RFC 2572. * @param msgFlags The msg flags. */ public static void checkSecurityLevel(byte msgFlags) throws SnmpBadSecurityLevelException { int secLevel = msgFlags & SnmpDefinitions.authPriv; if((secLevel & SnmpDefinitions.privMask) != 0) if((secLevel & SnmpDefinitions.authMask) == 0) { throw new SnmpBadSecurityLevelException("Security level:"+ " noAuthPriv!!!"); } }
Example #22
Source File: SnmpRequestHandler.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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 #23
Source File: JvmCompilationMeta.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public boolean skipVariable(long var, Object data, int pduVersion) { switch((int)var) { case 2: if (pduVersion==SnmpDefinitions.snmpVersionOne) return true; break; default: break; } return super.skipVariable(var,data,pduVersion); }
Example #24
Source File: SnmpRequestHandler.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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 #25
Source File: SnmpEngineImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Checks the passed msg flags according to the rules specified in RFC 2572. * @param msgFlags The msg flags. */ public static void checkSecurityLevel(byte msgFlags) throws SnmpBadSecurityLevelException { int secLevel = msgFlags & SnmpDefinitions.authPriv; if((secLevel & SnmpDefinitions.privMask) != 0) if((secLevel & SnmpDefinitions.authMask) == 0) { throw new SnmpBadSecurityLevelException("Security level:"+ " noAuthPriv!!!"); } }
Example #26
Source File: JvmMemPoolEntryImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Checker for the "JvmMemPoolThreshold" variable. */ public void checkJvmMemPoolThreshold(Long x) throws SnmpStatusException { // if threshold is -1, it means that low memory detection is not // supported. if (!pool.isUsageThresholdSupported()) throw new SnmpStatusException(SnmpDefinitions.snmpRspInconsistentValue); final long val = x.longValue(); if (val < 0 ) throw new SnmpStatusException(SnmpDefinitions.snmpRspWrongValue); }
Example #27
Source File: SnmpRequestTree.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@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 #28
Source File: JvmMemPoolEntryMeta.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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 #29
Source File: SnmpErrorHandlerAgent.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Processes a <CODE>set</CODE> operation. Should never be called (check previously called having failed). * * @param inRequest The SnmpMibRequest object holding the list of variable to be set. * * @exception SnmpStatusException An error occurred during the operation. */ @Override public void set(SnmpMibRequest inRequest) throws SnmpStatusException { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpErrorHandlerAgent.class.getName(), "set", "Set in Exception, CANNOT be called"); throw new SnmpStatusException(SnmpDefinitions.snmpRspNotWritable); }
Example #30
Source File: JvmThreadingImpl.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Checker for the "JvmThreadContentionMonitoring" variable. */ public void checkJvmThreadContentionMonitoring( EnumJvmThreadContentionMonitoring x) throws SnmpStatusException { //Can't be set externaly to unsupported state. if(JvmThreadContentionMonitoringUnsupported.intValue()==x.intValue()) { log.debug("checkJvmThreadContentionMonitoring", "Try to set to illegal unsupported value"); throw new SnmpStatusException(SnmpDefinitions.snmpRspWrongValue); } if ((JvmThreadContentionMonitoringEnabled.intValue()==x.intValue()) || (JvmThreadContentionMonitoringDisabled.intValue()==x.intValue())) { // The value is valid, but is the feature supported ? ThreadMXBean mbean = getThreadMXBean(); if(mbean.isThreadContentionMonitoringSupported()) return; log.debug("checkJvmThreadContentionMonitoring", "Unsupported operation, can't set state"); throw new SnmpStatusException(SnmpDefinitions.snmpRspInconsistentValue); } log.debug("checkJvmThreadContentionMonitoring", "Try to set to unknown value"); throw new SnmpStatusException(SnmpDefinitions.snmpRspWrongValue); }