]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Add -S <system_description> override.
authorStig Thormodsrud <stig@vyatta.com>
Fri, 23 Apr 2010 01:32:53 +0000 (18:32 -0700)
committerVincent Bernat <bernat@luffy.cx>
Fri, 23 Apr 2010 21:55:05 +0000 (23:55 +0200)
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

src/lldpd.c
src/lldpd.h

index 03bfb7a8e488e3ebc61e5dd4803d26316266661d..8db63ea3d202d796833d253af13a8493fec20829 100644 (file)
@@ -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)
index 947307b75285fa362ae09942a83aedf6f996d556..7bead7962089390851937733a275c39b0467cf2c 100644 (file)
@@ -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;