diff options
57 files changed, 297 insertions, 183 deletions
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); @@ -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()) { @@ -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 "<all|common|event|interface|kernel|route|vici>" @@ -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); |