From d798504262549e68c9a1801687bbcef907b21699 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Thu, 5 Dec 2013 21:37:04 +0100 Subject: [PATCH] lldp: do not send system description TLV if empty 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 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/daemon/lldp.c b/src/daemon/lldp.c index 38403aa9..6e5806ad 100644 --- a/src/daemon/lldp.c +++ b/src/daemon/lldp.c @@ -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 (!( -- 2.39.5