]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldpcli: possibility to configure tx-delay
authorVincent Bernat <bernat@luffy.cx>
Tue, 22 Jan 2013 22:14:53 +0000 (23:14 +0100)
committerVincent Bernat <bernat@luffy.cx>
Tue, 22 Jan 2013 22:14:53 +0000 (23:14 +0100)
src/client/conf-dot3.c
src/client/conf-med.c
src/client/conf.c
src/client/lldpcli.8

index 5588f7579a4de6d7639fe8823976993e200dcc86..a71aa7aa596b7ae49bfe663753a6ffcb0e3078a6 100644 (file)
 void
 register_commands_configure_dot3(struct cmd_node *configure)
 {
+       if (lldpctl_key_get_map(
+                   lldpctl_k_dot3_power_class)[0].string == NULL)
+               return;
+
        struct cmd_node *configure_dot3 = commands_new(
                configure,
                "dot3", "Dot3 configuration",
index 4aef70c91dfa5f4b6aae64aeff7eb925e94bc13e..daede1ccd423e80b53d04898f0d6bb5571e316d4 100644 (file)
@@ -462,6 +462,10 @@ register_commands_medpol(struct cmd_node *configure_med)
 void
 register_commands_configure_med(struct cmd_node *configure)
 {
+       if (lldpctl_key_get_map(
+                   lldpctl_k_med_policy_type)[0].string == NULL)
+               return;
+
        struct cmd_node *configure_med = commands_new(
                configure,
                "med", "MED configuration",
index 3a9b8df85bcc5bd882657fbe231e31ae7eeba7a7..cc6e81200b5cdf4139d9646fae2c037943779bf8 100644 (file)
 #include "client.h"
 #include "../log.h"
 
+static int
+cmd_txdelay(struct lldpctl_conn_t *conn, struct writer *w,
+    struct cmd_env *env, void *arg)
+{
+       log_debug("lldpctl", "set transmit delay");
+
+       lldpctl_atom_t *config = lldpctl_get_configuration(conn);
+       if (config == NULL) {
+               log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
+                   lldpctl_last_strerror(conn));
+               return 0;
+       }
+       if (lldpctl_atom_set_str(config,
+               lldpctl_k_config_tx_interval, cmdenv_get(env, "tx-interval")) == NULL) {
+               log_warnx("lldpctl", "unable to set transmit delay. %s",
+                   lldpctl_last_strerror(conn));
+               lldpctl_atom_dec_ref(config);
+               return 0;
+       }
+       log_info("lldpctl", "transmit delay set to new value");
+       lldpctl_atom_dec_ref(config);
+       return 1;
+}
+
+/**
+ * Register `configure lldp` commands.
+ */
+void
+register_commands_configure_lldp(struct cmd_node *configure)
+{
+       struct cmd_node *configure_lldp = commands_new(
+               configure,
+               "lldp", "LLDP configuration",
+               NULL, NULL, NULL);
+
+        commands_new(
+               commands_new(
+                       commands_new(configure_lldp,
+                           "tx-interval", "Set LLDP transmit delay",
+                           cmd_check_no_env, NULL, "ports"),
+                       NULL, "LLDP transmit delay in seconds",
+                       NULL, cmd_store_env_value, "tx-interval"),
+               NEWLINE, "Set LLDP transmit delay",
+               NULL, cmd_txdelay, NULL);
+}
 
 /**
  * Register `configure` and `no configure` commands.
 void
 register_commands_configure(struct cmd_node *root)
 {
-       int has_med  = (lldpctl_key_get_map(
-                   lldpctl_k_med_policy_type)[0].string != NULL);
-       int has_dot3 = (lldpctl_key_get_map(
-                   lldpctl_k_dot3_power_class)[0].string != NULL);
-       if (!has_med && !has_dot3) return;
-
        struct cmd_node *configure = commands_new(
                root,
                "configure",
@@ -41,6 +80,7 @@ register_commands_configure(struct cmd_node *root)
                NULL, NULL, NULL);
        cmd_restrict_ports(configure);
 
-       if (has_med) register_commands_configure_med(configure);
-       if (has_dot3) register_commands_configure_dot3(configure);
+        register_commands_configure_lldp(configure);
+        register_commands_configure_med(configure);
+        register_commands_configure_dot3(configure);
 }
index 1c726d7686e2c6a304b1c2d91863d4293c4c507d..dffa7a67ab43bf8616dbfb3c7adea5f9508368f2 100644 (file)
@@ -150,6 +150,15 @@ Make
 update its information and send new LLDP PDU on all interfaces.
 .Ed
 
+.Cd configure
+.Op ports Ar ethX Op ,...
+.Cd lldp tx-interval Ar interval
+.Bd -ragged -offset XXXXXX
+Change transmit delay to the specified value in seconds. The transmit
+delay is the delay between two transmissions of LLDP PDU. The default
+value is 30 seconds.
+.Ed
+
 .Cd configure
 .Op ports Ar ethX Op ,...
 .Cd med location coordinate