From: Vincent Bernat Date: Sat, 5 Jan 2013 16:37:37 +0000 (+0100) Subject: lldpcli: don't propose configure for options not compiled X-Git-Tag: 0.7.0~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=552502a43d93cfe2344c3b56f0b2fe058bc4ef3b;p=thirdparty%2Flldpd.git 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. --- 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); + } }