diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2016-11-16 07:00:52 +0100 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2016-12-01 17:25:56 +0100 |
commit | 0b84f294904959a4be58db6fe0e89d71b2c1f401 (patch) | |
tree | f52c765644294f314ede33506f29b6888439b904 /lib | |
parent | Merge branch 'stable/2.0' (diff) | |
download | frr-0b84f294904959a4be58db6fe0e89d71b2c1f401.tar.xz frr-0b84f294904959a4be58db6fe0e89d71b2c1f401.zip |
*: make DEFUN installations file-local
This moves all install_element calls into the file where the DEFUNs are
located. This fixes several small related bugs:
- ospf6d wasn't installing a "no interface FOO" command
- zebra had a useless copy of "interface FOO"
- pimd's copy of "interface FOO" was not setting qobj_index, which means
"description LINE" commands would fail with an error
The next commit will do the actual act of making "foo_cmd" static.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/command.c | 37 | ||||
-rw-r--r-- | lib/command.h | 7 | ||||
-rw-r--r-- | lib/if.c | 18 | ||||
-rw-r--r-- | lib/if.h | 18 | ||||
-rw-r--r-- | lib/thread.c | 7 | ||||
-rw-r--r-- | lib/thread.h | 3 | ||||
-rw-r--r-- | lib/vty.c | 2 | ||||
-rw-r--r-- | lib/workqueue.c | 6 | ||||
-rw-r--r-- | lib/workqueue.h | 4 |
9 files changed, 64 insertions, 38 deletions
diff --git a/lib/command.c b/lib/command.c index 3c429ce1a..8e935acf9 100644 --- a/lib/command.c +++ b/lib/command.c @@ -1051,6 +1051,13 @@ DEFUN (config_exit, "exit", "Exit current mode and down to previous mode\n") { + cmd_exit (vty); + return CMD_SUCCESS; +} + +void +cmd_exit (struct vty *vty) +{ switch (vty->node) { case VIEW_NODE: @@ -1118,7 +1125,6 @@ DEFUN (config_exit, default: break; } - return CMD_SUCCESS; } /* ALIAS_FIXME */ @@ -1264,17 +1270,12 @@ permute (struct graph_node *start, struct vty *vty) list_delete_node (position, listtail(position)); } -/* Help display function for all node. */ -DEFUN (config_list, - config_list_cmd, - "list [permutations]", - "Print command list\n" - "Print all possible command permutations\n") +int +cmd_list_cmds (struct vty *vty, int do_permute) { struct cmd_node *node = vector_slot (cmdvec, vty->node); - if ((strmatch (argv[0]->text, "list") && argc == 2) || - (strmatch (argv[0]->text, "show") && argc == 3)) + if (do_permute) permute (vector_slot (node->cmdgraph->nodes, 0), vty); else { @@ -1289,13 +1290,23 @@ DEFUN (config_list, return CMD_SUCCESS; } +/* Help display function for all node. */ +DEFUN (config_list, + config_list_cmd, + "list [permutations]", + "Print command list\n" + "Print all possible command permutations\n") +{ + return cmd_list_cmds (vty, argc == 2); +} + DEFUN (show_commandtree, show_commandtree_cmd, "show commandtree [permutations]", SHOW_STR "Show command tree\n") { - return config_list (self, vty, argc, argv); + return cmd_list_cmds (vty, argc == 3); } /* Write current configuration into file. */ @@ -2352,10 +2363,8 @@ cmd_init (int terminal) install_element (ENABLE_NODE, &config_logmsg_cmd); install_default (CONFIG_NODE); - install_element (VIEW_NODE, &show_thread_cpu_cmd); - install_element (ENABLE_NODE, &clear_thread_cpu_cmd); - - install_element (VIEW_NODE, &show_work_queues_cmd); + thread_cmd_init (); + workqueue_cmd_init (); } install_element (CONFIG_NODE, &hostname_cmd); diff --git a/lib/command.h b/lib/command.h index f120063ea..a170a9549 100644 --- a/lib/command.h +++ b/lib/command.h @@ -414,6 +414,8 @@ extern int cmd_execute_command (vector, struct vty *, const struct cmd_element * extern int cmd_execute_command_strict (vector, struct vty *, const struct cmd_element **); extern void cmd_init (int); extern void cmd_terminate (void); +extern void cmd_exit (struct vty *vty); +extern int cmd_list_cmds (struct vty *vty, int do_permute); /* memory management for cmd_element */ void @@ -430,11 +432,6 @@ struct cmd_token * copy_cmd_token (struct cmd_token *); /* Export typical functions. */ -extern struct cmd_element config_end_cmd; -extern struct cmd_element config_exit_cmd; -extern struct cmd_element config_quit_cmd; -extern struct cmd_element config_help_cmd; -extern struct cmd_element config_list_cmd; extern const char *host_config_get (void); extern void host_config_set (const char *); @@ -832,6 +832,17 @@ DEFUN_NOSH (no_interface, return CMD_SUCCESS; } +void +if_cmd_init (void) +{ + install_element (CONFIG_NODE, &interface_cmd); + install_element (CONFIG_NODE, &no_interface_cmd); + + install_default (INTERFACE_NODE); + install_element (INTERFACE_NODE, &interface_desc_cmd); + install_element (INTERFACE_NODE, &no_interface_desc_cmd); +} + DEFUN (vrf, vrf_cmd, "vrf NAME", @@ -890,6 +901,13 @@ DEFUN_NOSH (no_vrf, return CMD_SUCCESS; } +void +vrf_cmd_init (void) +{ + install_element (CONFIG_NODE, &vrf_cmd); + install_element (CONFIG_NODE, &no_vrf_cmd); + install_default (VRF_NODE); +} /* For debug purpose. */ DEFUN (show_address, @@ -445,11 +445,14 @@ extern int if_is_pointopoint (struct interface *); extern int if_is_multicast (struct interface *); extern void if_add_hook (int, int (*)(struct interface *)); extern void if_init (struct list **); +extern void if_cmd_init (void); extern void if_terminate (struct list **); extern void if_dump_all (void); extern const char *if_flag_dump(unsigned long); extern const char *if_link_type_str (enum zebra_link_type); +extern void vrf_cmd_init (void); + /* Please use ifindex2ifname instead of if_indextoname where possible; ifindex2ifname uses internal interface info, whereas if_indextoname must make a system call. */ @@ -483,19 +486,4 @@ struct nbr_connected *nbr_connected_check (struct interface *, struct prefix *); struct if_link_params *if_link_params_get (struct interface *); void if_link_params_free (struct interface *); -/* Exported variables. */ -extern struct cmd_element interface_desc_cmd; -extern struct cmd_element no_interface_desc_cmd; -extern struct cmd_element interface_cmd; -extern struct cmd_element no_interface_cmd; -extern struct cmd_element interface_vrf_cmd; -extern struct cmd_element no_interface_vrf_cmd; -extern struct cmd_element interface_pseudo_cmd; -extern struct cmd_element no_interface_pseudo_cmd; -extern struct cmd_element show_address_cmd; -extern struct cmd_element show_address_vrf_cmd; -extern struct cmd_element show_address_vrf_all_cmd; -extern struct cmd_element vrf_cmd; -extern struct cmd_element no_vrf_cmd; - #endif /* _ZEBRA_IF_H */ diff --git a/lib/thread.c b/lib/thread.c index ce93530ff..eac7f3250 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -423,6 +423,13 @@ DEFUN (clear_thread_cpu, return CMD_SUCCESS; } +void +thread_cmd_init (void) +{ + install_element (VIEW_NODE, &show_thread_cpu_cmd); + install_element (ENABLE_NODE, &clear_thread_cpu_cmd); +} + static int thread_timer_cmp(void *a, void *b) { diff --git a/lib/thread.h b/lib/thread.h index e41e96dec..5c6b96a32 100644 --- a/lib/thread.h +++ b/lib/thread.h @@ -244,8 +244,7 @@ extern void thread_set_yield_time (struct thread *, unsigned long); /* Internal libzebra exports */ extern void thread_getrusage (RUSAGE_T *); -extern struct cmd_element show_thread_cpu_cmd; -extern struct cmd_element clear_thread_cpu_cmd; +extern void thread_cmd_init (void); /* replacements for the system gettimeofday(), clock_gettime() and * time() functions, providing support for non-decrementing clock on @@ -715,7 +715,7 @@ static void vty_down_level (struct vty *vty) { vty_out (vty, "%s", VTY_NEWLINE); - (*config_exit_cmd.func)(NULL, vty, 0, NULL); + cmd_exit (vty); vty_prompt (vty); vty->cp = 0; } diff --git a/lib/workqueue.c b/lib/workqueue.c index 549bb2360..51017b34e 100644 --- a/lib/workqueue.c +++ b/lib/workqueue.c @@ -222,6 +222,12 @@ DEFUN (show_work_queues, return CMD_SUCCESS; } +void +workqueue_cmd_init (void) +{ + install_element (VIEW_NODE, &show_work_queues_cmd); +} + /* 'plug' a queue: Stop it from being scheduled, * ie: prevent the queue from draining. */ diff --git a/lib/workqueue.h b/lib/workqueue.h index eaf857490..548f96d8b 100644 --- a/lib/workqueue.h +++ b/lib/workqueue.h @@ -129,5 +129,7 @@ bool work_queue_is_scheduled (struct work_queue *); /* Helpers, exported for thread.c and command.c */ extern int work_queue_run (struct thread *); -extern struct cmd_element show_work_queues_cmd; + +extern void workqueue_cmd_init (void); + #endif /* _QUAGGA_WORK_QUEUE_H */ |