]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
cdp: allow to override value of platform TLV (Linux by default)
authorVincent Bernat <bernat@luffy.cx>
Sat, 25 Feb 2012 10:37:43 +0000 (11:37 +0100)
committerVincent Bernat <bernat@luffy.cx>
Sat, 25 Feb 2012 10:37:43 +0000 (11:37 +0100)
man/lldpd.8
src/cdp.c
src/lldpd.c
src/lldpd.h

index 447dd109dd619f72cbfafabcf6ffb0036507f194..3a5dbdb86e35185e6804b74dec0bd7166d40b5c1 100644 (file)
@@ -23,6 +23,7 @@
 .Nm
 .Op Fl dxcseiklr
 .Op Fl S Ar description
+.Op Fl P Ar platform
 .Op Fl X Ar socket
 .Op Fl m Ar management
 .Op Fl I Ar interfaces
@@ -69,6 +70,9 @@ description is the kernel name, the node name, the kernel version, the
 build date and the architecture (except if you use the
 .Fl k
 flag described above).
+.It Fl P Ar platform
+Override the CDP platform name with the provided value. The default
+description is the kernel name (Linux).
 .It Fl x
 Enable SNMP subagent.
 With this option,
index 4d873534bf924b9d4894a5f039c81d878aa5e6ca..609773b8d4814bc26ec85b3f3e3ab66b5053fbe1 100644 (file)
--- a/src/cdp.c
+++ b/src/cdp.c
@@ -164,9 +164,11 @@ cdp_send(struct lldpd *global,
                goto toobig;
 
        /* Platform */
+       char *platform = "Linux";
+       if (global && global->g_platform_override) platform = global->g_platform_override;
        if (!(
              POKE_START_CDP_TLV(CDP_TLV_PLATFORM) &&
-             POKE_BYTES("Linux", strlen("Linux")) &&
+             POKE_BYTES(platform, strlen(platform)) &&
              POKE_END_CDP_TLV))
                goto toobig;
        POKE_SAVE(end);
index 5371aa80c32f530177893333ccb103d11010fe35..ba72c207305b36f23da3dce6b0f8e13b2fb6376f 100644 (file)
@@ -92,6 +92,7 @@ usage(void)
        fprintf(stderr, "-i       Disable LLDP-MED inventory TLV transmission.\n");
        fprintf(stderr, "-k       Disable advertising of kernel release, version, machine.\n");
        fprintf(stderr, "-S descr Override the default system description.\n");
+       fprintf(stderr, "-P name  Override the default hardware platform.\n");
        fprintf(stderr, "-m IP    Specify the management address of this system.\n");
        fprintf(stderr, "-H mode  Specify the behaviour when detecting multiple neighbors.\n");
        fprintf(stderr, "-I iface Limit interfaces to use.\n");
@@ -1120,12 +1121,13 @@ lldpd_main(int argc, char *argv[])
        char *cidp = NULL;
        char *interfaces = NULL;
        char *popt, opts[] = 
-               "H:hkrdxX:m:I:C:p:M:S:i@                    ";
+               "H:hkrdxX:m:I:C:p:M:P:S:i@                    ";
        int i, found, advertise_version = 1;
 #ifdef ENABLE_LLDPMED
        int lldpmed = 0, noinventory = 0;
 #endif
-        char *descr_override = NULL;
+       char *descr_override = NULL;
+       char *platform_override = NULL;
        char *lsb_release = NULL;
        int smart = 15;
        int receiveonly = 0;
@@ -1176,7 +1178,6 @@ lldpd_main(int argc, char *argv[])
 #else
                case 'M':
                case 'i':
-               case 'P':
                        fprintf(stderr, "LLDP-MED support is not built-in\n");
                        usage();
                        break;
@@ -1199,6 +1200,9 @@ lldpd_main(int argc, char *argv[])
                 case 'S':
                         descr_override = strdup(optarg);
                         break;
+               case 'P':
+                       platform_override = strdup(optarg);
+                       break;
                case 'H':
                        smart = atoi(optarg);
                        break;
@@ -1279,6 +1283,9 @@ lldpd_main(int argc, char *argv[])
         if (descr_override)
            cfg->g_descr_override = descr_override;
 
+       if (platform_override)
+               cfg->g_platform_override = platform_override;
+
        /* Set system capabilities */
        if ((lchassis = (struct lldpd_chassis*)
                calloc(1, sizeof(struct lldpd_chassis))) == NULL)
index d7fed395771072cfa55155feef3a35087d983041..696c710fb2fec9dec4cbd0c8c492554d320f620c 100644 (file)
@@ -418,7 +418,8 @@ struct lldpd {
        char                    *g_cid_pattern;
        char                    *g_interfaces;
 
-        char                    *g_descr_override;
+       char                    *g_descr_override;
+       char                    *g_platform_override;
        char                    *g_lsb_release;
        int                      g_advertise_version;
 #ifdef ENABLE_LLDPMED