Skip Menu |

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

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

People
Owner: dtown [...] cpan.org
Requestors: aidas [...] elekta.lt
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 5.2.0
Fixed in: (no value)



Subject: Problems with Octet string values
Hi, i've got that problem with D-Link switch'es. OID - SNMPv2-SMI::mib- 2.17.7.1.3.1.1.3.1 (.iso.org.dod.internet.mgmt.mib- 2.dot1dBridge.qBridgeMIB.qBridgeMIBObjects.dot1qStatic.dot1qStaticUnica stTable) Labb uname -a FreeBSD unix.server 4.11-STABLE FreeBSD 4.11-STABLE #3: Thu Nov 3 12:05:50 EET 2005 /usr/obj/usr/src/sys/GENERIC i386 ------------------------------------------------------------------ ## Version of the Net::SNMP module our $VERSION = v5.2.0; ------------------------------------------------------------------ perl -V Summary of my perl5 (revision 5 version 8 subversion 6) configuration: Platform: osname=freebsd, osvers=4.11-stable, archname=i386-freebsd-thread- multi-64int uname='freebsd aps.elekta.lt 4.11-stable freebsd 4.11-stable #1: fri mar 4 11:53:35 eet 2005 root@aps.elekta.lt:usrobjusrsrcsysgeneric i386 ' config_args='-sde -Dprefix=/usr/local - Darchlib=/usr/local/lib/perl5/5.8.6/mach - Dprivlib=/usr/local/lib/perl5/5.8.6 - Dman3dir=/usr/local/lib/perl5/5.8.6/perl/man/man3 - Dman1dir=/usr/local/man/man1 - Dsitearch=/usr/local/lib/perl5/site_perl/5.8.6/mach - Dsitelib=/usr/local/lib/perl5/site_perl/5.8.6 - Dscriptdir=/usr/local/bin - Dsiteman3dir=/usr/local/lib/perl5/5.8.6/man/man3 - Dsiteman1dir=/usr/local/man/man1 -Ui_malloc -Ui_iconv - Uinstallusrbinperl -Dcc=cc -Doptimize=-O -pipe -Duseshrplib - Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.6/BSDPAN" -Ud_dosuid - Di_gdbm -Dusethreads=y -Dusemymalloc=n -Duse64bitint' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=define use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='- DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.6/BSDPAN" -D_THREAD_SAFE - DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe - I/usr/local/include', optimize='-O -pipe ', cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.6/BSDPAN" - D_THREAD_SAFE -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict- aliasing -pipe -I/usr/local/include' ccversion='', gccversion='2.95.4 20020320 [FreeBSD]', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags ='-pthread -Wl,-E -L/usr/local/lib' libpth=/usr/lib /usr/local/lib libs=-lgdbm -lm -lcrypt -lutil perllibs=-lm -lcrypt -lutil libc=, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -Wl,- R/usr/local/lib/perl5/5.8.6/mach/CORE' cccdlflags='-DPIC -fPIC', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY USE_ITHREADS USE_64_BIT_INT USE_LARGE_FILES PERL_IMPLICIT_CONTEXT Locally applied patches: SUIDPERLIO0 - fix PERLIO_DEBUG local root exploit (CAN-2005- 0155) SUIDPERLIO1 - fix PERLIO_DEBUG buffer overflow (CAN-2005-0156) Built under freebsd Compiled at Mar 7 2005 13:39:05 @INC: /usr/local/lib/perl5/site_perl/5.8.6/mach /usr/local/lib/perl5/site_perl/5.8.6 /usr/local/lib/perl5/site_perl /usr/local/lib/perl5/5.8.6/BSDPAN /usr/local/lib/perl5/5.8.6/mach /usr/local/lib/perl5/5.8.6 ------------------------------------------------------------------ from tcpdump: tcpdump: listening on em0 15:49:33.375488 unix.server.2694 > dlink.switch.snmp: C=Private GetRequest(26) system.sysUpTime.0 15:49:33.376877 dlink.switch.snmp > unix.server.2694: C=Private GetResponse(31) system.sysUpTime.0=1283974 15:49:33.386173 unix.server.2694 > dlink.switch.snmp: C=Private GetRequest(38) 17.7.1.3.1.1.3.1.0.13.97.30.126.13.0 15:49:33.389128 dlink.switch.snmp > unix.server.2694: C=Private GetResponse(44) 17.7.1.3.1.1.3.1.0.13.97.30.126.13.0=00_20_00_00 ------------------------------------------------------------------ from Net::SNMP debugger: perl upgrade.pl debug: [448] Net::SNMP::Dispatcher::_event_insert(): created new head and tail [ARRAY(0x8084eac)] debug: [593] Net::SNMP::Dispatcher::_event_handle(): event [ARRAY (0x8084eac)], poll delay = 0.000000 debug: [646] Net::SNMP::Message::send(): transport address dlink.switch:161 debug: [1896] Net::SNMP::Message::_buffer_dump(): 55 bytes [0000] 30 35 02 01 01 04 08 65 6C 65 6B 74 61 43 46 A0 05.....Private. [0016] 26 02 02 16 3E 02 01 00 02 01 00 30 1A 30 18 06 &...>......0.0.. [0032] 14 2B 06 01 02 01 11 07 01 03 01 01 03 01 00 0D .+.............. [0048] 61 1E 7E 0D 00 05 00 a.~.... debug: [202] Net::SNMP::Dispatcher::register(): adding descriptor [5] debug: [471] Net::SNMP::Dispatcher::_event_insert(): modified tail [ARRAY(0x8084c9c)] debug: [542] Net::SNMP::Dispatcher::_event_delete(): deleted [ARRAY (0x8084eac)], defined new head [ARRAY(0x8084c9c)] debug: [593] Net::SNMP::Dispatcher::_event_handle(): event [ARRAY (0x8084c9c)], poll delay = 1.999861 debug: [645] Net::SNMP::Dispatcher::_event_select(): descriptor [5] ready for read debug: [670] Net::SNMP::Message::recv(): transport address dlink.switch:161 debug: [1896] Net::SNMP::Message::_buffer_dump(): 65 bytes [0000] 30 82 00 3D 02 01 01 04 08 65 6C 65 6B 74 61 43 0..=.....elektaC [0016] 46 A2 82 00 2C 02 02 16 3E 02 01 00 02 01 00 30 F...,...>......0 [0032] 82 00 1E 30 1C 06 14 2B 06 01 02 01 11 07 01 03 ...0...+........ [0048] 01 01 03 01 00 0D 61 1E 7E 0D 00 04 04 00 20 00 ......a.~..... . [0064] 00 . debug: [953] Net::SNMP::PDU::_process_var_bind_list(): { 1.3.6.1.2.1.17.7.1.3.1.1.3.1.0.13.97.30.126.13.0 => OCTET STRING: } debug: [524] Net::SNMP::Dispatcher::_event_delete(): deleted [ARRAY (0x8084c9c)], list is now empty debug: [241] Net::SNMP::Dispatcher::deregister(): removing descriptor [5] 1.3.6.1.2.1.17.7.1.3.1.1.3.1.0.13.97.30.126.13.0 =>
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. The key factor here is "What is printable?". 0x00200000 00 - NUL <considered printable by the module> 20 - ' ' <space> 00 - NUL <considered printable by the module> 00 - NUL <considered printable by the module> The OCTET STRING in question contains all printable characters (as defined by the module), so no translation takes place. From the documentation: When the object decodes the GetResponse-PDU that is returned in response to a SNMP message, certain values are translated into a more ``human readable'' form. By default the following translations occur: * OCTET STRINGs and Opaques containing non-printable ASCII characters are converted into a hexadecimal representation prefixed with ``0x''. NOTE: The following ASCII control characters are considered to be printable by the module: NUL(0x00), HT(0x09), LF(0x0A), FF(0x0C), and CR(0x0D). If you know the "type" of the value to you will be querying, I usually recommend to users that they disable translation and do their own. ==== ($session, $error) = Net::SNMP->session( ... -translate => [-octetstring => 0x0], ... ); ... $oid = "<your OID>"; $response = $session->get_request(-varbindlist => [$oid]); printf("%s: %s\n", $oid, _format($response->{$oid})); ... sub _format { sprintf('0x%s', unpack('H*', $_[0])); } ==== -David