From 4bad193762919d31a3fea62468c7cfcbbb06a67f Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Tue, 25 Nov 2008 16:15:22 +0100 Subject: [PATCH] Allow to compile only needed protocols --- configure.ac | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/cdp.c | 4 ++++ src/edp.c | 4 ++++ src/lldpd.c | 16 ++++++++++++++++ src/lldpd.h | 20 ++++++++++++++++++-- src/sonmp.c | 4 ++++ 6 files changed, 91 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 609c6127..222941dc 100644 --- a/configure.ac +++ b/configure.ac @@ -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( diff --git a/src/cdp.c b/src/cdp.c index 3acc757e..ef205793 100644 --- 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 #include @@ -493,3 +495,5 @@ cdpv2_guess(char *frame, int len) { return cdp_guess(frame, len, 2); } + +#endif /* defined (ENABLE_CDP) || defined (ENABLE_FDP) */ diff --git a/src/edp.c b/src/edp.c index f13ed2ab..8e403b17 100644 --- a/src/edp.c +++ b/src/edp.c @@ -16,6 +16,8 @@ #include "lldpd.h" +#ifdef ENABLE_EDP + #include #include #include @@ -462,3 +464,5 @@ malformed: free(port); return -1; } + +#endif /* ENABLE_EDP */ diff --git a/src/lldpd.c b/src/lldpd.c index 07ecbfd8..28deec83 100644 --- a/src/lldpd.c +++ b/src/lldpd.c @@ -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) } }; diff --git a/src/lldpd.h b/src/lldpd.h index 59cfdfe4..56c517c0 100644 --- a/src/lldpd.h +++ b/src/lldpd.h @@ -37,9 +37,15 @@ #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 *); diff --git a/src/sonmp.c b/src/sonmp.c index 19067c70..151edd6b 100644 --- a/src/sonmp.c +++ b/src/sonmp.c @@ -16,6 +16,8 @@ #include "lldpd.h" +#ifdef ENABLE_SONMP + #include #include #include @@ -334,3 +336,5 @@ malformed: free(port); return -1; } + +#endif /* ENABLE_SONMP */ -- 2.39.5