]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Rework autoconf stuff.
authorVincent Bernat <bernat@luffy.cx>
Tue, 29 Sep 2009 14:44:59 +0000 (16:44 +0200)
committerVincent Bernat <bernat@luffy.cx>
Tue, 29 Sep 2009 14:54:59 +0000 (16:54 +0200)
Update to autoconf 2.64.

Use custom macro for ethtool, netsnmp and argument handling to shorten
main configure.ac file.

Use less verbose build process by default.

For headers, missing header is fatal for now because we don't know how
to replace them. Better handling will be done later. We only target
Linux for now with GNU LibC: portability issues are narrow.

Display results at the end of configure process.

AC_C_CONST is obsolete

See:
 http://www.nabble.com/fix-AC_C_CONST-to-work-with-CFLAGS--O2--Wall--Werror-td17164627.html
 http://www.gnu.org/software/autoconf/manual/autoconf.html#index-AC_005fC_005fCONST-790

Some useful documentation about autoconf:
 http://sources.redhat.com/autobook/ (a bit outdated)
 http://www.freesoftwaremagazine.com/books/autotools_a_guide_to_autoconf_automake_libtool
 http://www.flameeyes.eu/autotools-mythbuster/

configure.ac
m4/args.m4 [new file with mode: 0644]
m4/ethtool.m4 [new file with mode: 0644]
m4/snmp.m4 [new file with mode: 0644]
src/Makefile.am
src/compat.h
src/lldpd.h
src/malloc.c [new file with mode: 0644]
src/priv.c
src/realloc.c [new file with mode: 0644]
tests/Makefile.am

index 217fb9c3003a854f759803662edc803a4851ee31..99ca1401af2cd59ca3cebb8a89ded8a1d56a1102 100644 (file)
 #                                               -*- Autoconf -*-
 # Process this file with autoconf to produce a configure script.
 
-AC_PREREQ(2.61)
-AC_INIT(lldpd, 0.5.0, bernat@luffy.cx)
-AM_INIT_AUTOMAKE([foreign])
+#######################
+### Base configuration
+
+# Configure autoconf
+AC_PREREQ([2.64])
+AC_INIT([lldpd], [0.5.0], [bernat@luffy.cx])
 AC_CONFIG_SRCDIR([src/lldpd.c])
 AC_CONFIG_HEADER([config.h])
 AC_CONFIG_FILES([Makefile src/Makefile man/Makefile tests/Makefile])
 AC_CONFIG_MACRO_DIR([m4])
 
+# Configure automake
+AM_INIT_AUTOMAKE([foreign -Wall -Werror])
+AM_SILENT_RULES([yes])
+
+# Configure libtool
+LT_PREREQ([2.2])
+LT_INIT
+
+#######################
+### Checks
+
 # Checks for programs.
+AC_PROG_AWK
 AC_PROG_CC
-AC_PROG_LIBTOOL
+AC_PROG_CPP
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+AC_PROG_CXX
+AC_PROG_RANLIB
+AM_PROG_CC_C_O
 
-# Unit tests
-PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], have_check=yes, have_check=no)
-AM_CONDITIONAL(HAVE_CHECK, test x$have_check = xyes)
+# Checks for header files.
+AC_HEADER_RESOLV
+AC_CHECK_HEADERS([ \
+  arpa/inet.h \
+  fcntl.h \
+  malloc.h \
+  netdb.h \
+  netinet/in.h \
+  stdlib.h \
+  string.h \
+  sys/ioctl.h \
+  sys/param.h \
+  sys/socket.h \
+  sys/time.h \
+  sys/queue.h \
+  syslog.h \
+  unistd.h \
+  linux/sockios.h \
+  linux/filter.h \
+  net/if.h \
+],,AC_MSG_ERROR([Required header missing.]))
+AC_CHECK_HEADERS([ \
+  linux/wireless.h \
+  linux/if_bonding.h \
+  linux/if_vlan.h \
+  linux/if_bridge.h \
+  linux/if_packet.h \
+],,AC_MSG_ERROR([Required header missing.]),[
+@%:@include <arpa/inet.h>
+@%:@include <linux/if.h>
+])
 
