Dear list,
To better reflect the behavior of the snmpget command that comes with
the Net-SNMP package the patch attached makes an array of OIDs as a
parameter for the snmpget()/snmpgetnext() function possible. This allows
more efficient querying over SNMP as the Net-SNMP API will bundle the
OIDs into one request. The patch is backwards compatible, as in,
snmpget()/snmpgetnext() will still accept a string and return a string
in that case.
For completeness' sake, I've also added snmpgetoid() and
snmpgetnextoid() as the counterparts for snmpwalkoid().
Regards,
Jorrit Kronjee
Index: ext/snmp/php_snmp.h
===================================================================
--- ext/snmp/php_snmp.h (revision 303630)
+++ ext/snmp/php_snmp.h (working copy)
@@ -43,7 +43,9 @@
PHP_MINFO_FUNCTION(snmp);
PHP_FUNCTION(snmpget);
+PHP_FUNCTION(snmpgetoid);
PHP_FUNCTION(snmpgetnext);
+PHP_FUNCTION(snmpgetnextoid);
PHP_FUNCTION(snmpwalk);
PHP_FUNCTION(snmprealwalk);
PHP_FUNCTION(snmp_get_quick_print);
@@ -53,13 +55,17 @@
PHP_FUNCTION(snmpset);
PHP_FUNCTION(snmp2_get);
+PHP_FUNCTION(snmp2_getoid);
PHP_FUNCTION(snmp2_getnext);
+PHP_FUNCTION(snmp2_getnextoid);
PHP_FUNCTION(snmp2_walk);
PHP_FUNCTION(snmp2_real_walk);
PHP_FUNCTION(snmp2_set);
PHP_FUNCTION(snmp3_get);
+PHP_FUNCTION(snmp3_getoid);
PHP_FUNCTION(snmp3_getnext);
+PHP_FUNCTION(snmp3_getnextoid);
PHP_FUNCTION(snmp3_walk);
PHP_FUNCTION(snmp3_real_walk);
PHP_FUNCTION(snmp3_set);
Index: ext/snmp/snmp.c
===================================================================
--- ext/snmp/snmp.c (revision 303630)
+++ ext/snmp/snmp.c (working copy)
@@ -121,6 +121,14 @@
ZEND_ARG_INFO(0, retries)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_snmpgetoid, 0, 0, 3)
+ ZEND_ARG_INFO(0, host)
+ ZEND_ARG_INFO(0, community)
+ ZEND_ARG_INFO(0, object_id)
+ ZEND_ARG_INFO(0, timeout)
+ ZEND_ARG_INFO(0, retries)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_snmpgetnext, 0, 0, 3)
ZEND_ARG_INFO(0, host)
ZEND_ARG_INFO(0, community)
@@ -129,6 +137,14 @@
ZEND_ARG_INFO(0, retries)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_snmpgetnextoid, 0, 0, 3)
+ ZEND_ARG_INFO(0, host)
+ ZEND_ARG_INFO(0, community)
+ ZEND_ARG_INFO(0, object_id)
+ ZEND_ARG_INFO(0, timeout)
+ ZEND_ARG_INFO(0, retries)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_snmpwalk, 0, 0, 3)
ZEND_ARG_INFO(0, host)
ZEND_ARG_INFO(0, community)
@@ -181,6 +197,14 @@
ZEND_ARG_INFO(0, retries)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp2_getoid, 0, 0, 3)
+ ZEND_ARG_INFO(0, host)
+ ZEND_ARG_INFO(0, community)
+ ZEND_ARG_INFO(0, object_id)
+ ZEND_ARG_INFO(0, timeout)
+ ZEND_ARG_INFO(0, retries)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp2_getnext, 0, 0, 3)
ZEND_ARG_INFO(0, host)
ZEND_ARG_INFO(0, community)
@@ -189,6 +213,14 @@
ZEND_ARG_INFO(0, retries)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp2_getnextoid, 0, 0, 3)
+ ZEND_ARG_INFO(0, host)
+ ZEND_ARG_INFO(0, community)
+ ZEND_ARG_INFO(0, object_id)
+ ZEND_ARG_INFO(0, timeout)
+ ZEND_ARG_INFO(0, retries)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp2_walk, 0, 0, 3)
ZEND_ARG_INFO(0, host)
ZEND_ARG_INFO(0, community)
@@ -233,6 +265,19 @@
ZEND_ARG_INFO(0, retries)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp3_getoid, 0, 0, 8)
+ ZEND_ARG_INFO(0, host)
+ ZEND_ARG_INFO(0, sec_name)
+ ZEND_ARG_INFO(0, sec_level)
+ ZEND_ARG_INFO(0, auth_protocol)
+ ZEND_ARG_INFO(0, auth_passphrase)
+ ZEND_ARG_INFO(0, priv_protocol)
+ ZEND_ARG_INFO(0, priv_passphrase)
+ ZEND_ARG_INFO(0, object_id)
+ ZEND_ARG_INFO(0, timeout)
+ ZEND_ARG_INFO(0, retries)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp3_getnext, 0, 0, 8)
ZEND_ARG_INFO(0, host)
ZEND_ARG_INFO(0, sec_name)
@@ -246,6 +291,19 @@
ZEND_ARG_INFO(0, retries)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp3_getnextoid, 0, 0, 8)
+ ZEND_ARG_INFO(0, host)
+ ZEND_ARG_INFO(0, sec_name)
+ ZEND_ARG_INFO(0, sec_level)
+ ZEND_ARG_INFO(0, auth_protocol)
+ ZEND_ARG_INFO(0, auth_passphrase)
+ ZEND_ARG_INFO(0, priv_protocol)
+ ZEND_ARG_INFO(0, priv_passphrase)
+ ZEND_ARG_INFO(0, object_id)
+ ZEND_ARG_INFO(0, timeout)
+ ZEND_ARG_INFO(0, retries)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp3_walk, 0, 0, 8)
ZEND_ARG_INFO(0, host)
ZEND_ARG_INFO(0, sec_name)
@@ -303,7 +361,9 @@
*/
const zend_function_entry snmp_functions[] = {
PHP_FE(snmpget,
arginfo_snmpget)
+ PHP_FE(snmpgetoid,
arginfo_snmpgetoid)
PHP_FE(snmpgetnext,
arginfo_snmpgetnext)
+ PHP_FE(snmpgetnextoid,
arginfo_snmpgetnextoid)
PHP_FE(snmpwalk,
arginfo_snmpwalk)
PHP_FE(snmprealwalk,
arginfo_snmprealwalk)
PHP_FALIAS(snmpwalkoid, snmprealwalk, arginfo_snmprealwalk)
@@ -317,13 +377,17 @@
PHP_FE(snmpset, arginfo_snmpset)
PHP_FE(snmp2_get, arginfo_snmp2_get)
+ PHP_FE(snmp2_getoid, arginfo_snmp2_getoid)
PHP_FE(snmp2_getnext, arginfo_snmp2_getnext)
+ PHP_FE(snmp2_getnextoid, arginfo_snmp2_getnextoid)
PHP_FE(snmp2_walk, arginfo_snmp2_walk)
PHP_FE(snmp2_real_walk, arginfo_snmp2_real_walk)
PHP_FE(snmp2_set, arginfo_snmp2_set)
PHP_FE(snmp3_get, arginfo_snmp3_get)
+ PHP_FE(snmp3_getoid, arginfo_snmp3_getoid)
PHP_FE(snmp3_getnext, arginfo_snmp3_getnext)
+ PHP_FE(snmp3_getnextoid, arginfo_snmp3_getnextoid)
PHP_FE(snmp3_walk, arginfo_snmp3_walk)
PHP_FE(snmp3_real_walk, arginfo_snmp3_real_walk)
PHP_FE(snmp3_set, arginfo_snmp3_set)
@@ -336,9 +400,11 @@
/* }}} */
#define SNMP_CMD_GET 1
-#define SNMP_CMD_GETNEXT 2
-#define SNMP_CMD_WALK 3
-#define SNMP_CMD_REALWALK 4
+#define SNMP_CMD_GETOID 2
+#define SNMP_CMD_GETNEXT 3
+#define SNMP_CMD_GETNEXTOID 4
+#define SNMP_CMD_WALK 5
+#define SNMP_CMD_REALWALK 6
#define SNMP_CMD_SET 11
/* {{{ snmp_module_entry
@@ -534,7 +600,11 @@
* Generic SNMP object fetcher (for all SNMP versions)
*
* st=SNMP_CMD_GET get - query an agent with SNMP-GET.
+* st=SNMP_CMD_GETOID get - query an agent with SNMP-GET and return an
+* array of the oid and corresponding value
* st=SNMP_CMD_GETNEXT getnext - query an agent with SNMP-GETNEXT.
+* st=SNMP_CMD_GETNEXTOID getnext - query an agent with SNMP-GETNEXT and
+* return an array of the oid and corresponding value.
* st=SNMP_CMD_WALK walk - walk the mib and return a single dimensional array
* containing the values.
* st=SNMP_CMD_REALWALK realwalk() and walkoid() - walk the mib and return an
@@ -546,7 +616,8 @@
struct snmp_session
*session,
char *objid,
char type,
- char* value)
+ char* value,
+ zval *zval_oids)
{
struct snmp_session *ss;
struct snmp_pdu *pdu=NULL, *response;
@@ -562,6 +633,8 @@
int keepwalking=1;
char *err;
zval *snmpval = NULL;
+ zval **zval_oid = NULL;
+ int nelems, i;
if (st >= SNMP_CMD_WALK) { /* walk */
rootlen = MAX_NAME_LEN;
@@ -587,10 +660,19 @@
RETURN_FALSE;
}
- if (st >= SNMP_CMD_WALK) {
+ if (st >= SNMP_CMD_GET) {
memmove((char *)name, (char *)root, rootlen * sizeof(oid));
name_length = rootlen;
+
switch(st) {
+ case SNMP_CMD_GET:
+ case SNMP_CMD_GETNEXT:
+ if (Z_TYPE_P(zval_oids) == IS_ARRAY)
+ array_init(return_value);
+ break;
+
+ case SNMP_CMD_GETOID:
+ case SNMP_CMD_GETNEXTOID:
case SNMP_CMD_WALK:
case SNMP_CMD_REALWALK:
array_init(return_value);
@@ -603,15 +685,62 @@
while (keepwalking) {
keepwalking = 0;
- if ((st == SNMP_CMD_GET) || (st == SNMP_CMD_GETNEXT)) {
+ if ((st == SNMP_CMD_GET) || (st == SNMP_CMD_GETOID) ||
+ (st == SNMP_CMD_GETNEXT) || (st ==
SNMP_CMD_GETNEXTOID)) {
name_length = MAX_OID_LEN;
- if (!snmp_parse_oid(objid, name, &name_length)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,
"Invalid object identifier: %s", objid);
- snmp_close(ss);
- RETURN_FALSE;
+ pdu = snmp_pdu_create((st == SNMP_CMD_GET || st ==
SNMP_CMD_GETOID) ? SNMP_MSG_GET : SNMP_MSG_GETNEXT);
+
+ switch (Z_TYPE_P(zval_oids)) {
+ case IS_STRING:
+ if
(!snmp_parse_oid(Z_STRVAL_P(zval_oids), name, &name_length)) {
+ php_error_docref(NULL
TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", Z_STRVAL_P(zval_oids));
+ snmp_free_pdu(pdu);
+ snmp_close(ss);
+ RETURN_FALSE;
+ }
+
+ snmp_add_null_var(pdu, name,
name_length);
+ break;
+
+ case IS_ARRAY:
+ nelems =
zend_hash_num_elements(Z_ARRVAL_P(zval_oids));
+ if (nelems == 0 ) {
+ RETURN_FALSE;
+ }
+ for (i = 0; i < nelems; i++) {
+ if
(zend_hash_index_find(Z_ARRVAL_P(zval_oids), i, (void **) &zval_oid) ==
SUCCESS) {
+ switch
(Z_TYPE_PP(zval_oid)) {
+
+ case IS_STRING:
+ if
(!snmp_parse_oid(Z_STRVAL_PP(zval_oid), name, &name_length)) {
+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s",
Z_STRVAL_PP(zval_oid));
+
snmp_free_pdu(pdu);
+
snmp_close(ss);
+
RETURN_FALSE;
+ }
+
+
snmp_add_null_var(pdu, name, name_length);
+ break;
+
+ default:
+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument, expect string or
array of strings");
+
snmp_free_pdu(pdu);
+
snmp_close(ss);
+
RETURN_FALSE;
+ }
+ }
+ }
+ break;
+
+ default:
+ php_error_docref(NULL TSRMLS_CC,
E_WARNING, "Invalid argument, expect string or array of strings");
+ snmp_free_pdu(pdu);
+ snmp_close(ss);
+ RETURN_FALSE;
+ break;
}
- pdu = snmp_pdu_create((st == SNMP_CMD_GET) ?
SNMP_MSG_GET : SNMP_MSG_GETNEXT);
- snmp_add_null_var(pdu, name, name_length);
+
+
} else if (st == SNMP_CMD_SET) {
pdu = snmp_pdu_create(SNMP_MSG_SET);
if (snmp_add_var(pdu, name, name_length, type, value)) {
@@ -651,19 +780,25 @@
php_snmp_getvalue(vars, snmpval
TSRMLS_CC);
}
- if (st == SNMP_CMD_GET) {
- *return_value = *snmpval;
- zval_copy_ctor(return_value);
- zval_ptr_dtor(&snmpval);
- snmp_free_pdu(response);
- snmp_close(ss);
- return;
- } else if (st == SNMP_CMD_GETNEXT) {
- *return_value = *snmpval;
- zval_copy_ctor(return_value);
- snmp_free_pdu(response);
- snmp_close(ss);
- return;
+ if (st == SNMP_CMD_GET || st ==
SNMP_CMD_GETNEXT) {
+ if (Z_TYPE_P(zval_oids) ==
IS_STRING) {
+ /* Return a string */
+ *return_value =
*snmpval;
+
zval_copy_ctor(return_value);
+ zval_ptr_dtor(&snmpval);
+ snmp_free_pdu(response);
+ snmp_close(ss);
+ return;
+ }
+
add_next_index_zval(return_value,snmpval); /* Add to returned array */
+ } else if (st == SNMP_CMD_GETOID || st
== SNMP_CMD_GETNEXTOID) {
+#ifdef HAVE_NET_SNMP
+ snprint_objid(buf2,
sizeof(buf2), vars->name, vars->name_length);
+#else
+ sprint_objid(buf2, vars->name,
vars->name_length);
+#endif
+
add_assoc_zval(return_value,buf2,snmpval);
+
} else if (st == SNMP_CMD_WALK) {
add_next_index_zval(return_value,snmpval); /* Add to returned array */
} else if (st == SNMP_CMD_REALWALK &&
vars->type != SNMP_ENDOFMIBVIEW && vars->type != SNMP_NOSUCHOBJECT &&
vars->type != SNMP_NOSUCHINSTANCE) {
@@ -703,7 +838,8 @@
}
php_error_docref(NULL
TSRMLS_CC, E_WARNING, "This name does not exist: %s",buf);
}
- if (st == SNMP_CMD_GET) {
+
+ if (st == SNMP_CMD_GET || st ==
SNMP_CMD_GETOID) {
if ((pdu =
snmp_fix_pdu(response, SNMP_MSG_GET)) != NULL) {
snmp_free_pdu(response);
goto retry;
@@ -713,7 +849,7 @@
snmp_free_pdu(response);
goto retry;
}
- } else if (st == SNMP_CMD_GETNEXT) {
+ } else if (st == SNMP_CMD_GETNEXT || st
== SNMP_CMD_GETNEXTOID) {
if ((pdu =
snmp_fix_pdu(response, SNMP_MSG_GETNEXT)) != NULL) {
snmp_free_pdu(response);
goto retry;
@@ -728,7 +864,7 @@
}
snmp_free_pdu(response);
snmp_close(ss);
- if (st == SNMP_CMD_WALK || st ==
SNMP_CMD_REALWALK) {
+ if (st >= SNMP_CMD_GET && st !=
SNMP_CMD_SET) {
zval_dtor(return_value);
}
RETURN_FALSE;
@@ -736,14 +872,14 @@
}
} else if (status == STAT_TIMEOUT) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No
response from %s", session->peername);
- if (st == SNMP_CMD_WALK || st == SNMP_CMD_REALWALK) {
+ if (st >= SNMP_CMD_GET && st != SNMP_CMD_SET) {
zval_dtor(return_value);
}
snmp_close(ss);
RETURN_FALSE;
} else { /* status == STAT_ERROR */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "An error
occurred, quitting");
- if (st == SNMP_CMD_WALK || st == SNMP_CMD_REALWALK) {
+ if (st >= SNMP_CMD_GET && st != SNMP_CMD_SET) {
zval_dtor(return_value);
}
snmp_close(ss);
@@ -764,7 +900,11 @@
* The object fetcher is shared with SNMPv3.
*
* st=SNMP_CMD_GET get - query an agent with SNMP-GET.
+* st=SNMP_CMD_GETOID get - query an agent with SNMP-GET and return an array
+* of the oid and the corresponding value.
* st=SNMP_CMD_GETNEXT getnext - query an agent with SNMP-GETNEXT.
+* st=SNMP_CMD_GETNEXTOID getnext - query an agent with SNMP-GETNEXT and
+* return an array of the oid and the
corresponding value.
* st=SNMP_CMD_WALK walk - walk the mib and return a single dimensional array
* containing the values.
* st=SNMP_CMD_REALWALK realwalk() and walkoid() - walk the mib and return an
@@ -777,6 +917,7 @@
{
char *a1, *a2, *a3;
int a1_len, a2_len, a3_len;
+ zval *zval_oids = NULL;
struct snmp_session session;
long timeout = SNMP_DEFAULT_TIMEOUT;
long retries = SNMP_DEFAULT_RETRIES;
@@ -792,10 +933,12 @@
if (zend_parse_parameters(argc TSRMLS_CC, "sssss|ll", &a1,
&a1_len, &a2, &a2_len, &a3, &a3_len, &stype, &stype_len, &value, &value_len,
&timeout, &retries) == FAILURE) {
return;
}
+ } else if (st == SNMP_CMD_GET || st == SNMP_CMD_GETOID || st ==
SNMP_CMD_GETNEXT || st == SNMP_CMD_GETNEXTOID) {
+ if (zend_parse_parameters(argc TSRMLS_CC, "ssz|ll", &a1,
&a1_len, &a2, &a2_len, &zval_oids, &timeout, &retries) == FAILURE) {
+ return;
+ }
} else {
- /* SNMP_CMD_GET
- * SNMP_CMD_GETNEXT
- * SNMP_CMD_WALK
+ /* SNMP_CMD_WALK
* SNMP_CMD_REALWALK
*/
if (zend_parse_parameters(argc TSRMLS_CC, "sss|ll", &a1,
&a1_len, &a2, &a2_len, &a3, &a3_len, &timeout, &retries) == FAILURE) {
@@ -833,7 +976,7 @@
session.authenticator = NULL;
- php_snmp_internal(INTERNAL_FUNCTION_PARAM_PASSTHRU, st, &session, a3,
type, value);
+ php_snmp_internal(INTERNAL_FUNCTION_PARAM_PASSTHRU, st, &session, a3,
type, value, zval_oids);
}
/* }}} */
@@ -845,6 +988,14 @@
}
/* }}} */
+/* {{{ proto string snmpgetoid(string host, string community, string object_id
[, int timeout [, int retries]])
+ Fetch a SNMP object */
+PHP_FUNCTION(snmpgetoid)
+{
+ php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,SNMP_CMD_GETOID,
SNMP_VERSION_1);
+}
+/* }}} */
+
/* {{{ proto string snmpgetnext(string host, string community, string
object_id [, int timeout [, int retries]])
Fetch a SNMP object */
PHP_FUNCTION(snmpgetnext)
@@ -853,6 +1004,14 @@
}
/* }}} */
+/* {{{ proto string snmpgetnextoid(string host, string community, string
object_id [, int timeout [, int retries]])
+ Fetch a SNMP object */
+PHP_FUNCTION(snmpgetnextoid)
+{
+ php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,SNMP_CMD_GETNEXTOID,
SNMP_VERSION_1);
+}
+/* }}} */
+
/* {{{ proto array snmpwalk(string host, string community, string object_id [,
int timeout [, int retries]])
Return all objects under the specified object id */
PHP_FUNCTION(snmpwalk)
@@ -1125,6 +1284,14 @@
}
/* }}} */
+/* {{{ proto string snmp2_getoid(string host, string community, string
object_id [, int timeout [, int retries]])
+ Fetch a SNMP object */
+PHP_FUNCTION(snmp2_getoid)
+{
+ php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,SNMP_CMD_GETOID,
SNMP_VERSION_2c);
+}
+/* }}} */
+
/* {{{ proto string snmp2_getnext(string host, string community, string
object_id [, int timeout [, int retries]])
Fetch a SNMP object */
PHP_FUNCTION(snmp2_getnext)
@@ -1133,6 +1300,14 @@
}
/* }}} */
+/* {{{ proto string snmp2_getnextoid(string host, string community, string
object_id [, int timeout [, int retries]])
+ Fetch a SNMP object */
+PHP_FUNCTION(snmp2_getnextoid)
+{
+ php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,SNMP_CMD_GETNEXTOID,
SNMP_VERSION_2c);
+}
+/* }}} */
+
/* {{{ proto array snmp2_walk(string host, string community, string object_id
[, int timeout [, int retries]])
Return all objects under the specified object id */
PHP_FUNCTION(snmp2_walk)
@@ -1163,7 +1338,10 @@
* From here is passed on the the common internal object fetcher.
*
* st=SNMP_CMD_GET snmp3_get() - query an agent and return a single value.
+* st=SNMP_CMD_GETOID snmp3_getoid() - query an agent and return an array of
oid and value.
* st=SNMP_CMD_GETNEXT snmp3_getnext() - query an agent and return the next
single value.
+* st=SNMP_CMD_GETNEXTOID snmp3_getnextoid() - query an agent and return an
array of the
+* next oid and value.
* st=SNMP_CMD_WALK snmp3_walk() - walk the mib and return a single
dimensional array
* containing the values.
* st=SNMP_CMD_REALWALK snmp3_real_walk() - walk the mib and return an
@@ -1173,8 +1351,9 @@
*/
static void php_snmpv3(INTERNAL_FUNCTION_PARAMETERS, int st)
{
- char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
- int a1_len, a2_len, a3_len, a4_len, a5_len, a6_len, a7_len, a8_len;
+ char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;;
+ int a1_len, a2_len, a3_len, a4_len, a5_len, a6_len, a7_len, a8_len;;
+ zval *zval_oids = NULL;
struct snmp_session session;
long timeout = SNMP_DEFAULT_TIMEOUT;
long retries = SNMP_DEFAULT_RETRIES;
@@ -1191,10 +1370,13 @@
&a4, &a4_len, &a5, &a5_len, &a6, &a6_len, &a7, &a7_len,
&a8, &a8_len, &stype, &stype_len, &value, &value_len, &timeout, &retries) ==
FAILURE) {
return;
}
+ } else if (st == SNMP_CMD_GET || st == SNMP_CMD_GETOID || st ==
SNMP_CMD_GETNEXT || st == SNMP_CMD_GETNEXTOID) {
+ if (zend_parse_parameters(argc TSRMLS_CC, "sssssssz|ll", &a1,
&a1_len, &a2, &a2_len, &a3, &a3_len,
+ &a4, &a4_len, &a5, &a5_len, &a6, &a6_len, &a7, &a7_len,
&zval_oids, &timeout, &retries) == FAILURE) {
+ return;
+ }
} else {
- /* SNMP_CMD_GET
- * SNMP_CMD_GETNEXT
- * SNMP_CMD_WALK
+ /* SNMP_CMD_WALK
* SNMP_CMD_REALWALK
*/
if (zend_parse_parameters(argc TSRMLS_CC, "ssssssss|ll", &a1,
&a1_len, &a2, &a2_len, &a3, &a3_len,
@@ -1258,7 +1440,7 @@
session.retries = retries;
session.timeout = timeout;
- php_snmp_internal(INTERNAL_FUNCTION_PARAM_PASSTHRU, st, &session, a8,
type, value);
+ php_snmp_internal(INTERNAL_FUNCTION_PARAM_PASSTHRU, st, &session, a3,
type, value, zval_oids);
}
/* }}} */
@@ -1270,6 +1452,14 @@
}
/* }}} */
+/* {{{ proto int snmp3_getoid(string host, string sec_name, string sec_level,
string auth_protocol, string auth_passphrase, string priv_protocol, string
priv_passphrase, string object_id [, int timeout [, int retries]])
+ Fetch the value of a SNMP object */
+PHP_FUNCTION(snmp3_getoid)
+{
+ php_snmpv3(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_GETOID);
+}
+/* }}} */
+
/* {{{ proto int snmp3_getnext(string host, string sec_name, string sec_level,
string auth_protocol, string auth_passphrase, string priv_protocol, string
priv_passphrase, string object_id [, int timeout [, int retries]])
Fetch the value of a SNMP object */
PHP_FUNCTION(snmp3_getnext)
@@ -1278,6 +1468,14 @@
}
/* }}} */
+/* {{{ proto int snmp3_getnextoid(string host, string sec_name, string
sec_level, string auth_protocol, string auth_passphrase, string priv_protocol,
string priv_passphrase, string object_id [, int timeout [, int retries]])
+ Fetch the value of a SNMP object */
+PHP_FUNCTION(snmp3_getnextoid)
+{
+ php_snmpv3(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_GETNEXTOID);
+}
+/* }}} */
+
/* {{{ proto int snmp3_walk(string host, string sec_name, string sec_level,
string auth_protocol, string auth_passphrase, string priv_protocol, string
priv_passphrase, string object_id [, int timeout [, int retries]])
Fetch the value of a SNMP object */
PHP_FUNCTION(snmp3_walk)
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php