Subject: | It is a bug rather then translate feature. |
Date: | Mon, 12 Mar 2007 10:16:21 +0300 |
To: | bug-Net-SNMP [...] rt.cpan.org |
From: | Andrei Koulik <netsnmp [...] agk.nnov.ru> |
Hello,
I use perl Net-SNMP to manage my devices.
In particular it used to retrieve mac addresses.
Most of mac addresses are returned in hex-string format e.g. 0x001195287e87
but some in string format e.g. PpdOf
of course it is very hard to parse data in different formats, so i
tried to play with translate function, but was failed.
When I looked over code then found:
if (($this->{_translate} & $mask) &&
($s =~ /[\x01-\x08\x0b\x0e-\x1f\x7f-\xff]/g))
{
DEBUG_INFO("translating %s to printable hex string", asn1_itoa($type));
sprintf('0x%s', unpack('H*', $s));
It means the translate never occurs if no "non-printable" chars in
a string. other words I always will receive 00:50:70:64:4f:66 as PpdOf
but 00:11:95:28:7e:87 as 0x001195287e87
I think it is wrong logic and should be used OR operator instead of
AND:
If mask sets to use translate function, then it will used always.
Else it will be used only then string contains "non-printable" chars.
--
Best regards,
Koulik Andrei