com.sun.jmx.snmp.SnmpPduPacket Java Examples
The following examples show how to use
com.sun.jmx.snmp.SnmpPduPacket.
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 Project: jdk8u-jdk Author: lambdalab-mirror File: SnmpRequestHandler.java License: GNU General Public License v2.0 | 6 votes |
private SnmpPduPacket mergeResponses(SnmpPduRequest req) { if (req.type == pduGetNextRequestPdu) { return mergeNextResponses(req); } SnmpVarBind[] result= req.varBindList; // Go through the list of subrequests and concatenate. // Hopefully, by now all the sub-requests should be finished // for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) { SnmpSubRequestHandler sub= e.nextElement(); sub.updateResult(result); } return newValidResponsePdu(req,result); }
Example #2
Source Project: jdk1.8-source-analysis Author: raysonfang File: SnmpRequestHandler.java License: Apache License 2.0 | 6 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 #3
Source Project: jdk1.8-source-analysis Author: raysonfang File: SnmpRequestHandler.java License: 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 Project: jdk8u-jdk Author: lambdalab-mirror File: SnmpRequestHandler.java License: GNU General Public License v2.0 | 6 votes |
SnmpPduPacket makeErrorVarbindPdu(SnmpPduPacket req, int statusTag) { final SnmpVarBind[] vblist = req.varBindList; final int length = vblist.length; switch (statusTag) { case SnmpDataTypeEnums.errEndOfMibViewTag: for (int i=0 ; i<length ; i++) vblist[i].value = SnmpVarBind.endOfMibView; break; case SnmpDataTypeEnums.errNoSuchObjectTag: for (int i=0 ; i<length ; i++) vblist[i].value = SnmpVarBind.noSuchObject; break; case SnmpDataTypeEnums.errNoSuchInstanceTag: for (int i=0 ; i<length ; i++) vblist[i].value = SnmpVarBind.noSuchInstance; break; default: return newErrorResponsePdu(req,snmpRspGenErr,1); } return newValidResponsePdu(req,vblist); }
Example #5
Source Project: jdk8u_jdk Author: JetBrains File: SnmpRequestHandler.java License: 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 #6
Source Project: openjdk-8 Author: bpupadhyaya File: SnmpRequestHandler.java License: GNU General Public License v2.0 | 6 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 #7
Source Project: dragonwell8_jdk Author: alibaba File: SnmpRequestHandler.java License: GNU General Public License v2.0 | 6 votes |
SnmpPduPacket makeErrorVarbindPdu(SnmpPduPacket req, int statusTag) { final SnmpVarBind[] vblist = req.varBindList; final int length = vblist.length; switch (statusTag) { case SnmpDataTypeEnums.errEndOfMibViewTag: for (int i=0 ; i<length ; i++) vblist[i].value = SnmpVarBind.endOfMibView; break; case SnmpDataTypeEnums.errNoSuchObjectTag: for (int i=0 ; i<length ; i++) vblist[i].value = SnmpVarBind.noSuchObject; break; case SnmpDataTypeEnums.errNoSuchInstanceTag: for (int i=0 ; i<length ; i++) vblist[i].value = SnmpVarBind.noSuchInstance; break; default: return newErrorResponsePdu(req,snmpRspGenErr,1); } return newValidResponsePdu(req,vblist); }
Example #8
Source Project: dragonwell8_jdk Author: alibaba File: SnmpRequestHandler.java License: GNU General Public License v2.0 | 6 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 #9
Source Project: dragonwell8_jdk Author: alibaba File: SnmpRequestHandler.java License: 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 #10
Source Project: TencentKona-8 Author: Tencent File: SnmpRequestHandler.java License: GNU General Public License v2.0 | 6 votes |
SnmpPduPacket makeErrorVarbindPdu(SnmpPduPacket req, int statusTag) { final SnmpVarBind[] vblist = req.varBindList; final int length = vblist.length; switch (statusTag) { case SnmpDataTypeEnums.errEndOfMibViewTag: for (int i=0 ; i<length ; i++) vblist[i].value = SnmpVarBind.endOfMibView; break; case SnmpDataTypeEnums.errNoSuchObjectTag: for (int i=0 ; i<length ; i++) vblist[i].value = SnmpVarBind.noSuchObject; break; case SnmpDataTypeEnums.errNoSuchInstanceTag: for (int i=0 ; i<length ; i++) vblist[i].value = SnmpVarBind.noSuchInstance; break; default: return newErrorResponsePdu(req,snmpRspGenErr,1); } return newValidResponsePdu(req,vblist); }
Example #11
Source Project: openjdk-jdk8u-backup Author: AdoptOpenJDK File: SnmpRequestHandler.java License: GNU General Public License v2.0 | 6 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 #12
Source Project: jdk8u60 Author: chenghanpeng File: SnmpRequestHandler.java License: 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 #13
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: SnmpRequestHandler.java License: 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 #14
Source Project: jdk8u60 Author: chenghanpeng File: SnmpRequestHandler.java License: GNU General Public License v2.0 | 6 votes |
private SnmpPduPacket mergeResponses(SnmpPduRequest req) { if (req.type == pduGetNextRequestPdu) { return mergeNextResponses(req); } SnmpVarBind[] result= req.varBindList; // Go through the list of subrequests and concatenate. // Hopefully, by now all the sub-requests should be finished // for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) { SnmpSubRequestHandler sub= e.nextElement(); sub.updateResult(result); } return newValidResponsePdu(req,result); }
Example #15
Source Project: openjdk-8-source Author: keerath File: SnmpRequestHandler.java License: GNU General Public License v2.0 | 6 votes |
SnmpPduPacket makeErrorVarbindPdu(SnmpPduPacket req, int statusTag) { final SnmpVarBind[] vblist = req.varBindList; final int length = vblist.length; switch (statusTag) { case SnmpDataTypeEnums.errEndOfMibViewTag: for (int i=0 ; i<length ; i++) vblist[i].value = SnmpVarBind.endOfMibView; break; case SnmpDataTypeEnums.errNoSuchObjectTag: for (int i=0 ; i<length ; i++) vblist[i].value = SnmpVarBind.noSuchObject; break; case SnmpDataTypeEnums.errNoSuchInstanceTag: for (int i=0 ; i<length ; i++) vblist[i].value = SnmpVarBind.noSuchInstance; break; default: return newErrorResponsePdu(req,snmpRspGenErr,1); } return newValidResponsePdu(req,vblist); }
Example #16
Source Project: jdk8u_jdk Author: JetBrains File: SnmpRequestHandler.java License: GNU General Public License v2.0 | 6 votes |
private SnmpPduPacket mergeResponses(SnmpPduRequest req) { if (req.type == pduGetNextRequestPdu) { return mergeNextResponses(req); } SnmpVarBind[] result= req.varBindList; // Go through the list of subrequests and concatenate. // Hopefully, by now all the sub-requests should be finished // for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) { SnmpSubRequestHandler sub= e.nextElement(); sub.updateResult(result); } return newValidResponsePdu(req,result); }
Example #17
Source Project: openjdk-jdk8u-backup Author: AdoptOpenJDK File: SnmpAdaptorServer.java License: GNU General Public License v2.0 | 5 votes |
/** * Send the specified trap PDU to the passed <CODE>SnmpPeer</CODE>. * @param peer The destination peer. The Read community string is used of * <CODE>SnmpParameters</CODE> is used as the trap community string. * @param pdu The pdu to send. * @exception IOException An I/O error occurred while sending the trap. * @exception SnmpStatusException If the trap exceeds the limit defined * by <CODE>bufferSize</CODE>. * @since 1.5 */ @Override public void snmpPduTrap(SnmpPeer peer, SnmpPduPacket pdu) throws IOException, SnmpStatusException { if(peer != null) { pdu.port = peer.getDestPort(); sendTrapPdu(peer.getDestAddr(), pdu); } else { pdu.port = getTrapPort().intValue(); sendTrapPdu(pdu); } }
Example #18
Source Project: JDKSourceCode1.8 Author: wupeixuan File: SnmpRequestHandler.java License: MIT License | 5 votes |
private SnmpPduPacket mergeNextResponses(SnmpPduRequest req) { int max= req.varBindList.length; SnmpVarBind[] result= new SnmpVarBind[max]; // Go through the list of subrequests and concatenate. // Hopefully, by now all the sub-requests should be finished // for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) { SnmpSubRequestHandler sub= e.nextElement(); sub.updateResult(result); } if (req.version == snmpVersionTwo) { return newValidResponsePdu(req,result); } // In v1 make sure there is no endOfMibView ... // for(int i=0; i < max; i++) { SnmpValue val= result[i].value; if (val == SnmpVarBind.endOfMibView) return newErrorResponsePdu(req, SnmpDefinitions.snmpRspNoSuchName, i+1); } // So far so good ... // return newValidResponsePdu(req,result); }
Example #19
Source Project: dragonwell8_jdk Author: alibaba File: SnmpRequestHandler.java License: GNU General Public License v2.0 | 5 votes |
private SnmpPduPacket mergeNextResponses(SnmpPduRequest req) { int max= req.varBindList.length; SnmpVarBind[] result= new SnmpVarBind[max]; // Go through the list of subrequests and concatenate. // Hopefully, by now all the sub-requests should be finished // for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) { SnmpSubRequestHandler sub= e.nextElement(); sub.updateResult(result); } if (req.version == snmpVersionTwo) { return newValidResponsePdu(req,result); } // In v1 make sure there is no endOfMibView ... // for(int i=0; i < max; i++) { SnmpValue val= result[i].value; if (val == SnmpVarBind.endOfMibView) return newErrorResponsePdu(req, SnmpDefinitions.snmpRspNoSuchName, i+1); } // So far so good ... // return newValidResponsePdu(req,result); }
Example #20
Source Project: hottub Author: dsrg-uoft File: SnmpRequestHandler.java License: GNU General Public License v2.0 | 5 votes |
private SnmpPduPacket mergeNextResponses(SnmpPduRequest req) { int max= req.varBindList.length; SnmpVarBind[] result= new SnmpVarBind[max]; // Go through the list of subrequests and concatenate. // Hopefully, by now all the sub-requests should be finished // for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) { SnmpSubRequestHandler sub= e.nextElement(); sub.updateResult(result); } if (req.version == snmpVersionTwo) { return newValidResponsePdu(req,result); } // In v1 make sure there is no endOfMibView ... // for(int i=0; i < max; i++) { SnmpValue val= result[i].value; if (val == SnmpVarBind.endOfMibView) return newErrorResponsePdu(req, SnmpDefinitions.snmpRspNoSuchName, i+1); } // So far so good ... // return newValidResponsePdu(req,result); }
Example #21
Source Project: TencentKona-8 Author: Tencent File: SnmpRequestHandler.java License: GNU General Public License v2.0 | 5 votes |
private SnmpPduPacket mergeNextResponses(SnmpPduRequest req) { int max= req.varBindList.length; SnmpVarBind[] result= new SnmpVarBind[max]; // Go through the list of subrequests and concatenate. // Hopefully, by now all the sub-requests should be finished // for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) { SnmpSubRequestHandler sub= e.nextElement(); sub.updateResult(result); } if (req.version == snmpVersionTwo) { return newValidResponsePdu(req,result); } // In v1 make sure there is no endOfMibView ... // for(int i=0; i < max; i++) { SnmpValue val= result[i].value; if (val == SnmpVarBind.endOfMibView) return newErrorResponsePdu(req, SnmpDefinitions.snmpRspNoSuchName, i+1); } // So far so good ... // return newValidResponsePdu(req,result); }
Example #22
Source Project: openjdk-jdk8u-backup Author: AdoptOpenJDK File: SnmpRequestHandler.java License: GNU General Public License v2.0 | 5 votes |
private SnmpPduPacket mergeNextResponses(SnmpPduRequest req) { int max= req.varBindList.length; SnmpVarBind[] result= new SnmpVarBind[max]; // Go through the list of subrequests and concatenate. // Hopefully, by now all the sub-requests should be finished // for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) { SnmpSubRequestHandler sub= e.nextElement(); sub.updateResult(result); } if (req.version == snmpVersionTwo) { return newValidResponsePdu(req,result); } // In v1 make sure there is no endOfMibView ... // for(int i=0; i < max; i++) { SnmpValue val= result[i].value; if (val == SnmpVarBind.endOfMibView) return newErrorResponsePdu(req, SnmpDefinitions.snmpRspNoSuchName, i+1); } // So far so good ... // return newValidResponsePdu(req,result); }
Example #23
Source Project: jdk8u60 Author: chenghanpeng File: SnmpRequestHandler.java License: 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 #24
Source Project: jdk8u-jdk Author: lambdalab-mirror File: SnmpRequestHandler.java License: GNU General Public License v2.0 | 5 votes |
private SnmpPduPacket mergeNextResponses(SnmpPduRequest req) { int max= req.varBindList.length; SnmpVarBind[] result= new SnmpVarBind[max]; // Go through the list of subrequests and concatenate. // Hopefully, by now all the sub-requests should be finished // for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) { SnmpSubRequestHandler sub= e.nextElement(); sub.updateResult(result); } if (req.version == snmpVersionTwo) { return newValidResponsePdu(req,result); } // In v1 make sure there is no endOfMibView ... // for(int i=0; i < max; i++) { SnmpValue val= result[i].value; if (val == SnmpVarBind.endOfMibView) return newErrorResponsePdu(req, SnmpDefinitions.snmpRspNoSuchName, i+1); } // So far so good ... // return newValidResponsePdu(req,result); }
Example #25
Source Project: jdk8u-jdk Author: lambdalab-mirror File: SnmpRequestHandler.java License: GNU General Public License v2.0 | 5 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 newErrorResponsePdu(SnmpPduPacket req,int s,int i) { SnmpPduRequest result = newValidResponsePdu(req, null) ; result.errorStatus = s ; result.errorIndex = i ; result.varBindList = req.varBindList ; ((SnmpAdaptorServer)adaptorServer). updateErrorCounters(result.errorStatus) ; return result ; }
Example #26
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: SnmpRequestHandler.java License: GNU General Public License v2.0 | 5 votes |
private SnmpPduPacket mergeNextResponses(SnmpPduRequest req) { int max= req.varBindList.length; SnmpVarBind[] result= new SnmpVarBind[max]; // Go through the list of subrequests and concatenate. // Hopefully, by now all the sub-requests should be finished // for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) { SnmpSubRequestHandler sub= e.nextElement(); sub.updateResult(result); } if (req.version == snmpVersionTwo) { return newValidResponsePdu(req,result); } // In v1 make sure there is no endOfMibView ... // for(int i=0; i < max; i++) { SnmpValue val= result[i].value; if (val == SnmpVarBind.endOfMibView) return newErrorResponsePdu(req, SnmpDefinitions.snmpRspNoSuchName, i+1); } // So far so good ... // return newValidResponsePdu(req,result); }
Example #27
Source Project: JDKSourceCode1.8 Author: wupeixuan File: SnmpAdaptorServer.java License: MIT License | 5 votes |
/** * Send the specified trap PDU to the passed <CODE>SnmpPeer</CODE>. * @param peer The destination peer. The Read community string is used of * <CODE>SnmpParameters</CODE> is used as the trap community string. * @param pdu The pdu to send. * @exception IOException An I/O error occurred while sending the trap. * @exception SnmpStatusException If the trap exceeds the limit defined * by <CODE>bufferSize</CODE>. * @since 1.5 */ @Override public void snmpPduTrap(SnmpPeer peer, SnmpPduPacket pdu) throws IOException, SnmpStatusException { if(peer != null) { pdu.port = peer.getDestPort(); sendTrapPdu(peer.getDestAddr(), pdu); } else { pdu.port = getTrapPort().intValue(); sendTrapPdu(pdu); } }
Example #28
Source Project: JDKSourceCode1.8 Author: wupeixuan File: SnmpRequestHandler.java License: MIT License | 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 #29
Source Project: openjdk-8 Author: bpupadhyaya File: SnmpRequestHandler.java License: GNU General Public License v2.0 | 5 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 newErrorResponsePdu(SnmpPduPacket req,int s,int i) { SnmpPduRequest result = newValidResponsePdu(req, null) ; result.errorStatus = s ; result.errorIndex = i ; result.varBindList = req.varBindList ; ((SnmpAdaptorServer)adaptorServer). updateErrorCounters(result.errorStatus) ; return result ; }
Example #30
Source Project: openjdk-8 Author: bpupadhyaya File: SnmpRequestHandler.java License: GNU General Public License v2.0 | 5 votes |
private SnmpPduPacket mergeNextResponses(SnmpPduRequest req) { int max= req.varBindList.length; SnmpVarBind[] result= new SnmpVarBind[max]; // Go through the list of subrequests and concatenate. // Hopefully, by now all the sub-requests should be finished // for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) { SnmpSubRequestHandler sub= e.nextElement(); sub.updateResult(result); } if (req.version == snmpVersionTwo) { return newValidResponsePdu(req,result); } // In v1 make sure there is no endOfMibView ... // for(int i=0; i < max; i++) { SnmpValue val= result[i].value; if (val == SnmpVarBind.endOfMibView) return newErrorResponsePdu(req, SnmpDefinitions.snmpRspNoSuchName, i+1); } // So far so good ... // return newValidResponsePdu(req,result); }