VTY: Show single port; Use 'singular' for ports and links
This commit is contained in:
parent
c9f0c33587
commit
e70c91fc4a
128
src/v5le_vty.c
128
src/v5le_vty.c
|
@ -78,8 +78,8 @@ DEFUN(show_interface, show_interface_cmd,
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN(show_links, show_links_cmd,
|
DEFUN(show_link, show_link_cmd,
|
||||||
"show links",
|
"show link",
|
||||||
SHOW_STR "Show links and states")
|
SHOW_STR "Show links and states")
|
||||||
{
|
{
|
||||||
struct v5x_interface *v5if = get_interface(vty);
|
struct v5x_interface *v5if = get_interface(vty);
|
||||||
|
@ -127,9 +127,86 @@ DEFUN(show_links, show_links_cmd,
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN(show_ports, show_ports_cmd,
|
static void print_port(struct vty *vty, struct v5x_user_port *v5up)
|
||||||
"show ports",
|
{
|
||||||
SHOW_STR "Show user ports and states")
|
if (v5up->type == V5X_USER_TYPE_PSTN) {
|
||||||
|
vty_out(vty, "PSTN port nr %d:", v5up->nr);
|
||||||
|
vty_out(vty, " Port state=%s;", v5x_le_port_pstn_state_name(v5up->port_fi));
|
||||||
|
vty_out(vty, " PSTN state=%s%s", v5x_le_pstn_state_name(v5up->pstn.proto), VTY_NEWLINE);
|
||||||
|
if (v5up->ts[0]) {
|
||||||
|
if (v5up->interface->dialect == V5X_DIALECT_V51)
|
||||||
|
vty_out(vty, " Channel: TS %d%s", v5up->ts[0]->nr, VTY_NEWLINE);
|
||||||
|
else
|
||||||
|
vty_out(vty, " Channel: link %d TS %d%s", v5up->ts[0]->link->id,
|
||||||
|
v5up->ts[0]->nr, VTY_NEWLINE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
vty_out(vty, "ISDN port nr %d:", v5up->nr);
|
||||||
|
vty_out(vty, " Port state=%s%s", v5x_le_port_isdn_state_name(v5up->port_fi), VTY_NEWLINE);
|
||||||
|
if (v5up->ts[0]) {
|
||||||
|
if (v5up->interface->dialect == V5X_DIALECT_V51)
|
||||||
|
vty_out(vty, " Channel B1: TS %d%s", v5up->ts[0]->nr, VTY_NEWLINE);
|
||||||
|
else
|
||||||
|
vty_out(vty, " Channel B1: link %d TS %d%s", v5up->ts[0]->link->id,
|
||||||
|
v5up->ts[0]->nr, VTY_NEWLINE);
|
||||||
|
}
|
||||||
|
if (v5up->ts[1]) {
|
||||||
|
if (v5up->interface->dialect == V5X_DIALECT_V51)
|
||||||
|
vty_out(vty, " Channel B2: TS %d%s", v5up->ts[1]->nr, VTY_NEWLINE);
|
||||||
|
else
|
||||||
|
vty_out(vty, " Channel B2: link %d TS %d%s", v5up->ts[1]->link->id,
|
||||||
|
v5up->ts[1]->nr, VTY_NEWLINE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SHOW_PORT "Show given user port and states\n"
|
||||||
|
|
||||||
|
DEFUN(show_port_pstn, show_port_pstn_cmd,
|
||||||
|
"show port pstn <0-32767>",
|
||||||
|
SHOW_STR SHOW_PORT "Show given PSTN user port and states\n" "L3 address")
|
||||||
|
{
|
||||||
|
struct v5x_interface *v5if = get_interface(vty);
|
||||||
|
struct v5x_user_port *v5up;
|
||||||
|
|
||||||
|
if (!v5if)
|
||||||
|
return CMD_WARNING;
|
||||||
|
|
||||||
|
v5up = v5x_user_port_find(v5if, atoi(argv[0]), false);
|
||||||
|
if (!v5up) {
|
||||||
|
vty_out(vty, "%%Given PSTN user port does not exist.%s", VTY_NEWLINE);
|
||||||
|
return CMD_WARNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
print_port(vty, v5up);
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFUN(show_port_isdn, show_port_isdn_cmd,
|
||||||
|
"show port isdn <0-8175>",
|
||||||
|
SHOW_STR SHOW_PORT "Show given ISDN user port and states\n" "L3 address")
|
||||||
|
{
|
||||||
|
struct v5x_interface *v5if = get_interface(vty);
|
||||||
|
struct v5x_user_port *v5up;
|
||||||
|
|
||||||
|
if (!v5if)
|
||||||
|
return CMD_WARNING;
|
||||||
|
|
||||||
|
v5up = v5x_user_port_find(v5if, atoi(argv[0]), true);
|
||||||
|
if (!v5up) {
|
||||||
|
vty_out(vty, "%%Given ISDN user port does not exist.%s", VTY_NEWLINE);
|
||||||
|
return CMD_WARNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
print_port(vty, v5up);
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFUN(show_port, show_port_cmd,
|
||||||
|
"show port",
|
||||||
|
SHOW_STR "Show all user ports and states")
|
||||||
{
|
{
|
||||||
struct v5x_interface *v5if = get_interface(vty);
|
struct v5x_interface *v5if = get_interface(vty);
|
||||||
struct v5x_user_port *v5up;
|
struct v5x_user_port *v5up;
|
||||||
|
@ -141,37 +218,10 @@ DEFUN(show_ports, show_ports_cmd,
|
||||||
vty_out(vty, "%%No user ports created!%s", VTY_NEWLINE);
|
vty_out(vty, "%%No user ports created!%s", VTY_NEWLINE);
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
llist_for_each_entry(v5up, &v5if->user_ports, list) {
|
|
||||||
if (v5up->type == V5X_USER_TYPE_PSTN) {
|
llist_for_each_entry(v5up, &v5if->user_ports, list)
|
||||||
vty_out(vty, "PSTN port nr %d:", v5up->nr);
|
print_port(vty, v5up);
|
||||||
vty_out(vty, " Port state=%s", v5x_le_port_pstn_state_name(v5up->port_fi));
|
|
||||||
vty_out(vty, " PSTN state=%s%s", v5x_le_pstn_state_name(v5up->pstn.proto), VTY_NEWLINE);
|
|
||||||
if (v5up->ts[0]) {
|
|
||||||
if (v5if->dialect == V5X_DIALECT_V51)
|
|
||||||
vty_out(vty, " Channel: TS %d%s", v5up->ts[0]->nr, VTY_NEWLINE);
|
|
||||||
else
|
|
||||||
vty_out(vty, " Channel: link %d TS %d%s", v5up->ts[0]->link->id,
|
|
||||||
v5up->ts[0]->nr, VTY_NEWLINE);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
vty_out(vty, "ISDN port nr %d:", v5up->nr);
|
|
||||||
vty_out(vty, " Port state=%s%s", v5x_le_port_isdn_state_name(v5up->port_fi), VTY_NEWLINE);
|
|
||||||
if (v5up->ts[0]) {
|
|
||||||
if (v5if->dialect == V5X_DIALECT_V51)
|
|
||||||
vty_out(vty, " Channel B1: TS %d%s", v5up->ts[0]->nr, VTY_NEWLINE);
|
|
||||||
else
|
|
||||||
vty_out(vty, " Channel B1: link %d TS %d%s", v5up->ts[0]->link->id,
|
|
||||||
v5up->ts[0]->nr, VTY_NEWLINE);
|
|
||||||
}
|
|
||||||
if (v5up->ts[1]) {
|
|
||||||
if (v5if->dialect == V5X_DIALECT_V51)
|
|
||||||
vty_out(vty, " Channel B2: TS %d%s", v5up->ts[1]->nr, VTY_NEWLINE);
|
|
||||||
else
|
|
||||||
vty_out(vty, " Channel B2: link %d TS %d%s", v5up->ts[1]->link->id,
|
|
||||||
v5up->ts[1]->nr, VTY_NEWLINE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -797,8 +847,10 @@ static int config_write_interface_v52(struct vty *vty)
|
||||||
int v5le_vty_init(void)
|
int v5le_vty_init(void)
|
||||||
{
|
{
|
||||||
install_element_ve(&show_interface_cmd);
|
install_element_ve(&show_interface_cmd);
|
||||||
install_element_ve(&show_links_cmd);
|
install_element_ve(&show_link_cmd);
|
||||||
install_element_ve(&show_ports_cmd);
|
install_element_ve(&show_port_cmd);
|
||||||
|
install_element_ve(&show_port_pstn_cmd);
|
||||||
|
install_element_ve(&show_port_isdn_cmd);
|
||||||
install_element(ENABLE_NODE, &pstn_restart_cmd);
|
install_element(ENABLE_NODE, &pstn_restart_cmd);
|
||||||
install_element(ENABLE_NODE, &switchover_cmd);
|
install_element(ENABLE_NODE, &switchover_cmd);
|
||||||
install_element(ENABLE_NODE, &unblock_link_cmd);
|
install_element(ENABLE_NODE, &unblock_link_cmd);
|
||||||
|
|
Loading…
Reference in New Issue