]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
client: add alternative way to configure port description
authorThomas Eliasson <thomas.eliasson@westermo.se>
Thu, 8 Mar 2018 14:34:17 +0000 (15:34 +0100)
committerJonas Johansson <jonas.johansson@westermo.se>
Mon, 12 Mar 2018 11:59:04 +0000 (12:59 +0100)
The existing port description CLI command only allows user configured
description if setting port id subtype to local. This patch introduces
an subtype independent way to configure port description.

Signed-off-by: Jonas Johansson <jonas.johansson@westermo.se>
src/client/conf-lldp.c

index c9939f1b4a5fdce3d798a642a8d9e45bcf3976c1..8523f3cc5a405193edb5d95f2f56fb559bc0423b 100644 (file)
@@ -171,6 +171,26 @@ cmd_portid_type_local(struct lldpctl_conn_t *conn, struct writer *w,
        return 1;
 }
 
+static int
+cmd_port_descr(struct lldpctl_conn_t *conn, struct writer *w,
+               struct cmd_env *env, void *arg)
+{
+       lldpctl_atom_t *port;
+       const char *name;
+       const char *descr = cmdenv_get(env, "port-descr");
+
+       log_debug("lldpctl", "lldp port-descr '%s'", descr);
+
+       while ((port = cmd_iterate_on_ports(conn, env, &name))) {
+               if (descr && lldpctl_atom_set_str(port, lldpctl_k_port_descr, descr) == NULL) {
+                       log_warnx("lldpctl", "unable to set LLDP Port Description for %s."
+                           " %s", name, lldpctl_last_strerror(conn));
+               }
+       }
+
+       return 1;
+}
+
 static int
 cmd_portid_type(struct lldpctl_conn_t *conn, struct writer *w,
                struct cmd_env *env, void *arg)
@@ -604,6 +624,17 @@ register_commands_configure_lldp(struct cmd_node *configure,
                }
        }
 
+       commands_new(
+               commands_new(
+                       commands_new(configure_lldp,
+                           "portdescription",
+                           "Port Description",
+                           NULL, NULL, NULL),
+                       NULL, "Port description",
+                       NULL, cmd_store_env_value, "port-descr"),
+               NEWLINE, "Set port description",
+               NULL, cmd_port_descr, NULL);
+
        commands_new(
                commands_new(configure_lldp,
                    "capabilities-advertisements",