/** * Register common subcommands for `watch` and `show neighbors`. */ void register_common_commands(struct cmd_node *root) { /* With hidden neighbors */ commands_new(root, "hidden", "Include hidden neighbors", cmd_check_no_env, cmd_store_env_and_pop, "hidden"); /* With more details */ commands_new(root, "details", "With more details", cmd_check_no_detailed_nor_summary, cmd_store_env_and_pop, "detailed"); /* With less details */ commands_new(root, "summary", "With less details", cmd_check_no_detailed_nor_summary, cmd_store_env_and_pop, "summary"); /* Some specific port */ cmd_restrict_ports(root); /* Specific protocol */ cmd_restrict_protocol(root); }
/** * Register subcommands to `show` * * @param root Root node */ void register_commands_show(struct cmd_node *root) { struct cmd_node *show = commands_new( root, "show", "Show running system information", NULL, NULL, NULL); struct cmd_node *neighbors = commands_new( show, "neighbors", "Show neighbors data", NULL, NULL, NULL); struct cmd_node *stats = commands_new( show, "statistics", "Show statistics", NULL, NULL, NULL); /* Neighbors data */ commands_new(neighbors, NEWLINE, "Show neighbors data", NULL, cmd_show_neighbors, NULL); register_common_commands(neighbors); /* Stats data */ commands_new(stats, NEWLINE, "Show stats data", NULL, cmd_show_interface_stats, NULL); cmd_restrict_ports(stats); register_summary_command(stats); /* Register "show configuration" and "show running-configuration" */ commands_new( commands_new(show, "configuration", "Show running configuration", NULL, NULL, NULL), NEWLINE, "Show running configuration", NULL, cmd_show_configuration, NULL); commands_new( commands_new(show, "running-configuration", "Show running configuration", NULL, NULL, NULL), NEWLINE, "Show running configuration", NULL, cmd_show_configuration, NULL); }
/** * Register `configure` and `no configure` commands. */ void register_commands_configure(struct cmd_node *root) { struct cmd_node *configure = commands_new( root, "configure", "Change system settings", NULL, NULL, NULL); struct cmd_node *unconfigure = commands_new( root, "unconfigure", "Unconfigure system settings", NULL, NULL, NULL); cmd_restrict_ports(configure); cmd_restrict_ports(unconfigure); register_commands_configure_system(configure, unconfigure); register_commands_configure_lldp(configure); register_commands_configure_med(configure, unconfigure); register_commands_configure_dot3(configure); }