harrie          Wed Mar 16 11:19:59 2005 EDT

  Modified files:              (Branch: PHP_4_3)
    /php-src/ext/snmp   php_snmp.h snmp.c 
  Log:
  Adding SNMPv2 community based (i.e. protocol version) functions.
  
  
http://cvs.php.net/diff.php/php-src/ext/snmp/php_snmp.h?r1=1.14.2.5&r2=1.14.2.6&ty=u
Index: php-src/ext/snmp/php_snmp.h
diff -u php-src/ext/snmp/php_snmp.h:1.14.2.5 
php-src/ext/snmp/php_snmp.h:1.14.2.6
--- php-src/ext/snmp/php_snmp.h:1.14.2.5        Sat Jan  8 07:02:50 2005
+++ php-src/ext/snmp/php_snmp.h Wed Mar 16 11:19:59 2005
@@ -20,7 +20,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_snmp.h,v 1.14.2.5 2005/01/08 12:02:50 sniper Exp $ */
+/* $Id: php_snmp.h,v 1.14.2.6 2005/03/16 16:19:59 harrie Exp $ */
 
 #ifndef PHP_SNMP_H
 #define PHP_SNMP_H
@@ -51,6 +51,12 @@
 PHP_FUNCTION(snmp_set_oid_numeric_print);
 PHP_FUNCTION(snmpset);
 
+PHP_FUNCTION(snmp2_get);
+PHP_FUNCTION(snmp2_getnext);
+PHP_FUNCTION(snmp2_walk);
+PHP_FUNCTION(snmp2_real_walk);
+PHP_FUNCTION(snmp2_set);
+
 PHP_FUNCTION(snmp3_get);
 PHP_FUNCTION(snmp3_walk);
 PHP_FUNCTION(snmp3_real_walk);
http://cvs.php.net/diff.php/php-src/ext/snmp/snmp.c?r1=1.70.2.17&r2=1.70.2.18&ty=u
Index: php-src/ext/snmp/snmp.c
diff -u php-src/ext/snmp/snmp.c:1.70.2.17 php-src/ext/snmp/snmp.c:1.70.2.18
--- php-src/ext/snmp/snmp.c:1.70.2.17   Sat Feb 12 13:30:03 2005
+++ php-src/ext/snmp/snmp.c     Wed Mar 16 11:19:59 2005
@@ -20,7 +20,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: snmp.c,v 1.70.2.17 2005/02/12 18:30:03 sniper Exp $ */
+/* $Id: snmp.c,v 1.70.2.18 2005/03/16 16:19:59 harrie Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -134,6 +134,11 @@
 #endif
        PHP_FE(snmpset, NULL)
 
+       PHP_FE(snmp2_get, NULL)
+       PHP_FE(snmp2_walk, NULL)
+       PHP_FE(snmp2_real_walk, NULL)
+       PHP_FE(snmp2_set, NULL)
+
        PHP_FE(snmp3_get, NULL)
        PHP_FE(snmp3_walk, NULL)
        PHP_FE(snmp3_real_walk, NULL)
@@ -322,7 +327,7 @@
 
 /* {{{ php_snmp_internal
 *
-* Generic SNMP object fetcher (for both v3 and v1)
+* Generic SNMP object fetcher (for all SNMP versions)
 *
 * st=1   snmpget()  - query an agent and return a single value.
 * st=2   snmpwalk() - walk the mib and return a single dimensional array 
@@ -515,7 +520,7 @@
 
 /* {{{ php_snmp
 *
-* Generic SNMPv1 handler
+* Generic community based SNMP handler for version 1 and 2.
 * This function makes use of the internal SNMP object fetcher.
 * The object fetcher is shared with SNMPv3.
 *
@@ -528,7 +533,7 @@
 * st=11  snmpset() - query an agent and set a single value
 *
 */
-static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st) 
+static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version) 
 {
        zval **a1, **a2, **a3, **a4, **a5, **a6, **a7;
        struct snmp_session session;
@@ -590,7 +595,7 @@
 
        session.peername = hostname;
        session.remote_port = remote_port;
-       session.version = SNMP_VERSION_1;
+       session.version = version;
        /*
        * FIXME: potential memory leak
        * This is a workaround for an "artifact" (Mike Slifcak)
@@ -616,7 +621,7 @@
    Fetch a SNMP object */
 PHP_FUNCTION(snmpget)
 {
-       php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
+       php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,1, SNMP_VERSION_1);
 }
 /* }}} */
 
@@ -624,7 +629,7 @@
    Return all objects under the specified object id */
 PHP_FUNCTION(snmpwalk)
 {
-       php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,2);
+       php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,2, SNMP_VERSION_1);
 }
 /* }}} */
 
@@ -632,7 +637,7 @@
    Return all objects including their respective object id withing the 
specified one */
 PHP_FUNCTION(snmprealwalk)
 {
-       php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,3);
+       php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,3, SNMP_VERSION_1);
 }
 /* }}} */
 
@@ -710,7 +715,7 @@
    Set the value of a SNMP object */
 PHP_FUNCTION(snmpset)
 {
-       php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,11);
+       php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,11, SNMP_VERSION_1);
 }
 /* }}} */
 
@@ -792,6 +797,9 @@
 * symbol on purpose, as it's defined to be the same as the former.
 */
                        || !strcasecmp(prot, "AES")) {
+                       s->securityPrivProto = usmAES128PrivProtocol;
+                       s->securityPrivProtoLen = 
OIDSIZE(usmAES128PrivProtocol);
+                       return (0);
 #else                  
                ) {
                        s->securityPrivProto = usmAES128PrivProtocol;
@@ -876,6 +884,37 @@
 }
 /* }}} */
 
+/* {{{ proto string snmp2_get(string host, string community, string object_id 
[, int timeout [, int retries]]) 
+   Fetch a SNMP object */
+PHP_FUNCTION(snmp2_get)
+{
+       php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,1, SNMP_VERSION_2c);
+}
+/* }}} */
+
+/* {{{ proto array snmp2_walk(string host, string community, string object_id 
[, int timeout [, int retries]]) 
+   Return all objects under the specified object id */
+PHP_FUNCTION(snmp2_walk)
+{
+       php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,2, SNMP_VERSION_2c);
+}
+/* }}} */
+
+/* {{{ proto array snmp2_real_walk(string host, string community, string 
object_id [, int timeout [, int retries]])
+   Return all objects including their respective object id withing the 
specified one */
+PHP_FUNCTION(snmp2_real_walk)
+{
+       php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,3, SNMP_VERSION_2c);
+}
+/* }}} */
+
+/* {{{ proto int snmp2_set(string host, string community, string object_id, 
string type, mixed value [, int timeout [, int retries]]) 
+   Set the value of a SNMP object */
+PHP_FUNCTION(snmp2_set)
+{
+       php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,11, SNMP_VERSION_2c);
+}
+/* }}} */
 
 /* {{{ proto void php_snmpv3(INTERNAL_FUNCTION_PARAMETERS, int st)
 *

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to