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)
- SNMP_LIBNAME=netsnmp
+ snmp_full_version=`$SNMP_CONFIG --version`
+ ac_IFS=$IFS
+ IFS="."
+ set $snmp_full_version
+ IFS=$ac_IFS
+ SNMP_VERSION=`expr [$]1 \* 1000 + [$]2`
+ if test "$SNMP_VERSION" -ge "5003"; then
+ if test -n "$SNMP_LIBS" && test -n "$SNMP_PREFIX"; then
+ PHP_ADD_INCLUDE(${SNMP_PREFIX}/include)
+ PHP_EVAL_LIBLINE($SNMP_LIBS, SNMP_SHARED_LIBADD)
+ SNMP_LIBNAME=netsnmp
+ else
+ AC_MSG_ERROR([Could not find the required paths. Please check your net-snmp installation.])
+ fi
else
- AC_MSG_ERROR([Could not find the required paths. Please check your net-snmp installation.])
+ AC_MSG_ERROR([Net-SNMP version 5.3 or greater reqired (detected $snmp_full_version).])
fi
else
AC_MSG_ERROR([Could not find net-snmp-config binary. Please check your net-snmp installation.])
fi
- dnl Check whether snmp_parse_oid() exists.
- PHP_CHECK_LIBRARY($SNMP_LIBNAME, snmp_parse_oid,
+ dnl Test build.
+ PHP_CHECK_LIBRARY($SNMP_LIBNAME, init_snmp,
[
- AC_DEFINE(HAVE_SNMP_PARSE_OID, 1, [ ])
- ], [], [
+ AC_DEFINE(HAVE_SNMP,1,[ ])
+ ], [
+ AC_MSG_ERROR([SNMP sanity check failed. Please check config.log for more information.])
+ ], [
$SNMP_SHARED_LIBADD
])
$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
- ])
-
dnl Check for buggy snmp_snprint_value() (net-snmp BUGid 2027834)
AC_CACHE_CHECK([for buggy snmp_snprint_value], ac_cv_buggy_snprint_value,[
save_CFLAGS="$CFLAGS"
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
-/* 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))
-
#if PHP_VERSION_ID < 50300
#define Z_ADDREF_P(pz) pz->refcount++
#define Z_ISREF_PP(oid) (PZVAL_IS_REF(*(oid)))
}
#endif
-/* 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
session->securityNameLen = strlen(session->securityName);
} else {
session->authenticator = NULL;
-#ifdef UCD_SNMP_HACK
- session->community = (u_char *)strdup(community); /* memory freed by SNMP library, strdup NOT estrdup */
-#else
session->community = (u_char *)community;
-#endif
session->community_len = strlen(community);
}
{
if (!strcasecmp(prot, "MD5")) {
s->securityAuthProto = usmHMACMD5AuthProtocol;
- s->securityAuthProtoLen = OIDSIZE(usmHMACMD5AuthProtocol);
+ s->securityAuthProtoLen = USM_AUTH_PROTO_MD5_LEN;
} else if (!strcasecmp(prot, "SHA")) {
s->securityAuthProto = usmHMACSHA1AuthProtocol;
- s->securityAuthProtoLen = OIDSIZE(usmHMACSHA1AuthProtocol);
+ s->securityAuthProtoLen = USM_AUTH_PROTO_SHA_LEN;
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown authentication protocol '%s'", prot);
return (-1);
{
if (!strcasecmp(prot, "DES")) {
s->securityPrivProto = usmDESPrivProtocol;
- s->securityPrivProtoLen = OIDSIZE(usmDESPrivProtocol);
+ s->securityPrivProtoLen = USM_PRIV_PROTO_DES_LEN;
#ifdef HAVE_AES
- } else if (!strcasecmp(prot, "AES128")
-#ifdef SNMP_VALIDATE_ERR
-/*
-* In Net-SNMP before 5.2, the following symbols exist:
-* usmAES128PrivProtocol, usmAES192PrivProtocol, usmAES256PrivProtocol
-* In an effort to be more standards-compliant, 5.2 removed the last two.
-* As of 5.2, the symbols are:
-* usmAESPrivProtocol, usmAES128PrivProtocol
-*
-* As we want this extension to compile on both versions, we use the latter
-* symbol on purpose, as it's defined to be the same as the former.
-*
-* However, in 5.2 the type of usmAES128PrivProtocol is a pointer, not an
-* array, so we cannot use the OIDSIZE macro because it uses sizeof().
-*
-*/
- || !strcasecmp(prot, "AES")) {
- s->securityPrivProto = usmAES128PrivProtocol;
- s->securityPrivProtoLen = USM_PRIV_PROTO_AES128_LEN;
-#else
- ) {
- s->securityPrivProto = usmAES128PrivProtocol;
- s->securityPrivProtoLen = OIDSIZE(usmAES128PrivProtocol);
- } else if (!strcasecmp(prot, "AES192")) {
- s->securityPrivProto = usmAES192PrivProtocol;
- s->securityPrivProtoLen = OIDSIZE(usmAES192PrivProtocol);
- } else if (!strcasecmp(prot, "AES256")) {
- s->securityPrivProto = usmAES256PrivProtocol;
- s->securityPrivProtoLen = OIDSIZE(usmAES256PrivProtocol);
-#endif
+ } else if (!strcasecmp(prot, "AES128") || !strcasecmp(prot, "AES")) {
+ s->securityPrivProto = usmAESPrivProtocol;
+ s->securityPrivProtoLen = USM_PRIV_PROTO_AES_LEN;
#endif
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown security protocol '%s'", prot);