]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldpcli: don't propose configure for options not compiled
authorVincent Bernat <bernat@luffy.cx>
Sat, 5 Jan 2013 16:37:37 +0000 (17:37 +0100)
committerVincent Bernat <bernat@luffy.cx>
Sat, 5 Jan 2013 16:37:37 +0000 (17:37 +0100)
We don't rely on ENABLE_* variables to keep lldpcli independant of the
source code of the library.

src/client/actions.c

index 8387055d1a5d083a6c5f9458c26b9fc7926b9280..8b3331618684a1ff1d221578454db1a4ecb86ac6 100644 (file)
@@ -894,6 +894,12 @@ register_commands_dot3pow(struct cmd_node *configure_dot3)
 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",
@@ -901,19 +907,23 @@ register_commands_configure(struct cmd_node *root)
                NULL, NULL, NULL);
        restrict_ports(configure);
 
-       struct cmd_node *configure_med = commands_new(
-               configure,
-               "med", "MED configuration",
-               NULL, NULL, NULL);
+       if (has_med) {
+               struct cmd_node *configure_med = commands_new(
+                       configure,
+                       "med", "MED configuration",
+                       NULL, NULL, NULL);
 
-       register_commands_medloc(configure_med);
-       register_commands_medpol(configure_med);
-       register_commands_medpow(configure_med);
+               register_commands_medloc(configure_med);
+               register_commands_medpol(configure_med);
+               register_commands_medpow(configure_med);
+       }
 
-       struct cmd_node *configure_dot3 = commands_new(
-               configure,
-               "dot3", "Dot3 configuration",
-               NULL, NULL, NULL);
+       if (has_dot3) {
+               struct cmd_node *configure_dot3 = commands_new(
+                       configure,
+                       "dot3", "Dot3 configuration",
+                       NULL, NULL, NULL);
 
-       register_commands_dot3pow(configure_dot3);
+               register_commands_dot3pow(configure_dot3);
+       }
 }