note 39012 added to function.snmpwalk
| From: | piegtas at hotmail dot com | Date: | Wed, 14 Jan 2004 15:43:19 +0000 |
| Subject: | note 39012 added to function.snmpwalk | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-63535@lists.php.net to get a copy of this message | ||
I make a patch to add SNMP v2c support.
Just apply this patch with patch -p0. It adds a sixth parameter to snmpwalk/snmprealwalk/snmpget. It
must be 1 (snmp_v1) or 2 (snmp_v2).
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)
----
Manual Page -- http://www.php.net/manual/en/function.snmpwalk.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39012
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39012&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39012&report=yes
Search -- http://master.php.net/manage/user-notes.php