/** For SNMP Runtime internal use only. */
  final void processResponse() {

    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
      SNMP_ADAPTOR_LOGGER.logp(
          Level.FINER,
          SnmpInformRequest.class.getName(),
          "processResponse",
          "errstatus = " + errorStatus);
    }

    if (inProgress() == false) { // check if this request is still alive.
      responsePdu = null;
      return; // the request may have  cancelled.
    }

    if (errorStatus >= snmpReqInternalError) {
      handleInternalError("Internal Error...");
      return;
    }

    try {
      parsePduPacket(responsePdu);
      // responsePdu = null;

      // At this point the errorIndex is rationalized to start with 0.
      switch (errorStatus) {
        case snmpRspNoError:
          handleSuccess();
          return;
        case snmpReqTimeout:
          handleTimeout();
          return;
        case snmpReqInternalError:
          handleInternalError("Unknown internal error.  deal with it later!");
          return;
        case snmpReqHandleTooBig:
          setErrorStatusAndIndex(snmpRspTooBig, 0);
          handleError("Cannot handle too-big situation...");
          return;
        case snmpReqRefireAfterVbFix:
          // Refire request after fixing varbindlist.
          initializeAndFire();
          return;
        default:
          handleError("Error status set in packet...!!");
          return;
      }
    } catch (Exception e) {
      if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
        SNMP_ADAPTOR_LOGGER.logp(
            Level.FINEST,
            SnmpInformRequest.class.getName(),
            "processResponse",
            "Got unexpected exception",
            e);
      }
      reason = e.getMessage();
    }
    handleInternalError(reason);
  }
 private synchronized void initializeAndFire() {
   requestPdu = null;
   responsePdu = null;
   reason = null;
   startRequest(System.currentTimeMillis());
   setErrorStatusAndIndex(0, 0);
 }
  boolean sendPdu() {
    try {
      responsePdu = null;

      SnmpPduFactory pduFactory = adaptor.getPduFactory();
      SnmpMessage msg =
          (SnmpMessage)
              pduFactory.encodeSnmpPdu(
                  (SnmpPduPacket) requestPdu, adaptor.getBufferSize().intValue());

      if (msg == null) {
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
          SNMP_ADAPTOR_LOGGER.logp(
              Level.FINEST,
              SnmpInformRequest.class.getName(),
              "sendPdu",
              "pdu factory returned a null value");
        }
        throw new SnmpStatusException(snmpReqUnknownError);
        // This exception will caught hereafter and reported as an snmpReqUnknownError
        // FIXME: may be it's not the best behaviour ?
      }

      int maxPktSize = adaptor.getBufferSize().intValue();
      byte[] encoding = new byte[maxPktSize];
      int encodingLength = msg.encodeMessage(encoding);

      if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
        SNMP_ADAPTOR_LOGGER.logp(
            Level.FINER,
            SnmpInformRequest.class.getName(),
            "sendPdu",
            "Dump : \n" + msg.printMessage());
      }

      sendPduPacket(encoding, encodingLength);
      return true;
    } catch (SnmpTooBigException ar) {

      if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
        SNMP_ADAPTOR_LOGGER.logp(
            Level.FINEST,
            SnmpInformRequest.class.getName(),
            "sendPdu",
            "Got unexpected exception",
            ar);
      }

      setErrorStatusAndIndex(snmpReqPacketOverflow, ar.getVarBindCount());
      requestPdu = null;
      reason = ar.getMessage();
      if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
        SNMP_ADAPTOR_LOGGER.logp(
            Level.FINEST,
            SnmpInformRequest.class.getName(),
            "sendPdu",
            "Packet Overflow while building inform request");
      }
    } catch (java.io.IOException ioe) {
      setErrorStatusAndIndex(snmpReqSocketIOError, 0);
      reason = ioe.getMessage();
    } catch (Exception e) {
      if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
        SNMP_ADAPTOR_LOGGER.logp(
            Level.FINEST,
            SnmpInformRequest.class.getName(),
            "sendPdu",
            "Got unexpected exception",
            e);
      }
      setErrorStatusAndIndex(snmpReqUnknownError, 0);
      reason = e.getMessage();
    }
    return false;
  }