-# Checks for libraries.
-AC_ARG_WITH(snmp,
-  AC_HELP_STRING(
-    [--with-snmp],
-    [Enable the use of SNMP]
-  ),
-  [],
-  [with_snmp=no]
-)
-AM_CONDITIONAL([USE_SNMP], [test "${with_snmp}" != "no"])
-
-AC_ARG_WITH(privsep-user,
-       AC_HELP_STRING([--with-privsep-user],
-                      [Which user to use for privilege separation]),
-       AC_DEFINE_UNQUOTED([PRIVSEP_USER], "$withval", [User for privilege separation]),
-       AC_DEFINE_UNQUOTED([PRIVSEP_USER], "_lldpd", [User for privilege separation]))
-AC_ARG_WITH(privsep-group,
-       AC_HELP_STRING([--with-privsep-group],
-                      [Which group to use for privilege separation]),
-       AC_DEFINE_UNQUOTED([PRIVSEP_GROUP], "$withval", [Group for privilege separation]),
-       AC_DEFINE_UNQUOTED([PRIVSEP_GROUP], "_lldpd", [Group for privilege separation]))
-AC_ARG_WITH(privsep-chroot,
-       AC_HELP_STRING([--with-privsep-chroot],
-                      [Which directory to use to chroot lldpd]),
-       AC_DEFINE_UNQUOTED([PRIVSEP_CHROOT], "$withval", [Chroot directory]),
-       AC_DEFINE_UNQUOTED([PRIVSEP_CHROOT], "/var/run/lldpd", [Chroot directory]))
 
