php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #26907 SNMP v2c parameter support for functions
Submitted: 2004-01-14 13:42 UTC Modified: 2004-01-15 08:41 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: piegtas at hotmail dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.3.4 OS: All Unix
Private report: No CVE-ID: None
 [2004-01-14 13:42 UTC] piegtas at hotmail dot com
Description:
------------
I made a patch to add SNMP v2c support for snmpget/snmpwalk/snmprealwalk

I add a sixth parameter to those functions for use like this example:

snmpwalk("router.dot.com", "readcomm", "ifHCInOctets", 1, 2, 2);

This is my patch:

diff -u ext/snmp/snmp.c ext/snmp.1/snmp.c
--- ext/snmp/snmp.c     Wed Jan 14 12:38:15 2004
+++ ext/snmp.1/snmp.c   Wed Jan 14 12:35:47 2004
@@ -392,6 +392,7 @@
        long timeout=SNMP_DEFAULT_TIMEOUT;
        long retries=SNMP_DEFAULT_RETRIES;
        int myargc = ZEND_NUM_ARGS();
+       long myvers = SNMP_VERSION_1;
        char type = (char) 0;
        char *value = (char *) 0;
        char hostname[MAX_NAME_LEN];
@@ -437,6 +438,16 @@
                        convert_to_long_ex(a5);
                        retries = Z_LVAL_PP(a5);
                }
+
+               if(myargc > 5) {
+                       convert_to_long_ex(a6);
+                       switch(Z_LVAL_PP(a6)) {
+                               case 1: myvers = SNMP_VERSION_1;
+                                       break;
+                               case 2: myvers = SNMP_VERSION_2c;
+                                       break;
+                       }
+               }
        }

        snmp_sess_init(&session);
@@ -448,7 +459,7 @@

        session.peername = hostname;
        session.remote_port = remote_port;
-       session.version = SNMP_VERSION_1;
+       session.version = (int)myvers;
        /*
        * FIXME: potential memory leak
        * This is a workaround for an "artifact" (Mike Slifcak)



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-15 08:41 UTC] piegtas at hotmail dot com
Solved width my own fix
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 10:01:28 2024 UTC