summaryrefslogtreecommitdiff
path: root/ext/snmp
diff options
context:
space:
mode:
Diffstat (limited to 'ext/snmp')
-rw-r--r--ext/snmp/CREDITS2
-rw-r--r--ext/snmp/config.m4138
-rw-r--r--ext/snmp/config.w3218
-rw-r--r--ext/snmp/php_snmp.h84
-rw-r--r--ext/snmp/snmp.c1098
-rw-r--r--ext/snmp/snmp.dsp109
-rw-r--r--ext/snmp/winsnmp.c249
7 files changed, 0 insertions, 1698 deletions
diff --git a/ext/snmp/CREDITS b/ext/snmp/CREDITS
deleted file mode 100644
index 2ff38dbe6d..0000000000
--- a/ext/snmp/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-SNMP
-Rasmus Lerdorf, Harrie Hazewinkel, Mike Jackson, Steven Lawrance, Johann Hanne
diff --git a/ext/snmp/config.m4 b/ext/snmp/config.m4
deleted file mode 100644
index 455bc31cac..0000000000
--- a/ext/snmp/config.m4
+++ /dev/null
@@ -1,138 +0,0 @@
-dnl
-dnl $Id$
-dnl
-
-PHP_ARG_WITH(snmp,for SNMP support,
-[ --with-snmp[=DIR] Include SNMP support.])
-
-PHP_ARG_WITH(openssl-dir,OpenSSL dir for SNMP,
-[ --with-openssl-dir[=DIR] SNMP: openssl install prefix.], no, no)
-
-if test "$PHP_SNMP" != "no"; then
-
- dnl
- dnl Try net-snmp first
- dnl
- if test "$PHP_SNMP" = "yes"; then
- AC_PATH_PROG(SNMP_CONFIG,net-snmp-config,,[/usr/local/bin:$PATH])
- else
- SNMP_CONFIG="$PHP_SNMP/bin/net-snmp-config"
- fi
-
- if test -x "$SNMP_CONFIG"; then
- SNMP_LIBS=`$SNMP_CONFIG --netsnmp-libs`
- SNMP_LIBS="$SNMP_LIBS `$SNMP_CONFIG --external-libs`"
- SNMP_PREFIX=`$SNMP_CONFIG --prefix`
-
- if test -n "$SNMP_LIBS" && test -n "$SNMP_PREFIX"; then
- PHP_ADD_INCLUDE(${SNMP_PREFIX}/include)
- PHP_EVAL_LIBLINE($SNMP_LIBS, SNMP_SHARED_LIBADD)
- AC_DEFINE(HAVE_NET_SNMP,1,[ ])
- SNMP_LIBNAME=netsnmp
- else
- AC_MSG_ERROR([Could not find the required paths. Please check your net-snmp installation.])
- fi
- else
-
- dnl
- dnl Try ucd-snmp if net-snmp test failed
- dnl
-
- if test "$PHP_SNMP" = "yes"; then
- for i in /usr/include /usr/local/include; do
- test -f $i/snmp.h && SNMP_INCDIR=$i
- test -f $i/ucd-snmp/snmp.h && SNMP_INCDIR=$i/ucd-snmp
- test -f $i/snmp/snmp.h && SNMP_INCDIR=$i/snmp
- test -f $i/snmp/include/ucd-snmp/snmp.h && SNMP_INCDIR=$i/snmp/include/ucd-snmp
- done
- for i in /usr /usr/snmp /usr/local /usr/local/snmp; do
- test -f $i/lib/libsnmp.a -o -f $i/lib/libsnmp.$SHLIB_SUFFIX_NAME && SNMP_LIBDIR=$i/lib
- done
- else
- SNMP_INCDIR=$PHP_SNMP/include
- test -d $PHP_SNMP/include/ucd-snmp && SNMP_INCDIR=$PHP_SNMP/include/ucd-snmp
- SNMP_LIBDIR=$PHP_SNMP/lib
- fi
-
- if test -z "$SNMP_INCDIR"; then
- AC_MSG_ERROR(snmp.h not found. Check your SNMP installation.)
- elif test -z "$SNMP_LIBDIR"; then
- AC_MSG_ERROR(libsnmp not found. Check your SNMP installation.)
- fi
-
- old_CPPFLAGS=$CPPFLAGS
- CPPFLAGS=-I$SNMP_INCDIR
- AC_CHECK_HEADERS(default_store.h)
- if test "$ac_cv_header_default_store_h" = "yes"; then
- AC_MSG_CHECKING(for OpenSSL support in SNMP libraries)
- AC_EGREP_CPP(yes,[
-#include <ucd-snmp-config.h>
-#if USE_OPENSSL
- yes
-#endif
- ],[
- SNMP_SSL=yes
- ],[
- SNMP_SSL=no
- ])
- fi
- CPPFLAGS=$old_CPPFLAGS
- AC_MSG_RESULT($SNMP_SSL)
-
- if test "$SNMP_SSL" = "yes"; then
- if test "$PHP_OPENSSL_DIR" != "no"; then
- PHP_OPENSSL=$PHP_OPENSSL_DIR
- fi
-
- if test "$PHP_OPENSSL" = "no"; then
- AC_MSG_ERROR([The UCD-SNMP in this system is built with SSL support.
-
- Add --with-openssl-dir=DIR to your configure line.])
- else
- PHP_SETUP_OPENSSL(SNMP_SHARED_LIBADD, [], [
- AC_MSG_ERROR([SNMP: OpenSSL check failed. Please check config.log for more information.])
- ])
- fi
- fi
-
- AC_CHECK_LIB(kstat, kstat_read, [ PHP_ADD_LIBRARY(kstat,,SNMP_SHARED_LIBADD) ])
- PHP_ADD_INCLUDE($SNMP_INCDIR)
- PHP_ADD_LIBRARY_WITH_PATH(snmp, $SNMP_LIBDIR, SNMP_SHARED_LIBADD)
- SNMP_LIBNAME=snmp
- fi
-
- dnl Check whether snmp_parse_oid() exists.
- PHP_CHECK_LIBRARY($SNMP_LIBNAME, snmp_parse_oid,
- [
- AC_DEFINE(HAVE_SNMP_PARSE_OID, 1, [ ])
- ], [], [
- $SNMP_SHARED_LIBADD
- ])
-
- dnl Test build.
- PHP_CHECK_LIBRARY($SNMP_LIBNAME, init_snmp,
- [
- AC_DEFINE(HAVE_SNMP,1,[ ])
- ], [
- AC_MSG_ERROR([SNMP sanity check failed. Please check config.log for more information.])
- ], [
- $SNMP_SHARED_LIBADD
- ])
-
- PHP_NEW_EXTENSION(snmp, snmp.c, $ext_shared)
- PHP_SUBST(SNMP_SHARED_LIBADD)
-fi
-
-
-AC_MSG_CHECKING(whether to enable UCD SNMP hack)
-AC_ARG_ENABLE(ucd-snmp-hack,
-[ --enable-ucd-snmp-hack Enable UCD SNMP hack],[
- if test "$enableval" = "yes" ; then
- AC_DEFINE(UCD_SNMP_HACK, 1, [ ])
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
diff --git a/ext/snmp/config.w32 b/ext/snmp/config.w32
deleted file mode 100644
index 4bf6750d41..0000000000
--- a/ext/snmp/config.w32
+++ /dev/null
@@ -1,18 +0,0 @@
-// $Id$
-// vim:ft=javascript
-
-ARG_WITH("snmp", "SNMP support", "no");
-
-if (PHP_SNMP != "no") {
-
- if (CHECK_HEADER_ADD_INCLUDE("snmp.h", "CFLAGS_SNMP", PHP_PHP_BUILD + "\\include\\ucd-snmp;" + PHP_PHP_BUILD + "\\include\\net-snmp;" + PHP_SNMP) &&
- CHECK_LIB("libsnmp.lib", "snmp", PHP_SNMP)) {
- EXTENSION('snmp', 'snmp.c');
-
- AC_DEFINE('HAVE_SNMP', 1);
-
- } else {
- WARNING("snmp not enabled; libraries and headers not found");
- }
-}
-
diff --git a/ext/snmp/php_snmp.h b/ext/snmp/php_snmp.h
deleted file mode 100644
index e923ca11a3..0000000000
--- a/ext/snmp/php_snmp.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@php.net> |
- | Mike Jackson <mhjack@tscnet.com> |
- | Steven Lawrance <slawrance@technologist.com> |
- | Harrie Hazewinkel <harrie@lisanza.net> |
- | Johann Hanne <jonny@nurfuerspam.de> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef PHP_SNMP_H
-#define PHP_SNMP_H
-
-#if HAVE_SNMP
-
-#ifndef DLEXPORT
-#define DLEXPORT
-#endif
-
-extern zend_module_entry snmp_module_entry;
-#define snmp_module_ptr &snmp_module_entry
-
-#ifdef ZTS
-#include "TSRM.h"
-#endif
-
-PHP_MINIT_FUNCTION(snmp);
-PHP_MINFO_FUNCTION(snmp);
-
-PHP_FUNCTION(snmpget);
-PHP_FUNCTION(snmpgetnext);
-PHP_FUNCTION(snmpwalk);
-PHP_FUNCTION(snmprealwalk);
-PHP_FUNCTION(snmp_get_quick_print);
-PHP_FUNCTION(snmp_set_quick_print);
-PHP_FUNCTION(snmp_set_enum_print);
-PHP_FUNCTION(snmp_set_oid_numeric_print);
-PHP_FUNCTION(snmpset);
-
-PHP_FUNCTION(snmp3_get);
-PHP_FUNCTION(snmp3_getnext);
-PHP_FUNCTION(snmp3_walk);
-PHP_FUNCTION(snmp3_real_walk);
-PHP_FUNCTION(snmp3_set);
-
-PHP_FUNCTION(snmp_set_valueretrieval);
-PHP_FUNCTION(snmp_get_valueretrieval);
-
-PHP_FUNCTION(snmp_read_mib);
-
-
-ZEND_BEGIN_MODULE_GLOBALS(snmp)
- int valueretrieval;
-ZEND_END_MODULE_GLOBALS(snmp)
-
-#ifdef ZTS
-#define SNMP_G(v) TSRMG(snmp_globals_id, zend_snmp_globals *, v)
-#else
-#define SNMP_G(v) (snmp_globals.v)
-#endif
-
-#else
-
-#define snmp_module_ptr NULL
-
-#endif /* HAVE_SNMP */
-
-#define phpext_snmp_ptr snmp_module_ptr
-
-#endif /* PHP_SNMP_H */
diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c
deleted file mode 100644
index ec1f0abb2b..0000000000
--- a/ext/snmp/snmp.c
+++ /dev/null
@@ -1,1098 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@php.net> |
- | Mike Jackson <mhjack@tscnet.com> |
- | Steven Lawrance <slawrance@technologist.com> |
- | Harrie Hazewinkel <harrie@lisanza.net> |
- | Johann Hanne <jonny@nurfuerspam.de> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "php.h"
-#include "ext/standard/info.h"
-#include "php_snmp.h"
-
-#if HAVE_SNMP
-
-#include <sys/types.h>
-#ifdef PHP_WIN32
-#include <winsock2.h>
-#include <errno.h>
-#include <process.h>
-#include "win32/time.h"
-#elif defined(NETWARE)
-#ifdef USE_WINSOCK
-/*#include <ws2nlm.h>*/
-#include <novsock2.h>
-#else
-#include <sys/socket.h>
-#endif
-#include <errno.h>
-/*#include <process.h>*/
-#ifdef NEW_LIBC
-#include <sys/timeval.h>
-#else
-#include "netware/time_nw.h"
-#endif
-#else
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#ifndef _OSD_POSIX
-#include <sys/errno.h>
-#else
-#include <errno.h> /* BS2000/OSD uses <errno.h>, not <sys/errno.h> */
-#endif
-#include <netdb.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifndef __P
-#ifdef __GNUC__
-#define __P(args) args
-#else
-#define __P(args) ()
-#endif
-#endif
-
-#ifdef HAVE_NET_SNMP
-#include <net-snmp/net-snmp-config.h>
-#include <net-snmp/net-snmp-includes.h>
-#else
-#ifdef HAVE_DEFAULT_STORE_H
-#include "default_store.h"
-#endif
-#include "asn1.h"
-#include "snmp_api.h"
-#include "snmp_client.h"
-#include "snmp_impl.h"
-#include "snmp.h"
-#include "snmpv3.h"
-#include "keytools.h"
-#include "parse.h"
-#include "mib.h"
-#ifndef PHP_WIN32
-/* this doesn't appear to be needed under win32 (perhaps at all)
- * and the header file is not present in my UCD-SNMP headers */
-# include "version.h"
-#endif
-#include "transform_oids.h"
-#endif
-/* Ugly macro, since the length of OIDs in UCD-SNMP and NET-SNMP
- * is different and this way the code is not full of 'ifdef's.
- */
-#define OIDSIZE(p) (sizeof(p)/sizeof(oid))
-
-/* For really old ucd-snmp versions.. */
-#ifndef HAVE_SNMP_PARSE_OID
-#define snmp_parse_oid read_objid
-#endif
-
-#define SNMP_VALUE_LIBRARY 0
-#define SNMP_VALUE_PLAIN 1
-#define SNMP_VALUE_OBJECT 2
-
-ZEND_DECLARE_MODULE_GLOBALS(snmp)
-
-/* constant - can be shared among threads */
-static oid objid_mib[] = {1, 3, 6, 1, 2, 1};
-
-/* {{{ snmp_functions[]
- */
-function_entry snmp_functions[] = {
- PHP_FE(snmpget, NULL)
- PHP_FE(snmpgetnext, NULL)
- PHP_FE(snmpwalk, NULL)
- PHP_FE(snmprealwalk, NULL)
- PHP_FALIAS(snmpwalkoid, snmprealwalk, NULL)
- PHP_FE(snmp_get_quick_print, NULL)
- PHP_FE(snmp_set_quick_print, NULL)
-#ifdef HAVE_NET_SNMP
- PHP_FE(snmp_set_enum_print, NULL)
- PHP_FE(snmp_set_oid_numeric_print, NULL)
-#endif
- PHP_FE(snmpset, NULL)
-
- PHP_FE(snmp3_get, NULL)
- PHP_FE(snmp3_getnext, NULL)
- PHP_FE(snmp3_walk, NULL)
- PHP_FE(snmp3_real_walk, NULL)
- PHP_FE(snmp3_set, NULL)
- PHP_FE(snmp_set_valueretrieval, NULL)
- PHP_FE(snmp_get_valueretrieval, NULL)
-
- PHP_FE(snmp_read_mib, NULL)
- {NULL,NULL,NULL}
-};
-/* }}} */
-
-/* {{{ snmp_module_entry
- */
-zend_module_entry snmp_module_entry = {
- STANDARD_MODULE_HEADER,
- "snmp",
- snmp_functions,
- PHP_MINIT(snmp),
- NULL,
- NULL,
- NULL,
- PHP_MINFO(snmp),
- NO_VERSION_YET,
- STANDARD_MODULE_PROPERTIES
-};
-/* }}} */
-
-#ifdef COMPILE_DL_SNMP
-ZEND_GET_MODULE(snmp)
-#endif
-
-/* THREAD_LS snmp_module php_snmp_module; - may need one of these at some point */
-
-/* {{{ php_snmp_init_globals
- */
-static void php_snmp_init_globals(zend_snmp_globals *snmp_globals)
-{
- snmp_globals->valueretrieval = 0;
-}
-/* }}} */
-
-/* {{{ PHP_MINIT_FUNCTION
- */
-PHP_MINIT_FUNCTION(snmp)
-{
- init_snmp("snmpapp");
-
- ZEND_INIT_MODULE_GLOBALS(snmp, php_snmp_init_globals, NULL);
-
- REGISTER_LONG_CONSTANT("SNMP_VALUE_LIBRARY", SNMP_VALUE_LIBRARY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SNMP_VALUE_PLAIN", SNMP_VALUE_PLAIN, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SNMP_VALUE_OBJECT", SNMP_VALUE_OBJECT, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("SNMP_BIT_STR", ASN_BIT_STR, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SNMP_OCTET_STR", ASN_OCTET_STR, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SNMP_OPAQUE", ASN_OPAQUE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SNMP_NULL", ASN_NULL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SNMP_OBJECT_ID", ASN_OBJECT_ID, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SNMP_IPADDRESS", ASN_IPADDRESS, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SNMP_COUNTER", ASN_GAUGE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SNMP_UNSIGNED", ASN_UNSIGNED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SNMP_TIMETICKS", ASN_TIMETICKS, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SNMP_UINTEGER", ASN_UINTEGER, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SNMP_INTEGER", ASN_INTEGER, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SNMP_COUNTER64", ASN_COUNTER64, CONST_CS | CONST_PERSISTENT);
-
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ PHP_MINFO_FUNCTION
- */
-PHP_MINFO_FUNCTION(snmp)
-{
- php_info_print_table_start();
-#ifdef HAVE_NET_SNMP
- php_info_print_table_row(2, "NET-SNMP Support", "enabled");
- php_info_print_table_row(2, "NET-SNMP Version", netsnmp_get_version());
-#else
- php_info_print_table_row(2, "UCD-SNMP Support", "enabled");
- php_info_print_table_row(2, "UCD-SNMP Version", VersionInfo);
-#endif
- php_info_print_table_end();
-}
-/* }}} */
-
-static void php_snmp_getvalue(struct variable_list *vars, zval *snmpval TSRMLS_DC)
-{
- zval *val;
-#if I64CHARSZ > 2047
- char buf[I64CHARSZ + 1];
-#else
- char buf[2048];
-#endif
-
- buf[0] = 0;
-
- if (SNMP_G(valueretrieval) == 0) {
-#ifdef HAVE_NET_SNMP
- snprint_value(buf, sizeof(buf), vars->name, vars->name_length, vars);
-#else
- sprint_value(buf,vars->name, vars->name_length, vars);
-#endif
- ZVAL_STRING(snmpval, buf, 1);
- return;
- }
-
- MAKE_STD_ZVAL(val);
-
- switch (vars->type) {
- case ASN_BIT_STR: /* 0x03, asn1.h */
- ZVAL_STRINGL(val, vars->val.bitstring, vars->val_len, 1);
- break;
-
- case ASN_OCTET_STR: /* 0x04, asn1.h */
- case ASN_OPAQUE: /* 0x44, snmp_impl.h */
- ZVAL_STRINGL(val, vars->val.string, vars->val_len, 1);
- break;
-
- case ASN_NULL: /* 0x05, asn1.h */
- ZVAL_NULL(val);
- break;
-
- case ASN_OBJECT_ID: /* 0x06, asn1.h */
-#ifdef HAVE_NET_SNMP
- snprint_objid(buf, sizeof(buf), vars->val.objid, vars->val_len / sizeof(oid));
-#else
- sprint_objid(buf, vars->val.objid, vars->val_len / sizeof(oid));
-#endif
-
- ZVAL_STRING(val, buf, 1);
- break;
-
- case ASN_IPADDRESS: /* 0x40, snmp_impl.h */
- snprintf(buf, sizeof(buf)-1, "%d.%d.%d.%d",
- (vars->val.string)[0], (vars->val.string)[1],
- (vars->val.string)[2], (vars->val.string)[3]);
- buf[sizeof(buf)-1]=0;
- ZVAL_STRING(val, buf, 1);
- break;
-
- case ASN_COUNTER: /* 0x41, snmp_impl.h */
- case ASN_GAUGE: /* 0x42, snmp_impl.h */
- /* ASN_UNSIGNED is the same as ASN_GAUGE */
- case ASN_TIMETICKS: /* 0x43, snmp_impl.h */
- case ASN_UINTEGER: /* 0x47, snmp_impl.h */
- snprintf(buf, sizeof(buf)-1, "%lu", *vars->val.integer);
- buf[sizeof(buf)-1]=0;
- ZVAL_STRING(val, buf, 1);
- break;
-
- case ASN_INTEGER: /* 0x02, asn1.h */
- snprintf(buf, sizeof(buf)-1, "%ld", *vars->val.integer);
- buf[sizeof(buf)-1]=0;
- ZVAL_STRING(val, buf, 1);
- break;
-
- case ASN_COUNTER64: /* 0x46, snmp_impl.h */
- printU64(buf, vars->val.counter64);
- ZVAL_STRING(val, buf, 1);
- break;
-
- default:
- ZVAL_STRING(val, "Unknown value type", 1);
- break;
- }
-
- if (SNMP_G(valueretrieval) == 1) {
- *snmpval = *val;
- zval_copy_ctor(snmpval);
- } else {
- object_init(snmpval);
- add_property_long(snmpval, "type", vars->type);
- add_property_zval(snmpval, "value", val);
- }
-}
-
-/* {{{ php_snmp_internal
-*
-* Generic SNMP object fetcher (for both v3 and v1)
-*
-* st=1 snmpget() - query an agent and return a single value.
-* st=2 snmpget() - query an agent and return the next single value.
-* st=3 snmpwalk() - walk the mib and return a single dimensional array
-* containing the values.
-* st=4 snmprealwalk() and snmpwalkoid() - walk the mib and return an
-* array of oid,value pairs.
-* st=5-8 ** Reserved **
-* st=11 snmpset() - query an agent and set a single value
-*
-*/
-static void php_snmp_internal(INTERNAL_FUNCTION_PARAMETERS, int st,
- struct snmp_session *session,
- char *objid,
- char type,
- char* value)
-{
- struct snmp_session *ss;
- struct snmp_pdu *pdu=NULL, *response;
- struct variable_list *vars;
- oid name[MAX_NAME_LEN];
- int name_length;
- oid root[MAX_NAME_LEN];
- int rootlen = 0;
- int gotroot = 0;
- int status, count;
- char buf[2048];
- char buf2[2048];
- int keepwalking=1;
- char *err;
- zval *snmpval = NULL;
-
- if (st >= 3) { /* walk */
- rootlen = MAX_NAME_LEN;
- if (strlen(objid)) { /* on a walk, an empty string means top of tree - no error */
- if (snmp_parse_oid(objid, root, &rootlen)) {
- gotroot = 1;
- } else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid);
- }
- }
-
- if (!gotroot) {
- memmove((char *) root, (char *) objid_mib, sizeof(objid_mib));
- rootlen = sizeof(objid_mib) / sizeof(oid);
- gotroot = 1;
- }
- }
-
- if ((ss = snmp_open(session)) == NULL) {
- snmp_error(session, NULL, NULL, &err);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not open snmp connection: %s", err);
- free(err);
- RETURN_FALSE;
- }
-
- if (st >= 3) {
- memmove((char *)name, (char *)root, rootlen * sizeof(oid));
- name_length = rootlen;
- switch(st) {
- case 3:
- case 4:
- array_init(return_value);
- break;
- default:
- RETVAL_TRUE;
- break;
- }
- }
-
- while (keepwalking) {
- keepwalking = 0;
- if ((st == 1) || (st == 2)) {
- pdu = snmp_pdu_create((st == 1) ? SNMP_MSG_GET : SNMP_MSG_GETNEXT);
- name_length = MAX_OID_LEN;
- if (!snmp_parse_oid(objid, name, &name_length)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid);
- snmp_close(ss);
- RETURN_FALSE;
- }
- snmp_add_null_var(pdu, name, name_length);
- } else if (st == 11) {
- pdu = snmp_pdu_create(SNMP_MSG_SET);
- if (snmp_add_var(pdu, name, name_length, type, value)) {
-#ifdef HAVE_NET_SNMP
- snprint_objid(buf, sizeof(buf), name, name_length);
-#else
- sprint_objid(buf, name, name_length);
-#endif
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not add variable: %s %c %s", buf, type, value);
- snmp_close(ss);
- RETURN_FALSE;
- }
- } else if (st >= 3) {
- pdu = snmp_pdu_create(SNMP_MSG_GETNEXT);
- 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 >= 3 && st != 11 &&
- (vars->name_length < rootlen || memcmp(root, vars->name, rootlen * sizeof(oid)))) {
- continue; /* not part of this subtree */
- }
-
- if (st != 11) {
- MAKE_STD_ZVAL(snmpval);
- php_snmp_getvalue(vars, snmpval TSRMLS_CC);
- }
-
- if (st == 1) {
- *return_value = *snmpval;
- zval_copy_ctor(return_value);
- snmp_close(ss);
- return;
- } else if (st == 2) {
- *return_value = *snmpval;
- zval_copy_ctor(return_value);
- return;
- } else if (st == 3) {
- add_next_index_zval(return_value,snmpval); /* Add to returned array */
- } else if (st == 4) {
-#ifdef HAVE_NET_SNMP
- snprint_objid(buf2, sizeof(buf2), vars->name, vars->name_length);
-#else
- sprint_objid(buf2, vars->name, vars->name_length);
-#endif
- add_assoc_zval(return_value,buf2,snmpval);
- }
- if (st >= 3 && st != 11) {
- 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 != 3 || response->errstat != SNMP_ERR_NOSUCHNAME) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error in packet: %s", 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) {
-#ifdef HAVE_NET_SNMP
- snprint_objid(buf, sizeof(buf), vars->name, vars->name_length);
-#else
- sprint_objid(buf,vars->name, vars->name_length);
-#endif
- }
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "This name does not exist: %s",buf);
- }
- if (st == 1) {
- if ((pdu = snmp_fix_pdu(response, SNMP_MSG_GET)) != NULL) {
- goto retry;
- }
- } else if (st == 11) {
- if ((pdu = snmp_fix_pdu(response, SNMP_MSG_SET)) != NULL) {
- goto retry;
- }
- } else if (st >= 2) { /* Here we do both getnext and walks. */
- if ((pdu = snmp_fix_pdu(response, SNMP_MSG_GETNEXT)) != NULL) {
- goto retry;
- }
- }
- snmp_close(ss);
- RETURN_FALSE;
- }
- }
- } else if (status == STAT_TIMEOUT) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "No response from %s", session->peername);
- if (st == 3 || st == 4) {
- zval_dtor(return_value);
- }
- snmp_close(ss);
- RETURN_FALSE;
- } else { /* status == STAT_ERROR */
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "An error occurred, quitting");
- if (st == 3 || st == 4) {
- zval_dtor(return_value);
- }
- snmp_close(ss);
- RETURN_FALSE;
- }
- if (response) {
- snmp_free_pdu(response);
- }
- } /* keepwalking */
- snmp_close(ss);
-}
-/* }}} */
-
-/* {{{ php_snmp
-*
-* Generic SNMPv1 handler
-* This function makes use of the internal SNMP object fetcher.
-* The object fetcher is shared with SNMPv3.
-*
-* st=1 snmpget() - query an agent and return a single value.
-* st=2 snmpgetnext() - query an agent and return the next single value.
-* st=3 snmpwalk() - walk the mib and return a single dimensional array
-* containing the values.
-* st=4 snmprealwalk() and snmpwalkoid() - walk the mib and return an
-* array of oid,value pairs.
-* st=5-8 ** Reserved **
-* st=11 snmpset() - query an agent and set a single value
-*
-*/
-static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st)
-{
- zval **a1, **a2, **a3, **a4, **a5, **a6, **a7;
- struct snmp_session session;
- long timeout=SNMP_DEFAULT_TIMEOUT;
- long retries=SNMP_DEFAULT_RETRIES;
- int myargc = ZEND_NUM_ARGS();
- char type = (char) 0;
- char *value = (char *) 0;
- char hostname[MAX_NAME_LEN];
- int remote_port = 161;
- char *pptr;
-
- if (myargc < 3 || myargc > 7 ||
- zend_get_parameters_ex(myargc, &a1, &a2, &a3, &a4, &a5, &a6, &a7) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string_ex(a1);
- convert_to_string_ex(a2);
- convert_to_string_ex(a3);
-
- if (st == 11) {
- if (myargc < 5) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string_ex(a4);
- convert_to_string_ex(a5);
-
- if(myargc > 5) {
- convert_to_long_ex(a6);
- timeout = Z_LVAL_PP(a6);
- }
-
- if(myargc > 6) {
- convert_to_long_ex(a7);
- retries = Z_LVAL_PP(a7);
- }
-
- type = Z_STRVAL_PP(a4)[0];
- value = Z_STRVAL_PP(a5);
- } else {
- if(myargc > 3) {
- convert_to_long_ex(a4);
- timeout = Z_LVAL_PP(a4);
- }
-
- if(myargc > 4) {
- convert_to_long_ex(a5);
- retries = Z_LVAL_PP(a5);
- }
- }
-
- snmp_sess_init(&session);
- strcpy (hostname, Z_STRVAL_PP(a1));
- if ((pptr = strchr (hostname, ':'))) {
- remote_port = strtol (pptr + 1, NULL, 0);
- }
-
- session.peername = hostname;
- session.remote_port = remote_port;
- 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
- */
-#ifdef UCD_SNMP_HACK
- session.community = (u_char *)strdup(Z_STRVAL_PP(a2)); /* memory freed by SNMP library, strdup NOT estrdup */
-#else
- session.community = (u_char *)Z_STRVAL_PP(a2);
-#endif
- session.community_len = Z_STRLEN_PP(a2);
- session.retries = retries;
- session.timeout = timeout;
-
- session.authenticator = NULL;
-
- php_snmp_internal(INTERNAL_FUNCTION_PARAM_PASSTHRU, st, &session, Z_STRVAL_PP(a3), type, value);
-}
-/* }}} */
-
-/* {{{ proto string snmpget(string host, string community, string object_id [, int timeout [, int retries]])
- Fetch a SNMP object */
-PHP_FUNCTION(snmpget)
-{
- php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
-}
-/* }}} */
-
-/* {{{ proto string snmpgetnext(string host, string community, string object_id [, int timeout [, int retries]])
- Fetch a SNMP object */
-PHP_FUNCTION(snmpgetnext)
-{
- php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,2);
-}
-/* }}} */
-
-/* {{{ proto array snmpwalk(string host, string community, string object_id [, int timeout [, int retries]])
- Return all objects under the specified object id */
-PHP_FUNCTION(snmpwalk)
-{
- php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,3);
-}
-/* }}} */
-
-/* {{{ proto array 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)
-{
- php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,4);
-}
-/* }}} */
-
-/* {{{ proto bool snmp_get_quick_print(void)
- Return the current status of quick_print */
-PHP_FUNCTION(snmp_get_quick_print)
-{
- if (ZEND_NUM_ARGS() != 0) {
- WRONG_PARAM_COUNT;
- }
-
-#ifdef HAVE_NET_SNMP
- RETURN_BOOL(netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT));
-#else
- RETURN_BOOL(snmp_get_quick_print());
-#endif
-}
-/* }}} */
-
-/* {{{ proto void snmp_set_quick_print(int quick_print)
- Return all objects including their respective object id withing the specified one */
-PHP_FUNCTION(snmp_set_quick_print)
-{
- int argc = ZEND_NUM_ARGS();
- long a1;
-
- if (zend_parse_parameters(argc TSRMLS_CC, "l", &a1) == FAILURE) {
- return;
- }
-
-#ifdef HAVE_NET_SNMP
- netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT, (int) a1);
-#else
- snmp_set_quick_print((int)a1);
-#endif
-}
-/* }}} */
-
-#ifdef HAVE_NET_SNMP
-/* {{{ proto void snmp_set_enum_print(int enum_print)
- Return all values that are enums with their enum value instead of the raw integer */
-PHP_FUNCTION(snmp_set_enum_print)
-{
- int argc = ZEND_NUM_ARGS();
- long a1;
-
- if (zend_parse_parameters(argc TSRMLS_CC, "l", &a1) == FAILURE) {
- return;
- }
-
- netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM, (int) a1);
-}
-/* }}} */
-
-/* {{{ proto void snmp_set_oid_numeric_print(int oid_numeric_print)
- Return all objects including their respective object id withing the specified one */
-PHP_FUNCTION(snmp_set_oid_numeric_print)
-{
- int argc = ZEND_NUM_ARGS();
- long a1;
-
- if (zend_parse_parameters(argc TSRMLS_CC, "l", &a1) == FAILURE) {
- return;
- }
- if ((int) a1 != 0) {
- netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID,
- NETSNMP_DS_LIB_OID_OUTPUT_FORMAT,
- NETSNMP_OID_OUTPUT_NUMERIC);
- }
-}
-/* }}} */
-#endif
-
-/* {{{ proto int snmpset(string host, string community, string object_id, string type, mixed value [, int timeout [, int retries]])
- Set the value of a SNMP object */
-PHP_FUNCTION(snmpset)
-{
- php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,11);
-}
-/* }}} */
-
-/* {{{ int netsnmp_session_set_sec_name(struct snmp_session *s, char *name)
- Set the security name in the snmpv3 session */
-static int netsnmp_session_set_sec_name(struct snmp_session *s, char *name)
-{
- if ((s) && (name)) {
- s->securityName = strdup(name);
- s->securityNameLen = strlen(s->securityName);
- return (0);
- }
- return (-1);
-}
-/* }}} */
-
-/* {{{ int netsnmp_session_set_sec_level(struct snmp_session *s, char *level)
- Set the security level in the snmpv3 session */
-static int netsnmp_session_set_sec_level(struct snmp_session *s, char *level TSRMLS_DC)
-{
- if ((s) && (level)) {
- if (!strcasecmp(level, "noAuthNoPriv") || !strcasecmp(level, "nanp")) {
- s->securityLevel = SNMP_SEC_LEVEL_NOAUTH;
- return (0);
- } else if (!strcasecmp(level, "authNoPriv") || !strcasecmp(level, "anp")) {
- s->securityLevel = SNMP_SEC_LEVEL_AUTHNOPRIV;
- return (0);
- } else if (!strcasecmp(level, "authPriv") || !strcasecmp(level, "ap")) {
- s->securityLevel = SNMP_SEC_LEVEL_AUTHPRIV;
- return (0);
- }
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid security level: %s", level);
- }
- return (-1);
-}
-/* }}} */
-
-/* {{{ int netsnmp_session_set_auth_protocol(struct snmp_session *s, char *prot)
- Set the authentication protocol in the snmpv3 session */
-static int netsnmp_session_set_auth_protocol(struct snmp_session *s, char *prot TSRMLS_DC)
-{
- if ((s) && (prot)) {
- if (!strcasecmp(prot, "MD5")) {
- s->securityAuthProto = usmHMACMD5AuthProtocol;
- s->securityAuthProtoLen = OIDSIZE(usmHMACMD5AuthProtocol);
- return (0);
- } else if (!strcasecmp(prot, "SHA")) {
- s->securityAuthProto = usmHMACSHA1AuthProtocol;
- s->securityAuthProtoLen = OIDSIZE(usmHMACSHA1AuthProtocol);
- return (0);
- } else if (strlen(prot)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid authentication protocol: %s", prot);
- }
- }
- return (-1);
-}
-/* }}} */
-
-/* {{{ int netsnmp_session_set_sec_protocol(struct snmp_session *s, char *prot)
- Set the security protocol in the snmpv3 session */
-static int netsnmp_session_set_sec_protocol(struct snmp_session *s, char *prot TSRMLS_DC)
-{
- if ((s) && (prot)) {
- if (!strcasecmp(prot, "DES")) {
- s->securityPrivProto = usmDESPrivProtocol;
- s->securityPrivProtoLen = OIDSIZE(usmDESPrivProtocol);
- return (0);
-#ifdef HAVE_AES
- } else if (!strcasecmp(prot, "AES128")) {
- s->securityPrivProto = usmAES128PrivProtocol;
- s->securityPrivProtoLen = OIDSIZE(usmAES128PrivProtocol);
- return (0);
- } else if (!strcasecmp(prot, "AES192")) {
- s->securityPrivProto = usmAES192PrivProtocol;
- s->securityPrivProtoLen = OIDSIZE(usmAES192PrivProtocol);
- return (0);
- } else if (!strcasecmp(prot, "AES256")) {
- s->securityPrivProto = usmAES256PrivProtocol;
- s->securityPrivProtoLen = OIDSIZE(usmAES256PrivProtocol);
- return (0);
-#endif
- } else if (strlen(prot)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid privacy protocol: %s", prot);
- }
- }
- return (-1);
-}
-/* }}} */
-
-/* {{{ int netsnmp_session_gen_auth_key(struct snmp_session *s, char *pass)
- Make key from pass phrase in the snmpv3 session */
-static int netsnmp_session_gen_auth_key(struct snmp_session *s, char *pass TSRMLS_DC)
-{
- /*
- * make master key from pass phrases
- */
- if ((s) && (pass) && strlen(pass)) {
- s->securityAuthKeyLen = USM_AUTH_KU_LEN;
- if (s->securityAuthProto == NULL) {
- /* get .conf set default */
- oid *def = get_default_authtype(&(s->securityAuthProtoLen));
- s->securityAuthProto = snmp_duplicate_objid(def, s->securityAuthProtoLen);
- }
- if (s->securityAuthProto == NULL) {
- /* assume MD5 */
- s->securityAuthProto =
- snmp_duplicate_objid(usmHMACMD5AuthProtocol, OIDSIZE(usmHMACMD5AuthProtocol));
- s->securityAuthProtoLen = OIDSIZE(usmHMACMD5AuthProtocol);
- }
- if (generate_Ku(s->securityAuthProto, s->securityAuthProtoLen,
- (u_char *) pass, strlen(pass),
- s->securityAuthKey, &(s->securityAuthKeyLen)) != SNMPERR_SUCCESS) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error generating a key for authentication pass phrase");
- return (-2);
- }
- return (0);
- }
- return (-1);
-}
-/* }}} */
-
-/* {{{ int netsnmp_session_gen_sec_key(struct snmp_session *s, u_char *pass)
- Make key from pass phrase in the snmpv3 session */
-static int netsnmp_session_gen_sec_key(struct snmp_session *s, u_char *pass TSRMLS_DC)
-{
- if ((s) && (pass) && strlen(pass)) {
- s->securityPrivKeyLen = USM_PRIV_KU_LEN;
- if (s->securityPrivProto == NULL) {
- /* get .conf set default */
- oid *def = get_default_privtype(&(s->securityPrivProtoLen));
- s->securityPrivProto = snmp_duplicate_objid(def, s->securityPrivProtoLen);
- }
- if (s->securityPrivProto == NULL) {
- /* assume DES */
- s->securityPrivProto = snmp_duplicate_objid(usmDESPrivProtocol,
- OIDSIZE(usmDESPrivProtocol));
- s->securityPrivProtoLen = OIDSIZE(usmDESPrivProtocol);
- }
- if (generate_Ku(s->securityAuthProto, s->securityAuthProtoLen,
- pass, strlen(pass),
- s->securityPrivKey, &(s->securityPrivKeyLen)) != SNMPERR_SUCCESS) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error generating a key for privacy pass phrase");
- return (-2);
- }
- return (0);
- }
- return (-1);
-}
-/* }}} */
-
-
-/* {{{ proto void php_snmpv3(INTERNAL_FUNCTION_PARAMETERS, int st)
-*
-* Generic SNMPv3 object fetcher
-* From here is passed on the the common internal object fetcher.
-*
-* st=1 snmp3_get() - query an agent and return a single value.
-* st=2 snmp3_getnext() - query an agent and return the next single value.
-* st=3 snmp3_walk() - walk the mib and return a single dimensional array
-* containing the values.
-* st=4 snmp3_real_walk() - walk the mib and return an
-* array of oid,value pairs.
-* st=11 snmp3_set() - query an agent and set a single value
-*
-*/
-static void php_snmpv3(INTERNAL_FUNCTION_PARAMETERS, int st)
-{
- zval **a1, **a2, **a3, **a4, **a5, **a6, **a7, **a8, **a9, **a10, **a11, **a12;
- struct snmp_session session;
- long timeout=SNMP_DEFAULT_TIMEOUT;
- long retries=SNMP_DEFAULT_RETRIES;
- int myargc = ZEND_NUM_ARGS();
- char type = (char) 0;
- char *value = (char *) 0;
- char hostname[MAX_NAME_LEN];
- int remote_port = 161;
- char *pptr;
-
- if (myargc < 8 || myargc > 12 ||
- zend_get_parameters_ex(myargc, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9, &a10, &a11, &a12) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- snmp_sess_init(&session);
- /* This is all SNMPv3 */
- session.version = SNMP_VERSION_3;
-
- /* Reading the hostname and its optional non-default port number */
- convert_to_string_ex(a1);
- strcpy(hostname, Z_STRVAL_PP(a1));
- if ((pptr = strchr (hostname, ':'))) {
- remote_port = strtol (pptr + 1, NULL, 0);
- }
- session.peername = hostname;
- session.remote_port = remote_port;
-
- /* Setting the security name. */
- convert_to_string_ex(a2);
- if (netsnmp_session_set_sec_name(&session, Z_STRVAL_PP(a2))) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could net set security name: %s", Z_STRVAL_PP(a2));
- RETURN_FALSE;
- }
-
- /* Setting the security level. */
- convert_to_string_ex(a3);
- if (netsnmp_session_set_sec_level(&session, Z_STRVAL_PP(a3) TSRMLS_CC)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid security level: %s", Z_STRVAL_PP(a3));
- RETURN_FALSE;
- }
-
- /* Setting the authentication protocol. */
- convert_to_string_ex(a4);
- if (netsnmp_session_set_auth_protocol(&session, Z_STRVAL_PP(a4) TSRMLS_CC)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid authentication protocol: %s", Z_STRVAL_PP(a4));
- RETURN_FALSE;
- }
-
- /* Setting the authentication passphrase. */
- convert_to_string_ex(a5);
- if (netsnmp_session_gen_auth_key(&session, Z_STRVAL_PP(a5) TSRMLS_CC)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not generate key for authentication pass phrase: %s", Z_STRVAL_PP(a4));
- RETURN_FALSE;
- }
-
- /* Setting the security protocol. */
- convert_to_string_ex(a6);
- if (netsnmp_session_set_sec_protocol(&session, Z_STRVAL_PP(a6) TSRMLS_CC) &&
- (0 != strlen(Z_STRVAL_PP(a6)))) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid security protocol: %s", Z_STRVAL_PP(a6));
- RETURN_FALSE;
- }
-
- /* Setting the security protocol passphrase. */
- convert_to_string_ex(a7);
- if (netsnmp_session_gen_sec_key(&session, Z_STRVAL_PP(a7) TSRMLS_CC) &&
- (0 != strlen(Z_STRVAL_PP(a7)))) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not generate key for security pass phrase: %s", Z_STRVAL_PP(a7));
- RETURN_FALSE;
- }
-
- if (st == 11) {
- if (myargc < 10) {
- WRONG_PARAM_COUNT;
- }
- if (myargc > 10) {
- convert_to_long_ex(a11);
- timeout = Z_LVAL_PP(a11);
- }
- if (myargc > 11) {
- convert_to_long_ex(a12);
- retries = Z_LVAL_PP(a12);
- }
- convert_to_string_ex(a9);
- convert_to_string_ex(a10);
- type = Z_STRVAL_PP(a9)[0];
- value = Z_STRVAL_PP(a10);
- } else {
- if (myargc > 8) {
- convert_to_long_ex(a9);
- timeout = Z_LVAL_PP(a9);
- }
- if (myargc > 9) {
- convert_to_long_ex(a10);
- retries = Z_LVAL_PP(a10);
- }
- }
-
- session.retries = retries;
- session.timeout = timeout;
-
- php_snmp_internal(INTERNAL_FUNCTION_PARAM_PASSTHRU, st, &session, Z_STRVAL_PP(a8), type, value);
-}
-/* }}} */
-
-/* {{{ proto int snmp3_get(string host, string sec_name, string sec_level, string auth_protocol, string auth_passphrase, string priv_protocol, string priv_passphrase, string object_id [, int timeout [, int retries]])
- Fetch the value of a SNMP object */
-PHP_FUNCTION(snmp3_get)
-{
- php_snmpv3(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-/* {{{ proto int snmp3_getnext(string host, string sec_name, string sec_level, string auth_protocol, string auth_passphrase, string priv_protocol, string priv_passphrase, string object_id [, int timeout [, int retries]])
- Fetch the value of a SNMP object */
-PHP_FUNCTION(snmp3_getnext)
-{
- php_snmpv3(INTERNAL_FUNCTION_PARAM_PASSTHRU, 2);
-}
-/* }}} */
-
-/* {{{ proto int snmp3_walk(string host, string sec_name, string sec_level, string auth_protocol, string auth_passphrase, string priv_protocol, string priv_passphrase, string object_id [, int timeout [, int retries]])
- Fetch the value of a SNMP object */
-PHP_FUNCTION(snmp3_walk)
-{
- php_snmpv3(INTERNAL_FUNCTION_PARAM_PASSTHRU, 3);
-}
-/* }}} */
-
-/* {{{ proto int snmp3_real_walk(string host, string sec_name, string sec_level, string auth_protocol, string auth_passphrase, string priv_protocol, string priv_passphrase, string object_id [, int timeout [, int retries]])
- Fetch the value of a SNMP object */
-PHP_FUNCTION(snmp3_real_walk)
-{
- php_snmpv3(INTERNAL_FUNCTION_PARAM_PASSTHRU, 4);
-}
-/* }}} */
-
-/* {{{ proto int snmp3_set(string host, string sec_name, string sec_level, string auth_protocol, string auth_passphrase, string priv_protocol, string priv_passphrase, string object_id, string type, mixed value [, int timeout [, int retries]])
- Fetch the value of a SNMP object */
-PHP_FUNCTION(snmp3_set)
-{
- php_snmpv3(INTERNAL_FUNCTION_PARAM_PASSTHRU, 11);
-}
-/* }}} */
-
-/* {{{ proto int snmp_set_valueretrieval(int method)
- Specify the method how the SNMP values will be returned */
-PHP_FUNCTION(snmp_set_valueretrieval)
-{
- zval **method;
-
- if (ZEND_NUM_ARGS() != 1 ||
- zend_get_parameters_ex(ZEND_NUM_ARGS(), &method) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long_ex(method);
-
- if ((Z_LVAL_PP(method) == SNMP_VALUE_LIBRARY) ||
- (Z_LVAL_PP(method) == SNMP_VALUE_PLAIN) ||
- (Z_LVAL_PP(method) == SNMP_VALUE_OBJECT)) {
- SNMP_G(valueretrieval) = Z_LVAL_PP(method);
- }
-}
-/* }}} */
-
-/* {{{ proto int snmp_get_valueretrieval()
- Return the method how the SNMP values will be returned */
-PHP_FUNCTION(snmp_get_valueretrieval)
-{
- RETURN_LONG(SNMP_G(valueretrieval));
-}
-/* }}} */
-
-/* {{{ proto int snmp_read_mib(string filename)
- Reads and parses a MIB file into the active MIB tree. */
-PHP_FUNCTION(snmp_read_mib)
-{
- zval **filename;
-
- if (ZEND_NUM_ARGS() != 1 ||
- zend_get_parameters_ex(ZEND_NUM_ARGS(), &filename) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string_ex(filename);
-
- /* Prevent read_mib() from printing any errors. */
- snmp_disable_stderrlog();
-
- if (!read_mib(Z_STRVAL_PP(filename))) {
- char *error = strerror(errno);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while reading MIB file '%s': %s", Z_STRVAL_PP(filename), error);
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/ext/snmp/snmp.dsp b/ext/snmp/snmp.dsp
deleted file mode 100644
index 3cc62338bd..0000000000
--- a/ext/snmp/snmp.dsp
+++ /dev/null
@@ -1,109 +0,0 @@
-# Microsoft Developer Studio Project File - Name="snmp" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=snmp - Win32 Release_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "snmp.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "snmp.mak" CFG="snmp - Win32 Release_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "snmp - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "snmp - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "snmp - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL_SNMP" /D ZTS=1 /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SNMP_EXPORTS" /D "COMPILE_DL_SNMP" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_SNMP=1 /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x406 /d "NDEBUG"
-# ADD RSC /l 0x406 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php5ts.lib /nologo /dll /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php5ts.lib libsnmp.lib wsock32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_snmp.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline"
-
-!ELSEIF "$(CFG)" == "snmp - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL_SNMP" /D ZTS=1 /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SNMP_EXPORTS" /D "COMPILE_DL_SNMP" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_SNMP=1 /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x406 /d "NDEBUG"
-# ADD RSC /l 0x406 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php5ts.lib /nologo /dll /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php5ts_debug.lib libsnmp.lib wsock32.lib /nologo /dll /machine:I386 /out:"..\..\Debug_TS/php_snmp.dll" /libpath:"..\..\Debug_TS"
-
-!ENDIF
-
-# Begin Target
-
-# Name "snmp - Win32 Release_TS"
-# Name "snmp - Win32 Debug_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\snmp.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\php_snmp.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/ext/snmp/winsnmp.c b/ext/snmp/winsnmp.c
deleted file mode 100644
index 188d526ff5..0000000000
--- a/ext/snmp/winsnmp.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
-Created from the snmputil sample in the Microsoft SDK for NT
-*/
-
-#include "php.h"
-#if COMPILE_DL
-#include "../phpdl.h"
-#include "functions/dl.h"
-#endif
-#include "php_snmp.h"
-#include <sys/types.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <malloc.h>
-
-#if HAVE_SNMP
-
-#include <snmp.h>
-#include <mgmtapi.h>
-
-/* {{{ snmp_functions[]
- */
-function_entry snmp_functions[] = {
- {"snmpget", php3_snmpget, NULL},
- {"snmpwalk", php3_snmpwalk, NULL},
- {NULL,NULL,NULL}
-};
-/* }}} */
-
-/* {{{ snmp_module_entry
- */
-zend_module_entry snmp_module_entry = {
- STANDARD_MODULE_HEADER,
- "SNMP",
- snmp_functions,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NO_VERSION_YET,
- STANDARD_MODULE_PROPERTIES
-};
-/* }}} */
-
-#if COMPILE_DL
-DLEXPORT zend_module_entry *get_module() { return &snmp_module_entry; }
-#endif
-
-#define GET 1
-#define WALK 2
-#define GETNEXT 3
-
-#define TIMEOUT 6000 /* milliseconds */
-#define RETRIES 3
-
-/* {{{ _php_snmp
- */
-void _php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st) {
- pval *a1, *a2, *a3;
- INT operation;
- LPSTR agent;
- LPSTR community;
- RFC1157VarBindList variableBindings;
- LPSNMP_MGR_SESSION session;
-
- INT timeout = TIMEOUT;
- INT retries = RETRIES;
-
- BYTE requestType;
- AsnInteger errorStatus;
- AsnInteger errorIndex;
- AsnObjectIdentifier oid;
- char *chkPtr = NULL;
-
- if (zend_get_parameters_ex(3, &a1, &a2, &a3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string_ex(a1);
- convert_to_string_ex(a2);
- convert_to_string_ex(a3);
-
- agent=Z_STRVAL_PP(a1);
- community=Z_STRVAL_PP(a2);
- operation=st;
- SnmpMgrStrToOid(Z_STRVAL_PP(a3), &oid);
-
-/*
- I've limited this to only one oid, but we can create a
- list of oid's here, and expand the function to take multiple
- oid's
-*/
- variableBindings.list->name = oid;
- variableBindings.list->value.asnType = ASN_NULL;
- variableBindings.len = 1;
-
-/* Establish a SNMP session to communicate with the remote agent. The
- community, communications timeout, and communications retry count
- for the session are also required.
-*/
- if ((session = SnmpMgrOpen(agent, community, timeout, retries)) == NULL){
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "error on SnmpMgrOpen %d\n", GetLastError());
- }
-
- /* Determine and perform the requested operation.*/
- if (operation == GET || operation == GETNEXT){
- /* Get and GetNext are relatively simple operations to perform.
- Simply initiate the request and process the result and/or
- possible error conditions. */
-
- if (operation == GET){
- requestType = ASN_RFC1157_GETREQUEST;
- } else {
- requestType = ASN_RFC1157_GETNEXTREQUEST;
- }
-
- /* Request that the API carry out the desired operation.*/
- if (!SnmpMgrRequest(session, requestType, &variableBindings,
- &errorStatus, &errorIndex)){
- /* The API is indicating an error. */
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "error on SnmpMgrRequest %d\n", GetLastError());
- } else {
- /* The API succeeded, errors may be indicated from the remote
- agent. */
- if (errorStatus > 0){
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error: errorStatus=%d, errorIndex=%d\n",
- errorStatus, errorIndex);
- } else {
- /* Display the resulting variable bindings.*/
- UINT i;
- char *str = NULL;
-
- for(i=0; i < variableBindings.len; i++)
- {
- SnmpMgrOidToStr(&variableBindings.list[i].name, &str);
- php_printf("Variable = %s\n", str);
- if (str) SNMP_free(str);
-
- php_printf("Value = ");
- SnmpUtilPrintAsnAny(&variableBindings.list[i].value);
-
- php_printf("\n");
- } /* end for() */
- }
- }
-
- /* Free the variable bindings that have been allocated.*/
- SnmpUtilVarBindListFree(&variableBindings);
- }
- else if (operation == WALK)
- {
- /* Walk is a common term used to indicate that all MIB variables
- under a given OID are to be traversed and displayed. This is
- a more complex operation requiring tests and looping in addition
- to the steps for get/getnext above. */
- AsnObjectIdentifier root;
- AsnObjectIdentifier tempOid;
-
- SnmpUtilOidCpy(&root, &variableBindings.list[0].name);
- requestType = ASN_RFC1157_GETNEXTREQUEST;
-
- while(1)
- {
- if (!SnmpMgrRequest(session, requestType, &variableBindings,
- &errorStatus, &errorIndex)){
- /* The API is indicating an error.*/
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "error on SnmpMgrRequest %d\n", GetLastError());
- break;
- }
- else
- {
- /* The API succeeded, errors may be indicated from the remote
- agent.
- Test for end of subtree or end of MIB. */
- if (errorStatus == SNMP_ERRORSTATUS_NOSUCHNAME ||
- SnmpUtilOidNCmp(&variableBindings.list[0].name,
- &root, root.idLength))
- {
- PUTS("End of MIB subtree.\n\n");
- break;
- }
-
- /* Test for general error conditions or sucesss. */
- if (errorStatus > 0){
- php_error_docref(NULL TSRMLS_CC, E_ERROR,"Error: errorStatus=%d, errorIndex=%d \n", errorStatus, errorIndex);
- break;
- }
- else
- {
- /* Display resulting variable binding for this iteration. */
- char *str = NULL;
-
- SnmpMgrOidToStr(&variableBindings.list[0].name, &str);
- php_printf("Variable = %s\n", str);
- if (str) SNMP_free(str);
-
- php_printf("Value = ");
- SnmpUtilPrintAsnAny(&variableBindings.list[0].value);
-
- php_printf("\n");
- }
- } /* end if () */
- /* Prepare for the next iteration. Make sure returned oid is
- preserved and the returned value is freed.
- */
- SnmpUtilOidCpy(&tempOid, &variableBindings.list[0].name);
- SnmpUtilVarBindFree(&variableBindings.list[0]);
- SnmpUtilOidCpy(&variableBindings.list[0].name, &tempOid);
- variableBindings.list[0].value.asnType = ASN_NULL;
- SnmpUtilOidFree(&tempOid);
- } /* end while() */
- /* Free the variable bindings that have been allocated.*/
- SnmpUtilVarBindListFree(&variableBindings);
- SnmpUtilOidFree(&root);
- } /* end if (operation) */
-
-
- /* Close SNMP session with the remote agent.*/
- if (!SnmpMgrClose(session)){
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "error on SnmpMgrClose %d\n", GetLastError());
- }
-}
-/* }}} */
-
-/* {{{ php3_snmpget
- */
-DLEXPORT void php3_snmpget(INTERNAL_FUNCTION_PARAMETERS) {
- _php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
-}
-/* }}} */
-
-/* {{{ php3_snmpwalk
- */
-DLEXPORT void php3_snmpwalk(INTERNAL_FUNCTION_PARAMETERS) {
- _php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,2);
-}
-/* }}} */
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */