Java Code Examples for com.sun.jmx.snmp.SnmpPduPacket#pduGetBulkRequestPdu()
The following examples show how to use
com.sun.jmx.snmp.SnmpPduPacket#pduGetBulkRequestPdu() .
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 openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Here we make a response pdu from a request pdu. * We return null if there is no pdu to reply. */ private SnmpPduPacket makeResponsePdu(SnmpPduPacket reqPdu, Object userData) { SnmpAdaptorServer snmpServer = (SnmpAdaptorServer)adaptorServer ; SnmpPduPacket respPdu = null ; snmpServer.updateRequestCounters(reqPdu.type) ; if (reqPdu.varBindList != null) snmpServer.updateVarCounters(reqPdu.type, reqPdu.varBindList.length) ; if (checkPduType(reqPdu)) { respPdu = checkAcl(reqPdu) ; if (respPdu == null) { // reqPdu is accepted by ACLs if (mibs.size() < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "makeResponsePdu", "Request " + reqPdu.requestId + " received but no MIB registered."); } return makeNoMibErrorPdu((SnmpPduRequest)reqPdu, userData); } switch(reqPdu.type) { case SnmpPduPacket.pduGetRequestPdu: case SnmpPduPacket.pduGetNextRequestPdu: case SnmpPduPacket.pduSetRequestPdu: respPdu = makeGetSetResponsePdu((SnmpPduRequest)reqPdu, userData) ; break ; case SnmpPduPacket.pduGetBulkRequestPdu: respPdu = makeGetBulkResponsePdu((SnmpPduBulk)reqPdu, userData) ; break ; } } else { // reqPdu is rejected by ACLs // respPdu contains the error response to be sent. // We send this response only if authResEnabled is true. if (!snmpServer.getAuthRespEnabled()) { // No response should be sent respPdu = null ; } if (snmpServer.getAuthTrapEnabled()) { // A trap must be sent try { snmpServer.snmpV1Trap(SnmpPduTrap. trapAuthenticationFailure, 0, new SnmpVarBindList()) ; } catch(Exception x) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "makeResponsePdu", "Failure when sending authentication trap", x); } } } } } return respPdu ; }
Example 2
Source File: SnmpRequestHandler.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
private SnmpPduPacket reduceResponsePdu(SnmpPduPacket req, SnmpPduPacket resp, int acceptedVbCount) throws SnmpTooBigException { // Reduction can be attempted only on bulk response // if (req.type != SnmpPduPacket.pduGetBulkRequestPdu) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } // We're going to reduce the varbind list. // First determine which items should be removed. // Next duplicate and replace the existing list by the reduced one. // // acceptedVbCount is the number of varbind which have been // successfully encoded before reaching bufferSize: // * when it is >= 2, we split the varbindlist at this // position (-1 to be safe), // * when it is 1, we only put one (big?) item in the varbindlist // * when it is 0 (in fact, acceptedVbCount is not available), // we split the varbindlist by 2. // int vbCount; if (acceptedVbCount >= 3) vbCount = Math.min(acceptedVbCount - 1, resp.varBindList.length) ; else if (acceptedVbCount == 1) vbCount = 1 ; else // acceptedCount == 0 ie it is unknown vbCount = resp.varBindList.length / 2 ; if (vbCount < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } else { SnmpVarBind[] newVbList = new SnmpVarBind[vbCount] ; for (int i = 0 ; i < vbCount ; i++) { newVbList[i] = resp.varBindList[i] ; } if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", (resp.varBindList.length - newVbList.length) + " items have been removed"); } resp.varBindList = newVbList ; } return resp ; }
Example 3
Source File: SnmpRequestHandler.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
/** * Here we make a response pdu from a request pdu. * We return null if there is no pdu to reply. */ private SnmpPduPacket makeResponsePdu(SnmpPduPacket reqPdu, Object userData) { SnmpAdaptorServer snmpServer = (SnmpAdaptorServer)adaptorServer ; SnmpPduPacket respPdu = null ; snmpServer.updateRequestCounters(reqPdu.type) ; if (reqPdu.varBindList != null) snmpServer.updateVarCounters(reqPdu.type, reqPdu.varBindList.length) ; if (checkPduType(reqPdu)) { respPdu = checkAcl(reqPdu) ; if (respPdu == null) { // reqPdu is accepted by ACLs if (mibs.size() < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "makeResponsePdu", "Request " + reqPdu.requestId + " received but no MIB registered."); } return makeNoMibErrorPdu((SnmpPduRequest)reqPdu, userData); } switch(reqPdu.type) { case SnmpPduPacket.pduGetRequestPdu: case SnmpPduPacket.pduGetNextRequestPdu: case SnmpPduPacket.pduSetRequestPdu: respPdu = makeGetSetResponsePdu((SnmpPduRequest)reqPdu, userData) ; break ; case SnmpPduPacket.pduGetBulkRequestPdu: respPdu = makeGetBulkResponsePdu((SnmpPduBulk)reqPdu, userData) ; break ; } } else { // reqPdu is rejected by ACLs // respPdu contains the error response to be sent. // We send this response only if authResEnabled is true. if (!snmpServer.getAuthRespEnabled()) { // No response should be sent respPdu = null ; } if (snmpServer.getAuthTrapEnabled()) { // A trap must be sent try { snmpServer.snmpV1Trap(SnmpPduTrap. trapAuthenticationFailure, 0, new SnmpVarBindList()) ; } catch(Exception x) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "makeResponsePdu", "Failure when sending authentication trap", x); } } } } } return respPdu ; }
Example 4
Source File: SnmpRequestHandler.java From hottub with GNU General Public License v2.0 | 4 votes |
private SnmpPduPacket reduceResponsePdu(SnmpPduPacket req, SnmpPduPacket resp, int acceptedVbCount) throws SnmpTooBigException { // Reduction can be attempted only on bulk response // if (req.type != SnmpPduPacket.pduGetBulkRequestPdu) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } // We're going to reduce the varbind list. // First determine which items should be removed. // Next duplicate and replace the existing list by the reduced one. // // acceptedVbCount is the number of varbind which have been // successfully encoded before reaching bufferSize: // * when it is >= 2, we split the varbindlist at this // position (-1 to be safe), // * when it is 1, we only put one (big?) item in the varbindlist // * when it is 0 (in fact, acceptedVbCount is not available), // we split the varbindlist by 2. // int vbCount; if (acceptedVbCount >= 3) vbCount = Math.min(acceptedVbCount - 1, resp.varBindList.length) ; else if (acceptedVbCount == 1) vbCount = 1 ; else // acceptedCount == 0 ie it is unknown vbCount = resp.varBindList.length / 2 ; if (vbCount < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } else { SnmpVarBind[] newVbList = new SnmpVarBind[vbCount] ; for (int i = 0 ; i < vbCount ; i++) { newVbList[i] = resp.varBindList[i] ; } if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", (resp.varBindList.length - newVbList.length) + " items have been removed"); } resp.varBindList = newVbList ; } return resp ; }
Example 5
Source File: SnmpRequestHandler.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Here we make a response pdu from a request pdu. * We return null if there is no pdu to reply. */ private SnmpPduPacket makeResponsePdu(SnmpPduPacket reqPdu, Object userData) { SnmpAdaptorServer snmpServer = (SnmpAdaptorServer)adaptorServer ; SnmpPduPacket respPdu = null ; snmpServer.updateRequestCounters(reqPdu.type) ; if (reqPdu.varBindList != null) snmpServer.updateVarCounters(reqPdu.type, reqPdu.varBindList.length) ; if (checkPduType(reqPdu)) { respPdu = checkAcl(reqPdu) ; if (respPdu == null) { // reqPdu is accepted by ACLs if (mibs.size() < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "makeResponsePdu", "Request " + reqPdu.requestId + " received but no MIB registered."); } return makeNoMibErrorPdu((SnmpPduRequest)reqPdu, userData); } switch(reqPdu.type) { case SnmpPduPacket.pduGetRequestPdu: case SnmpPduPacket.pduGetNextRequestPdu: case SnmpPduPacket.pduSetRequestPdu: respPdu = makeGetSetResponsePdu((SnmpPduRequest)reqPdu, userData) ; break ; case SnmpPduPacket.pduGetBulkRequestPdu: respPdu = makeGetBulkResponsePdu((SnmpPduBulk)reqPdu, userData) ; break ; } } else { // reqPdu is rejected by ACLs // respPdu contains the error response to be sent. // We send this response only if authResEnabled is true. if (!snmpServer.getAuthRespEnabled()) { // No response should be sent respPdu = null ; } if (snmpServer.getAuthTrapEnabled()) { // A trap must be sent try { snmpServer.snmpV1Trap(SnmpPduTrap. trapAuthenticationFailure, 0, new SnmpVarBindList()) ; } catch(Exception x) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "makeResponsePdu", "Failure when sending authentication trap", x); } } } } } return respPdu ; }
Example 6
Source File: SnmpRequestHandler.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private SnmpPduPacket reduceResponsePdu(SnmpPduPacket req, SnmpPduPacket resp, int acceptedVbCount) throws SnmpTooBigException { // Reduction can be attempted only on bulk response // if (req.type != SnmpPduPacket.pduGetBulkRequestPdu) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } // We're going to reduce the varbind list. // First determine which items should be removed. // Next duplicate and replace the existing list by the reduced one. // // acceptedVbCount is the number of varbind which have been // successfully encoded before reaching bufferSize: // * when it is >= 2, we split the varbindlist at this // position (-1 to be safe), // * when it is 1, we only put one (big?) item in the varbindlist // * when it is 0 (in fact, acceptedVbCount is not available), // we split the varbindlist by 2. // int vbCount; if (acceptedVbCount >= 3) vbCount = Math.min(acceptedVbCount - 1, resp.varBindList.length) ; else if (acceptedVbCount == 1) vbCount = 1 ; else // acceptedCount == 0 ie it is unknown vbCount = resp.varBindList.length / 2 ; if (vbCount < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } else { SnmpVarBind[] newVbList = new SnmpVarBind[vbCount] ; for (int i = 0 ; i < vbCount ; i++) { newVbList[i] = resp.varBindList[i] ; } if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", (resp.varBindList.length - newVbList.length) + " items have been removed"); } resp.varBindList = newVbList ; } return resp ; }
Example 7
Source File: SnmpRequestHandler.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Here we make a response pdu from a request pdu. * We return null if there is no pdu to reply. */ private SnmpPduPacket makeResponsePdu(SnmpPduPacket reqPdu, Object userData) { SnmpAdaptorServer snmpServer = (SnmpAdaptorServer)adaptorServer ; SnmpPduPacket respPdu = null ; snmpServer.updateRequestCounters(reqPdu.type) ; if (reqPdu.varBindList != null) snmpServer.updateVarCounters(reqPdu.type, reqPdu.varBindList.length) ; if (checkPduType(reqPdu)) { respPdu = checkAcl(reqPdu) ; if (respPdu == null) { // reqPdu is accepted by ACLs if (mibs.size() < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "makeResponsePdu", "Request " + reqPdu.requestId + " received but no MIB registered."); } return makeNoMibErrorPdu((SnmpPduRequest)reqPdu, userData); } switch(reqPdu.type) { case SnmpPduPacket.pduGetRequestPdu: case SnmpPduPacket.pduGetNextRequestPdu: case SnmpPduPacket.pduSetRequestPdu: respPdu = makeGetSetResponsePdu((SnmpPduRequest)reqPdu, userData) ; break ; case SnmpPduPacket.pduGetBulkRequestPdu: respPdu = makeGetBulkResponsePdu((SnmpPduBulk)reqPdu, userData) ; break ; } } else { // reqPdu is rejected by ACLs // respPdu contains the error response to be sent. // We send this response only if authResEnabled is true. if (!snmpServer.getAuthRespEnabled()) { // No response should be sent respPdu = null ; } if (snmpServer.getAuthTrapEnabled()) { // A trap must be sent try { snmpServer.snmpV1Trap(SnmpPduTrap. trapAuthenticationFailure, 0, new SnmpVarBindList()) ; } catch(Exception x) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "makeResponsePdu", "Failure when sending authentication trap", x); } } } } } return respPdu ; }
Example 8
Source File: SnmpRequestHandler.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
private SnmpPduPacket reduceResponsePdu(SnmpPduPacket req, SnmpPduPacket resp, int acceptedVbCount) throws SnmpTooBigException { // Reduction can be attempted only on bulk response // if (req.type != SnmpPduPacket.pduGetBulkRequestPdu) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } // We're going to reduce the varbind list. // First determine which items should be removed. // Next duplicate and replace the existing list by the reduced one. // // acceptedVbCount is the number of varbind which have been // successfully encoded before reaching bufferSize: // * when it is >= 2, we split the varbindlist at this // position (-1 to be safe), // * when it is 1, we only put one (big?) item in the varbindlist // * when it is 0 (in fact, acceptedVbCount is not available), // we split the varbindlist by 2. // int vbCount; if (acceptedVbCount >= 3) vbCount = Math.min(acceptedVbCount - 1, resp.varBindList.length) ; else if (acceptedVbCount == 1) vbCount = 1 ; else // acceptedCount == 0 ie it is unknown vbCount = resp.varBindList.length / 2 ; if (vbCount < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } else { SnmpVarBind[] newVbList = new SnmpVarBind[vbCount] ; for (int i = 0 ; i < vbCount ; i++) { newVbList[i] = resp.varBindList[i] ; } if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", (resp.varBindList.length - newVbList.length) + " items have been removed"); } resp.varBindList = newVbList ; } return resp ; }
Example 9
Source File: SnmpRequestHandler.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Here we make a response pdu from a request pdu. * We return null if there is no pdu to reply. */ private SnmpPduPacket makeResponsePdu(SnmpPduPacket reqPdu, Object userData) { SnmpAdaptorServer snmpServer = (SnmpAdaptorServer)adaptorServer ; SnmpPduPacket respPdu = null ; snmpServer.updateRequestCounters(reqPdu.type) ; if (reqPdu.varBindList != null) snmpServer.updateVarCounters(reqPdu.type, reqPdu.varBindList.length) ; if (checkPduType(reqPdu)) { respPdu = checkAcl(reqPdu) ; if (respPdu == null) { // reqPdu is accepted by ACLs if (mibs.size() < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "makeResponsePdu", "Request " + reqPdu.requestId + " received but no MIB registered."); } return makeNoMibErrorPdu((SnmpPduRequest)reqPdu, userData); } switch(reqPdu.type) { case SnmpPduPacket.pduGetRequestPdu: case SnmpPduPacket.pduGetNextRequestPdu: case SnmpPduPacket.pduSetRequestPdu: respPdu = makeGetSetResponsePdu((SnmpPduRequest)reqPdu, userData) ; break ; case SnmpPduPacket.pduGetBulkRequestPdu: respPdu = makeGetBulkResponsePdu((SnmpPduBulk)reqPdu, userData) ; break ; } } else { // reqPdu is rejected by ACLs // respPdu contains the error response to be sent. // We send this response only if authResEnabled is true. if (!snmpServer.getAuthRespEnabled()) { // No response should be sent respPdu = null ; } if (snmpServer.getAuthTrapEnabled()) { // A trap must be sent try { snmpServer.snmpV1Trap(SnmpPduTrap. trapAuthenticationFailure, 0, new SnmpVarBindList()) ; } catch(Exception x) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "makeResponsePdu", "Failure when sending authentication trap", x); } } } } } return respPdu ; }
Example 10
Source File: SnmpRequestHandler.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * Here we make a response pdu from a request pdu. * We return null if there is no pdu to reply. */ private SnmpPduPacket makeResponsePdu(SnmpPduPacket reqPdu, Object userData) { SnmpAdaptorServer snmpServer = (SnmpAdaptorServer)adaptorServer ; SnmpPduPacket respPdu = null ; snmpServer.updateRequestCounters(reqPdu.type) ; if (reqPdu.varBindList != null) snmpServer.updateVarCounters(reqPdu.type, reqPdu.varBindList.length) ; if (checkPduType(reqPdu)) { respPdu = checkAcl(reqPdu) ; if (respPdu == null) { // reqPdu is accepted by ACLs if (mibs.size() < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "makeResponsePdu", "Request " + reqPdu.requestId + " received but no MIB registered."); } return makeNoMibErrorPdu((SnmpPduRequest)reqPdu, userData); } switch(reqPdu.type) { case SnmpPduPacket.pduGetRequestPdu: case SnmpPduPacket.pduGetNextRequestPdu: case SnmpPduPacket.pduSetRequestPdu: respPdu = makeGetSetResponsePdu((SnmpPduRequest)reqPdu, userData) ; break ; case SnmpPduPacket.pduGetBulkRequestPdu: respPdu = makeGetBulkResponsePdu((SnmpPduBulk)reqPdu, userData) ; break ; } } else { // reqPdu is rejected by ACLs // respPdu contains the error response to be sent. // We send this response only if authResEnabled is true. if (!snmpServer.getAuthRespEnabled()) { // No response should be sent respPdu = null ; } if (snmpServer.getAuthTrapEnabled()) { // A trap must be sent try { snmpServer.snmpV1Trap(SnmpPduTrap. trapAuthenticationFailure, 0, new SnmpVarBindList()) ; } catch(Exception x) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "makeResponsePdu", "Failure when sending authentication trap", x); } } } } } return respPdu ; }
Example 11
Source File: SnmpRequestHandler.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** * Here we make a response pdu from a request pdu. * We return null if there is no pdu to reply. */ private SnmpPduPacket makeResponsePdu(SnmpPduPacket reqPdu, Object userData) { SnmpAdaptorServer snmpServer = (SnmpAdaptorServer)adaptorServer ; SnmpPduPacket respPdu = null ; snmpServer.updateRequestCounters(reqPdu.type) ; if (reqPdu.varBindList != null) snmpServer.updateVarCounters(reqPdu.type, reqPdu.varBindList.length) ; if (checkPduType(reqPdu)) { respPdu = checkAcl(reqPdu) ; if (respPdu == null) { // reqPdu is accepted by ACLs if (mibs.size() < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "makeResponsePdu", "Request " + reqPdu.requestId + " received but no MIB registered."); } return makeNoMibErrorPdu((SnmpPduRequest)reqPdu, userData); } switch(reqPdu.type) { case SnmpPduPacket.pduGetRequestPdu: case SnmpPduPacket.pduGetNextRequestPdu: case SnmpPduPacket.pduSetRequestPdu: respPdu = makeGetSetResponsePdu((SnmpPduRequest)reqPdu, userData) ; break ; case SnmpPduPacket.pduGetBulkRequestPdu: respPdu = makeGetBulkResponsePdu((SnmpPduBulk)reqPdu, userData) ; break ; } } else { // reqPdu is rejected by ACLs // respPdu contains the error response to be sent. // We send this response only if authResEnabled is true. if (!snmpServer.getAuthRespEnabled()) { // No response should be sent respPdu = null ; } if (snmpServer.getAuthTrapEnabled()) { // A trap must be sent try { snmpServer.snmpV1Trap(SnmpPduTrap. trapAuthenticationFailure, 0, new SnmpVarBindList()) ; } catch(Exception x) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "makeResponsePdu", "Failure when sending authentication trap", x); } } } } } return respPdu ; }
Example 12
Source File: SnmpRequestHandler.java From JDKSourceCode1.8 with MIT License | 4 votes |
private SnmpPduPacket reduceResponsePdu(SnmpPduPacket req, SnmpPduPacket resp, int acceptedVbCount) throws SnmpTooBigException { // Reduction can be attempted only on bulk response // if (req.type != SnmpPduPacket.pduGetBulkRequestPdu) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } // We're going to reduce the varbind list. // First determine which items should be removed. // Next duplicate and replace the existing list by the reduced one. // // acceptedVbCount is the number of varbind which have been // successfully encoded before reaching bufferSize: // * when it is >= 2, we split the varbindlist at this // position (-1 to be safe), // * when it is 1, we only put one (big?) item in the varbindlist // * when it is 0 (in fact, acceptedVbCount is not available), // we split the varbindlist by 2. // int vbCount; if (acceptedVbCount >= 3) vbCount = Math.min(acceptedVbCount - 1, resp.varBindList.length) ; else if (acceptedVbCount == 1) vbCount = 1 ; else // acceptedCount == 0 ie it is unknown vbCount = resp.varBindList.length / 2 ; if (vbCount < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } else { SnmpVarBind[] newVbList = new SnmpVarBind[vbCount] ; for (int i = 0 ; i < vbCount ; i++) { newVbList[i] = resp.varBindList[i] ; } if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", (resp.varBindList.length - newVbList.length) + " items have been removed"); } resp.varBindList = newVbList ; } return resp ; }
Example 13
Source File: SnmpRequestHandler.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * Here we make a response pdu from a request pdu. * We return null if there is no pdu to reply. */ private SnmpPduPacket makeResponsePdu(SnmpPduPacket reqPdu, Object userData) { SnmpAdaptorServer snmpServer = (SnmpAdaptorServer)adaptorServer ; SnmpPduPacket respPdu = null ; snmpServer.updateRequestCounters(reqPdu.type) ; if (reqPdu.varBindList != null) snmpServer.updateVarCounters(reqPdu.type, reqPdu.varBindList.length) ; if (checkPduType(reqPdu)) { respPdu = checkAcl(reqPdu) ; if (respPdu == null) { // reqPdu is accepted by ACLs if (mibs.size() < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "makeResponsePdu", "Request " + reqPdu.requestId + " received but no MIB registered."); } return makeNoMibErrorPdu((SnmpPduRequest)reqPdu, userData); } switch(reqPdu.type) { case SnmpPduPacket.pduGetRequestPdu: case SnmpPduPacket.pduGetNextRequestPdu: case SnmpPduPacket.pduSetRequestPdu: respPdu = makeGetSetResponsePdu((SnmpPduRequest)reqPdu, userData) ; break ; case SnmpPduPacket.pduGetBulkRequestPdu: respPdu = makeGetBulkResponsePdu((SnmpPduBulk)reqPdu, userData) ; break ; } } else { // reqPdu is rejected by ACLs // respPdu contains the error response to be sent. // We send this response only if authResEnabled is true. if (!snmpServer.getAuthRespEnabled()) { // No response should be sent respPdu = null ; } if (snmpServer.getAuthTrapEnabled()) { // A trap must be sent try { snmpServer.snmpV1Trap(SnmpPduTrap. trapAuthenticationFailure, 0, new SnmpVarBindList()) ; } catch(Exception x) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "makeResponsePdu", "Failure when sending authentication trap", x); } } } } } return respPdu ; }
Example 14
Source File: SnmpRequestHandler.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
private SnmpPduPacket reduceResponsePdu(SnmpPduPacket req, SnmpPduPacket resp, int acceptedVbCount) throws SnmpTooBigException { // Reduction can be attempted only on bulk response // if (req.type != SnmpPduPacket.pduGetBulkRequestPdu) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } // We're going to reduce the varbind list. // First determine which items should be removed. // Next duplicate and replace the existing list by the reduced one. // // acceptedVbCount is the number of varbind which have been // successfully encoded before reaching bufferSize: // * when it is >= 2, we split the varbindlist at this // position (-1 to be safe), // * when it is 1, we only put one (big?) item in the varbindlist // * when it is 0 (in fact, acceptedVbCount is not available), // we split the varbindlist by 2. // int vbCount; if (acceptedVbCount >= 3) vbCount = Math.min(acceptedVbCount - 1, resp.varBindList.length) ; else if (acceptedVbCount == 1) vbCount = 1 ; else // acceptedCount == 0 ie it is unknown vbCount = resp.varBindList.length / 2 ; if (vbCount < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } else { SnmpVarBind[] newVbList = new SnmpVarBind[vbCount] ; for (int i = 0 ; i < vbCount ; i++) { newVbList[i] = resp.varBindList[i] ; } if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", (resp.varBindList.length - newVbList.length) + " items have been removed"); } resp.varBindList = newVbList ; } return resp ; }
Example 15
Source File: SnmpRequestHandler.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Here we make a response pdu from a request pdu. * We return null if there is no pdu to reply. */ private SnmpPduPacket makeResponsePdu(SnmpPduPacket reqPdu, Object userData) { SnmpAdaptorServer snmpServer = (SnmpAdaptorServer)adaptorServer ; SnmpPduPacket respPdu = null ; snmpServer.updateRequestCounters(reqPdu.type) ; if (reqPdu.varBindList != null) snmpServer.updateVarCounters(reqPdu.type, reqPdu.varBindList.length) ; if (checkPduType(reqPdu)) { respPdu = checkAcl(reqPdu) ; if (respPdu == null) { // reqPdu is accepted by ACLs if (mibs.size() < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "makeResponsePdu", "Request " + reqPdu.requestId + " received but no MIB registered."); } return makeNoMibErrorPdu((SnmpPduRequest)reqPdu, userData); } switch(reqPdu.type) { case SnmpPduPacket.pduGetRequestPdu: case SnmpPduPacket.pduGetNextRequestPdu: case SnmpPduPacket.pduSetRequestPdu: respPdu = makeGetSetResponsePdu((SnmpPduRequest)reqPdu, userData) ; break ; case SnmpPduPacket.pduGetBulkRequestPdu: respPdu = makeGetBulkResponsePdu((SnmpPduBulk)reqPdu, userData) ; break ; } } else { // reqPdu is rejected by ACLs // respPdu contains the error response to be sent. // We send this response only if authResEnabled is true. if (!snmpServer.getAuthRespEnabled()) { // No response should be sent respPdu = null ; } if (snmpServer.getAuthTrapEnabled()) { // A trap must be sent try { snmpServer.snmpV1Trap(SnmpPduTrap. trapAuthenticationFailure, 0, new SnmpVarBindList()) ; } catch(Exception x) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "makeResponsePdu", "Failure when sending authentication trap", x); } } } } } return respPdu ; }
Example 16
Source File: SnmpRequestHandler.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private SnmpPduPacket reduceResponsePdu(SnmpPduPacket req, SnmpPduPacket resp, int acceptedVbCount) throws SnmpTooBigException { // Reduction can be attempted only on bulk response // if (req.type != SnmpPduPacket.pduGetBulkRequestPdu) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } // We're going to reduce the varbind list. // First determine which items should be removed. // Next duplicate and replace the existing list by the reduced one. // // acceptedVbCount is the number of varbind which have been // successfully encoded before reaching bufferSize: // * when it is >= 2, we split the varbindlist at this // position (-1 to be safe), // * when it is 1, we only put one (big?) item in the varbindlist // * when it is 0 (in fact, acceptedVbCount is not available), // we split the varbindlist by 2. // int vbCount; if (acceptedVbCount >= 3) vbCount = Math.min(acceptedVbCount - 1, resp.varBindList.length) ; else if (acceptedVbCount == 1) vbCount = 1 ; else // acceptedCount == 0 ie it is unknown vbCount = resp.varBindList.length / 2 ; if (vbCount < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } else { SnmpVarBind[] newVbList = new SnmpVarBind[vbCount] ; for (int i = 0 ; i < vbCount ; i++) { newVbList[i] = resp.varBindList[i] ; } if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", (resp.varBindList.length - newVbList.length) + " items have been removed"); } resp.varBindList = newVbList ; } return resp ; }
Example 17
Source File: SnmpRequestHandler.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
private SnmpPduPacket reduceResponsePdu(SnmpPduPacket req, SnmpPduPacket resp, int acceptedVbCount) throws SnmpTooBigException { // Reduction can be attempted only on bulk response // if (req.type != SnmpPduPacket.pduGetBulkRequestPdu) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } // We're going to reduce the varbind list. // First determine which items should be removed. // Next duplicate and replace the existing list by the reduced one. // // acceptedVbCount is the number of varbind which have been // successfully encoded before reaching bufferSize: // * when it is >= 2, we split the varbindlist at this // position (-1 to be safe), // * when it is 1, we only put one (big?) item in the varbindlist // * when it is 0 (in fact, acceptedVbCount is not available), // we split the varbindlist by 2. // int vbCount; if (acceptedVbCount >= 3) vbCount = Math.min(acceptedVbCount - 1, resp.varBindList.length) ; else if (acceptedVbCount == 1) vbCount = 1 ; else // acceptedCount == 0 ie it is unknown vbCount = resp.varBindList.length / 2 ; if (vbCount < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } else { SnmpVarBind[] newVbList = new SnmpVarBind[vbCount] ; for (int i = 0 ; i < vbCount ; i++) { newVbList[i] = resp.varBindList[i] ; } if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", (resp.varBindList.length - newVbList.length) + " items have been removed"); } resp.varBindList = newVbList ; } return resp ; }
Example 18
Source File: SnmpRequestHandler.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
private SnmpPduPacket reduceResponsePdu(SnmpPduPacket req, SnmpPduPacket resp, int acceptedVbCount) throws SnmpTooBigException { // Reduction can be attempted only on bulk response // if (req.type != SnmpPduPacket.pduGetBulkRequestPdu) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } // We're going to reduce the varbind list. // First determine which items should be removed. // Next duplicate and replace the existing list by the reduced one. // // acceptedVbCount is the number of varbind which have been // successfully encoded before reaching bufferSize: // * when it is >= 2, we split the varbindlist at this // position (-1 to be safe), // * when it is 1, we only put one (big?) item in the varbindlist // * when it is 0 (in fact, acceptedVbCount is not available), // we split the varbindlist by 2. // int vbCount; if (acceptedVbCount >= 3) vbCount = Math.min(acceptedVbCount - 1, resp.varBindList.length) ; else if (acceptedVbCount == 1) vbCount = 1 ; else // acceptedCount == 0 ie it is unknown vbCount = resp.varBindList.length / 2 ; if (vbCount < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } else { SnmpVarBind[] newVbList = new SnmpVarBind[vbCount] ; for (int i = 0 ; i < vbCount ; i++) { newVbList[i] = resp.varBindList[i] ; } if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", (resp.varBindList.length - newVbList.length) + " items have been removed"); } resp.varBindList = newVbList ; } return resp ; }
Example 19
Source File: SnmpRequestHandler.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Here we make a response pdu from a request pdu. * We return null if there is no pdu to reply. */ private SnmpPduPacket makeResponsePdu(SnmpPduPacket reqPdu, Object userData) { SnmpAdaptorServer snmpServer = (SnmpAdaptorServer)adaptorServer ; SnmpPduPacket respPdu = null ; snmpServer.updateRequestCounters(reqPdu.type) ; if (reqPdu.varBindList != null) snmpServer.updateVarCounters(reqPdu.type, reqPdu.varBindList.length) ; if (checkPduType(reqPdu)) { respPdu = checkAcl(reqPdu) ; if (respPdu == null) { // reqPdu is accepted by ACLs if (mibs.size() < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "makeResponsePdu", "Request " + reqPdu.requestId + " received but no MIB registered."); } return makeNoMibErrorPdu((SnmpPduRequest)reqPdu, userData); } switch(reqPdu.type) { case SnmpPduPacket.pduGetRequestPdu: case SnmpPduPacket.pduGetNextRequestPdu: case SnmpPduPacket.pduSetRequestPdu: respPdu = makeGetSetResponsePdu((SnmpPduRequest)reqPdu, userData) ; break ; case SnmpPduPacket.pduGetBulkRequestPdu: respPdu = makeGetBulkResponsePdu((SnmpPduBulk)reqPdu, userData) ; break ; } } else { // reqPdu is rejected by ACLs // respPdu contains the error response to be sent. // We send this response only if authResEnabled is true. if (!snmpServer.getAuthRespEnabled()) { // No response should be sent respPdu = null ; } if (snmpServer.getAuthTrapEnabled()) { // A trap must be sent try { snmpServer.snmpV1Trap(SnmpPduTrap. trapAuthenticationFailure, 0, new SnmpVarBindList()) ; } catch(Exception x) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "makeResponsePdu", "Failure when sending authentication trap", x); } } } } } return respPdu ; }
Example 20
Source File: SnmpRequestHandler.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
private SnmpPduPacket reduceResponsePdu(SnmpPduPacket req, SnmpPduPacket resp, int acceptedVbCount) throws SnmpTooBigException { // Reduction can be attempted only on bulk response // if (req.type != SnmpPduPacket.pduGetBulkRequestPdu) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } // We're going to reduce the varbind list. // First determine which items should be removed. // Next duplicate and replace the existing list by the reduced one. // // acceptedVbCount is the number of varbind which have been // successfully encoded before reaching bufferSize: // * when it is >= 2, we split the varbindlist at this // position (-1 to be safe), // * when it is 1, we only put one (big?) item in the varbindlist // * when it is 0 (in fact, acceptedVbCount is not available), // we split the varbindlist by 2. // int vbCount; if (acceptedVbCount >= 3) vbCount = Math.min(acceptedVbCount - 1, resp.varBindList.length) ; else if (acceptedVbCount == 1) vbCount = 1 ; else // acceptedCount == 0 ie it is unknown vbCount = resp.varBindList.length / 2 ; if (vbCount < 1) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", "cannot remove anything"); } throw new SnmpTooBigException(acceptedVbCount) ; } else { SnmpVarBind[] newVbList = new SnmpVarBind[vbCount] ; for (int i = 0 ; i < vbCount ; i++) { newVbList[i] = resp.varBindList[i] ; } if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "reduceResponsePdu", (resp.varBindList.length - newVbList.length) + " items have been removed"); } resp.varBindList = newVbList ; } return resp ; }