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
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,
#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>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-#if HAVE_SNMP
#ifndef __P
#ifdef __GNUC__
#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
#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
}
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) {
} 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) {
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);
}