[SNMP4J] ACM-MIB and SNMPwalk.

Frank Fock fock at agentpp.com
Tue Oct 11 01:21:38 CEST 2005


Matthias,

There is a bug in the code that applies SNMPv1 error status on the
response PDU. The error is that the error status noSuchName is not
set on the GETNEXT response on the last supported OID (SNMPv1 only).

Please replace the following method in SnmpRequest.java of SNMP4J-Agent
(Basically mov the "break;"  one line up and change it to "return;"):

  protected void assignErrorStatus2Response() {
    int errStatus = getErrorStatus();
    if (requestEvent.getMessageProcessingModel() == 
MessageProcessingModel.MPv1) {
      switch (errStatus) {
        case SnmpConstants.SNMP_ERROR_NOT_WRITEABLE:
        case SnmpConstants.SNMP_ERROR_NO_ACCESS:
        case SnmpConstants.SNMP_ERROR_NO_CREATION:
        case SnmpConstants.SNMP_ERROR_INCONSISTENT_NAME: {
          response.setErrorStatus(SnmpConstants.SNMP_ERROR_NO_SUCH_NAME);
          break;
        }
        case SnmpConstants.SNMP_ERROR_RESOURCE_UNAVAILABLE:
        case SnmpConstants.SNMP_ERROR_COMMIT_FAILED:
        case SnmpConstants.SNMP_ERROR_UNDO_FAILED: {
          response.setErrorStatus(SnmpConstants.SNMP_ERROR_GENERAL_ERROR);
          break;
        }
        case SnmpConstants.SNMP_ERROR_WRONG_VALUE:
        case SnmpConstants.SNMP_ERROR_WRONG_LENGTH:
        case SnmpConstants.SNMP_ERROR_INCONSISTENT_VALUE:
        case SnmpConstants.SNMP_ERROR_WRONG_TYPE: {
          response.setErrorStatus(SnmpConstants.SNMP_ERROR_BAD_VALUE);
          break;
        }
        default: {
          response.setErrorStatus(errStatus);
        }
      }
      for (int i=0; i<response.size(); i++) {
        VariableBinding vb = response.get(i);
        if (vb.isException()) {
          response.setErrorStatus(PDU.noSuchName);
          response.setErrorIndex(i+1);
          response.set(i, new VariableBinding(vb.getOid()));
          return;
        }
      }
    }
    response.setErrorStatus(errStatus);
    response.setErrorIndex(getErrorIndex());
  }

Best regards,
Frank

Matthias Wiesmann wrote:

