diff options
| -rw-r--r-- | bgpd/bgp_clist.c | 64 | ||||
| -rw-r--r-- | bgpd/bgp_clist.h | 2 | ||||
| -rw-r--r-- | bgpd/bgp_route.c | 4 | ||||
| -rw-r--r-- | bgpd/bgp_vty.c | 2 |
4 files changed, 70 insertions, 2 deletions
diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c index fd8f51fed3..d6ac88c09b 100644 --- a/bgpd/bgp_clist.c +++ b/bgpd/bgp_clist.c @@ -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); +} diff --git a/bgpd/bgp_clist.h b/bgpd/bgp_clist.h index 632e1730cc..bb7c1363b2 100644 --- a/bgpd/bgp_clist.h +++ b/bgpd/bgp_clist.h @@ -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 */ diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 6039a91f7d..2b8a2eae3c 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -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\ >", diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 63b2fbd4e6..a031b78971 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -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 = { |
