]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
cdp: make the default platform name really the kernel name
authorBaptiste Daroussin <bapt@gandi.net>
Wed, 12 Aug 2015 12:40:45 +0000 (14:40 +0200)
committerVincent Bernat <vincent@bernat.im>
Wed, 12 Aug 2015 14:52:51 +0000 (16:52 +0200)
Instead of hardcoding 'Linux" directly query the kernel name of the user
is not overwriting it.

src/daemon/protocols/cdp.c

index cc6f8318c062e6718e37992a386a5faeef44d0e3..86013e61a18630c2679808c428994c7a168f1bf6 100644 (file)
@@ -21,6 +21,8 @@
 
 #if defined (ENABLE_CDP) || defined (ENABLE_FDP)
 
+#include <sys/utsname.h>
+
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
@@ -31,7 +33,8 @@ static int
 cdp_send(struct lldpd *global,
         struct lldpd_hardware *hardware, int version)
 {
-       const char *platform = "Linux";
+       const char *platform;
+       struct utsname utsname;
        struct lldpd_chassis *chassis;
        struct lldpd_mgmt *mgmt;
        struct lldpd_port *port;
@@ -198,7 +201,13 @@ cdp_send(struct lldpd *global,
                goto toobig;
 
        /* Platform */
-       if (global && global->g_config.c_platform) platform = global->g_config.c_platform;
+       if (global && global->g_config.c_platform)
+               platform = global->g_config.c_platform;
+       else {
+               uname(&utsname);
+               platform = utsname.sysname;
+       }
+
        if (!(
              POKE_START_CDP_TLV(CDP_TLV_PLATFORM) &&
              POKE_BYTES(platform, strlen(platform)) &&