php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #53862
Patch ext-snmp-output-extensions revision 2011-01-27 23:19 UTC by mloftis at wgops dot com

Patch ext-snmp-output-extensions for SNMP related Bug #53862

Patch version 2011-01-27 23:19 UTC

Return to Bug #53862 | Download this patch
Patch Revisions:

Developer: mloftis@wgops.com

Index: ext/snmp/php_snmp.h
===================================================================
--- ext/snmp/php_snmp.h	(revision 307802)
+++ ext/snmp/php_snmp.h	(working copy)
@@ -50,6 +50,7 @@
 PHP_FUNCTION(snmp_set_quick_print);
 PHP_FUNCTION(snmp_set_enum_print);
 PHP_FUNCTION(snmp_set_oid_output_format);
+PHP_FUNCTION(snmp_get_oid_output_format);
 PHP_FUNCTION(snmpset);
 
 PHP_FUNCTION(snmp2_get);
Index: ext/snmp/snmp.c
===================================================================
--- ext/snmp/snmp.c	(revision 307802)
+++ ext/snmp/snmp.c	(working copy)
@@ -161,6 +161,9 @@
 ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp_set_oid_output_format, 0, 0, 1)
 	ZEND_ARG_INFO(0, oid_format)
 ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_snmp_get_oid_output_format, 0)
+ZEND_END_ARG_INFO()
 #endif
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_snmpset, 0, 0, 5)
@@ -313,6 +316,7 @@
 	PHP_FE(snmp_set_enum_print, 			arginfo_snmp_set_enum_print)
 	PHP_FE(snmp_set_oid_output_format, 		arginfo_snmp_set_oid_output_format)
 	PHP_FALIAS(snmp_set_oid_numeric_print, snmp_set_oid_output_format, arginfo_snmp_set_oid_output_format)
+	PHP_FE(snmp_get_oid_output_format, 		arginfo_snmp_get_oid_output_format)
 #endif
 	PHP_FE(snmpset, 				arginfo_snmpset)
 
@@ -389,6 +393,10 @@
 #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);
+	REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_SUFFIX", NETSNMP_OID_OUTPUT_SUFFIX, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_MODULE", NETSNMP_OID_OUTPUT_MODULE, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_UCD", NETSNMP_OID_OUTPUT_UCD, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_NONE", NETSNMP_OID_OUTPUT_NONE, CONST_CS | CONST_PERSISTENT);
 #endif
 
 	REGISTER_LONG_CONSTANT("SNMP_VALUE_LIBRARY", SNMP_VALUE_LIBRARY, CONST_CS | CONST_PERSISTENT);
@@ -930,19 +938,49 @@
 
 	switch ((int) a1) {
 		case 0:
+			a1 = NETSNMP_OID_OUTPUT_FULL;
+			break;
+
+		case NETSNMP_OID_OUTPUT_SUFFIX:
+			a1 = NETSNMP_OID_OUTPUT_SUFFIX;
+			break;
+
+		case NETSNMP_OID_OUTPUT_MODULE:
+			a1 = NETSNMP_OID_OUTPUT_MODULE;
+			break;
+
 		case NETSNMP_OID_OUTPUT_FULL:
 			a1 = NETSNMP_OID_OUTPUT_FULL;
 			break;
 
-		default:
 		case NETSNMP_OID_OUTPUT_NUMERIC:
 			a1 = NETSNMP_OID_OUTPUT_NUMERIC;
 			break;
+
+		case NETSNMP_OID_OUTPUT_UCD:
+			a1 = NETSNMP_OID_OUTPUT_UCD;
+			break;
+
+		case NETSNMP_OID_OUTPUT_NONE:
+			a1 = NETSNMP_OID_OUTPUT_NONE;
+			break;
+
+		default:
+			a1 = NETSNMP_OID_OUTPUT_NUMERIC;
+			break;
 	}
 
-	netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT, a1);
+	netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT, (int)a1);
 } 
 /* }}} */
+/* {{{ proto int snmp_set_oid_output_format()
+   Get the OID output format. */
+PHP_FUNCTION(snmp_get_oid_output_format)
+{
+	long a1 = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
+	RETURN_LONG(a1);
+}
+/* }}} */
 #endif
 
 /* {{{ proto int snmpset(string host, string community, string object_id, string type, mixed value [, int timeout [, int retries]]) 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 15:01:30 2024 UTC