]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Make "listen on vlan" feature optional at compile-time.
authorVincent Bernat <bernat@luffy.cx>
Thu, 4 Jun 2009 21:26:25 +0000 (23:26 +0200)
committerVincent Bernat <bernat@luffy.cx>
Thu, 4 Jun 2009 21:26:25 +0000 (23:26 +0200)
The code to handle this feature is a bit kludgy and it seems safer to
compile out this feature by default.

configure.ac
src/interfaces.c
src/lldpd.c
src/lldpd.h

index 947400e1fcba4ad7d1111271fa80e52dd5c06632..6242de6b228c7be5852e62fc9478dc591991afd2 100644 (file)
@@ -174,4 +174,16 @@ else
        AC_MSG_RESULT(no)
 fi
 
+#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
+
 AC_OUTPUT
index 923b81261f5ae2ee29e78e2844aadb651c93d34d..d5a376877bb4abd4db43c46ed3d4c30f4d6189d4 100644 (file)
@@ -94,9 +94,11 @@ static int    iface_eth_init(struct lldpd *, struct lldpd_hardware *);
 static int      iface_bond_init(struct lldpd *, struct lldpd_hardware *);
 static void     iface_fds_close(struct lldpd *, struct lldpd_hardware *);
 #ifdef ENABLE_DOT1
+#ifdef ENABLE_LISTENVLAN
 static void     iface_vlan_close(struct lldpd *, struct lldpd_hardware *);
 static void     iface_listen_vlan(struct lldpd *,
     struct lldpd_hardware *, struct ifaddrs *);
+#endif
 static void     iface_append_vlan(struct lldpd *,
     struct lldpd_hardware *, struct ifaddrs *);
 #endif
@@ -619,7 +621,7 @@ iface_eth_recv(struct lldpd *cfg, struct lldpd_hardware *hardware,
 static int
 iface_eth_close(struct lldpd *cfg, struct lldpd_hardware *hardware)
 {
-#ifdef ENABLE_DOT1
+#if defined(ENABLE_DOT1) && defined(ENABLE_LISTENVLAN)
        iface_vlan_close(cfg, hardware);
 #endif
        close(hardware->h_sendfd);
@@ -794,7 +796,7 @@ iface_bond_recv(struct lldpd *cfg, struct lldpd_hardware *hardware,
 static int
 iface_bond_close(struct lldpd *cfg, struct lldpd_hardware *hardware)
 {
-#ifdef ENABLE_DOT1
+#if defined(ENABLE_DOT1) && defined(ENABLE_LISTENVLAN)
        iface_vlan_close(cfg, hardware);
 #endif
        iface_fds_close(cfg, hardware); /* h_sendfd is here too */
@@ -862,6 +864,7 @@ lldpd_ifh_bond(struct lldpd *cfg, struct ifaddrs *ifap)
 }
 
 #ifdef ENABLE_DOT1
+#ifdef ENABLE_LISTENVLAN
 /* We keep here the list of VLAN we listen to. */
 struct iface_vlans {
        TAILQ_ENTRY(iface_vlans) next;
@@ -940,6 +943,7 @@ iface_listen_vlan(struct lldpd *cfg,
        ifvl->hardware = hardware;
        TAILQ_INSERT_TAIL(&ifvls, ifvl, next);
 }
+#endif /* ENABLE_LISTENVLAN */
 
 static void
 iface_append_vlan(struct lldpd *cfg,
@@ -972,7 +976,9 @@ iface_append_vlan(struct lldpd *cfg,
        vlan->v_vid = ifv.u.VID;
        TAILQ_INSERT_TAIL(&port->p_vlans, vlan, v_entries);
 
+#ifdef ENABLE_LISTENVLAN
        iface_listen_vlan(cfg, hardware, ifa);
+#endif
 }
 
 void
@@ -981,13 +987,15 @@ lldpd_ifh_vlan(struct lldpd *cfg, struct ifaddrs *ifap)
        struct ifaddrs *ifa;
        struct vlan_ioctl_args ifv;
        struct lldpd_hardware *hardware;
-       struct iface_vlans *ifvl;
        
+#ifdef ENABLE_LISTENVLAN
+       struct iface_vlans *ifvl;
        if (cfg->g_listen_vlans) {
                _iface_vlan_setup();
                TAILQ_FOREACH(ifvl, &ifvls, next)
                    ifvl->refreshed = 0;
        }
+#endif
 
        for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
                if (!ifa->ifa_flags)
@@ -1029,7 +1037,9 @@ lldpd_ifh_vlan(struct lldpd *cfg, struct ifaddrs *ifap)
                            hardware, ifa);
                }
        }
+#ifdef ENABLE_LISTENVLAN
        iface_vlan_close(cfg, NULL);
+#endif
 }
 #endif
 
index 85ec04fa4c272fea465828d5a044550ab1270e63..dfd19d0de7bac15a1dda8463d07499d58f338b85 100644 (file)
@@ -725,8 +725,15 @@ main(int argc, char *argv[])
        int snmp = 0;
 #endif
        char *mgmtp = NULL;
-       char *popt, opts[] = "vdxm:p:M:i@                    ";
-       int i, found, vlan = 0;
+       char *popt, opts[] = 
+#ifdef ENABLE_LISTENVLAN
+               "v"
+#endif
+               "dxm:p:M:i@                    ";
+       int i, found;
+#ifdef ENABLE_LISTENVLAN
+       int vlan = 0;
+#endif
 #ifdef ENABLE_LLDPMED
        int lldpmed = 0, noinventory = 0;
 #endif
@@ -744,9 +751,11 @@ main(int argc, char *argv[])
        *popt = '\0';
        while ((ch = getopt(argc, argv, opts)) != -1) {
                switch (ch) {
+#ifdef ENABLE_LISTENVLAN
                case 'v':
                        vlan = 1;
                        break;
+#endif
                case 'd':
                        debug++;
                        break;
@@ -819,7 +828,9 @@ main(int argc, char *argv[])
                fatal(NULL);
 
        cfg->g_mgmt_pattern = mgmtp;
+#ifdef ENABLE_LISTENVLAN
        cfg->g_listen_vlans = vlan;
+#endif
 
        /* Get ioctl socket */
        if ((cfg->g_sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
index 5e772f16588faf8f622646a4deae24fb13d4ffe0..24620e7ef4649c070558cbd97e5c228ee1b87677 100644 (file)
@@ -272,7 +272,9 @@ struct lldpd {
        int                      g_delay;
 
        struct protocol         *g_protocols;
+#ifdef ENABLE_LISTENVLAN
        int                      g_listen_vlans;
+#endif
 #ifdef ENABLE_LLDPMED
        int                      g_noinventory;
 #endif