I find that with Net-SNMP, I can get the normal ifPhysAddress result .But when I use SNMP4J,I get some wrong result.How to fix it ?
The Net-SNMP result:
The snmp4j result:
Hi,
the OctetString::toString()
function (which is most likely used to produce the output) does not know that the string value is of a textual convention PhysAddress
. It just looks at the value and decides if the value has to be just returned as unmodified String, or if it should be returned as a hex string.
In the image, the first address has a 0x08 which is not printable and so it is returned as hex string. For the second address I would assume that the last byte is 0x20 (space), as we can only see 5 printable characters.
Regards,
Jochen
Can I set the raw format string in get-table method?I only want the raw format string.
In fact, 34:6b:5b:25:41:5f return 4k[%Ea in SNMP4J and return 34:6b:5b:25:41:5f in NET-SNMP. Can you show me which string is not printable?
Both values are the same. One is the string value and the other it’s hex-encoded representation. That‘s all. In SNMP4J you can retrieve both representations. See the Java Doc of the OctetString
class.
Can you expain why SNMP4J sometimes return hex-encoded representation,and sometimes return string.Did the reason is what @ jkatz say above?
If you call for example the TableEvent::toString()
function, it will in the end use OctetString::toString()
. Please have a look at the implementation of this function, then you will see .