[SNMP4J] IpAddress encoding error, wrong length: 16

Georg Lodde Georg.Lodde at materna.de
Wed May 23 07:48:44 CEST 2012


Hello,

I see the following error message while using SNMP4J.

  java.io.IOException: IpAddress encoding error, wrong length: 16
      at java.lang.Throwable.<init>(Throwable.java:67)
      at org.snmp4j.smi.IpAddress.decodeBER(IpAddress.java:159)
      at 
org.snmp4j.smi.AbstractVariable.createFromBER(AbstractVariable.java:172)
      at org.snmp4j.smi.VariableBinding.decodeBER(VariableBinding.java:167)
      at org.snmp4j.PDUv1.decodeBER(PDUv1.java:186)
      at org.snmp4j.mp.MPv1.prepareDataElements(MPv1.java:191)
      at 
org.snmp4j.MessageDispatcherImpl.dispatchMessage(MessageDispatcherImpl.java:272)
      at 
org.snmp4j.MessageDispatcherImpl.processMessage(MessageDispatcherImpl.java:368)
      at 
org.snmp4j.MessageDispatcherImpl.processMessage(MessageDispatcherImpl.java:328)
      at 
org.snmp4j.transport.AbstractTransportMapping.fireProcessMessage(AbstractTransportMapping.java:76)
      at 
org.snmp4j.transport.DefaultUdpTransportMapping$ListenThread.run(DefaultUdpTransportMapping.java:378)
      at java.lang.Thread.run(Thread.java:736

I have seen an earlier posting from /Wed Mar 23 10:45:58 CET 2011/ 
"SNMPv1 traps with IPv6 in AgentAddress are dropped". I know that the 
implementation of snmp4j is correct, but there are many agent 
implementation which are not and it would be easier to make snmp4j fault 
tolerant.

The problem is related with the decoeBER method in 
org.snmp4j.smi.IpAddress. I would like to suggest the /*<<>>*/ marked 
change, which probably will solve the problem.

/public void decodeBER(BERInputStream inputStream) throws 
java.io.IOException {
     BER.MutableByte type = new BER.MutableByte();
     byte[] value = BER.decodeString(inputStream, type);
     if (type.getValue() != BER.IPADDRESS) {
       throw new IOException("Wrong type encountered when decoding 
Counter: "+
                             type.getValue());
     }
     if (value.length != 4 //*<<>>*//*&& value.length!=16*//*<<>>*//) {
       throw new IOException("IpAddress encoding error, wrong length: " +
                             value.length);
     }
     inetAddress = InetAddress.getByAddress(value);
   }/


With kind regards

Georg Lodde




More information about the SNMP4J mailing list