note 47441 rejected from ref.snmp by sean

From: Date: Tue, 16 Nov 2004 15:53:22 +0000
Subject: note 47441 rejected from ref.snmp by sean
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-80601@lists.php.net to get a copy of this message
Note Submitter: piegtas at hotmail dot com ---- I'd make this patch to add SNMP v2c support. It' was tested on php-5.0.1 snmp extension and works fine. This patch adds an extra optional argument for all snmp functions. It could be 1 (snmp v1) or 2 (snmp v2). Example: snmpwalk($hostname, $community, "ifHCInOctets.1", $timeout, $retries, 2); Regards /-----------------------------------------/ diff -ruN ext/snmp.orig/snmp.c ext/snmp/snmp.c --- ext/snmp.orig/snmp.c Tue Mar 23 20:12:50 2004 +++ ext/snmp/snmp.c Fri Aug 6 13:01:54 2004 @@ -530,7 +530,7 @@ */ static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st) { - zval **a1, **a2, **a3, **a4, **a5, **a6, **a7; + zval **a1, **a2, **a3, **a4, **a5, **a6, **a7, **a8; struct snmp_session session; long timeout=SNMP_DEFAULT_TIMEOUT; long retries=SNMP_DEFAULT_RETRIES; @@ -539,10 +539,11 @@ char *value = (char *) 0; char hostname[MAX_NAME_LEN]; int remote_port = 161; + int s_version = SNMP_VERSION_1; char *pptr; if (myargc < 3 || myargc > 7 || - zend_get_parameters_ex(myargc, &a1, &a2, &a3, &a4, &a5, &a6, &a7) == FAILURE) { + zend_get_parameters_ex(myargc, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8) == FAILURE) { WRONG_PARAM_COUNT; } @@ -580,6 +581,11 @@ convert_to_long_ex(a5); retries = Z_LVAL_PP(a5); } + + if(myargc > 5) { + convert_to_long_ex(a6); + if(Z_LVAL_PP(a6) == 2) { s_version = SNMP_VERSION_2c; }; + } } snmp_sess_init(&session); @@ -590,7 +596,7 @@ session.peername = hostname; session.remote_port = remote_port; - session.version = SNMP_VERSION_1; + session.version = s_version; /* * FIXME: potential memory leak * This is a workaround for an "artifact" (Mike Slifcak)

« previous php.notes (#80601) next »