From: Operating system: PHP version: trunk-SVN-2011-04-10 (SVN) Package: SNMP related Bug Type: Feature/Change Request Bug description:Add support for the "BITS" datatype
Description: ------------ The SNMP command line tools are able to translate the numeric return values for OIDs of the "BITS" datatype back to meaningful string values by parsing the relevant parts of the MIB. The PHP functions currently seem unable to do that. I.e. in the following example I would like to get the string "notification" or "set" as return value but only get "0" or "1". As there is no other method to find and parse the MIB I'm left with hardcoding the values in the PHP script: $ snmptranslate -Td DISMAN-EVENT-MIB::mteEventActions DISMAN-EVENT-MIB::mteEventActions mteEventActions OBJECT-TYPE -- FROM DISMAN-EVENT-MIB SYNTAX BITS {notification(0), set(1)} Test script: --------------- >From commandline (mind the strange quotes, they're neccessary!): $ snmpwalk -v2c -c private localhost "DISMAN-EVENT-MIB::mteEventActions.\"_snmpd\".'_linkDown'" DISMAN-EVENT-MIB::mteEventActions."_snmpd".'_linkDown' = BITS: 80 notification(0) With PHP: snmp_set_valueretrieval(SNMP_VALUE_OBJECT); $snmp = new SNMP(SNMP_VERSION_2C, 'localhost', 'private'); $x = $snmp->get("DISMAN-EVENT-MIB::mteEventActions.\"_snmpd\".'_linkDown'"); var_dump($x); var_dump(bin2hex($x->value)); I get: object(stdClass)#190 (2) { ["type"]=> int(4) ["value"]=> string(1) "�" } string(2) "80" The value is not even numerical, it has to be converted to 0x80 using bin2hex()! Expected result: ---------------- Maybe * the SNMP_VALUE_OBJECT representation object can be enhanced to include alternative representations: object(stdClass)#190 (2) { ["type"]=> int(4) ["value"]=> string(1) "�" ["bits_value"]=> string(15) "notification(0)" } * or the the snmp_set_enum_print() function is used to toggle BITS, too * or a snmp_set_bits_print() function is introduced * or a snmp_translate() function is introduced that returns the "snmptranslate" output as PHP data structure -- Edit bug report at http://bugs.php.net/bug.php?id=54502&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54502&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54502&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54502&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=54502&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54502&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=54502&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=54502&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=54502&r=needscript Try newer version: http://bugs.php.net/fix.php?id=54502&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=54502&r=support Expected behavior: http://bugs.php.net/fix.php?id=54502&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=54502&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=54502&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=54502&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54502&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=54502&r=dst IIS Stability: http://bugs.php.net/fix.php?id=54502&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=54502&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=54502&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=54502&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=54502&r=mysqlcfg