#19601 [Com]: snmp_set_quick_print doesn't work

From: Date: Mon, 31 Mar 2003 14:37:06 +0000
Subject: #19601 [Com]: snmp_set_quick_print doesn't work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-36813@lists.php.net to get a copy of this message
ID: 19601 Comment by: domi at saargate dot de Reported By: cbowman at amtelecom dot ca Status: No Feedback Bug Type: SNMP related Operating System: RedHat Linux 7.3 PHP Version: 4.2.1 New Comment: 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) Previous Comments: ------------------------------------------------------------------------ [2002-11-01 01:00:04] php-bugs at lists dot php dot net No feedback was provided for this bug for over 2 weeks, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". ------------------------------------------------------------------------ [2002-10-16 21:53:54] sniper@php.net Basically: snmp_set_quick_print(1) just makes the ucd-snmp library to return less informative values, so the snmp_set_quick_print() obviously works for you since the output changes. But there indeed might be some bug in the ucd-snmp libs. At least ucd-snmp-4.2.6 and net-snmp-5.0.6 behave differently. I suggest you try the latest CVS snapshot of PHP with net-snmp-5.0.6. ------------------------------------------------------------------------ [2002-10-16 18:34:07] iliaa@php.net Please try using this CVS snapshot: http://snaps.php.net/php4-latest.tar.gz For Windows: http://snaps.php.net/win32/php4-win32-latest.zip ------------------------------------------------------------------------ [2002-09-25 13:54:11] 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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=19601&edit=1

« previous php.bugs (#36813) next »