[SNMP4J] Problem receiving traps I generate

Eric Thiebaut snmp4j at dungorm.com
Fri Mar 18 16:54:46 CET 2011


Hi,

I am sending a trap and trying to subscribe to it, but I'm facing some problems.
I'm compiling against the released source package of of 1.11.2 (in order to debug).

Sending the trap is pretty straight forward:
        PDUv1 pdu = new PDUv1();
        pdu.setType(PDU.V1TRAP);
        ...
        this.snmp.send(pdu, target);

I can check with wireshark and my packet looks fine.

Now I'm subscribing for events (actually in the same process):
                TransportMapping transport =
                    new DefaultUdpTransportMapping(new UdpAddress("0.0.0.0/10160"));
                snmp = new Snmp(transport);
                snmp.addCommandResponder(this);
                transport.listen();


All this is pretty straight forward.
But when traps are received, the reception thread throws an exception in PDU.java
as pduType.getValue() returns PDU.V1TRAP (as expected), which is not supported by the class PDU.

The problem seems to come from MessageDispatcherImpl:
      Integer32 version = new Integer32();
      version.decodeBER(wholeMessage);
      MessageProcessingModel mp = getMessageProcessingModel(version.getValue());

version decodes to 1. The mp at position 1 is MPv2c, and not MPv1 (which is at position 0).
So when MPv2c decodes the pdu, it creates a PDU object and not PDUv1 object, which does not support v1 traps.

Is this expected? At the moment I cannot receive my traps because of this.
Am I doing something wrong?

Thanks

Eric



More information about the SNMP4J mailing list