diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-01-24 15:35:56 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-01-24 16:14:25 +0100 |
commit | 315ec675ba29f0a10f20ded82d13f2e59958a476 (patch) | |
tree | 1c9e876ab89c048ca859d23a62d3a6b51da42979 | |
parent | ea5ce23d72cbb6571862a4356ca21890aae5ecc9 (diff) |
mtp: Implement VTY routines to block,unblock,reset a link
This can help in link management and reconfiguration of a
link at runtime. It is also a good engineering mode for
multiple linksets.
-rw-r--r-- | src/vty_interface.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/vty_interface.c b/src/vty_interface.c index 9c87fb5..d2a714e 100644 --- a/src/vty_interface.c +++ b/src/vty_interface.c @@ -412,6 +412,61 @@ DEFUN(pcap_set_stop, pcap_set_stop_cmd, return CMD_SUCCESS; } +#define FIND_LINK(vty, type, nr) ({ \ + struct mtp_link_set *set = NULL; \ + struct mtp_link *link = NULL, *tmp; \ + if (strcmp(type, "mtp") == 0) \ + set = bsc.link_set; \ + else if (strcmp(type, "m2ua") == 0) \ + set = bsc.m2ua_set; \ + else { \ + vty_out(vty, "Unknown linkset %s.%s", type, VTY_NEWLINE); \ + return CMD_WARNING; \ + } \ + llist_for_each_entry(tmp, &set->links, entry) { \ + if (tmp->link_no == nr) { \ + link = tmp; \ + break; \ + } \ + } \ + if (!link) { \ + vty_out(vty, "Can not find link %d.%s", nr, VTY_NEWLINE); \ + return CMD_WARNING; \ + } \ + link; }) + +#define LINK_STR "Operations on the link\n" \ + "MTP Linkset\n" "M2UA Linkset\n" \ + "Link number\n" + +DEFUN(lnk_block, lnk_block_cmd, + "link (mtp|m2ua) <0-15> block", + LINK_STR "Block it\n") +{ + struct mtp_link *link = FIND_LINK(vty, argv[0], atoi(argv[1])); + mtp_link_block(link); + return CMD_SUCCESS; +} + +DEFUN(lnk_unblock, lnk_unblock_cmd, + "link (mtp|m2ua) <0-15> unblock", + LINK_STR "Unblock it\n") +{ + struct mtp_link *link = FIND_LINK(vty, argv[0], atoi(argv[1])); + mtp_link_unblock(link); + return CMD_SUCCESS; +} + +DEFUN(lnk_reset, lnk_reset_cmd, + "link (mtp|m2ua) <0-15> reset", + LINK_STR "Reset it\n") +{ + struct mtp_link *link = FIND_LINK(vty, argv[0], atoi(argv[1])); + mtp_link_failure(link); + return CMD_SUCCESS; +} + + void cell_vty_init(void) { @@ -447,6 +502,9 @@ void cell_vty_init(void) /* special commands */ install_element(ENABLE_NODE, &pcap_set_cmd); install_element(ENABLE_NODE, &pcap_set_stop_cmd); + install_element(ENABLE_NODE, &lnk_block_cmd); + install_element(ENABLE_NODE, &lnk_unblock_cmd); + install_element(ENABLE_NODE, &lnk_reset_cmd); /* show commands */ install_element_ve(&show_stats_cmd); |