]> granicus.if.org Git - php/commitdiff
MFH: - Fixed bug #37164 (snmp_set_oid_numeric_print() misbehaves)
authorfoobar <sniper@php.net>
Thu, 27 Jul 2006 05:17:34 +0000 (05:17 +0000)
committerfoobar <sniper@php.net>
Thu, 27 Jul 2006 05:17:34 +0000 (05:17 +0000)
MFH:   . Renamed the function to snmp_set_oid_output_format() which describes
MFH:     it's behaviour better. Old one was left as an alias for it.
MFH:   . Added 2 new constants: SNMP_OID_OUTPUT_FULL and SNMP_OID_OUTPUT_NUMERIC
MFH: - Fixed some memleaks

NEWS
ext/snmp/php_snmp.h
ext/snmp/snmp.c

diff --git a/NEWS b/NEWS
index 808eb20c4fa253fe55e519e552e5779a17ef26e5..030f6fbd43c57f32b2e8933f7d4bc892a826399d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,12 @@ PHP                                                                        NEWS
   . ext/filepro (Derick, Tony)
   . ext/hwapi (Derick, Tony)
 
+- Improved SNMP extension: (Jani)
+  . Renamed snmp_set_oid_numeric_print() to snmp_set_oid_output_format().
+  . Added 2 new constants: SNMP_OID_OUTPUT_FULL and SNMP_OID_OUTPUT_NUMERIC
+  . Fixed bug #37564 (AES privacy encryption not possible due to net-snmp 5.2
+    compatibility issue). (Patch: scott dot moynes+php at gmail dot com)
+
 - Fixed bug #38220 (Crash on some object operations). (Dmitry)
 - Fixed bug #38217 (ReflectionClass::newInstanceArgs() tries to allocate too 
   much memory). (Tony)
index 718fa47fcce39d24920431f498d9ea8a4c4ea882..16cbea270337926c3fb98319f56b1031a00a5e63 100644 (file)
@@ -49,7 +49,7 @@ PHP_FUNCTION(snmprealwalk);
 PHP_FUNCTION(snmp_get_quick_print);
 PHP_FUNCTION(snmp_set_quick_print);
 PHP_FUNCTION(snmp_set_enum_print);
-PHP_FUNCTION(snmp_set_oid_numeric_print);
+PHP_FUNCTION(snmp_set_oid_output_format);
 PHP_FUNCTION(snmpset);
 
 PHP_FUNCTION(snmp2_get);
index e0568cec183522449c56bcc2597215652137f3cc..10e7ff3be66c87b7fcfe620efea92e2dbad9002a 100644 (file)
@@ -124,7 +124,8 @@ zend_function_entry snmp_functions[] = {
        PHP_FE(snmp_set_quick_print, NULL)
 #ifdef HAVE_NET_SNMP
        PHP_FE(snmp_set_enum_print, NULL)
-       PHP_FE(snmp_set_oid_numeric_print, NULL)
+       PHP_FE(snmp_set_oid_output_format, NULL)
+       PHP_FALIAS(snmp_set_oid_numeric_print, snmp_set_oid_output_format, NULL)
 #endif
        PHP_FE(snmpset, NULL)
 
@@ -198,6 +199,11 @@ PHP_MINIT_FUNCTION(snmp)
        netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_PERSIST_STATE, 1);
 #endif
 
+#ifdef HAVE_NET_SNMP
+       REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_FULL", NETSNMP_OID_OUTPUT_FULL, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_NUMERIC", NETSNMP_OID_OUTPUT_NUMERIC, CONST_CS | CONST_PERSISTENT);
+#endif
+
        REGISTER_LONG_CONSTANT("SNMP_VALUE_LIBRARY", SNMP_VALUE_LIBRARY, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("SNMP_VALUE_PLAIN", SNMP_VALUE_PLAIN, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("SNMP_VALUE_OBJECT", SNMP_VALUE_OBJECT, CONST_CS | CONST_PERSISTENT);
@@ -432,13 +438,13 @@ static void php_snmp_internal(INTERNAL_FUNCTION_PARAMETERS, int st,
                                RETURN_FALSE;
                        }
                } else if (st >= SNMP_CMD_WALK) {
-                        if (session->version == SNMP_VERSION_1) {
+                       if (session->version == SNMP_VERSION_1) {
                                pdu = snmp_pdu_create(SNMP_MSG_GETNEXT);
                        } else {
                                pdu = snmp_pdu_create(SNMP_MSG_GETBULK);
                                pdu->non_repeaters = 0;
                                pdu->max_repetitions = 20;
-                        }
+                       }
                        snmp_add_null_var(pdu, name, name_length);
                }
 
@@ -522,6 +528,9 @@ retry:
                                                }
                                        }
                                        snmp_close(ss);
+                                       if (st == SNMP_CMD_WALK || st == SNMP_CMD_REALWALK) {
+                                               zval_dtor(return_value);
+                                       }
                                        RETURN_FALSE;
                                }
                        }
@@ -731,9 +740,9 @@ PHP_FUNCTION(snmp_set_enum_print)
 } 
 /* }}} */
 
-/* {{{ proto void snmp_set_oid_numeric_print(int oid_numeric_print)
-   Return all objects including their respective object id withing the specified one */
-PHP_FUNCTION(snmp_set_oid_numeric_print)
+/* {{{ proto void snmp_set_oid_output_format(int oid_format)
+   Set the OID output format. */
+PHP_FUNCTION(snmp_set_oid_output_format)
 {
        int argc = ZEND_NUM_ARGS();
        long a1;
@@ -741,11 +750,20 @@ PHP_FUNCTION(snmp_set_oid_numeric_print)
        if (zend_parse_parameters(argc TSRMLS_CC, "l", &a1) == FAILURE) {
                return;
        }
-       if ((int) a1 != 0) {
-               netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID,
-                       NETSNMP_DS_LIB_OID_OUTPUT_FORMAT,
-                       NETSNMP_OID_OUTPUT_NUMERIC);
+
+       switch ((int) a1) {
+               case 0:
+               case NETSNMP_OID_OUTPUT_FULL:
+                       a1 = NETSNMP_OID_OUTPUT_FULL;
+                       break;
+
+               default:
+               case NETSNMP_OID_OUTPUT_NUMERIC:
+                       a1 = NETSNMP_OID_OUTPUT_NUMERIC;
+                       break;
        }
+
+       netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT, a1);
 } 
 /* }}} */
 #endif