Skip Menu |

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

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

People
Owner: dtown [...] cpan.org
Requestors: andrew.watson [...] cox.com
Cc:
AdminCc:

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



Subject: Incorrect Decoding of MAC Addresses
I have encountered errors when polling OIDs for MAC addresses where Net::SNMP returns a string like \0 \f A R ? s (output from od -c) instead of 000c41523f72. redhat 7.3 running perl: 5.6.1 Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration: Platform: osname=linux, osvers=2.4.17-0.13smp, archname=i386-linux uname='linux daffy.perf.redhat.com 2.4.17-0.13smp #1 smp fri feb 1 10:30:48 est 2002 i686 unknown ' config_args='-des -Doptimize=-O2 -march=i386 -mcpu=i686 -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dcccdlflags=-fPIC -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux -Uusethreads -Uuseithreads -Uuselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Di_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Dlocincpth=' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=undef usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef Compiler: cc='gcc', ccflags ='-fno-strict-aliasing -I/usr/local/include', optimize='-O2 -march=i386 -mcpu=i686', cppflags='-fno-strict-aliasing -I/usr/local/include' ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.1 2.96-98)', 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=4 alignbytes=4, usemymalloc=n, prototype=define Linker and Libraries: ld='gcc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -ldl -lm -lc -lcrypt -lutil perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil libc=/lib/libc-2.2.4.so, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic' cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: Built under linux Compiled at Feb 20 2002 15:01:16 %ENV: PERLLIB="." @INC: . /usr/lib/perl5/5.6.1/i386-linux /usr/lib/perl5/5.6.1 /usr/lib/perl5/site_perl/5.6.1/i386-linux /usr/lib/perl5/site_perl/5.6.1 /usr/lib/perl5/site_perl/5.6.0/i386-linux /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl . i worked around it by checking to see if the mac comes back too short and then sprintf("%02x") on each character's ord() value to get 41 instead of 'A'.
From: dtown [...] cpan.org
This is a duplicate report of bug #1946. Please see the resolution listed in that bug report at: http://rt.cpan.org/NoAuth/Bug.html?id=1946. -David
From: andrew.watson [...] cox.com
[DTOWN - Wed Apr 7 16:02:29 2004]: Show quoted text
> This is a duplicate report of bug #1946. Please see the resolution > listed in that bug report at: http://rt.cpan.org/NoAuth/Bug.html?id=1946. > > -David > >
Hmmm... but when i do this i can't bulkwalk and get IP addresses and mac addresses at the same time... the IPs come out as 0.0.0.0 :(
From: dtown [...] cpan.org
Show quoted text
> > Hmmm... but when i do this i can't bulkwalk and get IP addresses and mac > addresses at the same time... the IPs come out as 0.0.0.0 :(
When you are querying the IP addresses and MAC address, you know which OBJECT IDENTIFIER corresponds to the column containing the MAC address in the table. If the OBJECT IDENTIFIER matches the MAC address column, you format the address, else you just print the results. ==== use Net::SNMP qw(oid_base_match); ($session, $error) = Net::SNMP->session( ... -translate => [-octetstring => 0x0], ... ); ... # Define column that contains MAC addresses my $macoid = '1.3.6.x.x.x.x.x'; ... # perform "bulkwalk" ... foreach my $oid ($session->var_bind_names) { if (oid_base_match($macoid, $oid)) { printf("%s: %s\n", $oid, _format_mac($session->var_bind_list->{$oid})); } else { printf("%s: %s\n", $oid, $session->var_bind_list->{$oid}); } } ... sub _format_mac { sprintf("%s:%s:%s:%s:%s:%s", unpack('H2' x 6, $_[0])); } ====
The Net::SNMP module works at the protocol level and has no knowledge of what the binary stream of data represents. The "translate" functionality only works at a basic level. Any application level mapping of data to display format must be done by the user. -David