]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
configure: check more SNMP stuff.
authorVincent Bernat <bernat@luffy.cx>
Sat, 31 Dec 2011 09:52:03 +0000 (10:52 +0100)
committerVincent Bernat <bernat@luffy.cx>
Sat, 31 Dec 2011 10:19:04 +0000 (11:19 +0100)
First, we check that netsnmp_enable_subagent() exists. Otherwise, this
means that Net-SNMP has been compiled without this feature.

Second, we check if <net-snmp/agent/util_funcs.h> 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
m4/snmp.m4
src/agent.c

index 991bf785b8ff43cf4821cc8d26ecfaaea08e3a73..5539adf84a343f259582ea179fa4043f588ebac8 100644 (file)
--- 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:
index 369233a3eb551111b31b7f32172eb882c1169cfb..c1cf0749582941aaab4a841dc9222fcfd2d56495 100644 (file)
@@ -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 <net-snmp/net-snmp-config.h>
 @%:@include <net-snmp/net-snmp-includes.h>
 @%:@include <net-snmp/library/snmp_transport.h>
 ])
+   # Do we have a usable <net-snmp/agent/util_funcs.h> header?
+   AC_CHECK_HEADERS([net-snmp/agent/util_funcs.h],,,[
+@%:@include <net-snmp/net-snmp-config.h>
+@%:@include <net-snmp/net-snmp-includes.h>
+@%:@include <net-snmp/library/snmp_transport.h>
+@%:@include <net-snmp/agent/net-snmp-agent-includes.h>
+@%:@include <net-snmp/agent/snmp_vars.h>
+   ])
 
    CFLAGS="$_save_flags"
+   LDFLAGS="$_save_ldflags"
 ])
index 66c177424a014508d108c3170cf8d8d5e5d3a218..b26de384421ec816d4929a63504b1cb54e4a8d69 100644 (file)
 #include <net-snmp/net-snmp-includes.h>
 #include <net-snmp/agent/net-snmp-agent-includes.h>
 #include <net-snmp/agent/snmp_vars.h>
+#if HAVE_NET_SNMP_AGENT_UTIL_FUNCS_H
 #include <net-snmp/agent/util_funcs.h>
+#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};