From: Stig Thormodsrud Date: Fri, 23 Apr 2010 01:32:53 +0000 (-0700) Subject: Add -S override. X-Git-Tag: 0.5.1~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=40ce835b083ccd31d34d716753e9d8aff058cfe6;p=thirdparty%2Flldpd.git Add -S override. vyatta@vDUT:~$ show lldp neighbors detail ------------------------------------------------------------------------------- LLDP neighbors: ------------------------------------------------------------------------------- Interface: eth0, via: LLDP, RID: 14, Time: 0 day, 00:02:03 Chassis: ChassisID: mac 00:0c:29:8c:53:7c SysName: R1 SysDescr: Vyatta 3500 series running on VSE6.0 Capability: Bridge, off Capability: Router, on Capability: Wlan, off Port: PortID: ifname eth1 PortDescr: vmnet1 PMD autoneg: supported: yes, enabled: yes Adv: 10Base-T, HD: yes, FD: yes Adv: 100Base-T, HD: yes, FD: yes Adv: 1000Base-T, HD: no, FD: yes MAU oper type: 1000BaseTFD - Four-pair Category 5 UTP, full duplex mode VLAN: 101 eth1.101 --- diff --git a/src/lldpd.c b/src/lldpd.c index 03bfb7a8..8db63ea3 100644 --- a/src/lldpd.c +++ b/src/lldpd.c @@ -690,14 +690,22 @@ lldpd_update_localchassis(struct lldpd *cfg) free(LOCAL_CHASSIS(cfg)->c_descr); if ((LOCAL_CHASSIS(cfg)->c_name = strdup(hp)) == NULL) fatal(NULL); - if (cfg->g_advertise_version) { - if (asprintf(&LOCAL_CHASSIS(cfg)->c_descr, "%s %s %s %s", - un.sysname, un.release, un.version, un.machine) == -1) + if (cfg->g_descr_override) { + if (asprintf(&LOCAL_CHASSIS(cfg)->c_descr, "%s", + cfg->g_descr_override) == -1) fatal("failed to set full system description"); - } else { - if (asprintf(&LOCAL_CHASSIS(cfg)->c_descr, "%s", un.sysname) == -1) - fatal("failed to set minimal system description"); - } + } else { + if (cfg->g_advertise_version) { + if (asprintf(&LOCAL_CHASSIS(cfg)->c_descr, "%s %s %s %s", + un.sysname, un.release, un.version, un.machine) + == -1) + fatal("failed to set full system description"); + } else { + if (asprintf(&LOCAL_CHASSIS(cfg)->c_descr, "%s", + un.sysname) == -1) + fatal("failed to set minimal system description"); + } + } /* Check forwarding */ if ((f = priv_open("/proc/sys/net/ipv4/ip_forward")) >= 0) { @@ -830,7 +838,7 @@ lldpd_main(int argc, char *argv[]) #ifdef ENABLE_LISTENVLAN "v" #endif - "hkdxX:m:p:M:i@ "; + "hkdxX:m:p:M:S:i@ "; int i, found, advertise_version = 1; #ifdef ENABLE_LISTENVLAN int vlan = 0; @@ -838,6 +846,7 @@ lldpd_main(int argc, char *argv[]) #ifdef ENABLE_LLDPMED int lldpmed = 0, noinventory = 0; #endif + char *descr_override = NULL; saved_argv = argv; @@ -901,6 +910,9 @@ lldpd_main(int argc, char *argv[]) usage(); #endif break; + case 'S': + descr_override = strdup(optarg); + break; default: found = 0; for (i=0; protos[i].mode != 0; i++) { @@ -955,6 +967,9 @@ lldpd_main(int argc, char *argv[]) fatal("failed to get ioctl socket"); cfg->g_delay = LLDPD_TX_DELAY; + if (descr_override) + cfg->g_descr_override = descr_override; + /* Set system capabilities */ if ((lchassis = (struct lldpd_chassis*) calloc(1, sizeof(struct lldpd_chassis))) == NULL) diff --git a/src/lldpd.h b/src/lldpd.h index 947307b7..7bead796 100644 --- a/src/lldpd.h +++ b/src/lldpd.h @@ -309,6 +309,8 @@ struct lldpd { char *g_mgmt_pattern; + char *g_descr_override; + #define LOCAL_CHASSIS(cfg) ((struct lldpd_chassis *)(TAILQ_FIRST(&cfg->g_chassis))) TAILQ_HEAD(, lldpd_chassis) g_chassis; TAILQ_HEAD(, lldpd_hardware) g_hardware;