php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74642 snmprealwalk resets oid output format
Submitted: 2017-05-24 10:00 UTC Modified: 2017-06-12 06:31 UTC
From: mattias dot wallin at salanet dot se Assigned:
Status: Closed Package: SNMP related
PHP Version: 7.0.19 OS: Ubuntu 14.04 LTS
Private report: No CVE-ID: None
 [2017-05-24 10:00 UTC] mattias dot wallin at salanet dot se
Description:
------------
snmprealwalk with non numeric object_id resets oid output format for current call, and future calls.

Test script:
---------------
<?php
snmp_set_oid_output_format(SNMP_OID_OUTPUT_NUMERIC);
print_r(snmprealwalk('1.2.3.4', 'public', '.1.3.6.1.2.1.17.2.15.1.3.1'));
print_r(snmprealwalk('1.2.3.4', 'public', 'BRIDGE-MIB::dot1dStpPortState.1'));
print_r(snmprealwalk('1.2.3.4', 'public', '.1.3.6.1.2.1.17.2.15.1.3.1'));
?>

Expected result:
----------------
Array
(
    [.1.3.6.1.2.1.17.2.15.1.3.1] => INTEGER: 5
)
Array
(
    [.1.3.6.1.2.1.17.2.15.1.3.1] => INTEGER: 5
)
Array
(
    [.1.3.6.1.2.1.17.2.15.1.3.1] => INTEGER: 5
)

Actual result:
--------------
Array
(
    [.1.3.6.1.2.1.17.2.15.1.3.1] => INTEGER: 5
)
Array
(
    [.1.3.6.1.2.1.17.2.15.1.3.1] => INTEGER: forwarding(5)
)
Array
(
    [.1.3.6.1.2.1.17.2.15.1.3.1] => INTEGER: forwarding(5)
)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-06-10 23:58 UTC] php at mcq8 dot be
Based on what you have in the expected result, you want to use snmp_set_enum_print(1) instead of snmp_set_oid_output_format(SNMP_OID_OUTPUT_NUMERIC)?
The OIDs are in fact all numeric as expected in your example.
 [2017-06-12 06:31 UTC] mattias dot wallin at salanet dot se
-Status: Open +Status: Closed
 [2017-06-12 06:31 UTC] mattias dot wallin at salanet dot se
Yes, you are right.

I think i get how this confused me now..

When using snmprealwalk with numeric OID the MIB is not loaded, and therefore do not know about enum values.

Second call needs to load the MIB to parse the OID, which makes the enum values known and used for this and subsequent calls.

Using snmp_set_enum_print(0) do not change the actual result. But it is probably not a bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC