From: Thomas Eliasson Date: Thu, 8 Mar 2018 14:34:17 +0000 (+0100) Subject: client: add alternative way to configure port description X-Git-Tag: 1.0.0~8^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e180a95331f50c5d5cd42b36366249960dd54d6b;p=thirdparty%2Flldpd.git client: add alternative way to configure port description 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 --- diff --git a/src/client/conf-lldp.c b/src/client/conf-lldp.c index c9939f1b..8523f3cc 100644 --- a/src/client/conf-lldp.c +++ b/src/client/conf-lldp.c @@ -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",