CVS update: php3/functions
| From: | sas | Date: | Sat, 03 Apr 1999 02:19:43 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-4891@lists.php.net to get a copy of this message | ||
Date: Friday April 2, 1999 @ 21:19
Author: sas
Update of /repository/php3/functions
In directory asf:/u/temp/cvs-serv3069/functions
Modified Files:
snmp.c php3_snmp.h
Log Message:
add snmprealwalk() which returns an associative array so one can finally
really walk along the object (id) tree
Index: php3/functions/snmp.c
diff -c php3/functions/snmp.c:1.9 php3/functions/snmp.c:1.10
*** php3/functions/snmp.c:1.9 Tue Jan 5 11:12:28 1999
--- php3/functions/snmp.c Fri Apr 2 21:19:42 1999
***************
*** 26,32 ****
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
! /* $Id: snmp.c,v 1.9 1999/01/05 16:12:28 martin Exp $ */
#include "php.h"
#include "internal_functions.h"
--- 26,32 ----
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
! /* $Id: snmp.c,v 1.10 1999/04/03 02:19:42 sas Exp $ */
#include "php.h"
#include "internal_functions.h"
***************
*** 88,95 ****
void sprint_variable(char *, oid *, int, struct variable_list *);
function_entry snmp_functions[] = {
! {"snmpget", php3_snmpget, NULL},
! {"snmpwalk", php3_snmpwalk, NULL},
{NULL,NULL,NULL}
};
--- 88,96 ----
void sprint_variable(char *, oid *, int, struct variable_list *);
function_entry snmp_functions[] = {
! PHP_FE(snmpget, NULL)
! PHP_FE(snmpwalk, NULL)
! PHP_FE(snmprealwalk, NULL)
{NULL,NULL,NULL}
};
***************
*** 130,135 ****
--- 131,137 ----
int status, count,rootlen=0,gotroot=0;
oid root[MAX_NAME_LEN];
char buf[2048];
+ char buf2[2048];
int keepwalking=1;
long timeout=SNMP_DEFAULT_TIMEOUT;
long retries=SNMP_DEFAULT_RETRIES;
***************
*** 151,157 ****
}
objid=a3->value.str.val;
! if (st==2) { /* walk */
rootlen = MAX_NAME_LEN;
if (strlen(objid)) { /* on a walk, an empty string means top of tree - no error */
if (read_objid(objid, root, &rootlen)) {
--- 153,159 ----
}
objid=a3->value.str.val;
! if (st>=2) { /* walk */
rootlen = MAX_NAME_LEN;
if (strlen(objid)) { /* on a walk, an empty string means top of tree - no error */
if (read_objid(objid, root, &rootlen)) {
***************
*** 183,189 ****
php3_error(E_WARNING,"Couldn't open snmp\n");
RETURN_FALSE;
}
! if (st==2) {
memmove((char *)name, (char *)root, rootlen * sizeof(oid));
name_length = rootlen;
/* prepare result array */
--- 185,191 ----
php3_error(E_WARNING,"Couldn't open snmp\n");
RETURN_FALSE;
}
! if (st>=2) {
memmove((char *)name, (char *)root, rootlen * sizeof(oid));
name_length = rootlen;
/* prepare result array */
***************
*** 193,199 ****
while(keepwalking) {
keepwalking=0;
if (st==1) pdu = snmp_pdu_create(SNMP_MSG_GET);
! else if (st==2) pdu = snmp_pdu_create(SNMP_MSG_GETNEXT);
if (st==1) {
name_length = MAX_NAME_LEN;
--- 195,201 ----
while(keepwalking) {
keepwalking=0;
if (st==1) pdu = snmp_pdu_create(SNMP_MSG_GET);
! else if (st>=2) pdu = snmp_pdu_create(SNMP_MSG_GETNEXT);
if (st==1) {
name_length = MAX_NAME_LEN;
***************
*** 209,215 ****
if (status == STAT_SUCCESS) {
if (response->errstat == SNMP_ERR_NOERROR) {
for(vars = response->variables; vars; vars = vars->next_variable) {
! if (st==2 && (vars->name_length < rootlen || memcmp(root, vars->name,
rootlen * sizeof(oid))))
continue; /* not part of this subtree */
sprint_value(buf,vars->name, vars->name_length, vars);
--- 211,217 ----
if (status == STAT_SUCCESS) {
if (response->errstat == SNMP_ERR_NOERROR) {
for(vars = response->variables; vars; vars = vars->next_variable) {
! if (st>=2 && (vars->name_length < rootlen || memcmp(root, vars->name,
rootlen * sizeof(oid))))
continue; /* not part of this subtree */
sprint_value(buf,vars->name, vars->name_length, vars);
***************
*** 221,226 ****
--- 223,233 ----
} else if (st==2) {
/* Add to returned array */
add_next_index_string(return_value,buf,1);
+ } else if (st==3) {
+ sprint_objid(buf2, name, name_length);
+ add_assoc_string(return_value,buf2,buf,1);
+ }
+ if (st>=2) {
if (vars->type != SNMP_ENDOFMIBVIEW && vars->type != SNMP_NOSUCHOBJECT
&& vars->type != SNMP_NOSUCHINSTANCE) {
memmove((char *)name, (char *)vars->name,vars->name_length * sizeof(oid));
name_length = vars->name_length;
***************
*** 239,245 ****
}
if (st==1) {
if ((pdu = snmp_fix_pdu(response, SNMP_MSG_GET)) != NULL) goto retry;
! } else if (st==2) {
if ((pdu = snmp_fix_pdu(response, SNMP_MSG_GETNEXT)) != NULL) goto retry;
}
RETURN_FALSE;
--- 246,252 ----
}
if (st==1) {
if ((pdu = snmp_fix_pdu(response, SNMP_MSG_GET)) != NULL) goto retry;
! } else if (st>=2) {
if ((pdu = snmp_fix_pdu(response, SNMP_MSG_GETNEXT)) != NULL) goto retry;
}
RETURN_FALSE;
***************
*** 268,273 ****
--- 275,288 ----
Return all objects under the specified object id */
void php3_snmpwalk(INTERNAL_FUNCTION_PARAMETERS) {
return _php3_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,2);
+ }
+ /* }}} */
+
+ /* {{{ proto string snmprealwalk(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(snmprealwalk)
+ {
+ return _php3_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,3);
}
/* }}} */
Index: php3/functions/php3_snmp.h
diff -c php3/functions/php3_snmp.h:1.3 php3/functions/php3_snmp.h:1.4
*** php3/functions/php3_snmp.h:1.3 Fri Jan 1 12:59:16 1999
--- php3/functions/php3_snmp.h Fri Apr 2 21:19:42 1999
***************
*** 26,32 ****
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
! /* $Id: php3_snmp.h,v 1.3 1999/01/01 17:59:16 zeev Exp $ */
#ifndef _PHP3_SNMP_H
#define _PHP3_SNMP_H
--- 26,32 ----
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
! /* $Id: php3_snmp.h,v 1.4 1999/04/03 02:19:42 sas Exp $ */
#ifndef _PHP3_SNMP_H
#define _PHP3_SNMP_H
***************
*** 43,50 ****
#define snmp_module_ptr &snmp_module_entry
extern int php3i_snmp_init(INIT_FUNC_ARGS);
! extern void php3_snmpget(INTERNAL_FUNCTION_PARAMETERS);
! extern void php3_snmpwalk(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_info_snmp(void);
#else
--- 43,51 ----
#define snmp_module_ptr &snmp_module_entry
extern int php3i_snmp_init(INIT_FUNC_ARGS);
! extern PHP_FUNCTION(snmpget);
! extern PHP_FUNCTION(snmpwalk);
! extern PHP_FUNCTION(snmprealwalk);
extern void php3_info_snmp(void);
#else
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net