bgpd: autocomplete "router bgp" ASN

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2019-05-10 15:30:49 +02:00
parent 4a11bf2c09
commit 2ed9fe4a2b
2 changed files with 25 additions and 2 deletions

View File

@ -925,7 +925,7 @@ DEFUN (no_auto_summary,
/* "router bgp" commands. */
DEFUN_NOSH (router_bgp,
router_bgp_cmd,
"router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
"router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
ROUTER_STR
BGP_STR
AS_STR
@ -1015,7 +1015,7 @@ DEFUN_NOSH (router_bgp,
/* "no router bgp" commands. */
DEFUN (no_router_bgp,
no_router_bgp_cmd,
"no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
"no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
NO_STR
ROUTER_STR
BGP_STR

View File

@ -7878,8 +7878,31 @@ static void bgp_viewvrf_autocomplete(vector comps, struct cmd_token *token)
}
}
static void bgp_instasn_autocomplete(vector comps, struct cmd_token *token)
{
struct listnode *next, *next2;
struct bgp *bgp, *bgp2;
char buf[11];
for (ALL_LIST_ELEMENTS_RO(bm->bgp, next, bgp)) {
/* deduplicate */
for (ALL_LIST_ELEMENTS_RO(bm->bgp, next2, bgp2)) {
if (bgp2->as == bgp->as)
break;
if (bgp2 == bgp)
break;
}
if (bgp2 != bgp)
continue;
snprintf(buf, sizeof(buf), "%u", bgp->as);
vector_set(comps, XSTRDUP(MTYPE_COMPLETION, buf));
}
}
static const struct cmd_variable_handler bgp_viewvrf_var_handlers[] = {
{.tokenname = "VIEWVRFNAME", .completions = bgp_viewvrf_autocomplete},
{.varname = "instasn", .completions = bgp_instasn_autocomplete},
{.completions = NULL},
};