php.net |  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: ch@php.net Assigned: lytboris (profile)
Status: Wont fix Package: SNMP related
PHP Version: 5.4.0alpha2 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ch@php.net
New email:
PHP Version: OS:

 

 [2011-07-28 23:26 UTC] ch@php.net
Description:
------------
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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-15 07:20 UTC] lytboris@php.net
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: lytboris
 [2011-08-15 07:20 UTC] lytboris@php.net
There are some drawbacks. Look at this portion of code from snmp.h:#ifndef 
==================
NETSNMP_DISABLE_SNMPV1
#define SNMP_VERSION_1     0
#endif
#ifndef NETSNMP_DISABLE_SNMPV2C
#define SNMP_VERSION_2c    1
#endif
#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] ch@php.net
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] lytboris@php.net
That was quote from Net-SNMP sources, not php-snmp.
 [2011-08-20 16:24 UTC] lytboris@php.net
Automatic comment from SVN on behalf of lytboris
Revision: http://svn.php.net/viewvc/?view=revision&revision=315238
Log: document FR #55312, #42918
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 19:01:30 2024 UTC