diff options
| author | David Lamparter <equinox@opensourcerouting.org> | 2018-09-08 22:31:43 +0200 | 
|---|---|---|
| committer | David Lamparter <equinox@diac24.net> | 2020-04-16 12:53:00 +0200 | 
| commit | 612c2c15d86e0e5c7e35f1a9a1491f90f365b93c (patch) | |
| tree | 5fd4cb67296f7748d26a420ad6357615dcd3b382 /lib | |
| parent | 249a771b63505b24d2a8c05158d7692384811533 (diff) | |
*: 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 <equinox@diac24.net>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/agentx.c | 4 | ||||
| -rw-r--r-- | lib/command.c | 19 | ||||
| -rw-r--r-- | lib/command.h | 4 | ||||
| -rw-r--r-- | lib/filter.c | 12 | ||||
| -rw-r--r-- | lib/keychain.c | 6 | ||||
| -rw-r--r-- | lib/nexthop_group.c | 4 | ||||
| -rw-r--r-- | lib/northbound_cli.c | 3 | ||||
| -rw-r--r-- | lib/plist.c | 8 | ||||
| -rw-r--r-- | lib/resolver.c | 4 | ||||
| -rw-r--r-- | lib/routemap.c | 4 | ||||
| -rw-r--r-- | lib/routemap_cli.c | 4 | ||||
| -rw-r--r-- | lib/vrf.c | 7 | ||||
| -rw-r--r-- | lib/vty.c | 4 | 
13 files changed, 56 insertions, 27 deletions
diff --git a/lib/agentx.c b/lib/agentx.c index 8ce1545243..42c843bbb1 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 a26ec1a266..7d46202da8 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 06c7ce7b4d..ed7706c309 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 5665dd82b2..c6cc16d7d9 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 c66c1de077..bbe2070b1d 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 95087fe305..cce5af1e78 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 5803dbd787..d0e05990a8 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 8f2389a32e..acc4491a00 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 9005ee5275..56b2d6cd66 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 41057c8704..2208a69f94 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 a53c542918..b97948d5c6 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);  | 
