From 320af9d81add210d1ec70d03a47f0c268e1488d5 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sat, 30 Mar 2024 00:19:05 +0100 Subject: [PATCH] Display interface(s) in accordance with user expectations * show interfaces (display breef line per interface) * show interface (display detailed interface information) --- src/v5le_vty.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/v5le_vty.c b/src/v5le_vty.c index 22febef..427afd2 100644 --- a/src/v5le_vty.c +++ b/src/v5le_vty.c @@ -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);