]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Allow to compile only needed protocols
authorVincent Bernat <vbernat@wanadooportails.com>
Tue, 25 Nov 2008 15:15:22 +0000 (16:15 +0100)
committerVincent Bernat <vbernat@wanadooportails.com>
Tue, 25 Nov 2008 15:15:22 +0000 (16:15 +0100)
configure.ac
src/cdp.c
src/edp.c
src/lldpd.c
src/lldpd.h
src/sonmp.c

index 609c61276e04b374863aa2467639545ccae32d78..222941dc7ae6af867df534b201fd9679b74bb01c 100644 (file)
@@ -11,6 +11,51 @@ AC_CONFIG_FILES([Makefile src/Makefile man/Makefile])
 # Checks for programs.
 AC_PROG_CC
 
+# Options
+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
+
+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
+
+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
+
+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)
+fi
+
 # Checks for libraries.
 AC_ARG_WITH(snmp,
   AC_HELP_STRING(
index 3acc757e482cbfb97d2d2ad06da41a7776ae98ed..ef205793eab70e2dce0a2871a5288b1100f3b751 100644 (file)
--- a/src/cdp.c
+++ b/src/cdp.c
@@ -17,6 +17,8 @@
 /* We also supports FDP which is very similar to CDPv1 */
 #include "lldpd.h"
 
+#if defined (ENABLE_CDP) || defined (ENABLE_FDP)
+
 #include <errno.h>
 #include <arpa/inet.h>
 
@@ -493,3 +495,5 @@ cdpv2_guess(char *frame, int len)
 {
        return cdp_guess(frame, len, 2);
 }
+
+#endif /* defined (ENABLE_CDP) || defined (ENABLE_FDP) */
index f13ed2abde608fb9c237111844df843f1d97ee50..8e403b17e76105779a365a548faa3fb28f78f4b4 100644 (file)
--- a/src/edp.c
+++ b/src/edp.c
@@ -16,6 +16,8 @@
 
 #include "lldpd.h"
 
+#ifdef ENABLE_EDP
+
 #include <stdio.h>
 #include <errno.h>
 #include <arpa/inet.h>
@@ -462,3 +464,5 @@ malformed:
        free(port);
        return -1;
 }
+
+#endif /* ENABLE_EDP */
index 07ecbfd8c3c235c386aac1e7bd6a983fa2ac16a8..28deec8311d1eba9c16d05fd9fdd27777ab71777 100644 (file)
@@ -65,6 +65,7 @@ void                   lldpd_iface_multicast(struct lldpd *, const char *, int);
         { 0x6, 0, 0, 0x0000ffff },                                     \
         { 0x6, 0, 0, 0x00000000 },
 struct sock_filter lldpd_filter_lldp_f[] = { LLDPD_FILTER_LLDP_F };
+#ifdef ENABLE_FDP
 /* "ether dst 01:e0:52:cc:cc:cc" */
 #define LLDPD_FILTER_FDP_F                     \
         { 0x20, 0, 0, 0x00000002 },            \
@@ -74,6 +75,8 @@ struct sock_filter lldpd_filter_lldp_f[] = { LLDPD_FILTER_LLDP_F };
         { 0x6, 0, 0, 0x0000ffff },             \
         { 0x6, 0, 0, 0x00000000 },
 struct sock_filter lldpd_filter_fdp_f[] = { LLDPD_FILTER_FDP_F };
+#endif /* ENABLE_FDP */
+#ifdef ENABLE_CDP
 /* "ether dst 01:00:0c:cc:cc:cc" */
 #define LLDPD_FILTER_CDP_F                     \
         { 0x20, 0, 0, 0x00000002 },            \
@@ -83,6 +86,8 @@ struct sock_filter lldpd_filter_fdp_f[] = { LLDPD_FILTER_FDP_F };
         { 0x6, 0, 0, 0x0000ffff },             \
         { 0x6, 0, 0, 0x00000000 },
 struct sock_filter lldpd_filter_cdp_f[] = { LLDPD_FILTER_CDP_F };
+#endif /* ENABLE_CDP */
+#ifdef ENABLE_SONMP
 /* "ether dst 01:00:81:00:01:00" */
 #define LLDPD_FILTER_SONMP_F                   \
         { 0x20, 0, 0, 0x00000002 },            \
@@ -92,6 +97,8 @@ struct sock_filter lldpd_filter_cdp_f[] = { LLDPD_FILTER_CDP_F };
         { 0x6, 0, 0, 0x0000ffff },             \
         { 0x6, 0, 0, 0x00000000 },
 struct sock_filter lldpd_filter_sonmp_f[] = { LLDPD_FILTER_SONMP_F };
+#endif /* ENABLE_SONMP */
+#ifdef ENABLE_EDP
 /* "ether dst 00:e0:2b:00:00:00" */
 #define LLDPD_FILTER_EDP_F              \
        { 0x20, 0, 0, 0x00000002 },     \
@@ -100,6 +107,7 @@ struct sock_filter lldpd_filter_sonmp_f[] = { LLDPD_FILTER_SONMP_F };
        { 0x15, 0, 1, 0x000000e0 },     \
        { 0x6, 0, 0, 0x0000ffff },      \
        { 0x6, 0, 0, 0x00000000 },
+#endif /* ENABLE_EDP */
 struct sock_filter lldpd_filter_edp_f[] = { LLDPD_FILTER_EDP_F };
 #define LLDPD_FILTER_ANY_F             \
        { 0x28, 0, 0, 0x0000000c },     \
@@ -127,16 +135,24 @@ struct protocol protos[] =
 {
        { LLDPD_MODE_LLDP, 1, "LLDP", ' ', lldp_send, lldp_decode, NULL,
          LLDP_MULTICAST_ADDR, lldpd_filter_lldp_f, sizeof(lldpd_filter_lldp_f) },
+#ifdef ENABLE_CDP
        { LLDPD_MODE_CDPV1, 0, "CDPv1", 'c', cdpv1_send, cdp_decode, cdpv1_guess,
          CDP_MULTICAST_ADDR, lldpd_filter_cdp_f, sizeof(lldpd_filter_cdp_f) },
        { LLDPD_MODE_CDPV2, 0, "CDPv2", 'c', cdpv2_send, cdp_decode, cdpv2_guess,
          CDP_MULTICAST_ADDR, lldpd_filter_cdp_f, sizeof(lldpd_filter_cdp_f) },
+#endif
+#ifdef ENABLE_SONMP
        { LLDPD_MODE_SONMP, 0, "SONMP", 's', sonmp_send, sonmp_decode, NULL,
          SONMP_MULTICAST_ADDR, lldpd_filter_sonmp_f, sizeof(lldpd_filter_sonmp_f) },
+#endif
+#ifdef ENABLE_EDP
        { LLDPD_MODE_EDP, 0, "EDP", 'e', edp_send, edp_decode, NULL,
          EDP_MULTICAST_ADDR, lldpd_filter_edp_f, sizeof(lldpd_filter_edp_f) },
+#endif
+#ifdef ENABLE_FDP
        { LLDPD_MODE_FDP, 0, "FDP", 'f', fdp_send, cdp_decode, NULL,
          FDP_MULTICAST_ADDR, lldpd_filter_fdp_f, sizeof(lldpd_filter_fdp_f) },
+#endif
        { 0, 0, "any", ' ', NULL, NULL, NULL,
          {0,0,0,0,0,0}, lldpd_filter_any_f, sizeof(lldpd_filter_any_f) }
 };
index 59cfdfe44c2c0e75013821d8ad37a28f6e51874c..56c517c0ca6f04dfa3d2f7a22821306ee0b14744 100644 (file)
 
 #include "compat.h"
 #include "lldp.h"
+#if defined (ENABLE_CDP) || defined (ENABLE_FDP)
 #include "cdp.h"
+#endif
+#ifdef ENABLE_SONMP
 #include "sonmp.h"
+#endif
+#ifdef ENABLE_EDP
 #include "edp.h"
+#endif
 
 #define LLDPD_TTL              120
 #define LLDPD_TX_DELAY         30
@@ -247,20 +253,30 @@ int        lldp_send(PROTO_SEND_SIG);
 int     lldp_decode(PROTO_DECODE_SIG);
 
 /* cdp.c */
+#ifdef ENABLE_CDP
 int     cdpv1_send(PROTO_SEND_SIG);
 int     cdpv2_send(PROTO_SEND_SIG);
-int     fdp_send(PROTO_SEND_SIG);
-int     cdp_decode(PROTO_DECODE_SIG);
 int     cdpv1_guess(PROTO_GUESS_SIG);
 int     cdpv2_guess(PROTO_GUESS_SIG);
+#endif
+#if defined (ENABLE_CDP) || defined (ENABLE_FDP)
+int     cdp_decode(PROTO_DECODE_SIG);
+#endif
+#ifdef ENABLE_FDP
+int     fdp_send(PROTO_SEND_SIG);
+#endif
 
+#ifdef ENABLE_SONMP
 /* sonmp.c */
 int     sonmp_send(PROTO_SEND_SIG);
 int     sonmp_decode(PROTO_DECODE_SIG);
+#endif
 
+#ifdef ENABLE_EDP
 /* edp.c */
 int     edp_send(PROTO_SEND_SIG);
 int     edp_decode(PROTO_DECODE_SIG);
+#endif
 
 /* ctl.c */
 int     ctl_create(char *);
index 19067c70850a4ec30a5c866837603c09fd3e443a..151edd6be9439eadcd28cdd21c6e083194f2c259 100644 (file)
@@ -16,6 +16,8 @@
 
 #include "lldpd.h"
 
+#ifdef ENABLE_SONMP
+
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
@@ -334,3 +336,5 @@ malformed:
        free(port);
        return -1;
 }
+
+#endif /* ENABLE_SONMP */