Merge pull request #10891 from opensourcerouting/feature/autocomplate_for_bmptagets

bgpd: Add autocomplete for BMP targets
This commit is contained in:
Donald Sharp 2022-03-27 07:29:21 -04:00 committed by GitHub
commit 535e035ed6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1931,6 +1931,28 @@ static struct cmd_node bmp_node = {
.prompt = "%s(config-bgp-bmp)# "
};
static void bmp_targets_autocomplete(vector comps, struct cmd_token *token)
{
struct bgp *bgp;
struct bmp_targets *target;
struct listnode *node;
for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) {
struct bmp_bgp *bmpbgp = bmp_bgp_find(bgp);
if (!bmpbgp)
continue;
frr_each_safe (bmp_targets, &bmpbgp->targets, target)
vector_set(comps,
XSTRDUP(MTYPE_COMPLETION, target->name));
}
}
static const struct cmd_variable_handler bmp_targets_var_handlers[] = {
{.tokenname = "BMPTARGETS", .completions = bmp_targets_autocomplete},
{.completions = NULL}};
#define BMP_STR "BGP Monitoring Protocol\n"
#ifndef VTYSH_EXTRACT_PL
@ -2424,6 +2446,9 @@ static int bgp_bmp_init(struct thread_master *tm)
{
install_node(&bmp_node);
install_default(BMP_NODE);
cmd_variable_handler_register(bmp_targets_var_handlers);
install_element(BGP_NODE, &bmp_targets_cmd);
install_element(BGP_NODE, &no_bmp_targets_cmd);