If an IP address is defined based on InetAddressType/InetAddress TC,
then the OctetString in byte format (aka C0:A8:01:23) is the correct
return for an IPv4 address. I believe that most - if not all - Cisco's
routers and switches use InetAddress to express the IP addresses.

For the case of 192.168.1.34, you may want to check the corresponding
MIB definition of that object. If that's an InetAddress object, then
IMHO returning "xxx.xxx.xxx.xxx" is an incorrect development. If it's
a DisplayString/SnmpAdminString object, then it's a different story.

On Fri, Jan 20, 2012 at 12:33 AM, Chris Richmond
<crichm...@referentia.com> wrote:
> Hello,
>
> I am performing polling and one particular field  for EIGRP neighbors in
> cisco routers (.1.3.6.1.4.1.9.9.449.1.4.1.1.3)  returns ip addresses in
> a hex string format delimited by ":"...such as c0:A8:01:23. This was
> what I always got for devices I tested and I handled it like this in my
> code using the SNMP4j classes :
>
>            /// neighborAddressStat.getValue().toString()  = "c0:A8:01:23"
>
>                 OctetString os =
> OctetString.fromHexString(neighborAddressStat.getValue().toString());
>                 org.snmp4j.smi.Address snmp4jIpAddress = new
> org.snmp4j.smi.IpAddress(os.getValue());
>                 neighborAddress = snmp4jIpAddress.toString();
>
>
> where neighborAddress gives me a string "192.168.1.34"
>
> Worked fine until some devices are now returning a string like
> "192.168.1.34" instead of the hex string, which  of course breaks this code.
>
> There doesn't seem to be a comprehensive method or API in SNMP4j for
> handling both situtions.  In other words,   org.snmp4j.smi.Address can
> be constructed from a "192.168.1.34" string or a byte array.  Octet
> string breaks on "192.168.1.34" but can provide a byte array from a
> "c0:A8:01:23" format.
>
> It seems as though I am possibly missing the ideal way to handle this
> within the Snmp4j library.
>
> Any ideas?
>
> Thanks,
> Chris
>
>
>
>
>
> _______________________________________________
> SNMP4J mailing list
> SNMP4J@agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j
_______________________________________________
SNMP4J mailing list
SNMP4J@agentpp.org
http://lists.agentpp.org/mailman/listinfo/snmp4j

Reply via email to