>I have noticed that the TestAgent that comes with version 1.0 alpha 2
>fails with a simple SNMP walk in the ACM-MIB. Basically, OIDs fail to
>increase at the end of the MIB.
>
>The problem occurs on both Mac OS X and Linux.
>
>Is there a way to address this?
>
>Environnement:
>=============
>Darwin reki.local 8.2.0 Darwin Kernel Version 8.2.0: Fri Jun 24
>17:46:54 PDT 2005; root:xnu-792.2.4.obj~3/RELEASE_PPC Power Macintosh
>powerpc
>
>Linux ddg.jaist.ac.jp 2.6.12-1.1447_FC4smp #1 SMP Fri Aug 26 20:57:13
>EDT 2005 i686 i686 i386 GNU/Linux
>
>(Mac OS X) snmpwalk: Version:  5.2.1  http://www.net-snmp.org/
>(Linux) Version:  5.2.1.2 Web:      http://www.net-snmp.org/
>
>(Mac OS X) java version "1.4.2_09"
>Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_09-232)
>Java HotSpot(TM) Client VM (build 1.4.2-54, mixed mode)
>
>(Linux) java version "1.4.2"
>gij (GNU libgcj) version 4.0.1 20050727 (Red Hat 4.0.1-5)
>
>Copyright (C) 2005 Free Software Foundation, Inc.
>
>
>How to get the problem
>===================
>
>1) start the agent java -cp SNMP4J.jar:.:log4j-1.2.9.jar
>org.snmp4j.agent.test.TestAgent 127.0.0.1/1616
>2) do a snmpwalk: snmpwalk -v 1 -c public 127.0.0.1:1616 .
>
>On the agent side:
>===============
>
>14537 [DefaultUDPTransportMapping_127.0.0.1/1616] DEBUG
>org.snmp4j.Snmp  - Fire process PDU event:
>CommandResponderEvent[transportMapping=org.snmp4j.transport.DefaultUdpTransportMapping at fb24d3peerAddress=127.0.0.1/53038,
>processed=false, pdu=[GETNEXT[reqestID=1669284127,
>timestamp=0:00:00.00, enterprise=, genericTrap=0, specificTrap=0,
>VBS[1.3.6.1.6.3.16.1.5.2.1.6.20.114.101.115.116.114.105.99.116.101.100.78.111.116.105.102.121.86.105.101.119.5.1.3.6.1.2
>= Null]]], securityName=[B at 87275d, securityModel=1, securityLevel=1]
>14538 [DefaultUDPTransportMapping_127.0.0.1/1616] DEBUG
>org.snmp4j.agent.mo.snmp.VacmMIB  - Matching view found for group name
>'v1v2group' is 'fullReadView'
>14538 [DefaultUDPTransportMapping_127.0.0.1/1616] DEBUG
>org.snmp4j.agent.DefaultMOServer  - Scanning managed object:
>1.3.6.1.6.3.16.1.5.2.1-1.3.6.1.6.3.16.1.5.2.2 for
>org.snmp4j.agent.CommandProcessor$VACMQuery[viewName=fullReadView]=1.3.6.1.6.3.16.1.5.2.1.6.20.114.101.115.116.114.105.99.116.101.100.78.111.116.105.102.121.86.105.101.119.5.1.3.6.1.2<
>x <null
>14540 [DefaultUDPTransportMapping_127.0.0.1/1616] DEBUG
>org.snmp4j.agent.CommandProcessor  - EndOfMibView at
>OID=1.3.6.1.6.3.16.1.5.2.1.6.20.114.101.115.116.114.105.99.116.101.100.78.111.116.105.102.121.86.105.101.119.5.1.3.6.1.2
>14541 [DefaultUDPTransportMapping_127.0.0.1/1616] DEBUG
>org.snmp4j.transport.DefaultUdpTransportMapping  - Sending message to
>127.0.0.1/53038 with length 73:
>30:47:02:01:00:04:06:70:75:62:6c:69:63:a2:3a:02:04:63:7f:41:1f:02:01:00:02:01:00:30:2c:30:2a:06:26:2b:06:01:06:03:10:01:05:02:01:06:14:72:65:73:74:72:69:63:74:65:64:4e:6f:74:69:66:79:56:69:65:77:05:01:03:06:01:02:05:00
>
>On the client side:
>-----------------------
>
>SNMP-VIEW-BASED-ACM-MIB::vacmViewTreeFamilyStatus."restrictedReadView".5.1.3.6.1.2
>= INTEGER: active(1)
>SNMP-VIEW-BASED-ACM-MIB::vacmViewTreeFamilyStatus."restrictedWriteView".6.1.3.6.1.2.1
>= INTEGER: active(1)
>SNMP-VIEW-BASED-ACM-MIB::vacmViewTreeFamilyStatus."restrictedNotifyView".5.1.3.6.1.2
>= INTEGER: active(1)
>SNMP-VIEW-BASED-ACM-MIB::vacmViewTreeFamilyStatus."restrictedNotifyView".5.1.3.6.1.2
>= Wrong Type (should be INTEGER): NULL
>Error: OID not increasing:
>SNMP-VIEW-BASED-ACM-MIB::vacmViewTreeFamilyStatus."restrictedNotifyView".5.1.3.6.1.2
> >= SNMP-VIEW-BASED-ACM-MIB::vacmViewTreeFamilyStatus."restrictedNotifyView".5.1.3.6.1.2
>_______________________________________________
>SNMP4J mailing list
>SNMP4J at agentpp.org
>http://lists.agentpp.org/mailman/listinfo/snmp4j
>
>
>  
>


-- 
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com





More information about the SNMP4J mailing list