Skip to content

Commit

Permalink
*: remove second parameter on install_node()
Browse files Browse the repository at this point in the history
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".

Signed-off-by: David Lamparter <equinox@diac24.net>
  • Loading branch information
eqvinox committed Apr 2, 2020
1 parent c6c6530 commit 8d529ae
Show file tree
Hide file tree
Showing 53 changed files with 284 additions and 175 deletions.
4 changes: 3 additions & 1 deletion babeld/babel_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};


Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion babeld/babeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions bfdd/bfdd_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,9 +846,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 = {
Expand Down Expand Up @@ -881,11 +883,11 @@ void bfdd_vty_init(void)
install_element(ENABLE_NODE, &show_debugging_bfd_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();
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion bgpd/bgp_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion bgpd/bgp_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion bgpd/bgp_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion bgpd/bgp_rpki.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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);
Expand Down
31 changes: 17 additions & 14 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -15286,6 +15286,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 = {
Expand Down Expand Up @@ -15409,19 +15410,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);
Expand Down Expand Up @@ -17823,14 +17824,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);
Expand Down
8 changes: 4 additions & 4 deletions bgpd/rfapi/bgp_rfapi_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion bgpd/rfapi/vnc_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions eigrpd/eigrp_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
};


Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion eigrpd/eigrp_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions isisd/isis_circuit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 8d529ae

Please sign in to comment.