[PHP-CVS] cvs: php-src(PHP_5_3) /ext/snmp snmp.c
iliaa Mon Jun 1 13:10:18 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/snmp snmp.c Log: Fixed bug #48273 (snmp*_real_walk() returns SNMP errors as values) http://cvs.php.net/viewvc.cgi/php-src/ext/snmp/snmp.c?r1=1.106.2.2.2.5.2.12&r2=1.106.2.2.2.5.2.13&diff_format=u Index: php-src/ext/snmp/snmp.c diff -u php-src/ext/snmp/snmp.c:1.106.2.2.2.5.2.12 php-src/ext/snmp/snmp.c:1.106.2.2.2.5.2.13 --- php-src/ext/snmp/snmp.c:1.106.2.2.2.5.2.12 Sun May 31 14:11:04 2009 +++ php-src/ext/snmp/snmp.c Mon Jun 1 13:10:18 2009 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: snmp.c,v 1.106.2.2.2.5.2.12 2009/05/31 14:11:04 iliaa Exp $ */ +/* $Id: snmp.c,v 1.106.2.2.2.5.2.13 2009/06/01 13:10:18 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -666,7 +666,7 @@ return; } else if (st == SNMP_CMD_WALK) { add_next_index_zval(return_value,snmpval); /* Add to returned array */ - } else if (st == SNMP_CMD_REALWALK) { + } else if (st == SNMP_CMD_REALWALK && vars->type != SNMP_ENDOFMIBVIEW && vars->type != SNMP_NOSUCHOBJECT && vars->type != SNMP_NOSUCHINSTANCE) { #ifdef HAVE_NET_SNMP snprint_objid(buf2, sizeof(buf2), vars->name, vars->name_length); #else -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/snmp snmp.c
iliaa Sun May 31 14:11:04 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/snmp snmp.c Log: Fixed bug #48359 (Script hangs on snmprealwalk if OID is not increasing) # Original patch by simonov at gmail dot com http://cvs.php.net/viewvc.cgi/php-src/ext/snmp/snmp.c?r1=1.106.2.2.2.5.2.11&r2=1.106.2.2.2.5.2.12&diff_format=u Index: php-src/ext/snmp/snmp.c diff -u php-src/ext/snmp/snmp.c:1.106.2.2.2.5.2.11 php-src/ext/snmp/snmp.c:1.106.2.2.2.5.2.12 --- php-src/ext/snmp/snmp.c:1.106.2.2.2.5.2.11 Sat May 2 21:13:54 2009 +++ php-src/ext/snmp/snmp.c Sun May 31 14:11:04 2009 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: snmp.c,v 1.106.2.2.2.5.2.11 2009/05/02 21:13:54 jani Exp $ */ +/* $Id: snmp.c,v 1.106.2.2.2.5.2.12 2009/05/31 14:11:04 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -677,9 +677,14 @@ if (st >= SNMP_CMD_WALK && st != SNMP_CMD_SET) { if (vars->type != SNMP_ENDOFMIBVIEW && vars->type != SNMP_NOSUCHOBJECT && vars->type != SNMP_NOSUCHINSTANCE) { - memmove((char *)name, (char *)vars->name,vars->name_length * sizeof(oid)); - name_length = vars->name_length; - keepwalking = 1; + if (snmp_oid_compare(name, name_length, vars->name, vars->name_length) >= 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error: OID not increasing: %s",name); + keepwalking = 0; + } else { + memmove((char *)name, (char *)vars->name,vars->name_length * sizeof(oid)); + name_length = vars->name_length; + keepwalking = 1; + } } } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/snmp snmp.c
janiSat May 2 21:13:54 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/snmp snmp.c Log: MFH:- Revert bad patch (which caused bug #48133) http://cvs.php.net/viewvc.cgi/php-src/ext/snmp/snmp.c?r1=1.106.2.2.2.5.2.10&r2=1.106.2.2.2.5.2.11&diff_format=u Index: php-src/ext/snmp/snmp.c diff -u php-src/ext/snmp/snmp.c:1.106.2.2.2.5.2.10 php-src/ext/snmp/snmp.c:1.106.2.2.2.5.2.11 --- php-src/ext/snmp/snmp.c:1.106.2.2.2.5.2.10 Wed Dec 31 11:15:43 2008 +++ php-src/ext/snmp/snmp.c Sat May 2 21:13:54 2009 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: snmp.c,v 1.106.2.2.2.5.2.10 2008/12/31 11:15:43 sebastian Exp $ */ +/* $Id: snmp.c,v 1.106.2.2.2.5.2.11 2009/05/02 21:13:54 jani Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -655,13 +655,13 @@ *return_value = *snmpval; zval_copy_ctor(return_value); zval_ptr_dtor(&snmpval); - snmp_free_pdu(pdu); + 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(pdu); + snmp_free_pdu(response); snmp_close(ss); return; } else if (st == SNMP_CMD_WALK) { @@ -700,28 +700,28 @@ } if (st == SNMP_CMD_GET) { if ((pdu = snmp_fix_pdu(response, SNMP_MSG_GET)) != NULL) { - snmp_free_pdu(pdu); + snmp_free_pdu(response); goto retry; } } else if (st == SNMP_CMD_SET) { if ((pdu = snmp_fix_pdu(response, SNMP_MSG_SET)) != NULL) { - snmp_free_pdu(pdu); + snmp_free_pdu(response); goto retry; } } else if (st == SNMP_CMD_GETNEXT) { if ((pdu = snmp_fix_pdu(response, SNMP_MSG_GETNEXT)) != NULL) { - snmp_free_pdu(pdu); + snmp_free_pdu(response); goto retry; } } else if (st >= SNMP_CMD_WALK) { /* Here we do walks. */ if ((pdu = snmp_fix_pdu(response, ((session->version == SNMP_VERSION_1) ? SNMP_MSG_GETNEXT : SNMP_MSG_GETBULK))) != NULL) { - snmp_free_pdu(pdu); + snmp_free_pdu(response); goto retry; } } - snmp_free_pdu(pdu); + snmp_free_pdu(response); snmp_close(ss); if (st == SNMP_CMD_WALK || st == SNMP_CMD_REALWALK) { zval_dtor(return_value); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/snmp snmp.c
felipe Wed Aug 13 14:06:21 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/snmp snmp.c Log: - MFH: New parameter parsing API http://cvs.php.net/viewvc.cgi/php-src/ext/snmp/snmp.c?r1=1.106.2.2.2.5.2.4&r2=1.106.2.2.2.5.2.5&diff_format=u Index: php-src/ext/snmp/snmp.c diff -u php-src/ext/snmp/snmp.c:1.106.2.2.2.5.2.4 php-src/ext/snmp/snmp.c:1.106.2.2.2.5.2.5 --- php-src/ext/snmp/snmp.c:1.106.2.2.2.5.2.4 Tue Jul 1 19:13:44 2008 +++ php-src/ext/snmp/snmp.c Wed Aug 13 14:06:21 2008 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: snmp.c,v 1.106.2.2.2.5.2.4 2008/07/01 19:13:44 felipe Exp $ */ +/* $Id: snmp.c,v 1.106.2.2.2.5.2.5 2008/08/13 14:06:21 felipe Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -785,60 +785,63 @@ */ static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version) { - zval **a1, **a2, **a3, **a4, **a5, **a6, **a7; + char *a1, **a2, **a3; + int a1_len, a2_len, a3_len; + zval **a4 = NULL, **a5 = NULL; + long a6 = 0, a7 = 0; struct snmp_session session; - long timeout=SNMP_DEFAULT_TIMEOUT; - long retries=SNMP_DEFAULT_RETRIES; - int myargc = ZEND_NUM_ARGS(); + long timeout = SNMP_DEFAULT_TIMEOUT; + long retries = SNMP_DEFAULT_RETRIES; char type = (char) 0; char *value = (char *) 0; char hostname[MAX_NAME_LEN]; int remote_port = 161; char *pptr; + int argc = ZEND_NUM_ARGS(); - if (myargc < 3 || myargc > 7 || - zend_get_parameters_ex(myargc, &a1, &a2, &a3, &a4, &a5, &a6, &a7) == FAILURE) { - WRONG_PARAM_COUNT; + if (st == SNMP_CMD_SET) { + if (zend_parse_parameters(argc TSRMLS_CC, "sssZZ|ll", &a1, &a1_len, &a2, &a2_len, &a3, &a3_len, &a4, &a5, &a6, &a7) == FAILURE) { + return; + } + } else { + /* SNMP_CMD_GET +* SNMP_CMD_GETNEXT +* SNMP_CMD_WALK +* SNMP_CMD_REALWALK +*/ + if (zend_parse_parameters(argc TSRMLS_CC, "sss|ZZ", &a1, &a1_len, &a2, &a2_len, &a3, &a3_len, &a4, &a5) == FAILURE) { + return; + } } - - convert_to_string_ex(a1); - convert_to_string_ex(a2); - convert_to_string_ex(a3); if (st == SNMP_CMD_SET) { - if (myargc < 5) { - WRONG_PARAM_COUNT; - } - convert_to_string_ex(a4); convert_to_string_ex(a5); - if(myargc > 5) { - convert_to_long_ex(a6); - timeout = Z_LVAL_PP(a6); + if (argc > 5) { + timeout = a6; } - if(myargc > 6) { - convert_to_long_ex(a7); - retries = Z_LVAL_PP(a7); + if (argc > 6) { + retries = a7; } type = Z_STRVAL_PP(a4)[0]; value = Z_STRVAL_PP(a5); } else { - if(myargc > 3) { + if (argc > 3) { convert_to_long_ex(a4); timeout = Z_LVAL_PP(a4); } - if(myargc > 4) { + if (argc > 4) { convert_to_long_ex(a5); retries = Z_LVAL_PP(a5); } } snmp_sess_init(&session); - strlcpy(hostname, Z_STRVAL_PP(a1), sizeof(hostname)); + strlcpy(hostname, a1, sizeof(hostname)); if ((pptr = strchr (hostname, ':'))) { remote_port = strtol (pptr + 1, NULL, 0); } @@ -853,17 +856,17 @@ * memory it did not allocate */ #ifdef UCD_SNMP_HACK - session.community = (u_char *)strdup(Z_STRVAL_PP(a2)); /* memory freed by SNMP library, strdup NOT estrdup */ + session.community = (u_char *)strdup(a2); /* memory freed by SNMP library, strdup NOT estrdup */ #else - session.community = (u_char *)Z_STRVAL_PP(a2); + session.community = (u_char *)a2; #endif - session.community_len = Z_STRLEN_PP(a2); + session.community_len = a2_len; session.retries = retries; session.timeout = timeout; session.authenticator = NULL; - php_snmp_internal(INTERNAL_FUNCTION_PARAM_PASSTHRU, st, &session, Z_STRVAL_PP(a3), type, value); + php_snmp_internal(INTERNAL_FUNCTION_PARAM_PASSTHRU, st, &session, a3, type, value); } /* }}} */ @@ -919,10 +922,9 @@ Return all objects including their respective object id withing the specified one */ PHP_FUNCTION(snmp_set_quick_print) { - int argc = ZEND_NUM_ARGS(); long a1; - if (zend_parse_parameters(argc TSRMLS_CC, "l", &a1) == FAILURE) { + if (zend_parse_paramete
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/snmp snmp.c
felipe Tue Jul 1 19:13:44 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/snmp snmp.c Log: - Added arginfo http://cvs.php.net/viewvc.cgi/php-src/ext/snmp/snmp.c?r1=1.106.2.2.2.5.2.3&r2=1.106.2.2.2.5.2.4&diff_format=u Index: php-src/ext/snmp/snmp.c diff -u php-src/ext/snmp/snmp.c:1.106.2.2.2.5.2.3 php-src/ext/snmp/snmp.c:1.106.2.2.2.5.2.4 --- php-src/ext/snmp/snmp.c:1.106.2.2.2.5.2.3 Mon Mar 10 22:12:35 2008 +++ php-src/ext/snmp/snmp.c Tue Jul 1 19:13:44 2008 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: snmp.c,v 1.106.2.2.2.5.2.3 2008/03/10 22:12:35 felipe Exp $ */ +/* $Id: snmp.c,v 1.106.2.2.2.5.2.4 2008/07/01 19:13:44 felipe Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -112,38 +112,248 @@ /* constant - can be shared among threads */ static oid objid_mib[] = {1, 3, 6, 1, 2, 1}; +/* {{{ arginfo */ +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmpget, 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() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmpgetnext, 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() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmpwalk, 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() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmprealwalk, 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() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp_get_quick_print, 0, 0, 1) + ZEND_ARG_INFO(0, d) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp_set_quick_print, 0, 0, 1) + ZEND_ARG_INFO(0, quick_print) +ZEND_END_ARG_INFO() + +#ifdef HAVE_NET_SNMP +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp_set_enum_print, 0, 0, 1) + ZEND_ARG_INFO(0, enum_print) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp_set_oid_output_format, 0, 0, 1) + ZEND_ARG_INFO(0, oid_format) +ZEND_END_ARG_INFO() +#endif + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmpset, 0, 0, 5) + ZEND_ARG_INFO(0, host) + ZEND_ARG_INFO(0, community) + ZEND_ARG_INFO(0, object_id) + ZEND_ARG_INFO(0, type) + ZEND_ARG_INFO(0, value) + ZEND_ARG_INFO(0, timeout) + ZEND_ARG_INFO(0, retries) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp2_get, 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() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp2_getnext, 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() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp2_walk, 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() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp2_real_walk, 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() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp2_set, 0, 0, 5) + ZEND_ARG_INFO(0, host) + ZEND_ARG_INFO(0, community) + ZEND_ARG_INFO(0, object_id) + ZEND_ARG_INFO(0, type) + ZEND_ARG_INFO(0, value) + ZEND_ARG_INFO(0, timeout) + ZEND_ARG_INFO(0, retries) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_php_snmpv3, 0, 0, 2) + ZEND_ARG_INFO(0, s) + ZEND_ARG_INFO(0, st) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp3_get, 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() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp3_getnext, 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