[AGENT++] IpAddress: how to create a Hex-String instead a String?
Jochen Katz
katz at agentpp.com
Sat Nov 6 14:00:57 CET 2010
Hello,
> I have a simple table with an agent++::IpAddress, but when I read this
> OID, the result is NOT encoded as I expected
>
> This is how I fill this value:
>
> IpAddress _ipAddr("::1");
> row->get_nth(nNetSnmpHostAddress)-
> >replace_value(OctetStr(_ipAddr).clone());
>
> NET-SNMP-EXAMPLES-MIB::netSnmpHostAddress."loopback" = STRING:
> "0000:0000:0000:0000:0000:0000:0000:0001"
> SNMP-TARGET-MIB::snmpTargetAddrTAddress.'internal0' = Hex-STRING: 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 A2 00
>
>
> As you can see, the TargetAddressTable is more compact for this simple
> ipv6 localhost address!
>
> Too, IpAddress::get_printable() should get the string as "::1" in this
> case.
> Is it possible to control this?
not at the moment. Both, "operator const char*" and get_printable use
the IpAddress::format_output() function, that always generates the full
string. There is currently no code to detect blocks of zeroes or ipv4
mapped addresses.
The hex string could be created like this:
OctetStr hex;
hex.set_len(ip.get_length());
for (int i=0; i < ip.get_length(); i++)
hex[i] = ip[i];
Regards,
Jochen
More information about the AGENTPP
mailing list