CVS update: php3/functions
| From: | rasmus | Date: | Sat, 19 Sep 1998 14:21:26 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-1252@lists.php.net to get a copy of this message | ||
Date: Saturday September 19, 1998 @ 10:21
Author: rasmus
Update of /repository/php3/functions
In directory asf:/u2/tmp/cvs-serv21972/functions
Modified Files:
php3_snmp.h snmp.c
Log Message:
Some SNMP module cleanups
Index: php3/functions/php3_snmp.h
diff -c php3/functions/php3_snmp.h:1.1 php3/functions/php3_snmp.h:1.2
*** php3/functions/php3_snmp.h:1.1 Fri Sep 18 12:56:50 1998
--- php3/functions/php3_snmp.h Sat Sep 19 10:21:24 1998
***************
*** 26,32 ****
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
! /* $Id: php3_snmp.h,v 1.1 1998/09/18 16:56:50 rasmus Exp $ */
#ifndef _PHP3_SNMP_H
#define _PHP3_SNMP_H
--- 26,32 ----
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
! /* $Id: php3_snmp.h,v 1.2 1998/09/19 14:21:24 rasmus Exp $ */
#ifndef _PHP3_SNMP_H
#define _PHP3_SNMP_H
***************
*** 42,47 ****
--- 42,48 ----
extern php3_module_entry snmp_module_entry;
#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);
Index: php3/functions/snmp.c
diff -c php3/functions/snmp.c:1.1 php3/functions/snmp.c:1.2
*** php3/functions/snmp.c:1.1 Fri Sep 18 12:56:51 1998
--- php3/functions/snmp.c Sat Sep 19 10:21:25 1998
***************
*** 26,32 ****
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
! /* $Id: snmp.c,v 1.1 1998/09/18 16:56:51 rasmus Exp $ */
#include "php.h"
#include "internal_functions.h"
--- 26,32 ----
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
! /* $Id: snmp.c,v 1.2 1998/09/19 14:21:25 rasmus Exp $ */
#include "php.h"
#include "internal_functions.h"
***************
*** 58,63 ****
--- 58,64 ----
#include "snmp_impl.h"
#include "snmp.h"
#include "parse.h"
+ #include "mib.h"
void _php3_snmp(INTERNAL_FUNCTION_PARAMETERS, int st);
***************
*** 74,80 ****
};
php3_module_entry snmp_module_entry = {
! "SNMP",snmp_functions,NULL,NULL,NULL,NULL,php3_info_snmp,STANDARD_MODULE_PROPERTIES
};
#if COMPILE_DL
--- 75,81 ----
};
php3_module_entry snmp_module_entry = {
!
"SNMP",snmp_functions,php3i_snmp_init,NULL,NULL,NULL,php3_info_snmp,STANDARD_MODULE_PROPERTIES
};
#if COMPILE_DL
***************
*** 83,88 ****
--- 84,94 ----
/* THREAD_LS snmp_module php3_snmp_module; - may need one of these at some point */
+ int php3i_snmp_init(INIT_FUNC_ARGS) {
+ init_mib();
+ return SUCCESS;
+ }
+
void php3_info_snmp(void) {
php3_printf("ucd-snmp");
}
***************
*** 95,105 ****
* st=2 WALK
*/
void _php3_snmp(INTERNAL_FUNCTION_PARAMETERS, int st) {
! pval *a1, *a2, *a3;
struct snmp_session session, *ss;
struct snmp_pdu *pdu=NULL, *response;
struct variable_list *vars;
- char *community, *hostname;
char *objid;
oid name[MAX_NAME_LEN];
int name_length;
--- 101,110 ----
* st=2 WALK
*/
void _php3_snmp(INTERNAL_FUNCTION_PARAMETERS, int st) {
! pval *a1, *a2, *a3, *a4, *a5;
struct snmp_session session, *ss;
struct snmp_pdu *pdu=NULL, *response;
struct variable_list *vars;
char *objid;
oid name[MAX_NAME_LEN];
int name_length;
***************
*** 107,130 ****
oid root[MAX_NAME_LEN];
char buf[2048];
int keepwalking=1;
! static int mib_init=0;
!
! if (getParameters(ht, 3, &a1, &a2, &a3) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string(a1);
convert_to_string(a2);
convert_to_string(a3);
!
! hostname=a1->value.str.val;
! community=a2->value.str.val;
! objid=a3->value.str.val;
!
! if (!mib_init) {
! init_mib();
! mib_init=1;
}
!
if (st==2) { /* walk */
rootlen = MAX_NAME_LEN;
if (strlen(objid)) { /* on a walk, an empty string means top of tree - no error */
--- 112,137 ----
oid root[MAX_NAME_LEN];
char buf[2048];
int keepwalking=1;
! long timeout=SNMP_DEFAULT_TIMEOUT;
! long retries=SNMP_DEFAULT_RETRIES;
! int myargc = ARG_COUNT(ht);
!
! if (myargc<3 || myargc>5 || getParameters(ht, myargc, &a1, &a2, &a3, &a4,
&a5) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string(a1);
convert_to_string(a2);
convert_to_string(a3);
! if(myargc>3) {
! convert_to_long(a4);
! timeout=a4->value.lval;
}
! if(myargc>4) {
! convert_to_long(a5);
! retries=a5->value.lval;
! }
! 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 */
***************
*** 142,154 ****
}
memset(&session, 0, sizeof(struct snmp_session));
! session.peername = hostname;
session.version = SNMP_VERSION_1;
! session.community = (u_char *)community;
! session.community_len = strlen((char *)community);
! session.retries = SNMP_DEFAULT_RETRIES;
! session.timeout = SNMP_DEFAULT_TIMEOUT;
session.authenticator = NULL;
snmp_synch_setup(&session);
--- 149,161 ----
}
memset(&session, 0, sizeof(struct snmp_session));
! session.peername = a1->value.str.val;
session.version = SNMP_VERSION_1;
! session.community = (u_char *)a2->value.str.val;
! session.community_len = a2->value.str.len;
! session.retries = retries;
! session.timeout = timeout;
session.authenticator = NULL;
snmp_synch_setup(&session);
***************
*** 220,226 ****
}
}
} else if (status == STAT_TIMEOUT) {
! php3_error(E_WARNING,"No Response from %s\n", hostname);
RETURN_FALSE;
} else { /* status == STAT_ERROR */
php3_error(E_WARNING,"An error occurred, Quitting\n");
--- 227,233 ----
}
}
} else if (status == STAT_TIMEOUT) {
! php3_error(E_WARNING,"No Response from %s\n", a1->value.str.val);
RETURN_FALSE;
} else { /* status == STAT_ERROR */
php3_error(E_WARNING,"An error occurred, Quitting\n");
--
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