/* Install interface node */
install_node (&interface_node, isis_interface_config_write);
- 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);
+ if_cmd_init ();
isis_vty_init ();
}
{
/* Install interface node. */
install_node (&interface_node, interface_config_write);
-
- install_element(CONFIG_NODE, &interface_cmd);
- install_element(CONFIG_NODE, &no_interface_cmd);
- install_default(INTERFACE_NODE);
-
- /* "description" commands. */
- install_element(INTERFACE_NODE, &interface_desc_cmd);
- install_element(INTERFACE_NODE, &no_interface_desc_cmd);
+ if_cmd_init ();
}
struct iface *
config_exit_cmd,
"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)
{
default:
break;
}
- return CMD_SUCCESS;
}
/* ALIAS_FIXME */
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
{
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. */
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);
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
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 *);
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",
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,
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. */
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 */
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)
{
/* 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
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;
}
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.
*/
/* 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 */
{
/* Install interface node. */
install_node (&interface_node, config_write_ospf6_interface);
+ if_cmd_init ();
install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
- install_element (CONFIG_NODE, &interface_cmd);
- install_default (INTERFACE_NODE);
- install_element (INTERFACE_NODE, &interface_desc_cmd);
- install_element (INTERFACE_NODE, &no_interface_desc_cmd);
install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
install_element (INTERFACE_NODE, &no_ipv6_ospf6_cost_cmd);
install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
{
/* Install interface node. */
install_node (&interface_node, config_write_interface);
-
- install_element (CONFIG_NODE, &interface_cmd);
- install_element (CONFIG_NODE, &no_interface_cmd);
- install_default (INTERFACE_NODE);
-
- /* "description" commands. */
- install_element (INTERFACE_NODE, &interface_desc_cmd);
- install_element (INTERFACE_NODE, &no_interface_desc_cmd);
+ if_cmd_init ();
/* "ip ospf authentication" commands. */
install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
clear_pim_interfaces();
}
-DEFUN (pim_interface,
- pim_interface_cmd,
- "interface IFNAME",
- "Select an interface to configure\n"
- "Interface's name\n")
-{
- int idx_ifname = 1;
- struct interface *ifp;
- const char *ifname = argv[idx_ifname]->arg;
- size_t sl;
-
- sl = strlen(ifname);
- if (sl > INTERFACE_NAMSIZ) {
- vty_out(vty, "%% Interface name %s is invalid: length exceeds "
- "%d characters%s",
- ifname, INTERFACE_NAMSIZ, VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- ifp = if_lookup_by_name_len(ifname, sl);
- if (!ifp) {
- vty_out(vty, "%% Interface %s does not exist%s", ifname, VTY_NEWLINE);
-
- /* Returning here would prevent pimd from booting when there are
- interface commands in pimd.conf, since all interfaces are
- unknown at pimd boot time (the zebra daemon has not been
- contacted for interface discovery). */
-
- ifp = if_get_by_name_len(ifname, sl);
- if (!ifp) {
- vty_out(vty, "%% Could not create interface %s%s", ifname, VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
-
- vty->index = ifp;
- vty->node = INTERFACE_NODE;
-
- return CMD_SUCCESS;
-}
-
DEFUN (clear_ip_interfaces,
clear_ip_interfaces_cmd,
"clear ip interfaces",
{
install_node (&pim_global_node, pim_global_config_write); /* PIM_NODE */
install_node (&interface_node, pim_interface_config_write); /* INTERFACE_NODE */
+ if_cmd_init ();
install_element (CONFIG_NODE, &ip_multicast_routing_cmd);
install_element (CONFIG_NODE, &no_ip_multicast_routing_cmd);
install_element (CONFIG_NODE, &no_ip_pim_rp_cmd);
install_element (CONFIG_NODE, &ip_ssmpingd_cmd);
install_element (CONFIG_NODE, &no_ip_ssmpingd_cmd);
-#if 0
- install_element (CONFIG_NODE, &interface_cmd); /* from if.h */
-#else
- install_element (CONFIG_NODE, &pim_interface_cmd);
-#endif
- install_element (CONFIG_NODE, &no_interface_cmd); /* from if.h */
-
- install_default (INTERFACE_NODE);
+
install_element (INTERFACE_NODE, &interface_ip_igmp_cmd);
install_element (INTERFACE_NODE, &interface_no_ip_igmp_cmd);
install_element (INTERFACE_NODE, &interface_ip_igmp_join_cmd);
/* Install interface node. */
install_node (&interface_node, rip_interface_config_write);
+ if_cmd_init ();
/* Install commands. */
- 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);
install_element (RIP_NODE, &rip_network_cmd);
install_element (RIP_NODE, &no_rip_network_cmd);
install_element (RIP_NODE, &rip_neighbor_cmd);
/* Install interface node. */
install_node (&interface_node, interface_config_write);
-
- /* Install commands. */
- 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);
+ if_cmd_init ();
install_element (RIPNG_NODE, &ripng_network_cmd);
install_element (RIPNG_NODE, &no_ripng_network_cmd);
}
#endif
+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);
+}
+
static void
vtysh_install_default (enum node_type node)
{
#endif /* HAVE_NET_RT_IFLIST */
}
-/* Wrapper hook point for zebra daemon so that ifindex can be set
- * DEFUN macro not used as extract.pl HAS to ignore this
- * See also interface_cmd in lib/if.c
- */
-DEFUN_NOSH (zebra_interface,
- zebra_interface_cmd,
- "interface IFNAME",
- "Select an interface to configure\n"
- "Interface's name\n")
-{
- int ret;
-
- /* Call lib interface() */
- if ((ret = interface_cmd.func (self, vty, argc, argv)) != CMD_SUCCESS)
- return ret;
-
- VTY_DECLVAR_CONTEXT (interface, ifp);
-
- if (ifp->ifindex == IFINDEX_INTERNAL)
- /* Is this really necessary? Shouldn't status be initialized to 0
- in that case? */
- UNSET_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE);
-
- return ret;
-}
-
static void
interface_update_stats (void)
{
1
};
+#if 0
/* Wrapper hook point for zebra daemon so that ifindex can be set
* DEFUN macro not used as extract.pl HAS to ignore this
* See also interface_cmd in lib/if.c
return ret;
}
+#endif
struct cmd_node vrf_node =
{
install_node (&interface_node, if_config_write);
install_node (&link_params_node, NULL);
install_node (&vrf_node, vrf_config_write);
+ if_cmd_init ();
install_element (VIEW_NODE, &show_interface_cmd);
install_element (VIEW_NODE, &show_interface_vrf_all_cmd);
install_element (ENABLE_NODE, &show_interface_desc_cmd);
install_element (ENABLE_NODE, &show_interface_desc_vrf_all_cmd);
- install_element (CONFIG_NODE, &zebra_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);
install_element (INTERFACE_NODE, &multicast_cmd);
install_element (INTERFACE_NODE, &no_multicast_cmd);
install_element (INTERFACE_NODE, &linkdetect_cmd);
install_element(LINK_PARAMS_NODE, &no_link_params_use_bw_cmd);
install_element(LINK_PARAMS_NODE, &exit_link_params_cmd);
- install_element (CONFIG_NODE, &zebra_vrf_cmd);
- install_element (CONFIG_NODE, &no_vrf_cmd);
- install_default (VRF_NODE);
+ vrf_cmd_init();
}