diff options
author | Stig Bakken <ssb@php.net> | 1999-04-22 02:48:28 +0000 |
---|---|---|
committer | Stig Bakken <ssb@php.net> | 1999-04-22 02:48:28 +0000 |
commit | 2c0ad3ee25cd8e449b02c4668a39f48998507739 (patch) | |
tree | 8064c7ee59309ffed3d9c5b8fd5c329ede193561 /ext/snmp | |
parent | 2a78f92804ae6f3e32cd278afbb9aa8ec3d2f52d (diff) | |
download | php-git-2c0ad3ee25cd8e449b02c4668a39f48998507739.tar.gz |
last bunch of extensions moving to ext/
fhttpd module taken out of functions, functions is ready to go.
The only extensions I have tested are gd+freetype and odbc(solid).
Please try compiling in your favourite extensions and let me know how it
works.
Diffstat (limited to 'ext/snmp')
-rw-r--r-- | ext/snmp/Makefile.am | 6 | ||||
-rw-r--r-- | ext/snmp/Makefile.in | 270 | ||||
-rw-r--r-- | ext/snmp/config.h.stub | 2 | ||||
-rw-r--r-- | ext/snmp/config.m4 | 31 | ||||
-rw-r--r-- | ext/snmp/php3_snmp.h | 56 | ||||
-rw-r--r-- | ext/snmp/snmp.c | 298 |
6 files changed, 663 insertions, 0 deletions
diff --git a/ext/snmp/Makefile.am b/ext/snmp/Makefile.am new file mode 100644 index 0000000000..ebb5c25b5c --- /dev/null +++ b/ext/snmp/Makefile.am @@ -0,0 +1,6 @@ +# $Id$ + +INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend +noinst_LIBRARIES=libphpext_snmp.a +libphpext_snmp_a_SOURCES=snmp.c + diff --git a/ext/snmp/Makefile.in b/ext/snmp/Makefile.in new file mode 100644 index 0000000000..a010158376 --- /dev/null +++ b/ext/snmp/Makefile.in @@ -0,0 +1,270 @@ +# Makefile.in generated automatically by automake 1.3 from Makefile.am + +# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# $Id$ + + +SHELL = /bin/sh + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DISTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = ../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +APACHE_INCLUDE = @APACHE_INCLUDE@ +APACHE_TARGET = @APACHE_TARGET@ +APXS = @APXS@ +APXS_LDFLAGS = @APXS_LDFLAGS@ +BINNAME = @BINNAME@ +CC = @CC@ +CFLAGS = @CFLAGS@ +CFLAGS_SHLIB = @CFLAGS_SHLIB@ +DEBUG_CFLAGS = @DEBUG_CFLAGS@ +EXTINFO_DEPS = @EXTINFO_DEPS@ +EXTRA_LIBS = @EXTRA_LIBS@ +EXT_LIBS = @EXT_LIBS@ +EXT_SUBDIRS = @EXT_SUBDIRS@ +FHTTPD_LIB = @FHTTPD_LIB@ +FHTTPD_TARGET = @FHTTPD_TARGET@ +HSREGEX = @HSREGEX@ +INSTALL_IT = @INSTALL_IT@ +LDFLAGS_SHLIB = @LDFLAGS_SHLIB@ +LDFLAGS_SHLIB_EXPORT = @LDFLAGS_SHLIB_EXPORT@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +PACKAGE = @PACKAGE@ +PERL_PATH = @PERL_PATH@ +PHP_BUILD_DATE = @PHP_BUILD_DATE@ +PHP_DEBUG = @PHP_DEBUG@ +PHP_LIBS = @PHP_LIBS@ +PHP_VERSION = @PHP_VERSION@ +PROG_SENDMAIL = @PROG_SENDMAIL@ +RANLIB = @RANLIB@ +RDYNAMIC_LFLAGS = @RDYNAMIC_LFLAGS@ +REGEX_LIB = @REGEX_LIB@ +STRONGHOLD = @STRONGHOLD@ +VERSION = @VERSION@ +WARNING_LEVEL = @WARNING_LEVEL@ +YACC = @YACC@ + +INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend +noinst_LIBRARIES=libphpext_snmp.a +libphpext_snmp_a_SOURCES=snmp.c +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../../config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I../.. +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +libphpext_snmp_a_LIBADD = +libphpext_snmp_a_OBJECTS = snmp.o +AR = ar +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP = --best +SOURCES = $(libphpext_snmp_a_SOURCES) +OBJECTS = $(libphpext_snmp_a_OBJECTS) + +all: Makefile $(LIBRARIES) + +.SUFFIXES: +.SUFFIXES: .S .c .o .s +$(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps ext/snmp/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-noinstLIBRARIES: + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) + +distclean-noinstLIBRARIES: + +maintainer-clean-noinstLIBRARIES: + +.c.o: + $(COMPILE) -c $< + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +libphpext_snmp.a: $(libphpext_snmp_a_OBJECTS) $(libphpext_snmp_a_DEPENDENCIES) + -rm -f libphpext_snmp.a + $(AR) cru libphpext_snmp.a $(libphpext_snmp_a_OBJECTS) $(libphpext_snmp_a_LIBADD) + $(RANLIB) libphpext_snmp.a + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $(SOURCES) $(HEADERS) $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = ext/snmp + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file; \ + done +info: +dvi: +check: all + $(MAKE) +installcheck: +install-exec: + @$(NORMAL_INSTALL) + +install-data: + @$(NORMAL_INSTALL) + +install: install-exec install-data all + @: + +uninstall: + +install-strip: + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install +installdirs: + + +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f Makefile $(DISTCLEANFILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +mostlyclean: mostlyclean-noinstLIBRARIES mostlyclean-compile \ + mostlyclean-tags mostlyclean-generic + +clean: clean-noinstLIBRARIES clean-compile clean-tags clean-generic \ + mostlyclean + +distclean: distclean-noinstLIBRARIES distclean-compile distclean-tags \ + distclean-generic clean + -rm -f config.status + +maintainer-clean: maintainer-clean-noinstLIBRARIES \ + maintainer-clean-compile maintainer-clean-tags \ + maintainer-clean-generic distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \ +clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile tags mostlyclean-tags distclean-tags \ +clean-tags maintainer-clean-tags distdir info dvi installcheck \ +install-exec install-data install uninstall all installdirs \ +mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/ext/snmp/config.h.stub b/ext/snmp/config.h.stub new file mode 100644 index 0000000000..e400f18f01 --- /dev/null +++ b/ext/snmp/config.h.stub @@ -0,0 +1,2 @@ +/* Define if you want the SNMP interface */ +#define HAVE_SNMP 0 diff --git a/ext/snmp/config.m4 b/ext/snmp/config.m4 new file mode 100644 index 0000000000..928dad4187 --- /dev/null +++ b/ext/snmp/config.m4 @@ -0,0 +1,31 @@ +dnl $Id$ + +AC_MSG_CHECKING(for SNMP support) +AC_ARG_WITH(snmp, +[ --with-snmp[=DIR] Include SNMP support. DIR is the SNMP base + install directory, defaults to /usr/local], +[ + if test "$withval" != "no"; then + if test "$withval" = "yes"; then + SNMP_INCDIR=/usr/local/include + test -d /usr/local/include/ucd-snmp && SNMP_INCDIR=/usr/local/include/ucd-snmp + SNMP_LIBDIR=/usr/local/lib + else + SNMP_INCDIR=$withval/include + test -d $withval/include/ucd-snmp && SNMP_INCDIR=$withval/include/ucd-snmp + SNMP_LIBDIR=$withval/lib + fi + SNMP_INCLUDE=-I$SNMP_INCDIR + SNMP_LFLAGS=-L$SNMP_LIBDIR + SNMP_LIBS="-lsnmp" + AC_DEFINE(HAVE_SNMP) + AC_MSG_RESULT(yes) + PHP_EXTENSION(snmp) + EXTRA_LIBS="$EXTRA_LIBS $SNMP_LFLAGS $SNMP_LIBS" + INCLUDES="$INCLUDES $SNMP_INCLUDE" + else + AC_MSG_RESULT(no) + fi +],[ + AC_MSG_RESULT(no) +]) diff --git a/ext/snmp/php3_snmp.h b/ext/snmp/php3_snmp.h new file mode 100644 index 0000000000..c35962cf8f --- /dev/null +++ b/ext/snmp/php3_snmp.h @@ -0,0 +1,56 @@ +/* + +----------------------------------------------------------------------+ + | PHP HTML Embedded Scripting Language Version 3.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997,1998 PHP Development Team (See Credits file) | + +----------------------------------------------------------------------+ + | This program is free software; you can redistribute it and/or modify | + | it under the terms of one of the following licenses: | + | | + | A) the GNU General Public License as published by the Free Software | + | Foundation; either version 2 of the License, or (at your option) | + | any later version. | + | | + | B) the PHP License as published by the PHP Development Team and | + | included in the distribution in the file: LICENSE | + | | + | This program is distributed in the hope that it will be useful, | + | but WITHOUT ANY WARRANTY; without even the implied warranty of | + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | + | GNU General Public License for more details. | + | | + | You should have received a copy of both licenses referred to here. | + | If you did not, or have any questions about PHP licensing, please | + | contact core@php.net. | + +----------------------------------------------------------------------+ + | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | + +----------------------------------------------------------------------+ + */ +/* $Id$ */ +#ifndef _PHP3_SNMP_H +#define _PHP3_SNMP_H + +#if COMPILE_DL +#undef HAVE_SNMP +#define HAVE_SNMP 1 +#endif +#if HAVE_SNMP +#ifndef DLEXPORT +#define DLEXPORT +#endif + +extern php3_module_entry snmp_module_entry; +#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 + +#define snmp_module_ptr NULL + +#endif /* HAVE_SNMP */ + +#endif /* _PHP3_SNMP_H */ diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c new file mode 100644 index 0000000000..05c35f3b54 --- /dev/null +++ b/ext/snmp/snmp.c @@ -0,0 +1,298 @@ +/* + +----------------------------------------------------------------------+ + | PHP HTML Embedded Scripting Language Version 3.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997,1998 PHP Development Team (See Credits file) | + +----------------------------------------------------------------------+ + | This program is free software; you can redistribute it and/or modify | + | it under the terms of one of the following licenses: | + | | + | A) the GNU General Public License as published by the Free Software | + | Foundation; either version 2 of the License, or (at your option) | + | any later version. | + | | + | B) the PHP License as published by the PHP Development Team and | + | included in the distribution in the file: LICENSE | + | | + | This program is distributed in the hope that it will be useful, | + | but WITHOUT ANY WARRANTY; without even the implied warranty of | + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | + | GNU General Public License for more details. | + | | + | You should have received a copy of both licenses referred to here. | + | If you did not, or have any questions about PHP licensing, please | + | contact core@php.net. | + +----------------------------------------------------------------------+ + | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | + +----------------------------------------------------------------------+ + */ +/* $Id$ */ + +#include "php.h" +#if defined(COMPILE_DL) +#include "phpdl.h" +#include "functions/dl.h" +#endif +#include "php3_snmp.h" +#include <sys/types.h> +#if MSVC5 +#include <winsock.h> +#include <errno.h> +#include <process.h> +#include "win32/time.h" +#else +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <sys/errno.h> +#include <netdb.h> +#endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +#if HAVE_SNMP + +#ifndef __P +#ifdef __GNUC__ +#define __P(args) args +#else +#define __P(args) () +#endif +#endif + +#include "asn1.h" +#include "snmp_api.h" +#include "snmp_client.h" +#include "snmp_impl.h" +#include "snmp.h" +#include "parse.h" +#include "mib.h" + +/* ucd-snmp 3.3.1 changed the name of a few #defines... They've been changed back to the original ones in 3.5.3! */ +#ifndef SNMP_MSG_GET +#define SNMP_MSG_GET GET_REQ_MSG +#define SNMP_MSG_GETNEXT GETNEXT_REQ_MSG +#endif + +void _php3_snmp(INTERNAL_FUNCTION_PARAMETERS, int st); + +/* constant - can be shared among threads */ +static oid objid_mib[] = {1, 3, 6, 1, 2, 1}; + +/* Add missing prototype */ +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} +}; + +php3_module_entry snmp_module_entry = { + "SNMP",snmp_functions,php3i_snmp_init,NULL,NULL,NULL,php3_info_snmp,STANDARD_MODULE_PROPERTIES +}; + +#if COMPILE_DL +DLEXPORT php3_module_entry *get_module() { return &snmp_module_entry; }; +#endif + +/* 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"); +} + + +/* + * Generic SNMP object fetcher + * + * st=1 GET + * st=2 WALK + * st=3 WALK (returns OIDs additionally) + */ +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; + 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; + 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 */ + if (read_objid(objid, root, &rootlen)) { + gotroot = 1; + } else { + php3_error(E_WARNING,"Invalid object identifier: %s\n", objid); + } + } + if (gotroot == 0) { + memmove((char *)root, (char *)objid_mib, sizeof(objid_mib)); + rootlen = sizeof(objid_mib) / sizeof(oid); + gotroot = 1; + } + } + + memset(&session, 0, sizeof(struct snmp_session)); + session.peername = a1->value.str.val; + + session.version = SNMP_VERSION_1; + /* + * FIXME: potential memory leak + * This is a workaround for an "artifact" (Mike Slifcak) + * in (at least) ucd-snmp 3.6.1 which frees + * memory it did not allocate + */ + session.community = (u_char *) strdup(a2->value.str.val); + session.community_len = a2->value.str.len; + session.retries = retries; + session.timeout = timeout; + + session.authenticator = NULL; + snmp_synch_setup(&session); + ss = snmp_open(&session); + if (ss == NULL){ + 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 */ + array_init(return_value); + } + + 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; + if (!read_objid(objid, name, &name_length)) { + php3_error(E_WARNING,"Invalid object identifier: %s\n", objid); + RETURN_FALSE; + } + } + snmp_add_null_var(pdu, name, name_length); + +retry: + status = snmp_synch_response(ss, pdu, &response); + 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); +#if 0 + Debug("snmp response is: %s\n",buf); +#endif + if (st==1) { + RETVAL_STRING(buf,1); + } 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; + keepwalking = 1; + } + } + } + } else { + if (st!=2 || response->errstat != SNMP_ERR_NOSUCHNAME) { + php3_error(E_WARNING,"Error in packet.\nReason: %s\n", snmp_errstring(response->errstat)); + if (response->errstat == SNMP_ERR_NOSUCHNAME) { + for(count=1, vars = response->variables; vars && count != response->errindex; + vars = vars->next_variable, count++); + if (vars) sprint_objid(buf,vars->name, vars->name_length); + php3_error(E_WARNING,"This name does not exist: %s\n",buf); + } + 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; + } + } + } 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"); + RETURN_FALSE; + } + if (response) snmp_free_pdu(response); + } /* keepwalking */ + snmp_close(ss); +} + +/* {{{ proto string snmpget(string host, string community, string object_id [, int timeout [, int retries]]) + Fetch an SNMP object */ +void php3_snmpget(INTERNAL_FUNCTION_PARAMETERS) { + _php3_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,1); +} +/* }}} */ + +/* {{{ proto string snmpwalk(string host, string community, string object_id [, int timeout [, int retries]]) + 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); +} +/* }}} */ + +#endif + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + */ |