[PHP-CVS] com php-src: Merge branch 'PHP-5.4' into PHP-5.5: ext/snmp/snmp.c
Commit:6c5c04888d95c7e5f7d3b355df6c302cb23161d0 Author:Boris Lytochkin Thu, 7 Feb 2013 14:49:45 +0400 Parents: 4730bc86801e593b8e910e3dce30e32cd758adee ed6763420c10c5eb47d6db675322ecaa6de079b6 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6c5c04888d95c7e5f7d3b355df6c302cb23161d0 Log: Merge branch 'PHP-5.4' into PHP-5.5 * PHP-5.4: fix bug #64124 (IPv6 malformed) Bugs: https://bugs.php.net/64124 Changed paths: MM ext/snmp/snmp.c Diff: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: fix bug #64124 (IPv6 malformed): ext/snmp/snmp.c ext/snmp/tests/bug64124.phpt
Commit:ed6763420c10c5eb47d6db675322ecaa6de079b6 Author:Boris Lytochkin Thu, 7 Feb 2013 14:48:28 +0400 Parents: 702b436ef470cc02f8e2cc21f2fadeee42103c74 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ed6763420c10c5eb47d6db675322ecaa6de079b6 Log: fix bug #64124 (IPv6 malformed) hostname returned from zend_parse_parameters() was modified in netsnmp_session_init() that caused imput parameter modification along with unpredictable changes when parameter is a constant sctring. One typo in comment was fixed. Bugs: https://bugs.php.net/64124 Changed paths: M ext/snmp/snmp.c A ext/snmp/tests/bug64124.phpt Diff: diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index 037fcce..a3bd44c 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -1096,8 +1096,7 @@ static int php_snmp_parse_oid(zval *object, int st, struct objid_query *objid_qu static int netsnmp_session_init(php_snmp_session **session_p, int version, char *hostname, char *community, int timeout, int retries TSRMLS_DC) { php_snmp_session *session; - char *pptr; - char buf[MAX_NAME_LEN]; + char *pptr, *host_ptr; int force_ipv6 = FALSE; int n; struct sockaddr **psal; @@ -,8 +1110,6 @@ static int netsnmp_session_init(php_snmp_session **session_p, int version, char } memset(session, 0, sizeof(php_snmp_session)); - strlcpy(buf, hostname, sizeof(buf)); - snmp_sess_init(session); session->version = version; @@ -1123,13 +1120,15 @@ static int netsnmp_session_init(php_snmp_session **session_p, int version, char php_error_docref(NULL TSRMLS_CC, E_WARNING, "emalloc() failed while copying hostname"); return (-1); } - *(session->peername) = '\0'; + /* we copy original hostname for further processing */ + strlcpy(session->peername, hostname, MAX_NAME_LEN); + host_ptr = session->peername; /* Reading the hostname and its optional non-default port number */ - if (*hostname == '[') { /* IPv6 address */ + if (*host_ptr == '[') { /* IPv6 address */ force_ipv6 = TRUE; - hostname++; - if ((pptr = strchr(hostname, ']'))) { + host_ptr++; + if ((pptr = strchr(host_ptr, ']'))) { if (pptr[1] == ':') { session->remote_port = atoi(pptr + 2); } @@ -1139,7 +1138,7 @@ static int netsnmp_session_init(php_snmp_session **session_p, int version, char return (-1); } } else { /* IPv4 address */ - if ((pptr = strchr(hostname, ':'))) { + if ((pptr = strchr(host_ptr, ':'))) { session->remote_port = atoi(pptr + 1); *pptr = '\0'; } @@ -1147,11 +1146,13 @@ static int netsnmp_session_init(php_snmp_session **session_p, int version, char /* since Net-SNMP library requires 'udp6:' prefix for all IPv6 addresses (in FQDN form too) we need to perform possible name resolution before running any SNMP queries */ - if ((n = php_network_getaddresses(hostname, SOCK_DGRAM, &psal, NULL TSRMLS_CC)) == 0) { /* some resover error */ + if ((n = php_network_getaddresses(host_ptr, SOCK_DGRAM, &psal, NULL TSRMLS_CC)) == 0) { /* some resolver error */ /* warnings sent, bailing out */ return (-1); } + /* we have everything we need in psal, flush peername and fill it properly */ + *(session->peername) = '\0'; res = psal; while (n-- > 0) { pptr = session->peername; @@ -1181,7 +1182,7 @@ static int netsnmp_session_init(php_snmp_session **session_p, int version, char } if (strlen(session->peername) == 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown failure while resolving '%s'", buf); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown failure while resolving '%s'", hostname); return (-1); } /* XXX FIXME diff --git a/ext/snmp/tests/bug64124.phpt b/ext/snmp/tests/bug64124.phpt new file mode 100644 index 000..454b06d --- /dev/null +++ b/ext/snmp/tests/bug64124.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #64124 IPv6 malformed +--CREDITS-- +Boris Lytochkin +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +%unicode|string%(%d) "%s" +bool(true) +%unicode|string%(%d) "%s" +bool(true) +%unicode|string%(%d) "%s" +bool(true) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fixed bug #64124 (IPv6 malformed): NEWS
Commit:cddc9f598b251327dfd666b5311905c2b27f34dd Author:Boris Lytochkin Thu, 14 Feb 2013 23:12:53 +0400 Parents: 1bde2b4fc9859866af6a53c3fd062b561b9d742c Branches: PHP-5.5 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=cddc9f598b251327dfd666b5311905c2b27f34dd Log: Fixed bug #64124 (IPv6 malformed) Bugs: https://bugs.php.net/64124 Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index 81ee851..90a0982 100644 --- a/NEWS +++ b/NEWS @@ -45,6 +45,9 @@ PHP NEWS - Filter: . Implemented FR #49180 - added MAC address validation. (Martin) +- SNMP: + . Fixed bug #64124 (IPv6 malformed). (Boris Lytochkin) + 24 Jan 2013, PHP 5.5.0 Alpha 4 - Core: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: +Fixed bug #64124 (IPv6 malformed). (Boris Lytochkin): NEWS
Commit:68fa6a3eb761ad5aeea3aefe1c22be3273fa4fbc Author:Boris Lytochkin Thu, 14 Feb 2013 23:08:08 +0400 Parents: 4b900f483153b849167c4f45a81b5b882274a2a2 Branches: PHP-5.4 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=68fa6a3eb761ad5aeea3aefe1c22be3273fa4fbc Log: +Fixed bug #64124 (IPv6 malformed). (Boris Lytochkin) Bugs: https://bugs.php.net/64124 Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index 4bdd8c3..61fead4 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,9 @@ PHP NEWS . Fixed bug #64106 (Segfault on SplFixedArray[][x] = y when extended). (Nikita Popov) +- SNMP: + . Fixed bug #64124 (IPv6 malformed). (Boris Lytochkin) + ?? ??? 2012, PHP 5.4.12 - Core: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: more test coverage: missing square bracket error message: ext/snmp/tests/ipv6.phpt
Commit:85d9d85ce27cf46d26b2717a5cfc3b8f917116ef Author:Boris Lytochkin Sun, 17 Mar 2013 20:40:15 +0400 Parents: 44197774c02506be626c85ec60889b58c6c0575e Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=85d9d85ce27cf46d26b2717a5cfc3b8f917116ef Log: more test coverage: missing square bracket error message Changed paths: M ext/snmp/tests/ipv6.phpt Diff: diff --git a/ext/snmp/tests/ipv6.phpt b/ext/snmp/tests/ipv6.phpt index 1287941..f5239e1 100644 --- a/ext/snmp/tests/ipv6.phpt +++ b/ext/snmp/tests/ipv6.phpt @@ -20,6 +20,10 @@ snmp_set_quick_print(false); snmp_set_valueretrieval(SNMP_VALUE_PLAIN); var_dump(snmpget($hostname6_port, $community, '.1.3.6.1.2.1.1.1.0')); +var_dump(snmpget('[dead:beef::', $community, '.1.3.6.1.2.1.1.1.0')); ?> --EXPECTF-- %unicode|string%(%d) "%s" + +Warning: snmpget(): malformed IPv6 address, closing square bracket missing in %s on line %d +bool(false) \ No newline at end of file -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fixed bug #61981: NEWS
Commit:44197774c02506be626c85ec60889b58c6c0575e Author:Boris Lytochkin Sun, 17 Mar 2013 20:29:14 +0400 Parents: b32405053f5a32d8c4d83f7566f5b414afd3aedb Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=44197774c02506be626c85ec60889b58c6c0575e Log: Fixed bug #61981 Bugs: https://bugs.php.net/61981 Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index 0176a93..d697c5f 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,10 @@ PHP NEWS - PCRE: . Merged PCRE 8.32. (Anatol) +- SNMP: + . Fixed bug #61981 (OO API, walk: $suffix_as_key is not working correctly). + (Boris Lytochkin) + ?? ??? 2013, PHP 5.4.13 - Core: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: merge with 5.4: NEWS
Commit:fe384b34447b5c7f7f472b5a073b11f5d3a33401 Author:Boris Lytochkin Sun, 17 Mar 2013 20:52:55 +0400 Parents: c5ba47ac599e7e6ac5dd8ef6403f9e447783e8e9 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=fe384b34447b5c7f7f472b5a073b11f5d3a33401 Log: merge with 5.4 Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index 46e69d6..2ea5117 100644 --- a/NEWS +++ b/NEWS @@ -39,6 +39,10 @@ PHP NEWS - DateTime: . Fixed bug #64359 (strftime crash with VS2012). (Anatol) +- SNMP: + . Fixed bug #61981 (OO API, walk: $suffix_as_key is not working correctly). + (Boris Lytochkin) + 21 Feb 2013, PHP 5.5.0 Alpha 5 - Core: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Merge branch 'PHP-5.4' into PHP-5.5: ext/snmp/snmp.c
Commit:5d0826e9c34f2172229fc5c13a006a5abcffcedc Author:Boris Lytochkin Sun, 17 Mar 2013 20:02:34 +0400 Parents: dcc927d3f2d199b0799152c9100906e64b94b5ea b32405053f5a32d8c4d83f7566f5b414afd3aedb Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5d0826e9c34f2172229fc5c13a006a5abcffcedc Log: Merge branch 'PHP-5.4' into PHP-5.5 * PHP-5.4: Fix bug #61981 Bugs: https://bugs.php.net/61981 Changed paths: MM ext/snmp/snmp.c Diff: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fix bug #61981: ext/snmp/snmp.c ext/snmp/tests/snmp-object.phpt
Commit:b32405053f5a32d8c4d83f7566f5b414afd3aedb Author:Boris Lytochkin Sun, 17 Mar 2013 20:00:37 +0400 Parents: 5de1b08482cdf2385e263f68ce9ea4001f724ffd Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b32405053f5a32d8c4d83f7566f5b414afd3aedb Log: Fix bug #61981 Bugs: https://bugs.php.net/61981 Changed paths: M ext/snmp/snmp.c M ext/snmp/tests/snmp-object.phpt Diff: diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index a3bd44c..0ae140f 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -832,9 +832,9 @@ retry: } } else if (st & SNMP_USE_SUFFIX_AS_KEYS && st & SNMP_CMD_WALK) { snprint_objid(buf2, sizeof(buf2), vars->name, vars->name_length); - if (objid_query->vars[0].name_length <= vars->name_length && snmp_oid_compare(objid_query->vars[0].name, objid_query->vars[0].name_length, vars->name, objid_query->vars[0].name_length) == 0) { + if (rootlen <= vars->name_length && snmp_oid_compare(root, rootlen, vars->name, rootlen) == 0) { buf2[0] = '\0'; - count = objid_query->vars[0].name_length; + count = rootlen; while(count < vars->name_length){ sprintf(buf, "%lu.", vars->name[count]); strcat(buf2, buf); diff --git a/ext/snmp/tests/snmp-object.phpt b/ext/snmp/tests/snmp-object.phpt index 06b6492..522d417 100644 --- a/ext/snmp/tests/snmp-object.phpt +++ b/ext/snmp/tests/snmp-object.phpt @@ -83,6 +83,19 @@ var_dump(gettype($z)); var_dump(count($z)); var_dump(key($z)); var_dump(array_shift($z)); +var_dump(key($z)); +array_shift($z); +var_dump(key($z)); +array_shift($z); +var_dump(key($z)); +array_shift($z); +var_dump(key($z)); +array_shift($z); +var_dump(key($z)); +array_shift($z); +var_dump(key($z)); +array_shift($z); +var_dump(key($z)); var_dump($session->close()); echo "SNMPv3 (default security settings)\n"; @@ -194,6 +207,13 @@ string(5) "array" int(%d) string(3) "1.0" string(%d) "%s" +string(3) "2.0" +string(3) "3.0" +string(3) "4.0" +string(3) "5.0" +string(3) "6.0" +string(3) "7.0" +string(3) "8.0" bool(true) SNMPv3 (default security settings) string(%d) "%S" -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: update NEWS: NEWS
Commit:a39282b64dad04a047f0ff8c230a5a64ad417a2f Author:Boris Lytochkin Fri, 3 May 2013 12:15:35 +0400 Parents: 3828f6227b188bd0c8d829a375ebf51faf67c448 Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a39282b64dad04a047f0ff8c230a5a64ad417a2f Log: update NEWS Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index c98167b..b6dc09c 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,9 @@ PHP NEWS detected by code coverity scan. (Remi) . Log a warning when a syscall fails. (Remi) +- SNMP: + . Fixed bug #64765 (Some IPv6 addresses get interpreted wrong). + (Boris Lytochkin) ?? ??? 2013, PHP 5.4.15 - Core: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: update NEWS: NEWS
Commit:cbe2870b72c4cfdb5c295e83c88d7cff5c39e396 Author:Boris Lytochkin Fri, 3 May 2013 12:25:49 +0400 Parents: 1ce836580d03b4468d88d614f5144fdf40a03c4a Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=cbe2870b72c4cfdb5c295e83c88d7cff5c39e396 Log: update NEWS Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index 4acfbd8..b038d06 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,9 @@ PHP NEWS detected by code coverity scan. (Remi) . Log a warning when a syscall fails. (Remi) +- SNMP: + . Fixed bug #64765 (Some IPv6 addresses get interpreted wrong). +(Boris Lytochkin) 25 Apr 2013, PHP 5.5.0 Beta 4 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fix bug #64765 (enclose IPv6 address into square brackets): ext/snmp/snmp.c
Commit:3828f6227b188bd0c8d829a375ebf51faf67c448 Author:Boris Lytochkin Fri, 3 May 2013 12:13:50 +0400 Parents: 5af2c5d20244a7cb3c9345ef4cf8c81997eb0984 Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3828f6227b188bd0c8d829a375ebf51faf67c448 Log: Fix bug #64765 (enclose IPv6 address into square brackets) Bugs: https://bugs.php.net/64765 Changed paths: M ext/snmp/snmp.c Diff: diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index 0ae140f..fad5d05 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -1162,9 +1162,10 @@ static int netsnmp_session_init(php_snmp_session **session_p, int version, char continue; } if ((*res)->sa_family == AF_INET6) { - strcpy(session->peername, "udp6:"); + strcpy(session->peername, "udp6:["); pptr = session->peername + strlen(session->peername); inet_ntop((*res)->sa_family, &(((struct sockaddr_in6*)(*res))->sin6_addr), pptr, MAX_NAME_LEN); + strcat(pptr, "]"); } else if ((*res)->sa_family == AF_INET) { inet_ntop((*res)->sa_family, &(((struct sockaddr_in*)(*res))->sin_addr), pptr, MAX_NAME_LEN); } else { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Merge branch 'PHP-5.4' into PHP-5.5: ext/snmp/snmp.c
Commit:1ce836580d03b4468d88d614f5144fdf40a03c4a Author:Boris Lytochkin Fri, 3 May 2013 12:19:10 +0400 Parents: 5f67584fd7038ed28087a384c2d76093430ac996 a39282b64dad04a047f0ff8c230a5a64ad417a2f Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1ce836580d03b4468d88d614f5144fdf40a03c4a Log: Merge branch 'PHP-5.4' into PHP-5.5 * PHP-5.4: update NEWS Fix bug #64765 (enclose IPv6 address into square brackets) Bugs: https://bugs.php.net/64765 Changed paths: MM ext/snmp/snmp.c Diff: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fixed bug #64159 (Truncated snmpget): NEWS
Commit:2c336c9cde524cb6465bbd75924b7e40251aefab Author:Boris Lytochkin Fri, 3 May 2013 15:46:43 +0400 Parents: c68f9d5503dda84326cfdde4c5e9c51d077aabd0 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2c336c9cde524cb6465bbd75924b7e40251aefab Log: Fixed bug #64159 (Truncated snmpget) Bugs: https://bugs.php.net/64159 Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index b038d06..00b11c4 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ PHP NEWS - SNMP: . Fixed bug #64765 (Some IPv6 addresses get interpreted wrong). (Boris Lytochkin) + . Fixed bug #64159 (Truncated snmpget). (Boris Lytochkin) 25 Apr 2013, PHP 5.5.0 Beta 4 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fixed bug #64159 (Truncated snmpget): NEWS ext/snmp/snmp.c
Commit:e36adfe94a663bc1eeb5d9d378dc80883de179db Author:Boris Lytochkin Fri, 3 May 2013 15:35:09 +0400 Parents: a39282b64dad04a047f0ff8c230a5a64ad417a2f Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e36adfe94a663bc1eeb5d9d378dc80883de179db Log: Fixed bug #64159 (Truncated snmpget) Bugs: https://bugs.php.net/64159 Changed paths: M NEWS M ext/snmp/snmp.c Diff: diff --git a/NEWS b/NEWS index b6dc09c..dba1508 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,7 @@ PHP NEWS - SNMP: . Fixed bug #64765 (Some IPv6 addresses get interpreted wrong). (Boris Lytochkin) + . Fixed bug #64159 (Truncated snmpget). (Boris Lytochkin) ?? ??? 2013, PHP 5.4.15 - Core: diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index fad5d05..9d854ec 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -561,25 +561,50 @@ static void php_snmp_getvalue(struct variable_list *vars, zval *snmpval TSRMLS_D int buflen = sizeof(sbuf) - 1; int val_len = vars->val_len; - if ((valueretrieval & SNMP_VALUE_PLAIN) == 0) { - val_len += 32; /* snprint_value will add type info into value, make some space for it */ + /* use emalloc() for large values, use static array otherwize */ + + /* There is no way to know the size of buffer snprint_value() needs in order to print a value there. +* So we are forced to probe it +*/ + while ((valueretrieval & SNMP_VALUE_PLAIN) == 0) { + *buf = '\0'; + if (snprint_value(buf, buflen, vars->name, vars->name_length, vars) == -1) { +/* buffer is not long enough to hold full output, double it */ + val_len *= 2; + } else { + break; + } + + if (buf == dbuf) { + dbuf = (char *)erealloc(dbuf, val_len + 1); + } else { + dbuf = (char *)emalloc(val_len + 1); + } + + if (!dbuf) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "emalloc() failed: %s, fallback to static buffer", strerror(errno)); + buf = &(sbuf[0]); + buflen = sizeof(sbuf) - 1; + break; + } + + buf = dbuf; + buflen = val_len; } - /* use emalloc() for large values, use static array otherwize */ - if(val_len > buflen){ + if((valueretrieval & SNMP_VALUE_PLAIN) && val_len > buflen){ if ((dbuf = (char *)emalloc(val_len + 1))) { buf = dbuf; buflen = val_len; } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "emalloc() failed: %s, fallback to static array", strerror(errno)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "emalloc() failed: %s, fallback to static buffer", strerror(errno)); } } - *buf = 0; - MAKE_STD_ZVAL(val); if (valueretrieval & SNMP_VALUE_PLAIN) { + *buf = 0; switch (vars->type) { case ASN_BIT_STR: /* 0x03, asn1.h */ ZVAL_STRINGL(val, (char *)vars->val.bitstring, vars->val_len, 1); @@ -652,7 +677,7 @@ static void php_snmp_getvalue(struct variable_list *vars, zval *snmpval TSRMLS_D break; } } else /* use Net-SNMP value translation */ { - snprint_value(buf, buflen, vars->name, vars->name_length, vars); + /* we have desired string in buffer, just use it */ ZVAL_STRING(val, buf, 1); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Merge branch 'PHP-5.4' into PHP-5.5: ext/snmp/snmp.c
Commit:c68f9d5503dda84326cfdde4c5e9c51d077aabd0 Author:Boris Lytochkin Fri, 3 May 2013 15:39:57 +0400 Parents: cbe2870b72c4cfdb5c295e83c88d7cff5c39e396 e36adfe94a663bc1eeb5d9d378dc80883de179db Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c68f9d5503dda84326cfdde4c5e9c51d077aabd0 Log: Merge branch 'PHP-5.4' into PHP-5.5 * PHP-5.4: Fixed bug #64159 (Truncated snmpget) Bugs: https://bugs.php.net/64159 Changed paths: MM ext/snmp/snmp.c Diff: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: cut PHP_VERSION_ID - we know API version now: ext/snmp/snmp.c
Commit:1c8befe893cb9b12a6122c04b8fb239e371a15d6 Author:Boris Lytochkin Fri, 3 May 2013 19:22:21 +0400 Parents: 74ef9b6ceab4a2fb7a18380eb759b00c07ee5d5b Branches: PHP-5.5 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1c8befe893cb9b12a6122c04b8fb239e371a15d6 Log: cut PHP_VERSION_ID - we know API version now Changed paths: M ext/snmp/snmp.c Diff: diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index 756e531..eb2eab3 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -80,14 +80,6 @@ #include #include -#if PHP_VERSION_ID < 50300 -#define Z_ADDREF_P(pz) pz->refcount++ -#define Z_ISREF_PP(oid) (PZVAL_IS_REF(*(oid))) -#define Z_REFCOUNT_P(pz) pz->refcount -#define Z_SET_REFCOUNT_P(pz, rc) pz->refcount = rc -#define zend_parse_parameters_none() zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") -#endif - /* For net-snmp prior to 5.4 */ #ifndef HAVE_SHUTDOWN_SNMP_LOGGING extern netsnmp_log_handler *logh_head; @@ -497,9 +489,6 @@ static void php_snmp_object_free_storage(void *object TSRMLS_DC) static zend_object_value php_snmp_object_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ { -#if PHP_VERSION_ID < 50399 - zval *tmp; -#endif zend_object_value retval; php_snmp_object *intern; @@ -508,11 +497,7 @@ static zend_object_value php_snmp_object_new(zend_class_entry *class_type TSRMLS memset(&intern->zo, 0, sizeof(php_snmp_object)); zend_object_std_init(&intern->zo, class_type TSRMLS_CC); -#if PHP_VERSION_ID < 50399 - zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref,(void *) &tmp, sizeof(zval *)); -#else object_properties_init(&intern->zo, class_type); -#endif retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) php_snmp_object_free_storage, NULL TSRMLS_CC); retval.handlers = (zend_object_handlers *) &php_snmp_object_handlers; @@ -1801,11 +1786,7 @@ PHP_FUNCTION(snmp_read_mib) char *filename; int filename_len; -#if PHP_VERSION_ID < 50399 - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { -#else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) { -#endif RETURN_FALSE; } @@ -1830,31 +1811,17 @@ PHP_METHOD(snmp, __construct) long retries = SNMP_DEFAULT_RETRIES; long version = SNMP_DEFAULT_VERSION; int argc = ZEND_NUM_ARGS(); -#if PHP_VERSION_ID > 50300 zend_error_handling error_handling; -#endif snmp_object = (php_snmp_object *)zend_object_store_get_object(object TSRMLS_CC); -#if PHP_VERSION_ID > 50300 zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC); -#else - php_set_error_handling(EH_THROW, zend_exception_get_default(TSRMLS_C) TSRMLS_CC); -#endif if (zend_parse_parameters(argc TSRMLS_CC, "lss|ll", &version, &a1, &a1_len, &a2, &a2_len, &timeout, &retries) == FAILURE) { -#if PHP_VERSION_ID > 50300 zend_restore_error_handling(&error_handling TSRMLS_CC); -#else - php_std_error_handling(); -#endif return; } -#if PHP_VERSION_ID > 50300 zend_restore_error_handling(&error_handling TSRMLS_CC); -#else - php_std_error_handling(); -#endif switch(version) { case SNMP_VERSION_1: @@ -2002,11 +1969,7 @@ void php_snmp_add_property(HashTable *h, const char *name, size_t name_length, p /* {{{ php_snmp_read_property(zval *object, zval *member, int type[, const zend_literal *key]) Generic object property reader */ -#if PHP_VERSION_ID < 50399 -zval *php_snmp_read_property(zval *object, zval *member, int type TSRMLS_DC) -#else zval *php_snmp_read_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC) -#endif { zval tmp_member; zval *retval; @@ -2036,11 +1999,7 @@ zval *php_snmp_read_property(zval *object, zval *member, int type, const zend_li } } else { zend_object_handlers * std_hnd = zend_get_std_object_handlers(); -#if PHP_VERSION_ID < 50399 - retval = std_hnd->read_property(object, member, type TSRMLS_CC); -#else retval = std_hnd->read_property(object, member, type, key TSRMLS_CC); -#endif } if (member == &tmp_member) { @@ -2052,11 +2011,7 @@ zval *php_snmp_read_property(zval *object, zval *member, int type, const zend_li /* {{{ php_snmp_write_property(zval *object, zval *member, zval *value[, const zend_literal *key]) Generic object property writer */ -#if PHP_VERSION_ID < 50
[PHP-CVS] com php-src: Merge branch 'PHP-5.4' into PHP-5.5: ext/snmp/snmp.c
Commit:eff60f993ccc9d9bbf0e2c2da12c124578be2bf9 Author:Boris Lytochkin Fri, 3 May 2013 23:10:11 +0400 Parents: 1c8befe893cb9b12a6122c04b8fb239e371a15d6 c34274acb8dedda6cbb05a54fa8a2bd0b4533be1 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=eff60f993ccc9d9bbf0e2c2da12c124578be2bf9 Log: Merge branch 'PHP-5.4' into PHP-5.5 * PHP-5.4: re-work walkaround for net-snmp BUGid 2027834, no need to detect it anymore add test for Bug #64159 bump default buffer size for values(32->512): do not reallocate buffers in 99% cases Bugs: https://bugs.php.net/64159 Changed paths: MM ext/snmp/snmp.c Diff: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: re-work walkaround for net-snmp BUGid 2027834, no need to detect it anymore add test for Bug #64159 bump default buffer size for values(32->512): do not reallocate buffers in 99
Commit:c34274acb8dedda6cbb05a54fa8a2bd0b4533be1 Author:Boris Lytochkin Fri, 3 May 2013 23:06:34 +0400 Parents: 3a413f216abb1ce6564d4b8bd493664c32eb928a Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c34274acb8dedda6cbb05a54fa8a2bd0b4533be1 Log: re-work walkaround for net-snmp BUGid 2027834, no need to detect it anymore add test for Bug #64159 bump default buffer size for values(32->512): do not reallocate buffers in 99% cases Bugs: https://bugs.php.net/64159 Changed paths: M ext/snmp/config.m4 M ext/snmp/snmp.c M ext/snmp/tests/README A ext/snmp/tests/bigtest.sh A ext/snmp/tests/bug64159.phpt M ext/snmp/tests/snmpd.conf Diff: diff --git a/ext/snmp/config.m4 b/ext/snmp/config.m4 index ccb7eea..9c0b82f 100644 --- a/ext/snmp/config.m4 +++ b/ext/snmp/config.m4 @@ -59,67 +59,6 @@ if test "$PHP_SNMP" != "no"; then $SNMP_SHARED_LIBADD ]) - dnl Check for buggy snmp_snprint_value() (net-snmp BUGid 2027834) - AC_CACHE_CHECK([for buggy snmp_snprint_value], ac_cv_buggy_snprint_value,[ -save_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -I${SNMP_PREFIX}/include $SNMP_SHARED_LIBADD" -AC_TRY_RUN( [ -#include -#include -#include -#include -#include - -u_char uname[] = "Linux nex1.php.net 2.6.18-194.32.1.el5 #1 SMP Wed Jan 5 17:53:09 EST 2011 i686"; - -int main(int argc, char **argv) -{ - struct variable_list vars; - char buf1[2048]; - char buf2[sizeof(buf1)]; - - memset(&(buf1[0]), 0, sizeof(buf1)); - memset(&(buf2[0]), 0, sizeof(buf2)); - memset(&vars, 0, sizeof(vars)); - vars.type = 4; - vars.val.integer = (long *)&(uname[0]); - vars.val.string = &(uname[0]); - vars.val.bitstring = &(uname[0]); - vars.val.counter64 = (struct counter64 *)&(uname[0]); - vars.val.floatVal = (float *)&(uname[0]); - vars.val_len = sizeof(uname), - vars.name_loc[0] = 1; - vars.name_loc[1] = 3; - vars.name_loc[2] = 6; - vars.name_loc[3] = 1; - vars.name_loc[4] = 2; - vars.name_loc[5] = 1; - vars.name_loc[6] = 1; - vars.name_loc[7] = 1; - vars.name = (oid *)&(vars.name_loc); - vars.name_length = 9; - - init_snmp("snmpapp"); - - netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT, 0); - - snprint_value(buf1, (sizeof(uname) + 32), vars.name, vars.name_length, &vars); - snprint_value(buf2, sizeof(buf2), vars.name, vars.name_length, &vars); - exit((strncmp(buf1, buf2, sizeof(buf1)) != 0)); -} -],[ - ac_cv_buggy_snprint_value=no -],[ - ac_cv_buggy_snprint_value=yes -],[ - ac_cv_buggy_snprint_value=no -]) -CFLAGS="$save_CFLAGS" - ]) - if test "$ac_cv_buggy_snprint_value" = "yes"; then - AC_DEFINE(BUGGY_SNMPRINT_VALUE, 1, [ ]) - fi - PHP_NEW_EXTENSION(snmp, snmp.c, $ext_shared) PHP_SUBST(SNMP_SHARED_LIBADD) fi diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index 9d854ec..c976928 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -551,11 +551,7 @@ static void php_snmp_error(zval *object, const char *docref TSRMLS_DC, int type, static void php_snmp_getvalue(struct variable_list *vars, zval *snmpval TSRMLS_DC, int valueretrieval) { zval *val; -#ifdef BUGGY_SNMPRINT_VALUE - char sbuf[2048]; -#else - char sbuf[64]; -#endif + char sbuf[512]; char *buf = &(sbuf[0]); char *dbuf = (char *)NULL; int buflen = sizeof(sbuf) - 1; @@ -569,6 +565,10 @@ static void php_snmp_getvalue(struct variable_list *vars, zval *snmpval TSRMLS_D while ((valueretrieval & SNMP_VALUE_PLAIN) == 0) { *buf = '\0'; if (snprint_value(buf, buflen, vars->name, vars->name_length, vars) == -1) { + if (val_len > 512*1024) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "snprint_value() asks for a buffer more than 512k, Net-SNMP bug?"); + break; + } /* buffer is not long enough to hold full output, double it */ val_len *= 2; } else { diff --git a/ext/snmp/tests/README b/ext/snmp/tests/README index 819a50d..0db1a4f 100644 --- a/ext/snmp/tests/README +++ b/ext/snmp/tests/README @@ -35,6 +35,8 @@ On Linux/FreeBSD Before launching daemon make sure that there is no file /var/net-snmp/snmpd.conf Delete it if exists. Ingoring to to so will fail SNMPv3 tests. +- Place bigtest.sh near snmpd.conf, tune path to it in snmpd.conf + - Launch snmpd (service snmpd start or /etc/init.d/snmpd start). Alternatively you can start snmpd daemon using following command line: sudo snmpd -C -c ./snmpd.conf -f
[PHP-CVS] com php-src: remove OS-specific OIDs from 'WALK multiple on single OID with OID suffix as keys' test part: ext/snmp/tests/snmp-object.phpt
Commit:8c3b8f39aa00fb4a24191d9f846cd2f4006cf23d Author:Boris Lytochkin Sat, 4 May 2013 00:04:52 +0400 Parents: c34274acb8dedda6cbb05a54fa8a2bd0b4533be1 Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8c3b8f39aa00fb4a24191d9f846cd2f4006cf23d Log: remove OS-specific OIDs from 'WALK multiple on single OID with OID suffix as keys' test part Changed paths: M ext/snmp/tests/snmp-object.phpt Diff: diff --git a/ext/snmp/tests/snmp-object.phpt b/ext/snmp/tests/snmp-object.phpt index 522d417..40567da 100644 --- a/ext/snmp/tests/snmp-object.phpt +++ b/ext/snmp/tests/snmp-object.phpt @@ -90,12 +90,6 @@ array_shift($z); var_dump(key($z)); array_shift($z); var_dump(key($z)); -array_shift($z); -var_dump(key($z)); -array_shift($z); -var_dump(key($z)); -array_shift($z); -var_dump(key($z)); var_dump($session->close()); echo "SNMPv3 (default security settings)\n"; @@ -211,9 +205,6 @@ string(3) "2.0" string(3) "3.0" string(3) "4.0" string(3) "5.0" -string(3) "6.0" -string(3) "7.0" -string(3) "8.0" bool(true) SNMPv3 (default security settings) string(%d) "%S" -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: fix typo in test: ext/snmp/tests/bug64159.phpt
Commit:7457867ba8c46e276d2bcb6e47766a9f5abb0c79 Author:Boris Lytochkin Sun, 16 Jun 2013 00:09:18 +0400 Parents: 8acfa0b3f8e10780c1f1a3f07c2b8466c289b9bb Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7457867ba8c46e276d2bcb6e47766a9f5abb0c79 Log: fix typo in test Changed paths: M ext/snmp/tests/bug64159.phpt Diff: diff --git a/ext/snmp/tests/bug64159.phpt b/ext/snmp/tests/bug64159.phpt index 51b1599..52e53c9 100644 --- a/ext/snmp/tests/bug64159.phpt +++ b/ext/snmp/tests/bug64159.phpt @@ -15,7 +15,7 @@ require_once(dirname(__FILE__).'/snmp_include.inc'); snmp_set_quick_print(false); snmp_set_valueretrieval(SNMP_VALUE_LIBRARY); -var_dump(("ab8283f948419b2d24d22f44a80b17d3" === md5(snmpget($hostname, $community, '.1.3.6.1.4.1.2021.8.1.101.2'; +var_dump(("ab8283f948419b2d24d22f44a80b17d3" === md5(snmpget($hostname, $community, '.1.3.6.1.4.1.2021.8.1.101.1'; ?> --EXPECTF-- -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/branches/ PHP_5_2/NEWS PHP_5_2/ext/snmp/snmp.c PHP_5_3/NEWS PHP_5_3/ext/snmp/snmp.c
lytboris Mon, 31 Jan 2011 11:34:12 + Revision: http://svn.php.net/viewvc?view=revision&revision=307876 Log: Fixed bug #51336 Bug: http://bugs.php.net/51336 (Open) snmprealwalk (snmp v1) does not handle end of OID tree correctly Changed paths: U php/php-src/branches/PHP_5_2/NEWS U php/php-src/branches/PHP_5_2/ext/snmp/snmp.c U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/snmp/snmp.c Modified: php/php-src/branches/PHP_5_2/NEWS === --- php/php-src/branches/PHP_5_2/NEWS 2011-01-31 11:17:22 UTC (rev 307875) +++ php/php-src/branches/PHP_5_2/NEWS 2011-01-31 11:34:12 UTC (rev 307876) @@ -8,6 +8,9 @@ - Fixed bug #53568 (swapped memset arguments in struct initialization). (crrodriguez at opensuse dot org) +- Fixed bug #51336 (snmprealwalk (snmp v1) does not handle end of OID tree correctly) + (Boris Lytochkin) + 06 Jan 2010, PHP 5.2.17 - Fixed Bug #53632 (infinite loop with x87 fpu). (CVE-2010-4645) (Scott, Rasmus) Modified: php/php-src/branches/PHP_5_2/ext/snmp/snmp.c === --- php/php-src/branches/PHP_5_2/ext/snmp/snmp.c2011-01-31 11:17:22 UTC (rev 307875) +++ php/php-src/branches/PHP_5_2/ext/snmp/snmp.c2011-01-31 11:34:12 UTC (rev 307876) @@ -502,7 +502,7 @@ } } } else { - if (st != SNMP_CMD_WALK || response->errstat != SNMP_ERR_NOSUCHNAME) { + if ((st != SNMP_CMD_WALK && st != SNMP_CMD_REALWALK) || response->errstat != SNMP_ERR_NOSUCHNAME) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error in packet: %s", snmp_errstring(response->errstat)); if (response->errstat == SNMP_ERR_NOSUCHNAME) { for (count=1, vars = response->variables; vars && count != response->errindex; Modified: php/php-src/branches/PHP_5_3/NEWS === --- php/php-src/branches/PHP_5_3/NEWS 2011-01-31 11:17:22 UTC (rev 307875) +++ php/php-src/branches/PHP_5_3/NEWS 2011-01-31 11:34:12 UTC (rev 307876) @@ -157,6 +157,9 @@ . Fixed bug #53885 (ZipArchive segfault with FL_UNCHANGED on empty archive). (Stas, Maksymilian Arciemowicz). +- Fixed bug #51336 (snmprealwalk (snmp v1) does not handle end of OID tree correctly) + (Boris Lytochkin) + 06 Jan 2011, PHP 5.3.5 - Fixed Bug #53632 (infinite loop with x87 fpu). (CVE-2010-4645) (Scott, Rasmus) Modified: php/php-src/branches/PHP_5_3/ext/snmp/snmp.c === --- php/php-src/branches/PHP_5_3/ext/snmp/snmp.c2011-01-31 11:17:22 UTC (rev 307875) +++ php/php-src/branches/PHP_5_3/ext/snmp/snmp.c2011-01-31 11:34:12 UTC (rev 307876) @@ -689,7 +689,7 @@ } } } else { - if (st != SNMP_CMD_WALK || response->errstat != SNMP_ERR_NOSUCHNAME) { + if ((st != SNMP_CMD_WALK && st != SNMP_CMD_REALWALK) || response->errstat != SNMP_ERR_NOSUCHNAME) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error in packet: %s", snmp_errstring(response->errstat)); if (response->errstat == SNMP_ERR_NOSUCHNAME) { for (count=1, vars = response->variables; vars && count != response->errindex; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/branches/PHP_5_2/ NEWS ext/snmp/snmp.c
lytboris Mon, 31 Jan 2011 13:00:27 + Revision: http://svn.php.net/viewvc?view=revision&revision=307881 Log: revert commit 307876 Changed paths: U php/php-src/branches/PHP_5_2/NEWS U php/php-src/branches/PHP_5_2/ext/snmp/snmp.c Modified: php/php-src/branches/PHP_5_2/NEWS === --- php/php-src/branches/PHP_5_2/NEWS 2011-01-31 12:47:28 UTC (rev 307880) +++ php/php-src/branches/PHP_5_2/NEWS 2011-01-31 13:00:27 UTC (rev 307881) @@ -8,9 +8,6 @@ - Fixed bug #53568 (swapped memset arguments in struct initialization). (crrodriguez at opensuse dot org) -- Fixed bug #51336 (snmprealwalk (snmp v1) does not handle end of OID tree correctly) - (Boris Lytochkin) - 06 Jan 2010, PHP 5.2.17 - Fixed Bug #53632 (infinite loop with x87 fpu). (CVE-2010-4645) (Scott, Rasmus) Modified: php/php-src/branches/PHP_5_2/ext/snmp/snmp.c === --- php/php-src/branches/PHP_5_2/ext/snmp/snmp.c2011-01-31 12:47:28 UTC (rev 307880) +++ php/php-src/branches/PHP_5_2/ext/snmp/snmp.c2011-01-31 13:00:27 UTC (rev 307881) @@ -502,7 +502,7 @@ } } } else { - if ((st != SNMP_CMD_WALK && st != SNMP_CMD_REALWALK) || response->errstat != SNMP_ERR_NOSUCHNAME) { + if (st != SNMP_CMD_WALK || response->errstat != SNMP_ERR_NOSUCHNAME) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error in packet: %s", snmp_errstring(response->errstat)); if (response->errstat == SNMP_ERR_NOSUCHNAME) { for (count=1, vars = response->variables; vars && count != response->errindex; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ NEWS ext/snmp/php_snmp.h ext/snmp/snmp.c ext/snmp/tests/snmp_parse_oid.phpt
int non_repeaters = 0; - int max_repetitions = 20; + int max_repetitions = -1; int argc = ZEND_NUM_ARGS(); struct objid_set objid_set; php_snmp_session *session; @@ -1345,6 +1350,12 @@ zval *object = getThis(); PHP_SNMP_SESSION_FROM_OBJECT(session, object); snmp_object = (php_snmp_object *)zend_object_store_get_object(object TSRMLS_CC); + if (snmp_object->max_oids > 0) { + objid_set.step = snmp_object->max_oids; + if (max_repetitions < 0) { // unspecified in function call, use session-wise + max_repetitions = snmp_object->max_oids; + } + } valueretrieval = snmp_object->valueretrieval; #ifdef HAVE_NET_SNMP glob_snmp_object.enum_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM); @@ -1359,7 +1370,13 @@ #endif } + if (max_repetitions < 0) { + max_repetitions = 20; // provide correct default value + } + php_snmp_internal(INTERNAL_FUNCTION_PARAM_PASSTHRU, st, session, &objid_set, non_repeaters, max_repetitions, valueretrieval); + + efree(objid_set.vars); if (session_less_mode) { netsnmp_session_free(&session); @@ -1678,6 +1695,7 @@ if (netsnmp_session_init(&(snmp_object->session), version, a1, a2, timeout, retries TSRMLS_CC)) { return; } + snmp_object->max_oids = 0; snmp_object->valueretrieval = SNMP_G(valueretrieval); #ifdef HAVE_NET_SNMP snmp_object->enum_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM); @@ -1932,6 +1950,15 @@ /* }}} */ /* {{{ */ +static int php_snmp_read_max_oids(php_snmp_object *snmp_object, zval **retval TSRMLS_DC) +{ + MAKE_STD_ZVAL(*retval); + ZVAL_LONG(*retval, snmp_object->max_oids); + return SUCCESS; +} +/* }}} */ + +/* {{{ */ static int php_snmp_read_valueretrieval(php_snmp_object *snmp_object, zval **retval TSRMLS_DC) { MAKE_STD_ZVAL(*retval); @@ -1970,6 +1997,28 @@ #endif /* {{{ */ +static int php_snmp_write_max_oids(php_snmp_object *snmp_object, zval *newval TSRMLS_DC) +{ + zval ztmp; + int ret = SUCCESS; + if (Z_TYPE_P(newval) != IS_LONG) { + ztmp = *newval; + zval_copy_ctor(&ztmp); + convert_to_long(&ztmp); + newval = &ztmp; + } + + snmp_object->max_oids = Z_LVAL_P(newval); + + if (newval == &ztmp) { + zval_dtor(newval); + } + + return ret; +} +/* }}} */ + +/* {{{ */ static int php_snmp_write_valueretrieval(php_snmp_object *snmp_object, zval *newval TSRMLS_DC) { zval ztmp; @@ -2096,6 +2145,7 @@ { "" #name "", sizeof("" #name "") - 1, php_snmp_read_##name, php_snmp_write_##name } const php_snmp_prop_handler php_snmp_property_entries[] = { + PHP_SNMP_PROPERTY_ENTRY_RECORD(max_oids), PHP_SNMP_PROPERTY_ENTRY_RECORD(valueretrieval), PHP_SNMP_PROPERTY_ENTRY_RECORD(quick_print), #ifdef HAVE_NET_SNMP Deleted: php/php-src/trunk/ext/snmp/tests/snmp_parse_oid.phpt === --- php/php-src/trunk/ext/snmp/tests/snmp_parse_oid.phpt2011-02-01 06:04:38 UTC (rev 307896) +++ php/php-src/trunk/ext/snmp/tests/snmp_parse_oid.phpt2011-02-01 07:45:30 UTC (rev 307897) @@ -1,36 +0,0 @@ ---TEST-- -Function snmp_parse_oid ---CREDITS-- -Boris Lytochkin ---SKIPIF-- - ---FILE-- - ---EXPECTF-- -Checking SNMP_MAXOIDS_IN_PDU - -Warning: snmp2_get(): Could not process more than %d OIDs in singe GET/GETNEXT/SET query in %s on line %d -bool(false) \ No newline at end of file -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c
lytboris Tue, 01 Feb 2011 08:20:13 + Revision: http://svn.php.net/viewvc?view=revision&revision=307898 Log: preprocessed changes made in rev.307894: keeping ext/snmp backwards compatible Changed paths: U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-02-01 07:45:30 UTC (rev 307897) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-02-01 08:20:13 UTC (rev 307898) @@ -506,6 +506,9 @@ static zend_object_value php_snmp_object_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ { +#if PHP_VERSION_ID < 503099 + zval *tmp; +#endif zend_object_value retval; php_snmp_object *intern; @@ -514,7 +517,11 @@ memset(&intern->zo, 0, sizeof(php_snmp_object)); zend_object_std_init(&intern->zo, class_type TSRMLS_CC); +#if PHP_VERSION_ID < 503099 + zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref,(void *) &tmp, sizeof(zval *)); +#else object_properties_init(&intern->zo, class_type); +#endif retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) php_snmp_object_free_storage, NULL TSRMLS_CC); retval.handlers = (zend_object_handlers *) &php_snmp_object_handlers; @@ -1795,9 +1802,13 @@ } /* }}} */ -/* {{{ php_snmp_read_property(zval *object, zval *member, int type) +/* {{{ php_snmp_read_property(zval *object, zval *member, int type[, const zend_literal *key]) Generic object property reader */ +#if PHP_VERSION_ID < 503099 +zval *php_snmp_read_property(zval *object, zval *member, int type TSRMLS_DC) +#else zval *php_snmp_read_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC) +#endif { zval tmp_member; zval *retval; @@ -1827,7 +1838,11 @@ } } else { zend_object_handlers * std_hnd = zend_get_std_object_handlers(); +#if PHP_VERSION_ID < 503099 + retval = std_hnd->read_property(object, member, type TSRMLS_CC); +#else retval = std_hnd->read_property(object, member, type, key TSRMLS_CC); +#endif } if (member == &tmp_member) { @@ -1837,9 +1852,13 @@ } /* }}} */ -/* {{{ php_snmp_write_property(zval *object, zval *member, zval *value) +/* {{{ php_snmp_write_property(zval *object, zval *member, zval *value[, const zend_literal *key]) Generic object property writer */ +#if PHP_VERSION_ID < 503099 +void php_snmp_write_property(zval *object, zval *member, zval *value TSRMLS_DC) +#else void php_snmp_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC) +#endif { zval tmp_member; php_snmp_object *obj; @@ -1866,7 +1885,11 @@ } } else { zend_object_handlers * std_hnd = zend_get_std_object_handlers(); +#if PHP_VERSION_ID < 503099 + std_hnd->write_property(object, member, value TSRMLS_CC); +#else std_hnd->write_property(object, member, value, key TSRMLS_CC); +#endif } if (member == &tmp_member) { @@ -1875,9 +1898,13 @@ } /* }}} */ -/* {{{ php_snmp_has_property(zval *object, zval *member, int has_set_exists) +/* {{{ php_snmp_has_property(zval *object, zval *member, int has_set_exists[, const zend_literal *key]) Generic object property checker */ +#if PHP_VERSION_ID < 503099 +static int php_snmp_has_property(zval *object, zval *member, int has_set_exists TSRMLS_DC) +#else static int php_snmp_has_property(zval *object, zval *member, int has_set_exists, const zend_literal *key TSRMLS_DC) +#endif { php_snmp_object *obj = (php_snmp_object *)zend_objects_get_address(object TSRMLS_CC); php_snmp_prop_handler *hnd; @@ -1889,7 +1916,11 @@ ret = 1; break; case 0: { +#if PHP_VERSION_ID < 503099 + zval *value = php_snmp_read_property(object, member, BP_VAR_IS TSRMLS_CC); +#else zval *value = php_snmp_read_property(object, member, BP_VAR_IS, key TSRMLS_CC); +#endif if (value != EG(uninitialized_zval_ptr)) { ret = Z_TYPE_P(value) != IS_NULL? 1:0; /* refcount is 0 */ @@ -1899,7 +1930,11 @@ break; } default: { +#if PHP_VERSION_ID < 503099 + zval *value = php_snmp_read_property(object, member, BP_VAR_IS TSRMLS_CC); +#else zval *value = php_snmp_read_property(object, member, BP_VAR_IS, key TSRMLS_CC); +#endif if (value !
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c tests/snmp-object-properties.phpt
lytboris Sat, 05 Feb 2011 00:29:31 + Revision: http://svn.php.net/viewvc?view=revision&revision=308037 Log: added r/o info property with basic session info, fix crash in _get_properties in trunk Changed paths: U php/php-src/trunk/ext/snmp/snmp.c U php/php-src/trunk/ext/snmp/tests/snmp-object-properties.phpt Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-02-04 21:49:51 UTC (rev 308036) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-02-05 00:29:31 UTC (rev 308037) @@ -1193,7 +1193,7 @@ static int netsnmp_session_set_contextEngineID(struct snmp_session *s, u_char * contextEngineID TSRMLS_DC) { size_t ebuf_len = 32, eout_len = 0; - u_char *ebuf = (u_char *) malloc(ebuf_len); /* memory freed by SNMP library, strdup NOT estrdup */ + u_char *ebuf = (u_char *) malloc(ebuf_len); /* memory freed by SNMP library, malloc NOT emalloc */ if (ebuf == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "malloc failure setting contextEngineID"); @@ -1204,6 +1204,11 @@ free(ebuf); return (-1); } + + if (s->contextEngineID) { + free(s->contextEngineID); + } + s->contextEngineID = ebuf; s->contextEngineIDLen = eout_len; return (0); @@ -1971,7 +1976,11 @@ ulong num_key; obj = (php_snmp_object *)zend_objects_get_address(object TSRMLS_CC); +#if PHP_VERSION_ID < 50399 props = obj->zo.properties; +#else + props = zend_std_get_properties(object TSRMLS_CC); +#endif zend_hash_internal_pointer_reset_ex(&php_snmp_properties, &pos); @@ -1989,6 +1998,34 @@ /* }}} */ /* {{{ */ +static int php_snmp_read_info(php_snmp_object *snmp_object, zval **retval TSRMLS_DC) +{ + zval *val; + + MAKE_STD_ZVAL(*retval); + array_init(*retval); + + MAKE_STD_ZVAL(val); + ZVAL_STRINGL(val, snmp_object->session->peername, strlen(snmp_object->session->peername), 1); + add_assoc_zval(*retval, "hostname", val); + + MAKE_STD_ZVAL(val); + ZVAL_LONG(val, snmp_object->session->remote_port); + add_assoc_zval(*retval, "port", val); + + MAKE_STD_ZVAL(val); + ZVAL_LONG(val, snmp_object->session->timeout); + add_assoc_zval(*retval, "timeout", val); + + MAKE_STD_ZVAL(val); + ZVAL_LONG(val, snmp_object->session->retries); + add_assoc_zval(*retval, "retries", val); + + return SUCCESS; +} +/* }}} */ + +/* {{{ */ static int php_snmp_read_max_oids(php_snmp_object *snmp_object, zval **retval TSRMLS_DC) { MAKE_STD_ZVAL(*retval); @@ -2036,6 +2073,14 @@ #endif /* {{{ */ +static int php_snmp_write_info(php_snmp_object *snmp_object, zval *newval TSRMLS_DC) +{ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "info property is read-only"); + return FAILURE; +} +/* }}} */ + +/* {{{ */ static int php_snmp_write_max_oids(php_snmp_object *snmp_object, zval *newval TSRMLS_DC) { zval ztmp; @@ -2184,6 +2229,7 @@ { "" #name "", sizeof("" #name "") - 1, php_snmp_read_##name, php_snmp_write_##name } const php_snmp_prop_handler php_snmp_property_entries[] = { + PHP_SNMP_PROPERTY_ENTRY_RECORD(info), PHP_SNMP_PROPERTY_ENTRY_RECORD(max_oids), PHP_SNMP_PROPERTY_ENTRY_RECORD(valueretrieval), PHP_SNMP_PROPERTY_ENTRY_RECORD(quick_print), Modified: php/php-src/trunk/ext/snmp/tests/snmp-object-properties.phpt === --- php/php-src/trunk/ext/snmp/tests/snmp-object-properties.phpt 2011-02-04 21:49:51 UTC (rev 308036) +++ php/php-src/trunk/ext/snmp/tests/snmp-object-properties.phpt 2011-02-05 00:29:31 UTC (rev 308037) @@ -21,6 +21,7 @@ $session = new SNMP(SNMP_VERSION_1, $hostname, $community, $timeout, $retries); var_dump($session); +$session->max_oids = 40; $session->enum_print = TRUE; $session->quick_print = TRUE; $session->valueretrieval = SNMP_VALUE_LIBRARY; @@ -28,6 +29,7 @@ var_dump($session); +$session->max_oids = "40"; $session->enum_print = "1"; $session->quick_print = "1"; $session->valueretrieval = "1"; @@ -55,10 +57,25 @@ $session->oid_output_format = 78; var_dump($session->oid_output_format); +$session->info = array("blah" => 2); +var_dump($session->info); ?> --EXPECTF-- Check working object(SNMP)#%d (%d) { + ["info"]=> + array(4) { +["hostname"]=> +%string|unicode%(%d) "%s" +["port"]=> +int(%d) +["timeout"]=> +int(%i) +["retries"]=> +int(%d) + } + ["max_oids"]=> + int(0) ["valueretrieval"]=> int(1) ["quick_print"]=> @@ -69,6 +86,19 @@ int(3) } object(SNMP)#%d (%d) { + ["info"]=> + array(4) { +["hostname"]=> +%string|unicode%(%d) "%s" +["port"]=> +int(%d) +["timeout"]=> +int(%i) +["retri
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c
lytboris Sat, 05 Feb 2011 13:22:38 + Revision: http://svn.php.net/viewvc?view=revision&revision=308046 Log: fix crash caused by incorrect offset altering Changed paths: U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-02-05 13:01:10 UTC (rev 308045) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-02-05 13:22:38 UTC (rev 308046) @@ -843,7 +843,7 @@ vars = vars->next_variable, count++); if (st & (SNMP_CMD_GET | SNMP_CMD_GETNEXT) && response->errstat == SNMP_ERR_TOOBIG && objid_set->step > 1) { /* Answer will not fit into single packet */ - objid_set->offset -= objid_set->step; + objid_set->offset = ((objid_set->offset > objid_set->step) ? (objid_set->offset - objid_set->step) : 0 ); objid_set->step /= 2; snmp_free_pdu(response); keepwalking = 1; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ config.m4 snmp.c
lytboris Thu, 17 Feb 2011 12:02:16 + Revision: http://svn.php.net/viewvc?view=revision&revision=308427 Log: * Fix memory leak on concurrent new, open * change comments to ANSI-C style * added compatibility with net-snmp prior 5.4 Changed paths: U php/php-src/trunk/ext/snmp/config.m4 U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/ext/snmp/config.m4 === --- php/php-src/trunk/ext/snmp/config.m42011-02-17 11:55:01 UTC (rev 308426) +++ php/php-src/trunk/ext/snmp/config.m42011-02-17 12:02:16 UTC (rev 308427) @@ -112,6 +112,14 @@ $SNMP_SHARED_LIBADD ]) + dnl Check whether shutdown_snmp_logging() exists. + PHP_CHECK_LIBRARY($SNMP_LIBNAME, shutdown_snmp_logging, + [ +AC_DEFINE(HAVE_SHUTDOWN_SNMP_LOGGING, 1, [ ]) + ], [], [ +$SNMP_SHARED_LIBADD + ]) + dnl Test build. PHP_CHECK_LIBRARY($SNMP_LIBNAME, init_snmp, [ Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-02-17 11:55:01 UTC (rev 308426) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-02-17 12:02:16 UTC (rev 308427) @@ -117,6 +117,17 @@ #define zend_parse_parameters_none() zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") #endif +/* For net-snmp prior to 5.4 */ +//#ifndef HAVE_SHUTDOWN_SNMP_LOGGING +extern netsnmp_log_handler *logh_head; +#define shutdown_snmp_logging() \ + { \ + snmp_disable_log(); \ + while(NULL != logh_head) \ + netsnmp_remove_loghandler( logh_head ); \ + } +//#endif + /* For really old ucd-snmp versions.. */ #ifndef HAVE_SNMP_PARSE_OID #define snmp_parse_oid read_objid @@ -960,7 +971,7 @@ } } objid_set->count++; - } else if (Z_TYPE_PP(oid) == IS_ARRAY) { // we got objid array + } else if (Z_TYPE_PP(oid) == IS_ARRAY) { /* we got objid array */ if (zend_hash_num_elements(Z_ARRVAL_PP(oid)) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Got empty OID array"); return FALSE; @@ -1366,7 +1377,7 @@ snmp_object = (php_snmp_object *)zend_object_store_get_object(object TSRMLS_CC); if (snmp_object->max_oids > 0) { objid_set.step = snmp_object->max_oids; - if (max_repetitions < 0) { // unspecified in function call, use session-wise + if (max_repetitions < 0) { /* unspecified in function call, use session-wise */ max_repetitions = snmp_object->max_oids; } } @@ -1385,7 +1396,7 @@ } if (max_repetitions < 0) { - max_repetitions = 20; // provide correct default value + max_repetitions = 20; /* provide correct default value */ } php_snmp_internal(INTERNAL_FUNCTION_PARAM_PASSTHRU, st, session, &objid_set, non_repeaters, max_repetitions, valueretrieval); @@ -1706,6 +1717,11 @@ return; } + /* handle re-open of snmp session */ + if (snmp_object->session) { + netsnmp_session_free(&(snmp_object->session)); + } + if (netsnmp_session_init(&(snmp_object->session), version, a1, a2, timeout, retries TSRMLS_CC)) { return; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c
lytboris Thu, 17 Feb 2011 12:12:22 + Revision: http://svn.php.net/viewvc?view=revision&revision=308429 Log: enable HAVE_SHUTDOWN_SNMP_LOGGING Changed paths: U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-02-17 12:08:08 UTC (rev 308428) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-02-17 12:12:22 UTC (rev 308429) @@ -118,7 +118,7 @@ #endif /* For net-snmp prior to 5.4 */ -//#ifndef HAVE_SHUTDOWN_SNMP_LOGGING +#ifndef HAVE_SHUTDOWN_SNMP_LOGGING extern netsnmp_log_handler *logh_head; #define shutdown_snmp_logging() \ { \ @@ -126,7 +126,7 @@ while(NULL != logh_head) \ netsnmp_remove_loghandler( logh_head ); \ } -//#endif +#endif /* For really old ucd-snmp versions.. */ #ifndef HAVE_SNMP_PARSE_OID -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c
lytboris Sat, 19 Feb 2011 11:13:10 + Revision: http://svn.php.net/viewvc?view=revision&revision=308479 Log: push most of SNMP query options into objid_query structure Changed paths: U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-02-19 09:30:41 UTC (rev 308478) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-02-19 11:13:10 UTC (rev 308479) @@ -416,10 +416,13 @@ } snmpobjarg; -struct objid_set { +struct objid_query { int count; int offset; int step; + int non_repeaters; + int max_repetitions; + int valueretrieval; int array_output; snmpobjarg *vars; }; @@ -674,9 +677,7 @@ */ static void php_snmp_internal(INTERNAL_FUNCTION_PARAMETERS, int st, struct snmp_session *session, - struct objid_set *objid_set, - int non_repeaters, int max_repetitions, - int valueretrieval) + struct objid_query *objid_query) { struct snmp_session *ss; struct snmp_pdu *pdu=NULL, *response; @@ -698,16 +699,16 @@ RETVAL_FALSE; if (st & SNMP_CMD_WALK) { - if (objid_set->count > 1) { + if (objid_query->count > 1) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Multi OID walks are not supported!"); RETURN_FALSE; } rootlen = MAX_NAME_LEN; - if (strlen(objid_set->vars[0].oid)) { /* on a walk, an empty string means top of tree - no error */ - if (snmp_parse_oid(objid_set->vars[0].oid, root, &rootlen)) { + if (strlen(objid_query->vars[0].oid)) { /* on a walk, an empty string means top of tree - no error */ + if (snmp_parse_oid(objid_query->vars[0].oid, root, &rootlen)) { gotroot = 1; } else { -php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid_set->vars[0].oid); +php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid_query->vars[0].oid); RETURN_FALSE; } } @@ -720,7 +721,7 @@ memmove((char *)name, (char *)root, rootlen * sizeof(oid)); name_length = rootlen; - objid_set->offset = objid_set->count; + objid_query->offset = objid_query->count; } if ((ss = snmp_open(session)) == NULL) { @@ -734,10 +735,10 @@ keepwalking = 0; if (st & (SNMP_CMD_GET | SNMP_CMD_GETNEXT)) { pdu = snmp_pdu_create((st & SNMP_CMD_GET) ? SNMP_MSG_GET : SNMP_MSG_GETNEXT); - for (count = 0; objid_set->offset < objid_set->count && count < objid_set->step; objid_set->offset++, count++){ + for (count = 0; objid_query->offset < objid_query->count && count < objid_query->step; objid_query->offset++, count++){ name_length = MAX_OID_LEN; -if (!snmp_parse_oid(objid_set->vars[objid_set->offset].oid, name, &name_length)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid_set->vars[objid_set->offset].oid); +if (!snmp_parse_oid(objid_query->vars[objid_query->offset].oid, name, &name_length)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid_query->vars[objid_query->offset].oid); } else { snmp_add_null_var(pdu, name, name_length); } @@ -749,17 +750,17 @@ } } else if (st & SNMP_CMD_SET) { pdu = snmp_pdu_create(SNMP_MSG_SET); - for (count = 0; objid_set->offset < objid_set->count && count < objid_set->step; objid_set->offset++, count++){ + for (count = 0; objid_query->offset < objid_query->count && count < objid_query->step; objid_query->offset++, count++){ name_length = MAX_OID_LEN; -if (!snmp_parse_oid(objid_set->vars[objid_set->offset].oid, name, &name_length)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid_set->vars[objid_set->offset].oid); +if (!snmp_parse_oid(objid_query->vars[objid_query->offset].oid, name, &name_length)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid_query->vars[objid_query->offset].oid); snmp_free_pdu(pdu); snmp_close(ss); RETURN_FALSE; } else { - if ((snmp_errno = snmp_add_var(pdu, name, name_length, objid_set->vars[objid_set->offset].type, objid_set->vars[objid_set->offset].value))) { + if ((snmp_errno = snmp_add_var(pdu, name, name_length, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value))) { SNMP_SNPRINT_OBJID(buf, sizeof(buf), name, name_length); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not add variable: OID='%s' type='%c' value='%s': %s", buf, objid_set->vars[objid_set->offset].type, objid_set->vars[objid_set->offset].value, snmp_api_errstring(snmp_errno)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not add variable: OID='%s' type='%c' value='%s': %s", buf, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value, snmp_api_errstring(snmp_errno)); snmp_free_pdu(pdu); snmp_close(ss); RETURN_FALSE; @@ -771
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c
lytboris Fri, 25 Feb 2011 19:22:15 + Revision: http://svn.php.net/viewvc?view=revision&revision=308682 Log: fix parse errors for non_repeaters & max_repetitions: aligment errors Changed paths: U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-02-25 18:34:03 UTC (rev 308681) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-02-25 19:22:15 UTC (rev 308682) @@ -420,8 +420,8 @@ int count; int offset; int step; - int non_repeaters; - int max_repetitions; + long non_repeaters; + long max_repetitions; int valueretrieval; int array_output; snmpobjarg *vars; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ php_snmp.h snmp.c tests/snmp-object-errno-errstr.phpt tests/snmp-object-error.phpt tests/snmp-object-properties.phpt tests/snmp-object-set_security_error.ph
LONG_CONSTANT("SNMP_VERSION_2c", SNMP_VERSION_2c, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_VERSION_3", SNMP_VERSION_3, CONST_CS | CONST_PERSISTENT); + REGISTER_PDO_CLASS_CONST_LONG("ERRNO_NOERROR", (long)PHP_SNMP_ERRNO_NOERROR); + REGISTER_PDO_CLASS_CONST_LONG("ERRNO_GENERIC", (long)PHP_SNMP_ERRNO_GENERIC); + REGISTER_PDO_CLASS_CONST_LONG("ERRNO_TIMEOUT", (long)PHP_SNMP_ERRNO_TIMEOUT); + REGISTER_PDO_CLASS_CONST_LONG("ERRNO_ERROR_IN_REPLY", (long)PHP_SNMP_ERRNO_ERROR_IN_REPLY); + REGISTER_PDO_CLASS_CONST_LONG("ERRNO_OID_NOT_INCREASING", (long)PHP_SNMP_ERRNO_OID_NOT_INCREASING); + return SUCCESS; } /* }}} */ Added: php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt === --- php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt (rev 0) +++ php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt 2011-02-26 08:27:26 UTC (rev 308703) @@ -0,0 +1,63 @@ +--TEST-- +OO API: get_errno & get_error functions +--CREDITS-- +Boris Lytochkin +--SKIPIF-- + +--FILE-- +get('.1.3.6.1.2.1.1.1.0')); +var_dump($session->get_errno() == SNMP::ERRNO_NOERROR); +var_dump($session->get_error()); +$session->close(); + +echo "SNMP::ERRNO_TIMEOUT\n"; +$session = new SNMP(SNMP_VERSION_2c, $hostname, 'timeout_community_432', $timeout, $retries); +$session->valueretrieval = SNMP_VALUE_LIBRARY; +var_dump(@$session->get('.1.3.6.1.2.1.1.1.0')); +var_dump($session->get_errno() == SNMP::ERRNO_TIMEOUT); +var_dump($session->get_error()); +$session->close(); +echo "SNMP::ERRNO_ERROR_IN_REPLY\n"; +$session = new SNMP(SNMP_VERSION_2c, $hostname, $community, $timeout, $retries); +var_dump(@$session->get('.1.3.6.1.2.1.1.1.110')); +var_dump($session->get_errno() == SNMP::ERRNO_ERROR_IN_REPLY); +var_dump($session->get_error()); +$session->close(); +echo "SNMP::ERRNO_GENERIC\n"; +$session = new SNMP(SNMP_VERSION_3, $hostname, 'somebogususer', $timeout, $retries); +$session->set_security('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass); +var_dump(@$session->get('.1.3.6.1.2.1.1.1.0')); +var_dump($session->get_errno() == SNMP::ERRNO_GENERIC); +var_dump($session->get_error()); +$session->close(); +?> +--EXPECTF-- +SNMP::ERRNO_NOERROR +%string|unicode%(%d) "%s" +bool(true) +%string|unicode%(0) "" +SNMP::ERRNO_TIMEOUT +bool(false) +bool(true) +%string|unicode%(%d) "No response from %s" +SNMP::ERRNO_ERROR_IN_REPLY +bool(false) +bool(true) +%string|unicode%(%d) "Error in packet %s" +SNMP::ERRNO_GENERIC +bool(false) +bool(true) +%string|unicode%(%d) "Fatal error: Unknown user name" \ No newline at end of file Modified: php/php-src/trunk/ext/snmp/tests/snmp-object-error.phpt === --- php/php-src/trunk/ext/snmp/tests/snmp-object-error.phpt 2011-02-26 04:34:53 UTC (rev 308702) +++ php/php-src/trunk/ext/snmp/tests/snmp-object-error.phpt 2011-02-26 08:27:26 UTC (rev 308703) @@ -1,5 +1,5 @@ --TEST-- -Errors in SNMP session-wise functions +OO API: Generic errors --CREDITS-- Boris Lytochkin --SKIPIF-- @@ -51,6 +51,10 @@ var_dump($session->get()); var_dump($session->set()); +var_dump($session->max_oids); +$session->max_oids = "ttt"; +$session->max_oids = 0; +var_dump($session->max_oids); ?> --EXPECTF-- SNMP::__construct() expects at least 3 parameters, 2 given @@ -82,3 +86,9 @@ Warning: SNMP::set() expects exactly 3 parameters, 0 given in %s on line %d bool(false) +NULL + +Warning: main(): max_oids should be positive integer or NULL, got 0 in %s on line %d + +Warning: main(): max_oids should be positive integer or NULL, got 0 in %s on line %d +NULL \ No newline at end of file Modified: php/php-src/trunk/ext/snmp/tests/snmp-object-properties.phpt ======= --- php/php-src/trunk/ext/snmp/tests/snmp-object-properties.phpt 2011-02-26 04:34:53 UTC (rev 308702) +++ php/php-src/trunk/ext/snmp/tests/snmp-object-properties.phpt 2011-02-26 08:27:26 UTC (rev 308703) @@ -59,6 +59,9 @@ $session->info = array("blah" => 2); var_dump($session->info); + +$session->max_oids = NULL; +var_dump($session->max_oids); ?> --EXPECTF-- Check working @@ -75,7 +78,7 @@ int(%d) } ["max_oids"]=> - int(0) + NULL ["valueretrieval"]=> int(1) ["quick_print"]=> @@ -183,4 +186,5 @@ int(%i) ["retries"]=> int(%d) -} \ No newline at end of file +} +NULL \ No newline at end of file Modified: php/php-src/trunk/ext/snmp/tests/snmp-object-set_security_error.phpt ==
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c
lytboris Sat, 26 Feb 2011 19:08:55 + Revision: http://svn.php.net/viewvc?view=revision&revision=308710 Log: remove compiler warnings fix various memory leaks seen with --enable-debug Changed paths: U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-02-26 17:28:31 UTC (rev 308709) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-02-26 19:08:55 UTC (rev 308710) @@ -140,17 +140,6 @@ typedef struct snmp_session php_snmp_session; #define PHP_SNMP_SESSION_RES_NAME "SNMP session" -#define PHP_SNMP_SESSION_FROM_OBJECT(session, object) \ - { \ - php_snmp_object *snmp_object; \ - snmp_object = (php_snmp_object *)zend_object_store_get_object(object TSRMLS_CC); \ - session = snmp_object->session; \ - if (!session) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid or uninitialized SNMP object"); \ - RETURN_FALSE; \ - } \ - } - #define PHP_SNMP_ADD_PROPERTIES(a, b) \ { \ int i = 0; \ @@ -614,6 +603,9 @@ if (valueretrieval == SNMP_VALUE_LIBRARY) { SNMP_SNPRINT_VALUE(buf, buflen, vars->name, vars->name_length, vars); ZVAL_STRING(snmpval, buf, 1); + if(dbuf){ /* malloc was used to store value */ + efree(dbuf); + } return; } @@ -621,12 +613,12 @@ switch (vars->type) { case ASN_BIT_STR: /* 0x03, asn1.h */ - ZVAL_STRINGL(val, vars->val.bitstring, vars->val_len, 1); + ZVAL_STRINGL(val, (char *)vars->val.bitstring, vars->val_len, 1); break; case ASN_OCTET_STR: /* 0x04, asn1.h */ case ASN_OPAQUE: /* 0x44, snmp_impl.h */ - ZVAL_STRINGL(val, vars->val.string, vars->val_len, 1); + ZVAL_STRINGL(val, (char *)vars->val.string, vars->val_len, 1); break; case ASN_NULL: /* 0x05, asn1.h */ @@ -699,6 +691,8 @@ add_property_long(snmpval, "type", vars->type); add_property_zval(snmpval, "value", val); } + zval_ptr_dtor(&val); + if(dbuf){ /* malloc was used to store value */ efree(dbuf); } @@ -747,7 +741,8 @@ gotroot = 1; } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid_query->vars[0].oid); -RETURN_FALSE; +RETVAL_FALSE; +return; } } @@ -766,7 +761,8 @@ snmp_error(session, NULL, NULL, &err); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not open snmp connection: %s", err); free(err); - RETURN_FALSE; + RETVAL_FALSE; + return; } while (keepwalking) { @@ -784,7 +780,8 @@ if(pdu->variables == NULL){ snmp_free_pdu(pdu); snmp_close(ss); -RETURN_FALSE; +RETVAL_FALSE; +return; } } else if (st & SNMP_CMD_SET) { pdu = snmp_pdu_create(SNMP_MSG_SET); @@ -794,14 +791,16 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid_query->vars[objid_query->offset].oid); snmp_free_pdu(pdu); snmp_close(ss); - RETURN_FALSE; + RETVAL_FALSE; + return; } else { if ((snmp_errno = snmp_add_var(pdu, name, name_length, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value))) { SNMP_SNPRINT_OBJID(buf, sizeof(buf), name, name_length); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not add variable: OID='%s' type='%c' value='%s': %s", buf, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value, snmp_api_errstring(snmp_errno)); snmp_free_pdu(pdu); snmp_close(ss); - RETURN_FALSE; + RETVAL_FALSE; + return; } } } @@ -823,7 +822,8 @@ if (st & SNMP_CMD_SET) { snmp_free_pdu(response); snmp_close(ss); - RETURN_TRUE; + RETVAL_TRUE; + return; } for (vars = response->variables; vars; vars = vars->next_variable) { /* do not output errors as values */ @@ -918,7 +918,8 @@ if (objid_query->array_output) { zval_dtor(return_value); } - RETURN_FALSE; + RETVAL_FALSE; + return; } } } else if (status == STAT_TIMEOUT) { @@ -927,7 +928,8 @@ zval_dtor(return_value); } snmp_close(ss); - RETURN_FALSE; + RETVAL_FALSE; + return; } else {/* status == STAT_ERROR */ snmp_error(ss, NULL, NULL, &err); php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_GENERIC, "Fatal error: %s", err); @@ -936,7 +938,8 @@ zval_dtor(return_value); } snmp_close(ss); - RETURN_FALSE; + RETVAL_FALSE; + return; } if (response) { snmp_free_pdu(response); @@ -992,6 +995,7 @@ objid_query->vars = (snmpobjarg *)emalloc(sizeof(snmpobjarg)); if (objid_query->vars == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "emalloc() failed while parsing oid: %s", strerror(errno)); + efree(objid_query->vars); return FALSE; } objid_query->vars[objid_query->count].oid = Z_STRVAL_PP(oid); @@ -999,6 +1003,7 @@ if (Z_TYPE_PP(type) == IS_STRING && Z_TYPE_PP(value) == IS_STRING)
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c
lytboris Wed, 02 Mar 2011 22:12:02 + Revision: http://svn.php.net/viewvc?view=revision&revision=308875 Log: fix warnings mentioned in 'Parameter Parsing Report' Changed paths: U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-03-02 22:03:38 UTC (rev 308874) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-03-02 22:12:02 UTC (rev 308875) @@ -1739,7 +1739,7 @@ int a1_len, a2_len; long timeout = SNMP_DEFAULT_TIMEOUT; long retries = SNMP_DEFAULT_RETRIES; - int version = SNMP_DEFAULT_VERSION; + long version = SNMP_DEFAULT_VERSION; int argc = ZEND_NUM_ARGS(); #if PHP_VERSION_ID > 50300 zend_error_handling error_handling; @@ -1854,7 +1854,7 @@ php_snmp_object *snmp_object; zval *object = getThis(); char *a1 = "", *a2 = "", *a3 = "", *a4 = "", *a5 = "", *a6 = "", *a7 = ""; - int a1_len, a2_len, a3_len, a4_len, a5_len, a6_len, a7_len; + int a1_len = 0, a2_len = 0, a3_len = 0, a4_len = 0, a5_len = 0, a6_len = 0, a7_len = 0; int argc = ZEND_NUM_ARGS(); snmp_object = (php_snmp_object *)zend_object_store_get_object(object TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ php_snmp.h snmp.c tests/snmp2_set.phpt tests/wrong_hostname.phpt
lytboris Fri, 04 Mar 2011 18:58:01 + Revision: http://svn.php.net/viewvc?view=revision&revision=308931 Log: * fix warning about redefining REGISTER_PDO_CLASS_CONST_LONG (damn copy'n'paste) * tuned two unit test that failed at gcov.php.net/PHP_HEAD Changed paths: U php/php-src/trunk/ext/snmp/php_snmp.h U php/php-src/trunk/ext/snmp/snmp.c U php/php-src/trunk/ext/snmp/tests/snmp2_set.phpt U php/php-src/trunk/ext/snmp/tests/wrong_hostname.phpt Modified: php/php-src/trunk/ext/snmp/php_snmp.h === --- php/php-src/trunk/ext/snmp/php_snmp.h 2011-03-04 18:48:22 UTC (rev 308930) +++ php/php-src/trunk/ext/snmp/php_snmp.h 2011-03-04 18:58:01 UTC (rev 308931) @@ -124,7 +124,7 @@ #define SNMP_G(v) (snmp_globals.v) #endif -#define REGISTER_PDO_CLASS_CONST_LONG(const_name, value) \ +#define REGISTER_SNMP_CLASS_CONST_LONG(const_name, value) \ zend_declare_class_constant_long(php_snmp_get_ce(), const_name, sizeof(const_name)-1, (long)value TSRMLS_CC); #else Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-03-04 18:48:22 UTC (rev 308930) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-03-04 18:58:01 UTC (rev 308931) @@ -2436,11 +2436,11 @@ REGISTER_LONG_CONSTANT("SNMP_VERSION_2c", SNMP_VERSION_2c, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SNMP_VERSION_3",SNMP_VERSION_3, CONST_CS | CONST_PERSISTENT); - REGISTER_PDO_CLASS_CONST_LONG("ERRNO_NOERROR", (long)PHP_SNMP_ERRNO_NOERROR); - REGISTER_PDO_CLASS_CONST_LONG("ERRNO_GENERIC", (long)PHP_SNMP_ERRNO_GENERIC); - REGISTER_PDO_CLASS_CONST_LONG("ERRNO_TIMEOUT", (long)PHP_SNMP_ERRNO_TIMEOUT); - REGISTER_PDO_CLASS_CONST_LONG("ERRNO_ERROR_IN_REPLY", (long)PHP_SNMP_ERRNO_ERROR_IN_REPLY); - REGISTER_PDO_CLASS_CONST_LONG("ERRNO_OID_NOT_INCREASING", (long)PHP_SNMP_ERRNO_OID_NOT_INCREASING); + REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_NOERROR", (long)PHP_SNMP_ERRNO_NOERROR); + REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_GENERIC", (long)PHP_SNMP_ERRNO_GENERIC); + REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_TIMEOUT", (long)PHP_SNMP_ERRNO_TIMEOUT); + REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_ERROR_IN_REPLY", (long)PHP_SNMP_ERRNO_ERROR_IN_REPLY); + REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_OID_NOT_INCREASING", (long)PHP_SNMP_ERRNO_OID_NOT_INCREASING); return SUCCESS; } Modified: php/php-src/trunk/ext/snmp/tests/snmp2_set.phpt === --- php/php-src/trunk/ext/snmp/tests/snmp2_set.phpt 2011-03-04 18:48:22 UTC (rev 308930) +++ php/php-src/trunk/ext/snmp/tests/snmp2_set.phpt 2011-03-04 18:58:01 UTC (rev 308931) @@ -224,13 +224,13 @@ bool(true) Multiple OID, 1st bogus, single type, multiple value -Warning: snmp2_set(): Error in packet at '%s': noCreation (That table does not support row creation or that object can not ever be created) in %s on line %d +Warning: snmp2_set(): Error in packet at '%s': %rnoCreation|notWritable%r (%s) in %s on line %d bool(false) bool(true) bool(true) Multiple OID, 2nd bogus, single type, multiple value -Warning: snmp2_set(): Error in packet at '%s': noCreation (That table does not support row creation or that object can not ever be created) in %s on line %d +Warning: snmp2_set(): Error in packet at '%s': %rnoCreation|notWritable%r (%s) in %s on line %d bool(false) bool(true) bool(true) Modified: php/php-src/trunk/ext/snmp/tests/wrong_hostname.phpt === --- php/php-src/trunk/ext/snmp/tests/wrong_hostname.phpt2011-03-04 18:48:22 UTC (rev 308930) +++ php/php-src/trunk/ext/snmp/tests/wrong_hostname.phpt2011-03-04 18:58:01 UTC (rev 308931) @@ -18,5 +18,5 @@ ?> --EXPECTF-- -Warning: snmpget(): Could not open snmp connection: Unknown host (192.168..6.1) (Bad file descriptor) in %s on line %d +Warning: snmpget(): Could not open snmp connection: Unknown host (192.168..6.1) (%s) in %s on line %d bool(false) \ No newline at end of file -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c tests/snmp2_walk.phpt
lytboris Fri, 04 Mar 2011 19:23:25 + Revision: http://svn.php.net/viewvc?view=revision&revision=308932 Log: * tune snmp2_walk.phpt * more net-snmp v5.3 compatibility (OPAQUE_SPECIAL_TYPES) Changed paths: U php/php-src/trunk/ext/snmp/snmp.c U php/php-src/trunk/ext/snmp/tests/snmp2_walk.phpt Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-03-04 18:58:01 UTC (rev 308931) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-03-04 19:23:25 UTC (rev 308932) @@ -654,7 +654,7 @@ ZVAL_STRING(val, buf, 1); break; -#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES +#if defined(NETSNMP_WITH_OPAQUE_SPECIAL_TYPES) || defined(OPAQUE_SPECIAL_TYPES) case ASN_OPAQUE_FLOAT: /* 0x78, asn1.h */ snprintf(buf, buflen, "%f", *vars->val.floatVal); ZVAL_STRING(val, buf, 1); Modified: php/php-src/trunk/ext/snmp/tests/snmp2_walk.phpt === --- php/php-src/trunk/ext/snmp/tests/snmp2_walk.phpt2011-03-04 18:58:01 UTC (rev 308931) +++ php/php-src/trunk/ext/snmp/tests/snmp2_walk.phpt2011-03-04 19:23:25 UTC (rev 308932) @@ -68,7 +68,7 @@ Checking working Single OID %unicode|string%(5) "array" -int(32) +int(%d) %unicode|string%(6) "string" %unicode|string%(6) "string" Single OID in array -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c
lytboris Fri, 11 Mar 2011 07:21:13 + Revision: http://svn.php.net/viewvc?view=revision&revision=309111 Log: fix typo in SNMP_SNPRINT_VALUE usage: use val_len, not name_length Changed paths: U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-03-11 06:45:59 UTC (rev 309110) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-03-11 07:21:13 UTC (rev 309111) @@ -601,7 +601,7 @@ *buf = 0; if (valueretrieval == SNMP_VALUE_LIBRARY) { - SNMP_SNPRINT_VALUE(buf, buflen, vars->name, vars->name_length, vars); + SNMP_SNPRINT_VALUE(buf, buflen, vars->name, vars->val_len, vars); ZVAL_STRING(snmpval, buf, 1); if(dbuf){ /* malloc was used to store value */ efree(dbuf); @@ -834,7 +834,7 @@ break; } SNMP_SNPRINT_OBJID(buf, sizeof(buf), vars->name, vars->name_length); - SNMP_SNPRINT_VALUE(buf2, sizeof(buf2), vars->name, vars->name_length, vars); + SNMP_SNPRINT_VALUE(buf2, sizeof(buf2), vars->name, vars->val_len, vars); php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_ERROR_IN_REPLY, "Error in packet at '%s': %s", buf, buf2); continue; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c
lytboris Sat, 19 Mar 2011 20:50:39 + Revision: http://svn.php.net/viewvc?view=revision&revision=309453 Log: revert r309111 (name_len was not a typo) Changed paths: U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-03-19 19:35:59 UTC (rev 309452) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-03-19 20:50:39 UTC (rev 309453) @@ -601,7 +601,7 @@ *buf = 0; if (valueretrieval == SNMP_VALUE_LIBRARY) { - SNMP_SNPRINT_VALUE(buf, buflen, vars->name, vars->val_len, vars); + SNMP_SNPRINT_VALUE(buf, buflen, vars->name, vars->name_length, vars); ZVAL_STRING(snmpval, buf, 1); if(dbuf){ /* malloc was used to store value */ efree(dbuf); @@ -834,7 +834,7 @@ break; } SNMP_SNPRINT_OBJID(buf, sizeof(buf), vars->name, vars->name_length); - SNMP_SNPRINT_VALUE(buf2, sizeof(buf2), vars->name, vars->val_len, vars); + SNMP_SNPRINT_VALUE(buf2, sizeof(buf2), vars->name, vars->name_length, vars); php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_ERROR_IN_REPLY, "Error in packet at '%s': %s", buf, buf2); continue; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ php_snmp.h snmp.c tests/generic_timeout_error.phpt tests/snmp-object-errno-errstr.phpt tests/snmp-object-error.phpt tests/snmp-object-properties.phpt tests/
7;MD5', $auth_pass, 'AES', $priv_pass); +$session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass); var_dump(@$session->get('.1.3.6.1.2.1.1.1.0')); var_dump($session->get_errno() == SNMP::ERRNO_GENERIC); var_dump($session->get_error()); @@ -60,4 +60,4 @@ SNMP::ERRNO_GENERIC bool(false) bool(true) -%string|unicode%(%d) "Fatal error: Unknown user name" \ No newline at end of file +%string|unicode%(%d) "Fatal error: Unknown user name" Modified: php/php-src/trunk/ext/snmp/tests/snmp-object-error.phpt === --- php/php-src/trunk/ext/snmp/tests/snmp-object-error.phpt 2011-03-20 17:10:28 UTC (rev 309484) +++ php/php-src/trunk/ext/snmp/tests/snmp-object-error.phpt 2011-03-20 20:07:33 UTC (rev 309485) @@ -91,4 +91,4 @@ Warning: main(): max_oids should be positive integer or NULL, got 0 in %s on line %d Warning: main(): max_oids should be positive integer or NULL, got 0 in %s on line %d -NULL \ No newline at end of file +NULL Modified: php/php-src/trunk/ext/snmp/tests/snmp-object-properties.phpt === --- php/php-src/trunk/ext/snmp/tests/snmp-object-properties.phpt 2011-03-20 17:10:28 UTC (rev 309484) +++ php/php-src/trunk/ext/snmp/tests/snmp-object-properties.phpt 2011-03-20 20:07:33 UTC (rev 309485) @@ -187,4 +187,4 @@ ["retries"]=> int(%d) } -NULL \ No newline at end of file +NULL Copied: php/php-src/trunk/ext/snmp/tests/snmp-object-setSecurity_error.phpt (from rev 309453, php/php-src/trunk/ext/snmp/tests/snmp-object-set_security_error.phpt) === --- php/php-src/trunk/ext/snmp/tests/snmp-object-setSecurity_error.phpt (rev 0) +++ php/php-src/trunk/ext/snmp/tests/snmp-object-setSecurity_error.phpt 2011-03-20 20:07:33 UTC (rev 309485) @@ -0,0 +1,66 @@ +--TEST-- +OO API: SNMP::setSecurity (errors) +--CREDITS-- +Boris Lytochkin +--SKIPIF-- + +--FILE-- +setSecurity('noAuthNoPriv'); + +#echo "Checking error handling\n"; +var_dump($session->setSecurity()); +var_dump($session->setSecurity('')); +var_dump($session->setSecurity('bugusPriv')); +var_dump($session->setSecurity('authNoPriv', 'TTT')); +var_dump($session->setSecurity('authNoPriv', 'MD5', '')); +var_dump($session->setSecurity('authNoPriv', 'MD5', 'te')); +var_dump($session->setSecurity('authPriv', 'MD5', $auth_pass, 'BBB')); +var_dump($session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', '')); +var_dump($session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', 'ty')); +var_dump($session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', 'test12345', 'context', 'dsa')); + +var_dump($session->close()); + +?> +--EXPECTF-- + +Warning: SNMP::setSecurity() expects at least 1 parameter, 0 given in %s on line %d +bool(false) + +Warning: SNMP::setSecurity(): Invalid security level '' in %s on line %d +bool(false) + +Warning: SNMP::setSecurity(): Invalid security level 'bugusPriv' in %s on line %d +bool(false) + +Warning: SNMP::setSecurity(): Unknown authentication protocol 'TTT' in %s on line %d +bool(false) + +Warning: SNMP::setSecurity(): Error generating a key for authentication pass phrase '': Generic error (The supplied password length is too short.) in %s on line %d +bool(false) + +Warning: SNMP::setSecurity(): Error generating a key for authentication pass phrase 'te': Generic error (The supplied password length is too short.) in %s on line %d +bool(false) + +Warning: SNMP::setSecurity(): Unknown security protocol 'BBB' in %s on line %d +bool(false) + +Warning: SNMP::setSecurity(): Error generating a key for privacy pass phrase '': Generic error (The supplied password length is too short.) in %s on line %d +bool(false) + +Warning: SNMP::setSecurity(): Error generating a key for privacy pass phrase 'ty': Generic error (The supplied password length is too short.) in %s on line %d +bool(false) + +Warning: SNMP::setSecurity(): Bad engine ID value 'dsa' in %s on line %d +bool(false) +bool(true) Deleted: php/php-src/trunk/ext/snmp/tests/snmp-object-set_security_error.phpt === --- php/php-src/trunk/ext/snmp/tests/snmp-object-set_security_error.phpt 2011-03-20 17:10:28 UTC (rev 309484) +++ php/php-src/trunk/ext/snmp/tests/snmp-object-set_security_error.phpt 2011-03-20 20:07:33 UTC (rev 309485) @@ -1,66 +0,0 @@ ---TEST-- -OO API: SNMP::set_security (e
[PHP-CVS] svn: /php/php-src/trunk/ UPGRADING
lytboris Sun, 27 Mar 2011 09:44:38 + Revision: http://svn.php.net/viewvc?view=revision&revision=309740 Log: added info about changes in SNMP extension Changed paths: U php/php-src/trunk/UPGRADING Modified: php/php-src/trunk/UPGRADING === --- php/php-src/trunk/UPGRADING 2011-03-27 08:55:27 UTC (rev 309739) +++ php/php-src/trunk/UPGRADING 2011-03-27 09:44:38 UTC (rev 309740) @@ -255,6 +255,16 @@ - The session extension now can hook into the file upload feature in order to provide upload progress information through session variables. +- SNMP extension + - Functions in SNMP extension now returns FALSE on every error + condition including SNMP-related (no such instance, end of MIB, + etc). Thus, in patricular, breaks previous behaviour of get/walk + functions returning an empty string on SNMP-related errors. + - Multi OID get/getnext/set queries are now supported. + - New constants added for use in snmp_set_oid_output_format() + function. + - Added feature-rich OO API (SNMP class) + d. no longer possible to disable @@ -353,6 +363,9 @@ - Intl: - Transliterator + + - SNMP: + - SNMP h. New methods -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ UPGRADING ext/snmp/CREDITS ext/snmp/config.m4 ext/snmp/config.w32 ext/snmp/php_snmp.h ext/snmp/snmp.c
lytboris Tue, 05 Apr 2011 12:20:35 + Revision: http://svn.php.net/viewvc?view=revision&revision=309971 Log: * added detection and walkaround for net-snmp library bug (net-snmp BUGid 2027834) * drop UCD-SNMP support, R.I.P. Changed paths: U php/php-src/trunk/UPGRADING U php/php-src/trunk/ext/snmp/CREDITS U php/php-src/trunk/ext/snmp/config.m4 U php/php-src/trunk/ext/snmp/config.w32 U php/php-src/trunk/ext/snmp/php_snmp.h U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/UPGRADING === --- php/php-src/trunk/UPGRADING 2011-04-05 10:47:25 UTC (rev 309970) +++ php/php-src/trunk/UPGRADING 2011-04-05 12:20:35 UTC (rev 309971) @@ -276,6 +276,8 @@ - New constants added for use in snmp_set_oid_output_format() function. - Added feature-rich OO API (SNMP class) + - Dropped UCD-SNMP compatibility code. Consider upgrading to + net-snmp v5.3+. Net-SNMP v5.4+ is required for Windows version. d. no longer possible to disable Modified: php/php-src/trunk/ext/snmp/CREDITS === --- php/php-src/trunk/ext/snmp/CREDITS 2011-04-05 10:47:25 UTC (rev 309970) +++ php/php-src/trunk/ext/snmp/CREDITS 2011-04-05 12:20:35 UTC (rev 309971) @@ -1,2 +1,2 @@ SNMP -Rasmus Lerdorf, Harrie Hazewinkel, Mike Jackson, Steven Lawrance, Johann Hanne +Rasmus Lerdorf, Harrie Hazewinkel, Mike Jackson, Steven Lawrance, Johann Hanne, Boris Lytochkin Modified: php/php-src/trunk/ext/snmp/config.m4 === --- php/php-src/trunk/ext/snmp/config.m4 2011-04-05 10:47:25 UTC (rev 309970) +++ php/php-src/trunk/ext/snmp/config.m4 2011-04-05 12:20:35 UTC (rev 309971) @@ -8,14 +8,8 @@ PHP_ARG_WITH(openssl-dir,OpenSSL dir for SNMP, [ --with-openssl-dir[=DIR] SNMP: openssl install prefix], no, no) -PHP_ARG_ENABLE(ucd-snmp-hack, whether to enable UCD SNMP hack, -[ --enable-ucd-snmp-hackSNMP: Enable UCD SNMP hack], no, no) - if test "$PHP_SNMP" != "no"; then - dnl - dnl Try net-snmp first - dnl if test "$PHP_SNMP" = "yes"; then AC_PATH_PROG(SNMP_CONFIG,net-snmp-config,,[/usr/local/bin:$PATH]) else @@ -30,78 +24,12 @@ if test -n "$SNMP_LIBS" && test -n "$SNMP_PREFIX"; then PHP_ADD_INCLUDE(${SNMP_PREFIX}/include) PHP_EVAL_LIBLINE($SNMP_LIBS, SNMP_SHARED_LIBADD) - AC_DEFINE(HAVE_NET_SNMP,1,[ ]) SNMP_LIBNAME=netsnmp else AC_MSG_ERROR([Could not find the required paths. Please check your net-snmp installation.]) fi else - -dnl -dnl Try ucd-snmp if net-snmp test failed -dnl - -if test "$PHP_SNMP" = "yes"; then - for i in /usr/include /usr/local/include; do -test -f $i/snmp.h && SNMP_INCDIR=$i -test -f $i/ucd-snmp/snmp.h && SNMP_INCDIR=$i/ucd-snmp -test -f $i/snmp/snmp.h && SNMP_INCDIR=$i/snmp -test -f $i/snmp/include/ucd-snmp/snmp.h && SNMP_INCDIR=$i/snmp/include/ucd-snmp - done - for i in /usr/$PHP_LIBDIR /usr/snmp/lib /usr/local/$PHP_LIBDIR /usr/local/lib /usr/local/snmp/lib; do -test -f $i/libsnmp.a || test -f $i/libsnmp.$SHLIB_SUFFIX_NAME && SNMP_LIBDIR=$i - done -else - SNMP_INCDIR=$PHP_SNMP/include - test -d $PHP_SNMP/include/ucd-snmp && SNMP_INCDIR=$PHP_SNMP/include/ucd-snmp - SNMP_LIBDIR=$PHP_SNMP/lib -fi - -if test -z "$SNMP_INCDIR"; then - AC_MSG_ERROR(snmp.h not found. Check your SNMP installation.) -elif test -z "$SNMP_LIBDIR"; then - AC_MSG_ERROR(libsnmp not found. Check your SNMP installation.) -fi - -old_CPPFLAGS=$CPPFLAGS -CPPFLAGS=-I$SNMP_INCDIR -AC_CHECK_HEADERS(default_store.h) -if test "$ac_cv_header_default_store_h" = "yes"; then - AC_MSG_CHECKING(for OpenSSL support in SNMP libraries) - AC_EGREP_CPP(yes,[ -#include -#if USE_OPENSSL -yes -#endif - ],[ -SNMP_SSL=yes - ],[ -SNMP_SSL=no - ]) -fi -CPPFLAGS=$old_CPPFLAGS -AC_MSG_RESULT($SNMP_SSL) - -if test "$SNMP_SSL" = "yes"; then - if test "$PHP_OPENSSL_DIR" != "no"; then -PHP_OPENSSL=$PHP_OPENSSL_DIR - fi - - if test "$PHP_OPENSSL" = "no"; then -AC_MSG_ERROR([The UCD-SNMP in this system is built with SSL support. - -Add --with-openssl-dir=DIR to your configure line.]) - else -PHP_SETUP_OPENSSL(SNMP_SHARED_LIBADD, [], [ - AC_MSG_ERROR([SNMP: OpenSSL check failed. Please check config.log for more information.]) -]) - fi -
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ config.m4 snmp.c
lytboris Wed, 06 Apr 2011 06:58:25 + Revision: http://svn.php.net/viewvc?view=revision&revision=309976 Log: * Net-SNMP version detection and proper processing * more UCD-SNMP-related code removal Changed paths: U php/php-src/trunk/ext/snmp/config.m4 U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/ext/snmp/config.m4 === --- php/php-src/trunk/ext/snmp/config.m42011-04-06 02:16:55 UTC (rev 309975) +++ php/php-src/trunk/ext/snmp/config.m42011-04-06 06:58:25 UTC (rev 309976) @@ -20,23 +20,34 @@ SNMP_LIBS=`$SNMP_CONFIG --netsnmp-libs` SNMP_LIBS="$SNMP_LIBS `$SNMP_CONFIG --external-libs`" SNMP_PREFIX=`$SNMP_CONFIG --prefix` - -if test -n "$SNMP_LIBS" && test -n "$SNMP_PREFIX"; then - PHP_ADD_INCLUDE(${SNMP_PREFIX}/include) - PHP_EVAL_LIBLINE($SNMP_LIBS, SNMP_SHARED_LIBADD) - SNMP_LIBNAME=netsnmp +snmp_full_version=`$SNMP_CONFIG --version` +ac_IFS=$IFS +IFS="." +set $snmp_full_version +IFS=$ac_IFS +SNMP_VERSION=`expr [$]1 \* 1000 + [$]2` +if test "$SNMP_VERSION" -ge "5003"; then + if test -n "$SNMP_LIBS" && test -n "$SNMP_PREFIX"; then +PHP_ADD_INCLUDE(${SNMP_PREFIX}/include) +PHP_EVAL_LIBLINE($SNMP_LIBS, SNMP_SHARED_LIBADD) +SNMP_LIBNAME=netsnmp + else +AC_MSG_ERROR([Could not find the required paths. Please check your net-snmp installation.]) + fi else - AC_MSG_ERROR([Could not find the required paths. Please check your net-snmp installation.]) + AC_MSG_ERROR([Net-SNMP version 5.3 or greater reqired (detected $snmp_full_version).]) fi else AC_MSG_ERROR([Could not find net-snmp-config binary. Please check your net-snmp installation.]) fi - dnl Check whether snmp_parse_oid() exists. - PHP_CHECK_LIBRARY($SNMP_LIBNAME, snmp_parse_oid, + dnl Test build. + PHP_CHECK_LIBRARY($SNMP_LIBNAME, init_snmp, [ -AC_DEFINE(HAVE_SNMP_PARSE_OID, 1, [ ]) - ], [], [ +AC_DEFINE(HAVE_SNMP,1,[ ]) + ], [ +AC_MSG_ERROR([SNMP sanity check failed. Please check config.log for more information.]) + ], [ $SNMP_SHARED_LIBADD ]) @@ -48,16 +59,6 @@ $SNMP_SHARED_LIBADD ]) - dnl Test build. - PHP_CHECK_LIBRARY($SNMP_LIBNAME, init_snmp, - [ -AC_DEFINE(HAVE_SNMP,1,[ ]) - ], [ -AC_MSG_ERROR([SNMP sanity check failed. Please check config.log for more information.]) - ], [ -$SNMP_SHARED_LIBADD - ]) - dnl Check for buggy snmp_snprint_value() (net-snmp BUGid 2027834) AC_CACHE_CHECK([for buggy snmp_snprint_value], ac_cv_buggy_snprint_value,[ save_CFLAGS="$CFLAGS" Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-04-06 02:16:55 UTC (rev 309975) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-04-06 06:58:25 UTC (rev 309976) @@ -75,11 +75,6 @@ #include #include -/* Ugly macro, since the length of OIDs in UCD-SNMP and NET-SNMP - * is different and this way the code is not full of 'ifdef's. - */ -#define OIDSIZE(p) (sizeof(p)/sizeof(oid)) - #if PHP_VERSION_ID < 50300 #define Z_ADDREF_P(pz) pz->refcount++ #define Z_ISREF_PP(oid) (PZVAL_IS_REF(*(oid))) @@ -99,11 +94,6 @@ } #endif -/* For really old ucd-snmp versions.. */ -#ifndef HAVE_SNMP_PARSE_OID -#define snmp_parse_oid read_objid -#endif - #define SNMP_VALUE_LIBRARY 0 #define SNMP_VALUE_PLAIN 1 #define SNMP_VALUE_OBJECT 2 @@ -1092,11 +1082,7 @@ session->securityNameLen = strlen(session->securityName); } else { session->authenticator = NULL; -#ifdef UCD_SNMP_HACK - session->community = (u_char *)strdup(community); /* memory freed by SNMP library, strdup NOT estrdup */ -#else session->community = (u_char *)community; -#endif session->community_len = strlen(community); } @@ -1129,10 +1115,10 @@ { if (!strcasecmp(prot, "MD5")) { s->securityAuthProto = usmHMACMD5AuthProtocol; - s->securityAuthProtoLen = OIDSIZE(usmHMACMD5AuthProtocol); + s->securityAuthProtoLen = USM_AUTH_PROTO_MD5_LEN; } else if (!strcasecmp(prot, "SHA")) { s->securityAuthProto = usmHMACSHA1AuthProtocol; - s->securityAuthProtoLen = OIDSIZE(usmHMACSHA1AuthProtocol); + s->securityAuthProtoLen = USM_AUTH_PROTO_SHA_LEN; } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown authentication protocol '%s'", prot); return (-1); @@ -1147,39 +1133,12 @@ { if (!strcasecmp(prot, "DES")) { s->securityPrivProto = usmDESPrivProtocol; - s->securityPrivProtoLen = OIDSIZE(usmDESPrivProtocol); + s->securityPrivProtoLen = USM_PRIV_PROTO_DES_LEN; #ifdef HAVE_AES - }
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ config.m4
lytboris Tue, 12 Apr 2011 08:00:14 + Revision: http://svn.php.net/viewvc?view=revision&revision=310157 Log: fix typo Changed paths: U php/php-src/trunk/ext/snmp/config.m4 Modified: php/php-src/trunk/ext/snmp/config.m4 === --- php/php-src/trunk/ext/snmp/config.m42011-04-12 06:50:48 UTC (rev 310156) +++ php/php-src/trunk/ext/snmp/config.m42011-04-12 08:00:14 UTC (rev 310157) @@ -74,7 +74,6 @@ int main(int argc, char **argv) { - int result = 0; struct variable_list vars; char buf1[2048]; char buf2[sizeof(buf1)]; @@ -117,7 +116,7 @@ ]) CFLAGS="$save_CFLAGS" ]) - if test "ac_cv_buggy_snprint_value" = "yes"; then + if test "$ac_cv_buggy_snprint_value" = "yes"; then AC_DEFINE(BUGGY_SNMPRINT_VALUE, 1, [ ]) fi -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c
lytboris Sun, 08 May 2011 09:20:58 + Revision: http://svn.php.net/viewvc?view=revision&revision=310836 Log: fix error reporting on OID not increasing calling arguments markup Changed paths: U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-05-08 05:52:53 UTC (rev 310835) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-05-08 09:20:58 UTC (rev 310836) @@ -837,10 +837,11 @@ /* OID increase check */ if (st & SNMP_CMD_WALK) { if (snmp_oid_compare(name, name_length, vars->name, vars->name_length) >= 0) { - php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_NOT_INCREASING, "Error: OID not increasing: %s", name); + snprint_objid(buf2, sizeof(buf2), vars->name, vars->name_length); + php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_NOT_INCREASING, "Error: OID not increasing: %s", buf2); keepwalking = 0; } else { - memmove((char *)name, (char *)vars->name,vars->name_length * sizeof(oid)); + 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] svn: /php/php-src/trunk/ext/snmp/ php_snmp.h snmp.c tests/snmp-object-error.phpt tests/snmp-object.phpt
lytboris Sun, 08 May 2011 13:58:37 + Revision: http://svn.php.net/viewvc?view=revision&revision=310839 Log: * new option for SNMP::get: force keys of return array be as in request array * new option for SNMP::walk: use suffix of OID for keys in return array, not full OID Changed paths: U php/php-src/trunk/ext/snmp/php_snmp.h U php/php-src/trunk/ext/snmp/snmp.c U php/php-src/trunk/ext/snmp/tests/snmp-object-error.phpt U php/php-src/trunk/ext/snmp/tests/snmp-object.phpt Modified: php/php-src/trunk/ext/snmp/php_snmp.h === --- php/php-src/trunk/ext/snmp/php_snmp.h 2011-05-08 13:17:06 UTC (rev 310838) +++ php/php-src/trunk/ext/snmp/php_snmp.h 2011-05-08 13:58:37 UTC (rev 310839) @@ -41,6 +41,9 @@ #include "TSRM.h" #endif +#include +#include + PHP_MINIT_FUNCTION(snmp); PHP_MSHUTDOWN_FUNCTION(snmp); PHP_MINFO_FUNCTION(snmp); @@ -109,7 +112,8 @@ char *oid; char type; char *value; - + oid name[MAX_OID_LEN]; + size_t name_length; } snmpobjarg; ZEND_BEGIN_MODULE_GLOBALS(snmp) Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-05-08 13:17:06 UTC (rev 310838) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-05-08 13:58:37 UTC (rev 310839) @@ -421,6 +421,10 @@ #define SNMP_CMD_WALK (1<<3) /* force values-only output */ #define SNMP_NUMERIC_KEYS (1<<7) +/* use user-supplied OID names for keys in array output mode in GET method */ +#define SNMP_ORIGINAL_NAMES_AS_KEYS (1<<8) +/* use OID suffix (`index') for keys in array output mode in WALK method */ +#define SNMP_USE_SUFFIX_AS_KEYS (1<<9) #ifdef COMPILE_DL_SNMP ZEND_GET_MODULE(snmp) @@ -677,7 +681,7 @@ oid root[MAX_NAME_LEN]; size_t rootlen = 0; int gotroot = 0; - int status, count; + int status, count, found; char buf[2048]; char buf2[2048]; int keepwalking=1; @@ -716,6 +720,10 @@ memmove((char *)name, (char *)root, rootlen * sizeof(oid)); name_length = rootlen; objid_query->offset = objid_query->count; + + memmove((char *)objid_query->vars[0].name, (char *)root, rootlen * sizeof(oid)); + objid_query->vars[0].name_length = rootlen; + } if ((ss = snmp_open(session)) == NULL) { @@ -731,11 +739,11 @@ if (st & (SNMP_CMD_GET | SNMP_CMD_GETNEXT)) { pdu = snmp_pdu_create((st & SNMP_CMD_GET) ? SNMP_MSG_GET : SNMP_MSG_GETNEXT); for (count = 0; objid_query->offset < objid_query->count && count < objid_query->step; objid_query->offset++, count++){ -name_length = MAX_OID_LEN; -if (!snmp_parse_oid(objid_query->vars[objid_query->offset].oid, name, &name_length)) { +objid_query->vars[objid_query->offset].name_length = MAX_OID_LEN; +if (!snmp_parse_oid(objid_query->vars[objid_query->offset].oid, objid_query->vars[objid_query->offset].name, &(objid_query->vars[objid_query->offset].name_length))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid_query->vars[objid_query->offset].oid); } else { - snmp_add_null_var(pdu, name, name_length); + snmp_add_null_var(pdu, objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length); } } if(pdu->variables == NULL){ @@ -747,16 +755,16 @@ } else if (st & SNMP_CMD_SET) { pdu = snmp_pdu_create(SNMP_MSG_SET); for (count = 0; objid_query->offset < objid_query->count && count < objid_query->step; objid_query->offset++, count++){ -name_length = MAX_OID_LEN; -if (!snmp_parse_oid(objid_query->vars[objid_query->offset].oid, name, &name_length)) { +objid_query->vars[objid_query->offset].name_length = MAX_OID_LEN; +if (!snmp_parse_oid(objid_query->vars[objid_query->offset].oid, objid_query->vars[objid_query->offset].name, &(objid_query->vars[objid_query->offset].name_length))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid_query->vars[objid_query->offset].oid); snmp_free_pdu(pdu); snmp_close(ss); RETVAL_FALSE; return; } else { - if ((snmp_errno = snmp_add_var(pdu, name, name_length, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value))) { - snprint_objid(buf, sizeof(buf), name, name_length); + if ((snmp_errno = snmp_add_var(pdu, objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value))) { + snprint_objid(buf, sizeof(buf), objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not add variable: OID='%s' type='%c' value='%s': %s", buf, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value, snmp_api_errstring(snmp_errno)); snmp_free_pdu(pd
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c
lytboris Mon, 09 May 2011 19:34:07 + Revision: http://svn.php.net/viewvc?view=revision&revision=310861 Log: remove method open, __construct is enough Changed paths: U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-05-09 18:22:39 UTC (rev 310860) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-05-09 19:34:07 UTC (rev 310861) @@ -322,7 +322,7 @@ /* OO arginfo */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp_open, 0, 0, 3) +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp_create, 0, 0, 3) ZEND_ARG_INFO(0, version) ZEND_ARG_INFO(0, host) ZEND_ARG_INFO(0, community) @@ -1687,9 +1687,9 @@ } /* }}} */ -/* {{{ proto SNMP SNMP::open(int version, string hostname, string community|securityName [, long timeout [, long retries]]) +/* {{{ proto SNMP SNMP::__construct(int version, string hostname, string community|securityName [, long timeout [, long retries]]) Creates a new SNMP session to specified host. */ -PHP_METHOD(snmp, open) +PHP_METHOD(snmp, __construct) { php_snmp_object *snmp_object; zval *object = getThis(); @@ -2286,7 +2286,7 @@ /* {{{ php_snmp_class_methods[] */ static zend_function_entry php_snmp_class_methods[] = { - PHP_ME(snmp, open, arginfo_snmp_open, ZEND_ACC_PUBLIC) + PHP_ME(snmp, __construct, arginfo_snmp_create, ZEND_ACC_PUBLIC) PHP_ME(snmp, close, arginfo_snmp_void, ZEND_ACC_PUBLIC) PHP_ME(snmp, setSecurity, arginfo_snmp_setSecurity, ZEND_ACC_PUBLIC) @@ -2297,7 +2297,6 @@ PHP_ME(snmp, get_errno, arginfo_snmp_void, ZEND_ACC_PUBLIC) PHP_ME(snmp, get_error, arginfo_snmp_void, ZEND_ACC_PUBLIC) - PHP_MALIAS(snmp, __construct, open, arginfo_snmp_open, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) {NULL, NULL, NULL} }; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c tests/snmp-object-errno-errstr.phpt
lytboris Tue, 10 May 2011 11:48:10 + Revision: http://svn.php.net/viewvc?view=revision&revision=310887 Log: method renaming: SNMP::get_errno() -> SNMP::getErrno() SNMP::get_error() -> SNMP::getError() Changed paths: U php/php-src/trunk/ext/snmp/snmp.c U php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-05-10 11:34:48 UTC (rev 310886) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-05-10 11:48:10 UTC (rev 310887) @@ -1826,9 +1826,9 @@ } /* }}} */ -/* {{{ proto long SNMP::get_errno() +/* {{{ proto long SNMP::getErrno() Get last error code number */ -PHP_METHOD(snmp, get_errno) +PHP_METHOD(snmp, getErrno) { php_snmp_object *snmp_object; zval *object = getThis(); @@ -1840,9 +1840,9 @@ } /* }}} */ -/* {{{ proto long SNMP::error() +/* {{{ proto long SNMP::getError() Get last error message */ -PHP_METHOD(snmp, get_error) +PHP_METHOD(snmp, getError) { php_snmp_object *snmp_object; zval *object = getThis(); @@ -2294,8 +2294,8 @@ PHP_ME(snmp, getnext, arginfo_snmp_get, ZEND_ACC_PUBLIC) PHP_ME(snmp, walk, arginfo_snmp_walk, ZEND_ACC_PUBLIC) PHP_ME(snmp, set, arginfo_snmp_set, ZEND_ACC_PUBLIC) - PHP_ME(snmp, get_errno, arginfo_snmp_void, ZEND_ACC_PUBLIC) - PHP_ME(snmp, get_error, arginfo_snmp_void, ZEND_ACC_PUBLIC) + PHP_ME(snmp, getErrno, arginfo_snmp_void, ZEND_ACC_PUBLIC) + PHP_ME(snmp, getError, arginfo_snmp_void, ZEND_ACC_PUBLIC) {NULL, NULL, NULL} }; Modified: php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt === --- php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt 2011-05-10 11:34:48 UTC (rev 310886) +++ php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt 2011-05-10 11:48:10 UTC (rev 310887) @@ -1,5 +1,5 @@ --TEST-- -OO API: get_errno & get_error functions +OO API: getErrno & getError functions --CREDITS-- Boris Lytochkin --SKIPIF-- @@ -19,29 +19,29 @@ echo "SNMP::ERRNO_NOERROR\n"; $session = new SNMP(SNMP_VERSION_2c, $hostname, $community, $timeout, $retries); var_dump(@$session->get('.1.3.6.1.2.1.1.1.0')); -var_dump($session->get_errno() == SNMP::ERRNO_NOERROR); -var_dump($session->get_error()); +var_dump($session->getErrno() == SNMP::ERRNO_NOERROR); +var_dump($session->getError()); $session->close(); echo "SNMP::ERRNO_TIMEOUT\n"; $session = new SNMP(SNMP_VERSION_2c, $hostname, 'timeout_community_432', $timeout, $retries); $session->valueretrieval = SNMP_VALUE_LIBRARY; var_dump(@$session->get('.1.3.6.1.2.1.1.1.0')); -var_dump($session->get_errno() == SNMP::ERRNO_TIMEOUT); -var_dump($session->get_error()); +var_dump($session->getErrno() == SNMP::ERRNO_TIMEOUT); +var_dump($session->getError()); $session->close(); echo "SNMP::ERRNO_ERROR_IN_REPLY\n"; $session = new SNMP(SNMP_VERSION_2c, $hostname, $community, $timeout, $retries); var_dump(@$session->get('.1.3.6.1.2.1.1.1.110')); -var_dump($session->get_errno() == SNMP::ERRNO_ERROR_IN_REPLY); -var_dump($session->get_error()); +var_dump($session->getErrno() == SNMP::ERRNO_ERROR_IN_REPLY); +var_dump($session->getError()); $session->close(); echo "SNMP::ERRNO_GENERIC\n"; $session = new SNMP(SNMP_VERSION_3, $hostname, 'somebogususer', $timeout, $retries); $session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass); var_dump(@$session->get('.1.3.6.1.2.1.1.1.0')); -var_dump($session->get_errno() == SNMP::ERRNO_GENERIC); -var_dump($session->get_error()); +var_dump($session->getErrno() == SNMP::ERRNO_GENERIC); +var_dump($session->getError()); $session->close(); ?> --EXPECTF-- -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ config.m4 snmp.c tests/snmp-object-errno-errstr.phpt tests/wrong_hostname.phpt
lytboris Tue, 10 May 2011 20:04:26 + Revision: http://svn.php.net/viewvc?view=revision&revision=310936 Log: fixed typos in tests ucd-snmp epoch is over, drop legacy memory allocation (non e*) tune 'buggy snmp_snprint_value' detection on some systems Changed paths: U php/php-src/trunk/ext/snmp/config.m4 U php/php-src/trunk/ext/snmp/snmp.c U php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt U php/php-src/trunk/ext/snmp/tests/wrong_hostname.phpt Modified: php/php-src/trunk/ext/snmp/config.m4 === --- php/php-src/trunk/ext/snmp/config.m42011-05-10 19:59:07 UTC (rev 310935) +++ php/php-src/trunk/ext/snmp/config.m42011-05-10 20:04:26 UTC (rev 310936) @@ -62,7 +62,7 @@ dnl Check for buggy snmp_snprint_value() (net-snmp BUGid 2027834) AC_CACHE_CHECK([for buggy snmp_snprint_value], ac_cv_buggy_snprint_value,[ save_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -I${SNMP_PREFIX}/include" +CFLAGS="$CFLAGS -I${SNMP_PREFIX}/include $SNMP_SHARED_LIBADD" AC_TRY_RUN( [ #include #include Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-05-10 19:59:07 UTC (rev 310935) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-05-10 20:04:26 UTC (rev 310936) @@ -440,12 +440,20 @@ } /* }}} */ +#define PHP_SNMP_SESSION_FREE(a) { \ + if ((*session)->a) { \ + efree((*session)->a); \ + (*session)->a = NULL; \ + } \ +} + static void netsnmp_session_free(php_snmp_session **session) { if (*session) { - if ((*session)->peername) { - efree((*session)->peername); - } + PHP_SNMP_SESSION_FREE(peername); + PHP_SNMP_SESSION_FREE(community); + PHP_SNMP_SESSION_FREE(securityName); + PHP_SNMP_SESSION_FREE(contextEngineID); efree(*session); *session = NULL; } @@ -1115,11 +1123,11 @@ if (version == SNMP_VERSION_3) { /* Setting the security name. */ - session->securityName = strdup(community); + session->securityName = estrdup(community); session->securityNameLen = strlen(session->securityName); } else { session->authenticator = NULL; - session->community = (u_char *)community; + session->community = (u_char *)estrdup(community); session->community_len = strlen(community); } @@ -1222,7 +1230,7 @@ static int netsnmp_session_set_contextEngineID(struct snmp_session *s, char * contextEngineID TSRMLS_DC) { size_t ebuf_len = 32, eout_len = 0; - u_char *ebuf = (u_char *) malloc(ebuf_len); /* memory freed by SNMP library, malloc NOT emalloc */ + u_char *ebuf = (u_char *) emalloc(ebuf_len); if (ebuf == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "malloc failure setting contextEngineID"); @@ -1230,12 +1238,12 @@ } if (!snmp_hex_to_binary(&ebuf, &ebuf_len, &eout_len, 1, contextEngineID)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad engine ID value '%s'", contextEngineID); - free(ebuf); + efree(ebuf); return (-1); } if (s->contextEngineID) { - free(s->contextEngineID); + efree(s->contextEngineID); } s->contextEngineID = ebuf; Modified: php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt === --- php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt 2011-05-10 19:59:07 UTC (rev 310935) +++ php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt 2011-05-10 20:04:26 UTC (rev 310936) @@ -1,5 +1,5 @@ --TEST-- -OO API: getErrno & getError functions +OO API: getErrno & getError methods --CREDITS-- Boris Lytochkin --SKIPIF-- Modified: php/php-src/trunk/ext/snmp/tests/wrong_hostname.phpt === --- php/php-src/trunk/ext/snmp/tests/wrong_hostname.phpt2011-05-10 19:59:07 UTC (rev 310935) +++ php/php-src/trunk/ext/snmp/tests/wrong_hostname.phpt 2011-05-10 20:04:26 UTC (rev 310936) @@ -1,5 +1,5 @@ --TEST-- -Generic timeout (wrong community) +Wrong hostname --CREDITS-- Boris Lytochkin --SKIPIF-- -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ php_snmp.h
lytboris Sun, 12 Jun 2011 10:07:43 + Revision: http://svn.php.net/viewvc?view=revision&revision=312088 Log: fix method names in header Changed paths: U php/php-src/trunk/ext/snmp/php_snmp.h Modified: php/php-src/trunk/ext/snmp/php_snmp.h === --- php/php-src/trunk/ext/snmp/php_snmp.h 2011-06-12 09:08:17 UTC (rev 312087) +++ php/php-src/trunk/ext/snmp/php_snmp.h 2011-06-12 10:07:43 UTC (rev 312088) @@ -82,8 +82,8 @@ PHP_METHOD(SNMP, getnext); PHP_METHOD(SNMP, walk); PHP_METHOD(SNMP, set); -PHP_METHOD(SNMP, get_errno); -PHP_METHOD(SNMP, get_error); +PHP_METHOD(SNMP, getErrno); +PHP_METHOD(SNMP, getError); typedef struct _php_snmp_object { zend_object zo; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ php_snmp.h
lytboris Sun, 12 Jun 2011 10:13:30 + Revision: http://svn.php.net/viewvc?view=revision&revision=312089 Log: no more method open Changed paths: U php/php-src/trunk/ext/snmp/php_snmp.h Modified: php/php-src/trunk/ext/snmp/php_snmp.h === --- php/php-src/trunk/ext/snmp/php_snmp.h 2011-06-12 10:07:43 UTC (rev 312088) +++ php/php-src/trunk/ext/snmp/php_snmp.h 2011-06-12 10:13:30 UTC (rev 312089) @@ -75,7 +75,6 @@ PHP_FUNCTION(snmp_read_mib); -PHP_METHOD(SNMP, open); PHP_METHOD(SNMP, setSecurity); PHP_METHOD(SNMP, close); PHP_METHOD(SNMP, get); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c
lytboris Sun, 12 Jun 2011 11:25:20 + Revision: http://svn.php.net/viewvc?view=revision&revision=312090 Log: fix typo in comment Changed paths: U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-06-12 10:13:30 UTC (rev 312089) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-06-12 11:25:20 UTC (rev 312090) @@ -1809,7 +1809,7 @@ php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_SET, (-1)); } -/* {{{ proto bool SNMP::setSecurity(resource session, string sec_level, [ string auth_protocol, string auth_passphrase [, string priv_protocol, string priv_passphrase [, string contextName [, string contextEngineID) +/* {{{ proto bool SNMP::setSecurity(string sec_level, [ string auth_protocol, string auth_passphrase [, string priv_protocol, string priv_passphrase [, string contextName [, string contextEngineID) Set SNMPv3 security-related session parameters */ PHP_METHOD(snmp, setSecurity) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c tests/snmp-object-errno-errstr.phpt tests/snmp-object-error.phpt tests/snmp-object-properties.phpt tests/snmp-object-setSecurity_error.phpt tests/snm
lytboris Sun, 12 Jun 2011 11:58:49 + Revision: http://svn.php.net/viewvc?view=revision&revision=312092 Log: move SNMP VERSION constants into SNMP class itself Changed paths: U php/php-src/trunk/ext/snmp/snmp.c U php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt U php/php-src/trunk/ext/snmp/tests/snmp-object-error.phpt U php/php-src/trunk/ext/snmp/tests/snmp-object-properties.phpt U php/php-src/trunk/ext/snmp/tests/snmp-object-setSecurity_error.phpt U php/php-src/trunk/ext/snmp/tests/snmp-object.phpt Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-06-12 11:31:01 UTC (rev 312091) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-06-12 11:58:49 UTC (rev 312092) @@ -2385,10 +2385,10 @@ REGISTER_LONG_CONSTANT("SNMP_INTEGER", ASN_INTEGER, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SNMP_COUNTER64", ASN_COUNTER64, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_VERSION_1", SNMP_VERSION_1, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_VERSION_2c", SNMP_VERSION_2c, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_VERSION_2C", SNMP_VERSION_2c, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_VERSION_3", SNMP_VERSION_3, CONST_CS | CONST_PERSISTENT); + REGISTER_SNMP_CLASS_CONST_LONG("VERSION_1", (long)SNMP_VERSION_1); + REGISTER_SNMP_CLASS_CONST_LONG("VERSION_2c", (long)SNMP_VERSION_2c); + REGISTER_SNMP_CLASS_CONST_LONG("VERSION_2C", (long)SNMP_VERSION_2c); + REGISTER_SNMP_CLASS_CONST_LONG("VERSION_3", (long)SNMP_VERSION_3); REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_NOERROR", (long)PHP_SNMP_ERRNO_NOERROR); REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_GENERIC", (long)PHP_SNMP_ERRNO_GENERIC); Modified: php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt === --- php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt 2011-06-12 11:31:01 UTC (rev 312091) +++ php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt 2011-06-12 11:58:49 UTC (rev 312092) @@ -17,27 +17,27 @@ snmp_set_oid_output_format(SNMP_OID_OUTPUT_FULL); echo "SNMP::ERRNO_NOERROR\n"; -$session = new SNMP(SNMP_VERSION_2c, $hostname, $community, $timeout, $retries); +$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries); var_dump(@$session->get('.1.3.6.1.2.1.1.1.0')); var_dump($session->getErrno() == SNMP::ERRNO_NOERROR); var_dump($session->getError()); $session->close(); echo "SNMP::ERRNO_TIMEOUT\n"; -$session = new SNMP(SNMP_VERSION_2c, $hostname, 'timeout_community_432', $timeout, $retries); +$session = new SNMP(SNMP::VERSION_2c, $hostname, 'timeout_community_432', $timeout, $retries); $session->valueretrieval = SNMP_VALUE_LIBRARY; var_dump(@$session->get('.1.3.6.1.2.1.1.1.0')); var_dump($session->getErrno() == SNMP::ERRNO_TIMEOUT); var_dump($session->getError()); $session->close(); echo "SNMP::ERRNO_ERROR_IN_REPLY\n"; -$session = new SNMP(SNMP_VERSION_2c, $hostname, $community, $timeout, $retries); +$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries); var_dump(@$session->get('.1.3.6.1.2.1.1.1.110')); var_dump($session->getErrno() == SNMP::ERRNO_ERROR_IN_REPLY); var_dump($session->getError()); $session->close(); echo "SNMP::ERRNO_GENERIC\n"; -$session = new SNMP(SNMP_VERSION_3, $hostname, 'somebogususer', $timeout, $retries); +$session = new SNMP(SNMP::VERSION_3, $hostname, 'somebogususer', $timeout, $retries); $session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass); var_dump(@$session->get('.1.3.6.1.2.1.1.1.0')); var_dump($session->getErrno() == SNMP::ERRNO_GENERIC); Modified: php/php-src/trunk/ext/snmp/tests/snmp-object-error.phpt === --- php/php-src/trunk/ext/snmp/tests/snmp-object-error.phpt 2011-06-12 11:31:01 UTC (rev 312091) +++ php/php-src/trunk/ext/snmp/tests/snmp-object-error.phpt 2011-06-12 11:58:49 UTC (rev 312092) @@ -15,17 +15,17 @@ snmp_set_valueretrieval(SNMP_VALUE_PLAIN); try { -var_dump(new SNMP(SNMP_VERSION_1, $hostname)); +var_dump(new SNMP(SNMP::VERSION_1, $hostname)); } catch (Exception $e) { print $e->getMessage() . "\n"; } try { -var_dump(new SNMP(SNMP_VERSION_1, $hostname, $community, '')); +var_dump(new SNMP(SNMP::VERSION_1, $hostname, $community, '')); } catch (Exception $e) { print $e->getMessage() . "\n"; } try { -var_dump(new SNMP(SNMP_VERSION_1, $hostname, $community, $timeout, '')); +var_dump(new SNMP(SNMP::VERSION_1, $hostname, $community, $timeout, '')); } catch (Exception $e) { print $e->getMessage() . "\n"; } @@ -36,7 +36,7 @@ } echo "Open normal session\n"; -$session = new SNMP(SNMP_VERSION_3, $hostname, $user_noauth, $timeout, $retries); +$session = new SNMP(SNMP::VERSION_3, $hostname,
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/snmp/ php_snmp.h snmp.c tests/snmp-object-errno-errstr.phpt tests/snmp-object-error.phpt tests/snmp-object-properties.phpt tests/snmp-object-setSecurit
lytboris Sun, 12 Jun 2011 12:10:01 + Revision: http://svn.php.net/viewvc?view=revision&revision=312093 Log: merging from trunk (r312088...r312092): move SNMP VERSION constants into SNMP class itself fix typo in comment no more method open fix method names in header Changed paths: _U php/php-src/branches/PHP_5_4/ext/snmp/ U php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h U php/php-src/branches/PHP_5_4/ext/snmp/snmp.c U php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-errno-errstr.phpt U php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-error.phpt U php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-properties.phpt U php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-setSecurity_error.phpt U php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object.phpt Property changes on: php/php-src/branches/PHP_5_4/ext/snmp ___ Added: svn:mergeinfo + /php/php-src/trunk/ext/snmp:284726,311033-312092 Modified: php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h === --- php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h 2011-06-12 11:58:49 UTC (rev 312092) +++ php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h 2011-06-12 12:10:01 UTC (rev 312093) @@ -75,15 +75,14 @@ PHP_FUNCTION(snmp_read_mib); -PHP_METHOD(SNMP, open); PHP_METHOD(SNMP, setSecurity); PHP_METHOD(SNMP, close); PHP_METHOD(SNMP, get); PHP_METHOD(SNMP, getnext); PHP_METHOD(SNMP, walk); PHP_METHOD(SNMP, set); -PHP_METHOD(SNMP, get_errno); -PHP_METHOD(SNMP, get_error); +PHP_METHOD(SNMP, getErrno); +PHP_METHOD(SNMP, getError); typedef struct _php_snmp_object { zend_object zo; Modified: php/php-src/branches/PHP_5_4/ext/snmp/snmp.c === --- php/php-src/branches/PHP_5_4/ext/snmp/snmp.c 2011-06-12 11:58:49 UTC (rev 312092) +++ php/php-src/branches/PHP_5_4/ext/snmp/snmp.c 2011-06-12 12:10:01 UTC (rev 312093) @@ -1809,7 +1809,7 @@ php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_SET, (-1)); } -/* {{{ proto bool SNMP::setSecurity(resource session, string sec_level, [ string auth_protocol, string auth_passphrase [, string priv_protocol, string priv_passphrase [, string contextName [, string contextEngineID) +/* {{{ proto bool SNMP::setSecurity(string sec_level, [ string auth_protocol, string auth_passphrase [, string priv_protocol, string priv_passphrase [, string contextName [, string contextEngineID) Set SNMPv3 security-related session parameters */ PHP_METHOD(snmp, setSecurity) { @@ -2385,10 +2385,10 @@ REGISTER_LONG_CONSTANT("SNMP_INTEGER", ASN_INTEGER, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SNMP_COUNTER64", ASN_COUNTER64, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_VERSION_1", SNMP_VERSION_1, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_VERSION_2c", SNMP_VERSION_2c, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_VERSION_2C", SNMP_VERSION_2c, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_VERSION_3", SNMP_VERSION_3, CONST_CS | CONST_PERSISTENT); + REGISTER_SNMP_CLASS_CONST_LONG("VERSION_1", (long)SNMP_VERSION_1); + REGISTER_SNMP_CLASS_CONST_LONG("VERSION_2c", (long)SNMP_VERSION_2c); + REGISTER_SNMP_CLASS_CONST_LONG("VERSION_2C", (long)SNMP_VERSION_2c); + REGISTER_SNMP_CLASS_CONST_LONG("VERSION_3", (long)SNMP_VERSION_3); REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_NOERROR", (long)PHP_SNMP_ERRNO_NOERROR); REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_GENERIC", (long)PHP_SNMP_ERRNO_GENERIC); Modified: php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-errno-errstr.phpt === --- php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-errno-errstr.phpt 2011-06-12 11:58:49 UTC (rev 312092) +++ php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-errno-errstr.phpt 2011-06-12 12:10:01 UTC (rev 312093) @@ -17,27 +17,27 @@ snmp_set_oid_output_format(SNMP_OID_OUTPUT_FULL); echo "SNMP::ERRNO_NOERROR\n"; -$session = new SNMP(SNMP_VERSION_2c, $hostname, $community, $timeout, $retries); +$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries); var_dump(@$session->get('.1.3.6.1.2.1.1.1.0')); var_dump($session->getErrno() == SNMP::ERRNO_NOERROR); var_dump($session->getError()); $session->close(); echo "SNMP::ERRNO_TIMEOUT\n"; -$session = new SNMP(SNMP_VERSION_2c, $hostname, 'timeout_community_432', $timeout, $retries); +$session = new SNMP(SNMP::VERSION_2c, $hostname, 'timeout_community_432', $timeout, $retries); $session->valueretrieval = SNMP_VALUE_LIBRARY; var_dump(@$session->get('.1.3.6.1.2.1.1.1.0')); var_dump($session->getErrno() == SNMP::ERRNO_TIMEOUT); var_dump($session->getError()); $session->close(); echo "SNMP::ERRNO_ERROR_IN_REPLY\n"; -$session = new SN
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/snmp/ snmp.c
lytboris Sun, 12 Jun 2011 12:26:51 + Revision: http://svn.php.net/viewvc?view=revision&revision=312094 Log: remove PHP_VERSION_ID ifdef's, limiting to 5.4 branch Changed paths: U php/php-src/branches/PHP_5_4/ext/snmp/snmp.c Modified: php/php-src/branches/PHP_5_4/ext/snmp/snmp.c === --- php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2011-06-12 12:10:01 UTC (rev 312093) +++ php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2011-06-12 12:26:51 UTC (rev 312094) @@ -75,14 +75,6 @@ #include #include -#if PHP_VERSION_ID < 50300 -#define Z_ADDREF_P(pz) pz->refcount++ -#define Z_ISREF_PP(oid) (PZVAL_IS_REF(*(oid))) -#define Z_REFCOUNT_P(pz) pz->refcount -#define Z_SET_REFCOUNT_P(pz, rc) pz->refcount = rc -#define zend_parse_parameters_none() zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") -#endif - /* For net-snmp prior to 5.4 */ #ifndef HAVE_SHUTDOWN_SNMP_LOGGING extern netsnmp_log_handler *logh_head; @@ -482,9 +474,6 @@ static zend_object_value php_snmp_object_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ { -#if PHP_VERSION_ID < 50399 - zval *tmp; -#endif zend_object_value retval; php_snmp_object *intern; @@ -493,11 +482,7 @@ memset(&intern->zo, 0, sizeof(php_snmp_object)); zend_object_std_init(&intern->zo, class_type TSRMLS_CC); -#if PHP_VERSION_ID < 50399 - zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref,(void *) &tmp, sizeof(zval *)); -#else object_properties_init(&intern->zo, class_type); -#endif retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) php_snmp_object_free_storage, NULL TSRMLS_CC); retval.handlers = (zend_object_handlers *) &php_snmp_object_handlers; @@ -1707,31 +1692,17 @@ long retries = SNMP_DEFAULT_RETRIES; long version = SNMP_DEFAULT_VERSION; int argc = ZEND_NUM_ARGS(); -#if PHP_VERSION_ID > 50300 zend_error_handling error_handling; -#endif snmp_object = (php_snmp_object *)zend_object_store_get_object(object TSRMLS_CC); -#if PHP_VERSION_ID > 50300 zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC); -#else - php_set_error_handling(EH_THROW, zend_exception_get_default(TSRMLS_C) TSRMLS_CC); -#endif if (zend_parse_parameters(argc TSRMLS_CC, "lss|ll", &version, &a1, &a1_len, &a2, &a2_len, &timeout, &retries) == FAILURE) { -#if PHP_VERSION_ID > 50300 zend_restore_error_handling(&error_handling TSRMLS_CC); -#else - php_std_error_handling(); -#endif return; } -#if PHP_VERSION_ID > 50300 zend_restore_error_handling(&error_handling TSRMLS_CC); -#else - php_std_error_handling(); -#endif switch(version) { case SNMP_VERSION_1: @@ -1877,11 +1848,7 @@ /* {{{ php_snmp_read_property(zval *object, zval *member, int type[, const zend_literal *key]) Generic object property reader */ -#if PHP_VERSION_ID < 50399 -zval *php_snmp_read_property(zval *object, zval *member, int type TSRMLS_DC) -#else zval *php_snmp_read_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC) -#endif { zval tmp_member; zval *retval; @@ -1911,11 +1878,7 @@ } } else { zend_object_handlers * std_hnd = zend_get_std_object_handlers(); -#if PHP_VERSION_ID < 50399 - retval = std_hnd->read_property(object, member, type TSRMLS_CC); -#else retval = std_hnd->read_property(object, member, type, key TSRMLS_CC); -#endif } if (member == &tmp_member) { @@ -1927,11 +1890,7 @@ /* {{{ php_snmp_write_property(zval *object, zval *member, zval *value[, const zend_literal *key]) Generic object property writer */ -#if PHP_VERSION_ID < 50399 -void php_snmp_write_property(zval *object, zval *member, zval *value TSRMLS_DC) -#else void php_snmp_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC) -#endif { zval tmp_member; php_snmp_object *obj; @@ -1958,11 +1917,7 @@ } } else { zend_object_handlers * std_hnd = zend_get_std_object_handlers(); -#if PHP_VERSION_ID < 50399 - std_hnd->write_property(object, member, value TSRMLS_CC); -#else std_hnd->write_property(object, member, value, key TSRMLS_CC); -#endif } if (member == &tmp_member) { @@ -1973,11 +1928,7 @@ /* {{{ php_snmp_has_property(zval *object, zval *member, int has_set_exists[, const zend_literal *key]) Generic object property checker */ -#if PHP_VERSION_ID < 50399 -static int php_snmp_has_property(zval *object, zval *member, int has_set_exists TSRMLS_DC) -#else static int php_snmp
[PHP-CVS] svn: /php/php-src/trunk/ NEWS
lytboris Fri, 17 Jun 2011 18:18:21 + Revision: http://svn.php.net/viewvc?view=revision&revision=312237 Log: expand SNMP section Changed paths: U php/php-src/trunk/NEWS Modified: php/php-src/trunk/NEWS === --- php/php-src/trunk/NEWS 2011-06-17 18:15:30 UTC (rev 312236) +++ php/php-src/trunk/NEWS 2011-06-17 18:18:21 UTC (rev 312237) @@ -206,14 +206,19 @@ - Improved ZLIB extension: . Re-implemented non-file related functionality. (Mike) -- Improved SNMP extension: - . Added OO API. FR #53594. +- Improved SNMP extension (Boris Lytochkin): + . Added OO API. FR #53594 (php-snmp rewrite). . Sanitized return values of existing functions. Now it returns FALSE on failure. . Allow ~infinite OIDs in GET/GETNEXT/SET queries. Autochunk them to max_oids upon request. . Introducing unit tests for extension with ~full coverage. - . Fixed bugs #44193, #44193, #45893, #46065, #51336, #53862. + . Fixed bugs +. #44193 (snmp v3 noAuthNoPriv doesn't work) +. #45893 (Snmp buffer limited to 2048 char) +. #46065 (snmp_set_quick_print() persists between requests) +. #51336 (snmprealwalk (snmp v1) does not handle end of OID tree correctly) +. #53862 (snmp_set_oid_output_format does not allow returning to default) ## UNSORTED ## -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ NEWS
lytboris Fri, 17 Jun 2011 18:26:54 + Revision: http://svn.php.net/viewvc?view=revision&revision=312240 Log: expand SNMP section Changed paths: U php/php-src/branches/PHP_5_4/NEWS Modified: php/php-src/branches/PHP_5_4/NEWS === --- php/php-src/branches/PHP_5_4/NEWS 2011-06-17 18:24:56 UTC (rev 312239) +++ php/php-src/branches/PHP_5_4/NEWS 2011-06-17 18:26:54 UTC (rev 312240) @@ -212,14 +212,19 @@ - Improved ZLIB extension: . Re-implemented non-file related functionality. (Mike) -- Improved SNMP extension: - . Added OO API. FR #53594. +- Improved SNMP extension (Boris Lytochkin): + . Added OO API. FR #53594 (php-snmp rewrite). . Sanitized return values of existing functions. Now it returns FALSE on failure. . Allow ~infinite OIDs in GET/GETNEXT/SET queries. Autochunk them to max_oids upon request. . Introducing unit tests for extension with ~full coverage. - . Fixed bugs #44193, #44193, #45893, #46065, #51336, #53862. + . Fixed bugs +. #44193 (snmp v3 noAuthNoPriv doesn't work) +. #45893 (Snmp buffer limited to 2048 char) +. #46065 (snmp_set_quick_print() persists between requests) +. #51336 (snmprealwalk (snmp v1) does not handle end of OID tree correctly) +. #53862 (snmp_set_oid_output_format does not allow returning to default) ## UNSORTED ## -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ EXTENSIONS
lytboris Sat, 18 Jun 2011 07:09:11 + Revision: http://svn.php.net/viewvc?view=revision&revision=312251 Log: take over mantainership on snmp extension Changed paths: U php/php-src/trunk/EXTENSIONS Modified: php/php-src/trunk/EXTENSIONS === --- php/php-src/trunk/EXTENSIONS2011-06-18 02:24:01 UTC (rev 312250) +++ php/php-src/trunk/EXTENSIONS2011-06-18 07:09:11 UTC (rev 312251) @@ -497,8 +497,8 @@ SINCE: 4.0.3 --- EXTENSION: snmp -PRIMARY MAINTAINER: Rasmus Lerdorf , Pierre-Alain Joye -MAINTENANCE: Odd Fixes +PRIMARY MAINTAINER: Boris Lytochkin , Rasmus Lerdorf , Pierre-Alain Joye +MAINTENANCE: Maintained STATUS: Working --- EXTENSION: sockets -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ EXTENSIONS
lytboris Sat, 18 Jun 2011 07:12:35 + Revision: http://svn.php.net/viewvc?view=revision&revision=312252 Log: take over mantainership on snmp extension Changed paths: U php/php-src/branches/PHP_5_4/EXTENSIONS Modified: php/php-src/branches/PHP_5_4/EXTENSIONS === --- php/php-src/branches/PHP_5_4/EXTENSIONS 2011-06-18 07:09:11 UTC (rev 312251) +++ php/php-src/branches/PHP_5_4/EXTENSIONS 2011-06-18 07:12:35 UTC (rev 312252) @@ -497,8 +497,8 @@ SINCE: 4.0.3 --- EXTENSION: snmp -PRIMARY MAINTAINER: Rasmus Lerdorf , Pierre-Alain Joye -MAINTENANCE: Odd Fixes +PRIMARY MAINTAINER: Boris Lytochkin , Rasmus Lerdorf , Pierre-Alain Joye +MAINTENANCE: Maintained STATUS: Working --- EXTENSION: sockets -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c
lytboris Sun, 17 Jul 2011 13:57:28 + Revision: http://svn.php.net/viewvc?view=revision&revision=313324 Log: update ARG_INFO_EX for walk and get methods, fix comments Changed paths: U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-07-17 11:41:57 UTC (rev 313323) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-07-17 13:57:28 UTC (rev 313324) @@ -347,10 +347,12 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp_get, 0, 0, 1) ZEND_ARG_INFO(0, object_id) + ZEND_ARG_INFO(0, use_orignames) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp_walk, 0, 0, 3) +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp_walk, 0, 0, 4) ZEND_ARG_INFO(0, object_id) + ZEND_ARG_INFO(0, suffix_keys) ZEND_ARG_INFO(0, non_repeaters) ZEND_ARG_INFO(0, max_repetitions) ZEND_END_ARG_INFO() @@ -1778,7 +1780,7 @@ } /* }}} */ -/* {{{ proto mixed SNMP::get_assoc(mixed object_id) +/* {{{ proto mixed SNMP::get(mixed object_id [, bool preserve_keys]) Fetch a SNMP object returing scalar for single OID and array of oid->value pairs for multi OID request */ PHP_METHOD(snmp, get) { @@ -1786,7 +1788,7 @@ } /* }}} */ -/* {{{ proto mixed SNMP::getnext(mixed object_id) +/* {{{ proto mixed SNMP::getnext(mixed object_id) Fetch a SNMP object returing scalar for single OID and array of oid->value pairs for multi OID request */ PHP_METHOD(snmp, getnext) { @@ -1794,7 +1796,7 @@ } /* }}} */ -/* {{{ proto mixed SNMP::walk(mixed object_id) +/* {{{ proto mixed SNMP::walk(mixed object_id [, bool $suffix_as_key = FALSE [, int $non_repeaters [, int $max_repetitions ]]]) Return all objects including their respective object id withing the specified one as array of oid->value pairs */ PHP_METHOD(snmp, walk) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/snmp/ snmp.c
lytboris Sun, 17 Jul 2011 14:06:05 + Revision: http://svn.php.net/viewvc?view=revision&revision=313325 Log: backport r313324 Changed paths: _U php/php-src/branches/PHP_5_4/ext/snmp/ U php/php-src/branches/PHP_5_4/ext/snmp/snmp.c Property changes on: php/php-src/branches/PHP_5_4/ext/snmp ___ Modified: svn:mergeinfo - /php/php-src/trunk/ext/snmp:284726,311033-312092 + /php/php-src/trunk/ext/snmp:284726,311033-313324 Modified: php/php-src/branches/PHP_5_4/ext/snmp/snmp.c === --- php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2011-07-17 13:57:28 UTC (rev 313324) +++ php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2011-07-17 14:06:05 UTC (rev 313325) @@ -339,10 +339,12 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp_get, 0, 0, 1) ZEND_ARG_INFO(0, object_id) + ZEND_ARG_INFO(0, use_orignames) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp_walk, 0, 0, 3) +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp_walk, 0, 0, 4) ZEND_ARG_INFO(0, object_id) + ZEND_ARG_INFO(0, suffix_keys) ZEND_ARG_INFO(0, non_repeaters) ZEND_ARG_INFO(0, max_repetitions) ZEND_END_ARG_INFO() @@ -1749,7 +1751,7 @@ } /* }}} */ -/* {{{ proto mixed SNMP::get_assoc(mixed object_id) +/* {{{ proto mixed SNMP::get(mixed object_id [, bool preserve_keys]) Fetch a SNMP object returing scalar for single OID and array of oid->value pairs for multi OID request */ PHP_METHOD(snmp, get) { @@ -1757,7 +1759,7 @@ } /* }}} */ -/* {{{ proto mixed SNMP::getnext(mixed object_id) +/* {{{ proto mixed SNMP::getnext(mixed object_id) Fetch a SNMP object returing scalar for single OID and array of oid->value pairs for multi OID request */ PHP_METHOD(snmp, getnext) { @@ -1765,7 +1767,7 @@ } /* }}} */ -/* {{{ proto mixed SNMP::walk(mixed object_id) +/* {{{ proto mixed SNMP::walk(mixed object_id [, bool $suffix_as_key = FALSE [, int $non_repeaters [, int $max_repetitions ]]]) Return all objects including their respective object id withing the specified one as array of oid->value pairs */ PHP_METHOD(snmp, walk) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ NEWS UPGRADING ext/snmp/snmp.c ext/snmp/tests/snmp_get_valueretrieval.phpt ext/snmp/tests/snmp_getvalue.phpt
lytboris Sun, 17 Jul 2011 17:18:31 + Revision: http://svn.php.net/viewvc?view=revision&revision=313331 Log: fix FR #54502: allow user to change OID value output mode when SNMP_VALUE_OBJECT is used. Bug: https://bugs.php.net/54502 (Assigned) Add support for the "BITS" datatype Changed paths: U php/php-src/branches/PHP_5_4/NEWS U php/php-src/branches/PHP_5_4/UPGRADING U php/php-src/branches/PHP_5_4/ext/snmp/snmp.c U php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp_get_valueretrieval.phpt U php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp_getvalue.phpt Modified: php/php-src/branches/PHP_5_4/NEWS === --- php/php-src/branches/PHP_5_4/NEWS 2011-07-17 15:42:44 UTC (rev 313330) +++ php/php-src/branches/PHP_5_4/NEWS 2011-07-17 17:18:31 UTC (rev 313331) @@ -259,6 +259,9 @@ . Allow ~infinite OIDs in GET/GETNEXT/SET queries. Autochunk them to max_oids upon request. . Introducing unit tests for extension with ~full coverage. + . Way of representing OID value can now be changed when SNMP_VALUE_OBJECT +is used for value output mode. Use or'ed SNMP_VALUE_LIBRARY(default if +not specified) or SNMP_VALUE_PLAIN. (FR #54502) . Fixed bugs . #44193 (snmp v3 noAuthNoPriv doesn't work) . #45893 (Snmp buffer limited to 2048 char) Modified: php/php-src/branches/PHP_5_4/UPGRADING === --- php/php-src/branches/PHP_5_4/UPGRADING 2011-07-17 15:42:44 UTC (rev 313330) +++ php/php-src/branches/PHP_5_4/UPGRADING 2011-07-17 17:18:31 UTC (rev 313331) @@ -285,6 +285,13 @@ - Multi OID get/getnext/set queries are now supported. - New constants added for use in snmp_set_oid_output_format() function. + - Function snmp_set_valueretrieval() changed it's behaviour: +SNMP_VALUE_OBJECT can be combined with one of +SNMP_VALUE_PLAIN or SNMP_VALUE_LIBRARY resulting OID value +changes. When no SNMP_VALUE_PLAIN or SNMP_VALUE_LIBRARY +is supplied with SNMP_VALUE_OBJECT, SNMP_VALUE_LIBRARY is used. +Prior to 5.4.0 when no SNMP_VALUE_PLAIN or SNMP_VALUE_LIBRARY +was supplied with SNMP_VALUE_OBJECT, SNMP_VALUE_PLAIN was used. - Added feature-rich OO API (SNMP class) - Dropped UCD-SNMP compatibility code. Consider upgrading to net-snmp v5.3+. Net-SNMP v5.4+ is required for Windows version. Modified: php/php-src/branches/PHP_5_4/ext/snmp/snmp.c === --- php/php-src/branches/PHP_5_4/ext/snmp/snmp.c 2011-07-17 15:42:44 UTC (rev 313330) +++ php/php-src/branches/PHP_5_4/ext/snmp/snmp.c 2011-07-17 17:18:31 UTC (rev 313331) @@ -86,9 +86,9 @@ } #endif -#define SNMP_VALUE_LIBRARY 0 -#define SNMP_VALUE_PLAIN 1 -#define SNMP_VALUE_OBJECT 2 +#define SNMP_VALUE_LIBRARY (0 << 0) +#define SNMP_VALUE_PLAIN (1 << 0) +#define SNMP_VALUE_OBJECT (1 << 1) typedef struct snmp_session php_snmp_session; #define PHP_SNMP_SESSION_RES_NAME "SNMP session" @@ -544,7 +544,7 @@ int buflen = sizeof(sbuf) - 1; int val_len = vars->val_len; - if (valueretrieval == SNMP_VALUE_LIBRARY) { + if ((valueretrieval & SNMP_VALUE_PLAIN) == 0) { val_len += 32; /* snprint_value will add type info into value, make some space for it */ } @@ -560,96 +560,92 @@ *buf = 0; - if (valueretrieval == SNMP_VALUE_LIBRARY) { - snprint_value(buf, buflen, vars->name, vars->name_length, vars); - ZVAL_STRING(snmpval, buf, 1); - if(dbuf){ /* malloc was used to store value */ - efree(dbuf); - } - return; - } - MAKE_STD_ZVAL(val); - switch (vars->type) { - case ASN_BIT_STR: /* 0x03, asn1.h */ - ZVAL_STRINGL(val, (char *)vars->val.bitstring, vars->val_len, 1); - break; + if (valueretrieval & SNMP_VALUE_PLAIN) { + switch (vars->type) { + case ASN_BIT_STR: /* 0x03, asn1.h */ + ZVAL_STRINGL(val, (char *)vars->val.bitstring, vars->val_len, 1); + break; - case ASN_OCTET_STR: /* 0x04, asn1.h */ - case ASN_OPAQUE: /* 0x44, snmp_impl.h */ - ZVAL_STRINGL(val, (char *)vars->val.string, vars->val_len, 1); - break; + case ASN_OCTET_STR: /* 0x04, asn1.h */ + case ASN_OPAQUE: /* 0x44, snmp_impl.h */ + ZVAL_STRINGL(val, (char *)vars->val.string, vars->val_len, 1); + break; - case ASN_NULL: /* 0x05, asn1.h */ - ZVAL_NULL(val); - break; + case ASN_NULL: /* 0x05, asn1.h */ + ZVAL_NULL(val); + break; - case ASN_OBJECT_ID: /* 0x06, asn1.h */ - snprint_objid(buf, buflen, vars->val.objid, vars->val_len / sizeof(oid)); - ZVAL_STRING(val, buf, 1); - break; + case ASN_OBJECT_ID: /* 0x06, asn1.h */ + snprint_objid(buf, buflen, vars->val.objid, vars->val_len / sizeof(oid)); + ZVAL_STRING(val, buf, 1); + break; - case ASN_IPADDRESS: /* 0x40, snmp_impl.h */ - sn
[PHP-CVS] svn: /php/php-src/trunk/ NEWS UPGRADING ext/snmp/snmp.c ext/snmp/tests/snmp_get_valueretrieval.phpt ext/snmp/tests/snmp_getvalue.phpt
lytboris Sun, 17 Jul 2011 17:27:00 + Revision: http://svn.php.net/viewvc?view=revision&revision=31 Log: fix FR #54502: allow user to change OID value output mode when SNMP_VALUE_OBJECT is used. Bug: https://bugs.php.net/54502 (Feedback) Add support for the "BITS" datatype Changed paths: U php/php-src/trunk/NEWS U php/php-src/trunk/UPGRADING U php/php-src/trunk/ext/snmp/snmp.c U php/php-src/trunk/ext/snmp/tests/snmp_get_valueretrieval.phpt U php/php-src/trunk/ext/snmp/tests/snmp_getvalue.phpt Modified: php/php-src/trunk/NEWS === --- php/php-src/trunk/NEWS 2011-07-17 17:21:54 UTC (rev 313332) +++ php/php-src/trunk/NEWS 2011-07-17 17:27:00 UTC (rev 31) @@ -221,6 +221,9 @@ . Allow ~infinite OIDs in GET/GETNEXT/SET queries. Autochunk them to max_oids upon request. . Introducing unit tests for extension with ~full coverage. + . Way of representing OID value can now be changed when SNMP_VALUE_OBJECT +is used for value output mode. Use or'ed SNMP_VALUE_LIBRARY(default if +not specified) or SNMP_VALUE_PLAIN. (FR #54502) . Fixed bugs . #44193 (snmp v3 noAuthNoPriv doesn't work) . #45893 (Snmp buffer limited to 2048 char) Modified: php/php-src/trunk/UPGRADING === --- php/php-src/trunk/UPGRADING 2011-07-17 17:21:54 UTC (rev 313332) +++ php/php-src/trunk/UPGRADING 2011-07-17 17:27:00 UTC (rev 31) @@ -283,6 +283,13 @@ - Multi OID get/getnext/set queries are now supported. - New constants added for use in snmp_set_oid_output_format() function. + - Function snmp_set_valueretrieval() changed it's behaviour: +SNMP_VALUE_OBJECT can be combined with one of +SNMP_VALUE_PLAIN or SNMP_VALUE_LIBRARY resulting OID value +changes. When no SNMP_VALUE_PLAIN or SNMP_VALUE_LIBRARY +is supplied with SNMP_VALUE_OBJECT, SNMP_VALUE_LIBRARY is used. +Prior to 5.4.0 when no SNMP_VALUE_PLAIN or SNMP_VALUE_LIBRARY +was supplied with SNMP_VALUE_OBJECT, SNMP_VALUE_PLAIN was used. - Added feature-rich OO API (SNMP class) - Dropped UCD-SNMP compatibility code. Consider upgrading to net-snmp v5.3+. Net-SNMP v5.4+ is required for Windows version. Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-07-17 17:21:54 UTC (rev 313332) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-07-17 17:27:00 UTC (rev 31) @@ -94,9 +94,9 @@ } #endif -#define SNMP_VALUE_LIBRARY 0 -#define SNMP_VALUE_PLAIN 1 -#define SNMP_VALUE_OBJECT 2 +#define SNMP_VALUE_LIBRARY (0 << 0) +#define SNMP_VALUE_PLAIN (1 << 0) +#define SNMP_VALUE_OBJECT (1 << 1) typedef struct snmp_session php_snmp_session; #define PHP_SNMP_SESSION_RES_NAME "SNMP session" @@ -559,7 +559,7 @@ int buflen = sizeof(sbuf) - 1; int val_len = vars->val_len; - if (valueretrieval == SNMP_VALUE_LIBRARY) { + if ((valueretrieval & SNMP_VALUE_PLAIN) == 0) { val_len += 32; /* snprint_value will add type info into value, make some space for it */ } @@ -575,96 +575,92 @@ *buf = 0; - if (valueretrieval == SNMP_VALUE_LIBRARY) { - snprint_value(buf, buflen, vars->name, vars->name_length, vars); - ZVAL_STRING(snmpval, buf, 1); - if(dbuf){ /* malloc was used to store value */ - efree(dbuf); - } - return; - } - MAKE_STD_ZVAL(val); - switch (vars->type) { - case ASN_BIT_STR: /* 0x03, asn1.h */ - ZVAL_STRINGL(val, (char *)vars->val.bitstring, vars->val_len, 1); - break; + if (valueretrieval & SNMP_VALUE_PLAIN) { + switch (vars->type) { + case ASN_BIT_STR: /* 0x03, asn1.h */ + ZVAL_STRINGL(val, (char *)vars->val.bitstring, vars->val_len, 1); + break; - case ASN_OCTET_STR: /* 0x04, asn1.h */ - case ASN_OPAQUE: /* 0x44, snmp_impl.h */ - ZVAL_STRINGL(val, (char *)vars->val.string, vars->val_len, 1); - break; + case ASN_OCTET_STR: /* 0x04, asn1.h */ + case ASN_OPAQUE: /* 0x44, snmp_impl.h */ + ZVAL_STRINGL(val, (char *)vars->val.string, vars->val_len, 1); + break; - case ASN_NULL: /* 0x05, asn1.h */ - ZVAL_NULL(val); - break; + case ASN_NULL: /* 0x05, asn1.h */ + ZVAL_NULL(val); + break; - case ASN_OBJECT_ID: /* 0x06, asn1.h */ - snprint_objid(buf, buflen, vars->val.objid, vars->val_len / sizeof(oid)); - ZVAL_STRING(val, buf, 1); - break; + case ASN_OBJECT_ID: /* 0x06, asn1.h */ + snprint_objid(buf, buflen, vars->val.objid, vars->val_len / sizeof(oid)); + ZVAL_STRING(val, buf, 1); + break; - case ASN_IPADDRESS: /* 0x40, snmp_impl.h */ - snprintf(buf, buflen, "%d.%d.%d.%d", - (vars->val.string)[0], (vars->val.string)[1], - (vars->val.string)[2], (vars->val.string)[3]); - buf[buflen]=0
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/snmp/ snmp.c tests/snmp-object-error.phpt tests/snmp-object.phpt
lytboris Sun, 17 Jul 2011 18:14:38 + Revision: http://svn.php.net/viewvc?view=revision&revision=313336 Log: swap non_repeaters and max_repetitions in walk query, max_repetitions whould be used more frequently Changed paths: U php/php-src/branches/PHP_5_4/ext/snmp/snmp.c U php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-error.phpt U php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object.phpt Modified: php/php-src/branches/PHP_5_4/ext/snmp/snmp.c === --- php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2011-07-17 18:08:02 UTC (rev 313335) +++ php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2011-07-17 18:14:38 UTC (rev 313336) @@ -345,8 +345,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp_walk, 0, 0, 4) ZEND_ARG_INFO(0, object_id) ZEND_ARG_INFO(0, suffix_keys) + ZEND_ARG_INFO(0, max_repetitions) ZEND_ARG_INFO(0, non_repeaters) - ZEND_ARG_INFO(0, max_repetitions) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp_set, 0, 0, 3) @@ -1355,7 +1355,7 @@ RETURN_FALSE; } } else if (st & SNMP_CMD_WALK) { - if (zend_parse_parameters(argc TSRMLS_CC, "Z|bll", &oid, &suffix_keys, &(objid_query.non_repeaters), &(objid_query.max_repetitions)) == FAILURE) { + if (zend_parse_parameters(argc TSRMLS_CC, "Z|bll", &oid, &suffix_keys, &(objid_query.max_repetitions), &(objid_query.non_repeaters)) == FAILURE) { RETURN_FALSE; } if (suffix_keys) { @@ -1763,7 +1763,7 @@ } /* }}} */ -/* {{{ proto mixed SNMP::walk(mixed object_id [, bool $suffix_as_key = FALSE [, int $non_repeaters [, int $max_repetitions ]]]) +/* {{{ proto mixed SNMP::walk(mixed object_id [, bool $suffix_as_key = FALSE [, int $max_repetitions [, int $non_repeaters]]) Return all objects including their respective object id withing the specified one as array of oid->value pairs */ PHP_METHOD(snmp, walk) { Modified: php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-error.phpt === --- php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-error.phpt 2011-07-17 18:08:02 UTC (rev 313335) +++ php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-error.phpt 2011-07-17 18:14:38 UTC (rev 313336) @@ -47,7 +47,7 @@ $session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries); var_dump($session->walk('.1.3.6.1.2.1.1', FALSE, '')); -var_dump($session->walk('.1.3.6.1.2.1.1', FALSE, 0, '')); +var_dump($session->walk('.1.3.6.1.2.1.1', FALSE, 30, '')); var_dump($session->get()); var_dump($session->getnext()); var_dump($session->set()); Modified: php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object.phpt === --- php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object.phpt 2011-07-17 18:08:02 UTC (rev 313335) +++ php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object.phpt 2011-07-17 18:14:38 UTC (rev 313336) @@ -48,18 +48,18 @@ var_dump(array_shift($z)); var_dump($session->close()); -echo "WALK multiple on single OID, non_repeaters set to 0\n"; +echo "WALK multiple on single OID, max_repetitions set to 30\n"; $session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries); -$z = $session->walk('.1.3.6.1.2.1.1', 0); +$z = $session->walk('.1.3.6.1.2.1.1', FALSE, 30); var_dump(gettype($z)); var_dump(count($z)); var_dump(key($z)); var_dump(array_shift($z)); var_dump($session->close()); -echo "WALK multiple on single OID, non_repeaters set to 0, max_repetitions set to 30\n"; +echo "WALK multiple on single OID, max_repetitions set to 30, non_repeaters set to 0\n"; $session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries); -$z = $session->walk('.1.3.6.1.2.1.1', 0, 30); +$z = $session->walk('.1.3.6.1.2.1.1', FALSE, 30, 0); var_dump(gettype($z)); var_dump(count($z)); var_dump(key($z)); @@ -154,13 +154,13 @@ string(%d) "%S" string(%d) "%S" bool(true) -WALK multiple on single OID, non_repeaters set to 0 +WALK multiple on single OID, max_repetitions set to 30 string(5) "array" int(%d) string(%d) "%S" string(%d) "%S" bool(true) -WALK multiple on single OID, non_repeaters set to 0, max_repetitions set to 30 +WALK multiple on single OID, max_repetitions set to 30, non_repeaters set to 0 string(5) "array" int(%d) string(%d) "%S" -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c tests/snmp-object-error.phpt tests/snmp-object.phpt
lytboris Sun, 17 Jul 2011 18:17:43 + Revision: http://svn.php.net/viewvc?view=revision&revision=313338 Log: swap non_repeaters and max_repetitions in walk query, max_repetitions whould be used more frequently Changed paths: _U php/php-src/trunk/ext/snmp/ U php/php-src/trunk/ext/snmp/snmp.c U php/php-src/trunk/ext/snmp/tests/snmp-object-error.phpt U php/php-src/trunk/ext/snmp/tests/snmp-object.phpt Property changes on: php/php-src/trunk/ext/snmp ___ Added: svn:mergeinfo + /php/php-src/branches/PHP_5_4/ext/snmp:313331,313336 /php/php-src/trunk/ext/snmp:284726 Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-07-17 18:15:37 UTC (rev 313337) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-07-17 18:17:43 UTC (rev 313338) @@ -353,8 +353,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp_walk, 0, 0, 4) ZEND_ARG_INFO(0, object_id) ZEND_ARG_INFO(0, suffix_keys) + ZEND_ARG_INFO(0, max_repetitions) ZEND_ARG_INFO(0, non_repeaters) - ZEND_ARG_INFO(0, max_repetitions) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp_set, 0, 0, 3) @@ -1370,7 +1370,7 @@ RETURN_FALSE; } } else if (st & SNMP_CMD_WALK) { - if (zend_parse_parameters(argc TSRMLS_CC, "Z|bll", &oid, &suffix_keys, &(objid_query.non_repeaters), &(objid_query.max_repetitions)) == FAILURE) { + if (zend_parse_parameters(argc TSRMLS_CC, "Z|bll", &oid, &suffix_keys, &(objid_query.max_repetitions), &(objid_query.non_repeaters)) == FAILURE) { RETURN_FALSE; } if (suffix_keys) { @@ -1792,7 +1792,7 @@ } /* }}} */ -/* {{{ proto mixed SNMP::walk(mixed object_id [, bool $suffix_as_key = FALSE [, int $non_repeaters [, int $max_repetitions ]]]) +/* {{{ proto mixed SNMP::walk(mixed object_id [, bool $suffix_as_key = FALSE [, int $max_repetitions [, int $non_repeaters]]) Return all objects including their respective object id withing the specified one as array of oid->value pairs */ PHP_METHOD(snmp, walk) { Modified: php/php-src/trunk/ext/snmp/tests/snmp-object-error.phpt === --- php/php-src/trunk/ext/snmp/tests/snmp-object-error.phpt 2011-07-17 18:15:37 UTC (rev 313337) +++ php/php-src/trunk/ext/snmp/tests/snmp-object-error.phpt 2011-07-17 18:17:43 UTC (rev 313338) @@ -47,7 +47,7 @@ $session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries); var_dump($session->walk('.1.3.6.1.2.1.1', FALSE, '')); -var_dump($session->walk('.1.3.6.1.2.1.1', FALSE, 0, '')); +var_dump($session->walk('.1.3.6.1.2.1.1', FALSE, 30, '')); var_dump($session->get()); var_dump($session->getnext()); var_dump($session->set()); Modified: php/php-src/trunk/ext/snmp/tests/snmp-object.phpt === --- php/php-src/trunk/ext/snmp/tests/snmp-object.phpt 2011-07-17 18:15:37 UTC (rev 313337) +++ php/php-src/trunk/ext/snmp/tests/snmp-object.phpt 2011-07-17 18:17:43 UTC (rev 313338) @@ -48,18 +48,18 @@ var_dump(array_shift($z)); var_dump($session->close()); -echo "WALK multiple on single OID, non_repeaters set to 0\n"; +echo "WALK multiple on single OID, max_repetitions set to 30\n"; $session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries); -$z = $session->walk('.1.3.6.1.2.1.1', 0); +$z = $session->walk('.1.3.6.1.2.1.1', FALSE, 30); var_dump(gettype($z)); var_dump(count($z)); var_dump(key($z)); var_dump(array_shift($z)); var_dump($session->close()); -echo "WALK multiple on single OID, non_repeaters set to 0, max_repetitions set to 30\n"; +echo "WALK multiple on single OID, max_repetitions set to 30, non_repeaters set to 0\n"; $session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries); -$z = $session->walk('.1.3.6.1.2.1.1', 0, 30); +$z = $session->walk('.1.3.6.1.2.1.1', FALSE, 30, 0); var_dump(gettype($z)); var_dump(count($z)); var_dump(key($z)); @@ -154,13 +154,13 @@ string(%d) "%S" string(%d) "%S" bool(true) -WALK multiple on single OID, non_repeaters set to 0 +WALK multiple on single OID, max_repetitions set to 30 string(5) "array" int(%d) string(%d) "%S" string(%d) "%S" bool(true) -WALK multiple on single OID, non_repeaters set to 0, max_repetitions set to 30 +WALK multiple on single OID, max_repetitions set to 30, non_repeaters set to 0 string(5) "array" int(%d) string(%d) "%S" -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ php_snmp.h snmp.c tests/snmp-object-properties.phpt
lytboris Sun, 17 Jul 2011 19:45:05 + Revision: http://svn.php.net/viewvc?view=revision&revision=313341 Log: new propery noOIDIncreasingCheck allowing to skip OID increasing check (userful for bogus SNMP agents) Changed paths: U php/php-src/trunk/ext/snmp/php_snmp.h U php/php-src/trunk/ext/snmp/snmp.c U php/php-src/trunk/ext/snmp/tests/snmp-object-properties.phpt Modified: php/php-src/trunk/ext/snmp/php_snmp.h === --- php/php-src/trunk/ext/snmp/php_snmp.h 2011-07-17 19:26:54 UTC (rev 313340) +++ php/php-src/trunk/ext/snmp/php_snmp.h 2011-07-17 19:45:05 UTC (rev 313341) @@ -93,6 +93,7 @@ int enum_print; int oid_output_format; int snmp_errno; + int noOIDIncreasingCheck; char snmp_errstr[128]; } php_snmp_object; Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-07-17 19:26:54 UTC (rev 313340) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-07-17 19:45:05 UTC (rev 313341) @@ -376,6 +376,7 @@ long max_repetitions; int valueretrieval; int array_output; + int noOIDIncreasingCheck; snmpobjarg *vars; }; @@ -878,7 +879,7 @@ /* OID increase check */ if (st & SNMP_CMD_WALK) { - if (snmp_oid_compare(name, name_length, vars->name, vars->name_length) >= 0) { + if (objid_query->noOIDIncreasingCheck == FALSE && snmp_oid_compare(name, name_length, vars->name, vars->name_length) >= 0) { snprint_objid(buf2, sizeof(buf2), vars->name, vars->name_length); php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_NOT_INCREASING, "Error: OID not increasing: %s", buf2); keepwalking = 0; @@ -1331,6 +1332,7 @@ objid_query.max_repetitions = -1; objid_query.non_repeaters = 0; objid_query.valueretrieval = SNMP_G(valueretrieval); + objid_query.noOIDIncreasingCheck = FALSE; if (session_less_mode) { if (version == SNMP_VERSION_3) { @@ -1424,6 +1426,7 @@ objid_query.max_repetitions = snmp_object->max_oids; } } + objid_query.noOIDIncreasingCheck = snmp_object->noOIDIncreasingCheck; objid_query.valueretrieval = snmp_object->valueretrieval; glob_snmp_object.enum_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM); netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM, snmp_object->enum_print); @@ -2107,41 +2110,28 @@ } /* }}} */ -/* {{{ */ -static int php_snmp_read_valueretrieval(php_snmp_object *snmp_object, zval **retval TSRMLS_DC) -{ - MAKE_STD_ZVAL(*retval); - ZVAL_LONG(*retval, snmp_object->valueretrieval); - return SUCCESS; -} -/* }}} */ +#define PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(name) \ + static int php_snmp_read_##name(php_snmp_object *snmp_object, zval **retval TSRMLS_DC) \ + { \ + MAKE_STD_ZVAL(*retval); \ + ZVAL_BOOL(*retval, snmp_object->name); \ + return SUCCESS; \ + } -/* {{{ */ -static int php_snmp_read_quick_print(php_snmp_object *snmp_object, zval **retval TSRMLS_DC) -{ - MAKE_STD_ZVAL(*retval); - ZVAL_BOOL(*retval, snmp_object->quick_print); - return SUCCESS; -} -/* }}} */ +PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(noOIDIncreasingCheck) +PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(quick_print) +PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(enum_print) -/* {{{ */ -static int php_snmp_read_enum_print(php_snmp_object *snmp_object, zval **retval TSRMLS_DC) -{ - MAKE_STD_ZVAL(*retval); - ZVAL_BOOL(*retval, snmp_object->enum_print); - return SUCCESS; -} -/* }}} */ +#define PHP_SNMP_LONG_PROPERTY_READER_FUNCTION(name) \ + static int php_snmp_read_##name(php_snmp_object *snmp_object, zval **retval TSRMLS_DC) \ + { \ + MAKE_STD_ZVAL(*retval); \ + ZVAL_LONG(*retval, snmp_object->name); \ + return SUCCESS; \ + } -/* {{{ */ -static int php_snmp_read_oid_output_format(php_snmp_object *snmp_object, zval **retval TSRMLS_DC) -{ - MAKE_STD_ZVAL(*retval); - ZVAL_LONG(*retval, snmp_object->oid_output_format); - return SUCCESS; -} -/* }}} */ +PHP_SNMP_LONG_PROPERTY_READER_FUNCTION(valueretrieval) +PHP_SNMP_LONG_PROPERTY_READER_FUNCTION(oid_output_format) /* {{{ */ static int php_snmp_write_info(php_snmp_object *snmp_object, zval *newval TSRML
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/snmp/ php_snmp.h snmp.c tests/snmp-object-properties.phpt
lytboris Sun, 17 Jul 2011 19:47:24 + Revision: http://svn.php.net/viewvc?view=revision&revision=313342 Log: new propery noOIDIncreasingCheck allowing to skip OID increasing check (userful for bogus SNMP agents) Changed paths: _U php/php-src/branches/PHP_5_4/ext/snmp/ U php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h U php/php-src/branches/PHP_5_4/ext/snmp/snmp.c U php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-properties.phpt Property changes on: php/php-src/branches/PHP_5_4/ext/snmp ___ Modified: svn:mergeinfo - /php/php-src/trunk/ext/snmp:284726,311033-313324 + /php/php-src/trunk/ext/snmp:284726,311033-313324,313341 Modified: php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h === --- php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h2011-07-17 19:45:05 UTC (rev 313341) +++ php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h2011-07-17 19:47:24 UTC (rev 313342) @@ -93,6 +93,7 @@ int enum_print; int oid_output_format; int snmp_errno; + int noOIDIncreasingCheck; char snmp_errstr[128]; } php_snmp_object; Modified: php/php-src/branches/PHP_5_4/ext/snmp/snmp.c === --- php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2011-07-17 19:45:05 UTC (rev 313341) +++ php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2011-07-17 19:47:24 UTC (rev 313342) @@ -368,6 +368,7 @@ long max_repetitions; int valueretrieval; int array_output; + int noOIDIncreasingCheck; snmpobjarg *vars; }; @@ -863,7 +864,7 @@ /* OID increase check */ if (st & SNMP_CMD_WALK) { - if (snmp_oid_compare(name, name_length, vars->name, vars->name_length) >= 0) { + if (objid_query->noOIDIncreasingCheck == FALSE && snmp_oid_compare(name, name_length, vars->name, vars->name_length) >= 0) { snprint_objid(buf2, sizeof(buf2), vars->name, vars->name_length); php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_NOT_INCREASING, "Error: OID not increasing: %s", buf2); keepwalking = 0; @@ -1316,6 +1317,7 @@ objid_query.max_repetitions = -1; objid_query.non_repeaters = 0; objid_query.valueretrieval = SNMP_G(valueretrieval); + objid_query.noOIDIncreasingCheck = FALSE; if (session_less_mode) { if (version == SNMP_VERSION_3) { @@ -1409,6 +1411,7 @@ objid_query.max_repetitions = snmp_object->max_oids; } } + objid_query.noOIDIncreasingCheck = snmp_object->noOIDIncreasingCheck; objid_query.valueretrieval = snmp_object->valueretrieval; glob_snmp_object.enum_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM); netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM, snmp_object->enum_print); @@ -2042,41 +2045,28 @@ } /* }}} */ -/* {{{ */ -static int php_snmp_read_valueretrieval(php_snmp_object *snmp_object, zval **retval TSRMLS_DC) -{ - MAKE_STD_ZVAL(*retval); - ZVAL_LONG(*retval, snmp_object->valueretrieval); - return SUCCESS; -} -/* }}} */ +#define PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(name) \ + static int php_snmp_read_##name(php_snmp_object *snmp_object, zval **retval TSRMLS_DC) \ + { \ + MAKE_STD_ZVAL(*retval); \ + ZVAL_BOOL(*retval, snmp_object->name); \ + return SUCCESS; \ + } -/* {{{ */ -static int php_snmp_read_quick_print(php_snmp_object *snmp_object, zval **retval TSRMLS_DC) -{ - MAKE_STD_ZVAL(*retval); - ZVAL_BOOL(*retval, snmp_object->quick_print); - return SUCCESS; -} -/* }}} */ +PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(noOIDIncreasingCheck) +PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(quick_print) +PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(enum_print) -/* {{{ */ -static int php_snmp_read_enum_print(php_snmp_object *snmp_object, zval **retval TSRMLS_DC) -{ - MAKE_STD_ZVAL(*retval); - ZVAL_BOOL(*retval, snmp_object->enum_print); - return SUCCESS; -} -/* }}} */ +#define PHP_SNMP_LONG_PROPERTY_READER_FUNCTION(name) \ + static int php_snmp_read_##name(php_snmp_object *snmp_object, zval **retval TSRMLS_DC) \ + { \ + MAKE_STD_ZVAL(*retval); \ + ZVAL_LONG(*retval, snmp_object->name); \ + return SUCCESS; \ + } -/* {{{ */ -static int php_snmp_
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ php_snmp.h snmp.c tests/snmp-object-properties.phpt
lytboris Thu, 21 Jul 2011 12:47:07 + Revision: http://svn.php.net/viewvc?view=revision&revision=313532 Log: s/noOIDIncreasingCheck/oid_increasing_check/ Changed paths: U php/php-src/trunk/ext/snmp/php_snmp.h U php/php-src/trunk/ext/snmp/snmp.c U php/php-src/trunk/ext/snmp/tests/snmp-object-properties.phpt Modified: php/php-src/trunk/ext/snmp/php_snmp.h === --- php/php-src/trunk/ext/snmp/php_snmp.h 2011-07-21 12:27:00 UTC (rev 313531) +++ php/php-src/trunk/ext/snmp/php_snmp.h 2011-07-21 12:47:07 UTC (rev 313532) @@ -93,7 +93,7 @@ int enum_print; int oid_output_format; int snmp_errno; - int noOIDIncreasingCheck; + int oid_increasing_check; char snmp_errstr[128]; } php_snmp_object; Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-07-21 12:27:00 UTC (rev 313531) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-07-21 12:47:07 UTC (rev 313532) @@ -376,7 +376,7 @@ long max_repetitions; int valueretrieval; int array_output; - int noOIDIncreasingCheck; + int oid_increasing_check; snmpobjarg *vars; }; @@ -879,7 +879,7 @@ /* OID increase check */ if (st & SNMP_CMD_WALK) { - if (objid_query->noOIDIncreasingCheck == FALSE && snmp_oid_compare(name, name_length, vars->name, vars->name_length) >= 0) { + if (objid_query->oid_increasing_check == TRUE && snmp_oid_compare(name, name_length, vars->name, vars->name_length) >= 0) { snprint_objid(buf2, sizeof(buf2), vars->name, vars->name_length); php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_NOT_INCREASING, "Error: OID not increasing: %s", buf2); keepwalking = 0; @@ -1332,7 +1332,7 @@ objid_query.max_repetitions = -1; objid_query.non_repeaters = 0; objid_query.valueretrieval = SNMP_G(valueretrieval); - objid_query.noOIDIncreasingCheck = FALSE; + objid_query.oid_increasing_check = TRUE; if (session_less_mode) { if (version == SNMP_VERSION_3) { @@ -1426,7 +1426,7 @@ objid_query.max_repetitions = snmp_object->max_oids; } } - objid_query.noOIDIncreasingCheck = snmp_object->noOIDIncreasingCheck; + objid_query.oid_increasing_check = snmp_object->oid_increasing_check; objid_query.valueretrieval = snmp_object->valueretrieval; glob_snmp_object.enum_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM); netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM, snmp_object->enum_print); @@ -1757,6 +1757,7 @@ snmp_object->enum_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM); snmp_object->oid_output_format = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT); snmp_object->quick_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT); + snmp_object->oid_increasing_check = TRUE; } /* }}} */ @@ -2118,7 +2119,7 @@ return SUCCESS; \ } -PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(noOIDIncreasingCheck) +PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(oid_increasing_check) PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(quick_print) PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(enum_print) @@ -,7 +2223,7 @@ PHP_SNMP_BOOL_PROPERTY_WRITER_FUNCTION(quick_print) PHP_SNMP_BOOL_PROPERTY_WRITER_FUNCTION(enum_print) -PHP_SNMP_BOOL_PROPERTY_WRITER_FUNCTION(noOIDIncreasingCheck) +PHP_SNMP_BOOL_PROPERTY_WRITER_FUNCTION(oid_increasing_check) /* {{{ */ static int php_snmp_write_oid_output_format(php_snmp_object *snmp_object, zval *newval TSRMLS_DC) @@ -2284,7 +2285,7 @@ PHP_SNMP_PROPERTY_ENTRY_RECORD(quick_print), PHP_SNMP_PROPERTY_ENTRY_RECORD(enum_print), PHP_SNMP_PROPERTY_ENTRY_RECORD(oid_output_format), - PHP_SNMP_PROPERTY_ENTRY_RECORD(noOIDIncreasingCheck), + PHP_SNMP_PROPERTY_ENTRY_RECORD(oid_increasing_check), { NULL, 0, NULL, NULL} }; /* }}} */ Modified: php/php-src/trunk/ext/snmp/tests/snmp-object-properties.phpt === --- php/php-src/trunk/ext/snmp/tests/snmp-object-properties.phpt 2011-07-21 12:27:00 UTC (rev 313531) +++ php/php-src/trunk/ext/snmp/tests/snmp-object-properties.phpt 2011-07-21 12
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/snmp/ php_snmp.h snmp.c tests/snmp-object-properties.phpt
lytboris Thu, 21 Jul 2011 12:48:47 + Revision: http://svn.php.net/viewvc?view=revision&revision=313533 Log: s/noOIDIncreasingCheck/oid_increasing_check/ Changed paths: _U php/php-src/branches/PHP_5_4/ext/snmp/ U php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h U php/php-src/branches/PHP_5_4/ext/snmp/snmp.c U php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-properties.phpt Property changes on: php/php-src/branches/PHP_5_4/ext/snmp ___ Modified: svn:mergeinfo - /php/php-src/trunk/ext/snmp:284726,311033-313324,313341 + /php/php-src/trunk/ext/snmp:284726,311033-313324,313341,313532 Modified: php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h === --- php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h2011-07-21 12:47:07 UTC (rev 313532) +++ php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h2011-07-21 12:48:47 UTC (rev 313533) @@ -93,7 +93,7 @@ int enum_print; int oid_output_format; int snmp_errno; - int noOIDIncreasingCheck; + int oid_increasing_check; char snmp_errstr[128]; } php_snmp_object; Modified: php/php-src/branches/PHP_5_4/ext/snmp/snmp.c === --- php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2011-07-21 12:47:07 UTC (rev 313532) +++ php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2011-07-21 12:48:47 UTC (rev 313533) @@ -368,7 +368,7 @@ long max_repetitions; int valueretrieval; int array_output; - int noOIDIncreasingCheck; + int oid_increasing_check; snmpobjarg *vars; }; @@ -864,7 +864,7 @@ /* OID increase check */ if (st & SNMP_CMD_WALK) { - if (objid_query->noOIDIncreasingCheck == FALSE && snmp_oid_compare(name, name_length, vars->name, vars->name_length) >= 0) { + if (objid_query->oid_increasing_check == TRUE && snmp_oid_compare(name, name_length, vars->name, vars->name_length) >= 0) { snprint_objid(buf2, sizeof(buf2), vars->name, vars->name_length); php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_NOT_INCREASING, "Error: OID not increasing: %s", buf2); keepwalking = 0; @@ -1317,7 +1317,7 @@ objid_query.max_repetitions = -1; objid_query.non_repeaters = 0; objid_query.valueretrieval = SNMP_G(valueretrieval); - objid_query.noOIDIncreasingCheck = FALSE; + objid_query.oid_increasing_check = TRUE; if (session_less_mode) { if (version == SNMP_VERSION_3) { @@ -1411,7 +1411,7 @@ objid_query.max_repetitions = snmp_object->max_oids; } } - objid_query.noOIDIncreasingCheck = snmp_object->noOIDIncreasingCheck; + objid_query.oid_increasing_check = snmp_object->oid_increasing_check; objid_query.valueretrieval = snmp_object->valueretrieval; glob_snmp_object.enum_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM); netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM, snmp_object->enum_print); @@ -1728,6 +1728,7 @@ snmp_object->enum_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM); snmp_object->oid_output_format = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT); snmp_object->quick_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT); + snmp_object->oid_increasing_check = TRUE; } /* }}} */ @@ -2053,7 +2054,7 @@ return SUCCESS; \ } -PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(noOIDIncreasingCheck) +PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(oid_increasing_check) PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(quick_print) PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(enum_print) @@ -2157,7 +2158,7 @@ PHP_SNMP_BOOL_PROPERTY_WRITER_FUNCTION(quick_print) PHP_SNMP_BOOL_PROPERTY_WRITER_FUNCTION(enum_print) -PHP_SNMP_BOOL_PROPERTY_WRITER_FUNCTION(noOIDIncreasingCheck) +PHP_SNMP_BOOL_PROPERTY_WRITER_FUNCTION(oid_increasing_check) /* {{{ */ static int php_snmp_write_oid_output_format(php_snmp_object *snmp_object, zval *newval TSRMLS_DC) @@ -2219,7 +2220,7 @@ PHP_SNMP_PROPERTY_ENTRY_RECORD(quick_print), PHP_SNMP_PROPERTY_ENTRY_RECORD(enum_print), PHP_SNMP_PROPERTY_ENTRY_RECORD(oid_output_format), - PHP_SNMP_PROPERTY_ENTRY_RECORD(noOIDIncreasingCheck), + PH
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c
lytboris Sat, 23 Jul 2011 07:40:40 + Revision: http://svn.php.net/viewvc?view=revision&revision=313620 Log: provide backwards compatibility for 'p' in zend_parse_parameters() Changed paths: U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-07-23 06:04:26 UTC (rev 313619) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-07-23 07:40:40 UTC (rev 313620) @@ -1683,7 +1683,11 @@ char *filename; int filename_len; +#if PHP_VERSION_ID < 50399 + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { +#else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) { +#endif RETURN_FALSE; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/tests/ generic_timeout_error.phpt snmp-object-errno-errstr.phpt
lytboris Sat, 20 Aug 2011 14:50:49 + Revision: http://svn.php.net/viewvc?view=revision&revision=315235 Log: more code coverage Changed paths: U php/php-src/trunk/ext/snmp/tests/generic_timeout_error.phpt U php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt Modified: php/php-src/trunk/ext/snmp/tests/generic_timeout_error.phpt === --- php/php-src/trunk/ext/snmp/tests/generic_timeout_error.phpt 2011-08-20 14:21:47 UTC (rev 315234) +++ php/php-src/trunk/ext/snmp/tests/generic_timeout_error.phpt 2011-08-20 14:50:49 UTC (rev 315235) @@ -15,8 +15,13 @@ snmp_set_valueretrieval(SNMP_VALUE_PLAIN); var_dump(snmpget($hostname, 'timeout_community_432', '.1.3.6.1.2.1.1.1.0', $timeout, $retries)); +var_dump(snmpget($hostname, 'timeout_community_432', array('.1.3.6.1.2.1.1.1.0'), $timeout, $retries)); ?> --EXPECTF-- Warning: snmpget(): No response from %s in %s on line %d bool(false) + +Warning: snmpget(): No response from %s in %s on line %d +bool(false) + Modified: php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt === --- php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt 2011-08-20 14:21:47 UTC (rev 315234) +++ php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt 2011-08-20 14:50:49 UTC (rev 315235) @@ -42,6 +42,7 @@ var_dump(@$session->get('.1.3.6.1.2.1.1.1.0')); var_dump($session->getErrno() == SNMP::ERRNO_GENERIC); var_dump($session->getError()); +var_dump(@$session->get(array('.1.3.6.1.2.1.1.1.0'))); $session->close(); ?> --EXPECTF-- @@ -61,3 +62,4 @@ bool(false) bool(true) %string|unicode%(%d) "Fatal error: Unknown user name" +bool(false) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c tests/README tests/ipv6.phpt tests/snmp_include.inc tests/wrong_hostname.phpt
+ } + strcat(pptr, inet_ntoa(res)); +#endif + break; + } + + if (strlen(session->peername) == 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown failure while resolving '%s'", buf); + return (-1); + } + /* XXX FIXME + There should be check for non-empty session->peername! + */ + + php_network_freeaddresses(psal); + if (version == SNMP_VERSION_3) { /* Setting the security name. */ session->securityName = estrdup(community); Modified: php/php-src/trunk/ext/snmp/tests/README === --- php/php-src/trunk/ext/snmp/tests/README 2011-08-20 14:50:49 UTC (rev 315235) +++ php/php-src/trunk/ext/snmp/tests/README 2011-08-20 15:53:44 UTC (rev 315236) @@ -9,7 +9,9 @@ ** How to test ** You need to give credentials with environment vars if default ones are not sutable (see snmp_include.inc for more info): -SNMP_HOSTNAME : IP or IP:PORT to connect to +SNMP_HOSTNAME : IPv4 of remote SNMP agent +SNMP_HOSTNAME : IPv6 or remote SNMP agent +SNMP_PORT : SNMP port for queries SNMP_COMMUNITY : community name SNMP_COMMUNITY_WRITE : community used for write tests (snmpset()). SNMP_MIBDIR : Directory containing MIBS @@ -26,6 +28,7 @@ ## Config file # rocommunity public 127.0.0.1 +rocommunity6 public ::1 rwcommunity private 127.0.0.1 Do not enable them - being set here they make appropriate OID switch into r/o Added: php/php-src/trunk/ext/snmp/tests/ipv6.phpt === --- php/php-src/trunk/ext/snmp/tests/ipv6.phpt (rev 0) +++ php/php-src/trunk/ext/snmp/tests/ipv6.phpt 2011-08-20 15:53:44 UTC (rev 315236) @@ -0,0 +1,24 @@ +--TEST-- +IPv6 support +--CREDITS-- +Boris Lytochkin +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +%unicode|string%(%d) "%s" Modified: php/php-src/trunk/ext/snmp/tests/snmp_include.inc === --- php/php-src/trunk/ext/snmp/tests/snmp_include.inc 2011-08-20 14:50:49 UTC (rev 315235) +++ php/php-src/trunk/ext/snmp/tests/snmp_include.inc 2011-08-20 15:53:44 UTC (rev 315236) @@ -6,9 +6,11 @@ Default timeout is 1000ms and there will be one request performed. */ -$hostname =getenv('SNMP_HOSTNAME') ? getenv('SNMP_HOSTNAME') : '127.0.0.1'; +$hostname4 = getenv('SNMP_HOSTNAME') ? getenv('SNMP_HOSTNAME') : '127.0.0.1'; +$hostname6 = getenv('SNMP_HOSTNAME6')? getenv('SNMP_HOSTNAME6') : '::1'; $port =getenv('SNMP_PORT') ? getenv('SNMP_PORT') : '161'; -$hostname .= ":$port"; +$hostname = "$hostname4:$port"; +$hostname6_port = "[$hostname6]:$port"; $community = getenv('SNMP_COMMUNITY')? getenv('SNMP_COMMUNITY') : 'public'; $communityWrite = getenv('SNMP_COMMUNITY_WRITE')? getenv('SNMP_COMMUNITY_WRITE'):'private'; Modified: php/php-src/trunk/ext/snmp/tests/wrong_hostname.phpt === --- php/php-src/trunk/ext/snmp/tests/wrong_hostname.phpt2011-08-20 14:50:49 UTC (rev 315235) +++ php/php-src/trunk/ext/snmp/tests/wrong_hostname.phpt2011-08-20 15:53:44 UTC (rev 315236) @@ -18,5 +18,5 @@ ?> --EXPECTF-- -Warning: snmpget(): Could not open snmp connection: Unknown host (192.168..6.1) (%s) in %s on line %d +Warning: snmpget(): php_network_getaddresses: getaddrinfo failed: hostname nor servname provided, or not known in %s on line %d bool(false) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/snmp/ snmp.c tests/README tests/generic_timeout_error.phpt tests/ipv6.phpt tests/snmp-object-errno-errstr.phpt tests/snmp_include.inc tests/wrong_hostn
buf); + return (-1); + } + /* XXX FIXME + There should be check for non-empty session->peername! + */ + + php_network_freeaddresses(psal); + if (version == SNMP_VERSION_3) { /* Setting the security name. */ session->securityName = estrdup(community); Modified: php/php-src/branches/PHP_5_4/ext/snmp/tests/README === --- php/php-src/branches/PHP_5_4/ext/snmp/tests/README 2011-08-20 15:53:44 UTC (rev 315236) +++ php/php-src/branches/PHP_5_4/ext/snmp/tests/README 2011-08-20 16:10:48 UTC (rev 315237) @@ -9,7 +9,9 @@ ** How to test ** You need to give credentials with environment vars if default ones are not sutable (see snmp_include.inc for more info): -SNMP_HOSTNAME : IP or IP:PORT to connect to +SNMP_HOSTNAME : IPv4 of remote SNMP agent +SNMP_HOSTNAME : IPv6 or remote SNMP agent +SNMP_PORT : SNMP port for queries SNMP_COMMUNITY : community name SNMP_COMMUNITY_WRITE : community used for write tests (snmpset()). SNMP_MIBDIR : Directory containing MIBS @@ -26,6 +28,7 @@ ## Config file # rocommunity public 127.0.0.1 +rocommunity6 public ::1 rwcommunity private 127.0.0.1 Do not enable them - being set here they make appropriate OID switch into r/o Modified: php/php-src/branches/PHP_5_4/ext/snmp/tests/generic_timeout_error.phpt === --- php/php-src/branches/PHP_5_4/ext/snmp/tests/generic_timeout_error.phpt 2011-08-20 15:53:44 UTC (rev 315236) +++ php/php-src/branches/PHP_5_4/ext/snmp/tests/generic_timeout_error.phpt 2011-08-20 16:10:48 UTC (rev 315237) @@ -15,8 +15,13 @@ snmp_set_valueretrieval(SNMP_VALUE_PLAIN); var_dump(snmpget($hostname, 'timeout_community_432', '.1.3.6.1.2.1.1.1.0', $timeout, $retries)); +var_dump(snmpget($hostname, 'timeout_community_432', array('.1.3.6.1.2.1.1.1.0'), $timeout, $retries)); ?> --EXPECTF-- Warning: snmpget(): No response from %s in %s on line %d bool(false) + +Warning: snmpget(): No response from %s in %s on line %d +bool(false) + Copied: php/php-src/branches/PHP_5_4/ext/snmp/tests/ipv6.phpt (from rev 315236, php/php-src/trunk/ext/snmp/tests/ipv6.phpt) === --- php/php-src/branches/PHP_5_4/ext/snmp/tests/ipv6.phpt (rev 0) +++ php/php-src/branches/PHP_5_4/ext/snmp/tests/ipv6.phpt 2011-08-20 16:10:48 UTC (rev 315237) @@ -0,0 +1,24 @@ +--TEST-- +IPv6 support +--CREDITS-- +Boris Lytochkin +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +%unicode|string%(%d) "%s" Modified: php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-errno-errstr.phpt === --- php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-errno-errstr.phpt 2011-08-20 15:53:44 UTC (rev 315236) +++ php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-errno-errstr.phpt 2011-08-20 16:10:48 UTC (rev 315237) @@ -42,6 +42,7 @@ var_dump(@$session->get('.1.3.6.1.2.1.1.1.0')); var_dump($session->getErrno() == SNMP::ERRNO_GENERIC); var_dump($session->getError()); +var_dump(@$session->get(array('.1.3.6.1.2.1.1.1.0'))); $session->close(); ?> --EXPECTF-- @@ -61,3 +62,4 @@ bool(false) bool(true) %string|unicode%(%d) "Fatal error: Unknown user name" +bool(false) Modified: php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp_include.inc === --- php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp_include.inc 2011-08-20 15:53:44 UTC (rev 315236) +++ php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp_include.inc 2011-08-20 16:10:48 UTC (rev 315237) @@ -6,9 +6,11 @@ Default timeout is 1000ms and there will be one request performed. */ -$hostname = getenv('SNMP_HOSTNAME') ? getenv('SNMP_HOSTNAME') : '127.0.0.1'; +$hostname4 = getenv('SNMP_HOSTNAME') ? getenv('SNMP_HOSTNAME') : '127.0.0.1'; +$hostname6 = getenv('SNMP_HOSTNAME6') ? getenv('SNMP_HOSTNAME6') : '::1'; $port = getenv('SNMP_PORT') ? getenv('SNMP_PORT') : '161'; -$hostname .= ":$port"; +$hostname = "$hostname4:$port"; +$hostname6_port = "[$hostname6]:$port"; $community = getenv('SNMP_COMMUNITY') ? getenv('SNMP_COMMUNITY') : 'public'; $communityWrite = getenv('SNMP_COMMUNITY_WRITE')? getenv('SNMP_COMMUNITY_WRITE'):'private'; Modified: php/php-src/branches/PHP_5_4/ext/snmp/tests/wrong_hostname.phpt === --- php/php-src/branches/PHP_5_4/ext/snmp/tests/wrong_hostname.phpt 2011-08-20 15:53:44 UTC (rev 315236) +++ php/php-src/branches/PHP_5_4/ext/snmp/tests/wrong_hostname.phpt 2011-08-20 16:10:48 UTC (rev 315237) @@ -18,5 +18,5 @@ ?> --EXPECTF-- -Warning: snmpget(): Could not open snmp connection: Unknown host (192.168..6.1) (%s) in %s on line %d +Warning: snmpget(): php_network_getaddresses: getaddrinfo failed: hostname nor servname provided, or not known in %s on line %d bool(false) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/NEWS branches/PHP_5_4/UPGRADING trunk/NEWS trunk/UPGRADING
lytboris Sat, 20 Aug 2011 20:56:02 + Revision: http://svn.php.net/viewvc?view=revision&revision=315245 Log: IPv6 Support for SNMP. (FR #42918) Bug: https://bugs.php.net/42918 (Feedback) IPv6 addresses not supported in SNMP extension Changed paths: U php/php-src/branches/PHP_5_4/NEWS U php/php-src/branches/PHP_5_4/UPGRADING U php/php-src/trunk/NEWS U php/php-src/trunk/UPGRADING Modified: php/php-src/branches/PHP_5_4/NEWS === --- php/php-src/branches/PHP_5_4/NEWS 2011-08-20 18:21:04 UTC (rev 315244) +++ php/php-src/branches/PHP_5_4/NEWS 2011-08-20 20:56:02 UTC (rev 315245) @@ -307,6 +307,7 @@ . Allow ~infinite OIDs in GET/GETNEXT/SET queries. Autochunk them to max_oids upon request. . Introducing unit tests for extension with ~full coverage. + IPv6 support. (FR #42918) . Way of representing OID value can now be changed when SNMP_VALUE_OBJECT is used for value output mode. Use or'ed SNMP_VALUE_LIBRARY(default if not specified) or SNMP_VALUE_PLAIN. (FR #54502) Modified: php/php-src/branches/PHP_5_4/UPGRADING === --- php/php-src/branches/PHP_5_4/UPGRADING 2011-08-20 18:21:04 UTC (rev 315244) +++ php/php-src/branches/PHP_5_4/UPGRADING 2011-08-20 20:56:02 UTC (rev 315245) @@ -318,6 +318,9 @@ - Added feature-rich OO API (SNMP class) - Dropped UCD-SNMP compatibility code. Consider upgrading to net-snmp v5.3+. Net-SNMP v5.4+ is required for Windows version. + - In sake of adding support for IPv6 DNS name resolution of + remote SNMP agent (peer) is done by extension now, not by Net-SNMP + library anymore. d. no longer possible to disable Modified: php/php-src/trunk/NEWS === --- php/php-src/trunk/NEWS 2011-08-20 18:21:04 UTC (rev 315244) +++ php/php-src/trunk/NEWS 2011-08-20 20:56:02 UTC (rev 315245) @@ -231,6 +231,7 @@ . Allow ~infinite OIDs in GET/GETNEXT/SET queries. Autochunk them to max_oids upon request. . Introducing unit tests for extension with ~full coverage. + . IPv6 support. (FR #42918) . Way of representing OID value can now be changed when SNMP_VALUE_OBJECT is used for value output mode. Use or'ed SNMP_VALUE_LIBRARY(default if not specified) or SNMP_VALUE_PLAIN. (FR #54502) Modified: php/php-src/trunk/UPGRADING === --- php/php-src/trunk/UPGRADING 2011-08-20 18:21:04 UTC (rev 315244) +++ php/php-src/trunk/UPGRADING 2011-08-20 20:56:02 UTC (rev 315245) @@ -302,6 +302,9 @@ - Added feature-rich OO API (SNMP class) - Dropped UCD-SNMP compatibility code. Consider upgrading to net-snmp v5.3+. Net-SNMP v5.4+ is required for Windows version. + - In sake of adding support for IPv6 DNS name resolution of + remote SNMP agent (peer) is done by extension now, not by Net-SNMP + library anymore. d. no longer possible to disable -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/tests/ README snmpd.conf
lytboris Tue, 23 Aug 2011 19:13:49 + Revision: http://svn.php.net/viewvc?view=revision&revision=315386 Log: apply docs fixes suggested in BR #55474 Bug: https://bugs.php.net/55474 (Open) Improve tests/README... Changed paths: U php/php-src/trunk/ext/snmp/tests/README A php/php-src/trunk/ext/snmp/tests/snmpd.conf Modified: php/php-src/trunk/ext/snmp/tests/README === --- php/php-src/trunk/ext/snmp/tests/README 2011-08-23 19:11:10 UTC (rev 315385) +++ php/php-src/trunk/ext/snmp/tests/README 2011-08-23 19:13:49 UTC (rev 315386) @@ -21,44 +21,17 @@ On Linux/FreeBSD -- Install package net-snmpd (name may differ based on your distribution) -- Edit config file (by default this is /etc/snmp/snmpd.conf on Linux and - usr/local/etc/snmp/snmpd.conf on FreeBSD) and replace whole content - with following lines: +- Install package net-snmpd (name may differ based on your distribution). +- Replace config file (by default this is /etc/snmp/snmpd.conf on Linux and + /usr/local/etc/snmp/snmpd.conf on FreeBSD) with snmpd.conf supplied. -## Config file # -rocommunity public 127.0.0.1 -rocommunity6 public ::1 -rwcommunity private 127.0.0.1 - -Do not enable them - being set here they make appropriate OID switch into r/o -#syslocation "Somewhere in the world" -#syscontact "root" - -#SNMPv3 credentials -rouser adminMD5 -rouser adminSHA -rwuser adminMD5AES -rouser adminMD5AES128 -rouser adminMD5DES -createUser adminMD5 MD5 test1234 -createUser adminSHA SHA test1234 -createUser adminMD5AES MD5 test1234 AES test1234 -createUser adminMD5AES128 MD5 test1234 AES test1234 -createUser adminMD5DES MD5 test1234 DES test1234 - -createUser noAuthUser -authuser read noAuthUser noauth -## End # - Before launching daemon make sure that there is no file /var/net-snmp/snmpd.conf -Delete it if exists. Ingoring to to so will fail SNMPv3 tests +Delete it if exists. Ingoring to to so will fail SNMPv3 tests. -Make snmpd bind on localhost only. To do so, pass '127.0.0.1' into it's startup arguments -(see /etc/init.d/snmpd on Linux and set snmpd_flags="127.0.0.1" in rc.conf in FreeBSD). -Otherwise your SNMP daemon will answer SNMPv3 messages from remote clients. +- Launch snmpd (service snmpd start or /etc/init.d/snmpd start). + Alternatively you can start snmpd daemon using following command line: +sudo snmpd -C -c ./snmpd.conf -f -Le -- Launch snmpd (service snmpd start or /etc/init.d/snmpd start) On Windows -- Added: php/php-src/trunk/ext/snmp/tests/snmpd.conf === --- php/php-src/trunk/ext/snmp/tests/snmpd.conf (rev 0) +++ php/php-src/trunk/ext/snmp/tests/snmpd.conf 2011-08-23 19:13:49 UTC (rev 315386) @@ -0,0 +1,25 @@ +# Listen for connections from the local system only +agentaddress udp:127.0.0.1:161,udp6:[::1]:161 + +rocommunity public 127.0.0.1 +rocommunity6 public ::1 +rwcommunity private 127.0.0.1 + +Do not enable them - being set here they make appropriate OID switch into r/o +#syslocation "Somewhere in the world" +#syscontact "root" + +#SNMPv3 credentials +rouser adminMD5 +rouser adminSHA +rwuser adminMD5AES +rouser adminMD5AES128 +rouser adminMD5DES +createUser adminMD5 MD5 test1234 +createUser adminSHA SHA test1234 +createUser adminMD5AES MD5 test1234 AES test1234 +createUser adminMD5AES128 MD5 test1234 AES test1234 +createUser adminMD5DES MD5 test1234 DES test1234 + +createUser noAuthUser +authuser read noAuthUser noauth -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/snmp/tests/ README snmpd.conf
lytboris Tue, 23 Aug 2011 19:15:58 + Revision: http://svn.php.net/viewvc?view=revision&revision=315387 Log: apply docs fixes suggested in BR #55474 Bug: https://bugs.php.net/55474 (Feedback) Improve tests/README... Changed paths: _U php/php-src/branches/PHP_5_4/ext/snmp/tests/ U php/php-src/branches/PHP_5_4/ext/snmp/tests/README A + php/php-src/branches/PHP_5_4/ext/snmp/tests/snmpd.conf (from php/php-src/trunk/ext/snmp/tests/snmpd.conf:r315386) Property changes on: php/php-src/branches/PHP_5_4/ext/snmp/tests ___ Added: svn:mergeinfo + /php/php-src/trunk/ext/snmp/tests:284726,311033-315236,315386 Modified: php/php-src/branches/PHP_5_4/ext/snmp/tests/README === --- php/php-src/branches/PHP_5_4/ext/snmp/tests/README 2011-08-23 19:13:49 UTC (rev 315386) +++ php/php-src/branches/PHP_5_4/ext/snmp/tests/README 2011-08-23 19:15:58 UTC (rev 315387) @@ -21,44 +21,17 @@ On Linux/FreeBSD -- Install package net-snmpd (name may differ based on your distribution) -- Edit config file (by default this is /etc/snmp/snmpd.conf on Linux and - usr/local/etc/snmp/snmpd.conf on FreeBSD) and replace whole content - with following lines: +- Install package net-snmpd (name may differ based on your distribution). +- Replace config file (by default this is /etc/snmp/snmpd.conf on Linux and + /usr/local/etc/snmp/snmpd.conf on FreeBSD) with snmpd.conf supplied. -## Config file # -rocommunity public 127.0.0.1 -rocommunity6 public ::1 -rwcommunity private 127.0.0.1 - -Do not enable them - being set here they make appropriate OID switch into r/o -#syslocation "Somewhere in the world" -#syscontact "root" - -#SNMPv3 credentials -rouser adminMD5 -rouser adminSHA -rwuser adminMD5AES -rouser adminMD5AES128 -rouser adminMD5DES -createUser adminMD5 MD5 test1234 -createUser adminSHA SHA test1234 -createUser adminMD5AES MD5 test1234 AES test1234 -createUser adminMD5AES128 MD5 test1234 AES test1234 -createUser adminMD5DES MD5 test1234 DES test1234 - -createUser noAuthUser -authuser read noAuthUser noauth -## End # - Before launching daemon make sure that there is no file /var/net-snmp/snmpd.conf -Delete it if exists. Ingoring to to so will fail SNMPv3 tests +Delete it if exists. Ingoring to to so will fail SNMPv3 tests. -Make snmpd bind on localhost only. To do so, pass '127.0.0.1' into it's startup arguments -(see /etc/init.d/snmpd on Linux and set snmpd_flags="127.0.0.1" in rc.conf in FreeBSD). -Otherwise your SNMP daemon will answer SNMPv3 messages from remote clients. +- Launch snmpd (service snmpd start or /etc/init.d/snmpd start). + Alternatively you can start snmpd daemon using following command line: +sudo snmpd -C -c ./snmpd.conf -f -Le -- Launch snmpd (service snmpd start or /etc/init.d/snmpd start) On Windows -- Copied: php/php-src/branches/PHP_5_4/ext/snmp/tests/snmpd.conf (from rev 315386, php/php-src/trunk/ext/snmp/tests/snmpd.conf) === --- php/php-src/branches/PHP_5_4/ext/snmp/tests/snmpd.conf (rev 0) +++ php/php-src/branches/PHP_5_4/ext/snmp/tests/snmpd.conf 2011-08-23 19:15:58 UTC (rev 315387) @@ -0,0 +1,25 @@ +# Listen for connections from the local system only +agentaddress udp:127.0.0.1:161,udp6:[::1]:161 + +rocommunity public 127.0.0.1 +rocommunity6 public ::1 +rwcommunity private 127.0.0.1 + +Do not enable them - being set here they make appropriate OID switch into r/o +#syslocation "Somewhere in the world" +#syscontact "root" + +#SNMPv3 credentials +rouser adminMD5 +rouser adminSHA +rwuser adminMD5AES +rouser adminMD5AES128 +rouser adminMD5DES +createUser adminMD5 MD5 test1234 +createUser adminSHA SHA test1234 +createUser adminMD5AES MD5 test1234 AES test1234 +createUser adminMD5AES128 MD5 test1234 AES test1234 +createUser adminMD5DES MD5 test1234 DES test1234 + +createUser noAuthUser +authuser read noAuthUser noauth -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/ext/snmp/tests/README trunk/ext/snmp/tests/README
lytboris Thu, 25 Aug 2011 06:00:11 + Revision: http://svn.php.net/viewvc?view=revision&revision=315461 Log: tune test's README more per FR #55474 Bug: https://bugs.php.net/55474 (Feedback) Improve tests/README... Changed paths: U php/php-src/branches/PHP_5_4/ext/snmp/tests/README U php/php-src/trunk/ext/snmp/tests/README Modified: php/php-src/branches/PHP_5_4/ext/snmp/tests/README === --- php/php-src/branches/PHP_5_4/ext/snmp/tests/README 2011-08-25 02:05:18 UTC (rev 315460) +++ php/php-src/branches/PHP_5_4/ext/snmp/tests/README 2011-08-25 06:00:11 UTC (rev 315461) @@ -16,6 +16,13 @@ SNMP_COMMUNITY_WRITE : community used for write tests (snmpset()). SNMP_MIBDIR : Directory containing MIBS +To run test suite you may use this command (presuming that you pwd is where +this README file is located): +> make -C ../../.. test TESTS="`cd ../../..; /bin/ls -1 ext/snmp/tests/*.phpt | xargs echo`" +Running run-tests.php directly will clear your environment and therefore +tests will fail if your SNMP configuration does not fit into default values +specified in snmp_include.inc. + ** Configuring the SNMPD server ** On Linux/FreeBSD Modified: php/php-src/trunk/ext/snmp/tests/README === --- php/php-src/trunk/ext/snmp/tests/README 2011-08-25 02:05:18 UTC (rev 315460) +++ php/php-src/trunk/ext/snmp/tests/README 2011-08-25 06:00:11 UTC (rev 315461) @@ -16,6 +16,13 @@ SNMP_COMMUNITY_WRITE : community used for write tests (snmpset()). SNMP_MIBDIR : Directory containing MIBS +To run test suite you may use this command (presuming that you pwd is where +this README file is located): +> make -C ../../.. test TESTS="`cd ../../..; /bin/ls -1 ext/snmp/tests/*.phpt | xargs echo`" +Running run-tests.php directly will clear your environment and therefore +tests will fail if your SNMP configuration does not fit into default values +specified in snmp_include.inc. + ** Configuring the SNMPD server ** On Linux/FreeBSD -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/snmp/ snmp.c tests/snmp2_get.phpt tests/snmpget.phpt
lytboris Sat, 27 Aug 2011 07:33:27 + Revision: http://svn.php.net/viewvc?view=revision&revision=315607 Log: merge from trunk: reformat OID parsing procedure, fail whole SNMP query on single OID parsing failure Changed paths: _U php/php-src/branches/PHP_5_4/ext/snmp/ U php/php-src/branches/PHP_5_4/ext/snmp/snmp.c _U php/php-src/branches/PHP_5_4/ext/snmp/tests/ U php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp2_get.phpt U php/php-src/branches/PHP_5_4/ext/snmp/tests/snmpget.phpt Property changes on: php/php-src/branches/PHP_5_4/ext/snmp ___ Modified: svn:mergeinfo - /php/php-src/trunk/ext/snmp:284726,311033-315236 + /php/php-src/trunk/ext/snmp:284726,311033-315236,315606 Modified: php/php-src/branches/PHP_5_4/ext/snmp/snmp.c === --- php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2011-08-27 07:24:44 UTC (rev 315606) +++ php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2011-08-27 07:33:27 UTC (rev 315607) @@ -729,24 +729,28 @@ while (keepwalking) { keepwalking = 0; - if (st & (SNMP_CMD_GET | SNMP_CMD_GETNEXT)) { - pdu = snmp_pdu_create((st & SNMP_CMD_GET) ? SNMP_MSG_GET : SNMP_MSG_GETNEXT); - for (count = 0; objid_query->offset < objid_query->count && count < objid_query->step; objid_query->offset++, count++){ - objid_query->vars[objid_query->offset].name_length = MAX_OID_LEN; - if (!snmp_parse_oid(objid_query->vars[objid_query->offset].oid, objid_query->vars[objid_query->offset].name, &(objid_query->vars[objid_query->offset].name_length))) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid_query->vars[objid_query->offset].oid); - } else { - snmp_add_null_var(pdu, objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length); - } + if (st & SNMP_CMD_WALK) { + if (session->version == SNMP_VERSION_1) { + pdu = snmp_pdu_create(SNMP_MSG_GETNEXT); + } else { + pdu = snmp_pdu_create(SNMP_MSG_GETBULK); + pdu->non_repeaters = objid_query->non_repeaters; + pdu->max_repetitions = objid_query->max_repetitions; } - if(pdu->variables == NULL){ - snmp_free_pdu(pdu); + snmp_add_null_var(pdu, name, name_length); + } else { + if (st & SNMP_CMD_GET) { + pdu = snmp_pdu_create(SNMP_MSG_GET); + } else if (st & SNMP_CMD_GETNEXT) { + pdu = snmp_pdu_create(SNMP_MSG_GETNEXT); + } else if (st & SNMP_CMD_SET) { + pdu = snmp_pdu_create(SNMP_MSG_SET); + } else { snmp_close(ss); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unknown SNMP command (internals)"); RETVAL_FALSE; return; } - } else if (st & SNMP_CMD_SET) { - pdu = snmp_pdu_create(SNMP_MSG_SET); for (count = 0; objid_query->offset < objid_query->count && count < objid_query->step; objid_query->offset++, count++){ objid_query->vars[objid_query->offset].name_length = MAX_OID_LEN; if (!snmp_parse_oid(objid_query->vars[objid_query->offset].oid, objid_query->vars[objid_query->offset].name, &(objid_query->vars[objid_query->offset].name_length))) { @@ -755,7 +759,8 @@ snmp_close(ss); RETVAL_FALSE; return; - } else { + } + if (st & SNMP_CMD_SET) { if ((snmp_errno = snmp_add_var(pdu, objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value))) { snprint_objid(buf, sizeof(buf), objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length); php_error_docref(NULL TSRMLS_CC, E_WARNING, "C
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c tests/snmp2_get.phpt tests/snmpget.phpt
lytboris Sat, 27 Aug 2011 07:24:44 + Revision: http://svn.php.net/viewvc?view=revision&revision=315606 Log: reformat OID parsing procedure, fail whole SNMP query on single OID parsing failure Changed paths: U php/php-src/trunk/ext/snmp/snmp.c U php/php-src/trunk/ext/snmp/tests/snmp2_get.phpt U php/php-src/trunk/ext/snmp/tests/snmpget.phpt Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-08-27 01:52:47 UTC (rev 315605) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-08-27 07:24:44 UTC (rev 315606) @@ -744,24 +744,28 @@ while (keepwalking) { keepwalking = 0; - if (st & (SNMP_CMD_GET | SNMP_CMD_GETNEXT)) { - pdu = snmp_pdu_create((st & SNMP_CMD_GET) ? SNMP_MSG_GET : SNMP_MSG_GETNEXT); - for (count = 0; objid_query->offset < objid_query->count && count < objid_query->step; objid_query->offset++, count++){ - objid_query->vars[objid_query->offset].name_length = MAX_OID_LEN; - if (!snmp_parse_oid(objid_query->vars[objid_query->offset].oid, objid_query->vars[objid_query->offset].name, &(objid_query->vars[objid_query->offset].name_length))) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid_query->vars[objid_query->offset].oid); - } else { - snmp_add_null_var(pdu, objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length); - } + if (st & SNMP_CMD_WALK) { + if (session->version == SNMP_VERSION_1) { + pdu = snmp_pdu_create(SNMP_MSG_GETNEXT); + } else { + pdu = snmp_pdu_create(SNMP_MSG_GETBULK); + pdu->non_repeaters = objid_query->non_repeaters; + pdu->max_repetitions = objid_query->max_repetitions; } - if(pdu->variables == NULL){ - snmp_free_pdu(pdu); + snmp_add_null_var(pdu, name, name_length); + } else { + if (st & SNMP_CMD_GET) { + pdu = snmp_pdu_create(SNMP_MSG_GET); + } else if (st & SNMP_CMD_GETNEXT) { + pdu = snmp_pdu_create(SNMP_MSG_GETNEXT); + } else if (st & SNMP_CMD_SET) { + pdu = snmp_pdu_create(SNMP_MSG_SET); + } else { snmp_close(ss); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unknown SNMP command (internals)"); RETVAL_FALSE; return; } - } else if (st & SNMP_CMD_SET) { - pdu = snmp_pdu_create(SNMP_MSG_SET); for (count = 0; objid_query->offset < objid_query->count && count < objid_query->step; objid_query->offset++, count++){ objid_query->vars[objid_query->offset].name_length = MAX_OID_LEN; if (!snmp_parse_oid(objid_query->vars[objid_query->offset].oid, objid_query->vars[objid_query->offset].name, &(objid_query->vars[objid_query->offset].name_length))) { @@ -770,7 +774,8 @@ snmp_close(ss); RETVAL_FALSE; return; - } else { + } + if (st & SNMP_CMD_SET) { if ((snmp_errno = snmp_add_var(pdu, objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value))) { snprint_objid(buf, sizeof(buf), objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not add variable: OID='%s' type='%c' value='%s': %s", buf, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value, snmp_api_errstring(snmp_errno)); @@ -779,17 +784,16 @@ RETVAL_FALSE; return; } + } else { + snmp_add_nu
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ php_snmp.h snmp.c tests/snmp-object-errno-errstr.phpt
lytboris Sat, 27 Aug 2011 08:16:32 + Revision: http://svn.php.net/viewvc?view=revision&revision=315608 Log: export ERRNO_OID_PARSING_ERROR constant: raise it evry time OID parsing has failed Changed paths: U php/php-src/trunk/ext/snmp/php_snmp.h U php/php-src/trunk/ext/snmp/snmp.c U php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt Modified: php/php-src/trunk/ext/snmp/php_snmp.h === --- php/php-src/trunk/ext/snmp/php_snmp.h 2011-08-27 07:33:27 UTC (rev 315607) +++ php/php-src/trunk/ext/snmp/php_snmp.h 2011-08-27 08:16:32 UTC (rev 315608) @@ -94,7 +94,7 @@ int oid_output_format; int snmp_errno; int oid_increasing_check; - char snmp_errstr[128]; + char snmp_errstr[256]; } php_snmp_object; Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-08-27 07:33:27 UTC (rev 315607) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-08-27 08:16:32 UTC (rev 315608) @@ -117,6 +117,7 @@ #define PHP_SNMP_ERRNO_TIMEOUT 2 #define PHP_SNMP_ERRNO_ERROR_IN_REPLY 3 #define PHP_SNMP_ERRNO_OID_NOT_INCREASING 4 +#define PHP_SNMP_ERRNO_OID_PARSING_ERROR 5 ZEND_DECLARE_MODULE_GLOBALS(snmp) static PHP_GINIT_FUNCTION(snmp); @@ -705,7 +706,7 @@ if (st & SNMP_CMD_WALK) { if (objid_query->count > 1) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Multi OID walks are not supported!"); + php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Multi OID walks are not supported!"); RETURN_FALSE; } rootlen = MAX_NAME_LEN; @@ -713,7 +714,7 @@ if (snmp_parse_oid(objid_query->vars[0].oid, root, &rootlen)) { gotroot = 1; } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid_query->vars[0].oid); + php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Invalid object identifier: %s", objid_query->vars[0].oid); RETVAL_FALSE; return; } @@ -769,7 +770,7 @@ for (count = 0; objid_query->offset < objid_query->count && count < objid_query->step; objid_query->offset++, count++){ objid_query->vars[objid_query->offset].name_length = MAX_OID_LEN; if (!snmp_parse_oid(objid_query->vars[objid_query->offset].oid, objid_query->vars[objid_query->offset].name, &(objid_query->vars[objid_query->offset].name_length))) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid_query->vars[objid_query->offset].oid); + php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Invalid object identifier: %s", objid_query->vars[objid_query->offset].oid); snmp_free_pdu(pdu); snmp_close(ss); RETVAL_FALSE; @@ -778,7 +779,7 @@ if (st & SNMP_CMD_SET) { if ((snmp_errno = snmp_add_var(pdu, objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value))) { snprint_objid(buf, sizeof(buf), objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not add variable: OID='%s' type='%c' value='%s': %s", buf, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value, snmp_api_errstring(snmp_errno)); + php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Could not add variable: OID='%s' type='%c' value='%s': %s", buf, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value, snmp_api_errstring(snmp_errno)); snmp_free_pdu(pdu); snmp_close(ss); RETVAL_FALSE; @@ -2437,6 +2438,7 @@ REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_TIMEOUT", (long)PHP_SNMP_ERRNO_TIMEOUT); REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_ERROR_IN_REPLY", (long)PHP_SNM
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/snmp/tests/ snmp-object-errno-errstr.phpt
lytboris Sat, 27 Aug 2011 08:29:19 + Revision: http://svn.php.net/viewvc?view=revision&revision=315609 Log: merge from trunk: export ERRNO_OID_PARSING_ERROR constant: raise it evry time OID parsing has failed Changed paths: _U php/php-src/branches/PHP_5_4/ext/snmp/tests/ U php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-errno-errstr.phpt Property changes on: php/php-src/branches/PHP_5_4/ext/snmp/tests ___ Modified: svn:mergeinfo - /php/php-src/trunk/ext/snmp/tests:284726,311033-315236,315386,315606 + /php/php-src/trunk/ext/snmp/tests:284726,311033-315236,315386,315606,315608 Modified: php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-errno-errstr.phpt === --- php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-errno-errstr.phpt 2011-08-27 08:16:32 UTC (rev 315608) +++ php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-errno-errstr.phpt 2011-08-27 08:29:19 UTC (rev 315609) @@ -30,12 +30,14 @@ var_dump($session->getErrno() == SNMP::ERRNO_TIMEOUT); var_dump($session->getError()); $session->close(); + echo "SNMP::ERRNO_ERROR_IN_REPLY\n"; $session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries); var_dump(@$session->get('.1.3.6.1.2.1.1.1.110')); var_dump($session->getErrno() == SNMP::ERRNO_ERROR_IN_REPLY); var_dump($session->getError()); $session->close(); + echo "SNMP::ERRNO_GENERIC\n"; $session = new SNMP(SNMP::VERSION_3, $hostname, 'somebogususer', $timeout, $retries); $session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass); @@ -44,6 +46,33 @@ var_dump($session->getError()); var_dump(@$session->get(array('.1.3.6.1.2.1.1.1.0'))); $session->close(); + +echo "SNMP::ERRNO_OID_PARSING_ERROR\n"; +echo "GET: Single wrong OID\n"; +$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries); +var_dump(@$session->get('.1.3.6.1.2..1.1.1.0')); +var_dump($session->getErrno() == SNMP::ERRNO_OID_PARSING_ERROR); +var_dump($session->getError()); +$session->close(); +echo "GET: Miltiple OID, one wrong\n"; +$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries); +var_dump(@$session->get(array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2..1.1.1.0'))); +var_dump($session->getErrno() == SNMP::ERRNO_OID_PARSING_ERROR); +var_dump($session->getError()); +$session->close(); +echo "WALK: Single wrong OID\n"; +$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries); +var_dump(@$session->walk('.1.3.6.1.2..1.1')); +var_dump($session->getErrno() == SNMP::ERRNO_OID_PARSING_ERROR); +var_dump($session->getError()); +$session->close(); +echo "SET: Wrong type\n"; +$session = new SNMP(SNMP::VERSION_3, $hostname, $rwuser, $timeout, $retries); +$session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass); +$oid1 = 'SNMPv2-MIB::sysContact.0'; +var_dump(@$session->set($oid1, 'q', 'blah')); +var_dump($session->getErrno() == SNMP::ERRNO_OID_PARSING_ERROR); +var_dump($session->getError()); ?> --EXPECTF-- SNMP::ERRNO_NOERROR @@ -63,3 +92,20 @@ bool(true) %string|unicode%(%d) "Fatal error: Unknown user name" bool(false) +SNMP::ERRNO_OID_PARSING_ERROR +GET: Single wrong OID +bool(false) +bool(true) +string(46) "Invalid object identifier: .1.3.6.1.2..1.1.1.0" +GET: Miltiple OID, one wrong +bool(false) +bool(true) +string(46) "Invalid object identifier: .1.3.6.1.2..1.1.1.0" +WALK: Single wrong OID +bool(false) +bool(true) +string(42) "Invalid object identifier: .1.3.6.1.2..1.1" +SET: Wrong type +bool(false) +bool(true) +string(129) "Could not add variable: OID='.iso.org.dod.internet.mgmt.mib-2.system.sysContact.0' type='q' value='blah': Bad variable type ("q")" \ No newline at end of file -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/snmp/ php_snmp.h snmp.c
lytboris Tue, 30 Aug 2011 14:24:00 + Revision: http://svn.php.net/viewvc?view=revision&revision=315786 Log: merge from trunk: set ERRNO_OID_PARSING_ERROR on OID parse error Changed paths: _U php/php-src/branches/PHP_5_4/ext/snmp/ U php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h U php/php-src/branches/PHP_5_4/ext/snmp/snmp.c Property changes on: php/php-src/branches/PHP_5_4/ext/snmp ___ Modified: svn:mergeinfo - /php/php-src/trunk/ext/snmp:284726,311033-315236,315606 + /php/php-src/trunk/ext/snmp:284726,311033-315236,315606,315608 Modified: php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h === --- php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h2011-08-30 14:17:02 UTC (rev 315785) +++ php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h2011-08-30 14:24:00 UTC (rev 315786) @@ -94,7 +94,7 @@ int oid_output_format; int snmp_errno; int oid_increasing_check; - char snmp_errstr[128]; + char snmp_errstr[256]; } php_snmp_object; Modified: php/php-src/branches/PHP_5_4/ext/snmp/snmp.c === --- php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2011-08-30 14:17:02 UTC (rev 315785) +++ php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2011-08-30 14:24:00 UTC (rev 315786) @@ -109,6 +109,7 @@ #define PHP_SNMP_ERRNO_TIMEOUT 2 #define PHP_SNMP_ERRNO_ERROR_IN_REPLY 3 #define PHP_SNMP_ERRNO_OID_NOT_INCREASING 4 +#define PHP_SNMP_ERRNO_OID_PARSING_ERROR 5 ZEND_DECLARE_MODULE_GLOBALS(snmp) static PHP_GINIT_FUNCTION(snmp); @@ -690,7 +691,7 @@ if (st & SNMP_CMD_WALK) { if (objid_query->count > 1) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Multi OID walks are not supported!"); + php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Multi OID walks are not supported!"); RETURN_FALSE; } rootlen = MAX_NAME_LEN; @@ -698,7 +699,7 @@ if (snmp_parse_oid(objid_query->vars[0].oid, root, &rootlen)) { gotroot = 1; } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid_query->vars[0].oid); + php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Invalid object identifier: %s", objid_query->vars[0].oid); RETVAL_FALSE; return; } @@ -754,7 +755,7 @@ for (count = 0; objid_query->offset < objid_query->count && count < objid_query->step; objid_query->offset++, count++){ objid_query->vars[objid_query->offset].name_length = MAX_OID_LEN; if (!snmp_parse_oid(objid_query->vars[objid_query->offset].oid, objid_query->vars[objid_query->offset].name, &(objid_query->vars[objid_query->offset].name_length))) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid_query->vars[objid_query->offset].oid); + php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Invalid object identifier: %s", objid_query->vars[objid_query->offset].oid); snmp_free_pdu(pdu); snmp_close(ss); RETVAL_FALSE; @@ -763,7 +764,7 @@ if (st & SNMP_CMD_SET) { if ((snmp_errno = snmp_add_var(pdu, objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value))) { snprint_objid(buf, sizeof(buf), objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not add variable: OID='%s' type='%c' value='%s': %s", buf, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value, snmp_api_errstring(snmp_errno)); + php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Could not add variable: OID='%s' type='%c' value='%s': %s", buf, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value, snmp_api_errstring(snmp_errno)); snmp_free_pdu(pdu);
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c tests/snmp-object.phpt tests/snmp3-error.phpt
lytboris Wed, 31 Aug 2011 08:28:13 + Revision: http://svn.php.net/viewvc?view=revision&revision=315862 Log: more tuning based on discussion in FR #40816: * parse all OIDs earlier, detect all wrong OIDs before any query is made (GET-operations) * introduce ERRNO_MULTIPLE_SET_QUERIES: warn if request contains more OIDs than max_oids and SET operation (and type&value checks) will be done in chunks. fix set method when request contains more OIDs than max_oids (2nd and subsequent chunk were ignored) Bug: https://bugs.php.net/40816 (Feedback) Add "snmptranslate" function Changed paths: U php/php-src/trunk/ext/snmp/snmp.c U php/php-src/trunk/ext/snmp/tests/snmp-object.phpt U php/php-src/trunk/ext/snmp/tests/snmp3-error.phpt Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-08-31 07:49:52 UTC (rev 315861) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-08-31 08:28:13 UTC (rev 315862) @@ -118,6 +118,7 @@ #define PHP_SNMP_ERRNO_ERROR_IN_REPLY 3 #define PHP_SNMP_ERRNO_OID_NOT_INCREASING 4 #define PHP_SNMP_ERRNO_OID_PARSING_ERROR 5 +#define PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES 6 ZEND_DECLARE_MODULE_GLOBALS(snmp) static PHP_GINIT_FUNCTION(snmp); @@ -685,11 +686,8 @@ struct snmp_session *ss; struct snmp_pdu *pdu=NULL, *response; struct variable_list *vars; - oid name[MAX_NAME_LEN]; - size_t name_length; oid root[MAX_NAME_LEN]; size_t rootlen = 0; - int gotroot = 0; int status, count, found; char buf[2048]; char buf2[2048]; @@ -704,35 +702,10 @@ /* reset errno and errstr */ php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_NOERROR, ""); - if (st & SNMP_CMD_WALK) { - if (objid_query->count > 1) { - php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Multi OID walks are not supported!"); - RETURN_FALSE; - } - rootlen = MAX_NAME_LEN; - if (strlen(objid_query->vars[0].oid)) { /* on a walk, an empty string means top of tree - no error */ - if (snmp_parse_oid(objid_query->vars[0].oid, root, &rootlen)) { -gotroot = 1; - } else { -php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Invalid object identifier: %s", objid_query->vars[0].oid); -RETVAL_FALSE; -return; - } - } - - if (!gotroot) { - memmove((char *) root, (char *) objid_mib, sizeof(objid_mib)); - rootlen = sizeof(objid_mib) / sizeof(oid); - gotroot = 1; - } - - memmove((char *)name, (char *)root, rootlen * sizeof(oid)); - name_length = rootlen; + if (st & SNMP_CMD_WALK) { /* remember root OID */ + memmove((char *)root, (char *)(objid_query->vars[0].name), (objid_query->vars[0].name_length) * sizeof(oid)); + rootlen = objid_query->vars[0].name_length; objid_query->offset = objid_query->count; - - memmove((char *)objid_query->vars[0].name, (char *)root, rootlen * sizeof(oid)); - objid_query->vars[0].name_length = rootlen; - } if ((ss = snmp_open(session)) == NULL) { @@ -743,6 +716,10 @@ return; } + if ((st & SNMP_CMD_SET) && objid_query->count > objid_query->step) { + php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES, "Can not fit all OIDs for SET query into one packet, using multiple queries"); + } + while (keepwalking) { keepwalking = 0; if (st & SNMP_CMD_WALK) { @@ -753,7 +730,7 @@ pdu->non_repeaters = objid_query->non_repeaters; pdu->max_repetitions = objid_query->max_repetitions; } - snmp_add_null_var(pdu, name, name_length); + snmp_add_null_var(pdu, objid_query->vars[0].name, objid_query->vars[0].name_length); } else { if (st & SNMP_CMD_GET) { pdu = snmp_pdu_create(SNMP_MSG_GET); @@ -768,14 +745,6 @@ return; } for (count = 0; objid_query->offset < objid_query->count && count < objid_query->step; objid_query->offset++, count++){ -objid_query->vars[objid_query->offset].name_length = MAX_OID_LEN; -if (!snmp_parse_oid(objid_query->vars[objid_query->offset].oid, objid_query->vars[objid_query->offset].name, &(objid_query->vars[objid_query->offset].name_length))) { - php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Invalid object identifier: %s", objid_query->vars[objid_query->offset].oid); - snmp_free_pdu(pdu); - snmp_close(ss); - RETVAL_FALSE; - return; -} if (st & SNMP_CMD_SET) { if ((snmp_errno = snmp_add_var(pdu, objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value))) { snprint_objid(buf, sizeof(buf), objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length); @@ -802,6 +771,10 @@ if (status == STAT_SUCCESS) { if (response->errstat == SNMP_ERR_NOERROR) { if (st & SNMP_CMD_SET) { + if (objid_query->offset < objid_
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/snmp/ snmp.c tests/snmp-object.phpt tests/snmp3-error.phpt
lytboris Wed, 31 Aug 2011 08:36:22 + Revision: http://svn.php.net/viewvc?view=revision&revision=315865 Log: more tuning based on discussion in FR #40816: * parse all OIDs earlier, detect all wrong OIDs before any query is made (GET-operations) * introduce ERRNO_MULTIPLE_SET_QUERIES: warn if request contains more OIDs than max_oids and SET operation (and type&value checks) will be done in chunks. fix set method when request contains more OIDs than max_oids (2nd and subsequent chunk were ignored) Bug: https://bugs.php.net/40816 (Feedback) Add "snmptranslate" function Changed paths: _U php/php-src/branches/PHP_5_4/ext/snmp/ U php/php-src/branches/PHP_5_4/ext/snmp/snmp.c _U php/php-src/branches/PHP_5_4/ext/snmp/tests/ U php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object.phpt U php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp3-error.phpt Property changes on: php/php-src/branches/PHP_5_4/ext/snmp ___ Modified: svn:mergeinfo - /php/php-src/trunk/ext/snmp:284726,311033-315236,315606,315608 + /php/php-src/trunk/ext/snmp:284726,311033-315236,315606,315608,315862 Modified: php/php-src/branches/PHP_5_4/ext/snmp/snmp.c === --- php/php-src/branches/PHP_5_4/ext/snmp/snmp.c 2011-08-31 08:35:57 UTC (rev 315864) +++ php/php-src/branches/PHP_5_4/ext/snmp/snmp.c 2011-08-31 08:36:22 UTC (rev 315865) @@ -110,6 +110,7 @@ #define PHP_SNMP_ERRNO_ERROR_IN_REPLY 3 #define PHP_SNMP_ERRNO_OID_NOT_INCREASING 4 #define PHP_SNMP_ERRNO_OID_PARSING_ERROR 5 +#define PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES 6 ZEND_DECLARE_MODULE_GLOBALS(snmp) static PHP_GINIT_FUNCTION(snmp); @@ -670,11 +671,8 @@ struct snmp_session *ss; struct snmp_pdu *pdu=NULL, *response; struct variable_list *vars; - oid name[MAX_NAME_LEN]; - size_t name_length; oid root[MAX_NAME_LEN]; size_t rootlen = 0; - int gotroot = 0; int status, count, found; char buf[2048]; char buf2[2048]; @@ -689,35 +687,10 @@ /* reset errno and errstr */ php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_NOERROR, ""); - if (st & SNMP_CMD_WALK) { - if (objid_query->count > 1) { - php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Multi OID walks are not supported!"); - RETURN_FALSE; - } - rootlen = MAX_NAME_LEN; - if (strlen(objid_query->vars[0].oid)) { /* on a walk, an empty string means top of tree - no error */ - if (snmp_parse_oid(objid_query->vars[0].oid, root, &rootlen)) { -gotroot = 1; - } else { -php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Invalid object identifier: %s", objid_query->vars[0].oid); -RETVAL_FALSE; -return; - } - } - - if (!gotroot) { - memmove((char *) root, (char *) objid_mib, sizeof(objid_mib)); - rootlen = sizeof(objid_mib) / sizeof(oid); - gotroot = 1; - } - - memmove((char *)name, (char *)root, rootlen * sizeof(oid)); - name_length = rootlen; + if (st & SNMP_CMD_WALK) { /* remember root OID */ + memmove((char *)root, (char *)(objid_query->vars[0].name), (objid_query->vars[0].name_length) * sizeof(oid)); + rootlen = objid_query->vars[0].name_length; objid_query->offset = objid_query->count; - - memmove((char *)objid_query->vars[0].name, (char *)root, rootlen * sizeof(oid)); - objid_query->vars[0].name_length = rootlen; - } if ((ss = snmp_open(session)) == NULL) { @@ -728,6 +701,10 @@ return; } + if ((st & SNMP_CMD_SET) && objid_query->count > objid_query->step) { + php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES, "Can not fit all OIDs for SET query into one packet, using multiple queries"); + } + while (keepwalking) { keepwalking = 0; if (st & SNMP_CMD_WALK) { @@ -738,7 +715,7 @@ pdu->non_repeaters = objid_query->non_repeaters; pdu->max_repetitions = objid_query->max_repetitions; } - snmp_add_null_var(pdu, name, name_length); + snmp_add_null_var(pdu, objid_query->vars[0].name, objid_query->vars[0].name_length); } else { if (st & SNMP_CMD_GET) { pdu = snmp_pdu_create(SNMP_MSG_GET); @@ -753,14 +730,6 @@ return; } for (count = 0; objid_query->offset < objid_query->count && count < objid_query->step; objid_query->offset++, count++){ -objid_query->vars[objid_query->offset].name_length = MAX_OID_LEN; -if (!snmp_parse_oid(objid_query->vars[objid_query->offset].oid, objid_query->vars[objid_query->offset].name, &(objid_query->vars[objid_query->offset].name_length))) { - php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Invalid object identifier: %s", objid_query->vars[objid_query->offset].oid); - snmp_free_pdu(pdu); - snmp_close(ss); - RETVAL_FALSE; - return; -} if (st & SNMP_CMD_SET) { if ((snmp_errno = snmp_add_var(pdu, objid_query->vars[objid_query->offset]
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/tests/ snmp-object-errno-errstr.phpt
lytboris Wed, 31 Aug 2011 19:44:39 + Revision: http://svn.php.net/viewvc?view=revision&revision=315916 Log: test coverage for SNMP::ERRNO_MULTIPLE_SET_QUERIES Changed paths: U php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt Modified: php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt === --- php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt 2011-08-31 19:40:42 UTC (rev 315915) +++ php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt 2011-08-31 19:44:39 UTC (rev 315916) @@ -73,6 +73,30 @@ var_dump(@$session->set($oid1, 'q', 'blah')); var_dump($session->getErrno() == SNMP::ERRNO_OID_PARSING_ERROR); var_dump($session->getError()); + +echo "SNMP::ERRNO_MULTIPLE_SET_QUERIES\n"; +$oid1 = 'SNMPv2-MIB::sysContact.0'; +$oid2 = 'SNMPv2-MIB::sysLocation.0'; +$session = new SNMP(SNMP::VERSION_3, $hostname, $rwuser, $timeout, $retries); +$session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass); +$session->max_oids = 1; +$oldvalue1 = $session->get($oid1); +$newvalue1 = $oldvalue1 . '0'; +$oldvalue2 = $session->get($oid2); +$newvalue2 = $oldvalue2 . '0'; +$z = @$session->set(array($oid1, $oid2), array('s','s'), array($newvalue1, $newvalue2)); +var_dump($z); +var_dump($session->getErrno() == SNMP::ERRNO_MULTIPLE_SET_QUERIES); +var_dump($session->getError()); +var_dump(($session->get($oid1) === $newvalue1)); +var_dump(($session->get($oid2) === $newvalue2)); +$z = @$session->set(array($oid1, $oid2), array('s','s'), array($oldvalue1, $oldvalue2)); +var_dump($z); +var_dump($session->getErrno() == SNMP::ERRNO_MULTIPLE_SET_QUERIES); +var_dump($session->getError()); +var_dump(($session->get($oid1) === $oldvalue1)); +var_dump(($session->get($oid2) === $oldvalue2)); +var_dump($session->close()); ?> --EXPECTF-- SNMP::ERRNO_NOERROR @@ -108,4 +132,16 @@ SET: Wrong type bool(false) bool(true) -string(129) "Could not add variable: OID='.iso.org.dod.internet.mgmt.mib-2.system.sysContact.0' type='q' value='blah': Bad variable type ("q")" \ No newline at end of file +string(129) "Could not add variable: OID='.iso.org.dod.internet.mgmt.mib-2.system.sysContact.0' type='q' value='blah': Bad variable type ("q")" +SNMP::ERRNO_MULTIPLE_SET_QUERIES +bool(true) +bool(true) +string(74) "Can not fit all OIDs for SET query into one packet, using multiple queries" +bool(true) +bool(true) +bool(true) +bool(true) +string(74) "Can not fit all OIDs for SET query into one packet, using multiple queries" +bool(true) +bool(true) +bool(true) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/snmp/tests/ snmp-object-errno-errstr.phpt
lytboris Wed, 31 Aug 2011 19:45:45 + Revision: http://svn.php.net/viewvc?view=revision&revision=315917 Log: test coverage for SNMP::ERRNO_MULTIPLE_SET_QUERIES Changed paths: _U php/php-src/branches/PHP_5_4/ext/snmp/tests/ U php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-errno-errstr.phpt Property changes on: php/php-src/branches/PHP_5_4/ext/snmp/tests ___ Modified: svn:mergeinfo - /php/php-src/trunk/ext/snmp/tests:284726,311033-315236,315386,315606,315608,315862 + /php/php-src/trunk/ext/snmp/tests:284726,311033-315236,315386,315606,315608,315862,315916 Modified: php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-errno-errstr.phpt === --- php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-errno-errstr.phpt 2011-08-31 19:44:39 UTC (rev 315916) +++ php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-errno-errstr.phpt 2011-08-31 19:45:45 UTC (rev 315917) @@ -73,6 +73,30 @@ var_dump(@$session->set($oid1, 'q', 'blah')); var_dump($session->getErrno() == SNMP::ERRNO_OID_PARSING_ERROR); var_dump($session->getError()); + +echo "SNMP::ERRNO_MULTIPLE_SET_QUERIES\n"; +$oid1 = 'SNMPv2-MIB::sysContact.0'; +$oid2 = 'SNMPv2-MIB::sysLocation.0'; +$session = new SNMP(SNMP::VERSION_3, $hostname, $rwuser, $timeout, $retries); +$session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass); +$session->max_oids = 1; +$oldvalue1 = $session->get($oid1); +$newvalue1 = $oldvalue1 . '0'; +$oldvalue2 = $session->get($oid2); +$newvalue2 = $oldvalue2 . '0'; +$z = @$session->set(array($oid1, $oid2), array('s','s'), array($newvalue1, $newvalue2)); +var_dump($z); +var_dump($session->getErrno() == SNMP::ERRNO_MULTIPLE_SET_QUERIES); +var_dump($session->getError()); +var_dump(($session->get($oid1) === $newvalue1)); +var_dump(($session->get($oid2) === $newvalue2)); +$z = @$session->set(array($oid1, $oid2), array('s','s'), array($oldvalue1, $oldvalue2)); +var_dump($z); +var_dump($session->getErrno() == SNMP::ERRNO_MULTIPLE_SET_QUERIES); +var_dump($session->getError()); +var_dump(($session->get($oid1) === $oldvalue1)); +var_dump(($session->get($oid2) === $oldvalue2)); +var_dump($session->close()); ?> --EXPECTF-- SNMP::ERRNO_NOERROR @@ -108,4 +132,16 @@ SET: Wrong type bool(false) bool(true) -string(129) "Could not add variable: OID='.iso.org.dod.internet.mgmt.mib-2.system.sysContact.0' type='q' value='blah': Bad variable type ("q")" \ No newline at end of file +string(129) "Could not add variable: OID='.iso.org.dod.internet.mgmt.mib-2.system.sysContact.0' type='q' value='blah': Bad variable type ("q")" +SNMP::ERRNO_MULTIPLE_SET_QUERIES +bool(true) +bool(true) +string(74) "Can not fit all OIDs for SET query into one packet, using multiple queries" +bool(true) +bool(true) +bool(true) +bool(true) +string(74) "Can not fit all OIDs for SET query into one packet, using multiple queries" +bool(true) +bool(true) +bool(true) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c
lytboris Wed, 31 Aug 2011 20:15:32 + Revision: http://svn.php.net/viewvc?view=revision&revision=315924 Log: tune text align Changed paths: U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-08-31 20:14:13 UTC (rev 315923) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-08-31 20:15:32 UTC (rev 315924) @@ -112,13 +112,13 @@ } \ } -#define PHP_SNMP_ERRNO_NOERROR 0 -#define PHP_SNMP_ERRNO_GENERIC 1 -#define PHP_SNMP_ERRNO_TIMEOUT 2 -#define PHP_SNMP_ERRNO_ERROR_IN_REPLY 3 -#define PHP_SNMP_ERRNO_OID_NOT_INCREASING 4 -#define PHP_SNMP_ERRNO_OID_PARSING_ERROR 5 -#define PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES 6 +#define PHP_SNMP_ERRNO_NOERROR 0 +#define PHP_SNMP_ERRNO_GENERIC 1 +#define PHP_SNMP_ERRNO_TIMEOUT 2 +#define PHP_SNMP_ERRNO_ERROR_IN_REPLY 3 +#define PHP_SNMP_ERRNO_OID_NOT_INCREASING 4 +#define PHP_SNMP_ERRNO_OID_PARSING_ERROR 5 +#define PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES6 ZEND_DECLARE_MODULE_GLOBALS(snmp) static PHP_GINIT_FUNCTION(snmp); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/snmp/ snmp.c
lytboris Wed, 31 Aug 2011 20:16:56 + Revision: http://svn.php.net/viewvc?view=revision&revision=315926 Log: tune text align Changed paths: _U php/php-src/branches/PHP_5_4/ext/snmp/ U php/php-src/branches/PHP_5_4/ext/snmp/snmp.c _U php/php-src/branches/PHP_5_4/ext/snmp/tests/ Property changes on: php/php-src/branches/PHP_5_4/ext/snmp ___ Modified: svn:mergeinfo - /php/php-src/trunk/ext/snmp:284726,311033-315236,315606,315608,315862 + /php/php-src/trunk/ext/snmp:284726,311033-315236,315606,315608,315862,315924 Modified: php/php-src/branches/PHP_5_4/ext/snmp/snmp.c === --- php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2011-08-31 20:16:11 UTC (rev 315925) +++ php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2011-08-31 20:16:56 UTC (rev 315926) @@ -104,13 +104,13 @@ } \ } -#define PHP_SNMP_ERRNO_NOERROR 0 -#define PHP_SNMP_ERRNO_GENERIC 1 -#define PHP_SNMP_ERRNO_TIMEOUT 2 -#define PHP_SNMP_ERRNO_ERROR_IN_REPLY 3 -#define PHP_SNMP_ERRNO_OID_NOT_INCREASING 4 -#define PHP_SNMP_ERRNO_OID_PARSING_ERROR 5 -#define PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES 6 +#define PHP_SNMP_ERRNO_NOERROR 0 +#define PHP_SNMP_ERRNO_GENERIC 1 +#define PHP_SNMP_ERRNO_TIMEOUT 2 +#define PHP_SNMP_ERRNO_ERROR_IN_REPLY 3 +#define PHP_SNMP_ERRNO_OID_NOT_INCREASING 4 +#define PHP_SNMP_ERRNO_OID_PARSING_ERROR 5 +#define PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES6 ZEND_DECLARE_MODULE_GLOBALS(snmp) static PHP_GINIT_FUNCTION(snmp); Property changes on: php/php-src/branches/PHP_5_4/ext/snmp/tests ___ Modified: svn:mergeinfo - /php/php-src/trunk/ext/snmp/tests:284726,311033-315236,315386,315606,315608,315862,315916 + /php/php-src/trunk/ext/snmp/tests:284726,311033-315236,315386,315606,315608,315862,315916,315924 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ php_snmp.h snmp.c
lytboris Fri, 02 Sep 2011 08:07:58 + Revision: http://svn.php.net/viewvc?view=revision&revision=316022 Log: remove php_snmp_get_ce() Changed paths: U php/php-src/trunk/ext/snmp/php_snmp.h U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/ext/snmp/php_snmp.h === --- php/php-src/trunk/ext/snmp/php_snmp.h 2011-09-02 07:18:24 UTC (rev 316021) +++ php/php-src/trunk/ext/snmp/php_snmp.h 2011-09-02 08:07:58 UTC (rev 316022) @@ -127,7 +127,7 @@ #endif #define REGISTER_SNMP_CLASS_CONST_LONG(const_name, value) \ - zend_declare_class_constant_long(php_snmp_get_ce(), const_name, sizeof(const_name)-1, (long)value TSRMLS_CC); + zend_declare_class_constant_long(php_snmp_ce, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC); #else Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-09-02 07:18:24 UTC (rev 316021) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-09-02 08:07:58 UTC (rev 316022) @@ -132,13 +132,8 @@ static zend_object_handlers php_snmp_object_handlers; /* Class entries */ -zend_class_entry *php_snmp_class_entry; +zend_class_entry *php_snmp_ce; -zend_class_entry *php_snmp_get_ce() -{ - return php_snmp_class_entry; -} - /* Class object properties */ static HashTable php_snmp_properties; @@ -2399,7 +2394,7 @@ INIT_CLASS_ENTRY(ce, "SNMP", php_snmp_class_methods); ce.create_object = php_snmp_object_new; php_snmp_object_handlers.clone_obj = NULL; - php_snmp_class_entry = zend_register_internal_class(&ce TSRMLS_CC); + php_snmp_ce = zend_register_internal_class(&ce TSRMLS_CC); /* Register SNMP Class properties */ zend_hash_init(&php_snmp_properties, 0, NULL, NULL, 1); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/snmp/ php_snmp.h snmp.c
lytboris Fri, 02 Sep 2011 08:09:23 + Revision: http://svn.php.net/viewvc?view=revision&revision=316023 Log: merge from trunk: remove php_snmp_get_ce() Changed paths: _U php/php-src/branches/PHP_5_4/ext/snmp/ U php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h U php/php-src/branches/PHP_5_4/ext/snmp/snmp.c _U php/php-src/branches/PHP_5_4/ext/snmp/tests/ Property changes on: php/php-src/branches/PHP_5_4/ext/snmp ___ Modified: svn:mergeinfo - /php/php-src/trunk/ext/snmp:284726,311033-315236,315606,315608,315862,315924 + /php/php-src/trunk/ext/snmp:284726,311033-315236,315606,315608,315862,315924,316022 Modified: php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h === --- php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h2011-09-02 08:07:58 UTC (rev 316022) +++ php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h2011-09-02 08:09:23 UTC (rev 316023) @@ -127,7 +127,7 @@ #endif #define REGISTER_SNMP_CLASS_CONST_LONG(const_name, value) \ - zend_declare_class_constant_long(php_snmp_get_ce(), const_name, sizeof(const_name)-1, (long)value TSRMLS_CC); + zend_declare_class_constant_long(php_snmp_ce, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC); #else Modified: php/php-src/branches/PHP_5_4/ext/snmp/snmp.c === --- php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2011-09-02 08:07:58 UTC (rev 316022) +++ php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2011-09-02 08:09:23 UTC (rev 316023) @@ -124,13 +124,8 @@ static zend_object_handlers php_snmp_object_handlers; /* Class entries */ -zend_class_entry *php_snmp_class_entry; +zend_class_entry *php_snmp_ce; -zend_class_entry *php_snmp_get_ce() -{ - return php_snmp_class_entry; -} - /* Class object properties */ static HashTable php_snmp_properties; @@ -2330,7 +2325,7 @@ INIT_CLASS_ENTRY(ce, "SNMP", php_snmp_class_methods); ce.create_object = php_snmp_object_new; php_snmp_object_handlers.clone_obj = NULL; - php_snmp_class_entry = zend_register_internal_class(&ce TSRMLS_CC); + php_snmp_ce = zend_register_internal_class(&ce TSRMLS_CC); /* Register SNMP Class properties */ zend_hash_init(&php_snmp_properties, 0, NULL, NULL, 1); Property changes on: php/php-src/branches/PHP_5_4/ext/snmp/tests ___ Modified: svn:mergeinfo - /php/php-src/trunk/ext/snmp/tests:284726,311033-315236,315386,315606,315608,315862,315916,315924 + /php/php-src/trunk/ext/snmp/tests:284726,311033-315236,315386,315606,315608,315862,315916,315924,316022 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ php_snmp.h snmp.c tests/snmp-object-error.phpt tests/snmp-object-properties.phpt
lytboris Fri, 02 Sep 2011 10:04:19 + Revision: http://svn.php.net/viewvc?view=revision&revision=316029 Log: added SNMPException class, enabling ability to throw exceptions when a known SNMP error has occured FR #55542 Bug: https://bugs.php.net/55542 (Assigned) SNMP class should use Exceptions instead of PHP Errors Changed paths: U php/php-src/trunk/ext/snmp/php_snmp.h U php/php-src/trunk/ext/snmp/snmp.c U php/php-src/trunk/ext/snmp/tests/snmp-object-error.phpt U php/php-src/trunk/ext/snmp/tests/snmp-object-properties.phpt Modified: php/php-src/trunk/ext/snmp/php_snmp.h === --- php/php-src/trunk/ext/snmp/php_snmp.h 2011-09-02 09:27:23 UTC (rev 316028) +++ php/php-src/trunk/ext/snmp/php_snmp.h 2011-09-02 10:04:19 UTC (rev 316029) @@ -94,6 +94,7 @@ int oid_output_format; int snmp_errno; int oid_increasing_check; + int exceptions_enabled; char snmp_errstr[256]; } php_snmp_object; Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-09-02 09:27:23 UTC (rev 316028) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-09-02 10:04:19 UTC (rev 316029) @@ -34,6 +34,10 @@ #include "zend_exceptions.h" +#if HAVE_SPL +#include "ext/spl/spl_exceptions.h" +#endif + #if HAVE_SNMP #include @@ -113,12 +117,21 @@ } #define PHP_SNMP_ERRNO_NOERROR 0 -#define PHP_SNMP_ERRNO_GENERIC 1 -#define PHP_SNMP_ERRNO_TIMEOUT 2 -#define PHP_SNMP_ERRNO_ERROR_IN_REPLY 3 -#define PHP_SNMP_ERRNO_OID_NOT_INCREASING 4 -#define PHP_SNMP_ERRNO_OID_PARSING_ERROR 5 -#define PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES 6 +#define PHP_SNMP_ERRNO_GENERIC (1 << 1) +#define PHP_SNMP_ERRNO_TIMEOUT (1 << 2) +#define PHP_SNMP_ERRNO_ERROR_IN_REPLY (1 << 3) +#define PHP_SNMP_ERRNO_OID_NOT_INCREASING (1 << 4) +#define PHP_SNMP_ERRNO_OID_PARSING_ERROR (1 << 5) +#define PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES (1 << 6) +#define PHP_SNMP_ERRNO_ANY ( \ + PHP_SNMP_ERRNO_GENERIC | \ + PHP_SNMP_ERRNO_TIMEOUT | \ + PHP_SNMP_ERRNO_ERROR_IN_REPLY | \ + PHP_SNMP_ERRNO_OID_NOT_INCREASING | \ + PHP_SNMP_ERRNO_OID_PARSING_ERROR | \ + PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES | \ + PHP_SNMP_ERRNO_NOERROR \ + ) ZEND_DECLARE_MODULE_GLOBALS(snmp) static PHP_GINIT_FUNCTION(snmp); @@ -133,6 +146,7 @@ /* Class entries */ zend_class_entry *php_snmp_ce; +zend_class_entry *php_snmp_exception_ce; /* Class object properties */ static HashTable php_snmp_properties; @@ -533,9 +547,13 @@ return; } - va_start(args, format); - php_verror(docref, "", E_WARNING, format, args TSRMLS_CC); - va_end(args); + if (object && (snmp_object->exceptions_enabled & type)) { + zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr TSRMLS_CC); + } else { + va_start(args, format); + php_verror(docref, "", E_WARNING, format, args TSRMLS_CC); + va_end(args); + } } /* }}} */ @@ -1829,6 +1847,7 @@ snmp_object->oid_output_format = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT); snmp_object->quick_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT); snmp_object->oid_increasing_check = TRUE; + snmp_object->exceptions_enabled = 0; } /* }}} */ @@ -2204,6 +2223,7 @@ PHP_SNMP_LONG_PROPERTY_READER_FUNCTION(valueretrieval) PHP_SNMP_LONG_PROPERTY_READER_FUNCTION(oid_output_format) +PHP_SNMP_LONG_PROPERTY_READER_FUNCTION(exceptions_enabled) /* {{{ */ static int php_snmp_write_info(php_snmp_object *snmp_object, zval *newval TSRMLS_DC) @@ -2330,6 +2350,27 @@ } /* }}} */ +/* {{{ */ +static int php_snmp_write_exceptions_enabled(php_snmp_object *snmp_object, zval *newval TSRMLS_DC) +{ + zval ztmp; + int ret = SUCCESS; + if (Z_TYPE_P(newval) != IS_LONG) { + ztmp = *newval; + zval_copy_ctor(&ztmp); + convert_to_long(&ztmp); + newval = &ztmp; + } + + snmp_object->exceptions_enabled = Z_LVAL_P(newval); + + if (newval == &ztmp) { + zval_dtor(newval); + } + return ret; +} +/* }}} */ + /* {{{ php_snmp_class_methods[] */ static zend_function_entry php_snmp_class_methods[] = { PHP_ME(snmp, __construct, arginfo_snmp_create, ZEND_ACC_PUBLIC) @@ -2357,6 +2398,7 @@ PHP_SNMP_PROPERTY_ENTRY_RECORD(enum_print), PHP_SNMP_PROPERTY_ENTRY_RECORD(oid_output_format), PHP_SNMP_PROPERTY_ENTRY_RECORD(oid_increasing_check), + PHP_SNMP_PROPERTY_ENTRY_RECORD(exceptions_enabled), { NULL, 0, NULL, NULL} }; /* }}} */ @@ -2366,7 +2408,7 @@ PHP_MINIT_FUNCTION(snmp) { netsnmp_log_handler *logh; - zend_class_entry ce; + zend_class_entry ce, cex; le_snmp_session = zend_register_list_destructors_ex(php_snmp_session_destructor, NULL, PHP_SNMP_SESSION_RES_NAME, module_number); @@ -2424,19 +2466,28 @@ REGISTER_LONG_CONSTANT("SNMP_INTEGER", ASN_INTEGER, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SNMP_COUNTER64", ASN_COUNTER64, CONST_CS | CONST_PERSISTENT); -
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c
lytboris Fri, 02 Sep 2011 10:07:01 + Revision: http://svn.php.net/viewvc?view=revision&revision=316031 Log: remove extra white space Changed paths: U php/php-src/trunk/ext/snmp/snmp.c Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2011-09-02 10:06:06 UTC (rev 316030) +++ php/php-src/trunk/ext/snmp/snmp.c 2011-09-02 10:07:01 UTC (rev 316031) @@ -2526,8 +2526,6 @@ ZEND_MOD_END }; #endif - - /* }}} */ /* {{{ snmp_module_entry -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/snmp/ php_snmp.h snmp.c tests/snmp-object-error.phpt tests/snmp-object-properties.phpt
lytboris Fri, 02 Sep 2011 10:13:30 + Revision: http://svn.php.net/viewvc?view=revision&revision=316032 Log: merge from trunk added SNMPException class, enabling ability to throw exceptions when a known SNMP error has occured FR #55542 Bug: https://bugs.php.net/55542 (Assigned) SNMP class should use Exceptions instead of PHP Errors Changed paths: _U php/php-src/branches/PHP_5_4/ext/snmp/ U php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h U php/php-src/branches/PHP_5_4/ext/snmp/snmp.c _U php/php-src/branches/PHP_5_4/ext/snmp/tests/ U php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-error.phpt U php/php-src/branches/PHP_5_4/ext/snmp/tests/snmp-object-properties.phpt Property changes on: php/php-src/branches/PHP_5_4/ext/snmp ___ Modified: svn:mergeinfo - /php/php-src/trunk/ext/snmp:284726,311033-315236,315606,315608,315862,315924,316022 + /php/php-src/trunk/ext/snmp:284726,311033-315236,315606,315608,315862,315924,316022,316029,316031 Modified: php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h === --- php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h 2011-09-02 10:07:01 UTC (rev 316031) +++ php/php-src/branches/PHP_5_4/ext/snmp/php_snmp.h 2011-09-02 10:13:30 UTC (rev 316032) @@ -94,6 +94,7 @@ int oid_output_format; int snmp_errno; int oid_increasing_check; + int exceptions_enabled; char snmp_errstr[256]; } php_snmp_object; Modified: php/php-src/branches/PHP_5_4/ext/snmp/snmp.c === --- php/php-src/branches/PHP_5_4/ext/snmp/snmp.c 2011-09-02 10:07:01 UTC (rev 316031) +++ php/php-src/branches/PHP_5_4/ext/snmp/snmp.c 2011-09-02 10:13:30 UTC (rev 316032) @@ -34,6 +34,10 @@ #include "zend_exceptions.h" +#if HAVE_SPL +#include "ext/spl/spl_exceptions.h" +#endif + #if HAVE_SNMP #include @@ -105,12 +109,21 @@ } #define PHP_SNMP_ERRNO_NOERROR 0 -#define PHP_SNMP_ERRNO_GENERIC 1 -#define PHP_SNMP_ERRNO_TIMEOUT 2 -#define PHP_SNMP_ERRNO_ERROR_IN_REPLY 3 -#define PHP_SNMP_ERRNO_OID_NOT_INCREASING 4 -#define PHP_SNMP_ERRNO_OID_PARSING_ERROR 5 -#define PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES 6 +#define PHP_SNMP_ERRNO_GENERIC (1 << 1) +#define PHP_SNMP_ERRNO_TIMEOUT (1 << 2) +#define PHP_SNMP_ERRNO_ERROR_IN_REPLY (1 << 3) +#define PHP_SNMP_ERRNO_OID_NOT_INCREASING (1 << 4) +#define PHP_SNMP_ERRNO_OID_PARSING_ERROR (1 << 5) +#define PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES (1 << 6) +#define PHP_SNMP_ERRNO_ANY ( \ + PHP_SNMP_ERRNO_GENERIC | \ + PHP_SNMP_ERRNO_TIMEOUT | \ + PHP_SNMP_ERRNO_ERROR_IN_REPLY | \ + PHP_SNMP_ERRNO_OID_NOT_INCREASING | \ + PHP_SNMP_ERRNO_OID_PARSING_ERROR | \ + PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES | \ + PHP_SNMP_ERRNO_NOERROR \ + ) ZEND_DECLARE_MODULE_GLOBALS(snmp) static PHP_GINIT_FUNCTION(snmp); @@ -125,6 +138,7 @@ /* Class entries */ zend_class_entry *php_snmp_ce; +zend_class_entry *php_snmp_exception_ce; /* Class object properties */ static HashTable php_snmp_properties; @@ -518,9 +532,13 @@ return; } - va_start(args, format); - php_verror(docref, "", E_WARNING, format, args TSRMLS_CC); - va_end(args); + if (object && (snmp_object->exceptions_enabled & type)) { + zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr TSRMLS_CC); + } else { + va_start(args, format); + php_verror(docref, "", E_WARNING, format, args TSRMLS_CC); + va_end(args); + } } /* }}} */ @@ -1796,6 +1814,7 @@ snmp_object->oid_output_format = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT); snmp_object->quick_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT); snmp_object->oid_increasing_check = TRUE; + snmp_object->exceptions_enabled = 0; } /* }}} */ @@ -2135,6 +2154,7 @@ PHP_SNMP_LONG_PROPERTY_READER_FUNCTION(valueretrieval) PHP_SNMP_LONG_PROPERTY_READER_FUNCTION(oid_output_format) +PHP_SNMP_LONG_PROPERTY_READER_FUNCTION(exceptions_enabled) /* {{{ */ static int php_snmp_write_info(php_snmp_object *snmp_object, zval *newval TSRMLS_DC) @@ -2261,6 +2281,27 @@ } /* }}} */ +/* {{{ */ +static int php_snmp_write_exceptions_enabled(php_snmp_object *snmp_object, zval *newval TSRMLS_DC) +{ + zval ztmp; + int ret = SUCCESS; + if (Z_TYPE_P(newval) != IS_LONG) { + ztmp = *newval; + zval_copy_ctor(&ztmp); + convert_to_long(&ztmp); + newval = &ztmp; + } + + snmp_object->exceptions_enabled = Z_LVAL_P(newval); + + if (newval == &ztmp) { + zval_dtor(newval); + } + return ret; +} +/* }}} */ + /* {{{ php_snmp_class_methods[] */ static zend_function_entry php_snmp_class_methods[] = { PHP_ME(snmp, __construct, arginfo_snmp_create, ZEND_ACC_PUBLIC) @@ -2288,6 +2329,7 @@ PHP_SNMP_PROPERTY_ENTRY_RECORD(enum_print), PHP_SNMP_PROPERTY_ENTRY_RECORD(oid_output_format), PHP_SNMP_PROPERTY_ENTRY_RECORD(oid_incre
[PHP-CVS] svn: /php/php-src/trunk/ext/snmp/ snmp.c tests/bug60749.phpt tests/ipv6.phpt
lytboris Fri, 13 Jan 2012 18:34:21 + Revision: http://svn.php.net/viewvc?view=revision&revision=322213 Log: Fixed bug #60585 (php build fails with USE flag snmp when IPv6 support is disabled) Fixed bug #60749 (SNMP module should not strip non-standard SNMP port from hostname) Fixed ipv6 test skipto if IPv6 support is disabled Bugs: https://bugs.php.net/60585 (Assigned) php build fails with USE flag snmp when IPv6 support is disabled https://bugs.php.net/60749 (Assigned) SNMP module should not strip non-standard SNMP port from hostname Changed paths: U php/php-src/trunk/ext/snmp/snmp.c A php/php-src/trunk/ext/snmp/tests/bug60749.phpt U php/php-src/trunk/ext/snmp/tests/ipv6.phpt Modified: php/php-src/trunk/ext/snmp/snmp.c === --- php/php-src/trunk/ext/snmp/snmp.c 2012-01-13 17:15:19 UTC (rev 322212) +++ php/php-src/trunk/ext/snmp/snmp.c 2012-01-13 18:34:21 UTC (rev 322213) @@ -1186,11 +1186,11 @@ continue; } #else - if (res->sa_family != AF_INET) { + if ((*res)->sa_family != AF_INET) { res++; continue; } - strcat(pptr, inet_ntoa(res)); + strcat(pptr, inet_ntoa(((struct sockaddr_in*)(*res))->sin_addr)); #endif break; } @@ -1203,6 +1203,12 @@ There should be check for non-empty session->peername! */ + /* put back non-standard SNMP port */ + if (session->remote_port != SNMP_PORT) { + pptr = session->peername + strlen(session->peername); + sprintf(pptr, ":%d", session->remote_port); + } + php_network_freeaddresses(psal); if (version == SNMP_VERSION_3) { Added: php/php-src/trunk/ext/snmp/tests/bug60749.phpt === --- php/php-src/trunk/ext/snmp/tests/bug60749.phpt (rev 0) +++ php/php-src/trunk/ext/snmp/tests/bug60749.phpt 2012-01-13 18:34:21 UTC (rev 322213) @@ -0,0 +1,28 @@ +--TEST-- +Bug #60749: SNMP module should not strip non-standard SNMP port from hostname +--CREDITS-- +Boris Lytochkin +--SKIPIF-- + +--FILE-- +info; +if (strcmp($info["hostname"], "$ip:$port") !== 0) { + echo "'" . $info["hostname"] . "' != '$ip:$port'\n"; +} +var_dump($session->close()); +?> +--EXPECTF-- +bool(true) Modified: php/php-src/trunk/ext/snmp/tests/ipv6.phpt === --- php/php-src/trunk/ext/snmp/tests/ipv6.phpt 2012-01-13 17:15:19 UTC (rev 322212) +++ php/php-src/trunk/ext/snmp/tests/ipv6.phpt 2012-01-13 18:34:21 UTC (rev 322213) @@ -4,16 +4,17 @@ Boris Lytochkin --SKIPIF-- --FILE-- -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ NEWS ext/snmp/snmp.c ext/snmp/tests/bug60749.phpt ext/snmp/tests/ipv6.phpt
lytboris Fri, 13 Jan 2012 18:46:56 + Revision: http://svn.php.net/viewvc?view=revision&revision=322214 Log: merge from trunk: Fixed bug #60585 (php build fails with USE flag snmp when IPv6 support is disabled Fixed bug #60749 (SNMP module should not strip non-standard SNMP port from hostname Bugs: https://bugs.php.net/60585 (Assigned) php build fails with USE flag snmp when IPv6 support is disabled https://bugs.php.net/60749 (Assigned) SNMP module should not strip non-standard SNMP port from hostname Changed paths: U php/php-src/branches/PHP_5_4/NEWS _U php/php-src/branches/PHP_5_4/ext/snmp/ U php/php-src/branches/PHP_5_4/ext/snmp/snmp.c _U php/php-src/branches/PHP_5_4/ext/snmp/tests/ A + php/php-src/branches/PHP_5_4/ext/snmp/tests/bug60749.phpt (from php/php-src/trunk/ext/snmp/tests/bug60749.phpt:r322213) U php/php-src/branches/PHP_5_4/ext/snmp/tests/ipv6.phpt Modified: php/php-src/branches/PHP_5_4/NEWS === --- php/php-src/branches/PHP_5_4/NEWS 2012-01-13 18:34:21 UTC (rev 322213) +++ php/php-src/branches/PHP_5_4/NEWS 2012-01-13 18:46:56 UTC (rev 322214) @@ -12,6 +12,12 @@ . Fixed bug #53280 (segfaults if query column count less than param count). (Mariuz) +- SNMP: + . Fixed bug #60585 (php build fails with USE flag snmp when IPv6 support +is disabled). (Boris Lytochkin) + . Fixed bug #60749 (SNMP module should not strip non-standard SNMP port +from hostname). (Boris Lytochkin) + 07 Jan 2012, PHP 5.4.0 RC5 - Core: . Fixed bug #60613 (Segmentation fault with $cls->{expr}() syntax). (Dmitry) Property changes on: php/php-src/branches/PHP_5_4/ext/snmp ___ Modified: svn:mergeinfo - /php/php-src/trunk/ext/snmp:284726,311033-315236,315606,315608,315862,315924,316022,316029,316031 + /php/php-src/trunk/ext/snmp:284726,311033-315236,315606,315608,315862,315924,316022,316029,316031,322213 Modified: php/php-src/branches/PHP_5_4/ext/snmp/snmp.c === --- php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2012-01-13 18:34:21 UTC (rev 322213) +++ php/php-src/branches/PHP_5_4/ext/snmp/snmp.c2012-01-13 18:46:56 UTC (rev 322214) @@ -1171,11 +1171,11 @@ continue; } #else - if (res->sa_family != AF_INET) { + if ((*res)->sa_family != AF_INET) { res++; continue; } - strcat(pptr, inet_ntoa(res)); + strcat(pptr, inet_ntoa(((struct sockaddr_in*)(*res))->sin_addr)); #endif break; } @@ -1188,6 +1188,12 @@ There should be check for non-empty session->peername! */ + /* put back non-standard SNMP port */ + if (session->remote_port != SNMP_PORT) { + pptr = session->peername + strlen(session->peername); + sprintf(pptr, ":%d", session->remote_port); + } + php_network_freeaddresses(psal); if (version == SNMP_VERSION_3) { Property changes on: php/php-src/branches/PHP_5_4/ext/snmp/tests ___ Modified: svn:mergeinfo - /php/php-src/trunk/ext/snmp/tests:284726,311033-315236,315386,315606,315608,315862,315916,315924,316022,316029,316031 + /php/php-src/trunk/ext/snmp/tests:284726,311033-315236,315386,315606,315608,315862,315916,315924,316022,316029,316031,322213 Copied: php/php-src/branches/PHP_5_4/ext/snmp/tests/bug60749.phpt (from rev 322213, php/php-src/trunk/ext/snmp/tests/bug60749.phpt) === --- php/php-src/branches/PHP_5_4/ext/snmp/tests/bug60749.phpt (rev 0) +++ php/php-src/branches/PHP_5_4/ext/snmp/tests/bug60749.phpt 2012-01-13 18:46:56 UTC (rev 322214) @@ -0,0 +1,28 @@ +--TEST-- +Bug #60749: SNMP module should not strip non-standard SNMP port from hostname +--CREDITS-- +Boris Lytochkin +--SKIPIF-- + +--FILE-- +info; +if (strcmp($info["hostname"], "$ip:$port") !== 0) { + echo "'" . $info["hostname"] . "' != '$ip:$port'\n"; +} +var_dump($session->close()); +?> +--EXPECTF-- +bool(true) Modified: php/php-src/branches/PHP_5_4/ext/snmp/tests/ipv6.phpt === --- php/php-src/branches/PHP_5_4/ext/snmp/tests/ipv6.phpt 2012-01-13 18:34:21 UTC (rev 322213) +++ php/php-src/branches/PHP_5_4/ext/snmp/tests/ipv6.phpt 2012-01-13 18:46:56 UTC (rev 322214) @@ -4,16 +4,17 @@ Boris Lytochkin --SKIPIF-- --FILE-- -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php