Skip Menu |

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

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

People
Owner: dtown [...] cpan.org
Requestors: joe.henderson1 [...] insightbb.com
Cc:
AdminCc:

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



Subject: OCTET String.. Includes "
############### PERL -V Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=linux, osvers=2.6.20-arch, archname=i686-linux-thread-multi uname='linux wohnung 2.6.20-arch #1 smp preempt sat mar 10 10:12:25 cet 2007 i686 amd athlon(tm) xp 2200+ authenticamd gnulinux ' config_args='-des -Dprefix=/usr -Dinstallprefix=/usr -Dman1dir=/usr/man/man1 -Dman3dir=/usr/man/man3 -Doptimize=-march=i686 -O2 -pipe -Dusethreads' 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=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-march=i686 -O2 -pipe', cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include' ccversion='', gccversion='4.1.2', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc libc=/lib/libc-2.5.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.5' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP THREADS_HAVE_PIDS USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API Built under linux Compiled at Mar 12 2007 19:08:43 @INC: /usr/lib/perl5/5.8.8/i686-linux-thread-multi /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/i686-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7/i686-linux-thread-multi /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6/i686-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5/i686-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4/i686-linux-thread-multi /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.3/i686-linux-thread-multi /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2/i686-linux-thread-multi /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.1/i686-linux-thread-multi /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0/i686-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl ############### EO PERL -V ############### UNAME -A Linux ent-ux-3 2.6.20 #5 SMP Wed Apr 25 08:33:33 EDT 2007 i686 Intel(R) Xeon(TM) CPU 3.20GHz GenuineIntel GNU/Linux ############### EO UNAME -A ARCH LINUX .8 ############### SNMP VERSION Tue Apr 10 16:33:12 2007: "Module" Net::SNMP · "installed into: /usr/lib/perl5/site_perl/5.8.8" · "LINKTYPE: dynamic" · "VERSION: 5.2.0" · "EXE_FILES: snmpkey" ############### EO SNMP VERSION Problem: -- when the snmp packet is sent using "net:snmp" a " is added to the beginning and ending of a "octet string" variable.. the "snmpset" command from cli does -not- include the extra ".. ####### SNMP DUMP FROM TCPDUMP VIA CLI 09:57:21.009883 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 88) ##########.46587 > ##########.snmp: [bad udp cksum 2300!] { SNMPv1 C=########## { SetRequest(40) R=396982680 E:388.1.8.4.4.1.2.1=00_00_00_00_00_00 } } ####### EO SNMP DUMP FROM TCPDUMP VIA CLI ####### SNMP DUMP FROM TCPDUMP VIA PERL SCRIPT 09:58:45.985995 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 97) ##########.46587 > ###########.snmp: [bad udp cksum aa4f!] { SNMPv1 C=######### { SetRequest(49) R=654 E:388.1.8.4.4.1.2.1="00_00_00_00_00_00" } } ####### EO SNMP DUMP FROM TCPDUMP VIA PERL SCRIPT NOTE: the "" in the send variable on the perl script the symbol device rejects this as "invalid snmp".. Why does the module insert a " in the variable.. ########### PERL SCRIPT SNIPPET $res = undef; $val = "00_00_00_00_00_00"; $res = $sess->set_request($smacacloid, OCTET_STRING, $val); if(!($res) || ($res eq "")) { $res = "res_no_res"; if($debug == 1) { print "BROKE\n"; } } else { if($debug == 1) { print "GO\n"; } } ########### EO PERL SCRIPT SNIPPET I have tried it a scalar and a direct input $res = $sess->set_request($smacacloid, OCTET_STRING, 00_00_00_00_00_00); the code above will dump out as this ######## 10:02:06.130382 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 81) #############.46616 > ###########.snmp: [bad udp cksum c630!] { SNMPv1 C=######### { SetRequest(33) R=12469 E:388.1.8.4.4.1.2.1="0" } } ######## HELP! thanks joe
I am 100% sure that the Net::SNMP module is not inserting the quote characters into the OCTET STRING, you are seeing them as part of how the dump programs display printable strings. I am assuming that your problem is based upon your script sending the ASCII representation of a string where you really want to send the binary presentation. When you pass the value "00_00_00_00_00_00" to the set_request() method, the following hex value (representing the ASCII input) is sent: 0x30305f30305f30305f30305f30305f3030, where ASCII '0' = 0x30 and '_' = 0x5f. I assume really to send binary 0x000000000000 (i.e. a six byte value). You need to provide a binary string to be sent. This is typically done using the pack() function in Perl. $hex = "00112233aabb"; $bin = pack('H*', $hex); -David
Mistakenly reopened.
From: joe.henderson1 [...] insightbb.com
On Mon May 12 10:27:45 2008, DTOWN wrote: Show quoted text
> Mistakenly reopened.
This is the correct bug opened... the "35811" was the broke one..
From: joe.henderson1 [...] insightbb.com
On Mon May 12 10:26:01 2008, DTOWN wrote: Show quoted text
> I am 100% sure that the Net::SNMP module is not inserting the quote > characters into the OCTET STRING, you are seeing them as part of how the > dump programs display printable strings. > > I am assuming that your problem is based upon your script sending the > ASCII representation of a string where you really want to send the > binary presentation. When you pass the value "00_00_00_00_00_00" to the > set_request() method, the following hex value (representing the ASCII > input) is sent: 0x30305f30305f30305f30305f30305f3030, where ASCII '0' = > 0x30 and '_' = 0x5f. I assume really to send binary 0x000000000000 > (i.e. a six byte value). You need to provide a binary string to be > sent. This is typically done using the pack() function in Perl. > > $hex = "00112233aabb"; > $bin = pack('H*', $hex); > > -David
This works like a champ... Is there a why to put this fix in the perldoc/howto? I could not find this answer anywhere... Here's the finished product.. ######## $val = pack('H*', "000000000000"); $macacloid = ".1.3.6.1.4.1.388.1.8.4.3.1.2.1"; $res = undef; $res = $sess->set_request($macacloid, OCTET_STRING, $val); if(!($res) || ($res eq "")) { $res = "res_no_res"; if($debug == 1) { print "BROKE\n"; } } else { if($debug == 1) { print "GO\n"; } } ######## THANK YOU FOR YOUR HELP AND QUICK REPLY!!!!!! Joe
I tend to shy away from adding "how-to" details in the Net::SNMP documentation that are specific to "application level" implementations to prevent the documentation from getting out of hand. Unfortunately I do not maintain any type of FAQ either. Closing the ticket. -David