From ab2d1c1f1ffa85ee6bee0a16ec2fbcb83b4740ba Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sat, 31 Dec 2011 10:52:03 +0100 Subject: [PATCH] configure: check more SNMP stuff. First, we check that netsnmp_enable_subagent() exists. Otherwise, this means that Net-SNMP has been compiled without this feature. Second, we check if header is usable. There was incomplete installation of files required by this header with NetSNMP 5.4 and situation got worse with NetSNMP 5.7. If the header is not usable, we fallback to define the two functions that we need. --- CHANGELOG | 2 ++ m4/snmp.m4 | 22 +++++++++++++++++++--- src/agent.c | 9 +++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 991bf785..5539adf8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,8 @@ lldpd (0.5.6) * Features: + Send and receive native VLAN TLV with CDP + Add a whitelist for some drivers (currently: dsa and veth) + * Fixes: + + Compilation issues with NetSNMP 5.7 (and with earlier versions too) lldpd (0.5.5) * Features: diff --git a/m4/snmp.m4 b/m4/snmp.m4 index 369233a3..c1cf0749 100644 --- a/m4/snmp.m4 +++ b/m4/snmp.m4 @@ -1,8 +1,6 @@ # # lldp_CHECK_SNMP # - - AC_DEFUN([lldp_CHECK_SNMP], [ AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], [no]) if test x"$NETSNMP_CONFIG" = x"no"; then @@ -12,8 +10,10 @@ AC_DEFUN([lldp_CHECK_SNMP], [ NETSNMP_CFLAGS="`${NETSNMP_CONFIG} --base-cflags` -DNETSNMP_NO_INLINE" _save_flags="$CFLAGS" + _save_ldflags="$LDFLAGS" CFLAGS="$CFLAGS ${NETSNMP_CFLAGS}" - AC_MSG_CHECKING([whether C compiler supports flag "${NETSNMP_CFLAGS}" from Net-SNMP]) + LDFLAGS="$LDFLAGS ${NETSNMP_LIBS}" + AC_MSG_CHECKING([whether C compiler supports flag "${NETSNMP_CFLAGS} ${NETSNMP_LIBS}" from Net-SNMP]) AC_LINK_IFELSE([AC_LANG_PROGRAM([ int main(void); ], @@ -24,17 +24,33 @@ int main(void); ])],[AC_MSG_RESULT(yes)],[ AC_MSG_RESULT(no) AC_MSG_ERROR([*** incorrect CFLAGS from net-snmp-config])]) + # Is Net-SNMP usable? AC_CHECK_LIB([netsnmp], [snmp_register_callback], [:], [AC_MSG_ERROR([*** unable to use net-snmp])], ${NETSNMP_LIBS}) + # Do we have subagent support? + AC_CHECK_FUNCS([netsnmp_enable_subagent], [:], + [AC_MSG_ERROR([*** no subagent support in net-snmp])]) + AC_SUBST([NETSNMP_LIBS]) AC_SUBST([NETSNMP_CFLAGS]) AC_DEFINE_UNQUOTED([USE_SNMP], 1, [Define to indicate to enable SNMP support]) + + # Should we use f_create_from_tstring_new or f_create_from_tstring? AC_CHECK_MEMBERS([netsnmp_tdomain.f_create_from_tstring_new],,, [ @%:@include @%:@include @%:@include ]) + # Do we have a usable header? + AC_CHECK_HEADERS([net-snmp/agent/util_funcs.h],,,[ +@%:@include +@%:@include +@%:@include +@%:@include +@%:@include + ]) CFLAGS="$_save_flags" + LDFLAGS="$_save_ldflags" ]) diff --git a/src/agent.c b/src/agent.c index 66c17742..b26de384 100644 --- a/src/agent.c +++ b/src/agent.c @@ -21,7 +21,16 @@ #include #include #include +#if HAVE_NET_SNMP_AGENT_UTIL_FUNCS_H #include +#else +/* The above header may be buggy. We just need those two functions. */ +int header_simple_table(struct variable *, oid *, size_t *, + int, size_t *, + WriteMethod ** write_method, int); +int header_generic(struct variable *, oid *, size_t *, int, + size_t *, WriteMethod **); +#endif static oid lldp_oid[] = {1, 0, 8802, 1, 1, 2}; -- 2.39.5