Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions drivers/snmp-ups.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,27 @@
#include "hpe-pdu-mib.h"

/* Address API change */
#ifndef usmAESPrivProtocol
#if ( ! NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol ) && ( ! defined usmAESPrivProtocol )
#define usmAESPrivProtocol usmAES128PrivProtocol
#endif

#ifdef USM_PRIV_PROTO_AES_LEN
# define NUT_securityPrivProtoLen USM_PRIV_PROTO_AES_LEN
#else
# ifdef USM_PRIV_PROTO_AES128_LEN
# define NUT_securityPrivProtoLen USM_PRIV_PROTO_AES128_LEN
# else
/* FIXME: Find another way to get the size of array(?) to avoid:
* error: division 'sizeof (oid * {aka long unsigned int *}) / sizeof (oid {aka long unsigned int})' does not compute the number of array elements [-Werror=sizeof-pointer-div]
* See also https://bugs.php.net/bug.php?id=37564 for context
* which is due to most values in /usr/include/net-snmp/librarytransform_oids.h
* being defined as "oid[10]" or similar arrays, and "backwards compatibility"
* usmAESPrivProtocol name is an "oid *" pointer.
*/
# define NUT_securityPrivProtoLen (sizeof(usmAESPrivProtocol)/sizeof(oid))
# endif
#endif

static mib2nut_info_t *mib2nut[] = {
&apc,
&mge,
Expand Down Expand Up @@ -593,7 +610,7 @@ void nut_snmp_init(const char *type, const char *hostname)
}
else if (strcmp(privProtocol, "AES") == 0) {
g_snmp_sess.securityPrivProto = usmAESPrivProtocol;
g_snmp_sess.securityPrivProtoLen = sizeof(usmAESPrivProtocol)/sizeof(oid);
g_snmp_sess.securityPrivProtoLen = NUT_securityPrivProtoLen;
}
else
fatalx(EXIT_FAILURE, "Bad SNMPv3 authProtocol: %s", authProtocol);
Expand Down
16 changes: 16 additions & 0 deletions m4/nut_check_libnetsnmp.m4
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ if test -z "${nut_have_libnetsnmp_seen}"; then
if test "${nut_have_libnetsnmp}" = "yes"; then
LIBNETSNMP_CFLAGS="${CFLAGS}"
LIBNETSNMP_LIBS="${LIBS}"

AC_MSG_CHECKING([for defined usmAESPrivProtocol])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
oid * pProto = usmAESPrivProtocol;
],
[]
)],
[AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol, 1, [Variable or macro by this name is resolvable])
],
[AC_MSG_RESULT([no])
AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol, 0, [Variable or macro by this name is not resolvable])
])

fi

dnl restore original CFLAGS and LIBS
Expand Down