Search in sources :

Example 1 with SnmpPduBulk

use of com.sun.jmx.snmp.SnmpPduBulk in project jdk8u_jdk by JetBrains.

the class SnmpRequestHandler method makeResponsePdu.

/**
     * 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 {
            // 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;
}
Also used : SnmpPduBulk(com.sun.jmx.snmp.SnmpPduBulk) SnmpPduPacket(com.sun.jmx.snmp.SnmpPduPacket) SnmpPduRequest(com.sun.jmx.snmp.SnmpPduRequest) SnmpVarBindList(com.sun.jmx.snmp.SnmpVarBindList) SnmpTooBigException(com.sun.jmx.snmp.SnmpTooBigException) InterruptedIOException(java.io.InterruptedIOException) SocketException(java.net.SocketException) SnmpStatusException(com.sun.jmx.snmp.SnmpStatusException)

Aggregations

SnmpPduBulk (com.sun.jmx.snmp.SnmpPduBulk)1 SnmpPduPacket (com.sun.jmx.snmp.SnmpPduPacket)1 SnmpPduRequest (com.sun.jmx.snmp.SnmpPduRequest)1 SnmpStatusException (com.sun.jmx.snmp.SnmpStatusException)1 SnmpTooBigException (com.sun.jmx.snmp.SnmpTooBigException)1 SnmpVarBindList (com.sun.jmx.snmp.SnmpVarBindList)1 InterruptedIOException (java.io.InterruptedIOException)1 SocketException (java.net.SocketException)1