diff options
| author | foobar <sniper@php.net> | 2002-10-15 00:43:34 +0000 |
|---|---|---|
| committer | foobar <sniper@php.net> | 2002-10-15 00:43:34 +0000 |
| commit | 23706f18d6b34aa196f1f007c08c584b4f6f8493 (patch) | |
| tree | 5d1e59ea24c12b0c601a7713a6ec4d81fe88142e | |
| parent | 226f0a1ed865a8aaed2c37f8629d35dbcaef86ee (diff) | |
| download | php-git-23706f18d6b34aa196f1f007c08c584b4f6f8493.tar.gz | |
Make this thing to compile with net-snmp-5.0.x
| -rw-r--r-- | ext/snmp/config.m4 | 39 | ||||
| -rw-r--r-- | ext/snmp/snmp.c | 24 |
2 files changed, 55 insertions, 8 deletions
diff --git a/ext/snmp/config.m4 b/ext/snmp/config.m4 index a0113e92fa..9c3b859c20 100644 --- a/ext/snmp/config.m4 +++ b/ext/snmp/config.m4 @@ -5,7 +5,34 @@ dnl PHP_ARG_WITH(snmp,for SNMP support, [ --with-snmp[=DIR] Include SNMP support.]) - if test "$PHP_SNMP" != "no"; then +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,[ ]) + 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 @@ -60,15 +87,15 @@ PHP_ARG_WITH(snmp,for SNMP support, fi AC_CHECK_LIB(kstat, kstat_read, [ PHP_ADD_LIBRARY(kstat,,SNMP_SHARED_LIBADD) ]) - - AC_DEFINE(HAVE_SNMP,1,[ ]) PHP_ADD_INCLUDE($SNMP_INCDIR) PHP_ADD_LIBRARY_WITH_PATH(snmp, $SNMP_LIBDIR, SNMP_SHARED_LIBADD) - - PHP_NEW_EXTENSION(snmp, snmp.c, $ext_shared) - PHP_SUBST(SNMP_SHARED_LIBADD) fi + PHP_NEW_EXTENSION(snmp, snmp.c, $ext_shared) + PHP_SUBST(SNMP_SHARED_LIBADD) + AC_DEFINE(HAVE_SNMP,1,[ ]) +fi + AC_MSG_CHECKING(whether to enable UCD SNMP hack) AC_ARG_ENABLE(ucd-snmp-hack, diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index 7408ccb322..5fcf191c10 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -26,6 +26,9 @@ #include "php.h" #include "ext/standard/info.h" #include "php_snmp.h" + +#if HAVE_SNMP + #include <sys/types.h> #ifdef PHP_WIN32 #include <winsock.h> @@ -60,7 +63,6 @@ #ifdef HAVE_UNISTD_H #include <unistd.h> #endif -#if HAVE_SNMP #ifndef __P #ifdef __GNUC__ @@ -70,6 +72,11 @@ #endif #endif +#ifdef HAVE_NET_SNMP +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#define VersionInfo NetSnmpVersionInfo +#else #ifdef HAVE_DEFAULT_STORE_H #include "default_store.h" #endif @@ -81,6 +88,7 @@ #include "parse.h" #include "mib.h" #include "version.h" +#endif /* 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 @@ -329,7 +337,11 @@ retry: } if (st != 11) { - sprint_value((struct sbuf *)buf,vars->name, vars->name_length, vars); +#ifdef HAVE_NET_SNMP + snprint_value(buf, strlen(buf), vars->name, vars->name_length, vars); +#else + sprint_value((struct sbuf *) buf,vars->name, vars->name_length, vars); +#endif } if (st == 1) { @@ -337,7 +349,11 @@ retry: } else if (st == 2) { add_next_index_string(return_value,buf,1); /* Add to returned array */ } else if (st == 3) { +#ifdef HAVE_NET_SNMP + snprint_objid(buf2, strlen(buf2), vars->name, vars->name_length); +#else sprint_objid((struct sbuf *)buf2, vars->name, vars->name_length); +#endif add_assoc_string(return_value,buf2,buf,1); } if (st >= 2 && st != 11) { @@ -356,7 +372,11 @@ retry: for (count=1, vars = response->variables; vars && count != response->errindex; vars = vars->next_variable, count++); if (vars) { +#ifdef HAVE_NET_SNMP + snprint_objid(buf, strlen(buf), vars->name, vars->name_length); +#else sprint_objid((struct sbuf *)buf,vars->name, vars->name_length); +#endif } php_error(E_WARNING,"This name does not exist: %s\n",buf); } |
