Display interface(s) in accordance with user expectations

* show interfaces (display breef line per interface)
 * show interface (display detailed interface information)
This commit is contained in:
Andreas Eversberg 2024-03-30 00:19:05 +01:00
parent 0e42560095
commit 320af9d81a
1 changed files with 23 additions and 4 deletions

View File

@ -142,6 +142,24 @@ static const char *link_status(bool established, struct lapv5_instance *li)
return "up";
}
DEFUN(show_interfaces, show_interfaces_cmd, "show interfaces",
SHOW_STR "Show all interfaces")
{
struct v5x_interface *v5if;
if (llist_empty(&v5i->interfaces)) {
vty_out(vty, "%%No interface created!%s", VTY_NEWLINE);
return CMD_SUCCESS;
}
llist_for_each_entry(v5if, &v5i->interfaces, list) {
vty_out(vty, "Interface %d: %s %s%s", v5if->id, v5if->name ? v5if->name : "(unnamed)",
(v5if->dialect == V5X_DIALECT_V51) ? "V5.1" : "V5.2", VTY_NEWLINE);
}
return CMD_SUCCESS;
}
DEFUN(interface, interface_cmd,
"interface <0-16777215>",
"Select given interface\n" "Interface ID")
@ -171,9 +189,9 @@ DEFUN(interface, interface_cmd,
return CMD_SUCCESS;
}
DEFUN(info_interface, info_interface_cmd,
"info",
"Show interface information and states")
DEFUN(info_interface, show_interface_cmd,
"show interface",
SHOW_STR "Show interface information and states")
{
struct v5x_interface *v5if = vty->index;
struct v5x_link *v5l;
@ -1295,9 +1313,10 @@ static int config_write_interfaces(struct vty *vty)
int v5le_vty_init(void)
{
install_element_ve(&show_interfaces_cmd);
install_element(ENABLE_NODE, &interface_cmd);
install_node(&interface_node, NULL);
install_element(INTERFACE_NODE, &info_interface_cmd);
install_element(INTERFACE_NODE, &show_interface_cmd);
install_element(INTERFACE_NODE, &show_link_cmd);
install_element(INTERFACE_NODE, &show_port_cmd);
install_element(INTERFACE_NODE, &show_port_pstn_cmd);