From: Donald Sharp Date: Wed, 5 Jun 2019 10:33:00 +0000 (-0400) Subject: lib, pbrd, sharpd, vtysh: Add autocompletion for 'nexthop-group' X-Git-Tag: frr-7.2~279^2~1 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=868ee86cec06cc85272cb38c81586f62ade50303;p=mirror_frr.git lib, pbrd, sharpd, vtysh: Add autocompletion for 'nexthop-group' Add some auto-completion for the nexthop-group command Signed-off-by: Donald Sharp --- diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c index ed22f6449..10f610db3 100644 --- a/lib/nexthop_group.c +++ b/lib/nexthop_group.c @@ -308,7 +308,7 @@ static void nhgc_delete(struct nexthop_group_cmd *nhgc) DEFINE_QOBJ_TYPE(nexthop_group_cmd) -DEFUN_NOSH(nexthop_group, nexthop_group_cmd, "nexthop-group NAME", +DEFUN_NOSH(nexthop_group, nexthop_group_cmd, "nexthop-group NHGNAME", "Enter into the nexthop-group submode\n" "Specify the NAME of the nexthop-group\n") { @@ -321,7 +321,7 @@ DEFUN_NOSH(nexthop_group, nexthop_group_cmd, "nexthop-group NAME", return CMD_SUCCESS; } -DEFUN_NOSH(no_nexthop_group, no_nexthop_group_cmd, "no nexthop-group NAME", +DEFUN_NOSH(no_nexthop_group, no_nexthop_group_cmd, "no nexthop-group NHGNAME", NO_STR "Delete the nexthop-group\n" "Specify the NAME of the nexthop-group\n") @@ -714,6 +714,19 @@ void nexthop_group_interface_state_change(struct interface *ifp, } } +static void nhg_name_autocomplete(vector comps, struct cmd_token *token) +{ + struct nexthop_group_cmd *nhgc; + + RB_FOREACH (nhgc, nhgc_entry_head, &nhgc_entries) { + vector_set(comps, XSTRDUP(MTYPE_COMPLETION, nhgc->name)); + } +} + +static const struct cmd_variable_handler nhg_name_handlers[] = { + {.tokenname = "NHGNAME", .completions = nhg_name_autocomplete}, + {.completions = NULL}}; + void nexthop_group_init(void (*new)(const char *name), void (*add_nexthop)(const struct nexthop_group_cmd *nhg, const struct nexthop *nhop), @@ -723,6 +736,8 @@ void nexthop_group_init(void (*new)(const char *name), { RB_INIT(nhgc_entry_head, &nhgc_entries); + cmd_variable_handler_register(nhg_name_handlers); + install_node(&nexthop_group_node, nexthop_group_write); install_element(CONFIG_NODE, &nexthop_group_cmd); install_element(CONFIG_NODE, &no_nexthop_group_cmd); diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c index 067d5c01f..8e1683565 100644 --- a/pbrd/pbr_vty.c +++ b/pbrd/pbr_vty.c @@ -172,7 +172,7 @@ DEFPY(pbr_map_match_dst, pbr_map_match_dst_cmd, } DEFPY(pbr_map_nexthop_group, pbr_map_nexthop_group_cmd, - "[no] set nexthop-group NAME$name", + "[no] set nexthop-group NHGNAME$name", NO_STR "Set for the PBR-MAP\n" "nexthop-group to use\n" diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c index fbcbbe3fd..31608dcdb 100644 --- a/sharpd/sharp_vty.c +++ b/sharpd/sharp_vty.c @@ -157,7 +157,7 @@ DEFPY (install_routes_data_dump, DEFPY (install_routes, install_routes_cmd, - "sharp install routes [vrf NAME$name] |nexthop-group NAME$nexthop_group> (1-1000000)$routes [instance (0-255)$instance] [repeat (2-1000)$rpt]", + "sharp install routes [vrf NAME$name] |nexthop-group NHGNAME$nexthop_group> (1-1000000)$routes [instance (0-255)$instance] [repeat (2-1000)$rpt]", "Sharp routing Protocol\n" "install some routes\n" "Routes to install\n" diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index baf77d1cb..05ffeecf1 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -2114,7 +2114,7 @@ DEFSH(VTYSH_ZEBRA, vtysh_no_logicalrouter_cmd, "The file name in " NS_RUN_DIR ", or a full pathname\n") DEFUNSH(VTYSH_PBRD | VTYSH_SHARPD, vtysh_nexthop_group, vtysh_nexthop_group_cmd, - "nexthop-group NAME", + "nexthop-group NHGNAME", "Nexthop Group configuration\n" "Name of the Nexthop Group\n") { @@ -2123,7 +2123,7 @@ DEFUNSH(VTYSH_PBRD | VTYSH_SHARPD, vtysh_nexthop_group, vtysh_nexthop_group_cmd, } DEFSH(VTYSH_PBRD | VTYSH_SHARPD, vtysh_no_nexthop_group_cmd, - "no nexthop-group NAME", + "no nexthop-group NHGNAME", NO_STR "Nexthop Group Configuration\n" "Name of the Nexthop Group\n")