mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-28 02:20:43 +00:00
Merge pull request #9350 from ton31337/feature/autocomplete_for_community_lists
bgpd: Auto-complete for community lists (show commands)
This commit is contained in:
commit
06dc3705b7
@ -1373,3 +1373,67 @@ void community_list_terminate(struct community_list_handler *ch)
|
||||
|
||||
XFREE(MTYPE_COMMUNITY_LIST_HANDLER, ch);
|
||||
}
|
||||
|
||||
static int bgp_community_list_vector_walker(struct hash_bucket *bucket,
|
||||
void *data)
|
||||
{
|
||||
vector *comps = data;
|
||||
struct community_list *list = bucket->data;
|
||||
|
||||
vector_set(*comps, XSTRDUP(MTYPE_COMPLETION, list->name));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void bgp_community_list_cmd_completion(vector comps,
|
||||
struct cmd_token *token)
|
||||
{
|
||||
struct community_list_master *cm;
|
||||
|
||||
cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER);
|
||||
|
||||
hash_walk(cm->hash, bgp_community_list_vector_walker, &comps);
|
||||
}
|
||||
|
||||
static void bgp_lcommunity_list_cmd_completion(vector comps,
|
||||
struct cmd_token *token)
|
||||
{
|
||||
struct community_list_master *cm;
|
||||
|
||||
cm = community_list_master_lookup(bgp_clist,
|
||||
LARGE_COMMUNITY_LIST_MASTER);
|
||||
|
||||
hash_walk(cm->hash, bgp_community_list_vector_walker, &comps);
|
||||
}
|
||||
|
||||
static void bgp_extcommunity_list_cmd_completion(vector comps,
|
||||
struct cmd_token *token)
|
||||
{
|
||||
struct community_list_master *cm;
|
||||
|
||||
cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER);
|
||||
|
||||
hash_walk(cm->hash, bgp_community_list_vector_walker, &comps);
|
||||
}
|
||||
|
||||
static const struct cmd_variable_handler community_list_handlers[] = {
|
||||
{.tokenname = "COMMUNITY_LIST_NAME",
|
||||
.completions = bgp_community_list_cmd_completion},
|
||||
{.completions = NULL}};
|
||||
|
||||
static const struct cmd_variable_handler lcommunity_list_handlers[] = {
|
||||
{.tokenname = "LCOMMUNITY_LIST_NAME",
|
||||
.completions = bgp_lcommunity_list_cmd_completion},
|
||||
{.completions = NULL}};
|
||||
|
||||
static const struct cmd_variable_handler extcommunity_list_handlers[] = {
|
||||
{.tokenname = "EXTCOMMUNITY_LIST_NAME",
|
||||
.completions = bgp_extcommunity_list_cmd_completion},
|
||||
{.completions = NULL}};
|
||||
|
||||
void bgp_community_list_command_completion_setup(void)
|
||||
{
|
||||
cmd_variable_handler_register(community_list_handlers);
|
||||
cmd_variable_handler_register(lcommunity_list_handlers);
|
||||
cmd_variable_handler_register(extcommunity_list_handlers);
|
||||
}
|
||||
|
@ -184,4 +184,6 @@ static inline uint32_t bgp_clist_hash_key(char *name)
|
||||
return jhash(name, strlen(name), 0xdeadbeaf);
|
||||
}
|
||||
|
||||
extern void bgp_community_list_command_completion_setup(void);
|
||||
|
||||
#endif /* _QUAGGA_BGP_CLIST_H */
|
||||
|
@ -11715,7 +11715,7 @@ static int bgp_show_lcommunity_list(struct vty *vty, struct bgp *bgp,
|
||||
|
||||
DEFUN (show_ip_bgp_large_community_list,
|
||||
show_ip_bgp_large_community_list_cmd,
|
||||
"show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] large-community-list <(1-500)|WORD> [exact-match] [json]",
|
||||
"show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> [exact-match] [json]",
|
||||
SHOW_STR
|
||||
IP_STR
|
||||
BGP_STR
|
||||
@ -11948,7 +11948,7 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
|
||||
|route-map WORD\
|
||||
|prefix-list WORD\
|
||||
|filter-list WORD\
|
||||
|community-list <(1-500)|WORD> [exact-match]\
|
||||
|community-list <(1-500)|COMMUNITY_LIST_NAME> [exact-match]\
|
||||
|A.B.C.D/M longer-prefixes\
|
||||
|X:X::X:X/M longer-prefixes\
|
||||
>",
|
||||
|
@ -19910,6 +19910,8 @@ static void community_list_vty(void)
|
||||
install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd);
|
||||
install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd);
|
||||
install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd);
|
||||
|
||||
bgp_community_list_command_completion_setup();
|
||||
}
|
||||
|
||||
static struct cmd_node community_alias_node = {
|
||||
|
Loading…
Reference in New Issue
Block a user