|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #55312 Please change SNMP::VERSION_ constants to sensible values
Submitted: 2011-07-28 23:26 UTC Modified: 2011-08-15 09:38 UTC
From: Assigned: lytboris (profile)
Status: Wont fix Package: SNMP related
PHP Version: 5.4.0alpha2 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2011-07-28 23:26 UTC]
Currently the SNMP::VERSION class constants have the following internal values:

const integer SNMP::VERSION_1 = 0 ;
const integer SNMP::VERSION_2C = 1 ;
const integer SNMP::VERSION_2c = 1 ;
const integer SNMP::VERSION_3 = 3 ;

As PHP does not yet have the concept of Enums the documentation just says that the first parameter has to be numeric so people will be tempted to enter 1, 2 or 3 as paramter which results in hard to debug errors (it mostly works just some OIDs do not).

Would there be any drawbacks if we change the internal values to 1, 2, 2, 3?
It's still Alpha so no Backward Compatibility problems.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-15 07:20 UTC]
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: lytboris
 [2011-08-15 07:20 UTC]
There are some drawbacks. Look at this portion of code from snmp.h:#ifndef 
#define SNMP_VERSION_1     0
#define SNMP_VERSION_2c    1
#define SNMP_VERSION_2u    2    /* not (will never be) supported by this code */
#define SNMP_VERSION_3     3

     * versions not based on a version field
#define SNMP_VERSION_sec   128  /* not (will never be) supported by this code */
#define SNMP_VERSION_2p    129  /* no longer supported by this code (> 4.0) */
#define SNMP_VERSION_2star 130  /* not (will never be) supported by this code */

There are 4 versions of protocol that are glued to major "second" version. I am not sure that any user specifying '2' in SNMP constructor call would mean 2c.

I will fix constructor manual adding note that version parameter should be a SNMP class version constant and not an ordinary integer.
 [2011-08-15 07:51 UTC]
Why don't you just swap SNMP_VERSION_2c to "2" and SNMP_VERSION_2u to "1"? Then (accidently) specify "2" would lead to a sensible result.
 [2011-08-15 09:38 UTC]
That was quote from Net-SNMP sources, not php-snmp.
 [2011-08-20 16:24 UTC]
Automatic comment from SVN on behalf of lytboris
Log: document FR #55312, #42918
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Feb 23 01:01:30 2024 UTC