[SNMP4J] Trap Agent Address & IPv6

Frank Fock fock at agentpp.com
Sun Jun 21 22:52:06 CEST 2009


Senthil,

Thanks for your bug report. This bug will be fixed
in the next release of SNMP4J IpAddress.java by:

   public void encodeBER(OutputStream outputStream) throws 
java.io.IOException {
     byte[] address = new byte[4];
     if (inetAddress instanceof Inet6Address) {
       Inet6Address v6Addr = (Inet6Address)inetAddress;
       if (v6Addr.isIPv4CompatibleAddress()) {
         byte[] v6Bytes = inetAddress.getAddress();
         System.arraycopy(v6Bytes, v6Bytes.length-5, address, 0, 4);
       }
     }
     else {
       System.arraycopy(inetAddress.getAddress(), 0, address, 0, 4);
     }
     BER.encodeString(outputStream, BER.IPADDRESS, address);
   }


Best regards,
Frank

Senthil Muniswamy wrote:
> Frank,
> 
> In the Proxy Agent, when a SNMPv2 trap from IPv6 agent gets translated as
> SNMPv1 trap, the IpAddress is created with Inet6Address
> [PDUv1.setAgentAddress(org.snmp4j.smi.IpAddress agentAddress)].
> 
> It causes java.nio.BufferOverflowException during BER encoding because
> org.snmp4j.smi.IpAddress can not handle IPv6 address.
> 
> Additional checking is required to set only IPv4 where ever agent address is
> set.
> 
> -Senthil
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j

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




More information about the SNMP4J mailing list