|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-03-15 02:25 UTC] jamuel at my740il dot com
with Net-SNMP v5.0.9pre1 snmpset always fails for shortened textual OIDs even though the same smmpset cmd (built from the netsnmp library) works correctly from the linux shell. (Makes me think the problem is in PHP vs in Net-SNMP) The failure text is: Warning: snmpset() [http://www.php.net/function.snmpset]: Invalid object identifier: sysContact.0 in /var/www/html/set-test.php on line 16 Warning: snmpset() [http://www.php.net/function.snmpset]: Error in packet: (noSuchName) There is no such variable name in this MIB. in /var/www/html/set-test.php on line 16 Warning: snmpset() [http://www.php.net/function.snmpset]: This name does not exist: SNMPv2-SMI::internet in /var/www/html/set-test.php on line 16 (Please note the value is not set as well.) Also, full text OIDs from the ".iso.org.dod . . ." root work just fine with snmpset (and so do full numeric OIDs). FWIW, the shortened text OIDs *do* work correctly with snmpget. Here's the line in php that fails: echo snmpset ('10.1.1.1', 'private', 'sysContact.0', 's', 'My Name'); Thanks for your help . . . JPS PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 05:00:01 2025 UTC |
Ok so the following patch resolves the issue on my system. Not really sure why the existing function call fails but regardless snmpset now works correctly with shortened textual oids, full textual oids, and full numeric oids. I also tested snmpget and it works fine as well. --- snmp.c Fri Feb 21 02:42:01 2003 +++ snmp.c Tue Mar 18 13:58:48 2003 @@ -217,7 +217,7 @@ static void php_snmp_internal(INTERNAL_F if (st >= 2) { /* walk */ rootlen = MAX_NAME_LEN; if (strlen(objid)) { /* on a walk, an empty string means top of tree - no error */ - if (read_objid(objid, root, &rootlen)) { + if (snmp_parse_oid(objid, root, &rootlen)) { gotroot = 1; } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid); Do a patch -po -l from the ../ext/snmp directory and paste the above patch-text into patch, press <CTRL-D> twice to exit patch and you should see "patching file snmp.c". cd back to the root of the PHP-4 source directory, make clean, make all, make install and you should be in business! BTW, no really sure how this form will mangle the patch-text but it's really only a one line change. So you could just manually edit the snmp.c file and look for line 220 and make the change from read_objid to snmp_parse_oid (the parameters remain unchanged.) Hope that helps . . . Cheers, JPS