]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldp: do not send system description TLV if empty
authorVincent Bernat <bernat@luffy.cx>
Thu, 5 Dec 2013 20:37:04 +0000 (21:37 +0100)
committerVincent Bernat <bernat@luffy.cx>
Thu, 5 Dec 2013 20:37:04 +0000 (21:37 +0100)
This makes this TLV optional to send (as authorized in 802.1AB). The
user just has to provide an empty TLV, with, for example `-S ""`.

src/daemon/lldp.c

index 38403aa9b94cd49041a17953adb6e157a1933d94..6e5806ad4e04154755d434e2000b4bce84711acf 100644 (file)
@@ -129,12 +129,14 @@ lldp_send(struct lldpd *global,
              POKE_END_LLDP_TLV))
                goto toobig;
 
-       /* System description */
-       if (!(
-             POKE_START_LLDP_TLV(LLDP_TLV_SYSTEM_DESCR) &&
-             POKE_BYTES(chassis->c_descr, strlen(chassis->c_descr)) &&
-             POKE_END_LLDP_TLV))
-               goto toobig;
+       /* System description (skip it if empty) */
+       if (chassis->c_descr && *chassis->c_descr != '\0') {
+               if (!(
+                           POKE_START_LLDP_TLV(LLDP_TLV_SYSTEM_DESCR) &&
+                           POKE_BYTES(chassis->c_descr, strlen(chassis->c_descr)) &&
+                           POKE_END_LLDP_TLV))
+                       goto toobig;
+       }
 
        /* System capabilities */
        if (!(