Edit report at https://bugs.php.net/bug.php?id=54502&edit=1

 ID:                 54502
 Updated by:         lytbo...@php.net
 Reported by:        c...@php.net
 Summary:            Add support for the "BITS" datatype
-Status:             Assigned
+Status:             Feedback
 Type:               Feature/Change Request
 Package:            SNMP related
 PHP Version:        trunk-SVN-2011-04-10 (SVN)
 Assigned To:        lytboris
 Block user comment: N
 Private report:     N

 New Comment:

Please try using this snapshot:

  http://snaps.php.net/php5.4-latest.tar.gz

For Windows:

  http://windows.php.net/snapshots/

Now you can combine SNMP_VALUE_OBJECT with one of SNMP_VALUE_PLAIN or 
SNMP_VALUE_LIBRARY to alter 'value' output mode.
As for
>The value is not even numerical, it has to be converted to 0x80 using 
>bin2hex()!
This is normal, because this is exactly what php-snmp receives from remote SNMP 
agent.


Previous Comments:
------------------------------------------------------------------------
[2011-07-17 13:18:27] lytbo...@php.net

Automatic comment from SVN on behalf of lytboris
Revision: http://svn.php.net/viewvc/?view=revision&revision=313331
Log: fix FR #54502: allow user to change OID value output mode when 
SNMP_VALUE_OBJECT is used.

------------------------------------------------------------------------
[2011-07-17 09:18:04] lytbo...@php.net

There is support for BITS datatype actually when SNMP_VALUE_LIBRARY is enabled 
for value processing. When you enable other SNMP_VALUE_* modes no value 
processing is performed and output from remote SNMP agent is passed through 
SNMP library.

------------------------------------------------------------------------
[2011-04-10 15:34:01] c...@php.net

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 this bug report at https://bugs.php.net/bug.php?id=54502&edit=1

Reply via email to