diff options
Diffstat (limited to 'vtysh/vtysh.c')
| -rw-r--r-- | vtysh/vtysh.c | 144 |
1 files changed, 110 insertions, 34 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index e25a576926..ef4d1a0835 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -45,6 +45,7 @@ #include "libfrr.h" #include "command_graph.h" #include "frrstr.h" +#include "json.h" DEFINE_MTYPE_STATIC(MVTYSH, VTYSH_CMD, "Vtysh cmd copy") @@ -134,6 +135,7 @@ struct vtysh_client vtysh_client[] = { {.fd = -1, .name = "watchfrr", .flag = VTYSH_WATCHFRR, .next = NULL}, {.fd = -1, .name = "pbrd", .flag = VTYSH_PBRD, .next = NULL}, {.fd = -1, .name = "staticd", .flag = VTYSH_STATICD, .next = NULL}, + {.fd = -1, .name = "bfdd", .flag = VTYSH_BFDD, .next = NULL}, }; enum vtysh_write_integrated vtysh_write_integrated = @@ -1254,6 +1256,18 @@ struct cmd_node link_params_node = { static struct cmd_node rpki_node = {RPKI_NODE, "%s(config-rpki)# ", 1}; #endif +#if HAVE_BFDD > 0 +static struct cmd_node bfd_node = { + BFD_NODE, + "%s(config-bfd)# ", +}; + +static struct cmd_node bfd_peer_node = { + BFD_PEER_NODE, + "%s(config-bfd-peer)# ", +}; +#endif /* HAVE_BFDD */ + /* Defined in lib/vty.c */ extern struct cmd_node vty_node; @@ -1680,6 +1694,32 @@ DEFUNSH(VTYSH_PBRD, vtysh_pbr_map, vtysh_pbr_map_cmd, return CMD_SUCCESS; } +#if HAVE_BFDD > 0 +DEFUNSH(VTYSH_BFDD, bfd_enter, bfd_enter_cmd, "bfd", "Configure BFD peers\n") +{ + vty->node = BFD_NODE; + return CMD_SUCCESS; +} + +DEFUNSH(VTYSH_BFDD, bfd_peer_enter, bfd_peer_enter_cmd, + "peer <A.B.C.D|X:X::X:X> [{multihop|local-address <A.B.C.D|X:X::X:X>|interface IFNAME|vrf NAME}]", + "Configure peer\n" + "IPv4 peer address\n" + "IPv6 peer address\n" + "Configure multihop\n" + "Configure local address\n" + "IPv4 local address\n" + "IPv6 local address\n" + INTERFACE_STR + "Configure interface name to use\n" + "Configure VRF\n" + "Configure VRF name\n") +{ + vty->node = BFD_PEER_NODE; + return CMD_SUCCESS; +} +#endif /* HAVE_BFDD */ + DEFSH(VTYSH_PBRD, vtysh_no_pbr_map_cmd, "no pbr-map WORD [seq (1-700)]", NO_STR "Delete pbr-map\n" @@ -1749,6 +1789,7 @@ static int vtysh_exit(struct vty *vty) case PBRMAP_NODE: case VTY_NODE: case KEYCHAIN_NODE: + case BFD_NODE: vtysh_execute("end"); vtysh_execute("configure terminal"); vty->node = CONFIG_NODE; @@ -1792,6 +1833,9 @@ static int vtysh_exit(struct vty *vty) case LINK_PARAMS_NODE: vty->node = INTERFACE_NODE; break; + case BFD_PEER_NODE: + vty->node = BFD_NODE; + break; default: break; } @@ -1988,6 +2032,17 @@ DEFUNSH(VTYSH_ISISD, vtysh_quit_isisd, vtysh_quit_isisd_cmd, "quit", return vtysh_exit_isisd(self, vty, argc, argv); } +#if HAVE_BFDD > 0 +DEFUNSH(VTYSH_BFDD, vtysh_exit_bfdd, vtysh_exit_bfdd_cmd, "exit", + "Exit current mode and down to previous mode\n") +{ + return vtysh_exit(vty); +} + +ALIAS(vtysh_exit_bfdd, vtysh_quit_bfdd_cmd, "quit", + "Exit current mode and down to previous mode\n") +#endif + DEFUNSH(VTYSH_ALL, vtysh_exit_line_vty, vtysh_exit_line_vty_cmd, "exit", "Exit current mode and down to previous mode\n") { @@ -2018,18 +2073,6 @@ DEFUNSH(VTYSH_ZEBRA, vtysh_pseudowire, vtysh_pseudowire_cmd, return CMD_SUCCESS; } -/* TODO Implement "no interface command in isisd. */ -DEFSH(VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_RIPNGD | VTYSH_OSPFD | VTYSH_OSPF6D - | VTYSH_EIGRPD, - vtysh_no_interface_cmd, "no interface IFNAME", NO_STR - "Delete a pseudo interface's configuration\n" - "Interface's name\n") - -DEFSH(VTYSH_ZEBRA, vtysh_no_interface_vrf_cmd, "no interface IFNAME vrf NAME", - NO_STR - "Delete a pseudo interface's configuration\n" - "Interface's name\n" VRF_CMD_HELP_STR) - DEFUNSH(VTYSH_ZEBRA, vtysh_logicalrouter, vtysh_logicalrouter_cmd, "logical-router (1-65535) ns NAME", "Enable a logical-router\n" @@ -2070,9 +2113,16 @@ DEFUNSH(VTYSH_VRF, vtysh_vrf, vtysh_vrf_cmd, "vrf NAME", return CMD_SUCCESS; } -DEFSH(VTYSH_ZEBRA, vtysh_no_vrf_cmd, "no vrf NAME", NO_STR - "Delete a pseudo vrf's configuration\n" - "VRF's name\n") +DEFSH(VTYSH_ZEBRA, vtysh_vrf_netns_cmd, + "netns NAME", + "Attach VRF to a Namespace\n" + "The file name in " NS_RUN_DIR ", or a full pathname\n") + +DEFSH(VTYSH_ZEBRA, vtysh_no_vrf_netns_cmd, + "no netns [NAME]", + NO_STR + "Detach VRF from a Namespace\n" + "The file name in " NS_RUN_DIR ", or a full pathname\n") DEFUNSH(VTYSH_NS, vtysh_exit_logicalrouter, vtysh_exit_logicalrouter_cmd, "exit", @@ -2112,19 +2162,6 @@ DEFUNSH(VTYSH_VRF, vtysh_quit_nexthop_group, vtysh_quit_nexthop_group_cmd, return vtysh_exit_nexthop_group(self, vty, argc, argv); } -/* - * TODO Implement interface description commands in ripngd, ospf6d - * and isisd. - */ -DEFSH(VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_OSPFD | VTYSH_EIGRPD, - vtysh_interface_desc_cmd, "description LINE...", - "Interface specific description\n" - "Characters describing this interface\n") - -DEFSH(VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_OSPFD | VTYSH_EIGRPD, - vtysh_no_interface_desc_cmd, "no description", - NO_STR "Interface specific description\n") - DEFUNSH(VTYSH_INTERFACE, vtysh_exit_interface, vtysh_exit_interface_cmd, "exit", "Exit current mode and down to previous mode\n") { @@ -2308,6 +2345,28 @@ DEFUN (vtysh_show_debugging_hashtable, "Hashtable statistics for %s:\n"); } +DEFUN (vtysh_show_error_code, + vtysh_show_error_code_cmd, + "show error <(1-4294967296)|all> [json]", + SHOW_STR + "Information on errors\n" + "Error code to get info about\n" + "Information on all errors\n" + JSON_STR) +{ + char *fcmd = argv_concat(argv, argc, 0); + char cmd[256]; + int rv; + + snprintf(cmd, sizeof(cmd), "do %s", fcmd); + + /* FIXME: Needs to determine which daemon to send to via code ranges */ + rv = show_per_daemon(cmd, ""); + + XFREE(MTYPE_TMP, fcmd); + return rv; +} + /* Memory */ DEFUN (vtysh_show_memory, vtysh_show_memory_cmd, @@ -3440,6 +3499,10 @@ void vtysh_init_vty(void) #if defined(HAVE_RPKI) install_node(&rpki_node, NULL); #endif +#if HAVE_BFDD > 0 + install_node(&bfd_node, NULL); + install_node(&bfd_peer_node, NULL); +#endif /* HAVE_BFDD */ struct cmd_node *node; for (unsigned int i = 0; i < vector_active(cmdvec); i++) { @@ -3534,6 +3597,21 @@ void vtysh_init_vty(void) install_element(RMAP_NODE, &vtysh_quit_rmap_cmd); install_element(PBRMAP_NODE, &vtysh_exit_pbr_map_cmd); install_element(PBRMAP_NODE, &vtysh_quit_pbr_map_cmd); +#if HAVE_BFDD > 0 + /* Enter node. */ + install_element(CONFIG_NODE, &bfd_enter_cmd); + install_element(BFD_NODE, &bfd_peer_enter_cmd); + + /* Exit/quit node. */ + install_element(BFD_NODE, &vtysh_exit_bfdd_cmd); + install_element(BFD_NODE, &vtysh_quit_bfdd_cmd); + install_element(BFD_PEER_NODE, &vtysh_exit_bfdd_cmd); + install_element(BFD_PEER_NODE, &vtysh_quit_bfdd_cmd); + + /* End/exit all. */ + install_element(BFD_NODE, &vtysh_end_all_cmd); + install_element(BFD_PEER_NODE, &vtysh_end_all_cmd); +#endif /* HAVE_BFDD */ install_element(VTY_NODE, &vtysh_exit_line_vty_cmd); install_element(VTY_NODE, &vtysh_quit_line_vty_cmd); @@ -3577,8 +3655,6 @@ void vtysh_init_vty(void) install_element(PBRMAP_NODE, &vtysh_end_all_cmd); install_element(VTY_NODE, &vtysh_end_all_cmd); - install_element(INTERFACE_NODE, &vtysh_interface_desc_cmd); - install_element(INTERFACE_NODE, &vtysh_no_interface_desc_cmd); install_element(INTERFACE_NODE, &vtysh_end_all_cmd); install_element(INTERFACE_NODE, &vtysh_exit_interface_cmd); install_element(LINK_PARAMS_NODE, &exit_link_params_cmd); @@ -3682,17 +3758,16 @@ void vtysh_init_vty(void) install_element(KEYCHAIN_NODE, &key_chain_cmd); install_element(KEYCHAIN_KEY_NODE, &key_chain_cmd); install_element(CONFIG_NODE, &vtysh_interface_cmd); - install_element(CONFIG_NODE, &vtysh_no_interface_cmd); - install_element(CONFIG_NODE, &vtysh_no_interface_vrf_cmd); install_element(CONFIG_NODE, &vtysh_pseudowire_cmd); install_element(INTERFACE_NODE, &vtysh_link_params_cmd); install_element(ENABLE_NODE, &vtysh_show_running_config_cmd); install_element(ENABLE_NODE, &vtysh_copy_running_config_cmd); + install_element(CONFIG_NODE, &vtysh_vrf_cmd); + install_element(VRF_NODE, &vtysh_vrf_netns_cmd); + install_element(VRF_NODE, &vtysh_no_vrf_netns_cmd); install_element(VRF_NODE, &exit_vrf_config_cmd); - install_element(CONFIG_NODE, &vtysh_vrf_cmd); - install_element(CONFIG_NODE, &vtysh_no_vrf_cmd); install_element(CONFIG_NODE, &vtysh_no_nexthop_group_cmd); /* "write terminal" command. */ @@ -3728,6 +3803,7 @@ void vtysh_init_vty(void) /* debugging */ install_element(VIEW_NODE, &vtysh_show_debugging_cmd); + install_element(VIEW_NODE, &vtysh_show_error_code_cmd); install_element(VIEW_NODE, &vtysh_show_debugging_hashtable_cmd); install_element(ENABLE_NODE, &vtysh_debug_all_cmd); install_element(CONFIG_NODE, &vtysh_debug_all_cmd); |
