]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Add an option to not send LLDP-MED inventory TLV
authorVincent Bernat <bernat@luffy.cx>
Fri, 28 Nov 2008 17:06:11 +0000 (18:06 +0100)
committerVincent Bernat <bernat@luffy.cx>
Fri, 28 Nov 2008 17:06:11 +0000 (18:06 +0100)
man/lldpd.8
src/lldp.c
src/lldpd.c

index 701642b5b5ddba1afbb70075f3e5fff0910bb3c2..db8057fdaf40665a872f9e6174a1ce8259b66217 100644 (file)
@@ -21,7 +21,7 @@
 .Nd LLDP daemon
 .Sh SYNOPSIS
 .Nm
-.Op Fl dvxcse
+.Op Fl dvxcsei
 .Op Fl m Ar management
 .Op Fl p Ar probe time
 .Op Fl M Ar class
@@ -105,6 +105,12 @@ Communication Device Endpoints (Class III)
 .It Ar 4
 Network Connectivity Device
 .El
+.It Fl i
+Disable LLDP-MED inventory TLV transmission.
+.Nm
+will still receive (and publish using SNMP if enabled) those LLDP-MED
+TLV but will not send them. Use this option if you don't want to
+transmit sensible information like serial numbers.
 .Sh FILES
 .Bl -tag -width "/var/run/lldpd.socketXX" -compact
 .It /var/run/lldpd.socket
index 755e9184ebb532379b01bdfde5c9fcd4857ed57a..ff1dceb90bd0df3341f1d3a072ced7181eac3865 100644 (file)
@@ -285,20 +285,23 @@ lldp_send(struct lldpd *global, struct lldpd_chassis *chassis,
                    iov[c].iov_base = value;                            \
                    iov[c].iov_len = len;                               \
                }
-               LLDP_INVENTORY(global->g_lchassis.c_med_hw,
-                   medhw, LLDP_TLV_MED_IV_HW);
-               LLDP_INVENTORY(global->g_lchassis.c_med_fw,
-                   medfw, LLDP_TLV_MED_IV_FW);
-               LLDP_INVENTORY(global->g_lchassis.c_med_sw,
-                   medsw, LLDP_TLV_MED_IV_SW);
-               LLDP_INVENTORY(global->g_lchassis.c_med_sn,
-                   medsn, LLDP_TLV_MED_IV_SN);
-               LLDP_INVENTORY(global->g_lchassis.c_med_manuf,
-                   medmanuf, LLDP_TLV_MED_IV_MANUF);
-               LLDP_INVENTORY(global->g_lchassis.c_med_model,
-                   medmodel, LLDP_TLV_MED_IV_MODEL);
-               LLDP_INVENTORY(global->g_lchassis.c_med_asset,
-                   medasset, LLDP_TLV_MED_IV_ASSET);
+
+               if (!global->g_med_noinventory) {
+                       LLDP_INVENTORY(global->g_lchassis.c_med_hw,
+                           medhw, LLDP_TLV_MED_IV_HW);
+                       LLDP_INVENTORY(global->g_lchassis.c_med_fw,
+                           medfw, LLDP_TLV_MED_IV_FW);
+                       LLDP_INVENTORY(global->g_lchassis.c_med_sw,
+                           medsw, LLDP_TLV_MED_IV_SW);
+                       LLDP_INVENTORY(global->g_lchassis.c_med_sn,
+                           medsn, LLDP_TLV_MED_IV_SN);
+                       LLDP_INVENTORY(global->g_lchassis.c_med_manuf,
+                           medmanuf, LLDP_TLV_MED_IV_MANUF);
+                       LLDP_INVENTORY(global->g_lchassis.c_med_model,
+                           medmodel, LLDP_TLV_MED_IV_MODEL);
+                       LLDP_INVENTORY(global->g_lchassis.c_med_asset,
+                           medasset, LLDP_TLV_MED_IV_ASSET);
+               }
        }
 #endif
 
index bf9063388a65b069eef19749cde7206f5b5f3c6d..d5cf46df005f9203567570ba5ad3ea9f1b5a49ad 100644 (file)
@@ -178,11 +178,8 @@ void
 usage(void)
 {
        extern const char       *__progname;
-#ifndef USE_SNMP
-       fprintf(stderr, "usage: %s [-dvcse] [-p|-P] [-m ip]\n", __progname);
-#else /* USE_SNMP */
-       fprintf(stderr, "usage: %s [-dvcsex] [-p|-P] [-m ip]\n", __progname);
-#endif /* USE_SNMP */
+       fprintf(stderr, "usage: %s [options]\n", __progname);
+       fprintf(stderr, "see manual page lldpd(8) for more information\n");
        exit(1);
 }
 
@@ -1377,12 +1374,15 @@ int
 main(int argc, char *argv[])
 {
        struct lldpd *cfg;
-       int ch, snmp = 0, debug = 0;
+       int ch, debug = 0;
+#ifdef USE_SNMP
+       int snmp = 0;
+#endif
        char *mgmtp = NULL;
-       char *popt, opts[] = "vdxm:p:@                    ";
+       char *popt, opts[] = "vdxm:p:M:i@                    ";
        int probe = 0, i, found, vlan = 0;
 #ifdef ENABLE_LLDPMED
-       int lldpmed = 0;
+       int lldpmed = 0, noinventory = 0;
 #endif
 
        saved_argv = argv;
@@ -1395,10 +1395,6 @@ main(int argc, char *argv[])
                if (protos[i].enabled == 1) continue;
                *(popt++) = protos[i].arg;
        }
-#ifdef ENABLE_LLDPMED
-       *(popt++) = 'M';
-       *(popt++) = ':';
-#endif
        *popt = '\0';
        while ((ch = getopt(argc, argv, opts)) != -1) {
                switch (ch) {
@@ -1411,18 +1407,36 @@ main(int argc, char *argv[])
                case 'm':
                        mgmtp = optarg;
                        break;
-#ifdef ENABLE_LLDPMED
                case 'M':
+#ifdef ENABLE_LLDPMED
                        lldpmed = atoi(optarg);
-                       if ((lldpmed < 1) || (lldpmed > 4))
+                       if ((lldpmed < 1) || (lldpmed > 4)) {
+                               fprintf(stderr, "-M requires an argument between 1 and 4\n");
                                usage();
+                       }
+#else
+                       fprintf(stderr, "LLDP-MED support is not built-in\n");
+                       usage();
+#endif
                        break;
+               case 'i':
+#ifdef ENABLE_LLDPMED
+                       noinventory = 1;
+#else
+                       fprintf(stderr, "LLDP-MED support is not built-in\n");
+                       usage();
 #endif
+                       break;
                case 'p':
                        probe = atoi(optarg);
                        break;
                case 'x':
+#ifdef USE_SNMP
                        snmp = 1;
+#else
+                       fprintf(stderr, "SNMP support is not built-in\n");
+                       usage();
+#endif
                        break;
                default:
                        found = 0;
@@ -1480,7 +1494,10 @@ main(int argc, char *argv[])
                if (lldpmed == LLDPMED_CLASS_III)
                        cfg->g_lchassis.c_cap_available |= LLDP_CAP_TELEPHONE;
                cfg->g_lchassis.c_med_type = lldpmed;
-               cfg->g_lchassis.c_med_cap = LLDPMED_CAP_CAP | LLDPMED_CAP_IV;
+               cfg->g_lchassis.c_med_cap = LLDPMED_CAP_CAP;
+               if (!noinventory)
+                       cfg->g_lchassis.c_med_cap |= LLDPMED_CAP_IV;
+               cfg->g_med_noinventory = noinventory;
        }
 #endif