From: piegtas at hotmail dot com Operating system: All Unix PHP version: 4.3.4 PHP Bug Type: Feature/Change Request Bug description: SNMP v2c parameter support for functions
Description: ------------ I made a patch to add SNMP v2c support for snmpget/snmpwalk/snmprealwalk I add a sixth parameter to those functions for use like this example: snmpwalk("router.dot.com", "readcomm", "ifHCInOctets", 1, 2, 2); This is my patch: diff -u ext/snmp/snmp.c ext/snmp.1/snmp.c --- ext/snmp/snmp.c Wed Jan 14 12:38:15 2004 +++ ext/snmp.1/snmp.c Wed Jan 14 12:35:47 2004 @@ -392,6 +392,7 @@ long timeout=SNMP_DEFAULT_TIMEOUT; long retries=SNMP_DEFAULT_RETRIES; int myargc = ZEND_NUM_ARGS(); + long myvers = SNMP_VERSION_1; char type = (char) 0; char *value = (char *) 0; char hostname[MAX_NAME_LEN]; @@ -437,6 +438,16 @@ convert_to_long_ex(a5); retries = Z_LVAL_PP(a5); } + + if(myargc > 5) { + convert_to_long_ex(a6); + switch(Z_LVAL_PP(a6)) { + case 1: myvers = SNMP_VERSION_1; + break; + case 2: myvers = SNMP_VERSION_2c; + break; + } + } } snmp_sess_init(&session); @@ -448,7 +459,7 @@ session.peername = hostname; session.remote_port = remote_port; - session.version = SNMP_VERSION_1; + session.version = (int)myvers; /* * FIXME: potential memory leak * This is a workaround for an "artifact" (Mike Slifcak) -- Edit bug report at http://bugs.php.net/?id=26907&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26907&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26907&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=26907&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=26907&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=26907&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=26907&r=needscript Try newer version: http://bugs.php.net/fix.php?id=26907&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=26907&r=support Expected behavior: http://bugs.php.net/fix.php?id=26907&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=26907&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=26907&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=26907&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26907&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=26907&r=dst IIS Stability: http://bugs.php.net/fix.php?id=26907&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=26907&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=26907&r=float