From 62b346eefa1b9e09c9372f5b6376e1bca4162015 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Sat, 8 Sep 2018 21:46:23 +0200 Subject: *: clean up cmd_node initializers ... and use named assignments everywhere (so I can change the struct.) Signed-off-by: David Lamparter --- pimd/pim_cmd.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'pimd') diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index d6c500cdb..248fb9543 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -70,10 +70,16 @@ #endif static struct cmd_node interface_node = { - INTERFACE_NODE, "%s(config-if)# ", 1 /* vtysh ? yes */ + .node = INTERFACE_NODE, + .prompt = "%s(config-if)# ", + .vtysh = 1, }; -static struct cmd_node debug_node = {DEBUG_NODE, "", 1}; +static struct cmd_node debug_node = { + .node = DEBUG_NODE, + .prompt = "", + .vtysh = 1, +}; static struct vrf *pim_cmd_lookup_vrf(struct vty *vty, struct cmd_token *argv[], const int argc, int *idx) -- cgit v1.2.3 From 249a771b63505b24d2a8c05158d7692384811533 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Sat, 8 Sep 2018 22:00:24 +0200 Subject: *: remove cmd_node->vtysh The only nodes that have this as 0 don't have a "->func" anyway, so the entire thing is really just pointless. Signed-off-by: David Lamparter --- babeld/babel_interface.c | 1 - babeld/babeld.c | 1 - bfdd/bfdd_vty.c | 2 -- bgpd/bgp_debug.c | 1 - bgpd/bgp_dump.c | 1 - bgpd/bgp_filter.c | 1 - bgpd/bgp_rpki.c | 1 - bgpd/bgp_vty.c | 14 -------------- bgpd/rfapi/bgp_rfapi_cfg.c | 4 ---- bgpd/rfapi/vnc_debug.c | 1 - eigrpd/eigrp_cli.c | 2 -- eigrpd/eigrp_dump.c | 1 - isisd/isis_circuit.c | 1 - isisd/isisd.c | 2 -- ldpd/ldp_debug.c | 1 - ldpd/ldp_vty_conf.c | 7 ------- lib/agentx.c | 1 - lib/command.c | 4 +--- lib/command.h | 3 --- lib/filter.c | 3 --- lib/keychain.c | 2 -- lib/nexthop_group.c | 1 - lib/northbound_cli.c | 1 - lib/plist.c | 2 -- lib/resolver.c | 1 - lib/routemap.c | 1 - lib/routemap_cli.c | 1 - lib/vrf.c | 2 -- lib/vty.c | 1 - nhrpd/nhrp_vty.c | 2 -- ospf6d/ospf6_interface.c | 1 - ospf6d/ospf6_top.c | 1 - ospf6d/ospf6d.c | 1 - ospfd/ospf_dump.c | 1 - ospfd/ospf_vty.c | 2 -- pbrd/pbr_vty.c | 3 --- pimd/pim_cmd.c | 2 -- ripd/rip_debug.c | 1 - ripd/rip_interface.c | 1 - ripd/ripd.c | 1 - ripngd/ripng_debug.c | 1 - ripngd/ripng_interface.c | 1 - ripngd/ripngd.c | 1 - staticd/static_vty.c | 1 - vrrpd/vrrp_vty.c | 3 --- vtysh/vtysh.c | 1 - zebra/debug.c | 1 - zebra/dplane_fpm_nl.c | 1 - zebra/interface.c | 2 -- zebra/zebra_fpm.c | 1 - zebra/zebra_mpls_vty.c | 1 - zebra/zebra_pw.c | 1 - zebra/zebra_vty.c | 4 ---- 53 files changed, 1 insertion(+), 98 deletions(-) (limited to 'pimd') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index a009af320..ee7a06c8a 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -61,7 +61,6 @@ static vector babel_enable_if; /* enable interfaces (by cmd). */ static struct cmd_node babel_interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", - .vtysh = 1, }; diff --git a/babeld/babeld.c b/babeld/babeld.c index a7a348199..6d853c527 100644 --- a/babeld/babeld.c +++ b/babeld/babeld.c @@ -73,7 +73,6 @@ static struct cmd_node cmd_babel_node = { .node = BABEL_NODE, .prompt = "%s(config-router)# ", - .vtysh = 1, }; /* print current babel configuration on vty */ diff --git a/bfdd/bfdd_vty.c b/bfdd/bfdd_vty.c index fddefb750..ee0898d86 100644 --- a/bfdd/bfdd_vty.c +++ b/bfdd/bfdd_vty.c @@ -888,13 +888,11 @@ DEFUN_NOSH(show_debugging_bfd, struct cmd_node bfd_node = { .node = BFD_NODE, .prompt = "%s(config-bfd)# ", - .vtysh = 1, }; struct cmd_node bfd_peer_node = { .node = BFD_PEER_NODE, .prompt = "%s(config-bfd-peer)# ", - .vtysh = 1, }; static int bfdd_write_config(struct vty *vty) diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index 4cb86e38e..f2f4ebf92 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -2285,7 +2285,6 @@ static int bgp_config_write_debug(struct vty *vty) static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", - .vtysh = 1, }; void bgp_debug_init(void) diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index d5609e04e..498950f54 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -781,7 +781,6 @@ DEFUN (no_dump_bgp_all, static struct cmd_node bgp_dump_node = { .node = DUMP_NODE, .prompt = "", - .vtysh = 1, }; #if 0 diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c index 49912583d..2a19597e4 100644 --- a/bgpd/bgp_filter.c +++ b/bgpd/bgp_filter.c @@ -670,7 +670,6 @@ static int config_write_as_list(struct vty *vty) static struct cmd_node as_list_node = { .node = AS_LIST_NODE, .prompt = "", - .vtysh = 1, }; /* Register functions. */ diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c index d626d731f..49d3f25ae 100644 --- a/bgpd/bgp_rpki.c +++ b/bgpd/bgp_rpki.c @@ -146,7 +146,6 @@ static int rpki_sync_socket_bgpd; static struct cmd_node rpki_node = { .node = RPKI_NODE, .prompt = "%s(config-rpki)# ", - .vtysh = 1, }; static const struct route_map_rule_cmd route_match_rpki_cmd = { "rpki", route_match, route_match_compile, route_match_free}; diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 6700b632a..a9123abd1 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -15337,79 +15337,66 @@ int bgp_config_write(struct vty *vty) static struct cmd_node bgp_node = { .node = BGP_NODE, .prompt = "%s(config-router)# ", - .vtysh = 1, }; static struct cmd_node bgp_ipv4_unicast_node = { .node = BGP_IPV4_NODE, .prompt = "%s(config-router-af)# ", - .vtysh = 1, }; static struct cmd_node bgp_ipv4_multicast_node = { .node = BGP_IPV4M_NODE, .prompt = "%s(config-router-af)# ", - .vtysh = 1, }; static struct cmd_node bgp_ipv4_labeled_unicast_node = { .node = BGP_IPV4L_NODE, .prompt = "%s(config-router-af)# ", - .vtysh = 1, }; static struct cmd_node bgp_ipv6_unicast_node = { .node = BGP_IPV6_NODE, .prompt = "%s(config-router-af)# ", - .vtysh = 1, }; static struct cmd_node bgp_ipv6_multicast_node = { .node = BGP_IPV6M_NODE, .prompt = "%s(config-router-af)# ", - .vtysh = 1, }; static struct cmd_node bgp_ipv6_labeled_unicast_node = { .node = BGP_IPV6L_NODE, .prompt = "%s(config-router-af)# ", - .vtysh = 1, }; static struct cmd_node bgp_vpnv4_node = { .node = BGP_VPNV4_NODE, .prompt = "%s(config-router-af)# ", - .vtysh = 1, }; static struct cmd_node bgp_vpnv6_node = { .node = BGP_VPNV6_NODE, .prompt = "%s(config-router-af-vpnv6)# ", - .vtysh = 1, }; static struct cmd_node bgp_evpn_node = { .node = BGP_EVPN_NODE, .prompt = "%s(config-router-evpn)# ", - .vtysh = 1, }; static struct cmd_node bgp_evpn_vni_node = { .node = BGP_EVPN_VNI_NODE, .prompt = "%s(config-router-af-vni)# ", - .vtysh = 1, }; static struct cmd_node bgp_flowspecv4_node = { .node = BGP_FLOWSPECV4_NODE, .prompt = "%s(config-router-af)# ", - .vtysh = 1, }; static struct cmd_node bgp_flowspecv6_node = { .node = BGP_FLOWSPECV6_NODE, .prompt = "%s(config-router-af-vpnv6)# ", - .vtysh = 1, }; static void community_list_vty(void); @@ -17893,7 +17880,6 @@ static int community_list_config_write(struct vty *vty) static struct cmd_node community_list_node = { .node = COMMUNITY_LIST_NODE, .prompt = "", - .vtysh = 1, }; static void community_list_vty(void) diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index 6f949775f..e9b7ae1c6 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -2967,13 +2967,11 @@ DEFUN_NOSH (exit_vnc, static struct cmd_node bgp_vnc_defaults_node = { .node = BGP_VNC_DEFAULTS_NODE, .prompt = "%s(config-router-vnc-defaults)# ", - .vtysh = 1, }; static struct cmd_node bgp_vnc_nve_group_node = { .node = BGP_VNC_NVE_GROUP_NODE, .prompt = "%s(config-router-vnc-nve-group)# ", - .vtysh = 1, }; /*------------------------------------------------------------------------- @@ -3396,7 +3394,6 @@ DEFUN_NOSH (exit_vrf_policy, static struct cmd_node bgp_vrf_policy_node = { .node = BGP_VRF_POLICY_NODE, .prompt = "%s(config-router-vrf-policy)# ", - .vtysh = 1, }; /*------------------------------------------------------------------------- @@ -3635,7 +3632,6 @@ DEFUN (vnc_l2_group_rt, static struct cmd_node bgp_vnc_l2_group_node = { .node = BGP_VNC_L2_GROUP_NODE, .prompt = "%s(config-router-vnc-l2-group)# ", - .vtysh = 1, }; struct rfapi_l2_group_cfg * diff --git a/bgpd/rfapi/vnc_debug.c b/bgpd/rfapi/vnc_debug.c index abc97786b..9a2ab9bb5 100644 --- a/bgpd/rfapi/vnc_debug.c +++ b/bgpd/rfapi/vnc_debug.c @@ -176,7 +176,6 @@ static int bgp_vnc_config_write_debug(struct vty *vty) static struct cmd_node debug_node = { .node = DEBUG_VNC_NODE, .prompt = "", - .vtysh = 1, }; void vnc_debug_init(void) diff --git a/eigrpd/eigrp_cli.c b/eigrpd/eigrp_cli.c index 9b7d65c9c..6d324d47e 100644 --- a/eigrpd/eigrp_cli.c +++ b/eigrpd/eigrp_cli.c @@ -841,7 +841,6 @@ void eigrp_cli_show_keychain(struct vty *vty, struct lyd_node *dnode, static struct cmd_node eigrp_node = { .node = EIGRP_NODE, .prompt = "%s(config-router)# ", - .vtysh = 1, }; static int eigrp_config_write(struct vty *vty) @@ -861,7 +860,6 @@ static int eigrp_config_write(struct vty *vty) static struct cmd_node eigrp_interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", - .vtysh = 1, }; diff --git a/eigrpd/eigrp_dump.c b/eigrpd/eigrp_dump.c index c37e0fae5..3aaac4f53 100644 --- a/eigrpd/eigrp_dump.c +++ b/eigrpd/eigrp_dump.c @@ -558,7 +558,6 @@ DEFUN (no_debug_eigrp_packets, static struct cmd_node eigrp_debug_node = { .node = DEBUG_NODE, .prompt = "", - .vtysh = 1, }; /* Initialize debug commands. */ diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index 2d3bd89fa..24d0408e3 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -1338,7 +1338,6 @@ ferr_r isis_circuit_passwd_hmac_md5_set(struct isis_circuit *circuit, struct cmd_node interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", - .vtysh = 1, }; void isis_circuit_circ_type_set(struct isis_circuit *circuit, int circ_type) diff --git a/isisd/isisd.c b/isisd/isisd.c index b56f88982..3341bd441 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -788,7 +788,6 @@ DEFUN_NOSH (show_debugging, static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", - .vtysh = 1, }; static int config_write_debug(struct vty *vty) @@ -2148,7 +2147,6 @@ int isis_config_write(struct vty *vty) struct cmd_node router_node = { .node = ROUTER_NODE, .prompt = "%s(config-router)# ", - .vtysh = 1, }; void isis_init(void) diff --git a/ldpd/ldp_debug.c b/ldpd/ldp_debug.c index 78d40b8ff..77ec8c699 100644 --- a/ldpd/ldp_debug.c +++ b/ldpd/ldp_debug.c @@ -33,7 +33,6 @@ struct ldp_debug ldp_debug; struct cmd_node ldp_debug_node = { .node = DEBUG_NODE, .prompt = "", - .vtysh = 1, }; int diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c index 3b8c3404e..dcea6e892 100644 --- a/ldpd/ldp_vty_conf.c +++ b/ldpd/ldp_vty_conf.c @@ -40,43 +40,36 @@ static int ldp_iface_is_configured(struct ldpd_conf *, const char *); struct cmd_node ldp_node = { .node = LDP_NODE, .prompt = "%s(config-ldp)# ", - .vtysh = 1, }; struct cmd_node ldp_ipv4_node = { .node = LDP_IPV4_NODE, .prompt = "%s(config-ldp-af)# ", - .vtysh = 1, }; struct cmd_node ldp_ipv6_node = { .node = LDP_IPV6_NODE, .prompt = "%s(config-ldp-af)# ", - .vtysh = 1, }; struct cmd_node ldp_ipv4_iface_node = { .node = LDP_IPV4_IFACE_NODE, .prompt = "%s(config-ldp-af-if)# ", - .vtysh = 1, }; struct cmd_node ldp_ipv6_iface_node = { .node = LDP_IPV6_IFACE_NODE, .prompt = "%s(config-ldp-af-if)# ", - .vtysh = 1, }; struct cmd_node ldp_l2vpn_node = { .node = LDP_L2VPN_NODE, .prompt = "%s(config-l2vpn)# ", - .vtysh = 1, }; struct cmd_node ldp_pseudowire_node = { .node = LDP_PSEUDOWIRE_NODE, .prompt = "%s(config-l2vpn-pw)# ", - .vtysh = 1, }; int diff --git a/lib/agentx.c b/lib/agentx.c index 0215affd9..8ce154524 100644 --- a/lib/agentx.c +++ b/lib/agentx.c @@ -161,7 +161,6 @@ static void agentx_events_update(void) static struct cmd_node agentx_node = { .node = SMUX_NODE, .prompt = "", - .vtysh = 1, }; /* Logging NetSNMP messages */ diff --git a/lib/command.c b/lib/command.c index 85ccbbf19..a26ec1a26 100644 --- a/lib/command.c +++ b/lib/command.c @@ -203,7 +203,6 @@ static struct cmd_node enable_node = { static struct cmd_node config_node = { .node = CONFIG_NODE, .prompt = "%s(config)# ", - .vtysh = 1, }; static const struct facility_map { @@ -1724,8 +1723,7 @@ static int vty_write_config(struct vty *vty) vty_out(vty, "!\n"); for (i = 0; i < vector_active(cmdvec); i++) - if ((node = vector_slot(cmdvec, i)) && node->func - && (node->vtysh || vty->type != VTY_SHELL)) { + if ((node = vector_slot(cmdvec, i)) && node->func) { if ((*node->func)(vty)) vty_out(vty, "!\n"); } diff --git a/lib/command.h b/lib/command.h index ea8a76a96..06c7ce7b4 100644 --- a/lib/command.h +++ b/lib/command.h @@ -176,9 +176,6 @@ struct cmd_node { /* Prompt character at vty interface. */ const char *prompt; - /* Is this node's configuration goes to vtysh ? */ - int vtysh; - /* Node's configuration write function */ int (*func)(struct vty *); diff --git a/lib/filter.c b/lib/filter.c index 381f9829b..5665dd82b 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -2815,7 +2815,6 @@ static int config_write_access(struct vty *vty, afi_t afi) static struct cmd_node access_mac_node = { .node = ACCESS_MAC_NODE, .prompt = "", - .vtysh = 1, }; static int config_write_access_mac(struct vty *vty) @@ -2868,7 +2867,6 @@ static void access_list_init_mac(void) static struct cmd_node access_node = { .node = ACCESS_NODE, .prompt = "", - .vtysh = 1, }; static int config_write_access_ipv4(struct vty *vty) @@ -2955,7 +2953,6 @@ static void access_list_init_ipv4(void) static struct cmd_node access_ipv6_node = { .node = ACCESS_IPV6_NODE, .prompt = "", - .vtysh = 1, }; static int config_write_access_ipv6(struct vty *vty) diff --git a/lib/keychain.c b/lib/keychain.c index c0af630c4..c66c1de07 100644 --- a/lib/keychain.c +++ b/lib/keychain.c @@ -962,13 +962,11 @@ DEFUN (no_send_lifetime, static struct cmd_node keychain_node = { .node = KEYCHAIN_NODE, .prompt = "%s(config-keychain)# ", - .vtysh = 1, }; static struct cmd_node keychain_key_node = { .node = KEYCHAIN_KEY_NODE, .prompt = "%s(config-keychain-key)# ", - .vtysh = 1, }; static int keychain_strftime(char *buf, int bufsiz, time_t *time) diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c index 7c7914a72..95087fe30 100644 --- a/lib/nexthop_group.c +++ b/lib/nexthop_group.c @@ -936,7 +936,6 @@ DEFPY(ecmp_nexthops, ecmp_nexthops_cmd, static struct cmd_node nexthop_group_node = { .node = NH_GROUP_NODE, .prompt = "%s(config-nh-group)# ", - .vtysh = 1, }; void nexthop_group_write_nexthop(struct vty *vty, struct nexthop *nh) diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c index 9c001a3b0..5803dbd78 100644 --- a/lib/northbound_cli.c +++ b/lib/northbound_cli.c @@ -1677,7 +1677,6 @@ static struct debug_callbacks nb_dbg_cbs = {.debug_set_all = nb_debug_set_all}; static struct cmd_node nb_debug_node = { .node = NORTHBOUND_DEBUG_NODE, .prompt = "", - .vtysh = 1, }; void nb_cli_install_default(int node) diff --git a/lib/plist.c b/lib/plist.c index 15a79a1cd..8f2389a32 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -2048,7 +2048,6 @@ static void prefix_list_reset_afi(afi_t afi, int orf) static struct cmd_node prefix_node = { .node = PREFIX_NODE, .prompt = "", - .vtysh = 1, }; static int config_write_prefix_ipv4(struct vty *vty) @@ -2113,7 +2112,6 @@ static void prefix_list_init_ipv4(void) static struct cmd_node prefix_ipv6_node = { .node = PREFIX_IPV6_NODE, .prompt = "", - .vtysh = 1, }; static int config_write_prefix_ipv6(struct vty *vty) diff --git a/lib/resolver.c b/lib/resolver.c index 83e2f5269..9005ee527 100644 --- a/lib/resolver.c +++ b/lib/resolver.c @@ -248,7 +248,6 @@ DEFUN(debug_resolver, static struct cmd_node resolver_debug_node = { .node = RESOLVER_DEBUG_NODE, .prompt = "", - .vtysh = 1, }; static int resolver_config_write_debug(struct vty *vty) diff --git a/lib/routemap.c b/lib/routemap.c index dc73b1e0d..41057c870 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -3018,7 +3018,6 @@ DEFUN (no_debug_rmap, static struct cmd_node rmap_debug_node = { .node = RMAP_DEBUG_NODE, .prompt = "", - .vtysh = 1, }; /* Configuration write function. */ diff --git a/lib/routemap_cli.c b/lib/routemap_cli.c index b7db1d4dd..a53c54291 100644 --- a/lib/routemap_cli.c +++ b/lib/routemap_cli.c @@ -1067,7 +1067,6 @@ static int route_map_config_write(struct vty *vty) static struct cmd_node rmap_node = { .node = RMAP_NODE, .prompt = "%s(config-route-map)# ", - .vtysh = 1, }; static void rmap_autocomplete(vector comps, struct cmd_token *token) diff --git a/lib/vrf.c b/lib/vrf.c index 52923a5cd..fbc45fa18 100644 --- a/lib/vrf.c +++ b/lib/vrf.c @@ -761,7 +761,6 @@ DEFUN (no_vrf, static struct cmd_node vrf_node = { .node = VRF_NODE, .prompt = "%s(config-vrf)# ", - .vtysh = 1, }; DEFUN_NOSH (vrf_netns, @@ -855,7 +854,6 @@ static int vrf_write_host(struct vty *vty) static struct cmd_node vrf_debug_node = { .node = VRF_DEBUG_NODE, .prompt = "", - .vtysh = 1, }; void vrf_install_commands(void) diff --git a/lib/vty.c b/lib/vty.c index 57350ea89..5b86455f6 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -2992,7 +2992,6 @@ static int vty_config_write(struct vty *vty) struct cmd_node vty_node = { .node = VTY_NODE, .prompt = "%s(config-line)# ", - .vtysh = 1, }; /* Reset all VTY status. */ diff --git a/nhrpd/nhrp_vty.c b/nhrpd/nhrp_vty.c index cc35f09aa..69be4db90 100644 --- a/nhrpd/nhrp_vty.c +++ b/nhrpd/nhrp_vty.c @@ -20,13 +20,11 @@ static struct cmd_node zebra_node = { .node = ZEBRA_NODE, .prompt = "%s(config-router)# ", - .vtysh = 1, }; static struct cmd_node nhrp_interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", - .vtysh = 1, }; #define NHRP_DEBUG_FLAGS_CMD "" diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index a0dd396cc..2bcaccc42 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -1946,7 +1946,6 @@ static int config_write_ospf6_interface(struct vty *vty) static struct cmd_node interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", - .vtysh = 1, }; static int ospf6_ifp_create(struct interface *ifp) diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index 2f646ce44..ae7ecb55a 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -1116,7 +1116,6 @@ static int config_write_ospf6(struct vty *vty) static struct cmd_node ospf6_node = { .node = OSPF6_NODE, .prompt = "%s(config-ospf6)# ", - .vtysh = 1, }; /* Install ospf related commands. */ diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c index 1beadca79..8e5406642 100644 --- a/ospf6d/ospf6d.c +++ b/ospf6d/ospf6d.c @@ -72,7 +72,6 @@ struct route_node *route_prev(struct route_node *node) static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", - .vtysh = 1, }; static int config_write_ospf6_debug(struct vty *vty) diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index fda96a80d..6640c7c48 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -1644,7 +1644,6 @@ DEFUN_NOSH (show_debugging_ospf_instance, static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", - .vtysh = 1, }; static int config_write_debug(struct vty *vty) diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index c2b08cab7..b95a98476 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -10559,7 +10559,6 @@ void ospf_vty_show_init(void) static struct cmd_node interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", - .vtysh = 1, }; /* Initialization of OSPF interface. */ @@ -10675,7 +10674,6 @@ static void ospf_vty_zebra_init(void) static struct cmd_node ospf_node = { .node = OSPF_NODE, .prompt = "%s(config-router)# ", - .vtysh = 1, }; static void ospf_interface_clear(struct interface *ifp) diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c index 0ef856bd0..a60d29e51 100644 --- a/pbrd/pbr_vty.c +++ b/pbrd/pbr_vty.c @@ -680,7 +680,6 @@ DEFPY (show_pbr_interface, static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", - .vtysh = 1, }; DEFPY(debug_pbr, @@ -732,7 +731,6 @@ DEFUN_NOSH(show_debugging_pbr, static struct cmd_node interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", - .vtysh = 1, }; static int pbr_interface_config_write(struct vty *vty) @@ -764,7 +762,6 @@ static int pbr_interface_config_write(struct vty *vty) static struct cmd_node pbr_map_node = { .node = PBRMAP_NODE, .prompt = "%s(config-pbr-map)# ", - .vtysh = 1, }; static int pbr_vty_map_config_write_sequence(struct vty *vty, diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 248fb9543..3b590230c 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -72,13 +72,11 @@ static struct cmd_node interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", - .vtysh = 1, }; static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", - .vtysh = 1, }; static struct vrf *pim_cmd_lookup_vrf(struct vty *vty, struct cmd_token *argv[], diff --git a/ripd/rip_debug.c b/ripd/rip_debug.c index fe6b534c9..72cd0c62f 100644 --- a/ripd/rip_debug.c +++ b/ripd/rip_debug.c @@ -176,7 +176,6 @@ DEFUN (no_debug_rip_zebra, static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", - .vtysh = 1, }; static int config_write_debug(struct vty *vty) diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index 99b7c78d6..10e23787e 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -1196,7 +1196,6 @@ int rip_show_network_config(struct vty *vty, struct rip *rip) static struct cmd_node interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", - .vtysh = 1, }; void rip_interface_sync(struct interface *ifp) diff --git a/ripd/ripd.c b/ripd/ripd.c index ecb3fa2d3..95ea19a98 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -3331,7 +3331,6 @@ static int config_write_rip(struct vty *vty) static struct cmd_node rip_node = { .node = RIP_NODE, .prompt = "%s(config-router)# ", - .vtysh = 1, }; /* Distribute-list update functions. */ diff --git a/ripngd/ripng_debug.c b/ripngd/ripng_debug.c index fe4ec256b..24da4b005 100644 --- a/ripngd/ripng_debug.c +++ b/ripngd/ripng_debug.c @@ -178,7 +178,6 @@ DEFUN (no_debug_ripng_zebra, static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", - .vtysh = 1, }; static int config_write_debug(struct vty *vty) diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c index d322a6ddb..3fac88514 100644 --- a/ripngd/ripng_interface.c +++ b/ripngd/ripng_interface.c @@ -958,7 +958,6 @@ static int interface_config_write(struct vty *vty) static struct cmd_node interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", - .vtysh = 1, }; /* Initialization of interface. */ diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index 12f8b268f..ad40c0b13 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -2438,7 +2438,6 @@ static int ripng_config_write(struct vty *vty) static struct cmd_node cmd_ripng_node = { .node = RIPNG_NODE, .prompt = "%s(config-router)# ", - .vtysh = 1, }; static void ripng_distribute_update(struct distribute_ctx *ctx, diff --git a/staticd/static_vty.c b/staticd/static_vty.c index 82d8997da..05c5f7cfe 100644 --- a/staticd/static_vty.c +++ b/staticd/static_vty.c @@ -1473,7 +1473,6 @@ DEFUN_NOSH (show_debugging_static, static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", - .vtysh = 1, }; void static_vty_init(void) diff --git a/vrrpd/vrrp_vty.c b/vrrpd/vrrp_vty.c index 98e0e598e..e1dd0a2d4 100644 --- a/vrrpd/vrrp_vty.c +++ b/vrrpd/vrrp_vty.c @@ -747,19 +747,16 @@ static int vrrp_config_write_interface(struct vty *vty) static struct cmd_node interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", - .vtysh = 1, }; static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", - .vtysh = 1, }; static struct cmd_node vrrp_node = { .node = VRRP_NODE, .prompt = "", - .vtysh = 1, }; void vrrp_vty_init(void) diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index b8fd31142..563914af4 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -1390,7 +1390,6 @@ struct cmd_node link_params_node = { static struct cmd_node rpki_node = { .node = RPKI_NODE, .prompt = "%s(config-rpki)# ", - .vtysh = 1, }; #if HAVE_BFDD > 0 diff --git a/zebra/debug.c b/zebra/debug.c index 6e177f839..f7ad228a1 100644 --- a/zebra/debug.c +++ b/zebra/debug.c @@ -474,7 +474,6 @@ DEFPY (debug_zebra_nexthop, struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", - .vtysh = 1, }; static int config_write_debug(struct vty *vty) diff --git a/zebra/dplane_fpm_nl.c b/zebra/dplane_fpm_nl.c index a697a306b..f3bc670a1 100644 --- a/zebra/dplane_fpm_nl.c +++ b/zebra/dplane_fpm_nl.c @@ -371,7 +371,6 @@ static int fpm_write_config(struct vty *vty) struct cmd_node fpm_node = { .node = VTY_NODE, .prompt = "", - .vtysh = 1, }; /* diff --git a/zebra/interface.c b/zebra/interface.c index 520d6a336..e330c4c84 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -1667,7 +1667,6 @@ static void interface_update_stats(void) struct cmd_node interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", - .vtysh = 1, }; #ifndef VTYSH_EXTRACT_PL @@ -2080,7 +2079,6 @@ DEFUN (no_bandwidth_if, struct cmd_node link_params_node = { .node = LINK_PARAMS_NODE, .prompt = "%s(config-link-params)# ", - .vtysh = 1, }; static void link_param_cmd_set_uint32(struct interface *ifp, uint32_t *field, diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index d0e193317..03ad89dcb 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -1942,7 +1942,6 @@ static int fpm_remote_srv_write(struct vty *vty) static struct cmd_node zebra_node = { .node = ZEBRA_NODE, .prompt = "", - .vtysh = 1, }; diff --git a/zebra/zebra_mpls_vty.c b/zebra/zebra_mpls_vty.c index 78a3110ea..9137f3882 100644 --- a/zebra/zebra_mpls_vty.c +++ b/zebra/zebra_mpls_vty.c @@ -453,7 +453,6 @@ DEFUN (no_mpls_label_global_block, static struct cmd_node mpls_node = { .node = MPLS_NODE, .prompt = "", - .vtysh = 1, }; /* MPLS VTY. */ diff --git a/zebra/zebra_pw.c b/zebra/zebra_pw.c index d16082c51..16f39cd0c 100644 --- a/zebra/zebra_pw.c +++ b/zebra/zebra_pw.c @@ -550,7 +550,6 @@ static int zebra_pw_config(struct vty *vty) static struct cmd_node pw_node = { .node = PW_NODE, .prompt = "%s(config-pw)# ", - .vtysh = 1, }; void zebra_pw_vty_init(void) diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index d663e4c5a..c3199bcb5 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -3481,23 +3481,19 @@ DEFUN_HIDDEN (show_frr, static struct cmd_node ip_node = { .node = IP_NODE, .prompt = "", - .vtysh = 1, }; static struct cmd_node protocol_node = { .node = PROTOCOL_NODE, .prompt = "", - .vtysh = 1, }; /* table node for routing tables. */ static struct cmd_node table_node = { .node = TABLE_NODE, .prompt = "", - .vtysh = 1, }; static struct cmd_node forwarding_node = { .node = FORWARDING_NODE, .prompt = "", - .vtysh = 1, }; /* Route VTY. */ -- cgit v1.2.3 From 612c2c15d86e0e5c7e35f1a9a1491f90f365b93c Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Sat, 8 Sep 2018 22:31:43 +0200 Subject: *: remove second parameter on install_node() There is really no reason to not put this in the cmd_node. And while we're add it, rename from pointless ".func" to ".config_write". [v2: fix forgotten ldpd config_write] Signed-off-by: David Lamparter --- babeld/babel_interface.c | 4 +- babeld/babeld.c | 4 +- bfdd/bfdd_vty.c | 6 ++- bgpd/bgp_bmp.c | 2 +- bgpd/bgp_debug.c | 4 +- bgpd/bgp_dump.c | 4 +- bgpd/bgp_filter.c | 4 +- bgpd/bgp_rpki.c | 3 +- bgpd/bgp_vty.c | 31 +++++++------- bgpd/rfapi/bgp_rfapi_cfg.c | 8 ++-- bgpd/rfapi/vnc_debug.c | 4 +- eigrpd/eigrp_cli.c | 8 +++- eigrpd/eigrp_dump.c | 4 +- isisd/isis_circuit.c | 8 ++-- isisd/isisd.c | 12 +++--- ldpd/ldp_debug.c | 5 ++- ldpd/ldp_vty.h | 3 -- ldpd/ldp_vty_cmds.c | 16 ++++---- ldpd/ldp_vty_conf.c | 8 +++- lib/agentx.c | 4 +- lib/command.c | 19 ++++----- lib/command.h | 4 +- lib/filter.c | 12 ++++-- lib/keychain.c | 6 ++- lib/nexthop_group.c | 4 +- lib/northbound_cli.c | 3 +- lib/plist.c | 8 +++- lib/resolver.c | 4 +- lib/routemap.c | 4 +- lib/routemap_cli.c | 4 +- lib/vrf.c | 7 +++- lib/vty.c | 4 +- nhrpd/nhrp_vty.c | 8 +++- ospf6d/ospf6_interface.c | 4 +- ospf6d/ospf6_top.c | 4 +- ospf6d/ospf6d.c | 4 +- ospfd/ospf_dump.c | 4 +- ospfd/ospf_vty.c | 8 +++- pbrd/pbr_vty.c | 13 +++--- pimd/pim_cmd.c | 7 ++-- ripd/rip_debug.c | 4 +- ripd/rip_interface.c | 4 +- ripd/ripd.c | 4 +- ripngd/ripng_debug.c | 4 +- ripngd/ripng_interface.c | 4 +- ripngd/ripngd.c | 4 +- staticd/static_vty.c | 3 +- tests/lib/cli/test_commands.c | 34 ++++++++-------- vrrpd/vrrp_vty.c | 9 +++-- vtysh/vtysh.c | 94 +++++++++++++++++++++---------------------- zebra/debug.c | 4 +- zebra/dplane_fpm_nl.c | 5 ++- zebra/interface.c | 6 ++- zebra/zebra_fpm.c | 4 +- zebra/zebra_mpls_vty.c | 4 +- zebra/zebra_pw.c | 4 +- zebra/zebra_vty.c | 16 ++++++-- 57 files changed, 297 insertions(+), 183 deletions(-) (limited to 'pimd') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index ee7a06c8a..4360ec8e8 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -58,9 +58,11 @@ static void babel_interface_free (babel_interface_nfo *bi); static vector babel_enable_if; /* enable interfaces (by cmd). */ +static int interface_config_write(struct vty *vty); static struct cmd_node babel_interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", + .config_write = interface_config_write, }; @@ -1245,7 +1247,7 @@ babel_if_init(void) babel_enable_if = vector_init (1); /* install interface node and commands */ - install_node (&babel_interface_node, interface_config_write); + install_node(&babel_interface_node); if_cmd_init(); install_element(BABEL_NODE, &babel_network_cmd); diff --git a/babeld/babeld.c b/babeld/babeld.c index 6d853c527..2eaa9c968 100644 --- a/babeld/babeld.c +++ b/babeld/babeld.c @@ -69,10 +69,12 @@ static time_t expiry_time; static time_t source_expiry_time; /* Babel node structure. */ +static int babel_config_write (struct vty *vty); static struct cmd_node cmd_babel_node = { .node = BABEL_NODE, .prompt = "%s(config-router)# ", + .config_write = babel_config_write, }; /* print current babel configuration on vty */ @@ -718,7 +720,7 @@ void babeld_quagga_init(void) { - install_node(&cmd_babel_node, &babel_config_write); + install_node(&cmd_babel_node); install_element(CONFIG_NODE, &router_babel_cmd); install_element(CONFIG_NODE, &no_router_babel_cmd); diff --git a/bfdd/bfdd_vty.c b/bfdd/bfdd_vty.c index ee0898d86..62a0016a1 100644 --- a/bfdd/bfdd_vty.c +++ b/bfdd/bfdd_vty.c @@ -885,9 +885,11 @@ DEFUN_NOSH(show_debugging_bfd, return CMD_SUCCESS; } +static int bfdd_write_config(struct vty *vty); struct cmd_node bfd_node = { .node = BFD_NODE, .prompt = "%s(config-bfd)# ", + .config_write = bfdd_write_config, }; struct cmd_node bfd_peer_node = { @@ -943,11 +945,11 @@ void bfdd_vty_init(void) install_element(CONFIG_NODE, &bfd_debug_network_cmd); /* Install BFD node and commands. */ - install_node(&bfd_node, bfdd_write_config); + install_node(&bfd_node); install_default(BFD_NODE); /* Install BFD peer node. */ - install_node(&bfd_peer_node, NULL); + install_node(&bfd_peer_node); install_default(BFD_PEER_NODE); bfdd_cli_init(); diff --git a/bgpd/bgp_bmp.c b/bgpd/bgp_bmp.c index 871a693bc..7a97ff19d 100644 --- a/bgpd/bgp_bmp.c +++ b/bgpd/bgp_bmp.c @@ -2269,7 +2269,7 @@ static int bmp_config_write(struct bgp *bgp, struct vty *vty) static int bgp_bmp_init(struct thread_master *tm) { - install_node(&bmp_node, NULL); + install_node(&bmp_node); install_default(BMP_NODE); install_element(BGP_NODE, &bmp_targets_cmd); install_element(BGP_NODE, &no_bmp_targets_cmd); diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index f2f4ebf92..a20015bbc 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -2282,14 +2282,16 @@ static int bgp_config_write_debug(struct vty *vty) return write; } +static int bgp_config_write_debug(struct vty *vty); static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", + .config_write = bgp_config_write_debug, }; void bgp_debug_init(void) { - install_node(&debug_node, bgp_config_write_debug); + install_node(&debug_node); install_element(ENABLE_NODE, &show_debugging_bgp_cmd); diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index 498950f54..36efcd538 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -777,10 +777,12 @@ DEFUN (no_dump_bgp_all, return bgp_dump_unset(bgp_dump_struct); } +static int config_write_bgp_dump(struct vty *vty); /* BGP node structure. */ static struct cmd_node bgp_dump_node = { .node = DUMP_NODE, .prompt = "", + .config_write = config_write_bgp_dump, }; #if 0 @@ -860,7 +862,7 @@ void bgp_dump_init(void) stream_new((BGP_MAX_PACKET_SIZE << 1) + BGP_DUMP_MSG_HEADER + BGP_DUMP_HEADER_SIZE); - install_node(&bgp_dump_node, config_write_bgp_dump); + install_node(&bgp_dump_node); install_element(CONFIG_NODE, &dump_bgp_all_cmd); install_element(CONFIG_NODE, &no_dump_bgp_all_cmd); diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c index 2a19597e4..0f70e6e5a 100644 --- a/bgpd/bgp_filter.c +++ b/bgpd/bgp_filter.c @@ -667,15 +667,17 @@ static int config_write_as_list(struct vty *vty) return write; } +static int config_write_as_list(struct vty *vty); static struct cmd_node as_list_node = { .node = AS_LIST_NODE, .prompt = "", + .config_write = config_write_as_list, }; /* Register functions. */ void bgp_filter_init(void) { - install_node(&as_list_node, config_write_as_list); + install_node(&as_list_node); install_element(CONFIG_NODE, &bgp_as_path_cmd); install_element(CONFIG_NODE, &no_bgp_as_path_cmd); diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c index 49d3f25ae..9bffa65c4 100644 --- a/bgpd/bgp_rpki.c +++ b/bgpd/bgp_rpki.c @@ -146,6 +146,7 @@ static int rpki_sync_socket_bgpd; static struct cmd_node rpki_node = { .node = RPKI_NODE, .prompt = "%s(config-rpki)# ", + .config_write = config_write, }; static const struct route_map_rule_cmd route_match_rpki_cmd = { "rpki", route_match, route_match_compile, route_match_free}; @@ -1542,7 +1543,7 @@ static void overwrite_exit_commands(void) static void install_cli_commands(void) { // TODO: make config write work - install_node(&rpki_node, &config_write); + install_node(&rpki_node); install_default(RPKI_NODE); overwrite_exit_commands(); install_element(CONFIG_NODE, &rpki_cmd); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index a9123abd1..78cbe250c 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -15337,6 +15337,7 @@ int bgp_config_write(struct vty *vty) static struct cmd_node bgp_node = { .node = BGP_NODE, .prompt = "%s(config-router)# ", + .config_write = bgp_config_write, }; static struct cmd_node bgp_ipv4_unicast_node = { @@ -15460,19 +15461,19 @@ void bgp_vty_init(void) cmd_variable_handler_register(bgp_var_peergroup); /* Install bgp top node. */ - install_node(&bgp_node, bgp_config_write); - install_node(&bgp_ipv4_unicast_node, NULL); - install_node(&bgp_ipv4_multicast_node, NULL); - install_node(&bgp_ipv4_labeled_unicast_node, NULL); - install_node(&bgp_ipv6_unicast_node, NULL); - install_node(&bgp_ipv6_multicast_node, NULL); - install_node(&bgp_ipv6_labeled_unicast_node, NULL); - install_node(&bgp_vpnv4_node, NULL); - install_node(&bgp_vpnv6_node, NULL); - install_node(&bgp_evpn_node, NULL); - install_node(&bgp_evpn_vni_node, NULL); - install_node(&bgp_flowspecv4_node, NULL); - install_node(&bgp_flowspecv6_node, NULL); + install_node(&bgp_node); + install_node(&bgp_ipv4_unicast_node); + install_node(&bgp_ipv4_multicast_node); + install_node(&bgp_ipv4_labeled_unicast_node); + install_node(&bgp_ipv6_unicast_node); + install_node(&bgp_ipv6_multicast_node); + install_node(&bgp_ipv6_labeled_unicast_node); + install_node(&bgp_vpnv4_node); + install_node(&bgp_vpnv6_node); + install_node(&bgp_evpn_node); + install_node(&bgp_evpn_vni_node); + install_node(&bgp_flowspecv4_node); + install_node(&bgp_flowspecv6_node); /* Install default VTY commands to new nodes. */ install_default(BGP_NODE); @@ -17877,14 +17878,16 @@ static int community_list_config_write(struct vty *vty) return write; } +static int community_list_config_write(struct vty *vty); static struct cmd_node community_list_node = { .node = COMMUNITY_LIST_NODE, .prompt = "", + .config_write = community_list_config_write, }; static void community_list_vty(void) { - install_node(&community_list_node, community_list_config_write); + install_node(&community_list_node); /* Community-list. */ install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index e9b7ae1c6..38d4ff9a4 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -3689,10 +3689,10 @@ bgp_rfapi_get_ecommunity_by_lni_label(struct bgp *bgp, uint32_t is_import, void bgp_rfapi_cfg_init(void) { - install_node(&bgp_vnc_defaults_node, NULL); - install_node(&bgp_vnc_nve_group_node, NULL); - install_node(&bgp_vrf_policy_node, NULL); - install_node(&bgp_vnc_l2_group_node, NULL); + install_node(&bgp_vnc_defaults_node); + install_node(&bgp_vnc_nve_group_node); + install_node(&bgp_vrf_policy_node); + install_node(&bgp_vnc_l2_group_node); install_default(BGP_VRF_POLICY_NODE); install_default(BGP_VNC_DEFAULTS_NODE); install_default(BGP_VNC_NVE_GROUP_NODE); diff --git a/bgpd/rfapi/vnc_debug.c b/bgpd/rfapi/vnc_debug.c index 9a2ab9bb5..5839d96f4 100644 --- a/bgpd/rfapi/vnc_debug.c +++ b/bgpd/rfapi/vnc_debug.c @@ -173,14 +173,16 @@ static int bgp_vnc_config_write_debug(struct vty *vty) return write; } +static int bgp_vnc_config_write_debug(struct vty *vty); static struct cmd_node debug_node = { .node = DEBUG_VNC_NODE, .prompt = "", + .config_write = bgp_vnc_config_write_debug, }; void vnc_debug_init(void) { - install_node(&debug_node, bgp_vnc_config_write_debug); + install_node(&debug_node); install_element(ENABLE_NODE, &show_debugging_bgp_vnc_cmd); install_element(ENABLE_NODE, &debug_bgp_vnc_cmd); diff --git a/eigrpd/eigrp_cli.c b/eigrpd/eigrp_cli.c index 6d324d47e..511195286 100644 --- a/eigrpd/eigrp_cli.c +++ b/eigrpd/eigrp_cli.c @@ -838,9 +838,11 @@ void eigrp_cli_show_keychain(struct vty *vty, struct lyd_node *dnode, /* * CLI installation procedures. */ +static int eigrp_config_write(struct vty *vty); static struct cmd_node eigrp_node = { .node = EIGRP_NODE, .prompt = "%s(config-router)# ", + .config_write = eigrp_config_write, }; static int eigrp_config_write(struct vty *vty) @@ -857,9 +859,11 @@ static int eigrp_config_write(struct vty *vty) return written; } +static int eigrp_write_interface(struct vty *vty); static struct cmd_node eigrp_interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", + .config_write = eigrp_write_interface, }; @@ -893,7 +897,7 @@ eigrp_cli_init(void) install_element(CONFIG_NODE, &router_eigrp_cmd); install_element(CONFIG_NODE, &no_router_eigrp_cmd); - install_node(&eigrp_node, eigrp_config_write); + install_node(&eigrp_node); install_default(EIGRP_NODE); install_element(EIGRP_NODE, &eigrp_router_id_cmd); @@ -911,7 +915,7 @@ eigrp_cli_init(void) install_element(EIGRP_NODE, &eigrp_neighbor_cmd); install_element(EIGRP_NODE, &eigrp_redistribute_source_metric_cmd); - install_node(&eigrp_interface_node, eigrp_write_interface); + install_node(&eigrp_interface_node); if_cmd_init(); install_element(INTERFACE_NODE, &eigrp_if_delay_cmd); diff --git a/eigrpd/eigrp_dump.c b/eigrpd/eigrp_dump.c index 3aaac4f53..05a25a433 100644 --- a/eigrpd/eigrp_dump.c +++ b/eigrpd/eigrp_dump.c @@ -555,15 +555,17 @@ DEFUN (no_debug_eigrp_packets, } /* Debug node. */ +static int config_write_debug(struct vty *vty); static struct cmd_node eigrp_debug_node = { .node = DEBUG_NODE, .prompt = "", + .config_write = config_write_debug, }; /* Initialize debug commands. */ void eigrp_debug_init(void) { - install_node(&eigrp_debug_node, config_write_debug); + install_node(&eigrp_debug_node); install_element(ENABLE_NODE, &show_debugging_eigrp_cmd); install_element(ENABLE_NODE, &debug_eigrp_packets_all_cmd); diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index 24d0408e3..10874fad3 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -67,7 +67,6 @@ DEFINE_HOOK(isis_if_new_hook, (struct interface *ifp), (ifp)) /* * Prototypes. */ -int isis_interface_config_write(struct vty *); int isis_if_new_hook(struct interface *); int isis_if_delete_hook(struct interface *); @@ -969,7 +968,7 @@ DEFINE_HOOK(isis_circuit_config_write, (circuit, vty)) #ifdef FABRICD -int isis_interface_config_write(struct vty *vty) +static int isis_interface_config_write(struct vty *vty) { struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); int write = 0; @@ -1192,7 +1191,7 @@ int isis_interface_config_write(struct vty *vty) return write; } #else -int isis_interface_config_write(struct vty *vty) +static int isis_interface_config_write(struct vty *vty) { struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); int write = 0; @@ -1338,6 +1337,7 @@ ferr_r isis_circuit_passwd_hmac_md5_set(struct isis_circuit *circuit, struct cmd_node interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", + .config_write = isis_interface_config_write, }; void isis_circuit_circ_type_set(struct isis_circuit *circuit, int circ_type) @@ -1442,7 +1442,7 @@ void isis_circuit_init(void) hook_register_prio(if_del, 0, isis_if_delete_hook); /* Install interface node */ - install_node(&interface_node, isis_interface_config_write); + install_node(&interface_node); if_cmd_init(); if_zapi_callbacks(isis_ifp_create, isis_ifp_up, isis_ifp_down, isis_ifp_destroy); diff --git a/isisd/isisd.c b/isisd/isisd.c index 3341bd441..29d7f914f 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -73,7 +73,6 @@ int area_clear_net_title(struct vty *, const char *); int show_isis_interface_common(struct vty *, const char *ifname, char); int show_isis_neighbor_common(struct vty *, const char *id, char); int clear_isis_neighbor_common(struct vty *, const char *id); -int isis_config_write(struct vty *); void isis_new(unsigned long process_id, vrf_id_t vrf_id) @@ -784,10 +783,12 @@ DEFUN_NOSH (show_debugging, return CMD_SUCCESS; } +static int config_write_debug(struct vty *vty); /* Debug node. */ static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", + .config_write = config_write_debug, }; static int config_write_debug(struct vty *vty) @@ -1855,7 +1856,7 @@ DEFUN (no_log_adj_changes, #endif /* ifdef FABRICD */ #ifdef FABRICD /* IS-IS configuration write function */ -int isis_config_write(struct vty *vty) +static int isis_config_write(struct vty *vty) { int write = 0; @@ -2129,7 +2130,7 @@ int isis_config_write(struct vty *vty) #else /* IS-IS configuration write function */ -int isis_config_write(struct vty *vty) +static int isis_config_write(struct vty *vty) { int write = 0; struct lyd_node *dnode; @@ -2147,12 +2148,13 @@ int isis_config_write(struct vty *vty) struct cmd_node router_node = { .node = ROUTER_NODE, .prompt = "%s(config-router)# ", + .config_write = isis_config_write, }; void isis_init(void) { /* Install IS-IS top node */ - install_node(&router_node, isis_config_write); + install_node(&router_node); install_element(VIEW_NODE, &show_isis_summary_cmd); @@ -2173,7 +2175,7 @@ void isis_init(void) install_element(ENABLE_NODE, &show_debugging_isis_cmd); - install_node(&debug_node, config_write_debug); + install_node(&debug_node); install_element(ENABLE_NODE, &debug_isis_adj_cmd); install_element(ENABLE_NODE, &no_debug_isis_adj_cmd); diff --git a/ldpd/ldp_debug.c b/ldpd/ldp_debug.c index 77ec8c699..59d8676ec 100644 --- a/ldpd/ldp_debug.c +++ b/ldpd/ldp_debug.c @@ -29,10 +29,13 @@ struct ldp_debug conf_ldp_debug; struct ldp_debug ldp_debug; +static int ldp_debug_config_write(struct vty *); + /* Debug node. */ struct cmd_node ldp_debug_node = { .node = DEBUG_NODE, .prompt = "", + .config_write = ldp_debug_config_write, }; int @@ -140,7 +143,7 @@ ldp_vty_show_debugging(struct vty *vty) return (CMD_SUCCESS); } -int +static int ldp_debug_config_write(struct vty *vty) { int write = 0; diff --git a/ldpd/ldp_vty.h b/ldpd/ldp_vty.h index af5f1d561..f6ba8f8c9 100644 --- a/ldpd/ldp_vty.h +++ b/ldpd/ldp_vty.h @@ -33,9 +33,6 @@ extern struct cmd_node ldp_debug_node; union ldpd_addr; int ldp_get_address(const char *, int *, union ldpd_addr *); -int ldp_config_write(struct vty *); -int ldp_l2vpn_config_write(struct vty *); -int ldp_debug_config_write(struct vty *); int ldp_vty_mpls_ldp (struct vty *, const char *); int ldp_vty_address_family (struct vty *, const char *, const char *); int ldp_vty_disc_holdtime(struct vty *, const char *, enum hello_type, long); diff --git a/ldpd/ldp_vty_cmds.c b/ldpd/ldp_vty_cmds.c index c10c6ae35..fc84c7f76 100644 --- a/ldpd/ldp_vty_cmds.c +++ b/ldpd/ldp_vty_cmds.c @@ -779,14 +779,14 @@ ldp_vty_init (void) { cmd_variable_handler_register(l2vpn_var_handlers); - install_node(&ldp_node, ldp_config_write); - install_node(&ldp_ipv4_node, NULL); - install_node(&ldp_ipv6_node, NULL); - install_node(&ldp_ipv4_iface_node, NULL); - install_node(&ldp_ipv6_iface_node, NULL); - install_node(&ldp_l2vpn_node, ldp_l2vpn_config_write); - install_node(&ldp_pseudowire_node, NULL); - install_node(&ldp_debug_node, ldp_debug_config_write); + install_node(&ldp_node); + install_node(&ldp_ipv4_node); + install_node(&ldp_ipv6_node); + install_node(&ldp_ipv4_iface_node); + install_node(&ldp_ipv6_iface_node); + install_node(&ldp_l2vpn_node); + install_node(&ldp_pseudowire_node); + install_node(&ldp_debug_node); install_default(LDP_NODE); install_default(LDP_IPV4_NODE); install_default(LDP_IPV6_NODE); diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c index dcea6e892..69aa3220b 100644 --- a/ldpd/ldp_vty_conf.c +++ b/ldpd/ldp_vty_conf.c @@ -30,9 +30,11 @@ #include "vty.h" #include "ldp_vty.h" +static int ldp_config_write(struct vty *); static void ldp_af_iface_config_write(struct vty *, int); static void ldp_af_config_write(struct vty *, int, struct ldpd_conf *, struct ldpd_af_conf *); +static int ldp_l2vpn_config_write(struct vty *); static void ldp_l2vpn_pw_config_write(struct vty *, struct l2vpn_pw *); static int ldp_vty_get_af(struct vty *); static int ldp_iface_is_configured(struct ldpd_conf *, const char *); @@ -40,6 +42,7 @@ static int ldp_iface_is_configured(struct ldpd_conf *, const char *); struct cmd_node ldp_node = { .node = LDP_NODE, .prompt = "%s(config-ldp)# ", + .config_write = ldp_config_write, }; struct cmd_node ldp_ipv4_node = { @@ -65,6 +68,7 @@ struct cmd_node ldp_ipv6_iface_node = { struct cmd_node ldp_l2vpn_node = { .node = LDP_L2VPN_NODE, .prompt = "%s(config-l2vpn)# ", + .config_write = ldp_l2vpn_config_write, }; struct cmd_node ldp_pseudowire_node = { @@ -226,7 +230,7 @@ ldp_af_config_write(struct vty *vty, int af, struct ldpd_conf *conf, vty_out(vty, " exit-address-family\n"); } -int +static int ldp_config_write(struct vty *vty) { struct nbr_params *nbrp; @@ -331,7 +335,7 @@ ldp_l2vpn_pw_config_write(struct vty *vty, struct l2vpn_pw *pw) vty_out (vty," ! Incomplete config, specify a pw-id\n"); } -int +static int ldp_l2vpn_config_write(struct vty *vty) { struct l2vpn *l2vpn; diff --git a/lib/agentx.c b/lib/agentx.c index 8ce154524..42c843bbb 100644 --- a/lib/agentx.c +++ b/lib/agentx.c @@ -158,9 +158,11 @@ static void agentx_events_update(void) } /* AgentX node. */ +static int config_write_agentx(struct vty *vty); static struct cmd_node agentx_node = { .node = SMUX_NODE, .prompt = "", + .config_write = config_write_agentx, }; /* Logging NetSNMP messages */ @@ -247,7 +249,7 @@ void smux_init(struct thread_master *tm) agentx_log_callback, NULL); init_agent(FRR_SMUX_NAME); - install_node(&agentx_node, config_write_agentx); + install_node(&agentx_node); install_element(CONFIG_NODE, &agentx_enable_cmd); install_element(CONFIG_NODE, &no_agentx_cmd); } diff --git a/lib/command.c b/lib/command.c index a26ec1a26..7d46202da 100644 --- a/lib/command.c +++ b/lib/command.c @@ -200,9 +200,11 @@ static struct cmd_node enable_node = { .prompt = "%s# ", }; +static int config_write_host(struct vty *vty); static struct cmd_node config_node = { .node = CONFIG_NODE, .prompt = "%s(config)# ", + .config_write = config_write_host, }; static const struct facility_map { @@ -352,10 +354,9 @@ static bool cmd_hash_cmp(const void *a, const void *b) } /* Install top node of command vector. */ -void install_node(struct cmd_node *node, int (*func)(struct vty *)) +void install_node(struct cmd_node *node) { vector_set_index(cmdvec, node->node, node); - node->func = func; node->cmdgraph = graph_new(); node->cmd_vector = vector_init(VECTOR_MIN_SIZE); // add start node @@ -1723,8 +1724,8 @@ static int vty_write_config(struct vty *vty) vty_out(vty, "!\n"); for (i = 0; i < vector_active(cmdvec); i++) - if ((node = vector_slot(cmdvec, i)) && node->func) { - if ((*node->func)(vty)) + if ((node = vector_slot(cmdvec, i)) && node->config_write) { + if ((*node->config_write)(vty)) vty_out(vty, "!\n"); } @@ -2889,11 +2890,11 @@ void cmd_init(int terminal) host.motdfile = NULL; /* Install top nodes. */ - install_node(&view_node, NULL); - install_node(&enable_node, NULL); - install_node(&auth_node, NULL); - install_node(&auth_enable_node, NULL); - install_node(&config_node, config_write_host); + install_node(&view_node); + install_node(&enable_node); + install_node(&auth_node); + install_node(&auth_enable_node); + install_node(&config_node); /* Each node's basic commands. */ install_element(VIEW_NODE, &show_version_cmd); diff --git a/lib/command.h b/lib/command.h index 06c7ce7b4..ed7706c30 100644 --- a/lib/command.h +++ b/lib/command.h @@ -177,7 +177,7 @@ struct cmd_node { const char *prompt; /* Node's configuration write function */ - int (*func)(struct vty *); + int (*config_write)(struct vty *); /* Node's command graph */ struct graph *cmdgraph; @@ -431,7 +431,7 @@ struct cmd_node { #define NO_GR_NEIGHBOR_HELPER_CMD "Undo Graceful Restart Helper command for a neighbor\n" /* Prototypes. */ -extern void install_node(struct cmd_node *node, int (*)(struct vty *)); +extern void install_node(struct cmd_node *node); extern void install_default(enum node_type); extern void install_element(enum node_type, const struct cmd_element *); diff --git a/lib/filter.c b/lib/filter.c index 5665dd82b..c6cc16d7d 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -2812,9 +2812,11 @@ static int config_write_access(struct vty *vty, afi_t afi) return write; } +static int config_write_access_mac(struct vty *vty); static struct cmd_node access_mac_node = { .node = ACCESS_MAC_NODE, .prompt = "", + .config_write = config_write_access_mac, }; static int config_write_access_mac(struct vty *vty) @@ -2851,7 +2853,7 @@ static void access_list_reset_mac(void) /* Install vty related command. */ static void access_list_init_mac(void) { - install_node(&access_mac_node, config_write_access_mac); + install_node(&access_mac_node); install_element(ENABLE_NODE, &show_mac_access_list_cmd); install_element(ENABLE_NODE, &show_mac_access_list_name_cmd); @@ -2864,9 +2866,11 @@ static void access_list_init_mac(void) } /* Access-list node. */ +static int config_write_access_ipv4(struct vty *vty); static struct cmd_node access_node = { .node = ACCESS_NODE, .prompt = "", + .config_write = config_write_access_ipv4, }; static int config_write_access_ipv4(struct vty *vty) @@ -2903,7 +2907,7 @@ static void access_list_reset_ipv4(void) /* Install vty related command. */ static void access_list_init_ipv4(void) { - install_node(&access_node, config_write_access_ipv4); + install_node(&access_node); install_element(ENABLE_NODE, &show_ip_access_list_cmd); install_element(ENABLE_NODE, &show_ip_access_list_name_cmd); @@ -2950,9 +2954,11 @@ static void access_list_init_ipv4(void) install_element(CONFIG_NODE, &no_access_list_remark_comment_cmd); } +static int config_write_access_ipv6(struct vty *vty); static struct cmd_node access_ipv6_node = { .node = ACCESS_IPV6_NODE, .prompt = "", + .config_write = config_write_access_ipv6, }; static int config_write_access_ipv6(struct vty *vty) @@ -2988,7 +2994,7 @@ static void access_list_reset_ipv6(void) static void access_list_init_ipv6(void) { - install_node(&access_ipv6_node, config_write_access_ipv6); + install_node(&access_ipv6_node); install_element(ENABLE_NODE, &show_ipv6_access_list_cmd); install_element(ENABLE_NODE, &show_ipv6_access_list_name_cmd); diff --git a/lib/keychain.c b/lib/keychain.c index c66c1de07..bbe2070b1 100644 --- a/lib/keychain.c +++ b/lib/keychain.c @@ -959,9 +959,11 @@ DEFUN (no_send_lifetime, return CMD_SUCCESS; } +static int keychain_config_write(struct vty *vty); static struct cmd_node keychain_node = { .node = KEYCHAIN_NODE, .prompt = "%s(config-keychain)# ", + .config_write = keychain_config_write, }; static struct cmd_node keychain_key_node = { @@ -1046,8 +1048,8 @@ void keychain_init(void) { keychain_list = list_new(); - install_node(&keychain_node, keychain_config_write); - install_node(&keychain_key_node, NULL); + install_node(&keychain_node); + install_node(&keychain_key_node); install_default(KEYCHAIN_NODE); install_default(KEYCHAIN_KEY_NODE); diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c index 95087fe30..cce5af1e7 100644 --- a/lib/nexthop_group.c +++ b/lib/nexthop_group.c @@ -933,9 +933,11 @@ DEFPY(ecmp_nexthops, ecmp_nexthops_cmd, return CMD_SUCCESS; } +static int nexthop_group_write(struct vty *vty); static struct cmd_node nexthop_group_node = { .node = NH_GROUP_NODE, .prompt = "%s(config-nh-group)# ", + .config_write = nexthop_group_write, }; void nexthop_group_write_nexthop(struct vty *vty, struct nexthop *nh) @@ -1209,7 +1211,7 @@ void nexthop_group_init(void (*new)(const char *name), cmd_variable_handler_register(nhg_name_handlers); - install_node(&nexthop_group_node, nexthop_group_write); + install_node(&nexthop_group_node); install_element(CONFIG_NODE, &nexthop_group_cmd); install_element(CONFIG_NODE, &no_nexthop_group_cmd); diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c index 5803dbd78..d0e05990a 100644 --- a/lib/northbound_cli.c +++ b/lib/northbound_cli.c @@ -1677,6 +1677,7 @@ static struct debug_callbacks nb_dbg_cbs = {.debug_set_all = nb_debug_set_all}; static struct cmd_node nb_debug_node = { .node = NORTHBOUND_DEBUG_NODE, .prompt = "", + .config_write = nb_debug_config_write, }; void nb_cli_install_default(int node) @@ -1741,7 +1742,7 @@ void nb_cli_init(struct thread_master *tm) debug_init(&nb_dbg_cbs); - install_node(&nb_debug_node, nb_debug_config_write); + install_node(&nb_debug_node); install_element(ENABLE_NODE, &debug_nb_cmd); install_element(CONFIG_NODE, &debug_nb_cmd); diff --git a/lib/plist.c b/lib/plist.c index 8f2389a32..acc4491a0 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -2044,10 +2044,12 @@ static void prefix_list_reset_afi(afi_t afi, int orf) } +static int config_write_prefix_ipv4(struct vty *vty); /* Prefix-list node. */ static struct cmd_node prefix_node = { .node = PREFIX_NODE, .prompt = "", + .config_write = config_write_prefix_ipv4, }; static int config_write_prefix_ipv4(struct vty *vty) @@ -2086,7 +2088,7 @@ static const struct cmd_variable_handler plist_var_handlers[] = { static void prefix_list_init_ipv4(void) { - install_node(&prefix_node, config_write_prefix_ipv4); + install_node(&prefix_node); install_element(CONFIG_NODE, &ip_prefix_list_cmd); install_element(CONFIG_NODE, &no_ip_prefix_list_cmd); @@ -2108,10 +2110,12 @@ static void prefix_list_init_ipv4(void) install_element(ENABLE_NODE, &clear_ip_prefix_list_cmd); } +static int config_write_prefix_ipv6(struct vty *vty); /* Prefix-list node. */ static struct cmd_node prefix_ipv6_node = { .node = PREFIX_IPV6_NODE, .prompt = "", + .config_write = config_write_prefix_ipv6, }; static int config_write_prefix_ipv6(struct vty *vty) @@ -2121,7 +2125,7 @@ static int config_write_prefix_ipv6(struct vty *vty) static void prefix_list_init_ipv6(void) { - install_node(&prefix_ipv6_node, config_write_prefix_ipv6); + install_node(&prefix_ipv6_node); install_element(CONFIG_NODE, &ipv6_prefix_list_cmd); install_element(CONFIG_NODE, &no_ipv6_prefix_list_cmd); diff --git a/lib/resolver.c b/lib/resolver.c index 9005ee527..56b2d6cd6 100644 --- a/lib/resolver.c +++ b/lib/resolver.c @@ -245,9 +245,11 @@ DEFUN(debug_resolver, return CMD_SUCCESS; } +static int resolver_config_write_debug(struct vty *vty); static struct cmd_node resolver_debug_node = { .node = RESOLVER_DEBUG_NODE, .prompt = "", + .config_write = resolver_config_write_debug, }; static int resolver_config_write_debug(struct vty *vty) @@ -277,7 +279,7 @@ void resolver_init(struct thread_master *tm) ARES_OPT_SOCK_STATE_CB | ARES_OPT_TIMEOUT | ARES_OPT_TRIES); - install_node(&resolver_debug_node, resolver_config_write_debug); + install_node(&resolver_debug_node); install_element(CONFIG_NODE, &debug_resolver_cmd); install_element(ENABLE_NODE, &debug_resolver_cmd); } diff --git a/lib/routemap.c b/lib/routemap.c index 41057c870..2208a69f9 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -3015,9 +3015,11 @@ DEFUN (no_debug_rmap, } /* Debug node. */ +static int rmap_config_write_debug(struct vty *vty); static struct cmd_node rmap_debug_node = { .node = RMAP_DEBUG_NODE, .prompt = "", + .config_write = rmap_config_write_debug, }; /* Configuration write function. */ @@ -3245,7 +3247,7 @@ void route_map_init(void) route_map_cli_init(); /* Install route map top node. */ - install_node(&rmap_debug_node, rmap_config_write_debug); + install_node(&rmap_debug_node); /* Install route map commands. */ install_element(CONFIG_NODE, &debug_rmap_cmd); diff --git a/lib/routemap_cli.c b/lib/routemap_cli.c index a53c54291..b97948d5c 100644 --- a/lib/routemap_cli.c +++ b/lib/routemap_cli.c @@ -1064,9 +1064,11 @@ static int route_map_config_write(struct vty *vty) } /* Route map node structure. */ +static int route_map_config_write(struct vty *vty); static struct cmd_node rmap_node = { .node = RMAP_NODE, .prompt = "%s(config-route-map)# ", + .config_write = route_map_config_write, }; static void rmap_autocomplete(vector comps, struct cmd_token *token) @@ -1090,7 +1092,7 @@ void route_map_cli_init(void) cmd_variable_handler_register(rmap_var_handlers); /* CLI commands. */ - install_node(&rmap_node, route_map_config_write); + install_node(&rmap_node); install_default(RMAP_NODE); install_element(CONFIG_NODE, &route_map_cmd); install_element(CONFIG_NODE, &no_route_map_cmd); diff --git a/lib/vrf.c b/lib/vrf.c index fbc45fa18..b825ff03f 100644 --- a/lib/vrf.c +++ b/lib/vrf.c @@ -851,14 +851,16 @@ static int vrf_write_host(struct vty *vty) return 1; } +static int vrf_write_host(struct vty *vty); static struct cmd_node vrf_debug_node = { .node = VRF_DEBUG_NODE, .prompt = "", + .config_write = vrf_write_host, }; void vrf_install_commands(void) { - install_node(&vrf_debug_node, vrf_write_host); + install_node(&vrf_debug_node); install_element(CONFIG_NODE, &vrf_debug_cmd); install_element(ENABLE_NODE, &vrf_debug_cmd); @@ -871,7 +873,8 @@ void vrf_cmd_init(int (*writefunc)(struct vty *vty), { install_element(CONFIG_NODE, &vrf_cmd); install_element(CONFIG_NODE, &no_vrf_cmd); - install_node(&vrf_node, writefunc); + vrf_node.config_write = writefunc; + install_node(&vrf_node); install_default(VRF_NODE); install_element(VRF_NODE, &vrf_exit_cmd); if (vrf_is_backend_netns() && ns_have_netns()) { diff --git a/lib/vty.c b/lib/vty.c index 5b86455f6..1d94d3d31 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -2989,9 +2989,11 @@ static int vty_config_write(struct vty *vty) return CMD_SUCCESS; } +static int vty_config_write(struct vty *vty); struct cmd_node vty_node = { .node = VTY_NODE, .prompt = "%s(config-line)# ", + .config_write = vty_config_write, }; /* Reset all VTY status. */ @@ -3085,7 +3087,7 @@ void vty_init(struct thread_master *master_thread, bool do_command_logging) Vvty_serv_thread = vector_init(VECTOR_MIN_SIZE); /* Install bgp top node. */ - install_node(&vty_node, vty_config_write); + install_node(&vty_node); install_element(VIEW_NODE, &config_who_cmd); install_element(VIEW_NODE, &show_history_cmd); diff --git a/nhrpd/nhrp_vty.c b/nhrpd/nhrp_vty.c index 69be4db90..f9ed1e96c 100644 --- a/nhrpd/nhrp_vty.c +++ b/nhrpd/nhrp_vty.c @@ -17,14 +17,18 @@ #include "nhrpd.h" #include "netlink.h" +static int nhrp_config_write(struct vty *vty); static struct cmd_node zebra_node = { .node = ZEBRA_NODE, .prompt = "%s(config-router)# ", + .config_write = nhrp_config_write, }; +static int interface_config_write(struct vty *vty); static struct cmd_node nhrp_interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", + .config_write = interface_config_write, }; #define NHRP_DEBUG_FLAGS_CMD "" @@ -1094,7 +1098,7 @@ static int interface_config_write(struct vty *vty) void nhrp_config_init(void) { - install_node(&zebra_node, nhrp_config_write); + install_node(&zebra_node); install_default(ZEBRA_NODE); /* access-list commands */ @@ -1118,7 +1122,7 @@ void nhrp_config_init(void) install_element(CONFIG_NODE, &no_nhrp_nflog_group_cmd); /* interface specific commands */ - install_node(&nhrp_interface_node, interface_config_write); + install_node(&nhrp_interface_node); if_cmd_init(); install_element(INTERFACE_NODE, &tunnel_protection_cmd); diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index 2bcaccc42..3d1c6f9fa 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -1943,9 +1943,11 @@ static int config_write_ospf6_interface(struct vty *vty) return 0; } +static int config_write_ospf6_interface(struct vty *vty); static struct cmd_node interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", + .config_write = config_write_ospf6_interface, }; static int ospf6_ifp_create(struct interface *ifp) @@ -2002,7 +2004,7 @@ static int ospf6_ifp_destroy(struct interface *ifp) void ospf6_interface_init(void) { /* Install interface node. */ - install_node(&interface_node, config_write_ospf6_interface); + install_node(&interface_node); if_cmd_init(); if_zapi_callbacks(ospf6_ifp_create, ospf6_ifp_up, ospf6_ifp_down, ospf6_ifp_destroy); diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index ae7ecb55a..616865621 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -1112,17 +1112,19 @@ static int config_write_ospf6(struct vty *vty) return 0; } +static int config_write_ospf6(struct vty *vty); /* OSPF6 node structure. */ static struct cmd_node ospf6_node = { .node = OSPF6_NODE, .prompt = "%s(config-ospf6)# ", + .config_write = config_write_ospf6, }; /* Install ospf related commands. */ void ospf6_top_init(void) { /* Install ospf6 top node. */ - install_node(&ospf6_node, config_write_ospf6); + install_node(&ospf6_node); install_element(VIEW_NODE, &show_ipv6_ospf6_cmd); install_element(CONFIG_NODE, &router_ospf6_cmd); diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c index 8e5406642..efbb332b6 100644 --- a/ospf6d/ospf6d.c +++ b/ospf6d/ospf6d.c @@ -69,9 +69,11 @@ struct route_node *route_prev(struct route_node *node) return prev; } +static int config_write_ospf6_debug(struct vty *vty); static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", + .config_write = config_write_ospf6_debug, }; static int config_write_ospf6_debug(struct vty *vty) @@ -1217,7 +1219,7 @@ void ospf6_init(void) prefix_list_delete_hook(ospf6_plist_del); ospf6_bfd_init(); - install_node(&debug_node, config_write_ospf6_debug); + install_node(&debug_node); install_element_ospf6_debug_message(); install_element_ospf6_debug_lsa(); diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index 6640c7c48..e012326ea 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -1640,10 +1640,12 @@ DEFUN_NOSH (show_debugging_ospf_instance, return show_debugging_ospf_common(vty, ospf); } +static int config_write_debug(struct vty *vty); /* Debug node. */ static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", + .config_write = config_write_debug, }; static int config_write_debug(struct vty *vty) @@ -1784,7 +1786,7 @@ static int config_write_debug(struct vty *vty) /* Initialize debug commands. */ void ospf_debug_init(void) { - install_node(&debug_node, config_write_debug); + install_node(&debug_node); install_element(ENABLE_NODE, &show_debugging_ospf_cmd); install_element(ENABLE_NODE, &debug_ospf_ism_cmd); diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index b95a98476..ab12c3818 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -10555,17 +10555,19 @@ void ospf_vty_show_init(void) } +static int config_write_interface(struct vty *vty); /* ospfd's interface node. */ static struct cmd_node interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", + .config_write = config_write_interface, }; /* Initialization of OSPF interface. */ static void ospf_vty_if_init(void) { /* Install interface node. */ - install_node(&interface_node, config_write_interface); + install_node(&interface_node); if_cmd_init(); /* "ip ospf authentication" commands. */ @@ -10671,9 +10673,11 @@ static void ospf_vty_zebra_init(void) #endif /* 0 */ } +static int ospf_config_write(struct vty *vty); static struct cmd_node ospf_node = { .node = OSPF_NODE, .prompt = "%s(config-router)# ", + .config_write = ospf_config_write, }; static void ospf_interface_clear(struct interface *ifp) @@ -10747,7 +10751,7 @@ void ospf_vty_clear_init(void) void ospf_vty_init(void) { /* Install ospf top node. */ - install_node(&ospf_node, ospf_config_write); + install_node(&ospf_node); /* "router ospf" commands. */ install_element(CONFIG_NODE, &router_ospf_cmd); diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c index a60d29e51..2f5d4dcbc 100644 --- a/pbrd/pbr_vty.c +++ b/pbrd/pbr_vty.c @@ -680,6 +680,7 @@ DEFPY (show_pbr_interface, static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", + .config_write = pbr_debug_config_write, }; DEFPY(debug_pbr, @@ -728,9 +729,11 @@ DEFUN_NOSH(show_debugging_pbr, /* ------------------------------------------------------------------------- */ +static int pbr_interface_config_write(struct vty *vty); static struct cmd_node interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", + .config_write = pbr_interface_config_write, }; static int pbr_interface_config_write(struct vty *vty) @@ -758,10 +761,12 @@ static int pbr_interface_config_write(struct vty *vty) return 1; } +static int pbr_vty_map_config_write(struct vty *vty); /* PBR map node structure. */ static struct cmd_node pbr_map_node = { .node = PBRMAP_NODE, .prompt = "%s(config-pbr-map)# ", + .config_write = pbr_vty_map_config_write, }; static int pbr_vty_map_config_write_sequence(struct vty *vty, @@ -840,15 +845,13 @@ void pbr_vty_init(void) { cmd_variable_handler_register(pbr_map_name); - install_node(&interface_node, - pbr_interface_config_write); + install_node(&interface_node); if_cmd_init(); - install_node(&pbr_map_node, - pbr_vty_map_config_write); + install_node(&pbr_map_node); /* debug */ - install_node(&debug_node, pbr_debug_config_write); + install_node(&debug_node); install_element(VIEW_NODE, &debug_pbr_cmd); install_element(CONFIG_NODE, &debug_pbr_cmd); install_element(VIEW_NODE, &show_debugging_pbr_cmd); diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 3b590230c..a386e33d2 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -72,11 +72,13 @@ static struct cmd_node interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", + .config_write = pim_interface_config_write, }; static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", + .config_write = pim_debug_config_write, }; static struct vrf *pim_cmd_lookup_vrf(struct vty *vty, struct cmd_token *argv[], @@ -10831,11 +10833,10 @@ DEFUN_HIDDEN (ip_pim_mlag, void pim_cmd_init(void) { - install_node(&interface_node, - pim_interface_config_write); /* INTERFACE_NODE */ + install_node(&interface_node); /* INTERFACE_NODE */ if_cmd_init(); - install_node(&debug_node, pim_debug_config_write); + install_node(&debug_node); install_element(ENABLE_NODE, &pim_test_sg_keepalive_cmd); diff --git a/ripd/rip_debug.c b/ripd/rip_debug.c index 72cd0c62f..676fc0cca 100644 --- a/ripd/rip_debug.c +++ b/ripd/rip_debug.c @@ -172,10 +172,12 @@ DEFUN (no_debug_rip_zebra, return CMD_SUCCESS; } +static int config_write_debug(struct vty *vty); /* Debug node. */ static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", + .config_write = config_write_debug, }; static int config_write_debug(struct vty *vty) @@ -211,7 +213,7 @@ void rip_debug_init(void) rip_debug_packet = 0; rip_debug_zebra = 0; - install_node(&debug_node, config_write_debug); + install_node(&debug_node); install_element(ENABLE_NODE, &show_debugging_rip_cmd); install_element(ENABLE_NODE, &debug_rip_events_cmd); diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index 10e23787e..87899e468 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -1193,9 +1193,11 @@ int rip_show_network_config(struct vty *vty, struct rip *rip) return 0; } +static int rip_interface_config_write(struct vty *vty); static struct cmd_node interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", + .config_write = rip_interface_config_write, }; void rip_interface_sync(struct interface *ifp) @@ -1237,7 +1239,7 @@ void rip_if_init(void) hook_register_prio(if_del, 0, rip_interface_delete_hook); /* Install interface node. */ - install_node(&interface_node, rip_interface_config_write); + install_node(&interface_node); if_cmd_init(); if_zapi_callbacks(rip_ifp_create, rip_ifp_up, rip_ifp_down, rip_ifp_destroy); diff --git a/ripd/ripd.c b/ripd/ripd.c index 95ea19a98..71511deb1 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -3327,10 +3327,12 @@ static int config_write_rip(struct vty *vty) return write; } +static int config_write_rip(struct vty *vty); /* RIP node structure. */ static struct cmd_node rip_node = { .node = RIP_NODE, .prompt = "%s(config-router)# ", + .config_write = config_write_rip, }; /* Distribute-list update functions. */ @@ -3734,7 +3736,7 @@ void rip_vrf_terminate(void) void rip_init(void) { /* Install top nodes. */ - install_node(&rip_node, config_write_rip); + install_node(&rip_node); /* Install rip commands. */ install_element(VIEW_NODE, &show_ip_rip_cmd); diff --git a/ripngd/ripng_debug.c b/ripngd/ripng_debug.c index 24da4b005..117148a3a 100644 --- a/ripngd/ripng_debug.c +++ b/ripngd/ripng_debug.c @@ -174,10 +174,12 @@ DEFUN (no_debug_ripng_zebra, return CMD_SUCCESS; } +static int config_write_debug(struct vty *vty); /* Debug node. */ static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", + .config_write = config_write_debug, }; static int config_write_debug(struct vty *vty) @@ -213,7 +215,7 @@ void ripng_debug_init(void) ripng_debug_packet = 0; ripng_debug_zebra = 0; - install_node(&debug_node, config_write_debug); + install_node(&debug_node); install_element(VIEW_NODE, &show_debugging_ripng_cmd); diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c index 3fac88514..efaabdb6d 100644 --- a/ripngd/ripng_interface.c +++ b/ripngd/ripng_interface.c @@ -954,10 +954,12 @@ static int interface_config_write(struct vty *vty) return write; } +static int interface_config_write(struct vty *vty); /* ripngd's interface node. */ static struct cmd_node interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", + .config_write = interface_config_write, }; /* Initialization of interface. */ @@ -968,7 +970,7 @@ void ripng_if_init(void) hook_register_prio(if_del, 0, ripng_if_delete_hook); /* Install interface node. */ - install_node(&interface_node, interface_config_write); + install_node(&interface_node); if_cmd_init(); if_zapi_callbacks(ripng_ifp_create, ripng_ifp_up, ripng_ifp_down, ripng_ifp_destroy); diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index ad40c0b13..cde8d860e 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -2434,10 +2434,12 @@ static int ripng_config_write(struct vty *vty) return write; } +static int ripng_config_write(struct vty *vty); /* RIPng node structure. */ static struct cmd_node cmd_ripng_node = { .node = RIPNG_NODE, .prompt = "%s(config-router)# ", + .config_write = ripng_config_write, }; static void ripng_distribute_update(struct distribute_ctx *ctx, @@ -2851,7 +2853,7 @@ void ripng_vrf_terminate(void) void ripng_init(void) { /* Install RIPNG_NODE. */ - install_node(&cmd_ripng_node, ripng_config_write); + install_node(&cmd_ripng_node); /* Install ripng commands. */ install_element(VIEW_NODE, &show_ipv6_ripng_cmd); diff --git a/staticd/static_vty.c b/staticd/static_vty.c index 05c5f7cfe..733578f86 100644 --- a/staticd/static_vty.c +++ b/staticd/static_vty.c @@ -1473,11 +1473,12 @@ DEFUN_NOSH (show_debugging_static, static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", + .config_write = static_config_write_debug, }; void static_vty_init(void) { - install_node(&debug_node, static_config_write_debug); + install_node(&debug_node); install_element(CONFIG_NODE, &ip_mroute_dist_cmd); diff --git a/tests/lib/cli/test_commands.c b/tests/lib/cli/test_commands.c index 3ebe46a9a..d269e51be 100644 --- a/tests/lib/cli/test_commands.c +++ b/tests/lib/cli/test_commands.c @@ -179,23 +179,23 @@ static void test_init(void) yang_init(true); nb_init(master, NULL, 0); - install_node(&bgp_node, NULL); - install_node(&rip_node, NULL); - install_node(&interface_node, NULL); - install_node(&rmap_node, NULL); - install_node(&zebra_node, NULL); - install_node(&bgp_vpnv4_node, NULL); - install_node(&bgp_ipv4_node, NULL); - install_node(&bgp_ipv4m_node, NULL); - install_node(&bgp_ipv6_node, NULL); - install_node(&bgp_ipv6m_node, NULL); - install_node(&ospf_node, NULL); - install_node(&ripng_node, NULL); - install_node(&ospf6_node, NULL); - install_node(&keychain_node, NULL); - install_node(&keychain_key_node, NULL); - install_node(&isis_node, NULL); - install_node(&vty_node, NULL); + install_node(&bgp_node); + install_node(&rip_node); + install_node(&interface_node); + install_node(&rmap_node); + install_node(&zebra_node); + install_node(&bgp_vpnv4_node); + install_node(&bgp_ipv4_node); + install_node(&bgp_ipv4m_node); + install_node(&bgp_ipv6_node); + install_node(&bgp_ipv6m_node); + install_node(&ospf_node); + install_node(&ripng_node); + install_node(&ospf6_node); + install_node(&keychain_node); + install_node(&keychain_key_node); + install_node(&isis_node); + install_node(&vty_node); test_init_cmd(); diff --git a/vrrpd/vrrp_vty.c b/vrrpd/vrrp_vty.c index e1dd0a2d4..98ce74593 100644 --- a/vrrpd/vrrp_vty.c +++ b/vrrpd/vrrp_vty.c @@ -747,23 +747,26 @@ static int vrrp_config_write_interface(struct vty *vty) static struct cmd_node interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", + .config_write = vrrp_config_write_interface, }; static struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", + .config_write = vrrp_config_write_debug, }; static struct cmd_node vrrp_node = { .node = VRRP_NODE, .prompt = "", + .config_write = vrrp_config_write_global, }; void vrrp_vty_init(void) { - install_node(&debug_node, vrrp_config_write_debug); - install_node(&interface_node, vrrp_config_write_interface); - install_node(&vrrp_node, vrrp_config_write_global); + install_node(&debug_node); + install_node(&interface_node); + install_node(&vrrp_node); if_cmd_init(); install_element(VIEW_NODE, &vrrp_vrid_show_cmd); diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 563914af4..028a9c7e0 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -3821,54 +3821,54 @@ void vtysh_init_vty(void) cmd_variable_handler_register(vtysh_var_handler); /* Install nodes. */ - install_node(&bgp_node, NULL); - install_node(&rip_node, NULL); - install_node(&interface_node, NULL); - install_node(&pw_node, NULL); - install_node(&link_params_node, NULL); - install_node(&vrf_node, NULL); - install_node(&nh_group_node, NULL); - install_node(&rmap_node, NULL); - install_node(&pbr_map_node, NULL); - install_node(&zebra_node, NULL); - install_node(&bgp_vpnv4_node, NULL); - install_node(&bgp_vpnv6_node, NULL); - install_node(&bgp_flowspecv4_node, NULL); - install_node(&bgp_flowspecv6_node, NULL); - install_node(&bgp_ipv4_node, NULL); - install_node(&bgp_ipv4m_node, NULL); - install_node(&bgp_ipv4l_node, NULL); - install_node(&bgp_ipv6_node, NULL); - install_node(&bgp_ipv6m_node, NULL); - install_node(&bgp_ipv6l_node, NULL); - install_node(&bgp_vrf_policy_node, NULL); - install_node(&bgp_evpn_node, NULL); - install_node(&bgp_evpn_vni_node, NULL); - install_node(&bgp_vnc_defaults_node, NULL); - install_node(&bgp_vnc_nve_group_node, NULL); - install_node(&bgp_vnc_l2_group_node, NULL); - install_node(&ospf_node, NULL); - install_node(&eigrp_node, NULL); - install_node(&babel_node, NULL); - install_node(&ripng_node, NULL); - install_node(&ospf6_node, NULL); - install_node(&ldp_node, NULL); - install_node(&ldp_ipv4_node, NULL); - install_node(&ldp_ipv6_node, NULL); - install_node(&ldp_ipv4_iface_node, NULL); - install_node(&ldp_ipv6_iface_node, NULL); - install_node(&ldp_l2vpn_node, NULL); - install_node(&ldp_pseudowire_node, NULL); - install_node(&keychain_node, NULL); - install_node(&keychain_key_node, NULL); - install_node(&isis_node, NULL); - install_node(&openfabric_node, NULL); - install_node(&vty_node, NULL); - install_node(&rpki_node, NULL); - install_node(&bmp_node, NULL); + install_node(&bgp_node); + install_node(&rip_node); + install_node(&interface_node); + install_node(&pw_node); + install_node(&link_params_node); + install_node(&vrf_node); + install_node(&nh_group_node); + install_node(&rmap_node); + install_node(&pbr_map_node); + install_node(&zebra_node); + install_node(&bgp_vpnv4_node); + install_node(&bgp_vpnv6_node); + install_node(&bgp_flowspecv4_node); + install_node(&bgp_flowspecv6_node); + install_node(&bgp_ipv4_node); + install_node(&bgp_ipv4m_node); + install_node(&bgp_ipv4l_node); + install_node(&bgp_ipv6_node); + install_node(&bgp_ipv6m_node); + install_node(&bgp_ipv6l_node); + install_node(&bgp_vrf_policy_node); + install_node(&bgp_evpn_node); + install_node(&bgp_evpn_vni_node); + install_node(&bgp_vnc_defaults_node); + install_node(&bgp_vnc_nve_group_node); + install_node(&bgp_vnc_l2_group_node); + install_node(&ospf_node); + install_node(&eigrp_node); + install_node(&babel_node); + install_node(&ripng_node); + install_node(&ospf6_node); + install_node(&ldp_node); + install_node(&ldp_ipv4_node); + install_node(&ldp_ipv6_node); + install_node(&ldp_ipv4_iface_node); + install_node(&ldp_ipv6_iface_node); + install_node(&ldp_l2vpn_node); + install_node(&ldp_pseudowire_node); + install_node(&keychain_node); + install_node(&keychain_key_node); + install_node(&isis_node); + install_node(&openfabric_node); + install_node(&vty_node); + install_node(&rpki_node); + install_node(&bmp_node); #if HAVE_BFDD > 0 - install_node(&bfd_node, NULL); - install_node(&bfd_peer_node, NULL); + install_node(&bfd_node); + install_node(&bfd_peer_node); #endif /* HAVE_BFDD */ struct cmd_node *node; diff --git a/zebra/debug.c b/zebra/debug.c index f7ad228a1..a77693d94 100644 --- a/zebra/debug.c +++ b/zebra/debug.c @@ -471,9 +471,11 @@ DEFPY (debug_zebra_nexthop, } /* Debug node. */ +static int config_write_debug(struct vty *vty); struct cmd_node debug_node = { .node = DEBUG_NODE, .prompt = "", + .config_write = config_write_debug, }; static int config_write_debug(struct vty *vty) @@ -589,7 +591,7 @@ void zebra_debug_init(void) zebra_debug_nht = 0; zebra_debug_nexthop = 0; - install_node(&debug_node, config_write_debug); + install_node(&debug_node); install_element(VIEW_NODE, &show_debugging_zebra_cmd); diff --git a/zebra/dplane_fpm_nl.c b/zebra/dplane_fpm_nl.c index f3bc670a1..0a827df14 100644 --- a/zebra/dplane_fpm_nl.c +++ b/zebra/dplane_fpm_nl.c @@ -368,9 +368,10 @@ static int fpm_write_config(struct vty *vty) return written; } -struct cmd_node fpm_node = { +static struct cmd_node fpm_node = { .node = VTY_NODE, .prompt = "", + .config_write = fpm_write_config, }; /* @@ -1102,7 +1103,7 @@ static int fpm_nl_new(struct thread_master *tm) if (IS_ZEBRA_DEBUG_DPLANE) zlog_debug("%s register status: %d", prov_name, rv); - install_node(&fpm_node, fpm_write_config); + install_node(&fpm_node); install_element(ENABLE_NODE, &fpm_show_counters_cmd); install_element(ENABLE_NODE, &fpm_show_counters_json_cmd); install_element(ENABLE_NODE, &fpm_reset_counters_cmd); diff --git a/zebra/interface.c b/zebra/interface.c index e330c4c84..8d119eac7 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -1664,9 +1664,11 @@ static void interface_update_stats(void) #endif /* HAVE_NET_RT_IFLIST */ } +static int if_config_write(struct vty *vty); struct cmd_node interface_node = { .node = INTERFACE_NODE, .prompt = "%s(config-if)# ", + .config_write = if_config_write, }; #ifndef VTYSH_EXTRACT_PL @@ -3315,8 +3317,8 @@ void zebra_if_init(void) hook_register_prio(if_del, 0, if_zebra_delete_hook); /* Install configuration write function. */ - install_node(&interface_node, if_config_write); - install_node(&link_params_node, NULL); + install_node(&interface_node); + install_node(&link_params_node); if_cmd_init(); /* * This is *intentionally* setting this to NULL, signaling diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index 03ad89dcb..beb6fcb2e 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -1938,10 +1938,12 @@ static int fpm_remote_srv_write(struct vty *vty) } +static int fpm_remote_srv_write(struct vty *vty); /* Zebra node */ static struct cmd_node zebra_node = { .node = ZEBRA_NODE, .prompt = "", + .config_write = fpm_remote_srv_write, }; @@ -1979,7 +1981,7 @@ static int zfpm_init(struct thread_master *master) zfpm_stats_init(&zfpm_g->last_ivl_stats); zfpm_stats_init(&zfpm_g->cumulative_stats); - install_node(&zebra_node, fpm_remote_srv_write); + install_node(&zebra_node); install_element(ENABLE_NODE, &show_zebra_fpm_stats_cmd); install_element(ENABLE_NODE, &clear_zebra_fpm_stats_cmd); install_element(CONFIG_NODE, &fpm_remote_ip_cmd); diff --git a/zebra/zebra_mpls_vty.c b/zebra/zebra_mpls_vty.c index 9137f3882..148b9c46d 100644 --- a/zebra/zebra_mpls_vty.c +++ b/zebra/zebra_mpls_vty.c @@ -449,10 +449,12 @@ DEFUN (no_mpls_label_global_block, return zebra_mpls_global_block(vty, 0, NULL, NULL); } +static int zebra_mpls_config(struct vty *vty); /* MPLS node for MPLS LSP. */ static struct cmd_node mpls_node = { .node = MPLS_NODE, .prompt = "", + .config_write = zebra_mpls_config, }; /* MPLS VTY. */ @@ -460,7 +462,7 @@ void zebra_mpls_vty_init(void) { install_element(VIEW_NODE, &show_mpls_status_cmd); - install_node(&mpls_node, zebra_mpls_config); + install_node(&mpls_node); install_element(CONFIG_NODE, &mpls_transit_lsp_cmd); install_element(CONFIG_NODE, &no_mpls_transit_lsp_cmd); diff --git a/zebra/zebra_pw.c b/zebra/zebra_pw.c index 16f39cd0c..9717805d0 100644 --- a/zebra/zebra_pw.c +++ b/zebra/zebra_pw.c @@ -547,14 +547,16 @@ static int zebra_pw_config(struct vty *vty) return write; } +static int zebra_pw_config(struct vty *vty); static struct cmd_node pw_node = { .node = PW_NODE, .prompt = "%s(config-pw)# ", + .config_write = zebra_pw_config, }; void zebra_pw_vty_init(void) { - install_node(&pw_node, zebra_pw_config); + install_node(&pw_node); install_default(PW_NODE); install_element(CONFIG_NODE, &pseudowire_if_cmd); diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index c3199bcb5..bb8d0c774 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -3478,30 +3478,38 @@ DEFUN_HIDDEN (show_frr, } /* IP node for static routes. */ +static int zebra_ip_config(struct vty *vty); static struct cmd_node ip_node = { .node = IP_NODE, .prompt = "", + .config_write = zebra_ip_config, }; +static int config_write_protocol(struct vty *vty); static struct cmd_node protocol_node = { .node = PROTOCOL_NODE, .prompt = "", + .config_write = config_write_protocol, }; /* table node for routing tables. */ +static int config_write_table(struct vty *vty); static struct cmd_node table_node = { .node = TABLE_NODE, .prompt = "", + .config_write = config_write_table, }; +static int config_write_forwarding(struct vty *vty); static struct cmd_node forwarding_node = { .node = FORWARDING_NODE, .prompt = "", + .config_write = config_write_forwarding, }; /* Route VTY. */ void zebra_vty_init(void) { /* Install configuration write function. */ - install_node(&table_node, config_write_table); - install_node(&forwarding_node, config_write_forwarding); + install_node(&table_node); + install_node(&forwarding_node); install_element(VIEW_NODE, &show_ip_forwarding_cmd); install_element(CONFIG_NODE, &ip_forwarding_cmd); @@ -3515,8 +3523,8 @@ void zebra_vty_init(void) /* Route-map */ zebra_route_map_init(); - install_node(&ip_node, zebra_ip_config); - install_node(&protocol_node, config_write_protocol); + install_node(&ip_node); + install_node(&protocol_node); install_element(CONFIG_NODE, &allow_external_route_update_cmd); install_element(CONFIG_NODE, &no_allow_external_route_update_cmd); -- cgit v1.2.3 From 243895805abcd27cc23f784c0b42036197fa1c3c Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Sat, 8 Sep 2018 23:15:09 +0200 Subject: *: move CLI parent data to cmd_node->parent_node Same as before, instead of shoving this into a big central list we can just put the parent node in cmd_node. Signed-off-by: David Lamparter --- babeld/babel_interface.c | 1 + babeld/babeld.c | 1 + bfdd/bfdd_vty.c | 2 ++ bgpd/bgp_bmp.c | 1 + bgpd/bgp_rpki.c | 1 + bgpd/bgp_vty.c | 13 ++++++++ bgpd/rfapi/bgp_rfapi_cfg.c | 4 +++ eigrpd/eigrp_cli.c | 2 ++ isisd/isis_circuit.c | 1 + isisd/isisd.c | 1 + ldpd/ldp_vty_conf.c | 7 +++++ lib/command.c | 72 +++---------------------------------------- lib/command.h | 1 + lib/keychain.c | 2 ++ lib/nexthop_group.c | 1 + lib/routemap_cli.c | 1 + lib/vrf.c | 1 + lib/vty.c | 19 ++++++++++++ nhrpd/nhrp_vty.c | 2 ++ ospf6d/ospf6_interface.c | 1 + ospf6d/ospf6_top.c | 1 + ospfd/ospf_vty.c | 2 ++ pbrd/pbr_vty.c | 2 ++ pimd/pim_cmd.c | 1 + ripd/rip_interface.c | 1 + ripd/ripd.c | 1 + ripngd/ripng_interface.c | 1 + ripngd/ripngd.c | 1 + tests/lib/cli/test_commands.c | 16 ++++++++++ vrrpd/vrrp_vty.c | 1 + vtysh/vtysh.c | 46 +++++++++++++++++++++++++++ zebra/interface.c | 2 ++ zebra/zebra_fpm.c | 1 + zebra/zebra_pw.c | 1 + 34 files changed, 144 insertions(+), 67 deletions(-) (limited to 'pimd') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 4360ec8e8..072ad7060 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -61,6 +61,7 @@ static vector babel_enable_if; /* enable interfaces (by cmd). */ static int interface_config_write(struct vty *vty); static struct cmd_node babel_interface_node = { .node = INTERFACE_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", .config_write = interface_config_write, }; diff --git a/babeld/babeld.c b/babeld/babeld.c index 2eaa9c968..6a83fa102 100644 --- a/babeld/babeld.c +++ b/babeld/babeld.c @@ -73,6 +73,7 @@ static int babel_config_write (struct vty *vty); static struct cmd_node cmd_babel_node = { .node = BABEL_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", .config_write = babel_config_write, }; diff --git a/bfdd/bfdd_vty.c b/bfdd/bfdd_vty.c index 62a0016a1..5a4ce22b2 100644 --- a/bfdd/bfdd_vty.c +++ b/bfdd/bfdd_vty.c @@ -888,12 +888,14 @@ DEFUN_NOSH(show_debugging_bfd, static int bfdd_write_config(struct vty *vty); struct cmd_node bfd_node = { .node = BFD_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-bfd)# ", .config_write = bfdd_write_config, }; struct cmd_node bfd_peer_node = { .node = BFD_PEER_NODE, + .parent_node = BFD_NODE, .prompt = "%s(config-bfd-peer)# ", }; diff --git a/bgpd/bgp_bmp.c b/bgpd/bgp_bmp.c index 7a97ff19d..0a0271dd1 100644 --- a/bgpd/bgp_bmp.c +++ b/bgpd/bgp_bmp.c @@ -1774,6 +1774,7 @@ static void bmp_active_setup(struct bmp_active *ba) static struct cmd_node bmp_node = { .node = BMP_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-bgp-bmp)# " }; diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c index 9bffa65c4..2d11718b5 100644 --- a/bgpd/bgp_rpki.c +++ b/bgpd/bgp_rpki.c @@ -145,6 +145,7 @@ static int rpki_sync_socket_bgpd; static struct cmd_node rpki_node = { .node = RPKI_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-rpki)# ", .config_write = config_write, }; diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 78cbe250c..e44f51518 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -15336,67 +15336,80 @@ int bgp_config_write(struct vty *vty) /* BGP node structure. */ static struct cmd_node bgp_node = { .node = BGP_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", .config_write = bgp_config_write, }; static struct cmd_node bgp_ipv4_unicast_node = { .node = BGP_IPV4_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv4_multicast_node = { .node = BGP_IPV4M_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv4_labeled_unicast_node = { .node = BGP_IPV4L_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv6_unicast_node = { .node = BGP_IPV6_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv6_multicast_node = { .node = BGP_IPV6M_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv6_labeled_unicast_node = { .node = BGP_IPV6L_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_vpnv4_node = { .node = BGP_VPNV4_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_vpnv6_node = { .node = BGP_VPNV6_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af-vpnv6)# ", }; static struct cmd_node bgp_evpn_node = { .node = BGP_EVPN_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-evpn)# ", }; static struct cmd_node bgp_evpn_vni_node = { .node = BGP_EVPN_VNI_NODE, + .parent_node = BGP_EVPN_NODE, .prompt = "%s(config-router-af-vni)# ", }; static struct cmd_node bgp_flowspecv4_node = { .node = BGP_FLOWSPECV4_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_flowspecv6_node = { .node = BGP_FLOWSPECV6_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af-vpnv6)# ", }; diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index 38d4ff9a4..929165aa6 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -2966,11 +2966,13 @@ DEFUN_NOSH (exit_vnc, static struct cmd_node bgp_vnc_defaults_node = { .node = BGP_VNC_DEFAULTS_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-vnc-defaults)# ", }; static struct cmd_node bgp_vnc_nve_group_node = { .node = BGP_VNC_NVE_GROUP_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-vnc-nve-group)# ", }; @@ -3393,6 +3395,7 @@ DEFUN_NOSH (exit_vrf_policy, static struct cmd_node bgp_vrf_policy_node = { .node = BGP_VRF_POLICY_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-vrf-policy)# ", }; @@ -3631,6 +3634,7 @@ DEFUN (vnc_l2_group_rt, static struct cmd_node bgp_vnc_l2_group_node = { .node = BGP_VNC_L2_GROUP_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-vnc-l2-group)# ", }; diff --git a/eigrpd/eigrp_cli.c b/eigrpd/eigrp_cli.c index 511195286..502d29ebf 100644 --- a/eigrpd/eigrp_cli.c +++ b/eigrpd/eigrp_cli.c @@ -841,6 +841,7 @@ void eigrp_cli_show_keychain(struct vty *vty, struct lyd_node *dnode, static int eigrp_config_write(struct vty *vty); static struct cmd_node eigrp_node = { .node = EIGRP_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", .config_write = eigrp_config_write, }; @@ -862,6 +863,7 @@ static int eigrp_config_write(struct vty *vty) static int eigrp_write_interface(struct vty *vty); static struct cmd_node eigrp_interface_node = { .node = INTERFACE_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", .config_write = eigrp_write_interface, }; diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index 10874fad3..47e91ac10 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -1336,6 +1336,7 @@ ferr_r isis_circuit_passwd_hmac_md5_set(struct isis_circuit *circuit, struct cmd_node interface_node = { .node = INTERFACE_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", .config_write = isis_interface_config_write, }; diff --git a/isisd/isisd.c b/isisd/isisd.c index 29d7f914f..a776e2da0 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -2147,6 +2147,7 @@ static int isis_config_write(struct vty *vty) struct cmd_node router_node = { .node = ROUTER_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", .config_write = isis_config_write, }; diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c index 69aa3220b..ca82263b7 100644 --- a/ldpd/ldp_vty_conf.c +++ b/ldpd/ldp_vty_conf.c @@ -41,38 +41,45 @@ static int ldp_iface_is_configured(struct ldpd_conf *, const char *); struct cmd_node ldp_node = { .node = LDP_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-ldp)# ", .config_write = ldp_config_write, }; struct cmd_node ldp_ipv4_node = { .node = LDP_IPV4_NODE, + .parent_node = LDP_NODE, .prompt = "%s(config-ldp-af)# ", }; struct cmd_node ldp_ipv6_node = { .node = LDP_IPV6_NODE, + .parent_node = LDP_NODE, .prompt = "%s(config-ldp-af)# ", }; struct cmd_node ldp_ipv4_iface_node = { .node = LDP_IPV4_IFACE_NODE, + .parent_node = LDP_IPV4_NODE, .prompt = "%s(config-ldp-af-if)# ", }; struct cmd_node ldp_ipv6_iface_node = { .node = LDP_IPV6_IFACE_NODE, + .parent_node = LDP_IPV6_NODE, .prompt = "%s(config-ldp-af-if)# ", }; struct cmd_node ldp_l2vpn_node = { .node = LDP_L2VPN_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-l2vpn)# ", .config_write = ldp_l2vpn_config_write, }; struct cmd_node ldp_pseudowire_node = { .node = LDP_PSEUDOWIRE_NODE, + .parent_node = LDP_L2VPN_NODE, .prompt = "%s(config-l2vpn-pw)# ", }; diff --git a/lib/command.c b/lib/command.c index 7d46202da..dad35bfbf 100644 --- a/lib/command.c +++ b/lib/command.c @@ -203,6 +203,7 @@ static struct cmd_node enable_node = { static int config_write_host(struct vty *vty); static struct cmd_node config_node = { .node = CONFIG_NODE, + .parent_node = ENABLE_NODE, .prompt = "%s(config)# ", .config_write = config_write_host, }; @@ -1458,6 +1459,8 @@ DEFUN (config_exit, void cmd_exit(struct vty *vty) { + struct cmd_node *cnode = vector_lookup(cmdvec, vty->node); + switch (vty->node) { case VIEW_NODE: case ENABLE_NODE: @@ -1470,73 +1473,9 @@ void cmd_exit(struct vty *vty) vty->node = ENABLE_NODE; vty_config_exit(vty); break; - case INTERFACE_NODE: - case PW_NODE: - case VRF_NODE: - case NH_GROUP_NODE: - case ZEBRA_NODE: - case BGP_NODE: - case RIP_NODE: - case EIGRP_NODE: - case BABEL_NODE: - case RIPNG_NODE: - case OSPF_NODE: - case OSPF6_NODE: - case LDP_NODE: - case LDP_L2VPN_NODE: - case ISIS_NODE: - case OPENFABRIC_NODE: - case KEYCHAIN_NODE: - case RMAP_NODE: - case PBRMAP_NODE: - case VTY_NODE: - case BFD_NODE: - vty->node = CONFIG_NODE; - break; - case BGP_IPV4_NODE: - case BGP_IPV4M_NODE: - case BGP_IPV4L_NODE: - case BGP_VPNV4_NODE: - case BGP_VPNV6_NODE: - case BGP_FLOWSPECV4_NODE: - case BGP_FLOWSPECV6_NODE: - case BGP_VRF_POLICY_NODE: - case BGP_VNC_DEFAULTS_NODE: - case BGP_VNC_NVE_GROUP_NODE: - case BGP_VNC_L2_GROUP_NODE: - case BGP_IPV6_NODE: - case BGP_IPV6M_NODE: - case BGP_EVPN_NODE: - case BGP_IPV6L_NODE: - case BMP_NODE: - vty->node = BGP_NODE; - break; - case BGP_EVPN_VNI_NODE: - vty->node = BGP_EVPN_NODE; - break; - case LDP_IPV4_NODE: - case LDP_IPV6_NODE: - vty->node = LDP_NODE; - break; - case LDP_IPV4_IFACE_NODE: - vty->node = LDP_IPV4_NODE; - break; - case LDP_IPV6_IFACE_NODE: - vty->node = LDP_IPV6_NODE; - break; - case LDP_PSEUDOWIRE_NODE: - vty->node = LDP_L2VPN_NODE; - break; - case KEYCHAIN_KEY_NODE: - vty->node = KEYCHAIN_NODE; - break; - case LINK_PARAMS_NODE: - vty->node = INTERFACE_NODE; - break; - case BFD_PEER_NODE: - vty->node = BFD_NODE; - break; default: + if (cnode->parent_node) + vty->node = cnode->parent_node; break; } @@ -1564,7 +1503,6 @@ DEFUN (config_end, vty_config_exit(vty); vty->node = ENABLE_NODE; } - return CMD_SUCCESS; } diff --git a/lib/command.h b/lib/command.h index ed7706c30..c1de67e10 100644 --- a/lib/command.h +++ b/lib/command.h @@ -172,6 +172,7 @@ extern const char *const node_names[]; struct cmd_node { /* Node index. */ enum node_type node; + enum node_type parent_node; /* Prompt character at vty interface. */ const char *prompt; diff --git a/lib/keychain.c b/lib/keychain.c index bbe2070b1..bfeaa7fec 100644 --- a/lib/keychain.c +++ b/lib/keychain.c @@ -962,12 +962,14 @@ DEFUN (no_send_lifetime, static int keychain_config_write(struct vty *vty); static struct cmd_node keychain_node = { .node = KEYCHAIN_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-keychain)# ", .config_write = keychain_config_write, }; static struct cmd_node keychain_key_node = { .node = KEYCHAIN_KEY_NODE, + .parent_node = KEYCHAIN_NODE, .prompt = "%s(config-keychain-key)# ", }; diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c index cce5af1e7..554460529 100644 --- a/lib/nexthop_group.c +++ b/lib/nexthop_group.c @@ -936,6 +936,7 @@ DEFPY(ecmp_nexthops, ecmp_nexthops_cmd, static int nexthop_group_write(struct vty *vty); static struct cmd_node nexthop_group_node = { .node = NH_GROUP_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-nh-group)# ", .config_write = nexthop_group_write, }; diff --git a/lib/routemap_cli.c b/lib/routemap_cli.c index b97948d5c..16ecd1194 100644 --- a/lib/routemap_cli.c +++ b/lib/routemap_cli.c @@ -1067,6 +1067,7 @@ static int route_map_config_write(struct vty *vty) static int route_map_config_write(struct vty *vty); static struct cmd_node rmap_node = { .node = RMAP_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-route-map)# ", .config_write = route_map_config_write, }; diff --git a/lib/vrf.c b/lib/vrf.c index b825ff03f..1fadf5c0c 100644 --- a/lib/vrf.c +++ b/lib/vrf.c @@ -760,6 +760,7 @@ DEFUN (no_vrf, static struct cmd_node vrf_node = { .node = VRF_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-vrf)# ", }; diff --git a/lib/vty.c b/lib/vty.c index 1d94d3d31..24cdfeda4 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -2605,6 +2605,24 @@ int vty_config_enter(struct vty *vty, bool private_config, bool exclusive) void vty_config_exit(struct vty *vty) { + enum node_type node = vty->node; + struct cmd_node *cnode; + + /* unlock and jump up to ENABLE_NODE if -and only if- we're + * somewhere below CONFIG_NODE */ + while (node && node != CONFIG_NODE) { + cnode = vector_lookup(cmdvec, node); + node = cnode->parent_node; + } + if (node != CONFIG_NODE) { + vty_out(vty, + "WARNING: vty_config_exit() from outside CONFIG_NODE!\n"); + return; + } + + while (vty->node != ENABLE_NODE) + cmd_exit(vty); + /* Check if there's a pending confirmed commit. */ if (vty->t_confirmed_commit_timeout) { vty_out(vty, @@ -2992,6 +3010,7 @@ static int vty_config_write(struct vty *vty) static int vty_config_write(struct vty *vty); struct cmd_node vty_node = { .node = VTY_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-line)# ", .config_write = vty_config_write, }; diff --git a/nhrpd/nhrp_vty.c b/nhrpd/nhrp_vty.c index f9ed1e96c..bf29d0218 100644 --- a/nhrpd/nhrp_vty.c +++ b/nhrpd/nhrp_vty.c @@ -20,6 +20,7 @@ static int nhrp_config_write(struct vty *vty); static struct cmd_node zebra_node = { .node = ZEBRA_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", .config_write = nhrp_config_write, }; @@ -27,6 +28,7 @@ static struct cmd_node zebra_node = { static int interface_config_write(struct vty *vty); static struct cmd_node nhrp_interface_node = { .node = INTERFACE_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", .config_write = interface_config_write, }; diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index 3d1c6f9fa..8ed9c6797 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -1946,6 +1946,7 @@ static int config_write_ospf6_interface(struct vty *vty) static int config_write_ospf6_interface(struct vty *vty); static struct cmd_node interface_node = { .node = INTERFACE_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", .config_write = config_write_ospf6_interface, }; diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index 616865621..75c0460ec 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -1116,6 +1116,7 @@ static int config_write_ospf6(struct vty *vty); /* OSPF6 node structure. */ static struct cmd_node ospf6_node = { .node = OSPF6_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-ospf6)# ", .config_write = config_write_ospf6, }; diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index ab12c3818..25bd41001 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -10559,6 +10559,7 @@ static int config_write_interface(struct vty *vty); /* ospfd's interface node. */ static struct cmd_node interface_node = { .node = INTERFACE_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", .config_write = config_write_interface, }; @@ -10676,6 +10677,7 @@ static void ospf_vty_zebra_init(void) static int ospf_config_write(struct vty *vty); static struct cmd_node ospf_node = { .node = OSPF_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", .config_write = ospf_config_write, }; diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c index 2f5d4dcbc..35dbb24d1 100644 --- a/pbrd/pbr_vty.c +++ b/pbrd/pbr_vty.c @@ -732,6 +732,7 @@ DEFUN_NOSH(show_debugging_pbr, static int pbr_interface_config_write(struct vty *vty); static struct cmd_node interface_node = { .node = INTERFACE_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", .config_write = pbr_interface_config_write, }; @@ -765,6 +766,7 @@ static int pbr_vty_map_config_write(struct vty *vty); /* PBR map node structure. */ static struct cmd_node pbr_map_node = { .node = PBRMAP_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-pbr-map)# ", .config_write = pbr_vty_map_config_write, }; diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index a386e33d2..895072a89 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -71,6 +71,7 @@ static struct cmd_node interface_node = { .node = INTERFACE_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", .config_write = pim_interface_config_write, }; diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index 87899e468..924eb8334 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -1196,6 +1196,7 @@ int rip_show_network_config(struct vty *vty, struct rip *rip) static int rip_interface_config_write(struct vty *vty); static struct cmd_node interface_node = { .node = INTERFACE_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", .config_write = rip_interface_config_write, }; diff --git a/ripd/ripd.c b/ripd/ripd.c index 71511deb1..b6bbfb253 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -3331,6 +3331,7 @@ static int config_write_rip(struct vty *vty); /* RIP node structure. */ static struct cmd_node rip_node = { .node = RIP_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", .config_write = config_write_rip, }; diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c index efaabdb6d..e45bbbe21 100644 --- a/ripngd/ripng_interface.c +++ b/ripngd/ripng_interface.c @@ -958,6 +958,7 @@ static int interface_config_write(struct vty *vty); /* ripngd's interface node. */ static struct cmd_node interface_node = { .node = INTERFACE_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", .config_write = interface_config_write, }; diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index cde8d860e..47083f947 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -2438,6 +2438,7 @@ static int ripng_config_write(struct vty *vty); /* RIPng node structure. */ static struct cmd_node cmd_ripng_node = { .node = RIPNG_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", .config_write = ripng_config_write, }; diff --git a/tests/lib/cli/test_commands.c b/tests/lib/cli/test_commands.c index d269e51be..54417f495 100644 --- a/tests/lib/cli/test_commands.c +++ b/tests/lib/cli/test_commands.c @@ -50,81 +50,97 @@ static char test_buf[32768]; static struct cmd_node bgp_node = { .node = BGP_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node rip_node = { .node = RIP_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node isis_node = { .node = ISIS_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node interface_node = { .node = INTERFACE_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", }; static struct cmd_node rmap_node = { .node = RMAP_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-route-map)# ", }; static struct cmd_node zebra_node = { .node = ZEBRA_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node bgp_vpnv4_node = { .node = BGP_VPNV4_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv4_node = { .node = BGP_IPV4_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv4m_node = { .node = BGP_IPV4M_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv6_node = { .node = BGP_IPV6_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv6m_node = { .node = BGP_IPV6M_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node ospf_node = { .node = OSPF_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node ripng_node = { .node = RIPNG_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node ospf6_node = { .node = OSPF6_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-ospf6)# ", }; static struct cmd_node keychain_node = { .node = KEYCHAIN_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-keychain)# ", }; static struct cmd_node keychain_key_node = { .node = KEYCHAIN_KEY_NODE, + .parent_node = KEYCHAIN_NODE, .prompt = "%s(config-keychain-key)# ", }; diff --git a/vrrpd/vrrp_vty.c b/vrrpd/vrrp_vty.c index 98ce74593..f2048db98 100644 --- a/vrrpd/vrrp_vty.c +++ b/vrrpd/vrrp_vty.c @@ -746,6 +746,7 @@ static int vrrp_config_write_interface(struct vty *vty) static struct cmd_node interface_node = { .node = INTERFACE_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", .config_write = vrrp_config_write_interface, }; diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 028a9c7e0..ddb40a572 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -1174,232 +1174,278 @@ static char **new_completion(const char *text, int start, int end) /* Vty node structures. */ static struct cmd_node bgp_node = { .node = BGP_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node rip_node = { .node = RIP_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node isis_node = { .node = ISIS_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node openfabric_node = { .node = OPENFABRIC_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node interface_node = { .node = INTERFACE_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", }; static struct cmd_node pw_node = { .node = PW_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-pw)# ", }; static struct cmd_node vrf_node = { .node = VRF_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-vrf)# ", }; static struct cmd_node nh_group_node = { .node = NH_GROUP_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-nh-group)# ", }; static struct cmd_node rmap_node = { .node = RMAP_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-route-map)# ", }; static struct cmd_node pbr_map_node = { .node = PBRMAP_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-pbr-map)# ", }; static struct cmd_node zebra_node = { .node = ZEBRA_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node bgp_vpnv4_node = { .node = BGP_VPNV4_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_vpnv6_node = { .node = BGP_VPNV6_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_flowspecv4_node = { .node = BGP_FLOWSPECV4_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_flowspecv6_node = { .node = BGP_FLOWSPECV6_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv4_node = { .node = BGP_IPV4_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv4m_node = { .node = BGP_IPV4M_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv4l_node = { .node = BGP_IPV4L_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv6_node = { .node = BGP_IPV6_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv6m_node = { .node = BGP_IPV6M_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_evpn_node = { .node = BGP_EVPN_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_evpn_vni_node = { .node = BGP_EVPN_VNI_NODE, + .parent_node = BGP_EVPN_NODE, .prompt = "%s(config-router-af-vni)# ", }; static struct cmd_node bgp_ipv6l_node = { .node = BGP_IPV6L_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_vnc_defaults_node = { .node = BGP_VNC_DEFAULTS_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-vnc-defaults)# ", }; static struct cmd_node bgp_vnc_nve_group_node = { .node = BGP_VNC_NVE_GROUP_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-vnc-nve-group)# ", }; static struct cmd_node bgp_vrf_policy_node = { .node = BGP_VRF_POLICY_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-vrf-policy)# ", }; static struct cmd_node bgp_vnc_l2_group_node = { .node = BGP_VNC_L2_GROUP_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-router-vnc-l2-group)# ", }; static struct cmd_node bmp_node = { .node = BMP_NODE, + .parent_node = BGP_NODE, .prompt = "%s(config-bgp-bmp)# " }; static struct cmd_node ospf_node = { .node = OSPF_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node eigrp_node = { .node = EIGRP_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node babel_node = { .node = BABEL_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node ripng_node = { .node = RIPNG_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node ospf6_node = { .node = OSPF6_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-ospf6)# ", }; static struct cmd_node ldp_node = { .node = LDP_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-ldp)# ", }; static struct cmd_node ldp_ipv4_node = { .node = LDP_IPV4_NODE, + .parent_node = LDP_NODE, .prompt = "%s(config-ldp-af)# ", }; static struct cmd_node ldp_ipv6_node = { .node = LDP_IPV6_NODE, + .parent_node = LDP_NODE, .prompt = "%s(config-ldp-af)# ", }; static struct cmd_node ldp_ipv4_iface_node = { .node = LDP_IPV4_IFACE_NODE, + .parent_node = LDP_IPV4_NODE, .prompt = "%s(config-ldp-af-if)# ", }; static struct cmd_node ldp_ipv6_iface_node = { .node = LDP_IPV6_IFACE_NODE, + .parent_node = LDP_IPV6_NODE, .prompt = "%s(config-ldp-af-if)# ", }; static struct cmd_node ldp_l2vpn_node = { .node = LDP_L2VPN_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-l2vpn)# ", }; static struct cmd_node ldp_pseudowire_node = { .node = LDP_PSEUDOWIRE_NODE, + .parent_node = LDP_L2VPN_NODE, .prompt = "%s(config-l2vpn-pw)# ", }; static struct cmd_node keychain_node = { .node = KEYCHAIN_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-keychain)# ", }; static struct cmd_node keychain_key_node = { .node = KEYCHAIN_KEY_NODE, + .parent_node = KEYCHAIN_NODE, .prompt = "%s(config-keychain-key)# ", }; struct cmd_node link_params_node = { .node = LINK_PARAMS_NODE, + .parent_node = INTERFACE_NODE, .prompt = "%s(config-link-params)# ", }; static struct cmd_node rpki_node = { .node = RPKI_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-rpki)# ", }; #if HAVE_BFDD > 0 static struct cmd_node bfd_node = { .node = BFD_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-bfd)# ", }; static struct cmd_node bfd_peer_node = { .node = BFD_PEER_NODE, + .parent_node = BFD_NODE, .prompt = "%s(config-bfd-peer)# ", }; #endif /* HAVE_BFDD */ diff --git a/zebra/interface.c b/zebra/interface.c index 8d119eac7..f4b330d8a 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -1667,6 +1667,7 @@ static void interface_update_stats(void) static int if_config_write(struct vty *vty); struct cmd_node interface_node = { .node = INTERFACE_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", .config_write = if_config_write, }; @@ -2080,6 +2081,7 @@ DEFUN (no_bandwidth_if, struct cmd_node link_params_node = { .node = LINK_PARAMS_NODE, + .parent_node = INTERFACE_NODE, .prompt = "%s(config-link-params)# ", }; diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index beb6fcb2e..462a75b55 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -1942,6 +1942,7 @@ static int fpm_remote_srv_write(struct vty *vty); /* Zebra node */ static struct cmd_node zebra_node = { .node = ZEBRA_NODE, + .parent_node = CONFIG_NODE, .prompt = "", .config_write = fpm_remote_srv_write, }; diff --git a/zebra/zebra_pw.c b/zebra/zebra_pw.c index 9717805d0..188540128 100644 --- a/zebra/zebra_pw.c +++ b/zebra/zebra_pw.c @@ -550,6 +550,7 @@ static int zebra_pw_config(struct vty *vty) static int zebra_pw_config(struct vty *vty); static struct cmd_node pw_node = { .node = PW_NODE, + .parent_node = CONFIG_NODE, .prompt = "%s(config-pw)# ", .config_write = zebra_pw_config, }; -- cgit v1.2.3 From f4b8291fcbcfb16c23d07c60d4669afaf396dbea Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Sun, 9 Sep 2018 00:15:50 +0200 Subject: *: move CLI node names to cmd_node->name And again for the name. Why on earth would we centralize this, just so people can forget to update it? Signed-off-by: David Lamparter --- babeld/babel_interface.c | 1 + babeld/babeld.c | 1 + bfdd/bfdd_vty.c | 2 + bgpd/bgp_bmp.c | 1 + bgpd/bgp_debug.c | 1 + bgpd/bgp_dump.c | 1 + bgpd/bgp_filter.c | 1 + bgpd/bgp_rpki.c | 1 + bgpd/bgp_vty.c | 14 ++++++ bgpd/rfapi/bgp_rfapi_cfg.c | 4 ++ bgpd/rfapi/vnc_debug.c | 1 + eigrpd/eigrp_cli.c | 2 + eigrpd/eigrp_dump.c | 1 + isisd/isis_circuit.c | 1 + isisd/isisd.c | 13 +++++- ldpd/ldp_debug.c | 1 + ldpd/ldp_vty_conf.c | 7 +++ lib/agentx.c | 1 + lib/command.c | 102 +++++------------------------------------- lib/command.h | 3 +- lib/filter.c | 3 ++ lib/grammar_sandbox.c | 2 +- lib/keychain.c | 2 + lib/nexthop_group.c | 1 + lib/northbound_cli.c | 1 + lib/plist.c | 2 + lib/resolver.c | 1 + lib/routemap.c | 1 + lib/routemap_cli.c | 1 + lib/vrf.c | 2 + lib/vty.c | 1 + nhrpd/nhrp_vty.c | 2 + ospf6d/ospf6_interface.c | 1 + ospf6d/ospf6_top.c | 1 + ospf6d/ospf6d.c | 1 + ospfd/ospf_dump.c | 1 + ospfd/ospf_vty.c | 2 + pbrd/pbr_vty.c | 3 ++ pimd/pim_cmd.c | 2 + ripd/rip_debug.c | 1 + ripd/rip_interface.c | 1 + ripd/ripd.c | 1 + ripngd/ripng_debug.c | 1 + ripngd/ripng_interface.c | 1 + ripngd/ripngd.c | 1 + staticd/static_vty.c | 1 + tests/lib/cli/test_commands.c | 16 +++++++ vrrpd/vrrp_vty.c | 3 ++ vtysh/vtysh.c | 48 +++++++++++++++++++- zebra/debug.c | 1 + zebra/interface.c | 2 + zebra/zebra_fpm.c | 1 + zebra/zebra_mpls_vty.c | 1 + zebra/zebra_pw.c | 1 + zebra/zebra_vty.c | 4 ++ 55 files changed, 178 insertions(+), 95 deletions(-) (limited to 'pimd') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 072ad7060..21fb48163 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -60,6 +60,7 @@ static void babel_interface_free (babel_interface_nfo *bi); static vector babel_enable_if; /* enable interfaces (by cmd). */ static int interface_config_write(struct vty *vty); static struct cmd_node babel_interface_node = { + .name = "interface", .node = INTERFACE_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", diff --git a/babeld/babeld.c b/babeld/babeld.c index 6a83fa102..906f48564 100644 --- a/babeld/babeld.c +++ b/babeld/babeld.c @@ -72,6 +72,7 @@ static time_t source_expiry_time; static int babel_config_write (struct vty *vty); static struct cmd_node cmd_babel_node = { + .name = "babel", .node = BABEL_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", diff --git a/bfdd/bfdd_vty.c b/bfdd/bfdd_vty.c index 5a4ce22b2..71d0a49f6 100644 --- a/bfdd/bfdd_vty.c +++ b/bfdd/bfdd_vty.c @@ -887,6 +887,7 @@ DEFUN_NOSH(show_debugging_bfd, static int bfdd_write_config(struct vty *vty); struct cmd_node bfd_node = { + .name = "bfd", .node = BFD_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-bfd)# ", @@ -894,6 +895,7 @@ struct cmd_node bfd_node = { }; struct cmd_node bfd_peer_node = { + .name = "bfd peer", .node = BFD_PEER_NODE, .parent_node = BFD_NODE, .prompt = "%s(config-bfd-peer)# ", diff --git a/bgpd/bgp_bmp.c b/bgpd/bgp_bmp.c index 0a0271dd1..8902a8789 100644 --- a/bgpd/bgp_bmp.c +++ b/bgpd/bgp_bmp.c @@ -1773,6 +1773,7 @@ static void bmp_active_setup(struct bmp_active *ba) } static struct cmd_node bmp_node = { + .name = "bmp", .node = BMP_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-bgp-bmp)# " diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index a20015bbc..f503c1b18 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -2284,6 +2284,7 @@ static int bgp_config_write_debug(struct vty *vty) static int bgp_config_write_debug(struct vty *vty); static struct cmd_node debug_node = { + .name = "debug", .node = DEBUG_NODE, .prompt = "", .config_write = bgp_config_write_debug, diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index 36efcd538..a79c5e0da 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -780,6 +780,7 @@ DEFUN (no_dump_bgp_all, static int config_write_bgp_dump(struct vty *vty); /* BGP node structure. */ static struct cmd_node bgp_dump_node = { + .name = "dump", .node = DUMP_NODE, .prompt = "", .config_write = config_write_bgp_dump, diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c index 0f70e6e5a..3e26263df 100644 --- a/bgpd/bgp_filter.c +++ b/bgpd/bgp_filter.c @@ -669,6 +669,7 @@ static int config_write_as_list(struct vty *vty) static int config_write_as_list(struct vty *vty); static struct cmd_node as_list_node = { + .name = "as list", .node = AS_LIST_NODE, .prompt = "", .config_write = config_write_as_list, diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c index 2d11718b5..11ef8563c 100644 --- a/bgpd/bgp_rpki.c +++ b/bgpd/bgp_rpki.c @@ -144,6 +144,7 @@ static int rpki_sync_socket_rtr; static int rpki_sync_socket_bgpd; static struct cmd_node rpki_node = { + .name = "rpki", .node = RPKI_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-rpki)# ", diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index e44f51518..873edf66c 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -15335,6 +15335,7 @@ int bgp_config_write(struct vty *vty) /* BGP node structure. */ static struct cmd_node bgp_node = { + .name = "bgp", .node = BGP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", @@ -15342,72 +15343,84 @@ static struct cmd_node bgp_node = { }; static struct cmd_node bgp_ipv4_unicast_node = { + .name = "bgp ipv4 unicast", .node = BGP_IPV4_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv4_multicast_node = { + .name = "bgp ipv4 multicast", .node = BGP_IPV4M_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv4_labeled_unicast_node = { + .name = "bgp ipv4 labeled unicast", .node = BGP_IPV4L_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv6_unicast_node = { + .name = "bgp ipv6", .node = BGP_IPV6_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv6_multicast_node = { + .name = "bgp ipv6 multicast", .node = BGP_IPV6M_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv6_labeled_unicast_node = { + .name = "bgp ipv6 labeled unicast", .node = BGP_IPV6L_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_vpnv4_node = { + .name = "bgp vpnv4", .node = BGP_VPNV4_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_vpnv6_node = { + .name = "bgp vpnv6", .node = BGP_VPNV6_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af-vpnv6)# ", }; static struct cmd_node bgp_evpn_node = { + .name = "bgp evpn", .node = BGP_EVPN_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-evpn)# ", }; static struct cmd_node bgp_evpn_vni_node = { + .name = "bgp evpn vni", .node = BGP_EVPN_VNI_NODE, .parent_node = BGP_EVPN_NODE, .prompt = "%s(config-router-af-vni)# ", }; static struct cmd_node bgp_flowspecv4_node = { + .name = "bgp ipv4 flowspec", .node = BGP_FLOWSPECV4_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_flowspecv6_node = { + .name = "bgp ipv6 flowspec", .node = BGP_FLOWSPECV6_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af-vpnv6)# ", @@ -17893,6 +17906,7 @@ static int community_list_config_write(struct vty *vty) static int community_list_config_write(struct vty *vty); static struct cmd_node community_list_node = { + .name = "community list", .node = COMMUNITY_LIST_NODE, .prompt = "", .config_write = community_list_config_write, diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index 929165aa6..dd21a8391 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -2965,12 +2965,14 @@ DEFUN_NOSH (exit_vnc, } static struct cmd_node bgp_vnc_defaults_node = { + .name = "bgp vnc defaults", .node = BGP_VNC_DEFAULTS_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-vnc-defaults)# ", }; static struct cmd_node bgp_vnc_nve_group_node = { + .name = "bgp vnc nve", .node = BGP_VNC_NVE_GROUP_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-vnc-nve-group)# ", @@ -3394,6 +3396,7 @@ DEFUN_NOSH (exit_vrf_policy, } static struct cmd_node bgp_vrf_policy_node = { + .name = "bgp vrf policy", .node = BGP_VRF_POLICY_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-vrf-policy)# ", @@ -3633,6 +3636,7 @@ DEFUN (vnc_l2_group_rt, static struct cmd_node bgp_vnc_l2_group_node = { + .name = "bgp vnc l2", .node = BGP_VNC_L2_GROUP_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-vnc-l2-group)# ", diff --git a/bgpd/rfapi/vnc_debug.c b/bgpd/rfapi/vnc_debug.c index 5839d96f4..5c627efbe 100644 --- a/bgpd/rfapi/vnc_debug.c +++ b/bgpd/rfapi/vnc_debug.c @@ -175,6 +175,7 @@ static int bgp_vnc_config_write_debug(struct vty *vty) static int bgp_vnc_config_write_debug(struct vty *vty); static struct cmd_node debug_node = { + .name = "vnc debug", .node = DEBUG_VNC_NODE, .prompt = "", .config_write = bgp_vnc_config_write_debug, diff --git a/eigrpd/eigrp_cli.c b/eigrpd/eigrp_cli.c index 502d29ebf..c76e06768 100644 --- a/eigrpd/eigrp_cli.c +++ b/eigrpd/eigrp_cli.c @@ -840,6 +840,7 @@ void eigrp_cli_show_keychain(struct vty *vty, struct lyd_node *dnode, */ static int eigrp_config_write(struct vty *vty); static struct cmd_node eigrp_node = { + .name = "eigrp", .node = EIGRP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", @@ -862,6 +863,7 @@ static int eigrp_config_write(struct vty *vty) static int eigrp_write_interface(struct vty *vty); static struct cmd_node eigrp_interface_node = { + .name = "interface", .node = INTERFACE_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", diff --git a/eigrpd/eigrp_dump.c b/eigrpd/eigrp_dump.c index 05a25a433..a3d6eb2e9 100644 --- a/eigrpd/eigrp_dump.c +++ b/eigrpd/eigrp_dump.c @@ -557,6 +557,7 @@ DEFUN (no_debug_eigrp_packets, /* Debug node. */ static int config_write_debug(struct vty *vty); static struct cmd_node eigrp_debug_node = { + .name = "debug", .node = DEBUG_NODE, .prompt = "", .config_write = config_write_debug, diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index 47e91ac10..4add1e6bf 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -1335,6 +1335,7 @@ ferr_r isis_circuit_passwd_hmac_md5_set(struct isis_circuit *circuit, } struct cmd_node interface_node = { + .name = "interface", .node = INTERFACE_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", diff --git a/isisd/isisd.c b/isisd/isisd.c index a776e2da0..2bb028f5f 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -786,6 +786,7 @@ DEFUN_NOSH (show_debugging, static int config_write_debug(struct vty *vty); /* Debug node. */ static struct cmd_node debug_node = { + .name = "debug", .node = DEBUG_NODE, .prompt = "", .config_write = config_write_debug, @@ -2128,6 +2129,13 @@ static int isis_config_write(struct vty *vty) return write; } +struct cmd_node router_node = { + .name = "openfabric", + .node = OPENFABRIC_NODE, + .parent_node = CONFIG_NODE, + .prompt = "%s(config-router)# ", + .config_write = isis_config_write, +}; #else /* IS-IS configuration write function */ static int isis_config_write(struct vty *vty) @@ -2143,14 +2151,15 @@ static int isis_config_write(struct vty *vty) return write; } -#endif /* ifdef FABRICD */ struct cmd_node router_node = { - .node = ROUTER_NODE, + .name = "isis", + .node = ISIS_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", .config_write = isis_config_write, }; +#endif /* ifdef FABRICD */ void isis_init(void) { diff --git a/ldpd/ldp_debug.c b/ldpd/ldp_debug.c index 59d8676ec..b9ef60ff9 100644 --- a/ldpd/ldp_debug.c +++ b/ldpd/ldp_debug.c @@ -33,6 +33,7 @@ static int ldp_debug_config_write(struct vty *); /* Debug node. */ struct cmd_node ldp_debug_node = { + .name = "debug", .node = DEBUG_NODE, .prompt = "", .config_write = ldp_debug_config_write, diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c index ca82263b7..3abd0817a 100644 --- a/ldpd/ldp_vty_conf.c +++ b/ldpd/ldp_vty_conf.c @@ -40,6 +40,7 @@ static int ldp_vty_get_af(struct vty *); static int ldp_iface_is_configured(struct ldpd_conf *, const char *); struct cmd_node ldp_node = { + .name = "ldp", .node = LDP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-ldp)# ", @@ -47,30 +48,35 @@ struct cmd_node ldp_node = { }; struct cmd_node ldp_ipv4_node = { + .name = "ldp ipv4", .node = LDP_IPV4_NODE, .parent_node = LDP_NODE, .prompt = "%s(config-ldp-af)# ", }; struct cmd_node ldp_ipv6_node = { + .name = "ldp ipv6", .node = LDP_IPV6_NODE, .parent_node = LDP_NODE, .prompt = "%s(config-ldp-af)# ", }; struct cmd_node ldp_ipv4_iface_node = { + .name = "ldp ipv4 interface", .node = LDP_IPV4_IFACE_NODE, .parent_node = LDP_IPV4_NODE, .prompt = "%s(config-ldp-af-if)# ", }; struct cmd_node ldp_ipv6_iface_node = { + .name = "ldp ipv6 interface", .node = LDP_IPV6_IFACE_NODE, .parent_node = LDP_IPV6_NODE, .prompt = "%s(config-ldp-af-if)# ", }; struct cmd_node ldp_l2vpn_node = { + .name = "ldp l2vpn", .node = LDP_L2VPN_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-l2vpn)# ", @@ -78,6 +84,7 @@ struct cmd_node ldp_l2vpn_node = { }; struct cmd_node ldp_pseudowire_node = { + .name = "ldp", .node = LDP_PSEUDOWIRE_NODE, .parent_node = LDP_L2VPN_NODE, .prompt = "%s(config-l2vpn-pw)# ", diff --git a/lib/agentx.c b/lib/agentx.c index 42c843bbb..7c4bdcbe2 100644 --- a/lib/agentx.c +++ b/lib/agentx.c @@ -160,6 +160,7 @@ static void agentx_events_update(void) /* AgentX node. */ static int config_write_agentx(struct vty *vty); static struct cmd_node agentx_node = { + .name = "smux", .node = SMUX_NODE, .prompt = "", .config_write = config_write_agentx, diff --git a/lib/command.c b/lib/command.c index dad35bfbf..8ec93c1b3 100644 --- a/lib/command.c +++ b/lib/command.c @@ -73,86 +73,6 @@ const struct message tokennames[] = { item(END_TKN), {0}, }; - -const char *const node_names[] = { - "auth", // AUTH_NODE, - "view", // VIEW_NODE, - "auth enable", // AUTH_ENABLE_NODE, - "enable", // ENABLE_NODE, - "config", // CONFIG_NODE, - "debug", // DEBUG_NODE, - "vrf debug", // VRF_DEBUG_NODE, - "northbound debug", // NORTHBOUND_DEBUG_NODE, - "vnc debug", // DEBUG_VNC_NODE, - "route-map debug", /* RMAP_DEBUG_NODE */ - "resolver debug", /* RESOLVER_DEBUG_NODE */ - "aaa", // AAA_NODE, - "keychain", // KEYCHAIN_NODE, - "keychain key", // KEYCHAIN_KEY_NODE, - "static ip", // IP_NODE, - "vrf", // VRF_NODE, - "interface", // INTERFACE_NODE, - "nexthop-group", // NH_GROUP_NODE, - "zebra", // ZEBRA_NODE, - "table", // TABLE_NODE, - "rip", // RIP_NODE, - "ripng", // RIPNG_NODE, - "babel", // BABEL_NODE, - "eigrp", // EIGRP_NODE, - "bgp", // BGP_NODE, - "bgp vpnv4", // BGP_VPNV4_NODE, - "bgp vpnv6", // BGP_VPNV6_NODE, - "bgp ipv4 unicast", // BGP_IPV4_NODE, - "bgp ipv4 multicast", // BGP_IPV4M_NODE, - "bgp ipv4 labeled unicast", // BGP_IPV4L_NODE, - "bgp ipv6", // BGP_IPV6_NODE, - "bgp ipv6 multicast", // BGP_IPV6M_NODE, - "bgp ipv6 labeled unicast", // BGP_IPV6L_NODE, - "bgp vrf policy", // BGP_VRF_POLICY_NODE, - "bgp vnc defaults", // BGP_VNC_DEFAULTS_NODE, - "bgp vnc nve", // BGP_VNC_NVE_GROUP_NODE, - "bgp vnc l2", // BGP_VNC_L2_GROUP_NODE, - "rfp defaults", // RFP_DEFAULTS_NODE, - "bgp evpn", // BGP_EVPN_NODE, - "ospf", // OSPF_NODE, - "ospf6", // OSPF6_NODE, - "ldp", // LDP_NODE, - "ldp ipv4", // LDP_IPV4_NODE, - "ldp ipv6", // LDP_IPV6_NODE, - "ldp ipv4 interface", // LDP_IPV4_IFACE_NODE, - "ldp ipv6 interface", // LDP_IPV6_IFACE_NODE, - "ldp l2vpn", // LDP_L2VPN_NODE, - "ldp", // LDP_PSEUDOWIRE_NODE, - "isis", // ISIS_NODE, - "ipv4 access list", // ACCESS_NODE, - "ipv4 prefix list", // PREFIX_NODE, - "ipv6 access list", // ACCESS_IPV6_NODE, - "MAC access list", // ACCESS_MAC_NODE, - "ipv6 prefix list", // PREFIX_IPV6_NODE, - "as list", // AS_LIST_NODE, - "community list", // COMMUNITY_LIST_NODE, - "routemap", // RMAP_NODE, - "pbr-map", // PBRMAP_NODE, - "smux", // SMUX_NODE, - "dump", // DUMP_NODE, - "forwarding", // FORWARDING_NODE, - "protocol", // PROTOCOL_NODE, - "mpls", // MPLS_NODE, - "pw", // PW_NODE, - "vty", // VTY_NODE, - "link-params", // LINK_PARAMS_NODE, - "bgp evpn vni", // BGP_EVPN_VNI_NODE, - "rpki", // RPKI_NODE - "bgp ipv4 flowspec", /* BGP_FLOWSPECV4_NODE - */ - "bgp ipv6 flowspec", /* BGP_FLOWSPECV6_NODE - */ - "bfd", /* BFD_NODE */ - "bfd peer", /* BFD_PEER_NODE */ - "openfabric", // OPENFABRIC_NODE - "vrrp", /* VRRP_NODE */ - "bmp", /* BMP_NODE */ -}; /* clang-format on */ /* Command vector which includes some level of command lists. Normally @@ -181,27 +101,32 @@ const char *cmd_domainname_get(void) /* Standard command node structures. */ static struct cmd_node auth_node = { + .name = "auth", .node = AUTH_NODE, .prompt = "Password: ", }; static struct cmd_node view_node = { + .name = "view", .node = VIEW_NODE, .prompt = "%s> ", }; static struct cmd_node auth_enable_node = { + .name = "auth enable", .node = AUTH_ENABLE_NODE, .prompt = "Password: ", }; static struct cmd_node enable_node = { + .name = "enable", .node = ENABLE_NODE, .prompt = "%s# ", }; static int config_write_host(struct vty *vty); static struct cmd_node config_node = { + .name = "config", .node = CONFIG_NODE, .parent_node = ENABLE_NODE, .prompt = "%s(config)# ", @@ -395,9 +320,9 @@ void install_element(enum node_type ntype, const struct cmd_element *cmd) if (cnode == NULL) { fprintf(stderr, "%s[%s]:\n" - "\tnode %d (%s) does not exist.\n" + "\tnode %d does not exist.\n" "\tplease call install_node() before install_element()\n", - cmd->name, cmd->string, ntype, node_names[ntype]); + cmd->name, cmd->string, ntype); exit(EXIT_FAILURE); } @@ -406,7 +331,7 @@ void install_element(enum node_type ntype, const struct cmd_element *cmd) "%s[%s]:\n" "\tnode %d (%s) already has this command installed.\n" "\tduplicate install_element call?\n", - cmd->name, cmd->string, ntype, node_names[ntype]); + cmd->name, cmd->string, ntype, cnode->name); return; } @@ -444,9 +369,9 @@ void uninstall_element(enum node_type ntype, const struct cmd_element *cmd) if (cnode == NULL) { fprintf(stderr, "%s[%s]:\n" - "\tnode %d (%s) does not exist.\n" + "\tnode %d does not exist.\n" "\tplease call install_node() before uninstall_element()\n", - cmd->name, cmd->string, ntype, node_names[ntype]); + cmd->name, cmd->string, ntype); exit(EXIT_FAILURE); } @@ -455,7 +380,7 @@ void uninstall_element(enum node_type ntype, const struct cmd_element *cmd) "%s[%s]:\n" "\tnode %d (%s) does not have this command installed.\n" "\tduplicate uninstall_element call?\n", - cmd->name, cmd->string, ntype, node_names[ntype]); + cmd->name, cmd->string, ntype, cnode->name); return; } @@ -2745,7 +2670,7 @@ DEFUN(find, if (regexec(&exp, cli->string, 0, NULL, 0) == 0) vty_out(vty, " (%s) %s\n", - node_names[node->node], cli->string); + node->name, cli->string); } } @@ -2793,9 +2718,6 @@ void cmd_init(int terminal) { struct utsname names; - if (array_size(node_names) != NODE_TYPE_MAX) - assert(!"Update the CLI node description array!"); - uname(&names); qobj_init(); diff --git a/lib/command.h b/lib/command.h index c1de67e10..6ab8497fe 100644 --- a/lib/command.h +++ b/lib/command.h @@ -165,11 +165,12 @@ enum node_type { extern vector cmdvec; extern const struct message tokennames[]; -extern const char *const node_names[]; /* Node which has some commands and prompt string and configuration function pointer . */ struct cmd_node { + const char *name; + /* Node index. */ enum node_type node; enum node_type parent_node; diff --git a/lib/filter.c b/lib/filter.c index c6cc16d7d..71c9b8095 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -2814,6 +2814,7 @@ static int config_write_access(struct vty *vty, afi_t afi) static int config_write_access_mac(struct vty *vty); static struct cmd_node access_mac_node = { + .name = "MAC access list", .node = ACCESS_MAC_NODE, .prompt = "", .config_write = config_write_access_mac, @@ -2868,6 +2869,7 @@ static void access_list_init_mac(void) /* Access-list node. */ static int config_write_access_ipv4(struct vty *vty); static struct cmd_node access_node = { + .name = "ipv4 access list", .node = ACCESS_NODE, .prompt = "", .config_write = config_write_access_ipv4, @@ -2956,6 +2958,7 @@ static void access_list_init_ipv4(void) static int config_write_access_ipv6(struct vty *vty); static struct cmd_node access_ipv6_node = { + .name = "ipv6 access list", .node = ACCESS_IPV6_NODE, .prompt = "", .config_write = config_write_access_ipv6, diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c index 8ccdbfcbc..a40b815ca 100644 --- a/lib/grammar_sandbox.c +++ b/lib/grammar_sandbox.c @@ -399,7 +399,7 @@ DEFUN (grammar_findambig, if (!nodegraph) continue; vty_out(vty, "scanning node %d (%s)\n", scannode - 1, - node_names[scannode - 1]); + cnode->name); } commands = cmd_graph_permutations(nodegraph); diff --git a/lib/keychain.c b/lib/keychain.c index bfeaa7fec..251211734 100644 --- a/lib/keychain.c +++ b/lib/keychain.c @@ -961,6 +961,7 @@ DEFUN (no_send_lifetime, static int keychain_config_write(struct vty *vty); static struct cmd_node keychain_node = { + .name = "keychain", .node = KEYCHAIN_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-keychain)# ", @@ -968,6 +969,7 @@ static struct cmd_node keychain_node = { }; static struct cmd_node keychain_key_node = { + .name = "keychain key", .node = KEYCHAIN_KEY_NODE, .parent_node = KEYCHAIN_NODE, .prompt = "%s(config-keychain-key)# ", diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c index 554460529..c23c57d2e 100644 --- a/lib/nexthop_group.c +++ b/lib/nexthop_group.c @@ -935,6 +935,7 @@ DEFPY(ecmp_nexthops, ecmp_nexthops_cmd, static int nexthop_group_write(struct vty *vty); static struct cmd_node nexthop_group_node = { + .name = "nexthop-group", .node = NH_GROUP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-nh-group)# ", diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c index d0e05990a..d4467faca 100644 --- a/lib/northbound_cli.c +++ b/lib/northbound_cli.c @@ -1675,6 +1675,7 @@ static int nb_debug_config_write(struct vty *vty) static struct debug_callbacks nb_dbg_cbs = {.debug_set_all = nb_debug_set_all}; static struct cmd_node nb_debug_node = { + .name = "northbound debug", .node = NORTHBOUND_DEBUG_NODE, .prompt = "", .config_write = nb_debug_config_write, diff --git a/lib/plist.c b/lib/plist.c index acc4491a0..8d43b9bd8 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -2047,6 +2047,7 @@ static void prefix_list_reset_afi(afi_t afi, int orf) static int config_write_prefix_ipv4(struct vty *vty); /* Prefix-list node. */ static struct cmd_node prefix_node = { + .name = "ipv4 prefix list", .node = PREFIX_NODE, .prompt = "", .config_write = config_write_prefix_ipv4, @@ -2113,6 +2114,7 @@ static void prefix_list_init_ipv4(void) static int config_write_prefix_ipv6(struct vty *vty); /* Prefix-list node. */ static struct cmd_node prefix_ipv6_node = { + .name = "ipv6 prefix list", .node = PREFIX_IPV6_NODE, .prompt = "", .config_write = config_write_prefix_ipv6, diff --git a/lib/resolver.c b/lib/resolver.c index 56b2d6cd6..e5caadb2d 100644 --- a/lib/resolver.c +++ b/lib/resolver.c @@ -247,6 +247,7 @@ DEFUN(debug_resolver, static int resolver_config_write_debug(struct vty *vty); static struct cmd_node resolver_debug_node = { + .name = "resolver debug", .node = RESOLVER_DEBUG_NODE, .prompt = "", .config_write = resolver_config_write_debug, diff --git a/lib/routemap.c b/lib/routemap.c index 2208a69f9..210512212 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -3017,6 +3017,7 @@ DEFUN (no_debug_rmap, /* Debug node. */ static int rmap_config_write_debug(struct vty *vty); static struct cmd_node rmap_debug_node = { + .name = "route-map debug", .node = RMAP_DEBUG_NODE, .prompt = "", .config_write = rmap_config_write_debug, diff --git a/lib/routemap_cli.c b/lib/routemap_cli.c index 16ecd1194..2c45f0975 100644 --- a/lib/routemap_cli.c +++ b/lib/routemap_cli.c @@ -1066,6 +1066,7 @@ static int route_map_config_write(struct vty *vty) /* Route map node structure. */ static int route_map_config_write(struct vty *vty); static struct cmd_node rmap_node = { + .name = "routemap", .node = RMAP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-route-map)# ", diff --git a/lib/vrf.c b/lib/vrf.c index 1fadf5c0c..0f57c602b 100644 --- a/lib/vrf.c +++ b/lib/vrf.c @@ -759,6 +759,7 @@ DEFUN (no_vrf, static struct cmd_node vrf_node = { + .name = "vrf", .node = VRF_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-vrf)# ", @@ -854,6 +855,7 @@ static int vrf_write_host(struct vty *vty) static int vrf_write_host(struct vty *vty); static struct cmd_node vrf_debug_node = { + .name = "vrf debug", .node = VRF_DEBUG_NODE, .prompt = "", .config_write = vrf_write_host, diff --git a/lib/vty.c b/lib/vty.c index 24cdfeda4..683c39f89 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -3009,6 +3009,7 @@ static int vty_config_write(struct vty *vty) static int vty_config_write(struct vty *vty); struct cmd_node vty_node = { + .name = "vty", .node = VTY_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-line)# ", diff --git a/nhrpd/nhrp_vty.c b/nhrpd/nhrp_vty.c index bf29d0218..fe681b405 100644 --- a/nhrpd/nhrp_vty.c +++ b/nhrpd/nhrp_vty.c @@ -19,6 +19,7 @@ static int nhrp_config_write(struct vty *vty); static struct cmd_node zebra_node = { + .name = "zebra", .node = ZEBRA_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", @@ -27,6 +28,7 @@ static struct cmd_node zebra_node = { static int interface_config_write(struct vty *vty); static struct cmd_node nhrp_interface_node = { + .name = "interface", .node = INTERFACE_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index 8ed9c6797..120999751 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -1945,6 +1945,7 @@ static int config_write_ospf6_interface(struct vty *vty) static int config_write_ospf6_interface(struct vty *vty); static struct cmd_node interface_node = { + .name = "interface", .node = INTERFACE_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index 75c0460ec..dd672dd1c 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -1115,6 +1115,7 @@ static int config_write_ospf6(struct vty *vty) static int config_write_ospf6(struct vty *vty); /* OSPF6 node structure. */ static struct cmd_node ospf6_node = { + .name = "ospf6", .node = OSPF6_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-ospf6)# ", diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c index efbb332b6..17e33902d 100644 --- a/ospf6d/ospf6d.c +++ b/ospf6d/ospf6d.c @@ -71,6 +71,7 @@ struct route_node *route_prev(struct route_node *node) static int config_write_ospf6_debug(struct vty *vty); static struct cmd_node debug_node = { + .name = "debug", .node = DEBUG_NODE, .prompt = "", .config_write = config_write_ospf6_debug, diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index e012326ea..f0740349a 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -1643,6 +1643,7 @@ DEFUN_NOSH (show_debugging_ospf_instance, static int config_write_debug(struct vty *vty); /* Debug node. */ static struct cmd_node debug_node = { + .name = "debug", .node = DEBUG_NODE, .prompt = "", .config_write = config_write_debug, diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 25bd41001..a3a02a0f9 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -10558,6 +10558,7 @@ void ospf_vty_show_init(void) static int config_write_interface(struct vty *vty); /* ospfd's interface node. */ static struct cmd_node interface_node = { + .name = "interface", .node = INTERFACE_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", @@ -10676,6 +10677,7 @@ static void ospf_vty_zebra_init(void) static int ospf_config_write(struct vty *vty); static struct cmd_node ospf_node = { + .name = "ospf", .node = OSPF_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c index 35dbb24d1..a52c2d1e3 100644 --- a/pbrd/pbr_vty.c +++ b/pbrd/pbr_vty.c @@ -678,6 +678,7 @@ DEFPY (show_pbr_interface, /* PBR debugging CLI ------------------------------------------------------- */ static struct cmd_node debug_node = { + .name = "debug", .node = DEBUG_NODE, .prompt = "", .config_write = pbr_debug_config_write, @@ -731,6 +732,7 @@ DEFUN_NOSH(show_debugging_pbr, static int pbr_interface_config_write(struct vty *vty); static struct cmd_node interface_node = { + .name = "interface", .node = INTERFACE_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", @@ -765,6 +767,7 @@ static int pbr_interface_config_write(struct vty *vty) static int pbr_vty_map_config_write(struct vty *vty); /* PBR map node structure. */ static struct cmd_node pbr_map_node = { + .name = "pbr-map", .node = PBRMAP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-pbr-map)# ", diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 895072a89..f99888b3a 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -70,6 +70,7 @@ #endif static struct cmd_node interface_node = { + .name = "interface", .node = INTERFACE_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", @@ -77,6 +78,7 @@ static struct cmd_node interface_node = { }; static struct cmd_node debug_node = { + .name = "debug", .node = DEBUG_NODE, .prompt = "", .config_write = pim_debug_config_write, diff --git a/ripd/rip_debug.c b/ripd/rip_debug.c index 676fc0cca..871ee8e87 100644 --- a/ripd/rip_debug.c +++ b/ripd/rip_debug.c @@ -175,6 +175,7 @@ DEFUN (no_debug_rip_zebra, static int config_write_debug(struct vty *vty); /* Debug node. */ static struct cmd_node debug_node = { + .name = "debug", .node = DEBUG_NODE, .prompt = "", .config_write = config_write_debug, diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index 924eb8334..177f53db4 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -1195,6 +1195,7 @@ int rip_show_network_config(struct vty *vty, struct rip *rip) static int rip_interface_config_write(struct vty *vty); static struct cmd_node interface_node = { + .name = "interface", .node = INTERFACE_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", diff --git a/ripd/ripd.c b/ripd/ripd.c index b6bbfb253..fee700583 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -3330,6 +3330,7 @@ static int config_write_rip(struct vty *vty) static int config_write_rip(struct vty *vty); /* RIP node structure. */ static struct cmd_node rip_node = { + .name = "rip", .node = RIP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", diff --git a/ripngd/ripng_debug.c b/ripngd/ripng_debug.c index 117148a3a..54edb17ec 100644 --- a/ripngd/ripng_debug.c +++ b/ripngd/ripng_debug.c @@ -177,6 +177,7 @@ DEFUN (no_debug_ripng_zebra, static int config_write_debug(struct vty *vty); /* Debug node. */ static struct cmd_node debug_node = { + .name = "debug", .node = DEBUG_NODE, .prompt = "", .config_write = config_write_debug, diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c index e45bbbe21..e8c907227 100644 --- a/ripngd/ripng_interface.c +++ b/ripngd/ripng_interface.c @@ -957,6 +957,7 @@ static int interface_config_write(struct vty *vty) static int interface_config_write(struct vty *vty); /* ripngd's interface node. */ static struct cmd_node interface_node = { + .name = "interface", .node = INTERFACE_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index 47083f947..d26e10386 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -2437,6 +2437,7 @@ static int ripng_config_write(struct vty *vty) static int ripng_config_write(struct vty *vty); /* RIPng node structure. */ static struct cmd_node cmd_ripng_node = { + .name = "ripng", .node = RIPNG_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", diff --git a/staticd/static_vty.c b/staticd/static_vty.c index 733578f86..16cd64bcb 100644 --- a/staticd/static_vty.c +++ b/staticd/static_vty.c @@ -1471,6 +1471,7 @@ DEFUN_NOSH (show_debugging_static, } static struct cmd_node debug_node = { + .name = "debug", .node = DEBUG_NODE, .prompt = "", .config_write = static_config_write_debug, diff --git a/tests/lib/cli/test_commands.c b/tests/lib/cli/test_commands.c index 54417f495..2b345c91e 100644 --- a/tests/lib/cli/test_commands.c +++ b/tests/lib/cli/test_commands.c @@ -49,96 +49,112 @@ static vector test_cmds; static char test_buf[32768]; static struct cmd_node bgp_node = { + .name = "bgp", .node = BGP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node rip_node = { + .name = "rip", .node = RIP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node isis_node = { + .name = "isis", .node = ISIS_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node interface_node = { + .name = "interface", .node = INTERFACE_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", }; static struct cmd_node rmap_node = { + .name = "routemap", .node = RMAP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-route-map)# ", }; static struct cmd_node zebra_node = { + .name = "zebra", .node = ZEBRA_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node bgp_vpnv4_node = { + .name = "bgp vpnv4", .node = BGP_VPNV4_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv4_node = { + .name = "bgp ipv4 unicast", .node = BGP_IPV4_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv4m_node = { + .name = "bgp ipv4 multicast", .node = BGP_IPV4M_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv6_node = { + .name = "bgp ipv6", .node = BGP_IPV6_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv6m_node = { + .name = "bgp ipv6 multicast", .node = BGP_IPV6M_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node ospf_node = { + .name = "ospf", .node = OSPF_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node ripng_node = { + .name = "ripng", .node = RIPNG_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node ospf6_node = { + .name = "ospf6", .node = OSPF6_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-ospf6)# ", }; static struct cmd_node keychain_node = { + .name = "keychain", .node = KEYCHAIN_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-keychain)# ", }; static struct cmd_node keychain_key_node = { + .name = "keychain key", .node = KEYCHAIN_KEY_NODE, .parent_node = KEYCHAIN_NODE, .prompt = "%s(config-keychain-key)# ", diff --git a/vrrpd/vrrp_vty.c b/vrrpd/vrrp_vty.c index f2048db98..b6388cc5b 100644 --- a/vrrpd/vrrp_vty.c +++ b/vrrpd/vrrp_vty.c @@ -745,6 +745,7 @@ static int vrrp_config_write_interface(struct vty *vty) } static struct cmd_node interface_node = { + .name = "interface", .node = INTERFACE_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", @@ -752,12 +753,14 @@ static struct cmd_node interface_node = { }; static struct cmd_node debug_node = { + .name = "debug", .node = DEBUG_NODE, .prompt = "", .config_write = vrrp_config_write_debug, }; static struct cmd_node vrrp_node = { + .name = "vrrp", .node = VRRP_NODE, .prompt = "", .config_write = vrrp_config_write_global, diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index ddb40a572..a21deb4a0 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -1173,264 +1173,308 @@ static char **new_completion(const char *text, int start, int end) /* Vty node structures. */ static struct cmd_node bgp_node = { + .name = "bgp", .node = BGP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node rip_node = { + .name = "rip", .node = RIP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node isis_node = { + .name = "isis", .node = ISIS_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node openfabric_node = { + .name = "openfabric", .node = OPENFABRIC_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node interface_node = { + .name = "interface", .node = INTERFACE_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", }; static struct cmd_node pw_node = { + .name = "pw", .node = PW_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-pw)# ", }; static struct cmd_node vrf_node = { + .name = "vrf", .node = VRF_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-vrf)# ", }; static struct cmd_node nh_group_node = { + .name = "nexthop-group", .node = NH_GROUP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-nh-group)# ", }; static struct cmd_node rmap_node = { + .name = "routemap", .node = RMAP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-route-map)# ", }; static struct cmd_node pbr_map_node = { + .name = "pbr-map", .node = PBRMAP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-pbr-map)# ", }; static struct cmd_node zebra_node = { + .name = "zebra", .node = ZEBRA_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node bgp_vpnv4_node = { + .name = "bgp vpnv4", .node = BGP_VPNV4_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_vpnv6_node = { + .name = "bgp vpnv6", .node = BGP_VPNV6_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_flowspecv4_node = { + .name = "bgp ipv4 flowspec", .node = BGP_FLOWSPECV4_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_flowspecv6_node = { + .name = "bgp ipv6 flowspec", .node = BGP_FLOWSPECV6_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv4_node = { + .name = "bgp ipv4 unicast", .node = BGP_IPV4_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv4m_node = { + .name = "bgp ipv4 multicast", .node = BGP_IPV4M_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv4l_node = { + .name = "bgp ipv4 labeled unicast", .node = BGP_IPV4L_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv6_node = { + .name = "bgp ipv6", .node = BGP_IPV6_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_ipv6m_node = { + .name = "bgp ipv6 multicast", .node = BGP_IPV6M_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_evpn_node = { + .name = "bgp evpn", .node = BGP_EVPN_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_evpn_vni_node = { + .name = "bgp evpn vni", .node = BGP_EVPN_VNI_NODE, .parent_node = BGP_EVPN_NODE, .prompt = "%s(config-router-af-vni)# ", }; static struct cmd_node bgp_ipv6l_node = { + .name = "bgp ipv6 labeled unicast", .node = BGP_IPV6L_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-af)# ", }; static struct cmd_node bgp_vnc_defaults_node = { + .name = "bgp vnc defaults", .node = BGP_VNC_DEFAULTS_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-vnc-defaults)# ", }; static struct cmd_node bgp_vnc_nve_group_node = { + .name = "bgp vnc nve", .node = BGP_VNC_NVE_GROUP_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-vnc-nve-group)# ", }; static struct cmd_node bgp_vrf_policy_node = { + .name = "bgp vrf policy", .node = BGP_VRF_POLICY_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-vrf-policy)# ", }; static struct cmd_node bgp_vnc_l2_group_node = { + .name = "bgp vnc l2", .node = BGP_VNC_L2_GROUP_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-router-vnc-l2-group)# ", }; static struct cmd_node bmp_node = { + .name = "bmp", .node = BMP_NODE, .parent_node = BGP_NODE, .prompt = "%s(config-bgp-bmp)# " }; static struct cmd_node ospf_node = { + .name = "ospf", .node = OSPF_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node eigrp_node = { + .name = "eigrp", .node = EIGRP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node babel_node = { + .name = "babel", .node = BABEL_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node ripng_node = { + .name = "ripng", .node = RIPNG_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; static struct cmd_node ospf6_node = { + .name = "ospf6", .node = OSPF6_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-ospf6)# ", }; static struct cmd_node ldp_node = { + .name = "ldp", .node = LDP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-ldp)# ", }; static struct cmd_node ldp_ipv4_node = { + .name = "ldp ipv4", .node = LDP_IPV4_NODE, .parent_node = LDP_NODE, .prompt = "%s(config-ldp-af)# ", }; static struct cmd_node ldp_ipv6_node = { + .name = "ldp ipv6", .node = LDP_IPV6_NODE, .parent_node = LDP_NODE, .prompt = "%s(config-ldp-af)# ", }; static struct cmd_node ldp_ipv4_iface_node = { + .name = "ldp ipv4 interface", .node = LDP_IPV4_IFACE_NODE, .parent_node = LDP_IPV4_NODE, .prompt = "%s(config-ldp-af-if)# ", }; static struct cmd_node ldp_ipv6_iface_node = { + .name = "ldp ipv6 interface", .node = LDP_IPV6_IFACE_NODE, .parent_node = LDP_IPV6_NODE, .prompt = "%s(config-ldp-af-if)# ", }; static struct cmd_node ldp_l2vpn_node = { + .name = "ldp l2vpn", .node = LDP_L2VPN_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-l2vpn)# ", }; static struct cmd_node ldp_pseudowire_node = { + .name = "ldp", .node = LDP_PSEUDOWIRE_NODE, .parent_node = LDP_L2VPN_NODE, .prompt = "%s(config-l2vpn-pw)# ", }; static struct cmd_node keychain_node = { + .name = "keychain", .node = KEYCHAIN_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-keychain)# ", }; static struct cmd_node keychain_key_node = { + .name = "keychain key", .node = KEYCHAIN_KEY_NODE, .parent_node = KEYCHAIN_NODE, .prompt = "%s(config-keychain-key)# ", }; struct cmd_node link_params_node = { + .name = "link-params", .node = LINK_PARAMS_NODE, .parent_node = INTERFACE_NODE, .prompt = "%s(config-link-params)# ", }; static struct cmd_node rpki_node = { + .name = "rpki", .node = RPKI_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-rpki)# ", @@ -1438,12 +1482,14 @@ static struct cmd_node rpki_node = { #if HAVE_BFDD > 0 static struct cmd_node bfd_node = { + .name = "bfd", .node = BFD_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-bfd)# ", }; static struct cmd_node bfd_peer_node = { + .name = "bfd peer", .node = BFD_PEER_NODE, .parent_node = BFD_NODE, .prompt = "%s(config-bfd-peer)# ", @@ -3568,7 +3614,7 @@ DEFUN(find, if (regexec(&exp, cli->string, 0, NULL, 0) == 0) vty_out(vty, " (%s) %s\n", - node_names[node->node], cli->string); + node->name, cli->string); } } diff --git a/zebra/debug.c b/zebra/debug.c index a77693d94..c920fca5f 100644 --- a/zebra/debug.c +++ b/zebra/debug.c @@ -473,6 +473,7 @@ DEFPY (debug_zebra_nexthop, /* Debug node. */ static int config_write_debug(struct vty *vty); struct cmd_node debug_node = { + .name = "debug", .node = DEBUG_NODE, .prompt = "", .config_write = config_write_debug, diff --git a/zebra/interface.c b/zebra/interface.c index f4b330d8a..cad382ff0 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -1666,6 +1666,7 @@ static void interface_update_stats(void) static int if_config_write(struct vty *vty); struct cmd_node interface_node = { + .name = "interface", .node = INTERFACE_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-if)# ", @@ -2080,6 +2081,7 @@ DEFUN (no_bandwidth_if, struct cmd_node link_params_node = { + .name = "link-params", .node = LINK_PARAMS_NODE, .parent_node = INTERFACE_NODE, .prompt = "%s(config-link-params)# ", diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index 462a75b55..41d73f3c9 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -1941,6 +1941,7 @@ static int fpm_remote_srv_write(struct vty *vty) static int fpm_remote_srv_write(struct vty *vty); /* Zebra node */ static struct cmd_node zebra_node = { + .name = "zebra", .node = ZEBRA_NODE, .parent_node = CONFIG_NODE, .prompt = "", diff --git a/zebra/zebra_mpls_vty.c b/zebra/zebra_mpls_vty.c index 148b9c46d..d789f2007 100644 --- a/zebra/zebra_mpls_vty.c +++ b/zebra/zebra_mpls_vty.c @@ -452,6 +452,7 @@ DEFUN (no_mpls_label_global_block, static int zebra_mpls_config(struct vty *vty); /* MPLS node for MPLS LSP. */ static struct cmd_node mpls_node = { + .name = "mpls", .node = MPLS_NODE, .prompt = "", .config_write = zebra_mpls_config, diff --git a/zebra/zebra_pw.c b/zebra/zebra_pw.c index 188540128..7a14f6304 100644 --- a/zebra/zebra_pw.c +++ b/zebra/zebra_pw.c @@ -549,6 +549,7 @@ static int zebra_pw_config(struct vty *vty) static int zebra_pw_config(struct vty *vty); static struct cmd_node pw_node = { + .name = "pw", .node = PW_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-pw)# ", diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index bb8d0c774..8042264ca 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -3480,12 +3480,14 @@ DEFUN_HIDDEN (show_frr, /* IP node for static routes. */ static int zebra_ip_config(struct vty *vty); static struct cmd_node ip_node = { + .name = "static ip", .node = IP_NODE, .prompt = "", .config_write = zebra_ip_config, }; static int config_write_protocol(struct vty *vty); static struct cmd_node protocol_node = { + .name = "protocol", .node = PROTOCOL_NODE, .prompt = "", .config_write = config_write_protocol, @@ -3493,12 +3495,14 @@ static struct cmd_node protocol_node = { /* table node for routing tables. */ static int config_write_table(struct vty *vty); static struct cmd_node table_node = { + .name = "table", .node = TABLE_NODE, .prompt = "", .config_write = config_write_table, }; static int config_write_forwarding(struct vty *vty); static struct cmd_node forwarding_node = { + .name = "forwarding", .node = FORWARDING_NODE, .prompt = "", .config_write = config_write_forwarding, -- cgit v1.2.3