harrie Mon Apr 11 10:56:51 2005 EDT
Modified files:
/php-src/ext/snmp snmp.c
Log:
Adding support for a getbulk oriented walk.
The getbulk can only be used for SNMPv2c and SNMPv3.
http://cvs.php.net/diff.php/php-src/ext/snmp/snmp.c?r1=1.98&r2=1.99&ty=u
Index: php-src/ext/snmp/snmp.c
diff -u php-src/ext/snmp/snmp.c:1.98 php-src/ext/snmp/snmp.c:1.99
--- php-src/ext/snmp/snmp.c:1.98 Wed Mar 16 09:29:40 2005
+++ php-src/ext/snmp/snmp.c Mon Apr 11 10:56:44 2005
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: snmp.c,v 1.98 2005/03/16 14:29:40 harrie Exp $ */
+/* $Id: snmp.c,v 1.99 2005/04/11 14:56:44 harrie Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -326,14 +326,14 @@
*
* Generic SNMP object fetcher (for all SNMP versions)
*
-* st=1 snmpget() - query an agent and return a single value.
-* st=2 snmpget() - query an agent and return the next single value.
-* st=3 snmpwalk() - walk the mib and return a single dimensional array
-* containing the values.
-* st=4 snmprealwalk() and snmpwalkoid() - walk the mib and return an
-* array of oid,value pairs.
+* st=1 get - query an agent with SNMP-GET.
+* st=2 getnext - query an agent with SNMP-GETNEXT.
+* st=3 walk - walk the mib and return a single dimensional array
+* containing the values.
+* st=4 realwalk() and walkoid() - walk the mib and return an
+* array of oid,value pairs.
* st=5-8 ** Reserved **
-* st=11 snmpset() - query an agent and set a single value
+* st=11 set() - query an agent and set a single value
*
*/
static void php_snmp_internal(INTERNAL_FUNCTION_PARAMETERS, int st,
@@ -419,7 +419,13 @@
RETURN_FALSE;
}
} else if (st >= 3) {
- pdu = snmp_pdu_create(SNMP_MSG_GETNEXT);
+ if (session->version == SNMP_VERSION_1) {
+ pdu = snmp_pdu_create(SNMP_MSG_GETNEXT);
+ } else {
+ pdu = snmp_pdu_create(SNMP_MSG_GETBULK);
+ pdu->non_repeaters = 0;
+ pdu->max_repetitions = 20;
+ }
snmp_add_null_var(pdu, name, name_length);
}
@@ -490,10 +496,16 @@
if ((pdu =
snmp_fix_pdu(response, SNMP_MSG_SET)) != NULL) {
goto retry;
}
- } else if (st >= 2) { /* Here we do
both getnext and walks. */
+ } else if (st == 2) {
if ((pdu =
snmp_fix_pdu(response, SNMP_MSG_GETNEXT)) != NULL) {
goto retry;
}
+ } else if (st >= 3) { /* Here we do
walks. */
+ if ((pdu =
snmp_fix_pdu(response, ((session->version == SNMP_VERSION_1)
+
? SNMP_MSG_GETNEXT
+
: SNMP_MSG_GETBULK))) != NULL) {
+ goto retry;
+ }
}
snmp_close(ss);
RETURN_FALSE;
@@ -528,14 +540,14 @@
* This function makes use of the internal SNMP object fetcher.
* The object fetcher is shared with SNMPv3.
*
-* st=1 snmpget() - query an agent and return a single value.
-* st=2 snmpgetnext() - query an agent and return the next single value.
-* st=3 snmpwalk() - walk the mib and return a single dimensional array
+* st=1 get - query an agent with SNMP-GET.
+* st=2 getnext - query an agent with SNMP-GETNEXT.
+* st=3 walk - walk the mib and return a single dimensional array
* containing the values.
-* st=4 snmprealwalk() and snmpwalkoid() - walk the mib and return an
+* st=4 realwalk() and walkoid() - walk the mib and return an
* array of oid,value pairs.
* st=5-8 ** Reserved **
-* st=11 snmpset() - query an agent and set a single value
+* st=11 set() - query an agent and set a single value
*
*/
static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php