-# Checks for header files.
-AC_CHECK_DECLS([TAILQ_FIRST, TAILQ_NEXT, TAILQ_FOREACH, TAILQ_EMPTY],[],[],[[#include <sys/queue.h>]])
-AC_CHECK_DECLS([SLIST_HEAD, SLIST_ENTRY, SLIST_INIT, SLIST_INSERT_HEAD],[],[],[[#include <sys/queue.h>]])
-AC_CHECK_DECLS([SLIST_FIRST, SLIST_NEXT, SLIST_REMOVE_HEAD, SLIST_EMPTY],[],[],[[#include <sys/queue.h>]])
-AC_CHECK_DECLS([PACKET_ORIGDEV],[],[],[[#include <linux/if_packet.h>]])
-AC_CHECK_DECLS([ADVERTISED_2500baseX_Full, ADVERTISED_Pause, ADVERTISED_Asym_Pause, ADVERTISED_10000baseT_Full, SPEED_10000],
-                                          [],[],[[#include <linux/ethtool.h>]])
-AC_CHECK_DECLS([ETHERTYPE_VLAN],[],[],[[#include <net/ethernet.h>]])
+# Check for sys/queue.h completeness, missing bits will be in compat.h
+AC_CHECK_DECLS([ \
+TAILQ_FIRST, \
+TAILQ_NEXT, \
+TAILQ_FOREACH, \
+TAILQ_EMPTY, \
+SLIST_HEAD, \
+SLIST_ENTRY, \
+SLIST_INIT, \
+SLIST_INSERT_HEAD, \
+SLIST_FIRST, \
+SLIST_NEXT, \
+SLIST_REMOVE_HEAD, \
+SLIST_EMPTY \
+],[],[],[[@%:@include <sys/queue.h>]])
+
+# Do we have PACKET_ORIGDEV (it can be present at runtime, put it in compat.h)
+AC_CHECK_DECLS([PACKET_ORIGDEV],[],[],[[@%:@include <linux/if_packet.h>]])
+
+# Check for ethtool stuff
+lldp_CHECK_HEADER_ETHTOOL
+AC_CHECK_DECLS([ \
+ADVERTISED_2500baseX_Full, \
+ADVERTISED_Pause, \
+ADVERTISED_Asym_Pause, \
+ADVERTISED_10000baseT_Full, \
+SPEED_10000 \
+],[],[],[[@%:@include <linux/ethtool.h>]])
+
+# Check for ETHERTYPE_VLAN, put it in compat.h if not defined
+AC_CHECK_DECLS([ETHERTYPE_VLAN],[],[],[[@%:@include <net/ethernet.h>]])
+
+# Check some stuff in linux/if_vlan.h
+AC_CHECK_DECLS([ \
+GET_VLAN_REALDEV_NAME_CMD, \
+GET_VLAN_VID_CMD \
+],[],[],[[@%:@include <linux/if_vlan.h>]])
 
 # Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_CHECK_TYPES([int16_t, u_int16_t, int8_t, u_int8_t, int32_t, u_int32_t],[],[AC_MSG_ERROR([mandatory type not found])])
-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>
-])
+AC_TYPE_UID_T
+AC_C_INLINE
+AC_TYPE_INT16_T
+AC_TYPE_INT32_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_TYPE_SSIZE_T
+AC_TYPE_UINT16_T
+AC_TYPE_UINT32_T
+AC_TYPE_UINT8_T
 
 # Checks for library functions.
+AC_FUNC_CHOWN
+AC_FUNC_FORK
+AC_FUNC_MALLOC
+AC_FUNC_REALLOC
+AC_CHECK_FUNCS([ \
+   atexit \
+   gethostbyname \
+   inet_ntoa memset \
+   regcomp \
+   select \
+   setenv \
+   socket \
+   strchr \
+   strdup \
+   strerror \
+   strndup \
+   tzset \
+   uname \
+],,[AC_MSG_ERROR(Required function not found.)])
+
 AC_REPLACE_FUNCS([strlcpy])
 AC_REPLACE_FUNCS([getifaddrs])
 
-AC_PROG_GCC_TRADITIONAL
+## Unit tests wich check
+PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no])
 
-## NetSNMP
-NETSNMP_CONFIG=No
-if test "${with_snmp}" != "no"; then   
-      AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No)
-fi
-if test x"${NETSNMP_CONFIG}" != xNo; then
-   NETSNMP_libs=`${NETSNMP_CONFIG} --agent-libs`
-   
-   AC_CHECK_LIB([netsnmp], [snmp_register_callback],
-       AC_DEFINE_UNQUOTED([HAVE_NETSNMP], 1, [Define to indicate the Net-SNMP library])
-       AC_DEFINE_UNQUOTED([USE_SNMP], 1, [Define to indicate to enable SNMP support]),
-       [], ${NETSNMP_libs})
-
-   if test "${ac_cv_lib_netsnmp_snmp_register_callback}" = "yes"; then
-      AC_SUBST([NETSNMP_LIB],"${NETSNMP_libs}")
-   fi
-fi
-if test "${with_snmp}" != "no"; then
-   if test "${ac_cv_lib_netsnmp_snmp_register_callback}" != "yes"; then
-         AC_MSG_NOTICE([***])
-         AC_MSG_NOTICE([*** net-snmp libraries not found])
-         AC_MSG_NOTICE([*** Either correct the installation, or run configure])
-         AC_MSG_NOTICE([*** including --without-snmp])
-        exit 1
-   fi
-fi
+#######################
+### Options
 
-# Options
-# CDP
-AC_ARG_ENABLE(cdp, AC_HELP_STRING([--enable-cdp],
-                  [Enable Cisco Discovery Protocol]),
-             [enable_cdp=$enableval],[enable_cdp=yes])
-AC_MSG_CHECKING(whether to enable CDP)
-if test x$enable_cdp = xyes; then
-       AC_MSG_RESULT(yes)
-       AC_DEFINE([ENABLE_CDP],, [Enable Cisco Discovery Protocol])
-else
-       AC_MSG_RESULT(no)
-fi
-
-# FDP
-AC_ARG_ENABLE(fdp, AC_HELP_STRING([--enable-fdp],
-                  [Enable Foundry Discovery Protocol]),
-             [enable_fdp=$enableval],[enable_fdp=yes])
-AC_MSG_CHECKING(whether to enable FDP)
-if test x$enable_fdp = xyes; then
-       AC_MSG_RESULT(yes)
-       AC_DEFINE([ENABLE_FDP],, [Enable Foundry Discovery Protocol])
-else
-       AC_MSG_RESULT(no)
-fi
-
-# EDP
-AC_ARG_ENABLE(edp, AC_HELP_STRING([--enable-edp],
-                  [Enable Extreme Discovery Protocol]),
-             [enable_edp=$enableval],[enable_edp=yes])
-AC_MSG_CHECKING(whether to enable EDP)
-if test x$enable_edp = xyes; then
-       AC_MSG_RESULT(yes)
-       AC_DEFINE([ENABLE_EDP],, [Enable Extreme Discovery Protocol])
-else
-       AC_MSG_RESULT(no)
-fi
-
-# SONMP
-AC_ARG_ENABLE(sonmp, AC_HELP_STRING([--enable-sonmp],
-                  [Enable SynOptics Network Management Protocol]),
-             [enable_sonmp=$enableval],[enable_sonmp=yes])
-AC_MSG_CHECKING(whether to enable SONMP)
-if test x$enable_sonmp = xyes; then
-       AC_MSG_RESULT(yes)
-       AC_DEFINE([ENABLE_SONMP],, [Enable SynOptics Network Management Protocol])
-else
-       AC_MSG_RESULT(no)
+# SNMP
+AC_ARG_WITH([snmp],
+  AS_HELP_STRING(
+    [--with-snmp],
+    [Enable the use of SNMP @<:@default=no@:>@]
+  ))
+if test x"$with_snmp" = x"yes"; then
+   lldp_CHECK_SNMP
 fi
 
-#LLDPMED
-AC_ARG_ENABLE(lldpmed, AC_HELP_STRING([--enable-lldpmed],
-                  [Enable LLDP-MED extension]),
-             [enable_lldpmed=$enableval],[enable_lldpmed=yes])
-AC_MSG_CHECKING(whether to enable LLDP-MED)
-if test x$enable_lldpmed = xyes; then
-       AC_MSG_RESULT(yes)
-       AC_DEFINE([ENABLE_LLDPMED],, [Enable LLDP-MED extension])
-else
-       AC_MSG_RESULT(no)
-fi
+# Privsep settings
+lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd])
+lldp_ARG_WITH([privsep-group], [Which group to use for privilege separation], [_lldpd])
+lldp_ARG_WITH([privsep-chroot], [Which directory to use to chroot lldpd], [/var/run/lldpd])
 
-#Dot1
-AC_ARG_ENABLE(dot1, AC_HELP_STRING([--enable-dot1],
-                  [Enable LLDP Dot1 extension]),
-             [enable_dot1=$enableval],[enable_dot1=yes])
-AC_MSG_CHECKING(whether to enable Dot1)
-if test x$enable_dot1 = xyes; then
-       AC_MSG_RESULT(yes)
-       AC_DEFINE([ENABLE_DOT1],, [Enable LLDP Dot1 extension])
-else
-       AC_MSG_RESULT(no)
-fi
+# CDP/FDP/EDP/SONMP
+lldp_ARG_ENABLE([cdp], [Cisco Discovery Protocol], [yes])
+lldp_ARG_ENABLE([fdp], [Foundry Discovery Protocol], [yes])
+lldp_ARG_ENABLE([edp], [Extreme Discovery Protocol], [yes])
+lldp_ARG_ENABLE([sonmp], [SynOptics Network Management Protocol], [yes])
 
-#Dot3
-AC_ARG_ENABLE(dot3, AC_HELP_STRING([--enable-dot3],
-                  [Enable LLDP Dot3 extension]),
-             [enable_dot3=$enableval],[enable_dot3=yes])
-AC_MSG_CHECKING(whether to enable Dot3)
-if test x$enable_dot3 = xyes; then
-       AC_MSG_RESULT(yes)
-       AC_DEFINE([ENABLE_DOT3],, [Enable LLDP Dot3 extension])
-else
-       AC_MSG_RESULT(no)
-fi
+# LLDPMED/Dot1/Dot3
+lldp_ARG_ENABLE([lldpmed], [LLDP-MED extension], [yes])
+lldp_ARG_ENABLE([dot1], [Dot1 extension (VLAN stuff)], [yes])
+lldp_ARG_ENABLE([dot3], [Dot3 extension (PHY stuff)], [yes])
 
 #Listen on vlan
-AC_ARG_ENABLE(listenvlan, AC_HELP_STRING([--enable-listenvlan],
-                  [Allow to listen on VLAN]),
-             [enable_listenvlan=$enableval],[enable_listenvlan=no])
-AC_MSG_CHECKING(whether to allow to listen on VLAN)
-if test x$enable_listenvlan = xyes; then
-       AC_MSG_RESULT(yes)
-       AC_DEFINE([ENABLE_LISTENVLAN],, [Allow to listen on VLAN])
-else
-       AC_MSG_RESULT(no)
-fi
+lldp_ARG_ENABLE([listenvlan], [listen on any VLAN], [no])
 
+#######################
+# Output results
+AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = x"yes"])
+AM_CONDITIONAL([USE_SNMP], [test x"$with_snmp" = x"yes"])
 AC_OUTPUT
+
+cat <<EOF
+
+------------------ Summary ------------------
+ $PACKAGE_NAME version $PACKAGE_VERSION
+  Prefix.........: $prefix
+  C Compiler.....: $CC $CFLAGS $CPPFLAGS
+  Linker.........: $LD $LDFLAGS $LIBS
+ Optional features:
+  SNMP support...: ${with_snmp-no}
+  CDP............: $enable_cdp
+  FDP............: $enable_fdp
+  EDP............: $enable_edp
+  SONMP..........: $enable_sonmp
+  LLDPMED........: $enable_lldpmed
+  DOT1...........: $enable_dot1
+  DOT3...........: $enable_dot3
+  Listen on VLAN.: $enable_listenvlan
+---------------------------------------------
+
+Check the above options and compile with:
+ ${MAKE-make}
+
+EOF
diff --git a/m4/args.m4 b/m4/args.m4
new file mode 100644 (file)
index 0000000..9c9dc19
--- /dev/null
@@ -0,0 +1,29 @@
+#
+# lldp_ARG_WITH
+#
+
+dnl lldp_ARG_WITH(name, help1, default)
+
+AC_DEFUN([lldp_ARG_WITH],[
+  AC_ARG_WITH([$1],
+       AS_HELP_STRING([--with-$1],
+               [$2 @<:@default=$3@:>@]),
+       AC_DEFINE_UNQUOTED(AS_TR_CPP([$1]), ["$withval"], [$2]),
+       AC_DEFINE_UNQUOTED(AS_TR_CPP([$1]), ["$3"], [$2]))
+])
+
+dnl lldp_ARG_ENABLE(name, help1, default)
+
+AC_DEFUN([lldp_ARG_ENABLE],[
+  AC_ARG_ENABLE([$1],
+       AS_HELP_STRING([--enable-$1],
+               [Enable $2 @<:@default=$3@:>@]),
+       [enable_$1=$enableval], [enable_$1=$3])
+  AC_MSG_CHECKING(whether to enable $2)
+  if test x"$enable_$1" = x"yes"; then
+     AC_MSG_RESULT(yes)
+     AC_DEFINE([ENABLE_]AS_TR_CPP([$1]),, [$2])
+  else
+     AC_MSG_RESULT(no)
+  fi
+])
diff --git a/m4/ethtool.m4 b/m4/ethtool.m4
new file mode 100644 (file)
index 0000000..f3efa9d
--- /dev/null
@@ -0,0 +1,48 @@
+#
+# lldp_CHECK_HEADER_ETHTOOL
+#
+AC_DEFUN([lldp_CHECK_HEADER_ETHTOOL], [
+        AC_CACHE_CHECK([for linux/ethtool.h], mac_cv_header_ethtool_h, [
+                AC_COMPILE_IFELSE([
+                        AC_LANG_SOURCE([
+AC_INCLUDES_DEFAULT
+@%:@include <linux/ethtool.h>
+                        ])
+                ], [mac_cv_header_ethtool_h=yes], [mac_cv_header_ethtool_h=no]
+                )
+                if test "$mac_cv_header_ethtool_h" = no; then
+                        AC_COMPILE_IFELSE([
+                                AC_LANG_SOURCE([
+AC_INCLUDES_DEFAULT
+@%:@define u8  uint8_t
+@%:@define s8  int8_t
+@%:@define u16 uint16_t
+@%:@define s16 int16_t
+@%:@define u32 uint32_t
+@%:@define s32 int32_t
+@%:@define u64 uint64_t
+@%:@define s64 int64_t
+@%:@include <linux/ethtool.h>
+                                ])
+                        ],
+                        [mac_cv_header_ethtool_h="yes (with type munging)"],
+                        [mac_cv_header_ethtool_h=no]
+                        )
+                ])
+        fi
+        if test "$mac_cv_header_ethtool_h" = "yes (with type munging)"; then
+                AC_DEFINE(u8,  uint8_t,  [Define to the type u8 should expand to.])
+                AC_DEFINE(s8,  int8_t,   [Define to the type u8 should expand to.])
+                AC_DEFINE(u16, uint16_t, [Define to the type u16 should expand to.])
+                AC_DEFINE(s16, int16_t,  [Define to the type u16 should expand to.])
+                AC_DEFINE(u32, uint32_t, [Define to the type u32 should expand to.])
+                AC_DEFINE(s32, int32_t,  [Define to the type u32 should expand to.])
+                AC_DEFINE(u64, uint64_t, [Define to the type u64 should expand to.])
+                AC_DEFINE(s64, int64_t,  [Define to the type u64 should expand to.])
+        fi
+        if test "$mac_cv_header_ethtool_h" = no; then
+                :
+        else
+                AC_DEFINE(HAVE_ETHTOOL_H, 1, [Define to 1 if you have the <linux/ethtool.h> header file.])
+        fi
+])
diff --git a/m4/snmp.m4 b/m4/snmp.m4
new file mode 100644 (file)
index 0000000..f3295bc
--- /dev/null
@@ -0,0 +1,40 @@
+#
+# 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
+      AC_MSG_ERROR([*** unable to find net-snmp-config])
+   fi
+   NETSNMP_LIBS=`${NETSNMP_CONFIG} --agent-libs`
+   NETSNMP_CFLAGS=`${NETSNMP_CONFIG} --base-cflags`
+
+   _save_flags="$CFLAGS"
+   CFLAGS="$CFLAGS ${NETSNMP_CFLAGS}"
+   AC_MSG_CHECKING([whether C compiler supports flag "${NETSNMP_CFLAGS}" from Net-SNMP])
+   AC_LINK_IFELSE([AC_LANG_PROGRAM([
+int main(void);
+],
+[
+{
+  return 0;
+}
+])],[AC_MSG_RESULT(yes)],[
+AC_MSG_RESULT(no)
+AC_MSG_ERROR([*** incorrect CFLAGS from net-snmp-config])])
+   AC_CHECK_LIB([netsnmp], [snmp_register_callback], [],
+       [AC_MSG_ERROR([*** unable to use net-snmp])], ${NETSNMP_LIBS})
+   AC_SUBST([NETSNMP_LIBS])
+   AC_SUBST([NETSNMP_CFLAGS])
+   AC_DEFINE_UNQUOTED([USE_SNMP], 1, [Define to indicate to enable SNMP support])
+   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>
+])
+
+   CFLAGS="$_save_flags"
+])
index ac988ee296b26d76f140f72f25dbe7e00f868913..65d7b6a44b6113a5a6bba30c656d83cbc119b4cc 100644 (file)
@@ -21,5 +21,6 @@ lldpctl_LDADD = libcommon.la
 ## With SNMP...
 if USE_SNMP
 liblldpd_la_SOURCES += agent.c agent_priv.c
-lldpd_LDADD += @NETSNMP_LIB@
+liblldpd_la_CFLAGS = @NETSNMP_CFLAGS@
+lldpd_LDADD += @NETSNMP_LIBS@
 endif
index 4458a4ae0ce7cf66a2f903e41912ba7474fc7b27..3f5823de97698f423a25effb0a5c5b43a4989d46 100644 (file)
@@ -121,6 +121,16 @@ struct {                                                           \
 #define ETHERTYPE_VLAN 0x8100
 #endif
 
+#if !HAVE_DECL_GET_VLAN_REALDEV_NAME_CMD
+#include <linux/if_vlan.h>
+#define GET_VLAN_REALDEV_NAME_CMD (SET_VLAN_FLAG_CMD + 1)
+#endif
+
+#if !HAVE_DECL_GET_VLAN_VID_CMD
+#include <linux/if_vlan.h>
+#define GET_VLAN_VID_CMD (GET_VLAN_REALDEV_NAME_CMD + 1)
+#endif
+
 #if !HAVE_GETIFADDRS
 struct ifaddrs {
        struct ifaddrs  *ifa_next;    /* Next item in list */
@@ -154,3 +164,11 @@ void freeifaddrs(struct ifaddrs *ifa);
 #if !HAVE_STRLCPY
 size_t strlcpy(char *, const char *, size_t);
 #endif
+
+#if !HAVE_MALLOC
+void *malloc(size_t size);
+#endif
+
+#if !HAVE_REALLOC
+void *realloc(void *ptr, size_t size);
+#endif
index f0af03412a04dc3bd5a2df2ecbaeaa0e088f5b90..7ec53642c3f978839d4e9cc9215347a36ff685f2 100644 (file)
 #define _LLDPD_H
 
 #if HAVE_CONFIG_H
- #include <config.h>
+#  include <config.h>
 #endif
 
 #define _GNU_SOURCE 1
 #include <stdlib.h>
 #include <string.h>
 #include <sys/queue.h>
+#ifdef HAVE_SYS_TYPES_H
+#  include <sys/types.h>
+#endif
 #ifndef INCLUDE_LINUX_IF_H
-#include <net/if.h>
+#  include <net/if.h>
 #else
-#include <arpa/inet.h>
-#include <sys/types.h>
-#include <linux/if.h>
+#  include <arpa/inet.h>
+#  include <linux/if.h>
 #endif
 #if HAVE_GETIFADDRS
-#include <ifaddrs.h>
+#  include <ifaddrs.h>
 #endif
 #include <net/ethernet.h>
 #include <netinet/in.h>
 #include "compat.h"
 #include "lldp.h"
 #if defined (ENABLE_CDP) || defined (ENABLE_FDP)
-#include "cdp.h"
+#  include "cdp.h"
 #endif
 #ifdef ENABLE_SONMP
-#include "sonmp.h"
+#  include "sonmp.h"
 #endif
 #ifdef ENABLE_EDP
-#include "edp.h"
+#  include "edp.h"
 #endif
 
 #define SYSFS_CLASS_NET "/sys/class/net/"
diff --git a/src/malloc.c b/src/malloc.c
new file mode 100644 (file)
index 0000000..8ff490a
--- /dev/null
@@ -0,0 +1,14 @@
+/* malloc replacement that can allocate 0 byte */
+
+#undef malloc
+#include <stdlib.h>
+#include <sys/types.h>
+
+/* Allocate an N-byte block of memory from the heap.
+   If N is zero, allocate a 1-byte block.  */
+void *
+rpl_malloc(size_t n)
+{
+       if (n == 0) n = 1;
+       return malloc (n);
+}
index 3ab45d5dcf613423fa338a1b2021865d9ac69dff..1129e3756ca51a96672c45ebd28a45c828cf9e17 100644 (file)
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
-#include <sys/types.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
-#include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <regex.h>
 #include <netdb.h>
 #include <linux/sockios.h>
 #include <linux/if_packet.h>
-#include <netinet/in.h>
-#include <arpa/nameser.h>
+
+/* Use resolv.h */
+#ifdef HAVE_SYS_TYPES_H
+#  include <sys/types.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#  include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_NAMESER_H
+#  include <arpa/nameser.h> /* DNS HEADER struct */
+#endif
+#ifdef HAVE_NETDB_H
+#  include <netdb.h>
+#endif
 #include <resolv.h>
 
 enum {
diff --git a/src/realloc.c b/src/realloc.c
new file mode 100644 (file)
index 0000000..8a89d4b
--- /dev/null
@@ -0,0 +1,15 @@
+/* realloc replacement that can reallocate 0 byte or NULL pointers*/
+
+#undef realloc
+#include <stdlib.h>
+#include <sys/types.h>
+
+/* Reallocate an N-byte block of memory from the heap.
+   If N is zero, allocate a 1-byte block.  */
+void *
+rpl_realloc(void *ptr, size_t n)
+{
+       if (!ptr) return malloc(n);
+       if (n == 0) n = 1;
+       return realloc(ptr, n);
+}
index 683dfe95e611f627f72c46a5b253e4a983a782c2..6feece40a39ccf0e027bb20fc4607754b8b853f7 100644 (file)
@@ -40,12 +40,12 @@ check_ifaddrs_CFLAGS = @CHECK_CFLAGS@
 check_ifaddrs_LDADD = $(top_builddir)/src/liblldpd.la @CHECK_LIBS@
 
 if USE_SNMP
-check_pack_LDADD += @NETSNMP_LIB@
-check_lldp_LDADD += @NETSNMP_LIB@
-check_cdp_LDADD += @NETSNMP_LIB@
-check_sonmp_LDADD += @NETSNMP_LIB@
-check_edp_LDADD += @NETSNMP_LIB@
-check_ifaddrs_LDADD += @NETSNMP_LIB@
+check_pack_LDADD += @NETSNMP_LIBS@
+check_lldp_LDADD += @NETSNMP_LIBS@
+check_cdp_LDADD += @NETSNMP_LIBS@
+check_sonmp_LDADD += @NETSNMP_LIBS@
+check_edp_LDADD += @NETSNMP_LIBS@
+check_ifaddrs_LDADD += @NETSNMP_LIBS@
 endif
 
 endif