From 552502a43d93cfe2344c3b56f0b2fe058bc4ef3b Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sat, 5 Jan 2013 17:37:37 +0100 Subject: [PATCH] lldpcli: don't propose configure for options not compiled We don't rely on ENABLE_* variables to keep lldpcli independant of the source code of the library. --- src/client/actions.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/client/actions.c b/src/client/actions.c index 8387055d..8b333161 100644 --- a/src/client/actions.c +++ b/src/client/actions.c @@ -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); + } } -- 2.47.2