From 166f9103d3e97f84d32e0e176beac79daa0b1d33 Mon Sep 17 00:00:00 2001 From: Abhinay Ramesh Date: Tue, 11 May 2021 08:43:25 +0000 Subject: lib: Support auto completion of configured keychain. Problem Statement: ================= When modules use keychain there is no option for auto completion of configured keychains. RCA: ==== Not implemented. Fix: ==== Changes to support auto completion of configured keychain names. Risk: ===== Low risk Tests Executed: =============== Have tested auto completion of configured keychain names with newly implemented auth CLI. frr(config-if)# ipv6 ospf6 authentication keychain KEYCHAIN_NAME Keychain name abcd pqr 12345 Signed-off-by: Abhinay Ramesh --- lib/keychain.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib/keychain.c') diff --git a/lib/keychain.c b/lib/keychain.c index 02f83ef0a..1d678b949 100644 --- a/lib/keychain.c +++ b/lib/keychain.c @@ -1051,10 +1051,28 @@ static int keychain_config_write(struct vty *vty) return 0; } +static void keychain_active_config(vector comps, struct cmd_token *token) +{ + struct keychain *keychain; + struct listnode *node; + + for (ALL_LIST_ELEMENTS_RO(keychain_list, node, keychain)) + vector_set(comps, XSTRDUP(MTYPE_COMPLETION, keychain->name)); +} + +static const struct cmd_variable_handler keychain_var_handlers[] = { + {.varname = "key_chain", .completions = keychain_active_config}, + {.tokenname = "KEYCHAIN_NAME", .completions = keychain_active_config}, + {.tokenname = "KCHAIN_NAME", .completions = keychain_active_config}, + {.completions = NULL} +}; + void keychain_init(void) { keychain_list = list_new(); + /* Register handler for keychain auto config support */ + cmd_variable_handler_register(keychain_var_handlers); install_node(&keychain_node); install_node(&keychain_key_node); -- cgit v1.2.3