Req #81416 [NEW]: Missing SNMP constant for Counter32 type

From: Date: Fri, 03 Sep 2021 15:56:28 +0000
Subject: Req #81416 [NEW]: Missing SNMP constant for Counter32 type
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236397@lists.php.net to get a copy of this message
From:             miloslav dot hula at gmail dot com
Operating system: Linux
PHP version:      8.0.10
Package:          SNMP related
Bug Type:         Feature/Change Request
Bug description:Missing SNMP constant for Counter32 type

Description:
------------
The SNMP_VALUE_OBJECT type can be 65 for which is missing PHP SNMP
constant. For example I get:

type = 65
value = 'Counter32: 231'

There is defined SNMP_COUNTER, internally defined as ASN_GAUGE, which is
equal to ASN_UNSIGNED, which is definition for SNMP_UNSIGNED.

So SNMP_COUNTER === SNMP_UNSIGNED which I think is a mistake.


https://github.com/php/php-src/blob/218fd03532ecd955dbe6e5f08b9b970f36f8b6c1/ext/snmp/snmp.c#L2052

https://github.com/net-snmp/net-snmp/blob/4ff38daccd86dd0e7c3c2385dcf2152e2e74cb88/include/net-snmp/library/snmp_impl.h#L90-L91


Soulution would be probably redefine SNMP_COUNTER as ASN_COUNTER, or
define new constant SNMP_COUNTER32 to prevent BC break.


Test script:
---------------
<?php

$types = [
    'SNMP_INTEGER',
    'SNMP_BIT_STR',
    'SNMP_OCTET_STR',
    'SNMP_NULL',
    'SNMP_OBJECT_ID',
    'SNMP_IPADDRESS',
    'SNMP_COUNTER',
    'SNMP_UNSIGNED',
    'SNMP_TIMETICKS',
    'SNMP_OPAQUE',
    'SNMP_COUNTER64',
    'SNMP_UINTEGER',
];

foreach ($types as $type) {
    echo sprintf('%14s = %d', $type, constant($type)) . "\n";
}


Actual result:
--------------
  SNMP_INTEGER = 2
  SNMP_BIT_STR = 3
SNMP_OCTET_STR = 4
     SNMP_NULL = 5
SNMP_OBJECT_ID = 6
SNMP_IPADDRESS = 64
  SNMP_COUNTER = 66  <-- should be 65
 SNMP_UNSIGNED = 66
SNMP_TIMETICKS = 67
   SNMP_OPAQUE = 68
SNMP_COUNTER64 = 70
 SNMP_UINTEGER = 71


-- 
Edit bug report at https://bugs.php.net/bug.php?id=81416&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81416&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81416&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81416&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81416&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81416&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81416&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81416&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81416&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81416&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81416&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81416&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81416&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81416&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81416&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81416&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81416&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81416&r=mysqlcfg


Thread (2 messages)

« previous php.bugs (#236397) next »