|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-09-25 13:54 UTC] cbowman at amtelecom dot ca
OS: RedHat Linux 7.3 (Linux version 2.4.18-10) i386 PHP RPM: php-4.1.2-7.3.4 PHP SNMP RPM: php-snmp-4.1.2-7.3.4 UCD SNMP RPM: ucd-snmp-4.2.5-7.73.0 Basically, all this fuction will do is remove the "=" sign between the OID & the value. ie.. snmp_set_quick_print(0) 69.1.3.5.0 = "2.1.1.107.004" OR snmp_set_quick_print(1) 69.1.3.5.0 "2.1.1.107.004" I'm not sure why this happens, perhaps it is a bug in UCD & not PHP. Any help appreciated. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 07:00:02 2025 UTC |
I don't think this is a bug, neither in PHP or in the UCD SNMP library. Maybe the behaviour of the latter has changed between 4.2.3 and 4.2.5 - there were a lot of changes between the two versions, as far as I can know. Apart from the "quick print" option, the SNMP API supports another option, which is described in the snmpcmd(1) manual page: -Ov Output only the variable value, not the OID: snmpget -c public -Ov localhost ip.ipForwarding.0 forwarding(1) Avoiding to print the OID is probably the problem stated in this case. I managed to add two new functions to PHP 4.2.3 in order to toggle the value of this options (internally it is called "bare value"). They can be used just as snmp_[sg]et_quick_print() can be used: diff -urN php-4.2.3.orig/ext/snmp/php_snmp.h php-4.2.3/ext/snmp/php_snmp.h --- php-4.2.3.orig/ext/snmp/php_snmp.h Thu Feb 28 09:26:42 2002 +++ php-4.2.3/ext/snmp/php_snmp.h Mon Mar 31 16:36:22 2003 @@ -34,6 +34,8 @@ PHP_FUNCTION(snmpget); PHP_FUNCTION(snmpwalk); PHP_FUNCTION(snmprealwalk); +PHP_FUNCTION(snmp_get_bare_value); +PHP_FUNCTION(snmp_set_bare_value); PHP_FUNCTION(snmp_get_quick_print); PHP_FUNCTION(snmp_set_quick_print); PHP_FUNCTION(snmpset); diff -urN php-4.2.3.orig/ext/snmp/snmp.c php-4.2.3/ext/snmp/snmp.c --- php-4.2.3.orig/ext/snmp/snmp.c Fri Mar 1 04:31:01 2002 +++ php-4.2.3/ext/snmp/snmp.c Mon Mar 31 16:36:26 2003 @@ -88,6 +88,8 @@ PHP_FALIAS(snmpwalkoid, snmprealwalk, NULL) PHP_FE(snmp_get_quick_print, NULL) PHP_FE(snmp_set_quick_print, NULL) + PHP_FE(snmp_get_bare_value, NULL) + PHP_FE(snmp_set_bare_value, NULL) PHP_FE(snmpset, NULL) {NULL,NULL,NULL} }; @@ -433,6 +435,32 @@ } /* }}} */ +/* {{{ proto bool snmp_get_bare_value(void) + Return the current status of bare_value */ +PHP_FUNCTION(snmp_get_bare_value) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + RETURN_LONG(ds_get_boolean(DS_LIBRARY_ID, DS_LIB_PRINT_BARE_VALUE) ? 1 : 0); +} +/* }}} */ + +/* {{{ proto void snmp_set_bare_value(int bare_value) + Set the current status of bare_value */ +PHP_FUNCTION(snmp_set_bare_value) +{ + int argc = ZEND_NUM_ARGS(); + long a1; + + if (zend_parse_parameters(argc TSRMLS_CC, "l", &a1) == FAILURE) { + return; + } + + ds_set_boolean(DS_LIBRARY_ID, DS_LIB_PRINT_BARE_VALUE, (int)a1); +} +/* }}} */ /* {{{ proto int snmpset(string host, string community, string object_id, string type, mixed value [, int timeout [, int retries]]) Set the value of a SNMP object */ PHP_FUNCTION(snmpset)