Skip Menu |

This queue is for tickets about the Net-SNMP CPAN distribution.

Report information
The Basics
Id: 55716
Status: resolved
Worked: 5 min
Priority: 0/
Queue: Net-SNMP

People
Owner: dtown [...] cpan.org
Requestors: patrick.best [...] telus.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: v6.0.0
Fixed in: (no value)



Subject: Some Received Values not being assigned to hash properly
When using get_table , some retrieved Hex values appear to be stored in the hash value as "J1" or "J1X" or "J1Y" etc... This occurs only for about five percent of all values. In this case, I am requesting a table with 244 elements. Snoops reveal that sane data is indeed being retrieved. I will attach a capture file from the workstation doing the polling. The capture was run with: snoop -s 1600 -o /home/bestpa/snmp_20100319.cap host 10.33.221.48 In the capture you can see that the value for OID .1.3.6.1.4.1.3375.2.2.10.1.2.1.3.22.118.115.95.77.77.83.67.95.80.85.66.95.75.79.79.68.79.95.83.77.84.80 is being returned with a value of "4A31000B". However, the stored value in the hash for that key is "J1Y". I will also attach script output using session parameter "debug => 0xFF" in a file. ---------------CODE: #!/usr/bin/perl # Functionality test script use Net::SNMP; $hostname="10.33.221.48"; $port=161; $version="snmpv2c"; $community="p4tr1ck_rul3s"; $max_msg_size=65535; ($session, $error) = Net::SNMP->session( -hostname => $hostname, -port => $port, -nonblocking => 0, -version => $version, -community => $community, -maxmsgsize => $max_msg_size, -timeout => 20, ); if (!defined $session) { printf "ERROR: %s.\n", $error; exit 1; } $oidADDRESS=".1.3.6.1.4.1.3375.2.2.10.1.2.1.3"; $resultADDRESS = $session->get_table( -baseoid => $oidADDRESS, ); if (!defined $resultADDRESS) { printf "ERROR: %s\n", $session->error(); $session->close(); exit 1; } print "size of IP ADDRESS hash: " . keys(%$resultADDRESS) . ".\n"; while (( my $k,$v) = each %$resultADDRESS) { print "$k\n$v\n\n"; }; ---------------OUTPUT (truncated for brevity to show good versus bad examples: .1.3.6.1.4.1.3375.2.2.10.1.2.1.3.21.118.115.95.49.48.95.51.51.95.50.51.56.95.50.50.49.95.54.48.55.48 0x0a21eedd .1.3.6.1.4.1.3375.2.2.10.1.2.1.3.19.118.115.95.49.48.95.51.51.95.50.51.57.95.56.95.57.48.48.53 0x0a21ef08 .1.3.6.1.4.1.3375.2.2.10.1.2.1.3.21.118.115.95.49.48.95.51.51.95.50.51.56.95.49.57.48.95.57.48.48.52 0x0a21eebe .1.3.6.1.4.1.3375.2.2.10.1.2.1.3.22.118.115.95.77.77.83.67.95.80.85.66.95.75.79.79.68.79.95.83.77.84.80 J1Y .1.3.6.1.4.1.3375.2.2.10.1.2.1.3.20.118.115.95.49.48.95.51.51.95.50.51.56.95.56.49.95.49.48.50.53 0x0a21ee51 .1.3.6.1.4.1.3375.2.2.10.1.2.1.3.25.118.115.95.77.65.71.54.46.54.95.80.80.71.95.80.82.83.95.116.114.117.115.116.101.100 0x0a21ef08 .1.3.6.1.4.1.3375.2.2.10.1.2.1.3.19.118.115.95.49.48.95.51.51.95.50.51.57.95.56.95.53.57.57.49 0x0a21ef08
Subject: snmp_20100319.cap
Download snmp_20100319.cap
application/octet-stream 50.4k

Message body not shown because it is not plain text.

From: patrick.best [...] telus.com
Output with "-debug => 0xFF" attached.
Subject: snmp_20100319.scriptoutput.withdebug.txt

Message body is not shown because it is too large.

What you are seeing is the expected behavior of the module. The Net::SNMP module has translation enabled by default. When an OCTET STRING is received, the contents of the string are checked to make sure that all octets are printable. If any octet is not printable, the string is translated into the hexadecimal representation. If all of the octets are considered printable by the module, then no translation takes place (which is what is happening in your case). See ticket #27819 (https://rt.cpan.org/Public/Bug/Display.html?id=27819) for a more detailed explanation.
Subject: RE: [rt.cpan.org #55716] AutoReply: Some Received Values not being assigned to hash properly
Date: Mon, 22 Mar 2010 11:23:46 -0400
To: "bug-Net-SNMP [...] rt.cpan.org" <bug-Net-SNMP [...] rt.cpan.org>
From: Patrick Best <Patrick.Best [...] telus.com>
Thanks for your response. I have since turned off translation for OCTET and am using the following code to do my own translation on the retrieved data: while (( my $k,$v) = each %$resultADDRESS) { $this = unpack("B32",$v); $F0=oct( "0b".substr($this,0,8) ); $F1=oct( "0b".substr($this,8,8) ); $F2=oct( "0b".substr($this,16,8) ); $F3=oct( "0b".substr($this,24,8) ); print "$k\n$this\n$F0.$F1.$F2.$F3\n"; };
Using "%vd" with [s]print[f] will also do the format conversion. printf "%vd\n", $v; Considering the issue resolved.