ID: 36196
Comment by: cesarmata2000 at cantv dot net
Reported By: [EMAIL PROTECTED]
Status: Open
Bug Type: SNMP related
Operating System: gentoo linux
PHP Version: 5.1.2
New Comment:
Test with that
<?php
//Bug #36196 SNMP_VALUE_PLAIN
snmp_set_valueretrieval(0);
$mac = snmpget("192.168.0.1",'public',".1.3.6.1.2.1.2.2.1.6.x");
snmp_set_valueretrieval(1);
$mac = str_replace('""'," ",$mac);
$mac = str_replace('Hex: ',"",$mac);
$mac = str_replace(' ',":",trim($mac));
print $mac;
?>
Previous Comments:
------------------------------------------------------------------------
[2006-01-29 00:38:53] [EMAIL PROTECTED]
seems perl also works as expected...
# cat ./test.pl
#!/usr/bin/perl
use Net::SNMP;
use strict;
my ($session, $error);
( $session, $error ) = Net::SNMP->session(
-hostname => 'reboot1',
-community => 'public',
-timeout => 5,
-port => 161,
-localaddr => '192.168.0.1',
-version => 1,
);
print $error;
my $result =
$session->get_request('.1.3.6.1.2.1.2.2.1.6.1');
print $result->{'.1.3.6.1.2.1.2.2.1.6.1'};
print "\n";
# ./test.pl
0x00c0b76a8747
------------------------------------------------------------------------
[2006-01-29 00:24:13] [EMAIL PROTECTED]
Description:
------------
despite PHP and snmpwalk sharing the same library, they
return different results for a query....
# ldd /usr/bin/snmpwalk | grep snmp
libnetsnmp.so.5 => /usr/lib/libnetsnmp.so.5
(0xb7ee6000)
# ldd /usr/bin/php | grep snmp
libnetsnmp.so.5 => /usr/lib/libnetsnmp.so.5
(0xb7616000)
Bug #29998 covers this, but was dismissed - I am left
wondering how despite using the same library, results
differ. According to the documentation, using the
SNMP_VALUE_PLAIN should prevent the displayed behaviour.
Sorry if I'm missing something.
Reproduce code:
---------------
# cat ./test.php
<?php
snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
echo snmpget('reboot1', 'public', '.1.3.6.1.2.1.2.2.1.6.1') . "\n";
Expected result:
----------------
# snmpwalk -v 1 -c public
reboot2 .1.3.6.1.2.1.2.2.1.6.1
IF-MIB::ifPhysAddress.1 = STRING: 0:c0:b7:6a:c4:96
Actual result:
--------------
# php ./test.php
À·jG
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36196&edit=1