diff options
139 files changed, 17394 insertions, 30371 deletions
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index bf1e92b26d..de6caa1596 100644 --- a/bgpd/bgp_aspath.c +++ b/bgpd/bgp_aspath.c @@ -28,6 +28,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "str.h" #include "log.h" #include "stream.h" +#include "command.h" #include "jhash.h" #include "queue.h" #include "filter.h" diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 827e4610f4..0cdaa545d6 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -32,6 +32,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "queue.h" #include "table.h" #include "filter.h" +#include "command.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_attr.h" diff --git a/bgpd/bgp_bfd.c b/bgpd/bgp_bfd.c index ad221d922d..670d959fe5 100644 --- a/bgpd/bgp_bfd.c +++ b/bgpd/bgp_bfd.c @@ -555,15 +555,16 @@ bgp_bfd_show_info(struct vty *vty, struct peer *peer, u_char use_json, json_obje DEFUN (neighbor_bfd, neighbor_bfd_cmd, - NEIGHBOR_CMD2 "bfd", + "neighbor <A.B.C.D|X:X::X:X|WORD> bfd", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Enables BFD support\n") { + int idx_peer = 1; struct peer *peer; int ret; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -578,7 +579,7 @@ DEFUN (neighbor_bfd, DEFUN (neighbor_bfd_param, neighbor_bfd_param_cmd, - NEIGHBOR_CMD2 "bfd " BFD_CMD_DETECT_MULT_RANGE BFD_CMD_MIN_RX_RANGE BFD_CMD_MIN_TX_RANGE, + "neighbor <A.B.C.D|X:X::X:X|WORD> bfd (2-255) (50-60000) (50-60000)", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Enables BFD support\n" @@ -586,17 +587,21 @@ DEFUN (neighbor_bfd_param, "Required min receive interval\n" "Desired min transmit interval\n") { + int idx_peer = 1; + int idx_number_1 = 3; + int idx_number_2 = 4; + int idx_number_3 = 5; struct peer *peer; u_int32_t rx_val; u_int32_t tx_val; u_int8_t dm_val; int ret; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (!peer) return CMD_WARNING; - if ((ret = bfd_validate_param (vty, argv[1], argv[2], argv[3], &dm_val, + if ((ret = bfd_validate_param (vty, argv[idx_number_1]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg, &dm_val, &rx_val, &tx_val)) != CMD_SUCCESS) return ret; @@ -610,23 +615,26 @@ DEFUN (neighbor_bfd_param, DEFUN_HIDDEN (neighbor_bfd_type, neighbor_bfd_type_cmd, - NEIGHBOR_CMD2 "bfd " BFD_CMD_TYPE, + "neighbor <A.B.C.D|X:X::X:X|WORD> bfd <multihop|singlehop>", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Enables BFD support\n" - "Session type\n") + "Multihop session\n" + "Single hop session\n") { + int idx_peer = 1; + int idx_hop = 3; struct peer *peer; enum bfd_sess_type type; int ret; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (!peer) return CMD_WARNING; - if (!strcmp(argv[1], "singlehop")) + if (!strcmp(argv[idx_hop]->arg, "singlehop")) type = BFD_TYPE_SINGLEHOP; - else if (!strcmp(argv[1], "multihop")) + else if (!strcmp(argv[idx_hop]->arg, "multihop")) type = BFD_TYPE_MULTIHOP; else return CMD_WARNING; @@ -640,16 +648,20 @@ DEFUN_HIDDEN (neighbor_bfd_type, DEFUN (no_neighbor_bfd, no_neighbor_bfd_cmd, - NO_NEIGHBOR_CMD2 "bfd", + "no neighbor <A.B.C.D|X:X::X:X|WORD> bfd [(2-255) (50-60000) (50-60000)]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "Disables BFD support\n") + "Disables BFD support\n" + "Detect Multiplier\n" + "Required min receive interval\n" + "Desired min transmit interval\n") { + int idx_peer = 2; struct peer *peer; int ret; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -660,30 +672,21 @@ DEFUN (no_neighbor_bfd, return CMD_SUCCESS; } -ALIAS (no_neighbor_bfd, - no_neighbor_bfd_val_cmd, - NO_NEIGHBOR_CMD2 "bfd " BFD_CMD_DETECT_MULT_RANGE BFD_CMD_MIN_RX_RANGE BFD_CMD_MIN_TX_RANGE, - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "Disables BFD support\n" - "Detect Multiplier\n" - "Required min receive interval\n" - "Desired min transmit interval\n") DEFUN_HIDDEN (no_neighbor_bfd_type, no_neighbor_bfd_type_cmd, - NO_NEIGHBOR_CMD2 "bfd " BFD_CMD_TYPE, + "no neighbor <A.B.C.D|X:X::X:X|WORD> bfd <multihop|singlehop>", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Disables BFD support\n" "Session type\n") { + int idx_peer = 2; struct peer *peer; int ret; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -711,6 +714,5 @@ bgp_bfd_init(void) install_element (BGP_NODE, &neighbor_bfd_param_cmd); install_element (BGP_NODE, &neighbor_bfd_type_cmd); install_element (BGP_NODE, &no_neighbor_bfd_cmd); - install_element (BGP_NODE, &no_neighbor_bfd_val_cmd); install_element (BGP_NODE, &no_neighbor_bfd_type_cmd); } diff --git a/bgpd/bgp_community.c b/bgpd/bgp_community.c index 450cbddcfa..17a3d2fdae 100644 --- a/bgpd/bgp_community.c +++ b/bgpd/bgp_community.c @@ -20,6 +20,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include <zebra.h> +#include "command.h" #include "hash.h" #include "memory.h" diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index 4d9ff60e92..f6b0500433 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -622,7 +622,7 @@ DEFUN (debug_bgp_neighbor_events, DEFUN (debug_bgp_neighbor_events_peer, debug_bgp_neighbor_events_peer_cmd, - "debug bgp neighbor-events (A.B.C.D|X:X::X:X|WORD)", + "debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>", DEBUG_STR BGP_STR "BGP Neighbor Events\n" @@ -630,7 +630,8 @@ DEFUN (debug_bgp_neighbor_events_peer, "BGP IPv6 neighbor to debug\n" "BGP neighbor on interface to debug\n") { - const char *host = argv[0]; + int idx_peer = 3; + const char *host = argv[idx_peer]->arg; if (!bgp_debug_neighbor_events_peers) bgp_debug_neighbor_events_peers = list_new (); @@ -675,7 +676,7 @@ DEFUN (no_debug_bgp_neighbor_events, DEFUN (no_debug_bgp_neighbor_events_peer, no_debug_bgp_neighbor_events_peer_cmd, - "no debug bgp neighbor-events (A.B.C.D|X:X::X:X|WORD)", + "no debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>", NO_STR DEBUG_STR BGP_STR @@ -684,8 +685,9 @@ DEFUN (no_debug_bgp_neighbor_events_peer, "BGP IPv6 neighbor to debug\n" "BGP neighbor on interface to debug\n") { + int idx_peer = 4; int found_peer = 0; - const char *host = argv[0]; + const char *host = argv[idx_peer]->arg; if (bgp_debug_neighbor_events_peers && !list_isempty(bgp_debug_neighbor_events_peers)) { @@ -766,7 +768,7 @@ DEFUN (debug_bgp_keepalive, DEFUN (debug_bgp_keepalive_peer, debug_bgp_keepalive_peer_cmd, - "debug bgp keepalives (A.B.C.D|X:X::X:X|WORD)", + "debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>", DEBUG_STR BGP_STR "BGP Neighbor Events\n" @@ -774,7 +776,8 @@ DEFUN (debug_bgp_keepalive_peer, "BGP IPv6 neighbor to debug\n" "BGP neighbor on interface to debug\n") { - const char *host = argv[0]; + int idx_peer = 3; + const char *host = argv[idx_peer]->arg; if (!bgp_debug_keepalive_peers) bgp_debug_keepalive_peers = list_new (); @@ -819,7 +822,7 @@ DEFUN (no_debug_bgp_keepalive, DEFUN (no_debug_bgp_keepalive_peer, no_debug_bgp_keepalive_peer_cmd, - "no debug bgp keepalives (A.B.C.D|X:X::X:X|WORD)", + "no debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>", NO_STR DEBUG_STR BGP_STR @@ -828,8 +831,9 @@ DEFUN (no_debug_bgp_keepalive_peer, "BGP IPv6 neighbor to debug\n" "BGP neighbor on interface to debug\n") { + int idx_peer = 4; int found_peer = 0; - const char *host = argv[0]; + const char *host = argv[idx_peer]->arg; if (bgp_debug_keepalive_peers && !list_isempty(bgp_debug_keepalive_peers)) { @@ -855,19 +859,20 @@ DEFUN (no_debug_bgp_keepalive_peer, /* debug bgp bestpath */ DEFUN (debug_bgp_bestpath_prefix, debug_bgp_bestpath_prefix_cmd, - "debug bgp bestpath (A.B.C.D/M|X:X::X:X/M)", + "debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>", DEBUG_STR BGP_STR "BGP bestpath\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "IPv6 prefix <network>/<length>\n") + "IPv4 prefix\n" + "IPv6 prefix\n") { + int idx_ipv4_ipv6_prefixlen = 3; struct prefix *argv_p; int ret; argv_p = prefix_new(); - ret = str2prefix (argv[0], argv_p); + ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p); if (!ret) { prefix_free(argv_p); @@ -881,7 +886,7 @@ DEFUN (debug_bgp_bestpath_prefix, if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes, NULL, argv_p)) { - vty_out (vty, "BGP bestptah debugging is already enabled for %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "BGP bestptah debugging is already enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); return CMD_SUCCESS; } @@ -894,7 +899,7 @@ DEFUN (debug_bgp_bestpath_prefix, else { TERM_DEBUG_ON (bestpath, BESTPATH); - vty_out (vty, "BGP bestpath debugging is on for %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "BGP bestpath debugging is on for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); } return CMD_SUCCESS; @@ -902,21 +907,22 @@ DEFUN (debug_bgp_bestpath_prefix, DEFUN (no_debug_bgp_bestpath_prefix, no_debug_bgp_bestpath_prefix_cmd, - "no debug bgp bestpath (A.B.C.D/M|X:X::X:X/M)", + "no debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>", NO_STR DEBUG_STR BGP_STR "BGP bestpath\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "IPv6 prefix <network>/<length>\n") + "IPv4 prefix\n" + "IPv6 prefix\n") { + int idx_ipv4_ipv6_prefixlen = 4; struct prefix *argv_p; int found_prefix = 0; int ret; argv_p = prefix_new(); - ret = str2prefix (argv[0], argv_p); + ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p); if (!ret) { prefix_free(argv_p); @@ -943,9 +949,9 @@ DEFUN (no_debug_bgp_bestpath_prefix, } if (found_prefix) - vty_out (vty, "BGP bestpath debugging is off for %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "BGP bestpath debugging is off for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); else - vty_out (vty, "BGP bestpath debugging was not enabled for %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "BGP bestpath debugging was not enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); return CMD_SUCCESS; } @@ -998,29 +1004,30 @@ DEFUN (debug_bgp_update, DEFUN (debug_bgp_update_direct, debug_bgp_update_direct_cmd, - "debug bgp updates (in|out)", + "debug bgp updates <in|out>", DEBUG_STR BGP_STR "BGP updates\n" "Inbound updates\n" "Outbound updates\n") { + int idx_in_out = 3; - if (strncmp ("i", argv[0], 1) == 0) + if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0) bgp_debug_list_free(bgp_debug_update_in_peers); else bgp_debug_list_free(bgp_debug_update_out_peers); if (vty->node == CONFIG_NODE) { - if (strncmp ("i", argv[0], 1) == 0) + if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0) DEBUG_ON (update, UPDATE_IN); else DEBUG_ON (update, UPDATE_OUT); } else { - if (strncmp ("i", argv[0], 1) == 0) + if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0) { TERM_DEBUG_ON (update, UPDATE_IN); vty_out (vty, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE); @@ -1036,7 +1043,7 @@ DEFUN (debug_bgp_update_direct, DEFUN (debug_bgp_update_direct_peer, debug_bgp_update_direct_peer_cmd, - "debug bgp updates (in|out) (A.B.C.D|X:X::X:X|WORD)", + "debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>", DEBUG_STR BGP_STR "BGP updates\n" @@ -1046,7 +1053,9 @@ DEFUN (debug_bgp_update_direct_peer, "BGP IPv6 neighbor to debug\n" "BGP neighbor on interface to debug\n") { - const char *host = argv[1]; + int idx_in_out = 3; + int idx_peer = 4; + const char *host = argv[idx_peer]->arg; int inbound; if (!bgp_debug_update_in_peers) @@ -1055,7 +1064,7 @@ DEFUN (debug_bgp_update_direct_peer, if (!bgp_debug_update_out_peers) bgp_debug_update_out_peers = list_new (); - if (strncmp ("i", argv[0], 1) == 0) + if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0) inbound = 1; else inbound = 0; @@ -1117,12 +1126,12 @@ DEFUN (debug_bgp_update_direct_peer, if (inbound) { TERM_DEBUG_ON (update, UPDATE_IN); - vty_out (vty, "BGP updates debugging is on (inbound) for %s%s", argv[1], VTY_NEWLINE); + vty_out (vty, "BGP updates debugging is on (inbound) for %s%s", argv[idx_peer]->arg, VTY_NEWLINE); } else { TERM_DEBUG_ON (update, UPDATE_OUT); - vty_out (vty, "BGP updates debugging is on (outbound) for %s%s", argv[1], VTY_NEWLINE); + vty_out (vty, "BGP updates debugging is on (outbound) for %s%s", argv[idx_peer]->arg, VTY_NEWLINE); } } return CMD_SUCCESS; @@ -1130,7 +1139,7 @@ DEFUN (debug_bgp_update_direct_peer, DEFUN (no_debug_bgp_update_direct, no_debug_bgp_update_direct_cmd, - "no debug bgp updates (in|out)", + "no debug bgp updates <in|out>", NO_STR DEBUG_STR BGP_STR @@ -1138,7 +1147,8 @@ DEFUN (no_debug_bgp_update_direct, "Inbound updates\n" "Outbound updates\n") { - if (strncmp ("i", argv[0], 1) == 0) + int idx_in_out = 4; + if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0) { bgp_debug_list_free(bgp_debug_update_in_peers); @@ -1172,7 +1182,7 @@ DEFUN (no_debug_bgp_update_direct, DEFUN (no_debug_bgp_update_direct_peer, no_debug_bgp_update_direct_peer_cmd, - "no debug bgp updates (in|out) (A.B.C.D|X:X::X:X|WORD)", + "no debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>", NO_STR DEBUG_STR BGP_STR @@ -1183,11 +1193,13 @@ DEFUN (no_debug_bgp_update_direct_peer, "BGP IPv6 neighbor to debug\n" "BGP neighbor on interface to debug\n") { + int idx_in_out = 4; + int idx_peer = 5; int inbound; int found_peer = 0; - const char *host = argv[1]; + const char *host = argv[idx_peer]->arg; - if (strncmp ("i", argv[0], 1) == 0) + if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0) inbound = 1; else inbound = 0; @@ -1262,20 +1274,21 @@ DEFUN (no_debug_bgp_update_direct_peer, DEFUN (debug_bgp_update_prefix, debug_bgp_update_prefix_cmd, - "debug bgp updates prefix (A.B.C.D/M|X:X::X:X/M)", + "debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>", DEBUG_STR BGP_STR "BGP updates\n" "Specify a prefix to debug\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "IPv6 prefix <network>/<length>\n") + "IPv4 prefix\n" + "IPv6 prefix\n") { + int idx_ipv4_ipv6_prefixlen = 4; struct prefix *argv_p; int ret; argv_p = prefix_new(); - ret = str2prefix (argv[0], argv_p); + ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p); if (!ret) { prefix_free(argv_p); @@ -1289,7 +1302,7 @@ DEFUN (debug_bgp_update_prefix, if (bgp_debug_list_has_entry(bgp_debug_update_prefixes, NULL, argv_p)) { - vty_out (vty, "BGP updates debugging is already enabled for %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "BGP updates debugging is already enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); return CMD_SUCCESS; } @@ -1302,7 +1315,7 @@ DEFUN (debug_bgp_update_prefix, else { TERM_DEBUG_ON (update, UPDATE_PREFIX); - vty_out (vty, "BGP updates debugging is on for %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "BGP updates debugging is on for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); } return CMD_SUCCESS; @@ -1310,22 +1323,23 @@ DEFUN (debug_bgp_update_prefix, DEFUN (no_debug_bgp_update_prefix, no_debug_bgp_update_prefix_cmd, - "no debug bgp updates prefix (A.B.C.D/M|X:X::X:X/M)", + "no debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>", NO_STR DEBUG_STR BGP_STR "BGP updates\n" "Specify a prefix to debug\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "IPv6 prefix <network>/<length>\n") + "IPv4 prefix\n" + "IPv6 prefix\n") { + int idx_ipv4_ipv6_prefixlen = 5; struct prefix *argv_p; int found_prefix = 0; int ret; argv_p = prefix_new(); - ret = str2prefix (argv[0], argv_p); + ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p); if (!ret) { prefix_free(argv_p); @@ -1352,9 +1366,9 @@ DEFUN (no_debug_bgp_update_prefix, } if (found_prefix) - vty_out (vty, "BGP updates debugging is off for %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "BGP updates debugging is off for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); else - vty_out (vty, "BGP updates debugging was not enabled for %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "BGP updates debugging was not enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); return CMD_SUCCESS; } @@ -1409,20 +1423,21 @@ DEFUN (debug_bgp_zebra, DEFUN (debug_bgp_zebra_prefix, debug_bgp_zebra_prefix_cmd, - "debug bgp zebra prefix (A.B.C.D/M|X:X::X:X/M)", + "debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>", DEBUG_STR BGP_STR "BGP Zebra messages\n" "Specify a prefix to debug\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "IPv6 prefix <network>/<length>\n") + "IPv4 prefix\n" + "IPv6 prefix\n") { + int idx_ipv4_ipv6_prefixlen = 4; struct prefix *argv_p; int ret; argv_p = prefix_new(); - ret = str2prefix (argv[0], argv_p); + ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p); if (!ret) { prefix_free(argv_p); @@ -1435,7 +1450,7 @@ DEFUN (debug_bgp_zebra_prefix, if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes, NULL, argv_p)) { - vty_out (vty, "BGP zebra debugging is already enabled for %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "BGP zebra debugging is already enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); return CMD_SUCCESS; } @@ -1446,7 +1461,7 @@ DEFUN (debug_bgp_zebra_prefix, else { TERM_DEBUG_ON (zebra, ZEBRA); - vty_out (vty, "BGP zebra debugging is on for %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "BGP zebra debugging is on for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); } return CMD_SUCCESS; @@ -1474,22 +1489,23 @@ DEFUN (no_debug_bgp_zebra, DEFUN (no_debug_bgp_zebra_prefix, no_debug_bgp_zebra_prefix_cmd, - "no debug bgp zebra prefix (A.B.C.D/M|X:X::X:X/M)", + "no debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>", NO_STR DEBUG_STR BGP_STR "BGP Zebra messages\n" "Specify a prefix to debug\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "IPv6 prefix <network>/<length>\n") + "IPv4 prefix\n" + "IPv6 prefix\n") { + int idx_ipv4_ipv6_prefixlen = 5; struct prefix *argv_p; int found_prefix = 0; int ret; argv_p = prefix_new(); - ret = str2prefix (argv[0], argv_p); + ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p); if (!ret) { prefix_free(argv_p); @@ -1514,9 +1530,9 @@ DEFUN (no_debug_bgp_zebra_prefix, } if (found_prefix) - vty_out (vty, "BGP zebra debugging is off for %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "BGP zebra debugging is off for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); else - vty_out (vty, "BGP zebra debugging was not enabled for %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "BGP zebra debugging was not enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); return CMD_SUCCESS; } @@ -1556,12 +1572,6 @@ DEFUN (no_debug_bgp_allow_martians, return CMD_SUCCESS; } -ALIAS (no_debug_bgp_allow_martians, - undebug_bgp_allow_martians_cmd, - "undebug bgp allow-martians", - UNDEBUG_STR - BGP_STR - "BGP allow martian next hops\n") /* debug bgp update-groups */ DEFUN (debug_bgp_update_groups, @@ -1906,7 +1916,6 @@ bgp_debug_init (void) install_element (ENABLE_NODE, &no_debug_bgp_zebra_cmd); install_element (CONFIG_NODE, &no_debug_bgp_zebra_cmd); install_element (ENABLE_NODE, &no_debug_bgp_allow_martians_cmd); - install_element (ENABLE_NODE, &undebug_bgp_allow_martians_cmd); install_element (CONFIG_NODE, &no_debug_bgp_allow_martians_cmd); install_element (ENABLE_NODE, &no_debug_bgp_update_groups_cmd); install_element (CONFIG_NODE, &no_debug_bgp_update_groups_cmd); diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index 7a4d4e701f..e1f54bbfef 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -737,7 +737,7 @@ bgp_dump_unset (struct vty *vty, struct bgp_dump *bgp_dump) DEFUN (dump_bgp_all, dump_bgp_all_cmd, - "dump bgp (all|all-et|updates|updates-et|routes-mrt) PATH [INTERVAL]", + "dump bgp <all|all-et|updates|updates-et|routes-mrt> PATH [INTERVAL]", "Dump packet\n" "BGP packet dump\n" "Dump all BGP packets\nDump all BGP packets (Extended Timestamp Header)\n" @@ -746,13 +746,16 @@ DEFUN (dump_bgp_all, "Output filename\n" "Interval of output\n") { + int idx_dump_routes = 2; + int idx_path = 3; + int idx_interval = 4; int bgp_dump_type = 0; const char *interval = NULL; struct bgp_dump *bgp_dump_struct = NULL; const struct bgp_dump_type_map *map = NULL; for (map = bgp_dump_type_map; map->str; map++) - if (strcmp(argv[0], map->str) == 0) + if (strcmp(argv[idx_dump_routes]->arg, map->str) == 0) bgp_dump_type = map->type; switch (bgp_dump_type) @@ -772,16 +775,16 @@ DEFUN (dump_bgp_all, } /* When an interval is given */ - if (argc == 3) - interval = argv[2]; + if (argc == idx_interval + 1) + interval = argv[idx_interval]->arg; return bgp_dump_set (vty, bgp_dump_struct, bgp_dump_type, - argv[1], interval); + argv[idx_path]->arg, interval); } DEFUN (no_dump_bgp_all, no_dump_bgp_all_cmd, - "no dump bgp (all|all-et|updates|updates-et|routes-mrt) [PATH] [INTERVAL]", + "no dump bgp <all|all-et|updates|updates-et|routes-mrt> [PATH] [INTERVAL]", NO_STR "Stop dump packet\n" "Stop BGP packet dump\n" @@ -791,12 +794,13 @@ DEFUN (no_dump_bgp_all, "Stop dump process updates-et\n" "Stop dump process route-mrt\n") { + int idx_dump_routes = 3; int bgp_dump_type = 0; const struct bgp_dump_type_map *map = NULL; struct bgp_dump *bgp_dump_struct = NULL; for (map = bgp_dump_type_map; map->str; map++) - if (strcmp(argv[0], map->str) == 0) + if (strcmp(argv[idx_dump_routes]->arg, map->str) == 0) bgp_dump_type = map->type; switch (bgp_dump_type) diff --git a/bgpd/bgp_encap.c b/bgpd/bgp_encap.c index 533a306975..dd35bb2c3c 100644 --- a/bgpd/bgp_encap.c +++ b/bgpd/bgp_encap.c @@ -217,13 +217,16 @@ DEFUN (encap_network, encap_network_cmd, "network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD", "Specify a network to announce via BGP\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" + "IPv4 prefix\n" "Specify Route Distinguisher\n" "ENCAP Route Distinguisher\n" "BGP tag\n" "tag value\n") { - return bgp_static_set_safi (SAFI_ENCAP, vty, argv[0], argv[1], argv[2], NULL); + int idx_ipv4 = 1; + int idx_rd = 3; + int idx_word = 5; + return bgp_static_set_safi (SAFI_ENCAP, vty, argv[idx_ipv4]->arg, argv[idx_rd]->arg, argv[idx_word]->arg, NULL); } /* For testing purpose, static route of ENCAP. */ @@ -232,13 +235,16 @@ DEFUN (no_encap_network, "no network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD", NO_STR "Specify a network to announce via BGP\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" + "IPv4 prefix\n" "Specify Route Distinguisher\n" "ENCAP Route Distinguisher\n" "BGP tag\n" "tag value\n") { - return bgp_static_unset_safi (SAFI_ENCAP, vty, argv[0], argv[1], argv[2]); + int idx_ipv4 = 2; + int idx_rd = 4; + int idx_word = 6; + return bgp_static_unset_safi (SAFI_ENCAP, vty, argv[idx_ipv4]->arg, argv[idx_rd]->arg, argv[idx_word]->arg); } static int @@ -500,10 +506,11 @@ DEFUN (show_bgp_ipv4_encap_rd, "Display information for a route distinguisher\n" "ENCAP Route Distinguisher\n") { + int idx_rd = 5; int ret; struct prefix_rd prd; - ret = str2prefix_rd (argv[0], &prd); + ret = str2prefix_rd (argv[idx_rd]->arg, &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); @@ -523,10 +530,11 @@ DEFUN (show_bgp_ipv6_encap_rd, "ENCAP Route Distinguisher\n" "Display BGP tags for prefixes\n") { + int idx_rd = 5; int ret; struct prefix_rd prd; - ret = str2prefix_rd (argv[0], &prd); + ret = str2prefix_rd (argv[idx_rd]->arg, &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); @@ -572,10 +580,11 @@ DEFUN (show_bgp_ipv4_encap_rd_tags, "ENCAP Route Distinguisher\n" "Display BGP tags for prefixes\n") { + int idx_rd = 5; int ret; struct prefix_rd prd; - ret = str2prefix_rd (argv[0], &prd); + ret = str2prefix_rd (argv[idx_rd]->arg, &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); @@ -595,10 +604,11 @@ DEFUN (show_bgp_ipv6_encap_rd_tags, "ENCAP Route Distinguisher\n" "Display BGP tags for prefixes\n") { + int idx_rd = 5; int ret; struct prefix_rd prd; - ret = str2prefix_rd (argv[0], &prd); + ret = str2prefix_rd (argv[idx_rd]->arg, &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); @@ -619,12 +629,13 @@ DEFUN (show_bgp_ipv4_encap_neighbor_routes, "Neighbor to display information about\n" "Display routes learned from neighbor\n") { + int idx_peer = 5; union sockunion su; struct peer *peer; - if (str2sockunion(argv[0], &su)) + if (sockunion_str2su (argv[idx_peer]->arg)) { - vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -649,12 +660,13 @@ DEFUN (show_bgp_ipv6_encap_neighbor_routes, "Neighbor to display information about\n" "Display routes learned from neighbor\n") { + int idx_peer = 5; union sockunion su; struct peer *peer; - if (str2sockunion(argv[0], &su)) + if (str2sockunion(argv[idx_peer]->arg, &su)) { - vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -671,7 +683,7 @@ DEFUN (show_bgp_ipv6_encap_neighbor_routes, DEFUN (show_bgp_ipv4_encap_rd_neighbor_routes, show_bgp_ipv4_encap_rd_neighbor_routes_cmd, - "show bgp ipv4 encap rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) routes", + "show bgp ipv4 encap rd ASN:nn_or_IP-address:nn neighbors <A.B.C.D|X:X::X:X> routes", SHOW_STR BGP_STR "Address Family\n" @@ -683,21 +695,23 @@ DEFUN (show_bgp_ipv4_encap_rd_neighbor_routes, "Neighbor to display information about\n" "Display routes learned from neighbor\n") { + int idx_rd = 5; + int idx_peer = 7; int ret; union sockunion su; struct peer *peer; struct prefix_rd prd; - ret = str2prefix_rd (argv[0], &prd); + ret = str2prefix_rd (argv[idx_rd]->arg, &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); return CMD_WARNING; } - if (str2sockunion(argv[1], &su)) + if (str2sockunion(argv[idx_peer]->arg, &su)) { - vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); + vty_out (vty, "Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -713,7 +727,7 @@ DEFUN (show_bgp_ipv4_encap_rd_neighbor_routes, #ifdef HAVE_IPV6 DEFUN (show_bgp_ipv6_encap_rd_neighbor_routes, show_bgp_ipv6_encap_rd_neighbor_routes_cmd, - "show bgp ipv6 encap rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) routes", + "show bgp ipv6 encap rd ASN:nn_or_IP-address:nn neighbors <A.B.C.D|X:X::X:X> routes", SHOW_STR BGP_STR "Address Family\n" @@ -725,21 +739,23 @@ DEFUN (show_bgp_ipv6_encap_rd_neighbor_routes, "Neighbor to display information about\n" "Display routes learned from neighbor\n") { + int idx_rd = 5; + int idx_peer = 7; int ret; union sockunion su; struct peer *peer; struct prefix_rd prd; - ret = str2prefix_rd (argv[0], &prd); + ret = str2prefix_rd (argv[idx_rd]->arg, &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); return CMD_WARNING; } - if (str2sockunion(argv[1], &su)) + if (str2sockunion(argv[idx_peer]->arg, &su)) { - vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); + vty_out (vty, "Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -765,14 +781,15 @@ DEFUN (show_bgp_ipv4_encap_neighbor_advertised_routes, "Neighbor to display information about\n" "Display the routes advertised to a BGP neighbor\n") { + int idx_peer = 5; int ret; struct peer *peer; union sockunion su; - ret = str2sockunion (argv[0], &su); + ret = str2sockunion (argv[idx_peer]->arg, &su); if (ret < 0) { - vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "%% Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); return CMD_WARNING; } peer = peer_lookup (NULL, &su); @@ -796,14 +813,15 @@ DEFUN (show_bgp_ipv6_encap_neighbor_advertised_routes, "Neighbor to display information about\n" "Display the routes advertised to a BGP neighbor\n") { + int idx_peer = 5; int ret; struct peer *peer; union sockunion su; - ret = str2sockunion (argv[0], &su); + ret = str2sockunion (argv[idx_peer]->arg, &su); if (ret < 0) { - vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "%% Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); return CMD_WARNING; } peer = peer_lookup (NULL, &su); @@ -819,7 +837,7 @@ DEFUN (show_bgp_ipv6_encap_neighbor_advertised_routes, DEFUN (show_bgp_ipv4_encap_rd_neighbor_advertised_routes, show_bgp_ipv4_encap_rd_neighbor_advertised_routes_cmd, - "show bgp ipv4 encap rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) advertised-routes", + "show bgp ipv4 encap rd ASN:nn_or_IP-address:nn neighbors <A.B.C.D|X:X::X:X> advertised-routes", SHOW_STR BGP_STR "Address Family\n" @@ -831,15 +849,17 @@ DEFUN (show_bgp_ipv4_encap_rd_neighbor_advertised_routes, "Neighbor to display information about\n" "Display the routes advertised to a BGP neighbor\n") { + int idx_rd = 5; + int idx_peer = 7; int ret; struct peer *peer; struct prefix_rd prd; union sockunion su; - ret = str2sockunion (argv[1], &su); + ret = str2sockunion (argv[idx_peer]->arg, &su); if (ret < 0) { - vty_out (vty, "%% Malformed address: %s%s", argv[1], VTY_NEWLINE); + vty_out (vty, "%% Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); return CMD_WARNING; } peer = peer_lookup (NULL, &su); @@ -849,7 +869,7 @@ DEFUN (show_bgp_ipv4_encap_rd_neighbor_advertised_routes, return CMD_WARNING; } - ret = str2prefix_rd (argv[0], &prd); + ret = str2prefix_rd (argv[idx_rd]->arg, &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); @@ -861,7 +881,7 @@ DEFUN (show_bgp_ipv4_encap_rd_neighbor_advertised_routes, #ifdef HAVE_IPV6 DEFUN (show_bgp_ipv6_encap_rd_neighbor_advertised_routes, show_bgp_ipv6_encap_rd_neighbor_advertised_routes_cmd, - "show bgp ipv6 encap rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) advertised-routes", + "show bgp ipv6 encap rd ASN:nn_or_IP-address:nn neighbors <A.B.C.D|X:X::X:X> advertised-routes", SHOW_STR BGP_STR "Address Family\n" @@ -873,15 +893,17 @@ DEFUN (show_bgp_ipv6_encap_rd_neighbor_advertised_routes, "Neighbor to display information about\n" "Display the routes advertised to a BGP neighbor\n") { + int idx_rd = 5; + int idx_peer = 7; int ret; struct peer *peer; struct prefix_rd prd; union sockunion su; - ret = str2sockunion (argv[1], &su); + ret = str2sockunion (argv[idx_peer]->arg, &su); if (ret < 0) { - vty_out (vty, "%% Malformed address: %s%s", argv[1], VTY_NEWLINE); + vty_out (vty, "%% Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); return CMD_WARNING; } peer = peer_lookup (NULL, &su); @@ -891,7 +913,7 @@ DEFUN (show_bgp_ipv6_encap_rd_neighbor_advertised_routes, return CMD_WARNING; } - ret = str2prefix_rd (argv[0], &prd); + ret = str2prefix_rd (argv[idx_rd]->arg, &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); diff --git a/bgpd/bgp_encap_tlv.c b/bgpd/bgp_encap_tlv.c index c554ade27e..5c18629aa6 100644 --- a/bgpd/bgp_encap_tlv.c +++ b/bgpd/bgp_encap_tlv.c @@ -19,6 +19,7 @@ #include <zebra.h> +#include "command.h" #include "memory.h" #include "prefix.h" #include "vty.h" diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c index a95a7564ec..6755335535 100644 --- a/bgpd/bgp_filter.c +++ b/bgpd/bgp_filter.c @@ -426,8 +426,9 @@ as_list_dup_check (struct as_list *aslist, struct as_filter *new) return 0; } -DEFUN (ip_as_path, ip_as_path_cmd, - "ip as-path access-list WORD (deny|permit) .LINE", +DEFUN (ip_as_path, + ip_as_path_cmd, + "ip as-path access-list WORD <deny|permit> LINE...", IP_STR "BGP autonomous system path filter\n" "Specify an access list name\n" @@ -436,6 +437,8 @@ DEFUN (ip_as_path, ip_as_path_cmd, "Specify packets to forward\n" "A regular-expression to match the BGP AS paths\n") { + int idx_word = 3; + int idx_permit_deny = 4; enum as_filter_type type; struct as_filter *asfilter; struct as_list *aslist; @@ -443,9 +446,9 @@ DEFUN (ip_as_path, ip_as_path_cmd, char *regstr; /* Check the filter type. */ - if (strncmp (argv[1], "p", 1) == 0) + if (strncmp (argv[idx_permit_deny]->arg, "p", 1) == 0) type = AS_FILTER_PERMIT; - else if (strncmp (argv[1], "d", 1) == 0) + else if (strncmp (argv[idx_permit_deny]->arg, "d", 1) == 0) type = AS_FILTER_DENY; else { @@ -454,13 +457,13 @@ DEFUN (ip_as_path, ip_as_path_cmd, } /* Check AS path regex. */ - regstr = argv_concat(argv, argc, 2); + regstr = argv_concat(argv, argc, idx_permit_deny); regex = bgp_regcomp (regstr); if (!regex) { XFREE (MTYPE_TMP, regstr); - vty_out (vty, "can't compile regexp %s%s", argv[0], + vty_out (vty, "can't compile regexp %s%s", argv[idx_word]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -470,7 +473,7 @@ DEFUN (ip_as_path, ip_as_path_cmd, XFREE (MTYPE_TMP, regstr); /* Install new filter to the access_list. */ - aslist = as_list_get (argv[0]); + aslist = as_list_get (argv[idx_word]->arg); /* Duplicate insertion check. */; if (as_list_dup_check (aslist, asfilter)) @@ -483,7 +486,7 @@ DEFUN (ip_as_path, ip_as_path_cmd, DEFUN (no_ip_as_path, no_ip_as_path_cmd, - "no ip as-path access-list WORD (deny|permit) .LINE", + "no ip as-path access-list WORD <deny|permit> LINE...", NO_STR IP_STR "BGP autonomous system path filter\n" @@ -493,6 +496,8 @@ DEFUN (no_ip_as_path, "Specify packets to forward\n" "A regular-expression to match the BGP AS paths\n") { + int idx_word = 4; + int idx_permit_deny = 5; enum as_filter_type type; struct as_filter *asfilter; struct as_list *aslist; @@ -500,18 +505,18 @@ DEFUN (no_ip_as_path, regex_t *regex; /* Lookup AS list from AS path list. */ - aslist = as_list_lookup (argv[0]); + aslist = as_list_lookup (argv[idx_word]->arg); if (aslist == NULL) { - vty_out (vty, "ip as-path access-list %s doesn't exist%s", argv[0], + vty_out (vty, "ip as-path access-list %s doesn't exist%s", argv[idx_word]->arg, VTY_NEWLINE); return CMD_WARNING; } /* Check the filter type. */ - if (strncmp (argv[1], "p", 1) == 0) + if (strncmp (argv[idx_permit_deny]->arg, "p", 1) == 0) type = AS_FILTER_PERMIT; - else if (strncmp (argv[1], "d", 1) == 0) + else if (strncmp (argv[idx_permit_deny]->arg, "d", 1) == 0) type = AS_FILTER_DENY; else { @@ -520,13 +525,13 @@ DEFUN (no_ip_as_path, } /* Compile AS path. */ - regstr = argv_concat(argv, argc, 2); + regstr = argv_concat(argv, argc, idx_permit_deny); regex = bgp_regcomp (regstr); if (!regex) { XFREE (MTYPE_TMP, regstr); - vty_out (vty, "can't compile regexp %s%s", argv[0], + vty_out (vty, "can't compile regexp %s%s", argv[idx_word]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -557,12 +562,13 @@ DEFUN (no_ip_as_path_all, "Specify an access list name\n" "Regular expression access list name\n") { + int idx_word = 4; struct as_list *aslist; - aslist = as_list_lookup (argv[0]); + aslist = as_list_lookup (argv[idx_word]->arg); if (aslist == NULL) { - vty_out (vty, "ip as-path access-list %s doesn't exist%s", argv[0], + vty_out (vty, "ip as-path access-list %s doesn't exist%s", argv[idx_word]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -571,7 +577,7 @@ DEFUN (no_ip_as_path_all, /* Run hook function. */ if (as_list_master.delete_hook) - (*as_list_master.delete_hook) (argv[0]); + (*as_list_master.delete_hook) (argv[idx_word]->arg); return CMD_SUCCESS; } @@ -627,9 +633,10 @@ DEFUN (show_ip_as_path_access_list, "List AS path access lists\n" "AS path access list name\n") { + int idx_word = 3; struct as_list *aslist; - aslist = as_list_lookup (argv[0]); + aslist = as_list_lookup (argv[idx_word]->arg); if (aslist) as_list_show (vty, aslist); diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index ab4ea71d61..2f2ea3ae41 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -33,6 +33,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "workqueue.h" #include "queue.h" #include "filter.h" +#include "command.h" #include "lib/json.h" #include "bgpd/bgpd.h" diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 39cb41d74a..312a9f3727 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -274,8 +274,8 @@ bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr, if (attr) { - bgp_update (peer, &p, addpath_id, attr, packet->afi, SAFI_MPLS_VPN, - ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, tagpnt, 0); + bgp_update (peer, &p, addpath_id, attr, packet->afi, SAFI_MPLS_VPN, + ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, tagpnt, 0); #if ENABLE_BGP_VNC rfapiProcessUpdate(peer, NULL, &p, &prd, attr, packet->afi, SAFI_MPLS_VPN, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, @@ -288,9 +288,9 @@ bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr, rfapiProcessWithdraw(peer, NULL, &p, &prd, attr, packet->afi, SAFI_MPLS_VPN, ZEBRA_ROUTE_BGP, 0); #endif - bgp_withdraw (peer, &p, addpath_id, attr, packet->afi, SAFI_MPLS_VPN, - ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, tagpnt); - } + bgp_withdraw (peer, &p, addpath_id, attr, packet->afi, SAFI_MPLS_VPN, + ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, tagpnt); + } } /* Packet length consistency check. */ if (pnt != lim) @@ -445,20 +445,23 @@ DEFUN (vpnv4_network, vpnv4_network_cmd, "network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD", "Specify a network to announce via BGP\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" + "IPv4 prefix\n" "Specify Route Distinguisher\n" "VPN Route Distinguisher\n" "BGP tag\n" "tag value\n") { - return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[0], argv[1], argv[2], NULL); + int idx_ipv4_prefixlen = 1; + int idx_ext_community = 3; + int idx_word = 5; + return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, NULL); } DEFUN (vpnv4_network_route_map, vpnv4_network_route_map_cmd, "network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD route-map WORD", "Specify a network to announce via BGP\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" + "IPv4 prefix\n" "Specify Route Distinguisher\n" "VPN Route Distinguisher\n" "BGP tag\n" @@ -466,7 +469,11 @@ DEFUN (vpnv4_network_route_map, "route map\n" "route map name\n") { - return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[0], argv[1], argv[2], argv[3]); + int idx_ipv4_prefixlen = 1; + int idx_ext_community = 3; + int idx_word = 5; + int idx_word_2 = 7; + return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, argv[idx_word_2]->arg); } /* For testing purpose, static route of MPLS-VPN. */ @@ -475,13 +482,16 @@ DEFUN (no_vpnv4_network, "no network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD", NO_STR "Specify a network to announce via BGP\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" + "IPv4 prefix\n" "Specify Route Distinguisher\n" "VPN Route Distinguisher\n" "BGP tag\n" "tag value\n") { - return bgp_static_unset_safi (SAFI_MPLS_VPN, vty, argv[0], argv[1], argv[2]); + int idx_ipv4_prefixlen = 2; + int idx_ext_community = 4; + int idx_word = 6; + return bgp_static_unset_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg); } static int @@ -887,7 +897,7 @@ bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd, DEFUN (show_bgp_ivp4_vpn, show_bgp_ipv4_vpn_cmd, - "show bgp ipv4 vpn {json}", + "show bgp ipv4 vpn [json]", SHOW_STR BGP_STR "Address Family\n" @@ -898,7 +908,7 @@ DEFUN (show_bgp_ivp4_vpn, DEFUN (show_bgp_ipv6_vpn, show_bgp_ipv6_vpn_cmd, - "show bgp ipv6 vpn {json}", + "show bgp ipv6 vpn [json]", SHOW_STR BGP_STR "Address Family\n" @@ -909,7 +919,7 @@ DEFUN (show_bgp_ipv6_vpn, DEFUN (show_bgp_ipv4_vpn_rd, show_bgp_ipv4_vpn_rd_cmd, - "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn {json}", + "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn [json]", SHOW_STR BGP_STR "Address Family\n" @@ -918,10 +928,11 @@ DEFUN (show_bgp_ipv4_vpn_rd, "VPN Route Distinguisher\n" JSON_STR) { + int idx_ext_community = 5; int ret; struct prefix_rd prd; - ret = str2prefix_rd (argv[0], &prd); + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); @@ -932,7 +943,7 @@ DEFUN (show_bgp_ipv4_vpn_rd, DEFUN (show_bgp_ipv6_vpn_rd, show_bgp_ipv6_vpn_rd_cmd, - "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn {json}", + "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn [json]", SHOW_STR BGP_STR "Address Family\n" @@ -941,10 +952,11 @@ DEFUN (show_bgp_ipv6_vpn_rd, "VPN Route Distinguisher\n" JSON_STR) { + int idx_ext_community = 5; int ret; struct prefix_rd prd; - ret = str2prefix_rd (argv[0], &prd); + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); if (!ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); @@ -960,7 +972,7 @@ DEFUN (show_ip_bgp_vpnv4_all, SHOW_STR IP_STR BGP_STR - "Display VPNv4 NLRI specific information\n" + "Address Family\n" "Display information about all VPNv4 NLRIs\n") { return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 0, 0); @@ -972,14 +984,15 @@ DEFUN (show_ip_bgp_vpnv4_rd, SHOW_STR IP_STR BGP_STR - "Display VPNv4 NLRI specific information\n" + "Address Family\n" "Display information for a route distinguisher\n" "VPN Route Distinguisher\n") { + int idx_ext_community = 5; int ret; struct prefix_rd prd; - ret = str2prefix_rd (argv[0], &prd); + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); @@ -994,7 +1007,7 @@ DEFUN (show_ip_bgp_vpnv4_all_tags, SHOW_STR IP_STR BGP_STR - "Display VPNv4 NLRI specific information\n" + "Address Family\n" "Display information about all VPNv4 NLRIs\n" "Display BGP tags for prefixes\n") { @@ -1007,15 +1020,16 @@ DEFUN (show_ip_bgp_vpnv4_rd_tags, SHOW_STR IP_STR BGP_STR - "Display VPNv4 NLRI specific information\n" + "Address Family\n" "Display information for a route distinguisher\n" "VPN Route Distinguisher\n" "Display BGP tags for prefixes\n") { + int idx_ext_community = 5; int ret; struct prefix_rd prd; - ret = str2prefix_rd (argv[0], &prd); + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); @@ -1026,23 +1040,24 @@ DEFUN (show_ip_bgp_vpnv4_rd_tags, DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes, show_ip_bgp_vpnv4_all_neighbor_routes_cmd, - "show ip bgp vpnv4 all neighbors A.B.C.D routes {json}", + "show ip bgp vpnv4 all neighbors A.B.C.D routes [json]", SHOW_STR IP_STR BGP_STR - "Display VPNv4 NLRI specific information\n" + "Address Family\n" "Display information about all VPNv4 NLRIs\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Display routes learned from neighbor\n" "JavaScript Object Notation\n") { + int idx_ipv4 = 6; union sockunion su; struct peer *peer; int ret; u_char uj = use_json(argc, argv); - ret = str2sockunion (argv[0], &su); + ret = str2sockunion (argv[idx_ipv4]->arg, &su); if (ret < 0) { if (uj) @@ -1054,7 +1069,7 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes, json_object_free(json_no); } else - vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "Malformed address: %s%s", argv[idx_ipv4]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -1079,11 +1094,11 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes, DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes, show_ip_bgp_vpnv4_rd_neighbor_routes_cmd, - "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D routes {json}", + "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D routes [json]", SHOW_STR IP_STR BGP_STR - "Display VPNv4 NLRI specific information\n" + "Address Family\n" "Display information for a route distinguisher\n" "VPN Route Distinguisher\n" "Detailed information on TCP and BGP neighbor connections\n" @@ -1091,13 +1106,15 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes, "Display routes learned from neighbor\n" "JavaScript Object Notation\n") { + int idx_ext_community = 5; + int idx_ipv4 = 7; int ret; union sockunion su; struct peer *peer; struct prefix_rd prd; u_char uj = use_json(argc, argv); - ret = str2prefix_rd (argv[0], &prd); + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); if (! ret) { if (uj) @@ -1113,7 +1130,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes, return CMD_WARNING; } - ret = str2sockunion (argv[1], &su); + ret = str2sockunion (argv[idx_ipv4]->arg, &su); if (ret < 0) { if (uj) @@ -1125,7 +1142,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes, json_object_free(json_no); } else - vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "Malformed address: %s%s", argv[idx_ext_community]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -1150,23 +1167,24 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes, DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes, show_ip_bgp_vpnv4_all_neighbor_advertised_routes_cmd, - "show ip bgp vpnv4 all neighbors A.B.C.D advertised-routes {json}", + "show ip bgp vpnv4 all neighbors A.B.C.D advertised-routes [json]", SHOW_STR IP_STR BGP_STR - "Display VPNv4 NLRI specific information\n" + "Address Family\n" "Display information about all VPNv4 NLRIs\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Display the routes advertised to a BGP neighbor\n" "JavaScript Object Notation\n") { + int idx_ipv4 = 6; int ret; struct peer *peer; union sockunion su; u_char uj = use_json(argc, argv); - ret = str2sockunion (argv[0], &su); + ret = str2sockunion (argv[idx_ipv4]->arg, &su); if (ret < 0) { if (uj) @@ -1178,7 +1196,7 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes, json_object_free(json_no); } else - vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "Malformed address: %s%s", argv[idx_ipv4]->arg, VTY_NEWLINE); return CMD_WARNING; } peer = peer_lookup (NULL, &su); @@ -1202,11 +1220,11 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes, DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes, show_ip_bgp_vpnv4_rd_neighbor_advertised_routes_cmd, - "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D advertised-routes {json}", + "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D advertised-routes [json]", SHOW_STR IP_STR BGP_STR - "Display VPNv4 NLRI specific information\n" + "Address Family\n" "Display information for a route distinguisher\n" "VPN Route Distinguisher\n" "Detailed information on TCP and BGP neighbor connections\n" @@ -1214,13 +1232,15 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes, "Display the routes advertised to a BGP neighbor\n" "JavaScript Object Notation\n") { + int idx_ext_community = 5; + int idx_ipv4 = 7; int ret; struct peer *peer; struct prefix_rd prd; union sockunion su; u_char uj = use_json(argc, argv); - ret = str2sockunion (argv[1], &su); + ret = str2sockunion (argv[idx_ipv4]->arg, &su); if (ret < 0) { if (uj) @@ -1232,7 +1252,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes, json_object_free(json_no); } else - vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "Malformed address: %s%s", argv[idx_ext_community]->arg, VTY_NEWLINE); return CMD_WARNING; } peer = peer_lookup (NULL, &su); @@ -1251,7 +1271,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes, return CMD_WARNING; } - ret = str2prefix_rd (argv[0], &prd); + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); if (! ret) { if (uj) diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index 6c30fefae5..493655d7fa 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -494,41 +494,22 @@ bgp_show_all_instances_nexthops_vty (struct vty *vty) DEFUN (show_ip_bgp_nexthop, show_ip_bgp_nexthop_cmd, - "show ip bgp nexthop", - SHOW_STR - IP_STR - BGP_STR - "BGP nexthop table\n") -{ - return show_ip_bgp_nexthop_table (vty, NULL, 0); -} - -DEFUN (show_ip_bgp_nexthop_detail, - show_ip_bgp_nexthop_detail_cmd, - "show ip bgp nexthop detail", - SHOW_STR - IP_STR - BGP_STR - "BGP nexthop table\n") -{ - return show_ip_bgp_nexthop_table (vty, NULL, 1); -} - -DEFUN (show_ip_bgp_instance_nexthop, - show_ip_bgp_instance_nexthop_cmd, - "show ip bgp " BGP_INSTANCE_CMD " nexthop", + "show [ip] bgp [<view|vrf> VRFNAME] nexthop [detail]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "BGP nexthop table\n") { - return show_ip_bgp_nexthop_table (vty, argv[1], 0); + int idx = 0; + char *vrf = argv_find (argv, argc, "VRFNAME", &idx) ? argv[idx]->arg : NULL; + int detail = argv_find (argv, argc, "detail", &idx) ? 1 : 0; + return show_ip_bgp_nexthop_table (vty, vrf, detail); } DEFUN (show_ip_bgp_instance_all_nexthop, show_ip_bgp_instance_all_nexthop_cmd, - "show ip bgp " BGP_INSTANCE_ALL_CMD " nexthop", + "show [ip] bgp <view|vrf> all nexthop", SHOW_STR IP_STR BGP_STR @@ -539,18 +520,6 @@ DEFUN (show_ip_bgp_instance_all_nexthop, return CMD_SUCCESS; } -DEFUN (show_ip_bgp_instance_nexthop_detail, - show_ip_bgp_instance_nexthop_detail_cmd, - "show ip bgp " BGP_INSTANCE_CMD " nexthop detail", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "BGP nexthop table\n") -{ - return show_ip_bgp_nexthop_table (vty, argv[1], 1); -} - void bgp_scan_init (struct bgp *bgp) { @@ -571,10 +540,7 @@ void bgp_scan_vty_init (void) { install_element (VIEW_NODE, &show_ip_bgp_nexthop_cmd); - install_element (VIEW_NODE, &show_ip_bgp_nexthop_detail_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_nexthop_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_all_nexthop_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_nexthop_detail_cmd); } void diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 57e38ce10c..6c71fd525c 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -20,7 +20,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include <zebra.h> -#include "lib/json.h" #include "prefix.h" #include "linklist.h" #include "memory.h" @@ -37,6 +36,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "workqueue.h" #include "queue.h" #include "memory.h" +#include "lib/json.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_table.h" @@ -60,7 +60,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "bgpd/bgp_mpath.h" #include "bgpd/bgp_nht.h" #include "bgpd/bgp_updgrp.h" -#include "bgpd/bgp_vty.h" #if ENABLE_BGP_VNC #include "bgpd/rfapi/rfapi_backend.h" @@ -1929,7 +1928,7 @@ bgp_process_main (struct work_queue *wq, void *data) vnc_import_bgp_add_route(bgp, p, old_select); vnc_import_bgp_exterior_add_route(bgp, p, old_select); #endif - bgp_zebra_announce (p, old_select, bgp, afi, safi); + bgp_zebra_announce (p, old_select, bgp, afi, safi); } UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); bgp_zebra_clear_route_change_flags (rn); @@ -2226,7 +2225,7 @@ bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); return; } - + #if ENABLE_BGP_VNC if (safi == SAFI_MPLS_VPN) { struct bgp_node *prn = NULL; @@ -3335,10 +3334,10 @@ bgp_cleanup_table(struct bgp_table *table, safi_t safi) if (table->owner && table->owner->bgp) vnc_import_bgp_del_route(table->owner->bgp, &rn->p, ri); #endif - bgp_zebra_withdraw (&rn->p, ri, safi); - } + bgp_zebra_withdraw (&rn->p, ri, safi); } } +} /* Delete all kernel routes. */ void @@ -4483,8 +4482,9 @@ DEFUN (bgp_table_map, "BGP table to RIB route download filter\n" "Name of the route map\n") { + int idx_word = 1; return bgp_table_map_set (vty, vty->index, - bgp_node_afi (vty), bgp_node_safi (vty), argv[0]); + bgp_node_afi (vty), bgp_node_safi (vty), argv[idx_word]->arg); } DEFUN (no_bgp_table_map, no_bgp_table_map_cmd, @@ -4492,17 +4492,19 @@ DEFUN (no_bgp_table_map, "BGP table to RIB route download filter\n" "Name of the route map\n") { + int idx_word = 2; return bgp_table_map_unset (vty, vty->index, - bgp_node_afi (vty), bgp_node_safi (vty), argv[0]); + bgp_node_afi (vty), bgp_node_safi (vty), argv[idx_word]->arg); } DEFUN (bgp_network, bgp_network_cmd, "network A.B.C.D/M", "Specify a network to announce via BGP\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") + "IPv4 prefix\n") { - return bgp_static_set (vty, vty->index, argv[0], + int idx_ipv4_prefixlen = 1; + return bgp_static_set (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, AFI_IP, bgp_node_safi (vty), NULL, 0); } @@ -4510,22 +4512,25 @@ DEFUN (bgp_network_route_map, bgp_network_route_map_cmd, "network A.B.C.D/M route-map WORD", "Specify a network to announce via BGP\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" + "IPv4 prefix\n" "Route-map to modify the attributes\n" "Name of the route map\n") { - return bgp_static_set (vty, vty->index, argv[0], - AFI_IP, bgp_node_safi (vty), argv[1], 0); + int idx_ipv4_prefixlen = 1; + int idx_word = 3; + return bgp_static_set (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, + AFI_IP, bgp_node_safi (vty), argv[idx_word]->arg, 0); } DEFUN (bgp_network_backdoor, bgp_network_backdoor_cmd, "network A.B.C.D/M backdoor", "Specify a network to announce via BGP\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" + "IPv4 prefix\n" "Specify a BGP backdoor route\n") { - return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, + int idx_ipv4_prefixlen = 1; + return bgp_static_set (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1); } @@ -4537,10 +4542,12 @@ DEFUN (bgp_network_mask, "Network mask\n" "Network mask\n") { + int idx_ipv4 = 1; + int idx_ipv4_2 = 3; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); @@ -4561,10 +4568,13 @@ DEFUN (bgp_network_mask_route_map, "Route-map to modify the attributes\n" "Name of the route map\n") { + int idx_ipv4 = 1; + int idx_ipv4_2 = 3; + int idx_word = 5; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); @@ -4572,7 +4582,7 @@ DEFUN (bgp_network_mask_route_map, } return bgp_static_set (vty, vty->index, prefix_str, - AFI_IP, bgp_node_safi (vty), argv[2], 0); + AFI_IP, bgp_node_safi (vty), argv[idx_word]->arg, 0); } DEFUN (bgp_network_mask_backdoor, @@ -4584,10 +4594,12 @@ DEFUN (bgp_network_mask_backdoor, "Network mask\n" "Specify a BGP backdoor route\n") { + int idx_ipv4 = 1; + int idx_ipv4_2 = 3; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); @@ -4604,10 +4616,11 @@ DEFUN (bgp_network_mask_natural, "Specify a network to announce via BGP\n" "Network number\n") { + int idx_ipv4 = 1; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, NULL, prefix_str); if (! ret) { vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); @@ -4626,10 +4639,12 @@ DEFUN (bgp_network_mask_natural_route_map, "Route-map to modify the attributes\n" "Name of the route map\n") { + int idx_ipv4 = 1; + int idx_word = 3; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, NULL, prefix_str); if (! ret) { vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); @@ -4637,7 +4652,7 @@ DEFUN (bgp_network_mask_natural_route_map, } return bgp_static_set (vty, vty->index, prefix_str, - AFI_IP, bgp_node_safi (vty), argv[1], 0); + AFI_IP, bgp_node_safi (vty), argv[idx_word]->arg, 0); } DEFUN (bgp_network_mask_natural_backdoor, @@ -4647,10 +4662,11 @@ DEFUN (bgp_network_mask_natural_backdoor, "Network number\n" "Specify a BGP backdoor route\n") { + int idx_ipv4 = 1; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, NULL, prefix_str); if (! ret) { vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); @@ -4663,45 +4679,37 @@ DEFUN (bgp_network_mask_natural_backdoor, DEFUN (no_bgp_network, no_bgp_network_cmd, - "no network A.B.C.D/M", + "no network A.B.C.D/M [<backdoor|route-map WORD>]", NO_STR "Specify a network to announce via BGP\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") + "IPv4 prefix\n" + "Specify a BGP backdoor route\n" + "Route-map to modify the attributes\n" + "Name of the route map\n") { - return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, + int idx_ipv4_prefixlen = 2; + return bgp_static_unset (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, AFI_IP, bgp_node_safi (vty)); } -ALIAS (no_bgp_network, - no_bgp_network_route_map_cmd, - "no network A.B.C.D/M route-map WORD", - NO_STR - "Specify a network to announce via BGP\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "Route-map to modify the attributes\n" - "Name of the route map\n") - -ALIAS (no_bgp_network, - no_bgp_network_backdoor_cmd, - "no network A.B.C.D/M backdoor", - NO_STR - "Specify a network to announce via BGP\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "Specify a BGP backdoor route\n") - DEFUN (no_bgp_network_mask, no_bgp_network_mask_cmd, - "no network A.B.C.D mask A.B.C.D", + "no network A.B.C.D mask A.B.C.D [<backdoor|route-map WORD>]", NO_STR "Specify a network to announce via BGP\n" "Network number\n" "Network mask\n" - "Network mask\n") + "Network mask\n" + "Specify a BGP backdoor route\n" + "Route-map to modify the attributes\n" + "Name of the route map\n") { + int idx_ipv4 = 2; + int idx_ipv4_2 = 4; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); @@ -4712,38 +4720,21 @@ DEFUN (no_bgp_network_mask, bgp_node_safi (vty)); } -ALIAS (no_bgp_network_mask, - no_bgp_network_mask_route_map_cmd, - "no network A.B.C.D mask A.B.C.D route-map WORD", +DEFUN (no_bgp_network_mask_natural, + no_bgp_network_mask_natural_cmd, + "no network A.B.C.D [<backdoor|route-map WORD>]", NO_STR "Specify a network to announce via BGP\n" "Network number\n" - "Network mask\n" - "Network mask\n" + "Specify a BGP backdoor route\n" "Route-map to modify the attributes\n" "Name of the route map\n") - -ALIAS (no_bgp_network_mask, - no_bgp_network_mask_backdoor_cmd, - "no network A.B.C.D mask A.B.C.D backdoor", - NO_STR - "Specify a network to announce via BGP\n" - "Network number\n" - "Network mask\n" - "Network mask\n" - "Specify a BGP backdoor route\n") - -DEFUN (no_bgp_network_mask_natural, - no_bgp_network_mask_natural_cmd, - "no network A.B.C.D", - NO_STR - "Specify a network to announce via BGP\n" - "Network number\n") { + int idx_ipv4 = 2; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, NULL, prefix_str); if (! ret) { vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); @@ -4754,31 +4745,14 @@ DEFUN (no_bgp_network_mask_natural, bgp_node_safi (vty)); } -ALIAS (no_bgp_network_mask_natural, - no_bgp_network_mask_natural_route_map_cmd, - "no network A.B.C.D route-map WORD", - NO_STR - "Specify a network to announce via BGP\n" - "Network number\n" - "Route-map to modify the attributes\n" - "Name of the route map\n") - -ALIAS (no_bgp_network_mask_natural, - no_bgp_network_mask_natural_backdoor_cmd, - "no network A.B.C.D backdoor", - NO_STR - "Specify a network to announce via BGP\n" - "Network number\n" - "Specify a BGP backdoor route\n") - -#ifdef HAVE_IPV6 DEFUN (ipv6_bgp_network, ipv6_bgp_network_cmd, "network X:X::X:X/M", "Specify a network to announce via BGP\n" - "IPv6 prefix <network>/<length>\n") + "IPv6 prefix\n") { - return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty), + int idx_ipv6_prefixlen = 1; + return bgp_static_set (vty, vty->index, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, bgp_node_safi(vty), NULL, 0); } @@ -4786,50 +4760,28 @@ DEFUN (ipv6_bgp_network_route_map, ipv6_bgp_network_route_map_cmd, "network X:X::X:X/M route-map WORD", "Specify a network to announce via BGP\n" - "IPv6 prefix <network>/<length>\n" + "IPv6 prefix\n" "Route-map to modify the attributes\n" "Name of the route map\n") { - return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, - bgp_node_safi (vty), argv[1], 0); + int idx_ipv6_prefixlen = 1; + int idx_word = 3; + return bgp_static_set (vty, vty->index, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, + bgp_node_safi (vty), argv[idx_word]->arg, 0); } DEFUN (no_ipv6_bgp_network, no_ipv6_bgp_network_cmd, - "no network X:X::X:X/M", - NO_STR - "Specify a network to announce via BGP\n" - "IPv6 prefix <network>/<length>\n") -{ - return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty)); -} - -ALIAS (no_ipv6_bgp_network, - no_ipv6_bgp_network_route_map_cmd, - "no network X:X::X:X/M route-map WORD", + "no network X:X::X:X/M [route-map WORD]", NO_STR "Specify a network to announce via BGP\n" - "IPv6 prefix <network>/<length>\n" + "IPv6 prefix\n" "Route-map to modify the attributes\n" "Name of the route map\n") - -ALIAS (ipv6_bgp_network, - old_ipv6_bgp_network_cmd, - "ipv6 bgp network X:X::X:X/M", - IPV6_STR - BGP_STR - "Specify a network to announce via BGP\n" - "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") - -ALIAS (no_ipv6_bgp_network, - old_no_ipv6_bgp_network_cmd, - "no ipv6 bgp network X:X::X:X/M", - NO_STR - IPV6_STR - BGP_STR - "Specify a network to announce via BGP\n" - "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") -#endif /* HAVE_IPV6 */ +{ + int idx_ipv6_prefixlen = 2; + return bgp_static_unset (vty, vty->index, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, bgp_node_safi(vty)); +} /* Aggreagete address: @@ -5434,137 +5386,46 @@ bgp_aggregate_set (struct vty *vty, const char *prefix_str, DEFUN (aggregate_address, aggregate_address_cmd, - "aggregate-address A.B.C.D/M", - "Configure BGP aggregate entries\n" - "Aggregate prefix\n") -{ - return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); -} - -DEFUN (aggregate_address_mask, - aggregate_address_mask_cmd, - "aggregate-address A.B.C.D A.B.C.D", - "Configure BGP aggregate entries\n" - "Aggregate address\n" - "Aggregate mask\n") -{ - int ret; - char prefix_str[BUFSIZ]; - - ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); - - if (! ret) - { - vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), - 0, 0); -} - -DEFUN (aggregate_address_summary_only, - aggregate_address_summary_only_cmd, - "aggregate-address A.B.C.D/M summary-only", - "Configure BGP aggregate entries\n" - "Aggregate prefix\n" - "Filter more specific routes from updates\n") -{ - return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), - AGGREGATE_SUMMARY_ONLY, 0); -} - -DEFUN (aggregate_address_mask_summary_only, - aggregate_address_mask_summary_only_cmd, - "aggregate-address A.B.C.D A.B.C.D summary-only", - "Configure BGP aggregate entries\n" - "Aggregate address\n" - "Aggregate mask\n" - "Filter more specific routes from updates\n") -{ - int ret; - char prefix_str[BUFSIZ]; - - ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); - - if (! ret) - { - vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), - AGGREGATE_SUMMARY_ONLY, 0); -} - -DEFUN (aggregate_address_as_set, - aggregate_address_as_set_cmd, - "aggregate-address A.B.C.D/M as-set", + "aggregate-address A.B.C.D/M [<as-set [summary-only]|summary-only [as-set]>]", "Configure BGP aggregate entries\n" "Aggregate prefix\n" + "Generate AS set path information\n" + "Filter more specific routes from updates\n" + "Filter more specific routes from updates\n" "Generate AS set path information\n") { - return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), - 0, AGGREGATE_AS_SET); + int idx = 0; + argv_find (argv, argc, "A.B.C.D/M", &idx); + char *prefix = argv[idx]->arg; + int as_set = argv_find (argv, argc, "as-set", &idx) ? AGGREGATE_AS_SET : 0; + idx = 0; + int summary_only = argv_find (argv, argc, "summary-only", &idx) ? AGGREGATE_SUMMARY_ONLY : 0; + + return bgp_aggregate_set (vty, prefix, AFI_IP, bgp_node_safi (vty), summary_only, as_set); } -DEFUN (aggregate_address_mask_as_set, - aggregate_address_mask_as_set_cmd, - "aggregate-address A.B.C.D A.B.C.D as-set", +DEFUN (aggregate_address_mask, + aggregate_address_mask_cmd, + "aggregate-address A.B.C.D A.B.C.D [<as-set [summary-only]|summary-only [as-set]>]", "Configure BGP aggregate entries\n" "Aggregate address\n" "Aggregate mask\n" - "Generate AS set path information\n") -{ - int ret; - char prefix_str[BUFSIZ]; - - ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); - - if (! ret) - { - vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), - 0, AGGREGATE_AS_SET); -} - - -DEFUN (aggregate_address_as_set_summary, - aggregate_address_as_set_summary_cmd, - "aggregate-address A.B.C.D/M as-set summary-only", - "Configure BGP aggregate entries\n" - "Aggregate prefix\n" "Generate AS set path information\n" - "Filter more specific routes from updates\n") -{ - return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), - AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); -} - -ALIAS (aggregate_address_as_set_summary, - aggregate_address_summary_as_set_cmd, - "aggregate-address A.B.C.D/M summary-only as-set", - "Configure BGP aggregate entries\n" - "Aggregate prefix\n" + "Filter more specific routes from updates\n" "Filter more specific routes from updates\n" "Generate AS set path information\n") - -DEFUN (aggregate_address_mask_as_set_summary, - aggregate_address_mask_as_set_summary_cmd, - "aggregate-address A.B.C.D A.B.C.D as-set summary-only", - "Configure BGP aggregate entries\n" - "Aggregate address\n" - "Aggregate mask\n" - "Generate AS set path information\n" - "Filter more specific routes from updates\n") { - int ret; - char prefix_str[BUFSIZ]; + int idx = 0; + argv_find (argv, argc, "A.B.C.D", &idx); + char *prefix = argv[idx++]->arg; + argv_find (argv, argc, "A.B.C.D", &idx); + char *mask = argv[idx]->arg; + int as_set = argv_find (argv, argc, "as-set", &idx) ? AGGREGATE_AS_SET : 0; + idx = 0; + int summary_only = argv_find (argv, argc, "summary-only", &idx) ? AGGREGATE_SUMMARY_ONLY : 0; - ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); + char prefix_str[BUFSIZ]; + int ret = netmask_str2prefix_str (prefix, mask, prefix_str); if (! ret) { @@ -5572,75 +5433,46 @@ DEFUN (aggregate_address_mask_as_set_summary, return CMD_WARNING; } - return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), - AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); + return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), summary_only, as_set); } -ALIAS (aggregate_address_mask_as_set_summary, - aggregate_address_mask_summary_as_set_cmd, - "aggregate-address A.B.C.D A.B.C.D summary-only as-set", - "Configure BGP aggregate entries\n" - "Aggregate address\n" - "Aggregate mask\n" - "Filter more specific routes from updates\n" - "Generate AS set path information\n") - DEFUN (no_aggregate_address, no_aggregate_address_cmd, - "no aggregate-address A.B.C.D/M", - NO_STR - "Configure BGP aggregate entries\n" - "Aggregate prefix\n") -{ - return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); -} - -ALIAS (no_aggregate_address, - no_aggregate_address_summary_only_cmd, - "no aggregate-address A.B.C.D/M summary-only", - NO_STR - "Configure BGP aggregate entries\n" - "Aggregate prefix\n" - "Filter more specific routes from updates\n") - -ALIAS (no_aggregate_address, - no_aggregate_address_as_set_cmd, - "no aggregate-address A.B.C.D/M as-set", - NO_STR - "Configure BGP aggregate entries\n" - "Aggregate prefix\n" - "Generate AS set path information\n") - -ALIAS (no_aggregate_address, - no_aggregate_address_as_set_summary_cmd, - "no aggregate-address A.B.C.D/M as-set summary-only", + "no aggregate-address A.B.C.D/M [<as-set [summary-only]|summary-only [as-set]>]", NO_STR "Configure BGP aggregate entries\n" "Aggregate prefix\n" "Generate AS set path information\n" - "Filter more specific routes from updates\n") - -ALIAS (no_aggregate_address, - no_aggregate_address_summary_as_set_cmd, - "no aggregate-address A.B.C.D/M summary-only as-set", - NO_STR - "Configure BGP aggregate entries\n" - "Aggregate prefix\n" + "Filter more specific routes from updates\n" "Filter more specific routes from updates\n" "Generate AS set path information\n") +{ + int idx = 0; + argv_find (argv, argc, "A.B.C.D/M", &idx); + char *prefix = argv[idx]->arg; + return bgp_aggregate_unset (vty, prefix, AFI_IP, bgp_node_safi (vty)); +} DEFUN (no_aggregate_address_mask, no_aggregate_address_mask_cmd, - "no aggregate-address A.B.C.D A.B.C.D", + "no aggregate-address A.B.C.D A.B.C.D [<as-set [summary-only]|summary-only [as-set]>]", NO_STR "Configure BGP aggregate entries\n" "Aggregate address\n" - "Aggregate mask\n") + "Aggregate mask\n" + "Generate AS set path information\n" + "Filter more specific routes from updates\n" + "Filter more specific routes from updates\n" + "Generate AS set path information\n") { - int ret; - char prefix_str[BUFSIZ]; + int idx = 0; + argv_find (argv, argc, "A.B.C.D", &idx); + char *prefix = argv[idx++]->arg; + argv_find (argv, argc, "A.B.C.D", &idx); + char *mask = argv[idx]->arg; - ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); + char prefix_str[BUFSIZ]; + int ret = netmask_str2prefix_str (prefix, mask, prefix_str); if (! ret) { @@ -5651,123 +5483,34 @@ DEFUN (no_aggregate_address_mask, return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); } -ALIAS (no_aggregate_address_mask, - no_aggregate_address_mask_summary_only_cmd, - "no aggregate-address A.B.C.D A.B.C.D summary-only", - NO_STR - "Configure BGP aggregate entries\n" - "Aggregate address\n" - "Aggregate mask\n" - "Filter more specific routes from updates\n") - -ALIAS (no_aggregate_address_mask, - no_aggregate_address_mask_as_set_cmd, - "no aggregate-address A.B.C.D A.B.C.D as-set", - NO_STR - "Configure BGP aggregate entries\n" - "Aggregate address\n" - "Aggregate mask\n" - "Generate AS set path information\n") - -ALIAS (no_aggregate_address_mask, - no_aggregate_address_mask_as_set_summary_cmd, - "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", - NO_STR - "Configure BGP aggregate entries\n" - "Aggregate address\n" - "Aggregate mask\n" - "Generate AS set path information\n" - "Filter more specific routes from updates\n") - -ALIAS (no_aggregate_address_mask, - no_aggregate_address_mask_summary_as_set_cmd, - "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", - NO_STR - "Configure BGP aggregate entries\n" - "Aggregate address\n" - "Aggregate mask\n" - "Filter more specific routes from updates\n" - "Generate AS set path information\n") - -#ifdef HAVE_IPV6 DEFUN (ipv6_aggregate_address, ipv6_aggregate_address_cmd, - "aggregate-address X:X::X:X/M", - "Configure BGP aggregate entries\n" - "Aggregate prefix\n") -{ - return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); -} - -DEFUN (ipv6_aggregate_address_summary_only, - ipv6_aggregate_address_summary_only_cmd, - "aggregate-address X:X::X:X/M summary-only", + "aggregate-address X:X::X:X/M [summary-only]", "Configure BGP aggregate entries\n" "Aggregate prefix\n" "Filter more specific routes from updates\n") { - return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, - AGGREGATE_SUMMARY_ONLY, 0); + int idx = 0; + argv_find (argv, argc, "X:X::X:X/M", &idx); + char *prefix = argv[idx]->arg; + int sum_only = argv_find (argv, argc, "summary-only", &idx) ? AGGREGATE_SUMMARY_ONLY : 0; + return bgp_aggregate_set (vty, prefix, AFI_IP6, SAFI_UNICAST, sum_only, 0); } DEFUN (no_ipv6_aggregate_address, no_ipv6_aggregate_address_cmd, - "no aggregate-address X:X::X:X/M", - NO_STR - "Configure BGP aggregate entries\n" - "Aggregate prefix\n") -{ - return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); -} - -DEFUN (no_ipv6_aggregate_address_summary_only, - no_ipv6_aggregate_address_summary_only_cmd, - "no aggregate-address X:X::X:X/M summary-only", + "no aggregate-address X:X::X:X/M [summary-only]", NO_STR "Configure BGP aggregate entries\n" "Aggregate prefix\n" "Filter more specific routes from updates\n") { - return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); + int idx = 0; + argv_find (argv, argc, "X:X::X:X/M", &idx); + char *prefix = argv[idx]->arg; + return bgp_aggregate_unset (vty, prefix, AFI_IP6, SAFI_UNICAST); } -ALIAS (ipv6_aggregate_address, - old_ipv6_aggregate_address_cmd, - "ipv6 bgp aggregate-address X:X::X:X/M", - IPV6_STR - BGP_STR - "Configure BGP aggregate entries\n" - "Aggregate prefix\n") - -ALIAS (ipv6_aggregate_address_summary_only, - old_ipv6_aggregate_address_summary_only_cmd, - "ipv6 bgp aggregate-address X:X::X:X/M summary-only", - IPV6_STR - BGP_STR - "Configure BGP aggregate entries\n" - "Aggregate prefix\n" - "Filter more specific routes from updates\n") - -ALIAS (no_ipv6_aggregate_address, - old_no_ipv6_aggregate_address_cmd, - "no ipv6 bgp aggregate-address X:X::X:X/M", - NO_STR - IPV6_STR - BGP_STR - "Configure BGP aggregate entries\n" - "Aggregate prefix\n") - -ALIAS (no_ipv6_aggregate_address_summary_only, - old_no_ipv6_aggregate_address_summary_only_cmd, - "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", - NO_STR - IPV6_STR - BGP_STR - "Configure BGP aggregate entries\n" - "Aggregate prefix\n" - "Filter more specific routes from updates\n") -#endif /* HAVE_IPV6 */ - /* Redistribute route treatment. */ void bgp_redistribute_add (struct bgp *bgp, struct prefix *p, const struct in_addr *nexthop, @@ -6255,7 +5998,7 @@ route_vty_out (struct vty *vty, struct prefix *p, if (json_paths) json_object_int_add(json_path, "med", attr->med); else - vty_out (vty, "%10u ", attr->med); + vty_out (vty, "%10u", attr->med); else if (!json_paths) vty_out (vty, " "); @@ -6265,7 +6008,7 @@ route_vty_out (struct vty *vty, struct prefix *p, if (json_paths) json_object_int_add(json_path, "localpref", attr->local_pref); else - vty_out (vty, "%7u ", attr->local_pref); + vty_out (vty, "%7u", attr->local_pref); else if (!json_paths) vty_out (vty, " "); @@ -6327,7 +6070,7 @@ route_vty_out (struct vty *vty, struct prefix *p, } else { - vty_out (vty, "%s", VTY_NEWLINE); + vty_out (vty, "%s", VTY_NEWLINE); #if ENABLE_BGP_VNC /* prints an additional line, indented, with VNC info, if present */ if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP) || (safi == SAFI_UNICAST)) @@ -6438,12 +6181,12 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, struct attr *attr, safi_t } #endif /* HAVE_IPV6 */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) - vty_out (vty, "%10u ", attr->med); + vty_out (vty, "%10u", attr->med); else vty_out (vty, " "); if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) - vty_out (vty, "%7u ", attr->local_pref); + vty_out (vty, "%7u", attr->local_pref); else vty_out (vty, " "); @@ -7492,14 +7235,6 @@ enum bgp_show_type bgp_show_type_community_list, bgp_show_type_community_list_exact, bgp_show_type_flap_statistics, - bgp_show_type_flap_address, - bgp_show_type_flap_prefix, - bgp_show_type_flap_cidr_only, - bgp_show_type_flap_regexp, - bgp_show_type_flap_filter_list, - bgp_show_type_flap_prefix_list, - bgp_show_type_flap_prefix_longer, - bgp_show_type_flap_route_map, bgp_show_type_flap_neighbor, bgp_show_type_dampend_paths, bgp_show_type_damp_neighbor @@ -7525,6 +7260,12 @@ static int bgp_show_prefix_longer (struct vty *vty, const char *name, const char *prefix, afi_t afi, safi_t safi, enum bgp_show_type type); +static int +bgp_show_regexp (struct vty *vty, const char *regstr, afi_t afi, + safi_t safi, enum bgp_show_type type); +static int +bgp_show_community (struct vty *vty, const char *view_name, int argc, + struct cmd_token **argv, int exact, afi_t afi, safi_t safi); static int bgp_show_table (struct vty *vty, struct bgp *bgp, struct bgp_table *table, @@ -7573,14 +7314,6 @@ bgp_show_table (struct vty *vty, struct bgp *bgp, struct bgp_table *table, { total_count++; if (type == bgp_show_type_flap_statistics - || type == bgp_show_type_flap_address - || type == bgp_show_type_flap_prefix - || type == bgp_show_type_flap_cidr_only - || type == bgp_show_type_flap_regexp - || type == bgp_show_type_flap_filter_list - || type == bgp_show_type_flap_prefix_list - || type == bgp_show_type_flap_prefix_longer - || type == bgp_show_type_flap_route_map || type == bgp_show_type_flap_neighbor || type == bgp_show_type_dampend_paths || type == bgp_show_type_damp_neighbor) @@ -7588,32 +7321,28 @@ bgp_show_table (struct vty *vty, struct bgp *bgp, struct bgp_table *table, if (!(ri->extra && ri->extra->damp_info)) continue; } - if (type == bgp_show_type_regexp - || type == bgp_show_type_flap_regexp) + if (type == bgp_show_type_regexp) { regex_t *regex = output_arg; if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) continue; } - if (type == bgp_show_type_prefix_list - || type == bgp_show_type_flap_prefix_list) + if (type == bgp_show_type_prefix_list) { struct prefix_list *plist = output_arg; if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) continue; } - if (type == bgp_show_type_filter_list - || type == bgp_show_type_flap_filter_list) + if (type == bgp_show_type_filter_list) { struct as_list *as_list = output_arg; if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) continue; } - if (type == bgp_show_type_route_map - || type == bgp_show_type_flap_route_map) + if (type == bgp_show_type_route_map) { struct route_map *rmap = output_arg; struct bgp_info binfo; @@ -7640,8 +7369,7 @@ bgp_show_table (struct vty *vty, struct bgp *bgp, struct bgp_table *table, if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) continue; } - if (type == bgp_show_type_cidr_only - || type == bgp_show_type_flap_cidr_only) + if (type == bgp_show_type_cidr_only) { u_int32_t destination; @@ -7653,8 +7381,7 @@ bgp_show_table (struct vty *vty, struct bgp *bgp, struct bgp_table *table, if (IN_CLASSA (destination) && rn->p.prefixlen == 8) continue; } - if (type == bgp_show_type_prefix_longer - || type == bgp_show_type_flap_prefix_longer) + if (type == bgp_show_type_prefix_longer) { struct prefix *p = output_arg; @@ -7696,18 +7423,6 @@ bgp_show_table (struct vty *vty, struct bgp *bgp, struct bgp_table *table, if (! community_list_exact_match (ri->attr->community, list)) continue; } - if (type == bgp_show_type_flap_address - || type == bgp_show_type_flap_prefix) - { - struct prefix *p = output_arg; - - if (! prefix_match (&rn->p, p)) - continue; - - if (type == bgp_show_type_flap_prefix) - if (p->prefixlen != rn->p.prefixlen) - continue; - } if (type == bgp_show_type_dampend_paths || type == bgp_show_type_damp_neighbor) { @@ -7725,14 +7440,6 @@ bgp_show_table (struct vty *vty, struct bgp *bgp, struct bgp_table *table, || type == bgp_show_type_damp_neighbor) vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); else if (type == bgp_show_type_flap_statistics - || type == bgp_show_type_flap_address - || type == bgp_show_type_flap_prefix - || type == bgp_show_type_flap_cidr_only - || type == bgp_show_type_flap_regexp - || type == bgp_show_type_flap_filter_list - || type == bgp_show_type_flap_prefix_list - || type == bgp_show_type_flap_prefix_longer - || type == bgp_show_type_flap_route_map || type == bgp_show_type_flap_neighbor) vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); else @@ -7744,14 +7451,6 @@ bgp_show_table (struct vty *vty, struct bgp *bgp, struct bgp_table *table, || type == bgp_show_type_damp_neighbor) damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST, use_json, json_paths); else if (type == bgp_show_type_flap_statistics - || type == bgp_show_type_flap_address - || type == bgp_show_type_flap_prefix - || type == bgp_show_type_flap_cidr_only - || type == bgp_show_type_flap_regexp - || type == bgp_show_type_flap_filter_list - || type == bgp_show_type_flap_prefix_list - || type == bgp_show_type_flap_prefix_longer - || type == bgp_show_type_flap_route_map || type == bgp_show_type_flap_neighbor) flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST, use_json, json_paths); else @@ -8141,1126 +7840,353 @@ bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str, } /* BGP route print out function. */ -DEFUN (show_ip_bgp, - show_ip_bgp_cmd, - "show ip bgp {json}", - SHOW_STR - IP_STR - BGP_STR - "JavaScript Object Notation\n") -{ - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL, use_json(argc, argv)); -} - DEFUN (show_ip_bgp_ipv4, show_ip_bgp_ipv4_cmd, - "show ip bgp ipv4 (unicast|multicast) {json}", + "show [ip] bgp [<view|vrf> WORD] [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>]\ + [<\ + cidr-only\ + |dampening <flap-statistics|dampened-paths|parameters>\ + |route-map WORD\ + |prefix-list WORD\ + |filter-list WORD\ + |community [<AA:NN|local-AS|no-advertise|no-export> [exact-match]]\ + |community-list <(1-500)|WORD> [exact-match]\ + |A.B.C.D/M longer-prefixes\ + |X:X::X:X/M longer-prefixes\ + >]\ + [json]", SHOW_STR IP_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, - NULL, uj); - - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL, uj); -} - -ALIAS (show_ip_bgp_ipv4, - show_bgp_ipv4_safi_cmd, - "show bgp ipv4 (unicast|multicast) {json}", - SHOW_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "JavaScript Object Notation\n") - -DEFUN (show_ip_bgp_route, - show_ip_bgp_route_cmd, - "show ip bgp A.B.C.D {json}", - SHOW_STR - IP_STR - BGP_STR - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") -{ - return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); -} - -DEFUN (show_ip_bgp_route_pathtype, - show_ip_bgp_route_pathtype_cmd, - "show ip bgp A.B.C.D (bestpath|multipath) {json}", - SHOW_STR - IP_STR - BGP_STR - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - - if (strncmp (argv[1], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); -} - -DEFUN (show_bgp_ipv4_safi_route_pathtype, - show_bgp_ipv4_safi_route_pathtype_cmd, - "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath) {json}", - SHOW_STR - BGP_STR - "Address family\n" + BGP_INSTANCE_HELP_STR + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - - if (strncmp (argv[0], "m", 1) == 0) - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); - else - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); -} - -DEFUN (show_bgp_ipv4_prefix, - show_bgp_ipv4_prefix_cmd, - "show bgp ipv4 A.B.C.D/M {json}", - SHOW_STR - BGP_STR - IP_STR - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - JSON_STR) -{ - return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json (argc, argv)); -} - -DEFUN (show_bgp_ipv6_route, - show_bgp_ipv6_route_cmd, - "show bgp ipv6 X:X::X:X {json}", - SHOW_STR - BGP_STR - "Address family\n" - "Network in the BGP routing table to display\n" - JSON_STR) -{ - return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json (argc, argv)); -} - -DEFUN (show_bgp_ipv6_prefix, - show_bgp_ipv6_prefix_cmd, - "show bgp ipv6 X:X::X:X/M {json}", - SHOW_STR - BGP_STR - IP_STR - "IPv6 prefix <network>/<length>\n" - JSON_STR) -{ - return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json (argc,argv)); -} - -DEFUN (show_ip_bgp_ipv4_route, - show_ip_bgp_ipv4_route_cmd, - "show ip bgp ipv4 (unicast|multicast) A.B.C.D {json}", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj); - - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj); -} - -ALIAS (show_ip_bgp_ipv4_route, - show_bgp_ipv4_safi_route_cmd, - "show bgp ipv4 (unicast|multicast) A.B.C.D {json}", - SHOW_STR - BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" + "Address Family\n" "Address Family modifier\n" - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") - -DEFUN (show_ip_bgp_vpnv4_all_route, - show_ip_bgp_vpnv4_all_route_cmd, - "show ip bgp vpnv4 all A.B.C.D {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information about all VPNv4 NLRIs\n" - "Network in the BGP routing table to display\n" + "Display only routes with non-natural netmasks\n" + "Display detailed information about dampening\n" + "Display flap statistics of routes\n" + "Display paths suppressed due to dampening\n" + "Display dampening parameters\n" + "Display routes matching the route-map\n" + "A route-map to match on\n" + "Display routes conforming to the prefix-list\n" + "Prefix-list name\n" + "Display routes conforming to the filter-list\n" + "Regular expression access list name\n" + "Display routes matching the communities\n" + COMMUNITY_AANN_STR + "Do not send outside local AS (well-known community)\n" + "Do not advertise to any peer (well-known community)\n" + "Do not export to next AS (well-known community)\n" + "Exact match of the communities\n" + "Display routes matching the community-list\n" + "community-list number\n" + "community-list name\n" + "Exact match of the communities\n" + "IPv4 prefix\n" + "Display route and more specific routes\n" + "IPv6 prefix\n" + "Display route and more specific routes\n" "JavaScript Object Notation\n") { - return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); -} + char *vrf = NULL; + afi_t afi = AFI_IP6; + safi_t safi = SAFI_UNICAST; + int exact_match; + enum bgp_show_type sh_type = bgp_show_type_normal; + + int idx = 0; + + if (argv_find (argv, argc, "ip", &idx)) + afi = AFI_IP; + if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) + vrf = argv[++idx]->arg; + if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) + { + afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; + if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) + safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST; + } + else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) + { + afi = AFI_IP; + safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN; + // advance idx if necessary + argv_find (argv, argc, "unicast", &idx); + } -DEFUN (show_bgp_ipv4_vpn_route, - show_bgp_ipv4_vpn_route_cmd, - "show bgp ipv4 vpn A.B.C.D {json}", - SHOW_STR - BGP_STR - "Address Family\n" - "Display VPN NLRI specific information\n" - "Network in the BGP routing table to display\n" - JSON_STR) -{ - return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json (argc, argv)); -} + int uj = use_json (argc, argv); + if (uj) argc--; -DEFUN (show_bgp_ipv6_vpn_route, - show_bgp_ipv6_vpn_route_cmd, - "show bgp ipv6 vpn X:X::X:X {json}", - SHOW_STR - BGP_STR - "Address Family\n" - "Display VPN NLRI specific information\n" - "Network in the BGP routing table to display\n" - JSON_STR) -{ - return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json (argc, argv)); -} + struct bgp *bgp = bgp_lookup_by_name (vrf); + if (bgp == NULL) + { + vty_out (vty, "Can't find BGP instance %s%s", vrf, VTY_NEWLINE); + return CMD_WARNING; + } -DEFUN (show_bgp_ipv4_vpn_rd_route, - show_bgp_ipv4_vpn_rd_route_cmd, - "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D {json}", - SHOW_STR - BGP_STR - IP_STR - "Display VPN NLRI specific information\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "Network in the BGP routing table to display\n" - JSON_STR) -{ - int ret; - struct prefix_rd prd; + if (++idx < argc) + { + if (strmatch(argv[idx]->text, "cidr-only")) + return bgp_show (vty, bgp, afi, safi, bgp_show_type_cidr_only, NULL, uj); - ret = str2prefix_rd (argv[0], &prd); - if (! ret) + else if (strmatch(argv[idx]->text, "dampening")) { - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); - return CMD_WARNING; + if (argv_find (argv, argc, "dampened-paths", &idx)) + return bgp_show (vty, bgp, afi, safi, bgp_show_type_dampend_paths, NULL, uj); + else if (argv_find (argv, argc, "flap-statistics", &idx)) + return bgp_show (vty, bgp, afi, safi, bgp_show_type_flap_statistics, NULL, uj); + else if (argv_find (argv, argc, "parameters", &idx)) + return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); } - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json (argc, argv)); -} -DEFUN (show_bgp_ipv6_vpn_rd_route, - show_bgp_ipv6_vpn_rd_route_cmd, - "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X {json}", - SHOW_STR - BGP_STR - "Address Family\n" - "Display VPN NLRI specific information\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "Network in the BGP routing table to display\n" - JSON_STR) -{ - int ret; - struct prefix_rd prd; + else if (strmatch(argv[idx]->text, "prefix-list")) + return bgp_show_prefix_list (vty, vrf, argv[idx + 1]->arg, afi, safi, bgp_show_type_prefix_list); - ret = str2prefix_rd (argv[0], &prd); - if (! ret) - { - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); - return CMD_WARNING; - } - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json (argc, argv)); -} + else if (strmatch(argv[idx]->text, "filter-list")) + return bgp_show_filter_list (vty, vrf, argv[idx + 1]->arg, afi, safi, bgp_show_type_filter_list); -DEFUN (show_ip_bgp_vpnv4_rd_route, - show_ip_bgp_vpnv4_rd_route_cmd, - "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") -{ - int ret; - struct prefix_rd prd; - u_char uj= use_json(argc, argv); + else if (strmatch(argv[idx]->text, "route-map")) + return bgp_show_route_map (vty, vrf, argv[idx + 1]->arg, afi, safi, bgp_show_type_route_map); - ret = str2prefix_rd (argv[0], &prd); - if (! ret) + else if (strmatch(argv[idx]->text, "community")) { - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); - return CMD_WARNING; + /* show a specific community */ + if (argv[idx + 1]->type == VARIABLE_TKN || + strmatch(argv[idx + 1]->text, "local-AS") || + strmatch(argv[idx + 1]->text, "no-advertise") || + strmatch(argv[idx + 1]->text, "no-export")) + { + if (strmatch(argv[idx + 2]->text, "exact_match")) + exact_match = 1; + return bgp_show_community (vty, vrf, argc, argv, exact_match, afi, safi); + } + /* show all communities */ + else + return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL, uj); } - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, uj); -} - -DEFUN (show_ip_bgp_prefix, - show_ip_bgp_prefix_cmd, - "show ip bgp A.B.C.D/M {json}", - SHOW_STR - IP_STR - BGP_STR - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "JavaScript Object Notation\n") -{ - return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); -} + else if (strmatch(argv[idx]->text, "community-list")) + { + const char *clist_number_or_name = argv[++idx]->arg; + if (++idx < argc && strmatch (argv[idx]->arg, "exact-match")) + exact_match = 1; + return bgp_show_community_list (vty, vrf, clist_number_or_name, exact_match, afi, safi); + } + /* prefix-longer */ + else if (argv[idx]->type == IPV4_TKN || argv[idx]->type == IPV6_TKN) + return bgp_show_prefix_longer (vty, vrf, argv[idx + 1]->arg, afi, safi, bgp_show_type_prefix_longer); + } -DEFUN (show_ip_bgp_prefix_pathtype, - show_ip_bgp_prefix_pathtype_cmd, - "show ip bgp A.B.C.D/M (bestpath|multipath) {json}", - SHOW_STR - IP_STR - BGP_STR - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - if (strncmp (argv[1], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); + return bgp_show (vty, bgp, afi, safi, sh_type, NULL, uj); } -DEFUN (show_ip_bgp_ipv4_prefix, - show_ip_bgp_ipv4_prefix_cmd, - "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M {json}", +DEFUN (show_ip_bgp_route, + show_ip_bgp_route_cmd, + "show [ip] bgp [<view|vrf> WORD] [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>]" + "<A.B.C.D|A.B.C.D/M|X:X::X:X|X:X::X:X/M> [<bestpath|multipath>] [json]", SHOW_STR IP_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj); - - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj); -} - -ALIAS (show_ip_bgp_ipv4_prefix, - show_bgp_ipv4_safi_prefix_cmd, - "show bgp ipv4 (unicast|multicast) A.B.C.D/M {json}", - SHOW_STR - BGP_STR - "Address family\n" + BGP_INSTANCE_HELP_STR + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "JavaScript Object Notation\n") - -DEFUN (show_ip_bgp_ipv4_prefix_pathtype, - show_ip_bgp_ipv4_prefix_pathtype_cmd, - "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - - if (strncmp (argv[0], "m", 1) == 0) - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); - else - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); -} - -ALIAS (show_ip_bgp_ipv4_prefix_pathtype, - show_bgp_ipv4_safi_prefix_pathtype_cmd, - "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}", - SHOW_STR - BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" + "Address Family\n" "Address Family modifier\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" + "Network in the BGP routing table to display\n" + "IPv4 prefix\n" + "Network in the BGP routing table to display\n" + "IPv6 prefix\n" "Display only the bestpath\n" "Display only multipaths\n" "JavaScript Object Notation\n") - -DEFUN (show_ip_bgp_vpnv4_all_prefix, - show_ip_bgp_vpnv4_all_prefix_cmd, - "show ip bgp vpnv4 all A.B.C.D/M {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information about all VPNv4 NLRIs\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "JavaScript Object Notation\n") { - return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); -} + int prefix_check = 0; -DEFUN (show_ip_bgp_vpnv4_rd_prefix, - show_ip_bgp_vpnv4_rd_prefix_cmd, - "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "JavaScript Object Notation\n") -{ - int ret; - struct prefix_rd prd; + afi_t afi = AFI_IP6; + safi_t safi = SAFI_UNICAST; + char *vrf = NULL; + char *prefix = NULL; - ret = str2prefix_rd (argv[0], &prd); - if (! ret) - { - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); - return CMD_WARNING; - } - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json(argc, argv)); -} - -DEFUN (show_ip_bgp_view, - show_ip_bgp_instance_cmd, - "show ip bgp " BGP_INSTANCE_CMD " {json}", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "JavaScript Object Notation\n") -{ - struct bgp *bgp; - - /* BGP structure lookup. */ - bgp = bgp_lookup_by_name (argv[1]); - if (bgp == NULL) - { - vty_out (vty, "Can't find BGP instance %s%s", argv[1], VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL, use_json(argc, argv)); -} - -DEFUN (show_ip_bgp_instance_all, - show_ip_bgp_instance_all_cmd, - "show ip bgp " BGP_INSTANCE_ALL_CMD " {json}", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_ALL_HELP_STR - "JavaScript Object Notation\n") -{ + enum bgp_path_type path_type; u_char uj = use_json(argc, argv); - bgp_show_all_instances_routes_vty (vty, AFI_IP, SAFI_UNICAST, uj); - return CMD_SUCCESS; -} + int idx = 0; + + /* show [ip] bgp */ + if (argv_find (argv, argc, "ip", &idx)) + afi = AFI_IP; + /* [<view|vrf> WORD] */ + if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) + vrf = argv[++idx]->arg; + /* [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] */ + if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) + { + afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; + if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) + safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST; + } + else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) + { + afi = AFI_IP; + safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN; + // advance idx if necessary + argv_find (argv, argc, "unicast", &idx); + } -DEFUN (show_ip_bgp_instance_route, - show_ip_bgp_instance_route_cmd, - "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D {json}", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") -{ - return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); -} + /* <A.B.C.D|A.B.C.D/M|X:X::X:X|X:X::X:X/M> */ + if (argv_find (argv, argc, "A.B.C.D", &idx) || argv_find (argv, argc, "X:X::X:X", &idx)) + prefix_check = 0; + else if (argv_find (argv, argc, "A.B.C.D/M", &idx) || argv_find (argv, argc, "X:X::X:X/M", &idx)) + prefix_check = 1; -DEFUN (show_ip_bgp_instance_route_pathtype, - show_ip_bgp_instance_route_pathtype_cmd, - "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D (bestpath|multipath) {json}", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Network in the BGP routing table to display\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - - if (strncmp (argv[3], "b", 1) == 0) - return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); -} + if ((argv[idx]->type == IPV6_TKN || argv[idx]->type == IPV6_PREFIX_TKN) && afi != AFI_IP6) + { + vty_out (vty, "%% Cannot specify IPv6 address or prefix with IPv4 AFI%s", VTY_NEWLINE); + return CMD_WARNING; + } + if ((argv[idx]->type == IPV4_TKN || argv[idx]->type == IPV4_PREFIX_TKN) && afi != AFI_IP) + { + vty_out (vty, "%% Cannot specify IPv4 address or prefix with IPv6 AFI%s", VTY_NEWLINE); + return CMD_WARNING; + } -DEFUN (show_ip_bgp_instance_prefix, - show_ip_bgp_instance_prefix_cmd, - "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D/M {json}", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "JavaScript Object Notation\n") -{ - return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); -} + prefix = argv[idx]->arg; -DEFUN (show_ip_bgp_instance_prefix_pathtype, - show_ip_bgp_instance_prefix_pathtype_cmd, - "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D/M (bestpath|multipath) {json}", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - if (strncmp (argv[3], "b", 1) == 0) - return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); + /* [<bestpath|multipath>] */ + if (argv_find (argv, argc, "bestpath", &idx)) + path_type = BGP_PATH_BESTPATH; + else if (argv_find (argv, argc, "multipath", &idx)) + path_type = BGP_PATH_MULTIPATH; else - return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); -} + path_type = BGP_PATH_ALL; -#ifdef HAVE_IPV6 -DEFUN (show_bgp, - show_bgp_cmd, - "show bgp {json}", - SHOW_STR - BGP_STR - "JavaScript Object Notation\n") -{ - return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, - NULL, use_json(argc, argv)); + return bgp_show_route (vty, vrf, prefix, afi, safi, NULL, prefix_check, path_type, uj); } -ALIAS (show_bgp, - show_bgp_ipv6_cmd, - "show bgp ipv6 {json}", - SHOW_STR - BGP_STR - "Address family\n" - "JavaScript Object Notation\n") - -DEFUN (show_bgp_ipv6_safi, - show_bgp_ipv6_safi_cmd, - "show bgp ipv6 (unicast|multicast) {json}", +DEFUN (show_ip_bgp_regexp, + show_ip_bgp_regexp_cmd, + "show [ip] bgp [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] regexp REGEX...", SHOW_STR + IP_STR BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, - NULL, uj); - - return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL, uj); -} - -static void -bgp_show_ipv6_bgp_deprecate_warning (struct vty *vty) -{ - vty_out (vty, "WARNING: The 'show ipv6 bgp' parse tree will be deprecated in our" - " next release%sPlese use 'show bgp ipv6' instead%s%s", - VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); -} - -/* old command */ -DEFUN (show_ipv6_bgp, - show_ipv6_bgp_cmd, - "show ipv6 bgp {json}", - SHOW_STR - IP_STR - BGP_STR - "JavaScript Object Notation\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, - NULL, use_json(argc, argv)); -} - -DEFUN (show_bgp_route, - show_bgp_route_cmd, - "show bgp X:X::X:X {json}", - SHOW_STR - BGP_STR - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") -{ - return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); -} - -DEFUN (show_bgp_ipv6_safi_route, - show_bgp_ipv6_safi_route_cmd, - "show bgp ipv6 (unicast|multicast) X:X::X:X {json}", - SHOW_STR - BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") + "Address Family\n" + "Address Family modifier\n" + "Address Family\n" + "Address Family modifier\n" + "Display routes matching the AS path regular expression\n" + "A regular-expression to match the BGP AS paths\n") { - u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj); + afi_t afi = AFI_IP6; + safi_t safi = SAFI_UNICAST; - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj); -} + int idx = 0; -DEFUN (show_bgp_route_pathtype, - show_bgp_route_pathtype_cmd, - "show bgp X:X::X:X (bestpath|multipath) {json}", - SHOW_STR - BGP_STR - "Network in the BGP routing table to display\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - if (strncmp (argv[1], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); -} + /* [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] */ + if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) + { + afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; + if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) + safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST; + } + else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) + { + afi = AFI_IP; + safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN; + // advance idx if necessary + argv_find (argv, argc, "unicast", &idx); + } -ALIAS (show_bgp_route_pathtype, - show_bgp_ipv6_route_pathtype_cmd, - "show bgp ipv6 X:X::X:X (bestpath|multipath) {json}", - SHOW_STR - BGP_STR - "Address family\n" - "Network in the BGP routing table to display\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") + // get index of regex + argv_find (argv, argc, "regexp", &idx); + idx++; -DEFUN (show_bgp_ipv6_safi_route_pathtype, - show_bgp_ipv6_safi_route_pathtype_cmd, - "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath) {json}", - SHOW_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Network in the BGP routing table to display\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); - else - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); + char *regstr = argv_concat (argv, argc, idx); + int rc = bgp_show_regexp (vty, (const char *) regstr, afi, safi, bgp_show_type_regexp); + XFREE (MTYPE_TMP, regstr); + return rc; } -/* old command */ -DEFUN (show_ipv6_bgp_route, - show_ipv6_bgp_route_cmd, - "show ipv6 bgp X:X::X:X {json}", +DEFUN (show_ip_bgp_instance_all, + show_ip_bgp_instance_all_cmd, + "show [ip] bgp <view|vrf> all [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] [json]", SHOW_STR IP_STR BGP_STR - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); -} - -DEFUN (show_bgp_prefix, - show_bgp_prefix_cmd, - "show bgp X:X::X:X/M {json}", - SHOW_STR - BGP_STR - "IPv6 prefix <network>/<length>\n" - "JavaScript Object Notation\n") -{ - return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); -} - -DEFUN (show_bgp_ipv6_safi_prefix, - show_bgp_ipv6_safi_prefix_cmd, - "show bgp ipv6 (unicast|multicast) X:X::X:X/M {json}", - SHOW_STR - BGP_STR - "Address family\n" + BGP_INSTANCE_ALL_HELP_STR + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" - "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj); - - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj); -} - -DEFUN (show_bgp_prefix_pathtype, - show_bgp_prefix_pathtype_cmd, - "show bgp X:X::X:X/M (bestpath|multipath) {json}", - SHOW_STR - BGP_STR - "IPv6 prefix <network>/<length>\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - if (strncmp (argv[1], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); -} - -ALIAS (show_bgp_prefix_pathtype, - show_bgp_ipv6_prefix_pathtype_cmd, - "show bgp ipv6 X:X::X:X/M (bestpath|multipath) {json}", - SHOW_STR - BGP_STR - "Address family\n" - "IPv6 prefix <network>/<length>\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") - -DEFUN (show_bgp_ipv6_safi_prefix_pathtype, - show_bgp_ipv6_safi_prefix_pathtype_cmd, - "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath) {json}", - SHOW_STR - BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" - "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); - else - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); -} - -/* old command */ -DEFUN (show_ipv6_bgp_prefix, - show_ipv6_bgp_prefix_cmd, - "show ipv6 bgp X:X::X:X/M {json}", - SHOW_STR - IP_STR - BGP_STR - "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" + "Address Family\n" + "Address Family modifier\n" + "Address Family\n" + "Address Family modifier\n" "JavaScript Object Notation\n") { - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); -} + afi_t afi = AFI_IP; + safi_t safi = SAFI_UNICAST; -DEFUN (show_bgp_view, - show_bgp_instance_cmd, - "show bgp " BGP_INSTANCE_CMD " {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "JavaScript Object Notation\n") -{ - struct bgp *bgp; + int idx = 0; - /* BGP structure lookup. */ - bgp = bgp_lookup_by_name (argv[1]); - if (bgp == NULL) - { - vty_out (vty, "Can't find BGP instance %s%s", argv[1], VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL, use_json(argc, argv)); -} + /* show [ip] bgp */ + if (argv_find (argv, argc, "ip", &idx)) + afi = AFI_IP; + /* [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] */ + if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) + { + afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; + if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) + safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST; + } + else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) + { + afi = AFI_IP; + safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN; + // advance idx if necessary + argv_find (argv, argc, "unicast", &idx); + } -DEFUN (show_bgp_instance_all, - show_bgp_instance_all_cmd, - "show bgp " BGP_INSTANCE_ALL_CMD " {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_ALL_HELP_STR - "JavaScript Object Notation\n") -{ u_char uj = use_json(argc, argv); - bgp_show_all_instances_routes_vty (vty, AFI_IP6, SAFI_UNICAST, uj); + bgp_show_all_instances_routes_vty (vty, afi, safi, uj); return CMD_SUCCESS; } -ALIAS (show_bgp_view, - show_bgp_instance_ipv6_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "JavaScript Object Notation\n") - -DEFUN (show_bgp_instance_route, - show_bgp_instance_route_cmd, - "show bgp " BGP_INSTANCE_CMD " X:X::X:X {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") -{ - return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); -} - -ALIAS (show_bgp_instance_route, - show_bgp_instance_ipv6_route_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") - -DEFUN (show_bgp_instance_route_pathtype, - show_bgp_instance_route_pathtype_cmd, - "show bgp " BGP_INSTANCE_CMD " X:X::X:X (bestpath|multipath) {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Network in the BGP routing table to display\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - if (strncmp (argv[3], "b", 1) == 0) - return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); -} - -ALIAS (show_bgp_instance_route_pathtype, - show_bgp_instance_ipv6_route_pathtype_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X (bestpath|multipath) {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Network in the BGP routing table to display\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") - -DEFUN (show_bgp_instance_prefix, - show_bgp_instance_prefix_cmd, - "show bgp " BGP_INSTANCE_CMD " X:X::X:X/M {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "IPv6 prefix <network>/<length>\n" - "JavaScript Object Notation\n") -{ - return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); -} - -ALIAS (show_bgp_instance_prefix, - show_bgp_instance_ipv6_prefix_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X/M {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "IPv6 prefix <network>/<length>\n" - "JavaScript Object Notation\n") - -DEFUN (show_bgp_instance_prefix_pathtype, - show_bgp_instance_prefix_pathtype_cmd, - "show bgp " BGP_INSTANCE_CMD " X:X::X:X/M (bestpath|multipath) {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "IPv6 prefix <network>/<length>\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - if (strncmp (argv[3], "b", 1) == 0) - return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); -} - -ALIAS (show_bgp_instance_prefix_pathtype, - show_bgp_instance_ipv6_prefix_pathtype_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X/M (bestpath|multipath) {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "IPv6 prefix <network>/<length>\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") - -DEFUN (show_bgp_instance_prefix_list, - show_bgp_instance_prefix_list_cmd, - "show bgp " BGP_INSTANCE_CMD " prefix-list WORD", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Display routes conforming to the prefix-list\n" - "IPv6 prefix-list name\n") -{ - return bgp_show_prefix_list (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, - bgp_show_type_prefix_list); -} - -ALIAS (show_bgp_instance_prefix_list, - show_bgp_instance_ipv6_prefix_list_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 prefix-list WORD", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Display routes conforming to the prefix-list\n" - "IPv6 prefix-list name\n") - -DEFUN (show_bgp_instance_filter_list, - show_bgp_instance_filter_list_cmd, - "show bgp " BGP_INSTANCE_CMD " filter-list WORD", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Display routes conforming to the filter-list\n" - "Regular expression access list name\n") -{ - return bgp_show_filter_list (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, - bgp_show_type_filter_list); -} - -ALIAS (show_bgp_instance_filter_list, - show_bgp_instance_ipv6_filter_list_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 filter-list WORD", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Display routes conforming to the filter-list\n" - "Regular expression access list name\n") - -DEFUN (show_bgp_instance_route_map, - show_bgp_instance_route_map_cmd, - "show bgp " BGP_INSTANCE_CMD " route-map WORD", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Display routes matching the route-map\n" - "A route-map to match on\n") -{ - return bgp_show_route_map (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, - bgp_show_type_route_map); -} - -ALIAS (show_bgp_instance_route_map, - show_bgp_instance_ipv6_route_map_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 route-map WORD", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Display routes matching the route-map\n" - "A route-map to match on\n") - -DEFUN (show_bgp_instance_community_list, - show_bgp_instance_community_list_cmd, - "show bgp " BGP_INSTANCE_CMD " community-list (<1-500>|WORD)", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Display routes matching the community-list\n" - "community-list number\n" - "community-list name\n") -{ - return bgp_show_community_list (vty, argv[1], argv[2], 0, AFI_IP6, SAFI_UNICAST); -} - -ALIAS (show_bgp_instance_community_list, - show_bgp_instance_ipv6_community_list_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 community-list (<1-500>|WORD)", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Display routes matching the community-list\n" - "community-list number\n" - "community-list name\n") - -DEFUN (show_bgp_instance_prefix_longer, - show_bgp_instance_prefix_longer_cmd, - "show bgp " BGP_INSTANCE_CMD " X:X::X:X/M longer-prefixes", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "IPv6 prefix <network>/<length>\n" - "Display route and more specific routes\n") -{ - return bgp_show_prefix_longer (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, - bgp_show_type_prefix_longer); -} - -ALIAS (show_bgp_instance_prefix_longer, - show_bgp_instance_ipv6_prefix_longer_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X/M longer-prefixes", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "IPv6 prefix <network>/<length>\n" - "Display route and more specific routes\n") - -/* old command */ -DEFUN (show_ipv6_mbgp, - show_ipv6_mbgp_cmd, - "show ipv6 mbgp {json}", - SHOW_STR - IP_STR - MBGP_STR - "JavaScript Object Notation\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, - NULL, use_json(argc, argv)); -} - -/* old command */ -DEFUN (show_ipv6_mbgp_route, - show_ipv6_mbgp_route_cmd, - "show ipv6 mbgp X:X::X:X {json}", - SHOW_STR - IP_STR - MBGP_STR - "Network in the MBGP routing table to display\n" - "JavaScript Object Notation\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); -} - -/* old command */ -DEFUN (show_ipv6_mbgp_prefix, - show_ipv6_mbgp_prefix_cmd, - "show ipv6 mbgp X:X::X:X/M {json}", - SHOW_STR - IP_STR - MBGP_STR - "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" - "JavaScript Object Notation\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); -} -#endif - static int -bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi, +bgp_show_regexp (struct vty *vty, const char *regstr, afi_t afi, safi_t safi, enum bgp_show_type type) { - int i; - struct buffer *b; - char *regstr; - int first; + return CMD_SUCCESS; + regex_t *regex; int rc; - first = 0; - b = buffer_new (1024); - for (i = 0; i < argc; i++) - { - if (first) - buffer_putc (b, ' '); - else - { - if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) - continue; - first = 1; - } - - buffer_putstr (b, argv[i]); - } - buffer_putc (b, '\0'); - - regstr = buffer_getstr (b); - buffer_free (b); - regex = bgp_regcomp (regstr); - XFREE(MTYPE_TMP, regstr); if (! regex) { - vty_out (vty, "Can't compile regexp %s%s", argv[0], - VTY_NEWLINE); + vty_out (vty, "Can't compile regexp %s%s", regstr, VTY_NEWLINE); return CMD_WARNING; } @@ -9269,117 +8195,6 @@ bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi, return rc; } -DEFUN (show_ip_bgp_regexp, - show_ip_bgp_regexp_cmd, - "show ip bgp regexp .LINE", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the AS path regular expression\n" - "A regular-expression to match the BGP AS paths\n") -{ - return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, - bgp_show_type_regexp); -} - -DEFUN (show_ip_bgp_flap_regexp, - show_ip_bgp_flap_regexp_cmd, - "show ip bgp flap-statistics regexp .LINE", - SHOW_STR - IP_STR - BGP_STR - "Display flap statistics of routes\n" - "Display routes matching the AS path regular expression\n" - "A regular-expression to match the BGP AS paths\n") -{ - return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, - bgp_show_type_flap_regexp); -} - -ALIAS (show_ip_bgp_flap_regexp, - show_ip_bgp_damp_flap_regexp_cmd, - "show ip bgp dampening flap-statistics regexp .LINE", - SHOW_STR - IP_STR - BGP_STR - "Display detailed information about dampening\n" - "Display flap statistics of routes\n" - "Display routes matching the AS path regular expression\n" - "A regular-expression to match the BGP AS paths\n") - -DEFUN (show_ip_bgp_ipv4_regexp, - show_ip_bgp_ipv4_regexp_cmd, - "show ip bgp ipv4 (unicast|multicast) regexp .LINE", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the AS path regular expression\n" - "A regular-expression to match the BGP AS paths\n") -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, - bgp_show_type_regexp); - - return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, - bgp_show_type_regexp); -} - -#ifdef HAVE_IPV6 -DEFUN (show_bgp_regexp, - show_bgp_regexp_cmd, - "show bgp regexp .LINE", - SHOW_STR - BGP_STR - "Display routes matching the AS path regular expression\n" - "A regular-expression to match the BGP AS paths\n") -{ - return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, - bgp_show_type_regexp); -} - -ALIAS (show_bgp_regexp, - show_bgp_ipv6_regexp_cmd, - "show bgp ipv6 regexp .LINE", - SHOW_STR - BGP_STR - "Address family\n" - "Display routes matching the AS path regular expression\n" - "A regular-expression to match the BGP AS paths\n") - -/* old command */ -DEFUN (show_ipv6_bgp_regexp, - show_ipv6_bgp_regexp_cmd, - "show ipv6 bgp regexp .LINE", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the AS path regular expression\n" - "A regular-expression to match the BGP AS paths\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, - bgp_show_type_regexp); -} - -/* old command */ -DEFUN (show_ipv6_mbgp_regexp, - show_ipv6_mbgp_regexp_cmd, - "show ipv6 mbgp regexp .LINE", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the AS path regular expression\n" - "A regular-expression to match the MBGP AS paths\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, - bgp_show_type_regexp); -} -#endif /* HAVE_IPV6 */ - static int bgp_show_prefix_list (struct vty *vty, const char *name, const char *prefix_list_str, afi_t afi, @@ -9405,131 +8220,6 @@ bgp_show_prefix_list (struct vty *vty, const char *name, return bgp_show (vty, bgp, afi, safi, type, plist, 0); } -DEFUN (show_ip_bgp_prefix_list, - show_ip_bgp_prefix_list_cmd, - "show ip bgp prefix-list WORD", - SHOW_STR - IP_STR - BGP_STR - "Display routes conforming to the prefix-list\n" - "IP prefix-list name\n") -{ - return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, - bgp_show_type_prefix_list); -} - -DEFUN (show_ip_bgp_instance_prefix_list, - show_ip_bgp_instance_prefix_list_cmd, - "show ip bgp " BGP_INSTANCE_CMD " prefix-list WORD", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Display routes conforming to the prefix-list\n" - "IP prefix-list name\n") -{ - return bgp_show_prefix_list (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, - bgp_show_type_prefix_list); -} - -DEFUN (show_ip_bgp_flap_prefix_list, - show_ip_bgp_flap_prefix_list_cmd, - "show ip bgp flap-statistics prefix-list WORD", - SHOW_STR - IP_STR - BGP_STR - "Display flap statistics of routes\n" - "Display routes conforming to the prefix-list\n" - "IP prefix-list name\n") -{ - return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, - bgp_show_type_flap_prefix_list); -} - -ALIAS (show_ip_bgp_flap_prefix_list, - show_ip_bgp_damp_flap_prefix_list_cmd, - "show ip bgp dampening flap-statistics prefix-list WORD", - SHOW_STR - IP_STR - BGP_STR - "Display detailed information about dampening\n" - "Display flap statistics of routes\n" - "Display routes conforming to the prefix-list\n" - "IP prefix-list name\n") - -DEFUN (show_ip_bgp_ipv4_prefix_list, - show_ip_bgp_ipv4_prefix_list_cmd, - "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes conforming to the prefix-list\n" - "IP prefix-list name\n") -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_prefix_list (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, - bgp_show_type_prefix_list); - - return bgp_show_prefix_list (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, - bgp_show_type_prefix_list); -} - -#ifdef HAVE_IPV6 -DEFUN (show_bgp_prefix_list, - show_bgp_prefix_list_cmd, - "show bgp prefix-list WORD", - SHOW_STR - BGP_STR - "Display routes conforming to the prefix-list\n" - "IPv6 prefix-list name\n") -{ - return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, - bgp_show_type_prefix_list); -} - -ALIAS (show_bgp_prefix_list, - show_bgp_ipv6_prefix_list_cmd, - "show bgp ipv6 prefix-list WORD", - SHOW_STR - BGP_STR - "Address family\n" - "Display routes conforming to the prefix-list\n" - "IPv6 prefix-list name\n") - -/* old command */ -DEFUN (show_ipv6_bgp_prefix_list, - show_ipv6_bgp_prefix_list_cmd, - "show ipv6 bgp prefix-list WORD", - SHOW_STR - IPV6_STR - BGP_STR - "Display routes matching the prefix-list\n" - "IPv6 prefix-list name\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, - bgp_show_type_prefix_list); -} - -/* old command */ -DEFUN (show_ipv6_mbgp_prefix_list, - show_ipv6_mbgp_prefix_list_cmd, - "show ipv6 mbgp prefix-list WORD", - SHOW_STR - IPV6_STR - MBGP_STR - "Display routes matching the prefix-list\n" - "IPv6 prefix-list name\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, - bgp_show_type_prefix_list); -} -#endif /* HAVE_IPV6 */ - static int bgp_show_filter_list (struct vty *vty, const char *name, const char *filter, afi_t afi, @@ -9554,131 +8244,6 @@ bgp_show_filter_list (struct vty *vty, const char *name, return bgp_show (vty, bgp, afi, safi, type, as_list, 0); } -DEFUN (show_ip_bgp_filter_list, - show_ip_bgp_filter_list_cmd, - "show ip bgp filter-list WORD", - SHOW_STR - IP_STR - BGP_STR - "Display routes conforming to the filter-list\n" - "Regular expression access list name\n") -{ - return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, - bgp_show_type_filter_list); -} - -DEFUN (show_ip_bgp_instance_filter_list, - show_ip_bgp_instance_filter_list_cmd, - "show ip bgp " BGP_INSTANCE_CMD " filter-list WORD", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Display routes conforming to the filter-list\n" - "Regular expression access list name\n") -{ - return bgp_show_filter_list (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, - bgp_show_type_filter_list); -} - -DEFUN (show_ip_bgp_flap_filter_list, - show_ip_bgp_flap_filter_list_cmd, - "show ip bgp flap-statistics filter-list WORD", - SHOW_STR - IP_STR - BGP_STR - "Display flap statistics of routes\n" - "Display routes conforming to the filter-list\n" - "Regular expression access list name\n") -{ - return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, - bgp_show_type_flap_filter_list); -} - -ALIAS (show_ip_bgp_flap_filter_list, - show_ip_bgp_damp_flap_filter_list_cmd, - "show ip bgp dampening flap-statistics filter-list WORD", - SHOW_STR - IP_STR - BGP_STR - "Display detailed information about dampening\n" - "Display flap statistics of routes\n" - "Display routes conforming to the filter-list\n" - "Regular expression access list name\n") - -DEFUN (show_ip_bgp_ipv4_filter_list, - show_ip_bgp_ipv4_filter_list_cmd, - "show ip bgp ipv4 (unicast|multicast) filter-list WORD", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes conforming to the filter-list\n" - "Regular expression access list name\n") -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_filter_list (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, - bgp_show_type_filter_list); - - return bgp_show_filter_list (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, - bgp_show_type_filter_list); -} - -#ifdef HAVE_IPV6 -DEFUN (show_bgp_filter_list, - show_bgp_filter_list_cmd, - "show bgp filter-list WORD", - SHOW_STR - BGP_STR - "Display routes conforming to the filter-list\n" - "Regular expression access list name\n") -{ - return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, - bgp_show_type_filter_list); -} - -ALIAS (show_bgp_filter_list, - show_bgp_ipv6_filter_list_cmd, - "show bgp ipv6 filter-list WORD", - SHOW_STR - BGP_STR - "Address family\n" - "Display routes conforming to the filter-list\n" - "Regular expression access list name\n") - -/* old command */ -DEFUN (show_ipv6_bgp_filter_list, - show_ipv6_bgp_filter_list_cmd, - "show ipv6 bgp filter-list WORD", - SHOW_STR - IPV6_STR - BGP_STR - "Display routes conforming to the filter-list\n" - "Regular expression access list name\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, - bgp_show_type_filter_list); -} - -/* old command */ -DEFUN (show_ipv6_mbgp_filter_list, - show_ipv6_mbgp_filter_list_cmd, - "show ipv6 mbgp filter-list WORD", - SHOW_STR - IPV6_STR - MBGP_STR - "Display routes conforming to the filter-list\n" - "Regular expression access list name\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, - bgp_show_type_filter_list); -} -#endif /* HAVE_IPV6 */ - DEFUN (show_ip_bgp_dampening_info, show_ip_bgp_dampening_params_cmd, "show ip bgp dampening parameters", @@ -9694,63 +8259,23 @@ DEFUN (show_ip_bgp_dampening_info, DEFUN (show_ip_bgp_ipv4_dampening_parameters, show_ip_bgp_ipv4_dampening_parameters_cmd, - "show ip bgp ipv4 (unicast|multicast) dampening parameters", + "show ip bgp ipv4 <unicast|multicast> dampening parameters", SHOW_STR IP_STR BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" "Display detailed information about dampening\n" "Display detail of configured dampening parameters\n") { - if (strncmp(argv[0], "m", 1) == 0) + int idx_safi = 4; + if (strncmp(argv[idx_safi]->arg, "m", 1) == 0) return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_MULTICAST); return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); } - -DEFUN (show_ip_bgp_ipv4_dampening_flap_stats, - show_ip_bgp_ipv4_dampening_flap_stats_cmd, - "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display detailed information about dampening\n" - "Display flap statistics of routes\n") -{ - if (strncmp(argv[0], "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, - bgp_show_type_flap_statistics, NULL, 0); - - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, - bgp_show_type_flap_statistics, NULL, 0); -} - -DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths, - show_ip_bgp_ipv4_dampening_dampd_paths_cmd, - "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display detailed information about dampening\n" - "Display paths suppressed due to dampening\n") -{ - if (strncmp(argv[0], "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, - bgp_show_type_dampend_paths, NULL, 0); - - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, - bgp_show_type_dampend_paths, NULL, 0); -} - static int bgp_show_route_map (struct vty *vty, const char *name, const char *rmap_str, afi_t afi, @@ -9761,6 +8286,8 @@ bgp_show_route_map (struct vty *vty, const char *name, if (name && !(bgp = bgp_lookup_by_name(name))) { + + vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); return CMD_WARNING; } @@ -9776,236 +8303,9 @@ bgp_show_route_map (struct vty *vty, const char *name, return bgp_show (vty, bgp, afi, safi, type, rmap, 0); } -DEFUN (show_ip_bgp_route_map, - show_ip_bgp_route_map_cmd, - "show ip bgp route-map WORD", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the route-map\n" - "A route-map to match on\n") -{ - return bgp_show_route_map (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, - bgp_show_type_route_map); -} - -DEFUN (show_ip_bgp_instance_route_map, - show_ip_bgp_instance_route_map_cmd, - "show ip bgp " BGP_INSTANCE_CMD " route-map WORD", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Display routes matching the route-map\n" - "A route-map to match on\n") -{ - return bgp_show_route_map (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, - bgp_show_type_route_map); -} - -DEFUN (show_ip_bgp_flap_route_map, - show_ip_bgp_flap_route_map_cmd, - "show ip bgp flap-statistics route-map WORD", - SHOW_STR - IP_STR - BGP_STR - "Display flap statistics of routes\n" - "Display routes matching the route-map\n" - "A route-map to match on\n") -{ - return bgp_show_route_map (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, - bgp_show_type_flap_route_map); -} - -ALIAS (show_ip_bgp_flap_route_map, - show_ip_bgp_damp_flap_route_map_cmd, - "show ip bgp dampening flap-statistics route-map WORD", - SHOW_STR - IP_STR - BGP_STR - "Display detailed information about dampening\n" - "Display flap statistics of routes\n" - "Display routes matching the route-map\n" - "A route-map to match on\n") - -DEFUN (show_ip_bgp_ipv4_route_map, - show_ip_bgp_ipv4_route_map_cmd, - "show ip bgp ipv4 (unicast|multicast) route-map WORD", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the route-map\n" - "A route-map to match on\n") -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_route_map (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, - bgp_show_type_route_map); - - return bgp_show_route_map (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, - bgp_show_type_route_map); -} - -DEFUN (show_bgp_route_map, - show_bgp_route_map_cmd, - "show bgp route-map WORD", - SHOW_STR - BGP_STR - "Display routes matching the route-map\n" - "A route-map to match on\n") -{ - return bgp_show_route_map (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, - bgp_show_type_route_map); -} - -ALIAS (show_bgp_route_map, - show_bgp_ipv6_route_map_cmd, - "show bgp ipv6 route-map WORD", - SHOW_STR - BGP_STR - "Address family\n" - "Display routes matching the route-map\n" - "A route-map to match on\n") - -DEFUN (show_ip_bgp_cidr_only, - show_ip_bgp_cidr_only_cmd, - "show ip bgp cidr-only", - SHOW_STR - IP_STR - BGP_STR - "Display only routes with non-natural netmasks\n") -{ - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, - bgp_show_type_cidr_only, NULL, 0); -} - -DEFUN (show_ip_bgp_flap_cidr_only, - show_ip_bgp_flap_cidr_only_cmd, - "show ip bgp flap-statistics cidr-only", - SHOW_STR - IP_STR - BGP_STR - "Display flap statistics of routes\n" - "Display only routes with non-natural netmasks\n") -{ - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, - bgp_show_type_flap_cidr_only, NULL, 0); -} - -ALIAS (show_ip_bgp_flap_cidr_only, - show_ip_bgp_damp_flap_cidr_only_cmd, - "show ip bgp dampening flap-statistics cidr-only", - SHOW_STR - IP_STR - BGP_STR - "Display detailed information about dampening\n" - "Display flap statistics of routes\n" - "Display only routes with non-natural netmasks\n") - -DEFUN (show_ip_bgp_ipv4_cidr_only, - show_ip_bgp_ipv4_cidr_only_cmd, - "show ip bgp ipv4 (unicast|multicast) cidr-only", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display only routes with non-natural netmasks\n") -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, - bgp_show_type_cidr_only, NULL, 0); - - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, - bgp_show_type_cidr_only, NULL, 0); -} - -DEFUN (show_ip_bgp_community_all, - show_ip_bgp_community_all_cmd, - "show ip bgp community", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the communities\n") -{ - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, - bgp_show_type_community_all, NULL, 0); -} - -DEFUN (show_ip_bgp_ipv4_community_all, - show_ip_bgp_ipv4_community_all_cmd, - "show ip bgp ipv4 (unicast|multicast) community", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the communities\n") -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, - bgp_show_type_community_all, NULL, 0); - - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, - bgp_show_type_community_all, NULL, 0); -} - -#ifdef HAVE_IPV6 -DEFUN (show_bgp_community_all, - show_bgp_community_all_cmd, - "show bgp community", - SHOW_STR - BGP_STR - "Display routes matching the communities\n") -{ - return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, - bgp_show_type_community_all, NULL, 0); -} - -ALIAS (show_bgp_community_all, - show_bgp_ipv6_community_all_cmd, - "show bgp ipv6 community", - SHOW_STR - BGP_STR - "Address family\n" - "Display routes matching the communities\n") - -/* old command */ -DEFUN (show_ipv6_bgp_community_all, - show_ipv6_bgp_community_all_cmd, - "show ipv6 bgp community", - SHOW_STR - IPV6_STR - BGP_STR - "Display routes matching the communities\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, - bgp_show_type_community_all, NULL, 0); -} - -/* old command */ -DEFUN (show_ipv6_mbgp_community_all, - show_ipv6_mbgp_community_all_cmd, - "show ipv6 mbgp community", - SHOW_STR - IPV6_STR - MBGP_STR - "Display routes matching the communities\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, - bgp_show_type_community_all, NULL, 0); -} -#endif /* HAVE_IPV6 */ - static int bgp_show_community (struct vty *vty, const char *view_name, int argc, - const char **argv, int exact, afi_t afi, safi_t safi) + struct cmd_token **argv, int exact, afi_t afi, safi_t safi) { struct community *com; struct buffer *b; @@ -10041,12 +8341,12 @@ bgp_show_community (struct vty *vty, const char *view_name, int argc, buffer_putc (b, ' '); else { - if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) + if ((strcmp (argv[i]->arg, "unicast") == 0) || (strcmp (argv[i]->arg, "multicast") == 0)) continue; first = 1; } - buffer_putstr (b, argv[i]); + buffer_putstr (b, argv[i]->arg); } buffer_putc (b, '\0'); @@ -10066,1093 +8366,6 @@ bgp_show_community (struct vty *vty, const char *view_name, int argc, bgp_show_type_community), com, 0); } -DEFUN (show_ip_bgp_community, - show_ip_bgp_community_cmd, - "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") -{ - return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); -} - -ALIAS (show_ip_bgp_community, - show_ip_bgp_community2_cmd, - "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -ALIAS (show_ip_bgp_community, - show_ip_bgp_community3_cmd, - "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -ALIAS (show_ip_bgp_community, - show_ip_bgp_community4_cmd, - "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -DEFUN (show_ip_bgp_ipv4_community, - show_ip_bgp_ipv4_community_cmd, - "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); - - return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); -} - -ALIAS (show_ip_bgp_ipv4_community, - show_ip_bgp_ipv4_community2_cmd, - "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -ALIAS (show_ip_bgp_ipv4_community, - show_ip_bgp_ipv4_community3_cmd, - "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -ALIAS (show_ip_bgp_ipv4_community, - show_ip_bgp_ipv4_community4_cmd, - "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -DEFUN (show_bgp_instance_afi_safi_community_all, - show_bgp_instance_afi_safi_community_all_cmd, - "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the communities\n") -{ - int afi; - int safi; - struct bgp *bgp; - - /* BGP structure lookup. */ - bgp = bgp_lookup_by_name (argv[1]); - if (bgp == NULL) - { - vty_out (vty, "Can't find BGP instance %s%s", argv[1], VTY_NEWLINE); - return CMD_WARNING; - } - - afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; - safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; - return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL, 0); -} - -DEFUN (show_bgp_instance_afi_safi_community, - show_bgp_instance_afi_safi_community_cmd, - "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Address family\n" - "Address family modifier\n" - "Address family modifier\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") -{ - int afi; - int safi; - - afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; - safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; - return bgp_show_community (vty, argv[1], argc-4, &argv[4], 0, afi, safi); -} - -ALIAS (show_bgp_instance_afi_safi_community, - show_bgp_instance_afi_safi_community2_cmd, - "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Address family\n" - "Address family modifier\n" - "Address family modifier\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -ALIAS (show_bgp_instance_afi_safi_community, - show_bgp_instance_afi_safi_community3_cmd, - "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Address family\n" - "Address family modifier\n" - "Address family modifier\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -ALIAS (show_bgp_instance_afi_safi_community, - show_bgp_instance_afi_safi_community4_cmd, - "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Address family\n" - "Address family modifier\n" - "Address family modifier\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -DEFUN (show_ip_bgp_community_exact, - show_ip_bgp_community_exact_cmd, - "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") -{ - return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); -} - -ALIAS (show_ip_bgp_community_exact, - show_ip_bgp_community2_exact_cmd, - "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") - -ALIAS (show_ip_bgp_community_exact, - show_ip_bgp_community3_exact_cmd, - "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") - -ALIAS (show_ip_bgp_community_exact, - show_ip_bgp_community4_exact_cmd, - "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") - -DEFUN (show_ip_bgp_ipv4_community_exact, - show_ip_bgp_ipv4_community_exact_cmd, - "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); - - return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); -} - -ALIAS (show_ip_bgp_ipv4_community_exact, - show_ip_bgp_ipv4_community2_exact_cmd, - "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") - -ALIAS (show_ip_bgp_ipv4_community_exact, - show_ip_bgp_ipv4_community3_exact_cmd, - "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") - -ALIAS (show_ip_bgp_ipv4_community_exact, - show_ip_bgp_ipv4_community4_exact_cmd, - "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") - -#ifdef HAVE_IPV6 -DEFUN (show_bgp_community, - show_bgp_community_cmd, - "show bgp community (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") -{ - return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); -} - -ALIAS (show_bgp_community, - show_bgp_ipv6_community_cmd, - "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - BGP_STR - "Address family\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -ALIAS (show_bgp_community, - show_bgp_community2_cmd, - "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -ALIAS (show_bgp_community, - show_bgp_ipv6_community2_cmd, - "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - BGP_STR - "Address family\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -ALIAS (show_bgp_community, - show_bgp_community3_cmd, - "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -ALIAS (show_bgp_community, - show_bgp_ipv6_community3_cmd, - "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - BGP_STR - "Address family\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -ALIAS (show_bgp_community, - show_bgp_community4_cmd, - "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -ALIAS (show_bgp_community, - show_bgp_ipv6_community4_cmd, - "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - BGP_STR - "Address family\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -/* old command */ -DEFUN (show_ipv6_bgp_community, - show_ipv6_bgp_community_cmd, - "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - IPV6_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); -} - -/* old command */ -ALIAS (show_ipv6_bgp_community, - show_ipv6_bgp_community2_cmd, - "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - IPV6_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -/* old command */ -ALIAS (show_ipv6_bgp_community, - show_ipv6_bgp_community3_cmd, - "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - IPV6_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -/* old command */ -ALIAS (show_ipv6_bgp_community, - show_ipv6_bgp_community4_cmd, - "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - IPV6_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -DEFUN (show_bgp_community_exact, - show_bgp_community_exact_cmd, - "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") -{ - return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); -} - -ALIAS (show_bgp_community_exact, - show_bgp_ipv6_community_exact_cmd, - "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - BGP_STR - "Address family\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") - -ALIAS (show_bgp_community_exact, - show_bgp_community2_exact_cmd, - "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") - -ALIAS (show_bgp_community_exact, - show_bgp_ipv6_community2_exact_cmd, - "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - BGP_STR - "Address family\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") - -ALIAS (show_bgp_community_exact, - show_bgp_community3_exact_cmd, - "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") - -ALIAS (show_bgp_community_exact, - show_bgp_ipv6_community3_exact_cmd, - "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - BGP_STR - "Address family\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") - -ALIAS (show_bgp_community_exact, - show_bgp_community4_exact_cmd, - "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") - -ALIAS (show_bgp_community_exact, - show_bgp_ipv6_community4_exact_cmd, - "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - BGP_STR - "Address family\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") - -/* old command */ -DEFUN (show_ipv6_bgp_community_exact, - show_ipv6_bgp_community_exact_cmd, - "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - IPV6_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); -} - -/* old command */ -ALIAS (show_ipv6_bgp_community_exact, - show_ipv6_bgp_community2_exact_cmd, - "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - IPV6_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") - -/* old command */ -ALIAS (show_ipv6_bgp_community_exact, - show_ipv6_bgp_community3_exact_cmd, - "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - IPV6_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") - -/* old command */ -ALIAS (show_ipv6_bgp_community_exact, - show_ipv6_bgp_community4_exact_cmd, - "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - IPV6_STR - BGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") - -/* old command */ -DEFUN (show_ipv6_mbgp_community, - show_ipv6_mbgp_community_cmd, - "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - IPV6_STR - MBGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); -} - -/* old command */ -ALIAS (show_ipv6_mbgp_community, - show_ipv6_mbgp_community2_cmd, - "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - IPV6_STR - MBGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -/* old command */ -ALIAS (show_ipv6_mbgp_community, - show_ipv6_mbgp_community3_cmd, - "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - IPV6_STR - MBGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -/* old command */ -ALIAS (show_ipv6_mbgp_community, - show_ipv6_mbgp_community4_cmd, - "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - SHOW_STR - IPV6_STR - MBGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n") - -/* old command */ -DEFUN (show_ipv6_mbgp_community_exact, - show_ipv6_mbgp_community_exact_cmd, - "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - IPV6_STR - MBGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); -} - -/* old command */ -ALIAS (show_ipv6_mbgp_community_exact, - show_ipv6_mbgp_community2_exact_cmd, - "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - IPV6_STR - MBGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") - -/* old command */ -ALIAS (show_ipv6_mbgp_community_exact, - show_ipv6_mbgp_community3_exact_cmd, - "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - IPV6_STR - MBGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") - -/* old command */ -ALIAS (show_ipv6_mbgp_community_exact, - show_ipv6_mbgp_community4_exact_cmd, - "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - SHOW_STR - IPV6_STR - MBGP_STR - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Exact match of the communities") -#endif /* HAVE_IPV6 */ - static int bgp_show_community_list (struct vty *vty, const char *name, const char *com, int exact, @@ -11180,192 +8393,6 @@ bgp_show_community_list (struct vty *vty, const char *name, bgp_show_type_community_list), list, 0); } -DEFUN (show_ip_bgp_community_list, - show_ip_bgp_community_list_cmd, - "show ip bgp community-list (<1-500>|WORD)", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the community-list\n" - "community-list number\n" - "community-list name\n") -{ - return bgp_show_community_list (vty, NULL, argv[0], 0, AFI_IP, SAFI_UNICAST); -} - -DEFUN (show_ip_bgp_instance_community_list, - show_ip_bgp_instance_community_list_cmd, - "show ip bgp " BGP_INSTANCE_CMD " community-list (<1-500>|WORD)", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Display routes matching the community-list\n" - "community-list number\n" - "community-list name\n") -{ - return bgp_show_community_list (vty, argv[1], argv[2], 0, AFI_IP, SAFI_UNICAST); -} - -DEFUN (show_ip_bgp_ipv4_community_list, - show_ip_bgp_ipv4_community_list_cmd, - "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the community-list\n" - "community-list number\n" - "community-list name\n") -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_community_list (vty, NULL, argv[1], 0, AFI_IP, SAFI_MULTICAST); - - return bgp_show_community_list (vty, NULL, argv[1], 0, AFI_IP, SAFI_UNICAST); -} - -DEFUN (show_ip_bgp_community_list_exact, - show_ip_bgp_community_list_exact_cmd, - "show ip bgp community-list (<1-500>|WORD) exact-match", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the community-list\n" - "community-list number\n" - "community-list name\n" - "Exact match of the communities\n") -{ - return bgp_show_community_list (vty, NULL, argv[0], 1, AFI_IP, SAFI_UNICAST); -} - -DEFUN (show_ip_bgp_ipv4_community_list_exact, - show_ip_bgp_ipv4_community_list_exact_cmd, - "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the community-list\n" - "community-list number\n" - "community-list name\n" - "Exact match of the communities\n") -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_community_list (vty, NULL, argv[1], 1, AFI_IP, SAFI_MULTICAST); - - return bgp_show_community_list (vty, NULL, argv[1], 1, AFI_IP, SAFI_UNICAST); -} - -#ifdef HAVE_IPV6 -DEFUN (show_bgp_community_list, - show_bgp_community_list_cmd, - "show bgp community-list (<1-500>|WORD)", - SHOW_STR - BGP_STR - "Display routes matching the community-list\n" - "community-list number\n" - "community-list name\n") -{ - return bgp_show_community_list (vty, NULL, argv[0], 0, AFI_IP6, SAFI_UNICAST); -} - -ALIAS (show_bgp_community_list, - show_bgp_ipv6_community_list_cmd, - "show bgp ipv6 community-list (<1-500>|WORD)", - SHOW_STR - BGP_STR - "Address family\n" - "Display routes matching the community-list\n" - "community-list number\n" - "community-list name\n") - -/* old command */ -DEFUN (show_ipv6_bgp_community_list, - show_ipv6_bgp_community_list_cmd, - "show ipv6 bgp community-list WORD", - SHOW_STR - IPV6_STR - BGP_STR - "Display routes matching the community-list\n" - "community-list name\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community_list (vty, NULL, argv[0], 0, AFI_IP6, SAFI_UNICAST); -} - -/* old command */ -DEFUN (show_ipv6_mbgp_community_list, - show_ipv6_mbgp_community_list_cmd, - "show ipv6 mbgp community-list WORD", - SHOW_STR - IPV6_STR - MBGP_STR - "Display routes matching the community-list\n" - "community-list name\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community_list (vty, NULL, argv[0], 0, AFI_IP6, SAFI_MULTICAST); -} - -DEFUN (show_bgp_community_list_exact, - show_bgp_community_list_exact_cmd, - "show bgp community-list (<1-500>|WORD) exact-match", - SHOW_STR - BGP_STR - "Display routes matching the community-list\n" - "community-list number\n" - "community-list name\n" - "Exact match of the communities\n") -{ - return bgp_show_community_list (vty, NULL, argv[0], 1, AFI_IP6, SAFI_UNICAST); -} - -ALIAS (show_bgp_community_list_exact, - show_bgp_ipv6_community_list_exact_cmd, - "show bgp ipv6 community-list (<1-500>|WORD) exact-match", - SHOW_STR - BGP_STR - "Address family\n" - "Display routes matching the community-list\n" - "community-list number\n" - "community-list name\n" - "Exact match of the communities\n") - -/* old command */ -DEFUN (show_ipv6_bgp_community_list_exact, - show_ipv6_bgp_community_list_exact_cmd, - "show ipv6 bgp community-list WORD exact-match", - SHOW_STR - IPV6_STR - BGP_STR - "Display routes matching the community-list\n" - "community-list name\n" - "Exact match of the communities\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community_list (vty, NULL, argv[0], 1, AFI_IP6, SAFI_UNICAST); -} - -/* old command */ -DEFUN (show_ipv6_mbgp_community_list_exact, - show_ipv6_mbgp_community_list_exact_cmd, - "show ipv6 mbgp community-list WORD exact-match", - SHOW_STR - IPV6_STR - MBGP_STR - "Display routes matching the community-list\n" - "community-list name\n" - "Exact match of the communities\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community_list (vty, NULL, argv[0], 1, AFI_IP6, SAFI_MULTICAST); -} -#endif /* HAVE_IPV6 */ - static int bgp_show_prefix_longer (struct vty *vty, const char *name, const char *prefix, afi_t afi, @@ -11395,177 +8422,6 @@ bgp_show_prefix_longer (struct vty *vty, const char *name, return ret; } -DEFUN (show_ip_bgp_prefix_longer, - show_ip_bgp_prefix_longer_cmd, - "show ip bgp A.B.C.D/M longer-prefixes", - SHOW_STR - IP_STR - BGP_STR - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "Display route and more specific routes\n") -{ - return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, - bgp_show_type_prefix_longer); -} - -DEFUN (show_ip_bgp_instance_prefix_longer, - show_ip_bgp_instance_prefix_longer_cmd, - "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D/M longer-prefixes", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "Display route and more specific routes\n") -{ - return bgp_show_prefix_longer (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, - bgp_show_type_prefix_longer); -} - -DEFUN (show_ip_bgp_flap_prefix_longer, - show_ip_bgp_flap_prefix_longer_cmd, - "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", - SHOW_STR - IP_STR - BGP_STR - "Display flap statistics of routes\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "Display route and more specific routes\n") -{ - return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, - bgp_show_type_flap_prefix_longer); -} - -ALIAS (show_ip_bgp_flap_prefix_longer, - show_ip_bgp_damp_flap_prefix_longer_cmd, - "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes", - SHOW_STR - IP_STR - BGP_STR - "Display detailed information about dampening\n" - "Display flap statistics of routes\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "Display route and more specific routes\n") - -DEFUN (show_ip_bgp_ipv4_prefix_longer, - show_ip_bgp_ipv4_prefix_longer_cmd, - "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "Display route and more specific routes\n") -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_prefix_longer (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, - bgp_show_type_prefix_longer); - - return bgp_show_prefix_longer (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, - bgp_show_type_prefix_longer); -} - -DEFUN (show_ip_bgp_flap_address, - show_ip_bgp_flap_address_cmd, - "show ip bgp flap-statistics A.B.C.D", - SHOW_STR - IP_STR - BGP_STR - "Display flap statistics of routes\n" - "Network in the BGP routing table to display\n") -{ - return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, - bgp_show_type_flap_address); -} - -ALIAS (show_ip_bgp_flap_address, - show_ip_bgp_damp_flap_address_cmd, - "show ip bgp dampening flap-statistics A.B.C.D", - SHOW_STR - IP_STR - BGP_STR - "Display detailed information about dampening\n" - "Display flap statistics of routes\n" - "Network in the BGP routing table to display\n") - -DEFUN (show_ip_bgp_flap_prefix, - show_ip_bgp_flap_prefix_cmd, - "show ip bgp flap-statistics A.B.C.D/M", - SHOW_STR - IP_STR - BGP_STR - "Display flap statistics of routes\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") -{ - return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, - bgp_show_type_flap_prefix); -} - -ALIAS (show_ip_bgp_flap_prefix, - show_ip_bgp_damp_flap_prefix_cmd, - "show ip bgp dampening flap-statistics A.B.C.D/M", - SHOW_STR - IP_STR - BGP_STR - "Display detailed information about dampening\n" - "Display flap statistics of routes\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") - -#ifdef HAVE_IPV6 -DEFUN (show_bgp_prefix_longer, - show_bgp_prefix_longer_cmd, - "show bgp X:X::X:X/M longer-prefixes", - SHOW_STR - BGP_STR - "IPv6 prefix <network>/<length>\n" - "Display route and more specific routes\n") -{ - return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, - bgp_show_type_prefix_longer); -} - -ALIAS (show_bgp_prefix_longer, - show_bgp_ipv6_prefix_longer_cmd, - "show bgp ipv6 X:X::X:X/M longer-prefixes", - SHOW_STR - BGP_STR - "Address family\n" - "IPv6 prefix <network>/<length>\n" - "Display route and more specific routes\n") - -/* old command */ -DEFUN (show_ipv6_bgp_prefix_longer, - show_ipv6_bgp_prefix_longer_cmd, - "show ipv6 bgp X:X::X:X/M longer-prefixes", - SHOW_STR - IPV6_STR - BGP_STR - "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" - "Display route and more specific routes\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, - bgp_show_type_prefix_longer); -} - -/* old command */ -DEFUN (show_ipv6_mbgp_prefix_longer, - show_ipv6_mbgp_prefix_longer_cmd, - "show ipv6 mbgp X:X::X:X/M longer-prefixes", - SHOW_STR - IPV6_STR - MBGP_STR - "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" - "Display route and more specific routes\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, - bgp_show_type_prefix_longer); -} -#endif /* HAVE_IPV6 */ - static struct peer * peer_lookup_in_view (struct vty *vty, const char *view_name, const char *ip_str, u_char use_json) @@ -11831,7 +8687,7 @@ bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) if (!bgp->rib[afi][safi]) { - vty_out (vty, "%% No RIB exists for the AFI(%d)/SAFI(%d)%s", + vty_out (vty, "%% No RIB exist's for the AFI(%d)/SAFI(%d)%s", afi, safi, VTY_NEWLINE); return CMD_WARNING; } @@ -11923,7 +8779,7 @@ bgp_table_stats_vty (struct vty *vty, const char *name, if (!bgp) { - vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); + vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); return CMD_WARNING; } if (strncmp (afi_str, "ipv", 3) == 0) @@ -11965,35 +8821,39 @@ bgp_table_stats_vty (struct vty *vty, const char *name, DEFUN (show_bgp_statistics, show_bgp_statistics_cmd, - "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", + "show bgp <ipv4|ipv6> <encap|multicast|unicast|vpn> statistics", SHOW_STR BGP_STR - "Address family\n" - "Address family\n" + "Address Family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" "Address Family modifier\n" "Address Family modifier\n" "BGP RIB advertisement statistics\n") { - return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); + int idx_afi = 2; + int idx_safi = 3; + return bgp_table_stats_vty (vty, NULL, argv[idx_afi]->arg, argv[idx_safi]->arg); } DEFUN (show_bgp_statistics_view, show_bgp_statistics_view_cmd, - "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast|vpn|encap) statistics", + "show bgp <view|vrf> WORD <ipv4|ipv6> <unicast|multicast|vpn|encap> statistics", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address family\n" - "Address family\n" + "Address Family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" "Address Family modifier\n" "Address Family modifier\n" "BGP RIB advertisement statistics\n") { - return bgp_table_stats_vty (vty, NULL, argv[1], argv[2]); + int idx_word = 3; + int idx_afi = 4; + return bgp_table_stats_vty (vty, NULL, argv[idx_word]->arg, argv[idx_afi]->arg); } enum bgp_pcounts @@ -12115,7 +8975,7 @@ bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, u_c if (use_json) { json_object_string_add(json, "warning", "No such neighbor or address family"); - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); + vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); json_object_free(json); } else @@ -12150,7 +9010,7 @@ bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, u_c json_object_string_add(json, "pfxctDriftFor", peer->host); json_object_string_add(json, "recommended", "Please report this bug, with the above command output"); } - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); + vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); json_object_free(json); } else @@ -12189,7 +9049,7 @@ bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, u_c DEFUN (show_ip_bgp_neighbor_prefix_counts, show_ip_bgp_neighbor_prefix_counts_cmd, - "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", + "show ip bgp neighbors <A.B.C.D|X:X::X:X|WORD> prefix-counts [json]", SHOW_STR IP_STR BGP_STR @@ -12200,10 +9060,11 @@ DEFUN (show_ip_bgp_neighbor_prefix_counts, "Display detailed prefix count information\n" "JavaScript Object Notation\n") { + int idx_peer = 4; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[0], uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -12212,7 +9073,7 @@ DEFUN (show_ip_bgp_neighbor_prefix_counts, DEFUN (show_ip_bgp_instance_neighbor_prefix_counts, show_ip_bgp_instance_neighbor_prefix_counts_cmd, - "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", + "show ip bgp <view|vrf> WORD neighbors <A.B.C.D|X:X::X:X|WORD> prefix-counts [json]", SHOW_STR IP_STR BGP_STR @@ -12224,10 +9085,12 @@ DEFUN (show_ip_bgp_instance_neighbor_prefix_counts, "Display detailed prefix count information\n" "JavaScript Object Notation\n") { + int idx_word = 4; + int idx_peer = 6; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); + peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -12236,10 +9099,10 @@ DEFUN (show_ip_bgp_instance_neighbor_prefix_counts, DEFUN (show_bgp_ipv6_neighbor_prefix_counts, show_bgp_ipv6_neighbor_prefix_counts_cmd, - "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", + "show bgp ipv6 neighbors <A.B.C.D|X:X::X:X|WORD> prefix-counts [json]", SHOW_STR BGP_STR - "Address family\n" + "Address Family\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -12247,10 +9110,11 @@ DEFUN (show_bgp_ipv6_neighbor_prefix_counts, "Display detailed prefix count information\n" "JavaScript Object Notation\n") { + int idx_peer = 4; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[0], uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -12259,11 +9123,11 @@ DEFUN (show_bgp_ipv6_neighbor_prefix_counts, DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts, show_bgp_instance_ipv6_neighbor_prefix_counts_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", + "show bgp <view|vrf> WORD ipv6 neighbors <A.B.C.D|X:X::X:X|WORD> prefix-counts [json]", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address family\n" + "Address Family\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -12271,10 +9135,12 @@ DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts, "Display detailed prefix count information\n" "JavaScript Object Notation\n") { + int idx_word = 3; + int idx_peer = 6; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); + peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -12283,11 +9149,11 @@ DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts, DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, - "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", + "show ip bgp ipv4 <unicast|multicast> neighbors <A.B.C.D|X:X::X:X|WORD> prefix-counts [json]", SHOW_STR IP_STR BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" @@ -12297,14 +9163,16 @@ DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, "Display detailed prefix count information\n" "JavaScript Object Notation\n") { + int idx_safi = 4; + int idx_peer = 6; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[1], uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; - if (strncmp (argv[0], "m", 1) == 0) + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST, uj); return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj); @@ -12312,11 +9180,11 @@ DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, - "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", + "show ip bgp vpnv4 all neighbors <A.B.C.D|X:X::X:X|WORD> prefix-counts [json]", SHOW_STR IP_STR BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" @@ -12326,10 +9194,11 @@ DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, "Display detailed prefix count information\n" "JavaScript Object Notation\n") { + int idx_peer = 6; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[0], uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -12387,7 +9256,7 @@ show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, if (use_json) { json_object_string_add(json, "alert", "no BGP"); - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); + vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); json_object_free(json); } else @@ -12528,7 +9397,7 @@ show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, } if (use_json) { - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); + vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); json_object_free(json); } @@ -12548,7 +9417,7 @@ peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, if (use_json) { json_object_string_add(json, "warning", "No such neighbor or address family"); - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); + vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); json_object_free(json); } else @@ -12562,7 +9431,7 @@ peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, if (use_json) { json_object_string_add(json, "warning", "Inbound soft reconfiguration not enabled"); - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); + vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); json_object_free(json); } else @@ -12578,558 +9447,95 @@ peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, DEFUN (show_ip_bgp_instance_neighbor_advertised_route, show_ip_bgp_instance_neighbor_advertised_route_cmd, - "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Display the routes advertised to a BGP neighbor\n" - "JavaScript Object Notation\n") -{ - struct peer *peer; - u_char uj = use_json(argc, argv); - - if (argc == 4 || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) - peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); - else - peer = peer_lookup_in_view (vty, NULL, argv[1], uj); - - if (! peer) - return CMD_WARNING; - - return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, NULL, uj); -} - -DEFUN (show_ip_bgp_neighbor_advertised_route, - show_ip_bgp_neighbor_advertised_route_cmd, - "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", - SHOW_STR - IP_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the routes advertised to a BGP neighbor\n" - "JavaScript Object Notation\n") - -{ - struct peer *peer; - const char *rmap_name = NULL; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[0], uj); - - if (! peer) - return CMD_WARNING; - - if ((argc == 2 && argv[1] && strcmp(argv[1], "json") != 0) - || (argc == 3)) - rmap_name = argv[1]; - - return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, rmap_name, uj); -} - -ALIAS (show_ip_bgp_neighbor_advertised_route, - show_ip_bgp_neighbor_advertised_route_rmap_cmd, - "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}", - SHOW_STR - IP_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the routes advertised to a BGP neighbor\n" - "JavaScript Object Notation\n") - -ALIAS (show_ip_bgp_instance_neighbor_advertised_route, - show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd, - "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}", + "show [ip] bgp [<view|vrf>] WORD [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] neighbors <A.B.C.D|X:X::X:X|WORD> [<received-routes|advertised-routes> [route-map WORD]] [json]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the routes advertised to a BGP neighbor\n" - "JavaScript Object Notation\n") -DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, - show_ip_bgp_ipv4_neighbor_advertised_route_cmd, - "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the routes advertised to a BGP neighbor\n" - "JavaScript Object Notation\n") -{ - struct peer *peer; - const char *rmap_name = NULL; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[1], uj); - if (! peer) - return CMD_WARNING; - - if ((argc == 4) || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) - rmap_name = argv[2]; - - if (strncmp (argv[0], "m", 1) == 0) - return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0, rmap_name, uj); - else - return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, rmap_name, uj); -} - -ALIAS (show_ip_bgp_ipv4_neighbor_advertised_route, - show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd, - "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the routes advertised to a BGP neighbor\n" - "Route-map to control what is displayed\n" - "JavaScript Object Notation\n") - -#ifdef HAVE_IPV6 -DEFUN (show_bgp_instance_neighbor_advertised_route, - show_bgp_instance_neighbor_advertised_route_cmd, - "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the routes advertised to a BGP neighbor\n" - "JavaScript Object Notation\n") -{ - struct peer *peer; - u_char uj = use_json(argc, argv); - - if (argc == 4 || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) - peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); - else - peer = peer_lookup_in_view (vty, NULL, argv[1], uj); - - if (! peer) - return CMD_WARNING; - - return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0, NULL, uj); -} - -ALIAS (show_bgp_instance_neighbor_advertised_route, - show_bgp_instance_ipv6_neighbor_advertised_route_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the routes advertised to a BGP neighbor\n" - "JavaScript Object Notation\n") - -DEFUN (show_bgp_neighbor_advertised_route, - show_bgp_neighbor_advertised_route_cmd, - "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", - SHOW_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the routes advertised to a BGP neighbor\n" - "JavaScript Object Notation\n") - -{ - struct peer *peer; - const char *rmap_name = NULL; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[0], uj); - - if (!peer) - return CMD_WARNING; - - if (argc == 3 || (argc == 2 && argv[1] && strcmp(argv[1], "json") != 0)) - rmap_name = argv[1]; - - return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0, rmap_name, uj); -} - -ALIAS (show_bgp_neighbor_advertised_route, - show_bgp_ipv6_neighbor_advertised_route_cmd, - "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", - SHOW_STR - BGP_STR - "Address family\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the routes advertised to a BGP neighbor\n" - "JavaScript Object Notation\n") - -/* old command */ -ALIAS (show_bgp_neighbor_advertised_route, - ipv6_bgp_neighbor_advertised_route_cmd, - "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", - SHOW_STR - IPV6_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the routes advertised to a BGP neighbor\n" - "JavaScript Object Notation\n") - -/* old command */ -DEFUN (ipv6_mbgp_neighbor_advertised_route, - ipv6_mbgp_neighbor_advertised_route_cmd, - "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", - SHOW_STR - IPV6_STR - MBGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Neighbor on bgp configured interface\n" - "Display the routes advertised to a BGP neighbor\n" - "JavaScript Object Notation\n") -{ - struct peer *peer; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[0], uj); - if (! peer) - return CMD_WARNING; - - bgp_show_ipv6_bgp_deprecate_warning(vty); - return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0, NULL, uj); -} -#endif /* HAVE_IPV6 */ - -DEFUN (show_bgp_instance_neighbor_received_routes, - show_bgp_instance_neighbor_received_routes_cmd, - "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the received routes from neighbor\n" - "JavaScript Object Notation\n") -{ - struct peer *peer; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); - if (! peer) - return CMD_WARNING; - - return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1, NULL, uj); -} - -DEFUN (show_ip_bgp_instance_neighbor_received_routes, - show_ip_bgp_instance_neighbor_received_routes_cmd, - "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the received routes from neighbor\n" - "JavaScript Object Notation\n") -{ - struct peer *peer; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); - if (! peer) - return CMD_WARNING; - - return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, NULL, uj); -} - -ALIAS (show_bgp_instance_neighbor_received_routes, - show_bgp_instance_ipv6_neighbor_received_routes_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the received routes from neighbor\n" - "JavaScript Object Notation\n") - -DEFUN (show_ip_bgp_neighbor_received_routes, - show_ip_bgp_neighbor_received_routes_cmd, - "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", - SHOW_STR - IP_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the received routes from neighbor\n" - "JavaScript Object Notation\n") - -{ - struct peer *peer; - const char *rmap_name = NULL; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[0], uj); - - if (! peer) - return CMD_WARNING; - - if (argc == 3 || (argc == 2 && argv[1] && strcmp(argv[1], "json") != 0)) - rmap_name = argv[1]; - - return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, rmap_name, uj); -} - -ALIAS (show_ip_bgp_neighbor_received_routes, - show_ip_bgp_neighbor_received_routes_rmap_cmd, - "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}", - SHOW_STR - IP_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the received routes from neighbor\n" - "JavaScript Object Notation\n") - -ALIAS (show_ip_bgp_instance_neighbor_received_routes, - show_ip_bgp_instance_neighbor_received_routes_rmap_cmd, - "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the received routes from neighbor\n" - "JavaScript Object Notation\n") - -DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, - show_ip_bgp_ipv4_neighbor_received_routes_cmd, - "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" + "Address Family\n" "Address Family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" "Neighbor on bgp configured interface\n" "Display the received routes from neighbor\n" + "Display the routes advertised to a BGP neighbor\n" + "Route-map to modify the attributes\n" + "Name of the route map\n" "JavaScript Object Notation\n") { - struct peer *peer; - const char *rmap_name = NULL; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[1], uj); - if (! peer) - return CMD_WARNING; - - if (argc == 4 || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) - rmap_name = argv[2]; + afi_t afi = AFI_IP6; + safi_t safi = SAFI_UNICAST; + char *vrf = NULL; + char *rmap_name = NULL; + char *peerstr = NULL; + int rcvd; - if (strncmp (argv[0], "m", 1) == 0) - return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1, rmap_name, uj); - else - return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, rmap_name, uj); -} - -ALIAS (show_ip_bgp_ipv4_neighbor_received_routes, - show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd, - "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the received routes from neighbor\n" - "JavaScript Object Notation\n") - -DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes, - show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd, - "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Address family\n" - "Address family modifier\n" - "Address family modifier\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the advertised routes to neighbor\n" - "Display the received routes from neighbor\n" - "JavaScript Object Notation\n") -{ - int afi; - int safi; - int in; struct peer *peer; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, argv[1], argv[4], uj); - - if (! peer) - return CMD_WARNING; - afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; - safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; - in = (strncmp (argv[5], "r", 1) == 0) ? 1 : 0; + int idx = 0; + + /* show [ip] bgp */ + if (argv_find (argv, argc, "ip", &idx)) + afi = AFI_IP; + /* [<view|vrf> WORD] */ + if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) + vrf = argv[++idx]->arg; + /* [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] */ + if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) + { + afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; + if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) + safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST; + } + else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) + { + afi = AFI_IP; + safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN; + // advance idx if necessary + argv_find (argv, argc, "unicast", &idx); + } - return peer_adj_routes (vty, peer, afi, safi, in, NULL, uj); -} + /* neighbors <A.B.C.D|X:X::X:X|WORD> */ + argv_find (argv, argc, "neighbors", &idx); + peerstr = argv[++idx]->arg; -DEFUN (show_ip_bgp_neighbor_received_prefix_filter, - show_ip_bgp_neighbor_received_prefix_filter_cmd, - "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", - SHOW_STR - IP_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display information received from a BGP neighbor\n" - "Display the prefixlist filter\n" - "JavaScript Object Notation\n") -{ - char name[BUFSIZ]; - union sockunion su; - struct peer *peer; - int count, ret; u_char uj = use_json(argc, argv); - ret = str2sockunion (argv[0], &su); - if (ret < 0) - { - peer = peer_lookup_by_conf_if (NULL, argv[0]); - if (! peer) - { - if (uj) - { - json_object *json_no = NULL; - json_object *json_sub = NULL; - json_no = json_object_new_object(); - json_sub = json_object_new_object(); - json_object_string_add(json_no, "warning", "Malformed address or name"); - json_object_string_add(json_sub, "warningCause", argv[0]); - json_object_object_add(json_no, "detail", json_sub); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "%% Malformed address or name: %s%s", argv[0], VTY_NEWLINE); - return CMD_WARNING; - } - } - else - { - peer = peer_lookup (NULL, &su); - if (! peer) - { - if (uj) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "Peer not found"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "No peer%s", VTY_NEWLINE); - return CMD_WARNING; - } - } + peer = peer_lookup_in_view (vty, vrf, peerstr, uj); - sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); - count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name, uj); - if (count) - { - if (!uj) - vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); - prefix_bgp_show_prefix_list (vty, AFI_IP, name, uj); - } - else + if (! peer) { - if (uj) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_boolean_true_add(json_no, "noFuntionalOutput"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "No functional output%s", VTY_NEWLINE); + vty_out (vty, "No such neighbor%s", VTY_NEWLINE); + return CMD_WARNING; } - return CMD_SUCCESS; + if (argv_find (argv, argc, "received-routes", &idx)) + rcvd = 1; + if (argv_find (argv, argc, "advertised-routes", &idx)) + rcvd = 0; + if (argv_find (argv, argc, "route-map", &idx)) + rmap_name = argv[++idx]->arg; + + return peer_adj_routes (vty, peer, afi, safi, rcvd, rmap_name, uj); } -DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, - show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, - "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", +DEFUN (show_ip_bgp_neighbor_received_prefix_filter, + show_ip_bgp_neighbor_received_prefix_filter_cmd, + "show [ip] bgp [<ipv4|ipv6> [unicast]] neighbors <A.B.C.D|X:X::X:X|WORD> received prefix-filter [json]", SHOW_STR IP_STR BGP_STR - "Address family\n" - "Address Family modifier\n" + "Address Family\n" + "Address Family\n" "Address Family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" @@ -13139,185 +9545,41 @@ DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, "Display the prefixlist filter\n" "JavaScript Object Notation\n") { + afi_t afi = AFI_IP6; + safi_t safi = SAFI_UNICAST; + char *peerstr = NULL; + char name[BUFSIZ]; union sockunion su; struct peer *peer; int count, ret; - u_char uj = use_json(argc, argv); - ret = str2sockunion (argv[1], &su); - if (ret < 0) - { - peer = peer_lookup_by_conf_if (NULL, argv[1]); - if (! peer) - { - if (uj) - { - json_object *json_no = NULL; - json_object *json_sub = NULL; - json_no = json_object_new_object(); - json_sub = json_object_new_object(); - json_object_string_add(json_no, "warning", "Malformed address or name"); - json_object_string_add(json_sub, "warningCause", argv[1]); - json_object_object_add(json_no, "detail", json_sub); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "%% Malformed address or name: %s%s", argv[1], VTY_NEWLINE); - return CMD_WARNING; - } - } - else - { - peer = peer_lookup (NULL, &su); - if (! peer) - { - if (uj) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "Peer not found"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "No peer%s", VTY_NEWLINE); - return CMD_WARNING; - } - } + int idx = 0; - if (strncmp (argv[0], "m", 1) == 0) - { - sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); - count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name, uj); - if (count) - { - if (!uj) - vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); - prefix_bgp_show_prefix_list (vty, AFI_IP, name, uj); - } - else - { - if (uj) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_boolean_true_add(json_no, "noFuntionalOutput"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "No functional output%s", VTY_NEWLINE); - } - } - else - { - sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); - count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name, uj); - if (count) - { - if (!uj) - vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); - prefix_bgp_show_prefix_list (vty, AFI_IP, name, uj); - } - else - { - if (uj) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_boolean_true_add(json_no, "noFuntionalOutput"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "No functional output%s", VTY_NEWLINE); - } - } + /* show [ip] bgp */ + if (argv_find (argv, argc, "ip", &idx)) + afi = AFI_IP; + /* [<ipv4|ipv6> [unicast]] */ + if (argv_find (argv, argc, "ipv4", &idx)) + afi = AFI_IP; + if (argv_find (argv, argc, "ipv6", &idx)) + afi = AFI_IP6; + /* neighbors <A.B.C.D|X:X::X:X|WORD> */ + argv_find (argv, argc, "neighbors", &idx); + peerstr = argv[++idx]->arg; - return CMD_SUCCESS; -} -#ifdef HAVE_IPV6 -DEFUN (show_bgp_neighbor_received_routes, - show_bgp_neighbor_received_routes_cmd, - "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", - SHOW_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the received routes from neighbor\n" - "JavaScript Object Notation\n") -{ - struct peer *peer; - const char *rmap_name = NULL; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[0], uj); - - if (! peer) - return CMD_WARNING; - - if (argc == 3 || (argc == 2 && argv[1] && strcmp(argv[1], "json") != 0)) - rmap_name = argv[1]; - - return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1, rmap_name, uj); -} - -ALIAS (show_bgp_neighbor_received_routes, - show_bgp_ipv6_neighbor_received_routes_cmd, - "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", - SHOW_STR - BGP_STR - "Address family\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the received routes from neighbor\n" - "JavaScript Object Notation\n") - -DEFUN (show_bgp_neighbor_received_prefix_filter, - show_bgp_neighbor_received_prefix_filter_cmd, - "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", - SHOW_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display information received from a BGP neighbor\n" - "Display the prefixlist filter\n" - "JavaScript Object Notation\n") -{ - char name[BUFSIZ]; - union sockunion su; - struct peer *peer; - int count, ret; - u_char uj = use_json(argc, argv); - - ret = str2sockunion (argv[0], &su); + ret = str2sockunion (peerstr, &su); if (ret < 0) { - peer = peer_lookup_by_conf_if (NULL, argv[0]); + peer = peer_lookup_by_conf_if (NULL, peerstr); if (! peer) { if (uj) - { - json_object *json_no = NULL; - json_object *json_sub = NULL; - json_no = json_object_new_object(); - json_sub = json_object_new_object(); - json_object_string_add(json_no, "warning", "Malformed address or name"); - json_object_string_add(json_sub, "warningCause", argv[0]); - json_object_object_add(json_no, "detail", json_sub); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } + vty_out (vty, "{}%s", VTY_NEWLINE); else - vty_out (vty, "%% Malformed address or name: %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "%% Malformed address or name: %s%s", peerstr, VTY_NEWLINE); return CMD_WARNING; } } @@ -13327,37 +9589,25 @@ DEFUN (show_bgp_neighbor_received_prefix_filter, if (! peer) { if (uj) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "No Peer"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } + vty_out (vty, "{}%s", VTY_NEWLINE); else vty_out (vty, "No peer%s", VTY_NEWLINE); return CMD_WARNING; } } - sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); - count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name, uj); + sprintf (name, "%s.%d.%d", peer->host, afi, safi); + count = prefix_bgp_show_prefix_list (NULL, afi, name, uj); if (count) { if (!uj) - vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); - prefix_bgp_show_prefix_list (vty, AFI_IP6, name, uj); + vty_out (vty, "Address Family: %s%s", afi_safi_print(afi, safi), VTY_NEWLINE); + prefix_bgp_show_prefix_list (vty, afi, name, uj); } else { if (uj) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_boolean_true_add(json_no, "noFuntionalOutput"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } + vty_out (vty, "{}%s", VTY_NEWLINE); else vty_out (vty, "No functional output%s", VTY_NEWLINE); } @@ -13365,167 +9615,6 @@ DEFUN (show_bgp_neighbor_received_prefix_filter, return CMD_SUCCESS; } -ALIAS (show_bgp_neighbor_received_prefix_filter, - show_bgp_ipv6_neighbor_received_prefix_filter_cmd, - "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", - SHOW_STR - BGP_STR - "Address family\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display information received from a BGP neighbor\n" - "Display the prefixlist filter\n" - "JavaScript Object Notation\n") - -/* old command */ -ALIAS (show_bgp_neighbor_received_routes, - ipv6_bgp_neighbor_received_routes_cmd, - "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", - SHOW_STR - IPV6_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the received routes from neighbor\n" - "JavaScript Object Notation\n") - -/* old command */ -DEFUN (ipv6_mbgp_neighbor_received_routes, - ipv6_mbgp_neighbor_received_routes_cmd, - "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", - SHOW_STR - IPV6_STR - MBGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the received routes from neighbor\n" - "JavaScript Object Notation\n") -{ - struct peer *peer; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[0], uj); - if (! peer) - return CMD_WARNING; - - bgp_show_ipv6_bgp_deprecate_warning(vty); - return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1, NULL, uj); -} - -DEFUN (show_bgp_instance_neighbor_received_prefix_filter, - show_bgp_instance_neighbor_received_prefix_filter_cmd, - "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display information received from a BGP neighbor\n" - "Display the prefixlist filter\n" - "JavaScript Object Notation\n") -{ - char name[BUFSIZ]; - union sockunion su; - struct peer *peer; - struct bgp *bgp; - int count, ret; - u_char uj = use_json(argc, argv); - - /* BGP structure lookup. */ - bgp = bgp_lookup_by_name (argv[1]); - if (bgp == NULL) - { - if (uj) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "Can't find BGP view"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "Can't find BGP instance %s%s", argv[1], VTY_NEWLINE); - return CMD_WARNING; - } - - ret = str2sockunion (argv[2], &su); - if (ret < 0) - { - peer = peer_lookup_by_conf_if (bgp, argv[2]); - if (! peer) - { - if (uj) - { - json_object *json_no = NULL; - json_object *json_sub = NULL; - json_no = json_object_new_object(); - json_sub = json_object_new_object(); - json_object_string_add(json_no, "warning", "Malformed address or name"); - json_object_string_add(json_sub, "warningCause", argv[2]); - json_object_object_add(json_no, "detail", json_sub); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "%% Malformed address or name: %s%s", argv[2], VTY_NEWLINE); - return CMD_WARNING; - } - } - else - { - peer = peer_lookup (bgp, &su); - if (! peer) - { - if (uj) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_boolean_true_add(json_no, "noPeer"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "No peer%s", VTY_NEWLINE); - return CMD_WARNING; - } - - } - - sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); - count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name, uj); - if (count) - { - if (!uj) - vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); - prefix_bgp_show_prefix_list (vty, AFI_IP6, name, uj); - } - - return CMD_SUCCESS; -} -ALIAS (show_bgp_instance_neighbor_received_prefix_filter, - show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display information received from a BGP neighbor\n" - "Display the prefixlist filter\n" - "JavaScript Object NOtation\n") -#endif /* HAVE_IPV6 */ - static int bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, enum bgp_show_type type, u_char use_json) @@ -13550,386 +9639,83 @@ bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, DEFUN (show_ip_bgp_neighbor_routes, show_ip_bgp_neighbor_routes_cmd, - "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", - SHOW_STR - IP_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display routes learned from neighbor\n" - "JavaScript Object Notation\n") -{ - struct peer *peer; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[0], uj); - if (! peer) - return CMD_WARNING; - - return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, - bgp_show_type_neighbor, uj); -} - -DEFUN (show_ip_bgp_instance_neighbor_routes, - show_ip_bgp_instance_neighbor_routes_cmd, - "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", + "show [ip] bgp [<view|vrf> WORD] [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] neighbors <A.B.C.D|X:X::X:X|WORD> <flap-statistics|dampened-routes|routes> [json]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display routes learned from neighbor\n" - "JavaScript Object Notation\n") -{ - struct peer *peer; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); - if (! peer) - return CMD_WARNING; - - return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, - bgp_show_type_neighbor, uj); -} - -DEFUN (show_ip_bgp_neighbor_flap, - show_ip_bgp_neighbor_flap_cmd, - "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", - SHOW_STR - IP_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display flap statistics of the routes learned from neighbor\n" - "JavaScript Object Notation\n") -{ - struct peer *peer; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[0], uj); - if (! peer) - return CMD_WARNING; - - return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, - bgp_show_type_flap_neighbor, uj); -} - -DEFUN (show_ip_bgp_neighbor_damp, - show_ip_bgp_neighbor_damp_cmd, - "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", - SHOW_STR - IP_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the dampened routes received from neighbor\n" - "JavaScript Object Notation\n") -{ - struct peer *peer; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[0], uj); - if (! peer) - return CMD_WARNING; - - return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, - bgp_show_type_damp_neighbor, uj); -} - -DEFUN (show_ip_bgp_ipv4_neighbor_routes, - show_ip_bgp_ipv4_neighbor_routes_cmd, - "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" + "Address Family\n" + "Address Family modifier\n" + "Address Family modifier\n" + "Address Family\n" + "Address Family modifier\n" + "Address Family\n" + "Address Family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" "Neighbor on bgp configured interface\n" - "Display routes learned from neighbor\n" - "JavaScript Object Notation\n") -{ - struct peer *peer; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[1], uj); - if (! peer) - return CMD_WARNING; - - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, - bgp_show_type_neighbor, uj); - - return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, - bgp_show_type_neighbor, uj); -} - -#ifdef HAVE_IPV6 -DEFUN (show_bgp_instance_neighbor_routes, - show_bgp_instance_neighbor_routes_cmd, - "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display routes learned from neighbor\n" - "JavaScript Object Notation\n") -{ - struct peer *peer; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); - if (! peer) - return CMD_WARNING; - - return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, - bgp_show_type_neighbor, uj); -} - -ALIAS (show_bgp_instance_neighbor_routes, - show_bgp_instance_ipv6_neighbor_routes_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display routes learned from neighbor\n" - "JavaScript Object Notation\n") - -DEFUN (show_bgp_instance_neighbor_damp, - show_bgp_instance_neighbor_damp_cmd, - "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" + "Display flap statistics of the routes learned from neighbor\n" "Display the dampened routes received from neighbor\n" + "Display routes learned from neighbor\n" "JavaScript Object Notation\n") { - struct peer *peer; - u_char uj = use_json(argc, argv); + char *vrf = NULL; + char *peerstr = NULL; - if ((argc == 4 && argv[3] && strcmp(argv[3], "json") == 0) - || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) - peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); - else - peer = peer_lookup_in_view (vty, NULL, argv[1], uj); - - if (! peer) - return CMD_WARNING; - - return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, - bgp_show_type_damp_neighbor, uj); -} - -ALIAS (show_bgp_instance_neighbor_damp, - show_bgp_instance_ipv6_neighbor_damp_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the dampened routes received from neighbor\n" - "JavaScript Object Notation\n") - -DEFUN (show_bgp_instance_neighbor_flap, - show_bgp_instance_neighbor_flap_cmd, - "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display flap statistics of the routes learned from neighbor\n" - "JavaScript Object Notation\n") -{ + afi_t afi = AFI_IP6; + safi_t safi = SAFI_UNICAST; struct peer *peer; - u_char uj = use_json(argc, argv); - - if ((argc == 4 && argv[3] && strcmp(argv[3], "json") == 0) - || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) - peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); - else - peer = peer_lookup_in_view (vty, NULL, argv[1], uj); - - if (! peer) - return CMD_WARNING; - - return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, - bgp_show_type_flap_neighbor, uj); -} + enum bgp_show_type sh_type = bgp_show_type_neighbor; + + int idx = 0; + + /* show [ip] bgp */ + if (argv_find (argv, argc, "ip", &idx)) + afi = AFI_IP; + /* [<view|vrf> WORD] */ + if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) + vrf = argv[++idx]->arg; + /* [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] */ + if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) + { + afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; + if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) + safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST; + } + else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) + { + afi = AFI_IP; + safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN; + // advance idx if necessary + argv_find (argv, argc, "unicast", &idx); + } + /* neighbors <A.B.C.D|X:X::X:X|WORD> */ + argv_find (argv, argc, "neighbors", &idx); + peerstr = argv[++idx]->arg; -ALIAS (show_bgp_instance_neighbor_flap, - show_bgp_instance_ipv6_neighbor_flap_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display flap statistics of the routes learned from neighbor\n" - "JavaScript Object Notation\n") - -DEFUN (show_bgp_neighbor_routes, - show_bgp_neighbor_routes_cmd, - "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", - SHOW_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display routes learned from neighbor\n" - "JavaScript Object Notation\n") -{ - struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[0], uj); + peer = peer_lookup_in_view (vty, vrf, peerstr, uj); if (! peer) - return CMD_WARNING; - - return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, - bgp_show_type_neighbor, uj); -} - - -ALIAS (show_bgp_neighbor_routes, - show_bgp_ipv6_neighbor_routes_cmd, - "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", - SHOW_STR - BGP_STR - "Address family\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display routes learned from neighbor\n" - "JavaScript Object Notation\n") - -/* old command */ -ALIAS (show_bgp_neighbor_routes, - ipv6_bgp_neighbor_routes_cmd, - "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", - SHOW_STR - IPV6_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display routes learned from neighbor\n" - "JavaScript Object Notation\n") + { + vty_out (vty, "No such neighbor%s", VTY_NEWLINE); + return CMD_WARNING; + } -/* old command */ -DEFUN (ipv6_mbgp_neighbor_routes, - ipv6_mbgp_neighbor_routes_cmd, - "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", - SHOW_STR - IPV6_STR - MBGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display routes learned from neighbor\n" - "JavaScript Object Notation\n") -{ - struct peer *peer; - u_char uj = use_json(argc, argv); + if (argv_find (argv, argc, "flap-statistics", &idx)) + sh_type = bgp_show_type_flap_neighbor; + else if (argv_find (argv, argc, "dampened-routes", &idx)) + sh_type = bgp_show_type_damp_neighbor; + else if (argv_find (argv, argc, "routes", &idx)) + sh_type = bgp_show_type_neighbor; - peer = peer_lookup_in_view (vty, NULL, argv[0], uj); - if (! peer) - return CMD_WARNING; - - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, - bgp_show_type_neighbor, uj); + return bgp_show_neighbor_route (vty, peer, afi, safi, sh_type, uj); } -ALIAS (show_bgp_instance_neighbor_flap, - show_bgp_neighbor_flap_cmd, - "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", - SHOW_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display flap statistics of the routes learned from neighbor\n" - "JavaScript Object Notation\n") - -ALIAS (show_bgp_instance_neighbor_flap, - show_bgp_ipv6_neighbor_flap_cmd, - "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", - SHOW_STR - BGP_STR - "Address family\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display flap statistics of the routes learned from neighbor\n" - "JavaScript Object Notation\n") - -ALIAS (show_bgp_instance_neighbor_damp, - show_bgp_neighbor_damp_cmd, - "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", - SHOW_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the dampened routes received from neighbor\n" - "JavaScript Object Notation\n") - -ALIAS (show_bgp_instance_neighbor_damp, - show_bgp_ipv6_neighbor_damp_cmd, - "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", - SHOW_STR - BGP_STR - "Address family\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display the dampened routes received from neighbor\n" - "JavaScript Object Notation\n") - -#endif /* HAVE_IPV6 */ - struct bgp_table *bgp_distance_table[AFI_MAX][SAFI_MAX]; struct bgp_distance @@ -14121,13 +9907,16 @@ bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, afi_t afi, DEFUN (bgp_distance, bgp_distance_cmd, - "distance bgp <1-255> <1-255> <1-255>", + "distance bgp (1-255) (1-255) (1-255)", "Define an administrative distance\n" "BGP distance\n" "Distance for routes external to the AS\n" "Distance for routes internal to the AS\n" "Distance for local routes\n") { + int idx_number = 2; + int idx_number_2 = 3; + int idx_number_3 = 4; struct bgp *bgp; afi_t afi; safi_t safi; @@ -14136,15 +9925,15 @@ DEFUN (bgp_distance, afi = bgp_node_afi (vty); safi = bgp_node_safi (vty); - bgp->distance_ebgp[afi][safi] = atoi (argv[0]); - bgp->distance_ibgp[afi][safi] = atoi (argv[1]); - bgp->distance_local[afi][safi] = atoi (argv[2]); + bgp->distance_ebgp[afi][safi] = atoi (argv[idx_number]->arg); + bgp->distance_ibgp[afi][safi] = atoi (argv[idx_number_2]->arg); + bgp->distance_local[afi][safi] = atoi (argv[idx_number_3]->arg); return CMD_SUCCESS; } DEFUN (no_bgp_distance, no_bgp_distance_cmd, - "no distance bgp <1-255> <1-255> <1-255>", + "no distance bgp [(1-255) (1-255) (1-255)]", NO_STR "Define an administrative distance\n" "BGP distance\n" @@ -14166,112 +9955,116 @@ DEFUN (no_bgp_distance, return CMD_SUCCESS; } -ALIAS (no_bgp_distance, - no_bgp_distance2_cmd, - "no distance bgp", - NO_STR - "Define an administrative distance\n" - "BGP distance\n") DEFUN (bgp_distance_source, bgp_distance_source_cmd, - "distance <1-255> A.B.C.D/M", + "distance (1-255) A.B.C.D/M", "Define an administrative distance\n" "Administrative distance\n" "IP source prefix\n") { - bgp_distance_set (vty, argv[0], argv[1], NULL); + int idx_number = 1; + int idx_ipv4_prefixlen = 2; + bgp_distance_set (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); return CMD_SUCCESS; } DEFUN (no_bgp_distance_source, no_bgp_distance_source_cmd, - "no distance <1-255> A.B.C.D/M", + "no distance (1-255) A.B.C.D/M", NO_STR "Define an administrative distance\n" "Administrative distance\n" "IP source prefix\n") { - bgp_distance_unset (vty, argv[0], argv[1], NULL); + int idx_number = 2; + int idx_ipv4_prefixlen = 3; + bgp_distance_unset (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); return CMD_SUCCESS; } DEFUN (bgp_distance_source_access_list, bgp_distance_source_access_list_cmd, - "distance <1-255> A.B.C.D/M WORD", + "distance (1-255) A.B.C.D/M WORD", "Define an administrative distance\n" "Administrative distance\n" "IP source prefix\n" "Access list name\n") { - bgp_distance_set (vty, argv[0], argv[1], argv[2]); + int idx_number = 1; + int idx_ipv4_prefixlen = 2; + int idx_word = 3; + bgp_distance_set (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); return CMD_SUCCESS; } DEFUN (no_bgp_distance_source_access_list, no_bgp_distance_source_access_list_cmd, - "no distance <1-255> A.B.C.D/M WORD", + "no distance (1-255) A.B.C.D/M WORD", NO_STR "Define an administrative distance\n" "Administrative distance\n" "IP source prefix\n" "Access list name\n") { - bgp_distance_unset (vty, argv[0], argv[1], argv[2]); + int idx_number = 2; + int idx_ipv4_prefixlen = 3; + int idx_word = 4; + bgp_distance_unset (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); return CMD_SUCCESS; } DEFUN (ipv6_bgp_distance_source, ipv6_bgp_distance_source_cmd, - "distance <1-255> X:X::X:X/M", + "distance (1-255) X:X::X:X/M", "Define an administrative distance\n" "Administrative distance\n" "IP source prefix\n") { - bgp_distance_set (vty, argv[0], argv[1], NULL); + bgp_distance_set (vty, argv[1]->arg, argv[2]->arg, NULL); return CMD_SUCCESS; } DEFUN (no_ipv6_bgp_distance_source, no_ipv6_bgp_distance_source_cmd, - "no distance <1-255> X:X::X:X/M", + "no distance (1-255) X:X::X:X/M", NO_STR "Define an administrative distance\n" "Administrative distance\n" "IP source prefix\n") { - bgp_distance_unset (vty, argv[0], argv[1], NULL); + bgp_distance_unset (vty, argv[2]->arg, argv[3]->arg, NULL); return CMD_SUCCESS; } DEFUN (ipv6_bgp_distance_source_access_list, ipv6_bgp_distance_source_access_list_cmd, - "distance <1-255> X:X::X:X/M WORD", + "distance (1-255) X:X::X:X/M WORD", "Define an administrative distance\n" "Administrative distance\n" "IP source prefix\n" "Access list name\n") { - bgp_distance_set (vty, argv[0], argv[1], argv[2]); + bgp_distance_set (vty, argv[1]->arg, argv[2]->arg, argv[3]->arg); return CMD_SUCCESS; } DEFUN (no_ipv6_bgp_distance_source_access_list, no_ipv6_bgp_distance_source_access_list_cmd, - "no distance <1-255> X:X::X:X/M WORD", + "no distance (1-255) X:X::X:X/M WORD", NO_STR "Define an administrative distance\n" "Administrative distance\n" "IP source prefix\n" "Access list name\n") { - bgp_distance_unset (vty, argv[0], argv[1], argv[2]); + bgp_distance_unset (vty, argv[2]->arg, argv[3]->arg, argv[4]->arg); return CMD_SUCCESS; } DEFUN (bgp_damp_set, bgp_damp_set_cmd, - "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", + "bgp dampening [(1-45) [(1-20000) (1-20000) (1-255)]]", "BGP Specific commands\n" "Enable route-flap dampening\n" "Half-life time for the penalty\n" @@ -14279,22 +10072,26 @@ DEFUN (bgp_damp_set, "Value to start suppressing a route\n" "Maximum duration to suppress a stable route\n") { + int idx_half_life = 2; + int idx_reuse = 3; + int idx_suppress = 4; + int idx_max_suppress = 5; struct bgp *bgp; int half = DEFAULT_HALF_LIFE * 60; int reuse = DEFAULT_REUSE; int suppress = DEFAULT_SUPPRESS; int max = 4 * half; - if (argc == 4) + if (argc == 6) { - half = atoi (argv[0]) * 60; - reuse = atoi (argv[1]); - suppress = atoi (argv[2]); - max = atoi (argv[3]) * 60; + half = atoi (argv[idx_half_life]->arg) * 60; + reuse = atoi (argv[idx_reuse]->arg); + suppress = atoi (argv[idx_suppress]->arg); + max = atoi (argv[idx_max_suppress]->arg) * 60; } - else if (argc == 1) + else if (argc == 3) { - half = atoi (argv[0]) * 60; + half = atoi (argv[idx_half_life]->arg) * 60; max = 4 * half; } @@ -14311,35 +10108,9 @@ DEFUN (bgp_damp_set, half, reuse, suppress, max); } -ALIAS (bgp_damp_set, - bgp_damp_set2_cmd, - "bgp dampening <1-45>", - "BGP Specific commands\n" - "Enable route-flap dampening\n" - "Half-life time for the penalty\n") - -ALIAS (bgp_damp_set, - bgp_damp_set3_cmd, - "bgp dampening", - "BGP Specific commands\n" - "Enable route-flap dampening\n") - DEFUN (bgp_damp_unset, bgp_damp_unset_cmd, - "no bgp dampening", - NO_STR - "BGP Specific commands\n" - "Enable route-flap dampening\n") -{ - struct bgp *bgp; - - bgp = vty->index; - return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); -} - -ALIAS (bgp_damp_unset, - bgp_damp_unset2_cmd, - "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", + "no bgp dampening [(1-45) [(1-20000) (1-20000) (1-255)]]", NO_STR "BGP Specific commands\n" "Enable route-flap dampening\n" @@ -14347,57 +10118,13 @@ ALIAS (bgp_damp_unset, "Value to start reusing a route\n" "Value to start suppressing a route\n" "Maximum duration to suppress a stable route\n") - -ALIAS (bgp_damp_unset, - bgp_damp_unset3_cmd, - "no bgp dampening <1-45>", - NO_STR - "BGP Specific commands\n" - "Enable route-flap dampening\n" - "Half-life time for the penalty\n") - -DEFUN (show_ip_bgp_dampened_paths, - show_ip_bgp_dampened_paths_cmd, - "show ip bgp dampened-paths", - SHOW_STR - IP_STR - BGP_STR - "Display paths suppressed due to dampening\n") { - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, - NULL, 0); -} - -ALIAS (show_ip_bgp_dampened_paths, - show_ip_bgp_damp_dampened_paths_cmd, - "show ip bgp dampening dampened-paths", - SHOW_STR - IP_STR - BGP_STR - "Display detailed information about dampening\n" - "Display paths suppressed due to dampening\n") + struct bgp *bgp; -DEFUN (show_ip_bgp_flap_statistics, - show_ip_bgp_flap_statistics_cmd, - "show ip bgp flap-statistics", - SHOW_STR - IP_STR - BGP_STR - "Display flap statistics of routes\n") -{ - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, - bgp_show_type_flap_statistics, NULL, 0); + bgp = vty->index; + return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); } -ALIAS (show_ip_bgp_flap_statistics, - show_ip_bgp_damp_flap_statistics_cmd, - "show ip bgp dampening flap-statistics", - SHOW_STR - IP_STR - BGP_STR - "Display detailed information about dampening\n" - "Display flap statistics of routes\n") - /* Display specified route of BGP table. */ static int bgp_clear_damp_route (struct vty *vty, const char *view_name, @@ -14519,9 +10246,10 @@ DEFUN (clear_ip_bgp_dampening_prefix, IP_STR BGP_STR "Clear route flap dampening information\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") + "IPv4 prefix\n") { - return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, + int idx_ipv4_prefixlen = 4; + return bgp_clear_damp_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1); } @@ -14534,7 +10262,8 @@ DEFUN (clear_ip_bgp_dampening_address, "Clear route flap dampening information\n" "Network to clear damping information\n") { - return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, + int idx_ipv4 = 4; + return bgp_clear_damp_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0); } @@ -14548,10 +10277,12 @@ DEFUN (clear_ip_bgp_dampening_address_mask, "Network to clear damping information\n" "Network mask\n") { + int idx_ipv4 = 4; + int idx_ipv4_2 = 5; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); @@ -14766,33 +10497,11 @@ bgp_route_init (void) install_element (BGP_NODE, &no_bgp_network_cmd); install_element (BGP_NODE, &no_bgp_network_mask_cmd); install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); - install_element (BGP_NODE, &no_bgp_network_route_map_cmd); - install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); - install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); - install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); - install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); - install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); install_element (BGP_NODE, &aggregate_address_cmd); install_element (BGP_NODE, &aggregate_address_mask_cmd); - install_element (BGP_NODE, &aggregate_address_summary_only_cmd); - install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); - install_element (BGP_NODE, &aggregate_address_as_set_cmd); - install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); - install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); - install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); - install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); - install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); install_element (BGP_NODE, &no_aggregate_address_cmd); - install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); - install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); - install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); - install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); install_element (BGP_NODE, &no_aggregate_address_mask_cmd); - install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); - install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); - install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); - install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); /* IPv4 unicast configuration. */ install_element (BGP_IPV4_NODE, &bgp_table_map_cmd); @@ -14806,30 +10515,11 @@ bgp_route_init (void) install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); - install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); - install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); - install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd); install_element (BGP_IPV4_NODE, &aggregate_address_cmd); install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); - install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); - install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); - install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); - install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); - install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); - install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); - install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); - install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); - install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); - install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); - install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); - install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); - install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); - install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); - install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); - install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); /* IPv4 multicast configuration. */ install_element (BGP_IPV4M_NODE, &bgp_table_map_cmd); @@ -14843,148 +10533,33 @@ bgp_route_init (void) install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); - install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); - install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); - install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); - install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); - install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); - install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); - install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); - install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); - install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); - install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); - install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); - install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); - install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); - install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); - install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); - install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); - install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); - install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); - install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); - install_element (VIEW_NODE, &show_ip_bgp_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_all_cmd); install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); install_element (VIEW_NODE, &show_ip_bgp_route_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_route_cmd); - install_element (VIEW_NODE, &show_ip_bgp_route_pathtype_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_route_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); - install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); - install_element (VIEW_NODE, &show_ip_bgp_prefix_pathtype_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_pathtype_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); - install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); - install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_filter_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_route_map_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); - install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); - install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); - install_element (VIEW_NODE, &show_ip_bgp_community_cmd); - install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); - install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); - install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); - install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community_all_cmd); - install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community_cmd); - install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community2_cmd); - install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community3_cmd); - install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community4_cmd); - install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); - install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); - install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); - install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); - install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_community_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); - install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_longer_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); - install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); + + install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_advertised_route_cmd); + install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); + install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); + install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd); + install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd); + + /* Restricted node: VIEW_NODE - (set of dangerous commands) */ + + install_element (VIEW_NODE, &show_ip_bgp_instance_all_cmd); + install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); + install_element (VIEW_NODE, &show_ip_bgp_route_cmd); + install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_advertised_route_cmd); - install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_rmap_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd); - install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_received_routes_cmd); - install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_rmap_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd); - install_element (VIEW_NODE, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd); install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_routes_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd); install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd); - install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd); - install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd); - install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); - install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd); - install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); - install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd); - install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); - install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); - install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); - install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); - install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); - install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); - install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); - install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd); - install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); - install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); - - install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd); - - install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd); /* BGP dampening clear commands */ install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); @@ -15007,230 +10582,57 @@ bgp_route_init (void) install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); install_element (BGP_IPV6_NODE, &no_bgp_table_map_cmd); install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); - install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); - install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); - install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); - /* Old config IPv6 BGP commands. */ - install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); - install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); - - install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); - install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); - install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); - install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); - - install_element (VIEW_NODE, &show_bgp_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); - install_element (VIEW_NODE, &show_bgp_route_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); - install_element (VIEW_NODE, &show_bgp_route_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_route_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_prefix_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); - install_element (VIEW_NODE, &show_bgp_prefix_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_prefix_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_regexp_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); - install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); - install_element (VIEW_NODE, &show_bgp_filter_list_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); - install_element (VIEW_NODE, &show_bgp_route_map_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); - install_element (VIEW_NODE, &show_bgp_community_all_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); - install_element (VIEW_NODE, &show_bgp_community_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); - install_element (VIEW_NODE, &show_bgp_community2_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); - install_element (VIEW_NODE, &show_bgp_community3_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); - install_element (VIEW_NODE, &show_bgp_community4_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); - install_element (VIEW_NODE, &show_bgp_community_exact_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); - install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); - install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); - install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); - install_element (VIEW_NODE, &show_bgp_community_list_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); - install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); - install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); - install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); - install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); - install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); - install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); - install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); - install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); - install_element (VIEW_NODE, &show_bgp_instance_cmd); - install_element (VIEW_NODE, &show_bgp_instance_all_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_cmd); - install_element (VIEW_NODE, &show_bgp_instance_route_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_route_cmd); - install_element (VIEW_NODE, &show_bgp_instance_route_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_route_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_instance_prefix_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_prefix_cmd); - install_element (VIEW_NODE, &show_bgp_instance_prefix_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_prefix_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_instance_prefix_list_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_prefix_list_cmd); - install_element (VIEW_NODE, &show_bgp_instance_filter_list_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_filter_list_cmd); - install_element (VIEW_NODE, &show_bgp_instance_route_map_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_route_map_cmd); - install_element (VIEW_NODE, &show_bgp_instance_community_list_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_community_list_cmd); - install_element (VIEW_NODE, &show_bgp_instance_prefix_longer_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_prefix_longer_cmd); - install_element (VIEW_NODE, &show_bgp_instance_neighbor_advertised_route_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd); - install_element (VIEW_NODE, &show_bgp_instance_neighbor_received_routes_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_received_routes_cmd); - install_element (VIEW_NODE, &show_bgp_instance_neighbor_routes_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_routes_cmd); - install_element (VIEW_NODE, &show_bgp_instance_neighbor_received_prefix_filter_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd); - install_element (VIEW_NODE, &show_bgp_instance_neighbor_flap_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_flap_cmd); - install_element (VIEW_NODE, &show_bgp_instance_neighbor_damp_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_damp_cmd); - /* Statistics */ install_element (ENABLE_NODE, &show_bgp_statistics_cmd); - //install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); - //install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); - - /* old command */ - install_element (VIEW_NODE, &show_ipv6_bgp_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); - - /* old command */ - install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); - install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); - - /* old command */ - install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); - install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); - - /* old command */ - install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); - install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); #endif /* HAVE_IPV6 */ install_element (BGP_NODE, &bgp_distance_cmd); install_element (BGP_NODE, &no_bgp_distance_cmd); - install_element (BGP_NODE, &no_bgp_distance2_cmd); install_element (BGP_NODE, &bgp_distance_source_cmd); install_element (BGP_NODE, &no_bgp_distance_source_cmd); install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); install_element (BGP_IPV4_NODE, &bgp_distance_cmd); install_element (BGP_IPV4_NODE, &no_bgp_distance_cmd); - install_element (BGP_IPV4_NODE, &no_bgp_distance2_cmd); install_element (BGP_IPV4_NODE, &bgp_distance_source_cmd); install_element (BGP_IPV4_NODE, &no_bgp_distance_source_cmd); install_element (BGP_IPV4_NODE, &bgp_distance_source_access_list_cmd); install_element (BGP_IPV4_NODE, &no_bgp_distance_source_access_list_cmd); install_element (BGP_IPV4M_NODE, &bgp_distance_cmd); install_element (BGP_IPV4M_NODE, &no_bgp_distance_cmd); - install_element (BGP_IPV4M_NODE, &no_bgp_distance2_cmd); install_element (BGP_IPV4M_NODE, &bgp_distance_source_cmd); install_element (BGP_IPV4M_NODE, &no_bgp_distance_source_cmd); install_element (BGP_IPV4M_NODE, &bgp_distance_source_access_list_cmd); install_element (BGP_IPV4M_NODE, &no_bgp_distance_source_access_list_cmd); install_element (BGP_IPV6_NODE, &bgp_distance_cmd); install_element (BGP_IPV6_NODE, &no_bgp_distance_cmd); - install_element (BGP_IPV6_NODE, &no_bgp_distance2_cmd); install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_cmd); install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_cmd); install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_access_list_cmd); install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_access_list_cmd); install_element (BGP_IPV6M_NODE, &bgp_distance_cmd); install_element (BGP_IPV6M_NODE, &no_bgp_distance_cmd); - install_element (BGP_IPV6M_NODE, &no_bgp_distance2_cmd); install_element (BGP_IPV6M_NODE, &ipv6_bgp_distance_source_cmd); install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_distance_source_cmd); install_element (BGP_IPV6M_NODE, &ipv6_bgp_distance_source_access_list_cmd); install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_distance_source_access_list_cmd); install_element (BGP_NODE, &bgp_damp_set_cmd); - install_element (BGP_NODE, &bgp_damp_set2_cmd); - install_element (BGP_NODE, &bgp_damp_set3_cmd); install_element (BGP_NODE, &bgp_damp_unset_cmd); - install_element (BGP_NODE, &bgp_damp_unset2_cmd); - install_element (BGP_NODE, &bgp_damp_unset3_cmd); install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); - install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); - install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); - install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); - install_element (BGP_IPV4_NODE, &bgp_damp_unset3_cmd); /* IPv4 Multicast Mode */ install_element (BGP_IPV4M_NODE, &bgp_damp_set_cmd); - install_element (BGP_IPV4M_NODE, &bgp_damp_set2_cmd); - install_element (BGP_IPV4M_NODE, &bgp_damp_set3_cmd); install_element (BGP_IPV4M_NODE, &bgp_damp_unset_cmd); - install_element (BGP_IPV4M_NODE, &bgp_damp_unset2_cmd); } void diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index ebf83a783e..0701415146 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -22,6 +22,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "prefix.h" #include "filter.h" +#include "vty.h" #include "routemap.h" #include "command.h" #include "linklist.h" @@ -110,7 +111,7 @@ o Local extensions set ipv6 next-hop local : Done set as-path exclude : Done -*/ +*/ /* generic value manipulation to be shared in multiple rules */ @@ -332,7 +333,7 @@ struct route_map_rule_cmd route_match_peer_cmd = /* Match function should return 1 if match is success else return zero. */ static route_map_result_t -route_match_ip_address (void *rule, struct prefix *prefix, +route_match_ip_address (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct access_list *alist; @@ -343,7 +344,7 @@ route_match_ip_address (void *rule, struct prefix *prefix, alist = access_list_lookup (AFI_IP, (char *) rule); if (alist == NULL) return RMAP_NOMATCH; - + return (access_list_apply (alist, prefix) == FILTER_DENY ? RMAP_NOMATCH : RMAP_MATCH); } @@ -378,7 +379,7 @@ struct route_map_rule_cmd route_match_ip_address_cmd = /* Match function return 1 if match is success else return zero. */ static route_map_result_t -route_match_ip_next_hop (void *rule, struct prefix *prefix, +route_match_ip_next_hop (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct access_list *alist; @@ -430,7 +431,7 @@ struct route_map_rule_cmd route_match_ip_next_hop_cmd = /* Match function return 1 if match is success else return zero. */ static route_map_result_t -route_match_ip_route_source (void *rule, struct prefix *prefix, +route_match_ip_route_source (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct access_list *alist; @@ -487,7 +488,7 @@ struct route_map_rule_cmd route_match_ip_route_source_cmd = /* `match ip address prefix-list PREFIX_LIST' */ static route_map_result_t -route_match_ip_address_prefix_list (void *rule, struct prefix *prefix, +route_match_ip_address_prefix_list (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct prefix_list *plist; @@ -497,7 +498,7 @@ route_match_ip_address_prefix_list (void *rule, struct prefix *prefix, plist = prefix_list_lookup (AFI_IP, (char *) rule); if (plist == NULL) return RMAP_NOMATCH; - + return (prefix_list_apply (plist, prefix) == PREFIX_DENY ? RMAP_NOMATCH : RMAP_MATCH); } @@ -694,7 +695,7 @@ struct route_map_rule_cmd route_match_local_pref_cmd = /* Match function return 1 if match is success else return zero. */ static route_map_result_t -route_match_metric (void *rule, struct prefix *prefix, +route_match_metric (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct rmap_value *rv; @@ -722,10 +723,10 @@ struct route_map_rule_cmd route_match_metric_cmd = /* Match function for as-path match. I assume given object is */ static route_map_result_t -route_match_aspath (void *rule, struct prefix *prefix, +route_match_aspath (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { - + struct as_list *as_list; struct bgp_info *bgp_info; @@ -758,7 +759,7 @@ route_match_aspath_free (void *rule) } /* Route map commands for aspath matching. */ -struct route_map_rule_cmd route_match_aspath_cmd = +struct route_map_rule_cmd route_match_aspath_cmd = { "as-path", route_match_aspath, @@ -775,14 +776,14 @@ struct rmap_community /* Match function for community match. */ static route_map_result_t -route_match_community (void *rule, struct prefix *prefix, +route_match_community (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct community_list *list; struct bgp_info *bgp_info; struct rmap_community *rcom; - if (type == RMAP_BGP) + if (type == RMAP_BGP) { bgp_info = object; rcom = rule; @@ -837,12 +838,12 @@ route_match_community_free (void *rule) { struct rmap_community *rcom = rule; - XFREE (MTYPE_ROUTE_MAP_COMPILED, rcom->name); + XFREE (MTYPE_ROUTE_MAP_COMPILED, rcom->name); XFREE (MTYPE_ROUTE_MAP_COMPILED, rcom); } /* Route map commands for community matching. */ -struct route_map_rule_cmd route_match_community_cmd = +struct route_map_rule_cmd route_match_community_cmd = { "community", route_match_community, @@ -852,19 +853,19 @@ struct route_map_rule_cmd route_match_community_cmd = /* Match function for extcommunity match. */ static route_map_result_t -route_match_ecommunity (void *rule, struct prefix *prefix, +route_match_ecommunity (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct community_list *list; struct bgp_info *bgp_info; - if (type == RMAP_BGP) + if (type == RMAP_BGP) { bgp_info = object; - + if (!bgp_info->attr->extra) return RMAP_NOMATCH; - + list = community_list_lookup (bgp_clist, (char *) rule, EXTCOMMUNITY_LIST_MASTER); if (! list) @@ -891,7 +892,7 @@ route_match_ecommunity_free (void *rule) } /* Route map commands for community matching. */ -struct route_map_rule_cmd route_match_ecommunity_cmd = +struct route_map_rule_cmd route_match_ecommunity_cmd = { "extcommunity", route_match_ecommunity, @@ -904,7 +905,7 @@ struct route_map_rule_cmd route_match_ecommunity_cmd = /* `match origin' */ static route_map_result_t -route_match_origin (void *rule, struct prefix *prefix, +route_match_origin (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { u_char *origin; @@ -914,7 +915,7 @@ route_match_origin (void *rule, struct prefix *prefix, { origin = rule; bgp_info = object; - + if (bgp_info->attr->origin == *origin) return RMAP_MATCH; } @@ -1128,7 +1129,7 @@ route_set_ip_nexthop (void *rule, struct prefix *prefix, { if ((CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN) || CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT)) - && peer->su_remote + && peer->su_remote && sockunion_family (peer->su_remote) == AF_INET) { bgp_info->attr->nexthop.s_addr = sockunion2ip (peer->su_remote); @@ -1202,7 +1203,7 @@ route_set_ip_nexthop_free (void *rule) if (rins->address) XFREE (MTYPE_ROUTE_MAP_COMPILED, rins->address); - + XFREE (MTYPE_ROUTE_MAP_COMPILED, rins); } @@ -1231,8 +1232,8 @@ route_set_local_pref (void *rule, struct prefix *prefix, /* Fetch routemap's rule information. */ rv = rule; bgp_info = object; - - /* Set local preference value. */ + + /* Set local preference value. */ if (bgp_info->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) locpref = bgp_info->attr->local_pref; @@ -1244,7 +1245,7 @@ route_set_local_pref (void *rule, struct prefix *prefix, } /* Set local preference rule structure. */ -struct route_map_rule_cmd route_set_local_pref_cmd = +struct route_map_rule_cmd route_set_local_pref_cmd = { "local-preference", route_set_local_pref, @@ -1268,8 +1269,8 @@ route_set_weight (void *rule, struct prefix *prefix, route_map_object_t type, /* Fetch routemap's rule information. */ rv = rule; bgp_info = object; - - /* Set weight value. */ + + /* Set weight value. */ weight = route_value_adjust(rv, 0, bgp_info->peer); if (weight) (bgp_attr_extra_get (bgp_info->attr))->weight = weight; @@ -1281,7 +1282,7 @@ route_set_weight (void *rule, struct prefix *prefix, route_map_object_t type, } /* Set local preference rule structure. */ -struct route_map_rule_cmd route_set_weight_cmd = +struct route_map_rule_cmd route_set_weight_cmd = { "weight", route_set_weight, @@ -1293,7 +1294,7 @@ struct route_map_rule_cmd route_set_weight_cmd = /* Set metric to attribute. */ static route_map_result_t -route_set_metric (void *rule, struct prefix *prefix, +route_set_metric (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct rmap_value *rv; @@ -1316,7 +1317,7 @@ route_set_metric (void *rule, struct prefix *prefix, } /* Set metric rule structure. */ -struct route_map_rule_cmd route_set_metric_cmd = +struct route_map_rule_cmd route_set_metric_cmd = { "metric", route_set_metric, @@ -1337,7 +1338,7 @@ route_set_aspath_prepend (void *rule, struct prefix *prefix, route_map_object_t if (type == RMAP_BGP) { binfo = object; - + if (binfo->attr->aspath->refcnt) new = aspath_dup (binfo->attr->aspath); else @@ -1381,7 +1382,7 @@ route_set_aspath_prepend_free (void *rule) /* Set as-path prepend rule structure. */ -struct route_map_rule_cmd route_set_aspath_prepend_cmd = +struct route_map_rule_cmd route_set_aspath_prepend_cmd = { "as-path prepend", route_set_aspath_prepend, @@ -1415,7 +1416,7 @@ route_set_aspath_exclude (void *rule, struct prefix *dummy, route_map_object_t t } /* Set ASn exlude rule structure. */ -struct route_map_rule_cmd route_set_aspath_exclude_cmd = +struct route_map_rule_cmd route_set_aspath_exclude_cmd = { "as-path exclude", route_set_aspath_exclude, @@ -1442,7 +1443,7 @@ route_set_community (void *rule, struct prefix *prefix, struct community *new = NULL; struct community *old; struct community *merge; - + if (type == RMAP_BGP) { rcs = rule; @@ -1465,8 +1466,8 @@ route_set_community (void *rule, struct prefix *prefix, if (rcs->additive && old) { merge = community_merge (community_dup (old), rcs->com); - - /* HACK: if the old community is not intern'd, + + /* HACK: if the old community is not intern'd, * we should free it here, or all reference to it may be lost. * Really need to cleanup attribute caching sometime. */ @@ -1477,7 +1478,7 @@ route_set_community (void *rule, struct prefix *prefix, } else new = community_dup (rcs->com); - + /* will be interned by caller if required */ attr->community = new; @@ -1496,7 +1497,7 @@ route_set_community_compile (const char *arg) char *sp; int additive = 0; int none = 0; - + if (strcmp (arg, "none") == 0) none = 1; else @@ -1518,12 +1519,12 @@ route_set_community_compile (const char *arg) if (! com) return NULL; } - + rcs = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct rmap_com_set)); rcs->com = com; rcs->additive = additive; rcs->none = none; - + return rcs; } @@ -1539,7 +1540,7 @@ route_set_community_free (void *rule) } /* Set community rule structure. */ -struct route_map_rule_cmd route_set_community_cmd = +struct route_map_rule_cmd route_set_community_cmd = { "community", route_set_community, @@ -1652,10 +1653,10 @@ route_set_ecommunity (void *rule, struct prefix *prefix, { ecom = rule; bgp_info = object; - + if (! ecom) return RMAP_OKAY; - + /* We assume additive for Extended Community. */ old_ecom = (bgp_attr_extra_get (bgp_info->attr))->ecommunity; @@ -1700,7 +1701,7 @@ route_set_ecommunity_free (void *rule) } /* Set community rule structure. */ -struct route_map_rule_cmd route_set_ecommunity_rt_cmd = +struct route_map_rule_cmd route_set_ecommunity_rt_cmd = { "extcommunity rt", route_set_ecommunity, @@ -1719,12 +1720,12 @@ route_set_ecommunity_soo_compile (const char *arg) ecom = ecommunity_str2com (arg, ECOMMUNITY_SITE_ORIGIN, 0); if (! ecom) return NULL; - + return ecommunity_intern (ecom); } /* Set community rule structure. */ -struct route_map_rule_cmd route_set_ecommunity_soo_cmd = +struct route_map_rule_cmd route_set_ecommunity_soo_cmd = { "extcommunity soo", route_set_ecommunity, @@ -1745,7 +1746,7 @@ route_set_origin (void *rule, struct prefix *prefix, route_map_object_t type, vo { origin = rule; bgp_info = object; - + bgp_info->attr->origin = *origin; } @@ -1778,7 +1779,7 @@ route_set_origin_free (void *rule) } /* Set origin rule structure. */ -struct route_map_rule_cmd route_set_origin_cmd = +struct route_map_rule_cmd route_set_origin_cmd = { "origin", route_set_origin, @@ -1819,7 +1820,7 @@ route_set_atomic_aggregate_free (void *rule) } /* Set atomic aggregate rule structure. */ -struct route_map_rule_cmd route_set_atomic_aggregate_cmd = +struct route_map_rule_cmd route_set_atomic_aggregate_cmd = { "atomic-aggregate", route_set_atomic_aggregate, @@ -1835,7 +1836,7 @@ struct aggregator }; static route_map_result_t -route_set_aggregator_as (void *rule, struct prefix *prefix, +route_set_aggregator_as (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct bgp_info *bgp_info; @@ -1847,7 +1848,7 @@ route_set_aggregator_as (void *rule, struct prefix *prefix, bgp_info = object; aggregator = rule; ae = bgp_attr_extra_get (bgp_info->attr); - + ae->aggregator_as = aggregator->as; ae->aggregator_addr = aggregator->address; bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR); @@ -1878,7 +1879,7 @@ route_set_aggregator_as_free (void *rule) XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); } -struct route_map_rule_cmd route_set_aggregator_as_cmd = +struct route_map_rule_cmd route_set_aggregator_as_cmd = { "aggregator as", route_set_aggregator_as, @@ -1923,7 +1924,7 @@ static struct route_map_rule_cmd route_set_tag_cmd = /* `match ipv6 address IP_ACCESS_LIST' */ static route_map_result_t -route_match_ipv6_address (void *rule, struct prefix *prefix, +route_match_ipv6_address (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct access_list *alist; @@ -1933,7 +1934,7 @@ route_match_ipv6_address (void *rule, struct prefix *prefix, alist = access_list_lookup (AFI_IP6, (char *) rule); if (alist == NULL) return RMAP_NOMATCH; - + return (access_list_apply (alist, prefix) == FILTER_DENY ? RMAP_NOMATCH : RMAP_MATCH); } @@ -1964,7 +1965,7 @@ struct route_map_rule_cmd route_match_ipv6_address_cmd = /* `match ipv6 next-hop IP_ADDRESS' */ static route_map_result_t -route_match_ipv6_next_hop (void *rule, struct prefix *prefix, +route_match_ipv6_next_hop (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct in6_addr *addr = rule; @@ -1973,10 +1974,10 @@ route_match_ipv6_next_hop (void *rule, struct prefix *prefix, if (type == RMAP_BGP) { bgp_info = object; - + if (!bgp_info->attr->extra) return RMAP_NOMATCH; - + if (IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_global, addr)) return RMAP_MATCH; @@ -2025,7 +2026,7 @@ struct route_map_rule_cmd route_match_ipv6_next_hop_cmd = /* `match ipv6 address prefix-list PREFIX_LIST' */ static route_map_result_t -route_match_ipv6_address_prefix_list (void *rule, struct prefix *prefix, +route_match_ipv6_address_prefix_list (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct prefix_list *plist; @@ -2035,7 +2036,7 @@ route_match_ipv6_address_prefix_list (void *rule, struct prefix *prefix, plist = prefix_list_lookup (AFI_IP6, (char *) rule); if (plist == NULL) return RMAP_NOMATCH; - + return (prefix_list_apply (plist, prefix) == PREFIX_DENY ? RMAP_NOMATCH : RMAP_MATCH); } @@ -2066,7 +2067,7 @@ struct route_map_rule_cmd route_match_ipv6_address_prefix_list_cmd = /* Set nexthop to object. ojbect must be pointer to struct attr. */ static route_map_result_t -route_set_ipv6_nexthop_global (void *rule, struct prefix *prefix, +route_set_ipv6_nexthop_global (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct in6_addr *address; @@ -2077,8 +2078,8 @@ route_set_ipv6_nexthop_global (void *rule, struct prefix *prefix, /* Fetch routemap's rule information. */ address = rule; bgp_info = object; - - /* Set next hop value. */ + + /* Set next hop value. */ (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global = *address; /* Set nexthop length. */ @@ -2194,7 +2195,7 @@ struct route_map_rule_cmd route_set_ipv6_nexthop_prefer_global_cmd = /* Set nexthop to object. ojbect must be pointer to struct attr. */ static route_map_result_t -route_set_ipv6_nexthop_local (void *rule, struct prefix *prefix, +route_set_ipv6_nexthop_local (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct in6_addr *address; @@ -2205,10 +2206,10 @@ route_set_ipv6_nexthop_local (void *rule, struct prefix *prefix, /* Fetch routemap's rule information. */ address = rule; bgp_info = object; - - /* Set next hop value. */ + + /* Set next hop value. */ (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_local = *address; - + /* Set nexthop length. */ if (bgp_info->attr->extra->mp_nexthop_len != BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) bgp_info->attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; @@ -2349,7 +2350,7 @@ struct route_map_rule_cmd route_set_ipv6_nexthop_peer_cmd = /* `set vpnv4 nexthop A.B.C.D' */ static route_map_result_t -route_set_vpnv4_nexthop (void *rule, struct prefix *prefix, +route_set_vpnv4_nexthop (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct in_addr *address; @@ -2360,8 +2361,8 @@ route_set_vpnv4_nexthop (void *rule, struct prefix *prefix, /* Fetch routemap's rule information. */ address = rule; bgp_info = object; - - /* Set next hop value. */ + + /* Set next hop value. */ (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global_in = *address; (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_len = 4; } @@ -2412,11 +2413,11 @@ route_set_originator_id (void *rule, struct prefix *prefix, route_map_object_t t struct in_addr *address; struct bgp_info *bgp_info; - if (type == RMAP_BGP) + if (type == RMAP_BGP) { address = rule; bgp_info = object; - + bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID); (bgp_attr_extra_get (bgp_info->attr))->originator_id = *address; } @@ -2452,7 +2453,7 @@ route_set_originator_id_free (void *rule) } /* Set originator-id rule structure. */ -struct route_map_rule_cmd route_set_originator_id_cmd = +struct route_map_rule_cmd route_set_originator_id_cmd = { "originator-id", route_set_originator_id, @@ -2546,52 +2547,6 @@ bgp_route_match_delete (struct vty *vty, struct route_map_index *index, return CMD_SUCCESS; } -/* Add bgp route map rule. */ -static int -bgp_route_set_add (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_add_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% BGP Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% BGP Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - -/* Delete bgp route map rule. */ -static int -bgp_route_set_delete (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_delete_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% BGP Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% BGP Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - /* * This is the workhorse routine for processing in/out routemap * modifications. @@ -2934,18 +2889,19 @@ bgp_route_map_event (route_map_event_t event, const char *rmap_name) DEFUN (match_peer, match_peer_cmd, - "match peer (A.B.C.D|X:X::X:X)", + "match peer <A.B.C.D|X:X::X:X>", MATCH_STR "Match peer address\n" "IP address of peer\n" "IPv6 address of peer\n") { - return bgp_route_match_add (vty, vty->index, "peer", argv[0], + int idx_ip = 2; + return bgp_route_match_add (vty, vty->index, "peer", argv[idx_ip]->arg, RMAP_EVENT_MATCH_ADDED); } DEFUN (match_peer_local, - match_peer_local_cmd, + match_peer_local_cmd, "match peer local", MATCH_STR "Match peer address\n" @@ -2957,155 +2913,58 @@ DEFUN (match_peer_local, DEFUN (no_match_peer, no_match_peer_cmd, - "no match peer", - NO_STR - MATCH_STR - "Match peer address\n") -{ - if (argc == 0) - return bgp_route_match_delete (vty, vty->index, "peer", NULL, - RMAP_EVENT_MATCH_DELETED); - - return bgp_route_match_delete (vty, vty->index, "peer", argv[0], - RMAP_EVENT_MATCH_DELETED); -} - -ALIAS (no_match_peer, - no_match_peer_val_cmd, - "no match peer (A.B.C.D|X:X::X:X)", + "no match peer [<local|A.B.C.D|X:X::X:X>]", NO_STR MATCH_STR "Match peer address\n" + "Static or Redistributed routes\n" "IP address of peer\n" "IPv6 address of peer\n") - -ALIAS (no_match_peer, - no_match_peer_local_cmd, - "no match peer local", - NO_STR - MATCH_STR - "Match peer address\n" - "Static or Redistributed routes\n") - -DEFUN (match_ip_address, - match_ip_address_cmd, - "match ip address (<1-199>|<1300-2699>|WORD)", - MATCH_STR - IP_STR - "Match address of route\n" - "IP access-list number\n" - "IP access-list number (expanded range)\n" - "IP Access-list name\n") -{ - return bgp_route_match_add (vty, vty->index, "ip address", argv[0], - RMAP_EVENT_FILTER_ADDED); -} - -DEFUN (no_match_ip_address, - no_match_ip_address_cmd, - "no match ip address", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n") -{ - if (argc == 0) - return bgp_route_match_delete (vty, vty->index, "ip address", NULL, - RMAP_EVENT_FILTER_DELETED); - - return bgp_route_match_delete (vty, vty->index, "ip address", argv[0], - RMAP_EVENT_FILTER_DELETED); -} - -ALIAS (no_match_ip_address, - no_match_ip_address_val_cmd, - "no match ip address (<1-199>|<1300-2699>|WORD)", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n" - "IP access-list number\n" - "IP access-list number (expanded range)\n" - "IP Access-list name\n") - -DEFUN (match_ip_next_hop, - match_ip_next_hop_cmd, - "match ip next-hop (<1-199>|<1300-2699>|WORD)", - MATCH_STR - IP_STR - "Match next-hop address of route\n" - "IP access-list number\n" - "IP access-list number (expanded range)\n" - "IP Access-list name\n") { - return bgp_route_match_add (vty, vty->index, "ip next-hop", argv[0], - RMAP_EVENT_FILTER_ADDED); -} + int idx_peer = 3; -DEFUN (no_match_ip_next_hop, - no_match_ip_next_hop_cmd, - "no match ip next-hop", - NO_STR - MATCH_STR - IP_STR - "Match next-hop address of route\n") -{ - if (argc == 0) - return bgp_route_match_delete (vty, vty->index, "ip next-hop", NULL, - RMAP_EVENT_FILTER_DELETED); - - return bgp_route_match_delete (vty, vty->index, "ip next-hop", argv[0], - RMAP_EVENT_FILTER_DELETED); + if (argc <= idx_peer) + return bgp_route_match_delete (vty, vty->index, "peer", NULL, + RMAP_EVENT_MATCH_DELETED); + return bgp_route_match_delete (vty, vty->index, "peer", argv[idx_peer]->arg, + RMAP_EVENT_MATCH_DELETED); } -ALIAS (no_match_ip_next_hop, - no_match_ip_next_hop_val_cmd, - "no match ip next-hop (<1-199>|<1300-2699>|WORD)", - NO_STR - MATCH_STR - IP_STR - "Match next-hop address of route\n" - "IP access-list number\n" - "IP access-list number (expanded range)\n" - "IP Access-list name\n") - -/* match probability { */ +/* match probability */ DEFUN (match_probability, match_probability_cmd, - "match probability <0-100>", + "match probability (0-100)", MATCH_STR "Match portion of routes defined by percentage value\n" "Percentage of routes\n") { - return bgp_route_match_add (vty, vty->index, "probability", argv[0], + int idx_number = 2; + return bgp_route_match_add (vty, vty->index, "probability", argv[idx_number]->arg, RMAP_EVENT_MATCH_ADDED); } + DEFUN (no_match_probability, no_match_probability_cmd, - "no match probability", + "no match probability [(1-99)]", NO_STR MATCH_STR - "Match portion of routes defined by percentage value\n") + "Match portion of routes defined by percentage value\n" + "Percentage of routes\n") { - return bgp_route_match_delete (vty, vty->index, "probability", argc ? argv[0] : NULL, + int idx_number = 3; + if (argc <= idx_number) + return bgp_route_match_delete (vty, vty->index, "probability", NULL, + RMAP_EVENT_MATCH_DELETED); + return bgp_route_match_delete (vty, vty->index, "probability", argv[idx_number]->arg, RMAP_EVENT_MATCH_DELETED); } -ALIAS (no_match_probability, - no_match_probability_val_cmd, - "no match probability <1-99>", - NO_STR - MATCH_STR - "Match portion of routes defined by percentage value\n" - "Percentage of routes\n") - -/* } */ -DEFUN (match_ip_route_source, +DEFUN (match_ip_route_source, match_ip_route_source_cmd, - "match ip route-source (<1-199>|<1300-2699>|WORD)", + "match ip route-source <(1-199)|(1300-2699)|WORD>", MATCH_STR IP_STR "Match advertising source address of route\n" @@ -3113,29 +2972,15 @@ DEFUN (match_ip_route_source, "IP access-list number (expanded range)\n" "IP standard access-list name\n") { - return bgp_route_match_add (vty, vty->index, "ip route-source", argv[0], + int idx_acl = 3; + return bgp_route_match_add (vty, vty->index, "ip route-source", argv[idx_acl]->arg, RMAP_EVENT_FILTER_ADDED); } + DEFUN (no_match_ip_route_source, no_match_ip_route_source_cmd, - "no match ip route-source", - NO_STR - MATCH_STR - IP_STR - "Match advertising source address of route\n") -{ - if (argc == 0) - return bgp_route_match_delete (vty, vty->index, "ip route-source", NULL, - RMAP_EVENT_FILTER_DELETED); - - return bgp_route_match_delete (vty, vty->index, "ip route-source", - argv[0], RMAP_EVENT_FILTER_DELETED); -} - -ALIAS (no_match_ip_route_source, - no_match_ip_route_source_val_cmd, - "no match ip route-source (<1-199>|<1300-2699>|WORD)", + "no match ip route-source [<(1-199)|(1300-2699)|WORD>]", NO_STR MATCH_STR IP_STR @@ -3143,82 +2988,17 @@ ALIAS (no_match_ip_route_source, "IP access-list number\n" "IP access-list number (expanded range)\n" "IP standard access-list name\n") - -DEFUN (match_ip_address_prefix_list, - match_ip_address_prefix_list_cmd, - "match ip address prefix-list WORD", - MATCH_STR - IP_STR - "Match address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") -{ - return bgp_route_match_add (vty, vty->index, "ip address prefix-list", - argv[0], RMAP_EVENT_PLIST_ADDED); -} - -DEFUN (no_match_ip_address_prefix_list, - no_match_ip_address_prefix_list_cmd, - "no match ip address prefix-list", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n" - "Match entries of prefix-lists\n") -{ - return bgp_route_match_delete (vty, vty->index, "ip address prefix-list", - argc == 0 ? NULL : argv[0], - RMAP_EVENT_PLIST_DELETED); -} - -ALIAS (no_match_ip_address_prefix_list, - no_match_ip_address_prefix_list_val_cmd, - "no match ip address prefix-list WORD", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") - -DEFUN (match_ip_next_hop_prefix_list, - match_ip_next_hop_prefix_list_cmd, - "match ip next-hop prefix-list WORD", - MATCH_STR - IP_STR - "Match next-hop address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") { - return bgp_route_match_add (vty, vty->index, "ip next-hop prefix-list", - argv[0], RMAP_EVENT_PLIST_ADDED); -} - -DEFUN (no_match_ip_next_hop_prefix_list, - no_match_ip_next_hop_prefix_list_cmd, - "no match ip next-hop prefix-list", - NO_STR - MATCH_STR - IP_STR - "Match next-hop address of route\n" - "Match entries of prefix-lists\n") -{ - return bgp_route_match_delete (vty, vty->index, "ip next-hop prefix-list", - argc == 0 ? NULL : argv[0], - RMAP_EVENT_PLIST_DELETED); + int idx_number = 4; + if (argc <= idx_number) + return bgp_route_match_delete (vty, vty->index, "ip route-source", + NULL, RMAP_EVENT_FILTER_DELETED); + return bgp_route_match_delete (vty, vty->index, "ip route-source", + argv[idx_number]->arg, RMAP_EVENT_FILTER_DELETED); } -ALIAS (no_match_ip_next_hop_prefix_list, - no_match_ip_next_hop_prefix_list_val_cmd, - "no match ip next-hop prefix-list WORD", - NO_STR - MATCH_STR - IP_STR - "Match next-hop address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") -DEFUN (match_ip_route_source_prefix_list, +DEFUN (match_ip_route_source_prefix_list, match_ip_route_source_prefix_list_cmd, "match ip route-source prefix-list WORD", MATCH_STR @@ -3227,115 +3007,79 @@ DEFUN (match_ip_route_source_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") { + int idx_word = 4; return bgp_route_match_add (vty, vty->index, "ip route-source prefix-list", - argv[0], RMAP_EVENT_PLIST_ADDED); + argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED); } + DEFUN (no_match_ip_route_source_prefix_list, no_match_ip_route_source_prefix_list_cmd, - "no match ip route-source prefix-list", - NO_STR - MATCH_STR - IP_STR - "Match advertising source address of route\n" - "Match entries of prefix-lists\n") -{ - return bgp_route_match_delete (vty, vty->index, "ip route-source prefix-list", - argc == 0 ? NULL : argv[0], - RMAP_EVENT_PLIST_DELETED); -} - -ALIAS (no_match_ip_route_source_prefix_list, - no_match_ip_route_source_prefix_list_val_cmd, - "no match ip route-source prefix-list WORD", + "no match ip route-source prefix-list [WORD]", NO_STR MATCH_STR IP_STR "Match advertising source address of route\n" "Match entries of prefix-lists\n" "IP prefix-list name\n") - -DEFUN (match_metric, - match_metric_cmd, - "match metric <0-4294967295>", - MATCH_STR - "Match metric of route\n" - "Metric value\n") -{ - return bgp_route_match_add (vty, vty->index, "metric", argv[0], - RMAP_EVENT_MATCH_ADDED); -} - -DEFUN (no_match_metric, - no_match_metric_cmd, - "no match metric", - NO_STR - MATCH_STR - "Match metric of route\n") { - return bgp_route_match_delete (vty, vty->index, "metric", - argc == 0 ? NULL : argv[0], - RMAP_EVENT_MATCH_DELETED); + int idx_word = 5; + if (argc <= idx_word) + return bgp_route_match_delete (vty, vty->index, "ip route-source prefix-list", + NULL, RMAP_EVENT_PLIST_DELETED); + return bgp_route_match_delete (vty, vty->index, "ip route-source prefix-list", + argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED); } -ALIAS (no_match_metric, - no_match_metric_val_cmd, - "no match metric <0-4294967295>", - NO_STR - MATCH_STR - "Match metric of route\n" - "Metric value\n") DEFUN (match_local_pref, match_local_pref_cmd, - "match local-preference <0-4294967295>", + "match local-preference (0-4294967295)", MATCH_STR "Match local-preference of route\n" "Metric value\n") { - return bgp_route_match_add (vty, vty->index, "local-preference", argv[0], + int idx_number = 2; + return bgp_route_match_add (vty, vty->index, "local-preference", argv[idx_number]->arg, RMAP_EVENT_MATCH_ADDED); } + DEFUN (no_match_local_pref, no_match_local_pref_cmd, - "no match local-preference", + "no match local-preference [(0-4294967295)]", NO_STR MATCH_STR - "Match local preference of route\n") + "Match local preference of route\n" + "Local preference value\n") { + int idx_localpref = 3; + if (argc <= idx_localpref) + return bgp_route_match_delete (vty, vty->index, "local-preference", + NULL, RMAP_EVENT_MATCH_DELETED); return bgp_route_match_delete (vty, vty->index, "local-preference", - argc == 0 ? NULL : argv[0], - RMAP_EVENT_MATCH_DELETED); - - return bgp_route_match_delete (vty, vty->index, "local-preference", argv[0], + argv[idx_localpref]->arg, RMAP_EVENT_MATCH_DELETED); } -ALIAS (no_match_local_pref, - no_match_local_pref_val_cmd, - "no match local-preference <0-4294967295>", - NO_STR - MATCH_STR - "Match local preference of route\n" - "Local preference value\n") -DEFUN (match_community, +DEFUN (match_community, match_community_cmd, - "match community (<1-99>|<100-500>|WORD)", + "match community <(1-99)|(100-500)|WORD>", MATCH_STR "Match BGP community list\n" "Community-list number (standard)\n" "Community-list number (expanded)\n" "Community-list name\n") { - return bgp_route_match_add (vty, vty->index, "community", argv[0], + int idx_comm_list = 2; + return bgp_route_match_add (vty, vty->index, "community", argv[idx_comm_list]->arg, RMAP_EVENT_CLIST_ADDED); } -DEFUN (match_community_exact, +DEFUN (match_community_exact, match_community_exact_cmd, - "match community (<1-99>|<100-500>|WORD) exact-match", + "match community <(1-99)|(100-500)|WORD> exact-match", MATCH_STR "Match BGP community list\n" "Community-list number (standard)\n" @@ -3343,13 +3087,14 @@ DEFUN (match_community_exact, "Community-list name\n" "Do exact matching of communities\n") { + int idx_comm_list = 2; int ret; char *argstr; argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, - strlen (argv[0]) + strlen ("exact-match") + 2); + strlen (argv[idx_comm_list]->arg) + strlen ("exact-match") + 2); - sprintf (argstr, "%s exact-match", argv[0]); + sprintf (argstr, "%s exact-match", argv[idx_comm_list]->arg); ret = bgp_route_match_add (vty, vty->index, "community", argstr, RMAP_EVENT_CLIST_ADDED); @@ -3361,69 +3106,50 @@ DEFUN (match_community_exact, DEFUN (no_match_community, no_match_community_cmd, - "no match community", + "no match community [<(1-99)|(100-500)|WORD> [exact-match]]", NO_STR MATCH_STR - "Match BGP community list\n") + "Match BGP community list\n" + "Community-list number (standard)\n" + "Community-list number (expanded)\n" + "Community-list name\n" + "Do exact matching of communities\n") { return bgp_route_match_delete (vty, vty->index, "community", NULL, RMAP_EVENT_CLIST_DELETED); } -ALIAS (no_match_community, - no_match_community_val_cmd, - "no match community (<1-99>|<100-500>|WORD)", - NO_STR - MATCH_STR - "Match BGP community list\n" - "Community-list number (standard)\n" - "Community-list number (expanded)\n" - "Community-list name\n") -ALIAS (no_match_community, - no_match_community_exact_cmd, - "no match community (<1-99>|<100-500>|WORD) exact-match", - NO_STR - MATCH_STR - "Match BGP community list\n" - "Community-list number (standard)\n" - "Community-list number (expanded)\n" - "Community-list name\n" - "Do exact matching of communities\n") -DEFUN (match_ecommunity, +DEFUN (match_ecommunity, match_ecommunity_cmd, - "match extcommunity (<1-99>|<100-500>|WORD)", + "match extcommunity <(1-99)|(100-500)|WORD>", MATCH_STR "Match BGP/VPN extended community list\n" "Extended community-list number (standard)\n" "Extended community-list number (expanded)\n" "Extended community-list name\n") { - return bgp_route_match_add (vty, vty->index, "extcommunity", argv[0], + int idx_comm_list = 2; + return bgp_route_match_add (vty, vty->index, "extcommunity", argv[idx_comm_list]->arg, RMAP_EVENT_ECLIST_ADDED); } + DEFUN (no_match_ecommunity, no_match_ecommunity_cmd, - "no match extcommunity", + "no match extcommunity [<(1-99)|(100-500)|WORD>]", NO_STR MATCH_STR - "Match BGP/VPN extended community list\n") + "Match BGP/VPN extended community list\n" + "Extended community-list number (standard)\n" + "Extended community-list number (expanded)\n" + "Extended community-list name\n") { return bgp_route_match_delete (vty, vty->index, "extcommunity", NULL, RMAP_EVENT_ECLIST_DELETED); } -ALIAS (no_match_ecommunity, - no_match_ecommunity_val_cmd, - "no match extcommunity (<1-99>|<100-500>|WORD)", - NO_STR - MATCH_STR - "Match BGP/VPN extended community list\n" - "Extended community-list number (standard)\n" - "Extended community-list number (expanded)\n" - "Extended community-list name\n") DEFUN (match_aspath, match_aspath_cmd, @@ -3432,169 +3158,63 @@ DEFUN (match_aspath, "Match BGP AS path list\n" "AS path access-list name\n") { - return bgp_route_match_add (vty, vty->index, "as-path", argv[0], + int idx_word = 2; + return bgp_route_match_add (vty, vty->index, "as-path", argv[idx_word]->arg, RMAP_EVENT_ASLIST_ADDED); } + DEFUN (no_match_aspath, no_match_aspath_cmd, - "no match as-path", + "no match as-path [WORD]", NO_STR MATCH_STR - "Match BGP AS path list\n") + "Match BGP AS path list\n" + "AS path access-list name\n") { return bgp_route_match_delete (vty, vty->index, "as-path", NULL, RMAP_EVENT_ASLIST_DELETED); } -ALIAS (no_match_aspath, - no_match_aspath_val_cmd, - "no match as-path WORD", - NO_STR - MATCH_STR - "Match BGP AS path list\n" - "AS path access-list name\n") DEFUN (match_origin, match_origin_cmd, - "match origin (egp|igp|incomplete)", + "match origin <egp|igp|incomplete>", MATCH_STR "BGP origin code\n" "remote EGP\n" "local IGP\n" "unknown heritage\n") { - if (strncmp (argv[0], "igp", 2) == 0) + int idx_origin = 2; + if (strncmp (argv[idx_origin]->arg, "igp", 2) == 0) return bgp_route_match_add (vty, vty->index, "origin", "igp", RMAP_EVENT_MATCH_ADDED); - if (strncmp (argv[0], "egp", 1) == 0) + if (strncmp (argv[idx_origin]->arg, "egp", 1) == 0) return bgp_route_match_add (vty, vty->index, "origin", "egp", RMAP_EVENT_MATCH_ADDED); - if (strncmp (argv[0], "incomplete", 2) == 0) + if (strncmp (argv[idx_origin]->arg, "incomplete", 2) == 0) return bgp_route_match_add (vty, vty->index, "origin", "incomplete", RMAP_EVENT_MATCH_ADDED); return CMD_WARNING; } + DEFUN (no_match_origin, no_match_origin_cmd, - "no match origin", - NO_STR - MATCH_STR - "BGP origin code\n") -{ - return bgp_route_match_delete (vty, vty->index, "origin", NULL, - RMAP_EVENT_MATCH_DELETED); -} - -ALIAS (no_match_origin, - no_match_origin_val_cmd, - "no match origin (egp|igp|incomplete)", + "no match origin [<egp|igp|incomplete>]", NO_STR MATCH_STR "BGP origin code\n" "remote EGP\n" "local IGP\n" "unknown heritage\n") - -DEFUN (match_interface, - match_interface_cmd, - "match interface WORD", - MATCH_STR - "Match first hop interface of route\n" - "Interface name\n") -{ - return bgp_route_match_add (vty, vty->index, "interface", argv[0], - RMAP_EVENT_MATCH_ADDED); -} - -DEFUN (no_match_interface, - no_match_interface_cmd, - "no match interface", - NO_STR - MATCH_STR - "Match first hop interface of route\n") { - if (argc == 0) - return bgp_route_match_delete (vty, vty->index, "interface", NULL, - RMAP_EVENT_MATCH_DELETED); - - return bgp_route_match_delete (vty, vty->index, "interface", argv[0], + return bgp_route_match_delete (vty, vty->index, "origin", NULL, RMAP_EVENT_MATCH_DELETED); } -ALIAS (no_match_interface, - no_match_interface_val_cmd, - "no match interface WORD", - NO_STR - MATCH_STR - "Match first hop interface of route\n" - "Interface name\n") - -DEFUN (match_tag, - match_tag_cmd, - "match tag <1-4294967295>", - MATCH_STR - "Match tag of route\n" - "Tag value\n") -{ - return bgp_route_match_add (vty, vty->index, "tag", argv[0], - RMAP_EVENT_MATCH_ADDED); -} - -DEFUN (no_match_tag, - no_match_tag_cmd, - "no match tag", - NO_STR - MATCH_STR - "Match tag of route\n") -{ - if (argc == 0) - return bgp_route_match_delete (vty, vty->index, "tag", NULL, - RMAP_EVENT_MATCH_DELETED); - - return bgp_route_match_delete (vty, vty->index, "tag", argv[0], - RMAP_EVENT_MATCH_DELETED); -} - -ALIAS (no_match_tag, - no_match_tag_val_cmd, - "no match tag <1-4294967295>", - NO_STR - MATCH_STR - "Match tag of route\n" - "Tag value\n") - - -DEFUN (set_ip_nexthop, - set_ip_nexthop_cmd, - "set ip next-hop A.B.C.D", - SET_STR - IP_STR - "Next hop address\n" - "IP address of next hop\n") -{ - union sockunion su; - int ret; - - ret = str2sockunion (argv[0], &su); - if (ret < 0) - { - vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (su.sin.sin_addr.s_addr == 0 || - IPV4_CLASS_DE(su.sin.sin_addr.s_addr)) - { - vty_out (vty, "%% nexthop address cannot be 0.0.0.0, multicast " - "or reserved%s", VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_route_set_add (vty, vty->index, "ip next-hop", argv[0]); -} - DEFUN (set_ip_nexthop_peer, set_ip_nexthop_peer_cmd, "set ip next-hop peer-address", @@ -3603,7 +3223,7 @@ DEFUN (set_ip_nexthop_peer, "Next hop address\n" "Use peer address (for BGP only)\n") { - return bgp_route_set_add (vty, vty->index, "ip next-hop", "peer-address"); + return generic_set_add (vty, vty->index, "ip next-hop", "peer-address"); } DEFUN (set_ip_nexthop_unchanged, @@ -3614,258 +3234,161 @@ DEFUN (set_ip_nexthop_unchanged, "Next hop address\n" "Don't modify existing Next hop address\n") { - return bgp_route_set_add (vty, vty->index, "ip next-hop", "unchanged"); -} - -DEFUN (no_set_ip_nexthop, - no_set_ip_nexthop_cmd, - "no set ip next-hop", - NO_STR - SET_STR - "Next hop address\n") -{ - if (argc == 0) - return bgp_route_set_delete (vty, vty->index, "ip next-hop", NULL); - - return bgp_route_set_delete (vty, vty->index, "ip next-hop", argv[0]); -} - -ALIAS (no_set_ip_nexthop, - no_set_ip_nexthop_val_cmd, - "no set ip next-hop A.B.C.D", - NO_STR - SET_STR - IP_STR - "Next hop address\n" - "IP address of next hop\n") - -ALIAS (no_set_ip_nexthop, - no_set_ip_nexthop_peer_cmd, - "no set ip next-hop peer-address", - NO_STR - SET_STR - IP_STR - "Next hop address\n" - "Use peer address (for BGP only)\n") - -DEFUN (set_metric, - set_metric_cmd, - "set metric <0-4294967295>", - SET_STR - "Metric value for destination routing protocol\n" - "Metric value\n") -{ - return bgp_route_set_add (vty, vty->index, "metric", argv[0]); -} - -ALIAS (set_metric, - set_metric_addsub_cmd, - "set metric <+/-metric>", - SET_STR - "Metric value for destination routing protocol\n" - "Add or subtract metric\n") - -ALIAS (set_metric, - set_metric_rtt_cmd, - "set metric (rtt|+rtt|-rtt)", - SET_STR - "Metric value for destination routing protocol\n" - "Assign round trip time\n" - "Add round trip time\n" - "Subtract round trip time\n") - -DEFUN (no_set_metric, - no_set_metric_cmd, - "no set metric", - NO_STR - SET_STR - "Metric value for destination routing protocol\n") -{ - if (argc == 0) - return bgp_route_set_delete (vty, vty->index, "metric", NULL); - - return bgp_route_set_delete (vty, vty->index, "metric", argv[0]); + return generic_set_add (vty, vty->index, "ip next-hop", "unchanged"); } -ALIAS (no_set_metric, - no_set_metric_val_cmd, - "no set metric <0-4294967295>", - NO_STR - SET_STR - "Metric value for destination routing protocol\n" - "Metric value\n") DEFUN (set_local_pref, set_local_pref_cmd, - "set local-preference <0-4294967295>", + "set local-preference (0-4294967295)", SET_STR "BGP local preference path attribute\n" "Preference value\n") { - return bgp_route_set_add (vty, vty->index, "local-preference", argv[0]); + int idx_number = 2; + return generic_set_add (vty, vty->index, "local-preference", argv[idx_number]->arg); } + DEFUN (no_set_local_pref, no_set_local_pref_cmd, - "no set local-preference", + "no set local-preference [(0-4294967295)]", NO_STR SET_STR - "BGP local preference path attribute\n") + "BGP local preference path attribute\n" + "Preference value\n") { - if (argc == 0) - return bgp_route_set_delete (vty, vty->index, "local-preference", NULL); - - return bgp_route_set_delete (vty, vty->index, "local-preference", argv[0]); + int idx_localpref = 3; + if (argc <= idx_localpref) + return generic_set_delete (vty, vty->index, "local-preference", NULL); + return generic_set_delete (vty, vty->index, "local-preference", argv[idx_localpref]->arg); } -ALIAS (no_set_local_pref, - no_set_local_pref_val_cmd, - "no set local-preference <0-4294967295>", - NO_STR - SET_STR - "BGP local preference path attribute\n" - "Preference value\n") DEFUN (set_weight, set_weight_cmd, - "set weight <0-4294967295>", + "set weight (0-4294967295)", SET_STR "BGP weight for routing table\n" "Weight value\n") { - return bgp_route_set_add (vty, vty->index, "weight", argv[0]); + int idx_number = 2; + return generic_set_add (vty, vty->index, "weight", argv[idx_number]->arg); } + DEFUN (no_set_weight, no_set_weight_cmd, - "no set weight", + "no set weight [(0-4294967295)]", NO_STR SET_STR - "BGP weight for routing table\n") + "BGP weight for routing table\n" + "Weight value\n") { - if (argc == 0) - return bgp_route_set_delete (vty, vty->index, "weight", NULL); - - return bgp_route_set_delete (vty, vty->index, "weight", argv[0]); + int idx_weight = 3; + if (argc <= idx_weight) + return generic_set_delete (vty, vty->index, "weight", NULL); + return generic_set_delete (vty, vty->index, "weight", argv[idx_weight]->arg); } -ALIAS (no_set_weight, - no_set_weight_val_cmd, - "no set weight <0-4294967295>", - NO_STR - SET_STR - "BGP weight for routing table\n" - "Weight value\n") -DEFUN (set_aspath_prepend, - set_aspath_prepend_cmd, - "set as-path prepend ." CMD_AS_RANGE, +DEFUN (set_aspath_prepend_asn, + set_aspath_prepend_asn_cmd, + "set as-path prepend (1-4294967295)...", SET_STR "Transform BGP AS_PATH attribute\n" "Prepend to the as-path\n" "AS number\n") { + int idx_asn = 3; int ret; char *str; - str = argv_concat (argv, argc, 0); - ret = bgp_route_set_add (vty, vty->index, "as-path prepend", str); + str = argv_concat (argv, argc, idx_asn); + ret = generic_set_add (vty, vty->index, "as-path prepend", str); XFREE (MTYPE_TMP, str); return ret; } -ALIAS (set_aspath_prepend, +DEFUN (set_aspath_prepend_lastas, set_aspath_prepend_lastas_cmd, - "set as-path prepend (last-as) <1-10>", + "set as-path prepend last-as (1-10)", SET_STR "Transform BGP AS_PATH attribute\n" "Prepend to the as-path\n" "Use the peer's AS-number\n" "Number of times to insert") +{ + return set_aspath_prepend_asn (self, vty, argc, argv); +} DEFUN (no_set_aspath_prepend, no_set_aspath_prepend_cmd, - "no set as-path prepend", + "no set as-path prepend [(1-4294967295)]", NO_STR SET_STR "Transform BGP AS_PATH attribute\n" - "Prepend to the as-path\n") + "Prepend to the as-path\n" + "AS number\n") { + int idx_asn = 4; int ret; char *str; - if (argc == 0) - return bgp_route_set_delete (vty, vty->index, "as-path prepend", NULL); - - str = argv_concat (argv, argc, 0); - ret = bgp_route_set_delete (vty, vty->index, "as-path prepend", str); + str = argv_concat (argv, argc, idx_asn); + ret = generic_set_delete (vty, vty->index, "as-path prepend", str); XFREE (MTYPE_TMP, str); return ret; } -ALIAS (no_set_aspath_prepend, - no_set_aspath_prepend_val_cmd, - "no set as-path prepend ." CMD_AS_RANGE, - NO_STR - SET_STR - "Transform BGP AS_PATH attribute\n" - "Prepend to the as-path\n" - "AS number\n") DEFUN (set_aspath_exclude, set_aspath_exclude_cmd, - "set as-path exclude ." CMD_AS_RANGE, + "set as-path exclude (1-4294967295)...", SET_STR "Transform BGP AS-path attribute\n" "Exclude from the as-path\n" "AS number\n") { + int idx_asn = 3; int ret; char *str; - str = argv_concat (argv, argc, 0); - ret = bgp_route_set_add (vty, vty->index, "as-path exclude", str); + str = argv_concat (argv, argc, idx_asn); + ret = generic_set_add (vty, vty->index, "as-path exclude", str); XFREE (MTYPE_TMP, str); return ret; } DEFUN (no_set_aspath_exclude, no_set_aspath_exclude_cmd, - "no set as-path exclude", + "no set as-path exclude (1-4294967295)...", NO_STR SET_STR "Transform BGP AS_PATH attribute\n" - "Exclude from the as-path\n") + "Exclude from the as-path\n" + "AS number\n") { + int idx_asn = 4; int ret; char *str; - if (argc == 0) - return bgp_route_set_delete (vty, vty->index, "as-path exclude", NULL); - - str = argv_concat (argv, argc, 0); - ret = bgp_route_set_delete (vty, vty->index, "as-path exclude", str); + str = argv_concat (argv, argc, idx_asn); + ret = generic_set_delete (vty, vty->index, "as-path exclude", str); XFREE (MTYPE_TMP, str); return ret; } -ALIAS (no_set_aspath_exclude, - no_set_aspath_exclude_val_cmd, - "no set as-path exclude ." CMD_AS_RANGE, - NO_STR - SET_STR - "Transform BGP AS_PATH attribute\n" - "Exclude from the as-path\n" - "AS number\n") DEFUN (set_community, set_community_cmd, - "set community .AA:NN", + "set community AA:NN...", SET_STR "BGP community attribute\n" COMMUNITY_VAL_STR) { + int idx_aa_nn = 2; int i; int first = 0; int additive = 0; @@ -3877,9 +3400,9 @@ DEFUN (set_community, b = buffer_new (1024); - for (i = 0; i < argc; i++) + for (i = idx_aa_nn; i < argc; i++) { - if (strncmp (argv[i], "additive", strlen (argv[i])) == 0) + if (strncmp (argv[i]->arg, "additive", strlen (argv[i]->arg)) == 0) { additive = 1; continue; @@ -3890,29 +3413,29 @@ DEFUN (set_community, else first = 1; - if (strncmp (argv[i], "internet", strlen (argv[i])) == 0) + if (strncmp (argv[i]->arg, "internet", strlen (argv[i]->arg)) == 0) { buffer_putstr (b, "internet"); continue; } - if (strncmp (argv[i], "local-AS", strlen (argv[i])) == 0) + if (strncmp (argv[i]->arg, "local-AS", strlen (argv[i]->arg)) == 0) { buffer_putstr (b, "local-AS"); continue; } - if (strncmp (argv[i], "no-a", strlen ("no-a")) == 0 - && strncmp (argv[i], "no-advertise", strlen (argv[i])) == 0) + if (strncmp (argv[i]->arg, "no-a", strlen ("no-a")) == 0 + && strncmp (argv[i]->arg, "no-advertise", strlen (argv[i]->arg)) == 0) { buffer_putstr (b, "no-advertise"); continue; } - if (strncmp (argv[i], "no-e", strlen ("no-e"))== 0 - && strncmp (argv[i], "no-export", strlen (argv[i])) == 0) + if (strncmp (argv[i]->arg, "no-e", strlen ("no-e"))== 0 + && strncmp (argv[i]->arg, "no-export", strlen (argv[i]->arg)) == 0) { buffer_putstr (b, "no-export"); continue; } - buffer_putstr (b, argv[i]); + buffer_putstr (b, argv[i]->arg); } buffer_putc (b, '\0'); @@ -3941,11 +3464,11 @@ DEFUN (set_community, argstr = XCALLOC (MTYPE_TMP, strlen (str) + strlen (" additive") + 1); strcpy (argstr, str); strcpy (argstr + strlen (str), " additive"); - ret = bgp_route_set_add (vty, vty->index, "community", argstr); + ret = generic_set_add (vty, vty->index, "community", argstr); XFREE (MTYPE_TMP, argstr); } else - ret = bgp_route_set_add (vty, vty->index, "community", str); + ret = generic_set_add (vty, vty->index, "community", str); community_free (com); @@ -3959,38 +3482,25 @@ DEFUN (set_community_none, "BGP community attribute\n" "No community attribute\n") { - return bgp_route_set_add (vty, vty->index, "community", "none"); + return generic_set_add (vty, vty->index, "community", "none"); } DEFUN (no_set_community, no_set_community_cmd, - "no set community", + "no set community AA:NN...", NO_STR SET_STR - "BGP community attribute\n") + "BGP community attribute\n" + COMMUNITY_VAL_STR) { - return bgp_route_set_delete (vty, vty->index, "community", NULL); + return generic_set_delete (vty, vty->index, "community", NULL); } -ALIAS (no_set_community, - no_set_community_val_cmd, - "no set community .AA:NN", - NO_STR - SET_STR - "BGP community attribute\n" - COMMUNITY_VAL_STR) -ALIAS (no_set_community, - no_set_community_none_cmd, - "no set community none", - NO_STR - SET_STR - "BGP community attribute\n" - "No community attribute\n") DEFUN (set_community_delete, set_community_delete_cmd, - "set comm-list (<1-99>|<100-500>|WORD) delete", + "set comm-list <(1-99)|(100-500)|WORD> delete", SET_STR "set BGP community list (for deletion)\n" "Community-list number (standard)\n" @@ -3998,13 +3508,14 @@ DEFUN (set_community_delete, "Community-list name\n" "Delete matching communities\n") { + int idx_comm_list = 2; char *str; - str = XCALLOC (MTYPE_TMP, strlen (argv[0]) + strlen (" delete") + 1); - strcpy (str, argv[0]); - strcpy (str + strlen (argv[0]), " delete"); + str = XCALLOC (MTYPE_TMP, strlen (argv[idx_comm_list]->arg) + strlen (" delete") + 1); + strcpy (str, argv[idx_comm_list]->arg); + strcpy (str + strlen (argv[idx_comm_list]->arg), " delete"); - bgp_route_set_add (vty, vty->index, "comm-list", str); + generic_set_add (vty, vty->index, "comm-list", str); XFREE (MTYPE_TMP, str); return CMD_SUCCESS; @@ -4012,17 +3523,7 @@ DEFUN (set_community_delete, DEFUN (no_set_community_delete, no_set_community_delete_cmd, - "no set comm-list", - NO_STR - SET_STR - "set BGP community list (for deletion)\n") -{ - return bgp_route_set_delete (vty, vty->index, "comm-list", NULL); -} - -ALIAS (no_set_community_delete, - no_set_community_delete_val_cmd, - "no set comm-list (<1-99>|<100-500>|WORD) delete", + "no set comm-list [<(1-99)|(100-500)|WORD> delete]", NO_STR SET_STR "set BGP community list (for deletion)\n" @@ -4030,20 +3531,25 @@ ALIAS (no_set_community_delete, "Community-list number (expanded)\n" "Community-list name\n" "Delete matching communities\n") +{ + return generic_set_delete (vty, vty->index, "comm-list", NULL); +} + DEFUN (set_ecommunity_rt, set_ecommunity_rt_cmd, - "set extcommunity rt .ASN:nn_or_IP-address:nn", + "set extcommunity rt ASN:nn_or_IP-address:nn...", SET_STR "BGP extended community attribute\n" "Route Target extended community\n" "VPN extended community\n") { + int idx_asn_nn = 3; int ret; char *str; - str = argv_concat (argv, argc, 0); - ret = bgp_route_set_add (vty, vty->index, "extcommunity rt", str); + str = argv_concat (argv, argc, idx_asn_nn); + ret = generic_set_add (vty, vty->index, "extcommunity rt", str); XFREE (MTYPE_TMP, str); return ret; @@ -4051,99 +3557,81 @@ DEFUN (set_ecommunity_rt, DEFUN (no_set_ecommunity_rt, no_set_ecommunity_rt_cmd, - "no set extcommunity rt", + "no set extcommunity rt ASN:nn_or_IP-address:nn...", NO_STR SET_STR "BGP extended community attribute\n" "Route Target extended community\n") { - return bgp_route_set_delete (vty, vty->index, "extcommunity rt", NULL); + return generic_set_delete (vty, vty->index, "extcommunity rt", NULL); } -ALIAS (no_set_ecommunity_rt, - no_set_ecommunity_rt_val_cmd, - "no set extcommunity rt .ASN:nn_or_IP-address:nn", - NO_STR - SET_STR - "BGP extended community attribute\n" - "Route Target extended community\n" - "VPN extended community\n") DEFUN (set_ecommunity_soo, set_ecommunity_soo_cmd, - "set extcommunity soo .ASN:nn_or_IP-address:nn", + "set extcommunity soo ASN:nn_or_IP-address:nn...", SET_STR "BGP extended community attribute\n" "Site-of-Origin extended community\n" "VPN extended community\n") { + int idx_asn_nn = 3; int ret; char *str; - str = argv_concat (argv, argc, 0); - ret = bgp_route_set_add (vty, vty->index, "extcommunity soo", str); + str = argv_concat (argv, argc, idx_asn_nn); + ret = generic_set_add (vty, vty->index, "extcommunity soo", str); XFREE (MTYPE_TMP, str); return ret; } + DEFUN (no_set_ecommunity_soo, no_set_ecommunity_soo_cmd, - "no set extcommunity soo", + "no set extcommunity soo ASN:nn_or_IP-address:nn...", NO_STR SET_STR "BGP extended community attribute\n" "Site-of-Origin extended community\n") { - return bgp_route_set_delete (vty, vty->index, "extcommunity soo", NULL); + return generic_set_delete (vty, vty->index, "extcommunity soo", NULL); } -ALIAS (no_set_ecommunity_soo, - no_set_ecommunity_soo_val_cmd, - "no set extcommunity soo .ASN:nn_or_IP-address:nn", - NO_STR - SET_STR - "BGP extended community attribute\n" - "Site-of-Origin extended community\n" - "VPN extended community\n") DEFUN (set_origin, set_origin_cmd, - "set origin (egp|igp|incomplete)", + "set origin <egp|igp|incomplete>", SET_STR "BGP origin code\n" "remote EGP\n" "local IGP\n" "unknown heritage\n") { - if (strncmp (argv[0], "igp", 2) == 0) - return bgp_route_set_add (vty, vty->index, "origin", "igp"); - if (strncmp (argv[0], "egp", 1) == 0) - return bgp_route_set_add (vty, vty->index, "origin", "egp"); - if (strncmp (argv[0], "incomplete", 2) == 0) - return bgp_route_set_add (vty, vty->index, "origin", "incomplete"); + int idx_origin = 2; + if (strncmp (argv[idx_origin]->arg, "igp", 2) == 0) + return generic_set_add (vty, vty->index, "origin", "igp"); + if (strncmp (argv[idx_origin]->arg, "egp", 1) == 0) + return generic_set_add (vty, vty->index, "origin", "egp"); + if (strncmp (argv[idx_origin]->arg, "incomplete", 2) == 0) + return generic_set_add (vty, vty->index, "origin", "incomplete"); return CMD_WARNING; } + DEFUN (no_set_origin, no_set_origin_cmd, - "no set origin", - NO_STR - SET_STR - "BGP origin code\n") -{ - return bgp_route_set_delete (vty, vty->index, "origin", NULL); -} - -ALIAS (no_set_origin, - no_set_origin_val_cmd, - "no set origin (egp|igp|incomplete)", + "no set origin [<egp|igp|incomplete>]", NO_STR SET_STR "BGP origin code\n" "remote EGP\n" "local IGP\n" "unknown heritage\n") +{ + return generic_set_delete (vty, vty->index, "origin", NULL); +} + DEFUN (set_atomic_aggregate, set_atomic_aggregate_cmd, @@ -4151,7 +3639,7 @@ DEFUN (set_atomic_aggregate, SET_STR "BGP atomic aggregate attribute\n" ) { - return bgp_route_set_add (vty, vty->index, "atomic-aggregate", NULL); + return generic_set_add (vty, vty->index, "atomic-aggregate", NULL); } DEFUN (no_set_atomic_aggregate, @@ -4161,23 +3649,25 @@ DEFUN (no_set_atomic_aggregate, SET_STR "BGP atomic aggregate attribute\n" ) { - return bgp_route_set_delete (vty, vty->index, "atomic-aggregate", NULL); + return generic_set_delete (vty, vty->index, "atomic-aggregate", NULL); } DEFUN (set_aggregator_as, set_aggregator_as_cmd, - "set aggregator as " CMD_AS_RANGE " A.B.C.D", + "set aggregator as (1-4294967295) A.B.C.D", SET_STR "BGP aggregator attribute\n" "AS number of aggregator\n" "AS number\n" "IP address of aggregator\n") { + int idx_number = 3; + int idx_ipv4 = 4; int ret; struct in_addr address; char *argstr; - - ret = inet_aton (argv[1], &address); + + ret = inet_aton (argv[idx_ipv4]->arg, &address); if (ret == 0) { vty_out (vty, "Aggregator IP address is invalid%s", VTY_NEWLINE); @@ -4185,33 +3675,38 @@ DEFUN (set_aggregator_as, } argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, - strlen (argv[0]) + strlen (argv[1]) + 2); + strlen (argv[idx_number]->arg) + strlen (argv[idx_ipv4]->arg) + 2); - sprintf (argstr, "%s %s", argv[0], argv[1]); + sprintf (argstr, "%s %s", argv[idx_number]->arg, argv[idx_ipv4]->arg); - ret = bgp_route_set_add (vty, vty->index, "aggregator as", argstr); + ret = generic_set_add (vty, vty->index, "aggregator as", argstr); XFREE (MTYPE_ROUTE_MAP_COMPILED, argstr); return ret; } + DEFUN (no_set_aggregator_as, no_set_aggregator_as_cmd, - "no set aggregator as", + "no set aggregator as [(1-4294967295) A.B.C.D]", NO_STR SET_STR "BGP aggregator attribute\n" - "AS number of aggregator\n") + "AS number of aggregator\n" + "AS number\n" + "IP address of aggregator\n") { + int idx_asn = 4; + int idx_ip = 5; int ret; struct in_addr address; char *argstr; - if (argv == 0) - return bgp_route_set_delete (vty, vty->index, "aggregator as", NULL); - - ret = inet_aton (argv[1], &address); + if (argc <= idx_asn) + return generic_set_delete (vty, vty->index, "aggregator as", NULL); + + ret = inet_aton (argv[idx_ip]->arg, &address); if (ret == 0) { vty_out (vty, "Aggregator IP address is invalid%s", VTY_NEWLINE); @@ -4219,86 +3714,19 @@ DEFUN (no_set_aggregator_as, } argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, - strlen (argv[0]) + strlen (argv[1]) + 2); + strlen (argv[idx_asn]->arg) + strlen (argv[idx_ip]->arg) + 2); - sprintf (argstr, "%s %s", argv[0], argv[1]); + sprintf (argstr, "%s %s", argv[idx_asn]->arg, argv[idx_ip]->arg); - ret = bgp_route_set_delete (vty, vty->index, "aggregator as", argstr); + ret = generic_set_delete (vty, vty->index, "aggregator as", argstr); XFREE (MTYPE_ROUTE_MAP_COMPILED, argstr); return ret; } -ALIAS (no_set_aggregator_as, - no_set_aggregator_as_val_cmd, - "no set aggregator as " CMD_AS_RANGE " A.B.C.D", - NO_STR - SET_STR - "BGP aggregator attribute\n" - "AS number of aggregator\n" - "AS number\n" - "IP address of aggregator\n") - -DEFUN (set_tag, - set_tag_cmd, - "set tag <1-4294967295>", - SET_STR - "Tag value for routing protocol\n" - "Tag value\n") -{ - return bgp_route_set_add (vty, vty->index, "tag", argv[0]); -} - -DEFUN (no_set_tag, - no_set_tag_cmd, - "no set tag", - NO_STR - SET_STR - "Tag value for routing protocol\n") -{ - if (argc == 0) - bgp_route_set_delete(vty, vty->index, "tag", NULL); - - return bgp_route_set_delete (vty, vty->index, "tag", argv[0]); -} - -ALIAS (no_set_tag, - no_set_tag_val_cmd, - "no set tag <1-4294967295>", - NO_STR - SET_STR - "Tag value for routing protocol\n" - "Tag value\n") - - #ifdef HAVE_IPV6 -DEFUN (match_ipv6_address, - match_ipv6_address_cmd, - "match ipv6 address WORD", - MATCH_STR - IPV6_STR - "Match IPv6 address of route\n" - "IPv6 access-list name\n") -{ - return bgp_route_match_add (vty, vty->index, "ipv6 address", argv[0], - RMAP_EVENT_FILTER_ADDED); -} - -DEFUN (no_match_ipv6_address, - no_match_ipv6_address_cmd, - "no match ipv6 address WORD", - NO_STR - MATCH_STR - IPV6_STR - "Match IPv6 address of route\n" - "IPv6 access-list name\n") -{ - return bgp_route_match_delete (vty, vty->index, "ipv6 address", argv[0], - RMAP_EVENT_FILTER_DELETED); -} - -DEFUN (match_ipv6_next_hop, +DEFUN (match_ipv6_next_hop, match_ipv6_next_hop_cmd, "match ipv6 next-hop X:X::X:X", MATCH_STR @@ -4306,7 +3734,8 @@ DEFUN (match_ipv6_next_hop, "Match IPv6 next-hop address of route\n" "IPv6 address of next hop\n") { - return bgp_route_match_add (vty, vty->index, "ipv6 next-hop", argv[0], + int idx_ipv6 = 3; + return bgp_route_match_add (vty, vty->index, "ipv6 next-hop", argv[idx_ipv6]->arg, RMAP_EVENT_MATCH_ADDED); } @@ -4319,36 +3748,11 @@ DEFUN (no_match_ipv6_next_hop, "Match IPv6 next-hop address of route\n" "IPv6 address of next hop\n") { - return bgp_route_match_delete (vty, vty->index, "ipv6 next-hop", argv[0], + int idx_ipv6 = 4; + return bgp_route_match_delete (vty, vty->index, "ipv6 next-hop", argv[idx_ipv6]->arg, RMAP_EVENT_MATCH_DELETED); } -DEFUN (match_ipv6_address_prefix_list, - match_ipv6_address_prefix_list_cmd, - "match ipv6 address prefix-list WORD", - MATCH_STR - IPV6_STR - "Match address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") -{ - return bgp_route_match_add (vty, vty->index, "ipv6 address prefix-list", - argv[0], RMAP_EVENT_PLIST_ADDED); -} - -DEFUN (no_match_ipv6_address_prefix_list, - no_match_ipv6_address_prefix_list_cmd, - "no match ipv6 address prefix-list WORD", - NO_STR - MATCH_STR - IPV6_STR - "Match address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") -{ - return bgp_route_match_delete (vty, vty->index, "ipv6 address prefix-list", - argv[0], RMAP_EVENT_PLIST_DELETED); -} DEFUN (set_ipv6_nexthop_peer, set_ipv6_nexthop_peer_cmd, @@ -4358,7 +3762,7 @@ DEFUN (set_ipv6_nexthop_peer, "Next hop address\n" "Use peer address (for BGP only)\n") { - return bgp_route_set_add (vty, vty->index, "ipv6 next-hop peer-address", NULL); + return generic_set_add (vty, vty->index, "ipv6 next-hop peer-address", NULL); } DEFUN (no_set_ipv6_nexthop_peer, @@ -4370,7 +3774,7 @@ DEFUN (no_set_ipv6_nexthop_peer, "IPv6 next-hop address\n" "Use peer address (for BGP only)\n") { - return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop peer-address", NULL); + return generic_set_delete (vty, vty->index, "ipv6 next-hop peer-address", NULL); } DEFUN (set_ipv6_nexthop_prefer_global, @@ -4381,7 +3785,7 @@ DEFUN (set_ipv6_nexthop_prefer_global, "IPv6 next-hop address\n" "Prefer global over link-local if both exist\n") { - return bgp_route_set_add (vty, vty->index, "ipv6 next-hop prefer-global", NULL);; + return generic_set_add (vty, vty->index, "ipv6 next-hop prefer-global", NULL);; } DEFUN (no_set_ipv6_nexthop_prefer_global, @@ -4393,7 +3797,7 @@ DEFUN (no_set_ipv6_nexthop_prefer_global, "IPv6 next-hop address\n" "Prefer global over link-local if both exist\n") { - return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop prefer-global", NULL); + return generic_set_delete (vty, vty->index, "ipv6 next-hop prefer-global", NULL); } DEFUN (set_ipv6_nexthop_global, @@ -4405,10 +3809,11 @@ DEFUN (set_ipv6_nexthop_global, "IPv6 global address\n" "IPv6 address of next hop\n") { + int idx_ipv6 = 4; struct in6_addr addr; int ret; - ret = inet_pton (AF_INET6, argv[0], &addr); + ret = inet_pton (AF_INET6, argv[idx_ipv6]->arg, &addr); if (!ret) { vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE); @@ -4423,26 +3828,12 @@ DEFUN (set_ipv6_nexthop_global, return CMD_WARNING; } - return bgp_route_set_add (vty, vty->index, "ipv6 next-hop global", argv[0]); + return generic_set_add (vty, vty->index, "ipv6 next-hop global", argv[idx_ipv6]->arg); } + DEFUN (no_set_ipv6_nexthop_global, no_set_ipv6_nexthop_global_cmd, - "no set ipv6 next-hop global", - NO_STR - SET_STR - IPV6_STR - "IPv6 next-hop address\n" - "IPv6 global address\n") -{ - if (argc == 0) - return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop global", NULL); - - return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop global", argv[0]); -} - -ALIAS (no_set_ipv6_nexthop_global, - no_set_ipv6_nexthop_global_val_cmd, "no set ipv6 next-hop global X:X::X:X", NO_STR SET_STR @@ -4450,58 +3841,12 @@ ALIAS (no_set_ipv6_nexthop_global, "IPv6 next-hop address\n" "IPv6 global address\n" "IPv6 address of next hop\n") - -DEFUN (set_ipv6_nexthop_local, - set_ipv6_nexthop_local_cmd, - "set ipv6 next-hop local X:X::X:X", - SET_STR - IPV6_STR - "IPv6 next-hop address\n" - "IPv6 local address\n" - "IPv6 address of next hop\n") { - struct in6_addr addr; - int ret; - - ret = inet_pton (AF_INET6, argv[0], &addr); - if (!ret) - { - vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!IN6_IS_ADDR_LINKLOCAL(&addr)) - { - vty_out (vty, "%% Invalid link-local nexthop address%s", VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_route_set_add (vty, vty->index, "ipv6 next-hop local", argv[0]); -} - -DEFUN (no_set_ipv6_nexthop_local, - no_set_ipv6_nexthop_local_cmd, - "no set ipv6 next-hop local", - NO_STR - SET_STR - IPV6_STR - "IPv6 next-hop address\n" - "IPv6 local address\n") -{ - if (argc == 0) - return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop local", NULL); - - return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop local", argv[0]); + int idx_ipv6 = 5; + if (argc <= idx_ipv6) + return generic_set_delete (vty, vty->index, "ipv6 next-hop global", NULL); + return generic_set_delete (vty, vty->index, "ipv6 next-hop global", argv[idx_ipv6]->arg); } - -ALIAS (no_set_ipv6_nexthop_local, - no_set_ipv6_nexthop_local_val_cmd, - "no set ipv6 next-hop local X:X::X:X", - NO_STR - SET_STR - IPV6_STR - "IPv6 next-hop address\n" - "IPv6 local address\n" - "IPv6 address of next hop\n") #endif /* HAVE_IPV6 */ DEFUN (set_vpnv4_nexthop, @@ -4512,31 +3857,26 @@ DEFUN (set_vpnv4_nexthop, "VPNv4 next-hop address\n" "IP address of next hop\n") { - return bgp_route_set_add (vty, vty->index, "vpnv4 next-hop", argv[0]); + int idx_ipv4 = 3; + return generic_set_add (vty, vty->index, "vpnv4 next-hop", argv[idx_ipv4]->arg); } + DEFUN (no_set_vpnv4_nexthop, no_set_vpnv4_nexthop_cmd, - "no set vpnv4 next-hop", + "no set vpnv4 next-hop [A.B.C.D]", NO_STR SET_STR "VPNv4 information\n" - "VPNv4 next-hop address\n") + "VPNv4 next-hop address\n" + "IP address of next hop\n") { - if (argc == 0) - return bgp_route_set_delete (vty, vty->index, "vpnv4 next-hop", NULL); - - return bgp_route_set_delete (vty, vty->index, "vpnv4 next-hop", argv[0]); + int idx_ipv4 = 4; + if (argc <= idx_ipv4) + return generic_set_delete (vty, vty->index, "vpnv4 next-hop", NULL); + return generic_set_delete (vty, vty->index, "vpnv4 next-hop", argv[idx_ipv4]->arg); } -ALIAS (no_set_vpnv4_nexthop, - no_set_vpnv4_nexthop_val_cmd, - "no set vpnv4 next-hop A.B.C.D", - NO_STR - SET_STR - "VPNv4 information\n" - "VPNv4 next-hop address\n" - "IP address of next hop\n") DEFUN (set_originator_id, set_originator_id_cmd, @@ -4545,29 +3885,25 @@ DEFUN (set_originator_id, "BGP originator ID attribute\n" "IP address of originator\n") { - return bgp_route_set_add (vty, vty->index, "originator-id", argv[0]); + int idx_ipv4 = 2; + return generic_set_add (vty, vty->index, "originator-id", argv[idx_ipv4]->arg); } + DEFUN (no_set_originator_id, no_set_originator_id_cmd, - "no set originator-id", + "no set originator-id [A.B.C.D]", NO_STR SET_STR - "BGP originator ID attribute\n") + "BGP originator ID attribute\n" + "IP address of originator\n") { - if (argc == 0) - return bgp_route_set_delete (vty, vty->index, "originator-id", NULL); - - return bgp_route_set_delete (vty, vty->index, "originator-id", argv[0]); + int idx_id = 3; + if (argc < idx_id) + return generic_set_delete (vty, vty->index, "originator-id", NULL); + return generic_set_delete (vty, vty->index, "originator-id", argv[idx_id]->arg); } -ALIAS (no_set_originator_id, - no_set_originator_id_val_cmd, - "no set originator-id A.B.C.D", - NO_STR - SET_STR - "BGP originator ID attribute\n" - "IP address of originator\n") /* Initialization of route map. */ void @@ -4579,6 +3915,45 @@ bgp_route_map_init (void) route_map_delete_hook (bgp_route_map_delete); route_map_event_hook (bgp_route_map_event); + route_map_match_interface_hook (generic_match_add); + route_map_no_match_interface_hook (generic_match_delete); + + route_map_match_ip_address_hook (generic_match_add); + route_map_no_match_ip_address_hook (generic_match_delete); + + route_map_match_ip_address_prefix_list_hook (generic_match_add); + route_map_no_match_ip_address_prefix_list_hook (generic_match_delete); + + route_map_match_ip_next_hop_hook (generic_match_add); + route_map_no_match_ip_next_hop_hook (generic_match_delete); + + route_map_match_ip_next_hop_prefix_list_hook (generic_match_add); + route_map_no_match_ip_next_hop_prefix_list_hook (generic_match_delete); + + route_map_match_ipv6_address_hook (generic_match_add); + route_map_no_match_ipv6_address_hook (generic_match_delete); + + route_map_match_ipv6_address_prefix_list_hook (generic_match_add); + route_map_no_match_ipv6_address_prefix_list_hook (generic_match_delete); + + route_map_match_metric_hook (generic_match_add); + route_map_no_match_metric_hook (generic_match_delete); + + route_map_match_tag_hook (generic_match_add); + route_map_no_match_tag_hook (generic_match_delete); + + route_map_set_ip_nexthop_hook (generic_set_add); + route_map_no_set_ip_nexthop_hook (generic_set_delete); + + route_map_set_ipv6_nexthop_local_hook (generic_set_add); + route_map_no_set_ipv6_nexthop_local_hook (generic_set_delete); + + route_map_set_metric_hook (generic_set_add); + route_map_no_set_metric_hook (generic_set_delete); + + route_map_set_tag_hook (generic_set_add); + route_map_no_set_tag_hook (generic_set_delete); + route_map_install_match (&route_match_peer_cmd); route_map_install_match (&route_match_local_pref_cmd); route_map_install_match (&route_match_ip_address_cmd); @@ -4617,112 +3992,55 @@ bgp_route_map_init (void) install_element (RMAP_NODE, &match_peer_cmd); install_element (RMAP_NODE, &match_peer_local_cmd); install_element (RMAP_NODE, &no_match_peer_cmd); - install_element (RMAP_NODE, &no_match_peer_val_cmd); - install_element (RMAP_NODE, &no_match_peer_local_cmd); - install_element (RMAP_NODE, &match_ip_address_cmd); - install_element (RMAP_NODE, &no_match_ip_address_cmd); - install_element (RMAP_NODE, &no_match_ip_address_val_cmd); - install_element (RMAP_NODE, &match_ip_next_hop_cmd); - install_element (RMAP_NODE, &no_match_ip_next_hop_cmd); - install_element (RMAP_NODE, &no_match_ip_next_hop_val_cmd); install_element (RMAP_NODE, &match_ip_route_source_cmd); install_element (RMAP_NODE, &no_match_ip_route_source_cmd); - install_element (RMAP_NODE, &no_match_ip_route_source_val_cmd); - install_element (RMAP_NODE, &match_ip_address_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ip_address_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ip_address_prefix_list_val_cmd); - install_element (RMAP_NODE, &match_ip_next_hop_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_val_cmd); install_element (RMAP_NODE, &match_ip_route_source_prefix_list_cmd); install_element (RMAP_NODE, &no_match_ip_route_source_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ip_route_source_prefix_list_val_cmd); install_element (RMAP_NODE, &match_aspath_cmd); install_element (RMAP_NODE, &no_match_aspath_cmd); - install_element (RMAP_NODE, &no_match_aspath_val_cmd); - install_element (RMAP_NODE, &match_metric_cmd); - install_element (RMAP_NODE, &no_match_metric_cmd); - install_element (RMAP_NODE, &no_match_metric_val_cmd); install_element (RMAP_NODE, &match_local_pref_cmd); install_element (RMAP_NODE, &no_match_local_pref_cmd); - install_element (RMAP_NODE, &no_match_local_pref_val_cmd); install_element (RMAP_NODE, &match_community_cmd); install_element (RMAP_NODE, &match_community_exact_cmd); install_element (RMAP_NODE, &no_match_community_cmd); - install_element (RMAP_NODE, &no_match_community_val_cmd); - install_element (RMAP_NODE, &no_match_community_exact_cmd); install_element (RMAP_NODE, &match_ecommunity_cmd); install_element (RMAP_NODE, &no_match_ecommunity_cmd); - install_element (RMAP_NODE, &no_match_ecommunity_val_cmd); install_element (RMAP_NODE, &match_origin_cmd); install_element (RMAP_NODE, &no_match_origin_cmd); - install_element (RMAP_NODE, &no_match_origin_val_cmd); install_element (RMAP_NODE, &match_probability_cmd); install_element (RMAP_NODE, &no_match_probability_cmd); - install_element (RMAP_NODE, &no_match_probability_val_cmd); - install_element (RMAP_NODE, &match_interface_cmd); - install_element (RMAP_NODE, &no_match_interface_cmd); - install_element (RMAP_NODE, &no_match_interface_val_cmd); - install_element (RMAP_NODE, &match_tag_cmd); - install_element (RMAP_NODE, &no_match_tag_cmd); - install_element (RMAP_NODE, &no_match_tag_val_cmd); - - install_element (RMAP_NODE, &set_ip_nexthop_cmd); + install_element (RMAP_NODE, &set_ip_nexthop_peer_cmd); install_element (RMAP_NODE, &set_ip_nexthop_unchanged_cmd); - install_element (RMAP_NODE, &no_set_ip_nexthop_cmd); - install_element (RMAP_NODE, &no_set_ip_nexthop_val_cmd); - install_element (RMAP_NODE, &no_set_ip_nexthop_peer_cmd); install_element (RMAP_NODE, &set_local_pref_cmd); install_element (RMAP_NODE, &no_set_local_pref_cmd); - install_element (RMAP_NODE, &no_set_local_pref_val_cmd); install_element (RMAP_NODE, &set_weight_cmd); install_element (RMAP_NODE, &no_set_weight_cmd); - install_element (RMAP_NODE, &no_set_weight_val_cmd); - install_element (RMAP_NODE, &set_metric_cmd); - install_element (RMAP_NODE, &set_metric_addsub_cmd); - install_element (RMAP_NODE, &set_metric_rtt_cmd); - install_element (RMAP_NODE, &no_set_metric_cmd); - install_element (RMAP_NODE, &no_set_metric_val_cmd); - install_element (RMAP_NODE, &set_aspath_prepend_cmd); + install_element (RMAP_NODE, &set_aspath_prepend_asn_cmd); install_element (RMAP_NODE, &set_aspath_prepend_lastas_cmd); install_element (RMAP_NODE, &set_aspath_exclude_cmd); install_element (RMAP_NODE, &no_set_aspath_prepend_cmd); - install_element (RMAP_NODE, &no_set_aspath_prepend_val_cmd); install_element (RMAP_NODE, &no_set_aspath_exclude_cmd); - install_element (RMAP_NODE, &no_set_aspath_exclude_val_cmd); install_element (RMAP_NODE, &set_origin_cmd); install_element (RMAP_NODE, &no_set_origin_cmd); - install_element (RMAP_NODE, &no_set_origin_val_cmd); install_element (RMAP_NODE, &set_atomic_aggregate_cmd); install_element (RMAP_NODE, &no_set_atomic_aggregate_cmd); install_element (RMAP_NODE, &set_aggregator_as_cmd); install_element (RMAP_NODE, &no_set_aggregator_as_cmd); - install_element (RMAP_NODE, &no_set_aggregator_as_val_cmd); install_element (RMAP_NODE, &set_community_cmd); install_element (RMAP_NODE, &set_community_none_cmd); install_element (RMAP_NODE, &no_set_community_cmd); - install_element (RMAP_NODE, &no_set_community_val_cmd); - install_element (RMAP_NODE, &no_set_community_none_cmd); install_element (RMAP_NODE, &set_community_delete_cmd); install_element (RMAP_NODE, &no_set_community_delete_cmd); - install_element (RMAP_NODE, &no_set_community_delete_val_cmd); install_element (RMAP_NODE, &set_ecommunity_rt_cmd); install_element (RMAP_NODE, &no_set_ecommunity_rt_cmd); - install_element (RMAP_NODE, &no_set_ecommunity_rt_val_cmd); install_element (RMAP_NODE, &set_ecommunity_soo_cmd); install_element (RMAP_NODE, &no_set_ecommunity_soo_cmd); - install_element (RMAP_NODE, &no_set_ecommunity_soo_val_cmd); install_element (RMAP_NODE, &set_vpnv4_nexthop_cmd); install_element (RMAP_NODE, &no_set_vpnv4_nexthop_cmd); - install_element (RMAP_NODE, &no_set_vpnv4_nexthop_val_cmd); install_element (RMAP_NODE, &set_originator_id_cmd); install_element (RMAP_NODE, &no_set_originator_id_cmd); - install_element (RMAP_NODE, &no_set_originator_id_val_cmd); - install_element (RMAP_NODE, &set_tag_cmd); - install_element (RMAP_NODE, &no_set_tag_cmd); - install_element (RMAP_NODE, &no_set_tag_val_cmd); #ifdef HAVE_IPV6 route_map_install_match (&route_match_ipv6_address_cmd); @@ -4733,20 +4051,12 @@ bgp_route_map_init (void) route_map_install_set (&route_set_ipv6_nexthop_local_cmd); route_map_install_set (&route_set_ipv6_nexthop_peer_cmd); - install_element (RMAP_NODE, &match_ipv6_address_cmd); - install_element (RMAP_NODE, &no_match_ipv6_address_cmd); install_element (RMAP_NODE, &match_ipv6_next_hop_cmd); install_element (RMAP_NODE, &no_match_ipv6_next_hop_cmd); - install_element (RMAP_NODE, &match_ipv6_address_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ipv6_address_prefix_list_cmd); install_element (RMAP_NODE, &set_ipv6_nexthop_global_cmd); install_element (RMAP_NODE, &no_set_ipv6_nexthop_global_cmd); - install_element (RMAP_NODE, &no_set_ipv6_nexthop_global_val_cmd); install_element (RMAP_NODE, &set_ipv6_nexthop_prefer_global_cmd); install_element (RMAP_NODE, &no_set_ipv6_nexthop_prefer_global_cmd); - install_element (RMAP_NODE, &set_ipv6_nexthop_local_cmd); - install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_cmd); - install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_val_cmd); install_element (RMAP_NODE, &set_ipv6_nexthop_peer_cmd); install_element (RMAP_NODE, &no_set_ipv6_nexthop_peer_cmd); #endif /* HAVE_IPV6 */ diff --git a/bgpd/bgp_table.c b/bgpd/bgp_table.c index 114c6ef013..884523919e 100644 --- a/bgpd/bgp_table.c +++ b/bgpd/bgp_table.c @@ -26,6 +26,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "vty.h" #include "queue.h" #include "filter.h" +#include "command.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_table.h" diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 4232ff8d9a..faa013ed91 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -20,8 +20,8 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include <zebra.h> -#include "lib/json.h" #include "command.h" +#include "lib/json.h" #include "prefix.h" #include "plist.h" #include "buffer.h" @@ -559,7 +559,7 @@ bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi, static void bgp_clear_star_soft_in (struct vty *vty, const char *name) { - bgp_clear_vty (vty,name, AFI_IP, SAFI_UNICAST, clear_all, + bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, BGP_CLEAR_SOFT_IN, NULL); bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, BGP_CLEAR_SOFT_IN, NULL); @@ -608,13 +608,14 @@ DEFUN (no_bgp_multiple_instance, DEFUN (bgp_config_type, bgp_config_type_cmd, - "bgp config-type (cisco|zebra)", + "bgp config-type <cisco|zebra>", BGP_STR "Configuration type\n" "cisco\n" "zebra\n") { - if (strncmp (argv[0], "c", 1) == 0) + int idx_vendor = 2; + if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) bgp_option_set (BGP_OPT_CONFIG_CISCO); else bgp_option_unset (BGP_OPT_CONFIG_CISCO); @@ -624,23 +625,17 @@ DEFUN (bgp_config_type, DEFUN (no_bgp_config_type, no_bgp_config_type_cmd, - "no bgp config-type", + "no bgp config-type [<cisco|zebra>]", NO_STR BGP_STR - "Display configuration type\n") + "Display configuration type\n" + "cisco\n" + "zebra\n") { bgp_option_unset (BGP_OPT_CONFIG_CISCO); return CMD_SUCCESS; } -ALIAS (no_bgp_config_type, - no_bgp_config_type_val_cmd, - "no bgp config-type (cisco|zebra)", - NO_STR - BGP_STR - "Configuration type\n" - "cisco\n" - "zebra\n") DEFUN (no_synchronization, no_synchronization_cmd, @@ -661,13 +656,17 @@ DEFUN (no_auto_summary, } /* "router bgp" commands. */ -DEFUN (router_bgp, - router_bgp_cmd, - "router bgp " CMD_AS_RANGE, +DEFUN (router_bgp, + router_bgp_cmd, + "router bgp [(1-4294967295) [<view|vrf> WORD]]", ROUTER_STR BGP_STR - AS_STR) + AS_STR + BGP_INSTANCE_HELP_STR) { + int idx_asn = 2; + int idx_view_vrf = 3; + int idx_vrf = 4; int ret; as_t as; struct bgp *bgp; @@ -675,7 +674,7 @@ DEFUN (router_bgp, enum bgp_instance_type inst_type; // "router bgp" without an ASN - if (argc < 1) + if (argc == 2) { //Pending: Make VRF option available for ASN less config bgp = bgp_get_default(); @@ -696,15 +695,16 @@ DEFUN (router_bgp, // "router bgp X" else { - VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX); + VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); inst_type = BGP_INSTANCE_TYPE_DEFAULT; - if (argc == 3) + if (argc > 3) { - name = argv[2]; - if (!strcmp(argv[1], "vrf")) + name = argv[idx_vrf]->arg; + + if (!strcmp(argv[idx_view_vrf]->text, "vrf")) inst_type = BGP_INSTANCE_TYPE_VRF; - else if (!strcmp(argv[1], "view")) + else if (!strcmp(argv[idx_view_vrf]->text, "view")) inst_type = BGP_INSTANCE_TYPE_VIEW; } @@ -734,37 +734,24 @@ DEFUN (router_bgp, return CMD_SUCCESS; } -ALIAS (router_bgp, - router_bgp_instance_cmd, - "router bgp " CMD_AS_RANGE " (view|vrf) WORD", - ROUTER_STR - BGP_STR - AS_STR - "BGP view\nBGP VRF\n" - "View/VRF name\n") - -ALIAS (router_bgp, - router_bgp_noasn_cmd, - "router bgp", - ROUTER_STR - BGP_STR) - /* "no router bgp" commands. */ DEFUN (no_router_bgp, no_router_bgp_cmd, - "no router bgp " CMD_AS_RANGE, + "no router bgp [(1-4294967295) [<view|vrf> WORD]]", NO_STR ROUTER_STR BGP_STR - AS_STR) + AS_STR + BGP_INSTANCE_HELP_STR) { + int idx_asn = 3; + int idx_vrf = 5; as_t as; struct bgp *bgp; const char *name = NULL; - // "no router bgp" without an ASN - if (argc < 1) + if (argc == 3) { //Pending: Make VRF option available for ASN less config bgp = bgp_get_default(); @@ -783,10 +770,10 @@ DEFUN (no_router_bgp, } else { - VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX); + VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); - if (argc == 3) - name = argv[2]; + if (argc > 4) + name = argv[idx_vrf]->arg; /* Lookup bgp structure. */ bgp = bgp_lookup (as, name); @@ -802,22 +789,7 @@ DEFUN (no_router_bgp, return CMD_SUCCESS; } -ALIAS (no_router_bgp, - no_router_bgp_instance_cmd, - "no router bgp " CMD_AS_RANGE " (view|vrf) WORD", - NO_STR - ROUTER_STR - BGP_STR - AS_STR - "BGP view\nBGP VRF\n" - "View/VRF name\n") -ALIAS (no_router_bgp, - no_router_bgp_noasn_cmd, - "no router bgp", - NO_STR - ROUTER_STR - BGP_STR) /* BGP router-id. */ @@ -828,13 +800,14 @@ DEFUN (bgp_router_id, "Override configured router identifier\n" "Manually configured router identifier\n") { + int idx_ipv4 = 2; int ret; struct in_addr id; struct bgp *bgp; bgp = vty->index; - ret = inet_aton (argv[0], &id); + ret = inet_aton (argv[idx_ipv4]->arg, &id); if (! ret) { vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE); @@ -848,20 +821,22 @@ DEFUN (bgp_router_id, DEFUN (no_bgp_router_id, no_bgp_router_id_cmd, - "no bgp router-id", + "no bgp router-id [A.B.C.D]", NO_STR BGP_STR - "Override configured router identifier\n") + "Override configured router identifier\n" + "Manually configured router identifier\n") { + int idx_router_id = 3; int ret; struct in_addr id; struct bgp *bgp; bgp = vty->index; - if (argc == 1) + if (argc > idx_router_id) { - ret = inet_aton (argv[0], &id); + ret = inet_aton (argv[idx_router_id]->arg, &id); if (! ret) { vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE); @@ -881,30 +856,24 @@ DEFUN (no_bgp_router_id, return CMD_SUCCESS; } -ALIAS (no_bgp_router_id, - no_bgp_router_id_val_cmd, - "no bgp router-id A.B.C.D", - NO_STR - BGP_STR - "Override configured router identifier\n" - "Manually configured router identifier\n") /* BGP Cluster ID. */ - DEFUN (bgp_cluster_id, bgp_cluster_id_cmd, - "bgp cluster-id A.B.C.D", + "bgp cluster-id <A.B.C.D|(1-4294967295)>", BGP_STR "Configure Route-Reflector Cluster-id\n" - "Route-Reflector Cluster-id in IP address format\n") + "Route-Reflector Cluster-id in IP address format\n" + "Route-Reflector Cluster-id as 32 bit quantity\n") { + int idx_ipv4 = 2; int ret; struct bgp *bgp; struct in_addr cluster; bgp = vty->index; - ret = inet_aton (argv[0], &cluster); + ret = inet_aton (argv[idx_ipv4]->arg, &cluster); if (! ret) { vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE); @@ -917,72 +886,39 @@ DEFUN (bgp_cluster_id, return CMD_SUCCESS; } -ALIAS (bgp_cluster_id, - bgp_cluster_id32_cmd, - "bgp cluster-id <1-4294967295>", - BGP_STR - "Configure Route-Reflector Cluster-id\n" - "Route-Reflector Cluster-id as 32 bit quantity\n") - DEFUN (no_bgp_cluster_id, no_bgp_cluster_id_cmd, - "no bgp cluster-id", + "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", NO_STR BGP_STR - "Configure Route-Reflector Cluster-id\n") + "Configure Route-Reflector Cluster-id\n" + "Route-Reflector Cluster-id in IP address format\n" + "Route-Reflector Cluster-id as 32 bit quantity\n") { - int ret; struct bgp *bgp; - struct in_addr cluster; bgp = vty->index; - - if (argc == 1) - { - ret = inet_aton (argv[0], &cluster); - if (! ret) - { - vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - bgp_cluster_id_unset (bgp); bgp_clear_star_soft_out (vty, bgp->name); return CMD_SUCCESS; } -ALIAS (no_bgp_cluster_id, - no_bgp_cluster_id_ip_cmd, - "no bgp cluster-id A.B.C.D", - NO_STR - BGP_STR - "Configure Route-Reflector Cluster-id\n" - "Route-Reflector Cluster-id in IP address format\n") - -ALIAS (no_bgp_cluster_id, - no_bgp_cluster_id_decimal_cmd, - "no bgp cluster-id <1-4294967295>", - NO_STR - BGP_STR - "Configure Route-Reflector Cluster-id\n" - "Route-Reflector Cluster-id as 32 bit quantity\n") - DEFUN (bgp_confederation_identifier, bgp_confederation_identifier_cmd, - "bgp confederation identifier " CMD_AS_RANGE, + "bgp confederation identifier (1-4294967295)", "BGP specific commands\n" "AS confederation parameters\n" "AS number\n" "Set routing domain confederation AS\n") { + int idx_number = 3; struct bgp *bgp; as_t as; bgp = vty->index; - VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX); + VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); bgp_confederation_id_set (bgp, as); @@ -991,7 +927,7 @@ DEFUN (bgp_confederation_identifier, DEFUN (no_bgp_confederation_identifier, no_bgp_confederation_identifier_cmd, - "no bgp confederation identifier", + "no bgp confederation identifier [(1-4294967295)]", NO_STR "BGP specific commands\n" "AS confederation parameters\n" @@ -1000,38 +936,29 @@ DEFUN (no_bgp_confederation_identifier, struct bgp *bgp; bgp = vty->index; - bgp_confederation_id_unset (bgp); return CMD_SUCCESS; } -ALIAS (no_bgp_confederation_identifier, - no_bgp_confederation_identifier_arg_cmd, - "no bgp confederation identifier " CMD_AS_RANGE, - NO_STR - "BGP specific commands\n" - "AS confederation parameters\n" - "AS number\n" - "Set routing domain confederation AS\n") - DEFUN (bgp_confederation_peers, bgp_confederation_peers_cmd, - "bgp confederation peers ." CMD_AS_RANGE, + "bgp confederation peers (1-4294967295)...", "BGP specific commands\n" "AS confederation parameters\n" "Peer ASs in BGP confederation\n" AS_STR) { + int idx_asn = 3; struct bgp *bgp; as_t as; int i; bgp = vty->index; - for (i = 0; i < argc; i++) + for (i = idx_asn; i < argc; i++) { - VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX); + VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); if (bgp->as == as) { @@ -1047,22 +974,23 @@ DEFUN (bgp_confederation_peers, DEFUN (no_bgp_confederation_peers, no_bgp_confederation_peers_cmd, - "no bgp confederation peers ." CMD_AS_RANGE, + "no bgp confederation peers (1-4294967295)...", NO_STR "BGP specific commands\n" "AS confederation parameters\n" "Peer ASs in BGP confederation\n" AS_STR) { + int idx_asn = 4; struct bgp *bgp; as_t as; int i; bgp = vty->index; - for (i = 0; i < argc; i++) + for (i = idx_asn; i < argc; i++) { - VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX); + VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); bgp_confederation_peers_remove (bgp, as); } @@ -1089,12 +1017,10 @@ bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths, safi = bgp_node_safi (vty); if (set) - { - VTY_GET_INTEGER_RANGE ("maximum-paths", maxpaths, mpaths, 1, - MULTIPATH_NUM); - ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths, - options); - } + { + maxpaths = strtol(mpaths, NULL, 10); + ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths, options); + } else ret = bgp_maximum_paths_unset (bgp, afi, safi, peer_type); @@ -1134,18 +1060,19 @@ DEFUN (bgp_maxmed_admin, DEFUN (bgp_maxmed_admin_medv, bgp_maxmed_admin_medv_cmd, - "bgp max-med administrative <0-4294967294>", + "bgp max-med administrative (0-4294967294)", BGP_STR "Advertise routes with max-med\n" "Administratively applied, for an indefinite period\n" "Max MED value to be used\n") { + int idx_number = 3; struct bgp *bgp; bgp = vty->index; bgp->v_maxmed_admin = 1; - VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[0]); + VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[idx_number]->arg); bgp_maxmed_update(bgp); @@ -1154,55 +1081,37 @@ DEFUN (bgp_maxmed_admin_medv, DEFUN (no_bgp_maxmed_admin, no_bgp_maxmed_admin_cmd, - "no bgp max-med administrative", + "no bgp max-med administrative [(0-4294967294)]", NO_STR BGP_STR "Advertise routes with max-med\n" - "Administratively applied, for an indefinite period\n") + "Administratively applied, for an indefinite period\n" + "Max MED value to be used\n") { struct bgp *bgp; bgp = vty->index; - bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; - bgp_maxmed_update(bgp); return CMD_SUCCESS; } -ALIAS (no_bgp_maxmed_admin, - no_bgp_maxmed_admin_medv_cmd, - "no bgp max-med administrative <0-4294967294>", - NO_STR - BGP_STR - "Advertise routes with max-med\n" - "Administratively applied, for an indefinite period\n" - "Max MED value to be used\n") - - DEFUN (bgp_maxmed_onstartup, bgp_maxmed_onstartup_cmd, - "bgp max-med on-startup <5-86400>", + "bgp max-med on-startup (5-86400)", BGP_STR "Advertise routes with max-med\n" "Effective on a startup\n" "Time (seconds) period for max-med\n") { + int idx_number = 3; struct bgp *bgp; bgp = vty->index; - - if (argc != 1) - { - vty_out (vty, "%% Must supply max-med on-startup period"); - return CMD_WARNING; - } - - VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[0]); + VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; - bgp_maxmed_update(bgp); return CMD_SUCCESS; @@ -1210,26 +1119,20 @@ DEFUN (bgp_maxmed_onstartup, DEFUN (bgp_maxmed_onstartup_medv, bgp_maxmed_onstartup_medv_cmd, - "bgp max-med on-startup <5-86400> <0-4294967294>", + "bgp max-med on-startup (5-86400) (0-4294967294)", BGP_STR "Advertise routes with max-med\n" "Effective on a startup\n" "Time (seconds) period for max-med\n" "Max MED value to be used\n") { + int idx_number = 3; + int idx_number_2 = 4; struct bgp *bgp; bgp = vty->index; - - if (argc != 2) - { - vty_out (vty, "%% Must supply max-med on-startup period and med value"); - return CMD_WARNING; - } - - VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[0]); - VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[1]); - + VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); + VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[idx_number_2]->arg); bgp_maxmed_update(bgp); return CMD_SUCCESS; @@ -1237,11 +1140,13 @@ DEFUN (bgp_maxmed_onstartup_medv, DEFUN (no_bgp_maxmed_onstartup, no_bgp_maxmed_onstartup_cmd, - "no bgp max-med on-startup", + "no bgp max-med on-startup [(5-86400) [(0-4294967294)]]", NO_STR BGP_STR "Advertise routes with max-med\n" - "Effective on a startup\n") + "Effective on a startup\n" + "Time (seconds) period for max-med\n" + "Max MED value to be used\n") { struct bgp *bgp; @@ -1262,25 +1167,6 @@ DEFUN (no_bgp_maxmed_onstartup, return CMD_SUCCESS; } -ALIAS (no_bgp_maxmed_onstartup, - no_bgp_maxmed_onstartup_period_cmd, - "no bgp max-med on-startup <5-86400>", - NO_STR - BGP_STR - "Advertise routes with max-med\n" - "Effective on a startup\n" - "Time (seconds) period for max-med\n") - -ALIAS (no_bgp_maxmed_onstartup, - no_bgp_maxmed_onstartup_period_medv_cmd, - "no bgp max-med on-startup <5-86400> <0-4294967294>", - NO_STR - BGP_STR - "Advertise routes with max-med\n" - "Effective on a startup\n" - "Time (seconds) period for max-med\n" - "Max MED value to be used\n") - static int bgp_update_delay_config_vty (struct vty *vty, const char *delay, const char *wait) @@ -1348,41 +1234,39 @@ bgp_config_write_update_delay (struct vty *vty, struct bgp *bgp) /* Update-delay configuration */ DEFUN (bgp_update_delay, bgp_update_delay_cmd, - "update-delay <0-3600>", + "update-delay (0-3600)", "Force initial delay for best-path and updates\n" "Seconds\n") { - return bgp_update_delay_config_vty(vty, argv[0], NULL); + int idx_number = 1; + return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); } DEFUN (bgp_update_delay_establish_wait, bgp_update_delay_establish_wait_cmd, - "update-delay <0-3600> <1-3600>", + "update-delay (0-3600) (1-3600)", "Force initial delay for best-path and updates\n" "Seconds\n" "Wait for peers to be established\n" "Seconds\n") { - return bgp_update_delay_config_vty(vty, argv[0], argv[1]); + int idx_number = 1; + int idx_number_2 = 2; + return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, argv[idx_number_2]->arg); } /* Update-delay deconfiguration */ DEFUN (no_bgp_update_delay, no_bgp_update_delay_cmd, - "no update-delay <0-3600>", + "no update-delay [(0-3600) [(1-3600)]]", + NO_STR "Force initial delay for best-path and updates\n" - "Seconds\n") + "Seconds\n" + "Wait for peers to be established\n") { return bgp_update_delay_deconfig_vty(vty); } -ALIAS (no_bgp_update_delay, - no_bgp_update_delay_establish_wait_cmd, - "no update-delay <0-3600> <1-3600>", - "Force initial delay for best-path and updates\n" - "Seconds\n" - "Wait for peers to be established\n" - "Seconds\n") static int bgp_wpkt_quanta_config_vty (struct vty *vty, const char *num, char set) @@ -1414,21 +1298,24 @@ bgp_config_write_wpkt_quanta (struct vty *vty, struct bgp *bgp) /* Update-delay configuration */ DEFUN (bgp_wpkt_quanta, bgp_wpkt_quanta_cmd, - "write-quanta <1-10000>", + "write-quanta (1-10000)", "How many packets to write to peer socket per run\n" "Number of packets\n") { - return bgp_wpkt_quanta_config_vty(vty, argv[0], 1); + int idx_number = 1; + return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); } /* Update-delay deconfiguration */ DEFUN (no_bgp_wpkt_quanta, no_bgp_wpkt_quanta_cmd, - "no write-quanta <1-10000>", + "no write-quanta (1-10000)", + NO_STR "How many packets to write to peer socket per run\n" "Number of packets\n") { - return bgp_wpkt_quanta_config_vty(vty, argv[0], 0); + int idx_number = 2; + return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); } static int @@ -1460,57 +1347,62 @@ bgp_config_write_coalesce_time (struct vty *vty, struct bgp *bgp) DEFUN (bgp_coalesce_time, bgp_coalesce_time_cmd, - "coalesce-time <0-4294967295>", + "coalesce-time (0-4294967295)", "Subgroup coalesce timer\n" "Subgroup coalesce timer value (in ms)\n") { - return bgp_coalesce_config_vty(vty, argv[0], 1); + int idx_number = 1; + return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 1); } DEFUN (no_bgp_coalesce_time, no_bgp_coalesce_time_cmd, - "no coalesce-time <0-4294967295>", + "no coalesce-time (0-4294967295)", "Subgroup coalesce timer\n" "Subgroup coalesce timer value (in ms)\n") { - return bgp_coalesce_config_vty(vty, argv[0], 0); + int idx_number = 2; + return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 0); } /* Maximum-paths configuration */ DEFUN (bgp_maxpaths, bgp_maxpaths_cmd, - "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), + "maximum-paths (1-255)", "Forward packets over multiple paths\n" "Number of paths\n") { - return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[0], 0, 1); + int idx_number = 1; + return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[idx_number]->arg, 0, 1); } DEFUN (bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_cmd, - "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), + "maximum-paths ibgp (1-255)", "Forward packets over multiple paths\n" "iBGP-multipath\n" "Number of paths\n") { - return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[0], 0, 1); + int idx_number = 2; + return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, 0, 1); } DEFUN (bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_cmd, - "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", + "maximum-paths ibgp (1-255) equal-cluster-length", "Forward packets over multiple paths\n" "iBGP-multipath\n" "Number of paths\n" "Match the cluster length\n") { - return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[0], + int idx_number = 2; + return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); } DEFUN (no_bgp_maxpaths, no_bgp_maxpaths_cmd, - "no maximum-paths", + "no maximum-paths [(1-255)]", NO_STR "Forward packets over multiple paths\n" "Number of paths\n") @@ -1518,41 +1410,18 @@ DEFUN (no_bgp_maxpaths, return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); } -ALIAS (no_bgp_maxpaths, - no_bgp_maxpaths_arg_cmd, - "no maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), - NO_STR - "Forward packets over multiple paths\n" - "Number of paths\n") - DEFUN (no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_cmd, - "no maximum-paths ibgp", + "no maximum-paths ibgp [(1-255) [equal-cluster-length]]", NO_STR "Forward packets over multiple paths\n" "iBGP-multipath\n" - "Number of paths\n") + "Number of paths\n" + "Match the cluster length\n") { return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); } -ALIAS (no_bgp_maxpaths_ibgp, - no_bgp_maxpaths_ibgp_arg_cmd, - "no maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), - NO_STR - "Forward packets over multiple paths\n" - "iBGP-multipath\n" - "Number of paths\n") - -ALIAS (no_bgp_maxpaths_ibgp, - no_bgp_maxpaths_ibgp_cluster_cmd, - "no maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", - NO_STR - "Forward packets over multiple paths\n" - "iBGP-multipath\n" - "Number of paths\n" - "Match the cluster length\n") - int bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, int *write) @@ -1582,20 +1451,22 @@ bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi, DEFUN (bgp_timers, bgp_timers_cmd, - "timers bgp <0-65535> <0-65535>", + "timers bgp (0-65535) (0-65535)", "Adjust routing timers\n" "BGP timers\n" "Keepalive interval\n" "Holdtime\n") { + int idx_number = 2; + int idx_number_2 = 3; struct bgp *bgp; unsigned long keepalive = 0; unsigned long holdtime = 0; bgp = vty->index; - VTY_GET_INTEGER ("keepalive", keepalive, argv[0]); - VTY_GET_INTEGER ("holdtime", holdtime, argv[1]); + VTY_GET_INTEGER ("keepalive", keepalive, argv[idx_number]->arg); + VTY_GET_INTEGER ("holdtime", holdtime, argv[idx_number_2]->arg); /* Holdtime value check. */ if (holdtime < 3 && holdtime != 0) @@ -1612,10 +1483,12 @@ DEFUN (bgp_timers, DEFUN (no_bgp_timers, no_bgp_timers_cmd, - "no timers bgp", + "no timers bgp [(0-65535) (0-65535)]", NO_STR "Adjust routing timers\n" - "BGP timers\n") + "BGP timers\n" + "Keepalive interval\n" + "Holdtime\n") { struct bgp *bgp; @@ -1625,14 +1498,6 @@ DEFUN (no_bgp_timers, return CMD_SUCCESS; } -ALIAS (no_bgp_timers, - no_bgp_timers_arg_cmd, - "no timers bgp <0-65535> <0-65535>", - NO_STR - "Adjust routing timers\n" - "BGP timers\n" - "Keepalive interval\n" - "Holdtime\n") DEFUN (bgp_client_to_client_reflection, bgp_client_to_client_reflection_cmd, @@ -1799,12 +1664,13 @@ DEFUN (no_bgp_graceful_restart, DEFUN (bgp_graceful_restart_stalepath_time, bgp_graceful_restart_stalepath_time_cmd, - "bgp graceful-restart stalepath-time <1-3600>", + "bgp graceful-restart stalepath-time (1-3600)", "BGP specific commands\n" "Graceful restart capability parameters\n" "Set the max time to hold onto restarting peer's stale paths\n" "Delay value (seconds)\n") { + int idx_number = 3; struct bgp *bgp; u_int32_t stalepath; @@ -1812,19 +1678,20 @@ DEFUN (bgp_graceful_restart_stalepath_time, if (! bgp) return CMD_WARNING; - VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[0], 1, 3600); + VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[idx_number]->arg, 1, 3600); bgp->stalepath_time = stalepath; return CMD_SUCCESS; } DEFUN (bgp_graceful_restart_restart_time, bgp_graceful_restart_restart_time_cmd, - "bgp graceful-restart restart-time <1-3600>", + "bgp graceful-restart restart-time (1-3600)", "BGP specific commands\n" "Graceful restart capability parameters\n" "Set the time to wait to delete stale routes before a BGP open message is received\n" "Delay value (seconds)\n") { + int idx_number = 3; struct bgp *bgp; u_int32_t restart; @@ -1832,18 +1699,19 @@ DEFUN (bgp_graceful_restart_restart_time, if (! bgp) return CMD_WARNING; - VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[0], 1, 3600); + VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[idx_number]->arg, 1, 3600); bgp->restart_time = restart; return CMD_SUCCESS; } DEFUN (no_bgp_graceful_restart_stalepath_time, no_bgp_graceful_restart_stalepath_time_cmd, - "no bgp graceful-restart stalepath-time", + "no bgp graceful-restart stalepath-time [(1-3600)]", NO_STR "BGP specific commands\n" "Graceful restart capability parameters\n" - "Set the max time to hold onto restarting peer's stale paths\n") + "Set the max time to hold onto restarting peer's stale paths\n" + "Delay value (seconds)\n") { struct bgp *bgp; @@ -1857,11 +1725,12 @@ DEFUN (no_bgp_graceful_restart_stalepath_time, DEFUN (no_bgp_graceful_restart_restart_time, no_bgp_graceful_restart_restart_time_cmd, - "no bgp graceful-restart restart-time", + "no bgp graceful-restart restart-time [(1-3600)]", NO_STR "BGP specific commands\n" "Graceful restart capability parameters\n" - "Set the time to wait to delete stale routes before a BGP open message is received\n") + "Set the time to wait to delete stale routes before a BGP open message is received\n" + "Delay value (seconds)\n") { struct bgp *bgp; @@ -1873,24 +1742,6 @@ DEFUN (no_bgp_graceful_restart_restart_time, return CMD_SUCCESS; } -ALIAS (no_bgp_graceful_restart_stalepath_time, - no_bgp_graceful_restart_stalepath_time_val_cmd, - "no bgp graceful-restart stalepath-time <1-3600>", - NO_STR - "BGP specific commands\n" - "Graceful restart capability parameters\n" - "Set the max time to hold onto restarting peer's stale paths\n" - "Delay value (seconds)\n") - -ALIAS (no_bgp_graceful_restart_restart_time, - no_bgp_graceful_restart_restart_time_val_cmd, - "no bgp graceful-restart restart-time <1-3600>", - NO_STR - "BGP specific commands\n" - "Graceful restart capability parameters\n" - "Set the time to wait to delete stale routes before a BGP open message is received\n" - "Delay value (seconds)\n") - /* "bgp fast-external-failover" configuration. */ DEFUN (bgp_fast_external_failover, bgp_fast_external_failover_cmd, @@ -2060,7 +1911,7 @@ DEFUN (no_bgp_bestpath_aspath_confed, /* "bgp bestpath as-path multipath-relax" configuration. */ DEFUN (bgp_bestpath_aspath_multipath_relax, bgp_bestpath_aspath_multipath_relax_cmd, - "bgp bestpath as-path multipath-relax {as-set|no-as-set}", + "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", "BGP specific commands\n" "Change the default bestpath selection\n" "AS-path attribute\n" @@ -2068,6 +1919,7 @@ DEFUN (bgp_bestpath_aspath_multipath_relax, "Generate an AS_SET\n" "Do not generate an AS_SET\n") { + int idx = 0; struct bgp *bgp; bgp = vty->index; @@ -2075,7 +1927,7 @@ DEFUN (bgp_bestpath_aspath_multipath_relax, /* no-as-set is now the default behavior so we can silently * ignore it */ - if (argv[0] != NULL && strncmp (argv[0], "a", 1) == 0) + if (argv_find (argv, argc, "as-set", &idx)) bgp_flag_set (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); else bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET) ; @@ -2087,7 +1939,7 @@ DEFUN (bgp_bestpath_aspath_multipath_relax, DEFUN (no_bgp_bestpath_aspath_multipath_relax, no_bgp_bestpath_aspath_multipath_relax_cmd, - "no bgp bestpath as-path multipath-relax {as-set|no-as-set}", + "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", NO_STR "BGP specific commands\n" "Change the default bestpath selection\n" @@ -2137,20 +1989,22 @@ DEFUN (no_bgp_log_neighbor_changes, /* "bgp bestpath med" configuration. */ DEFUN (bgp_bestpath_med, bgp_bestpath_med_cmd, - "bgp bestpath med (confed|missing-as-worst)", + "bgp bestpath med [<confed [missing-as-worst]|missing-as-worst [confed]>]", "BGP specific commands\n" "Change the default bestpath selection\n" "MED attribute\n" "Compare MED among confederation paths\n" - "Treat missing MED as the least preferred one\n") + "Treat missing MED as the least preferred one\n" + "Treat missing MED as the least preferred one\n" + "Compare MED among confederation paths\n") { - struct bgp *bgp; - - bgp = vty->index; + struct bgp *bgp = vty->index; - if (strncmp (argv[0], "confed", 1) == 0) + int idx = 0; + if (argv_find (argv, argc, "confed", &idx)) bgp_flag_set (bgp, BGP_FLAG_MED_CONFED); - else + idx = 0; + if (argv_find (argv, argc, "missing-as-worst", &idx)) bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST); bgp_recalculate_all_bestpaths (bgp); @@ -2158,37 +2012,9 @@ DEFUN (bgp_bestpath_med, return CMD_SUCCESS; } -DEFUN (bgp_bestpath_med2, - bgp_bestpath_med2_cmd, - "bgp bestpath med confed missing-as-worst", - "BGP specific commands\n" - "Change the default bestpath selection\n" - "MED attribute\n" - "Compare MED among confederation paths\n" - "Treat missing MED as the least preferred one\n") -{ - struct bgp *bgp; - - bgp = vty->index; - bgp_flag_set (bgp, BGP_FLAG_MED_CONFED); - bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST); - bgp_recalculate_all_bestpaths (bgp); - - return CMD_SUCCESS; -} - -ALIAS (bgp_bestpath_med2, - bgp_bestpath_med3_cmd, - "bgp bestpath med missing-as-worst confed", - "BGP specific commands\n" - "Change the default bestpath selection\n" - "MED attribute\n" - "Treat missing MED as the least preferred one\n" - "Compare MED among confederation paths\n") - DEFUN (no_bgp_bestpath_med, no_bgp_bestpath_med_cmd, - "no bgp bestpath med (confed|missing-as-worst)", + "no bgp bestpath med [<confed [missing-as-worst]|missing-as-worst [confed]>]", NO_STR "BGP specific commands\n" "Change the default bestpath selection\n" @@ -2196,13 +2022,13 @@ DEFUN (no_bgp_bestpath_med, "Compare MED among confederation paths\n" "Treat missing MED as the least preferred one\n") { - struct bgp *bgp; + struct bgp *bgp = vty->index; - bgp = vty->index; - - if (strncmp (argv[0], "confed", 1) == 0) + int idx = 0; + if (argv_find (argv, argc, "confed", &idx)) bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED); - else + idx = 0; + if (argv_find (argv, argc, "missing-as-worst", &idx)) bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST); bgp_recalculate_all_bestpaths (bgp); @@ -2210,36 +2036,6 @@ DEFUN (no_bgp_bestpath_med, return CMD_SUCCESS; } -DEFUN (no_bgp_bestpath_med2, - no_bgp_bestpath_med2_cmd, - "no bgp bestpath med confed missing-as-worst", - NO_STR - "BGP specific commands\n" - "Change the default bestpath selection\n" - "MED attribute\n" - "Compare MED among confederation paths\n" - "Treat missing MED as the least preferred one\n") -{ - struct bgp *bgp; - - bgp = vty->index; - bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED); - bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST); - bgp_recalculate_all_bestpaths (bgp); - - return CMD_SUCCESS; -} - -ALIAS (no_bgp_bestpath_med2, - no_bgp_bestpath_med3_cmd, - "no bgp bestpath med missing-as-worst confed", - NO_STR - "BGP specific commands\n" - "Change the default bestpath selection\n" - "MED attribute\n" - "Treat missing MED as the least preferred one\n" - "Compare MED among confederation paths\n") - /* "no bgp default ipv4-unicast". */ DEFUN (no_bgp_default_ipv4_unicast, no_bgp_default_ipv4_unicast_cmd, @@ -2350,18 +2146,19 @@ DEFUN (no_bgp_network_import_check, DEFUN (bgp_default_local_preference, bgp_default_local_preference_cmd, - "bgp default local-preference <0-4294967295>", + "bgp default local-preference (0-4294967295)", "BGP specific commands\n" "Configure BGP defaults\n" "local preference (higher=more preferred)\n" "Configure default local preference value\n") { + int idx_number = 3; struct bgp *bgp; u_int32_t local_pref; bgp = vty->index; - VTY_GET_INTEGER ("local preference", local_pref, argv[0]); + VTY_GET_INTEGER ("local preference", local_pref, argv[idx_number]->arg); bgp_default_local_preference_set (bgp, local_pref); bgp_clear_star_soft_in (vty, bgp->name); @@ -2371,11 +2168,12 @@ DEFUN (bgp_default_local_preference, DEFUN (no_bgp_default_local_preference, no_bgp_default_local_preference_cmd, - "no bgp default local-preference", + "no bgp default local-preference [(0-4294967295)]", NO_STR "BGP specific commands\n" "Configure BGP defaults\n" - "local preference (higher=more preferred)\n") + "local preference (higher=more preferred)\n" + "Configure default local preference value\n") { struct bgp *bgp; @@ -2386,29 +2184,22 @@ DEFUN (no_bgp_default_local_preference, return CMD_SUCCESS; } -ALIAS (no_bgp_default_local_preference, - no_bgp_default_local_preference_val_cmd, - "no bgp default local-preference <0-4294967295>", - NO_STR - "BGP specific commands\n" - "Configure BGP defaults\n" - "local preference (higher=more preferred)\n" - "Configure default local preference value\n") DEFUN (bgp_default_subgroup_pkt_queue_max, bgp_default_subgroup_pkt_queue_max_cmd, - "bgp default subgroup-pkt-queue-max <20-100>", + "bgp default subgroup-pkt-queue-max (20-100)", "BGP specific commands\n" "Configure BGP defaults\n" "subgroup-pkt-queue-max\n" "Configure subgroup packet queue max\n") { + int idx_number = 3; struct bgp *bgp; u_int32_t max_size; bgp = vty->index; - VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[0]); + VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[idx_number]->arg); bgp_default_subgroup_pkt_queue_max_set (bgp, max_size); @@ -2417,11 +2208,12 @@ DEFUN (bgp_default_subgroup_pkt_queue_max, DEFUN (no_bgp_default_subgroup_pkt_queue_max, no_bgp_default_subgroup_pkt_queue_max_cmd, - "no bgp default subgroup-pkt-queue-max", + "no bgp default subgroup-pkt-queue-max [(20-100)]", NO_STR "BGP specific commands\n" "Configure BGP defaults\n" - "subgroup-pkt-queue-max\n") + "subgroup-pkt-queue-max\n" + "Configure subgroup packet queue max\n") { struct bgp *bgp; @@ -2430,14 +2222,6 @@ DEFUN (no_bgp_default_subgroup_pkt_queue_max, return CMD_SUCCESS; } -ALIAS (no_bgp_default_subgroup_pkt_queue_max, - no_bgp_default_subgroup_pkt_queue_max_val_cmd, - "no bgp default subgroup-pkt-queue-max <20-100>", - NO_STR - "BGP specific commands\n" - "Configure BGP defaults\n" - "subgroup-pkt-queue-max\n" - "Configure subgroup packet queue max\n") DEFUN (bgp_rr_allow_outbound_policy, bgp_rr_allow_outbound_policy_cmd, @@ -2484,18 +2268,19 @@ DEFUN (no_bgp_rr_allow_outbound_policy, DEFUN (bgp_listen_limit, bgp_listen_limit_cmd, - "bgp listen limit " DYNAMIC_NEIGHBOR_LIMIT_RANGE, + "bgp listen limit (1-5000)", "BGP specific commands\n" "Configure BGP defaults\n" "maximum number of BGP Dynamic Neighbors that can be created\n" "Configure Dynamic Neighbors listen limit value\n") { + int idx_number = 3; struct bgp *bgp; int listen_limit; bgp = vty->index; - VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[0], + VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[idx_number]->arg, BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN, BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX); @@ -2506,11 +2291,12 @@ DEFUN (bgp_listen_limit, DEFUN (no_bgp_listen_limit, no_bgp_listen_limit_cmd, - "no bgp listen limit", + "no bgp listen limit [(1-5000)]", "BGP specific commands\n" "Configure BGP defaults\n" "unset maximum number of BGP Dynamic Neighbors that can be created\n" - "Configure Dynamic Neighbors listen limit value to default\n") + "Configure Dynamic Neighbors listen limit value to default\n" + "Configure Dynamic Neighbors listen limit value\n") { struct bgp *bgp; @@ -2519,14 +2305,6 @@ DEFUN (no_bgp_listen_limit, return CMD_SUCCESS; } -ALIAS (no_bgp_listen_limit, - no_bgp_listen_limit_val_cmd, - "no bgp listen limit " DYNAMIC_NEIGHBOR_LIMIT_RANGE, - NO_STR - "BGP specific commands\n" - "Configure BGP defaults\n" - "maximum number of BGP Dynamic Neighbors that can be created\n" - "Configure Dynamic Neighbors listen limit value\n") /* * Check if this listen range is already configured. Check for exact @@ -2562,24 +2340,31 @@ listen_range_exists (struct bgp *bgp, struct prefix *range, int exact) DEFUN (bgp_listen_range, bgp_listen_range_cmd, - LISTEN_RANGE_CMD "peer-group WORD" , + "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", "BGP specific commands\n" - "Configure BGP Dynamic Neighbors\n" - "add a listening range for Dynamic Neighbors\n" - LISTEN_RANGE_ADDR_STR) + "Configure BGP dynamic neighbors listen range\n" + "Configure BGP dynamic neighbors listen range\n" + NEIGHBOR_ADDR_STR + "Member of the peer-group\n" + "Peer-group name\n") { struct bgp *bgp; struct prefix range; struct peer_group *group, *existing_group; afi_t afi; int ret; + int idx = 0; - bgp = vty->index; + argv_find (argv, argc, "A.B.C.D/M", &idx); + argv_find (argv, argc, "X:X::X:X/M", &idx); + char *prefix = argv[idx]->arg; + argv_find (argv, argc, "WORD", &idx); + char *peergroup = argv[idx]->arg; - //VTY_GET_IPV4_PREFIX ("listen range", range, argv[0]); + bgp = vty->index; /* Convert IP prefix string to struct prefix. */ - ret = str2prefix (argv[0], &range); + ret = str2prefix (prefix, &range); if (! ret) { vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); @@ -2588,14 +2373,12 @@ DEFUN (bgp_listen_range, afi = family2afi(range.family); -#ifdef HAVE_IPV6 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) { vty_out (vty, "%% Malformed listen range (link-local address)%s", VTY_NEWLINE); return CMD_WARNING; } -#endif /* HAVE_IPV6 */ apply_mask (&range); @@ -2603,7 +2386,7 @@ DEFUN (bgp_listen_range, existing_group = listen_range_exists (bgp, &range, 1); if (existing_group) { - if (strcmp (existing_group->name, argv[1]) == 0) + if (strcmp (existing_group->name, peergroup) == 0) return CMD_SUCCESS; else { @@ -2621,7 +2404,7 @@ DEFUN (bgp_listen_range, return CMD_WARNING; } - group = peer_group_lookup (bgp, argv[1]); + group = peer_group_lookup (bgp, peergroup); if (! group) { vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); @@ -2634,24 +2417,34 @@ DEFUN (bgp_listen_range, DEFUN (no_bgp_listen_range, no_bgp_listen_range_cmd, - "no bgp listen range A.B.C.D/M peer-group WORD" , + "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", + NO_STR "BGP specific commands\n" - "Configure BGP defaults\n" - "delete a listening range for Dynamic Neighbors\n" - "Remove Dynamic Neighbors listening range\n") + "Unconfigure BGP dynamic neighbors listen range\n" + "Unconfigure BGP dynamic neighbors listen range\n" + NEIGHBOR_ADDR_STR + "Member of the peer-group\n" + "Peer-group name\n") { struct bgp *bgp; struct prefix range; struct peer_group *group; afi_t afi; int ret; + int idx = 0; + + argv_find (argv, argc, "A.B.C.D/M", &idx); + argv_find (argv, argc, "X:X::X:X/M", &idx); + char *prefix = argv[idx]->arg; + argv_find (argv, argc, "WORD", &idx); + char *peergroup = argv[idx]->arg; bgp = vty->index; - // VTY_GET_IPV4_PREFIX ("listen range", range, argv[0]); + // VTY_GET_IPV4_PREFIX ("listen range", range, argv[idx_ipv4_prefixlen]->arg); /* Convert IP prefix string to struct prefix. */ - ret = str2prefix (argv[0], &range); + ret = str2prefix (prefix, &range); if (! ret) { vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); @@ -2660,19 +2453,16 @@ DEFUN (no_bgp_listen_range, afi = family2afi(range.family); -#ifdef HAVE_IPV6 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) { vty_out (vty, "%% Malformed listen range (link-local address)%s", VTY_NEWLINE); return CMD_WARNING; } -#endif /* HAVE_IPV6 */ apply_mask (&range); - - group = peer_group_lookup (bgp, argv[1]); + group = peer_group_lookup (bgp, peergroup); if (! group) { vty_out (vty, "%% Peer-group does not exist%s", VTY_NEWLINE); @@ -2746,7 +2536,7 @@ DEFUN (no_bgp_disable_connected_route_check, static int -peer_remote_as_vty (struct vty *vty, const char *peer_str, +peer_remote_as_vty (struct vty *vty, const char *peer_str, const char *as_str, afi_t afi, safi_t safi) { int ret; @@ -2817,13 +2607,17 @@ peer_remote_as_vty (struct vty *vty, const char *peer_str, DEFUN (neighbor_remote_as, neighbor_remote_as_cmd, - NEIGHBOR_CMD2 "remote-as (" CMD_AS_RANGE "|external|internal)", + "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|external|internal>", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Specify a BGP neighbor\n" - AS_STR) + AS_STR + "External BGP peer\n" + "Internal BGP peer\n") { - return peer_remote_as_vty (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST); + int idx_peer = 1; + int idx_remote_as = 3; + return peer_remote_as_vty (vty, argv[idx_peer]->arg, argv[idx_remote_as]->arg, AFI_IP, SAFI_UNICAST); } static int @@ -2930,76 +2724,76 @@ peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi, DEFUN (neighbor_interface_config, neighbor_interface_config_cmd, - "neighbor WORD interface", + "neighbor WORD interface [peer-group WORD]", NEIGHBOR_STR "Interface name or neighbor tag\n" - "Enable BGP on interface\n") + "Enable BGP on interface\n" + "Member of the peer-group\n" + "Peer-group name\n") { - if (argc == 2) - return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 0, - argv[1], NULL); + int idx_word = 1; + int idx_peer_group_word = 4; + + if (argc > idx_peer_group_word) + return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, + argv[idx_peer_group_word]->arg, NULL); else - return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 0, + return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, NULL, NULL); } -ALIAS (neighbor_interface_config, - neighbor_interface_config_peergroup_cmd, - "neighbor WORD interface peer-group WORD", - NEIGHBOR_STR - "Interface name or neighbor tag\n" - "Enable BGP on interface\n" - "Member of the peer-group\n" - "peer-group name\n") - DEFUN (neighbor_interface_config_v6only, neighbor_interface_config_v6only_cmd, - "neighbor WORD interface v6only", + "neighbor WORD interface v6only [peer-group WORD]", NEIGHBOR_STR "Interface name or neighbor tag\n" "Enable BGP on interface\n" - "Enable BGP with v6 link-local only\n") + "Enable BGP with v6 link-local only\n" + "Member of the peer-group\n" + "Peer-group name\n") { - if (argc == 2) - return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 1, - argv[1], NULL); - else - return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 1, - NULL, NULL); + int idx_word = 1; + int idx_peer_group_word = 5; + + if (argc > idx_peer_group_word) + return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, + argv[idx_peer_group_word]->arg, NULL); + + return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, + NULL, NULL); } -ALIAS (neighbor_interface_config_v6only, - neighbor_interface_config_v6only_peergroup_cmd, - "neighbor WORD interface v6only peer-group WORD", - NEIGHBOR_STR - "Interface name or neighbor tag\n" - "Enable BGP on interface\n" - "Enable BGP with v6 link-local only\n" - "Member of the peer-group\n" - "peer-group name\n") DEFUN (neighbor_interface_config_remote_as, neighbor_interface_config_remote_as_cmd, - "neighbor WORD interface remote-as (" CMD_AS_RANGE "|external|internal)", + "neighbor WORD interface remote-as <(1-4294967295)|external|internal>", NEIGHBOR_STR "Interface name or neighbor tag\n" "Enable BGP on interface\n" - AS_STR) + AS_STR + "External BGP peer\n" + "Internal BGP peer\n") { - return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 0, - NULL, argv[1]); + int idx_word = 1; + int idx_remote_as = 4; + return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, + NULL, argv[idx_remote_as]->arg); } DEFUN (neighbor_interface_v6only_config_remote_as, neighbor_interface_v6only_config_remote_as_cmd, - "neighbor WORD interface v6only remote-as (" CMD_AS_RANGE "|external|internal)", + "neighbor WORD interface v6only remote-as <(1-4294967295)|external|internal>", NEIGHBOR_STR "Interface name or neighbor tag\n" "Enable BGP on interface\n" - AS_STR) + AS_STR + "External BGP peer\n" + "Internal BGP peer\n") { - return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 1, - NULL, argv[1]); + int idx_word = 1; + int idx_remote_as = 5; + return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, + NULL, argv[idx_remote_as]->arg); } DEFUN (neighbor_peer_group, @@ -3009,19 +2803,20 @@ DEFUN (neighbor_peer_group, "Interface name or neighbor tag\n" "Configure peer-group\n") { + int idx_word = 1; struct bgp *bgp; struct peer *peer; struct peer_group *group; bgp = vty->index; - peer = peer_lookup_by_conf_if (bgp, argv[0]); + peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); if (peer) { vty_out (vty, "%% Name conflict with interface: %s", VTY_NEWLINE); return CMD_WARNING; } - group = peer_group_get (bgp, argv[0]); + group = peer_group_get (bgp, argv[idx_word]->arg); if (! group) return CMD_WARNING; @@ -3030,22 +2825,23 @@ DEFUN (neighbor_peer_group, DEFUN (no_neighbor, no_neighbor_cmd, - NO_NEIGHBOR_CMD2, + "no neighbor <A.B.C.D|X:X::X:X|WORD> [remote-as <(1-4294967295)|internal|external>]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2) { + int idx_peer = 2; int ret; union sockunion su; struct peer_group *group; struct peer *peer; struct peer *other; - ret = str2sockunion (argv[0], &su); + ret = str2sockunion (argv[idx_peer]->arg, &su); if (ret < 0) { /* look up for neighbor by interface name config. */ - peer = peer_lookup_by_conf_if (vty->index, argv[0]); + peer = peer_lookup_by_conf_if (vty->index, argv[idx_peer]->arg); if (peer) { /* Request zebra to terminate IPv6 RAs on this interface. */ @@ -3055,7 +2851,7 @@ DEFUN (no_neighbor, return CMD_SUCCESS; } - group = peer_group_lookup (vty->index, argv[0]); + group = peer_group_lookup (vty->index, argv[idx_peer]->arg); if (group) peer_group_delete (group); else @@ -3086,27 +2882,24 @@ DEFUN (no_neighbor, return CMD_SUCCESS; } -ALIAS (no_neighbor, - no_neighbor_remote_as_cmd, - NO_NEIGHBOR_CMD "remote-as (" CMD_AS_RANGE "|internal|external)", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR - "Specify a BGP neighbor\n" - AS_STR) - DEFUN (no_neighbor_interface_config, no_neighbor_interface_config_cmd, - "no neighbor WORD interface", + "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", NO_STR NEIGHBOR_STR "Interface name\n" - "Configure BGP on interface\n") + "Configure BGP on interface\n" + "Enable BGP with v6 link-local only\n" + "Member of the peer-group\n" + "Peer-group name\n" + "Specify remote AS\n" + AS_STR) { + int idx_word = 2; struct peer *peer; /* look up for neighbor by interface name config. */ - peer = peer_lookup_by_conf_if (vty->index, argv[0]); + peer = peer_lookup_by_conf_if (vty->index, argv[idx_word]->arg); if (peer) { /* Request zebra to terminate IPv6 RAs on this interface. */ @@ -3122,55 +2915,6 @@ DEFUN (no_neighbor_interface_config, return CMD_SUCCESS; } -ALIAS (no_neighbor_interface_config, - no_neighbor_interface_config_peergroup_cmd, - "no neighbor WORD interface peer-group WORD", - NO_STR - NEIGHBOR_STR - "Interface name\n" - "Configure BGP on interface\n" - "Member of the peer-group\n" - "peer-group name\n") - -ALIAS (no_neighbor_interface_config, - no_neighbor_interface_config_v6only_cmd, - "no neighbor WORD interface v6only", - NO_STR - NEIGHBOR_STR - "Interface name\n" - "Configure BGP on interface\n" - "Enable BGP with v6 link-local only\n") - -ALIAS (no_neighbor_interface_config, - no_neighbor_interface_config_v6only_peergroup_cmd, - "no neighbor WORD interface v6only peer-group WORD", - NO_STR - NEIGHBOR_STR - "Interface name\n" - "Configure BGP on interface\n" - "Enable BGP with v6 link-local only\n" - "Member of the peer-group\n" - "peer-group name\n") - -ALIAS (no_neighbor_interface_config, - no_neighbor_interface_config_remote_as_cmd, - "no neighbor WORD interface remote-as (" CMD_AS_RANGE "|internal|external)", - NO_STR - NEIGHBOR_STR - "Interface name\n" - "Configure BGP on interface\n" - AS_STR) - -ALIAS (no_neighbor_interface_config, - no_neighbor_interface_config_v6only_remote_as_cmd, - "no neighbor WORD interface v6only remote-as (" CMD_AS_RANGE "|internal|external)", - NO_STR - NEIGHBOR_STR - "Interface name\n" - "Configure BGP on interface\n" - "Enable BGP with v6 link-local only\n" - AS_STR) - DEFUN (no_neighbor_peer_group, no_neighbor_peer_group_cmd, "no neighbor WORD peer-group", @@ -3179,9 +2923,10 @@ DEFUN (no_neighbor_peer_group, "Neighbor tag\n" "Configure peer-group\n") { + int idx_word = 2; struct peer_group *group; - group = peer_group_lookup (vty->index, argv[0]); + group = peer_group_lookup (vty->index, argv[idx_word]->arg); if (group) peer_group_delete (group); else @@ -3194,25 +2939,26 @@ DEFUN (no_neighbor_peer_group, DEFUN (no_neighbor_interface_peer_group_remote_as, no_neighbor_interface_peer_group_remote_as_cmd, - "no neighbor WORD remote-as (" CMD_AS_RANGE "|internal|external)", + "no neighbor WORD remote-as <(1-4294967295)|internal|external>", NO_STR NEIGHBOR_STR "Interface name or neighbor tag\n" "Specify a BGP neighbor\n" AS_STR) { + int idx_word = 2; struct peer_group *group; struct peer *peer; /* look up for neighbor by interface name config. */ - peer = peer_lookup_by_conf_if (vty->index, argv[0]); + peer = peer_lookup_by_conf_if (vty->index, argv[idx_word]->arg); if (peer) { peer_as_change (peer, 0, AS_SPECIFIED); return CMD_SUCCESS; } - group = peer_group_lookup (vty->index, argv[0]); + group = peer_group_lookup (vty->index, argv[idx_word]->arg); if (group) peer_group_remote_as_delete (group); else @@ -3225,46 +2971,50 @@ DEFUN (no_neighbor_interface_peer_group_remote_as, DEFUN (neighbor_local_as, neighbor_local_as_cmd, - NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE, + "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Specify a local-as number\n" "AS number used as local AS\n") { + int idx_peer = 1; + int idx_number = 3; struct peer *peer; int ret; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - ret = peer_local_as_set (peer, atoi (argv[1]), 0, 0); + ret = peer_local_as_set (peer, atoi (argv[idx_number]->arg), 0, 0); return bgp_vty_return (vty, ret); } DEFUN (neighbor_local_as_no_prepend, neighbor_local_as_no_prepend_cmd, - NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend", + "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Specify a local-as number\n" "AS number used as local AS\n" "Do not prepend local-as to updates from ebgp peers\n") { + int idx_peer = 1; + int idx_number = 3; struct peer *peer; int ret; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - ret = peer_local_as_set (peer, atoi (argv[1]), 1, 0); + ret = peer_local_as_set (peer, atoi (argv[idx_number]->arg), 1, 0); return bgp_vty_return (vty, ret); } DEFUN (neighbor_local_as_no_prepend_replace_as, neighbor_local_as_no_prepend_replace_as_cmd, - NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend replace-as", + "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Specify a local-as number\n" @@ -3272,30 +3022,35 @@ DEFUN (neighbor_local_as_no_prepend_replace_as, "Do not prepend local-as to updates from ebgp peers\n" "Do not prepend local-as to updates from ibgp peers\n") { + int idx_peer = 1; + int idx_number = 3; struct peer *peer; int ret; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - ret = peer_local_as_set (peer, atoi (argv[1]), 1, 1); + ret = peer_local_as_set (peer, atoi (argv[idx_number]->arg), 1, 1); return bgp_vty_return (vty, ret); } - DEFUN (no_neighbor_local_as, no_neighbor_local_as_cmd, - NO_NEIGHBOR_CMD2 "local-as", + "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "Specify a local-as number\n") + "Specify a local-as number\n" + "AS number used as local AS\n" + "Do not prepend local-as to updates from ebgp peers\n" + "Do not prepend local-as to updates from ibgp peers\n") { + int idx_peer = 2; struct peer *peer; int ret; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -3303,47 +3058,21 @@ DEFUN (no_neighbor_local_as, return bgp_vty_return (vty, ret); } -ALIAS (no_neighbor_local_as, - no_neighbor_local_as_val_cmd, - NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE, - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "Specify a local-as number\n" - "AS number used as local AS\n") -ALIAS (no_neighbor_local_as, - no_neighbor_local_as_val2_cmd, - NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "Specify a local-as number\n" - "AS number used as local AS\n" - "Do not prepend local-as to updates from ebgp peers\n") -ALIAS (no_neighbor_local_as, - no_neighbor_local_as_val3_cmd, - NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend replace-as", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "Specify a local-as number\n" - "AS number used as local AS\n" - "Do not prepend local-as to updates from ebgp peers\n" - "Do not prepend local-as to updates from ibgp peers\n") DEFUN (neighbor_solo, neighbor_solo_cmd, - NEIGHBOR_CMD2 "solo", + "neighbor <A.B.C.D|X:X::X:X|WORD> solo", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Solo peer - part of its own update group\n") { + int idx_peer = 1; struct peer *peer; int ret; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -3353,16 +3082,17 @@ DEFUN (neighbor_solo, DEFUN (no_neighbor_solo, no_neighbor_solo_cmd, - NO_NEIGHBOR_CMD2 "solo", + "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Solo peer - part of its own update group\n") { + int idx_peer = 2; struct peer *peer; int ret; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -3372,35 +3102,39 @@ DEFUN (no_neighbor_solo, DEFUN (neighbor_password, neighbor_password_cmd, - NEIGHBOR_CMD2 "password LINE", + "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Set a password\n" "The password\n") { + int idx_peer = 1; + int idx_line = 3; struct peer *peer; int ret; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - ret = peer_password_set (peer, argv[1]); + ret = peer_password_set (peer, argv[idx_line]->arg); return bgp_vty_return (vty, ret); } DEFUN (no_neighbor_password, no_neighbor_password_cmd, - NO_NEIGHBOR_CMD2 "password", + "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "Set a password\n") + "Set a password\n" + "The password\n") { + int idx_peer = 2; struct peer *peer; int ret; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -3408,26 +3142,19 @@ DEFUN (no_neighbor_password, return bgp_vty_return (vty, ret); } -ALIAS (no_neighbor_password, - no_neighbor_password_val_cmd, - NO_NEIGHBOR_CMD2 "password LINE", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "Set a password\n" - "The password\n") DEFUN (neighbor_activate, neighbor_activate_cmd, - NEIGHBOR_CMD2 "activate", + "neighbor <A.B.C.D|X:X::X:X|WORD> activate", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Enable the Address Family for this Neighbor\n") { + int idx_peer = 1; int ret; struct peer *peer; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -3440,17 +3167,18 @@ DEFUN (neighbor_activate, DEFUN (no_neighbor_activate, no_neighbor_activate_cmd, - NO_NEIGHBOR_CMD2 "activate", + "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Enable the Address Family for this Neighbor\n") { + int idx_peer = 2; int ret; struct peer *peer; /* Lookup peer. */ - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -3463,12 +3191,14 @@ DEFUN (no_neighbor_activate, DEFUN (neighbor_set_peer_group, neighbor_set_peer_group_cmd, - NEIGHBOR_CMD2 "peer-group WORD", + "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Member of the peer-group\n" - "peer-group name\n") + "Peer-group name\n") { + int idx_peer = 1; + int idx_word = 3; int ret; as_t as; union sockunion su; @@ -3479,13 +3209,13 @@ DEFUN (neighbor_set_peer_group, bgp = vty->index; peer = NULL; - ret = str2sockunion (argv[0], &su); + ret = str2sockunion (argv[idx_peer]->arg, &su); if (ret < 0) { - peer = peer_lookup_by_conf_if (bgp, argv[0]); + peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); if (!peer) { - vty_out (vty, "%% Malformed address or name: %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); return CMD_WARNING; } } @@ -3508,7 +3238,7 @@ DEFUN (neighbor_set_peer_group, } } - group = peer_group_lookup (bgp, argv[1]); + group = peer_group_lookup (bgp, argv[idx_word]->arg); if (! group) { vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); @@ -3528,13 +3258,15 @@ DEFUN (neighbor_set_peer_group, DEFUN (no_neighbor_set_peer_group, no_neighbor_set_peer_group_cmd, - NO_NEIGHBOR_CMD2 "peer-group WORD", + "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Member of the peer-group\n" - "peer-group name\n") + "Peer-group name\n") { + int idx_peer = 2; + int idx_word = 4; int ret; struct bgp *bgp; struct peer *peer; @@ -3542,11 +3274,11 @@ DEFUN (no_neighbor_set_peer_group, bgp = vty->index; - peer = peer_lookup_vty (vty, argv[0]); + peer = peer_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - group = peer_group_lookup (bgp, argv[1]); + group = peer_group_lookup (bgp, argv[idx_word]->arg); if (! group) { vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); @@ -3559,7 +3291,7 @@ DEFUN (no_neighbor_set_peer_group, } static int -peer_flag_modify_vty (struct vty *vty, const char *ip_str, +peer_flag_modify_vty (struct vty *vty, const char *ip_str, u_int16_t flag, int set) { int ret; @@ -3602,115 +3334,125 @@ peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag) /* neighbor passive. */ DEFUN (neighbor_passive, neighbor_passive_cmd, - NEIGHBOR_CMD2 "passive", + "neighbor <A.B.C.D|X:X::X:X|WORD> passive", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Don't send open messages to this neighbor\n") { - return peer_flag_set_vty (vty, argv[0], PEER_FLAG_PASSIVE); + int idx_peer = 1; + return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); } DEFUN (no_neighbor_passive, no_neighbor_passive_cmd, - NO_NEIGHBOR_CMD2 "passive", + "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Don't send open messages to this neighbor\n") { - return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_PASSIVE); + int idx_peer = 2; + return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); } /* neighbor shutdown. */ DEFUN (neighbor_shutdown, neighbor_shutdown_cmd, - NEIGHBOR_CMD2 "shutdown", + "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Administratively shut down this neighbor\n") { - return peer_flag_set_vty (vty, argv[0], PEER_FLAG_SHUTDOWN); + int idx_peer = 1; + return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); } DEFUN (no_neighbor_shutdown, no_neighbor_shutdown_cmd, - NO_NEIGHBOR_CMD2 "shutdown", + "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Administratively shut down this neighbor\n") { - return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_SHUTDOWN); + int idx_peer = 2; + return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); } /* neighbor capability dynamic. */ DEFUN (neighbor_capability_dynamic, neighbor_capability_dynamic_cmd, - NEIGHBOR_CMD2 "capability dynamic", + "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Advertise capability to the peer\n" "Advertise dynamic capability to this neighbor\n") { - return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY); + int idx_peer = 1; + return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); } DEFUN (no_neighbor_capability_dynamic, no_neighbor_capability_dynamic_cmd, - NO_NEIGHBOR_CMD2 "capability dynamic", + "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Advertise capability to the peer\n" "Advertise dynamic capability to this neighbor\n") { - return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY); + int idx_peer = 2; + return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); } /* neighbor dont-capability-negotiate */ DEFUN (neighbor_dont_capability_negotiate, neighbor_dont_capability_negotiate_cmd, - NEIGHBOR_CMD2 "dont-capability-negotiate", + "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Do not perform capability negotiation\n") { - return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY); + int idx_peer = 1; + return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); } DEFUN (no_neighbor_dont_capability_negotiate, no_neighbor_dont_capability_negotiate_cmd, - NO_NEIGHBOR_CMD2 "dont-capability-negotiate", + "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Do not perform capability negotiation\n") { - return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY); + int idx_peer = 2; + return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); } /* neighbor capability extended next hop encoding */ DEFUN (neighbor_capability_enhe, neighbor_capability_enhe_cmd, - NEIGHBOR_CMD2 "capability extended-nexthop", + "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Advertise capability to the peer\n" "Advertise extended next-hop capability to the peer\n") { - return peer_flag_set_vty (vty, argv[0], PEER_FLAG_CAPABILITY_ENHE); + int idx_peer = 1; + return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); } DEFUN (no_neighbor_capability_enhe, no_neighbor_capability_enhe_cmd, - NO_NEIGHBOR_CMD2 "capability extended-nexthop", + "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Advertise capability to the peer\n" "Advertise extended next-hop capability to the peer\n") { - return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_CAPABILITY_ENHE); + int idx_peer = 2; + return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); } static int @@ -3749,7 +3491,7 @@ peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi, /* neighbor capability orf prefix-list. */ DEFUN (neighbor_capability_orf_prefix, neighbor_capability_orf_prefix_cmd, - NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)", + "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Advertise capability to the peer\n" @@ -3759,24 +3501,26 @@ DEFUN (neighbor_capability_orf_prefix, "Capability to RECEIVE the ORF from this neighbor\n" "Capability to SEND the ORF to this neighbor\n") { + int idx_peer = 1; + int idx_send_recv = 5; u_int16_t flag = 0; - if (strncmp (argv[1], "s", 1) == 0) + if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) flag = PEER_FLAG_ORF_PREFIX_SM; - else if (strncmp (argv[1], "r", 1) == 0) + else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) flag = PEER_FLAG_ORF_PREFIX_RM; - else if (strncmp (argv[1], "b", 1) == 0) + else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; else return CMD_WARNING; - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), flag); } DEFUN (no_neighbor_capability_orf_prefix, no_neighbor_capability_orf_prefix_cmd, - NO_NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)", + "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 @@ -3787,70 +3531,76 @@ DEFUN (no_neighbor_capability_orf_prefix, "Capability to RECEIVE the ORF from this neighbor\n" "Capability to SEND the ORF to this neighbor\n") { + int idx_peer = 2; + int idx_send_recv = 6; u_int16_t flag = 0; - if (strncmp (argv[1], "s", 1) == 0) + if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) flag = PEER_FLAG_ORF_PREFIX_SM; - else if (strncmp (argv[1], "r", 1) == 0) + else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) flag = PEER_FLAG_ORF_PREFIX_RM; - else if (strncmp (argv[1], "b", 1) == 0) + else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; else return CMD_WARNING; - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), flag); } /* neighbor next-hop-self. */ DEFUN (neighbor_nexthop_self, neighbor_nexthop_self_cmd, - NEIGHBOR_CMD2 "next-hop-self", + "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Disable the next hop calculation for this neighbor\n") { - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF); } /* neighbor next-hop-self. */ DEFUN (neighbor_nexthop_self_force, neighbor_nexthop_self_force_cmd, - NEIGHBOR_CMD2 "next-hop-self force", + "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Disable the next hop calculation for this neighbor\n" "Set the next hop to self for reflected routes\n") { - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_FORCE_NEXTHOP_SELF); } DEFUN (no_neighbor_nexthop_self, no_neighbor_nexthop_self_cmd, - NO_NEIGHBOR_CMD2 "next-hop-self", + "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Disable the next hop calculation for this neighbor\n") { - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF); } DEFUN (no_neighbor_nexthop_self_force, no_neighbor_nexthop_self_force_cmd, - NO_NEIGHBOR_CMD2 "next-hop-self force", + "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Disable the next hop calculation for this neighbor\n" "Set the next hop to self for reflected routes\n") { - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_FORCE_NEXTHOP_SELF); } @@ -3858,25 +3608,27 @@ DEFUN (no_neighbor_nexthop_self_force, /* neighbor as-override */ DEFUN (neighbor_as_override, neighbor_as_override_cmd, - NEIGHBOR_CMD2 "as-override", + "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Override ASNs in outbound updates if aspath equals remote-as\n") { - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_AS_OVERRIDE); } DEFUN (no_neighbor_as_override, no_neighbor_as_override_cmd, - NO_NEIGHBOR_CMD2 "as-override", + "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Override ASNs in outbound updates if aspath equals remote-as\n") { - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_AS_OVERRIDE); } @@ -3884,108 +3636,116 @@ DEFUN (no_neighbor_as_override, /* neighbor remove-private-AS. */ DEFUN (neighbor_remove_private_as, neighbor_remove_private_as_cmd, - NEIGHBOR_CMD2 "remove-private-AS", + "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Remove private ASNs in outbound updates\n") { - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REMOVE_PRIVATE_AS); } DEFUN (neighbor_remove_private_as_all, neighbor_remove_private_as_all_cmd, - NEIGHBOR_CMD2 "remove-private-AS all", + "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Remove private ASNs in outbound updates\n" "Apply to all AS numbers") { - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REMOVE_PRIVATE_AS_ALL); } DEFUN (neighbor_remove_private_as_replace_as, neighbor_remove_private_as_replace_as_cmd, - NEIGHBOR_CMD2 "remove-private-AS replace-AS", + "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Remove private ASNs in outbound updates\n" "Replace private ASNs with our ASN in outbound updates\n") { - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); } DEFUN (neighbor_remove_private_as_all_replace_as, neighbor_remove_private_as_all_replace_as_cmd, - NEIGHBOR_CMD2 "remove-private-AS all replace-AS", + "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Remove private ASNs in outbound updates\n" - "Apply to all AS numbers" + "Apply to all AS numbers\n" "Replace private ASNs with our ASN in outbound updates\n") { - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); } DEFUN (no_neighbor_remove_private_as, no_neighbor_remove_private_as_cmd, - NO_NEIGHBOR_CMD2 "remove-private-AS", + "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Remove private ASNs in outbound updates\n") { - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REMOVE_PRIVATE_AS); } DEFUN (no_neighbor_remove_private_as_all, no_neighbor_remove_private_as_all_cmd, - NO_NEIGHBOR_CMD2 "remove-private-AS all", + "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Remove private ASNs in outbound updates\n" - "Apply to all AS numbers") + "Apply to all AS numbers\n") { - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REMOVE_PRIVATE_AS_ALL); } DEFUN (no_neighbor_remove_private_as_replace_as, no_neighbor_remove_private_as_replace_as_cmd, - NO_NEIGHBOR_CMD2 "remove-private-AS replace-AS", + "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Remove private ASNs in outbound updates\n" "Replace private ASNs with our ASN in outbound updates\n") { - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); } DEFUN (no_neighbor_remove_private_as_all_replace_as, no_neighbor_remove_private_as_all_replace_as_cmd, - NO_NEIGHBOR_CMD2 "remove-private-AS all replace-AS", + "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Remove private ASNs in outbound updates\n" - "Apply to all AS numbers" + "Apply to all AS numbers\n" "Replace private ASNs with our ASN in outbound updates\n") { - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); } @@ -3994,25 +3754,27 @@ DEFUN (no_neighbor_remove_private_as_all_replace_as, /* neighbor send-community. */ DEFUN (neighbor_send_community, neighbor_send_community_cmd, - NEIGHBOR_CMD2 "send-community", + "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Send Community attribute to this neighbor\n") { - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_SEND_COMMUNITY); } DEFUN (no_neighbor_send_community, no_neighbor_send_community_cmd, - NO_NEIGHBOR_CMD2 "send-community", + "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Send Community attribute to this neighbor\n") { - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_SEND_COMMUNITY); } @@ -4020,7 +3782,7 @@ DEFUN (no_neighbor_send_community, /* neighbor send-community extended. */ DEFUN (neighbor_send_community_type, neighbor_send_community_type_cmd, - NEIGHBOR_CMD2 "send-community (both|extended|standard)", + "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|extended|standard>", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Send Community attribute to this neighbor\n" @@ -4028,24 +3790,27 @@ DEFUN (neighbor_send_community_type, "Send Extended Community attributes\n" "Send Standard Community attributes\n") { - if (strncmp (argv[1], "s", 1) == 0) - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), - PEER_FLAG_SEND_COMMUNITY); - if (strncmp (argv[1], "e", 1) == 0) - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), - PEER_FLAG_SEND_EXT_COMMUNITY); + int idx = 0; + u_int32_t flag = 0; - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), - (PEER_FLAG_SEND_COMMUNITY| - PEER_FLAG_SEND_EXT_COMMUNITY)); + char *peer = argv[1]->arg; + + if (argv_find (argv, argc, "standard", &idx)) + SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); + else if (argv_find (argv, argc, "extended", &idx)) + SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); + else + { + SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); + SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); + } + + return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flag); } DEFUN (no_neighbor_send_community_type, no_neighbor_send_community_type_cmd, - NO_NEIGHBOR_CMD2 "send-community (both|extended|standard)", + "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|extended|standard>", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 @@ -4054,16 +3819,18 @@ DEFUN (no_neighbor_send_community_type, "Send Extended Community attributes\n" "Send Standard Community attributes\n") { - if (strncmp (argv[1], "s", 1) == 0) - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 2; + int idx_type = 4; + if (strncmp (argv[idx_type]->arg, "s", 1) == 0) + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_SEND_COMMUNITY); - if (strncmp (argv[1], "e", 1) == 0) - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), + if (strncmp (argv[idx_type]->arg, "e", 1) == 0) + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_SEND_EXT_COMMUNITY); - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), (PEER_FLAG_SEND_COMMUNITY | PEER_FLAG_SEND_EXT_COMMUNITY)); @@ -4072,59 +3839,63 @@ DEFUN (no_neighbor_send_community_type, /* neighbor soft-reconfig. */ DEFUN (neighbor_soft_reconfiguration, neighbor_soft_reconfiguration_cmd, - NEIGHBOR_CMD2 "soft-reconfiguration inbound", + "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Per neighbor soft reconfiguration\n" "Allow inbound soft reconfiguration for this neighbor\n") { - return peer_af_flag_set_vty (vty, argv[0], + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_SOFT_RECONFIG); } DEFUN (no_neighbor_soft_reconfiguration, no_neighbor_soft_reconfiguration_cmd, - NO_NEIGHBOR_CMD2 "soft-reconfiguration inbound", + "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Per neighbor soft reconfiguration\n" "Allow inbound soft reconfiguration for this neighbor\n") { - return peer_af_flag_unset_vty (vty, argv[0], + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_SOFT_RECONFIG); } DEFUN (neighbor_route_reflector_client, neighbor_route_reflector_client_cmd, - NEIGHBOR_CMD2 "route-reflector-client", + "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Configure a neighbor as Route Reflector client\n") { + int idx_peer = 1; struct peer *peer; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REFLECTOR_CLIENT); } DEFUN (no_neighbor_route_reflector_client, no_neighbor_route_reflector_client_cmd, - NO_NEIGHBOR_CMD2 "route-reflector-client", + "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Configure a neighbor as Route Reflector client\n") { - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REFLECTOR_CLIENT); } @@ -4132,396 +3903,148 @@ DEFUN (no_neighbor_route_reflector_client, /* neighbor route-server-client. */ DEFUN (neighbor_route_server_client, neighbor_route_server_client_cmd, - NEIGHBOR_CMD2 "route-server-client", + "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Configure a neighbor as Route Server client\n") { + int idx_peer = 1; struct peer *peer; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_RSERVER_CLIENT); } DEFUN (no_neighbor_route_server_client, no_neighbor_route_server_client_cmd, - NO_NEIGHBOR_CMD2 "route-server-client", + "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Configure a neighbor as Route Server client\n") { - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_RSERVER_CLIENT); } DEFUN (neighbor_nexthop_local_unchanged, neighbor_nexthop_local_unchanged_cmd, - NEIGHBOR_CMD2 "nexthop-local unchanged", + "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Configure treatment of outgoing link-local nexthop attribute\n" "Leave link-local nexthop unchanged for this peer\n") { - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); } DEFUN (no_neighbor_nexthop_local_unchanged, no_neighbor_nexthop_local_unchanged_cmd, - NO_NEIGHBOR_CMD2 "nexthop-local unchanged", + "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Configure treatment of outgoing link-local-nexthop attribute\n" "Leave link-local nexthop unchanged for this peer\n") { - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); } DEFUN (neighbor_attr_unchanged, neighbor_attr_unchanged_cmd, - NEIGHBOR_CMD2 "attribute-unchanged", - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n") -{ - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), - (PEER_FLAG_AS_PATH_UNCHANGED | - PEER_FLAG_NEXTHOP_UNCHANGED | - PEER_FLAG_MED_UNCHANGED)); -} - -DEFUN (neighbor_attr_unchanged1, - neighbor_attr_unchanged1_cmd, - NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)", + "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [<as-path|next-hop|med> [<as-path|next-hop|med> [<as-path|next-hop|med>]]]", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "BGP attribute is propagated unchanged to this neighbor\n" "As-path attribute\n" "Nexthop attribute\n" - "Med attribute\n") -{ - u_int16_t flags = 0; - - if (strncmp (argv[1], "as-path", 1) == 0) - SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); - else if (strncmp (argv[1], "next-hop", 1) == 0) - SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); - else if (strncmp (argv[1], "med", 1) == 0) - SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); - - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), flags); -} - -DEFUN (neighbor_attr_unchanged2, - neighbor_attr_unchanged2_cmd, - NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)", - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n" + "Med attribute\n" "As-path attribute\n" "Nexthop attribute\n" - "Med attribute\n") -{ - u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED; - - if (strncmp (argv[1], "next-hop", 1) == 0) - SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); - else if (strncmp (argv[1], "med", 1) == 0) - SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); - - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), flags); - -} - -DEFUN (neighbor_attr_unchanged3, - neighbor_attr_unchanged3_cmd, - NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)", - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n" - "Nexthop attribute\n" + "Med attribute\n" "As-path attribute\n" + "Nexthop attribute\n" "Med attribute\n") { - u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED; + int idx = 0; + char *peer = argv[1]->arg; + u_int16_t flags = 0; - if (strncmp (argv[1], "as-path", 1) == 0) + if (argv_find (argv, argc, "as-path", &idx)) SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); - else if (strncmp (argv[1], "med", 1) == 0) + idx = 0; + if (argv_find (argv, argc, "next-hop", &idx)) + SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); + idx = 0; + if (argv_find (argv, argc, "med", &idx)) SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), flags); -} - -DEFUN (neighbor_attr_unchanged4, - neighbor_attr_unchanged4_cmd, - NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)", - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n" - "Med attribute\n" - "As-path attribute\n" - "Nexthop attribute\n") -{ - u_int16_t flags = PEER_FLAG_MED_UNCHANGED; - - if (strncmp (argv[1], "as-path", 1) == 0) + if (!flags) // no flags means all of them! + { SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); - else if (strncmp (argv[1], "next-hop", 1) == 0) SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); + SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); + } - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), flags); + return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); } -ALIAS (neighbor_attr_unchanged, - neighbor_attr_unchanged5_cmd, - NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med", - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n" - "As-path attribute\n" - "Nexthop attribute\n" - "Med attribute\n") - -ALIAS (neighbor_attr_unchanged, - neighbor_attr_unchanged6_cmd, - NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop", +DEFUN (no_neighbor_attr_unchanged, + no_neighbor_attr_unchanged_cmd, + "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [<as-path|next-hop|med> [<as-path|next-hop|med> [<as-path|next-hop|med>]]]", + NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "BGP attribute is propagated unchanged to this neighbor\n" "As-path attribute\n" - "Med attribute\n" - "Nexthop attribute\n") - -ALIAS (neighbor_attr_unchanged, - neighbor_attr_unchanged7_cmd, - NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path", - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n" "Nexthop attribute\n" "Med attribute\n" - "As-path attribute\n") - -ALIAS (neighbor_attr_unchanged, - neighbor_attr_unchanged8_cmd, - NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med", - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n" - "Nexthop attribute\n" "As-path attribute\n" - "Med attribute\n") - -ALIAS (neighbor_attr_unchanged, - neighbor_attr_unchanged9_cmd, - NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path", - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n" - "Med attribute\n" "Nexthop attribute\n" - "As-path attribute\n") - -ALIAS (neighbor_attr_unchanged, - neighbor_attr_unchanged10_cmd, - NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop", - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n" "Med attribute\n" "As-path attribute\n" - "Nexthop attribute\n") - -DEFUN (no_neighbor_attr_unchanged, - no_neighbor_attr_unchanged_cmd, - NO_NEIGHBOR_CMD2 "attribute-unchanged", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n") -{ - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), - (PEER_FLAG_AS_PATH_UNCHANGED | - PEER_FLAG_NEXTHOP_UNCHANGED | - PEER_FLAG_MED_UNCHANGED)); -} - -DEFUN (no_neighbor_attr_unchanged1, - no_neighbor_attr_unchanged1_cmd, - NO_NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n" - "As-path attribute\n" "Nexthop attribute\n" "Med attribute\n") { + int idx = 0; + char *peer = argv[2]->arg; u_int16_t flags = 0; - if (strncmp (argv[1], "as-path", 1) == 0) + if (argv_find (argv, argc, "as-path", &idx)) SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); - else if (strncmp (argv[1], "next-hop", 1) == 0) + idx = 0; + if (argv_find (argv, argc, "next-hop", &idx)) SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); - else if (strncmp (argv[1], "med", 1) == 0) - SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); - - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), flags); -} - -DEFUN (no_neighbor_attr_unchanged2, - no_neighbor_attr_unchanged2_cmd, - NO_NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n" - "As-path attribute\n" - "Nexthop attribute\n" - "Med attribute\n") -{ - u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED; - - if (strncmp (argv[1], "next-hop", 1) == 0) - SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); - else if (strncmp (argv[1], "med", 1) == 0) - SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); - - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), flags); -} - -DEFUN (no_neighbor_attr_unchanged3, - no_neighbor_attr_unchanged3_cmd, - NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n" - "Nexthop attribute\n" - "As-path attribute\n" - "Med attribute\n") -{ - u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED; - - if (strncmp (argv[1], "as-path", 1) == 0) - SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); - else if (strncmp (argv[1], "med", 1) == 0) + idx = 0; + if (argv_find (argv, argc, "med", &idx)) SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), flags); -} - -DEFUN (no_neighbor_attr_unchanged4, - no_neighbor_attr_unchanged4_cmd, - NO_NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n" - "Med attribute\n" - "As-path attribute\n" - "Nexthop attribute\n") -{ - u_int16_t flags = PEER_FLAG_MED_UNCHANGED; - - if (strncmp (argv[1], "as-path", 1) == 0) + if (!flags) // no flags means all of them! + { SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); - else if (strncmp (argv[1], "next-hop", 1) == 0) SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); + SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); + } - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), flags); + return peer_af_flag_unset_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); } -ALIAS (no_neighbor_attr_unchanged, - no_neighbor_attr_unchanged5_cmd, - NO_NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n" - "As-path attribute\n" - "Nexthop attribute\n" - "Med attribute\n") - -ALIAS (no_neighbor_attr_unchanged, - no_neighbor_attr_unchanged6_cmd, - NO_NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n" - "As-path attribute\n" - "Med attribute\n" - "Nexthop attribute\n") - -ALIAS (no_neighbor_attr_unchanged, - no_neighbor_attr_unchanged7_cmd, - NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n" - "Nexthop attribute\n" - "Med attribute\n" - "As-path attribute\n") - -ALIAS (no_neighbor_attr_unchanged, - no_neighbor_attr_unchanged8_cmd, - NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n" - "Nexthop attribute\n" - "As-path attribute\n" - "Med attribute\n") - -ALIAS (no_neighbor_attr_unchanged, - no_neighbor_attr_unchanged9_cmd, - NO_NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n" - "Med attribute\n" - "Nexthop attribute\n" - "As-path attribute\n") - -ALIAS (no_neighbor_attr_unchanged, - no_neighbor_attr_unchanged10_cmd, - NO_NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP attribute is propagated unchanged to this neighbor\n" - "Med attribute\n" - "As-path attribute\n" - "Nexthop attribute\n") /* EBGP multihop configuration. */ static int -peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str, +peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str, const char *ttl_str) { struct peer *peer; @@ -4543,7 +4066,7 @@ peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str, } static int -peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str) +peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str) { struct peer *peer; @@ -4557,103 +4080,86 @@ peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str) /* neighbor ebgp-multihop. */ DEFUN (neighbor_ebgp_multihop, neighbor_ebgp_multihop_cmd, - NEIGHBOR_CMD2 "ebgp-multihop", + "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Allow EBGP neighbors not on directly connected networks\n") { - return peer_ebgp_multihop_set_vty (vty, argv[0], NULL); + int idx_peer = 1; + return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, NULL); } DEFUN (neighbor_ebgp_multihop_ttl, neighbor_ebgp_multihop_ttl_cmd, - NEIGHBOR_CMD2 "ebgp-multihop " CMD_RANGE_STR(1, MAXTTL), + "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Allow EBGP neighbors not on directly connected networks\n" "maximum hop count\n") { - return peer_ebgp_multihop_set_vty (vty, argv[0], argv[1]); + int idx_peer = 1; + int idx_number = 3; + return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); } DEFUN (no_neighbor_ebgp_multihop, no_neighbor_ebgp_multihop_cmd, - NO_NEIGHBOR_CMD2 "ebgp-multihop", + "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "Allow EBGP neighbors not on directly connected networks\n") + "Allow EBGP neighbors not on directly connected networks\n" + "maximum hop count\n") { - return peer_ebgp_multihop_unset_vty (vty, argv[0]); + int idx_peer = 2; + return peer_ebgp_multihop_unset_vty (vty, argv[idx_peer]->arg); } -ALIAS (no_neighbor_ebgp_multihop, - no_neighbor_ebgp_multihop_ttl_cmd, - NO_NEIGHBOR_CMD2 "ebgp-multihop " CMD_RANGE_STR(1, MAXTTL), - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "Allow EBGP neighbors not on directly connected networks\n" - "maximum hop count\n") /* disable-connected-check */ DEFUN (neighbor_disable_connected_check, neighbor_disable_connected_check_cmd, - NEIGHBOR_CMD2 "disable-connected-check", + "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "one-hop away EBGP peer using loopback address\n") + "one-hop away EBGP peer using loopback address\n" + "Enforce EBGP neighbors perform multihop\n") { - return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK); + int idx_peer = 1; + return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); } DEFUN (no_neighbor_disable_connected_check, no_neighbor_disable_connected_check_cmd, - NO_NEIGHBOR_CMD2 "disable-connected-check", + "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "one-hop away EBGP peer using loopback address\n") + "one-hop away EBGP peer using loopback address\n" + "Enforce EBGP neighbors perform multihop\n") { - return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK); + int idx_peer = 2; + return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); } -/* Enforce multihop. */ -ALIAS (neighbor_disable_connected_check, - neighbor_enforce_multihop_cmd, - NEIGHBOR_CMD2 "enforce-multihop", - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "Enforce EBGP neighbors perform multihop\n") - -/* Enforce multihop. */ -ALIAS (no_neighbor_disable_connected_check, - no_neighbor_enforce_multihop_cmd, - NO_NEIGHBOR_CMD2 "enforce-multihop", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "Enforce EBGP neighbors perform multihop\n") - DEFUN (neighbor_description, neighbor_description_cmd, - NEIGHBOR_CMD2 "description .LINE", + "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Neighbor specific description\n" "Up to 80 characters describing this neighbor\n") { + int idx_peer = 1; + int idx_line = 3; struct peer *peer; char *str; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - if (argc == 1) - return CMD_SUCCESS; - - str = argv_concat(argv, argc, 1); + str = argv_concat(argv, argc, idx_line); peer_description_set (peer, str); @@ -4664,15 +4170,17 @@ DEFUN (neighbor_description, DEFUN (no_neighbor_description, no_neighbor_description_cmd, - NO_NEIGHBOR_CMD2 "description", + "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "Neighbor specific description\n") + "Neighbor specific description\n" + "Up to 80 characters describing this neighbor\n") { + int idx_peer = 2; struct peer *peer; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -4681,18 +4189,10 @@ DEFUN (no_neighbor_description, return CMD_SUCCESS; } -ALIAS (no_neighbor_description, - no_neighbor_description_val_cmd, - NO_NEIGHBOR_CMD2 "description .LINE", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "Neighbor specific description\n" - "Up to 80 characters describing this neighbor\n") /* Neighbor update-source. */ static int -peer_update_source_vty (struct vty *vty, const char *peer_str, +peer_update_source_vty (struct vty *vty, const char *peer_str, const char *source_str) { struct peer *peer; @@ -4720,9 +4220,6 @@ peer_update_source_vty (struct vty *vty, const char *peer_str, return CMD_SUCCESS; } -#define BGP_UPDATE_SOURCE_STR "A.B.C.D|X:X::X:X|WORD" -#define BGP_UPDATE_SOURCE_REQ_STR "(" BGP_UPDATE_SOURCE_STR ")" -#define BGP_UPDATE_SOURCE_OPT_STR "{" BGP_UPDATE_SOURCE_STR "}" #define BGP_UPDATE_SOURCE_HELP_STR \ "IPv4 address\n" \ "IPv6 address\n" \ @@ -4730,30 +4227,33 @@ peer_update_source_vty (struct vty *vty, const char *peer_str, DEFUN (neighbor_update_source, neighbor_update_source_cmd, - NEIGHBOR_CMD2 "update-source " BGP_UPDATE_SOURCE_REQ_STR, + "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Source of routing updates\n" BGP_UPDATE_SOURCE_HELP_STR) { - return peer_update_source_vty (vty, argv[0], argv[1]); + int idx_peer = 1; + int idx_peer_2 = 3; + return peer_update_source_vty (vty, argv[idx_peer]->arg, argv[idx_peer_2]->arg); } DEFUN (no_neighbor_update_source, no_neighbor_update_source_cmd, - NO_NEIGHBOR_CMD2 "update-source " BGP_UPDATE_SOURCE_OPT_STR, + "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Source of routing updates\n" BGP_UPDATE_SOURCE_HELP_STR) { - return peer_update_source_vty (vty, argv[0], NULL); + int idx_peer = 2; + return peer_update_source_vty (vty, argv[idx_peer]->arg, NULL); } static int -peer_default_originate_set_vty (struct vty *vty, const char *peer_str, - afi_t afi, safi_t safi, +peer_default_originate_set_vty (struct vty *vty, const char *peer_str, + afi_t afi, safi_t safi, const char *rmap, int set) { int ret; @@ -4774,53 +4274,50 @@ peer_default_originate_set_vty (struct vty *vty, const char *peer_str, /* neighbor default-originate. */ DEFUN (neighbor_default_originate, neighbor_default_originate_cmd, - NEIGHBOR_CMD2 "default-originate", + "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Originate default route to this neighbor\n") { - return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 1; + return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), NULL, 1); } DEFUN (neighbor_default_originate_rmap, neighbor_default_originate_rmap_cmd, - NEIGHBOR_CMD2 "default-originate route-map WORD", + "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Originate default route to this neighbor\n" "Route-map to specify criteria to originate default\n" "route-map name\n") { - return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[1], 1); + int idx_peer = 1; + int idx_word = 4; + return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_word]->arg, 1); } DEFUN (no_neighbor_default_originate, no_neighbor_default_originate_cmd, - NO_NEIGHBOR_CMD2 "default-originate", + "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "Originate default route to this neighbor\n") + "Originate default route to this neighbor\n" + "Route-map to specify criteria to originate default\n" + "route-map name\n") { - return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 2; + return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), NULL, 0); } -ALIAS (no_neighbor_default_originate, - no_neighbor_default_originate_rmap_cmd, - NO_NEIGHBOR_CMD2 "default-originate route-map WORD", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "Originate default route to this neighbor\n" - "Route-map to specify criteria to originate default\n" - "route-map name\n") /* Set neighbor's BGP port. */ static int -peer_port_vty (struct vty *vty, const char *ip_str, int afi, +peer_port_vty (struct vty *vty, const char *ip_str, int afi, const char *port_str) { struct peer *peer; @@ -4832,7 +4329,7 @@ peer_port_vty (struct vty *vty, const char *ip_str, int afi, return CMD_WARNING; if (! port_str) - { + { sp = getservbyname ("bgp", "tcp"); port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port); } @@ -4849,38 +4346,34 @@ peer_port_vty (struct vty *vty, const char *ip_str, int afi, /* Set specified peer's BGP port. */ DEFUN (neighbor_port, neighbor_port_cmd, - NEIGHBOR_CMD "port <0-65535>", + "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", NEIGHBOR_STR NEIGHBOR_ADDR_STR "Neighbor's BGP port\n" "TCP port number\n") { - return peer_port_vty (vty, argv[0], AFI_IP, argv[1]); + int idx_ip = 1; + int idx_number = 3; + return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, argv[idx_number]->arg); } DEFUN (no_neighbor_port, no_neighbor_port_cmd, - NO_NEIGHBOR_CMD "port", + "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR - "Neighbor's BGP port\n") + "Neighbor's BGP port\n" + "TCP port number\n") { - return peer_port_vty (vty, argv[0], AFI_IP, NULL); + int idx_ip = 2; + return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, NULL); } -ALIAS (no_neighbor_port, - no_neighbor_port_val_cmd, - NO_NEIGHBOR_CMD "port <0-65535>", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR - "Neighbor's BGP port\n" - "TCP port number\n") /* neighbor weight. */ static int -peer_weight_set_vty (struct vty *vty, const char *ip_str, +peer_weight_set_vty (struct vty *vty, const char *ip_str, afi_t afi, safi_t safi, const char *weight_str) { @@ -4915,80 +4408,84 @@ peer_weight_unset_vty (struct vty *vty, const char *ip_str, DEFUN (neighbor_weight, neighbor_weight_cmd, - NEIGHBOR_CMD2 "weight <0-65535>", + "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Set default weight for routes from this neighbor\n" "default weight\n") { - return peer_weight_set_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty), argv[1]); + int idx_peer = 1; + int idx_number = 3; + return peer_weight_set_vty (vty, + argv[idx_peer]->arg, + bgp_node_afi (vty), + bgp_node_safi (vty), + argv[idx_number]->arg); } DEFUN (no_neighbor_weight, no_neighbor_weight_cmd, - NO_NEIGHBOR_CMD2 "weight", + "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "Set default weight for routes from this neighbor\n") + "Set default weight for routes from this neighbor\n" + "default weight\n") { - return peer_weight_unset_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty)); + int idx_peer = 2; + return peer_weight_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty)); } -ALIAS (no_neighbor_weight, - no_neighbor_weight_val_cmd, - NO_NEIGHBOR_CMD2 "weight <0-65535>", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "Set default weight for routes from this neighbor\n" - "default weight\n") /* Override capability negotiation. */ DEFUN (neighbor_override_capability, neighbor_override_capability_cmd, - NEIGHBOR_CMD2 "override-capability", + "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Override capability negotiation result\n") { - return peer_flag_set_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY); + int idx_peer = 1; + return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); } DEFUN (no_neighbor_override_capability, no_neighbor_override_capability_cmd, - NO_NEIGHBOR_CMD2 "override-capability", + "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Override capability negotiation result\n") { - return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY); + int idx_peer = 2; + return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); } DEFUN (neighbor_strict_capability, neighbor_strict_capability_cmd, - NEIGHBOR_CMD "strict-capability-match", + "neighbor <A.B.C.D|X:X::X:X> strict-capability-match", NEIGHBOR_STR NEIGHBOR_ADDR_STR "Strict capability negotiation match\n") { - return peer_flag_set_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH); + int idx_ip = 1; + return peer_flag_set_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); } DEFUN (no_neighbor_strict_capability, no_neighbor_strict_capability_cmd, - NO_NEIGHBOR_CMD "strict-capability-match", + "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR "Strict capability negotiation match\n") { - return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH); + int idx_ip = 2; + return peer_flag_unset_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); } static int -peer_timers_set_vty (struct vty *vty, const char *ip_str, +peer_timers_set_vty (struct vty *vty, const char *ip_str, const char *keep_str, const char *hold_str) { int ret; @@ -5025,39 +4522,36 @@ peer_timers_unset_vty (struct vty *vty, const char *ip_str) DEFUN (neighbor_timers, neighbor_timers_cmd, - NEIGHBOR_CMD2 "timers <0-65535> <0-65535>", + "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "BGP per neighbor timers\n" "Keepalive interval\n" "Holdtime\n") { - return peer_timers_set_vty (vty, argv[0], argv[1], argv[2]); + int idx_peer = 1; + int idx_number = 3; + int idx_number_2 = 4; + return peer_timers_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); } DEFUN (no_neighbor_timers, no_neighbor_timers_cmd, - NO_NEIGHBOR_CMD2 "timers", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP per neighbor timers\n") -{ - return peer_timers_unset_vty (vty, argv[0]); -} - -ALIAS (no_neighbor_timers, - no_neighbor_timers_val_cmd, - NO_NEIGHBOR_CMD2 "timers <0-65535> <0-65535>", + "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "BGP per neighbor timers\n" "Keepalive interval\n" "Holdtime\n") +{ + int idx_peer = 2; + return peer_timers_unset_vty (vty, argv[idx_peer]->arg); +} + static int -peer_timers_connect_set_vty (struct vty *vty, const char *ip_str, +peer_timers_connect_set_vty (struct vty *vty, const char *ip_str, const char *time_str) { int ret; @@ -5092,41 +4586,36 @@ peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str) DEFUN (neighbor_timers_connect, neighbor_timers_connect_cmd, - NEIGHBOR_CMD2 "timers connect <1-65535>", + "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "BGP per neighbor timers\n" "BGP connect timer\n" "Connect timer\n") { - return peer_timers_connect_set_vty (vty, argv[0], argv[1]); + int idx_peer = 1; + int idx_number = 4; + return peer_timers_connect_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); } DEFUN (no_neighbor_timers_connect, no_neighbor_timers_connect_cmd, - NO_NEIGHBOR_CMD2 "timers connect", + "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "BGP per neighbor timers\n" - "BGP connect timer\n") + "BGP connect timer\n" + "Connect timer\n") { - return peer_timers_connect_unset_vty (vty, argv[0]); + int idx_peer = 2; + return peer_timers_connect_unset_vty (vty, argv[idx_peer]->arg); } -ALIAS (no_neighbor_timers_connect, - no_neighbor_timers_connect_val_cmd, - NO_NEIGHBOR_CMD2 "timers connect <1-65535>", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "BGP per neighbor timers\n" - "BGP connect timer\n" - "Connect timer\n") static int -peer_advertise_interval_vty (struct vty *vty, const char *ip_str, - const char *time_str, int set) +peer_advertise_interval_vty (struct vty *vty, const char *ip_str, + const char *time_str, int set) { int ret; struct peer *peer; @@ -5149,49 +4638,46 @@ peer_advertise_interval_vty (struct vty *vty, const char *ip_str, DEFUN (neighbor_advertise_interval, neighbor_advertise_interval_cmd, - NEIGHBOR_CMD2 "advertisement-interval <0-600>", + "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Minimum interval between sending BGP routing updates\n" "time in seconds\n") { - return peer_advertise_interval_vty (vty, argv[0], argv[1], 1); + int idx_peer = 1; + int idx_number = 3; + return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, 1); } DEFUN (no_neighbor_advertise_interval, no_neighbor_advertise_interval_cmd, - NO_NEIGHBOR_CMD2 "advertisement-interval", + "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "Minimum interval between sending BGP routing updates\n") + "Minimum interval between sending BGP routing updates\n" + "time in seconds\n") { - return peer_advertise_interval_vty (vty, argv[0], NULL, 0); + int idx_peer = 2; + return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, NULL, 0); } -ALIAS (no_neighbor_advertise_interval, - no_neighbor_advertise_interval_val_cmd, - NO_NEIGHBOR_CMD2 "advertisement-interval <0-600>", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "Minimum interval between sending BGP routing updates\n" - "time in seconds\n") /* Time to wait before processing route-map updates */ DEFUN (bgp_set_route_map_delay_timer, bgp_set_route_map_delay_timer_cmd, - "bgp route-map delay-timer <0-600>", + "bgp route-map delay-timer (0-600)", SET_STR "BGP route-map delay timer\n" "Time in secs to wait before processing route-map changes\n" "0 disables the timer, no route updates happen when route-maps change\n") { + int idx_number = 3; u_int32_t rmap_delay_timer; - if (argv[0]) + if (argv[idx_number]->arg) { - VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[0], 0, 600); + VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[idx_number]->arg, 0, 600); bm->rmap_update_timer = rmap_delay_timer; /* if the dynamic update handling is being disabled, and a timer is @@ -5210,10 +4696,11 @@ DEFUN (bgp_set_route_map_delay_timer, DEFUN (no_bgp_set_route_map_delay_timer, no_bgp_set_route_map_delay_timer_cmd, - "no bgp route-map delay-timer", + "no bgp route-map delay-timer [(0-600)]", NO_STR "Default BGP route-map delay timer\n" - "Reset to default time to wait for processing route-map changes\n") + "Reset to default time to wait for processing route-map changes\n" + "0 disables the timer, no route updates happen when route-maps change\n") { bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; @@ -5221,13 +4708,6 @@ DEFUN (no_bgp_set_route_map_delay_timer, return CMD_SUCCESS; } -ALIAS (no_bgp_set_route_map_delay_timer, - no_bgp_set_route_map_delay_timer_val_cmd, - "no bgp route-map delay-timer <0-600>", - NO_STR - "Default BGP route-map delay timer\n" - "Reset to default time to wait for processing route-map changes\n" - "0 disables the timer, no route updates happen when route-maps change\n") /* neighbor interface */ static int @@ -5249,33 +4729,33 @@ peer_interface_vty (struct vty *vty, const char *ip_str, const char *str) DEFUN (neighbor_interface, neighbor_interface_cmd, - NEIGHBOR_CMD "interface WORD", + "neighbor <A.B.C.D|X:X::X:X> interface WORD", NEIGHBOR_STR NEIGHBOR_ADDR_STR "Interface\n" "Interface name\n") { - if (argc == 3) - return peer_interface_vty (vty, argv[0], argv[1]); - else - return peer_interface_vty (vty, argv[0], argv[1]); + int idx_ip = 1; + int idx_word = 3; + return peer_interface_vty (vty, argv[idx_ip]->arg, argv[idx_word]->arg); } DEFUN (no_neighbor_interface, no_neighbor_interface_cmd, - NO_NEIGHBOR_CMD2 "interface WORD", + "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", NO_STR NEIGHBOR_STR - NEIGHBOR_ADDR_STR + NEIGHBOR_ADDR_STR2 "Interface\n" "Interface name\n") { - return peer_interface_vty (vty, argv[0], NULL); + int idx_peer = 2; + return peer_interface_vty (vty, argv[idx_peer]->arg, NULL); } /* Set distribute list to the peer. */ static int -peer_distribute_set_vty (struct vty *vty, const char *ip_str, +peer_distribute_set_vty (struct vty *vty, const char *ip_str, afi_t afi, safi_t safi, const char *name_str, const char *direct_str) { @@ -5323,7 +4803,7 @@ peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, DEFUN (neighbor_distribute_list, neighbor_distribute_list_cmd, - NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)", + "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Filter updates to/from this neighbor\n" @@ -5333,13 +4813,16 @@ DEFUN (neighbor_distribute_list, "Filter incoming updates\n" "Filter outgoing updates\n") { - return peer_distribute_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[1], argv[2]); + int idx_peer = 1; + int idx_acl = 3; + int idx_in_out = 4; + return peer_distribute_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_acl]->arg, argv[idx_in_out]->arg); } DEFUN (no_neighbor_distribute_list, no_neighbor_distribute_list_cmd, - NO_NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)", + "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 @@ -5350,14 +4833,16 @@ DEFUN (no_neighbor_distribute_list, "Filter incoming updates\n" "Filter outgoing updates\n") { - return peer_distribute_unset_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[2]); + int idx_peer = 2; + int idx_in_out = 5; + return peer_distribute_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_in_out]->arg); } /* Set prefix list to the peer. */ static int peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi, - safi_t safi, const char *name_str, + safi_t safi, const char *name_str, const char *direct_str) { int ret; @@ -5390,7 +4875,7 @@ peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) return CMD_WARNING; - + /* Check filter direction. */ if (strncmp (direct_str, "i", 1) == 0) direct = FILTER_IN; @@ -5404,7 +4889,7 @@ peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, DEFUN (neighbor_prefix_list, neighbor_prefix_list_cmd, - NEIGHBOR_CMD2 "prefix-list WORD (in|out)", + "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Filter updates to/from this neighbor\n" @@ -5412,13 +4897,16 @@ DEFUN (neighbor_prefix_list, "Filter incoming updates\n" "Filter outgoing updates\n") { - return peer_prefix_list_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[1], argv[2]); + int idx_peer = 1; + int idx_word = 3; + int idx_in_out = 4; + return peer_prefix_list_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); } DEFUN (no_neighbor_prefix_list, no_neighbor_prefix_list_cmd, - NO_NEIGHBOR_CMD2 "prefix-list WORD (in|out)", + "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 @@ -5427,12 +4915,14 @@ DEFUN (no_neighbor_prefix_list, "Filter incoming updates\n" "Filter outgoing updates\n") { - return peer_prefix_list_unset_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[2]); + int idx_peer = 2; + int idx_in_out = 5; + return peer_prefix_list_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_in_out]->arg); } static int -peer_aslist_set_vty (struct vty *vty, const char *ip_str, +peer_aslist_set_vty (struct vty *vty, const char *ip_str, afi_t afi, safi_t safi, const char *name_str, const char *direct_str) { @@ -5456,7 +4946,7 @@ peer_aslist_set_vty (struct vty *vty, const char *ip_str, } static int -peer_aslist_unset_vty (struct vty *vty, const char *ip_str, +peer_aslist_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, safi_t safi, const char *direct_str) { @@ -5481,7 +4971,7 @@ peer_aslist_unset_vty (struct vty *vty, const char *ip_str, DEFUN (neighbor_filter_list, neighbor_filter_list_cmd, - NEIGHBOR_CMD2 "filter-list WORD (in|out)", + "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Establish BGP filters\n" @@ -5489,13 +4979,16 @@ DEFUN (neighbor_filter_list, "Filter incoming routes\n" "Filter outgoing routes\n") { - return peer_aslist_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[1], argv[2]); + int idx_peer = 1; + int idx_word = 3; + int idx_in_out = 4; + return peer_aslist_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); } DEFUN (no_neighbor_filter_list, no_neighbor_filter_list_cmd, - NO_NEIGHBOR_CMD2 "filter-list WORD (in|out)", + "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 @@ -5504,13 +4997,15 @@ DEFUN (no_neighbor_filter_list, "Filter incoming routes\n" "Filter outgoing routes\n") { - return peer_aslist_unset_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[2]); + int idx_peer = 2; + int idx_in_out = 5; + return peer_aslist_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_in_out]->arg); } /* Set route-map to the peer. */ static int -peer_route_map_set_vty (struct vty *vty, const char *ip_str, +peer_route_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi, safi_t safi, const char *name_str, const char *direct_str) { @@ -5558,7 +5053,7 @@ peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, DEFUN (neighbor_route_map, neighbor_route_map_cmd, - NEIGHBOR_CMD2 "route-map WORD (in|out)", + "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Apply route map to neighbor\n" @@ -5566,13 +5061,16 @@ DEFUN (neighbor_route_map, "Apply map to incoming routes\n" "Apply map to outbound routes\n") { - return peer_route_map_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[1], argv[2]); + int idx_peer = 1; + int idx_word = 3; + int idx_in_out = 4; + return peer_route_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); } DEFUN (no_neighbor_route_map, no_neighbor_route_map_cmd, - NO_NEIGHBOR_CMD2 "route-map WORD (in|out)", + "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 @@ -5581,8 +5079,10 @@ DEFUN (no_neighbor_route_map, "Apply map to incoming routes\n" "Apply map to outbound routes\n") { - return peer_route_map_unset_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[2]); + int idx_peer = 2; + int idx_in_out = 5; + return peer_route_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_in_out]->arg); } /* Set unsuppress-map to the peer. */ @@ -5621,32 +5121,35 @@ peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, DEFUN (neighbor_unsuppress_map, neighbor_unsuppress_map_cmd, - NEIGHBOR_CMD2 "unsuppress-map WORD", + "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Route-map to selectively unsuppress suppressed routes\n" "Name of route map\n") { - return peer_unsuppress_map_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[1]); + int idx_peer = 1; + int idx_word = 3; + return peer_unsuppress_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_word]->arg); } DEFUN (no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_cmd, - NO_NEIGHBOR_CMD2 "unsuppress-map WORD", + "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Route-map to selectively unsuppress suppressed routes\n" "Name of route map\n") { - return peer_unsuppress_map_unset_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 2; + return peer_unsuppress_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty)); } static int peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi, - safi_t safi, const char *num_str, + safi_t safi, const char *num_str, const char *threshold_str, int warning, const char *restart_str) { @@ -5697,48 +5200,55 @@ peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, each peer configuration. */ DEFUN (neighbor_maximum_prefix, neighbor_maximum_prefix_cmd, - NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>", + "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Maximum number of prefix accept from this peer\n" "maximum no. of prefix limit\n") { - return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[1], NULL, 0, + int idx_peer = 1; + int idx_number = 3; + return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, NULL); } DEFUN (neighbor_maximum_prefix_threshold, neighbor_maximum_prefix_threshold_cmd, - NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>", + "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Maximum number of prefix accept from this peer\n" "maximum no. of prefix limit\n" "Threshold value (%) at which to generate a warning msg\n") { - return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[1], argv[2], 0, + int idx_peer = 1; + int idx_number = 3; + int idx_number_2 = 4; + return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); } DEFUN (neighbor_maximum_prefix_warning, neighbor_maximum_prefix_warning_cmd, - NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only", + "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Maximum number of prefix accept from this peer\n" "maximum no. of prefix limit\n" "Only give warning message when limit is exceeded\n") { - return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[1], NULL, 1, + int idx_peer = 1; + int idx_number = 3; + return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_number]->arg, NULL, 1, NULL); } DEFUN (neighbor_maximum_prefix_threshold_warning, neighbor_maximum_prefix_threshold_warning_cmd, - NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only", + "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Maximum number of prefix accept from this peer\n" @@ -5746,13 +5256,16 @@ DEFUN (neighbor_maximum_prefix_threshold_warning, "Threshold value (%) at which to generate a warning msg\n" "Only give warning message when limit is exceeded\n") { - return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[1], argv[2], 1, NULL); + int idx_peer = 1; + int idx_number = 3; + int idx_number_2 = 4; + return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); } DEFUN (neighbor_maximum_prefix_restart, neighbor_maximum_prefix_restart_cmd, - NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>", + "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Maximum number of prefix accept from this peer\n" @@ -5760,125 +5273,80 @@ DEFUN (neighbor_maximum_prefix_restart, "Restart bgp connection after limit is exceeded\n" "Restart interval in minutes") { - return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[1], NULL, 0, argv[2]); + int idx_peer = 1; + int idx_number = 3; + int idx_number_2 = 5; + return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); } DEFUN (neighbor_maximum_prefix_threshold_restart, neighbor_maximum_prefix_threshold_restart_cmd, - NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>", + "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "Maximum number of prefix accept from this peer\n" + "Maximum number of prefixes to accept from this peer\n" "maximum no. of prefix limit\n" "Threshold value (%) at which to generate a warning msg\n" "Restart bgp connection after limit is exceeded\n" - "Restart interval in minutes") + "Restart interval in minutes\n") { - return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[1], argv[2], 0, argv[3]); + int idx_peer = 1; + int idx_number = 3; + int idx_number_2 = 4; + int idx_number_3 = 6; + return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, argv[idx_number_3]->arg); } DEFUN (no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_cmd, - NO_NEIGHBOR_CMD2 "maximum-prefix", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "Maximum number of prefix accept from this peer\n") -{ - return peer_maximum_prefix_unset_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty)); -} - -ALIAS (no_neighbor_maximum_prefix, - no_neighbor_maximum_prefix_val_cmd, - NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>", + "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "Maximum number of prefix accept from this peer\n" - "maximum no. of prefix limit\n") - -ALIAS (no_neighbor_maximum_prefix, - no_neighbor_maximum_prefix_threshold_cmd, - NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "Maximum number of prefix accept from this peer\n" - "maximum no. of prefix limit\n" - "Threshold value (%) at which to generate a warning msg\n") - -ALIAS (no_neighbor_maximum_prefix, - no_neighbor_maximum_prefix_warning_cmd, - NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "Maximum number of prefix accept from this peer\n" - "maximum no. of prefix limit\n" - "Only give warning message when limit is exceeded\n") - -ALIAS (no_neighbor_maximum_prefix, - no_neighbor_maximum_prefix_threshold_warning_cmd, - NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "Maximum number of prefix accept from this peer\n" + "Maximum number of prefixes to accept from this peer\n" "maximum no. of prefix limit\n" "Threshold value (%) at which to generate a warning msg\n" - "Only give warning message when limit is exceeded\n") - -ALIAS (no_neighbor_maximum_prefix, - no_neighbor_maximum_prefix_restart_cmd, - NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "Maximum number of prefix accept from this peer\n" - "maximum no. of prefix limit\n" "Restart bgp connection after limit is exceeded\n" - "Restart interval in minutes") + "Restart interval in minutes\n" + "Only give warning message when limit is exceeded\n") +{ + int idx_peer = 2; + return peer_maximum_prefix_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty)); +} -ALIAS (no_neighbor_maximum_prefix, - no_neighbor_maximum_prefix_threshold_restart_cmd, - NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "Maximum number of prefix accept from this peer\n" - "maximum no. of prefix limit\n" - "Threshold value (%) at which to generate a warning msg\n" - "Restart bgp connection after limit is exceeded\n" - "Restart interval in minutes") /* "neighbor allowas-in" */ DEFUN (neighbor_allowas_in, neighbor_allowas_in_cmd, - NEIGHBOR_CMD2 "allowas-in", + "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "Accept as-path with my AS present in it\n") + "Accept as-path with my AS present in it\n" + "Number of occurances of AS number\n" + "Only accept my AS in the as-path if the route was originated in my AS\n") { + int idx_peer = 1; + int idx_number_origin = 3; int ret; int origin = 0; struct peer *peer; int allow_num = 0; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - if (argc == 1) + if (argc <= idx_number_origin) allow_num = 3; else { - if (strncmp (argv[1], "o", 1) == 0) + if (argv[idx_number_origin]->type == WORD_TKN) origin = 1; else - VTY_GET_INTEGER_RANGE ("AS number", allow_num, argv[1], 1, 10); + allow_num = atoi (argv[idx_number_origin]->arg); } ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty), @@ -5887,27 +5355,21 @@ DEFUN (neighbor_allowas_in, return bgp_vty_return (vty, ret); } -ALIAS (neighbor_allowas_in, - neighbor_allowas_in_arg_cmd, - NEIGHBOR_CMD2 "allowas-in (<1-10>|origin)", - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "Accept as-path with my AS present in it\n" - "Number of occurances of AS number\n" - "Only accept my AS in the as-path if the route was originated in my AS\n") - DEFUN (no_neighbor_allowas_in, no_neighbor_allowas_in_cmd, - NO_NEIGHBOR_CMD2 "allowas-in", + "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "allow local ASN appears in aspath attribute\n") + "allow local ASN appears in aspath attribute\n" + "Number of occurances of AS number\n" + "Only accept my AS in the as-path if the route was originated in my AS\n") { + int idx_peer = 2; int ret; struct peer *peer; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -5916,31 +5378,25 @@ DEFUN (no_neighbor_allowas_in, return bgp_vty_return (vty, ret); } -ALIAS (no_neighbor_allowas_in, - no_neighbor_allowas_in_val_cmd, - NO_NEIGHBOR_CMD2 "allowas-in (<1-10>|origin)", - NO_STR - NEIGHBOR_STR - NEIGHBOR_ADDR_STR2 - "allow local ASN appears in aspath attribute\n" - "Number of occurances of AS number\n" - "Only accept my AS in the as-path if the route was originated in my AS\n") - DEFUN (neighbor_ttl_security, neighbor_ttl_security_cmd, - NEIGHBOR_CMD2 "ttl-security hops <1-254>", + "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "Specify the maximum number of hops to the BGP peer\n") + "BGP ttl-security parameters\n" + "Specify the maximum number of hops to the BGP peer\n" + "Number of hops to BGP peer\n") { + int idx_peer = 1; + int idx_number = 4; struct peer *peer; int gtsm_hops; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - - VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[1], 1, 254); + + VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[idx_number]->arg, 1, 254); /* * If 'neighbor swpX', then this is for directly connected peers, @@ -5948,7 +5404,7 @@ DEFUN (neighbor_ttl_security, */ if (peer->conf_if && (gtsm_hops > 1)) { vty_out (vty, "%s is directly connected peer, hops cannot exceed 1%s", - argv[0], VTY_NEWLINE); + argv[idx_peer]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -5957,15 +5413,17 @@ DEFUN (neighbor_ttl_security, DEFUN (no_neighbor_ttl_security, no_neighbor_ttl_security_cmd, - NO_NEIGHBOR_CMD2 "ttl-security hops <1-254>", + "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 + "BGP ttl-security parameters\n" "Specify the maximum number of hops to the BGP peer\n") { + int idx_peer = 2; struct peer *peer; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -5974,73 +5432,77 @@ DEFUN (no_neighbor_ttl_security, DEFUN (neighbor_addpath_tx_all_paths, neighbor_addpath_tx_all_paths_cmd, - NEIGHBOR_CMD2 "addpath-tx-all-paths", + "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Use addpath to advertise all paths to a neighbor\n") { + int idx_peer = 1; struct peer *peer; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_ADDPATH_TX_ALL_PATHS); } DEFUN (no_neighbor_addpath_tx_all_paths, no_neighbor_addpath_tx_all_paths_cmd, - NO_NEIGHBOR_CMD2 "addpath-tx-all-paths", + "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Use addpath to advertise all paths to a neighbor\n") { - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_ADDPATH_TX_ALL_PATHS); } DEFUN (neighbor_addpath_tx_bestpath_per_as, neighbor_addpath_tx_bestpath_per_as_cmd, - NEIGHBOR_CMD2 "addpath-tx-bestpath-per-AS", + "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Use addpath to advertise the bestpath per each neighboring AS\n") { + int idx_peer = 1; struct peer *peer; - peer = peer_and_group_lookup_vty (vty, argv[0]); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); } DEFUN (no_neighbor_addpath_tx_bestpath_per_as, no_neighbor_addpath_tx_bestpath_per_as_cmd, - NO_NEIGHBOR_CMD2 "addpath-tx-bestpath-per-AS", + "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Use addpath to advertise the bestpath per each neighboring AS\n") { - return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); } -/* Address family configuration. */ +/* Address Family configuration. */ DEFUN (address_family_ipv4, address_family_ipv4_cmd, "address-family ipv4", "Enter Address Family command mode\n" - "Address family\n") + "Address Family\n") { vty->node = BGP_IPV4_NODE; return CMD_SUCCESS; @@ -6048,13 +5510,14 @@ DEFUN (address_family_ipv4, DEFUN (address_family_ipv4_safi, address_family_ipv4_safi_cmd, - "address-family ipv4 (unicast|multicast)", + "address-family ipv4 <unicast|multicast>", "Enter Address Family command mode\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n") { - if (strncmp (argv[0], "m", 1) == 0) + int idx_safi = 2; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) vty->node = BGP_IPV4M_NODE; else vty->node = BGP_IPV4_NODE; @@ -6066,7 +5529,7 @@ DEFUN (address_family_ipv6, address_family_ipv6_cmd, "address-family ipv6", "Enter Address Family command mode\n" - "Address family\n") + "Address Family\n") { vty->node = BGP_IPV6_NODE; return CMD_SUCCESS; @@ -6074,13 +5537,14 @@ DEFUN (address_family_ipv6, DEFUN (address_family_ipv6_safi, address_family_ipv6_safi_cmd, - "address-family ipv6 (unicast|multicast)", + "address-family ipv6 <unicast|multicast>", "Enter Address Family command mode\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n") { - if (strncmp (argv[0], "m", 1) == 0) + int idx_safi = 2; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) vty->node = BGP_IPV6M_NODE; else vty->node = BGP_IPV6_NODE; @@ -6090,59 +5554,43 @@ DEFUN (address_family_ipv6_safi, DEFUN (address_family_vpnv4, address_family_vpnv4_cmd, - "address-family vpnv4", + "address-family vpnv4 [unicast]", "Enter Address Family command mode\n" - "Address family\n") + "Address Family\n" + "Address Family Modifier\n") { vty->node = BGP_VPNV4_NODE; return CMD_SUCCESS; } -ALIAS (address_family_vpnv4, - address_family_vpnv4_unicast_cmd, - "address-family vpnv4 unicast", - "Enter Address Family command mode\n" - "Address family\n" - "Address Family Modifier\n") - DEFUN (address_family_vpnv6, address_family_vpnv6_cmd, - "address-family vpnv6", + "address-family vpnv6 [unicast]", "Enter Address Family command mode\n" - "Address family\n") + "Address Family\n" + "Address Family Modifier\n") { vty->node = BGP_VPNV6_NODE; return CMD_SUCCESS; } -ALIAS (address_family_vpnv6, - address_family_vpnv6_unicast_cmd, - "address-family vpnv6 unicast", - "Enter Address Family command mode\n" - "Address family\n" - "Address Family Modifier\n") - DEFUN (address_family_encap, address_family_encap_cmd, - "address-family encap", + "address-family <encap|encapv4>", "Enter Address Family command mode\n" - "Address family\n") + "Address Family\n" + "Address Family\n") { vty->node = BGP_ENCAP_NODE; return CMD_SUCCESS; } -ALIAS (address_family_encap, - address_family_encapv4_cmd, - "address-family encapv4", - "Enter Address Family command mode\n" - "Address family\n") DEFUN (address_family_encapv6, address_family_encapv6_cmd, "address-family encapv6", "Enter Address Family command mode\n" - "Address family\n") + "Address Family\n") { vty->node = BGP_ENCAPV6_NODE; return CMD_SUCCESS; @@ -6246,3765 +5694,212 @@ bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str, return CMD_SUCCESS; } +/* one clear bgp command to rule them all */ DEFUN (clear_ip_bgp_all, clear_ip_bgp_all_cmd, - "clear ip bgp *", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n") -{ - if (argc == 2) - return bgp_clear_vty (vty, argv[1], 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL); - - return bgp_clear_vty (vty, NULL, 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL); -} - -ALIAS (clear_ip_bgp_all, - clear_ip_bgp_instance_all_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " *", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all peers\n") - -ALIAS (clear_ip_bgp_all, - clear_bgp_all_cmd, - "clear bgp *", - CLEAR_STR - BGP_STR - "Clear all peers\n") - -ALIAS (clear_ip_bgp_all, - clear_bgp_instance_all_cmd, - "clear bgp " BGP_INSTANCE_CMD " *", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all peers\n") - -ALIAS (clear_ip_bgp_all, - clear_bgp_ipv6_all_cmd, - "clear bgp ipv6 *", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all peers\n") - -ALIAS (clear_ip_bgp_all, - clear_bgp_instance_ipv6_all_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 *", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear all peers\n") - -DEFUN (clear_ip_bgp_peer, - clear_ip_bgp_peer_cmd, - "clear ip bgp (A.B.C.D|X:X::X:X|WORD)", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor IP address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n") -{ - if (argc == 3) - return bgp_clear_vty (vty, argv[1], 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[2]); - - return bgp_clear_vty (vty, NULL, 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[0]); -} - -ALIAS (clear_ip_bgp_peer, - clear_ip_bgp_instance_peer_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD)", + "clear [ip] bgp [<view|vrf> WORD] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] [<soft [<in|out>]|in [prefix-filter]|out>]", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "BGP neighbor IP address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n") - -ALIAS (clear_ip_bgp_peer, - clear_bgp_peer_cmd, - "clear bgp (A.B.C.D|X:X::X:X|WORD)", - CLEAR_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n") - -ALIAS (clear_ip_bgp_peer, - clear_bgp_instance_peer_cmd, - "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD)", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "BGP neighbor IP address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n") - -ALIAS (clear_ip_bgp_peer, - clear_bgp_ipv6_peer_cmd, - "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD)", - CLEAR_STR - BGP_STR - "Address family\n" - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n") - -ALIAS (clear_ip_bgp_peer, - clear_bgp_instance_ipv6_peer_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD)", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "BGP neighbor IP address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n") - -DEFUN (clear_ip_bgp_peer_group, - clear_ip_bgp_peer_group_cmd, - "clear ip bgp peer-group WORD", - CLEAR_STR - IP_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n") -{ - if (argc == 3) - return bgp_clear_vty (vty, argv[1], 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[2]); - - return bgp_clear_vty (vty, NULL, 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[0]); -} - -ALIAS (clear_ip_bgp_peer_group, - clear_ip_bgp_instance_peer_group_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n") - -ALIAS (clear_ip_bgp_peer_group, - clear_bgp_peer_group_cmd, - "clear bgp peer-group WORD", - CLEAR_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n") - -ALIAS (clear_ip_bgp_peer_group, - clear_bgp_instance_peer_group_cmd, - "clear bgp " BGP_INSTANCE_CMD " peer-group WORD", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n") - -ALIAS (clear_ip_bgp_peer_group, - clear_bgp_ipv6_peer_group_cmd, - "clear bgp ipv6 peer-group WORD", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all members of peer-group\n" - "BGP peer-group name\n") - -ALIAS (clear_ip_bgp_peer_group, - clear_bgp_instance_ipv6_peer_group_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear all members of peer-group\n" - "BGP peer-group name\n") - -DEFUN (clear_ip_bgp_external, - clear_ip_bgp_external_cmd, - "clear ip bgp external", - CLEAR_STR - IP_STR - BGP_STR - "Clear all external peers\n") -{ - if (argc == 2) - return bgp_clear_vty (vty, argv[1], 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL); - - return bgp_clear_vty (vty, NULL, 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL); -} - -ALIAS (clear_ip_bgp_external, - clear_ip_bgp_instance_external_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all external peers\n") - -ALIAS (clear_ip_bgp_external, - clear_bgp_external_cmd, - "clear bgp external", - CLEAR_STR - BGP_STR - "Clear all external peers\n") - -ALIAS (clear_ip_bgp_external, - clear_bgp_instance_external_cmd, - "clear bgp " BGP_INSTANCE_CMD " external", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all external peers\n") - -ALIAS (clear_ip_bgp_external, - clear_bgp_ipv6_external_cmd, - "clear bgp ipv6 external", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all external peers\n") - -ALIAS (clear_ip_bgp_external, - clear_bgp_instance_ipv6_external_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 external", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear all external peers\n") - -DEFUN (clear_ip_bgp_prefix, - clear_ip_bgp_prefix_cmd, - "clear ip bgp prefix A.B.C.D/M", - CLEAR_STR - IP_STR - BGP_STR - "Clear bestpath and re-advertise\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") -{ - if (argc == 3) - return bgp_clear_prefix (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL); - - return bgp_clear_prefix (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL); -} - -ALIAS (clear_ip_bgp_prefix, - clear_ip_bgp_instance_prefix_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " prefix A.B.C.D/M", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear bestpath and re-advertise\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") - -ALIAS (clear_ip_bgp_prefix, - clear_bgp_prefix_cmd, - "clear bgp prefix A.B.C.D/M", - CLEAR_STR - BGP_STR - "Clear bestpath and re-advertise\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") - -ALIAS (clear_ip_bgp_prefix, - clear_bgp_instance_prefix_cmd, - "clear bgp " BGP_INSTANCE_CMD " prefix A.B.C.D/M", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear bestpath and re-advertise\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") - -DEFUN (clear_ip_bgp_as, - clear_ip_bgp_as_cmd, - "clear ip bgp " CMD_AS_RANGE, - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n") -{ - if (argc == 3) - return bgp_clear_vty (vty, argv[1], 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[2]); - - return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[0]); -} - -ALIAS (clear_ip_bgp_as, - clear_ip_bgp_instance_as_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE, - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear peers with the AS number\n") - -ALIAS (clear_ip_bgp_as, - clear_bgp_as_cmd, - "clear bgp " CMD_AS_RANGE, - CLEAR_STR - BGP_STR - "Clear peers with the AS number\n") - -ALIAS (clear_ip_bgp_as, - clear_bgp_instance_as_cmd, - "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE, - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear peers with the AS number\n") - -ALIAS (clear_ip_bgp_as, - clear_bgp_ipv6_as_cmd, - "clear bgp ipv6 " CMD_AS_RANGE, - CLEAR_STR - BGP_STR - "Address family\n" - "Clear peers with the AS number\n") - -ALIAS (clear_ip_bgp_as, - clear_bgp_instance_ipv6_as_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE, - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear peers with the AS number\n") - -/* Outbound soft-reconfiguration */ -DEFUN (clear_ip_bgp_all_soft_out, - clear_ip_bgp_all_soft_out_cmd, - "clear ip bgp * soft out", - CLEAR_STR - IP_STR - BGP_STR "Clear all peers\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - if (argc == 2) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_OUT, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_OUT, NULL); -} - -ALIAS (clear_ip_bgp_all_soft_out, - clear_ip_bgp_instance_all_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * soft out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all peers\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_ip_bgp_all_soft_out, - clear_ip_bgp_all_out_cmd, - "clear ip bgp * out", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_ip_bgp_all_soft_out, - clear_ip_bgp_instance_all_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all peers\n" - BGP_SOFT_OUT_STR) - -DEFUN (clear_ip_bgp_all_ipv4_soft_out, - clear_ip_bgp_all_ipv4_soft_out_cmd, - "clear ip bgp * ipv4 (unicast|multicast) soft out", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all, - BGP_CLEAR_SOFT_OUT, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_OUT, NULL); -} - -DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out, - clear_ip_bgp_instance_all_ipv4_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) soft out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_OUT_STR) -{ - if (strncmp (argv[2], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_all, - BGP_CLEAR_SOFT_OUT, NULL); - - return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_OUT, NULL); -} - -ALIAS (clear_ip_bgp_all_ipv4_soft_out, - clear_ip_bgp_all_ipv4_out_cmd, - "clear ip bgp * ipv4 (unicast|multicast) out", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_ip_bgp_instance_all_ipv4_soft_out, - clear_ip_bgp_instance_all_ipv4_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_OUT_STR) - -DEFUN (clear_ip_bgp_all_vpnv4_soft_out, - clear_ip_bgp_all_vpnv4_soft_out_cmd, - "clear ip bgp * vpnv4 unicast soft out", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all, - BGP_CLEAR_SOFT_OUT, NULL); -} - -ALIAS (clear_ip_bgp_all_vpnv4_soft_out, - clear_ip_bgp_all_vpnv4_out_cmd, - "clear ip bgp * vpnv4 unicast out", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_OUT_STR) - -DEFUN (clear_ip_bgp_all_encap_soft_out, - clear_ip_bgp_all_encap_soft_out_cmd, - "clear ip bgp * encap unicast soft out", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig\n" - "Soft reconfig outbound update\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_all, - BGP_CLEAR_SOFT_OUT, NULL); -} - -ALIAS (clear_ip_bgp_all_encap_soft_out, - clear_ip_bgp_all_encap_out_cmd, - "clear ip bgp * encap unicast out", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig outbound update\n") - -DEFUN (clear_bgp_all_soft_out, - clear_bgp_all_soft_out_cmd, - "clear bgp * soft out", - CLEAR_STR - BGP_STR - "Clear all peers\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - if (argc == 2) - return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_OUT, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_OUT, NULL); -} - -ALIAS (clear_bgp_all_soft_out, - clear_bgp_instance_all_soft_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " * soft out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all peers\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_all_soft_out, - clear_bgp_all_out_cmd, - "clear bgp * out", - CLEAR_STR - BGP_STR - "Clear all peers\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_all_soft_out, - clear_bgp_instance_all_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " * out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all peers\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_all_soft_out, - clear_bgp_ipv6_all_soft_out_cmd, - "clear bgp ipv6 * soft out", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all peers\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_all_soft_out, - clear_bgp_instance_ipv6_all_soft_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 * soft out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear all peers\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_all_soft_out, - clear_bgp_ipv6_all_out_cmd, - "clear bgp ipv6 * out", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all peers\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_all_soft_out, - clear_bgp_instance_ipv6_all_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 * out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear all peers\n" - BGP_SOFT_OUT_STR) - -DEFUN (clear_bgp_ipv6_safi_prefix, - clear_bgp_ipv6_safi_prefix_cmd, - "clear bgp ipv6 (unicast|multicast) prefix X:X::X:X/M", - CLEAR_STR - BGP_STR - "Address family\n" - "Address Family Modifier\n" - "Clear bestpath and re-advertise\n" - "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL); - else - return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL); -} - -DEFUN (clear_bgp_instance_ipv6_safi_prefix, - clear_bgp_instance_ipv6_safi_prefix_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 (unicast|multicast) prefix X:X::X:X/M", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Address Family Modifier\n" - "Clear bestpath and re-advertise\n" - "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") -{ - if (strncmp (argv[2], "m", 1) == 0) - return bgp_clear_prefix (vty, argv[1], argv[3], AFI_IP6, SAFI_MULTICAST, NULL); - else - return bgp_clear_prefix (vty, argv[1], argv[3], AFI_IP6, SAFI_UNICAST, NULL); -} - -DEFUN (clear_ip_bgp_peer_soft_out, - clear_ip_bgp_peer_soft_out_cmd, - "clear ip bgp (A.B.C.D|WORD) soft out", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - if (argc == 3) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[2]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[0]); -} - -ALIAS (clear_ip_bgp_peer_soft_out, - clear_ip_bgp_instance_peer_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) soft out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_ip_bgp_peer_soft_out, - clear_ip_bgp_peer_out_cmd, - "clear ip bgp (A.B.C.D|WORD) out", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_ip_bgp_peer_soft_out, - clear_ip_bgp_instance_peer_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_OUT_STR) - -DEFUN (clear_ip_bgp_peer_ipv4_soft_out, - clear_ip_bgp_peer_ipv4_soft_out_cmd, - "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft out", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[0]); -} - -DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_out, - clear_ip_bgp_instance_peer_ipv4_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) soft out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - if (strncmp (argv[3], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[2]); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[2]); -} - -ALIAS (clear_ip_bgp_peer_ipv4_soft_out, - clear_ip_bgp_peer_ipv4_out_cmd, - "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) out", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_ip_bgp_instance_peer_ipv4_soft_out, - clear_ip_bgp_instance_peer_ipv4_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_OUT_STR) - -/* NOTE: WORD peers have not been tested for vpnv4 */ -DEFUN (clear_ip_bgp_peer_vpnv4_soft_out, - clear_ip_bgp_peer_vpnv4_soft_out_cmd, - "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft out", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[0]); -} - -ALIAS (clear_ip_bgp_peer_vpnv4_soft_out, - clear_ip_bgp_peer_vpnv4_out_cmd, - "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast out", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_OUT_STR) - -DEFUN (clear_ip_bgp_peer_encap_soft_out, - clear_ip_bgp_peer_encap_soft_out_cmd, - "clear ip bgp A.B.C.D encap unicast soft out", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig\n" - "Soft reconfig outbound update\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[0]); -} - -ALIAS (clear_ip_bgp_peer_encap_soft_out, - clear_ip_bgp_peer_encap_out_cmd, - "clear ip bgp A.B.C.D encap unicast out", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig outbound update\n") - -DEFUN (clear_bgp_peer_soft_out, - clear_bgp_peer_soft_out_cmd, - "clear bgp (A.B.C.D|X:X::X:X|WORD) soft out", - CLEAR_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - if (argc == 3) - return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[2]); - - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[0]); -} - -ALIAS (clear_bgp_peer_soft_out, - clear_bgp_instance_peer_soft_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) soft out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR "BGP neighbor address to clear\n" "BGP IPv6 neighbor to clear\n" "BGP neighbor on interface to clear\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_peer_soft_out, - clear_bgp_ipv6_peer_soft_out_cmd, - "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft out", - CLEAR_STR - BGP_STR - "Address family\n" - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_peer_soft_out, - clear_bgp_instance_ipv6_peer_soft_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) soft out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_peer_soft_out, - clear_bgp_peer_out_cmd, - "clear bgp (A.B.C.D|X:X::X:X|WORD) out", - CLEAR_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_peer_soft_out, - clear_bgp_instance_peer_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_peer_soft_out, - clear_bgp_ipv6_peer_out_cmd, - "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) out", - CLEAR_STR - BGP_STR - "Address family\n" - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_peer_soft_out, - clear_bgp_instance_ipv6_peer_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_OUT_STR) - -DEFUN (clear_ip_bgp_peer_group_soft_out, - clear_ip_bgp_peer_group_soft_out_cmd, - "clear ip bgp peer-group WORD soft out", - CLEAR_STR - IP_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - if (argc == 3) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_OUT, argv[2]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_OUT, argv[0]); -} - -ALIAS (clear_ip_bgp_peer_group_soft_out, - clear_ip_bgp_instance_peer_group_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD soft out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_ip_bgp_peer_group_soft_out, - clear_ip_bgp_peer_group_out_cmd, - "clear ip bgp peer-group WORD out", - CLEAR_STR - IP_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_ip_bgp_peer_group_soft_out, - clear_ip_bgp_instance_peer_group_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_OUT_STR) - -DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out, - clear_ip_bgp_peer_group_ipv4_soft_out_cmd, - "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft out", - CLEAR_STR - IP_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_OUT, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_OUT, argv[0]); -} - -DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_out, - clear_ip_bgp_instance_peer_group_ipv4_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) soft out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - if (strncmp (argv[3], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_OUT, argv[2]); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_OUT, argv[2]); -} - -ALIAS (clear_ip_bgp_peer_group_ipv4_soft_out, - clear_ip_bgp_peer_group_ipv4_out_cmd, - "clear ip bgp peer-group WORD ipv4 (unicast|multicast) out", - CLEAR_STR - IP_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_ip_bgp_instance_peer_group_ipv4_soft_out, - clear_ip_bgp_instance_peer_group_ipv4_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_OUT_STR) - -DEFUN (clear_bgp_peer_group_soft_out, - clear_bgp_peer_group_soft_out_cmd, - "clear bgp peer-group WORD soft out", - CLEAR_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - if (argc == 3) - return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_OUT, argv[2]); - - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_OUT, argv[0]); -} - -ALIAS (clear_bgp_peer_group_soft_out, - clear_bgp_instance_peer_group_soft_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " peer-group WORD soft out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_peer_group_soft_out, - clear_bgp_ipv6_peer_group_soft_out_cmd, - "clear bgp ipv6 peer-group WORD soft out", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_peer_group_soft_out, - clear_bgp_instance_ipv6_peer_group_soft_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD soft out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_peer_group_soft_out, - clear_bgp_peer_group_out_cmd, - "clear bgp peer-group WORD out", - CLEAR_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_peer_group_soft_out, - clear_bgp_instance_peer_group_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " peer-group WORD out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_peer_group_soft_out, - clear_bgp_ipv6_peer_group_out_cmd, - "clear bgp ipv6 peer-group WORD out", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_peer_group_soft_out, - clear_bgp_instance_ipv6_peer_group_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_OUT_STR) - -DEFUN (clear_ip_bgp_external_soft_out, - clear_ip_bgp_external_soft_out_cmd, - "clear ip bgp external soft out", - CLEAR_STR - IP_STR - BGP_STR - "Clear all external peers\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - if (argc == 2) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_OUT, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_OUT, NULL); -} - -ALIAS (clear_ip_bgp_external_soft_out, - clear_ip_bgp_instance_external_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external soft out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all external peers\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_ip_bgp_external_soft_out, - clear_ip_bgp_external_out_cmd, - "clear ip bgp external out", - CLEAR_STR - IP_STR - BGP_STR - "Clear all external peers\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_ip_bgp_external_soft_out, - clear_ip_bgp_instance_external_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all external peers\n" - BGP_SOFT_OUT_STR) - -DEFUN (clear_ip_bgp_external_ipv4_soft_out, - clear_ip_bgp_external_ipv4_soft_out_cmd, - "clear ip bgp external ipv4 (unicast|multicast) soft out", - CLEAR_STR - IP_STR - BGP_STR - "Clear all external peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external, - BGP_CLEAR_SOFT_OUT, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_OUT, NULL); -} - -DEFUN (clear_ip_bgp_instance_external_ipv4_soft_out, - clear_ip_bgp_instance_external_ipv4_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) soft out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all external peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - if (strncmp (argv[2], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_external, - BGP_CLEAR_SOFT_OUT, NULL); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_OUT, NULL); -} - -ALIAS (clear_ip_bgp_external_ipv4_soft_out, - clear_ip_bgp_external_ipv4_out_cmd, - "clear ip bgp external ipv4 (unicast|multicast) out", - CLEAR_STR - IP_STR - BGP_STR - "Clear all external peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_ip_bgp_instance_external_ipv4_soft_out, - clear_ip_bgp_instance_external_ipv4_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all external peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_OUT_STR) - -DEFUN (clear_bgp_external_soft_out, - clear_bgp_external_soft_out_cmd, - "clear bgp external soft out", - CLEAR_STR - BGP_STR - "Clear all external peers\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - if (argc == 2) - return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_OUT, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_OUT, NULL); -} - -ALIAS (clear_bgp_external_soft_out, - clear_bgp_instance_external_soft_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " external soft out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all external peers\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_external_soft_out, - clear_bgp_ipv6_external_soft_out_cmd, - "clear bgp ipv6 external soft out", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all external peers\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_external_soft_out, - clear_bgp_instance_ipv6_external_soft_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 external soft out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear all external peers\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_external_soft_out, - clear_bgp_external_out_cmd, - "clear bgp external out", - CLEAR_STR - BGP_STR - "Clear all external peers\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_external_soft_out, - clear_bgp_instance_external_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " external out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all external peers\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_external_soft_out, - clear_bgp_ipv6_external_out_cmd, - "clear bgp ipv6 external WORD out", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all external peers\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_external_soft_out, - clear_bgp_instance_ipv6_external_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 external WORD out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear all external peers\n" - BGP_SOFT_OUT_STR) - -DEFUN (clear_ip_bgp_as_soft_out, - clear_ip_bgp_as_soft_out_cmd, - "clear ip bgp " CMD_AS_RANGE " soft out", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - if (argc == 3) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_OUT, argv[2]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_OUT, argv[0]); -} - -ALIAS (clear_ip_bgp_as_soft_out, - clear_ip_bgp_instance_as_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear peers with the AS number\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_ip_bgp_as_soft_out, - clear_ip_bgp_as_out_cmd, - "clear ip bgp " CMD_AS_RANGE " out", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_ip_bgp_as_soft_out, - clear_ip_bgp_instance_as_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear peers with the AS number\n" - BGP_SOFT_OUT_STR) - -DEFUN (clear_ip_bgp_as_ipv4_soft_out, - clear_ip_bgp_as_ipv4_soft_out_cmd, - "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_OUT, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_OUT, argv[0]); -} - -DEFUN (clear_ip_bgp_instance_as_ipv4_soft_out, - clear_ip_bgp_instance_as_ipv4_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - if (strncmp (argv[3], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_OUT, argv[2]); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_OUT, argv[2]); -} - -ALIAS (clear_ip_bgp_as_ipv4_soft_out, - clear_ip_bgp_as_ipv4_out_cmd, - "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) out", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_ip_bgp_instance_as_ipv4_soft_out, - clear_ip_bgp_instance_as_ipv4_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) out", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_OUT_STR) - -DEFUN (clear_ip_bgp_as_vpnv4_soft_out, - clear_ip_bgp_as_vpnv4_soft_out_cmd, - "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft out", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as, - BGP_CLEAR_SOFT_OUT, argv[0]); -} - -ALIAS (clear_ip_bgp_as_vpnv4_soft_out, - clear_ip_bgp_as_vpnv4_out_cmd, - "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast out", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - BGP_SOFT_OUT_STR) - -DEFUN (clear_ip_bgp_as_encap_soft_out, - clear_ip_bgp_as_encap_soft_out_cmd, - "clear ip bgp " CMD_AS_RANGE " encap unicast soft out", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - "Soft reconfig\n" - "Soft reconfig outbound update\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as, - BGP_CLEAR_SOFT_OUT, argv[0]); -} - -ALIAS (clear_ip_bgp_as_encap_soft_out, - clear_ip_bgp_as_encap_out_cmd, - "clear ip bgp " CMD_AS_RANGE " encap unicast out", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - "Soft reconfig outbound update\n") - -DEFUN (clear_bgp_as_soft_out, - clear_bgp_as_soft_out_cmd, - "clear bgp " CMD_AS_RANGE " soft out", - CLEAR_STR - BGP_STR - "Clear peers with the AS number\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - if (argc == 3) - return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_OUT, argv[2]); - - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_OUT, argv[0]); -} - -ALIAS (clear_bgp_as_soft_out, - clear_bgp_instance_as_soft_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear peers with the AS number\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_as_soft_out, - clear_bgp_ipv6_as_soft_out_cmd, - "clear bgp ipv6 " CMD_AS_RANGE " soft out", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear peers with the AS number\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_as_soft_out, - clear_bgp_instance_ipv6_as_soft_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " soft out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear peers with the AS number\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_as_soft_out, - clear_bgp_as_out_cmd, - "clear bgp " CMD_AS_RANGE " out", - CLEAR_STR - BGP_STR - "Clear peers with the AS number\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_as_soft_out, - clear_bgp_instance_as_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear peers with the AS number\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_as_soft_out, - clear_bgp_ipv6_as_out_cmd, - "clear bgp ipv6 " CMD_AS_RANGE " out", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear peers with the AS number\n" - BGP_SOFT_OUT_STR) - -ALIAS (clear_bgp_as_soft_out, - clear_bgp_instance_ipv6_as_out_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " out", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" "Clear peers with the AS number\n" - BGP_SOFT_OUT_STR) - -/* Inbound soft-reconfiguration */ -DEFUN (clear_ip_bgp_all_soft_in, - clear_ip_bgp_all_soft_in_cmd, - "clear ip bgp * soft in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (argc == 2) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_IN, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_IN, NULL); -} - -ALIAS (clear_ip_bgp_all_soft_in, - clear_ip_bgp_instance_all_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * soft in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all peers\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_ip_bgp_all_soft_in, - clear_ip_bgp_all_in_cmd, - "clear ip bgp * in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_ip_bgp_all_soft_in, - clear_ip_bgp_instance_all_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all peers\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_ip_bgp_all_in_prefix_filter, - clear_ip_bgp_all_in_prefix_filter_cmd, - "clear ip bgp * in prefix-filter", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - BGP_SOFT_IN_STR - "Push out prefix-list ORF and do inbound soft reconfig\n") -{ - if (argc== 2) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); -} - -DEFUN (clear_ip_bgp_all_ipv4_soft_in, - clear_ip_bgp_all_ipv4_soft_in_cmd, - "clear ip bgp * ipv4 (unicast|multicast) soft in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all, - BGP_CLEAR_SOFT_IN, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_IN, NULL); -} - -DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in, - clear_ip_bgp_instance_all_ipv4_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) soft in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (strncmp (argv[2], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_all, - BGP_CLEAR_SOFT_IN, NULL); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_IN, NULL); -} - -ALIAS (clear_ip_bgp_all_ipv4_soft_in, - clear_ip_bgp_all_ipv4_in_cmd, - "clear ip bgp * ipv4 (unicast|multicast) in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_ip_bgp_instance_all_ipv4_soft_in, - clear_ip_bgp_instance_all_ipv4_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter, - clear_ip_bgp_all_ipv4_in_prefix_filter_cmd, - "clear ip bgp * ipv4 (unicast|multicast) in prefix-filter", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_IN_STR - "Push out prefix-list ORF and do inbound soft reconfig\n") -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); -} - -DEFUN (clear_ip_bgp_all_vpnv4_soft_in, - clear_ip_bgp_all_vpnv4_soft_in_cmd, - "clear ip bgp * vpnv4 unicast soft in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all, - BGP_CLEAR_SOFT_IN, NULL); -} - -ALIAS (clear_ip_bgp_all_vpnv4_soft_in, - clear_ip_bgp_all_vpnv4_in_cmd, - "clear ip bgp * vpnv4 unicast in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_ip_bgp_all_encap_soft_in, - clear_ip_bgp_all_encap_soft_in_cmd, - "clear ip bgp * encap unicast soft in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig\n" - "Soft reconfig inbound update\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_all, - BGP_CLEAR_SOFT_IN, NULL); -} - -ALIAS (clear_ip_bgp_all_encap_soft_in, - clear_ip_bgp_all_encap_in_cmd, - "clear ip bgp * encap unicast in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig inbound update\n") - -DEFUN (clear_bgp_all_soft_in, - clear_bgp_all_soft_in_cmd, - "clear bgp * soft in", - CLEAR_STR - BGP_STR - "Clear all peers\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (argc == 2) - return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_IN, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_IN, NULL); -} - -ALIAS (clear_bgp_all_soft_in, - clear_bgp_instance_all_soft_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " * soft in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all peers\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_all_soft_in, - clear_bgp_ipv6_all_soft_in_cmd, - "clear bgp ipv6 * soft in", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all peers\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_all_soft_in, - clear_bgp_instance_ipv6_all_soft_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 * soft in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear all peers\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_all_soft_in, - clear_bgp_all_in_cmd, - "clear bgp * in", - CLEAR_STR - BGP_STR - "Clear all peers\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_all_soft_in, - clear_bgp_instance_all_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " * in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all peers\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_all_soft_in, - clear_bgp_ipv6_all_in_cmd, - "clear bgp ipv6 * in", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all peers\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_all_soft_in, - clear_bgp_instance_ipv6_all_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 * in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear all peers\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_bgp_all_in_prefix_filter, - clear_bgp_all_in_prefix_filter_cmd, - "clear bgp * in prefix-filter", - CLEAR_STR - BGP_STR - "Clear all peers\n" - BGP_SOFT_IN_STR - "Push out prefix-list ORF and do inbound soft reconfig\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); -} - -ALIAS (clear_bgp_all_in_prefix_filter, - clear_bgp_ipv6_all_in_prefix_filter_cmd, - "clear bgp ipv6 * in prefix-filter", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all peers\n" - BGP_SOFT_IN_STR - "Push out prefix-list ORF and do inbound soft reconfig\n") - -DEFUN (clear_ip_bgp_peer_soft_in, - clear_ip_bgp_peer_soft_in_cmd, - "clear ip bgp (A.B.C.D|WORD) soft in", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (argc == 3) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_IN, argv[2]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_IN, argv[0]); -} - -ALIAS (clear_ip_bgp_peer_soft_in, - clear_ip_bgp_instance_peer_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) soft in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_ip_bgp_peer_soft_in, - clear_ip_bgp_peer_in_cmd, - "clear ip bgp (A.B.C.D|WORD) in", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_ip_bgp_peer_soft_in, - clear_ip_bgp_instance_peer_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_ip_bgp_peer_in_prefix_filter, - clear_ip_bgp_peer_in_prefix_filter_cmd, - "clear ip bgp (A.B.C.D|WORD) in prefix-filter", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_IN_STR - "Push out the existing ORF prefix-list\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); -} - -DEFUN (clear_ip_bgp_peer_ipv4_soft_in, - clear_ip_bgp_peer_ipv4_soft_in_cmd, - "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft in", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_IN, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_IN, argv[0]); -} - -DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_in, - clear_ip_bgp_instance_peer_ipv4_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) soft in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (strncmp (argv[3], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_IN, argv[2]); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_IN, argv[2]); -} - -ALIAS (clear_ip_bgp_peer_ipv4_soft_in, - clear_ip_bgp_peer_ipv4_in_cmd, - "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) in", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_ip_bgp_instance_peer_ipv4_soft_in, - clear_ip_bgp_instance_peer_ipv4_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter, - clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd, - "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) in prefix-filter", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_IN_STR - "Push out the existing ORF prefix-list\n") -{ - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); -} - -DEFUN (clear_ip_bgp_peer_vpnv4_soft_in, - clear_ip_bgp_peer_vpnv4_soft_in_cmd, - "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft in", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer, - BGP_CLEAR_SOFT_IN, argv[0]); -} - -ALIAS (clear_ip_bgp_peer_vpnv4_soft_in, - clear_ip_bgp_peer_vpnv4_in_cmd, - "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast in", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_ip_bgp_peer_encap_soft_in, - clear_ip_bgp_peer_encap_soft_in_cmd, - "clear ip bgp A.B.C.D encap unicast soft in", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig\n" - "Soft reconfig inbound update\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer, - BGP_CLEAR_SOFT_IN, argv[0]); -} - -ALIAS (clear_ip_bgp_peer_encap_soft_in, - clear_ip_bgp_peer_encap_in_cmd, - "clear ip bgp A.B.C.D encap unicast in", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig inbound update\n") - -DEFUN (clear_bgp_peer_soft_in, - clear_bgp_peer_soft_in_cmd, - "clear bgp (A.B.C.D|X:X::X:X|WORD) soft in", - CLEAR_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (argc == 3) - return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_IN, argv[2]); - - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_IN, argv[0]); -} - -ALIAS (clear_bgp_peer_soft_in, - clear_bgp_instance_peer_soft_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) soft in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_peer_soft_in, - clear_bgp_ipv6_peer_soft_in_cmd, - "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft in", - CLEAR_STR - BGP_STR - "Address family\n" - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_peer_soft_in, - clear_bgp_instance_ipv6_peer_soft_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) soft in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_peer_soft_in, - clear_bgp_peer_in_cmd, - "clear bgp (A.B.C.D|X:X::X:X|WORD) in", - CLEAR_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_peer_soft_in, - clear_bgp_instance_peer_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_peer_soft_in, - clear_bgp_ipv6_peer_in_cmd, - "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) in", - CLEAR_STR - BGP_STR - "Address family\n" - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_peer_soft_in, - clear_bgp_instance_ipv6_peer_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_bgp_peer_in_prefix_filter, - clear_bgp_peer_in_prefix_filter_cmd, - "clear bgp (A.B.C.D|X:X::X:X|WORD) in prefix-filter", - CLEAR_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_IN_STR - "Push out the existing ORF prefix-list\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); -} - -ALIAS (clear_bgp_peer_in_prefix_filter, - clear_bgp_ipv6_peer_in_prefix_filter_cmd, - "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) in prefix-filter", - CLEAR_STR - BGP_STR - "Address family\n" - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_IN_STR - "Push out the existing ORF prefix-list\n") - -DEFUN (clear_ip_bgp_peer_group_soft_in, - clear_ip_bgp_peer_group_soft_in_cmd, - "clear ip bgp peer-group WORD soft in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (argc == 3) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_IN, argv[2]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_IN, argv[0]); -} - -ALIAS (clear_ip_bgp_peer_group_soft_in, - clear_ip_bgp_instance_peer_group_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD soft in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_ip_bgp_peer_group_soft_in, - clear_ip_bgp_peer_group_in_cmd, - "clear ip bgp peer-group WORD in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_ip_bgp_peer_group_soft_in, - clear_ip_bgp_instance_peer_group_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_ip_bgp_peer_group_in_prefix_filter, - clear_ip_bgp_peer_group_in_prefix_filter_cmd, - "clear ip bgp peer-group WORD in prefix-filter", - CLEAR_STR - IP_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_IN_STR - "Push out prefix-list ORF and do inbound soft reconfig\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); -} - -DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in, - clear_ip_bgp_peer_group_ipv4_soft_in_cmd, - "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_IN, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_IN, argv[0]); -} - -DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_in, - clear_ip_bgp_instance_peer_group_ipv4_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) soft in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (strncmp (argv[3], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_IN, argv[2]); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_IN, argv[2]); -} - -ALIAS (clear_ip_bgp_peer_group_ipv4_soft_in, - clear_ip_bgp_peer_group_ipv4_in_cmd, - "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_ip_bgp_instance_peer_group_ipv4_soft_in, - clear_ip_bgp_instance_peer_group_ipv4_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter, - clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd, - "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in prefix-filter", - CLEAR_STR - IP_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_IN_STR - "Push out prefix-list ORF and do inbound soft reconfig\n") -{ - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); -} - -DEFUN (clear_bgp_peer_group_soft_in, - clear_bgp_peer_group_soft_in_cmd, - "clear bgp peer-group WORD soft in", - CLEAR_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (argc == 3) - return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_IN, argv[2]); - - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_IN, argv[0]); -} - -ALIAS (clear_bgp_peer_group_soft_in, - clear_bgp_instance_peer_group_soft_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " peer-group WORD soft in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_peer_group_soft_in, - clear_bgp_ipv6_peer_group_soft_in_cmd, - "clear bgp ipv6 peer-group WORD soft in", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_peer_group_soft_in, - clear_bgp_instance_ipv6_peer_group_soft_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD soft in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_peer_group_soft_in, - clear_bgp_peer_group_in_cmd, - "clear bgp peer-group WORD in", - CLEAR_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_peer_group_soft_in, - clear_bgp_instance_peer_group_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " peer-group WORD in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_peer_group_soft_in, - clear_bgp_ipv6_peer_group_in_cmd, - "clear bgp ipv6 peer-group WORD in", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_peer_group_soft_in, - clear_bgp_instance_ipv6_peer_group_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_bgp_peer_group_in_prefix_filter, - clear_bgp_peer_group_in_prefix_filter_cmd, - "clear bgp peer-group WORD in prefix-filter", - CLEAR_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_IN_STR - "Push out prefix-list ORF and do inbound soft reconfig\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); -} - -ALIAS (clear_bgp_peer_group_in_prefix_filter, - clear_bgp_ipv6_peer_group_in_prefix_filter_cmd, - "clear bgp ipv6 peer-group WORD in prefix-filter", - CLEAR_STR - BGP_STR - "Address family\n" + "Clear all external peers\n" "Clear all members of peer-group\n" "BGP peer-group name\n" - BGP_SOFT_IN_STR - "Push out prefix-list ORF and do inbound soft reconfig\n") - -DEFUN (clear_ip_bgp_external_soft_in, - clear_ip_bgp_external_soft_in_cmd, - "clear ip bgp external soft in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all external peers\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (argc == 2) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_IN, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_IN, NULL); -} - -ALIAS (clear_ip_bgp_external_soft_in, - clear_ip_bgp_instance_external_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external soft in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all external peers\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_ip_bgp_external_soft_in, - clear_ip_bgp_external_in_cmd, - "clear ip bgp external in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all external peers\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_ip_bgp_external_soft_in, - clear_ip_bgp_instance_external_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all external peers\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_ip_bgp_external_in_prefix_filter, - clear_ip_bgp_external_in_prefix_filter_cmd, - "clear ip bgp external in prefix-filter", - CLEAR_STR - IP_STR - BGP_STR - "Clear all external peers\n" - BGP_SOFT_IN_STR - "Push out prefix-list ORF and do inbound soft reconfig\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); -} - -DEFUN (clear_ip_bgp_external_ipv4_soft_in, - clear_ip_bgp_external_ipv4_soft_in_cmd, - "clear ip bgp external ipv4 (unicast|multicast) soft in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all external peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external, - BGP_CLEAR_SOFT_IN, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_IN, NULL); -} - -DEFUN (clear_ip_bgp_instance_external_ipv4_soft_in, - clear_ip_bgp_instance_external_ipv4_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) soft in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all external peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (strncmp (argv[2], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_external, - BGP_CLEAR_SOFT_IN, NULL); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_IN, NULL); -} - -ALIAS (clear_ip_bgp_external_ipv4_soft_in, - clear_ip_bgp_external_ipv4_in_cmd, - "clear ip bgp external ipv4 (unicast|multicast) in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all external peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_ip_bgp_instance_external_ipv4_soft_in, - clear_ip_bgp_instance_external_ipv4_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all external peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter, - clear_ip_bgp_external_ipv4_in_prefix_filter_cmd, - "clear ip bgp external ipv4 (unicast|multicast) in prefix-filter", - CLEAR_STR - IP_STR - BGP_STR - "Clear all external peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_IN_STR - "Push out prefix-list ORF and do inbound soft reconfig\n") -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); -} - -DEFUN (clear_bgp_external_soft_in, - clear_bgp_external_soft_in_cmd, - "clear bgp external soft in", - CLEAR_STR - BGP_STR - "Clear all external peers\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (argc == 2) - return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_IN, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_IN, NULL); -} - -ALIAS (clear_bgp_external_soft_in, - clear_bgp_instance_external_soft_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " external soft in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all external peers\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_external_soft_in, - clear_bgp_ipv6_external_soft_in_cmd, - "clear bgp ipv6 external soft in", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all external peers\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_external_soft_in, - clear_bgp_instance_ipv6_external_soft_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 external soft in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear all external peers\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_external_soft_in, - clear_bgp_external_in_cmd, - "clear bgp external in", - CLEAR_STR - BGP_STR - "Clear all external peers\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_external_soft_in, - clear_bgp_instance_external_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " external in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all external peers\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_external_soft_in, - clear_bgp_ipv6_external_in_cmd, - "clear bgp ipv6 external WORD in", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all external peers\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_external_soft_in, - clear_bgp_instance_ipv6_external_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 external WORD in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear all external peers\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_bgp_external_in_prefix_filter, - clear_bgp_external_in_prefix_filter_cmd, - "clear bgp external in prefix-filter", - CLEAR_STR - BGP_STR - "Clear all external peers\n" - BGP_SOFT_IN_STR - "Push out prefix-list ORF and do inbound soft reconfig\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); -} - -ALIAS (clear_bgp_external_in_prefix_filter, - clear_bgp_ipv6_external_in_prefix_filter_cmd, - "clear bgp ipv6 external in prefix-filter", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all external peers\n" - BGP_SOFT_IN_STR - "Push out prefix-list ORF and do inbound soft reconfig\n") - -DEFUN (clear_ip_bgp_as_soft_in, - clear_ip_bgp_as_soft_in_cmd, - "clear ip bgp " CMD_AS_RANGE " soft in", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (argc == 3) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_IN, argv[2]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_IN, argv[0]); -} - -ALIAS (clear_ip_bgp_as_soft_in, - clear_ip_bgp_instance_as_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear peers with the AS number\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_ip_bgp_as_soft_in, - clear_ip_bgp_as_in_cmd, - "clear ip bgp " CMD_AS_RANGE " in", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_ip_bgp_as_soft_in, - clear_ip_bgp_instance_as_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear peers with the AS number\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_ip_bgp_as_in_prefix_filter, - clear_ip_bgp_as_in_prefix_filter_cmd, - "clear ip bgp " CMD_AS_RANGE " in prefix-filter", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - BGP_SOFT_IN_STR - "Push out prefix-list ORF and do inbound soft reconfig\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); -} - -DEFUN (clear_ip_bgp_as_ipv4_soft_in, - clear_ip_bgp_as_ipv4_soft_in_cmd, - "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_IN, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_IN, argv[0]); -} - -DEFUN (clear_ip_bgp_instance_as_ipv4_soft_in, - clear_ip_bgp_instance_as_ipv4_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" + "Address Family\n" "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (strncmp (argv[3], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_IN, argv[2]); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_IN, argv[2]); -} - -ALIAS (clear_ip_bgp_as_ipv4_soft_in, - clear_ip_bgp_as_ipv4_in_cmd, - "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_ip_bgp_instance_as_ipv4_soft_in, - clear_ip_bgp_instance_as_ipv4_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) in", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear peers with the AS number\n" - "Address family\n" "Address Family modifier\n" + "Address Family\n" "Address Family modifier\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter, - clear_ip_bgp_as_ipv4_in_prefix_filter_cmd, - "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in prefix-filter", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" "Address Family modifier\n" + "Address Family\n" "Address Family modifier\n" - BGP_SOFT_IN_STR - "Push out prefix-list ORF and do inbound soft reconfig\n") -{ - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); -} - -DEFUN (clear_ip_bgp_as_vpnv4_soft_in, - clear_ip_bgp_as_vpnv4_soft_in_cmd, - "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft in", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as, - BGP_CLEAR_SOFT_IN, argv[0]); -} - -ALIAS (clear_ip_bgp_as_vpnv4_soft_in, - clear_ip_bgp_as_vpnv4_in_cmd, - "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast in", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_ip_bgp_as_encap_soft_in, - clear_ip_bgp_as_encap_soft_in_cmd, - "clear ip bgp " CMD_AS_RANGE " encap unicast soft in", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - "Soft reconfig\n" - "Soft reconfig inbound update\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as, - BGP_CLEAR_SOFT_IN, argv[0]); -} - -ALIAS (clear_ip_bgp_as_encap_soft_in, - clear_ip_bgp_as_encap_in_cmd, - "clear ip bgp " CMD_AS_RANGE " encap unicast in", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - "Soft reconfig inbound update\n") - -DEFUN (clear_bgp_as_soft_in, - clear_bgp_as_soft_in_cmd, - "clear bgp " CMD_AS_RANGE " soft in", - CLEAR_STR - BGP_STR - "Clear peers with the AS number\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - if (argc == 3) - return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_IN, argv[2]); - - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_IN, argv[0]); -} - -ALIAS (clear_bgp_as_soft_in, - clear_bgp_instance_as_soft_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear peers with the AS number\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_as_soft_in, - clear_bgp_ipv6_as_soft_in_cmd, - "clear bgp ipv6 " CMD_AS_RANGE " soft in", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear peers with the AS number\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_as_soft_in, - clear_bgp_instance_ipv6_as_soft_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " soft in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear peers with the AS number\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_as_soft_in, - clear_bgp_as_in_cmd, - "clear bgp " CMD_AS_RANGE " in", - CLEAR_STR - BGP_STR - "Clear peers with the AS number\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_as_soft_in, - clear_bgp_instance_as_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear peers with the AS number\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_as_soft_in, - clear_bgp_ipv6_as_in_cmd, - "clear bgp ipv6 " CMD_AS_RANGE " in", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear peers with the AS number\n" - BGP_SOFT_IN_STR) - -ALIAS (clear_bgp_as_soft_in, - clear_bgp_instance_ipv6_as_in_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " in", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear peers with the AS number\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_bgp_as_in_prefix_filter, - clear_bgp_as_in_prefix_filter_cmd, - "clear bgp " CMD_AS_RANGE " in prefix-filter", - CLEAR_STR - BGP_STR - "Clear peers with the AS number\n" BGP_SOFT_IN_STR - "Push out prefix-list ORF and do inbound soft reconfig\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); -} - -ALIAS (clear_bgp_as_in_prefix_filter, - clear_bgp_ipv6_as_in_prefix_filter_cmd, - "clear bgp ipv6 " CMD_AS_RANGE " in prefix-filter", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear peers with the AS number\n" + BGP_SOFT_OUT_STR BGP_SOFT_IN_STR - "Push out prefix-list ORF and do inbound soft reconfig\n") - -/* Both soft-reconfiguration */ -DEFUN (clear_ip_bgp_all_soft, - clear_ip_bgp_all_soft_cmd, - "clear ip bgp * soft", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - BGP_SOFT_STR) -{ - if (argc == 2) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_BOTH, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_BOTH, NULL); -} - -ALIAS (clear_ip_bgp_all_soft, - clear_ip_bgp_instance_all_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * soft", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all peers\n" - BGP_SOFT_STR) - - -DEFUN (clear_ip_bgp_all_ipv4_soft, - clear_ip_bgp_all_ipv4_soft_cmd, - "clear ip bgp * ipv4 (unicast|multicast) soft", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - "Address Family Modifier\n" - BGP_SOFT_STR) -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all, - BGP_CLEAR_SOFT_BOTH, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_BOTH, NULL); -} - -DEFUN (clear_ip_bgp_instance_all_ipv4_soft, - clear_ip_bgp_instance_all_ipv4_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) soft", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - "Address Family Modifier\n" - BGP_SOFT_STR) -{ - if (strncmp (argv[2], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_all, - BGP_CLEAR_SOFT_BOTH, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_BOTH, NULL); -} - -DEFUN (clear_ip_bgp_all_vpnv4_soft, - clear_ip_bgp_all_vpnv4_soft_cmd, - "clear ip bgp * vpnv4 unicast soft", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_STR) -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all, - BGP_CLEAR_SOFT_BOTH, argv[0]); -} - -DEFUN (clear_ip_bgp_all_encap_soft, - clear_ip_bgp_all_encap_soft_cmd, - "clear ip bgp * encap unicast soft", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_all, - BGP_CLEAR_SOFT_BOTH, argv[0]); -} - -DEFUN (clear_bgp_all_soft, - clear_bgp_all_soft_cmd, - "clear bgp * soft", - CLEAR_STR - BGP_STR - "Clear all peers\n" - BGP_SOFT_STR) -{ - if (argc == 2) - return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_BOTH, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_BOTH, NULL); -} - -ALIAS (clear_bgp_all_soft, - clear_bgp_instance_all_soft_cmd, - "clear bgp " BGP_INSTANCE_CMD " * soft", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all peers\n" - BGP_SOFT_STR) - -ALIAS (clear_bgp_all_soft, - clear_bgp_ipv6_all_soft_cmd, - "clear bgp ipv6 * soft", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all peers\n" - BGP_SOFT_STR) - -ALIAS (clear_bgp_all_soft, - clear_bgp_instance_ipv6_all_soft_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 * soft", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear all peers\n" - BGP_SOFT_STR) - -DEFUN (clear_ip_bgp_peer_soft, - clear_ip_bgp_peer_soft_cmd, - "clear ip bgp (A.B.C.D|WORD) soft", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_STR) -{ - if (argc == 3) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[2]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[0]); -} - -ALIAS (clear_ip_bgp_peer_soft, - clear_ip_bgp_instance_peer_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) soft", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_STR) - -DEFUN (clear_ip_bgp_peer_ipv4_soft, - clear_ip_bgp_peer_ipv4_soft_cmd, - "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family Modifier\n" - "Address Family Modifier\n" - BGP_SOFT_STR) -{ - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[0]); -} - -DEFUN (clear_ip_bgp_instance_peer_ipv4_soft, - clear_ip_bgp_instance_peer_ipv4_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) soft", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family Modifier\n" - "Address Family Modifier\n" - BGP_SOFT_STR) -{ - if (strncmp (argv[3], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[2]); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[2]); -} - -DEFUN (clear_ip_bgp_peer_vpnv4_soft, - clear_ip_bgp_peer_vpnv4_soft_cmd, - "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_STR) -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[0]); -} - -DEFUN (clear_ip_bgp_peer_encap_soft, - clear_ip_bgp_peer_encap_soft_cmd, - "clear ip bgp A.B.C.D encap unicast soft", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[0]); -} - -DEFUN (clear_bgp_peer_soft, - clear_bgp_peer_soft_cmd, - "clear bgp (A.B.C.D|X:X::X:X|WORD) soft", - CLEAR_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_STR) -{ - if (argc == 3) - return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[2]); - - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[0]); -} - -ALIAS (clear_bgp_peer_soft, - clear_bgp_instance_peer_soft_cmd, - "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) soft", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_STR) - -ALIAS (clear_bgp_peer_soft, - clear_bgp_ipv6_peer_soft_cmd, - "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft", - CLEAR_STR - BGP_STR - "Address family\n" - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_STR) - -ALIAS (clear_bgp_peer_soft, - clear_bgp_instance_ipv6_peer_soft_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) soft", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "BGP neighbor address to clear\n" - "BGP IPv6 neighbor to clear\n" - "BGP neighbor on interface to clear\n" - BGP_SOFT_STR) - -DEFUN (clear_ip_bgp_peer_group_soft, - clear_ip_bgp_peer_group_soft_cmd, - "clear ip bgp peer-group WORD soft", - CLEAR_STR - IP_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_STR) -{ - if (argc == 3) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[2]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[0]); -} - -ALIAS (clear_ip_bgp_peer_group_soft, - clear_ip_bgp_instance_peer_group_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD soft", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_STR) - -DEFUN (clear_ip_bgp_peer_group_ipv4_soft, - clear_ip_bgp_peer_group_ipv4_soft_cmd, - "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft", - CLEAR_STR - IP_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR) -{ - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[0]); -} - -DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft, - clear_ip_bgp_instance_peer_group_ipv4_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) soft", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR) -{ - if (strncmp (argv[3], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[2]); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[2]); -} - -DEFUN (clear_bgp_peer_group_soft, - clear_bgp_peer_group_soft_cmd, - "clear bgp peer-group WORD soft", - CLEAR_STR - BGP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_STR) + "Push out prefix-list ORF and do inbound soft reconfig\n" + BGP_SOFT_OUT_STR) { - if (argc == 3) - return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[2]); - - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[0]); -} + char *vrf = NULL; -ALIAS (clear_bgp_peer_group_soft, - clear_bgp_instance_peer_group_soft_cmd, - "clear bgp " BGP_INSTANCE_CMD " peer-group WORD soft", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_STR) + afi_t afi = AFI_IP6; + safi_t safi = SAFI_UNICAST; + enum clear_sort clr_sort = clear_peer; + enum bgp_clear_type clr_type; + char *clr_arg = NULL; -ALIAS (clear_bgp_peer_group_soft, - clear_bgp_ipv6_peer_group_soft_cmd, - "clear bgp ipv6 peer-group WORD soft", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_STR) + int idx = 0; -ALIAS (clear_bgp_peer_group_soft, - clear_bgp_instance_ipv6_peer_group_soft_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD soft", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear all members of peer-group\n" - "BGP peer-group name\n" - BGP_SOFT_STR) - -DEFUN (clear_ip_bgp_external_soft, - clear_ip_bgp_external_soft_cmd, - "clear ip bgp external soft", - CLEAR_STR - IP_STR - BGP_STR - "Clear all external peers\n" - BGP_SOFT_STR) -{ - if (argc == 2) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_BOTH, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_BOTH, NULL); -} - -ALIAS (clear_ip_bgp_external_soft, - clear_ip_bgp_instance_external_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external soft", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all external peers\n" - BGP_SOFT_STR) + /* clear [ip] bgp */ + if (argv_find (argv, argc, "ip", &idx)) + afi = AFI_IP; + /* [<view|vrf> WORD] */ + if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) + { + vrf = argv[idx + 1]->arg; + idx += 2; + } + /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ + if (argv_find (argv, argc, "*", &idx)) + { + clr_sort = clear_all; + } + else if (argv_find (argv, argc, "A.B.C.D", &idx)) + { + clr_sort = clear_peer; + clr_arg = argv[idx]->arg; + } + else if (argv_find (argv, argc, "X:X::X:X", &idx)) + { + clr_sort = clear_peer; + clr_arg = argv[idx]->arg; + } + else if (argv_find (argv, argc, "peer-group", &idx)) + { + clr_sort = clear_group; + idx++; + clr_arg = argv[idx]->arg; -DEFUN (clear_ip_bgp_external_ipv4_soft, - clear_ip_bgp_external_ipv4_soft_cmd, - "clear ip bgp external ipv4 (unicast|multicast) soft", - CLEAR_STR - IP_STR - BGP_STR - "Clear all external peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR) -{ - if (strncmp (argv[0], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external, - BGP_CLEAR_SOFT_BOTH, NULL); + if (! peer_group_lookup (vty->index, clr_arg)) + { + vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE); + return CMD_WARNING; + } + } + else if (argv_find (argv, argc, "WORD", &idx)) + { + if (peer_lookup_by_conf_if (vty->index, argv[idx]->arg)) + { + clr_sort = clear_peer; + clr_arg = argv[idx]->arg; + } + else + { + vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE); + return CMD_WARNING; + } + } + else if (argv_find (argv, argc, "(1-4294967295)", &idx)) + { + clr_sort = clear_as; + clr_arg = argv[idx]->arg; + } + else if (argv_find (argv, argc, "external", &idx)) + { + clr_sort = clear_external; + } + /* [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]||vpnv4 [unicast]>] */ + if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) + { + afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; + if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) + safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST; + } + else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) + { + afi = AFI_IP; + safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN; + // advance idx if necessary + argv_find (argv, argc, "unicast", &idx); + } + /* [<soft [<in|out>]|in [prefix-filter]|out>] */ + if (argv_find (argv, argc, "soft", &idx)) + { + if (argv_find (argv, argc, "in", &idx) || argv_find (argv, argc, "out", &idx)) + clr_type = strmatch (argv[idx]->text, "in") ? BGP_CLEAR_SOFT_IN : BGP_CLEAR_SOFT_OUT; + else + clr_type = BGP_CLEAR_SOFT_BOTH; + } + else if (argv_find (argv, argc, "in", &idx)) + { + clr_type = argv_find (argv, argc, "prefix-filter", &idx) ? BGP_CLEAR_SOFT_IN_ORF_PREFIX : BGP_CLEAR_SOFT_IN; + } + else if (argv_find (argv, argc, "out", &idx)) + { + clr_type = BGP_CLEAR_SOFT_OUT; + } + else + clr_type = BGP_CLEAR_SOFT_NONE; - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_BOTH, NULL); + return bgp_clear_vty (vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); } -DEFUN (clear_ip_bgp_instance_external_ipv4_soft, - clear_ip_bgp_instance_external_ipv4_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) soft", +DEFUN (clear_ip_bgp_prefix, + clear_ip_bgp_prefix_cmd, + "clear [ip] bgp [<view|vrf> WORD] prefix A.B.C.D/M", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "Clear all external peers\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - BGP_SOFT_STR) + "Clear bestpath and re-advertise\n" + "IPv4 prefix\n") { - if (strncmp (argv[2], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_external, - BGP_CLEAR_SOFT_BOTH, NULL); + char *vrf = NULL; + char *prefix = NULL; - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_BOTH, NULL); -} + int idx = 0; -DEFUN (clear_bgp_external_soft, - clear_bgp_external_soft_cmd, - "clear bgp external soft", - CLEAR_STR - BGP_STR - "Clear all external peers\n" - BGP_SOFT_STR) -{ - if (argc == 2) - return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_BOTH, NULL); + /* [<view|vrf> WORD] */ + if (argv_find (argv, argc, "WORD", &idx)) + vrf = argv[idx]->arg; - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_BOTH, NULL); -} + prefix = argv[argc-1]->arg; -ALIAS (clear_bgp_external_soft, - clear_bgp_instance_external_soft_cmd, - "clear bgp " BGP_INSTANCE_CMD " external soft", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear all external peers\n" - BGP_SOFT_STR) - -ALIAS (clear_bgp_external_soft, - clear_bgp_ipv6_external_soft_cmd, - "clear bgp ipv6 external soft", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear all external peers\n" - BGP_SOFT_STR) - -ALIAS (clear_bgp_external_soft, - clear_bgp_instance_ipv6_external_soft_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 external soft", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear all external peers\n" - BGP_SOFT_STR) - -DEFUN (clear_ip_bgp_as_soft, - clear_ip_bgp_as_soft_cmd, - "clear ip bgp " CMD_AS_RANGE " soft", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - BGP_SOFT_STR) -{ - if (argc == 3) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[2]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[0]); + return bgp_clear_prefix (vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); } -ALIAS (clear_ip_bgp_as_soft, - clear_ip_bgp_instance_as_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft", - CLEAR_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear peers with the AS number\n" - BGP_SOFT_STR) - -DEFUN (clear_ip_bgp_as_ipv4_soft, - clear_ip_bgp_as_ipv4_soft_cmd, - "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft", +DEFUN (clear_bgp_ipv6_safi_prefix, + clear_bgp_ipv6_safi_prefix_cmd, + "clear bgp ipv6 <unicast|multicast> prefix X:X::X:X/M", CLEAR_STR - IP_STR BGP_STR - "Clear peers with the AS number\n" - "Address family\n" + "Address Family\n" "Address Family Modifier\n" "Address Family Modifier\n" - BGP_SOFT_STR) + "Clear bestpath and re-advertise\n" + "IPv6 prefix\n") { - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[0]); - - return bgp_clear_vty (vty, NULL,AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[0]); + int idx_safi = 3; + int idx_ipv6_prefixlen = 5; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, NULL); + else + return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL); } -DEFUN (clear_ip_bgp_instance_as_ipv4_soft, - clear_ip_bgp_instance_as_ipv4_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) soft", +DEFUN (clear_bgp_instance_ipv6_safi_prefix, + clear_bgp_instance_ipv6_safi_prefix_cmd, + "clear bgp <view|vrf> WORD ipv6 <unicast|multicast> prefix X:X::X:X/M", CLEAR_STR - IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "Clear peers with the AS number\n" - "Address family\n" + "Address Family\n" "Address Family Modifier\n" "Address Family Modifier\n" - BGP_SOFT_STR) -{ - if (strncmp (argv[3], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[2]); - - return bgp_clear_vty (vty, argv[1],AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[2]); -} - -DEFUN (clear_ip_bgp_as_vpnv4_soft, - clear_ip_bgp_as_vpnv4_soft_cmd, - "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_STR) -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[0]); -} - -DEFUN (clear_ip_bgp_as_encap_soft, - clear_ip_bgp_as_encap_soft_cmd, - "clear ip bgp " CMD_AS_RANGE " encap unicast soft", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[0]); -} - -DEFUN (clear_bgp_as_soft, - clear_bgp_as_soft_cmd, - "clear bgp " CMD_AS_RANGE " soft", - CLEAR_STR - BGP_STR - "Clear peers with the AS number\n" - BGP_SOFT_STR) + "Clear bestpath and re-advertise\n" + "IPv6 prefix\n") { - if (argc == 3) - return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[2]); - - return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[0]); + int idx_word = 3; + int idx_safi = 5; + int idx_ipv6_prefixlen = 7; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, NULL); + else + return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL); } -ALIAS (clear_bgp_as_soft, - clear_bgp_instance_as_soft_cmd, - "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Clear peers with the AS number\n" - BGP_SOFT_STR) - -ALIAS (clear_bgp_as_soft, - clear_bgp_ipv6_as_soft_cmd, - "clear bgp ipv6 " CMD_AS_RANGE " soft", - CLEAR_STR - BGP_STR - "Address family\n" - "Clear peers with the AS number\n" - BGP_SOFT_STR) - -ALIAS (clear_bgp_as_soft, - clear_bgp_instance_ipv6_as_soft_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " soft", - CLEAR_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Clear peers with the AS number\n" - BGP_SOFT_STR) - DEFUN (show_bgp_views, show_bgp_views_cmd, - "show bgp views", + "show [ip] bgp views", SHOW_STR + IP_STR BGP_STR "Show the defined BGP views\n") { @@ -10017,7 +5912,7 @@ DEFUN (show_bgp_views, vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); return CMD_WARNING; } - + vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE); for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { @@ -10028,14 +5923,15 @@ DEFUN (show_bgp_views, bgp->name ? bgp->name : "(null)", bgp->as, VTY_NEWLINE); } - + return CMD_SUCCESS; } DEFUN (show_bgp_vrfs, show_bgp_vrfs_cmd, - "show bgp vrfs {json}", + "show [ip] bgp vrfs [json]", SHOW_STR + IP_STR BGP_STR "Show BGP VRFs\n" "JavaScript Object Notation\n") @@ -10140,7 +6036,7 @@ DEFUN (show_bgp_vrfs, return CMD_SUCCESS; } -DEFUN (show_bgp_memory, +DEFUN (show_bgp_memory, show_bgp_memory_cmd, "show bgp memory", SHOW_STR @@ -10149,14 +6045,14 @@ DEFUN (show_bgp_memory, { char memstrbuf[MTYPE_MEMSTR_LEN]; unsigned long count; - + /* RIB related usage stats */ count = mtype_stats_alloc (MTYPE_BGP_NODE); vty_out (vty, "%ld RIB nodes, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct bgp_node)), VTY_NEWLINE); - + count = mtype_stats_alloc (MTYPE_BGP_ROUTE); vty_out (vty, "%ld BGP routes, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), @@ -10167,7 +6063,7 @@ DEFUN (show_bgp_memory, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct bgp_info_extra)), VTY_NEWLINE); - + if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC))) vty_out (vty, "%ld Static routes, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), @@ -10179,7 +6075,7 @@ DEFUN (show_bgp_memory, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct bpacket)), VTY_NEWLINE); - + /* Adj-In/Out */ if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN))) vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count, @@ -10191,7 +6087,7 @@ DEFUN (show_bgp_memory, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct bgp_adj_out)), VTY_NEWLINE); - + if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE))) vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), @@ -10206,32 +6102,32 @@ DEFUN (show_bgp_memory, /* Attributes */ count = attr_count(); - vty_out (vty, "%ld BGP attributes, using %s of memory%s", count, - mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof(struct attr)), + vty_out (vty, "%ld BGP attributes, using %s of memory%s", count, + mtype_memstr (memstrbuf, sizeof (memstrbuf), + count * sizeof(struct attr)), VTY_NEWLINE); if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA))) - vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count, - mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof(struct attr_extra)), + vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count, + mtype_memstr (memstrbuf, sizeof (memstrbuf), + count * sizeof(struct attr_extra)), VTY_NEWLINE); - + if ((count = attr_unknown_count())) vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE); - + /* AS_PATH attributes */ count = aspath_count (); vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct aspath)), VTY_NEWLINE); - + count = mtype_stats_alloc (MTYPE_AS_SEG); vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct assegment)), VTY_NEWLINE); - + /* Other attributes */ if ((count = community_count ())) vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, @@ -10243,26 +6139,26 @@ DEFUN (show_bgp_memory, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct ecommunity)), VTY_NEWLINE); - + if ((count = mtype_stats_alloc (MTYPE_CLUSTER))) vty_out (vty, "%ld Cluster lists, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct cluster_list)), VTY_NEWLINE); - + /* Peer related usage */ count = mtype_stats_alloc (MTYPE_BGP_PEER); vty_out (vty, "%ld peers, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct peer)), VTY_NEWLINE); - + if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP))) vty_out (vty, "%ld peer groups, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct peer_group)), VTY_NEWLINE); - + /* Other */ if ((count = mtype_stats_alloc (MTYPE_HASH))) vty_out (vty, "%ld hash tables, using %s of memory%s", count, @@ -10495,7 +6391,7 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, vty_out (vty, "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd%s", VTY_NEWLINE); } } - + count++; if (use_json) @@ -10554,10 +6450,10 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, } if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) - len = vty_out (vty, "%s%s(%s) ", dn_flag, peer->hostname, + len = vty_out (vty, "%s%s(%s)", dn_flag, peer->hostname, peer->host); else - len = vty_out (vty, "%s%s ", dn_flag, peer->host); + len = vty_out (vty, "%s%s", dn_flag, peer->host); /* pad the neighbor column with spaces */ if (len < max_neighbor_width) @@ -10629,34 +6525,6 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, return CMD_SUCCESS; } -static int -bgp_show_summary_vty (struct vty *vty, const char *name, - afi_t afi, safi_t safi, u_char use_json) -{ - struct bgp *bgp; - - if (name) - { - bgp = bgp_lookup_by_name (name); - - if (! bgp) - { - vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); - return CMD_WARNING; - } - - bgp_show_summary (vty, bgp, afi, safi, use_json, NULL); - return CMD_SUCCESS; - } - - bgp = bgp_get_default (); - - if (bgp) - bgp_show_summary (vty, bgp, afi, safi, use_json, NULL); - - return CMD_SUCCESS; -} - static void bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, u_char use_json) @@ -10673,14 +6541,7 @@ bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, { if (use_json) { - if (!(json = json_object_new_object())) - { - zlog_err("Unable to allocate memory for JSON object"); - vty_out (vty, - "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s", - VTY_NEWLINE); - return; - } + json = json_object_new_object(); if (! is_first) vty_out (vty, ",%s", VTY_NEWLINE); @@ -10705,301 +6566,96 @@ bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, } -/* `show ip bgp summary' commands. */ -DEFUN (show_ip_bgp_summary, - show_ip_bgp_summary_cmd, - "show ip bgp summary {json}", - SHOW_STR - IP_STR - BGP_STR - "Summary of BGP neighbor status\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, uj); -} - -DEFUN (show_ip_bgp_instance_summary, - show_ip_bgp_instance_summary_cmd, - "show ip bgp " BGP_INSTANCE_CMD " summary {json}", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Summary of BGP neighbor status\n" - "JavaScript Object Notation\n") +static int +bgp_show_summary_vty (struct vty *vty, const char *name, + afi_t afi, safi_t safi, u_char use_json) { - u_char uj = use_json(argc, argv); - return bgp_show_summary_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, uj); -} + struct bgp *bgp; -DEFUN (show_ip_bgp_instance_all_summary, - show_ip_bgp_instance_all_summary_cmd, - "show ip bgp " BGP_INSTANCE_ALL_CMD " summary {json}", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_ALL_HELP_STR - "Summary of BGP neighbor status\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); + if (name) + { + if (strmatch(name, "all")) + { + bgp_show_all_instances_summary_vty (vty, afi, safi, use_json); + return CMD_SUCCESS; + } + else + { + bgp = bgp_lookup_by_name (name); - bgp_show_all_instances_summary_vty (vty, AFI_IP, SAFI_UNICAST, uj); - return CMD_SUCCESS; -} + if (! bgp) + { + if (use_json) + vty_out (vty, "{}%s", VTY_NEWLINE); + else + vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); + return CMD_WARNING; + } -DEFUN (show_ip_bgp_ipv4_summary, - show_ip_bgp_ipv4_summary_cmd, - "show ip bgp ipv4 (unicast|multicast) summary {json}", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Summary of BGP neighbor status\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, uj); + bgp_show_summary (vty, bgp, afi, safi, use_json, NULL); + return CMD_SUCCESS; + } + } - return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, uj); -} + bgp = bgp_get_default (); -ALIAS (show_ip_bgp_ipv4_summary, - show_bgp_ipv4_safi_summary_cmd, - "show bgp ipv4 (unicast|multicast) summary {json}", - SHOW_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Summary of BGP neighbor status\n") + if (bgp) + bgp_show_summary (vty, bgp, afi, safi, use_json, NULL); -DEFUN (show_bgp_ipv4_vpn_summary, - show_bgp_ipv4_vpn_summary_cmd, - "show bgp ipv4 vpn summary {json}", - SHOW_STR - BGP_STR - "IPv4\n" - "Display VPN NLRI specific information\n" - "Summary of BGP neighbor status\n" - JSON_STR) -{ - return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, use_json (argc, argv)); + return CMD_SUCCESS; } /* `show ip bgp summary' commands. */ -DEFUN (show_bgp_ipv6_vpn_summary, - show_bgp_ipv6_vpn_summary_cmd, - "show bgp ipv6 vpn summary {json}", - SHOW_STR - BGP_STR - "IPv6\n" - "Display VPN NLRI specific information\n" - "Summary of BGP neighbor status\n" - JSON_STR) -{ - return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MPLS_VPN, use_json (argc, argv)); -} - -DEFUN (show_ip_bgp_instance_ipv4_summary, - show_ip_bgp_instance_ipv4_summary_cmd, - "show ip bgp view WORD ipv4 (unicast|multicast) summary {json}", +DEFUN (show_ip_bgp_summary, + show_ip_bgp_summary_cmd, + "show [ip] bgp [<view|vrf> WORD] [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] summary [json]", SHOW_STR IP_STR BGP_STR - "BGP view\n" - "View name\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Summary of BGP neighbor status\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - if (strncmp (argv[1], "m", 1) == 0) - return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, uj); - else - return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, uj); -} - -ALIAS (show_ip_bgp_instance_ipv4_summary, - show_bgp_instance_ipv4_safi_summary_cmd, - "show bgp view WORD ipv4 (unicast|multicast) summary {json}", - SHOW_STR - BGP_STR - "BGP view\n" - "View name\n" - "Address family\n" + BGP_INSTANCE_HELP_STR + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" - "Summary of BGP neighbor status\n") - -DEFUN (show_ip_bgp_vpnv4_all_summary, - show_ip_bgp_vpnv4_all_summary_cmd, - "show ip bgp vpnv4 all summary {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information about all VPNv4 NLRIs\n" - "Summary of BGP neighbor status\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, uj); -} - -DEFUN (show_ip_bgp_vpnv4_rd_summary, - show_ip_bgp_vpnv4_rd_summary_cmd, - "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "Summary of BGP neighbor status\n" - "JavaScript Object Notation\n") -{ - int ret; - struct prefix_rd prd; - u_char uj = use_json(argc, argv); - - ret = str2prefix_rd (argv[0], &prd); - if (! ret) - { - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, uj); -} - -#ifdef HAVE_IPV6 -DEFUN (show_bgp_summary, - show_bgp_summary_cmd, - "show bgp summary {json}", - SHOW_STR - BGP_STR - "Summary of BGP neighbor status\n" - "JavaScript Object Notation\n") -{ - return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, use_json(argc, argv)); -} - -DEFUN (show_bgp_instance_summary, - show_bgp_instance_summary_cmd, - "show bgp " BGP_INSTANCE_CMD " summary {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Summary of BGP neighbor status\n" - "JavaScript Object Notation\n") -{ - return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, use_json(argc, argv)); -} - -DEFUN (show_bgp_instance_all_summary, - show_bgp_instance_all_summary_cmd, - "show bgp " BGP_INSTANCE_ALL_CMD " summary {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_ALL_HELP_STR - "Summary of BGP neighbor status\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - - bgp_show_all_instances_summary_vty (vty, AFI_IP6, SAFI_UNICAST, uj); - return CMD_SUCCESS; -} - -ALIAS (show_bgp_summary, - show_bgp_ipv6_summary_cmd, - "show bgp ipv6 summary {json}", - SHOW_STR - BGP_STR - "Address family\n" - "Summary of BGP neighbor status\n") - -ALIAS (show_bgp_instance_summary, - show_bgp_instance_ipv6_summary_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 summary {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Summary of BGP neighbor status\n") - -DEFUN (show_bgp_ipv6_safi_summary, - show_bgp_ipv6_safi_summary_cmd, - "show bgp ipv6 (unicast|multicast) summary {json}", - SHOW_STR - BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" - "Summary of BGP neighbor status\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, uj); - - return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, uj); -} - -DEFUN (show_bgp_instance_ipv6_safi_summary, - show_bgp_instance_ipv6_safi_summary_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 (unicast|multicast) summary {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" + "Address Family\n" "Address Family modifier\n" "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { - u_char uj = use_json(argc, argv); - if (strncmp (argv[2], "m", 1) == 0) - return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_MULTICAST, uj); - - return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, uj); -} - -/* old command */ -DEFUN (show_ipv6_bgp_summary, - show_ipv6_bgp_summary_cmd, - "show ipv6 bgp summary {json}", - SHOW_STR - IPV6_STR - BGP_STR - "Summary of BGP neighbor status\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, uj); -} + char *vrf = NULL; + afi_t afi = AFI_IP6; + safi_t safi = SAFI_UNICAST; + + int idx = 0; + + /* show [ip] bgp */ + if (argv_find (argv, argc, "ip", &idx)) + afi = AFI_IP; + /* [<view|vrf> WORD] */ + if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) + vrf = argv[++idx]->arg; + /* [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] */ + if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) + { + afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; + if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) + safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST; + } + else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) + { + afi = AFI_IP; + safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN; + // advance idx if necessary + argv_find (argv, argc, "unicast", &idx); + } + int uj = use_json (argc, argv); -/* old command */ -DEFUN (show_ipv6_mbgp_summary, - show_ipv6_mbgp_summary_cmd, - "show ipv6 mbgp summary {json}", - SHOW_STR - IPV6_STR - MBGP_STR - "Summary of BGP neighbor status\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, uj); + return bgp_show_summary_vty (vty, vrf, afi, safi, uj); } -#endif /* HAVE_IPV6 */ const char * afi_safi_print (afi_t afi, safi_t safi) @@ -11765,7 +7421,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as)) vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE); - + /* Status. */ vty_out (vty, " BGP state = %s", LOOKUP (bgp_status_msg, p->status)); @@ -11797,7 +7453,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js } } /* Capability. */ - if (p->status == Established) + if (p->status == Established) { if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] @@ -12016,7 +7672,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js } if (! restart_af_count) { - json_object_string_add(json_cap, "addressFamiliesByPeer", "none"); + json_object_string_add(json_cap, "addressFamiliesByPeer", "none"); json_object_free(json_restart); } else @@ -12140,7 +7796,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) { - vty_out (vty, " Address family %s:", afi_safi_print (afi, safi)); + vty_out (vty, " Address Family %s:", afi_safi_print (afi, safi)); if (p->afc_adv[afi][safi]) vty_out (vty, " advertised"); if (p->afc_recv[afi][safi]) @@ -12292,7 +7948,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js if (p->t_gr_restart) vty_out (vty, " The remaining time of restart timer is %ld%s", thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE); - + if (p->t_gr_stale) vty_out (vty, " The remaining time of stalepath timer is %ld%s", thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE); @@ -12543,7 +8199,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js ntohs (p->su_local->sin.sin_port), VTY_NEWLINE); } - + /* Remote address. */ if (p->su_remote) { @@ -12722,59 +8378,6 @@ bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type, return CMD_SUCCESS; } -static int -bgp_show_neighbor_vty (struct vty *vty, const char *name, - enum show_type type, const char *ip_str, u_char use_json, - json_object *json) -{ - int ret; - struct bgp *bgp; - union sockunion su; - - if (use_json && (json == NULL)) - json = json_object_new_object(); - - if (name) - { - bgp = bgp_lookup_by_name (name); - if (! bgp) - { - if (use_json) - { - json_object_boolean_true_add(json, "bgpNoSuchInstance"); - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); - json_object_free(json); - } - else - vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); - - return CMD_WARNING; - } - } - else - { - bgp = bgp_get_default (); - } - - if (bgp) - { - if (ip_str) - { - ret = str2sockunion (ip_str, &su); - if (ret < 0) - bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json); - else - bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json); - } - else - { - bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json); - } - } - - return CMD_SUCCESS; -} - static void bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json) { @@ -12829,249 +8432,110 @@ bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json) vty_out (vty, "}%s", VTY_NEWLINE); } -/* "show ip bgp neighbors" commands. */ -DEFUN (show_ip_bgp_neighbors, - show_ip_bgp_neighbors_cmd, - "show ip bgp neighbors {json}", - SHOW_STR - IP_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "JavaScript Object Notation\n") +static int +bgp_show_neighbor_vty (struct vty *vty, const char *name, + enum show_type type, const char *ip_str, u_char use_json) { - u_char uj = use_json(argc, argv); - - return bgp_show_neighbor_vty (vty, NULL, show_all, NULL, uj, NULL); -} - -ALIAS (show_ip_bgp_neighbors, - show_ip_bgp_ipv4_neighbors_cmd, - "show ip bgp ipv4 (unicast|multicast) neighbors {json}", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Detailed information on TCP and BGP neighbor connections\n" - "JavaScript Object Notation\n") - -ALIAS (show_ip_bgp_neighbors, - show_ip_bgp_vpnv4_all_neighbors_cmd, - "show ip bgp vpnv4 all neighbors {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information about all VPNv4 NLRIs\n" - "Detailed information on TCP and BGP neighbor connections\n" - "JavaScript Object Notation\n") + int ret; + struct bgp *bgp; + union sockunion su; + json_object *json = NULL; -ALIAS (show_ip_bgp_neighbors, - show_ip_bgp_vpnv4_rd_neighbors_cmd, - "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "Detailed information on TCP and BGP neighbor connections\n" - "JavaScript Object Notation\n") + if (use_json) + json = json_object_new_object(); -ALIAS (show_ip_bgp_neighbors, - show_bgp_neighbors_cmd, - "show bgp neighbors {json}", - SHOW_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "JavaScript Object Notation\n") + if (name) + { + if (strmatch(name, "all")) + { + bgp_show_all_instances_neighbors_vty (vty, use_json); + return CMD_SUCCESS; + } + else + { + bgp = bgp_lookup_by_name (name); + if (! bgp) + { + if (use_json) + { + json_object_boolean_true_add(json, "bgpNoSuchInstance"); + vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); + json_object_free(json); + } + else + vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); -ALIAS (show_ip_bgp_neighbors, - show_bgp_ipv6_neighbors_cmd, - "show bgp ipv6 neighbors {json}", - SHOW_STR - BGP_STR - "Address family\n" - "Detailed information on TCP and BGP neighbor connections\n" - "JavaScript Object Notation\n") + return CMD_WARNING; + } + } + } + else + { + bgp = bgp_get_default (); + } -DEFUN (show_ip_bgp_neighbors_peer, - show_ip_bgp_neighbors_peer_cmd, - "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) {json}", - SHOW_STR - IP_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); + if (bgp) + { + if (ip_str) + { + ret = str2sockunion (ip_str, &su); + if (ret < 0) + bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json); + else + bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json); + } + else + { + bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json); + } + } - return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 2], uj, NULL); + return CMD_SUCCESS; } -ALIAS (show_ip_bgp_neighbors_peer, - show_ip_bgp_ipv4_neighbors_peer_cmd, - "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) {json}", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "JavaScript Object Notation\n") - -ALIAS (show_ip_bgp_neighbors_peer, - show_ip_bgp_vpnv4_all_neighbors_peer_cmd, - "show ip bgp vpnv4 all neighbors A.B.C.D {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information about all VPNv4 NLRIs\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "JavaScript Object Notation\n") - -ALIAS (show_ip_bgp_neighbors_peer, - show_ip_bgp_vpnv4_rd_neighbors_peer_cmd, - "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D {json}", +/* "show ip bgp neighbors" commands. */ +DEFUN (show_ip_bgp_neighbors, + show_ip_bgp_neighbors_cmd, + "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", SHOW_STR IP_STR BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information about all VPNv4 NLRIs\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "JavaScript Object Notation\n") - -ALIAS (show_ip_bgp_neighbors_peer, - show_bgp_neighbors_peer_cmd, - "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) {json}", - SHOW_STR - BGP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "JavaScript Object Notation\n") - -ALIAS (show_ip_bgp_neighbors_peer, - show_bgp_ipv6_neighbors_peer_cmd, - "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) {json}", - SHOW_STR - BGP_STR - "Address family\n" + BGP_INSTANCE_ALL_HELP_STR + "Address Family\n" + "Address Family\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" "Neighbor on bgp configured interface\n" "JavaScript Object Notation\n") - -DEFUN (show_ip_bgp_instance_neighbors, - show_ip_bgp_instance_neighbors_cmd, - "show ip bgp " BGP_INSTANCE_CMD " neighbors {json}", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "JavaScript Object Notation\n") { - u_char uj = use_json(argc, argv); - - return bgp_show_neighbor_vty (vty, argv[1], show_all, NULL, uj, NULL); -} + char *vrf = NULL; + char *sh_arg = NULL; + enum show_type sh_type; -DEFUN (show_ip_bgp_instance_all_neighbors, - show_ip_bgp_instance_all_neighbors_cmd, - "show ip bgp " BGP_INSTANCE_ALL_CMD " neighbors {json}", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_ALL_HELP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "JavaScript Object Notation\n") -{ u_char uj = use_json(argc, argv); - bgp_show_all_instances_neighbors_vty (vty, uj); - return CMD_SUCCESS; -} + int idx = 0; -ALIAS (show_ip_bgp_instance_neighbors, - show_bgp_instance_neighbors_cmd, - "show bgp " BGP_INSTANCE_CMD " neighbors {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "JavaScript Object Notation\n") + if (argv_find (argv, argc, "WORD", &idx)) + vrf = argv[idx]->arg; -ALIAS (show_ip_bgp_instance_neighbors, - show_bgp_instance_ipv6_neighbors_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Detailed information on TCP and BGP neighbor connections\n" - "JavaScript Object Notation\n") - -DEFUN (show_ip_bgp_instance_neighbors_peer, - show_ip_bgp_instance_neighbors_peer_cmd, - "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) {json}", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); + if (argv_find (argv, argc, "A.B.C.D", &idx) || argv_find (argv, argc, "X:X::X:X", &idx) || + argv_find (argv, argc, "WORD", &idx)) + { + sh_type = show_peer; + sh_arg = argv[idx]->arg; + } + else + sh_type = show_all; - return bgp_show_neighbor_vty (vty, argv[1], show_peer, argv[2], uj, NULL); + return bgp_show_neighbor_vty (vty, vrf, sh_type, sh_arg, uj); } -ALIAS (show_ip_bgp_instance_neighbors_peer, - show_bgp_instance_neighbors_peer_cmd, - "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "JavaScript Object Notation\n") - -ALIAS (show_ip_bgp_instance_neighbors_peer, - show_bgp_instance_ipv6_neighbors_peer_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) {json}", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "JavaScript Object Notation\n") - /* Show BGP's AS paths internal data. There are both `show ip bgp paths' and `show ip mbgp paths'. Those functions results are the same.*/ -DEFUN (show_ip_bgp_paths, +DEFUN (show_ip_bgp_paths, show_ip_bgp_paths_cmd, "show ip bgp paths", SHOW_STR @@ -13084,13 +8548,13 @@ DEFUN (show_ip_bgp_paths, return CMD_SUCCESS; } -DEFUN (show_ip_bgp_ipv4_paths, +DEFUN (show_ip_bgp_ipv4_paths, show_ip_bgp_ipv4_paths_cmd, - "show ip bgp ipv4 (unicast|multicast) paths", + "show ip bgp ipv4 <unicast|multicast> paths", SHOW_STR IP_STR BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" "Path information\n") @@ -13114,9 +8578,9 @@ community_show_all_iterator (struct hash_backet *backet, struct vty *vty) } /* Show BGP's community internal data. */ -DEFUN (show_ip_bgp_community_info, +DEFUN (show_ip_bgp_community_info, show_ip_bgp_community_info_cmd, - "show ip bgp community-info", + "show [ip] bgp community-info", SHOW_STR IP_STR BGP_STR @@ -13124,7 +8588,7 @@ DEFUN (show_ip_bgp_community_info, { vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE); - hash_iterate (community_hash (), + hash_iterate (community_hash (), (void (*) (struct hash_backet *, void *)) community_show_all_iterator, vty); @@ -13132,9 +8596,9 @@ DEFUN (show_ip_bgp_community_info, return CMD_SUCCESS; } -DEFUN (show_ip_bgp_attr_info, +DEFUN (show_ip_bgp_attr_info, show_ip_bgp_attr_info_cmd, - "show ip bgp attribute-info", + "show [ip] bgp attribute-info", SHOW_STR IP_STR BGP_STR @@ -13144,22 +8608,6 @@ DEFUN (show_ip_bgp_attr_info, return CMD_SUCCESS; } -static int bgp_show_update_groups(struct vty *vty, const char *name, - int afi, int safi, - uint64_t subgrp_id) -{ - struct bgp *bgp; - - if (name) - bgp = bgp_lookup_by_name (name); - else - bgp = bgp_get_default (); - - if (bgp) - update_group_show(bgp, afi, safi, vty, subgrp_id); - return CMD_SUCCESS; -} - static void bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi) { @@ -13176,174 +8624,101 @@ bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi) } } -DEFUN (show_ip_bgp_updgrps, - show_ip_bgp_updgrps_cmd, - "show ip bgp update-groups", - SHOW_STR - IP_STR - BGP_STR - "Detailed info about dynamic update groups\n") +static int +bgp_show_update_groups(struct vty *vty, const char *name, + int afi, int safi, + uint64_t subgrp_id) { - return (bgp_show_update_groups(vty, NULL, AFI_IP, SAFI_UNICAST, 0)); -} + struct bgp *bgp; -DEFUN (show_ip_bgp_instance_updgrps, - show_ip_bgp_instance_updgrps_cmd, - "show ip bgp " BGP_INSTANCE_CMD " update-groups", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Detailed info about dynamic update groups\n") -{ - return (bgp_show_update_groups(vty, argv[1], AFI_IP, SAFI_UNICAST, 0)); -} + if (name) + { + if (strmatch (name, "all")) + { + bgp_show_all_instances_updgrps_vty (vty, afi, safi); + return CMD_SUCCESS; + } + else + { + bgp = bgp_lookup_by_name (name); + } + } + else + { + bgp = bgp_get_default (); + } -DEFUN (show_ip_bgp_instance_all_updgrps, - show_ip_bgp_instance_all_updgrps_cmd, - "show ip bgp " BGP_INSTANCE_ALL_CMD " update-groups", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_ALL_HELP_STR - "Detailed info about dynamic update groups\n") -{ - bgp_show_all_instances_updgrps_vty (vty, AFI_IP, SAFI_UNICAST); + if (bgp) + update_group_show(bgp, afi, safi, vty, subgrp_id); return CMD_SUCCESS; } -DEFUN (show_bgp_ipv6_updgrps, - show_bgp_ipv6_updgrps_cmd, - "show bgp update-groups", - SHOW_STR - BGP_STR - "Detailed info about v6 dynamic update groups\n") -{ - return (bgp_show_update_groups(vty, NULL, AFI_IP6, SAFI_UNICAST, 0)); -} - -DEFUN (show_bgp_instance_ipv6_updgrps, - show_bgp_instance_ipv6_updgrps_cmd, - "show bgp " BGP_INSTANCE_CMD " update-groups", +DEFUN (show_ip_bgp_updgrps, + show_ip_bgp_updgrps_cmd, + "show [ip] bgp [<view|vrf> WORD] [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] update-groups [SUBGROUP-ID]", SHOW_STR + IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "Detailed info about v6 dynamic update groups\n") -{ - return (bgp_show_update_groups(vty, argv[1], AFI_IP6, SAFI_UNICAST, 0)); -} - -DEFUN (show_bgp_instance_all_ipv6_updgrps, - show_bgp_instance_all_ipv6_updgrps_cmd, - "show bgp " BGP_INSTANCE_ALL_CMD " update-groups", - SHOW_STR - BGP_STR - BGP_INSTANCE_ALL_HELP_STR - "Detailed info about v6 dynamic update groups\n") -{ - bgp_show_all_instances_updgrps_vty (vty, AFI_IP6, SAFI_UNICAST); - return CMD_SUCCESS; -} - -DEFUN (show_bgp_updgrps, - show_bgp_updgrps_cmd, - "show bgp (ipv4|ipv6) (unicast|multicast) update-groups", - SHOW_STR - BGP_STR - "Address family\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" - "Detailed info about dynamic update groups\n") -{ - afi_t afi; - safi_t safi; - - afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; - safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; - return (bgp_show_update_groups(vty, NULL, afi, safi, 0)); -} - -DEFUN (show_ip_bgp_updgrps_s, - show_ip_bgp_updgrps_s_cmd, - "show ip bgp update-groups SUBGROUP-ID", - SHOW_STR - IP_STR - BGP_STR - "Detailed info about dynamic update groups\n" - "Specific subgroup to display detailed info for\n") -{ - uint64_t subgrp_id; - - VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]); - return (bgp_show_update_groups(vty, NULL, AFI_IP, SAFI_UNICAST, subgrp_id)); -} - -DEFUN (show_ip_bgp_instance_updgrps_s, - show_ip_bgp_instance_updgrps_s_cmd, - "show ip bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR + "Address Family\n" + "Address Family modifier\n" + "Address Family modifier\n" + "Address Family\n" + "Address Family modifier\n" + "Address Family\n" + "Address Family modifier\n" "Detailed info about dynamic update groups\n" "Specific subgroup to display detailed info for\n") { - uint64_t subgrp_id; - - VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); - return (bgp_show_update_groups(vty, argv[1], AFI_IP, SAFI_UNICAST, subgrp_id)); -} - -DEFUN (show_bgp_ipv6_updgrps_s, - show_bgp_ipv6_updgrps_s_cmd, - "show bgp update-groups SUBGROUP-ID", - SHOW_STR - BGP_STR - "Detailed info about v6 dynamic update groups\n" - "Specific subgroup to display detailed info for\n") -{ - uint64_t subgrp_id; - - VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]); - return(bgp_show_update_groups(vty, NULL, AFI_IP6, SAFI_UNICAST, subgrp_id)); -} + char *vrf = NULL; + afi_t afi = AFI_IP6; + safi_t safi = SAFI_UNICAST; + uint64_t subgrp_id = 0; + + int idx = 0; + + /* show [ip] bgp */ + if (argv_find (argv, argc, "ip", &idx)) + afi = AFI_IP; + /* [<view|vrf> WORD] */ + if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) + vrf = argv[++idx]->arg; + /* [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] */ + if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) + { + afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; + if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) + safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST; + } + else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) + { + afi = AFI_IP; + safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN; + // advance idx if necessary + argv_find (argv, argc, "unicast", &idx); + } -DEFUN (show_bgp_instance_ipv6_updgrps_s, - show_bgp_instance_ipv6_updgrps_s_cmd, - "show bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID", - SHOW_STR - BGP_STR - "Detailed info about v6 dynamic update groups\n" - "Specific subgroup to display detailed info for\n") -{ - uint64_t subgrp_id; + /* get subgroup id, if provided */ + idx = argc - 1; + if (argv[idx]->type == VARIABLE_TKN) + VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx]->arg); - VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); - return(bgp_show_update_groups(vty, argv[1], AFI_IP6, SAFI_UNICAST, subgrp_id)); + return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); } -DEFUN (show_bgp_updgrps_s, - show_bgp_updgrps_s_cmd, - "show bgp (ipv4|ipv6) (unicast|multicast) update-groups SUBGROUP-ID", +DEFUN (show_bgp_instance_all_ipv6_updgrps, + show_bgp_instance_all_ipv6_updgrps_cmd, + "show bgp <view|vrf> all update-groups", SHOW_STR BGP_STR - "Address family\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Detailed info about v6 dynamic update groups\n" - "Specific subgroup to display detailed info for") + BGP_INSTANCE_ALL_HELP_STR + "Detailed info about dynamic update groups\n") { - afi_t afi; - safi_t safi; - uint64_t subgrp_id; - - afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; - safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; - - VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); - return(bgp_show_update_groups(vty, NULL, afi, safi, subgrp_id)); + bgp_show_all_instances_updgrps_vty (vty, AFI_IP6, SAFI_UNICAST); + return CMD_SUCCESS; } DEFUN (show_bgp_updgrps_stats, @@ -13351,7 +8726,7 @@ DEFUN (show_bgp_updgrps_stats, "show bgp update-groups statistics", SHOW_STR BGP_STR - "BGP update groups\n" + "Detailed info about dynamic update groups\n" "Statistics\n") { struct bgp *bgp; @@ -13365,16 +8740,17 @@ DEFUN (show_bgp_updgrps_stats, DEFUN (show_bgp_instance_updgrps_stats, show_bgp_instance_updgrps_stats_cmd, - "show bgp " BGP_INSTANCE_CMD " update-groups statistics", + "show bgp <view|vrf> WORD update-groups statistics", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR - "BGP update groups\n" + "Detailed info about dynamic update groups\n" "Statistics\n") { + int idx_word = 3; struct bgp *bgp; - bgp = bgp_lookup_by_name (argv[1]); + bgp = bgp_lookup_by_name (argv[idx_word]->arg); if (bgp) update_group_show_stats(bgp, vty); @@ -13406,197 +8782,220 @@ show_bgp_updgrps_adj_info_aux (struct vty *vty, const char *name, DEFUN (show_ip_bgp_updgrps_adj, show_ip_bgp_updgrps_adj_cmd, - "show ip bgp update-groups (advertise-queue|advertised-routes|packet-queue)", + "show ip bgp update-groups <advertise-queue|advertised-routes|packet-queue>", SHOW_STR IP_STR BGP_STR - "BGP update groups\n" + "Detailed info about dynamic update groups\n" "Advertisement queue\n" "Announced routes\n" "Packet queue\n") { - show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[0], 0); + int idx_type = 4; + show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); return CMD_SUCCESS; } DEFUN (show_ip_bgp_instance_updgrps_adj, show_ip_bgp_instance_updgrps_adj_cmd, - "show ip bgp " BGP_INSTANCE_CMD " update-groups (advertise-queue|advertised-routes|packet-queue)", + "show ip bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "BGP update groups\n" + "Detailed info about dynamic update groups\n" "Advertisement queue\n" "Announced routes\n" "Packet queue\n") { - show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP, SAFI_UNICAST, argv[2], 0); + int idx_word = 4; + int idx_type = 6; + show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); return CMD_SUCCESS; } DEFUN (show_bgp_updgrps_afi_adj, show_bgp_updgrps_afi_adj_cmd, - "show bgp (ipv4|ipv6) (unicast|multicast) update-groups (advertise-queue|advertised-routes|packet-queue)", + "show bgp <ipv4|ipv6> <unicast|multicast> update-groups <advertise-queue|advertised-routes|packet-queue>", SHOW_STR BGP_STR - "Address family\n" - "Address family\n" + "Address Family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" - "BGP update groups\n" + "Detailed info about dynamic update groups\n" "Advertisement queue\n" "Announced routes\n" "Packet queue\n" "Specific subgroup info wanted for\n") { + int idx_afi = 2; + int idx_safi = 3; + int idx_type = 5; afi_t afi; safi_t safi; - afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; - safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; - show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[2], 0); + afi = (strcmp(argv[idx_afi]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6; + safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; + show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[idx_type]->arg, 0); return CMD_SUCCESS; } DEFUN (show_bgp_updgrps_adj, show_bgp_updgrps_adj_cmd, - "show bgp update-groups (advertise-queue|advertised-routes|packet-queue)", + "show bgp update-groups <advertise-queue|advertised-routes|packet-queue>", SHOW_STR BGP_STR - "BGP update groups\n" + "Detailed info about dynamic update groups\n" "Advertisement queue\n" "Announced routes\n" "Packet queue\n") { - show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[0], 0); + int idx_type = 3; + show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); return CMD_SUCCESS; } DEFUN (show_bgp_instance_updgrps_adj, show_bgp_instance_updgrps_adj_cmd, - "show bgp " BGP_INSTANCE_CMD " update-groups (advertise-queue|advertised-routes|packet-queue)", + "show bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR - "BGP update groups\n" + "Detailed info about dynamic update groups\n" "Advertisement queue\n" "Announced routes\n" "Packet queue\n") { - show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP6, SAFI_UNICAST, argv[2], 0); + int idx_word = 3; + int idx_type = 5; + show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); return CMD_SUCCESS; } DEFUN (show_ip_bgp_updgrps_adj_s, show_ip_bgp_updgrps_adj_s_cmd, - "show ip bgp update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)", + "show ip bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", SHOW_STR IP_STR BGP_STR - "BGP update groups\n" + "Detailed info about dynamic update groups\n" "Specific subgroup to display info for\n" "Advertisement queue\n" "Announced routes\n" "Packet queue\n") { + int idx_subgroup_id = 4; + int idx_type = 5; uint64_t subgrp_id; - VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]); + VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); - show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[1], subgrp_id); + show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); return CMD_SUCCESS; } DEFUN (show_ip_bgp_instance_updgrps_adj_s, show_ip_bgp_instance_updgrps_adj_s_cmd, - "show ip bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)", + "show ip bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "BGP update groups\n" + "Detailed info about dynamic update groups\n" "Specific subgroup to display info for\n" "Advertisement queue\n" "Announced routes\n" "Packet queue\n") { + int idx_vrf = 4; + int idx_subgroup_id = 6; + int idx_type = 7; uint64_t subgrp_id; - VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); + VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); - show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP, SAFI_UNICAST, argv[3], subgrp_id); + show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); return CMD_SUCCESS; } DEFUN (show_bgp_updgrps_afi_adj_s, show_bgp_updgrps_afi_adj_s_cmd, - "show bgp (ipv4|ipv6) (unicast|multicast) update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)", + "show bgp <ipv4|ipv6> <unicast|multicast> update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", SHOW_STR BGP_STR - "Address family\n" - "Address family\n" + "Address Family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" - "BGP update groups\n" + "Detailed info about dynamic update groups\n" "Specific subgroup to display info for\n" "Advertisement queue\n" "Announced routes\n" "Packet queue\n" "Specific subgroup info wanted for\n") { + int idx_afi = 2; + int idx_safi = 3; + int idx_subgroup_id = 5; + int idx_type = 6; afi_t afi; safi_t safi; uint64_t subgrp_id; - afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; - safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; - VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); + afi = (strmatch(argv[idx_afi]->text, "ipv4")) ? AFI_IP : AFI_IP6; + safi = (strmatch(argv[idx_safi]->text, "unicast")) ? SAFI_UNICAST : SAFI_MULTICAST; + VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); - show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[3], subgrp_id); + show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[idx_type]->arg, subgrp_id); return CMD_SUCCESS; } DEFUN (show_bgp_updgrps_adj_s, show_bgp_updgrps_adj_s_cmd, - "show bgp update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)", + "show bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", SHOW_STR BGP_STR - "BGP update groups\n" + "Detailed info about dynamic update groups\n" "Specific subgroup to display info for\n" "Advertisement queue\n" "Announced routes\n" "Packet queue\n") { + int idx_subgroup_id = 3; + int idx_type = 4; uint64_t subgrp_id; - VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]); + VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); - show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[1], subgrp_id); + show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); return CMD_SUCCESS; } DEFUN (show_bgp_instance_updgrps_adj_s, show_bgp_instance_updgrps_adj_s_cmd, - "show bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)", + "show bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR - "BGP update groups\n" + "Detailed info about dynamic update groups\n" "Specific subgroup to display info for\n" "Advertisement queue\n" "Announced routes\n" "Packet queue\n") { + int idx_vrf = 3; + int idx_subgroup_id = 5; + int idx_type = 6; uint64_t subgrp_id; - VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); + VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); - show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP6, SAFI_UNICAST, argv[3], subgrp_id); + show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); return CMD_SUCCESS; } @@ -13763,63 +9162,37 @@ bgp_show_peer_group_vty (struct vty *vty, const char *name, DEFUN (show_ip_bgp_peer_groups, show_ip_bgp_peer_groups_cmd, - "show ip bgp peer-group", - SHOW_STR - IP_STR - BGP_STR - "Detailed information on all BGP peer groups\n") -{ - return bgp_show_peer_group_vty (vty, NULL, show_all_groups, NULL); -} - -DEFUN (show_ip_bgp_instance_peer_groups, - show_ip_bgp_instance_peer_groups_cmd, - "show ip bgp " BGP_INSTANCE_CMD " peer-group", + "show [ip] bgp [<view|vrf> VRFNAME] peer-group [PGNAME]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "Detailed information on all BGP peer groups\n") + "Detailed information on BGP peer groups\n" + "Peer group name\n") { - return bgp_show_peer_group_vty (vty, argv[1], show_all_groups, NULL); -} + char *vrf, *pg; + vrf = pg = NULL; + int idx = 0; -DEFUN (show_ip_bgp_peer_group, - show_ip_bgp_peer_group_cmd, - "show ip bgp peer-group WORD", - SHOW_STR - IP_STR - BGP_STR - "BGP peer-group name\n" - "Detailed information on a BGP peer group\n") -{ - return bgp_show_peer_group_vty (vty, NULL, show_peer_group, argv[0]); -} + vrf = argv_find (argv, argc, "VRFNAME", &idx) ? argv[idx]->arg : NULL; + pg = argv_find (argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; -DEFUN (show_ip_bgp_instance_peer_group, - show_ip_bgp_instance_peer_group_cmd, - "show ip bgp " BGP_INSTANCE_CMD " peer-group WORD", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "BGP peer-group name\n" - "Detailed information on a BGP peer group\n") -{ - return bgp_show_peer_group_vty (vty, argv[1], show_peer_group, argv[2]); + return bgp_show_peer_group_vty (vty, vrf, show_all_groups, pg); } + /* Redistribute VTY commands. */ DEFUN (bgp_redistribute_ipv4, bgp_redistribute_ipv4_cmd, - "redistribute " QUAGGA_IP_REDIST_STR_BGPD, + "redistribute <kernel|connected|static|rip|ospf|isis|pim|table>", "Redistribute information from another routing protocol\n" QUAGGA_IP_REDIST_HELP_STR_BGPD) { + int idx_protocol = 1; int type; - type = proto_redistnum (AFI_IP, argv[0]); + type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); @@ -13831,16 +9204,18 @@ DEFUN (bgp_redistribute_ipv4, DEFUN (bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_cmd, - "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD", + "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> route-map WORD", "Redistribute information from another routing protocol\n" QUAGGA_IP_REDIST_HELP_STR_BGPD "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_word = 3; int type; struct bgp_redist *red; - type = proto_redistnum (AFI_IP, argv[0]); + type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); @@ -13848,29 +9223,31 @@ DEFUN (bgp_redistribute_ipv4_rmap, } red = bgp_redist_add(vty->index, AFI_IP, type, 0); - bgp_redistribute_rmap_set (red, argv[1]); + bgp_redistribute_rmap_set (red, argv[idx_word]->arg); return bgp_redistribute_set (vty->index, AFI_IP, type, 0); } DEFUN (bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_cmd, - "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>", + "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> metric (0-4294967295)", "Redistribute information from another routing protocol\n" QUAGGA_IP_REDIST_HELP_STR_BGPD "Metric for redistributed routes\n" "Default metric\n") { + int idx_protocol = 1; + int idx_number = 3; int type; u_int32_t metric; struct bgp_redist *red; - type = proto_redistnum (AFI_IP, argv[0]); + type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; } - VTY_GET_INTEGER ("metric", metric, argv[1]); + VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); red = bgp_redist_add(vty->index, AFI_IP, type, 0); bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric); @@ -13879,7 +9256,7 @@ DEFUN (bgp_redistribute_ipv4_metric, DEFUN (bgp_redistribute_ipv4_rmap_metric, bgp_redistribute_ipv4_rmap_metric_cmd, - "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>", + "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> route-map WORD metric (0-4294967295)", "Redistribute information from another routing protocol\n" QUAGGA_IP_REDIST_HELP_STR_BGPD "Route map reference\n" @@ -13887,27 +9264,30 @@ DEFUN (bgp_redistribute_ipv4_rmap_metric, "Metric for redistributed routes\n" "Default metric\n") { + int idx_protocol = 1; + int idx_word = 3; + int idx_number = 5; int type; u_int32_t metric; struct bgp_redist *red; - type = proto_redistnum (AFI_IP, argv[0]); + type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; } - VTY_GET_INTEGER ("metric", metric, argv[2]); + VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); red = bgp_redist_add(vty->index, AFI_IP, type, 0); - bgp_redistribute_rmap_set (red, argv[1]); + bgp_redistribute_rmap_set (red, argv[idx_word]->arg); bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric); return bgp_redistribute_set (vty->index, AFI_IP, type, 0); } DEFUN (bgp_redistribute_ipv4_metric_rmap, bgp_redistribute_ipv4_metric_rmap_cmd, - "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD", + "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> metric (0-4294967295) route-map WORD", "Redistribute information from another routing protocol\n" QUAGGA_IP_REDIST_HELP_STR_BGPD "Metric for redistributed routes\n" @@ -13915,38 +9295,43 @@ DEFUN (bgp_redistribute_ipv4_metric_rmap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_number = 3; + int idx_word = 5; int type; u_int32_t metric; struct bgp_redist *red; - type = proto_redistnum (AFI_IP, argv[0]); + type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; } - VTY_GET_INTEGER ("metric", metric, argv[1]); + VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); red = bgp_redist_add(vty->index, AFI_IP, type, 0); bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric); - bgp_redistribute_rmap_set (red, argv[2]); + bgp_redistribute_rmap_set (red, argv[idx_word]->arg); return bgp_redistribute_set (vty->index, AFI_IP, type, 0); } DEFUN (bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_cmd, - "redistribute (ospf|table) <1-65535>", + "redistribute <ospf|table> (1-65535)", "Redistribute information from another routing protocol\n" "Open Shortest Path First (OSPFv2)\n" "Non-main Kernel Routing Table\n" "Instance ID/Table ID\n") { + int idx_ospf_table = 1; + int idx_number = 2; u_short instance; u_short protocol; - VTY_GET_INTEGER ("Instance ID", instance, argv[1]); + VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); - if (strncmp(argv[0], "o", 1) == 0) + if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) protocol = ZEBRA_ROUTE_OSPF; else protocol = ZEBRA_ROUTE_TABLE; @@ -13957,7 +9342,7 @@ DEFUN (bgp_redistribute_ipv4_ospf, DEFUN (bgp_redistribute_ipv4_ospf_rmap, bgp_redistribute_ipv4_ospf_rmap_cmd, - "redistribute (ospf|table) <1-65535> route-map WORD", + "redistribute <ospf|table> (1-65535) route-map WORD", "Redistribute information from another routing protocol\n" "Open Shortest Path First (OSPFv2)\n" "Non-main Kernel Routing Table\n" @@ -13965,24 +9350,27 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_ospf_table = 1; + int idx_number = 2; + int idx_word = 4; struct bgp_redist *red; u_short instance; int protocol; - if (strncmp(argv[0], "o", 1) == 0) + if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) protocol = ZEBRA_ROUTE_OSPF; else protocol = ZEBRA_ROUTE_TABLE; - VTY_GET_INTEGER ("Instance ID", instance, argv[1]); + VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); red = bgp_redist_add(vty->index, AFI_IP, protocol, instance); - bgp_redistribute_rmap_set (red, argv[2]); + bgp_redistribute_rmap_set (red, argv[idx_word]->arg); return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance); } DEFUN (bgp_redistribute_ipv4_ospf_metric, bgp_redistribute_ipv4_ospf_metric_cmd, - "redistribute (ospf|table) <1-65535> metric <0-4294967295>", + "redistribute <ospf|table> (1-65535) metric (0-4294967295)", "Redistribute information from another routing protocol\n" "Open Shortest Path First (OSPFv2)\n" "Non-main Kernel Routing Table\n" @@ -13990,18 +9378,21 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric, "Metric for redistributed routes\n" "Default metric\n") { + int idx_ospf_table = 1; + int idx_number = 2; + int idx_number_2 = 4; u_int32_t metric; struct bgp_redist *red; u_short instance; int protocol; - if (strncmp(argv[0], "o", 1) == 0) + if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) protocol = ZEBRA_ROUTE_OSPF; else protocol = ZEBRA_ROUTE_TABLE; - VTY_GET_INTEGER ("Instance ID", instance, argv[1]); - VTY_GET_INTEGER ("metric", metric, argv[2]); + VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); + VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); red = bgp_redist_add(vty->index, AFI_IP, protocol, instance); bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric); @@ -14010,7 +9401,7 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric, DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, bgp_redistribute_ipv4_ospf_rmap_metric_cmd, - "redistribute (ospf|table) <1-65535> route-map WORD metric <0-4294967295>", + "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", "Redistribute information from another routing protocol\n" "Open Shortest Path First (OSPFv2)\n" "Non-main Kernel Routing Table\n" @@ -14020,28 +9411,32 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, "Metric for redistributed routes\n" "Default metric\n") { + int idx_ospf_table = 1; + int idx_number = 2; + int idx_word = 4; + int idx_number_2 = 6; u_int32_t metric; struct bgp_redist *red; u_short instance; int protocol; - if (strncmp(argv[0], "o", 1) == 0) + if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) protocol = ZEBRA_ROUTE_OSPF; else protocol = ZEBRA_ROUTE_TABLE; - VTY_GET_INTEGER ("Instance ID", instance, argv[1]); - VTY_GET_INTEGER ("metric", metric, argv[3]); + VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); + VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); red = bgp_redist_add(vty->index, AFI_IP, protocol, instance); - bgp_redistribute_rmap_set (red, argv[2]); + bgp_redistribute_rmap_set (red, argv[idx_word]->arg); bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric); return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance); } DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, bgp_redistribute_ipv4_ospf_metric_rmap_cmd, - "redistribute (ospf|table) <1-65535> metric <0-4294967295> route-map WORD", + "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", "Redistribute information from another routing protocol\n" "Open Shortest Path First (OSPFv2)\n" "Non-main Kernel Routing Table\n" @@ -14051,104 +9446,71 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_ospf_table = 1; + int idx_number = 2; + int idx_number_2 = 4; + int idx_word = 6; u_int32_t metric; struct bgp_redist *red; u_short instance; int protocol; - if (strncmp(argv[0], "o", 1) == 0) + if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) protocol = ZEBRA_ROUTE_OSPF; else protocol = ZEBRA_ROUTE_TABLE; - VTY_GET_INTEGER ("Instance ID", instance, argv[1]); - VTY_GET_INTEGER ("metric", metric, argv[2]); + VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); + VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); red = bgp_redist_add(vty->index, AFI_IP, protocol, instance); bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric); - bgp_redistribute_rmap_set (red, argv[3]); + bgp_redistribute_rmap_set (red, argv[idx_word]->arg); return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance); } DEFUN (no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_cmd, - "no redistribute (ospf|table) <1-65535>", + "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", NO_STR "Redistribute information from another routing protocol\n" "Open Shortest Path First (OSPFv2)\n" "Non-main Kernel Routing Table\n" - "Instance ID/Table ID\n") + "Instance ID/Table ID\n" + "Metric for redistributed routes\n" + "Default metric\n" + "Route map reference\n" + "Pointer to route-map entries\n") { + int idx_ospf_table = 2; + int idx_number = 3; u_short instance; int protocol; - if (strncmp(argv[0], "o", 1) == 0) + if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) protocol = ZEBRA_ROUTE_OSPF; else protocol = ZEBRA_ROUTE_TABLE; - VTY_GET_INTEGER ("Instance ID", instance, argv[1]); + VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); return bgp_redistribute_unset (vty->index, AFI_IP, protocol, instance); } -ALIAS (no_bgp_redistribute_ipv4_ospf, - no_bgp_redistribute_ipv4_ospf_rmap_cmd, - "no redistribute (ospf|table) <1-65535> route-map WORD", - NO_STR - "Redistribute information from another routing protocol\n" - "Open Shortest Path First (OSPFv2)\n" - "Non-main Kernel Routing Table\n" - "Instance ID/Table ID\n" - "Route map reference\n" - "Pointer to route-map entries\n") - -ALIAS (no_bgp_redistribute_ipv4_ospf, - no_bgp_redistribute_ipv4_ospf_metric_cmd, - "no redistribute (ospf|table) <1-65535> metric <0-4294967295>", - NO_STR - "Redistribute information from another routing protocol\n" - "Open Shortest Path First (OSPFv2)\n" - "Non-main Kernel Routing Table\n" - "Instance ID/Table ID\n" - "Metric for redistributed routes\n" - "Default metric\n") - -ALIAS (no_bgp_redistribute_ipv4_ospf, - no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd, - "no redistribute (ospf|table) <1-65535> route-map WORD metric <0-4294967295>", - NO_STR - "Redistribute information from another routing protocol\n" - "Open Shortest Path First (OSPFv2)\n" - "Non-main Kernel Routing Table\n" - "Instance ID/Table ID\n" - "Route map reference\n" - "Pointer to route-map entries\n" - "Metric for redistributed routes\n" - "Default metric\n") - -ALIAS (no_bgp_redistribute_ipv4_ospf, - no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd, - "no redistribute (ospf|table) <1-65535> metric <0-4294967295> route-map WORD", +DEFUN (no_bgp_redistribute_ipv4, + no_bgp_redistribute_ipv4_cmd, + "no redistribute <kernel|connected|static|rip|ospf|isis|pim|table> [metric (0-4294967295)] [route-map WORD]", NO_STR "Redistribute information from another routing protocol\n" - "Open Shortest Path First (OSPFv2)\n" - "Non-main Kernel Routing Table\n" - "Instance ID/Table ID\n" + QUAGGA_IP_REDIST_HELP_STR_BGPD "Metric for redistributed routes\n" "Default metric\n" "Route map reference\n" "Pointer to route-map entries\n") - -DEFUN (no_bgp_redistribute_ipv4, - no_bgp_redistribute_ipv4_cmd, - "no redistribute " QUAGGA_IP_REDIST_STR_BGPD, - NO_STR - "Redistribute information from another routing protocol\n" - QUAGGA_IP_REDIST_HELP_STR_BGPD) { + int idx_protocol = 2; int type; - type = proto_redistnum (AFI_IP, argv[0]); + type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); @@ -14157,56 +9519,17 @@ DEFUN (no_bgp_redistribute_ipv4, return bgp_redistribute_unset (vty->index, AFI_IP, type, 0); } -ALIAS (no_bgp_redistribute_ipv4, - no_bgp_redistribute_ipv4_rmap_cmd, - "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD", - NO_STR - "Redistribute information from another routing protocol\n" - QUAGGA_IP_REDIST_HELP_STR_BGPD - "Route map reference\n" - "Pointer to route-map entries\n") - -ALIAS (no_bgp_redistribute_ipv4, - no_bgp_redistribute_ipv4_metric_cmd, - "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>", - NO_STR - "Redistribute information from another routing protocol\n" - QUAGGA_IP_REDIST_HELP_STR_BGPD - "Metric for redistributed routes\n" - "Default metric\n") - -ALIAS (no_bgp_redistribute_ipv4, - no_bgp_redistribute_ipv4_rmap_metric_cmd, - "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>", - NO_STR - "Redistribute information from another routing protocol\n" - QUAGGA_IP_REDIST_HELP_STR_BGPD - "Route map reference\n" - "Pointer to route-map entries\n" - "Metric for redistributed routes\n" - "Default metric\n") - -ALIAS (no_bgp_redistribute_ipv4, - no_bgp_redistribute_ipv4_metric_rmap_cmd, - "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD", - NO_STR - "Redistribute information from another routing protocol\n" - QUAGGA_IP_REDIST_HELP_STR_BGPD - "Metric for redistributed routes\n" - "Default metric\n" - "Route map reference\n" - "Pointer to route-map entries\n") - #ifdef HAVE_IPV6 DEFUN (bgp_redistribute_ipv6, bgp_redistribute_ipv6_cmd, - "redistribute " QUAGGA_IP6_REDIST_STR_BGPD, + "redistribute <kernel|connected|static|ripng|ospf6|isis|table>", "Redistribute information from another routing protocol\n" QUAGGA_IP6_REDIST_HELP_STR_BGPD) { + int idx_protocol = 1; int type; - type = proto_redistnum (AFI_IP6, argv[0]); + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); @@ -14219,16 +9542,18 @@ DEFUN (bgp_redistribute_ipv6, DEFUN (bgp_redistribute_ipv6_rmap, bgp_redistribute_ipv6_rmap_cmd, - "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD", + "redistribute <kernel|connected|static|ripng|ospf6|isis|table> route-map WORD", "Redistribute information from another routing protocol\n" QUAGGA_IP6_REDIST_HELP_STR_BGPD "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_word = 3; int type; struct bgp_redist *red; - type = proto_redistnum (AFI_IP6, argv[0]); + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); @@ -14236,29 +9561,31 @@ DEFUN (bgp_redistribute_ipv6_rmap, } red = bgp_redist_add(vty->index, AFI_IP6, type, 0); - bgp_redistribute_rmap_set (red, argv[1]); + bgp_redistribute_rmap_set (red, argv[idx_word]->arg); return bgp_redistribute_set (vty->index, AFI_IP6, type, 0); } DEFUN (bgp_redistribute_ipv6_metric, bgp_redistribute_ipv6_metric_cmd, - "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>", + "redistribute <kernel|connected|static|ripng|ospf6|isis|table> metric (0-4294967295)", "Redistribute information from another routing protocol\n" QUAGGA_IP6_REDIST_HELP_STR_BGPD "Metric for redistributed routes\n" "Default metric\n") { + int idx_protocol = 1; + int idx_number = 3; int type; u_int32_t metric; struct bgp_redist *red; - type = proto_redistnum (AFI_IP6, argv[0]); + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; } - VTY_GET_INTEGER ("metric", metric, argv[1]); + VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); red = bgp_redist_add(vty->index, AFI_IP6, type, 0); bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric); @@ -14267,7 +9594,7 @@ DEFUN (bgp_redistribute_ipv6_metric, DEFUN (bgp_redistribute_ipv6_rmap_metric, bgp_redistribute_ipv6_rmap_metric_cmd, - "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>", + "redistribute <kernel|connected|static|ripng|ospf6|isis|table> route-map WORD metric (0-4294967295)", "Redistribute information from another routing protocol\n" QUAGGA_IP6_REDIST_HELP_STR_BGPD "Route map reference\n" @@ -14275,27 +9602,30 @@ DEFUN (bgp_redistribute_ipv6_rmap_metric, "Metric for redistributed routes\n" "Default metric\n") { + int idx_protocol = 1; + int idx_word = 3; + int idx_number = 5; int type; u_int32_t metric; struct bgp_redist *red; - type = proto_redistnum (AFI_IP6, argv[0]); + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; } - VTY_GET_INTEGER ("metric", metric, argv[2]); + VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); red = bgp_redist_add(vty->index, AFI_IP6, type, 0); - bgp_redistribute_rmap_set (red, argv[1]); + bgp_redistribute_rmap_set (red, argv[idx_word]->arg); bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric); return bgp_redistribute_set (vty->index, AFI_IP6, type, 0); } DEFUN (bgp_redistribute_ipv6_metric_rmap, bgp_redistribute_ipv6_metric_rmap_cmd, - "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD", + "redistribute <kernel|connected|static|ripng|ospf6|isis|table> metric (0-4294967295) route-map WORD", "Redistribute information from another routing protocol\n" QUAGGA_IP6_REDIST_HELP_STR_BGPD "Metric for redistributed routes\n" @@ -14303,34 +9633,42 @@ DEFUN (bgp_redistribute_ipv6_metric_rmap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_number = 3; + int idx_word = 5; int type; u_int32_t metric; struct bgp_redist *red; - type = proto_redistnum (AFI_IP6, argv[0]); + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; } - VTY_GET_INTEGER ("metric", metric, argv[1]); + VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); red = bgp_redist_add(vty->index, AFI_IP6, type, 0); bgp_redistribute_metric_set(vty->index, red, AFI_IP6, SAFI_UNICAST, metric); - bgp_redistribute_rmap_set (red, argv[2]); + bgp_redistribute_rmap_set (red, argv[idx_word]->arg); return bgp_redistribute_set (vty->index, AFI_IP6, type, 0); } DEFUN (no_bgp_redistribute_ipv6, no_bgp_redistribute_ipv6_cmd, - "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD, + "no redistribute <kernel|connected|static|ripng|ospf6|isis|table> [metric (0-4294967295)] [route-map WORD]", NO_STR "Redistribute information from another routing protocol\n" - QUAGGA_IP6_REDIST_HELP_STR_BGPD) + QUAGGA_IP6_REDIST_HELP_STR_BGPD + "Metric for redistributed routes\n" + "Default metric\n" + "Route map reference\n" + "Pointer to route-map entries\n") { + int idx_protocol = 2; int type; - type = proto_redistnum (AFI_IP6, argv[0]); + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); @@ -14340,45 +9678,9 @@ DEFUN (no_bgp_redistribute_ipv6, return bgp_redistribute_unset (vty->index, AFI_IP6, type, 0); } -ALIAS (no_bgp_redistribute_ipv6, - no_bgp_redistribute_ipv6_rmap_cmd, - "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD", - NO_STR - "Redistribute information from another routing protocol\n" - QUAGGA_IP6_REDIST_HELP_STR_BGPD - "Route map reference\n" - "Pointer to route-map entries\n") -ALIAS (no_bgp_redistribute_ipv6, - no_bgp_redistribute_ipv6_metric_cmd, - "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>", - NO_STR - "Redistribute information from another routing protocol\n" - QUAGGA_IP6_REDIST_HELP_STR_BGPD - "Metric for redistributed routes\n" - "Default metric\n") -ALIAS (no_bgp_redistribute_ipv6, - no_bgp_redistribute_ipv6_rmap_metric_cmd, - "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>", - NO_STR - "Redistribute information from another routing protocol\n" - QUAGGA_IP6_REDIST_HELP_STR_BGPD - "Route map reference\n" - "Pointer to route-map entries\n" - "Metric for redistributed routes\n" - "Default metric\n") -ALIAS (no_bgp_redistribute_ipv6, - no_bgp_redistribute_ipv6_metric_rmap_cmd, - "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD", - NO_STR - "Redistribute information from another routing protocol\n" - QUAGGA_IP6_REDIST_HELP_STR_BGPD - "Metric for redistributed routes\n" - "Default metric\n" - "Route map reference\n" - "Pointer to route-map entries\n") #endif /* HAVE_IPV6 */ int @@ -14514,19 +9816,18 @@ bgp_vty_init (void) install_default (BGP_VPNV6_NODE); install_default (BGP_ENCAP_NODE); install_default (BGP_ENCAPV6_NODE); - + /* "bgp multiple-instance" commands. */ install_element (CONFIG_NODE, &bgp_multiple_instance_cmd); install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd); /* "bgp config-type" commands. */ install_element (CONFIG_NODE, &bgp_config_type_cmd); - install_element (CONFIG_NODE, &no_bgp_config_type_val_cmd); + install_element (CONFIG_NODE, &no_bgp_config_type_cmd); /* bgp route-map delay-timer commands. */ install_element (CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); - install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_val_cmd); /* Dummy commands (Currently not supported) */ install_element (BGP_NODE, &no_synchronization_cmd); @@ -14534,30 +9835,21 @@ bgp_vty_init (void) /* "router bgp" commands. */ install_element (CONFIG_NODE, &router_bgp_cmd); - install_element (CONFIG_NODE, &router_bgp_instance_cmd); - install_element (CONFIG_NODE, &router_bgp_noasn_cmd); /* "no router bgp" commands. */ install_element (CONFIG_NODE, &no_router_bgp_cmd); - install_element (CONFIG_NODE, &no_router_bgp_instance_cmd); - install_element (CONFIG_NODE, &no_router_bgp_noasn_cmd); /* "bgp router-id" commands. */ install_element (BGP_NODE, &bgp_router_id_cmd); install_element (BGP_NODE, &no_bgp_router_id_cmd); - install_element (BGP_NODE, &no_bgp_router_id_val_cmd); /* "bgp cluster-id" commands. */ install_element (BGP_NODE, &bgp_cluster_id_cmd); - install_element (BGP_NODE, &bgp_cluster_id32_cmd); install_element (BGP_NODE, &no_bgp_cluster_id_cmd); - install_element (BGP_NODE, &no_bgp_cluster_id_ip_cmd); - install_element (BGP_NODE, &no_bgp_cluster_id_decimal_cmd); /* "bgp confederation" commands. */ install_element (BGP_NODE, &bgp_confederation_identifier_cmd); install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd); - install_element (BGP_NODE, &no_bgp_confederation_identifier_arg_cmd); /* "bgp confederation peers" commands. */ install_element (BGP_NODE, &bgp_confederation_peers_cmd); @@ -14567,12 +9859,9 @@ bgp_vty_init (void) install_element (BGP_NODE, &bgp_maxmed_admin_cmd); install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd); install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd); - install_element (BGP_NODE, &no_bgp_maxmed_admin_medv_cmd); install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd); install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd); - install_element (BGP_NODE, &no_bgp_maxmed_onstartup_period_cmd); install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd); - install_element (BGP_NODE, &no_bgp_maxmed_onstartup_period_medv_cmd); /* bgp disable-ebgp-connected-nh-check */ install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd); @@ -14582,7 +9871,6 @@ bgp_vty_init (void) install_element (BGP_NODE, &bgp_update_delay_cmd); install_element (BGP_NODE, &no_bgp_update_delay_cmd); install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd); - install_element (BGP_NODE, &no_bgp_update_delay_establish_wait_cmd); install_element (BGP_NODE, &bgp_wpkt_quanta_cmd); install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd); @@ -14593,38 +9881,27 @@ bgp_vty_init (void) /* "maximum-paths" commands. */ install_element (BGP_NODE, &bgp_maxpaths_cmd); install_element (BGP_NODE, &no_bgp_maxpaths_cmd); - install_element (BGP_NODE, &no_bgp_maxpaths_arg_cmd); install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd); install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); - install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_arg_cmd); install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd); install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); - install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_arg_cmd); install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd); install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_cmd); install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd); - install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_arg_cmd); - install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd); install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); - install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd); - install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_arg_cmd); install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); - install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_arg_cmd); - install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd); /* "timers bgp" commands. */ install_element (BGP_NODE, &bgp_timers_cmd); install_element (BGP_NODE, &no_bgp_timers_cmd); - install_element (BGP_NODE, &no_bgp_timers_arg_cmd); /* route-map delay-timer commands - per instance for backwards compat. */ install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd); install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); - install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_val_cmd); /* "bgp client-to-client reflection" commands */ install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd); @@ -14633,7 +9910,7 @@ bgp_vty_init (void) /* "bgp always-compare-med" commands */ install_element (BGP_NODE, &bgp_always_compare_med_cmd); install_element (BGP_NODE, &no_bgp_always_compare_med_cmd); - + /* "bgp deterministic-med" commands */ install_element (BGP_NODE, &bgp_deterministic_med_cmd); install_element (BGP_NODE, &no_bgp_deterministic_med_cmd); @@ -14643,11 +9920,9 @@ bgp_vty_init (void) install_element (BGP_NODE, &no_bgp_graceful_restart_cmd); install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); - install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_val_cmd); install_element (BGP_NODE, &bgp_graceful_restart_restart_time_cmd); install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); - install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_val_cmd); - + /* "bgp fast-external-failover" commands */ install_element (BGP_NODE, &bgp_fast_external_failover_cmd); install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd); @@ -14678,16 +9953,12 @@ bgp_vty_init (void) /* "bgp bestpath med" commands */ install_element (BGP_NODE, &bgp_bestpath_med_cmd); - install_element (BGP_NODE, &bgp_bestpath_med2_cmd); - install_element (BGP_NODE, &bgp_bestpath_med3_cmd); install_element (BGP_NODE, &no_bgp_bestpath_med_cmd); - install_element (BGP_NODE, &no_bgp_bestpath_med2_cmd); - install_element (BGP_NODE, &no_bgp_bestpath_med3_cmd); /* "no bgp default ipv4-unicast" commands. */ install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd); - + /* "bgp network import-check" commands. */ install_element (BGP_NODE, &bgp_network_import_check_cmd); install_element (BGP_NODE, &bgp_network_import_check_exact_cmd); @@ -14696,7 +9967,6 @@ bgp_vty_init (void) /* "bgp default local-preference" commands. */ install_element (BGP_NODE, &bgp_default_local_preference_cmd); install_element (BGP_NODE, &no_bgp_default_local_preference_cmd); - install_element (BGP_NODE, &no_bgp_default_local_preference_val_cmd); /* bgp default show-hostname */ install_element (BGP_NODE, &bgp_default_show_hostname_cmd); @@ -14705,7 +9975,6 @@ bgp_vty_init (void) /* "bgp default subgroup-pkt-queue-max" commands. */ install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); - install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_val_cmd); /* bgp ibgp-allow-policy-mods command */ install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); @@ -14714,7 +9983,6 @@ bgp_vty_init (void) /* "bgp listen limit" commands. */ install_element (BGP_NODE, &bgp_listen_limit_cmd); install_element (BGP_NODE, &no_bgp_listen_limit_cmd); - install_element (BGP_NODE, &no_bgp_listen_limit_val_cmd); /* "bgp listen range" commands. */ install_element (BGP_NODE, &bgp_listen_range_cmd); @@ -14724,18 +9992,10 @@ bgp_vty_init (void) install_element (BGP_NODE, &neighbor_remote_as_cmd); install_element (BGP_NODE, &neighbor_interface_config_cmd); install_element (BGP_NODE, &neighbor_interface_config_v6only_cmd); - install_element (BGP_NODE, &neighbor_interface_config_peergroup_cmd); - install_element (BGP_NODE, &neighbor_interface_config_v6only_peergroup_cmd); install_element (BGP_NODE, &neighbor_interface_config_remote_as_cmd); install_element (BGP_NODE, &neighbor_interface_v6only_config_remote_as_cmd); install_element (BGP_NODE, &no_neighbor_cmd); - install_element (BGP_NODE, &no_neighbor_remote_as_cmd); install_element (BGP_NODE, &no_neighbor_interface_config_cmd); - install_element (BGP_NODE, &no_neighbor_interface_config_v6only_cmd); - install_element (BGP_NODE, &no_neighbor_interface_config_peergroup_cmd); - install_element (BGP_NODE, &no_neighbor_interface_config_v6only_peergroup_cmd); - install_element (BGP_NODE, &no_neighbor_interface_config_remote_as_cmd); - install_element (BGP_NODE, &no_neighbor_interface_config_v6only_remote_as_cmd); /* "neighbor peer-group" commands. */ install_element (BGP_NODE, &neighbor_peer_group_cmd); @@ -14747,9 +10007,6 @@ bgp_vty_init (void) install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd); install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); install_element (BGP_NODE, &no_neighbor_local_as_cmd); - install_element (BGP_NODE, &no_neighbor_local_as_val_cmd); - install_element (BGP_NODE, &no_neighbor_local_as_val2_cmd); - install_element (BGP_NODE, &no_neighbor_local_as_val3_cmd); /* "neighbor solo" commands. */ install_element (BGP_NODE, &neighbor_solo_cmd); @@ -14758,7 +10015,6 @@ bgp_vty_init (void) /* "neighbor password" commands. */ install_element (BGP_NODE, &neighbor_password_cmd); install_element (BGP_NODE, &no_neighbor_password_cmd); - install_element (BGP_NODE, &no_neighbor_password_val_cmd); /* "neighbor activate" commands. */ install_element (BGP_NODE, &neighbor_activate_cmd); @@ -14808,7 +10064,7 @@ bgp_vty_init (void) install_element (BGP_VPNV6_NODE, &no_neighbor_set_peer_group_cmd); install_element (BGP_ENCAP_NODE, &no_neighbor_set_peer_group_cmd); install_element (BGP_ENCAPV6_NODE, &no_neighbor_set_peer_group_cmd); - + /* "neighbor softreconfiguration inbound" commands.*/ install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd); install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd); @@ -14831,205 +10087,25 @@ bgp_vty_init (void) /* "neighbor attribute-unchanged" commands. */ install_element (BGP_NODE, &neighbor_attr_unchanged_cmd); - install_element (BGP_NODE, &neighbor_attr_unchanged1_cmd); - install_element (BGP_NODE, &neighbor_attr_unchanged2_cmd); - install_element (BGP_NODE, &neighbor_attr_unchanged3_cmd); - install_element (BGP_NODE, &neighbor_attr_unchanged4_cmd); - install_element (BGP_NODE, &neighbor_attr_unchanged5_cmd); - install_element (BGP_NODE, &neighbor_attr_unchanged6_cmd); - install_element (BGP_NODE, &neighbor_attr_unchanged7_cmd); - install_element (BGP_NODE, &neighbor_attr_unchanged8_cmd); - install_element (BGP_NODE, &neighbor_attr_unchanged9_cmd); - install_element (BGP_NODE, &neighbor_attr_unchanged10_cmd); install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd); - install_element (BGP_NODE, &no_neighbor_attr_unchanged1_cmd); - install_element (BGP_NODE, &no_neighbor_attr_unchanged2_cmd); - install_element (BGP_NODE, &no_neighbor_attr_unchanged3_cmd); - install_element (BGP_NODE, &no_neighbor_attr_unchanged4_cmd); - install_element (BGP_NODE, &no_neighbor_attr_unchanged5_cmd); - install_element (BGP_NODE, &no_neighbor_attr_unchanged6_cmd); - install_element (BGP_NODE, &no_neighbor_attr_unchanged7_cmd); - install_element (BGP_NODE, &no_neighbor_attr_unchanged8_cmd); - install_element (BGP_NODE, &no_neighbor_attr_unchanged9_cmd); - install_element (BGP_NODE, &no_neighbor_attr_unchanged10_cmd); install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); - install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged1_cmd); - install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged2_cmd); - install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged3_cmd); - install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged4_cmd); - install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged5_cmd); - install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged6_cmd); - install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged7_cmd); - install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged8_cmd); - install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged9_cmd); - install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged10_cmd); install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged1_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged2_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged3_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged4_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged5_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged6_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged7_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged8_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged9_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged10_cmd); install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); - install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged1_cmd); - install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged2_cmd); - install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged3_cmd); - install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged4_cmd); - install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged5_cmd); - install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged6_cmd); - install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged7_cmd); - install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged8_cmd); - install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged9_cmd); - install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged10_cmd); install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged1_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged2_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged3_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged4_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged5_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged6_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged7_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged8_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged9_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged10_cmd); install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); - install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged1_cmd); - install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged2_cmd); - install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged3_cmd); - install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged4_cmd); - install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged5_cmd); - install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged6_cmd); - install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged7_cmd); - install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged8_cmd); - install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged9_cmd); - install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged10_cmd); install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged1_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged2_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged3_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged4_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged5_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged6_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged7_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged8_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged9_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged10_cmd); install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); - install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged1_cmd); - install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged2_cmd); - install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged3_cmd); - install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged4_cmd); - install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged5_cmd); - install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged6_cmd); - install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged7_cmd); - install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged8_cmd); - install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged9_cmd); - install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged10_cmd); install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); - install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged1_cmd); - install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged2_cmd); - install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged3_cmd); - install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged4_cmd); - install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged5_cmd); - install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged6_cmd); - install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged7_cmd); - install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged8_cmd); - install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged9_cmd); - install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged10_cmd); install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); - install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged1_cmd); - install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged2_cmd); - install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged3_cmd); - install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged4_cmd); - install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged5_cmd); - install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged6_cmd); - install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged7_cmd); - install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged8_cmd); - install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged9_cmd); - install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged10_cmd); install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged1_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged2_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged3_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged4_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged5_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged6_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged7_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged8_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged9_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged10_cmd); install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); - install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged1_cmd); - install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged2_cmd); - install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged3_cmd); - install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged4_cmd); - install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged5_cmd); - install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged6_cmd); - install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged7_cmd); - install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged8_cmd); - install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged9_cmd); - install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged10_cmd); install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); - install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged1_cmd); - install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged2_cmd); - install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged3_cmd); - install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged4_cmd); - install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged5_cmd); - install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged6_cmd); - install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged7_cmd); - install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged8_cmd); - install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged9_cmd); - install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged10_cmd); install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged_cmd); - install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged1_cmd); - install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged2_cmd); - install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged3_cmd); - install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged4_cmd); - install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged5_cmd); - install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged6_cmd); - install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged7_cmd); - install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged8_cmd); - install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged9_cmd); - install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged10_cmd); install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged_cmd); - install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged1_cmd); - install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged2_cmd); - install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged3_cmd); - install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged4_cmd); - install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged5_cmd); - install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged6_cmd); - install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged7_cmd); - install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged8_cmd); - install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged9_cmd); - install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged10_cmd); install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged_cmd); - install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged1_cmd); - install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged2_cmd); - install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged3_cmd); - install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged4_cmd); - install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged5_cmd); - install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged6_cmd); - install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged7_cmd); - install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged8_cmd); - install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged9_cmd); - install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged10_cmd); install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged_cmd); - install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged1_cmd); - install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged2_cmd); - install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged3_cmd); - install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged4_cmd); - install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged5_cmd); - install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged6_cmd); - install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged7_cmd); - install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged8_cmd); - install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged9_cmd); - install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged10_cmd); /* "nexthop-local unchanged" commands */ install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); @@ -15296,18 +10372,14 @@ bgp_vty_init (void) install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd); install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd); - install_element (BGP_NODE, &no_neighbor_ebgp_multihop_ttl_cmd); /* "neighbor disable-connected-check" commands. */ install_element (BGP_NODE, &neighbor_disable_connected_check_cmd); install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd); - install_element (BGP_NODE, &neighbor_enforce_multihop_cmd); - install_element (BGP_NODE, &no_neighbor_enforce_multihop_cmd); /* "neighbor description" commands. */ install_element (BGP_NODE, &neighbor_description_cmd); install_element (BGP_NODE, &no_neighbor_description_cmd); - install_element (BGP_NODE, &no_neighbor_description_val_cmd); /* "neighbor update-source" commands. "*/ install_element (BGP_NODE, &neighbor_update_source_cmd); @@ -15317,57 +10389,43 @@ bgp_vty_init (void) install_element (BGP_NODE, &neighbor_default_originate_cmd); install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd); install_element (BGP_NODE, &no_neighbor_default_originate_cmd); - install_element (BGP_NODE, &no_neighbor_default_originate_rmap_cmd); install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd); install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_rmap_cmd); install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd); install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_rmap_cmd); install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd); install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_rmap_cmd); install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd); install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); - install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_rmap_cmd); /* "neighbor port" commands. */ install_element (BGP_NODE, &neighbor_port_cmd); install_element (BGP_NODE, &no_neighbor_port_cmd); - install_element (BGP_NODE, &no_neighbor_port_val_cmd); /* "neighbor weight" commands. */ install_element (BGP_NODE, &neighbor_weight_cmd); install_element (BGP_NODE, &no_neighbor_weight_cmd); - install_element (BGP_NODE, &no_neighbor_weight_val_cmd); + install_element (BGP_IPV4_NODE, &neighbor_weight_cmd); install_element (BGP_IPV4_NODE, &no_neighbor_weight_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_weight_val_cmd); install_element (BGP_IPV4M_NODE, &neighbor_weight_cmd); install_element (BGP_IPV4M_NODE, &no_neighbor_weight_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_weight_val_cmd); install_element (BGP_IPV6_NODE, &neighbor_weight_cmd); install_element (BGP_IPV6_NODE, &no_neighbor_weight_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_weight_val_cmd); install_element (BGP_IPV6M_NODE, &neighbor_weight_cmd); install_element (BGP_IPV6M_NODE, &no_neighbor_weight_cmd); - install_element (BGP_IPV6M_NODE, &no_neighbor_weight_val_cmd); install_element (BGP_VPNV4_NODE, &neighbor_weight_cmd); install_element (BGP_VPNV4_NODE, &no_neighbor_weight_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_weight_val_cmd); install_element (BGP_VPNV6_NODE, &neighbor_weight_cmd); install_element (BGP_VPNV6_NODE, &no_neighbor_weight_cmd); - install_element (BGP_VPNV6_NODE, &no_neighbor_weight_val_cmd); install_element (BGP_ENCAP_NODE, &neighbor_weight_cmd); install_element (BGP_ENCAP_NODE, &no_neighbor_weight_cmd); - install_element (BGP_ENCAP_NODE, &no_neighbor_weight_val_cmd); install_element (BGP_ENCAPV6_NODE, &neighbor_weight_cmd); install_element (BGP_ENCAPV6_NODE, &no_neighbor_weight_cmd); - install_element (BGP_ENCAPV6_NODE, &no_neighbor_weight_val_cmd); /* "neighbor override-capability" commands. */ install_element (BGP_NODE, &neighbor_override_capability_cmd); @@ -15380,17 +10438,14 @@ bgp_vty_init (void) /* "neighbor timers" commands. */ install_element (BGP_NODE, &neighbor_timers_cmd); install_element (BGP_NODE, &no_neighbor_timers_cmd); - install_element (BGP_NODE, &no_neighbor_timers_val_cmd); /* "neighbor timers connect" commands. */ install_element (BGP_NODE, &neighbor_timers_connect_cmd); install_element (BGP_NODE, &no_neighbor_timers_connect_cmd); - install_element (BGP_NODE, &no_neighbor_timers_connect_val_cmd); /* "neighbor advertisement-interval" commands. */ install_element (BGP_NODE, &neighbor_advertise_interval_cmd); install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd); - install_element (BGP_NODE, &no_neighbor_advertise_interval_val_cmd); /* "neighbor interface" commands. */ install_element (BGP_NODE, &neighbor_interface_cmd); @@ -15504,12 +10559,6 @@ bgp_vty_init (void) install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd); install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd); - install_element (BGP_NODE, &no_neighbor_maximum_prefix_val_cmd); - install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_cmd); - install_element (BGP_NODE, &no_neighbor_maximum_prefix_warning_cmd); - install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd); - install_element (BGP_NODE, &no_neighbor_maximum_prefix_restart_cmd); - install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); @@ -15517,12 +10566,6 @@ bgp_vty_init (void) install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_val_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_warning_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_restart_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); @@ -15530,12 +10573,6 @@ bgp_vty_init (void) install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_val_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_warning_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_restart_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); @@ -15543,12 +10580,6 @@ bgp_vty_init (void) install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_val_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_warning_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_restart_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); @@ -15556,12 +10587,6 @@ bgp_vty_init (void) install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); - install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_val_cmd); - install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_cmd); - install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_warning_cmd); - install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd); - install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_restart_cmd); - install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); @@ -15569,12 +10594,6 @@ bgp_vty_init (void) install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_val_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_warning_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_restart_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); @@ -15582,12 +10601,6 @@ bgp_vty_init (void) install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); - install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_val_cmd); - install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd); - install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_warning_cmd); - install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd); - install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_restart_cmd); - install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_cmd); install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_cmd); @@ -15596,12 +10609,6 @@ bgp_vty_init (void) install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_restart_cmd); install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_cmd); - install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_val_cmd); - install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_threshold_cmd); - install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_warning_cmd); - install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd); - install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_restart_cmd); - install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_cmd); install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); @@ -15610,47 +10617,25 @@ bgp_vty_init (void) install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_restart_cmd); install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_cmd); - install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_val_cmd); - install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd); - install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_warning_cmd); - install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd); - install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_restart_cmd); - install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd); /* "neighbor allowas-in" */ install_element (BGP_NODE, &neighbor_allowas_in_cmd); - install_element (BGP_NODE, &neighbor_allowas_in_arg_cmd); install_element (BGP_NODE, &no_neighbor_allowas_in_cmd); - install_element (BGP_NODE, &no_neighbor_allowas_in_val_cmd); install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd); - install_element (BGP_IPV4_NODE, &neighbor_allowas_in_arg_cmd); install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_val_cmd); install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); - install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_arg_cmd); install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_val_cmd); install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd); - install_element (BGP_IPV6_NODE, &neighbor_allowas_in_arg_cmd); install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_val_cmd); install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); - install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_arg_cmd); install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); - install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_val_cmd); install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); - install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_arg_cmd); install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_val_cmd); install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); - install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_arg_cmd); install_element (BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); - install_element (BGP_VPNV6_NODE, &no_neighbor_allowas_in_val_cmd); install_element (BGP_ENCAP_NODE, &neighbor_allowas_in_cmd); - install_element (BGP_ENCAP_NODE, &neighbor_allowas_in_arg_cmd); install_element (BGP_ENCAP_NODE, &no_neighbor_allowas_in_cmd); install_element (BGP_ENCAPV6_NODE, &neighbor_allowas_in_cmd); - install_element (BGP_ENCAPV6_NODE, &neighbor_allowas_in_arg_cmd); install_element (BGP_ENCAPV6_NODE, &no_neighbor_allowas_in_cmd); /* address-family commands. */ @@ -15661,13 +10646,10 @@ bgp_vty_init (void) install_element (BGP_NODE, &address_family_ipv6_safi_cmd); #endif /* HAVE_IPV6 */ install_element (BGP_NODE, &address_family_vpnv4_cmd); - install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd); install_element (BGP_NODE, &address_family_vpnv6_cmd); - install_element (BGP_NODE, &address_family_vpnv6_unicast_cmd); install_element (BGP_NODE, &address_family_encap_cmd); - install_element (BGP_NODE, &address_family_encapv4_cmd); #ifdef HAVE_IPV6 install_element (BGP_NODE, &address_family_encapv6_cmd); #endif @@ -15684,313 +10666,16 @@ bgp_vty_init (void) /* "clear ip bgp commands" */ install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_external_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_cmd); - - install_element (ENABLE_NODE, &clear_bgp_all_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_all_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_all_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_cmd); - install_element (ENABLE_NODE, &clear_bgp_peer_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_peer_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_cmd); - install_element (ENABLE_NODE, &clear_bgp_peer_group_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_cmd); - install_element (ENABLE_NODE, &clear_bgp_external_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_external_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_external_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_cmd); - install_element (ENABLE_NODE, &clear_bgp_as_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_as_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_as_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_cmd); - - /* "clear ip bgp neighbor soft in" */ - install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_in_prefix_filter_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_prefix_filter_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_prefix_filter_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_external_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_external_in_prefix_filter_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_in_prefix_filter_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_prefix_filter_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_prefix_filter_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_prefix_filter_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_all_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_all_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_all_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_all_in_prefix_filter_cmd); - install_element (ENABLE_NODE, &clear_bgp_peer_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_peer_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_peer_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_peer_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_peer_in_prefix_filter_cmd); - install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_peer_group_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_peer_group_in_prefix_filter_cmd); - install_element (ENABLE_NODE, &clear_bgp_external_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_external_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_external_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_external_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_external_in_prefix_filter_cmd); - install_element (ENABLE_NODE, &clear_bgp_as_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_as_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_as_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_as_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_as_in_prefix_filter_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_prefix_filter_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_prefix_filter_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_prefix_filter_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_prefix_filter_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_soft_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_in_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_prefix_filter_cmd); /* clear ip bgp prefix */ install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_prefix_cmd); install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); - /* "clear ip bgp neighbor soft out" */ - install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_external_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_all_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_all_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_all_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_peer_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_peer_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_peer_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_peer_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_peer_group_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_external_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_external_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_external_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_external_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_as_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_as_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_as_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_as_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_all_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_external_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_soft_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_as_out_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_out_cmd); - - /* "clear ip bgp neighbor soft" */ - install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_all_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_peer_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_peer_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_external_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_external_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_as_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_as_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_cmd); - install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_soft_cmd); - /* "show ip bgp summary" commands. */ install_element (VIEW_NODE, &show_ip_bgp_summary_cmd); install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_all_updgrps_cmd); - install_element (VIEW_NODE, &show_bgp_updgrps_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_updgrps_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_updgrps_cmd); install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); - install_element (VIEW_NODE, &show_ip_bgp_updgrps_s_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_s_cmd); - install_element (VIEW_NODE, &show_bgp_updgrps_s_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_updgrps_s_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_updgrps_s_cmd); install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd); @@ -16001,61 +10686,27 @@ bgp_vty_init (void) install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_summary_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_all_summary_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_summary_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_safi_summary_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_summary_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_summary_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd); -#ifdef HAVE_IPV6 - install_element (VIEW_NODE, &show_bgp_summary_cmd); - install_element (VIEW_NODE, &show_bgp_instance_summary_cmd); - install_element (VIEW_NODE, &show_bgp_instance_all_summary_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_summary_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_safi_summary_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_summary_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_summary_cmd); -#endif /* HAVE_IPV6 */ - - install_element (VIEW_NODE, &show_bgp_ipv4_vpn_summary_cmd); - - install_element (VIEW_NODE, &show_bgp_ipv6_vpn_summary_cmd); + install_element (VIEW_NODE, &show_ip_bgp_summary_cmd); + install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd); + install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); + install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); + install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); + install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd); + install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd); + install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); + install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); + install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); + install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); + install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); + install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); + install_element (VIEW_NODE, &show_bgp_updgrps_stats_cmd); + install_element (VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); /* "show ip bgp neighbors" commands. */ install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd); - install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_all_neighbors_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd); - -#ifdef HAVE_IPV6 - install_element (VIEW_NODE, &show_bgp_neighbors_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_cmd); - install_element (VIEW_NODE, &show_bgp_neighbors_peer_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_peer_cmd); - install_element (VIEW_NODE, &show_bgp_instance_neighbors_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_cmd); - install_element (VIEW_NODE, &show_bgp_instance_neighbors_peer_cmd); - install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd); - - /* Old commands. */ - install_element (VIEW_NODE, &show_ipv6_bgp_summary_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_summary_cmd); -#endif /* HAVE_IPV6 */ /* "show ip bgp peer-group" commands. */ install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_peer_groups_cmd); - install_element (VIEW_NODE, &show_ip_bgp_peer_group_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_peer_group_cmd); /* "show ip bgp paths" commands. */ install_element (VIEW_NODE, &show_ip_bgp_paths_cmd); @@ -16071,54 +10722,34 @@ bgp_vty_init (void) install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd); install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd); install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd); - install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_cmd); install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd); - install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_cmd); install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); - install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd); - install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd); install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_cmd); install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); - install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_cmd); install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); - install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_metric_cmd); install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); - install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd); install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); - install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd); install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); - install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_rmap_cmd); install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); - install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_metric_cmd); install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); - install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd); - install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd); install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); - install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_cmd); install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); - install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_metric_cmd); install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); - install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd); install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); - install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd); #ifdef HAVE_IPV6 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); - install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_cmd); install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); - install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_cmd); install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); - install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_metric_cmd); - install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_rmap_cmd); #endif /* HAVE_IPV6 */ /* ttl_security commands */ @@ -16127,13 +10758,13 @@ bgp_vty_init (void) /* "show bgp memory" commands. */ install_element (VIEW_NODE, &show_bgp_memory_cmd); - + /* "show bgp views" commands. */ install_element (VIEW_NODE, &show_bgp_views_cmd); - + /* "show bgp vrfs" commands. */ install_element (VIEW_NODE, &show_bgp_vrfs_cmd); - + /* Community-list. */ community_list_vty (); } @@ -16181,48 +10812,38 @@ community_list_perror (struct vty *vty, int ret) } } -/* VTY interface for community_set() function. */ -static int -community_list_set_vty (struct vty *vty, int argc, const char **argv, - int style, int reject_all_digit_name) -{ - int ret; - int direct; - char *str; +/* "community-list" keyword help string. */ +#define COMMUNITY_LIST_STR "Add a community list entry\n" - /* Check the list type. */ - if (strncmp (argv[1], "p", 1) == 0) - direct = COMMUNITY_PERMIT; - else if (strncmp (argv[1], "d", 1) == 0) - direct = COMMUNITY_DENY; - else - { - vty_out (vty, "%% Matching condition must be permit or deny%s", - VTY_NEWLINE); - return CMD_WARNING; - } - /* All digit name check. */ - if (reject_all_digit_name && all_digit (argv[0])) - { - vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE); - return CMD_WARNING; - } +/* ip community-list standard */ +DEFUN (ip_community_list_standard, + ip_community_list_standard_cmd, + "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", + IP_STR + COMMUNITY_LIST_STR + "Community list number (standard)\n" + "Add an standard community-list entry\n" + "Community list name\n" + "Specify community to reject\n" + "Specify community to accept\n" + COMMUNITY_VAL_STR) +{ + char *cl_name_or_number = NULL; + int direct = 0; + int style = COMMUNITY_LIST_STANDARD; - /* Concat community string argument. */ - if (argc > 1) - str = argv_concat (argv, argc, 2); - else - str = NULL; + int idx = 0; + argv_find (argv, argc, "(1-99)", &idx); + argv_find (argv, argc, "WORD", &idx); + cl_name_or_number = argv[idx]->arg; + direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; + argv_find (argv, argc, "AA:NN", &idx); + char *str = argv_concat (argv, argc, idx); - /* When community_list_set() return nevetive value, it means - malformed community string. */ - ret = community_list_set (bgp_clist, argv[0], str, direct, style); + int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); - /* Free temporary community list string allocated by - argv_concat(). */ - if (str) - XFREE (MTYPE_TMP, str); + XFREE (MTYPE_TMP, str); if (ret < 0) { @@ -16234,40 +10855,34 @@ community_list_set_vty (struct vty *vty, int argc, const char **argv, return CMD_SUCCESS; } -/* Communiyt-list entry delete. */ -static int -community_list_unset_vty (struct vty *vty, int argc, const char **argv, - int style, int delete_all) +DEFUN (no_ip_community_list_standard_all, + no_ip_community_list_standard_all_cmd, + "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", + NO_STR + IP_STR + COMMUNITY_LIST_STR + "Community list number (standard)\n" + "Add an standard community-list entry\n" + "Community list name\n" + "Specify community to reject\n" + "Specify community to accept\n" + COMMUNITY_VAL_STR) { - int ret; - int direct = 0; - char *str = NULL; + int delete_all = 0; - if (argc > 1) - { - /* Check the list direct. */ - if (strncmp (argv[1], "p", 1) == 0) - direct = COMMUNITY_PERMIT; - else if (strncmp (argv[1], "d", 1) == 0) - direct = COMMUNITY_DENY; - else - { - vty_out (vty, "%% Matching condition must be permit or deny%s", - VTY_NEWLINE); - return CMD_WARNING; - } + char *cl_name_or_number = NULL; + int direct = 0; + int style = COMMUNITY_LIST_STANDARD; - /* Concat community string argument. */ - str = argv_concat (argv, argc, 2); - } + int idx = 0; + argv_find (argv, argc, "(1-99)", &idx); + argv_find (argv, argc, "WORD", &idx); + cl_name_or_number = argv[idx]->arg; + direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; + argv_find (argv, argc, "AA:NN", &idx); + char *str = argv_concat (argv, argc, idx); - /* Unset community list. */ - ret = community_list_unset (bgp_clist, argv[0], str, direct, style, delete_all); - - /* Free temporary community list string allocated by - argv_concat(). */ - if (str) - XFREE (MTYPE_TMP, str); + int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); if (ret < 0) { @@ -16278,212 +10893,81 @@ community_list_unset_vty (struct vty *vty, int argc, const char **argv, return CMD_SUCCESS; } -/* "community-list" keyword help string. */ -#define COMMUNITY_LIST_STR "Add a community list entry\n" - -DEFUN (ip_community_list_standard, - ip_community_list_standard_cmd, - "ip community-list <1-99> (deny|permit) .AA:NN", - IP_STR - COMMUNITY_LIST_STR - "Community list number (standard)\n" - "Specify community to reject\n" - "Specify community to accept\n" - COMMUNITY_VAL_STR) -{ - return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0); -} - -ALIAS (ip_community_list_standard, - ip_community_list_standard2_cmd, - "ip community-list <1-99> (deny|permit)", - IP_STR - COMMUNITY_LIST_STR - "Community list number (standard)\n" - "Specify community to reject\n" - "Specify community to accept\n") - -DEFUN (ip_community_list_expanded, - ip_community_list_expanded_cmd, - "ip community-list <100-500> (deny|permit) .LINE", +/* ip community-list expanded */ +DEFUN (ip_community_list_expanded_all, + ip_community_list_expanded_all_cmd, + "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", IP_STR COMMUNITY_LIST_STR "Community list number (expanded)\n" - "Specify community to reject\n" - "Specify community to accept\n" - "An ordered list as a regular-expression\n") -{ - return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0); -} - -DEFUN (ip_community_list_name_standard, - ip_community_list_name_standard_cmd, - "ip community-list standard WORD (deny|permit) .AA:NN", - IP_STR - COMMUNITY_LIST_STR - "Add a standard community-list entry\n" + "Add an expanded community-list entry\n" "Community list name\n" "Specify community to reject\n" "Specify community to accept\n" COMMUNITY_VAL_STR) { - return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1); -} + char *cl_name_or_number = NULL; + int direct = 0; + int style = COMMUNITY_LIST_EXPANDED; -ALIAS (ip_community_list_name_standard, - ip_community_list_name_standard2_cmd, - "ip community-list standard WORD (deny|permit)", - IP_STR - COMMUNITY_LIST_STR - "Add a standard community-list entry\n" - "Community list name\n" - "Specify community to reject\n" - "Specify community to accept\n") + int idx = 0; + argv_find (argv, argc, "(100-500)", &idx); + argv_find (argv, argc, "WORD", &idx); + cl_name_or_number = argv[idx]->arg; + direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; + argv_find (argv, argc, "AA:NN", &idx); + char *str = argv_concat (argv, argc, idx); -DEFUN (ip_community_list_name_expanded, - ip_community_list_name_expanded_cmd, - "ip community-list expanded WORD (deny|permit) .LINE", - IP_STR - COMMUNITY_LIST_STR - "Add an expanded community-list entry\n" - "Community list name\n" - "Specify community to reject\n" - "Specify community to accept\n" - "An ordered list as a regular-expression\n") -{ - return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1); -} + int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); -DEFUN (no_ip_community_list_standard_all, - no_ip_community_list_standard_all_cmd, - "no ip community-list <1-99>", - NO_STR - IP_STR - COMMUNITY_LIST_STR - "Community list number (standard)\n") -{ - return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1); -} + XFREE (MTYPE_TMP, str); -DEFUN (no_ip_community_list_standard_direction, - no_ip_community_list_standard_direction_cmd, - "no ip community-list <1-99> (deny|permit)", - NO_STR - IP_STR - COMMUNITY_LIST_STR - "Community list number (standard)\n" - "Specify community to reject\n" - "Specify community to accept\n") -{ - return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0); -} + if (ret < 0) + { + /* Display error string. */ + community_list_perror (vty, ret); + return CMD_WARNING; + } + return CMD_SUCCESS; +} DEFUN (no_ip_community_list_expanded_all, no_ip_community_list_expanded_all_cmd, - "no ip community-list <100-500>", - NO_STR - IP_STR - COMMUNITY_LIST_STR - "Community list number (expanded)\n") -{ - return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1); -} - -DEFUN (no_ip_community_list_name_standard_all, - no_ip_community_list_name_standard_all_cmd, - "no ip community-list standard WORD", - NO_STR - IP_STR - COMMUNITY_LIST_STR - "Add a standard community-list entry\n" - "Community list name\n") -{ - return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1); -} - -DEFUN (no_ip_community_list_name_expanded_all, - no_ip_community_list_name_expanded_all_cmd, - "no ip community-list expanded WORD", + "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", NO_STR IP_STR COMMUNITY_LIST_STR + "Community list number (expanded)\n" "Add an expanded community-list entry\n" - "Community list name\n") -{ - return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1); -} - -DEFUN (no_ip_community_list_standard, - no_ip_community_list_standard_cmd, - "no ip community-list <1-99> (deny|permit) .AA:NN", - NO_STR - IP_STR - COMMUNITY_LIST_STR - "Community list number (standard)\n" + "Community list name\n" "Specify community to reject\n" "Specify community to accept\n" COMMUNITY_VAL_STR) { - return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0); -} + int delete_all = 0; -DEFUN (no_ip_community_list_expanded, - no_ip_community_list_expanded_cmd, - "no ip community-list <100-500> (deny|permit) .LINE", - NO_STR - IP_STR - COMMUNITY_LIST_STR - "Community list number (expanded)\n" - "Specify community to reject\n" - "Specify community to accept\n" - "An ordered list as a regular-expression\n") -{ - return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0); -} + char *cl_name_or_number = NULL; + int direct = 0; + int style = COMMUNITY_LIST_EXPANDED; -DEFUN (no_ip_community_list_name_standard, - no_ip_community_list_name_standard_cmd, - "no ip community-list standard WORD (deny|permit) .AA:NN", - NO_STR - IP_STR - COMMUNITY_LIST_STR - "Specify a standard community-list\n" - "Community list name\n" - "Specify community to reject\n" - "Specify community to accept\n" - COMMUNITY_VAL_STR) -{ - return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0); -} + int idx = 0; + argv_find (argv, argc, "(100-500)", &idx); + argv_find (argv, argc, "WORD", &idx); + cl_name_or_number = argv[idx]->arg; + direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; + argv_find (argv, argc, "AA:NN", &idx); + char *str = argv_concat (argv, argc, idx); -DEFUN (no_ip_community_list_name_standard_brief, - no_ip_community_list_name_standard_brief_cmd, - "no ip community-list standard WORD (deny|permit)", - NO_STR - IP_STR - COMMUNITY_LIST_STR - "Specify a standard community-list\n" - "Community list name\n" - "Specify community to reject\n" - "Specify community to accept\n") -{ - return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0); -} + int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); -DEFUN (no_ip_community_list_name_expanded, - no_ip_community_list_name_expanded_cmd, - "no ip community-list expanded WORD (deny|permit) .LINE", - NO_STR - IP_STR - COMMUNITY_LIST_STR - "Specify an expanded community-list\n" - "Community list name\n" - "Specify community to reject\n" - "Specify community to accept\n" - "An ordered list as a regular-expression\n") -{ - return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0); + if (ret < 0) + { + community_list_perror (vty, ret); + return CMD_WARNING; + } + + return CMD_SUCCESS; } static void @@ -16543,16 +11027,17 @@ DEFUN (show_ip_community_list, DEFUN (show_ip_community_list_arg, show_ip_community_list_arg_cmd, - "show ip community-list (<1-500>|WORD)", + "show ip community-list <(1-500)|WORD>", SHOW_STR IP_STR "List community-list\n" "Community-list number\n" "Community-list name\n") { + int idx_comm_list = 3; struct community_list *list; - list = community_list_lookup (bgp_clist, argv[0], COMMUNITY_LIST_MASTER); + list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, COMMUNITY_LIST_MASTER); if (! list) { vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); @@ -16564,303 +11049,162 @@ DEFUN (show_ip_community_list_arg, return CMD_SUCCESS; } -static int -extcommunity_list_set_vty (struct vty *vty, int argc, const char **argv, - int style, int reject_all_digit_name) -{ - int ret; - int direct; - char *str; - - /* Check the list type. */ - if (strncmp (argv[1], "p", 1) == 0) - direct = COMMUNITY_PERMIT; - else if (strncmp (argv[1], "d", 1) == 0) - direct = COMMUNITY_DENY; - else - { - vty_out (vty, "%% Matching condition must be permit or deny%s", - VTY_NEWLINE); - return CMD_WARNING; - } - - /* All digit name check. */ - if (reject_all_digit_name && all_digit (argv[0])) - { - vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE); - return CMD_WARNING; - } - - /* Concat community string argument. */ - if (argc > 1) - str = argv_concat (argv, argc, 2); - else - str = NULL; - - ret = extcommunity_list_set (bgp_clist, argv[0], str, direct, style); - - /* Free temporary community list string allocated by - argv_concat(). */ - if (str) - XFREE (MTYPE_TMP, str); - - if (ret < 0) - { - community_list_perror (vty, ret); - return CMD_WARNING; - } - return CMD_SUCCESS; -} - -static int -extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv, - int style, int delete_all) -{ - int ret; - int direct = 0; - char *str = NULL; - - if (argc > 1) - { - /* Check the list direct. */ - if (strncmp (argv[1], "p", 1) == 0) - direct = COMMUNITY_PERMIT; - else if (strncmp (argv[1], "d", 1) == 0) - direct = COMMUNITY_DENY; - else - { - vty_out (vty, "%% Matching condition must be permit or deny%s", - VTY_NEWLINE); - return CMD_WARNING; - } - - /* Concat community string argument. */ - str = argv_concat (argv, argc, 2); - } - - /* Unset community list. */ - ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style, delete_all); - - /* Free temporary community list string allocated by - argv_concat(). */ - if (str) - XFREE (MTYPE_TMP, str); - - if (ret < 0) - { - community_list_perror (vty, ret); - return CMD_WARNING; - } - - return CMD_SUCCESS; -} - /* "extcommunity-list" keyword help string. */ #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" DEFUN (ip_extcommunity_list_standard, ip_extcommunity_list_standard_cmd, - "ip extcommunity-list <1-99> (deny|permit) .AA:NN", + "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", IP_STR EXTCOMMUNITY_LIST_STR "Extended Community list number (standard)\n" + "Specify standard extcommunity-list\n" + "Community list name\n" "Specify community to reject\n" "Specify community to accept\n" EXTCOMMUNITY_VAL_STR) { - return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0); -} + int style = EXTCOMMUNITY_LIST_STANDARD; + int direct = 0; + char *cl_number_or_name = NULL; -ALIAS (ip_extcommunity_list_standard, - ip_extcommunity_list_standard2_cmd, - "ip extcommunity-list <1-99> (deny|permit)", - IP_STR - EXTCOMMUNITY_LIST_STR - "Extended Community list number (standard)\n" - "Specify community to reject\n" - "Specify community to accept\n") + int idx = 0; + argv_find (argv, argc, "(1-99)", &idx); + argv_find (argv, argc, "WORD", &idx); + cl_number_or_name = argv[idx]->arg; + direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; + argv_find (argv, argc, "AA:NN", &idx); + char *str = argv_concat (argv, argc, idx); -DEFUN (ip_extcommunity_list_expanded, - ip_extcommunity_list_expanded_cmd, - "ip extcommunity-list <100-500> (deny|permit) .LINE", - IP_STR - EXTCOMMUNITY_LIST_STR - "Extended Community list number (expanded)\n" - "Specify community to reject\n" - "Specify community to accept\n" - "An ordered list as a regular-expression\n") -{ - return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0); -} + int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); -DEFUN (ip_extcommunity_list_name_standard, - ip_extcommunity_list_name_standard_cmd, - "ip extcommunity-list standard WORD (deny|permit) .AA:NN", - IP_STR - EXTCOMMUNITY_LIST_STR - "Specify standard extcommunity-list\n" - "Extended Community list name\n" - "Specify community to reject\n" - "Specify community to accept\n" - EXTCOMMUNITY_VAL_STR) -{ - return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1); -} + XFREE (MTYPE_TMP, str); -ALIAS (ip_extcommunity_list_name_standard, - ip_extcommunity_list_name_standard2_cmd, - "ip extcommunity-list standard WORD (deny|permit)", - IP_STR - EXTCOMMUNITY_LIST_STR - "Specify standard extcommunity-list\n" - "Extended Community list name\n" - "Specify community to reject\n" - "Specify community to accept\n") + if (ret < 0) + { + community_list_perror (vty, ret); + return CMD_WARNING; + } + + return CMD_SUCCESS; +} DEFUN (ip_extcommunity_list_name_expanded, ip_extcommunity_list_name_expanded_cmd, - "ip extcommunity-list expanded WORD (deny|permit) .LINE", + "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", IP_STR EXTCOMMUNITY_LIST_STR + "Extended Community list number (expanded)\n" "Specify expanded extcommunity-list\n" "Extended Community list name\n" "Specify community to reject\n" "Specify community to accept\n" "An ordered list as a regular-expression\n") { - return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1); -} + int style = EXTCOMMUNITY_LIST_EXPANDED; + int direct = 0; + char *cl_number_or_name = NULL; -DEFUN (no_ip_extcommunity_list_standard_all, - no_ip_extcommunity_list_standard_all_cmd, - "no ip extcommunity-list <1-99>", - NO_STR - IP_STR - EXTCOMMUNITY_LIST_STR - "Extended Community list number (standard)\n") -{ - return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1); -} + int idx = 0; + argv_find (argv, argc, "(100-500)", &idx); + argv_find (argv, argc, "WORD", &idx); + cl_number_or_name = argv[idx]->arg; + direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; + argv_find (argv, argc, "LINE", &idx); + char *str = argv_concat (argv, argc, idx); -DEFUN (no_ip_extcommunity_list_standard_direction, - no_ip_extcommunity_list_standard_direction_cmd, - "no ip extcommunity-list <1-99> (deny|permit)", - NO_STR - IP_STR - EXTCOMMUNITY_LIST_STR - "Extended Community list number (standard)\n" - "Specify community to reject\n" - "Specify community to accept\n") -{ - return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0); -} + int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); -DEFUN (no_ip_extcommunity_list_expanded_all, - no_ip_extcommunity_list_expanded_all_cmd, - "no ip extcommunity-list <100-500>", - NO_STR - IP_STR - EXTCOMMUNITY_LIST_STR - "Extended Community list number (expanded)\n") -{ - return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1); -} + XFREE (MTYPE_TMP, str); -DEFUN (no_ip_extcommunity_list_name_standard_all, - no_ip_extcommunity_list_name_standard_all_cmd, - "no ip extcommunity-list standard WORD", - NO_STR - IP_STR - EXTCOMMUNITY_LIST_STR - "Specify standard extcommunity-list\n" - "Extended Community list name\n") -{ - return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1); -} + if (ret < 0) + { + community_list_perror (vty, ret); + return CMD_WARNING; + } -DEFUN (no_ip_extcommunity_list_name_expanded_all, - no_ip_extcommunity_list_name_expanded_all_cmd, - "no ip extcommunity-list expanded WORD", - NO_STR - IP_STR - EXTCOMMUNITY_LIST_STR - "Specify expanded extcommunity-list\n" - "Extended Community list name\n") -{ - return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1); + return CMD_SUCCESS; } -DEFUN (no_ip_extcommunity_list_standard, - no_ip_extcommunity_list_standard_cmd, - "no ip extcommunity-list <1-99> (deny|permit) .AA:NN", +DEFUN (no_ip_extcommunity_list_standard_all, + no_ip_extcommunity_list_standard_all_cmd, + "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", NO_STR IP_STR EXTCOMMUNITY_LIST_STR "Extended Community list number (standard)\n" + "Specify standard extcommunity-list\n" + "Community list name\n" "Specify community to reject\n" "Specify community to accept\n" EXTCOMMUNITY_VAL_STR) { - return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0); -} + int deleteall = 0; -DEFUN (no_ip_extcommunity_list_expanded, - no_ip_extcommunity_list_expanded_cmd, - "no ip extcommunity-list <100-500> (deny|permit) .LINE", - NO_STR - IP_STR - EXTCOMMUNITY_LIST_STR - "Extended Community list number (expanded)\n" - "Specify community to reject\n" - "Specify community to accept\n" - "An ordered list as a regular-expression\n") -{ - return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0); -} + int style = EXTCOMMUNITY_LIST_STANDARD; + int direct = 0; + char *cl_number_or_name = NULL; -DEFUN (no_ip_extcommunity_list_name_standard, - no_ip_extcommunity_list_name_standard_cmd, - "no ip extcommunity-list standard WORD (deny|permit) .AA:NN", - NO_STR - IP_STR - EXTCOMMUNITY_LIST_STR - "Specify standard extcommunity-list\n" - "Extended Community list name\n" - "Specify community to reject\n" - "Specify community to accept\n" - EXTCOMMUNITY_VAL_STR) -{ - return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0); -} + int idx = 0; + argv_find (argv, argc, "(1-99)", &idx); + argv_find (argv, argc, "WORD", &idx); + cl_number_or_name = argv[idx]->arg; + direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; + argv_find (argv, argc, "AA:NN", &idx); + char *str = argv_concat (argv, argc, idx); -DEFUN (no_ip_extcommunity_list_name_standard_brief, - no_ip_extcommunity_list_name_standard_brief_cmd, - "no ip extcommunity-list standard WORD (deny|permit)", - NO_STR - IP_STR - EXTCOMMUNITY_LIST_STR - "Specify standard extcommunity-list\n" - "Extended Community list name\n" - "Specify community to reject\n" - "Specify community to accept\n") -{ - return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0); + int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); + + XFREE (MTYPE_TMP, str); + + if (ret < 0) + { + community_list_perror (vty, ret); + return CMD_WARNING; + } + + return CMD_SUCCESS; } -DEFUN (no_ip_extcommunity_list_name_expanded, - no_ip_extcommunity_list_name_expanded_cmd, - "no ip extcommunity-list expanded WORD (deny|permit) .LINE", +DEFUN (no_ip_extcommunity_list_expanded_all, + no_ip_extcommunity_list_expanded_all_cmd, + "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", NO_STR IP_STR EXTCOMMUNITY_LIST_STR + "Extended Community list number (expanded)\n" "Specify expanded extcommunity-list\n" - "Community list name\n" + "Extended Community list name\n" "Specify community to reject\n" "Specify community to accept\n" "An ordered list as a regular-expression\n") { - return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0); + int deleteall = 0; + + int style = EXTCOMMUNITY_LIST_EXPANDED; + int direct = 0; + char *cl_number_or_name = NULL; + + int idx = 0; + argv_find (argv, argc, "(100-500)", &idx); + argv_find (argv, argc, "WORD", &idx); + cl_number_or_name = argv[idx]->arg; + direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; + argv_find (argv, argc, "LINE", &idx); + char *str = argv_concat (argv, argc, idx); + + int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); + + XFREE (MTYPE_TMP, str); + + if (ret < 0) + { + community_list_perror (vty, ret); + return CMD_WARNING; + } + + return CMD_SUCCESS; } static void @@ -16920,16 +11264,17 @@ DEFUN (show_ip_extcommunity_list, DEFUN (show_ip_extcommunity_list_arg, show_ip_extcommunity_list_arg_cmd, - "show ip extcommunity-list (<1-500>|WORD)", + "show ip extcommunity-list <(1-500)|WORD>", SHOW_STR IP_STR "List extended-community list\n" "Extcommunity-list number\n" "Extcommunity-list name\n") { + int idx_comm_list = 3; struct community_list *list; - list = community_list_lookup (bgp_clist, argv[0], EXTCOMMUNITY_LIST_MASTER); + list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, EXTCOMMUNITY_LIST_MASTER); if (! list) { vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE); @@ -17030,41 +11375,16 @@ community_list_vty (void) /* Community-list. */ install_element (CONFIG_NODE, &ip_community_list_standard_cmd); - install_element (CONFIG_NODE, &ip_community_list_standard2_cmd); - install_element (CONFIG_NODE, &ip_community_list_expanded_cmd); - install_element (CONFIG_NODE, &ip_community_list_name_standard_cmd); - install_element (CONFIG_NODE, &ip_community_list_name_standard2_cmd); - install_element (CONFIG_NODE, &ip_community_list_name_expanded_cmd); install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd); - install_element (CONFIG_NODE, &no_ip_community_list_standard_direction_cmd); install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); - install_element (CONFIG_NODE, &no_ip_community_list_name_standard_all_cmd); - install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_all_cmd); - install_element (CONFIG_NODE, &no_ip_community_list_standard_cmd); - install_element (CONFIG_NODE, &no_ip_community_list_expanded_cmd); - install_element (CONFIG_NODE, &no_ip_community_list_name_standard_cmd); - install_element (CONFIG_NODE, &no_ip_community_list_name_standard_brief_cmd); - install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_cmd); install_element (VIEW_NODE, &show_ip_community_list_cmd); install_element (VIEW_NODE, &show_ip_community_list_arg_cmd); /* Extcommunity-list. */ install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd); - install_element (CONFIG_NODE, &ip_extcommunity_list_standard2_cmd); - install_element (CONFIG_NODE, &ip_extcommunity_list_expanded_cmd); - install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard_cmd); - install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard2_cmd); install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); - install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_direction_cmd); install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); - install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_all_cmd); - install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_all_cmd); - install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_cmd); - install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_cmd); - install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_cmd); - install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_brief_cmd); - install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_cmd); install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd); install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); } diff --git a/bgpd/bgp_vty.h b/bgpd/bgp_vty.h index 573e8c7072..382af0984f 100644 --- a/bgpd/bgp_vty.h +++ b/bgpd/bgp_vty.h @@ -23,11 +23,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA struct bgp; -#define CMD_AS_RANGE "<1-4294967295>" -#define DYNAMIC_NEIGHBOR_LIMIT_RANGE "<1-5000>" -#define BGP_INSTANCE_CMD "(view|vrf) WORD" #define BGP_INSTANCE_HELP_STR "BGP view\nBGP VRF\nView/VRF name\n" -#define BGP_INSTANCE_ALL_CMD "(view|vrf) all" #define BGP_INSTANCE_ALL_HELP_STR "BGP view\nBGP VRF\nAll Views/VRFs\n" extern void bgp_vty_init (void); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 3ddb465a75..1b79fb7821 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -20,7 +20,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include <zebra.h> -#include "lib/json.h" #include "prefix.h" #include "thread.h" #include "buffer.h" @@ -43,6 +42,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "hash.h" #include "jhash.h" #include "table.h" +#include "lib/json.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_table.h" @@ -4571,7 +4571,7 @@ peer_weight_set (struct peer *peer, afi_t afi, safi_t safi, u_int16_t weight) peer->weight[afi][safi] = weight; SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_WEIGHT); peer_on_policy_change (peer, afi, safi, 0); - } + } } return 0; } @@ -4583,7 +4583,7 @@ peer_weight_unset (struct peer *peer, afi_t afi, safi_t safi) struct listnode *node, *nnode; /* not the peer-group itself but a peer in a peer-group */ - if (peer_group_active(peer)) + if (peer_group_active (peer)) { group = peer->group; @@ -4614,13 +4614,13 @@ peer_weight_unset (struct peer *peer, afi_t afi, safi_t safi) peer_on_policy_change (peer, afi, safi, 0); } - /* peer-group member updates. */ - group = peer->group; + /* peer-group member updates. */ + group = peer->group; if (group) { - for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) - { + for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) + { if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_WEIGHT)) { peer->weight[afi][safi] = 0; @@ -4628,7 +4628,7 @@ peer_weight_unset (struct peer *peer, afi_t afi, safi_t safi) peer_on_policy_change (peer, afi, safi, 0); } } - } + } } return 0; } diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index c198564d10..1b6d1312ac 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -2543,7 +2543,7 @@ register_add ( ************************************************************************/ DEFUN (add_vnc_prefix_cost_life_lnh, add_vnc_prefix_cost_life_lnh_cmd, - "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255> lifetime <1-4294967295> .LNH_OPTIONS", + "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> cost (0-255) lifetime (1-4294967295) .LNH_OPTIONS", "Add registration\n" "VNC Information\n" "Add/modify prefix related infomation\n" @@ -2569,7 +2569,7 @@ DEFUN (add_vnc_prefix_cost_life_lnh, DEFUN (add_vnc_prefix_life_cost_lnh, add_vnc_prefix_life_cost_lnh_cmd, - "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295> cost <0-255> .LNH_OPTIONS", + "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> lifetime (1-4294967295) cost (0-255) .LNH_OPTIONS", "Add registration\n" "VNC Information\n" "Add/modify prefix related infomation\n" @@ -2595,7 +2595,7 @@ DEFUN (add_vnc_prefix_life_cost_lnh, DEFUN (add_vnc_prefix_cost_lnh, add_vnc_prefix_cost_lnh_cmd, - "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255> .LNH_OPTIONS", + "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> cost (0-255) .LNH_OPTIONS", "Add registration\n" "VNC Information\n" "Add/modify prefix related infomation\n" @@ -2619,7 +2619,7 @@ DEFUN (add_vnc_prefix_cost_lnh, DEFUN (add_vnc_prefix_life_lnh, add_vnc_prefix_life_lnh_cmd, - "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295> .LNH_OPTIONS", + "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> lifetime (1-4294967295) .LNH_OPTIONS", "Add registration\n" "VNC Information\n" "Add/modify prefix related infomation\n" @@ -2643,7 +2643,7 @@ DEFUN (add_vnc_prefix_life_lnh, DEFUN (add_vnc_prefix_lnh, add_vnc_prefix_lnh_cmd, - "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) .LNH_OPTIONS", + "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> .LNH_OPTIONS", "Add registration\n" "VNC Information\n" "Add/modify prefix related infomation\n" @@ -2668,7 +2668,7 @@ DEFUN (add_vnc_prefix_lnh, ************************************************************************/ DEFUN (add_vnc_prefix_cost_life, add_vnc_prefix_cost_life_cmd, - "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255> lifetime <1-4294967295>", + "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> cost (0-255) lifetime (1-4294967295)", "Add registration\n" "VNC Information\n" "Add/modify prefix related infomation\n" @@ -2694,7 +2694,7 @@ DEFUN (add_vnc_prefix_cost_life, DEFUN (add_vnc_prefix_life_cost, add_vnc_prefix_life_cost_cmd, - "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295> cost <0-255>", + "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> lifetime (1-4294967295) cost (0-255)", "Add registration\n" "VNC Information\n" "Add/modify prefix related infomation\n" @@ -2720,7 +2720,7 @@ DEFUN (add_vnc_prefix_life_cost, DEFUN (add_vnc_prefix_cost, add_vnc_prefix_cost_cmd, - "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255>", + "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> cost (0-255)", "Add registration\n" "VNC Information\n" "Add/modify prefix related infomation\n" @@ -2744,7 +2744,7 @@ DEFUN (add_vnc_prefix_cost, DEFUN (add_vnc_prefix_life, add_vnc_prefix_life_cmd, - "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295>", + "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> lifetime (1-4294967295)", "Add registration\n" "VNC Information\n" "Add/modify prefix related infomation\n" @@ -2768,7 +2768,7 @@ DEFUN (add_vnc_prefix_life, DEFUN (add_vnc_prefix, add_vnc_prefix_cmd, - "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X)", + "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X>", "Add registration\n" "VNC Information\n" "Add/modify prefix related infomation\n" @@ -2793,7 +2793,7 @@ DEFUN (add_vnc_prefix, ************************************************************************/ DEFUN (add_vnc_mac_vni_prefix_cost_life, add_vnc_mac_vni_prefix_cost_life_cmd, - "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) prefix (A.B.C.D/M|X:X::X:X/M) cost <0-255> lifetime <1-4294967295>", + "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> prefix <A.B.C.D/M|X:X::X:X/M> cost (0-255) lifetime (1-4294967295)", "Add registration\n" "VNC Information\n" "Add/modify mac address infomation\n" @@ -2823,7 +2823,7 @@ DEFUN (add_vnc_mac_vni_prefix_cost_life, DEFUN (add_vnc_mac_vni_prefix_life, add_vnc_mac_vni_prefix_life_cmd, - "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) prefix (A.B.C.D/M|X:X::X:X/M) lifetime <1-4294967295>", + "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> prefix <A.B.C.D/M|X:X::X:X/M> lifetime (1-4294967295)", "Add registration\n" "VNC Information\n" "Add/modify mac address infomation\n" @@ -2850,7 +2850,7 @@ DEFUN (add_vnc_mac_vni_prefix_life, DEFUN (add_vnc_mac_vni_prefix_cost, add_vnc_mac_vni_prefix_cost_cmd, - "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) prefix (A.B.C.D/M|X:X::X:X/M) cost <0-255>", + "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> prefix <A.B.C.D/M|X:X::X:X/M> cost (0-255)", "Add registration\n" "VNC Information\n" "Add/modify mac address infomation\n" @@ -2876,7 +2876,7 @@ DEFUN (add_vnc_mac_vni_prefix_cost, DEFUN (add_vnc_mac_vni_prefix, add_vnc_mac_vni_prefix_cmd, - "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) prefix (A.B.C.D/M|X:X::X:X/M)", + "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> prefix <A.B.C.D/M|X:X::X:X/M>", "Add registration\n" "VNC Information\n" "Add/modify mac address infomation\n" @@ -2900,7 +2900,7 @@ DEFUN (add_vnc_mac_vni_prefix, DEFUN (add_vnc_mac_vni_cost_life, add_vnc_mac_vni_cost_life_cmd, - "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255> lifetime <1-4294967295>", + "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> cost (0-255) lifetime (1-4294967295)", "Add registration\n" "VNC Information\n" "Add/modify mac address infomation\n" @@ -2927,7 +2927,7 @@ DEFUN (add_vnc_mac_vni_cost_life, DEFUN (add_vnc_mac_vni_cost, add_vnc_mac_vni_cost_cmd, - "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255>", + "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> cost (0-255)", "Add registration\n" "VNC Information\n" "Add/modify mac address infomation\n" @@ -2951,7 +2951,7 @@ DEFUN (add_vnc_mac_vni_cost, DEFUN (add_vnc_mac_vni_life, add_vnc_mac_vni_life_cmd, - "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295>", + "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> lifetime (1-4294967295)", "Add registration\n" "VNC Information\n" "Add/modify mac address infomation\n" @@ -2976,7 +2976,7 @@ DEFUN (add_vnc_mac_vni_life, DEFUN (add_vnc_mac_vni, add_vnc_mac_vni_cmd, - "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X)", + "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X>", "Add registration\n" "VNC Information\n" "Add/modify mac address infomation\n" @@ -3720,7 +3720,7 @@ DEFUN (clear_vnc_nve_all, DEFUN (clear_vnc_nve_vn_un, clear_vnc_nve_vn_un_cmd, - "clear vnc nve vn (*|A.B.C.D|X:X::X:X) un (*|A.B.C.D|X:X::X:X)", + "clear vnc nve vn <*|A.B.C.D|X:X::X:X> un <*|A.B.C.D|X:X::X:X>", "clear\n" "VNC Information\n" "Clear prefix registration infomation\n" @@ -3750,7 +3750,7 @@ DEFUN (clear_vnc_nve_vn_un, DEFUN (clear_vnc_nve_un_vn, clear_vnc_nve_un_vn_cmd, - "clear vnc nve un (*|A.B.C.D|X:X::X:X) vn (*|A.B.C.D|X:X::X:X)", + "clear vnc nve un <*|A.B.C.D|X:X::X:X> vn <*|A.B.C.D|X:X::X:X>", "clear\n" "VNC Information\n" "Clear prefix registration infomation\n" @@ -3780,7 +3780,7 @@ DEFUN (clear_vnc_nve_un_vn, DEFUN (clear_vnc_nve_vn, clear_vnc_nve_vn_cmd, - "clear vnc nve vn (*|A.B.C.D|X:X::X:X)", + "clear vnc nve vn <*|A.B.C.D|X:X::X:X>", "clear\n" "VNC Information\n" "Clear prefix registration infomation\n" @@ -3805,7 +3805,7 @@ DEFUN (clear_vnc_nve_vn, DEFUN (clear_vnc_nve_un, clear_vnc_nve_un_cmd, - "clear vnc nve un (*|A.B.C.D|X:X::X:X)", + "clear vnc nve un <*|A.B.C.D|X:X::X:X>", "clear\n" "VNC Information\n" "Clear prefix registration infomation\n" @@ -3838,7 +3838,7 @@ DEFUN (clear_vnc_nve_un, */ DEFUN (clear_vnc_prefix_vn_un, clear_vnc_prefix_vn_un_cmd, - "clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) vn (*|A.B.C.D|X:X::X:X) un (*|A.B.C.D|X:X::X:X)", + "clear vnc prefix <*|A.B.C.D/M|X:X::X:X/M> vn <*|A.B.C.D|X:X::X:X> un <*|A.B.C.D|X:X::X:X>", "clear\n" "VNC Information\n" "Clear prefix registration infomation\n" @@ -3868,7 +3868,7 @@ DEFUN (clear_vnc_prefix_vn_un, DEFUN (clear_vnc_prefix_un_vn, clear_vnc_prefix_un_vn_cmd, - "clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) un (*|A.B.C.D|X:X::X:X) vn (*|A.B.C.D|X:X::X:X)", + "clear vnc prefix <*|A.B.C.D/M|X:X::X:X/M> un <*|A.B.C.D|X:X::X:X> vn <*|A.B.C.D|X:X::X:X>", "clear\n" "VNC Information\n" "Clear prefix registration infomation\n" @@ -3898,7 +3898,7 @@ DEFUN (clear_vnc_prefix_un_vn, DEFUN (clear_vnc_prefix_un, clear_vnc_prefix_un_cmd, - "clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) un (*|A.B.C.D|X:X::X:X)", + "clear vnc prefix <*|A.B.C.D/M|X:X::X:X/M> un <*|A.B.C.D|X:X::X:X>", "clear\n" "VNC Information\n" "Clear prefix registration infomation\n" @@ -3924,7 +3924,7 @@ DEFUN (clear_vnc_prefix_un, DEFUN (clear_vnc_prefix_vn, clear_vnc_prefix_vn_cmd, - "clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) vn (*|A.B.C.D|X:X::X:X)", + "clear vnc prefix <*|A.B.C.D/M|X:X::X:X/M> vn <*|A.B.C.D|X:X::X:X>", "clear\n" "VNC Information\n" "Clear prefix registration infomation\n" @@ -3950,7 +3950,7 @@ DEFUN (clear_vnc_prefix_vn, DEFUN (clear_vnc_prefix_all, clear_vnc_prefix_all_cmd, - "clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) *", + "clear vnc prefix <*|A.B.C.D/M|X:X::X:X/M> *", "clear\n" "VNC Information\n" "Clear prefix registration infomation\n" @@ -3980,7 +3980,7 @@ DEFUN (clear_vnc_prefix_all, */ DEFUN (clear_vnc_mac_vn_un, clear_vnc_mac_vn_un_cmd, - "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) vn (*|A.B.C.D|X:X::X:X) un (*|A.B.C.D|X:X::X:X)", + "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> vn <*|A.B.C.D|X:X::X:X> un <*|A.B.C.D|X:X::X:X>", "clear\n" "VNC Information\n" "Clear mac registration infomation\n" @@ -4015,7 +4015,7 @@ DEFUN (clear_vnc_mac_vn_un, DEFUN (clear_vnc_mac_un_vn, clear_vnc_mac_un_vn_cmd, - "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) un (*|A.B.C.D|X:X::X:X) vn (*|A.B.C.D|X:X::X:X)", + "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> un <*|A.B.C.D|X:X::X:X> vn <*|A.B.C.D|X:X::X:X>", "clear\n" "VNC Information\n" "Clear mac registration infomation\n" @@ -4049,7 +4049,7 @@ DEFUN (clear_vnc_mac_un_vn, DEFUN (clear_vnc_mac_un, clear_vnc_mac_un_cmd, - "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) un (*|A.B.C.D|X:X::X:X)", + "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> un <*|A.B.C.D|X:X::X:X>", "clear\n" "VNC Information\n" "Clear mac registration infomation\n" @@ -4078,7 +4078,7 @@ DEFUN (clear_vnc_mac_un, DEFUN (clear_vnc_mac_vn, clear_vnc_mac_vn_cmd, - "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) vn (*|A.B.C.D|X:X::X:X)", + "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> vn <*|A.B.C.D|X:X::X:X>", "clear\n" "VNC Information\n" "Clear mac registration infomation\n" @@ -4107,7 +4107,7 @@ DEFUN (clear_vnc_mac_vn, DEFUN (clear_vnc_mac_all, clear_vnc_mac_all_cmd, - "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) *", + "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> *", "clear\n" "VNC Information\n" "Clear mac registration infomation\n" @@ -4137,7 +4137,7 @@ DEFUN (clear_vnc_mac_all, DEFUN (clear_vnc_mac_vn_un_prefix, clear_vnc_mac_vn_un_prefix_cmd, - "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) vn (*|A.B.C.D|X:X::X:X) un (*|A.B.C.D|X:X::X:X) prefix (*|A.B.C.D/M|X:X::X:X/M)", + "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> vn <*|A.B.C.D|X:X::X:X> un <*|A.B.C.D|X:X::X:X> prefix <*|A.B.C.D/M|X:X::X:X/M>", "clear\n" "VNC Information\n" "Clear mac registration infomation\n" @@ -4176,7 +4176,7 @@ DEFUN (clear_vnc_mac_vn_un_prefix, DEFUN (clear_vnc_mac_un_vn_prefix, clear_vnc_mac_un_vn_prefix_cmd, - "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) un (*|A.B.C.D|X:X::X:X) vn (*|A.B.C.D|X:X::X:X) prefix (*|A.B.C.D/M|X:X::X:X/M) prefix (*|A.B.C.D/M|X:X::X:X/M)", + "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> un <*|A.B.C.D|X:X::X:X> vn <*|A.B.C.D|X:X::X:X> prefix <*|A.B.C.D/M|X:X::X:X/M> prefix <*|A.B.C.D/M|X:X::X:X/M>", "clear\n" "VNC Information\n" "Clear mac registration infomation\n" @@ -4210,7 +4210,7 @@ DEFUN (clear_vnc_mac_un_vn_prefix, DEFUN (clear_vnc_mac_un_prefix, clear_vnc_mac_un_prefix_cmd, - "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) un (*|A.B.C.D|X:X::X:X) prefix (*|A.B.C.D/M|X:X::X:X/M)", + "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> un <*|A.B.C.D|X:X::X:X> prefix <*|A.B.C.D/M|X:X::X:X/M>", "clear\n" "VNC Information\n" "Clear mac registration infomation\n" @@ -4240,7 +4240,7 @@ DEFUN (clear_vnc_mac_un_prefix, DEFUN (clear_vnc_mac_vn_prefix, clear_vnc_mac_vn_prefix_cmd, - "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) vn (*|A.B.C.D|X:X::X:X) prefix (*|A.B.C.D/M|X:X::X:X/M)", + "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> vn <*|A.B.C.D|X:X::X:X> prefix <*|A.B.C.D/M|X:X::X:X/M>", "clear\n" "VNC Information\n" "Clear mac registration infomation\n" @@ -4270,7 +4270,7 @@ DEFUN (clear_vnc_mac_vn_prefix, DEFUN (clear_vnc_mac_all_prefix, clear_vnc_mac_all_prefix_cmd, - "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) prefix (*|A.B.C.D/M|X:X::X:X/M)", + "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> prefix <*|A.B.C.D/M|X:X::X:X/M>", "clear\n" "VNC Information\n" "Clear mac registration infomation\n" @@ -4554,7 +4554,7 @@ DEFUN (vnc_show_nves, DEFUN (vnc_show_nves_ptct, vnc_show_nves_ptct_cmd, - "show vnc nves (vn|un) (A.B.C.D|X:X::X:X)", + "show vnc nves <vn|un> <A.B.C.D|X:X::X:X>", SHOW_STR VNC_SHOW_STR "List known NVEs\n" @@ -4636,7 +4636,7 @@ rfapi_show_registrations ( DEFUN (vnc_show_registrations_pfx, vnc_show_registrations_pfx_cmd, - "show vnc registrations ([A.B.C.D/M]|[X:X::X:X/M]|[YY:YY:YY:YY:YY:YY])", + "show vnc registrations <[A.B.C.D/M]|[X:X::X:X/M]|[YY:YY:YY:YY:YY:YY]>", SHOW_STR VNC_SHOW_STR "List active prefix registrations\n" @@ -4748,8 +4748,8 @@ ALIAS (vnc_show_registrations_some_pfx, "show only remote registrations\n") DEFUN (vnc_show_responses_pfx, - vnc_show_responses_pfx_cmd, - "show vnc responses ([A.B.C.D/M]|[X:X::X:X/M]|[YY:YY:YY:YY:YY:YY])", + vnc_show_responses_pfx_cmd, + "show vnc responses <[A.B.C.D/M]|[X:X::X:X/M]|[YY:YY:YY:YY:YY:YY]>", SHOW_STR VNC_SHOW_STR "List recent query responses\n" @@ -4789,8 +4789,8 @@ ALIAS (vnc_show_responses_pfx, "List recent query responses\n") DEFUN (vnc_show_responses_some_pfx, - vnc_show_responses_some_pfx_cmd, - "show vnc responses (active|removed) ([A.B.C.D/M]|[X:X::X:X/M]|[YY:YY:YY:YY:YY:YY])", + vnc_show_responses_some_pfx_cmd, + "show vnc responses <active|removed> <[A.B.C.D/M]|[X:X::X:X/M]|[YY:YY:YY:YY:YY:YY]>", SHOW_STR VNC_SHOW_STR "List recent query responses\n" @@ -4855,7 +4855,7 @@ ALIAS (vnc_show_responses_some_pfx, DEFUN (show_vnc_queries_pfx, show_vnc_queries_pfx_cmd, - "show vnc queries ([A.B.C.D/M]|[X:X::X:X/M]|[YY:YY:YY:YY:YY:YY])", + "show vnc queries <[A.B.C.D/M]|[X:X::X:X/M]|[YY:YY:YY:YY:YY:YY]>", SHOW_STR VNC_SHOW_STR "List active queries\n" diff --git a/bgpd/rfapi/vnc_debug.c b/bgpd/rfapi/vnc_debug.c index eaa8c56ee9..5db6f558b8 100644 --- a/bgpd/rfapi/vnc_debug.c +++ b/bgpd/rfapi/vnc_debug.c @@ -57,7 +57,7 @@ struct vnc_debug vncdebug[] = ***********************************************************************/ DEFUN (debug_bgp_vnc, debug_bgp_vnc_cmd, - "debug bgp vnc (rfapi-query|import-bi-attach|import-del-remote)", + "debug bgp vnc <rfapi-query|import-bi-attach|import-del-remote>", DEBUG_STR BGP_STR VNC_STR @@ -91,7 +91,7 @@ DEFUN (debug_bgp_vnc, DEFUN (no_debug_bgp_vnc, no_debug_bgp_vnc_cmd, - "no debug bgp vnc (rfapi-query|import-bi-attach|import-del-remote)", + "no debug bgp vnc <rfapi-query|import-bi-attach|import-del-remote>", NO_STR DEBUG_STR BGP_STR diff --git a/configure.ac b/configure.ac index 4032a447cc..afb0731db5 100755 --- a/configure.ac +++ b/configure.ac @@ -1591,6 +1591,17 @@ AC_CHECK_DECL(CLOCK_MONOTONIC, AC_DEFINE(HAVE_CLOCK_MONOTONIC,, Have monotonic clock) ], [AC_MSG_RESULT(no)], [QUAGGA_INCLUDES]) +dnl -------------------------------------- +dnl checking for flex and bison +dnl -------------------------------------- +AM_PROG_LEX +if test "x$LEX" != xflex; then + LEX="$SHELL $missing_dir/missing flex" + AC_SUBST([LEX_OUTPUT_ROOT], [lex.yy]) + AC_SUBST([LEXLIB], ['']) +fi +AC_PROG_YACC + dnl ------------------- dnl capabilities checks dnl ------------------- diff --git a/debian/control b/debian/control index dd0013e82f..3bd4e21a9d 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: net Priority: optional Maintainer: Christian Hammers <ch@debian.org> Uploaders: Florian Weimer <fw@debian.org> -Build-Depends: debhelper (>= 7.0.50~), libncurses5-dev, libreadline-dev, texlive-latex-base, texlive-generic-recommended, libpam0g-dev | libpam-dev, libcap-dev, texinfo (>= 4.7), imagemagick, ghostscript, groff, po-debconf, autotools-dev, hardening-wrapper, libpcre3-dev, gawk, chrpath, libsnmp-dev, git, dh-autoreconf, libjson0, libjson0-dev, dh-systemd, libsystemd-dev, python-ipaddr +Build-Depends: debhelper (>= 7.0.50~), libncurses5-dev, libreadline-dev, texlive-latex-base, texlive-generic-recommended, libpam0g-dev | libpam-dev, libcap-dev, texinfo (>= 4.7), imagemagick, ghostscript, groff, po-debconf, autotools-dev, hardening-wrapper, libpcre3-dev, gawk, chrpath, libsnmp-dev, git, dh-autoreconf, libjson0, libjson0-dev, dh-systemd, libsystemd-dev, python-ipaddr, bison, flex Standards-Version: 3.9.6 Homepage: http://www.quagga.net/ XS-Testsuite: autopkgtest diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c index 21daaa7794..045c7daa32 100644 --- a/isisd/isis_redist.c +++ b/isisd/isis_redist.c @@ -540,8 +540,7 @@ isis_redist_area_finish(struct isis_area *area) DEFUN (isis_redistribute, isis_redistribute_cmd, - "redistribute (ipv4|ipv6) " QUAGGA_REDIST_STR_ISISD - " (level-1|level-2) {metric <0-16777215>|route-map WORD}", + "redistribute <ipv4|ipv6> <kernel|connected|static|rip|ripng|ospf|ospf6|bgp|pim|table> <level-1|level-2> [<metric (0-16777215)|route-map WORD>]", REDIST_STR "Redistribute IPv4 routes\n" "Redistribute IPv6 routes\n" @@ -553,18 +552,19 @@ DEFUN (isis_redistribute, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_afi = 1; + int idx_protocol = 2; + int idx_level = 3; + int idx_metric_rmap = 4; VTY_DECLVAR_CONTEXT (isis_area, area); int family; int afi; int type; int level; unsigned long metric; - const char *routemap; + const char *routemap = NULL; - if (argc < 5) - return CMD_WARNING; - - family = str2family(argv[0]); + family = str2family(argv[idx_afi]->arg); if (family < 0) return CMD_WARNING; @@ -572,13 +572,13 @@ DEFUN (isis_redistribute, if (!afi) return CMD_WARNING; - type = proto_redistnum(afi, argv[1]); + type = proto_redistnum(afi, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_ISIS) return CMD_WARNING; - if (!strcmp("level-1", argv[2])) + if (!strcmp("level-1", argv[idx_level]->arg)) level = 1; - else if (!strcmp("level-2", argv[2])) + else if (!strcmp("level-2", argv[idx_level]->arg)) level = 2; else return CMD_WARNING; @@ -589,28 +589,28 @@ DEFUN (isis_redistribute, return CMD_WARNING; } - if (argv[3]) + if (strmatch(argv[idx_metric_rmap]->text, "metric")) { char *endp; - metric = strtoul(argv[3], &endp, 10); - if (argv[3][0] == '\0' || *endp != '\0') + metric = strtoul(argv[idx_metric_rmap + 1]->arg, &endp, 10); + routemap = NULL; + + if (argv[idx_metric_rmap]->arg[0] == '\0' || *endp != '\0') return CMD_WARNING; } else { + routemap = argv[idx_metric_rmap + 1]->arg; metric = 0xffffffff; } - routemap = argv[4]; - isis_redist_set(area, level, family, type, metric, routemap, 0); return 0; } DEFUN (no_isis_redistribute, no_isis_redistribute_cmd, - "no redistribute (ipv4|ipv6) " QUAGGA_REDIST_STR_ISISD - " (level-1|level-2)", + "no redistribute <ipv4|ipv6> <kernel|connected|static|rip|ripng|ospf|ospf6|bgp|pim|table> <level-1|level-2>", NO_STR REDIST_STR "Redistribute IPv4 routes\n" @@ -619,16 +619,16 @@ DEFUN (no_isis_redistribute, "Redistribute into level-1\n" "Redistribute into level-2\n") { + int idx_afi = 2; + int idx_protocol = 3; + int idx_level = 4; VTY_DECLVAR_CONTEXT (isis_area, area); int type; int level; int family; int afi; - if (argc < 3) - return CMD_WARNING; - - family = str2family(argv[0]); + family = str2family(argv[idx_afi]->arg); if (family < 0) return CMD_WARNING; @@ -636,16 +636,11 @@ DEFUN (no_isis_redistribute, if (!afi) return CMD_WARNING; - type = proto_redistnum(afi, argv[1]); + type = proto_redistnum(afi, argv[idx_protocol]->text); if (type < 0 || type == ZEBRA_ROUTE_ISIS) return CMD_WARNING; - if (!strcmp("level-1", argv[2])) - level = 1; - else if (!strcmp("level-2", argv[2])) - level = 2; - else - return CMD_WARNING; + level = strmatch ("level-1", argv[idx_level]->text) ? 1 : 2; isis_redist_unset(area, level, family, type); return 0; @@ -653,8 +648,7 @@ DEFUN (no_isis_redistribute, DEFUN (isis_default_originate, isis_default_originate_cmd, - "default-information originate (ipv4|ipv6) (level-1|level-2) " - "{always|metric <0-16777215>|route-map WORD}", + "default-information originate <ipv4|ipv6> <level-1|level-2> [<always|metric (0-16777215)|route-map WORD>]", "Control distribution of default information\n" "Distribute a default route\n" "Distribute default route for IPv4\n" @@ -667,26 +661,21 @@ DEFUN (isis_default_originate, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_afi = 2; + int idx_level = 3; + int idx_metric_rmap = 4; VTY_DECLVAR_CONTEXT (isis_area, area); int family; - int originate_type; + int originate_type = DEFAULT_ORIGINATE; int level; - unsigned long metric; - const char *routemap; - - if (argc < 5) - return CMD_WARNING; + unsigned long metric = 0xffffffff; + const char *routemap = NULL; - family = str2family(argv[0]); + family = str2family(argv[idx_afi]->text); if (family < 0) return CMD_WARNING; - if (!strcmp("level-1", argv[1])) - level = 1; - else if (!strcmp("level-2", argv[1])) - level = 2; - else - return CMD_WARNING; + level = strmatch ("level-1", argv[idx_level]->text) ? 1 : 2; if ((area->is_type & level) != level) { @@ -694,10 +683,15 @@ DEFUN (isis_default_originate, return CMD_WARNING; } - if (argv[2] && *argv[2] != '\0') - originate_type = DEFAULT_ORIGINATE_ALWAYS; - else - originate_type = DEFAULT_ORIGINATE; + if (argc > 4) + { + if (strmatch (argv[idx_metric_rmap]->text, "always")) + originate_type = DEFAULT_ORIGINATE_ALWAYS; + else if (strmatch(argv[idx_metric_rmap]->text, "metric")) + metric = strtoul(argv[idx_metric_rmap + 1]->arg, NULL, 10); + else + routemap = argv[idx_metric_rmap + 1]->arg; + } if (family == AF_INET6 && originate_type != DEFAULT_ORIGINATE_ALWAYS) { @@ -705,27 +699,13 @@ DEFUN (isis_default_originate, vty_out(vty, "so use with care or use default-originate always.%s", VTY_NEWLINE); } - if (argv[3]) - { - char *endp; - metric = strtoul(argv[3], &endp, 10); - if (argv[3][0] == '\0' || *endp != '\0') - return CMD_WARNING; - } - else - { - metric = 0xffffffff; - } - - routemap = argv[4]; - isis_redist_set(area, level, family, DEFAULT_ROUTE, metric, routemap, originate_type); return 0; } DEFUN (no_isis_default_originate, no_isis_default_originate_cmd, - "no default-information originate (ipv4|ipv6) (level-1|level-2)", + "no default-information originate <ipv4|ipv6> <level-1|level-2>", NO_STR "Control distribution of default information\n" "Distribute a default route\n" @@ -734,20 +714,19 @@ DEFUN (no_isis_default_originate, "Distribute default route into level-1\n" "Distribute default route into level-2\n") { + int idx_afi = 3; + int idx_level = 4; VTY_DECLVAR_CONTEXT (isis_area, area); int family; int level; - if (argc < 2) - return CMD_WARNING; - - family = str2family(argv[0]); + family = str2family(argv[idx_afi]->text); if (family < 0) return CMD_WARNING; - if (!strcmp("level-1", argv[1])) + if (strmatch ("level-1", argv[idx_level]->text)) level = 1; - else if (!strcmp("level-2", argv[1])) + else if (strmatch ("level-2", argv[idx_level]->text)) level = 2; else return CMD_WARNING; diff --git a/isisd/isis_routemap.c b/isisd/isis_routemap.c index 070965b2df..61f3315f08 100644 --- a/isisd/isis_routemap.c +++ b/isisd/isis_routemap.c @@ -250,314 +250,29 @@ static struct route_map_rule_cmd route_set_metric_cmd = route_set_metric_free }; -/* ------------------------------------------------------------*/ - -static int -isis_route_match_add(struct vty *vty, - const char *command, const char *arg) -{ - VTY_DECLVAR_CONTEXT (route_map_index, index); - int ret; - - ret = route_map_add_match (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - -static int -isis_route_match_delete(struct vty *vty, - const char *command, const char *arg) -{ - VTY_DECLVAR_CONTEXT (route_map_index, index); - int ret; - - ret = route_map_delete_match (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - -static int -isis_route_set_add(struct vty *vty, - const char *command, const char *arg) -{ - VTY_DECLVAR_CONTEXT (route_map_index, index); - int ret; - - ret = route_map_add_set(index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - - return CMD_SUCCESS; -} - -static int -isis_route_set_delete (struct vty *vty, - const char *command, const char *arg) -{ - VTY_DECLVAR_CONTEXT (route_map_index, index); - int ret; - - ret = route_map_delete_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - - return CMD_SUCCESS; -} - -/* ------------------------------------------------------------*/ - -DEFUN (match_ip_address, - match_ip_address_cmd, - "match ip address (<1-199>|<1300-2699>|WORD)", - MATCH_STR - IP_STR - "Match address of route\n" - "IP access-list number\n" - "IP access-list number (expanded range)\n" - "IP Access-list name\n") -{ - return isis_route_match_add(vty, "ip address", argv[0]); -} - -DEFUN (no_match_ip_address, - no_match_ip_address_val_cmd, - "no match ip address (<1-199>|<1300-2699>|WORD)", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n" - "IP access-list number\n" - "IP access-list number (expanded range)\n" - "IP Access-list name\n") -{ - if (argc == 0) - return isis_route_match_delete(vty, "ip address", NULL); - return isis_route_match_delete(vty, "ip address", argv[0]); -} - -ALIAS (no_match_ip_address, - no_match_ip_address_cmd, - "no match ip address", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n") - -/* ------------------------------------------------------------*/ - -DEFUN (match_ip_address_prefix_list, - match_ip_address_prefix_list_cmd, - "match ip address prefix-list WORD", - MATCH_STR - IP_STR - "Match address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") -{ - return isis_route_match_add(vty, "ip address prefix-list", argv[0]); -} - -DEFUN (no_match_ip_address_prefix_list, - no_match_ip_address_prefix_list_cmd, - "no match ip address prefix-list", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n" - "Match entries of prefix-lists\n") -{ - if (argc == 0) - return isis_route_match_delete (vty, "ip address prefix-list", NULL); - return isis_route_match_delete (vty, "ip address prefix-list", argv[0]); -} - -ALIAS (no_match_ip_address_prefix_list, - no_match_ip_address_prefix_list_val_cmd, - "no match ip address prefix-list WORD", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") - -/* ------------------------------------------------------------*/ - -DEFUN (match_ipv6_address, - match_ipv6_address_cmd, - "match ipv6 address WORD", - MATCH_STR - IPV6_STR - "Match IPv6 address of route\n" - "IPv6 access-list name\n") -{ - return isis_route_match_add(vty, "ipv6 address", argv[0]); -} - -DEFUN (no_match_ipv6_address, - no_match_ipv6_address_val_cmd, - "no match ipv6 address WORD", - NO_STR - MATCH_STR - IPV6_STR - "Match IPv6 address of route\n" - "IPv6 access-list name\n") -{ - if (argc == 0) - return isis_route_match_delete(vty, "ipv6 address", NULL); - return isis_route_match_delete(vty, "ipv6 address", argv[0]); -} - -ALIAS (no_match_ipv6_address, - no_match_ipv6_address_cmd, - "no match ipv6 address", - NO_STR - MATCH_STR - IPV6_STR - "Match IPv6 address of route\n") - -/* ------------------------------------------------------------*/ - -DEFUN (match_ipv6_address_prefix_list, - match_ipv6_address_prefix_list_cmd, - "match ipv6 address prefix-list WORD", - MATCH_STR - IPV6_STR - "Match address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") -{ - return isis_route_match_add(vty, "ipv6 address prefix-list", argv[0]); -} - -DEFUN (no_match_ipv6_address_prefix_list, - no_match_ipv6_address_prefix_list_cmd, - "no match ipv6 address prefix-list", - NO_STR - MATCH_STR - IPV6_STR - "Match address of route\n" - "Match entries of prefix-lists\n") +void +isis_route_map_init(void) { - if (argc == 0) - return isis_route_match_delete (vty, "ipv6 address prefix-list", NULL); - return isis_route_match_delete (vty, "ipv6 address prefix-list", argv[0]); -} + route_map_init(); -ALIAS (no_match_ipv6_address_prefix_list, - no_match_ipv6_address_prefix_list_val_cmd, - "no match ipv6 address prefix-list WORD", - NO_STR - MATCH_STR - IPV6_STR - "Match address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") + route_map_match_ip_address_hook (generic_match_add); + route_map_no_match_ip_address_hook (generic_match_delete); -/* ------------------------------------------------------------*/ + route_map_match_ip_address_prefix_list_hook (generic_match_add); + route_map_no_match_ip_address_prefix_list_hook (generic_match_delete); -/* set metric already exists e.g. in the ospf routemap. vtysh doesn't cope well with different - * commands at the same node, therefore add set metric with the same 32-bit range as ospf and - * verify that the input is a valid isis metric */ -DEFUN (set_metric, - set_metric_cmd, - "set metric <0-4294967295>", - SET_STR - "Metric vale for destination routing protocol\n" - "Metric value\n") -{ - return isis_route_set_add(vty, "metric", argv[0]); -} + route_map_match_ipv6_address_hook (generic_match_add); + route_map_no_match_ipv6_address_hook (generic_match_delete); -DEFUN (no_set_metric, - no_set_metric_val_cmd, - "no set metric <0-4294967295>", - NO_STR - SET_STR - "Metric value for destination routing protocol\n" - "Metric value\n") -{ - if (argc == 0) - return isis_route_set_delete(vty, "metric", NULL); - return isis_route_set_delete(vty, "metric", argv[0]); -} + route_map_match_ipv6_address_prefix_list_hook (generic_match_add); + route_map_no_match_ipv6_address_prefix_list_hook (generic_match_delete); -ALIAS (no_set_metric, - no_set_metric_cmd, - "no set metric", - NO_STR - SET_STR - "Metric vale for destination routing protocol\n"); - -void -isis_route_map_init(void) -{ - route_map_init(); + route_map_set_metric_hook (generic_set_add); + route_map_no_set_metric_hook (generic_set_delete); route_map_install_match(&route_match_ip_address_cmd); - install_element(RMAP_NODE, &match_ip_address_cmd); - install_element(RMAP_NODE, &no_match_ip_address_val_cmd); - install_element(RMAP_NODE, &no_match_ip_address_cmd); - route_map_install_match(&route_match_ip_address_prefix_list_cmd); - install_element(RMAP_NODE, &match_ip_address_prefix_list_cmd); - install_element(RMAP_NODE, &no_match_ip_address_prefix_list_val_cmd); - install_element(RMAP_NODE, &no_match_ip_address_prefix_list_cmd); - route_map_install_match(&route_match_ipv6_address_cmd); - install_element(RMAP_NODE, &match_ipv6_address_cmd); - install_element(RMAP_NODE, &no_match_ipv6_address_val_cmd); - install_element(RMAP_NODE, &no_match_ipv6_address_cmd); - route_map_install_match(&route_match_ipv6_address_prefix_list_cmd); - install_element(RMAP_NODE, &match_ipv6_address_prefix_list_cmd); - install_element(RMAP_NODE, &no_match_ipv6_address_prefix_list_val_cmd); - install_element(RMAP_NODE, &no_match_ipv6_address_prefix_list_cmd); - route_map_install_set(&route_set_metric_cmd); - install_element(RMAP_NODE, &set_metric_cmd); - install_element(RMAP_NODE, &no_set_metric_val_cmd); - install_element(RMAP_NODE, &no_set_metric_cmd); } diff --git a/isisd/isis_te.c b/isisd/isis_te.c index 34300669b0..d3605f448c 100644 --- a/isisd/isis_te.c +++ b/isisd/isis_te.c @@ -1163,11 +1163,12 @@ DEFUN (isis_mpls_te_router_addr, "Stable IP address of the advertising router\n" "MPLS-TE router address in IPv4 address format\n") { + int idx_ipv4 = 2; struct in_addr value; struct listnode *node; struct isis_area *area; - if (! inet_aton (argv[0], &value)) + if (! inet_aton (argv[idx_ipv4]->arg, &value)) { vty_out (vty, "Please specify Router-Addr by A.B.C.D%s", VTY_NEWLINE); return CMD_WARNING; @@ -1190,7 +1191,7 @@ DEFUN (isis_mpls_te_router_addr, DEFUN (isis_mpls_te_inter_as, isis_mpls_te_inter_as_cmd, - "mpls-te inter-as (level-1|level-1-2|level-2-only)", + "mpls-te inter-as <level-1|level-1-2|level-2-only>", MPLS_TE_STR "Configure MPLS-TE Inter-AS support\n" "AREA native mode self originate INTER-AS LSP with L1 only flooding scope)\n" @@ -1317,11 +1318,12 @@ DEFUN (show_isis_mpls_te_interface, "Interface information\n" "Interface name\n") { + int idx_interface = 4; struct interface *ifp; struct listnode *node; /* Show All Interfaces. */ - if (argc == 0) + if (argc == 4) { for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) show_mpls_te_sub (vty, ifp); @@ -1329,7 +1331,7 @@ DEFUN (show_isis_mpls_te_interface, /* Interface name is specified. */ else { - if ((ifp = if_lookup_by_name (argv[0])) == NULL) + if ((ifp = if_lookup_by_name (argv[idx_interface]->arg)) == NULL) vty_out (vty, "No such interface name%s", VTY_NEWLINE); else show_mpls_te_sub (vty, ifp); diff --git a/isisd/isis_vty.c b/isisd/isis_vty.c index 12ef682c17..df13696b20 100644 --- a/isisd/isis_vty.c +++ b/isisd/isis_vty.c @@ -54,17 +54,19 @@ isis_circuit_lookup (struct vty *vty) DEFUN (ip_router_isis, ip_router_isis_cmd, - "(ip|ipv6) router isis WORD", + "ip router isis WORD", "Interface Internet Protocol config commands\n" "IP router interface commands\n" "IS-IS Routing for IP\n" "Routing process tag\n") { + int idx_afi = 0; + int idx_word = 3; VTY_DECLVAR_CONTEXT (interface, ifp); struct isis_circuit *circuit; struct isis_area *area; - const char *af = argv[0]; - const char *area_tag = argv[1]; + const char *af = argv[idx_afi]->arg; + const char *area_tag = argv[idx_word]->arg; /* Prevent more than one area per circuit */ circuit = circuit_scan_by_ifp (ifp); @@ -102,26 +104,39 @@ DEFUN (ip_router_isis, return CMD_SUCCESS; } +DEFUN (ip6_router_isis, + ip6_router_isis_cmd, + "ipv6 router isis WORD", + "Interface Internet Protocol config commands\n" + "IP router interface commands\n" + "IS-IS Routing for IP\n" + "Routing process tag\n") +{ + return ip_router_isis (self, vty, argc, argv); +} + DEFUN (no_ip_router_isis, no_ip_router_isis_cmd, - "no (ip|ipv6) router isis WORD", + "no <ip|ipv6> router isis WORD", NO_STR "Interface Internet Protocol config commands\n" "IP router interface commands\n" "IS-IS Routing for IP\n" "Routing process tag\n") { + int idx_afi = 1; + int idx_word = 4; VTY_DECLVAR_CONTEXT (interface, ifp); struct isis_area *area; struct isis_circuit *circuit; - const char *af = argv[0]; - const char *area_tag = argv[1]; + const char *af = argv[idx_afi]->arg; + const char *area_tag = argv[idx_word]->arg; area = isis_area_lookup (area_tag); if (!area) { vty_out (vty, "Can't find ISIS instance %s%s", - argv[0], VTY_NEWLINE); + argv[idx_afi]->arg, VTY_NEWLINE); return CMD_ERR_NO_MATCH; } @@ -181,19 +196,20 @@ DEFUN (no_isis_passive, DEFUN (isis_circuit_type, isis_circuit_type_cmd, - "isis circuit-type (level-1|level-1-2|level-2-only)", + "isis circuit-type <level-1|level-1-2|level-2-only>", "IS-IS commands\n" "Configure circuit type for interface\n" "Level-1 only adjacencies are formed\n" "Level-1-2 adjacencies are formed\n" "Level-2 only adjacencies are formed\n") { + int idx_level = 2; int is_type; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - is_type = string2circuit_t (argv[0]); + is_type = string2circuit_t (argv[idx_level]->arg); if (!is_type) { vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE); @@ -215,7 +231,7 @@ DEFUN (isis_circuit_type, DEFUN (no_isis_circuit_type, no_isis_circuit_type_cmd, - "no isis circuit-type (level-1|level-1-2|level-2-only)", + "no isis circuit-type <level-1|level-1-2|level-2-only>", NO_STR "IS-IS commands\n" "Configure circuit type for interface\n" @@ -287,22 +303,24 @@ DEFUN (no_isis_network, DEFUN (isis_passwd, isis_passwd_cmd, - "isis password (md5|clear) WORD", + "isis password <md5|clear> WORD", "IS-IS commands\n" "Configure the authentication password for a circuit\n" "HMAC-MD5 authentication\n" "Cleartext password\n" "Circuit password\n") { + int idx_encryption = 2; + int idx_word = 3; struct isis_circuit *circuit = isis_circuit_lookup (vty); int rv; if (!circuit) return CMD_ERR_NO_MATCH; - if (argv[0][0] == 'm') - rv = isis_circuit_passwd_hmac_md5_set(circuit, argv[1]); + if (argv[idx_encryption]->arg[0] == 'm') + rv = isis_circuit_passwd_hmac_md5_set(circuit, argv[idx_word]->arg); else - rv = isis_circuit_passwd_cleartext_set(circuit, argv[1]); + rv = isis_circuit_passwd_cleartext_set(circuit, argv[idx_word]->arg); if (rv) { vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE); @@ -314,10 +332,13 @@ DEFUN (isis_passwd, DEFUN (no_isis_passwd, no_isis_passwd_cmd, - "no isis password", + "no isis password [<md5|clear> WORD]", NO_STR "IS-IS commands\n" - "Configure the authentication password for a circuit\n") + "Configure the authentication password for a circuit\n" + "HMAC-MD5 authentication\n" + "Cleartext password\n" + "Circuit password\n") { struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) @@ -328,29 +349,21 @@ DEFUN (no_isis_passwd, return CMD_SUCCESS; } -ALIAS (no_isis_passwd, - no_isis_passwd_arg_cmd, - "no isis password (md5|clear) WORD", - NO_STR - "IS-IS commands\n" - "Configure the authentication password for a circuit\n" - "HMAC-MD5 authentication\n" - "Cleartext password\n" - "Circuit password\n") DEFUN (isis_priority, isis_priority_cmd, - "isis priority <0-127>", + "isis priority (0-127)", "IS-IS commands\n" "Set priority for Designated Router election\n" "Priority value\n") { + int idx_number = 2; int prio; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - prio = atoi (argv[0]); + prio = atoi (argv[idx_number]->arg); if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) { vty_out (vty, "Invalid priority %d - should be <0-127>%s", @@ -366,10 +379,11 @@ DEFUN (isis_priority, DEFUN (no_isis_priority, no_isis_priority_cmd, - "no isis priority", + "no isis priority [(0-127)]", NO_STR "IS-IS commands\n" - "Set priority for Designated Router election\n") + "Set priority for Designated Router election\n" + "Priority value\n") { struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) @@ -381,28 +395,22 @@ DEFUN (no_isis_priority, return CMD_SUCCESS; } -ALIAS (no_isis_priority, - no_isis_priority_arg_cmd, - "no isis priority <0-127>", - NO_STR - "IS-IS commands\n" - "Set priority for Designated Router election\n" - "Priority value\n") DEFUN (isis_priority_l1, isis_priority_l1_cmd, - "isis priority <0-127> level-1", + "isis priority (0-127) level-1", "IS-IS commands\n" "Set priority for Designated Router election\n" "Priority value\n" "Specify priority for level-1 routing\n") { + int idx_number = 2; int prio; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - prio = atoi (argv[0]); + prio = atoi (argv[idx_number]->arg); if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) { vty_out (vty, "Invalid priority %d - should be <0-127>%s", @@ -417,10 +425,11 @@ DEFUN (isis_priority_l1, DEFUN (no_isis_priority_l1, no_isis_priority_l1_cmd, - "no isis priority level-1", + "no isis priority [(0-127)] level-1", NO_STR "IS-IS commands\n" "Set priority for Designated Router election\n" + "Priority value\n" "Specify priority for level-1 routing\n") { struct isis_circuit *circuit = isis_circuit_lookup (vty); @@ -432,29 +441,22 @@ DEFUN (no_isis_priority_l1, return CMD_SUCCESS; } -ALIAS (no_isis_priority_l1, - no_isis_priority_l1_arg_cmd, - "no isis priority <0-127> level-1", - NO_STR - "IS-IS commands\n" - "Set priority for Designated Router election\n" - "Priority value\n" - "Specify priority for level-1 routing\n") DEFUN (isis_priority_l2, isis_priority_l2_cmd, - "isis priority <0-127> level-2", + "isis priority (0-127) level-2", "IS-IS commands\n" "Set priority for Designated Router election\n" "Priority value\n" "Specify priority for level-2 routing\n") { + int idx_number = 2; int prio; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - prio = atoi (argv[0]); + prio = atoi (argv[idx_number]->arg); if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) { vty_out (vty, "Invalid priority %d - should be <0-127>%s", @@ -469,10 +471,11 @@ DEFUN (isis_priority_l2, DEFUN (no_isis_priority_l2, no_isis_priority_l2_cmd, - "no isis priority level-2", + "no isis priority [(0-127)] level-2", NO_STR "IS-IS commands\n" "Set priority for Designated Router election\n" + "Priority value\n" "Specify priority for level-2 routing\n") { struct isis_circuit *circuit = isis_circuit_lookup (vty); @@ -484,29 +487,22 @@ DEFUN (no_isis_priority_l2, return CMD_SUCCESS; } -ALIAS (no_isis_priority_l2, - no_isis_priority_l2_arg_cmd, - "no isis priority <0-127> level-2", - NO_STR - "IS-IS commands\n" - "Set priority for Designated Router election\n" - "Priority value\n" - "Specify priority for level-2 routing\n") /* Metric command */ DEFUN (isis_metric, isis_metric_cmd, - "isis metric <0-16777215>", + "isis metric (0-16777215)", "IS-IS commands\n" "Set default metric for circuit\n" "Default metric value\n") { + int idx_number = 2; int met; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - met = atoi (argv[0]); + met = atoi (argv[idx_number]->arg); /* RFC3787 section 5.1 */ if (circuit->area && circuit->area->oldmetric == 1 && @@ -533,12 +529,14 @@ DEFUN (isis_metric, return CMD_SUCCESS; } + DEFUN (no_isis_metric, no_isis_metric_cmd, - "no isis metric", + "no isis metric [(0-16777215)]", NO_STR "IS-IS commands\n" - "Set default metric for circuit\n") + "Set default metric for circuit\n" + "Default metric value\n") { struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) @@ -549,28 +547,22 @@ DEFUN (no_isis_metric, return CMD_SUCCESS; } -ALIAS (no_isis_metric, - no_isis_metric_arg_cmd, - "no isis metric <0-16777215>", - NO_STR - "IS-IS commands\n" - "Set default metric for circuit\n" - "Default metric value\n") DEFUN (isis_metric_l1, isis_metric_l1_cmd, - "isis metric <0-16777215> level-1", + "isis metric (0-16777215) level-1", "IS-IS commands\n" "Set default metric for circuit\n" "Default metric value\n" "Specify metric for level-1 routing\n") { + int idx_number = 2; int met; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - met = atoi (argv[0]); + met = atoi (argv[idx_number]->arg); /* RFC3787 section 5.1 */ if (circuit->area && circuit->area->oldmetric == 1 && @@ -596,12 +588,14 @@ DEFUN (isis_metric_l1, return CMD_SUCCESS; } + DEFUN (no_isis_metric_l1, no_isis_metric_l1_cmd, - "no isis metric level-1", + "no isis metric [(0-16777215)] level-1", NO_STR "IS-IS commands\n" "Set default metric for circuit\n" + "Default metric value\n" "Specify metric for level-1 routing\n") { struct isis_circuit *circuit = isis_circuit_lookup (vty); @@ -612,29 +606,22 @@ DEFUN (no_isis_metric_l1, return CMD_SUCCESS; } -ALIAS (no_isis_metric_l1, - no_isis_metric_l1_arg_cmd, - "no isis metric <0-16777215> level-1", - NO_STR - "IS-IS commands\n" - "Set default metric for circuit\n" - "Default metric value\n" - "Specify metric for level-1 routing\n") DEFUN (isis_metric_l2, isis_metric_l2_cmd, - "isis metric <0-16777215> level-2", + "isis metric (0-16777215) level-2", "IS-IS commands\n" "Set default metric for circuit\n" "Default metric value\n" "Specify metric for level-2 routing\n") { + int idx_number = 2; int met; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - met = atoi (argv[0]); + met = atoi (argv[idx_number]->arg); /* RFC3787 section 5.1 */ if (circuit->area && circuit->area->oldmetric == 1 && @@ -660,12 +647,14 @@ DEFUN (isis_metric_l2, return CMD_SUCCESS; } + DEFUN (no_isis_metric_l2, no_isis_metric_l2_cmd, - "no isis metric level-2", + "no isis metric [(0-16777215)] level-2", NO_STR "IS-IS commands\n" "Set default metric for circuit\n" + "Default metric value\n" "Specify metric for level-2 routing\n") { struct isis_circuit *circuit = isis_circuit_lookup (vty); @@ -676,30 +665,23 @@ DEFUN (no_isis_metric_l2, return CMD_SUCCESS; } -ALIAS (no_isis_metric_l2, - no_isis_metric_l2_arg_cmd, - "no isis metric <0-16777215> level-2", - NO_STR - "IS-IS commands\n" - "Set default metric for circuit\n" - "Default metric value\n" - "Specify metric for level-2 routing\n") /* end of metrics */ DEFUN (isis_hello_interval, isis_hello_interval_cmd, - "isis hello-interval <1-600>", + "isis hello-interval (1-600)", "IS-IS commands\n" "Set Hello interval\n" "Hello interval value\n" "Holdtime 1 seconds, interval depends on multiplier\n") { + int idx_number = 2; int interval; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - interval = atoi (argv[0]); + interval = atoi (argv[idx_number]->arg); if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) { vty_out (vty, "Invalid hello-interval %d - should be <1-600>%s", @@ -713,12 +695,14 @@ DEFUN (isis_hello_interval, return CMD_SUCCESS; } + DEFUN (no_isis_hello_interval, no_isis_hello_interval_cmd, - "no isis hello-interval", + "no isis hello-interval [(1-600)]", NO_STR "IS-IS commands\n" - "Set Hello interval\n") + "Set Hello interval\n" + "Holdtime 1 second, interval depends on multiplier\n") { struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) @@ -730,30 +714,23 @@ DEFUN (no_isis_hello_interval, return CMD_SUCCESS; } -ALIAS (no_isis_hello_interval, - no_isis_hello_interval_arg_cmd, - "no isis hello-interval <1-600>", - NO_STR - "IS-IS commands\n" - "Set Hello interval\n" - "Hello interval value\n" - "Holdtime 1 second, interval depends on multiplier\n") DEFUN (isis_hello_interval_l1, isis_hello_interval_l1_cmd, - "isis hello-interval <1-600> level-1", + "isis hello-interval (1-600) level-1", "IS-IS commands\n" "Set Hello interval\n" "Hello interval value\n" "Holdtime 1 second, interval depends on multiplier\n" "Specify hello-interval for level-1 IIHs\n") { + int idx_number = 2; long interval; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - interval = atoi (argv[0]); + interval = atoi (argv[idx_number]->arg); if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) { vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s", @@ -766,12 +743,14 @@ DEFUN (isis_hello_interval_l1, return CMD_SUCCESS; } + DEFUN (no_isis_hello_interval_l1, no_isis_hello_interval_l1_cmd, - "no isis hello-interval level-1", + "no isis hello-interval [(1-600)] level-1", NO_STR "IS-IS commands\n" "Set Hello interval\n" + "Holdtime 1 second, interval depends on multiplier\n" "Specify hello-interval for level-1 IIHs\n") { struct isis_circuit *circuit = isis_circuit_lookup (vty); @@ -783,31 +762,23 @@ DEFUN (no_isis_hello_interval_l1, return CMD_SUCCESS; } -ALIAS (no_isis_hello_interval_l1, - no_isis_hello_interval_l1_arg_cmd, - "no isis hello-interval <1-600> level-1", - NO_STR - "IS-IS commands\n" - "Set Hello interval\n" - "Hello interval value\n" - "Holdtime 1 second, interval depends on multiplier\n" - "Specify hello-interval for level-1 IIHs\n") DEFUN (isis_hello_interval_l2, isis_hello_interval_l2_cmd, - "isis hello-interval <1-600> level-2", + "isis hello-interval (1-600) level-2", "IS-IS commands\n" "Set Hello interval\n" "Hello interval value\n" "Holdtime 1 second, interval depends on multiplier\n" "Specify hello-interval for level-2 IIHs\n") { + int idx_number = 2; long interval; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - interval = atoi (argv[0]); + interval = atoi (argv[idx_number]->arg); if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) { vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s", @@ -820,12 +791,14 @@ DEFUN (isis_hello_interval_l2, return CMD_SUCCESS; } + DEFUN (no_isis_hello_interval_l2, no_isis_hello_interval_l2_cmd, - "no isis hello-interval level-2", + "no isis hello-interval [(1-600)] level-2", NO_STR "IS-IS commands\n" "Set Hello interval\n" + "Holdtime 1 second, interval depends on multiplier\n" "Specify hello-interval for level-2 IIHs\n") { struct isis_circuit *circuit = isis_circuit_lookup (vty); @@ -837,29 +810,21 @@ DEFUN (no_isis_hello_interval_l2, return CMD_SUCCESS; } -ALIAS (no_isis_hello_interval_l2, - no_isis_hello_interval_l2_arg_cmd, - "no isis hello-interval <1-600> level-2", - NO_STR - "IS-IS commands\n" - "Set Hello interval\n" - "Hello interval value\n" - "Holdtime 1 second, interval depends on multiplier\n" - "Specify hello-interval for level-2 IIHs\n") DEFUN (isis_hello_multiplier, isis_hello_multiplier_cmd, - "isis hello-multiplier <2-100>", + "isis hello-multiplier (2-100)", "IS-IS commands\n" "Set multiplier for Hello holding time\n" "Hello multiplier value\n") { + int idx_number = 2; int mult; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - mult = atoi (argv[0]); + mult = atoi (argv[idx_number]->arg); if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) { vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s", @@ -873,12 +838,14 @@ DEFUN (isis_hello_multiplier, return CMD_SUCCESS; } + DEFUN (no_isis_hello_multiplier, no_isis_hello_multiplier_cmd, - "no isis hello-multiplier", + "no isis hello-multiplier [(2-100)]", NO_STR "IS-IS commands\n" - "Set multiplier for Hello holding time\n") + "Set multiplier for Hello holding time\n" + "Hello multiplier value\n") { struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) @@ -890,28 +857,22 @@ DEFUN (no_isis_hello_multiplier, return CMD_SUCCESS; } -ALIAS (no_isis_hello_multiplier, - no_isis_hello_multiplier_arg_cmd, - "no isis hello-multiplier <2-100>", - NO_STR - "IS-IS commands\n" - "Set multiplier for Hello holding time\n" - "Hello multiplier value\n") DEFUN (isis_hello_multiplier_l1, isis_hello_multiplier_l1_cmd, - "isis hello-multiplier <2-100> level-1", + "isis hello-multiplier (2-100) level-1", "IS-IS commands\n" "Set multiplier for Hello holding time\n" "Hello multiplier value\n" "Specify hello multiplier for level-1 IIHs\n") { + int idx_number = 2; int mult; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - mult = atoi (argv[0]); + mult = atoi (argv[idx_number]->arg); if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) { vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s", @@ -924,12 +885,14 @@ DEFUN (isis_hello_multiplier_l1, return CMD_SUCCESS; } + DEFUN (no_isis_hello_multiplier_l1, no_isis_hello_multiplier_l1_cmd, - "no isis hello-multiplier level-1", + "no isis hello-multiplier [(2-100)] level-1", NO_STR "IS-IS commands\n" "Set multiplier for Hello holding time\n" + "Hello multiplier value\n" "Specify hello multiplier for level-1 IIHs\n") { struct isis_circuit *circuit = isis_circuit_lookup (vty); @@ -941,29 +904,22 @@ DEFUN (no_isis_hello_multiplier_l1, return CMD_SUCCESS; } -ALIAS (no_isis_hello_multiplier_l1, - no_isis_hello_multiplier_l1_arg_cmd, - "no isis hello-multiplier <2-100> level-1", - NO_STR - "IS-IS commands\n" - "Set multiplier for Hello holding time\n" - "Hello multiplier value\n" - "Specify hello multiplier for level-1 IIHs\n") DEFUN (isis_hello_multiplier_l2, isis_hello_multiplier_l2_cmd, - "isis hello-multiplier <2-100> level-2", + "isis hello-multiplier (2-100) level-2", "IS-IS commands\n" "Set multiplier for Hello holding time\n" "Hello multiplier value\n" "Specify hello multiplier for level-2 IIHs\n") { + int idx_number = 2; int mult; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - mult = atoi (argv[0]); + mult = atoi (argv[idx_number]->arg); if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) { vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s", @@ -976,12 +932,14 @@ DEFUN (isis_hello_multiplier_l2, return CMD_SUCCESS; } + DEFUN (no_isis_hello_multiplier_l2, no_isis_hello_multiplier_l2_cmd, - "no isis hello-multiplier level-2", + "no isis hello-multiplier [(2-100)] level-2", NO_STR "IS-IS commands\n" "Set multiplier for Hello holding time\n" + "Hello multiplier value\n" "Specify hello multiplier for level-2 IIHs\n") { struct isis_circuit *circuit = isis_circuit_lookup (vty); @@ -993,14 +951,6 @@ DEFUN (no_isis_hello_multiplier_l2, return CMD_SUCCESS; } -ALIAS (no_isis_hello_multiplier_l2, - no_isis_hello_multiplier_l2_arg_cmd, - "no isis hello-multiplier <2-100> level-2", - NO_STR - "IS-IS commands\n" - "Set multiplier for Hello holding time\n" - "Hello multiplier value\n" - "Specify hello multiplier for level-2 IIHs\n") DEFUN (isis_hello_padding, isis_hello_padding_cmd, @@ -1039,17 +989,18 @@ DEFUN (no_isis_hello_padding, DEFUN (csnp_interval, csnp_interval_cmd, - "isis csnp-interval <1-600>", + "isis csnp-interval (1-600)", "IS-IS commands\n" "Set CSNP interval in seconds\n" "CSNP interval value\n") { + int idx_number = 2; unsigned long interval; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - interval = atol (argv[0]); + interval = atol (argv[idx_number]->arg); if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) { vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s", @@ -1063,12 +1014,14 @@ DEFUN (csnp_interval, return CMD_SUCCESS; } + DEFUN (no_csnp_interval, no_csnp_interval_cmd, - "no isis csnp-interval", + "no isis csnp-interval [(1-600)]", NO_STR "IS-IS commands\n" - "Set CSNP interval in seconds\n") + "Set CSNP interval in seconds\n" + "CSNP interval value\n") { struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) @@ -1080,28 +1033,22 @@ DEFUN (no_csnp_interval, return CMD_SUCCESS; } -ALIAS (no_csnp_interval, - no_csnp_interval_arg_cmd, - "no isis csnp-interval <1-600>", - NO_STR - "IS-IS commands\n" - "Set CSNP interval in seconds\n" - "CSNP interval value\n") DEFUN (csnp_interval_l1, csnp_interval_l1_cmd, - "isis csnp-interval <1-600> level-1", + "isis csnp-interval (1-600) level-1", "IS-IS commands\n" "Set CSNP interval in seconds\n" "CSNP interval value\n" "Specify interval for level-1 CSNPs\n") { + int idx_number = 2; unsigned long interval; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - interval = atol (argv[0]); + interval = atol (argv[idx_number]->arg); if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) { vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s", @@ -1114,12 +1061,14 @@ DEFUN (csnp_interval_l1, return CMD_SUCCESS; } + DEFUN (no_csnp_interval_l1, no_csnp_interval_l1_cmd, - "no isis csnp-interval level-1", + "no isis csnp-interval [(1-600)] level-1", NO_STR "IS-IS commands\n" "Set CSNP interval in seconds\n" + "CSNP interval value\n" "Specify interval for level-1 CSNPs\n") { struct isis_circuit *circuit = isis_circuit_lookup (vty); @@ -1131,29 +1080,22 @@ DEFUN (no_csnp_interval_l1, return CMD_SUCCESS; } -ALIAS (no_csnp_interval_l1, - no_csnp_interval_l1_arg_cmd, - "no isis csnp-interval <1-600> level-1", - NO_STR - "IS-IS commands\n" - "Set CSNP interval in seconds\n" - "CSNP interval value\n" - "Specify interval for level-1 CSNPs\n") DEFUN (csnp_interval_l2, csnp_interval_l2_cmd, - "isis csnp-interval <1-600> level-2", + "isis csnp-interval (1-600) level-2", "IS-IS commands\n" "Set CSNP interval in seconds\n" "CSNP interval value\n" "Specify interval for level-2 CSNPs\n") { + int idx_number = 2; unsigned long interval; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - interval = atol (argv[0]); + interval = atol (argv[idx_number]->arg); if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) { vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s", @@ -1166,12 +1108,14 @@ DEFUN (csnp_interval_l2, return CMD_SUCCESS; } + DEFUN (no_csnp_interval_l2, no_csnp_interval_l2_cmd, - "no isis csnp-interval level-2", + "no isis csnp-interval [(1-600)] level-2", NO_STR "IS-IS commands\n" "Set CSNP interval in seconds\n" + "CSNP interval value\n" "Specify interval for level-2 CSNPs\n") { struct isis_circuit *circuit = isis_circuit_lookup (vty); @@ -1183,28 +1127,21 @@ DEFUN (no_csnp_interval_l2, return CMD_SUCCESS; } -ALIAS (no_csnp_interval_l2, - no_csnp_interval_l2_arg_cmd, - "no isis csnp-interval <1-600> level-2", - NO_STR - "IS-IS commands\n" - "Set CSNP interval in seconds\n" - "CSNP interval value\n" - "Specify interval for level-2 CSNPs\n") DEFUN (psnp_interval, psnp_interval_cmd, - "isis psnp-interval <1-120>", + "isis psnp-interval (1-120)", "IS-IS commands\n" "Set PSNP interval in seconds\n" "PSNP interval value\n") { + int idx_number = 2; unsigned long interval; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - interval = atol (argv[0]); + interval = atol (argv[idx_number]->arg); if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) { vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s", @@ -1218,12 +1155,14 @@ DEFUN (psnp_interval, return CMD_SUCCESS; } + DEFUN (no_psnp_interval, no_psnp_interval_cmd, - "no isis psnp-interval", + "no isis psnp-interval [(1-120)]", NO_STR "IS-IS commands\n" - "Set PSNP interval in seconds\n") + "Set PSNP interval in seconds\n" + "PSNP interval value\n") { struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) @@ -1235,28 +1174,22 @@ DEFUN (no_psnp_interval, return CMD_SUCCESS; } -ALIAS (no_psnp_interval, - no_psnp_interval_arg_cmd, - "no isis psnp-interval <1-120>", - NO_STR - "IS-IS commands\n" - "Set PSNP interval in seconds\n" - "PSNP interval value\n") DEFUN (psnp_interval_l1, psnp_interval_l1_cmd, - "isis psnp-interval <1-120> level-1", + "isis psnp-interval (1-120) level-1", "IS-IS commands\n" "Set PSNP interval in seconds\n" "PSNP interval value\n" "Specify interval for level-1 PSNPs\n") { + int idx_number = 2; unsigned long interval; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - interval = atol (argv[0]); + interval = atol (argv[idx_number]->arg); if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) { vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s", @@ -1269,12 +1202,14 @@ DEFUN (psnp_interval_l1, return CMD_SUCCESS; } + DEFUN (no_psnp_interval_l1, no_psnp_interval_l1_cmd, - "no isis psnp-interval level-1", + "no isis psnp-interval [(1-120)] level-1", NO_STR "IS-IS commands\n" "Set PSNP interval in seconds\n" + "PSNP interval value\n" "Specify interval for level-1 PSNPs\n") { struct isis_circuit *circuit = isis_circuit_lookup (vty); @@ -1286,29 +1221,22 @@ DEFUN (no_psnp_interval_l1, return CMD_SUCCESS; } -ALIAS (no_psnp_interval_l1, - no_psnp_interval_l1_arg_cmd, - "no isis psnp-interval <1-120> level-1", - NO_STR - "IS-IS commands\n" - "Set PSNP interval in seconds\n" - "PSNP interval value\n" - "Specify interval for level-1 PSNPs\n") DEFUN (psnp_interval_l2, psnp_interval_l2_cmd, - "isis psnp-interval <1-120> level-2", + "isis psnp-interval (1-120) level-2", "IS-IS commands\n" "Set PSNP interval in seconds\n" "PSNP interval value\n" "Specify interval for level-2 PSNPs\n") { + int idx_number = 2; unsigned long interval; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - interval = atol (argv[0]); + interval = atol (argv[idx_number]->arg); if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) { vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s", @@ -1321,12 +1249,14 @@ DEFUN (psnp_interval_l2, return CMD_SUCCESS; } + DEFUN (no_psnp_interval_l2, no_psnp_interval_l2_cmd, - "no isis psnp-interval level-2", + "no isis psnp-interval [(1-120)] level-2", NO_STR "IS-IS commands\n" "Set PSNP interval in seconds\n" + "PSNP interval value\n" "Specify interval for level-2 PSNPs\n") { struct isis_circuit *circuit = isis_circuit_lookup (vty); @@ -1338,14 +1268,6 @@ DEFUN (no_psnp_interval_l2, return CMD_SUCCESS; } -ALIAS (no_psnp_interval_l2, - no_psnp_interval_l2_arg_cmd, - "no isis psnp-interval <1-120> level-2", - NO_STR - "IS-IS commands\n" - "Set PSNP interval in seconds\n" - "PSNP interval value\n" - "Specify interval for level-2 PSNPs\n") static int validate_metric_style_narrow (struct vty *vty, struct isis_area *area) @@ -1387,16 +1309,17 @@ validate_metric_style_narrow (struct vty *vty, struct isis_area *area) DEFUN (metric_style, metric_style_cmd, - "metric-style (narrow|transition|wide)", + "metric-style <narrow|transition|wide>", "Use old-style (ISO 10589) or new-style packet formats\n" "Use old style of TLVs with narrow metric\n" "Send and accept both styles of TLVs during transition\n" "Use new style of TLVs to carry wider metric\n") { + int idx_metric_style = 1; VTY_DECLVAR_CONTEXT (isis_area, area); int ret; - if (strncmp (argv[0], "w", 1) == 0) + if (strncmp (argv[idx_metric_style]->arg, "w", 1) == 0) { isis_area_metricstyle_set(area, false, true); return CMD_SUCCESS; @@ -1406,9 +1329,9 @@ DEFUN (metric_style, if (ret != CMD_SUCCESS) return ret; - if (strncmp (argv[0], "t", 1) == 0) + if (strncmp (argv[idx_metric_style]->arg, "t", 1) == 0) isis_area_metricstyle_set(area, true, true); - else if (strncmp (argv[0], "n", 1) == 0) + else if (strncmp (argv[idx_metric_style]->arg, "n", 1) == 0) isis_area_metricstyle_set(area, true, false); return CMD_SUCCESS; @@ -1471,6 +1394,7 @@ DEFUN (set_attached_bit, DEFUN (no_set_attached_bit, no_set_attached_bit_cmd, "no set-attached-bit", + NO_STR "Reset attached bit\n") { VTY_DECLVAR_CONTEXT (isis_area, area); @@ -1529,45 +1453,43 @@ static int area_lsp_mtu_set(struct vty *vty, unsigned int lsp_mtu) DEFUN (area_lsp_mtu, area_lsp_mtu_cmd, - "lsp-mtu <128-4352>", + "lsp-mtu (128-4352)", "Configure the maximum size of generated LSPs\n" "Maximum size of generated LSPs\n") { + int idx_number = 1; unsigned int lsp_mtu; - VTY_GET_INTEGER_RANGE("lsp-mtu", lsp_mtu, argv[0], 128, 4352); + VTY_GET_INTEGER_RANGE("lsp-mtu", lsp_mtu, argv[idx_number]->arg, 128, 4352); return area_lsp_mtu_set(vty, lsp_mtu); } + DEFUN (no_area_lsp_mtu, no_area_lsp_mtu_cmd, - "no lsp-mtu", + "no lsp-mtu [(128-4352)]", NO_STR - "Configure the maximum size of generated LSPs\n") + "Configure the maximum size of generated LSPs\n" + "Maximum size of generated LSPs\n") { return area_lsp_mtu_set(vty, DEFAULT_LSP_MTU); } -ALIAS (no_area_lsp_mtu, - no_area_lsp_mtu_arg_cmd, - "no lsp-mtu <128-4352>", - NO_STR - "Configure the maximum size of generated LSPs\n" - "Maximum size of generated LSPs\n"); DEFUN (is_type, is_type_cmd, - "is-type (level-1|level-1-2|level-2-only)", + "is-type <level-1|level-1-2|level-2-only>", "IS Level for this routing process (OSI only)\n" "Act as a station router only\n" "Act as both a station router and an area router\n" "Act as an area router only\n") { + int idx_level = 1; VTY_DECLVAR_CONTEXT (isis_area, area); int type; - type = string2circuit_t (argv[0]); + type = string2circuit_t (argv[idx_level]->arg); if (!type) { vty_out (vty, "Unknown IS level %s", VTY_NEWLINE); @@ -1581,7 +1503,7 @@ DEFUN (is_type, DEFUN (no_is_type, no_is_type_cmd, - "no is-type (level-1|level-1-2|level-2-only)", + "no is-type <level-1|level-1-2|level-2-only>", NO_STR "IS Level for this routing process (OSI only)\n" "Act as a station router only\n" @@ -1638,24 +1560,26 @@ set_lsp_gen_interval (struct vty *vty, struct isis_area *area, DEFUN (lsp_gen_interval, lsp_gen_interval_cmd, - "lsp-gen-interval <1-120>", + "lsp-gen-interval (1-120)", "Minimum interval between regenerating same LSP\n" "Minimum interval in seconds\n") { + int idx_number = 1; VTY_DECLVAR_CONTEXT (isis_area, area); uint16_t interval; int level; - interval = atoi (argv[0]); + interval = atoi (argv[idx_number]->arg); level = IS_LEVEL_1 | IS_LEVEL_2; return set_lsp_gen_interval (vty, area, interval, level); } DEFUN (no_lsp_gen_interval, no_lsp_gen_interval_cmd, - "no lsp-gen-interval", + "no lsp-gen-interval [(1-120)]", NO_STR - "Minimum interval between regenerating same LSP\n") + "Minimum interval between regenerating same LSP\n" + "Minimum interval in seconds\n") { VTY_DECLVAR_CONTEXT (isis_area, area); uint16_t interval; @@ -1666,32 +1590,27 @@ DEFUN (no_lsp_gen_interval, return set_lsp_gen_interval (vty, area, interval, level); } -ALIAS (no_lsp_gen_interval, - no_lsp_gen_interval_arg_cmd, - "no lsp-gen-interval <1-120>", - NO_STR - "Minimum interval between regenerating same LSP\n" - "Minimum interval in seconds\n") DEFUN (lsp_gen_interval_l1, lsp_gen_interval_l1_cmd, - "lsp-gen-interval level-1 <1-120>", + "lsp-gen-interval level-1 (1-120)", "Minimum interval between regenerating same LSP\n" "Set interval for level 1 only\n" "Minimum interval in seconds\n") { + int idx_number = 2; VTY_DECLVAR_CONTEXT (isis_area, area); uint16_t interval; int level; - interval = atoi (argv[0]); + interval = atoi (argv[idx_number]->arg); level = IS_LEVEL_1; return set_lsp_gen_interval (vty, area, interval, level); } DEFUN (no_lsp_gen_interval_l1, no_lsp_gen_interval_l1_cmd, - "no lsp-gen-interval level-1", + "no lsp-gen-interval level-1 [(1-120)]", NO_STR "Minimum interval between regenerating same LSP\n" "Set interval for level 1 only\n") @@ -1705,36 +1624,31 @@ DEFUN (no_lsp_gen_interval_l1, return set_lsp_gen_interval (vty, area, interval, level); } -ALIAS (no_lsp_gen_interval_l1, - no_lsp_gen_interval_l1_arg_cmd, - "no lsp-gen-interval level-1 <1-120>", - NO_STR - "Minimum interval between regenerating same LSP\n" - "Set interval for level 1 only\n" - "Minimum interval in seconds\n") DEFUN (lsp_gen_interval_l2, lsp_gen_interval_l2_cmd, - "lsp-gen-interval level-2 <1-120>", + "lsp-gen-interval level-2 (1-120)", "Minimum interval between regenerating same LSP\n" "Set interval for level 2 only\n" "Minimum interval in seconds\n") { VTY_DECLVAR_CONTEXT (isis_area, area); + int idx_number = 2; uint16_t interval; int level; - interval = atoi (argv[0]); + interval = atoi (argv[idx_number]->arg); level = IS_LEVEL_2; return set_lsp_gen_interval (vty, area, interval, level); } DEFUN (no_lsp_gen_interval_l2, no_lsp_gen_interval_l2_cmd, - "no lsp-gen-interval level-2", + "no lsp-gen-interval level-2 [(1-120)]", NO_STR "Minimum interval between regenerating same LSP\n" - "Set interval for level 2 only\n") + "Set interval for level 2 only\n" + "Minimum interval in seconds\n") { VTY_DECLVAR_CONTEXT (isis_area, area); uint16_t interval; @@ -1745,35 +1659,33 @@ DEFUN (no_lsp_gen_interval_l2, return set_lsp_gen_interval (vty, area, interval, level); } -ALIAS (no_lsp_gen_interval_l2, - no_lsp_gen_interval_l2_arg_cmd, - "no lsp-gen-interval level-2 <1-120>", - NO_STR - "Minimum interval between regenerating same LSP\n" - "Set interval for level 2 only\n" - "Minimum interval in seconds\n") DEFUN (spf_interval, spf_interval_cmd, - "spf-interval <1-120>", + "spf-interval (1-120)", "Minimum interval between SPF calculations\n" "Minimum interval between consecutive SPFs in seconds\n") { + int idx_number = 1; VTY_DECLVAR_CONTEXT (isis_area, area); u_int16_t interval; - interval = atoi (argv[0]); + interval = atoi (argv[idx_number]->arg); area->min_spf_interval[0] = interval; area->min_spf_interval[1] = interval; return CMD_SUCCESS; } + DEFUN (no_spf_interval, no_spf_interval_cmd, - "no spf-interval", + "no spf-interval [[<level-1|level-2>] (1-120)]", NO_STR - "Minimum interval between SPF calculations\n") + "Minimum interval between SPF calculations\n" + "Set interval for level 1 only\n" + "Set interval for level 2 only\n" + "Minimum interval between consecutive SPFs in seconds\n") { VTY_DECLVAR_CONTEXT (isis_area, area); @@ -1783,24 +1695,19 @@ DEFUN (no_spf_interval, return CMD_SUCCESS; } -ALIAS (no_spf_interval, - no_spf_interval_arg_cmd, - "no spf-interval <1-120>", - NO_STR - "Minimum interval between SPF calculations\n" - "Minimum interval between consecutive SPFs in seconds\n") DEFUN (spf_interval_l1, spf_interval_l1_cmd, - "spf-interval level-1 <1-120>", + "spf-interval level-1 (1-120)", "Minimum interval between SPF calculations\n" "Set interval for level 1 only\n" "Minimum interval between consecutive SPFs in seconds\n") { + int idx_number = 2; VTY_DECLVAR_CONTEXT (isis_area, area); u_int16_t interval; - interval = atoi (argv[0]); + interval = atoi (argv[idx_number]->arg); area->min_spf_interval[0] = interval; return CMD_SUCCESS; @@ -1820,25 +1727,19 @@ DEFUN (no_spf_interval_l1, return CMD_SUCCESS; } -ALIAS (no_spf_interval, - no_spf_interval_l1_arg_cmd, - "no spf-interval level-1 <1-120>", - NO_STR - "Minimum interval between SPF calculations\n" - "Set interval for level 1 only\n" - "Minimum interval between consecutive SPFs in seconds\n") DEFUN (spf_interval_l2, spf_interval_l2_cmd, - "spf-interval level-2 <1-120>", + "spf-interval level-2 (1-120)", "Minimum interval between SPF calculations\n" "Set interval for level 2 only\n" "Minimum interval between consecutive SPFs in seconds\n") { + int idx_number = 2; VTY_DECLVAR_CONTEXT (isis_area, area); u_int16_t interval; - interval = atoi (argv[0]); + interval = atoi (argv[idx_number]->arg); area->min_spf_interval[1] = interval; return CMD_SUCCESS; @@ -1858,13 +1759,6 @@ DEFUN (no_spf_interval_l2, return CMD_SUCCESS; } -ALIAS (no_spf_interval, - no_spf_interval_l2_arg_cmd, - "no spf-interval level-2 <1-120>", - NO_STR - "Minimum interval between SPF calculations\n" - "Set interval for level 2 only\n" - "Minimum interval between consecutive SPFs in seconds\n") static int area_max_lsp_lifetime_set(struct vty *vty, int level, @@ -1914,79 +1808,44 @@ area_max_lsp_lifetime_set(struct vty *vty, int level, DEFUN (max_lsp_lifetime, max_lsp_lifetime_cmd, - "max-lsp-lifetime <350-65535>", - "Maximum LSP lifetime\n" + "max-lsp-lifetime [<level-1|level-2>] (350-65535)", + "Maximum LSP lifetime for Level 1 only\n" + "Maximum LSP lifetime for Level 2 only\n" "LSP lifetime in seconds\n") { - return area_max_lsp_lifetime_set(vty, IS_LEVEL_1_AND_2, atoi(argv[0])); -} + int idx = 0; + unsigned int level = IS_LEVEL_1_AND_2; -DEFUN (no_max_lsp_lifetime, - no_max_lsp_lifetime_cmd, - "no max-lsp-lifetime", - NO_STR - "LSP lifetime in seconds\n") -{ - return area_max_lsp_lifetime_set(vty, IS_LEVEL_1_AND_2, - DEFAULT_LSP_LIFETIME); -} + if (argv_find (argv, argc, "level-1", &idx)) + level = IS_LEVEL_1; + else if (argv_find (argv, argc, "level-2", &idx)) + level = IS_LEVEL_2; -ALIAS (no_max_lsp_lifetime, - no_max_lsp_lifetime_arg_cmd, - "no max-lsp-lifetime <350-65535>", - NO_STR - "Maximum LSP lifetime\n" - "LSP lifetime in seconds\n") + argv_find (argv, argc, "(350-65535)", &idx); + int lifetime = atoi(argv[idx]->arg); -DEFUN (max_lsp_lifetime_l1, - max_lsp_lifetime_l1_cmd, - "max-lsp-lifetime level-1 <350-65535>", - "Maximum LSP lifetime for Level 1 only\n" - "LSP lifetime for Level 1 only in seconds\n") -{ - return area_max_lsp_lifetime_set(vty, IS_LEVEL_1, atoi(argv[0])); + return area_max_lsp_lifetime_set(vty, level, lifetime); } -DEFUN (no_max_lsp_lifetime_l1, - no_max_lsp_lifetime_l1_cmd, - "no max-lsp-lifetime level-1", - NO_STR - "LSP lifetime for Level 1 only in seconds\n") -{ - return area_max_lsp_lifetime_set(vty, IS_LEVEL_1, DEFAULT_LSP_LIFETIME); -} -ALIAS (no_max_lsp_lifetime_l1, - no_max_lsp_lifetime_l1_arg_cmd, - "no max-lsp-lifetime level-1 <350-65535>", +DEFUN (no_max_lsp_lifetime, + no_max_lsp_lifetime_cmd, + "no max-lsp-lifetime [<level-1|level-2>] [(350-65535)]", NO_STR "Maximum LSP lifetime for Level 1 only\n" - "LSP lifetime for Level 1 only in seconds\n") - -DEFUN (max_lsp_lifetime_l2, - max_lsp_lifetime_l2_cmd, - "max-lsp-lifetime level-2 <350-65535>", "Maximum LSP lifetime for Level 2 only\n" - "LSP lifetime for Level 2 only in seconds\n") + "LSP lifetime in seconds\n") { - return area_max_lsp_lifetime_set(vty, IS_LEVEL_2, atoi(argv[0])); -} + int idx = 0; + unsigned int level = IS_LEVEL_1_AND_2; -DEFUN (no_max_lsp_lifetime_l2, - no_max_lsp_lifetime_l2_cmd, - "no max-lsp-lifetime level-2", - NO_STR - "LSP lifetime for Level 2 only in seconds\n") -{ - return area_max_lsp_lifetime_set(vty, IS_LEVEL_2, DEFAULT_LSP_LIFETIME); -} + if (argv_find (argv, argc, "level-1", &idx)) + level = IS_LEVEL_1; + else if (argv_find (argv, argc, "level-2", &idx)) + level = IS_LEVEL_2; -ALIAS (no_max_lsp_lifetime_l2, - no_max_lsp_lifetime_l2_arg_cmd, - "no max-lsp-lifetime level-2 <350-65535>", - NO_STR - "Maximum LSP lifetime for Level 2 only\n" - "LSP lifetime for Level 2 only in seconds\n") + return area_max_lsp_lifetime_set(vty, level, DEFAULT_LSP_LIFETIME); +} static int area_lsp_refresh_interval_set(struct vty *vty, int level, uint16_t interval) @@ -2028,81 +1887,44 @@ area_lsp_refresh_interval_set(struct vty *vty, int level, uint16_t interval) DEFUN (lsp_refresh_interval, lsp_refresh_interval_cmd, - "lsp-refresh-interval <1-65235>", + "lsp-refresh-interval [<level-1|level-2>] (1-65235)", "LSP refresh interval\n" + "LSP refresh interval for Level 1 only\n" + "LSP refresh interval for Level 2 only\n" "LSP refresh interval in seconds\n") { - return area_lsp_refresh_interval_set(vty, IS_LEVEL_1_AND_2, atoi(argv[0])); + int idx = 0; + unsigned int level = IS_LEVEL_1_AND_2; + unsigned int interval = 0; + + if (argv_find (argv, argc, "level-1", &idx)) + level = IS_LEVEL_1; + else if (argv_find (argv, argc, "level-2", &idx)) + level = IS_LEVEL_2; + + interval = atoi(argv[argc-1]->arg); + return area_lsp_refresh_interval_set(vty, level, interval); } DEFUN (no_lsp_refresh_interval, no_lsp_refresh_interval_cmd, - "no lsp-refresh-interval", - NO_STR - "LSP refresh interval in seconds\n") -{ - return area_lsp_refresh_interval_set(vty, IS_LEVEL_1_AND_2, - DEFAULT_MAX_LSP_GEN_INTERVAL); -} - -ALIAS (no_lsp_refresh_interval, - no_lsp_refresh_interval_arg_cmd, - "no lsp-refresh-interval <1-65235>", + "no lsp-refresh-interval [<level-1|level-2>] [(1-65235)]", NO_STR "LSP refresh interval\n" - "LSP refresh interval in seconds\n") - -DEFUN (lsp_refresh_interval_l1, - lsp_refresh_interval_l1_cmd, - "lsp-refresh-interval level-1 <1-65235>", - "LSP refresh interval for Level 1 only\n" - "LSP refresh interval for Level 1 only in seconds\n") -{ - return area_lsp_refresh_interval_set(vty, IS_LEVEL_1, atoi(argv[0])); -} - -DEFUN (no_lsp_refresh_interval_l1, - no_lsp_refresh_interval_l1_cmd, - "no lsp-refresh-interval level-1", - NO_STR - "LSP refresh interval for Level 1 only in seconds\n") -{ - return area_lsp_refresh_interval_set(vty, IS_LEVEL_1, - DEFAULT_MAX_LSP_GEN_INTERVAL); -} - -ALIAS (no_lsp_refresh_interval_l1, - no_lsp_refresh_interval_l1_arg_cmd, - "no lsp-refresh-interval level-1 <1-65235>", - NO_STR "LSP refresh interval for Level 1 only\n" - "LSP refresh interval for Level 1 only in seconds\n") - -DEFUN (lsp_refresh_interval_l2, - lsp_refresh_interval_l2_cmd, - "lsp-refresh-interval level-2 <1-65235>", "LSP refresh interval for Level 2 only\n" - "LSP refresh interval for Level 2 only in seconds\n") + "LSP refresh interval in seconds\n") { - return area_lsp_refresh_interval_set(vty, IS_LEVEL_2, atoi(argv[0])); -} + int idx = 0; + unsigned int level = IS_LEVEL_1_AND_2; -DEFUN (no_lsp_refresh_interval_l2, - no_lsp_refresh_interval_l2_cmd, - "no lsp-refresh-interval level-2", - NO_STR - "LSP refresh interval for Level 2 only in seconds\n") -{ - return area_lsp_refresh_interval_set(vty, IS_LEVEL_2, - DEFAULT_MAX_LSP_GEN_INTERVAL); -} + if (argv_find (argv, argc, "level-1", &idx)) + level = IS_LEVEL_1; + else if (argv_find (argv, argc, "level-2", &idx)) + level = IS_LEVEL_2; -ALIAS (no_lsp_refresh_interval_l2, - no_lsp_refresh_interval_l2_arg_cmd, - "no lsp-refresh-interval level-2 <1-65235>", - NO_STR - "LSP refresh interval for Level 2 only\n" - "LSP refresh interval for Level 2 only in seconds\n") + return area_lsp_refresh_interval_set(vty, level, DEFAULT_MAX_LSP_GEN_INTERVAL); +} static int area_passwd_set(struct vty *vty, int level, @@ -2122,32 +1944,38 @@ area_passwd_set(struct vty *vty, int level, return CMD_SUCCESS; } + DEFUN (area_passwd_md5, area_passwd_md5_cmd, - "(area-password|domain-password) md5 WORD", + "area-password md5 WORD [authenticate snp <send-only|validate>]", "Configure the authentication password for an area\n" - "Set the authentication password for a routing domain\n" "Authentication type\n" - "Level-wide password\n") + "Level-wide password\n" + "Authentication\n" + "SNP PDUs\n" + "Send but do not check PDUs on receiving\n" + "Send and check PDUs on receiving\n") { + int idx_password = 0; + int idx_word = 2; + int idx_type = 5; u_char snp_auth = 0; - int level = (argv[0][0] == 'd') ? IS_LEVEL_2 : IS_LEVEL_1; + int level = strmatch(argv[idx_password]->text, "domain-password") ? IS_LEVEL_2 : IS_LEVEL_1; - if (argc > 2) + if (argc > 3) { snp_auth = SNP_AUTH_SEND; - if (strncmp(argv[2], "v", 1) == 0) + if (strmatch(argv[idx_type]->text, "validate")) snp_auth |= SNP_AUTH_RECV; } return area_passwd_set(vty, level, isis_area_passwd_hmac_md5_set, - argv[1], snp_auth); + argv[idx_word]->arg, snp_auth); } -ALIAS (area_passwd_md5, - area_passwd_md5_snpauth_cmd, - "(area-password|domain-password) md5 WORD authenticate snp (send-only|validate)", - "Configure the authentication password for an area\n" +DEFUN (domain_passwd_md5, + domain_passwd_md5_cmd, + "domain-password md5 WORD [authenticate snp <send-only|validate>]", "Set the authentication password for a routing domain\n" "Authentication type\n" "Level-wide password\n" @@ -2155,33 +1983,41 @@ ALIAS (area_passwd_md5, "SNP PDUs\n" "Send but do not check PDUs on receiving\n" "Send and check PDUs on receiving\n") +{ + return area_passwd_md5 (self, vty, argc, argv); +} DEFUN (area_passwd_clear, area_passwd_clear_cmd, - "(area-password|domain-password) clear WORD", + "area-password clear WORD [authenticate snp <send-only|validate>]", "Configure the authentication password for an area\n" - "Set the authentication password for a routing domain\n" "Authentication type\n" - "Area password\n") + "Area password\n" + "Authentication\n" + "SNP PDUs\n" + "Send but do not check PDUs on receiving\n" + "Send and check PDUs on receiving\n") { + int idx_password = 0; + int idx_word = 2; + int idx_type = 5; u_char snp_auth = 0; - int level = (argv[0][0] == 'd') ? IS_LEVEL_2 : IS_LEVEL_1; + int level = strmatch(argv[idx_password]->text, "domain-password") ? IS_LEVEL_2 : IS_LEVEL_1; - if (argc > 2) + if (argc > 3) { snp_auth = SNP_AUTH_SEND; - if (strncmp(argv[2], "v", 1) == 0) + if (strmatch (argv[idx_type]->text, "validate")) snp_auth |= SNP_AUTH_RECV; } return area_passwd_set(vty, level, isis_area_passwd_cleartext_set, - argv[1], snp_auth); + argv[idx_word]->arg, snp_auth); } -ALIAS (area_passwd_clear, - area_passwd_clear_snpauth_cmd, - "(area-password|domain-password) clear WORD authenticate snp (send-only|validate)", - "Configure the authentication password for an area\n" +DEFUN (domain_passwd_clear, + domain_passwd_clear_cmd, + "domain-password clear WORD [authenticate snp <send-only|validate>]", "Set the authentication password for a routing domain\n" "Authentication type\n" "Area password\n" @@ -2189,16 +2025,20 @@ ALIAS (area_passwd_clear, "SNP PDUs\n" "Send but do not check PDUs on receiving\n" "Send and check PDUs on receiving\n") +{ + return area_passwd_clear (self, vty, argc, argv); +} DEFUN (no_area_passwd, no_area_passwd_cmd, - "no (area-password|domain-password)", + "no <area-password|domain-password>", NO_STR "Configure the authentication password for an area\n" "Set the authentication password for a routing domain\n") { + int idx_password = 1; + int level = strmatch (argv[idx_password]->text, "domain-password") ? IS_LEVEL_2 : IS_LEVEL_1; VTY_DECLVAR_CONTEXT (isis_area, area); - int level = (argv[0][0] == 'd') ? IS_LEVEL_2 : IS_LEVEL_1; return isis_area_passwd_unset (area, level); } @@ -2207,6 +2047,7 @@ void isis_vty_init (void) { install_element (INTERFACE_NODE, &ip_router_isis_cmd); + install_element (INTERFACE_NODE, &ip6_router_isis_cmd); install_element (INTERFACE_NODE, &no_ip_router_isis_cmd); install_element (INTERFACE_NODE, &isis_passive_cmd); @@ -2220,70 +2061,51 @@ isis_vty_init (void) install_element (INTERFACE_NODE, &isis_passwd_cmd); install_element (INTERFACE_NODE, &no_isis_passwd_cmd); - install_element (INTERFACE_NODE, &no_isis_passwd_arg_cmd); install_element (INTERFACE_NODE, &isis_priority_cmd); install_element (INTERFACE_NODE, &no_isis_priority_cmd); - install_element (INTERFACE_NODE, &no_isis_priority_arg_cmd); install_element (INTERFACE_NODE, &isis_priority_l1_cmd); install_element (INTERFACE_NODE, &no_isis_priority_l1_cmd); - install_element (INTERFACE_NODE, &no_isis_priority_l1_arg_cmd); install_element (INTERFACE_NODE, &isis_priority_l2_cmd); install_element (INTERFACE_NODE, &no_isis_priority_l2_cmd); - install_element (INTERFACE_NODE, &no_isis_priority_l2_arg_cmd); install_element (INTERFACE_NODE, &isis_metric_cmd); install_element (INTERFACE_NODE, &no_isis_metric_cmd); - install_element (INTERFACE_NODE, &no_isis_metric_arg_cmd); install_element (INTERFACE_NODE, &isis_metric_l1_cmd); install_element (INTERFACE_NODE, &no_isis_metric_l1_cmd); - install_element (INTERFACE_NODE, &no_isis_metric_l1_arg_cmd); install_element (INTERFACE_NODE, &isis_metric_l2_cmd); install_element (INTERFACE_NODE, &no_isis_metric_l2_cmd); - install_element (INTERFACE_NODE, &no_isis_metric_l2_arg_cmd); install_element (INTERFACE_NODE, &isis_hello_interval_cmd); install_element (INTERFACE_NODE, &no_isis_hello_interval_cmd); - install_element (INTERFACE_NODE, &no_isis_hello_interval_arg_cmd); install_element (INTERFACE_NODE, &isis_hello_interval_l1_cmd); install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_cmd); - install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_arg_cmd); install_element (INTERFACE_NODE, &isis_hello_interval_l2_cmd); install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_cmd); - install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_arg_cmd); install_element (INTERFACE_NODE, &isis_hello_multiplier_cmd); install_element (INTERFACE_NODE, &no_isis_hello_multiplier_cmd); - install_element (INTERFACE_NODE, &no_isis_hello_multiplier_arg_cmd); install_element (INTERFACE_NODE, &isis_hello_multiplier_l1_cmd); install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_cmd); - install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_arg_cmd); install_element (INTERFACE_NODE, &isis_hello_multiplier_l2_cmd); install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_cmd); - install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_arg_cmd); install_element (INTERFACE_NODE, &isis_hello_padding_cmd); install_element (INTERFACE_NODE, &no_isis_hello_padding_cmd); install_element (INTERFACE_NODE, &csnp_interval_cmd); install_element (INTERFACE_NODE, &no_csnp_interval_cmd); - install_element (INTERFACE_NODE, &no_csnp_interval_arg_cmd); install_element (INTERFACE_NODE, &csnp_interval_l1_cmd); install_element (INTERFACE_NODE, &no_csnp_interval_l1_cmd); - install_element (INTERFACE_NODE, &no_csnp_interval_l1_arg_cmd); install_element (INTERFACE_NODE, &csnp_interval_l2_cmd); install_element (INTERFACE_NODE, &no_csnp_interval_l2_cmd); - install_element (INTERFACE_NODE, &no_csnp_interval_l2_arg_cmd); install_element (INTERFACE_NODE, &psnp_interval_cmd); install_element (INTERFACE_NODE, &no_psnp_interval_cmd); - install_element (INTERFACE_NODE, &no_psnp_interval_arg_cmd); install_element (INTERFACE_NODE, &psnp_interval_l1_cmd); install_element (INTERFACE_NODE, &no_psnp_interval_l1_cmd); - install_element (INTERFACE_NODE, &no_psnp_interval_l1_arg_cmd); install_element (INTERFACE_NODE, &psnp_interval_l2_cmd); install_element (INTERFACE_NODE, &no_psnp_interval_l2_cmd); - install_element (INTERFACE_NODE, &no_psnp_interval_l2_arg_cmd); install_element (ISIS_NODE, &metric_style_cmd); install_element (ISIS_NODE, &no_metric_style_cmd); @@ -2299,54 +2121,33 @@ isis_vty_init (void) install_element (ISIS_NODE, &area_lsp_mtu_cmd); install_element (ISIS_NODE, &no_area_lsp_mtu_cmd); - install_element (ISIS_NODE, &no_area_lsp_mtu_arg_cmd); install_element (ISIS_NODE, &is_type_cmd); install_element (ISIS_NODE, &no_is_type_cmd); install_element (ISIS_NODE, &lsp_gen_interval_cmd); install_element (ISIS_NODE, &no_lsp_gen_interval_cmd); - install_element (ISIS_NODE, &no_lsp_gen_interval_arg_cmd); install_element (ISIS_NODE, &lsp_gen_interval_l1_cmd); install_element (ISIS_NODE, &no_lsp_gen_interval_l1_cmd); - install_element (ISIS_NODE, &no_lsp_gen_interval_l1_arg_cmd); install_element (ISIS_NODE, &lsp_gen_interval_l2_cmd); install_element (ISIS_NODE, &no_lsp_gen_interval_l2_cmd); - install_element (ISIS_NODE, &no_lsp_gen_interval_l2_arg_cmd); install_element (ISIS_NODE, &spf_interval_cmd); install_element (ISIS_NODE, &no_spf_interval_cmd); - install_element (ISIS_NODE, &no_spf_interval_arg_cmd); install_element (ISIS_NODE, &spf_interval_l1_cmd); install_element (ISIS_NODE, &no_spf_interval_l1_cmd); - install_element (ISIS_NODE, &no_spf_interval_l1_arg_cmd); install_element (ISIS_NODE, &spf_interval_l2_cmd); install_element (ISIS_NODE, &no_spf_interval_l2_cmd); - install_element (ISIS_NODE, &no_spf_interval_l2_arg_cmd); install_element (ISIS_NODE, &max_lsp_lifetime_cmd); install_element (ISIS_NODE, &no_max_lsp_lifetime_cmd); - install_element (ISIS_NODE, &no_max_lsp_lifetime_arg_cmd); - install_element (ISIS_NODE, &max_lsp_lifetime_l1_cmd); - install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_cmd); - install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_arg_cmd); - install_element (ISIS_NODE, &max_lsp_lifetime_l2_cmd); - install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_cmd); - install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_arg_cmd); install_element (ISIS_NODE, &lsp_refresh_interval_cmd); install_element (ISIS_NODE, &no_lsp_refresh_interval_cmd); - install_element (ISIS_NODE, &no_lsp_refresh_interval_arg_cmd); - install_element (ISIS_NODE, &lsp_refresh_interval_l1_cmd); - install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_cmd); - install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_arg_cmd); - install_element (ISIS_NODE, &lsp_refresh_interval_l2_cmd); - install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_cmd); - install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_arg_cmd); install_element (ISIS_NODE, &area_passwd_md5_cmd); - install_element (ISIS_NODE, &area_passwd_md5_snpauth_cmd); install_element (ISIS_NODE, &area_passwd_clear_cmd); - install_element (ISIS_NODE, &area_passwd_clear_snpauth_cmd); + install_element (ISIS_NODE, &domain_passwd_md5_cmd); + install_element (ISIS_NODE, &domain_passwd_clear_cmd); install_element (ISIS_NODE, &no_area_passwd_cmd); } diff --git a/isisd/isisd.c b/isisd/isisd.c index d6ce627b93..c3bc33eb22 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -538,7 +538,8 @@ DEFUN (show_isis_interface_arg, "ISIS interface\n" "ISIS interface name\n") { - return show_isis_interface_common (vty, argv[0], ISIS_UI_LEVEL_DETAIL); + int idx_word = 3; + return show_isis_interface_common (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL); } /* @@ -712,7 +713,8 @@ DEFUN (show_isis_neighbor_arg, "ISIS neighbor adjacencies\n" "System id\n") { - return show_isis_neighbor_common (vty, argv[0], ISIS_UI_LEVEL_DETAIL); + int idx_word = 3; + return show_isis_neighbor_common (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL); } DEFUN (clear_isis_neighbor, @@ -733,7 +735,8 @@ DEFUN (clear_isis_neighbor_arg, "ISIS neighbor adjacencies\n" "System id\n") { - return clear_isis_neighbor_common (vty, argv[0]); + int idx_word = 3; + return clear_isis_neighbor_common (vty, argv[idx_word]->arg); } /* @@ -904,6 +907,7 @@ DEFUN (debug_isis_adj, DEFUN (no_debug_isis_adj, no_debug_isis_adj_cmd, "no debug isis adj-packets", + NO_STR UNDEBUG_STR "IS-IS information\n" "IS-IS Adjacency related packets\n") @@ -930,6 +934,7 @@ DEFUN (debug_isis_csum, DEFUN (no_debug_isis_csum, no_debug_isis_csum_cmd, "no debug isis checksum-errors", + NO_STR UNDEBUG_STR "IS-IS information\n" "IS-IS LSP checksum errors\n") @@ -956,6 +961,7 @@ DEFUN (debug_isis_lupd, DEFUN (no_debug_isis_lupd, no_debug_isis_lupd_cmd, "no debug isis local-updates", + NO_STR UNDEBUG_STR "IS-IS information\n" "IS-IS local update packets\n") @@ -982,6 +988,7 @@ DEFUN (debug_isis_err, DEFUN (no_debug_isis_err, no_debug_isis_err_cmd, "no debug isis protocol-errors", + NO_STR UNDEBUG_STR "IS-IS information\n" "IS-IS LSP protocol errors\n") @@ -1008,6 +1015,7 @@ DEFUN (debug_isis_snp, DEFUN (no_debug_isis_snp, no_debug_isis_snp_cmd, "no debug isis snp-packets", + NO_STR UNDEBUG_STR "IS-IS information\n" "IS-IS CSNP/PSNP packets\n") @@ -1034,6 +1042,7 @@ DEFUN (debug_isis_upd, DEFUN (no_debug_isis_upd, no_debug_isis_upd_cmd, "no debug isis update-packets", + NO_STR UNDEBUG_STR "IS-IS information\n" "IS-IS Update related packets\n") @@ -1060,6 +1069,7 @@ DEFUN (debug_isis_spfevents, DEFUN (no_debug_isis_spfevents, no_debug_isis_spfevents_cmd, "no debug isis spf-events", + NO_STR UNDEBUG_STR "IS-IS information\n" "IS-IS Shortest Path First Events\n") @@ -1086,6 +1096,7 @@ DEFUN (debug_isis_spfstats, DEFUN (no_debug_isis_spfstats, no_debug_isis_spfstats_cmd, "no debug isis spf-statistics", + NO_STR UNDEBUG_STR "IS-IS information\n" "IS-IS SPF Timing and Statistic Data\n") @@ -1112,6 +1123,7 @@ DEFUN (debug_isis_spftrigg, DEFUN (no_debug_isis_spftrigg, no_debug_isis_spftrigg_cmd, "no debug isis spf-triggers", + NO_STR UNDEBUG_STR "IS-IS information\n" "IS-IS SPF triggering events\n") @@ -1138,6 +1150,7 @@ DEFUN (debug_isis_rtevents, DEFUN (no_debug_isis_rtevents, no_debug_isis_rtevents_cmd, "no debug isis route-events", + NO_STR UNDEBUG_STR "IS-IS information\n" "IS-IS Route related events\n") @@ -1164,6 +1177,7 @@ DEFUN (debug_isis_events, DEFUN (no_debug_isis_events, no_debug_isis_events_cmd, "no debug isis events", + NO_STR UNDEBUG_STR "IS-IS information\n" "IS-IS Events\n") @@ -1190,6 +1204,7 @@ DEFUN (debug_isis_packet_dump, DEFUN (no_debug_isis_packet_dump, no_debug_isis_packet_dump_cmd, "no debug isis packet-dump", + NO_STR UNDEBUG_STR "IS-IS information\n" "IS-IS packet dump\n") @@ -1216,6 +1231,7 @@ DEFUN (debug_isis_lsp_gen, DEFUN (no_debug_isis_lsp_gen, no_debug_isis_lsp_gen_cmd, "no debug isis lsp-gen", + NO_STR UNDEBUG_STR "IS-IS information\n" "IS-IS generation of own LSPs\n") @@ -1242,6 +1258,7 @@ DEFUN (debug_isis_lsp_sched, DEFUN (no_debug_isis_lsp_sched, no_debug_isis_lsp_sched_cmd, "no debug isis lsp-sched", + NO_STR UNDEBUG_STR "IS-IS information\n" "IS-IS scheduling of LSP generation\n") @@ -1535,7 +1552,8 @@ DEFUN (show_database_lsp_brief, "IS-IS link state database\n" "LSP ID\n") { - return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_BRIEF); + int idx_word = 3; + return show_isis_database (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_BRIEF); } DEFUN (show_database_lsp_detail, @@ -1547,7 +1565,8 @@ DEFUN (show_database_lsp_detail, "LSP ID\n" "Detailed information\n") { - return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL); + int idx_word = 3; + return show_isis_database (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL); } DEFUN (show_database_detail, @@ -1569,7 +1588,8 @@ DEFUN (show_database_detail_lsp, "Detailed information\n" "LSP ID\n") { - return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL); + int idx_word = 4; + return show_isis_database (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL); } /* @@ -1582,7 +1602,8 @@ DEFUN (router_isis, "ISO IS-IS\n" "ISO Routing area tag") { - return isis_area_get (vty, argv[0]); + int idx_word = 2; + return isis_area_get (vty, argv[idx_word]->arg); } /* @@ -1593,7 +1614,8 @@ DEFUN (no_router_isis, "no router isis WORD", "no\n" ROUTER_STR "ISO IS-IS\n" "ISO Routing area tag") { - return isis_area_destroy (vty, argv[0]); + int idx_word = 3; + return isis_area_destroy (vty, argv[idx_word]->arg); } /* @@ -1605,7 +1627,8 @@ DEFUN (net, "A Network Entity Title for this process (OSI only)\n" "XX.XXXX. ... .XXX.XX Network entity title (NET)\n") { - return area_net_title (vty, argv[0]); + int idx_word = 1; + return area_net_title (vty, argv[idx_word]->arg); } /* @@ -1618,7 +1641,8 @@ DEFUN (no_net, "A Network Entity Title for this process (OSI only)\n" "XX.XXXX. ... .XXX.XX Network entity title (NET)\n") { - return area_clear_net_title (vty, argv[0]); + int idx_word = 2; + return area_clear_net_title (vty, argv[idx_word]->arg); } void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu) @@ -1882,6 +1906,7 @@ DEFUN (log_adj_changes, DEFUN (no_log_adj_changes, no_log_adj_changes_cmd, "no log-adjacency-changes", + NO_STR "Stop logging changes in adjacency state\n") { VTY_DECLVAR_CONTEXT (isis_area, area); @@ -1895,8 +1920,7 @@ DEFUN (no_log_adj_changes, DEFUN (topology_generate_grid, topology_generate_grid_cmd, - "topology generate grid <1-100> <1-100> <1-65000> [param] [param] " - "[param]", + "topology generate grid (1-100) (1-100) (1-65000) [param] [param] [param]", "Topology generation for IS-IS\n" "Topology generation\n" "Grid topology\n" @@ -1963,18 +1987,19 @@ DEFUN (topology_baseis, "A Network IS Base for this topology\n" "XXXX.XXXX.XXXX Network entity title (NET)\n") { + int idx_word = 2; u_char buff[ISIS_SYS_ID_LEN]; VTY_DECLVAR_CONTEXT (isis_area, area); - if (sysid2buff (buff, argv[0])) - sysid2buff (area->topology_baseis, argv[0]); + if (sysid2buff (buff, argv[idx_word]->arg)) + sysid2buff (area->topology_baseis, argv[idx_word]->arg); return CMD_SUCCESS; } DEFUN (no_topology_baseis, no_topology_baseis_cmd, - "no topology base-is WORD", + "no topology base-is [WORD]", NO_STR "Topology generation for IS-IS\n" "A Network IS Base for this topology\n" @@ -1986,12 +2011,6 @@ DEFUN (no_topology_baseis, return CMD_SUCCESS; } -ALIAS (no_topology_baseis, - no_topology_baseis_noid_cmd, - "no topology base-is", - NO_STR - "Topology generation for IS-IS\n" - "A Network IS Base for this topology\n") DEFUN (topology_basedynh, topology_basedynh_cmd, @@ -2000,10 +2019,11 @@ DEFUN (topology_basedynh, "Dynamic hostname base for this topology\n" "Dynamic hostname base\n") { + int idx_word = 2; VTY_DECLVAR_CONTEXT (isis_area, area); /* I hope that it's enough. */ - area->topology_basedynh = strndup (argv[0], 16); + area->topology_basedynh = strndup (argv[idx_word]->arg, 16); return CMD_SUCCESS; } @@ -2388,7 +2408,6 @@ isis_init () install_element (ISIS_NODE, &topology_baseis_cmd); install_element (ISIS_NODE, &topology_basedynh_cmd); install_element (ISIS_NODE, &no_topology_baseis_cmd); - install_element (ISIS_NODE, &no_topology_baseis_noid_cmd); install_element (VIEW_NODE, &show_isis_generated_topology_cmd); #endif /* TOPOLOGY_GENERATE */ } diff --git a/ldpd/ldp_vty_cmds.c b/ldpd/ldp_vty_cmds.c index b55c7fc8a9..64715999f2 100644 --- a/ldpd/ldp_vty_cmds.c +++ b/ldpd/ldp_vty_cmds.c @@ -96,7 +96,7 @@ DEFUN (ldp_address_family_ipv6, DEFUN (ldp_discovery_hello_holdtime_disc_time, ldp_discovery_hello_holdtime_disc_time_cmd, - "discovery hello holdtime <1-65535>", + "discovery hello holdtime (1-65535)", "Configure discovery parameters\n" "LDP Link Hellos\n" "Hello holdtime\n" @@ -113,7 +113,7 @@ DEFUN (ldp_discovery_hello_holdtime_disc_time, DEFUN (ldp_discovery_hello_interval_disc_time, ldp_discovery_hello_interval_disc_time_cmd, - "discovery hello interval <1-65535>", + "discovery hello interval (1-65535)", "Configure discovery parameters\n" "LDP Link Hellos\n" "Hello interval\n" @@ -130,7 +130,7 @@ DEFUN (ldp_discovery_hello_interval_disc_time, DEFUN (ldp_discovery_targeted_hello_holdtime_disc_time, ldp_discovery_targeted_hello_holdtime_disc_time_cmd, - "discovery targeted-hello holdtime <1-65535>", + "discovery targeted-hello holdtime (1-65535)", "Configure discovery parameters\n" "LDP Targeted Hellos\n" "Targeted hello holdtime\n" @@ -147,7 +147,7 @@ DEFUN (ldp_discovery_targeted_hello_holdtime_disc_time, DEFUN (ldp_discovery_targeted_hello_interval_disc_time, ldp_discovery_targeted_hello_interval_disc_time_cmd, - "discovery targeted-hello interval <1-65535>", + "discovery targeted-hello interval (1-65535)", "Configure discovery parameters\n" "LDP Targeted Hellos\n" "Targeted hello interval\n" @@ -203,7 +203,7 @@ DEFUN (ldp_neighbor_ipv4_password_word, DEFUN (ldp_neighbor_ipv4_session_holdtime_session_time, ldp_neighbor_ipv4_session_holdtime_session_time_cmd, - "neighbor A.B.C.D session holdtime <15-65535>", + "neighbor A.B.C.D session holdtime (15-65535)", "Configure neighbor parameters\n" "LDP Id of neighbor\n" "Configure session parameters\n" @@ -237,7 +237,7 @@ DEFUN (ldp_neighbor_ipv4_ttl_security_disable, DEFUN (ldp_neighbor_ipv4_ttl_security_hops_hops, ldp_neighbor_ipv4_ttl_security_hops_hops_cmd, - "neighbor A.B.C.D ttl-security hops <1-254>", + "neighbor A.B.C.D ttl-security hops (1-254)", "Configure neighbor parameters\n" "LDP Id of neighbor\n" "LDP ttl security check\n" @@ -301,7 +301,7 @@ DEFUN (ldp_no_address_family_ipv6, DEFUN (ldp_no_discovery_hello_holdtime_disc_time, ldp_no_discovery_hello_holdtime_disc_time_cmd, - "no discovery hello holdtime <1-65535>", + "no discovery hello holdtime (1-65535)", "Negate a command or set its defaults\n" "Configure discovery parameters\n" "LDP Link Hellos\n" @@ -320,7 +320,7 @@ DEFUN (ldp_no_discovery_hello_holdtime_disc_time, DEFUN (ldp_no_discovery_hello_interval_disc_time, ldp_no_discovery_hello_interval_disc_time_cmd, - "no discovery hello interval <1-65535>", + "no discovery hello interval (1-65535)", "Negate a command or set its defaults\n" "Configure discovery parameters\n" "LDP Link Hellos\n" @@ -339,7 +339,7 @@ DEFUN (ldp_no_discovery_hello_interval_disc_time, DEFUN (ldp_no_discovery_targeted_hello_holdtime_disc_time, ldp_no_discovery_targeted_hello_holdtime_disc_time_cmd, - "no discovery targeted-hello holdtime <1-65535>", + "no discovery targeted-hello holdtime (1-65535)", "Negate a command or set its defaults\n" "Configure discovery parameters\n" "LDP Targeted Hellos\n" @@ -358,7 +358,7 @@ DEFUN (ldp_no_discovery_targeted_hello_holdtime_disc_time, DEFUN (ldp_no_discovery_targeted_hello_interval_disc_time, ldp_no_discovery_targeted_hello_interval_disc_time_cmd, - "no discovery targeted-hello interval <1-65535>", + "no discovery targeted-hello interval (1-65535)", "Negate a command or set its defaults\n" "Configure discovery parameters\n" "LDP Targeted Hellos\n" @@ -428,7 +428,7 @@ DEFUN (ldp_no_neighbor_ipv4_password_word, DEFUN (ldp_no_neighbor_ipv4_session_holdtime_session_time, ldp_no_neighbor_ipv4_session_holdtime_session_time_cmd, - "no neighbor A.B.C.D session holdtime <15-65535>", + "no neighbor A.B.C.D session holdtime (15-65535)", "Negate a command or set its defaults\n" "Configure neighbor parameters\n" "LDP Id of neighbor\n" @@ -466,7 +466,7 @@ DEFUN (ldp_no_neighbor_ipv4_ttl_security_disable, DEFUN (ldp_no_neighbor_ipv4_ttl_security_hops_hops, ldp_no_neighbor_ipv4_ttl_security_hops_hops_cmd, - "no neighbor A.B.C.D ttl-security hops <1-254>", + "no neighbor A.B.C.D ttl-security hops (1-254)", "Negate a command or set its defaults\n" "Configure neighbor parameters\n" "LDP Id of neighbor\n" @@ -539,7 +539,7 @@ DEFUN (ldp_ttl_security_disable, DEFUN (ldp_session_holdtime_session_time, ldp_session_holdtime_session_time_cmd, - "session holdtime <15-65535>", + "session holdtime (15-65535)", "Configure session parameters\n" "Configure session holdtime\n" "Time (seconds)\n") @@ -647,7 +647,7 @@ DEFUN (ldp_no_ttl_security_disable, DEFUN (ldp_no_session_holdtime_session_time, ldp_no_session_holdtime_session_time_cmd, - "no session holdtime <15-65535>", + "no session holdtime (15-65535)", "Negate a command or set its defaults\n" "Configure session parameters\n" "Configure session holdtime\n" @@ -792,7 +792,7 @@ DEFUN (ldp_bridge_ifname, DEFUN (ldp_mtu_mtu, ldp_mtu_mtu_cmd, - "mtu <1500-9180>", + "mtu (1500-9180)", "set Maximum Transmission Unit\n" "Maximum Transmission Unit value\n") { @@ -836,7 +836,7 @@ DEFUN (ldp_member_pseudowire_ifname, DEFUN (ldp_vc_type_pwtype, ldp_vc_type_pwtype_cmd, - "vc type (ethernet|ethernet-tagged)", + "vc type <ethernet|ethernet-tagged>", "Virtual Circuit options\n" "Virtual Circuit type to use\n" "Ethernet (type 5)\n" @@ -868,7 +868,7 @@ DEFUN (ldp_no_bridge_ifname, DEFUN (ldp_no_mtu_mtu, ldp_no_mtu_mtu_cmd, - "no mtu <1500-9180>", + "no mtu (1500-9180)", "Negate a command or set its defaults\n" "set Maximum Transmission Unit\n" "Maximum Transmission Unit value\n") @@ -918,7 +918,7 @@ DEFUN (ldp_no_member_pseudowire_ifname, DEFUN (ldp_no_vc_type_pwtype, ldp_no_vc_type_pwtype_cmd, - "no vc type (ethernet|ethernet-tagged)", + "no vc type <ethernet|ethernet-tagged>", "Negate a command or set its defaults\n" "Virtual Circuit options\n" "Virtual Circuit type to use\n" @@ -936,7 +936,7 @@ DEFUN (ldp_no_vc_type_pwtype, DEFUN (ldp_control_word_cword, ldp_control_word_cword_cmd, - "control-word (exclude|include)", + "control-word <exclude|include>", "Control-word options\n" "Exclude control-word in pseudowire packets\n" "Include control-word in pseudowire packets\n") @@ -951,7 +951,7 @@ DEFUN (ldp_control_word_cword, DEFUN (ldp_neighbor_address_addr, ldp_neighbor_address_addr_cmd, - "neighbor address (A.B.C.D|X:X::X:X)", + "neighbor address <A.B.C.D|X:X::X:X>", "Remote endpoint configuration\n" "Specify the IPv4 or IPv6 address of the remote endpoint\n" "IPv4 address\n" @@ -982,7 +982,7 @@ DEFUN (ldp_neighbor_lsr_id_ipv4, DEFUN (ldp_pw_id_pwid, ldp_pw_id_pwid_cmd, - "pw-id <1-4294967295>", + "pw-id (1-4294967295)", "Set the Virtual Circuit ID\n" "Virtual Circuit ID value\n") { @@ -1006,7 +1006,7 @@ DEFUN (ldp_pw_status_disable, DEFUN (ldp_no_control_word_cword, ldp_no_control_word_cword_cmd, - "no control-word (exclude|include)", + "no control-word <exclude|include>", "Negate a command or set its defaults\n" "Control-word options\n" "Exclude control-word in pseudowire packets\n" @@ -1023,7 +1023,7 @@ DEFUN (ldp_no_control_word_cword, DEFUN (ldp_no_neighbor_address_addr, ldp_no_neighbor_address_addr_cmd, - "no neighbor address (A.B.C.D|X:X::X:X)", + "no neighbor address <A.B.C.D|X:X::X:X>", "Negate a command or set its defaults\n" "Remote endpoint configuration\n" "Specify the IPv4 or IPv6 address of the remote endpoint\n" @@ -1058,7 +1058,7 @@ DEFUN (ldp_no_neighbor_lsr_id_ipv4, DEFUN (ldp_no_pw_id_pwid, ldp_no_pw_id_pwid_cmd, - "no pw-id <1-4294967295>", + "no pw-id (1-4294967295)", "Negate a command or set its defaults\n" "Set the Virtual Circuit ID\n" "Virtual Circuit ID value\n") @@ -1137,7 +1137,7 @@ DEFUN (ldp_show_mpls_ldp_interface, DEFUN (ldp_show_mpls_ldp_address_family_binding, ldp_show_mpls_ldp_address_family_binding_cmd, - "show mpls ldp (ipv4|ipv6) binding", + "show mpls ldp <ipv4|ipv6> binding", "Show running system information\n" "MPLS information\n" "Label Distribution Protocol\n" @@ -1155,7 +1155,7 @@ DEFUN (ldp_show_mpls_ldp_address_family_binding, DEFUN (ldp_show_mpls_ldp_address_family_discovery, ldp_show_mpls_ldp_address_family_discovery_cmd, - "show mpls ldp (ipv4|ipv6) discovery", + "show mpls ldp <ipv4|ipv6> discovery", "Show running system information\n" "MPLS information\n" "Label Distribution Protocol\n" @@ -1173,7 +1173,7 @@ DEFUN (ldp_show_mpls_ldp_address_family_discovery, DEFUN (ldp_show_mpls_ldp_address_family_interface, ldp_show_mpls_ldp_address_family_interface_cmd, - "show mpls ldp (ipv4|ipv6) interface", + "show mpls ldp <ipv4|ipv6> interface", "Show running system information\n" "MPLS information\n" "Label Distribution Protocol\n" @@ -1239,7 +1239,7 @@ DEFUN (ldp_clear_mpls_ldp_neighbor, DEFUN (ldp_clear_mpls_ldp_neighbor_addr, ldp_clear_mpls_ldp_neighbor_addr_cmd, - "clear mpls ldp neighbor (A.B.C.D|X:X::X:X)", + "clear mpls ldp neighbor <A.B.C.D|X:X::X:X>", "Reset functions\n" "Reset MPLS statistical information\n" "Clear LDP state\n" @@ -1257,7 +1257,7 @@ DEFUN (ldp_clear_mpls_ldp_neighbor_addr, DEFUN (ldp_debug_mpls_ldp_discovery_hello_dir, ldp_debug_mpls_ldp_discovery_hello_dir_cmd, - "debug mpls ldp discovery hello (recv|sent)", + "debug mpls ldp discovery hello <recv|sent>", "Debugging functions\n" "MPLS information\n" "Label Distribution Protocol\n" @@ -1401,7 +1401,7 @@ DEFUN (ldp_debug_mpls_ldp_zebra, DEFUN (ldp_no_debug_mpls_ldp_discovery_hello_dir, ldp_no_debug_mpls_ldp_discovery_hello_dir_cmd, - "no debug mpls ldp discovery hello (recv|sent)", + "no debug mpls ldp discovery hello <recv|sent>", "Negate a command or set its defaults\n" "Debugging functions\n" "MPLS information\n" diff --git a/lib/.gitignore b/lib/.gitignore index fe75137bca..e45fec1786 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -15,4 +15,7 @@ gitversion.h.tmp *~ *.loT route_types.h +command_lex.c +command_parse.c +command_parse.h refix diff --git a/lib/Makefile.am b/lib/Makefile.am index 1c0906837a..f0d5bd53db 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -4,13 +4,16 @@ AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib \ -DVTY_DEPRECATE_INDEX AM_CFLAGS = $(WERROR) DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" +AM_YFLAGS = -d lib_LTLIBRARIES = libzebra.la libzebra_la_LDFLAGS = -version-info 0:0:0 libzebra_la_SOURCES = \ network.c pid_output.c getopt.c getopt1.c daemon.c \ - checksum.c vector.c linklist.c vty.c command.c \ + checksum.c vector.c linklist.c vty.c \ + graph.c command_parse.y command_lex.l command_match.c \ + command.c \ sockunion.c prefix.c thread.c if.c buffer.c table.c hash.c \ filter.c routemap.c distribute.c stream.c str.c log.c plist.c \ zclient.c sockopt.c smux.c agentx.c snmp.c md5.c if_rmap.c keychain.c privs.c \ @@ -20,15 +23,17 @@ libzebra_la_SOURCES = \ qobj.c \ event_counter.c -BUILT_SOURCES = route_types.h gitversion.h +BUILT_SOURCES = route_types.h gitversion.h command_parse.h libzebra_la_DEPENDENCIES = @LIB_REGEX@ libzebra_la_LIBADD = @LIB_REGEX@ @LIBCAP@ pkginclude_HEADERS = \ - buffer.h checksum.h command.h filter.h getopt.h hash.h \ + buffer.h checksum.h filter.h getopt.h hash.h \ if.h linklist.h log.h \ + graph.h command_match.h \ + command.h \ memory.h network.h prefix.h routemap.h distribute.h sockunion.h \ str.h stream.h table.h thread.h vector.h version.h vty.h zebra.h \ plist.h zclient.h sockopt.h smux.h md5.h if_rmap.h keychain.h \ @@ -65,7 +70,7 @@ GITH=gitversion.h gitversion.h.tmp: $(srcdir)/../.git @PERL@ $(srcdir)/gitversion.pl $(srcdir) > ${GITH}.tmp gitversion.h: gitversion.h.tmp - { test -f ${GITH} && diff -s -q ${GITH}.tmp ${GITH}; } || cp -v ${GITH}.tmp ${GITH} + { test -f ${GITH} && diff -s -q ${GITH}.tmp ${GITH}; } || cp -v ${GITH}.tmp ${GITH} else .PHONY: gitversion.h @@ -26,11 +26,6 @@ #include "lib/json.h" -#define BFD_CMD_DETECT_MULT_RANGE "<2-255> " -#define BFD_CMD_MIN_RX_RANGE "<50-60000> " -#define BFD_CMD_MIN_TX_RANGE "<50-60000>" -#define BFD_CMD_TYPE "(multihop|singlehop)" - #define BFD_DEF_MIN_RX 300 #define BFD_MIN_MIN_RX 50 #define BFD_MAX_MIN_RX 60000 diff --git a/lib/command.c b/lib/command.c index e8ba637623..bf7e269acc 100644 --- a/lib/command.c +++ b/lib/command.c @@ -1,25 +1,29 @@ /* - Command interpreter routine for virtual terminal [aka TeletYpe] - Copyright (C) 1997, 98, 99 Kunihiro Ishiguro - Copyright (C) 2013 by Open Source Routing. - Copyright (C) 2013 by Internet Systems Consortium, Inc. ("ISC") - -This file is part of GNU Zebra. - -GNU Zebra is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published -by the Free Software Foundation; either version 2, or (at your -option) any later version. - -GNU Zebra is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Zebra; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ + * CLI backend interface. + * + * -- + * Copyright (C) 2016 Cumulus Networks, Inc. + * Copyright (C) 1997, 98, 99 Kunihiro Ishiguro + * Copyright (C) 2013 by Open Source Routing. + * Copyright (C) 2013 by Internet Systems Consortium, Inc. ("ISC") + * + * This file is part of GNU Zebra. + * + * GNU Zebra is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * GNU Zebra is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Zebra; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ #include <zebra.h> @@ -29,10 +33,13 @@ Boston, MA 02111-1307, USA. */ #include <lib/version.h> #include "thread.h" #include "vector.h" +#include "linklist.h" #include "vty.h" #include "command.h" #include "workqueue.h" #include "vrf.h" +#include "command_match.h" +#include "command_parse.h" #include "qobj.h" DEFINE_MTYPE( LIB, HOST, "Host config") @@ -43,44 +50,6 @@ DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command desc") each daemon maintains each own cmdvec. */ vector cmdvec = NULL; -struct cmd_token token_cr; -char *command_cr = NULL; - -/** - * Filter types. These tell the parser whether to allow - * partial matching on tokens. - */ -enum filter_type -{ - FILTER_RELAXED, - FILTER_STRICT -}; - -/** - * Command matcher result value. - */ -enum matcher_rv -{ - MATCHER_OK, - MATCHER_COMPLETE, - MATCHER_INCOMPLETE, - MATCHER_NO_MATCH, - MATCHER_AMBIGUOUS, - MATCHER_EXCEED_ARGC_MAX -}; - -/** - * Defines which matcher_rv values constitute - * an error. Should be used against matcher_rv - * return values to do basic error checking. - */ -#define MATCHER_ERROR(matcher_rv) \ - ( (matcher_rv) == MATCHER_INCOMPLETE \ - || (matcher_rv) == MATCHER_NO_MATCH \ - || (matcher_rv) == MATCHER_AMBIGUOUS \ - || (matcher_rv) == MATCHER_EXCEED_ARGC_MAX \ - ) - /* Host information structure. */ struct host host; @@ -128,7 +97,7 @@ static const struct facility_map { int facility; const char *name; size_t match; -} syslog_facilities[] = +} syslog_facilities[] = { { LOG_KERN, "kern", 1 }, { LOG_USER, "user", 2 }, @@ -180,7 +149,7 @@ static int level_match(const char *s) { int level ; - + for ( level = 0 ; zlog_priority [level] != NULL ; level ++ ) if (!strncmp (s, zlog_priority[level], 2)) return level; @@ -200,7 +169,7 @@ print_version (const char *progname) /* Utility function to concatenate argv argument into a single string with inserting ' ' character between each argument. */ char * -argv_concat (const char **argv, int argc, int shift) +argv_concat (struct cmd_token **argv, int argc, int shift) { int i; size_t len; @@ -209,14 +178,14 @@ argv_concat (const char **argv, int argc, int shift) len = 0; for (i = shift; i < argc; i++) - len += strlen(argv[i])+1; + len += strlen(argv[i]->arg)+1; if (!len) return NULL; p = str = XMALLOC(MTYPE_TMP, len); for (i = shift; i < argc; i++) { size_t arglen; - memcpy(p, argv[i], (arglen = strlen(argv[i]))); + memcpy(p, argv[i]->arg, (arglen = strlen(argv[i]->arg))); p += arglen; *p++ = ' '; } @@ -224,6 +193,26 @@ argv_concat (const char **argv, int argc, int shift) return str; } +/** + * Convenience function for accessing argv data. + * + * @param argc + * @param argv + * @param text definition snippet of the desired token + * @param index the starting index, and where to store the + * index of the found token if it exists + * @return 1 if found, 0 otherwise + */ +int +argv_find (struct cmd_token **argv, int argc, const char *text, int *index) +{ + int found = 0; + for (int i = *index; i < argc && found == 0; i++) + if ((found = strmatch (text, argv[i]->text))) + *index = i; + return found; +} + static unsigned int cmd_hash_key (void *p) { @@ -238,65 +227,57 @@ cmd_hash_cmp (const void *a, const void *b) /* Install top node of command vector. */ void -install_node (struct cmd_node *node, - int (*func) (struct vty *)) +install_node (struct cmd_node *node, + int (*func) (struct vty *)) { vector_set_index (cmdvec, node->node, node); node->func = func; + node->cmdgraph = graph_new (); node->cmd_vector = vector_init (VECTOR_MIN_SIZE); + // add start node + struct cmd_token *token = new_cmd_token (START_TKN, CMD_ATTR_NORMAL, NULL, NULL); + graph_new_node (node->cmdgraph, token, (void (*)(void *)) &del_cmd_token); node->cmd_hash = hash_create (cmd_hash_key, cmd_hash_cmp); } -/* Breaking up string into each command piece. I assume given - character is separated by a space character. Return value is a - vector which includes char ** data element. */ +/** + * Tokenizes a string, storing tokens in a vector. + * Whitespace is ignored. + * + * Delimiter string = " \n\r\t". + * + * @param string to tokenize + * @return tokenized string + */ vector cmd_make_strvec (const char *string) { - const char *cp, *start; - char *token; - int strlen; - vector strvec; - - if (string == NULL) - return NULL; - - cp = string; + if (!string) return NULL; - /* Skip white spaces. */ - while (isspace ((int) *cp) && *cp != '\0') - cp++; + char *copy, *copystart; + copystart = copy = XSTRDUP (MTYPE_TMP, string); - /* Return if there is only white spaces */ - if (*cp == '\0') - return NULL; + // skip leading whitespace + while (isspace ((int) *copy) && *copy != '\0') copy++; - if (*cp == '!' || *cp == '#') + // if the entire string was whitespace or a comment, return + if (*copy == '\0' || *copy == '!' || *copy == '#') + { + XFREE (MTYPE_TMP, copystart); return NULL; + } - /* Prepare return vector. */ - strvec = vector_init (VECTOR_MIN_SIZE); + vector strvec = vector_init (VECTOR_MIN_SIZE); + const char *delim = " \n\r\t", *tok = NULL; + while (copy) + { + tok = strsep (©, delim); + if (*tok != '\0') + vector_set (strvec, XSTRDUP (MTYPE_STRVEC, tok)); + } - /* Copy each command piece and set into vector. */ - while (1) - { - start = cp; - while (!(isspace ((int) *cp) || *cp == '\r' || *cp == '\n') && - *cp != '\0') - cp++; - strlen = cp - start; - token = XMALLOC (MTYPE_STRVEC, strlen + 1); - memcpy (token, start, strlen); - *(token + strlen) = '\0'; - vector_set (strvec, token); - - while ((isspace ((int) *cp) || *cp == '\n' || *cp == '\r') && - *cp != '\0') - cp++; - - if (*cp == '\0') - return strvec; - } + XFREE (MTYPE_TMP, copystart); + return strvec; } /* Free allocated string vector. */ @@ -316,387 +297,22 @@ cmd_free_strvec (vector v) vector_free (v); } -/** - * State structure for command format parser. Tracks - * parse tree position and miscellaneous state variables. - * Used when building a command vector from format strings. - */ -struct format_parser_state -{ - vector topvect; /* Top level vector */ - vector intvect; /* Intermediate level vector, used when there's - a multiple in a keyword. */ - vector curvect; /* current vector where read tokens should be - appended. */ - - const char *string; /* pointer to command string, not modified */ - const char *cp; /* pointer in command string, moved along while - parsing */ - const char *dp; /* pointer in description string, moved along while - parsing */ - - int in_keyword; /* flag to remember if we are in a keyword group */ - int in_multiple; /* flag to remember if we are in a multiple group */ - int just_read_word; /* flag to remember if the last thing we read was a - real word and not some abstract token */ -}; - -static void -format_parser_error(struct format_parser_state *state, const char *message) -{ - int offset = state->cp - state->string + 1; - - fprintf(stderr, "\nError parsing command: \"%s\"\n", state->string); - fprintf(stderr, " %*c\n", offset, '^'); - fprintf(stderr, "%s at offset %d.\n", message, offset); - fprintf(stderr, "This is a programming error. Check your DEFUNs etc.\n"); - exit(1); -} - -/** - * Reads out one section of a help string from state->dp. - * Leading whitespace is trimmed and the string is read until - * a newline is reached. - * - * @param[out] state format parser state - * @return the help string token read - */ -static char * -format_parser_desc_str(struct format_parser_state *state) -{ - const char *cp, *start; - char *token; - int strlen; - - cp = state->dp; - - if (cp == NULL) - return NULL; - - /* Skip white spaces. */ - while (isspace ((int) *cp) && *cp != '\0') - cp++; - - /* Return if there is only white spaces */ - if (*cp == '\0') - return NULL; - - start = cp; - - while (!(*cp == '\r' || *cp == '\n') && *cp != '\0') - cp++; - - strlen = cp - start; - token = XMALLOC (MTYPE_CMD_TOKENS, strlen + 1); - memcpy (token, start, strlen); - *(token + strlen) = '\0'; - - state->dp = cp; - - return token; -} - -/** - * Transitions format parser state into keyword parsing mode. - * A cmd_token struct, `token`, representing this keyword token is initialized - * and appended to state->curvect. token->keyword is initialized as a vector of - * vector, a new vector is initialized and added to token->keyword, and - * state->curvect is set to point at this vector. When control returns to the - * caller newly parsed tokens will be added to this vector. - * - * In short: - * state->curvect[HEAD] = new cmd_token - * state->curvect[HEAD]->keyword[0] = new vector - * state->curvect = state->curvect[HEAD]->keyword[0] - * - * @param[out] state state struct to transition - */ -static void -format_parser_begin_keyword(struct format_parser_state *state) -{ - struct cmd_token *token; - vector keyword_vect; - - if (state->in_keyword - || state->in_multiple) - format_parser_error(state, "Unexpected '{'"); - - state->cp++; - state->in_keyword = 1; - - token = XCALLOC(MTYPE_CMD_TOKENS, sizeof(*token)); - token->type = TOKEN_KEYWORD; - token->keyword = vector_init(VECTOR_MIN_SIZE); - - keyword_vect = vector_init(VECTOR_MIN_SIZE); - vector_set(token->keyword, keyword_vect); - - vector_set(state->curvect, token); - state->curvect = keyword_vect; -} - -/** - * Transitions format parser state into multiple parsing mode. - * A cmd_token struct, `token`, representing this multiple token is initialized - * and appended to state->curvect. token->multiple is initialized as a vector - * of cmd_token and state->curvect is set to point at token->multiple. If - * state->curvect != state->topvect (i.e. this multiple token is nested inside - * another composite token) then a pointer to state->curvect is saved in - * state->intvect. - * - * In short: - * state->curvect[HEAD] = new cmd_token - * state->curvect[HEAD]->multiple = new vector - * state->intvect = state->curvect IFF nested token - * state->curvect = state->curvect[HEAD]->multiple - * - * @param[out] state state struct to transition - */ -static void -format_parser_begin_multiple(struct format_parser_state *state) -{ - struct cmd_token *token; - - if (state->in_keyword == 1) - format_parser_error(state, "Keyword starting with '('"); - - if (state->in_multiple) - format_parser_error(state, "Nested group"); - - state->cp++; - state->in_multiple = 1; - state->just_read_word = 0; - - token = XCALLOC(MTYPE_CMD_TOKENS, sizeof(*token)); - token->type = TOKEN_MULTIPLE; - token->multiple = vector_init(VECTOR_MIN_SIZE); - - vector_set(state->curvect, token); - if (state->curvect != state->topvect) - state->intvect = state->curvect; - state->curvect = token->multiple; -} - -/** - * Transition format parser state out of keyword parsing mode. - * This function is called upon encountering '}'. - * state->curvect is reassigned to the top level vector (as - * keywords cannot be nested) and state flags are set appropriately. - * - * @param[out] state state struct to transition - */ -static void -format_parser_end_keyword(struct format_parser_state *state) -{ - if (state->in_multiple - || !state->in_keyword) - format_parser_error(state, "Unexpected '}'"); - - if (state->in_keyword == 1) - format_parser_error(state, "Empty keyword group"); - - state->cp++; - state->in_keyword = 0; - state->curvect = state->topvect; -} - -/** - * Transition format parser state out of multiple parsing mode. - * This function is called upon encountering ')'. - * state->curvect is reassigned to its parent vector (state->intvect - * if the multiple token being exited was nested inside another token, - * state->topvect otherwise) and state flags are set appropriately. - * - * @param[out] state state struct to transition - */ -static void -format_parser_end_multiple(struct format_parser_state *state) -{ - char *dummy; - - if (!state->in_multiple) - format_parser_error(state, "Unexpected ')'"); - - if (vector_active(state->curvect) == 0) - format_parser_error(state, "Empty multiple section"); - - if (!state->just_read_word) - { - /* There are constructions like - * 'show ip ospf database ... (self-originate|)' - * in use. - * The old parser reads a description string for the - * word '' between |) which will never match. - * Simulate this behvaior by dropping the next desc - * string in such a case. */ - - dummy = format_parser_desc_str(state); - XFREE(MTYPE_CMD_TOKENS, dummy); - } - - state->cp++; - state->in_multiple = 0; - - if (state->intvect) - state->curvect = state->intvect; - else - state->curvect = state->topvect; -} - -/** - * Format parser handler for pipe '|' character. - * This character separates subtokens in multiple and keyword type tokens. - * If the current token is a multiple keyword, the position pointer is - * simply moved past the pipe and state flags are set appropriately. - * If the current token is a keyword token, the position pointer is moved - * past the pipe. Then the cmd_token struct for the keyword is fetched and - * a new vector of cmd_token is appended to its vector of vector. Finally - * state->curvect is set to point at this new vector. - * - * In short: - * state->curvect = state->topvect[HEAD]->keyword[HEAD] = new vector - * - * @param[out] state state struct to transition - */ -static void -format_parser_handle_pipe(struct format_parser_state *state) -{ - struct cmd_token *keyword_token; - vector keyword_vect; - - if (state->in_multiple) - { - state->just_read_word = 0; - state->cp++; - } - else if (state->in_keyword) - { - state->in_keyword = 1; - state->cp++; - - keyword_token = vector_slot(state->topvect, - vector_active(state->topvect) - 1); - keyword_vect = vector_init(VECTOR_MIN_SIZE); - vector_set(keyword_token->keyword, keyword_vect); - state->curvect = keyword_vect; - } - else - { - format_parser_error(state, "Unexpected '|'"); - } -} - -/** - * Format parser handler for terminal tokens. - * Parses the token, appends it to state->curvect, and sets - * state flags appropriately. - * - * @param[out] state state struct for current format parser state - */ -static void -format_parser_read_word(struct format_parser_state *state) -{ - const char *start; - int len; - char *cmd; - struct cmd_token *token; - - start = state->cp; - - while (state->cp[0] != '\0' - && !strchr("\r\n(){}|", state->cp[0]) - && !isspace((int)state->cp[0])) - state->cp++; - - len = state->cp - start; - cmd = XMALLOC(MTYPE_CMD_TOKENS, len + 1); - memcpy(cmd, start, len); - cmd[len] = '\0'; - - token = XCALLOC(MTYPE_CMD_TOKENS, sizeof(*token)); - token->type = TOKEN_TERMINAL; - if (strcmp (cmd, "A.B.C.D") == 0) - token->terminal = TERMINAL_IPV4; - else if (strcmp (cmd, "A.B.C.D/M") == 0) - token->terminal = TERMINAL_IPV4_PREFIX; - else if (strcmp (cmd, "X:X::X:X") == 0) - token->terminal = TERMINAL_IPV6; - else if (strcmp (cmd, "X:X::X:X/M") == 0) - token->terminal = TERMINAL_IPV6_PREFIX; - else if (cmd[0] == '[') - token->terminal = TERMINAL_OPTION; - else if (cmd[0] == '.') - token->terminal = TERMINAL_VARARG; - else if (cmd[0] == '<') - token->terminal = TERMINAL_RANGE; - else if (cmd[0] >= 'A' && cmd[0] <= 'Z') - token->terminal = TERMINAL_VARIABLE; - else - token->terminal = TERMINAL_LITERAL; - - token->cmd = cmd; - token->desc = format_parser_desc_str(state); - vector_set(state->curvect, token); - - if (state->in_keyword == 1) - state->in_keyword = 2; - - state->just_read_word = 1; -} - -/** - * Parse a given command format string and build a tree of tokens from - * it that is suitable to be used by the command subsystem. - * - * @param string Command format string. - * @param descstr Description string. - * @return A vector of struct cmd_token representing the given command, - * or NULL on error. - */ -static vector -cmd_parse_format(const char *string, const char *descstr) +char * +cmd_concat_strvec (vector v) { - struct format_parser_state state; - - if (string == NULL) - return NULL; - - memset(&state, 0, sizeof(state)); - state.topvect = state.curvect = vector_init(VECTOR_MIN_SIZE); - state.cp = state.string = string; - state.dp = descstr; + size_t strsize = 0; + for (unsigned int i = 0; i < vector_active (v); i++) + if (vector_slot (v, i)) + strsize += strlen ((char *) vector_slot (v, i)) + 1; - while (1) - { - while (isspace((int)state.cp[0]) && state.cp[0] != '\0') - state.cp++; + char *concatenated = calloc (sizeof (char), strsize); + for (unsigned int i = 0; i < vector_active (v); i++) + { + strlcat (concatenated, (char *) vector_slot (v, i), strsize); + strlcat (concatenated, " ", strsize); + } - switch (state.cp[0]) - { - case '\0': - if (state.in_keyword - || state.in_multiple) - format_parser_error(&state, "Unclosed group/keyword"); - return state.topvect; - case '{': - format_parser_begin_keyword(&state); - break; - case '(': - format_parser_begin_multiple(&state); - break; - case '}': - format_parser_end_keyword(&state); - break; - case ')': - format_parser_end_multiple(&state); - break; - case '|': - format_parser_handle_pipe(&state); - break; - default: - format_parser_read_word(&state); - } - } + return concatenated; } /* Return prompt character of specified node. */ @@ -714,7 +330,7 @@ void install_element (enum node_type ntype, struct cmd_element *cmd) { struct cmd_node *cnode; - + /* cmd_init hasn't been called */ if (!cmdvec) { @@ -722,29 +338,28 @@ install_element (enum node_type ntype, struct cmd_element *cmd) __func__); return; } - + cnode = vector_slot (cmdvec, ntype); - if (cnode == NULL) + if (cnode == NULL) { fprintf (stderr, "Command node %d doesn't exist, please check it\n", - ntype); - exit (1); + ntype); + exit (EXIT_FAILURE); } - + if (hash_lookup (cnode->cmd_hash, cmd) != NULL) { - fprintf (stderr, + fprintf (stderr, "Multiple command installs to node %d of command:\n%s\n", ntype, cmd->string); return; } - + assert (hash_get (cnode->cmd_hash, cmd, hash_alloc_intern)); - + + command_parse_format (cnode->cmdgraph, cmd); vector_set (cnode->cmd_vector, cmd); - if (cmd->tokens == NULL) - cmd->tokens = cmd_parse_format(cmd->string, cmd->doc); if (ntype == VIEW_NODE) install_element (ENABLE_NODE, cmd); @@ -756,7 +371,7 @@ static const unsigned char itoa64[] = static void to64(char *s, long v, int n) { - while (--n >= 0) + while (--n >= 0) { *s++ = itoa64[v&0x3f]; v >>= 6; @@ -771,7 +386,7 @@ zencrypt (const char *passwd) char *crypt (const char *, const char *); gettimeofday(&tv,0); - + to64(&salt[0], random(), 3); to64(&salt[3], tv.tv_usec, 3); salt[5] = '\0'; @@ -789,9 +404,9 @@ config_write_host (struct vty *vty) if (host.encrypt) { if (host.password_encrypt) - vty_out (vty, "password 8 %s%s", host.password_encrypt, VTY_NEWLINE); + vty_out (vty, "password 8 %s%s", host.password_encrypt, VTY_NEWLINE); if (host.enable_encrypt) - vty_out (vty, "enable password 8 %s%s", host.enable_encrypt, VTY_NEWLINE); + vty_out (vty, "enable password 8 %s%s", host.enable_encrypt, VTY_NEWLINE); } else { @@ -804,17 +419,17 @@ config_write_host (struct vty *vty) if (zlog_default->default_lvl != LOG_DEBUG) { vty_out (vty, "! N.B. The 'log trap' command is deprecated.%s", - VTY_NEWLINE); + VTY_NEWLINE); vty_out (vty, "log trap %s%s", - zlog_priority[zlog_default->default_lvl], VTY_NEWLINE); + zlog_priority[zlog_default->default_lvl], VTY_NEWLINE); } if (host.logfile && (zlog_default->maxlvl[ZLOG_DEST_FILE] != ZLOG_DISABLED)) { vty_out (vty, "log file %s", host.logfile); if (zlog_default->maxlvl[ZLOG_DEST_FILE] != zlog_default->default_lvl) - vty_out (vty, " %s", - zlog_priority[zlog_default->maxlvl[ZLOG_DEST_FILE]]); + vty_out (vty, " %s", + zlog_priority[zlog_default->maxlvl[ZLOG_DEST_FILE]]); vty_out (vty, "%s", VTY_NEWLINE); } @@ -822,8 +437,8 @@ config_write_host (struct vty *vty) { vty_out (vty, "log stdout"); if (zlog_default->maxlvl[ZLOG_DEST_STDOUT] != zlog_default->default_lvl) - vty_out (vty, " %s", - zlog_priority[zlog_default->maxlvl[ZLOG_DEST_STDOUT]]); + vty_out (vty, " %s", + zlog_priority[zlog_default->maxlvl[ZLOG_DEST_STDOUT]]); vty_out (vty, "%s", VTY_NEWLINE); } @@ -831,27 +446,27 @@ config_write_host (struct vty *vty) vty_out(vty,"no log monitor%s",VTY_NEWLINE); else if (zlog_default->maxlvl[ZLOG_DEST_MONITOR] != zlog_default->default_lvl) vty_out(vty,"log monitor %s%s", - zlog_priority[zlog_default->maxlvl[ZLOG_DEST_MONITOR]],VTY_NEWLINE); + zlog_priority[zlog_default->maxlvl[ZLOG_DEST_MONITOR]],VTY_NEWLINE); if (zlog_default->maxlvl[ZLOG_DEST_SYSLOG] != ZLOG_DISABLED) { vty_out (vty, "log syslog"); if (zlog_default->maxlvl[ZLOG_DEST_SYSLOG] != zlog_default->default_lvl) - vty_out (vty, " %s", - zlog_priority[zlog_default->maxlvl[ZLOG_DEST_SYSLOG]]); + vty_out (vty, " %s", + zlog_priority[zlog_default->maxlvl[ZLOG_DEST_SYSLOG]]); vty_out (vty, "%s", VTY_NEWLINE); } if (zlog_default->facility != LOG_DAEMON) vty_out (vty, "log facility %s%s", - facility_name(zlog_default->facility), VTY_NEWLINE); + facility_name(zlog_default->facility), VTY_NEWLINE); if (zlog_default->record_priority == 1) vty_out (vty, "log record-priority%s", VTY_NEWLINE); if (zlog_default->timestamp_precision > 0) vty_out (vty, "log timestamp precision %d%s", - zlog_default->timestamp_precision, VTY_NEWLINE); + zlog_default->timestamp_precision, VTY_NEWLINE); if (host.advanced) vty_out (vty, "service advanced-vty%s", VTY_NEWLINE); @@ -861,7 +476,7 @@ config_write_host (struct vty *vty) if (host.lines >= 0) vty_out (vty, "service terminal-length %d%s", host.lines, - VTY_NEWLINE); + VTY_NEWLINE); if (host.motdfile) vty_out (vty, "banner motd file %s%s", host.motdfile, VTY_NEWLINE); @@ -871,1376 +486,128 @@ config_write_host (struct vty *vty) return 1; } -/* Utility function for getting command vector. */ -static vector -cmd_node_vector (vector v, enum node_type ntype) +/* Utility function for getting command graph. */ +static struct graph * +cmd_node_graph (vector v, enum node_type ntype) { struct cmd_node *cnode = vector_slot (v, ntype); - return cnode->cmd_vector; -} - -/* Completion match types. */ -enum match_type -{ - no_match, - extend_match, - ipv4_prefix_match, - ipv4_match, - ipv6_prefix_match, - ipv6_match, - range_match, - vararg_match, - partly_match, - exact_match -}; - -static enum match_type -cmd_ipv4_match (const char *str) -{ - const char *sp; - int dots = 0, nums = 0; - char buf[4]; - - if (str == NULL) - return partly_match; - - for (;;) - { - memset (buf, 0, sizeof (buf)); - sp = str; - while (*str != '\0') - { - if (*str == '.') - { - if (dots >= 3) - return no_match; - - if (*(str + 1) == '.') - return no_match; - - if (*(str + 1) == '\0') - return partly_match; - - dots++; - break; - } - if (!isdigit ((int) *str)) - return no_match; - - str++; - } - - if (str - sp > 3) - return no_match; - - strncpy (buf, sp, str - sp); - if (atoi (buf) > 255) - return no_match; - - nums++; - - if (*str == '\0') - break; - - str++; - } - - if (nums < 4) - return partly_match; - - return exact_match; -} - -static enum match_type -cmd_ipv4_prefix_match (const char *str) -{ - const char *sp; - int dots = 0; - char buf[4]; - - if (str == NULL) - return partly_match; - - for (;;) - { - memset (buf, 0, sizeof (buf)); - sp = str; - while (*str != '\0' && *str != '/') - { - if (*str == '.') - { - if (dots == 3) - return no_match; - - if (*(str + 1) == '.' || *(str + 1) == '/') - return no_match; - - if (*(str + 1) == '\0') - return partly_match; - - dots++; - break; - } - - if (!isdigit ((int) *str)) - return no_match; - - str++; - } - - if (str - sp > 3) - return no_match; - - strncpy (buf, sp, str - sp); - if (atoi (buf) > 255) - return no_match; - - if (dots == 3) - { - if (*str == '/') - { - if (*(str + 1) == '\0') - return partly_match; - - str++; - break; - } - else if (*str == '\0') - return partly_match; - } - - if (*str == '\0') - return partly_match; - - str++; - } - - sp = str; - while (*str != '\0') - { - if (!isdigit ((int) *str)) - return no_match; - - str++; - } - - if (atoi (sp) > 32) - return no_match; - - return exact_match; -} - -#define IPV6_ADDR_STR "0123456789abcdefABCDEF:." -#define IPV6_PREFIX_STR "0123456789abcdefABCDEF:./" - -#ifdef HAVE_IPV6 - -static enum match_type -cmd_ipv6_match (const char *str) -{ - struct sockaddr_in6 sin6_dummy; - int ret; - - if (str == NULL) - return partly_match; - - if (strspn (str, IPV6_ADDR_STR) != strlen (str)) - return no_match; - - /* use inet_pton that has a better support, - * for example inet_pton can support the automatic addresses: - * ::1.2.3.4 - */ - ret = inet_pton(AF_INET6, str, &sin6_dummy.sin6_addr); - - if (ret == 1) - return exact_match; - - return no_match; -} - -static enum match_type -cmd_ipv6_prefix_match (const char *str) -{ - struct sockaddr_in6 sin6_dummy; - const char *delim = "/\0"; - char *dupe, *prefix, *mask, *context, *endptr; - int nmask = -1; - - if (str == NULL) - return partly_match; - - if (strspn (str, IPV6_PREFIX_STR) != strlen (str)) - return no_match; - - /* tokenize to address + mask */ - dupe = XMALLOC(MTYPE_TMP, strlen(str)+1); - strncpy(dupe, str, strlen(str)+1); - prefix = strtok_r(dupe, delim, &context); - mask = strtok_r(NULL, delim, &context); - - if (!mask) - return partly_match; - - /* validate prefix */ - if (inet_pton(AF_INET6, prefix, &sin6_dummy.sin6_addr) != 1) - return no_match; - - /* validate mask */ - nmask = strtol (mask, &endptr, 10); - if (*endptr != '\0' || nmask < 0 || nmask > 128) - return no_match; - - XFREE(MTYPE_TMP, dupe); - - return exact_match; + return cnode->cmdgraph; } -#endif /* HAVE_IPV6 */ - -#define DECIMAL_STRLEN_MAX 20 - static int -cmd_range_match (const char *range, const char *str) -{ - char *p; - char buf[DECIMAL_STRLEN_MAX + 1]; - char *endptr = NULL; - signed long long min, max, val; - - if (str == NULL) +cmd_try_do_shortcut (enum node_type node, char* first_word) { + if ( first_word != NULL && + node != AUTH_NODE && + node != VIEW_NODE && + node != AUTH_ENABLE_NODE && + node != ENABLE_NODE && + 0 == strcmp( "do", first_word ) ) return 1; - - val = strtoll (str, &endptr, 10); - if (*endptr != '\0') - return 0; - val = llabs(val); - - range++; - p = strchr (range, '-'); - if (p == NULL) - return 0; - if (p - range > DECIMAL_STRLEN_MAX) - return 0; - strncpy (buf, range, p - range); - buf[p - range] = '\0'; - min = strtoll (buf, &endptr, 10); - if (*endptr != '\0') - return 0; - - range = p + 1; - p = strchr (range, '>'); - if (p == NULL) - return 0; - if (p - range > DECIMAL_STRLEN_MAX) - return 0; - strncpy (buf, range, p - range); - buf[p - range] = '\0'; - max = strtoll (buf, &endptr, 10); - if (*endptr != '\0') - return 0; - - if (val < min || val > max) - return 0; - - return 1; -} - -static enum match_type -cmd_word_match(struct cmd_token *token, - enum filter_type filter, - const char *word) -{ - const char *str; - enum match_type match_type; - - str = token->cmd; - - if (filter == FILTER_RELAXED) - if (!word || !strlen(word)) - return partly_match; - - if (!word) - return no_match; - - switch (token->terminal) - { - case TERMINAL_VARARG: - return vararg_match; - - case TERMINAL_RANGE: - if (cmd_range_match(str, word)) - return range_match; - break; - - case TERMINAL_IPV6: - match_type = cmd_ipv6_match(word); - if ((filter == FILTER_RELAXED && match_type != no_match) - || (filter == FILTER_STRICT && match_type == exact_match)) - return ipv6_match; - break; - - case TERMINAL_IPV6_PREFIX: - match_type = cmd_ipv6_prefix_match(word); - if ((filter == FILTER_RELAXED && match_type != no_match) - || (filter == FILTER_STRICT && match_type == exact_match)) - return ipv6_prefix_match; - break; - - case TERMINAL_IPV4: - match_type = cmd_ipv4_match(word); - if ((filter == FILTER_RELAXED && match_type != no_match) - || (filter == FILTER_STRICT && match_type == exact_match)) - return ipv4_match; - break; - - case TERMINAL_IPV4_PREFIX: - match_type = cmd_ipv4_prefix_match(word); - if ((filter == FILTER_RELAXED && match_type != no_match) - || (filter == FILTER_STRICT && match_type == exact_match)) - return ipv4_prefix_match; - break; - - case TERMINAL_OPTION: - case TERMINAL_VARIABLE: - return extend_match; - - case TERMINAL_LITERAL: - if (filter == FILTER_RELAXED && !strncmp(str, word, strlen(word))) - { - if (!strcmp(str, word)) - return exact_match; - return partly_match; - } - if (filter == FILTER_STRICT && !strcmp(str, word)) - return exact_match; - break; - - default: - assert (0); - } - - return no_match; -} - -struct cmd_matcher -{ - struct cmd_element *cmd; /* The command element the matcher is using */ - enum filter_type filter; /* Whether to use strict or relaxed matching */ - vector vline; /* The tokenized commandline which is to be matched */ - unsigned int index; /* The index up to which matching should be done */ - - /* If set, construct a list of matches at the position given by index */ - enum match_type *match_type; - vector *match; - - unsigned int word_index; /* iterating over vline */ -}; - -static int -push_argument(int *argc, const char **argv, const char *arg) -{ - if (!arg || !strlen(arg)) - arg = NULL; - - if (!argc || !argv) - return 0; - - if (*argc >= CMD_ARGC_MAX) - return -1; - - argv[(*argc)++] = arg; return 0; } -static void -cmd_matcher_record_match(struct cmd_matcher *matcher, - enum match_type match_type, - struct cmd_token *token) -{ - if (matcher->word_index != matcher->index) - return; - - if (matcher->match) - { - if (!*matcher->match) - *matcher->match = vector_init(VECTOR_MIN_SIZE); - vector_set(*matcher->match, token); - } - - if (matcher->match_type) - { - if (match_type > *matcher->match_type) - *matcher->match_type = match_type; - } -} - -static int -cmd_matcher_words_left(struct cmd_matcher *matcher) -{ - return matcher->word_index < vector_active(matcher->vline); -} - -static const char* -cmd_matcher_get_word(struct cmd_matcher *matcher) -{ - assert(cmd_matcher_words_left(matcher)); - - return vector_slot(matcher->vline, matcher->word_index); -} - -static enum matcher_rv -cmd_matcher_match_terminal(struct cmd_matcher *matcher, - struct cmd_token *token, - int *argc, const char **argv) -{ - const char *word; - enum match_type word_match; - - assert(token->type == TOKEN_TERMINAL); - - if (!cmd_matcher_words_left(matcher)) - { - if (token->terminal == TERMINAL_OPTION) - return MATCHER_OK; /* missing optional args are NOT pushed as NULL */ - else - return MATCHER_INCOMPLETE; - } - - word = cmd_matcher_get_word(matcher); - word_match = cmd_word_match(token, matcher->filter, word); - if (word_match == no_match) - return MATCHER_NO_MATCH; - - /* We have to record the input word as argument if it matched - * against a variable. */ - if (TERMINAL_RECORD (token->terminal)) - { - if (push_argument(argc, argv, word)) - return MATCHER_EXCEED_ARGC_MAX; - } - - cmd_matcher_record_match(matcher, word_match, token); - - matcher->word_index++; - - /* A vararg token should consume all left over words as arguments */ - if (token->terminal == TERMINAL_VARARG) - while (cmd_matcher_words_left(matcher)) - { - word = cmd_matcher_get_word(matcher); - if (word && strlen(word)) - push_argument(argc, argv, word); - matcher->word_index++; - } - - return MATCHER_OK; -} - -static enum matcher_rv -cmd_matcher_match_multiple(struct cmd_matcher *matcher, - struct cmd_token *token, - int *argc, const char **argv) -{ - enum match_type multiple_match; - unsigned int multiple_index; - const char *word; - const char *arg = NULL; - struct cmd_token *word_token; - enum match_type word_match; - - assert(token->type == TOKEN_MULTIPLE); - - multiple_match = no_match; - - if (!cmd_matcher_words_left(matcher)) - return MATCHER_INCOMPLETE; - - word = cmd_matcher_get_word(matcher); - for (multiple_index = 0; - multiple_index < vector_active(token->multiple); - multiple_index++) - { - word_token = vector_slot(token->multiple, multiple_index); - - word_match = cmd_word_match(word_token, matcher->filter, word); - if (word_match == no_match) - continue; - - cmd_matcher_record_match(matcher, word_match, word_token); - - if (word_match > multiple_match) - { - multiple_match = word_match; - arg = word; - } - /* To mimic the behavior of the old command implementation, we - * tolerate any ambiguities here :/ */ - } - - matcher->word_index++; - - if (multiple_match == no_match) - return MATCHER_NO_MATCH; - - if (push_argument(argc, argv, arg)) - return MATCHER_EXCEED_ARGC_MAX; - - return MATCHER_OK; -} - -static enum matcher_rv -cmd_matcher_read_keywords(struct cmd_matcher *matcher, - struct cmd_token *token, - vector args_vector) -{ - unsigned int i; - unsigned long keyword_mask; - unsigned int keyword_found; - enum match_type keyword_match; - enum match_type word_match; - vector keyword_vector; - struct cmd_token *word_token; - const char *word; - int keyword_argc; - const char **keyword_argv; - enum matcher_rv rv = MATCHER_OK; - - keyword_mask = 0; - while (1) - { - if (!cmd_matcher_words_left(matcher)) - return MATCHER_OK; - - word = cmd_matcher_get_word(matcher); - - keyword_found = -1; - keyword_match = no_match; - for (i = 0; i < vector_active(token->keyword); i++) - { - if (keyword_mask & (1 << i)) - continue; - - keyword_vector = vector_slot(token->keyword, i); - word_token = vector_slot(keyword_vector, 0); - - word_match = cmd_word_match(word_token, matcher->filter, word); - if (word_match == no_match) - continue; - - cmd_matcher_record_match(matcher, word_match, word_token); - - if (word_match > keyword_match) - { - keyword_match = word_match; - keyword_found = i; - } - else if (word_match == keyword_match) - { - if (matcher->word_index != matcher->index || args_vector) - return MATCHER_AMBIGUOUS; - } - } - - if (keyword_found == (unsigned int)-1) - return MATCHER_NO_MATCH; - - matcher->word_index++; - - if (matcher->word_index > matcher->index) - return MATCHER_OK; - - keyword_mask |= (1 << keyword_found); - - if (args_vector) - { - keyword_argc = 0; - keyword_argv = XMALLOC(MTYPE_TMP, (CMD_ARGC_MAX + 1) * sizeof(char*)); - /* We use -1 as a marker for unused fields as NULL might be a valid value */ - for (i = 0; i < CMD_ARGC_MAX + 1; i++) - keyword_argv[i] = (void*)-1; - vector_set_index(args_vector, keyword_found, keyword_argv); - } - else - { - keyword_argv = NULL; - } - - keyword_vector = vector_slot(token->keyword, keyword_found); - /* the keyword itself is at 0. We are only interested in the arguments, - * so start counting at 1. */ - for (i = 1; i < vector_active(keyword_vector); i++) - { - word_token = vector_slot(keyword_vector, i); - - switch (word_token->type) - { - case TOKEN_TERMINAL: - rv = cmd_matcher_match_terminal(matcher, word_token, - &keyword_argc, keyword_argv); - break; - case TOKEN_MULTIPLE: - rv = cmd_matcher_match_multiple(matcher, word_token, - &keyword_argc, keyword_argv); - break; - case TOKEN_KEYWORD: - assert(!"Keywords should never be nested."); - break; - } - - if (MATCHER_ERROR(rv)) - return rv; - - if (matcher->word_index > matcher->index) - return MATCHER_OK; - } - } - /* not reached */ -} - -static enum matcher_rv -cmd_matcher_build_keyword_args(struct cmd_matcher *matcher, - struct cmd_token *token, - int *argc, const char **argv, - vector keyword_args_vector) -{ - unsigned int i, j; - const char **keyword_args; - vector keyword_vector; - struct cmd_token *word_token; - const char *arg; - enum matcher_rv rv; - - rv = MATCHER_OK; - - if (keyword_args_vector == NULL) - return rv; - - for (i = 0; i < vector_active(token->keyword); i++) - { - keyword_vector = vector_slot(token->keyword, i); - keyword_args = vector_lookup(keyword_args_vector, i); - - if (vector_active(keyword_vector) == 1) - { - /* this is a keyword without arguments */ - if (keyword_args) - { - word_token = vector_slot(keyword_vector, 0); - arg = word_token->cmd; - XFREE (MTYPE_TMP, keyword_args); - } - else - { - arg = NULL; - } - - if (push_argument(argc, argv, arg)) - rv = MATCHER_EXCEED_ARGC_MAX; - } - else - { - /* this is a keyword with arguments */ - if (keyword_args) - { - /* the keyword was present, so just fill in the arguments */ - for (j = 0; keyword_args[j] != (void*)-1; j++) - if (push_argument(argc, argv, keyword_args[j])) - rv = MATCHER_EXCEED_ARGC_MAX; - XFREE(MTYPE_TMP, keyword_args); - } - else - { - /* the keyword was not present, insert NULL for the arguments - * the keyword would have taken. */ - for (j = 1; j < vector_active(keyword_vector); j++) - { - word_token = vector_slot(keyword_vector, j); - if ((word_token->type == TOKEN_TERMINAL - && TERMINAL_RECORD (word_token->terminal)) - || word_token->type == TOKEN_MULTIPLE) - { - if (push_argument(argc, argv, NULL)) - rv = MATCHER_EXCEED_ARGC_MAX; - } - } - } - } - } - vector_free(keyword_args_vector); - return rv; -} - -static enum matcher_rv -cmd_matcher_match_keyword(struct cmd_matcher *matcher, - struct cmd_token *token, - int *argc, const char **argv) -{ - vector keyword_args_vector; - enum matcher_rv reader_rv; - enum matcher_rv builder_rv; - - assert(token->type == TOKEN_KEYWORD); - - if (argc && argv) - keyword_args_vector = vector_init(VECTOR_MIN_SIZE); - else - keyword_args_vector = NULL; - - reader_rv = cmd_matcher_read_keywords(matcher, token, keyword_args_vector); - builder_rv = cmd_matcher_build_keyword_args(matcher, token, argc, - argv, keyword_args_vector); - /* keyword_args_vector is consumed by cmd_matcher_build_keyword_args */ - - if (!MATCHER_ERROR(reader_rv) && MATCHER_ERROR(builder_rv)) - return builder_rv; - - return reader_rv; -} - -static void -cmd_matcher_init(struct cmd_matcher *matcher, - struct cmd_element *cmd, - enum filter_type filter, - vector vline, - unsigned int index, - enum match_type *match_type, - vector *match) -{ - memset(matcher, 0, sizeof(*matcher)); - - matcher->cmd = cmd; - matcher->filter = filter; - matcher->vline = vline; - matcher->index = index; - - matcher->match_type = match_type; - if (matcher->match_type) - *matcher->match_type = no_match; - matcher->match = match; - - matcher->word_index = 0; -} - -static enum matcher_rv -cmd_element_match(struct cmd_element *cmd_element, - enum filter_type filter, - vector vline, - unsigned int index, - enum match_type *match_type, - vector *match, - int *argc, - const char **argv) -{ - struct cmd_matcher matcher; - unsigned int token_index; - enum matcher_rv rv = MATCHER_OK; - - cmd_matcher_init(&matcher, cmd_element, filter, - vline, index, match_type, match); - - if (argc != NULL) - *argc = 0; - - for (token_index = 0; - token_index < vector_active(cmd_element->tokens); - token_index++) - { - struct cmd_token *token = vector_slot(cmd_element->tokens, token_index); - - switch (token->type) - { - case TOKEN_TERMINAL: - rv = cmd_matcher_match_terminal(&matcher, token, argc, argv); - break; - case TOKEN_MULTIPLE: - rv = cmd_matcher_match_multiple(&matcher, token, argc, argv); - break; - case TOKEN_KEYWORD: - rv = cmd_matcher_match_keyword(&matcher, token, argc, argv); - } - - if (MATCHER_ERROR(rv)) - return rv; - - if (matcher.word_index > index) - return MATCHER_OK; - } - - /* return MATCHER_COMPLETE if all words were consumed */ - if (matcher.word_index >= vector_active(vline)) - return MATCHER_COMPLETE; - - /* return MATCHER_COMPLETE also if only an empty word is left. */ - if (matcher.word_index == vector_active(vline) - 1 - && (!vector_slot(vline, matcher.word_index) - || !strlen((char*)vector_slot(vline, matcher.word_index)))) - return MATCHER_COMPLETE; - - return MATCHER_NO_MATCH; /* command is too long to match */ -} - -/** - * Filter a given vector of commands against a given commandline and - * calculate possible completions. - * - * @param commands A vector of struct cmd_element*. Commands that don't - * match against the given command line will be overwritten - * with NULL in that vector. - * @param filter Either FILTER_RELAXED or FILTER_STRICT. This basically - * determines how incomplete commands are handled, compare with - * cmd_word_match for details. - * @param vline A vector of char* containing the tokenized commandline. - * @param index Only match up to the given token of the commandline. - * @param match_type Record the type of the best match here. - * @param matches Record the matches here. For each cmd_element in the commands - * vector, a match vector will be created in the matches vector. - * That vector will contain all struct command_token* of the - * cmd_element which matched against the given vline at the given - * index. - * @return A code specifying if an error occured. If all went right, it's - * CMD_SUCCESS. - */ -static int -cmd_vector_filter(vector commands, - enum filter_type filter, - vector vline, - unsigned int index, - enum match_type *match_type, - vector *matches) -{ - unsigned int i; - struct cmd_element *cmd_element; - enum match_type best_match; - enum match_type element_match; - enum matcher_rv matcher_rv; - - best_match = no_match; - *matches = vector_init(VECTOR_MIN_SIZE); - - for (i = 0; i < vector_active (commands); i++) - if ((cmd_element = vector_slot (commands, i)) != NULL) - { - vector_set_index(*matches, i, NULL); - matcher_rv = cmd_element_match(cmd_element, filter, - vline, index, - &element_match, - (vector*)&vector_slot(*matches, i), - NULL, NULL); - if (MATCHER_ERROR(matcher_rv)) - { - vector_slot(commands, i) = NULL; - if (matcher_rv == MATCHER_AMBIGUOUS) - return CMD_ERR_AMBIGUOUS; - if (matcher_rv == MATCHER_EXCEED_ARGC_MAX) - return CMD_ERR_EXEED_ARGC_MAX; - } - else if (element_match > best_match) - { - best_match = element_match; - } - } - *match_type = best_match; - return CMD_SUCCESS; -} - /** - * Check whether a given commandline is complete if used for a specific - * cmd_element. - * - * @param cmd_element A cmd_element against which the commandline should be - * checked. - * @param vline The tokenized commandline. - * @return 1 if the given commandline is complete, 0 otherwise. + * Compare function for cmd_token. + * Used with qsort to sort command completions. */ static int -cmd_is_complete(struct cmd_element *cmd_element, - vector vline) +compare_completions (const void *fst, const void *snd) { - enum matcher_rv rv; - - rv = cmd_element_match(cmd_element, - FILTER_RELAXED, - vline, -1, - NULL, NULL, - NULL, NULL); - return (rv == MATCHER_COMPLETE); + struct cmd_token *first = *(struct cmd_token **) fst, + *secnd = *(struct cmd_token **) snd; + return strcmp (first->text, secnd->text); } /** - * Parse a given commandline and construct a list of arguments for the - * given command_element. + * Takes a list of completions returned by command_complete, + * dedeuplicates them based on both text and description, + * sorts them, and returns them as a vector. * - * @param cmd_element The cmd_element for which we want to construct arguments. - * @param vline The tokenized commandline. - * @param argc Where to store the argument count. - * @param argv Where to store the argument list. Should be at least - * CMD_ARGC_MAX elements long. - * @return CMD_SUCCESS if everything went alright, an error otherwise. + * @param completions linked list of cmd_token + * @return deduplicated and sorted vector with */ -static int -cmd_parse(struct cmd_element *cmd_element, - vector vline, - int *argc, const char **argv) +static vector +completions_to_vec (struct list *completions) { - enum matcher_rv rv = cmd_element_match(cmd_element, - FILTER_RELAXED, - vline, -1, - NULL, NULL, - argc, argv); - switch (rv) - { - case MATCHER_COMPLETE: - return CMD_SUCCESS; - - case MATCHER_NO_MATCH: - return CMD_ERR_NO_MATCH; - - case MATCHER_AMBIGUOUS: - return CMD_ERR_AMBIGUOUS; + vector comps = vector_init (VECTOR_MIN_SIZE); - case MATCHER_EXCEED_ARGC_MAX: - return CMD_ERR_EXEED_ARGC_MAX; + struct listnode *ln; + struct cmd_token *token, *cr = NULL; + unsigned int i, exists; + for (ALL_LIST_ELEMENTS_RO(completions,ln,token)) + { + if (token->type == END_TKN && (cr = token)) + continue; - default: - return CMD_ERR_INCOMPLETE; + // linear search for token in completions vector + exists = 0; + for (i = 0; i < vector_active (comps) && !exists; i++) + { + struct cmd_token *curr = vector_slot (comps, i); + exists = !strcmp (curr->text, token->text) && + !strcmp (curr->desc, token->desc); } -} -/* Check ambiguous match */ -static int -is_cmd_ambiguous (vector cmd_vector, - const char *command, - vector matches, - enum match_type type) -{ - unsigned int i; - unsigned int j; - const char *str = NULL; - const char *matched = NULL; - vector match_vector; - struct cmd_token *cmd_token; - - if (command == NULL) - command = ""; - - for (i = 0; i < vector_active (matches); i++) - if ((match_vector = vector_slot (matches, i)) != NULL) - { - int match = 0; - - for (j = 0; j < vector_active (match_vector); j++) - if ((cmd_token = vector_slot (match_vector, j)) != NULL) - { - enum match_type ret; - - assert(cmd_token->type == TOKEN_TERMINAL); - if (cmd_token->type != TOKEN_TERMINAL) - continue; - - str = cmd_token->cmd; - - switch (type) - { - case exact_match: - if (!TERMINAL_RECORD (cmd_token->terminal) - && strcmp (command, str) == 0) - match++; - break; - case partly_match: - if (!TERMINAL_RECORD (cmd_token->terminal) - && strncmp (command, str, strlen (command)) == 0) - { - if (matched && strcmp (matched, str) != 0) - return 1; /* There is ambiguous match. */ - else - matched = str; - match++; - } - break; - case range_match: - if (cmd_range_match (str, command)) - { - if (matched && strcmp (matched, str) != 0) - return 1; - else - matched = str; - match++; - } - break; -#ifdef HAVE_IPV6 - case ipv6_match: - if (cmd_token->terminal == TERMINAL_IPV6) - match++; - break; - case ipv6_prefix_match: - if ((ret = cmd_ipv6_prefix_match (command)) != no_match) - { - if (ret == partly_match) - return 2; /* There is incomplete match. */ - - match++; - } - break; -#endif /* HAVE_IPV6 */ - case ipv4_match: - if (cmd_token->terminal == TERMINAL_IPV4) - match++; - break; - case ipv4_prefix_match: - if ((ret = cmd_ipv4_prefix_match (command)) != no_match) - { - if (ret == partly_match) - return 2; /* There is incomplete match. */ - - match++; - } - break; - case extend_match: - if (TERMINAL_RECORD (cmd_token->terminal)) - match++; - break; - case no_match: - default: - break; - } - } - if (!match) - vector_slot (cmd_vector, i) = NULL; - } - return 0; -} - -/* If src matches dst return dst string, otherwise return NULL */ -static const char * -cmd_entry_function (const char *src, struct cmd_token *token) -{ - const char *dst = token->cmd; - - /* Skip variable arguments. */ - if (TERMINAL_RECORD (token->terminal)) - return NULL; - - /* In case of 'command \t', given src is NULL string. */ - if (src == NULL) - return dst; - - /* Matched with input string. */ - if (strncmp (src, dst, strlen (src)) == 0) - return dst; - - return NULL; -} - -/* If src matches dst return dst string, otherwise return NULL */ -/* This version will return the dst string always if it is - CMD_VARIABLE for '?' key processing */ -static const char * -cmd_entry_function_desc (const char *src, struct cmd_token *token) -{ - const char *dst = token->cmd; - - switch (token->terminal) - { - case TERMINAL_VARARG: - return dst; - - case TERMINAL_RANGE: - if (cmd_range_match (dst, src)) - return dst; - else - return NULL; - - case TERMINAL_IPV6: - if (cmd_ipv6_match (src)) - return dst; - else - return NULL; - - case TERMINAL_IPV6_PREFIX: - if (cmd_ipv6_prefix_match (src)) - return dst; - else - return NULL; - - case TERMINAL_IPV4: - if (cmd_ipv4_match (src)) - return dst; - else - return NULL; - - case TERMINAL_IPV4_PREFIX: - if (cmd_ipv4_prefix_match (src)) - return dst; - else - return NULL; - - /* Optional or variable commands always match on '?' */ - case TERMINAL_OPTION: - case TERMINAL_VARIABLE: - return dst; - - case TERMINAL_LITERAL: - /* In case of 'command \t', given src is NULL string. */ - if (src == NULL) - return dst; - - if (strncmp (src, dst, strlen (src)) == 0) - return dst; - else - return NULL; + if (!exists) + vector_set (comps, token); + } - default: - assert(0); - return NULL; - } -} + // sort completions + qsort (comps->index, + vector_active (comps), + sizeof (void *), + &compare_completions); -/** - * Check whether a string is already present in a vector of strings. - * @param v A vector of char*. - * @param str A char*. - * @return 0 if str is already present in the vector, 1 otherwise. - */ -static int -cmd_unique_string (vector v, const char *str) -{ - unsigned int i; - char *match; + // make <cr> the first element, if it is present + if (cr) + { + vector_set_index (comps, vector_active (comps), NULL); + memmove (comps->index + 1, comps->index, (comps->alloced - 1) * sizeof (void *)); + vector_set_index (comps, 0, cr); + } - for (i = 0; i < vector_active (v); i++) - if ((match = vector_slot (v, i)) != NULL) - if (strcmp (match, str) == 0) - return 0; - return 1; + return comps; } - /** - * Check whether a struct cmd_token matching a given string is already - * present in a vector of struct cmd_token. - * @param v A vector of struct cmd_token*. - * @param str A char* which should be searched for. - * @return 0 if there is a struct cmd_token* with its cmd matching str, - * 1 otherwise. + * Generates a vector of cmd_token representing possible completions + * on the current input. + * + * @param vline the vectorized input line + * @param vty the vty with the node to match on + * @param status pointer to matcher status code + * @return vector of struct cmd_token * with possible completions */ -static int -desc_unique_string (vector v, const char *str) -{ - unsigned int i; - struct cmd_token *token; - - for (i = 0; i < vector_active (v); i++) - if ((token = vector_slot (v, i)) != NULL) - if (strcmp (token->cmd, str) == 0) - return 0; - return 1; -} - -static int -cmd_try_do_shortcut (enum node_type node, char* first_word) { - if ( first_word != NULL && - node != AUTH_NODE && - node != VIEW_NODE && - node != AUTH_ENABLE_NODE && - node != ENABLE_NODE && - 0 == strcmp( "do", first_word ) ) - return 1; - return 0; -} - -static void -cmd_matches_free(vector *matches) -{ - unsigned int i; - vector cmd_matches; - - for (i = 0; i < vector_active(*matches); i++) - if ((cmd_matches = vector_slot(*matches, i)) != NULL) - vector_free(cmd_matches); - vector_free(*matches); - *matches = NULL; -} - -static int -cmd_describe_cmp(const void *a, const void *b) -{ - const struct cmd_token *first = *(struct cmd_token * const *)a; - const struct cmd_token *second = *(struct cmd_token * const *)b; - - return strcmp(first->cmd, second->cmd); -} - -static void -cmd_describe_sort(vector matchvec) -{ - qsort(matchvec->index, vector_active(matchvec), - sizeof(void*), cmd_describe_cmp); -} - -/* '?' describe command support. */ static vector -cmd_describe_command_real (vector vline, struct vty *vty, int *status) +cmd_complete_command_real (vector vline, struct vty *vty, int *status) { - unsigned int i; - vector cmd_vector; -#define INIT_MATCHVEC_SIZE 10 - vector matchvec; - struct cmd_element *cmd_element; - unsigned int index; - int ret; - enum match_type match; - char *command; - vector matches = NULL; - vector match_vector; - uint32_t command_found = 0; - const char *last_word; - - /* Set index. */ - if (vector_active (vline) == 0) - { - *status = CMD_ERR_NO_MATCH; - return NULL; - } - - index = vector_active (vline) - 1; - - /* Make copy vector of current node's command vector. */ - cmd_vector = vector_copy (cmd_node_vector (cmdvec, vty->node)); - - /* Prepare match vector */ - matchvec = vector_init (INIT_MATCHVEC_SIZE); - - /* Filter commands and build a list how they could possibly continue. */ - for (i = 0; i <= index; i++) - { - command = vector_slot (vline, i); - - if (matches) - cmd_matches_free(&matches); - - ret = cmd_vector_filter(cmd_vector, - FILTER_RELAXED, - vline, i, - &match, - &matches); - - if (ret != CMD_SUCCESS) - { - vector_free (cmd_vector); - vector_free (matchvec); - cmd_matches_free(&matches); - *status = ret; - return NULL; - } - - /* The last match may well be ambigious, so break here */ - if (i == index) - break; - - if (match == vararg_match) - { - /* We found a vararg match - so we can throw out the current matches here - * and don't need to continue checking the command input */ - unsigned int j, k; - - for (j = 0; j < vector_active (matches); j++) - if ((match_vector = vector_slot (matches, j)) != NULL) - for (k = 0; k < vector_active (match_vector); k++) - { - struct cmd_token *token = vector_slot (match_vector, k); - vector_set (matchvec, token); - } - - *status = CMD_SUCCESS; - vector_set(matchvec, &token_cr); - vector_free (cmd_vector); - cmd_matches_free(&matches); - cmd_describe_sort(matchvec); - return matchvec; - } - - ret = is_cmd_ambiguous(cmd_vector, command, matches, match); - if (ret == 1) - { - vector_free (cmd_vector); - vector_free (matchvec); - cmd_matches_free(&matches); - *status = CMD_ERR_AMBIGUOUS; - return NULL; - } - else if (ret == 2) - { - vector_free (cmd_vector); - vector_free (matchvec); - cmd_matches_free(&matches); - *status = CMD_ERR_NO_MATCH; - return NULL; - } - } - - /* Make description vector. */ - for (i = 0; i < vector_active (matches); i++) { - if ((cmd_element = vector_slot (cmd_vector, i)) != NULL && - !(cmd_element->attr == CMD_ATTR_DEPRECATED || - cmd_element->attr == CMD_ATTR_HIDDEN)) - { - unsigned int j; - vector vline_trimmed; - - command_found++; - last_word = vector_slot(vline, vector_active(vline) - 1); - if (last_word == NULL || !strlen(last_word)) - { - vline_trimmed = vector_copy(vline); - vector_unset(vline_trimmed, vector_active(vline_trimmed) - 1); - - if (cmd_is_complete(cmd_element, vline_trimmed) - && desc_unique_string(matchvec, command_cr)) - { - if (match != vararg_match) - vector_set(matchvec, &token_cr); - } - - vector_free(vline_trimmed); - } + struct list *completions; + struct graph *cmdgraph = cmd_node_graph (cmdvec, vty->node); - match_vector = vector_slot (matches, i); - if (match_vector) - for (j = 0; j < vector_active(match_vector); j++) - { - struct cmd_token *token = vector_slot(match_vector, j); - const char *string; + enum matcher_rv rv = command_complete (cmdgraph, vline, &completions); - string = cmd_entry_function_desc(command, token); - if (string && desc_unique_string(matchvec, string)) - vector_set(matchvec, token); - } - } - } - - /* - * We can get into this situation when the command is complete - * but the last part of the command is an optional piece of - * cli. - */ - last_word = vector_slot(vline, vector_active(vline) - 1); - if (command_found == 0 && (last_word == NULL || !strlen(last_word))) { - vector_set(matchvec, &token_cr); + if (MATCHER_ERROR(rv)) + { + *status = CMD_ERR_NO_MATCH; + return NULL; } - vector_free (cmd_vector); - cmd_matches_free(&matches); + vector comps = completions_to_vec (completions); + list_delete (completions); - if (vector_slot (matchvec, 0) == NULL) - { - vector_free (matchvec); + // set status code appropriately + switch (vector_active (comps)) + { + case 0: *status = CMD_ERR_NO_MATCH; - return NULL; - } + break; + case 1: + *status = CMD_COMPLETE_FULL_MATCH; + break; + default: + *status = CMD_COMPLETE_LIST_MATCH; + } - *status = CMD_SUCCESS; - cmd_describe_sort(matchvec); - return matchvec; + return comps; } vector @@ -2260,291 +627,93 @@ cmd_describe_command (vector vline, struct vty *vty, int *status) shifted_vline = vector_init (vector_count(vline)); /* use memcpy? */ - for (index = 1; index < vector_active (vline); index++) - { - vector_set_index (shifted_vline, index-1, vector_lookup(vline, index)); - } + for (index = 1; index < vector_active (vline); index++) + { + vector_set_index (shifted_vline, index-1, vector_lookup(vline, index)); + } - ret = cmd_describe_command_real (shifted_vline, vty, status); + ret = cmd_complete_command_real (shifted_vline, vty, status); vector_free(shifted_vline); vty->node = onode; return ret; } - - return cmd_describe_command_real (vline, vty, status); + return cmd_complete_command_real (vline, vty, status); } +/** + * Generate possible tab-completions for the given input. This function only + * returns results that would result in a valid command if used as Readline + * completions (as is the case in vtysh). For instance, if the passed vline ends + * with '4.3.2', the strings 'A.B.C.D' and 'A.B.C.D/M' will _not_ be returned. + * + * @param vline vectorized input line + * @param vty the vty + * @param status location to store matcher status code in + * @return set of valid strings for use with Readline as tab-completions. + */ -/* Check LCD of matched command. */ -static int -cmd_lcd (char **matched) -{ - int i; - int j; - int lcd = -1; - char *s1, *s2; - char c1, c2; - - if (matched[0] == NULL || matched[1] == NULL) - return 0; - - for (i = 1; matched[i] != NULL; i++) - { - s1 = matched[i - 1]; - s2 = matched[i]; - - for (j = 0; (c1 = s1[j]) && (c2 = s2[j]); j++) - if (c1 != c2) - break; - - if (lcd < 0) - lcd = j; - else - { - if (lcd > j) - lcd = j; - } - } - return lcd; -} - -static int -cmd_complete_cmp(const void *a, const void *b) +char ** +cmd_complete_command (vector vline, struct vty *vty, int *status) { - const char *first = *(char * const *)a; - const char *second = *(char * const *)b; - - if (!first) - { - if (!second) - return 0; - return 1; - } - if (!second) - return -1; - - return strcmp(first, second); -} + char **ret = NULL; + int original_node = vty->node; + vector input_line = vector_init (vector_count (vline)); -static void -cmd_complete_sort(vector matchvec) -{ - qsort(matchvec->index, vector_active(matchvec), - sizeof(void*), cmd_complete_cmp); -} + // if the first token is 'do' we'll want to execute the command in the enable node + int do_shortcut = cmd_try_do_shortcut (vty->node, vector_slot (vline, 0)); + vty->node = do_shortcut ? ENABLE_NODE : original_node; -/* Command line completion support. */ -static char ** -cmd_complete_command_real (vector vline, struct vty *vty, int *status, int islib) -{ - unsigned int i; - vector cmd_vector = vector_copy (cmd_node_vector (cmdvec, vty->node)); -#define INIT_MATCHVEC_SIZE 10 - vector matchvec; - unsigned int index; - char **match_str; - struct cmd_token *token; - char *command; - int lcd; - vector matches = NULL; - vector match_vector; + // construct the input line we'll be matching on + unsigned int offset = (do_shortcut) ? 1 : 0; + for (unsigned index = 0; index + offset < vector_active (vline); index++) + vector_set_index (input_line, index + offset, vector_lookup (vline, index)); - if (vector_active (vline) == 0) - { - vector_free (cmd_vector); - *status = CMD_ERR_NO_MATCH; - return NULL; - } - else - index = vector_active (vline) - 1; + // get token completions -- this is a copying operation + vector comps, initial_comps; + initial_comps = cmd_complete_command_real (input_line, vty, status); - /* First, filter by command string */ - for (i = 0; i <= index; i++) + if (!MATCHER_ERROR (*status)) + { + assert (initial_comps); + // filter out everything that is not suitable for a tab-completion + comps = vector_init (VECTOR_MIN_SIZE); + for (unsigned int i = 0; i < vector_active(initial_comps); i++) { - command = vector_slot (vline, i); - enum match_type match; - int ret; - - if (matches) - cmd_matches_free(&matches); - - /* First try completion match, if there is exactly match return 1 */ - ret = cmd_vector_filter(cmd_vector, - FILTER_RELAXED, - vline, i, - &match, - &matches); - - if (ret != CMD_SUCCESS) - { - vector_free(cmd_vector); - cmd_matches_free(&matches); - *status = ret; - return NULL; - } - - /* Break here - the completion mustn't be checked to be non-ambiguous */ - if (i == index) - break; - - /* If there is exact match then filter ambiguous match else check - ambiguousness. */ - ret = is_cmd_ambiguous (cmd_vector, command, matches, match); - if (ret == 1) - { - vector_free (cmd_vector); - cmd_matches_free(&matches); - *status = CMD_ERR_AMBIGUOUS; - return NULL; - } + struct cmd_token *token = vector_slot (initial_comps, i); + if (token->type == WORD_TKN) + vector_set (comps, token); } - - /* Prepare match vector. */ - matchvec = vector_init (INIT_MATCHVEC_SIZE); + vector_free (initial_comps); - /* Build the possible list of continuations into a list of completions */ - for (i = 0; i < vector_active (matches); i++) - if ((match_vector = vector_slot (matches, i))) + // copy completions text into an array of char* + ret = XMALLOC (MTYPE_TMP, (vector_active (comps)+1) * sizeof (char *)); + unsigned int i; + for (i = 0; i < vector_active (comps); i++) { - const char *string; - unsigned int j; - - for (j = 0; j < vector_active (match_vector); j++) - if ((token = vector_slot (match_vector, j))) - { - string = cmd_entry_function (vector_slot (vline, index), - token); - if (string && cmd_unique_string (matchvec, string)) - vector_set (matchvec, (islib != 0 ? - XSTRDUP (MTYPE_TMP, string) : - strdup (string) /* rl freed */)); - } + struct cmd_token *token = vector_slot (comps, i); + ret[i] = XSTRDUP (MTYPE_TMP, token->text); + vector_unset (comps, i); } + // set the last element to NULL, because this array is used in + // a Readline completion_generator function which expects NULL + // as a sentinel value + ret[i] = NULL; + vector_free (comps); + comps = NULL; + } - /* We don't need cmd_vector any more. */ - vector_free (cmd_vector); - cmd_matches_free(&matches); - - /* No matched command */ - if (vector_slot (matchvec, 0) == NULL) - { - vector_free (matchvec); - - /* In case of 'command \t' pattern. Do you need '?' command at - the end of the line. */ - if (vector_slot (vline, index) == '\0') - *status = CMD_ERR_NOTHING_TODO; - else - *status = CMD_ERR_NO_MATCH; - return NULL; - } - - /* Only one matched */ - if (vector_slot (matchvec, 1) == NULL) - { - size_t index_size = matchvec->alloced * sizeof (void *); - match_str = XMALLOC (MTYPE_TMP, index_size); - memcpy (match_str, matchvec->index, index_size); - vector_free (matchvec); - - *status = CMD_COMPLETE_FULL_MATCH; - return match_str; - } - /* Make it sure last element is NULL. */ - vector_set (matchvec, NULL); - - /* Check LCD of matched strings. */ - if (vector_slot (vline, index) != NULL) - { - lcd = cmd_lcd ((char **) matchvec->index); - - if (lcd) - { - int len = strlen (vector_slot (vline, index)); - - if (len < lcd) - { - char *lcdstr; - - lcdstr = (islib != 0 ? - XMALLOC (MTYPE_TMP, lcd + 1) : - malloc(lcd + 1)); - memcpy (lcdstr, matchvec->index[0], lcd); - lcdstr[lcd] = '\0'; - - /* Free matchvec. */ - for (i = 0; i < vector_active (matchvec); i++) - { - if (vector_slot (matchvec, i)) - { - if (islib != 0) - XFREE (MTYPE_TMP, vector_slot (matchvec, i)); - else - free (vector_slot (matchvec, i)); - } - } - vector_free (matchvec); - - /* Make new matchvec. */ - matchvec = vector_init (INIT_MATCHVEC_SIZE); - vector_set (matchvec, lcdstr); - - size_t index_size = matchvec->alloced * sizeof (void *); - match_str = XMALLOC (MTYPE_TMP, index_size); - memcpy (match_str, matchvec->index, index_size); - vector_free (matchvec); - - *status = CMD_COMPLETE_MATCH; - return match_str; - } - } - } - - match_str = (char **) matchvec->index; - cmd_complete_sort(matchvec); - vector_only_wrapper_free (matchvec); - *status = CMD_COMPLETE_LIST_MATCH; - return match_str; -} - -char ** -cmd_complete_command_lib (vector vline, struct vty *vty, int *status, int islib) -{ - char **ret; - - if ( cmd_try_do_shortcut(vty->node, vector_slot(vline, 0) ) ) - { - enum node_type onode; - vector shifted_vline; - unsigned int index; - - onode = vty->node; - vty->node = ENABLE_NODE; - /* We can try it on enable node, cos' the vty is authenticated */ - - shifted_vline = vector_init (vector_count(vline)); - /* use memcpy? */ - for (index = 1; index < vector_active (vline); index++) - { - vector_set_index (shifted_vline, index-1, vector_lookup(vline, index)); - } - - ret = cmd_complete_command_real (shifted_vline, vty, status, islib); + // comps should always be null here + assert (!comps); - vector_free(shifted_vline); - vty->node = onode; - return ret; - } + // free the adjusted input line + vector_free (input_line); - return cmd_complete_command_real (vline, vty, status, islib); -} + // reset vty->node to its original value + vty->node = original_node; -char ** -cmd_complete_command (vector vline, struct vty *vty, int *status) -{ - return cmd_complete_command_lib (vline, vty, status, 0); + return ret; } /* return parent node */ @@ -2563,8 +732,8 @@ node_parent ( enum node_type node ) case BGP_ENCAP_NODE: case BGP_ENCAPV6_NODE: case BGP_VNC_DEFAULTS_NODE: - case BGP_VNC_NVE_GROUP_NODE: - case BGP_VNC_L2_GROUP_NODE: + case BGP_VNC_NVE_GROUP_NODE: + case BGP_VNC_L2_GROUP_NODE: case BGP_IPV4_NODE: case BGP_IPV4M_NODE: case BGP_IPV6_NODE: @@ -2601,109 +770,55 @@ node_parent ( enum node_type node ) /* Execute command by argument vline vector. */ static int cmd_execute_command_real (vector vline, - enum filter_type filter, - struct vty *vty, - struct cmd_element **cmd) + enum filter_type filter, + struct vty *vty, + const struct cmd_element **cmd) { - unsigned int i; - unsigned int index; - vector cmd_vector; - struct cmd_element *cmd_element; - struct cmd_element *matched_element; - unsigned int matched_count, incomplete_count; - int argc; - const char *argv[CMD_ARGC_MAX]; - enum match_type match = 0; - char *command; - int ret; - vector matches; - - /* Make copy of command elements. */ - cmd_vector = vector_copy (cmd_node_vector (cmdvec, vty->node)); - - for (index = 0; index < vector_active (vline); index++) - { - command = vector_slot (vline, index); - ret = cmd_vector_filter(cmd_vector, - filter, - vline, index, - &match, - &matches); - - if (ret != CMD_SUCCESS) - { - cmd_matches_free(&matches); - return ret; - } - - if (match == vararg_match) - { - cmd_matches_free(&matches); - break; - } - - ret = is_cmd_ambiguous (cmd_vector, command, matches, match); - cmd_matches_free(&matches); - - if (ret == 1) - { - vector_free(cmd_vector); - return CMD_ERR_AMBIGUOUS; - } - else if (ret == 2) - { - vector_free(cmd_vector); - return CMD_ERR_NO_MATCH; - } - } - - /* Check matched count. */ - matched_element = NULL; - matched_count = 0; - incomplete_count = 0; + struct list *argv_list; + enum matcher_rv status; + const struct cmd_element *matched_element = NULL; - for (i = 0; i < vector_active (cmd_vector); i++) - if ((cmd_element = vector_slot (cmd_vector, i))) - { - if (cmd_is_complete(cmd_element, vline)) - { - matched_element = cmd_element; - matched_count++; - } - else - { - incomplete_count++; - } - } + struct graph *cmdgraph = cmd_node_graph (cmdvec, vty->node); + status = command_match (cmdgraph, vline, &argv_list, &matched_element); - /* Finish of using cmd_vector. */ - vector_free (cmd_vector); + if (cmd) + *cmd = matched_element; - /* To execute command, matched_count must be 1. */ - if (matched_count == 0) + // if matcher error, return corresponding CMD_ERR + if (MATCHER_ERROR(status)) + { + switch (status) { - if (incomplete_count) - return CMD_ERR_INCOMPLETE; - else - return CMD_ERR_NO_MATCH; + case MATCHER_INCOMPLETE: + return CMD_ERR_INCOMPLETE; + case MATCHER_AMBIGUOUS: + return CMD_ERR_AMBIGUOUS; + default: + return CMD_ERR_NO_MATCH; } + } - if (matched_count > 1) - return CMD_ERR_AMBIGUOUS; - - ret = cmd_parse(matched_element, vline, &argc, argv); - if (ret != CMD_SUCCESS) - return ret; + // build argv array from argv list + struct cmd_token **argv = XMALLOC (MTYPE_TMP, argv_list->count * sizeof (struct cmd_token *)); + struct listnode *ln; + struct cmd_token *token; + unsigned int i = 0; + for (ALL_LIST_ELEMENTS_RO(argv_list,ln,token)) + argv[i++] = token; - /* For vtysh execution. */ - if (cmd) - *cmd = matched_element; + int argc = argv_list->count; + int ret; if (matched_element->daemon) - return CMD_SUCCESS_DAEMON; + ret = CMD_SUCCESS_DAEMON; + else + ret = matched_element->func (matched_element, vty, argc, argv); - /* Execute matched command. */ - return (*matched_element->func) (matched_element, vty, argc, argv); + // delete list and cmd_token's in it + list_delete (argv_list); + XFREE (MTYPE_TMP, argv); + + return ret; } /** @@ -2722,14 +837,16 @@ cmd_execute_command_real (vector vline, * as to why no command could be executed. */ int -cmd_execute_command (vector vline, struct vty *vty, struct cmd_element **cmd, - int vtysh) { - int ret, saved_ret, tried = 0; +cmd_execute_command (vector vline, struct vty *vty, + const struct cmd_element **cmd, + int vtysh) +{ + int ret, saved_ret = 0; enum node_type onode, try_node; onode = try_node = vty->node; - if ( cmd_try_do_shortcut(vty->node, vector_slot(vline, 0) ) ) + if (cmd_try_do_shortcut(vty->node, vector_slot(vline, 0))) { vector shifted_vline; unsigned int index; @@ -2739,10 +856,8 @@ cmd_execute_command (vector vline, struct vty *vty, struct cmd_element **cmd, shifted_vline = vector_init (vector_count(vline)); /* use memcpy? */ - for (index = 1; index < vector_active (vline); index++) - { - vector_set_index (shifted_vline, index-1, vector_lookup(vline, index)); - } + for (index = 1; index < vector_active (vline); index++) + vector_set_index (shifted_vline, index-1, vector_lookup(vline, index)); ret = cmd_execute_command_real (shifted_vline, FILTER_RELAXED, vty, cmd); @@ -2751,30 +866,27 @@ cmd_execute_command (vector vline, struct vty *vty, struct cmd_element **cmd, return ret; } - saved_ret = ret = cmd_execute_command_real (vline, FILTER_RELAXED, vty, cmd); if (vtysh) return saved_ret; - /* This assumes all nodes above CONFIG_NODE are childs of CONFIG_NODE */ - while ( ret != CMD_SUCCESS && ret != CMD_WARNING - && vty->node > CONFIG_NODE ) + if (ret != CMD_SUCCESS && ret != CMD_WARNING) { - try_node = node_parent(try_node); - vty->node = try_node; - ret = cmd_execute_command_real (vline, FILTER_RELAXED, vty, cmd); - tried = 1; - if (ret == CMD_SUCCESS || ret == CMD_WARNING) - { - /* succesfull command, leave the node as is */ - return ret; - } + /* This assumes all nodes above CONFIG_NODE are childs of CONFIG_NODE */ + while (vty->node > CONFIG_NODE) + { + try_node = node_parent(try_node); + vty->node = try_node; + ret = cmd_execute_command_real (vline, FILTER_RELAXED, vty, cmd); + if (ret == CMD_SUCCESS || ret == CMD_WARNING) + return ret; + } + /* no command succeeded, reset the vty to the original node */ + vty->node = onode; } - /* no command succeeded, reset the vty to the original node and - return the error for this node */ - if ( tried ) - vty->node = onode; + + /* return command status for original node */ return saved_ret; } @@ -2793,7 +905,7 @@ cmd_execute_command (vector vline, struct vty *vty, struct cmd_element **cmd, */ int cmd_execute_command_strict (vector vline, struct vty *vty, - struct cmd_element **cmd) + const struct cmd_element **cmd) { return cmd_execute_command_real(vline, FILTER_STRICT, vty, cmd); } @@ -2811,7 +923,7 @@ cmd_execute_command_strict (vector vline, struct vty *vty, * as to why no command could be executed. */ int -command_config_read_one_line (struct vty *vty, struct cmd_element **cmd, int use_daemon) +command_config_read_one_line (struct vty *vty, const struct cmd_element **cmd, int use_daemon) { vector vline; int saved_node; @@ -2837,7 +949,7 @@ command_config_read_one_line (struct vty *vty, struct cmd_element **cmd, int use while (!(use_daemon && ret == CMD_SUCCESS_DAEMON) && !(!use_daemon && ret == CMD_ERR_NOTHING_TODO) && - ret != CMD_SUCCESS && + ret != CMD_SUCCESS && ret != CMD_WARNING && vty->node > CONFIG_NODE) { vty->node = node_parent(vty->node); @@ -2848,14 +960,16 @@ command_config_read_one_line (struct vty *vty, struct cmd_element **cmd, int use // stay at the same node if (!(use_daemon && ret == CMD_SUCCESS_DAEMON) && !(!use_daemon && ret == CMD_ERR_NOTHING_TODO) && - ret != CMD_SUCCESS && + ret != CMD_SUCCESS && ret != CMD_WARNING) { - vty->node = saved_node; - memcpy(vty->error_buf, vty->buf, VTY_BUFSIZ); + vty->node = saved_node; } } + if (ret != CMD_SUCCESS && ret != CMD_WARNING) + memcpy (vty->error_buf, vty->buf, VTY_BUFSIZ); + cmd_free_strvec (vline); return ret; @@ -2871,13 +985,13 @@ config_from_file (struct vty *vty, FILE *fp, unsigned int *line_num) while (fgets (vty->buf, VTY_BUFSIZ, fp)) { if (!error_ret) - ++(*line_num); + ++(*line_num); ret = command_config_read_one_line (vty, NULL, 0); if (ret != CMD_SUCCESS && ret != CMD_WARNING && - ret != CMD_ERR_NOTHING_TODO) - error_ret = ret; + ret != CMD_ERR_NOTHING_TODO) + error_ret = ret; } if (error_ret) { @@ -2905,7 +1019,7 @@ DEFUN (config_terminal, } /* Enable command */ -DEFUN (enable, +DEFUN (enable, config_enable_cmd, "enable", "Turn on privileged mode command\n") @@ -2921,7 +1035,7 @@ DEFUN (enable, } /* Disable command */ -DEFUN (disable, +DEFUN (disable, config_disable_cmd, "disable", "Turn off privileged mode command\n") @@ -2942,9 +1056,9 @@ DEFUN (config_exit, case VIEW_NODE: case ENABLE_NODE: if (vty_shell (vty)) - exit (0); + exit (0); else - vty->status = VTY_CLOSE; + vty->status = VTY_CLOSE; break; case CONFIG_NODE: vty->node = ENABLE_NODE; @@ -3007,12 +1121,16 @@ DEFUN (config_exit, return CMD_SUCCESS; } -/* quit is alias of exit. */ -ALIAS (config_exit, +/* ALIAS_FIXME */ +DEFUN (config_quit, config_quit_cmd, "quit", "Exit current mode and down to previous mode\n") - +{ + return config_exit (self, vty, argc, argv); +} + + /* End of configuration. */ DEFUN (config_end, config_end_cmd, @@ -3078,7 +1196,7 @@ DEFUN (show_version, "Displays zebra version\n") { vty_out (vty, "Quagga %s (%s).%s", QUAGGA_VERSION, host.name?host.name:"", - VTY_NEWLINE); + VTY_NEWLINE); vty_out (vty, "%s%s%s", QUAGGA_COPYRIGHT, GIT_INFO, VTY_NEWLINE); vty_out (vty, "configured with:%s %s%s", VTY_NEWLINE, QUAGGA_CONFIG_ARGS, VTY_NEWLINE); @@ -3092,8 +1210,8 @@ DEFUN (config_help, "help", "Description of the interactive help system\n") { - vty_out (vty, - "Quagga VTY provides advanced help feature. When you need help,%s\ + vty_out (vty, + "Quagga VTY provides advanced help feature. When you need help,%s\ anytime at the command line please press '?'.%s\ %s\ If nothing matches, the help list will be empty and you must backup%s\ @@ -3105,37 +1223,92 @@ argument.%s\ 2. Partial help is provided when an abbreviated argument is entered%s\ and you want to know what arguments match the input%s\ (e.g. 'show me?'.)%s%s", VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, - VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, - VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); + VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, + VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); return CMD_SUCCESS; } +static void +permute (struct graph_node *start, struct vty *vty) +{ + static struct list *position = NULL; + if (!position) position = list_new (); + + // recursive dfs + listnode_add (position, start); + for (unsigned int i = 0; i < vector_active (start->to); i++) + { + struct graph_node *gn = vector_slot (start->to, i); + struct cmd_token *tok = gn->data; + if (tok->attr == CMD_ATTR_HIDDEN || + tok->attr == CMD_ATTR_DEPRECATED) + continue; + else if (tok->type == END_TKN || gn == start) + { + struct graph_node *gnn; + struct listnode *ln; + vty_out (vty, " "); + for (ALL_LIST_ELEMENTS_RO (position,ln,gnn)) + { + struct cmd_token *tt = gnn->data; + if (tt->type < SELECTOR_TKN) + vty_out (vty, " %s", tt->text); + } + if (gn == start) + vty_out (vty, "..."); + vty_out (vty, VTY_NEWLINE); + } + else + permute (gn, vty); + } + list_delete_node (position, listtail(position)); +} + /* Help display function for all node. */ DEFUN (config_list, config_list_cmd, - "list", - "Print command list\n") + "list [permutations]", + "Print command list\n" + "Print all possible command permutations\n") { - unsigned int i; - struct cmd_node *cnode = vector_slot (cmdvec, vty->node); - struct cmd_element *cmd; - - for (i = 0; i < vector_active (cnode->cmd_vector); i++) - if ((cmd = vector_slot (cnode->cmd_vector, i)) != NULL - && !(cmd->attr == CMD_ATTR_DEPRECATED - || cmd->attr == CMD_ATTR_HIDDEN)) - vty_out (vty, " %s%s", cmd->string, - VTY_NEWLINE); + struct cmd_node *node = vector_slot (cmdvec, vty->node); + + if ((strmatch (argv[0]->text, "list") && argc == 2) || + (strmatch (argv[0]->text, "show") && argc == 3)) + permute (vector_slot (node->cmdgraph->nodes, 0), vty); + else + { + /* loop over all commands at this node */ + struct cmd_element *element = NULL; + for (unsigned int i = 0; i < vector_active(node->cmd_vector); i++) + if ((element = vector_slot (node->cmd_vector, i)) && + element->attr != CMD_ATTR_DEPRECATED && + element->attr != CMD_ATTR_HIDDEN) + vty_out (vty, " %s%s", element->string, VTY_NEWLINE); + } return CMD_SUCCESS; } +DEFUN (show_commandtree, + show_commandtree_cmd, + "show commandtree [permutations]", + SHOW_STR + "Show command tree\n") +{ + return config_list (self, vty, argc, argv); +} + /* Write current configuration into file. */ -DEFUN (config_write_file, - config_write_file_cmd, - "write file", + +DEFUN (config_write, + config_write_cmd, + "write [<file|memory|terminal>]", "Write running configuration to memory, network, or terminal\n" - "Write to configuration file\n") + "Write to configuration file\n" + "Write configuration currently in memory\n" + "Write configuration to terminal\n") { + int idx_type = 1; unsigned int i; int fd; struct cmd_node *node; @@ -3146,6 +1319,37 @@ DEFUN (config_write_file, struct vty *file_vty; struct stat conf_stat; + // if command was 'write terminal', 'write memory' or 'show running-config' + if (argc == 2 && (!strcmp(argv[idx_type]->text, "terminal") || + !strcmp(argv[idx_type]->text, "memory") || + !strcmp(argv[0]->text, "show"))) + { + if (vty->type == VTY_SHELL_SERV) + { + for (i = 0; i < vector_active (cmdvec); i++) + if ((node = vector_slot (cmdvec, i)) && node->func && node->vtysh) + { + if ((*node->func) (vty)) + vty_out (vty, "!%s", VTY_NEWLINE); + } + } + else + { + vty_out (vty, "%sCurrent configuration:%s", VTY_NEWLINE, + VTY_NEWLINE); + vty_out (vty, "!%s", VTY_NEWLINE); + + for (i = 0; i < vector_active (cmdvec); i++) + if ((node = vector_slot (cmdvec, i)) && node->func) + { + if ((*node->func) (vty)) + vty_out (vty, "!%s", VTY_NEWLINE); + } + vty_out (vty, "end%s",VTY_NEWLINE); + } + return CMD_SUCCESS; + } + if (host.noconfig) return CMD_SUCCESS; @@ -3153,13 +1357,13 @@ DEFUN (config_write_file, if (host.config == NULL) { vty_out (vty, "Can't save to configuration file, using vtysh.%s", - VTY_NEWLINE); + VTY_NEWLINE); return CMD_WARNING; } /* Get filename. */ config_file = host.config; - + config_file_sav = XMALLOC (MTYPE_TMP, strlen (config_file) + strlen (CONF_BACKUP_EXT) + 1); strcpy (config_file_sav, config_file); @@ -3168,16 +1372,16 @@ DEFUN (config_write_file, config_file_tmp = XMALLOC (MTYPE_TMP, strlen (config_file) + 8); sprintf (config_file_tmp, "%s.XXXXXX", config_file); - + /* Open file to configuration write. */ fd = mkstemp (config_file_tmp); if (fd < 0) { vty_out (vty, "Can't open configuration file %s.%s", config_file_tmp, - VTY_NEWLINE); + VTY_NEWLINE); goto finished; } - + /* Make vty for configuration file. */ file_vty = vty_new (); file_vty->wfd = fd; @@ -3191,51 +1395,51 @@ DEFUN (config_write_file, for (i = 0; i < vector_active (cmdvec); i++) if ((node = vector_slot (cmdvec, i)) && node->func) { - if ((*node->func) (file_vty)) - vty_out (file_vty, "!\n"); + if ((*node->func) (file_vty)) + vty_out (file_vty, "!\n"); } vty_close (file_vty); if (stat(config_file, &conf_stat) >= 0) { if (unlink (config_file_sav) != 0) - if (errno != ENOENT) - { - vty_out (vty, "Can't unlink backup configuration file %s.%s", config_file_sav, - VTY_NEWLINE); - goto finished; - } + if (errno != ENOENT) + { + vty_out (vty, "Can't unlink backup configuration file %s.%s", config_file_sav, + VTY_NEWLINE); + goto finished; + } if (link (config_file, config_file_sav) != 0) - { - vty_out (vty, "Can't backup old configuration file %s.%s", config_file_sav, - VTY_NEWLINE); - goto finished; - } + { + vty_out (vty, "Can't backup old configuration file %s.%s", config_file_sav, + VTY_NEWLINE); + goto finished; + } sync (); if (unlink (config_file) != 0) - { - vty_out (vty, "Can't unlink configuration file %s.%s", config_file, - VTY_NEWLINE); - goto finished; - } + { + vty_out (vty, "Can't unlink configuration file %s.%s", config_file, + VTY_NEWLINE); + goto finished; + } } if (link (config_file_tmp, config_file) != 0) { vty_out (vty, "Can't save configuration file %s.%s", config_file, - VTY_NEWLINE); + VTY_NEWLINE); goto finished; } sync (); - + if (chmod (config_file, CONFIGFILE_MASK) != 0) { - vty_out (vty, "Can't chmod configuration file %s: %s (%d).%s", - config_file, safe_strerror(errno), errno, VTY_NEWLINE); + vty_out (vty, "Can't chmod configuration file %s: %s (%d).%s", + config_file, safe_strerror(errno), errno, VTY_NEWLINE); goto finished; } vty_out (vty, "Configuration saved to %s%s", config_file, - VTY_NEWLINE); + VTY_NEWLINE); ret = CMD_SUCCESS; finished: @@ -3245,76 +1449,34 @@ finished: return ret; } -ALIAS (config_write_file, - config_write_cmd, - "write", - "Write running configuration to memory, network, or terminal\n") - -ALIAS (config_write_file, - config_write_memory_cmd, - "write memory", - "Write running configuration to memory, network, or terminal\n" - "Write configuration to the file (same as write file)\n") +/* ALIAS_FIXME for 'write <terminal|memory>' */ +DEFUN (show_running_config, + show_running_config_cmd, + "show running-config", + SHOW_STR + "running configuration (same as write terminal/memory)\n") +{ + return config_write (self, vty, argc, argv); +} -ALIAS (config_write_file, - copy_runningconfig_startupconfig_cmd, - "copy running-config startup-config", +/* ALIAS_FIXME for 'write file' */ +DEFUN (copy_runningconf_startupconf, + copy_runningconf_startupconf_cmd, + "copy running-config startup-config", "Copy configuration\n" "Copy running config to... \n" "Copy running config to startup config (same as write file)\n") - -/* Write current configuration into the terminal. */ -DEFUN (config_write_terminal, - config_write_terminal_cmd, - "write terminal", - "Write running configuration to memory, network, or terminal\n" - "Write to terminal\n") { - unsigned int i; - struct cmd_node *node; - - if (host.noconfig) - return CMD_SUCCESS; - - if (vty->type == VTY_SHELL_SERV) - { - for (i = 0; i < vector_active (cmdvec); i++) - if ((node = vector_slot (cmdvec, i)) && node->func && node->vtysh) - { - if ((*node->func) (vty)) - vty_out (vty, "!%s", VTY_NEWLINE); - } - } - else - { - vty_out (vty, "%sCurrent configuration:%s", VTY_NEWLINE, - VTY_NEWLINE); - vty_out (vty, "!%s", VTY_NEWLINE); - - for (i = 0; i < vector_active (cmdvec); i++) - if ((node = vector_slot (cmdvec, i)) && node->func) - { - if ((*node->func) (vty)) - vty_out (vty, "!%s", VTY_NEWLINE); - } - vty_out (vty, "end%s",VTY_NEWLINE); - } - return CMD_SUCCESS; + return config_write (self, vty, argc, argv); } - -/* Write current configuration into the terminal. */ -ALIAS (config_write_terminal, - show_running_config_cmd, - "show running-config", - SHOW_STR - "running configuration\n") +/** -- **/ /* Write startup configuration into the terminal. */ DEFUN (show_startup_config, show_startup_config_cmd, "show startup-config", SHOW_STR - "Contentes of startup configuration\n") + "Contents of startup configuration\n") { char buf[BUFSIZ]; FILE *confp; @@ -3328,7 +1490,7 @@ DEFUN (show_startup_config, if (confp == NULL) { vty_out (vty, "Can't open configuration file [%s] due to '%s'%s", - host.config, safe_strerror(errno), VTY_NEWLINE); + host.config, safe_strerror(errno), VTY_NEWLINE); return CMD_WARNING; } @@ -3337,7 +1499,7 @@ DEFUN (show_startup_config, char *cp = buf; while (*cp != '\r' && *cp != '\n' && *cp != '\0') - cp++; + cp++; *cp = '\0'; vty_out (vty, "%s%s", buf, VTY_NEWLINE); @@ -3349,13 +1511,15 @@ DEFUN (show_startup_config, } /* Hostname configuration */ -DEFUN (config_hostname, +DEFUN (config_hostname, hostname_cmd, "hostname WORD", "Set system's network name\n" "This system's network name\n") { - if (!isalpha((int) *argv[0])) + struct cmd_token *word = argv[1]; + + if (!isalpha((int) word->arg[0])) { vty_out (vty, "Please specify string starting with alphabet%s", VTY_NEWLINE); return CMD_WARNING; @@ -3363,12 +1527,12 @@ DEFUN (config_hostname, if (host.name) XFREE (MTYPE_HOST, host.name); - - host.name = XSTRDUP (MTYPE_HOST, argv[0]); + + host.name = XSTRDUP (MTYPE_HOST, word->arg); return CMD_SUCCESS; } -DEFUN (config_no_hostname, +DEFUN (config_no_hostname, no_hostname_cmd, "no hostname [HOSTNAME]", NO_STR @@ -3382,43 +1546,30 @@ DEFUN (config_no_hostname, } /* VTY interface password set. */ -DEFUN (config_password, password_cmd, - "password (8|) WORD", +DEFUN (config_password, + password_cmd, + "password [(8-8)] WORD", "Assign the terminal connection password\n" "Specifies a HIDDEN password will follow\n" - "dummy string \n" - "The HIDDEN line password string\n") + "The password string\n") { - /* Argument check. */ - if (argc == 0) - { - vty_out (vty, "Please specify password.%s", VTY_NEWLINE); - return CMD_WARNING; - } - - if (argc == 2) - { - if (*argv[0] == '8') - { - if (host.password) - XFREE (MTYPE_HOST, host.password); - host.password = NULL; - if (host.password_encrypt) - XFREE (MTYPE_HOST, host.password_encrypt); - host.password_encrypt = XSTRDUP (MTYPE_HOST, argv[1]); - return CMD_SUCCESS; - } - else - { - vty_out (vty, "Unknown encryption type.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } + int idx_8 = 1; + int idx_word = 2; + if (argc == 3) // '8' was specified + { + if (host.password) + XFREE (MTYPE_HOST, host.password); + host.password = NULL; + if (host.password_encrypt) + XFREE (MTYPE_HOST, host.password_encrypt); + host.password_encrypt = XSTRDUP (MTYPE_HOST, argv[idx_word]->arg); + return CMD_SUCCESS; + } - if (!isalnum ((int) *argv[0])) + if (!isalnum (argv[idx_8]->arg[0])) { - vty_out (vty, - "Please specify string starting with alphanumeric%s", VTY_NEWLINE); + vty_out (vty, + "Please specify string starting with alphanumeric%s", VTY_NEWLINE); return CMD_WARNING; } @@ -3429,62 +1580,53 @@ DEFUN (config_password, password_cmd, if (host.encrypt) { if (host.password_encrypt) - XFREE (MTYPE_HOST, host.password_encrypt); - host.password_encrypt = XSTRDUP (MTYPE_HOST, zencrypt (argv[0])); + XFREE (MTYPE_HOST, host.password_encrypt); + host.password_encrypt = XSTRDUP (MTYPE_HOST, zencrypt (argv[idx_8]->arg)); } else - host.password = XSTRDUP (MTYPE_HOST, argv[0]); + host.password = XSTRDUP (MTYPE_HOST, argv[idx_8]->arg); return CMD_SUCCESS; } -ALIAS (config_password, password_text_cmd, - "password LINE", - "Assign the terminal connection password\n" - "The UNENCRYPTED (cleartext) line password\n") - /* VTY enable password set. */ -DEFUN (config_enable_password, enable_password_cmd, - "enable password (8|) WORD", +DEFUN (config_enable_password, + enable_password_cmd, + "enable password [(8-8)] WORD", "Modify enable password parameters\n" "Assign the privileged level password\n" "Specifies a HIDDEN password will follow\n" - "dummy string \n" "The HIDDEN 'enable' password string\n") { - /* Argument check. */ - if (argc == 0) - { - vty_out (vty, "Please specify password.%s", VTY_NEWLINE); - return CMD_WARNING; - } + int idx_8 = 2; + int idx_word = 3; /* Crypt type is specified. */ - if (argc == 2) + if (argc == 4) { - if (*argv[0] == '8') - { - if (host.enable) - XFREE (MTYPE_HOST, host.enable); - host.enable = NULL; - - if (host.enable_encrypt) - XFREE (MTYPE_HOST, host.enable_encrypt); - host.enable_encrypt = XSTRDUP (MTYPE_HOST, argv[1]); - - return CMD_SUCCESS; - } + if (argv[idx_8]->arg[0] == '8') + { + if (host.enable) + XFREE (MTYPE_HOST, host.enable); + host.enable = NULL; + + if (host.enable_encrypt) + XFREE (MTYPE_HOST, host.enable_encrypt); + host.enable_encrypt = XSTRDUP (MTYPE_HOST, argv[idx_word]->arg); + + return CMD_SUCCESS; + } else - { - vty_out (vty, "Unknown encryption type.%s", VTY_NEWLINE); - return CMD_WARNING; - } + { + vty_out (vty, "Unknown encryption type.%s", VTY_NEWLINE); + return CMD_WARNING; + } } - if (!isalnum ((int) *argv[0])) + if (!isalnum (argv[idx_8]->arg[0])) { - vty_out (vty, - "Please specify string starting with alphanumeric%s", VTY_NEWLINE); + vty_out (vty, + "Please specify string starting with alphanumeric%s", VTY_NEWLINE); return CMD_WARNING; } @@ -3496,24 +1638,18 @@ DEFUN (config_enable_password, enable_password_cmd, if (host.encrypt) { if (host.enable_encrypt) - XFREE (MTYPE_HOST, host.enable_encrypt); - host.enable_encrypt = XSTRDUP (MTYPE_HOST, zencrypt (argv[0])); + XFREE (MTYPE_HOST, host.enable_encrypt); + host.enable_encrypt = XSTRDUP (MTYPE_HOST, zencrypt (argv[idx_8]->arg)); } else - host.enable = XSTRDUP (MTYPE_HOST, argv[0]); + host.enable = XSTRDUP (MTYPE_HOST, argv[idx_8]->arg); return CMD_SUCCESS; } -ALIAS (config_enable_password, - enable_password_text_cmd, - "enable password LINE", - "Modify enable password parameters\n" - "Assign the privileged level password\n" - "The UNENCRYPTED (cleartext) 'enable' password\n") - /* VTY enable password delete. */ -DEFUN (no_config_enable_password, no_enable_password_cmd, +DEFUN (no_config_enable_password, + no_enable_password_cmd, "no enable password", NO_STR "Modify enable password parameters\n" @@ -3529,7 +1665,7 @@ DEFUN (no_config_enable_password, no_enable_password_cmd, return CMD_SUCCESS; } - + DEFUN (service_password_encrypt, service_password_encrypt_cmd, "service password-encryption", @@ -3544,13 +1680,13 @@ DEFUN (service_password_encrypt, if (host.password) { if (host.password_encrypt) - XFREE (MTYPE_HOST, host.password_encrypt); + XFREE (MTYPE_HOST, host.password_encrypt); host.password_encrypt = XSTRDUP (MTYPE_HOST, zencrypt (host.password)); } if (host.enable) { if (host.enable_encrypt) - XFREE (MTYPE_HOST, host.enable_encrypt); + XFREE (MTYPE_HOST, host.enable_encrypt); host.enable_encrypt = XSTRDUP (MTYPE_HOST, zencrypt (host.enable)); } @@ -3580,16 +1716,18 @@ DEFUN (no_service_password_encrypt, return CMD_SUCCESS; } -DEFUN (config_terminal_length, config_terminal_length_cmd, - "terminal length <0-512>", +DEFUN (config_terminal_length, + config_terminal_length_cmd, + "terminal length (0-512)", "Set terminal line parameters\n" "Set number of lines on a screen\n" "Number of lines on screen (0 for no pausing)\n") { + int idx_number = 2; int lines; char *endptr = NULL; - lines = strtol (argv[0], &endptr, 10); + lines = strtol (argv[idx_number]->arg, &endptr, 10); if (lines < 0 || lines > 512 || *endptr != '\0') { vty_out (vty, "length is malformed%s", VTY_NEWLINE); @@ -3600,7 +1738,8 @@ DEFUN (config_terminal_length, config_terminal_length_cmd, return CMD_SUCCESS; } -DEFUN (config_terminal_no_length, config_terminal_no_length_cmd, +DEFUN (config_terminal_no_length, + config_terminal_no_length_cmd, "terminal no length", "Set terminal line parameters\n" NO_STR @@ -3610,16 +1749,18 @@ DEFUN (config_terminal_no_length, config_terminal_no_length_cmd, return CMD_SUCCESS; } -DEFUN (service_terminal_length, service_terminal_length_cmd, - "service terminal-length <0-512>", +DEFUN (service_terminal_length, + service_terminal_length_cmd, + "service terminal-length (0-512)", "Set up miscellaneous service\n" "System wide terminal length configuration\n" "Number of lines of VTY (0 means no line control)\n") { + int idx_number = 2; int lines; char *endptr = NULL; - lines = strtol (argv[0], &endptr, 10); + lines = strtol (argv[idx_number]->arg, &endptr, 10); if (lines < 0 || lines > 512 || *endptr != '\0') { vty_out (vty, "length is malformed%s", VTY_NEWLINE); @@ -3630,8 +1771,9 @@ DEFUN (service_terminal_length, service_terminal_length_cmd, return CMD_SUCCESS; } -DEFUN (no_service_terminal_length, no_service_terminal_length_cmd, - "no service terminal-length [<0-512>]", +DEFUN (no_service_terminal_length, + no_service_terminal_length_cmd, + "no service terminal-length [(0-512)]", NO_STR "Set up miscellaneous service\n" "System wide terminal length configuration\n" @@ -3642,15 +1784,15 @@ DEFUN (no_service_terminal_length, no_service_terminal_length_cmd, } DEFUN_HIDDEN (do_echo, - echo_cmd, - "echo .MESSAGE", - "Echo a message back to the vty\n" - "The message to echo\n") + echo_cmd, + "echo MESSAGE...", + "Echo a message back to the vty\n" + "The message to echo\n") { char *message; - vty_out (vty, "%s%s", ((message = argv_concat(argv, argc, 0)) ? message : ""), - VTY_NEWLINE); + vty_out (vty, "%s%s", ((message = argv_concat (argv, argc, 1)) ? message : ""), + VTY_NEWLINE); if (message) XFREE(MTYPE_TMP, message); return CMD_SUCCESS; @@ -3658,18 +1800,20 @@ DEFUN_HIDDEN (do_echo, DEFUN (config_logmsg, config_logmsg_cmd, - "logmsg "LOG_LEVELS" .MESSAGE", + "logmsg <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging> MESSAGE...", "Send a message to enabled logging destinations\n" LOG_LEVEL_DESC "The message to send\n") { + int idx_log_level = 1; + int idx_message = 2; int level; char *message; - if ((level = level_match(argv[0])) == ZLOG_DISABLED) + if ((level = level_match(argv[idx_log_level]->arg)) == ZLOG_DISABLED) return CMD_ERR_NO_MATCH; - zlog(NULL, level, "%s", ((message = argv_concat(argv, argc, 1)) ? message : "")); + zlog(NULL, level, "%s", ((message = argv_concat(argv, argc, idx_message)) ? message : "")); if (message) XFREE(MTYPE_TMP, message); @@ -3689,8 +1833,8 @@ DEFUN (show_logging, vty_out (vty, "disabled"); else vty_out (vty, "level %s, facility %s, ident %s", - zlog_priority[zl->maxlvl[ZLOG_DEST_SYSLOG]], - facility_name(zl->facility), zl->ident); + zlog_priority[zl->maxlvl[ZLOG_DEST_SYSLOG]], + facility_name(zl->facility), zl->ident); vty_out (vty, "%s", VTY_NEWLINE); vty_out (vty, "Stdout logging: "); @@ -3698,7 +1842,7 @@ DEFUN (show_logging, vty_out (vty, "disabled"); else vty_out (vty, "level %s", - zlog_priority[zl->maxlvl[ZLOG_DEST_STDOUT]]); + zlog_priority[zl->maxlvl[ZLOG_DEST_STDOUT]]); vty_out (vty, "%s", VTY_NEWLINE); vty_out (vty, "Monitor logging: "); @@ -3706,7 +1850,7 @@ DEFUN (show_logging, vty_out (vty, "disabled"); else vty_out (vty, "level %s", - zlog_priority[zl->maxlvl[ZLOG_DEST_MONITOR]]); + zlog_priority[zl->maxlvl[ZLOG_DEST_MONITOR]]); vty_out (vty, "%s", VTY_NEWLINE); vty_out (vty, "File logging: "); @@ -3715,40 +1859,37 @@ DEFUN (show_logging, vty_out (vty, "disabled"); else vty_out (vty, "level %s, filename %s", - zlog_priority[zl->maxlvl[ZLOG_DEST_FILE]], - zl->filename); + zlog_priority[zl->maxlvl[ZLOG_DEST_FILE]], + zl->filename); vty_out (vty, "%s", VTY_NEWLINE); vty_out (vty, "Protocol name: %s%s", - zlog_proto_names[zl->protocol], VTY_NEWLINE); + zlog_proto_names[zl->protocol], VTY_NEWLINE); vty_out (vty, "Record priority: %s%s", - (zl->record_priority ? "enabled" : "disabled"), VTY_NEWLINE); + (zl->record_priority ? "enabled" : "disabled"), VTY_NEWLINE); vty_out (vty, "Timestamp precision: %d%s", - zl->timestamp_precision, VTY_NEWLINE); + zl->timestamp_precision, VTY_NEWLINE); return CMD_SUCCESS; } DEFUN (config_log_stdout, config_log_stdout_cmd, - "log stdout", - "Logging control\n" - "Set stdout logging level\n") -{ - zlog_set_level (NULL, ZLOG_DEST_STDOUT, zlog_default->default_lvl); - return CMD_SUCCESS; -} - -DEFUN (config_log_stdout_level, - config_log_stdout_level_cmd, - "log stdout "LOG_LEVELS, + "log stdout [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]", "Logging control\n" "Set stdout logging level\n" LOG_LEVEL_DESC) { + int idx_log_level = 2; + + if (argc == idx_log_level) + { + zlog_set_level (NULL, ZLOG_DEST_STDOUT, zlog_default->default_lvl); + return CMD_SUCCESS; + } int level; - if ((level = level_match(argv[0])) == ZLOG_DISABLED) + if ((level = level_match(argv[idx_log_level]->arg)) == ZLOG_DISABLED) return CMD_ERR_NO_MATCH; zlog_set_level (NULL, ZLOG_DEST_STDOUT, level); return CMD_SUCCESS; @@ -3756,11 +1897,11 @@ DEFUN (config_log_stdout_level, DEFUN (no_config_log_stdout, no_config_log_stdout_cmd, - "no log stdout [LEVEL]", + "no log stdout [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]", NO_STR "Logging control\n" "Cancel logging to stdout\n" - "Logging level\n") + LOG_LEVEL_DESC) { zlog_set_level (NULL, ZLOG_DEST_STDOUT, ZLOG_DISABLED); return CMD_SUCCESS; @@ -3768,24 +1909,21 @@ DEFUN (no_config_log_stdout, DEFUN (config_log_monitor, config_log_monitor_cmd, - "log monitor", - "Logging control\n" - "Set terminal line (monitor) logging level\n") -{ - zlog_set_level (NULL, ZLOG_DEST_MONITOR, zlog_default->default_lvl); - return CMD_SUCCESS; -} - -DEFUN (config_log_monitor_level, - config_log_monitor_level_cmd, - "log monitor "LOG_LEVELS, + "log monitor [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]", "Logging control\n" "Set terminal line (monitor) logging level\n" LOG_LEVEL_DESC) { + int idx_log_level = 2; + + if (argc == idx_log_level) + { + zlog_set_level (NULL, ZLOG_DEST_MONITOR, zlog_default->default_lvl); + return CMD_SUCCESS; + } int level; - if ((level = level_match(argv[0])) == ZLOG_DISABLED) + if ((level = level_match(argv[idx_log_level]->arg)) == ZLOG_DISABLED) return CMD_ERR_NO_MATCH; zlog_set_level (NULL, ZLOG_DEST_MONITOR, level); return CMD_SUCCESS; @@ -3793,11 +1931,11 @@ DEFUN (config_log_monitor_level, DEFUN (no_config_log_monitor, no_config_log_monitor_cmd, - "no log monitor [LEVEL]", + "no log monitor [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]", NO_STR "Logging control\n" "Disable terminal line (monitor) logging\n" - "Logging level\n") + LOG_LEVEL_DESC) { zlog_set_level (NULL, ZLOG_DEST_MONITOR, ZLOG_DISABLED); return CMD_SUCCESS; @@ -3809,19 +1947,19 @@ set_log_file(struct vty *vty, const char *fname, int loglevel) int ret; char *p = NULL; const char *fullpath; - + /* Path detection. */ if (! IS_DIRECTORY_SEP (*fname)) { char cwd[MAXPATHLEN+1]; cwd[MAXPATHLEN] = '\0'; - + if (getcwd (cwd, MAXPATHLEN) == NULL) { zlog_err ("config_log_file: Unable to alloc mem!"); return CMD_WARNING; } - + if ( (p = XMALLOC (MTYPE_TMP, strlen (cwd) + strlen (fname) + 2)) == NULL) { @@ -3859,36 +1997,34 @@ set_log_file(struct vty *vty, const char *fname, int loglevel) DEFUN (config_log_file, config_log_file_cmd, - "log file FILENAME", - "Logging control\n" - "Logging to file\n" - "Logging filename\n") -{ - return set_log_file(vty, argv[0], zlog_default->default_lvl); -} - -DEFUN (config_log_file_level, - config_log_file_level_cmd, - "log file FILENAME "LOG_LEVELS, + "log file FILENAME [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]", "Logging control\n" "Logging to file\n" "Logging filename\n" LOG_LEVEL_DESC) { - int level; - - if ((level = level_match(argv[1])) == ZLOG_DISABLED) - return CMD_ERR_NO_MATCH; - return set_log_file(vty, argv[0], level); + int idx_filename = 2; + int idx_log_levels = 3; + if (argc == 4) + { + int level; + if ((level = level_match(argv[idx_log_levels]->arg)) == ZLOG_DISABLED) + return CMD_ERR_NO_MATCH; + return set_log_file(vty, argv[idx_filename]->arg, level); + } + else + return set_log_file(vty, argv[idx_filename]->arg, zlog_default->default_lvl); } DEFUN (no_config_log_file, no_config_log_file_cmd, - "no log file [FILENAME]", + "no log file [FILENAME [LEVEL]]", NO_STR "Logging control\n" "Cancel logging to file\n" - "Logging file name\n") + "Logging file name\n" + "Logging file name\n" + "Logging level\n") { zlog_reset_file (NULL); @@ -3900,52 +2036,38 @@ DEFUN (no_config_log_file, return CMD_SUCCESS; } -ALIAS (no_config_log_file, - no_config_log_file_level_cmd, - "no log file FILENAME LEVEL", - NO_STR - "Logging control\n" - "Cancel logging to file\n" - "Logging file name\n" - "Logging level\n") - DEFUN (config_log_syslog, config_log_syslog_cmd, - "log syslog", - "Logging control\n" - "Set syslog logging level\n") -{ - zlog_set_level (NULL, ZLOG_DEST_SYSLOG, zlog_default->default_lvl); - return CMD_SUCCESS; -} - -DEFUN (config_log_syslog_level, - config_log_syslog_level_cmd, - "log syslog "LOG_LEVELS, + "log syslog [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]", "Logging control\n" "Set syslog logging level\n" LOG_LEVEL_DESC) { - int level; - - if ((level = level_match(argv[0])) == ZLOG_DISABLED) - return CMD_ERR_NO_MATCH; - zlog_set_level (NULL, ZLOG_DEST_SYSLOG, level); - return CMD_SUCCESS; + int idx_log_levels = 2; + if (argc == 3) + { + int level; + if ((level = level_match (argv[idx_log_levels]->arg)) == ZLOG_DISABLED) + return CMD_ERR_NO_MATCH; + zlog_set_level (NULL, ZLOG_DEST_SYSLOG, level); + return CMD_SUCCESS; + } + else + { + zlog_set_level (NULL, ZLOG_DEST_SYSLOG, zlog_default->default_lvl); + return CMD_SUCCESS; + } } DEFUN_DEPRECATED (config_log_syslog_facility, - config_log_syslog_facility_cmd, - "log syslog facility "LOG_FACILITIES, - "Logging control\n" - "Logging goes to syslog\n" - "(Deprecated) Facility parameter for syslog messages\n" - LOG_FACILITY_DESC) + config_log_syslog_facility_cmd, + "log syslog facility (kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7)", + "Logging control\n" + "Logging goes to syslog\n" + "(Deprecated) Facility parameter for syslog messages\n" + LOG_FACILITY_DESC) { - int facility; - - if ((facility = facility_match(argv[0])) < 0) - return CMD_ERR_NO_MATCH; + int facility = facility_match(argv[3]->arg); zlog_set_level (NULL, ZLOG_DEST_SYSLOG, zlog_default->default_lvl); zlog_default->facility = facility; @@ -3954,63 +2076,54 @@ DEFUN_DEPRECATED (config_log_syslog_facility, DEFUN (no_config_log_syslog, no_config_log_syslog_cmd, - "no log syslog [LEVEL]", + "no log syslog [<kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>] [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]", NO_STR "Logging control\n" "Cancel logging to syslog\n" - "Logging level\n") + LOG_FACILITY_DESC + LOG_LEVEL_DESC) { zlog_set_level (NULL, ZLOG_DEST_SYSLOG, ZLOG_DISABLED); return CMD_SUCCESS; } -ALIAS (no_config_log_syslog, - no_config_log_syslog_facility_cmd, - "no log syslog facility "LOG_FACILITIES, - NO_STR - "Logging control\n" - "Logging goes to syslog\n" - "Facility parameter for syslog messages\n" - LOG_FACILITY_DESC) - DEFUN (config_log_facility, config_log_facility_cmd, - "log facility "LOG_FACILITIES, + "log facility <kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>", "Logging control\n" "Facility parameter for syslog messages\n" LOG_FACILITY_DESC) { - int facility; + int idx_target = 2; + int facility = facility_match(argv[idx_target]->arg); - if ((facility = facility_match(argv[0])) < 0) - return CMD_ERR_NO_MATCH; zlog_default->facility = facility; return CMD_SUCCESS; } DEFUN (no_config_log_facility, no_config_log_facility_cmd, - "no log facility [FACILITY]", + "no log facility [<kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>]", NO_STR "Logging control\n" "Reset syslog facility to default (daemon)\n" - "Syslog facility\n") + LOG_FACILITY_DESC) { zlog_default->facility = LOG_DAEMON; return CMD_SUCCESS; } DEFUN_DEPRECATED (config_log_trap, - config_log_trap_cmd, - "log trap "LOG_LEVELS, - "Logging control\n" - "(Deprecated) Set logging level and default for all destinations\n" - LOG_LEVEL_DESC) + config_log_trap_cmd, + "log trap <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>", + "Logging control\n" + "(Deprecated) Set logging level and default for all destinations\n" + LOG_LEVEL_DESC) { int new_level ; int i; - - if ((new_level = level_match(argv[0])) == ZLOG_DISABLED) + + if ((new_level = level_match(argv[2]->arg)) == ZLOG_DISABLED) return CMD_ERR_NO_MATCH; zlog_default->default_lvl = new_level; @@ -4021,12 +2134,12 @@ DEFUN_DEPRECATED (config_log_trap, } DEFUN_DEPRECATED (no_config_log_trap, - no_config_log_trap_cmd, - "no log trap [LEVEL]", - NO_STR - "Logging control\n" - "Permit all logging information\n" - "Logging level\n") + no_config_log_trap_cmd, + "no log trap [emergencies|alerts|critical|errors|warnings|notifications|informational|debugging]", + NO_STR + "Logging control\n" + "Permit all logging information\n" + LOG_LEVEL_DESC) { zlog_default->default_lvl = LOG_DEBUG; return CMD_SUCCESS; @@ -4055,20 +2168,15 @@ DEFUN (no_config_log_record_priority, DEFUN (config_log_timestamp_precision, config_log_timestamp_precision_cmd, - "log timestamp precision <0-6>", + "log timestamp precision (0-6)", "Logging control\n" "Timestamp configuration\n" "Set the timestamp precision\n" "Number of subsecond digits\n") { - if (argc != 1) - { - vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); - return CMD_WARNING; - } - + int idx_number = 3; VTY_GET_INTEGER_RANGE("Timestamp Precision", - zlog_default->timestamp_precision, argv[0], 0, 6); + zlog_default->timestamp_precision, argv[idx_number]->arg, 0, 6); return CMD_SUCCESS; } @@ -4099,7 +2207,7 @@ cmd_banner_motd_file (const char *file) if (in == rpath) { if (host.motdfile) - XFREE (MTYPE_HOST, host.motdfile); + XFREE (MTYPE_HOST, host.motdfile); host.motdfile = XSTRDUP (MTYPE_HOST, file); } else @@ -4116,13 +2224,14 @@ DEFUN (banner_motd_file, "Banner from a file\n" "Filename\n") { - int cmd = cmd_banner_motd_file (argv[0]); + int idx_file = 3; + const char *filename = argv[idx_file]->arg; + int cmd = cmd_banner_motd_file (filename); if (cmd == CMD_ERR_NO_FILE) - vty_out (vty, "%s does not exist", argv[0]); + vty_out (vty, "%s does not exist", filename); else if (cmd == CMD_WARNING) - vty_out (vty, "%s must be in %s", - argv[0], SYSCONFDIR); + vty_out (vty, "%s must be in %s", filename, SYSCONFDIR); return cmd; } @@ -4146,43 +2255,12 @@ DEFUN (no_banner_motd, "Strings for motd\n") { host.motd = NULL; - if (host.motdfile) + if (host.motdfile) XFREE (MTYPE_HOST, host.motdfile); host.motdfile = NULL; return CMD_SUCCESS; } -DEFUN (show_commandtree, - show_commandtree_cmd, - "show commandtree", - NO_STR - "Show command tree\n") -{ - /* TBD */ - vector cmd_vector; - unsigned int i; - - vty_out (vty, "Current node id: %d%s", vty->node, VTY_NEWLINE); - - /* vector of all commands installed at this node */ - cmd_vector = vector_copy (cmd_node_vector (cmdvec, vty->node)); - - /* loop over all commands at this node */ - for (i = 0; i < vector_active(cmd_vector); ++i) - { - struct cmd_element *cmd_element; - - /* A cmd_element (seems to be) is an individual command */ - if ((cmd_element = vector_slot (cmd_vector, i)) == NULL) - continue; - - vty_out (vty, " %s%s", cmd_element->string, VTY_NEWLINE); - } - - vector_free (cmd_vector); - return CMD_SUCCESS; -} - /* Set config filename. Called from vty.c */ void host_config_set (const char *filename) @@ -4207,9 +2285,6 @@ install_default (enum node_type node) install_element (node, &config_help_cmd); install_element (node, &config_list_cmd); - install_element (node, &config_write_terminal_cmd); - install_element (node, &config_write_file_cmd); - install_element (node, &config_write_memory_cmd); install_element (node, &config_write_cmd); install_element (node, &show_running_config_cmd); } @@ -4224,12 +2299,6 @@ cmd_init (int terminal) { qobj_init (); - command_cr = XSTRDUP(MTYPE_CMD_TOKENS, "<cr>"); - token_cr.type = TOKEN_TERMINAL; - token_cr.terminal = TERMINAL_LITERAL; - token_cr.cmd = command_cr; - token_cr.desc = XSTRDUP(MTYPE_CMD_TOKENS, ""); - /* Allocate initial top vector of commands. */ cmdvec = vector_init (VECTOR_MIN_SIZE); @@ -4272,10 +2341,7 @@ cmd_init (int terminal) install_element (ENABLE_NODE, &config_end_cmd); install_element (ENABLE_NODE, &config_disable_cmd); install_element (ENABLE_NODE, &config_terminal_cmd); - install_element (ENABLE_NODE, ©_runningconfig_startupconfig_cmd); - install_element (ENABLE_NODE, &config_write_terminal_cmd); - install_element (ENABLE_NODE, &config_write_file_cmd); - install_element (ENABLE_NODE, &config_write_memory_cmd); + install_element (ENABLE_NODE, ©_runningconf_startupconf_cmd); install_element (ENABLE_NODE, &config_write_cmd); install_element (ENABLE_NODE, &show_running_config_cmd); } @@ -4291,33 +2357,24 @@ cmd_init (int terminal) install_element (VIEW_NODE, &show_work_queues_cmd); } - + install_element (CONFIG_NODE, &hostname_cmd); install_element (CONFIG_NODE, &no_hostname_cmd); if (terminal > 0) { install_element (CONFIG_NODE, &password_cmd); - install_element (CONFIG_NODE, &password_text_cmd); install_element (CONFIG_NODE, &enable_password_cmd); - install_element (CONFIG_NODE, &enable_password_text_cmd); install_element (CONFIG_NODE, &no_enable_password_cmd); install_element (CONFIG_NODE, &config_log_stdout_cmd); - install_element (CONFIG_NODE, &config_log_stdout_level_cmd); install_element (CONFIG_NODE, &no_config_log_stdout_cmd); install_element (CONFIG_NODE, &config_log_monitor_cmd); - install_element (CONFIG_NODE, &config_log_monitor_level_cmd); install_element (CONFIG_NODE, &no_config_log_monitor_cmd); install_element (CONFIG_NODE, &config_log_file_cmd); - install_element (CONFIG_NODE, &config_log_file_level_cmd); install_element (CONFIG_NODE, &no_config_log_file_cmd); - install_element (CONFIG_NODE, &no_config_log_file_level_cmd); install_element (CONFIG_NODE, &config_log_syslog_cmd); - install_element (CONFIG_NODE, &config_log_syslog_level_cmd); - install_element (CONFIG_NODE, &config_log_syslog_facility_cmd); install_element (CONFIG_NODE, &no_config_log_syslog_cmd); - install_element (CONFIG_NODE, &no_config_log_syslog_facility_cmd); install_element (CONFIG_NODE, &config_log_facility_cmd); install_element (CONFIG_NODE, &no_config_log_facility_cmd); install_element (CONFIG_NODE, &config_log_trap_cmd); @@ -4339,87 +2396,90 @@ cmd_init (int terminal) srandom(time(NULL)); } -static void -cmd_terminate_token(struct cmd_token *token) +struct cmd_token * +new_cmd_token (enum cmd_token_type type, u_char attr, char *text, char *desc) { - unsigned int i, j; - vector keyword_vect; + struct cmd_token *token = XMALLOC (MTYPE_CMD_TOKENS, sizeof (struct cmd_token)); + token->type = type; + token->attr = attr; + token->text = text; + token->desc = desc; + token->arg = NULL; - if (token->multiple) - { - for (i = 0; i < vector_active(token->multiple); i++) - cmd_terminate_token(vector_slot(token->multiple, i)); - vector_free(token->multiple); - token->multiple = NULL; - } + return token; +} - if (token->keyword) - { - for (i = 0; i < vector_active(token->keyword); i++) - { - keyword_vect = vector_slot(token->keyword, i); - for (j = 0; j < vector_active(keyword_vect); j++) - cmd_terminate_token(vector_slot(keyword_vect, j)); - vector_free(keyword_vect); - } - vector_free(token->keyword); - token->keyword = NULL; - } +void +del_cmd_token (struct cmd_token *token) +{ + if (!token) return; - XFREE(MTYPE_CMD_TOKENS, token->cmd); - XFREE(MTYPE_CMD_TOKENS, token->desc); + if (token->text) + XFREE (MTYPE_CMD_TOKENS, token->text); + if (token->desc) + XFREE (MTYPE_CMD_TOKENS, token->desc); + if (token->arg) + XFREE (MTYPE_CMD_TOKENS, token->arg); - XFREE(MTYPE_CMD_TOKENS, token); + XFREE (MTYPE_CMD_TOKENS, token); } -static void -cmd_terminate_element(struct cmd_element *cmd) +struct cmd_token * +copy_cmd_token (struct cmd_token *token) { - unsigned int i; + struct cmd_token *copy = new_cmd_token (token->type, token->attr, NULL, NULL); + copy->max = token->max; + copy->min = token->min; + copy->text = token->text ? XSTRDUP (MTYPE_CMD_TOKENS, token->text) : NULL; + copy->desc = token->desc ? XSTRDUP (MTYPE_CMD_TOKENS, token->desc) : NULL; + copy->arg = token->arg ? XSTRDUP (MTYPE_CMD_TOKENS, token->arg) : NULL; - if (cmd->tokens == NULL) - return; + return copy; +} - for (i = 0; i < vector_active(cmd->tokens); i++) - cmd_terminate_token(vector_slot(cmd->tokens, i)); +void +del_cmd_element(struct cmd_element *cmd) +{ + if (!cmd) return; + free ((char *) cmd->string); + free ((char *) cmd->doc); + free (cmd); +} - vector_free(cmd->tokens); - cmd->tokens = NULL; +struct cmd_element * +copy_cmd_element(const struct cmd_element *cmd) +{ + struct cmd_element *el = XMALLOC(MTYPE_CMD_TOKENS, sizeof (struct cmd_element)); + el->string = cmd->string ? XSTRDUP(MTYPE_CMD_TOKENS, cmd->string) : NULL; + el->func = cmd->func; + el->doc = cmd->doc ? XSTRDUP(MTYPE_CMD_TOKENS, cmd->doc) : NULL; + el->daemon = cmd->daemon; + el->attr = cmd->attr; + return el; } void cmd_terminate () { - unsigned int i, j; struct cmd_node *cmd_node; - struct cmd_element *cmd_element; - vector cmd_node_v; if (cmdvec) { - for (i = 0; i < vector_active (cmdvec); i++) + for (unsigned int i = 0; i < vector_active (cmdvec); i++) if ((cmd_node = vector_slot (cmdvec, i)) != NULL) - { - cmd_node_v = cmd_node->cmd_vector; - - for (j = 0; j < vector_active (cmd_node_v); j++) - if ((cmd_element = vector_slot (cmd_node_v, j)) != NULL) - cmd_terminate_element(cmd_element); - - vector_free (cmd_node_v); - hash_clean (cmd_node->cmd_hash, NULL); - hash_free (cmd_node->cmd_hash); - cmd_node->cmd_hash = NULL; - } + { + // deleting the graph delets the cmd_element as well + graph_delete_graph (cmd_node->cmdgraph); + vector_free (cmd_node->cmd_vector); + hash_clean (cmd_node->cmd_hash, NULL); + hash_free (cmd_node->cmd_hash); + cmd_node->cmd_hash = NULL; + } vector_free (cmdvec); cmdvec = NULL; } - if (command_cr) - XFREE(MTYPE_CMD_TOKENS, command_cr); - if (token_cr.desc) - XFREE(MTYPE_CMD_TOKENS, token_cr.desc); if (host.name) XFREE (MTYPE_HOST, host.name); if (host.password) diff --git a/lib/command.h b/lib/command.h index d2fc969d70..50323d3753 100644 --- a/lib/command.h +++ b/lib/command.h @@ -8,7 +8,7 @@ * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2, or (at your * option) any later version. - * + * * GNU Zebra is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -26,6 +26,7 @@ #include "vector.h" #include "vty.h" #include "lib/route_types.h" +#include "graph.h" #include "memory.h" #include "hash.h" @@ -68,42 +69,42 @@ struct host }; /* There are some command levels which called from command node. */ -enum node_type +enum node_type { - AUTH_NODE, /* Authentication mode of vty interface. */ - VIEW_NODE, /* View node. Default mode of vty interface. */ - AUTH_ENABLE_NODE, /* Authentication mode for change enable. */ - ENABLE_NODE, /* Enable node. */ - CONFIG_NODE, /* Config node. Default mode of config file. */ - SERVICE_NODE, /* Service node. */ - DEBUG_NODE, /* Debug node. */ + AUTH_NODE, /* Authentication mode of vty interface. */ + VIEW_NODE, /* View node. Default mode of vty interface. */ + AUTH_ENABLE_NODE, /* Authentication mode for change enable. */ + ENABLE_NODE, /* Enable node. */ + CONFIG_NODE, /* Config node. Default mode of config file. */ + SERVICE_NODE, /* Service node. */ + DEBUG_NODE, /* Debug node. */ VRF_DEBUG_NODE, /* Vrf Debug node. */ DEBUG_VNC_NODE, /* Debug VNC node. */ - AAA_NODE, /* AAA node. */ - KEYCHAIN_NODE, /* Key-chain node. */ - KEYCHAIN_KEY_NODE, /* Key-chain key node. */ - NS_NODE, /* Logical-Router node. */ - VRF_NODE, /* VRF mode node. */ - INTERFACE_NODE, /* Interface mode node. */ - ZEBRA_NODE, /* zebra connection node. */ - TABLE_NODE, /* rtm_table selection node. */ - RIP_NODE, /* RIP protocol mode node. */ - RIPNG_NODE, /* RIPng protocol mode node. */ - BGP_NODE, /* BGP protocol mode which includes BGP4+ */ - BGP_VPNV4_NODE, /* BGP MPLS-VPN PE exchange. */ - BGP_VPNV6_NODE, /* BGP MPLS-VPN PE exchange. */ - BGP_IPV4_NODE, /* BGP IPv4 unicast address family. */ - BGP_IPV4M_NODE, /* BGP IPv4 multicast address family. */ - BGP_IPV6_NODE, /* BGP IPv6 address family */ - BGP_IPV6M_NODE, /* BGP IPv6 multicast address family. */ - BGP_ENCAP_NODE, /* BGP ENCAP SAFI */ - BGP_ENCAPV6_NODE, /* BGP ENCAP SAFI */ + AAA_NODE, /* AAA node. */ + KEYCHAIN_NODE, /* Key-chain node. */ + KEYCHAIN_KEY_NODE, /* Key-chain key node. */ + NS_NODE, /* Logical-Router node. */ + VRF_NODE, /* VRF mode node. */ + INTERFACE_NODE, /* Interface mode node. */ + ZEBRA_NODE, /* zebra connection node. */ + TABLE_NODE, /* rtm_table selection node. */ + RIP_NODE, /* RIP protocol mode node. */ + RIPNG_NODE, /* RIPng protocol mode node. */ + BGP_NODE, /* BGP protocol mode which includes BGP4+ */ + BGP_VPNV4_NODE, /* BGP MPLS-VPN PE exchange. */ + BGP_VPNV6_NODE, /* BGP MPLS-VPN PE exchange. */ + BGP_IPV4_NODE, /* BGP IPv4 unicast address family. */ + BGP_IPV4M_NODE, /* BGP IPv4 multicast address family. */ + BGP_IPV6_NODE, /* BGP IPv6 address family */ + BGP_IPV6M_NODE, /* BGP IPv6 multicast address family. */ + BGP_ENCAP_NODE, /* BGP ENCAP SAFI */ + BGP_ENCAPV6_NODE, /* BGP ENCAP SAFI */ BGP_VNC_DEFAULTS_NODE, /* BGP VNC nve defaults */ BGP_VNC_NVE_GROUP_NODE, /* BGP VNC nve group */ BGP_VNC_L2_GROUP_NODE, /* BGP VNC L2 group */ RFP_DEFAULTS_NODE, /* RFP defaults node */ - OSPF_NODE, /* OSPF protocol mode */ - OSPF6_NODE, /* OSPF protocol for IPv6 mode */ + OSPF_NODE, /* OSPF protocol mode */ + OSPF6_NODE, /* OSPF protocol for IPv6 mode */ LDP_NODE, /* LDP protocol mode */ LDP_IPV4_NODE, /* LDP IPv4 address family */ LDP_IPV6_NODE, /* LDP IPv6 address family */ @@ -111,43 +112,46 @@ enum node_type LDP_IPV6_IFACE_NODE, /* LDP IPv6 Interface */ LDP_L2VPN_NODE, /* LDP L2VPN node */ LDP_PSEUDOWIRE_NODE, /* LDP Pseudowire node */ - ISIS_NODE, /* ISIS protocol mode */ - PIM_NODE, /* PIM protocol mode */ - MASC_NODE, /* MASC for multicast. */ - IRDP_NODE, /* ICMP Router Discovery Protocol mode. */ - IP_NODE, /* Static ip route node. */ - ACCESS_NODE, /* Access list node. */ - PREFIX_NODE, /* Prefix list node. */ - ACCESS_IPV6_NODE, /* Access list node. */ - PREFIX_IPV6_NODE, /* Prefix list node. */ - AS_LIST_NODE, /* AS list node. */ - COMMUNITY_LIST_NODE, /* Community list node. */ - RMAP_NODE, /* Route map node. */ - SMUX_NODE, /* SNMP configuration node. */ - DUMP_NODE, /* Packet dump node. */ - FORWARDING_NODE, /* IP forwarding node. */ + ISIS_NODE, /* ISIS protocol mode */ + PIM_NODE, /* PIM protocol mode */ + MASC_NODE, /* MASC for multicast. */ + IRDP_NODE, /* ICMP Router Discovery Protocol mode. */ + IP_NODE, /* Static ip route node. */ + ACCESS_NODE, /* Access list node. */ + PREFIX_NODE, /* Prefix list node. */ + ACCESS_IPV6_NODE, /* Access list node. */ + PREFIX_IPV6_NODE, /* Prefix list node. */ + AS_LIST_NODE, /* AS list node. */ + COMMUNITY_LIST_NODE, /* Community list node. */ + RMAP_NODE, /* Route map node. */ + SMUX_NODE, /* SNMP configuration node. */ + DUMP_NODE, /* Packet dump node. */ + FORWARDING_NODE, /* IP forwarding node. */ PROTOCOL_NODE, /* protocol filtering node */ MPLS_NODE, /* MPLS config node */ - VTY_NODE, /* Vty node. */ - LINK_PARAMS_NODE, /* Link-parameters node */ + VTY_NODE, /* Vty node. */ + LINK_PARAMS_NODE, /* Link-parameters node */ }; /* Node which has some commands and prompt string and configuration function pointer . */ -struct cmd_node +struct cmd_node { /* Node index. */ - enum node_type node; + enum node_type node; /* Prompt character at vty interface. */ - const char *prompt; + const char *prompt; /* Is this node's configuration goes to vtysh ? */ int vtysh; - + /* Node's configuration write function */ int (*func) (struct vty *); + /* Node's command graph */ + struct graph *cmdgraph; + /* Vector of this node's command list. */ vector cmd_vector; @@ -155,63 +159,59 @@ struct cmd_node struct hash *cmd_hash; }; -enum -{ - CMD_ATTR_DEPRECATED = 1, - CMD_ATTR_HIDDEN, -}; - -/* Structure of command element. */ -struct cmd_element -{ - const char *string; /* Command specification by string. */ - int (*func) (struct cmd_element *, struct vty *, int, const char *[]); - const char *doc; /* Documentation of this command. */ - int daemon; /* Daemon to which this command belong. */ - vector tokens; /* Vector of cmd_tokens */ - u_char attr; /* Command attributes */ -}; - - +/** + * Types for tokens. + * + * The type determines what kind of data the token can match (in the + * matching use case) or hold (in the argv use case). + */ enum cmd_token_type { - TOKEN_TERMINAL = 0, - TOKEN_MULTIPLE, - TOKEN_KEYWORD, + WORD_TKN, // words + VARIABLE_TKN, // almost anything + RANGE_TKN, // integer range + IPV4_TKN, // IPV4 addresses + IPV4_PREFIX_TKN, // IPV4 network prefixes + IPV6_TKN, // IPV6 prefixes + IPV6_PREFIX_TKN, // IPV6 network prefixes + + /* plumbing types */ + SELECTOR_TKN, // marks beginning of selector + OPTION_TKN, // marks beginning of option + NUL_TKN, // dummy token + START_TKN, // first token in line + END_TKN, // last token in line }; -enum cmd_terminal_type +/* Command attributes */ +enum { - _TERMINAL_BUG = 0, - TERMINAL_LITERAL, - TERMINAL_OPTION, - TERMINAL_VARIABLE, - TERMINAL_VARARG, - TERMINAL_RANGE, - TERMINAL_IPV4, - TERMINAL_IPV4_PREFIX, - TERMINAL_IPV6, - TERMINAL_IPV6_PREFIX, + CMD_ATTR_NORMAL, + CMD_ATTR_DEPRECATED, + CMD_ATTR_HIDDEN, }; -/* argument to be recorded on argv[] if it's not a literal */ -#define TERMINAL_RECORD(t) ((t) >= TERMINAL_OPTION) - -/* Command description structure. */ +/* Comamand token struct. */ struct cmd_token { - enum cmd_token_type type; - enum cmd_terminal_type terminal; - - /* Used for type == MULTIPLE */ - vector multiple; /* vector of cmd_token, type == FINAL */ + enum cmd_token_type type; // token type + u_char attr; // token attributes + char *text; // token text + char *desc; // token description + long long min, max; // for ranges + char *arg; // user input that matches this token +}; - /* Used for type == KEYWORD */ - vector keyword; /* vector of vector of cmd_tokens */ +/* Structure of command element. */ +struct cmd_element +{ + const char *string; /* Command specification by string. */ + const char *doc; /* Documentation of this command. */ + int daemon; /* Daemon to which this command belong. */ + u_char attr; /* Command attributes */ - /* Used for type == TERMINAL */ - char *cmd; /* Command string. */ - char *desc; /* Command's description. */ + /* handler function for command */ + int (*func) (const struct cmd_element *, struct vty *, int, struct cmd_token *[]); }; /* Return value of the commands. */ @@ -233,7 +233,7 @@ struct cmd_token #define CMD_ARGC_MAX 25 /* Turn off these macros when uisng cpp with extract.pl */ -#ifndef VTYSH_EXTRACT_PL +#ifndef VTYSH_EXTRACT_PL /* helper defines for end-user DEFUN* macros */ #define DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attrs, dnum) \ @@ -247,179 +247,15 @@ struct cmd_token }; #define DEFUN_CMD_FUNC_DECL(funcname) \ - static int funcname (struct cmd_element *, struct vty *, int, const char *[]); + static int funcname (const struct cmd_element *, struct vty *, int, struct cmd_token *[]); #define DEFUN_CMD_FUNC_TEXT(funcname) \ static int funcname \ - (struct cmd_element *self __attribute__ ((unused)), \ + (const struct cmd_element *self __attribute__ ((unused)), \ struct vty *vty __attribute__ ((unused)), \ int argc __attribute__ ((unused)), \ - const char *argv[] __attribute__ ((unused)) ) + struct cmd_token *argv[] __attribute__ ((unused)) ) -/* DEFUN for vty command interafce. Little bit hacky ;-). - * - * DEFUN(funcname, cmdname, cmdstr, helpstr) - * - * funcname - * ======== - * - * Name of the function that will be defined. - * - * cmdname - * ======= - * - * Name of the struct that will be defined for the command. - * - * cmdstr - * ====== - * - * The cmdstr defines the command syntax. It is used by the vty subsystem - * and vtysh to perform matching and completion in the cli. So you have to take - * care to construct it adhering to the following grammar. The names used - * for the production rules losely represent the names used in lib/command.c - * - * cmdstr = cmd_token , { " " , cmd_token } ; - * - * cmd_token = cmd_terminal - * | cmd_multiple - * | cmd_keyword ; - * - * cmd_terminal_fixed = fixed_string - * | variable - * | range - * | ipv4 - * | ipv4_prefix - * | ipv6 - * | ipv6_prefix ; - * - * cmd_terminal = cmd_terminal_fixed - * | option - * | vararg ; - * - * multiple_part = cmd_terminal_fixed ; - * cmd_multiple = "(" , multiple_part , ( "|" | { "|" , multiple_part } ) , ")" ; - * - * keyword_part = fixed_string , { " " , ( cmd_terminal_fixed | cmd_multiple ) } ; - * cmd_keyword = "{" , keyword_part , { "|" , keyword_part } , "}" ; - * - * lowercase = "a" | ... | "z" ; - * uppercase = "A" | ... | "Z" ; - * digit = "0" | ... | "9" ; - * number = digit , { digit } ; - * - * fixed_string = (lowercase | digit) , { lowercase | digit | uppercase | "-" | "_" } ; - * variable = uppercase , { uppercase | "_" } ; - * range = "<" , number , "-" , number , ">" ; - * ipv4 = "A.B.C.D" ; - * ipv4_prefix = "A.B.C.D/M" ; - * ipv6 = "X:X::X:X" ; - * ipv6_prefix = "X:X::X:X/M" ; - * option = "[" , variable , "]" ; - * vararg = "." , variable ; - * - * To put that all in a textual description: A cmdstr is a sequence of tokens, - * separated by spaces. - * - * Terminal Tokens: - * - * A very simple cmdstring would be something like: "show ip bgp". It consists - * of three Terminal Tokens, each containing a fixed string. When this command - * is called, no arguments will be passed down to the function implementing it, - * as it only consists of fixed strings. - * - * Apart from fixed strings, Terminal Tokens can also contain variables: - * An example would be "show ip bgp A.B.C.D". This command expects an IPv4 - * as argument. As this is a variable, the IP address entered by the user will - * be passed down as an argument. Apart from two exceptions, the other options - * for Terminal Tokens behave exactly as we just discussed and only make a - * difference for the CLI. The two exceptions will be discussed in the next - * paragraphs. - * - * A Terminal Token can contain a so called option match. This is a simple - * string variable that the user may omit. An example would be: - * "show interface [IFNAME]". If the user calls this without an interface as - * argument, no arguments will be passed down to the function implementing - * this command. Otherwise, the interface name will be provided to the function - * as a regular argument. - - * Also, a Terminal Token can contain a so called vararg. This is used e.g. in - * "show ip bgp regexp .LINE". The last token is a vararg match and will - * consume all the arguments the user inputs on the command line and append - * those to the list of arguments passed down to the function implementing this - * command. (Therefore, it doesn't make much sense to have any tokens after a - * vararg because the vararg will already consume all the words the user entered - * in the CLI) - * - * Multiple Tokens: - * - * The Multiple Token type can be used if there are multiple possibilities what - * arguments may be used for a command, but it should map to the same function - * nonetheless. An example would be "ip route A.B.C.D/M (reject|blackhole)" - * In that case both "reject" and "blackhole" would be acceptable as last - * arguments. The words matched by Multiple Tokens are always added to the - * argument list, even if they are matched by fixed strings. Such a Multiple - * Token can contain almost any type of token that would also be acceptable - * for a Terminal Token, the exception are optional variables and varag. - * - * There is one special case that is used in some places of Quagga that should be - * pointed out here shortly. An example would be "password (8|) WORD". This - * construct is used to have fixed strings communicated as arguments. (The "8" - * will be passed down as an argument in this case) It does not mean that - * the "8" is optional. Another historic and possibly surprising property of - * this construct is that it consumes two parts of helpstr. (Help - * strings will be explained later) - * - * Keyword Tokens: - * - * There are commands that take a lot of different and possibly optional arguments. - * An example from ospf would be the "default-information originate" command. This - * command takes a lot of optional arguments that may be provided in any order. - * To accomodate such commands, the Keyword Token has been implemented. - * Using the keyword token, the "default-information originate" command and all - * its possible options can be represented using this single cmdstr: - * "default-information originate \ - * {always|metric <0-16777214>|metric-type (1|2)|route-map WORD}" - * - * Keywords always start with a fixed string and may be followed by arguments. - * Except optional variables and vararg, everything is permitted here. - * - * For the special case of a keyword without arguments, either NULL or the - * keyword itself will be pushed as an argument, depending on whether the - * keyword is present. - * For the other keywords, arguments will be only pushed for - * variables/Multiple Tokens. If the keyword is not present, the arguments that - * would have been pushed will be substituted by NULL. - * - * A few examples: - * "default information originate metric-type 1 metric 1000" - * would yield the following arguments: - * { NULL, "1000", "1", NULL } - * - * "default information originate always route-map RMAP-DEFAULT" - * would yield the following arguments: - * { "always", NULL, NULL, "RMAP-DEFAULT" } - * - * helpstr - * ======= - * - * The helpstr is used to show a short explantion for the commands that - * are available when the user presses '?' on the CLI. It is the concatenation - * of the helpstrings for all the tokens that make up the command. - * - * There should be one helpstring for each token in the cmdstr except those - * containing other tokens, like Multiple or Keyword Tokens. For those, there - * will only be the helpstrings of the contained tokens. - * - * The individual helpstrings are expected to be in the same order as their - * respective Tokens appear in the cmdstr. They should each be terminated with - * a linefeed. The last helpstring should be terminated with a linefeed as well. - * - * Care should also be taken to avoid having similar tokens with different - * helpstrings. Imagine e.g. the commands "show ip ospf" and "show ip bgp". - * they both contain a helpstring for "show", but only one will be displayed - * when the user enters "sh?". If those two helpstrings differ, it is not - * defined which one will be shown and the behavior is therefore unpredictable. - */ #define DEFUN(funcname, cmdname, cmdstr, helpstr) \ DEFUN_CMD_FUNC_DECL(funcname) \ DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) \ @@ -499,7 +335,6 @@ struct cmd_token */ #define CMD_CREATE_STR(s) CMD_CREATE_STR_HELPER(s) #define CMD_CREATE_STR_HELPER(s) #s -#define CMD_RANGE_STR(a,s) "<" CMD_CREATE_STR(a) "-" CMD_CREATE_STR(s) ">" /* Common descriptions. */ #define SHOW_STR "Show running system information\n" @@ -531,17 +366,16 @@ struct cmd_token #define IFNAME_STR "Interface name(e.g. ep0)\n" #define IP6_STR "IPv6 Information\n" #define OSPF6_STR "Open Shortest Path First (OSPF) for IPv6\n" -#define OSPF6_ROUTER_STR "Enable a routing process\n" -#define OSPF6_INSTANCE_STR "<1-65535> Instance ID\n" -#define SECONDS_STR "<1-65535> Seconds\n" +#define OSPF6_INSTANCE_STR "(1-65535) Instance ID\n" +#define SECONDS_STR "(1-65535) Seconds\n" #define ROUTE_STR "Routing Table\n" #define PREFIX_LIST_STR "Build a prefix list\n" #define OSPF6_DUMP_TYPE_LIST \ -"(neighbor|interface|area|lsa|zebra|config|dbex|spf|route|lsdb|redistribute|hook|asbr|prefix|abr)" +"<neighbor|interface|area|lsa|zebra|config|dbex|spf|route|lsdb|redistribute|hook|asbr|prefix|abr>" #define ISIS_STR "IS-IS information\n" #define AREA_TAG_STR "[area tag]\n" -#define COMMUNITY_AANN_STR "Community number where AA and NN are <0-65535>\n" -#define COMMUNITY_VAL_STR "Community number in AA:NN format (where AA and NN are <0-65535>) or local-AS|no-advertise|no-export|internet or additive\n" +#define COMMUNITY_AANN_STR "Community number where AA and NN are (0-65535)\n" +#define COMMUNITY_VAL_STR "Community number in AA:NN format (where AA and NN are (0-65535)) or local-AS|no-advertise|no-export|internet or additive\n" #define MPLS_TE_STR "MPLS-TE specific commands\n" #define LINK_PARAMS_STR "Configure interface link parameters\n" #define OSPF_RI_STR "OSPF Router Information specific commands\n" @@ -553,31 +387,14 @@ struct cmd_token /* IPv4 only machine should not accept IPv6 address for peer's IP address. So we replace VTY command string like below. */ #ifdef HAVE_IPV6 -#define NEIGHBOR_CMD "neighbor (A.B.C.D|X:X::X:X) " -#define NO_NEIGHBOR_CMD "no neighbor (A.B.C.D|X:X::X:X) " #define NEIGHBOR_ADDR_STR "Neighbor address\nIPv6 address\n" -#define NEIGHBOR_CMD2 "neighbor (A.B.C.D|X:X::X:X|WORD) " -#define NO_NEIGHBOR_CMD2 "no neighbor (A.B.C.D|X:X::X:X|WORD) " #define NEIGHBOR_ADDR_STR2 "Neighbor address\nNeighbor IPv6 address\nInterface name or neighbor tag\n" #define NEIGHBOR_ADDR_STR3 "Neighbor address\nIPv6 address\nInterface name\n" #else -#define NEIGHBOR_CMD "neighbor A.B.C.D " -#define NO_NEIGHBOR_CMD "no neighbor A.B.C.D " #define NEIGHBOR_ADDR_STR "Neighbor address\n" -#define NEIGHBOR_CMD2 "neighbor (A.B.C.D|WORD) " -#define NO_NEIGHBOR_CMD2 "no neighbor (A.B.C.D|WORD) " #define NEIGHBOR_ADDR_STR2 "Neighbor address\nNeighbor tag\n" #endif /* HAVE_IPV6 */ -/* Dynamic neighbor (listen range) configuration */ -#ifdef HAVE_IPV6 -#define LISTEN_RANGE_CMD "bgp listen range (A.B.C.D/M|X:X::X:X/M) " -#define LISTEN_RANGE_ADDR_STR "Neighbor address\nNeighbor IPv6 address\n" -#else -#define LISTEN_RANGE_CMD "bgp listen range A.B.C.D/M " -#define LISTEN_RANGE_ADDR_STR "Neighbor address\n" -#endif /* HAVE_IPV6 */ - /* Prototypes. */ extern void install_node (struct cmd_node *, int (*) (struct vty *)); extern void install_default (enum node_type); @@ -586,22 +403,37 @@ extern void install_element (enum node_type, struct cmd_element *); /* Concatenates argv[shift] through argv[argc-1] into a single NUL-terminated string with a space between each element (allocated using XMALLOC(MTYPE_TMP)). Returns NULL if shift >= argc. */ -extern char *argv_concat (const char **argv, int argc, int shift); +extern char *argv_concat (struct cmd_token **argv, int argc, int shift); +extern int argv_find (struct cmd_token **argv, int argc, const char *text, int *index); extern vector cmd_make_strvec (const char *); extern void cmd_free_strvec (vector); +extern char *cmd_concat_strvec (vector); extern vector cmd_describe_command (vector, struct vty *, int *status); extern char **cmd_complete_command (vector, struct vty *, int *status); -extern char **cmd_complete_command_lib (vector, struct vty *, int *status, int islib); extern const char *cmd_prompt (enum node_type); -extern int command_config_read_one_line (struct vty *vty, struct cmd_element **, int use_config_node); +extern int command_config_read_one_line (struct vty *vty, const struct cmd_element **, int use_config_node); extern int config_from_file (struct vty *, FILE *, unsigned int *line_num); extern enum node_type node_parent (enum node_type); -extern int cmd_execute_command (vector, struct vty *, struct cmd_element **, int); -extern int cmd_execute_command_strict (vector, struct vty *, struct cmd_element **); +extern int cmd_execute_command (vector, struct vty *, const struct cmd_element **, int); +extern int cmd_execute_command_strict (vector, struct vty *, const struct cmd_element **); extern void cmd_init (int); extern void cmd_terminate (void); +/* memory management for cmd_element */ +void +del_cmd_element(struct cmd_element *); +struct cmd_element * +copy_cmd_element(const struct cmd_element *cmd); + +/* memory management for cmd_token */ +struct cmd_token * +new_cmd_token (enum cmd_token_type, u_char attr, char *, char *); +void +del_cmd_token (struct cmd_token *); +struct cmd_token * +copy_cmd_token (struct cmd_token *); + /* Export typical functions. */ extern struct cmd_element config_end_cmd; extern struct cmd_element config_exit_cmd; @@ -616,8 +448,9 @@ extern void print_version (const char *); extern int cmd_banner_motd_file (const char *); /* struct host global, ick */ -extern struct host host; +extern struct host host; + +/* text for <cr> command */ +#define CMD_CR_TEXT "<cr>" -/* "<cr>" global */ -extern char *command_cr; #endif /* _ZEBRA_COMMAND_H */ diff --git a/lib/command_lex.l b/lib/command_lex.l new file mode 100644 index 0000000000..5c709dce22 --- /dev/null +++ b/lib/command_lex.l @@ -0,0 +1,71 @@ +/* + * Command format string lexer for CLI backend. + * + * -- + * Copyright (C) 2015 Cumulus Networks, Inc. + * + * This file is part of GNU Zebra. + * + * GNU Zebra is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * GNU Zebra is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Zebra; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +%{ +#include "command_parse.h" + +extern void set_lexer_string (const char *); +extern void cleanup_lexer (void); +YY_BUFFER_STATE buffer; +%} + +WORD (\-|\+)?[a-z\*][-+_a-zA-Z0-9\*]* +IPV4 A\.B\.C\.D +IPV4_PREFIX A\.B\.C\.D\/M +IPV6 X:X::X:X +IPV6_PREFIX X:X::X:X\/M +VARIABLE [A-Z][-_a-zA-Z:0-9]+ +NUMBER (\-|\+)?[0-9]{1,20} +RANGE \({NUMBER}[ ]?\-[ ]?{NUMBER}\) + +/* yytext shall be a pointer */ +%pointer +%option noyywrap +%option nounput +%option noinput +%option outfile="command_lex.c" + +%% +[ /t] /* ignore whitespace */; +{WORD} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return WORD;} +{IPV4} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return IPV4;} +{IPV4_PREFIX} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return IPV4_PREFIX;} +{IPV6} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return IPV6;} +{IPV6_PREFIX} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return IPV6_PREFIX;} +{VARIABLE} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return VARIABLE;} +{RANGE} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return RANGE;} +. {return yytext[0];} +%% + +void +set_lexer_string (const char *string) +{ + buffer = yy_scan_string (string); +} + +void +cleanup_lexer () +{ + yy_delete_buffer (buffer); +} diff --git a/lib/command_match.c b/lib/command_match.c new file mode 100644 index 0000000000..82090be732 --- /dev/null +++ b/lib/command_match.c @@ -0,0 +1,862 @@ +/* + * Input matching routines for CLI backend. + * + * -- + * Copyright (C) 2016 Cumulus Networks, Inc. + * + * This file is part of GNU Zebra. + * + * GNU Zebra is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * GNU Zebra is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Zebra; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include <zebra.h> + +#include "command_match.h" +#include "command_parse.h" +#include "memory.h" + +DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command Tokens") + +/* matcher helper prototypes */ +static int +add_nexthops (struct list *, struct graph_node *); + +static struct list * +command_match_r (struct graph_node *, vector, unsigned int); + +static int +score_precedence (enum cmd_token_type); + +static enum match_type +min_match_level (enum cmd_token_type); + +static void +del_arglist (struct list *); + +static struct cmd_token * +disambiguate_tokens (struct cmd_token *, struct cmd_token *, char *); + +static struct list * +disambiguate (struct list *, struct list *, vector, unsigned int); + +int +compare_completions (const void *, const void *); + +/* token matcher prototypes */ +static enum match_type +match_token (struct cmd_token *, char *); + +static enum match_type +match_ipv4 (const char *); + +static enum match_type +match_ipv4_prefix (const char *); + +static enum match_type +match_ipv6 (const char *); + +static enum match_type +match_ipv6_prefix (const char *); + +static enum match_type +match_range (struct cmd_token *, const char *); + +static enum match_type +match_word (struct cmd_token *, const char *); + +static enum match_type +match_variable (struct cmd_token *, const char *); + +/* matching functions */ +static enum matcher_rv matcher_rv; + +enum matcher_rv +command_match (struct graph *cmdgraph, + vector vline, + struct list **argv, + const struct cmd_element **el) +{ + matcher_rv = MATCHER_NO_MATCH; + + // prepend a dummy token to match that pesky start node + vector vvline = vector_init (vline->alloced + 1); + vector_set_index (vvline, 0, (void *) XSTRDUP (MTYPE_TMP, "dummy")); + memcpy (vvline->index + 1, vline->index, sizeof (void *) * vline->alloced); + vvline->active = vline->active + 1; + + struct graph_node *start = vector_slot (cmdgraph->nodes, 0); + if ((*argv = command_match_r (start, vvline, 0))) // successful match + { + struct listnode *head = listhead (*argv); + struct listnode *tail = listtail (*argv); + + // delete dummy start node + del_cmd_token ((struct cmd_token *) head->data); + list_delete_node (*argv, head); + + // get cmd_element out of list tail + *el = listgetdata (tail); + list_delete_node (*argv, tail); + + // now argv is an ordered list of cmd_token matching the user + // input, with each cmd_token->arg holding the corresponding input + assert (*el); + } + +#ifdef TRACE_MATCHER + if (!*el) + fprintf (stdout, "No match\n"); + else + fprintf (stdout, "Matched command\n->string %s\n->desc %s\n", (*el)->string, (*el)->doc); +#endif + + // free the leader token we alloc'd + XFREE (MTYPE_TMP, vector_slot (vvline, 0)); + // free vector + vector_free (vvline); + + return matcher_rv; +} + +/** + * Builds an argument list given a DFA and a matching input line. + * + * First the function determines if the node it is passed matches the first + * token of input. If it does not, it returns NULL (MATCHER_NO_MATCH). If it + * does match, then it saves the input token as the head of an argument list. + * + * The next step is to see if there is further input in the input line. If + * there is not, the current node's children are searched to see if any of them + * are leaves (type END_TKN). If this is the case, then the bottom of the + * recursion stack has been reached, the leaf is pushed onto the argument list, + * the current node is pushed, and the resulting argument list is + * returned (MATCHER_OK). If it is not the case, NULL is returned, indicating + * that there is no match for the input along this path (MATCHER_INCOMPLETE). + * + * If there is further input, then the function recurses on each of the current + * node's children, passing them the input line minus the token that was just + * matched. For each child, the return value of the recursive call is + * inspected. If it is null, then there is no match for the input along the + * subgraph headed by that child. If it is not null, then there is at least one + * input match in that subgraph (more on this in a moment). + * + * If a recursive call on a child returns a non-null value, then it has matched + * the input given it on the subgraph that starts with that child. However, due + * to the flexibility of the grammar, it is sometimes the case that two or more + * child graphs match the same input (two or more of the recursive calls have + * non-NULL return values). This is not a valid state, since only one true + * match is possible. In order to resolve this conflict, the function keeps a + * reference to the child node that most specifically matches the input. This + * is done by assigning each node type a precedence. If a child is found to + * match the remaining input, then the precedence values of the current + * best-matching child and this new match are compared. The node with higher + * precedence is kept, and the other match is discarded. Due to the recursive + * nature of this function, it is only necessary to compare the precedence of + * immediate children, since all subsequent children will already have been + * disambiguated in this way. + * + * In the event that two children are found to match with the same precedence, + * then the input is ambiguous for the passed cmd_element and NULL is returned. + * + * @param[in] start the start node. + * @param[in] vline the vectorized input line. + * @param[in] n the index of the first input token. + * @return A linked list of n elements. The first n-1 elements are pointers to + * struct cmd_token and represent the sequence of tokens matched by the input. + * The ->arg field of each token points to a copy of the input matched on it. + * The final nth element is a pointer to struct cmd_element, which is the + * command that was matched. + * + * If no match was found, the return value is NULL. + */ +static struct list * +command_match_r (struct graph_node *start, vector vline, unsigned int n) +{ + assert (n < vector_active (vline)); + + // get the minimum match level that can count as a full match + struct cmd_token *token = start->data; + enum match_type minmatch = min_match_level (token->type); + + // get the current operating input token + char *input_token = vector_slot (vline, n); + +#ifdef TRACE_MATCHER + fprintf (stdout, "\"%-20s\" matches \"%-30s\" ? ", input_token, token->text); + enum match_type mt = match_token (token, input_token); + fprintf (stdout, "min: %d - ", minmatch); + switch (mt) + { + case trivial_match: + fprintf (stdout, "trivial_match "); + break; + case no_match: + fprintf (stdout, "no_match "); + break; + case partly_match: + fprintf (stdout, "partly_match "); + break; + case exact_match: + fprintf (stdout, "exact_match "); + break; + } + if (mt >= minmatch) fprintf (stdout, " MATCH"); + fprintf (stdout, "\n"); +#endif + + // if we don't match this node, die + if (match_token (token, input_token) < minmatch) + return NULL; + + // pointers for iterating linklist + struct listnode *ln; + struct graph_node *gn; + + // get all possible nexthops + struct list *next = list_new(); + add_nexthops (next, start); + + // determine the best match + int ambiguous = 0; + struct list *currbest = NULL; + for (ALL_LIST_ELEMENTS_RO (next,ln,gn)) + { + // if we've matched all input we're looking for END_TKN + if (n+1 == vector_active (vline)) + { + struct cmd_token *tok = gn->data; + if (tok->type == END_TKN) + { + currbest = list_new(); + // node should have one child node with the element + struct graph_node *leaf = vector_slot (gn->to, 0); + // last node in the list will hold the cmd_element; + // this is important because list_delete() expects + // that all nodes have the same data type, so when + // deleting this list the last node must be + // manually deleted + struct cmd_element *el = leaf->data; + listnode_add (currbest, el); + currbest->del = (void (*)(void *)) &del_cmd_token; + break; + } + else continue; + } + + // else recurse on candidate child node + struct list *result = command_match_r (gn, vline, n+1); + + // save the best match + if (result && currbest) + { + // pick the best of two matches + struct list *newbest = disambiguate (currbest, result, vline, n+1); + // set ambiguity flag + ambiguous = !newbest || (ambiguous && newbest == currbest); + // delete the unnecessary result + struct list *todelete = ((newbest && newbest == result) ? currbest : result); + del_arglist (todelete); + + currbest = newbest ? newbest : currbest; + } + else if (result) + currbest = result; + } + + if (currbest) + { + if (ambiguous) + { + del_arglist (currbest); + currbest = NULL; + matcher_rv = MATCHER_AMBIGUOUS; + } + else + { + // copy token, set arg and prepend to currbest + struct cmd_token *token = start->data; + struct cmd_token *copy = copy_cmd_token (token); + copy->arg = XSTRDUP (MTYPE_CMD_TOKENS, input_token); + listnode_add_before (currbest, currbest->head, copy); + matcher_rv = MATCHER_OK; + } + } + else if (n+1 == vector_active (vline) && matcher_rv == MATCHER_NO_MATCH) + matcher_rv = MATCHER_INCOMPLETE; + + // cleanup + list_delete (next); + + return currbest; +} + +enum matcher_rv +command_complete (struct graph *graph, + vector vline, + struct list **completions) +{ + // pointer to next input token to match + char *input_token; + + struct list *current = list_new(), // current nodes to match input token against + *next = list_new(); // possible next hops after current input token + + // pointers used for iterating lists + struct graph_node *gn; + struct listnode *node; + + // add all children of start node to list + struct graph_node *start = vector_slot (graph->nodes, 0); + add_nexthops (next, start); + + unsigned int idx; + for (idx = 0; idx < vector_active (vline) && next->count > 0; idx++) + { + list_delete (current); + current = next; + next = list_new(); + + input_token = vector_slot (vline, idx); + + for (ALL_LIST_ELEMENTS_RO (current,node,gn)) + { + struct cmd_token *token = gn->data; + + if (token->attr == CMD_ATTR_HIDDEN || token->attr == CMD_ATTR_DEPRECATED) + continue; + + enum match_type minmatch = min_match_level (token->type); +#ifdef TRACE_MATCHER + fprintf (stdout, "\"%s\" matches \"%s\" (%d) ? ", input_token, token->text, token->type); +#endif + + switch (match_token (token, input_token)) + { + case trivial_match: +#ifdef TRACE_MATCHER + fprintf (stdout, "trivial_match\n"); +#endif + case partly_match: +#ifdef TRACE_MATCHER + fprintf (stdout, "partly_match\n"); +#endif + if (idx == vector_active (vline) - 1) + { + listnode_add (next, gn); + break; + } + if (minmatch > partly_match) + break; + case exact_match: +#ifdef TRACE_MATCHER + fprintf (stdout, "exact_match\n"); +#endif + add_nexthops (next, gn); + break; + default: +#ifdef TRACE_MATCHER + fprintf (stdout, "no_match\n"); +#endif + break; + } + } + } + + /* Variable summary + * ----------------------------------------------------------------- + * token = last input token processed + * idx = index in `command` of last token processed + * current = set of all transitions from the previous input token + * next = set of all nodes reachable from all nodes in `matched` + */ + + matcher_rv = + idx == vector_active(vline) && next->count ? + MATCHER_OK : + MATCHER_NO_MATCH; + + *completions = NULL; + if (!MATCHER_ERROR(matcher_rv)) + { + // extract cmd_token into list + *completions = list_new (); + for (ALL_LIST_ELEMENTS_RO (next,node,gn)) + listnode_add (*completions, gn->data); + } + + list_delete (current); + list_delete (next); + + return matcher_rv; +} + +/** + * Adds all children that are reachable by one parser hop to the given list. + * NUL_TKN, SELECTOR_TKN, and OPTION_TKN nodes are treated as transparent. + * + * @param[in] list to add the nexthops to + * @param[in] node to start calculating nexthops from + * @return the number of children added to the list + */ +static int +add_nexthops (struct list *list, struct graph_node *node) +{ + int added = 0; + struct graph_node *child; + for (unsigned int i = 0; i < vector_active (node->to); i++) + { + child = vector_slot (node->to, i); + struct cmd_token *token = child->data; + switch (token->type) + { + case OPTION_TKN: + case SELECTOR_TKN: + case NUL_TKN: + added += add_nexthops (list, child); + break; + default: + listnode_add (list, child); + added++; + } + } + + return added; +} + +/** + * Determines the node types for which a partial match may count as a full + * match. Enables command abbrevations. + * + * @param[in] type node type + * @return minimum match level needed to for a token to fully match + */ +static enum match_type +min_match_level (enum cmd_token_type type) +{ + switch (type) + { + // anything matches a start node, for the sake of recursion + case START_TKN: + return no_match; + // allowing words to partly match enables command abbreviation + case WORD_TKN: + return partly_match; + default: + return exact_match; + } +} + +/** + * Assigns precedence scores to node types. + * + * @param[in] type node type to score + * @return precedence score + */ +static int +score_precedence (enum cmd_token_type type) +{ + switch (type) + { + // some of these are mutually exclusive, so they share + // the same precedence value + case IPV4_TKN: + case IPV4_PREFIX_TKN: + case IPV6_TKN: + case IPV6_PREFIX_TKN: + case RANGE_TKN: + return 2; + case WORD_TKN: + return 3; + case VARIABLE_TKN: + return 4; + default: + return 10; + } +} + +/** + * Picks the better of two possible matches for a token. + * + * @param[in] first candidate node matching token + * @param[in] second candidate node matching token + * @param[in] token the token being matched + * @return the best-matching node, or NULL if the two are entirely ambiguous + */ +static struct cmd_token * +disambiguate_tokens (struct cmd_token *first, + struct cmd_token *second, + char *input_token) +{ + // if the types are different, simply go off of type precedence + if (first->type != second->type) + { + int firstprec = score_precedence (first->type); + int secndprec = score_precedence (second->type); + if (firstprec != secndprec) + return firstprec < secndprec ? first : second; + else + return NULL; + } + + // if they're the same, return the more exact match + enum match_type fmtype = match_token (first, input_token); + enum match_type smtype = match_token (second, input_token); + if (fmtype != smtype) + return fmtype > smtype ? first : second; + + return NULL; +} + +/** + * Picks the better of two possible matches for an input line. + * + * @param[in] first candidate list of cmd_token matching vline + * @param[in] second candidate list of cmd_token matching vline + * @param[in] vline the input line being matched + * @param[in] n index into vline to start comparing at + * @return the best-matching list, or NULL if the two are entirely ambiguous + */ +static struct list * +disambiguate (struct list *first, + struct list *second, + vector vline, + unsigned int n) +{ + // doesn't make sense for these to be inequal length + assert (first->count == second->count); + assert (first->count == vector_active (vline) - n+1); + + struct listnode *fnode = listhead (first), + *snode = listhead (second); + struct cmd_token *ftok = listgetdata (fnode), + *stok = listgetdata (snode), + *best = NULL; + + // compare each token, if one matches better use that one + for (unsigned int i = n; i < vector_active (vline); i++) + { + char *token = vector_slot(vline, i); + if ((best = disambiguate_tokens (ftok, stok, token))) + return best == ftok ? first : second; + fnode = listnextnode (fnode); + snode = listnextnode (snode); + ftok = listgetdata (fnode); + stok = listgetdata (snode); + } + + return NULL; +} + +/* + * Deletion function for arglist. + * + * Since list->del for arglists expects all listnode->data to hold cmd_token, + * but arglists have cmd_element as the data for the tail, this function + * manually deletes the tail before deleting the rest of the list as usual. + * + * The cmd_element at the end is *not* a copy. It is the one and only. + * + * @param list the arglist to delete + */ +static void +del_arglist (struct list *list) +{ + // manually delete last node + struct listnode *tail = listtail (list); + tail->data = NULL; + list_delete_node (list, tail); + + // delete the rest of the list as usual + list_delete (list); +} + +/*---------- token level matching functions ----------*/ + +static enum match_type +match_token (struct cmd_token *token, char *input_token) +{ + // nothing trivially matches everything + if (!input_token) + return trivial_match; + + switch (token->type) { + case WORD_TKN: + return match_word (token, input_token); + case IPV4_TKN: + return match_ipv4 (input_token); + case IPV4_PREFIX_TKN: + return match_ipv4_prefix (input_token); + case IPV6_TKN: + return match_ipv6 (input_token); + case IPV6_PREFIX_TKN: + return match_ipv6_prefix (input_token); + case RANGE_TKN: + return match_range (token, input_token); + case VARIABLE_TKN: + return match_variable (token, input_token); + case END_TKN: + default: + return no_match; + } +} + +#define IPV4_ADDR_STR "0123456789." +#define IPV4_PREFIX_STR "0123456789./" + +static enum match_type +match_ipv4 (const char *str) +{ + const char *sp; + int dots = 0, nums = 0; + char buf[4]; + + for (;;) + { + memset (buf, 0, sizeof (buf)); + sp = str; + while (*str != '\0') + { + if (*str == '.') + { + if (dots >= 3) + return no_match; + + if (*(str + 1) == '.') + return no_match; + + if (*(str + 1) == '\0') + return partly_match; + + dots++; + break; + } + if (!isdigit ((int) *str)) + return no_match; + + str++; + } + + if (str - sp > 3) + return no_match; + + strncpy (buf, sp, str - sp); + if (atoi (buf) > 255) + return no_match; + + nums++; + + if (*str == '\0') + break; + + str++; + } + + if (nums < 4) + return partly_match; + + return exact_match; +} + +static enum match_type +match_ipv4_prefix (const char *str) +{ + const char *sp; + int dots = 0; + char buf[4]; + + for (;;) + { + memset (buf, 0, sizeof (buf)); + sp = str; + while (*str != '\0' && *str != '/') + { + if (*str == '.') + { + if (dots == 3) + return no_match; + + if (*(str + 1) == '.' || *(str + 1) == '/') + return no_match; + + if (*(str + 1) == '\0') + return partly_match; + + dots++; + break; + } + + if (!isdigit ((int) *str)) + return no_match; + + str++; + } + + if (str - sp > 3) + return no_match; + + strncpy (buf, sp, str - sp); + if (atoi (buf) > 255) + return no_match; + + if (dots == 3) + { + if (*str == '/') + { + if (*(str + 1) == '\0') + return partly_match; + + str++; + break; + } + else if (*str == '\0') + return partly_match; + } + + if (*str == '\0') + return partly_match; + + str++; + } + + sp = str; + while (*str != '\0') + { + if (!isdigit ((int) *str)) + return no_match; + + str++; + } + + if (atoi (sp) > 32) + return no_match; + + return exact_match; +} + +#ifdef HAVE_IPV6 +#define IPV6_ADDR_STR "0123456789abcdefABCDEF:." +#define IPV6_PREFIX_STR "0123456789abcdefABCDEF:./" + +static enum match_type +match_ipv6 (const char *str) +{ + struct sockaddr_in6 sin6_dummy; + int ret; + + if (strspn (str, IPV6_ADDR_STR) != strlen (str)) + return no_match; + + ret = inet_pton(AF_INET6, str, &sin6_dummy.sin6_addr); + + if (ret == 1) + return exact_match; + + return no_match; +} + +static enum match_type +match_ipv6_prefix (const char *str) +{ + struct sockaddr_in6 sin6_dummy; + const char *delim = "/\0"; + char *tofree, *dupe, *prefix, *mask, *endptr; + int nmask = -1; + + if (strspn (str, IPV6_PREFIX_STR) != strlen (str)) + return no_match; + + /* tokenize to prefix + mask */ + tofree = dupe = XSTRDUP (MTYPE_TMP, str); + prefix = strsep (&dupe, delim); + mask = dupe; + + /* validate prefix */ + if (inet_pton (AF_INET6, prefix, &sin6_dummy.sin6_addr) != 1) + { + XFREE (MTYPE_TMP, tofree); + return no_match; + } + + /* validate mask */ + if (!mask) + { + XFREE (MTYPE_TMP, tofree); + return partly_match; + } + + nmask = strtoimax (mask, &endptr, 10); + if (*endptr != '\0' || nmask < 0 || nmask > 128) + { + XFREE (MTYPE_TMP, tofree); + return no_match; + } + + XFREE (MTYPE_TMP, tofree); + return exact_match; +} +#endif + +static enum match_type +match_range (struct cmd_token *token, const char *str) +{ + assert (token->type == RANGE_TKN); + + char *endptr = NULL; + long long val; + + val = strtoll (str, &endptr, 10); + if (*endptr != '\0') + return no_match; + + if (val < token->min || val > token->max) + return no_match; + else + return exact_match; +} + +static enum match_type +match_word (struct cmd_token *token, const char *word) +{ + assert (token->type == WORD_TKN); + + // if the passed token is 0 length, partly match + if (!strlen(word)) + return partly_match; + + // if the passed token is strictly a prefix of the full word, partly match + if (strlen (word) < strlen (token->text)) + return !strncmp (token->text, word, strlen (word)) ? + partly_match : + no_match; + + // if they are the same length and exactly equal, exact match + else if (strlen (word) == strlen (token->text)) + return !strncmp (token->text, word, strlen (word)) ? exact_match : no_match; + + return no_match; +} + +#define VARIABLE_ALPHABET \ +"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890:/._-" + +static enum match_type +match_variable (struct cmd_token *token, const char *word) +{ + assert (token->type == VARIABLE_TKN); + + return strlen (word) == strspn(word, VARIABLE_ALPHABET) ? + exact_match : no_match; +} diff --git a/lib/command_match.h b/lib/command_match.h new file mode 100644 index 0000000000..9e18b8d905 --- /dev/null +++ b/lib/command_match.h @@ -0,0 +1,113 @@ +/* + * Input matching routines for CLI backend. + * + * -- + * Copyright (C) 2016 Cumulus Networks, Inc. + * + * This file is part of GNU Zebra. + * + * GNU Zebra is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * GNU Zebra is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Zebra; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef _ZEBRA_COMMAND_MATCH_H +#define _ZEBRA_COMMAND_MATCH_H + +#include "graph.h" +#include "linklist.h" +#include "command.h" + +/* These definitions exist in command.c in the current engine but should be + * relocated here in the new engine + */ +enum filter_type +{ + FILTER_RELAXED, + FILTER_STRICT +}; + +/* matcher result value */ +enum matcher_rv +{ + MATCHER_NO_MATCH, + MATCHER_INCOMPLETE, + MATCHER_AMBIGUOUS, + MATCHER_OK, +}; + +/* completion match types */ +enum match_type +{ + trivial_match, // the input is null + no_match, // the input does not match + partly_match, // the input matches but is incomplete + exact_match // the input matches and is complete +}; + +/* Defines which matcher_rv values constitute an error. Should be used with + * matcher_rv return values to do basic error checking. + */ +#define MATCHER_ERROR(matcher_rv) \ + ( (matcher_rv) == MATCHER_INCOMPLETE \ + || (matcher_rv) == MATCHER_NO_MATCH \ + || (matcher_rv) == MATCHER_AMBIGUOUS \ + ) + +/** + * Attempt to find an exact command match for a line of user input. + * + * @param[in] cmdgraph command graph to match against + * @param[in] vline vectorized input string + * @param[out] argv pointer to argument list if successful match, NULL + * otherwise. The elements of this list are pointers to struct cmd_token + * and represent the sequence of tokens matched by the inpu. The ->arg + * field of each token points to a copy of the input matched on it. These + * may be safely deleted or modified. + * @param[out] element pointer to matched cmd_element if successful match, + * or NULL when MATCHER_ERROR(rv) is true. The cmd_element may *not* be + * safely deleted or modified; it is the instance initialized on startup. + * @return matcher status + */ +enum matcher_rv +command_match (struct graph *cmdgraph, + vector vline, + struct list **argv, + const struct cmd_element **element); + +/** + * Compiles possible completions for a given line of user input. + * + * @param[in] start the start node of the DFA to match against + * @param[in] vline vectorized input string + * @param[out] completions pointer to list of cmd_token representing + * acceptable next inputs, or NULL when MATCHER_ERROR(rv) is true. + * The elements of this list are pointers to struct cmd_token and take on a + * variety of forms depending on the passed vline. If the last element in vline + * is NULL, all previous elements are considered to be complete words (the case + * when a space is the last token of the line) and completions are generated + * based on what could follow that input. If the last element in vline is not + * NULL and each sequential element matches the corresponding tokens of one or + * more commands exactly (e.g. 'encapv4' and not 'en') the same result is + * generated. If the last element is not NULL and the best possible match is a + * partial match, then the result generated will be all possible continuations + * of that element (e.g. 'encapv4', 'encapv6', etc for input 'en'). + * @return matcher status + */ +enum matcher_rv +command_complete (struct graph *cmdgraph, + vector vline, + struct list **completions); + +#endif /* _ZEBRA_COMMAND_MATCH_H */ diff --git a/lib/command_parse.y b/lib/command_parse.y new file mode 100644 index 0000000000..6348643b8b --- /dev/null +++ b/lib/command_parse.y @@ -0,0 +1,573 @@ +/* + * Command format string parser for CLI backend. + * + * -- + * Copyright (C) 2016 Cumulus Networks, Inc. + * + * This file is part of GNU Zebra. + * + * GNU Zebra is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * GNU Zebra is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Zebra; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +%{ +// compile with debugging facilities +#define YYDEBUG 1 +%} + +/* names for generated header and parser files */ +%defines "command_parse.h" +%output "command_parse.c" + +/* required external units */ +%code requires { + #include "stdlib.h" + #include "string.h" + #include "command.h" + #include "log.h" + #include "graph.h" + + extern int + yylex (void); + + extern void + set_lexer_string (const char *); + + extern void + cleanup_lexer (void); +} + +/* functionality this unit exports */ +%code provides { + void + command_parse_format (struct graph *, struct cmd_element *); + + /* maximum length of a number, lexer will not match anything longer */ + #define DECIMAL_STRLEN_MAX 20 +} + +/* valid semantic types for tokens and rules */ +%union { + long long number; + char *string; + struct graph_node *node; + struct subgraph *subgraph; +} + +/* union types for lexed tokens */ +%token <string> WORD +%token <string> IPV4 +%token <string> IPV4_PREFIX +%token <string> IPV6 +%token <string> IPV6_PREFIX +%token <string> VARIABLE +%token <string> RANGE + +/* union types for parsed rules */ +%type <node> start +%type <node> sentence_root +%type <node> literal_token +%type <node> placeholder_token +%type <node> simple_token +%type <subgraph> option +%type <subgraph> option_token +%type <subgraph> option_token_seq +%type <subgraph> selector +%type <subgraph> selector_token +%type <subgraph> selector_token_seq +%type <subgraph> selector_seq_seq +%type <subgraph> compound_token + +%code { + /* bison declarations */ + void + yyerror (struct graph *, struct cmd_element *el, char const *msg); + + /* subgraph semantic value */ + struct subgraph { + struct graph_node *start, *end; + }; + + struct graph_node *currnode, *startnode; + + /* pointers to copy of command docstring */ + char *docstr_start, *docstr; + + /* helper functions for parser */ + static char * + doc_next (struct cmd_element *); + + static struct graph_node * + node_adjacent (struct graph_node *, struct graph_node *); + + static struct graph_node * + add_edge_dedup (struct graph_node *, struct graph_node *); + + static int + cmp_token (struct cmd_token *, struct cmd_token *); + + static struct graph_node * + new_token_node (struct graph *, + enum cmd_token_type type, + u_char attr, char *text, + char *doc); + + static void + terminate_graph (struct graph *, + struct graph_node *, + struct cmd_element *); + + static void + cleanup (void); +} + +/* yyparse parameters */ +%parse-param { struct graph *graph } +%parse-param { struct cmd_element *el } + +/* called automatically before yyparse */ +%initial-action { + /* clear state pointers */ + currnode = startnode = NULL; + + startnode = vector_slot (graph->nodes, 0); + + /* set string to parse */ + set_lexer_string (el->string); + + /* copy docstring and keep a pointer to the copy */ + if (el->doc) + { + // allocate a new buffer, making room for a flag + size_t length = (size_t) strlen (el->doc) + 2; + docstr = malloc (length); + memcpy (docstr, el->doc, strlen (el->doc)); + // set the flag so doc_next knows when to print a warning + docstr[length - 2] = 0x03; + // null terminate + docstr[length - 1] = 0x00; + } + docstr_start = docstr; +} + +%% + +start: + sentence_root cmd_token_seq +{ + // tack on the command element + terminate_graph (graph, currnode, el); +} +| sentence_root cmd_token_seq placeholder_token '.' '.' '.' +{ + if ((currnode = add_edge_dedup (currnode, $3)) != $3) + graph_delete_node (graph, $3); + + // adding a node as a child of itself accepts any number + // of the same token, which is what we want for variadics + add_edge_dedup (currnode, currnode); + + // tack on the command element + terminate_graph (graph, currnode, el); +} +; + +sentence_root: WORD +{ + struct graph_node *root = + new_token_node (graph, WORD_TKN, el->attr, strdup ($1), doc_next(el)); + + if ((currnode = add_edge_dedup (startnode, root)) != root) + graph_delete_node (graph, root); + + free ($1); + $$ = currnode; +} +; + +cmd_token_seq: + %empty +| cmd_token_seq cmd_token +; + +cmd_token: + simple_token +{ + if ((currnode = add_edge_dedup (currnode, $1)) != $1) + graph_delete_node (graph, $1); +} +| compound_token +{ + graph_add_edge (currnode, $1->start); + currnode = $1->end; + free ($1); +} +; + +simple_token: + literal_token +| placeholder_token +; + +compound_token: + selector +| option +; + +literal_token: WORD +{ + $$ = new_token_node (graph, WORD_TKN, el->attr, strdup($1), doc_next(el)); + free ($1); +} +; + +placeholder_token: + IPV4 +{ + $$ = new_token_node (graph, IPV4_TKN, el->attr, strdup($1), doc_next(el)); + free ($1); +} +| IPV4_PREFIX +{ + $$ = new_token_node (graph, IPV4_PREFIX_TKN, el->attr, strdup($1), doc_next(el)); + free ($1); +} +| IPV6 +{ + $$ = new_token_node (graph, IPV6_TKN, el->attr, strdup($1), doc_next(el)); + free ($1); +} +| IPV6_PREFIX +{ + $$ = new_token_node (graph, IPV6_PREFIX_TKN, el->attr, strdup($1), doc_next(el)); + free ($1); +} +| VARIABLE +{ + $$ = new_token_node (graph, VARIABLE_TKN, el->attr, strdup($1), doc_next(el)); + free ($1); +} +| RANGE +{ + $$ = new_token_node (graph, RANGE_TKN, el->attr, strdup($1), doc_next(el)); + struct cmd_token *token = $$->data; + + // get the numbers out + yylval.string++; + token->min = strtoll (yylval.string, &yylval.string, 10); + strsep (&yylval.string, "-"); + token->max = strtoll (yylval.string, &yylval.string, 10); + + // validate range + if (token->min > token->max) yyerror (graph, el, "Invalid range."); + + free ($1); +} + +/* <selector|set> productions */ +selector: '<' selector_seq_seq '>' +{ + $$ = malloc (sizeof (struct subgraph)); + $$->start = new_token_node (graph, SELECTOR_TKN, el->attr, NULL, NULL); + $$->end = new_token_node (graph, NUL_TKN, el->attr, NULL, NULL); + for (unsigned int i = 0; i < vector_active ($2->start->to); i++) + { + struct graph_node *sn = vector_slot ($2->start->to, i), + *en = vector_slot ($2->end->from, i); + graph_add_edge ($$->start, sn); + graph_add_edge (en, $$->end); + } + graph_delete_node (graph, $2->start); + graph_delete_node (graph, $2->end); + free ($2); +}; + +selector_seq_seq: + selector_seq_seq '|' selector_token_seq +{ + $$ = malloc (sizeof (struct subgraph)); + $$->start = graph_new_node (graph, NULL, NULL); + $$->end = graph_new_node (graph, NULL, NULL); + + // link in last sequence + graph_add_edge ($$->start, $3->start); + graph_add_edge ($3->end, $$->end); + + for (unsigned int i = 0; i < vector_active ($1->start->to); i++) + { + struct graph_node *sn = vector_slot ($1->start->to, i), + *en = vector_slot ($1->end->from, i); + graph_add_edge ($$->start, sn); + graph_add_edge (en, $$->end); + } + graph_delete_node (graph, $1->start); + graph_delete_node (graph, $1->end); + free ($1); + free ($3); +} +| selector_token_seq '|' selector_token_seq +{ + $$ = malloc (sizeof (struct subgraph)); + $$->start = graph_new_node (graph, NULL, NULL); + $$->end = graph_new_node (graph, NULL, NULL); + graph_add_edge ($$->start, $1->start); + graph_add_edge ($1->end, $$->end); + graph_add_edge ($$->start, $3->start); + graph_add_edge ($3->end, $$->end); + free ($1); + free ($3); +} +; + +selector_token_seq: + simple_token +{ + $$ = malloc (sizeof (struct subgraph)); + $$->start = $$->end = $1; +} +| selector_token_seq selector_token +{ + $$ = malloc (sizeof (struct subgraph)); + graph_add_edge ($1->end, $2->start); + $$->start = $1->start; + $$->end = $2->end; + free ($1); + free ($2); +} +; + +selector_token: + simple_token +{ + $$ = malloc (sizeof (struct subgraph)); + $$->start = $$->end = $1; +} +| option +| selector +; + +/* [option] productions */ +option: '[' option_token_seq ']' +{ + // make a new option + $$ = malloc (sizeof (struct subgraph)); + $$->start = new_token_node (graph, OPTION_TKN, el->attr, NULL, NULL); + $$->end = new_token_node (graph, NUL_TKN, el->attr, NULL, NULL); + // add a path through the sequence to the end + graph_add_edge ($$->start, $2->start); + graph_add_edge ($2->end, $$->end); + // add a path directly from the start to the end + graph_add_edge ($$->start, $$->end); + free ($2); +} +; + +option_token_seq: + option_token +| option_token_seq option_token +{ + $$ = malloc (sizeof (struct subgraph)); + graph_add_edge ($1->end, $2->start); + $$->start = $1->start; + $$->end = $2->end; + free ($1); + free ($2); +} +; + +option_token: + simple_token +{ + $$ = malloc (sizeof (struct subgraph)); + $$->start = $$->end = $1; +} +| compound_token +; + +%% + +void +command_parse_format (struct graph *graph, struct cmd_element *cmd) +{ + // set to 1 to enable parser traces + yydebug = 0; + + // parse command into DFA + yyparse (graph, cmd); + + // cleanup + cleanup (); +} + +/* parser helper functions */ + +void +yyerror (struct graph *graph, struct cmd_element *el, char const *msg) +{ + zlog_err ("%s: FATAL parse error: %s", __func__, msg); + zlog_err ("while parsing this command definition: \n\t%s\n", el->string); + //exit(EXIT_FAILURE); +} + +static void +cleanup() +{ + /* free resources */ + free (docstr_start); + + /* cleanup lexer */ + cleanup_lexer (); + + /* clear state pointers */ + currnode = NULL; + docstr_start = docstr = NULL; +} + +static void +terminate_graph (struct graph *graph, struct graph_node *finalnode, + struct cmd_element *element) +{ + // end of graph should look like this + // * -> finalnode -> END_TKN -> cmd_element + struct graph_node *end_token_node = + new_token_node (graph, + END_TKN, + element->attr, + strdup (CMD_CR_TEXT), + strdup ("")); + struct graph_node *end_element_node = + graph_new_node (graph, element, (void (*)(void *)) &del_cmd_element); + + if (node_adjacent (finalnode, end_token_node)) + yyerror (graph, element, "Duplicate command."); + + graph_add_edge (finalnode, end_token_node); + graph_add_edge (end_token_node, end_element_node); +} + +static char * +doc_next (struct cmd_element *el) +{ + const char *piece = docstr ? strsep (&docstr, "\n") : ""; + if (*piece == 0x03) + { + zlog_debug ("Ran out of docstring while parsing '%s'", el->string); + piece = ""; + } + + return strdup (piece); +} + +static struct graph_node * +new_token_node (struct graph *graph, enum cmd_token_type type, + u_char attr, char *text, char *doc) +{ + struct cmd_token *token = new_cmd_token (type, attr, text, doc); + return graph_new_node (graph, token, (void (*)(void *)) &del_cmd_token); +} + +/** + * Determines if there is an out edge from the first node to the second + */ +static struct graph_node * +node_adjacent (struct graph_node *first, struct graph_node *second) +{ + struct graph_node *adj; + for (unsigned int i = 0; i < vector_active (first->to); i++) + { + adj = vector_slot (first->to, i); + struct cmd_token *ftok = adj->data, + *stok = second->data; + if (cmp_token (ftok, stok)) + return adj; + } + return NULL; +} + +/** + * Creates an edge betwen two nodes, unless there is already an edge to an + * equivalent node. + * + * The first node's out edges are searched to see if any of them point to a + * node that is equivalent to the second node. If such a node exists, it is + * returned. Otherwise an edge is created from the first node to the second. + * + * @param from start node for edge + * @param to end node for edge + * @return the node which the new edge points to + */ +static struct graph_node * +add_edge_dedup (struct graph_node *from, struct graph_node *to) +{ + struct graph_node *existing = node_adjacent (from, to); + if (existing) + { + struct cmd_token *ex_tok = existing->data; + struct cmd_token *to_tok = to->data; + // NORMAL takes precedence over DEPRECATED takes precedence over HIDDEN + ex_tok->attr = (ex_tok->attr < to_tok->attr) ? ex_tok->attr : to_tok->attr; + return existing; + } + else + return graph_add_edge (from, to); +} + +/** + * Compares two cmd_token's for equality, + * + * As such, this function is the working definition of token equality + * for parsing purposes and determines overall graph structure. + */ +static int +cmp_token (struct cmd_token *first, struct cmd_token *second) +{ + // compare types + if (first->type != second->type) return 0; + + switch (first->type) { + case WORD_TKN: + case VARIABLE_TKN: + if (first->text && second->text) + { + if (strcmp (first->text, second->text)) + return 0; + } + else if (first->text != second->text) return 0; + break; + case RANGE_TKN: + if (first->min != second->min || first->max != second->max) + return 0; + break; + /* selectors and options should be equal if their subgraphs are equal, + * but the graph isomorphism problem is not known to be solvable in + * polynomial time so we consider selectors and options inequal in all + * cases; ultimately this forks the graph, but the matcher can handle + * this regardless + */ + case SELECTOR_TKN: + case OPTION_TKN: + return 0; + + /* end nodes are always considered equal, since each node may only + * have one END_TKN child at a time + */ + case START_TKN: + case END_TKN: + case NUL_TKN: + default: + break; + } + return 1; +} diff --git a/lib/distribute.c b/lib/distribute.c index 498410c22d..8726e993c5 100644 --- a/lib/distribute.c +++ b/lib/distribute.c @@ -161,8 +161,8 @@ distribute_cmp (const struct distribute *dist1, const struct distribute *dist2) } /* Set access-list name to the distribute list. */ -static struct distribute * -distribute_list_set (const char *ifname, enum distribute_type type, +static void +distribute_list_set (const char *ifname, enum distribute_type type, const char *alist_name) { struct distribute *dist; @@ -175,14 +175,12 @@ distribute_list_set (const char *ifname, enum distribute_type type, /* Apply this distribute-list to the interface. */ (*distribute_add_hook) (dist); - - return dist; } /* Unset distribute-list. If matched distribute-list exist then return 1. */ static int -distribute_list_unset (const char *ifname, enum distribute_type type, +distribute_list_unset (const char *ifname, enum distribute_type type, const char *alist_name) { struct distribute *dist; @@ -192,9 +190,9 @@ distribute_list_unset (const char *ifname, enum distribute_type type, return 0; if (!dist->list[type]) - return 0; + return 0; if (strcmp (dist->list[type], alist_name) != 0) - return 0; + return 0; XFREE(MTYPE_DISTRIBUTE_NAME, dist->list[type]); dist->list[type] = NULL; @@ -208,7 +206,7 @@ distribute_list_unset (const char *ifname, enum distribute_type type, } /* Set access-list name to the distribute list. */ -static struct distribute * +static void distribute_list_prefix_set (const char *ifname, enum distribute_type type, const char *plist_name) { @@ -222,8 +220,6 @@ distribute_list_prefix_set (const char *ifname, enum distribute_type type, /* Apply this distribute-list to the interface. */ (*distribute_add_hook) (dist); - - return dist; } /* Unset distribute-list. If matched distribute-list exist then @@ -239,9 +235,9 @@ distribute_list_prefix_unset (const char *ifname, enum distribute_type type, return 0; if (!dist->prefix[type]) - return 0; + return 0; if (strcmp (dist->prefix[type], plist_name) != 0) - return 0; + return 0; XFREE(MTYPE_DISTRIBUTE_NAME, dist->prefix[type]); dist->prefix[type] = NULL; @@ -254,212 +250,70 @@ distribute_list_prefix_unset (const char *ifname, enum distribute_type type, return 1; } -DEFUN (distribute_list_all, - distribute_list_all_cmd, - "distribute-list WORD (in|out)", - "Filter networks in routing updates\n" - "Access-list name\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n") -{ - enum distribute_type type; - - /* Check of distribute list type. */ - if (strncmp (argv[1], "i", 1) == 0) - type = DISTRIBUTE_V4_IN; - else if (strncmp (argv[1], "o", 1) == 0) - type = DISTRIBUTE_V4_OUT; - else - { - vty_out (vty, "distribute list direction must be [in|out]%s", - VTY_NEWLINE); - return CMD_WARNING; - } - - /* Get interface name corresponding distribute list. */ - distribute_list_set (NULL, type, argv[0]); - - return CMD_SUCCESS; -} - -DEFUN (ipv6_distribute_list_all, - ipv6_distribute_list_all_cmd, - "ipv6 distribute-list WORD (in|out)", - "Filter networks in routing updates\n" - "Access-list name\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n") -{ - enum distribute_type type; - - /* Check of distribute list type. */ - if (strncmp (argv[1], "i", 1) == 0) - type = DISTRIBUTE_V6_IN; - else if (strncmp (argv[1], "o", 1) == 0) - type = DISTRIBUTE_V6_OUT; - else - { - vty_out (vty, "distribute list direction must be [in|out]%s", - VTY_NEWLINE); - return CMD_WARNING; - } - - /* Get interface name corresponding distribute list. */ - distribute_list_set (NULL, type, argv[0]); - - return CMD_SUCCESS; -} - -ALIAS (ipv6_distribute_list_all, - ipv6_as_v4_distribute_list_all_cmd, - "distribute-list WORD (in|out)", - "Filter networks in routing updates\n" - "Access-list name\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n") - -DEFUN (no_distribute_list_all, - no_distribute_list_all_cmd, - "no distribute-list WORD (in|out)", - NO_STR - "Filter networks in routing updates\n" - "Access-list name\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n") -{ - int ret; - enum distribute_type type; - - /* Check of distribute list type. */ - if (strncmp (argv[1], "i", 1) == 0) - type = DISTRIBUTE_V4_IN; - else if (strncmp (argv[1], "o", 1) == 0) - type = DISTRIBUTE_V4_OUT; - else - { - vty_out (vty, "distribute list direction must be [in|out]%s", - VTY_NEWLINE); - return CMD_WARNING; - } - - ret = distribute_list_unset (NULL, type, argv[0]); - if (! ret) - { - vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE); - return CMD_WARNING; - } - return CMD_SUCCESS; -} - -DEFUN (no_ipv6_distribute_list_all, - no_ipv6_distribute_list_all_cmd, - "no ipv6 distribute-list WORD (in|out)", - NO_STR - "Filter networks in routing updates\n" - "Access-list name\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n") -{ - int ret; - enum distribute_type type; - - /* Check of distribute list type. */ - if (strncmp (argv[1], "i", 1) == 0) - type = DISTRIBUTE_V6_IN; - else if (strncmp (argv[1], "o", 1) == 0) - type = DISTRIBUTE_V6_OUT; - else - { - vty_out (vty, "distribute list direction must be [in|out]%s", - VTY_NEWLINE); - return CMD_WARNING; - } - - ret = distribute_list_unset (NULL, type, argv[0]); - if (! ret) - { - vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE); - return CMD_WARNING; - } - return CMD_SUCCESS; -} - -ALIAS (no_ipv6_distribute_list_all, - no_ipv6_as_v4_distribute_list_all_cmd, - "no distribute-list WORD (in|out)", - NO_STR - "Filter networks in routing updates\n" - "Access-list name\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n") - DEFUN (distribute_list, distribute_list_cmd, - "distribute-list WORD (in|out) WORD", + "distribute-list [prefix] WORD <in|out> [WORD]", "Filter networks in routing updates\n" "Access-list name\n" "Filter incoming routing updates\n" "Filter outgoing routing updates\n" "Interface name\n") { - enum distribute_type type; + int prefix = (argv[1]->type == WORD_TKN) ? 1 : 0; /* Check of distribute list type. */ - if (strncmp (argv[1], "i", 1) == 0) - type = DISTRIBUTE_V4_IN; - else if (strncmp (argv[1], "o", 1) == 0) - type = DISTRIBUTE_V4_OUT; - else - { - vty_out (vty, "distribute list direction must be [in|out]%s", VTY_NEWLINE); - return CMD_WARNING; - } + enum distribute_type type = argv[2 + prefix]->arg[0] == 'i' ? + DISTRIBUTE_V4_IN : DISTRIBUTE_V4_OUT; + + /* Set appropriate function call */ + void (*distfn)(const char *, enum distribute_type, const char *) = prefix ? + &distribute_list_prefix_set : &distribute_list_set; + + /* if interface is present, get name */ + const char *ifname = NULL; + if (argv[argc - 1]->type == VARIABLE_TKN) + ifname = argv[argc - 1]->arg; /* Get interface name corresponding distribute list. */ - distribute_list_set (argv[2], type, argv[0]); + distfn (ifname, type, argv[1 + prefix]->arg); return CMD_SUCCESS; } DEFUN (ipv6_distribute_list, ipv6_distribute_list_cmd, - "ipv6 distribute-list WORD (in|out) WORD", + "ipv6 distribute-list [prefix] WORD <in|out> [WORD]", + "IPv6\n" "Filter networks in routing updates\n" "Access-list name\n" "Filter incoming routing updates\n" "Filter outgoing routing updates\n" "Interface name\n") { - enum distribute_type type; + int prefix = (argv[2]->type == WORD_TKN) ? 1 : 0; /* Check of distribute list type. */ - if (strncmp (argv[1], "i", 1) == 0) - type = DISTRIBUTE_V6_IN; - else if (strncmp (argv[1], "o", 1) == 0) - type = DISTRIBUTE_V6_OUT; - else - { - vty_out (vty, "distribute list direction must be [in|out]%s", VTY_NEWLINE); - return CMD_WARNING; - } + enum distribute_type type = argv[3 + prefix]->arg[0] == 'i' ? + DISTRIBUTE_V6_IN : DISTRIBUTE_V6_OUT; + + /* Set appropriate function call */ + void (*distfn)(const char *, enum distribute_type, const char *) = prefix ? + &distribute_list_prefix_set : &distribute_list_set; + + /* if interface is present, get name */ + const char *ifname = NULL; + if (argv[argc - 1]->type == VARIABLE_TKN) + ifname = argv[argc - 1]->arg; /* Get interface name corresponding distribute list. */ - distribute_list_set (argv[2], type, argv[0]); + distfn (ifname, type, argv[1 + prefix]->arg); return CMD_SUCCESS; } - -ALIAS (ipv6_distribute_list, - ipv6_as_v4_distribute_list_cmd, - "distribute-list WORD (in|out) WORD", - "Filter networks in routing updates\n" - "Access-list name\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n" - "Interface name\n") - -DEFUN (no_distribute_list, no_distribute_list_cmd, - "no distribute-list WORD (in|out) WORD", + +DEFUN (no_distribute_list, + no_distribute_list_cmd, + "no [ipv6] distribute-list [prefix] WORD <in|out> [WORD]", NO_STR "Filter networks in routing updates\n" "Access-list name\n" @@ -467,312 +321,29 @@ DEFUN (no_distribute_list, no_distribute_list_cmd, "Filter outgoing routing updates\n" "Interface name\n") { - int ret; - enum distribute_type type; - - /* Check of distribute list type. */ - if (strncmp (argv[1], "i", 1) == 0) - type = DISTRIBUTE_V4_IN; - else if (strncmp (argv[1], "o", 1) == 0) - type = DISTRIBUTE_V4_OUT; - else - { - vty_out (vty, "distribute list direction must be [in|out]%s", VTY_NEWLINE); - return CMD_WARNING; - } - - ret = distribute_list_unset (argv[2], type, argv[0]); - if (! ret) - { - vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE); - return CMD_WARNING; - } - return CMD_SUCCESS; -} + int ipv6 = strmatch(argv[1]->text, "ipv6"); + int prefix = (argv[2 + ipv6]->type == WORD_TKN) ? 1 : 0; -DEFUN (no_ipv6_distribute_list, - no_ipv6_distribute_list_cmd, - "no ipv6 distribute-list WORD (in|out) WORD", - NO_STR - "Filter networks in routing updates\n" - "Access-list name\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n" - "Interface name\n") -{ - int ret; - enum distribute_type type; + int idx_alname = 2 + ipv6 + prefix; + int idx_disttype = idx_alname + 1; /* Check of distribute list type. */ - if (strncmp (argv[1], "i", 1) == 0) - type = DISTRIBUTE_V6_IN; - else if (strncmp (argv[1], "o", 1) == 0) - type = DISTRIBUTE_V6_OUT; - else - { - vty_out (vty, "distribute list direction must be [in|out]%s", VTY_NEWLINE); - return CMD_WARNING; - } + enum distribute_type distin = (ipv6) ? DISTRIBUTE_V6_IN : DISTRIBUTE_V4_IN; + enum distribute_type distout = (ipv6) ? DISTRIBUTE_V6_OUT : DISTRIBUTE_V4_OUT; - ret = distribute_list_unset (argv[2], type, argv[0]); - if (! ret) - { - vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE); - return CMD_WARNING; - } - return CMD_SUCCESS; -} - -ALIAS (no_ipv6_distribute_list, - no_ipv6_as_v4_distribute_list_cmd, - "no distribute-list WORD (in|out) WORD", - NO_STR - "Filter networks in routing updates\n" - "Access-list name\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n" - "Interface name\n") - -DEFUN (distribute_list_prefix_all, - distribute_list_prefix_all_cmd, - "distribute-list prefix WORD (in|out)", - "Filter networks in routing updates\n" - "Filter prefixes in routing updates\n" - "Name of an IP prefix-list\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n") -{ - enum distribute_type type; - - /* Check of distribute list type. */ - if (strncmp (argv[1], "i", 1) == 0) - type = DISTRIBUTE_V4_IN; - else if (strncmp (argv[1], "o", 1) == 0) - type = DISTRIBUTE_V4_OUT; - else - { - vty_out (vty, "distribute list direction must be [in|out]%s", - VTY_NEWLINE); - return CMD_WARNING; - } - - /* Get interface name corresponding distribute list. */ - distribute_list_prefix_set (NULL, type, argv[0]); - - return CMD_SUCCESS; -} - -DEFUN (ipv6_distribute_list_prefix_all, - ipv6_distribute_list_prefix_all_cmd, - "ipv6 distribute-list prefix WORD (in|out)", - "Filter networks in routing updates\n" - "Filter prefixes in routing updates\n" - "Name of an IP prefix-list\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n") -{ - enum distribute_type type; - - /* Check of distribute list type. */ - if (strncmp (argv[1], "i", 1) == 0) - type = DISTRIBUTE_V6_IN; - else if (strncmp (argv[1], "o", 1) == 0) - type = DISTRIBUTE_V6_OUT; - else - { - vty_out (vty, "distribute list direction must be [in|out]%s", - VTY_NEWLINE); - return CMD_WARNING; - } - - /* Get interface name corresponding distribute list. */ - distribute_list_prefix_set (NULL, type, argv[0]); - - return CMD_SUCCESS; -} - -ALIAS (ipv6_distribute_list_prefix_all, - ipv6_as_v4_distribute_list_prefix_all_cmd, - "distribute-list prefix WORD (in|out)", - "Filter networks in routing updates\n" - "Filter prefixes in routing updates\n" - "Name of an IP prefix-list\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n") - -DEFUN (no_distribute_list_prefix_all, - no_distribute_list_prefix_all_cmd, - "no distribute-list prefix WORD (in|out)", - NO_STR - "Filter networks in routing updates\n" - "Filter prefixes in routing updates\n" - "Name of an IP prefix-list\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n") -{ - int ret; - enum distribute_type type; - - /* Check of distribute list type. */ - if (strncmp (argv[1], "i", 1) == 0) - type = DISTRIBUTE_V4_IN; - else if (strncmp (argv[1], "o", 1) == 0) - type = DISTRIBUTE_V4_OUT; - else - { - vty_out (vty, "distribute list direction must be [in|out]%s", - VTY_NEWLINE); - return CMD_WARNING; - } - - ret = distribute_list_prefix_unset (NULL, type, argv[0]); - if (! ret) - { - vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE); - return CMD_WARNING; - } - return CMD_SUCCESS; -} - -DEFUN (no_ipv6_distribute_list_prefix_all, - no_ipv6_distribute_list_prefix_all_cmd, - "no ipv6 distribute-list prefix WORD (in|out)", - NO_STR - "Filter networks in routing updates\n" - "Filter prefixes in routing updates\n" - "Name of an IP prefix-list\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n") -{ - int ret; - enum distribute_type type; - - /* Check of distribute list type. */ - if (strncmp (argv[1], "i", 1) == 0) - type = DISTRIBUTE_V6_IN; - else if (strncmp (argv[1], "o", 1) == 0) - type = DISTRIBUTE_V6_OUT; - else - { - vty_out (vty, "distribute list direction must be [in|out]%s", - VTY_NEWLINE); - return CMD_WARNING; - } - - ret = distribute_list_prefix_unset (NULL, type, argv[0]); - if (! ret) - { - vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE); - return CMD_WARNING; - } - return CMD_SUCCESS; -} - -ALIAS (no_ipv6_distribute_list_prefix_all, - no_ipv6_as_v4_distribute_list_prefix_all_cmd, - "no distribute-list prefix WORD (in|out)", - NO_STR - "Filter networks in routing updates\n" - "Filter prefixes in routing updates\n" - "Name of an IP prefix-list\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n") - -DEFUN (distribute_list_prefix, distribute_list_prefix_cmd, - "distribute-list prefix WORD (in|out) WORD", - "Filter networks in routing updates\n" - "Filter prefixes in routing updates\n" - "Name of an IP prefix-list\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n" - "Interface name\n") -{ - enum distribute_type type; - - /* Check of distribute list type. */ - if (strncmp (argv[1], "i", 1) == 0) - type = DISTRIBUTE_V4_IN; - else if (strncmp (argv[1], "o", 1) == 0) - type = DISTRIBUTE_V4_OUT; - else - { - vty_out (vty, "distribute list direction must be [in|out]%s", - VTY_NEWLINE); - return CMD_WARNING; - } - - /* Get interface name corresponding distribute list. */ - distribute_list_prefix_set (argv[2], type, argv[0]); - - return CMD_SUCCESS; -} - -DEFUN (ipv6_distribute_list_prefix, - ipv6_distribute_list_prefix_cmd, - "ipv6 distribute-list prefix WORD (in|out) WORD", - "Filter networks in routing updates\n" - "Filter prefixes in routing updates\n" - "Name of an IP prefix-list\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n" - "Interface name\n") -{ - enum distribute_type type; - - /* Check of distribute list type. */ - if (strncmp (argv[1], "i", 1) == 0) - type = DISTRIBUTE_V6_IN; - else if (strncmp (argv[1], "o", 1) == 0) - type = DISTRIBUTE_V6_OUT; - else - { - vty_out (vty, "distribute list direction must be [in|out]%s", - VTY_NEWLINE); - return CMD_WARNING; - } + enum distribute_type type = argv[idx_disttype]->arg[0] == 'i' ? distin : distout; + /* Set appropriate function call */ + int (*distfn)(const char *, enum distribute_type, const char *) = prefix ? + &distribute_list_prefix_unset : &distribute_list_unset; + + /* if interface is present, get name */ + const char *ifname = NULL; + if (argv[argc - 1]->type == VARIABLE_TKN) + ifname = argv[argc - 1]->arg; /* Get interface name corresponding distribute list. */ - distribute_list_prefix_set (argv[2], type, argv[0]); - - return CMD_SUCCESS; -} - -ALIAS (ipv6_distribute_list_prefix, - ipv6_as_v4_distribute_list_prefix_cmd, - "distribute-list prefix WORD (in|out) WORD", - "Filter networks in routing updates\n" - "Filter prefixes in routing updates\n" - "Name of an IP prefix-list\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n" - "Interface name\n") - -DEFUN (no_distribute_list_prefix, no_distribute_list_prefix_cmd, - "no distribute-list prefix WORD (in|out) WORD", - NO_STR - "Filter networks in routing updates\n" - "Filter prefixes in routing updates\n" - "Name of an IP prefix-list\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n" - "Interface name\n") -{ - int ret; - enum distribute_type type; + int ret = distfn (ifname, type, argv[2 + prefix]->arg); - /* Check of distribute list type. */ - if (strncmp (argv[1], "i", 1) == 0) - type = DISTRIBUTE_V4_IN; - else if (strncmp (argv[1], "o", 1) == 0) - type = DISTRIBUTE_V4_OUT; - else - { - vty_out (vty, "distribute list direction must be [in|out]%s", - VTY_NEWLINE); - return CMD_WARNING; - } - - ret = distribute_list_prefix_unset (argv[2], type, argv[0]); if (! ret) { vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE); @@ -781,52 +352,6 @@ DEFUN (no_distribute_list_prefix, no_distribute_list_prefix_cmd, return CMD_SUCCESS; } -DEFUN (no_ipv6_distribute_list_prefix, - no_ipv6_distribute_list_prefix_cmd, - "no ipv6 distribute-list prefix WORD (in|out) WORD", - NO_STR - "Filter networks in routing updates\n" - "Filter prefixes in routing updates\n" - "Name of an IP prefix-list\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n" - "Interface name\n") -{ - int ret; - enum distribute_type type; - - /* Check of distribute list type. */ - if (strncmp (argv[1], "i", 1) == 0) - type = DISTRIBUTE_V6_IN; - else if (strncmp (argv[1], "o", 1) == 0) - type = DISTRIBUTE_V6_OUT; - else - { - vty_out (vty, "distribute list direction must be [in|out]%s", - VTY_NEWLINE); - return CMD_WARNING; - } - - ret = distribute_list_prefix_unset (argv[2], type, argv[0]); - if (! ret) - { - vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE); - return CMD_WARNING; - } - return CMD_SUCCESS; -} - -ALIAS (no_ipv6_distribute_list_prefix, - no_ipv6_as_v4_distribute_list_prefix_cmd, - "no distribute-list prefix WORD (in|out) WORD", - NO_STR - "Filter networks in routing updates\n" - "Filter prefixes in routing updates\n" - "Name of an IP prefix-list\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n" - "Interface name\n") - static int distribute_print (struct vty *vty, char *tab[], int is_prefix, enum distribute_type type, int has_print) @@ -851,7 +376,7 @@ config_show_distribute (struct vty *vty) /* Output filter configuration. */ dist = distribute_lookup (NULL); - vty_out(vty, " Outgoing update filter list for all interface is"); + vty_out (vty, " Outgoing update filter list for all interface is"); has_print = 0; if (dist) { @@ -874,8 +399,8 @@ config_show_distribute (struct vty *vty) { dist = mp->data; if (dist->ifname) - { - vty_out (vty, " %s filtered by", dist->ifname); + { + vty_out (vty, " %s filtered by", dist->ifname); has_print = 0; has_print = distribute_print(vty, dist->list, 0, DISTRIBUTE_V4_OUT, has_print); @@ -886,16 +411,16 @@ config_show_distribute (struct vty *vty) has_print = distribute_print(vty, dist->prefix, 1, DISTRIBUTE_V6_OUT, has_print); if (has_print) - vty_out (vty, "%s", VTY_NEWLINE); + vty_out (vty, "%s", VTY_NEWLINE); else vty_out(vty, " nothing%s", VTY_NEWLINE); - } + } } /* Input filter configuration. */ dist = distribute_lookup (NULL); - vty_out(vty, " Incoming update filter list for all interface is"); + vty_out (vty, " Incoming update filter list for all interface is"); has_print = 0; if (dist) { @@ -917,9 +442,9 @@ config_show_distribute (struct vty *vty) for (mp = disthash->index[i]; mp; mp = mp->next) { dist = mp->data; - if (dist->ifname) - { - vty_out (vty, " %s filtered by", dist->ifname); + if (dist->ifname) + { + vty_out (vty, " %s filtered by", dist->ifname); has_print = 0; has_print = distribute_print(vty, dist->list, 0, DISTRIBUTE_V4_IN, has_print); @@ -930,10 +455,10 @@ config_show_distribute (struct vty *vty) has_print = distribute_print(vty, dist->prefix, 1, DISTRIBUTE_V6_IN, has_print); if (has_print) - vty_out (vty, "%s", VTY_NEWLINE); + vty_out (vty, "%s", VTY_NEWLINE); else vty_out(vty, " nothing%s", VTY_NEWLINE); - } + } } return 0; } @@ -997,39 +522,24 @@ distribute_list_init (int node) { disthash = hash_create (distribute_hash_make, (int (*) (const void *, const void *)) distribute_cmp); - /* install v4 */ - if (node == RIP_NODE) { - install_element (node, &distribute_list_all_cmd); - install_element (node, &no_distribute_list_all_cmd); - install_element (node, &distribute_list_cmd); - install_element (node, &no_distribute_list_cmd); - install_element (node, &distribute_list_prefix_all_cmd); - install_element (node, &no_distribute_list_prefix_all_cmd); - install_element (node, &distribute_list_prefix_cmd); - install_element (node, &no_distribute_list_prefix_cmd); - } + + install_element (node, &distribute_list_cmd); + install_element (node, &no_distribute_list_cmd); /* install v6 */ if (node == RIPNG_NODE) { - install_element (node, &ipv6_distribute_list_all_cmd); - install_element (node, &no_ipv6_distribute_list_all_cmd); install_element (node, &ipv6_distribute_list_cmd); - install_element (node, &no_ipv6_distribute_list_cmd); - install_element (node, &ipv6_distribute_list_prefix_all_cmd); - install_element (node, &no_ipv6_distribute_list_prefix_all_cmd); - install_element (node, &ipv6_distribute_list_prefix_cmd); - install_element (node, &no_ipv6_distribute_list_prefix_cmd); } - /* install v4 syntax command for v6 only protocols. */ - if (node == RIPNG_NODE) { - install_element (node, &ipv6_as_v4_distribute_list_all_cmd); - install_element (node, &no_ipv6_as_v4_distribute_list_all_cmd); - install_element (node, &ipv6_as_v4_distribute_list_cmd); - install_element (node, &no_ipv6_as_v4_distribute_list_cmd); - install_element (node, &ipv6_as_v4_distribute_list_prefix_all_cmd); - install_element (node, &no_ipv6_as_v4_distribute_list_prefix_all_cmd); - install_element (node, &ipv6_as_v4_distribute_list_prefix_cmd); - install_element (node, &no_ipv6_as_v4_distribute_list_prefix_cmd); - } + /* TODO: install v4 syntax command for v6 only protocols. */ + /* if (node == RIPNG_NODE) { + * install_element (node, &ipv6_as_v4_distribute_list_all_cmd); + * install_element (node, &no_ipv6_as_v4_distribute_list_all_cmd); + * install_element (node, &ipv6_as_v4_distribute_list_cmd); + * install_element (node, &no_ipv6_as_v4_distribute_list_cmd); + * install_element (node, &ipv6_as_v4_distribute_list_prefix_all_cmd); + * install_element (node, &no_ipv6_as_v4_distribute_list_prefix_all_cmd); + * install_element (node, &ipv6_as_v4_distribute_list_prefix_cmd); + * install_element (node, &no_ipv6_as_v4_distribute_list_prefix_cmd); + }*/ } diff --git a/lib/filter.c b/lib/filter.c index e9ba715c92..501b28f2da 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -704,7 +704,7 @@ filter_set_cisco (struct vty *vty, const char *name_str, const char *type_str, /* Standard access-list */ DEFUN (access_list_standard, access_list_standard_cmd, - "access-list (<1-99>|<1300-1999>) (deny|permit) A.B.C.D A.B.C.D", + "access-list <(1-99)|(1300-1999)> <deny|permit> A.B.C.D A.B.C.D", "Add an access list entry\n" "IP standard access list\n" "IP standard access list (expanded range)\n" @@ -713,13 +713,17 @@ DEFUN (access_list_standard, "Address to match\n" "Wildcard bits\n") { - return filter_set_cisco (vty, argv[0], argv[1], argv[2], argv[3], + int idx_acl = 1; + int idx_permit_deny = 2; + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, NULL, NULL, 0, 1); } DEFUN (access_list_standard_nomask, access_list_standard_nomask_cmd, - "access-list (<1-99>|<1300-1999>) (deny|permit) A.B.C.D", + "access-list <(1-99)|(1300-1999)> <deny|permit> A.B.C.D", "Add an access list entry\n" "IP standard access list\n" "IP standard access list (expanded range)\n" @@ -727,13 +731,16 @@ DEFUN (access_list_standard_nomask, "Specify packets to forward\n" "Address to match\n") { - return filter_set_cisco (vty, argv[0], argv[1], argv[2], "0.0.0.0", + int idx_acl = 1; + int idx_permit_deny = 2; + int idx_ipv4 = 3; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, "0.0.0.0", NULL, NULL, 0, 1); } DEFUN (access_list_standard_host, access_list_standard_host_cmd, - "access-list (<1-99>|<1300-1999>) (deny|permit) host A.B.C.D", + "access-list <(1-99)|(1300-1999)> <deny|permit> host A.B.C.D", "Add an access list entry\n" "IP standard access list\n" "IP standard access list (expanded range)\n" @@ -742,13 +749,16 @@ DEFUN (access_list_standard_host, "A single host address\n" "Address to match\n") { - return filter_set_cisco (vty, argv[0], argv[1], argv[2], "0.0.0.0", + int idx_acl = 1; + int idx_permit_deny = 2; + int idx_ipv4 = 4; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, "0.0.0.0", NULL, NULL, 0, 1); } DEFUN (access_list_standard_any, access_list_standard_any_cmd, - "access-list (<1-99>|<1300-1999>) (deny|permit) any", + "access-list <(1-99)|(1300-1999)> <deny|permit> any", "Add an access list entry\n" "IP standard access list\n" "IP standard access list (expanded range)\n" @@ -756,13 +766,15 @@ DEFUN (access_list_standard_any, "Specify packets to forward\n" "Any source host\n") { - return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0", + int idx_acl = 1; + int idx_permit_deny = 2; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, "0.0.0.0", "255.255.255.255", NULL, NULL, 0, 1); } DEFUN (no_access_list_standard, no_access_list_standard_cmd, - "no access-list (<1-99>|<1300-1999>) (deny|permit) A.B.C.D A.B.C.D", + "no access-list <(1-99)|(1300-1999)> <deny|permit> A.B.C.D A.B.C.D", NO_STR "Add an access list entry\n" "IP standard access list\n" @@ -772,13 +784,17 @@ DEFUN (no_access_list_standard, "Address to match\n" "Wildcard bits\n") { - return filter_set_cisco (vty, argv[0], argv[1], argv[2], argv[3], + int idx_acl = 2; + int idx_permit_deny = 3; + int idx_ipv4 = 4; + int idx_ipv4_2 = 5; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, NULL, NULL, 0, 0); } DEFUN (no_access_list_standard_nomask, no_access_list_standard_nomask_cmd, - "no access-list (<1-99>|<1300-1999>) (deny|permit) A.B.C.D", + "no access-list <(1-99)|(1300-1999)> <deny|permit> A.B.C.D", NO_STR "Add an access list entry\n" "IP standard access list\n" @@ -787,13 +803,16 @@ DEFUN (no_access_list_standard_nomask, "Specify packets to forward\n" "Address to match\n") { - return filter_set_cisco (vty, argv[0], argv[1], argv[2], "0.0.0.0", + int idx_acl = 2; + int idx_permit_deny = 3; + int idx_ipv4 = 4; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, "0.0.0.0", NULL, NULL, 0, 0); } DEFUN (no_access_list_standard_host, no_access_list_standard_host_cmd, - "no access-list (<1-99>|<1300-1999>) (deny|permit) host A.B.C.D", + "no access-list <(1-99)|(1300-1999)> <deny|permit> host A.B.C.D", NO_STR "Add an access list entry\n" "IP standard access list\n" @@ -803,13 +822,16 @@ DEFUN (no_access_list_standard_host, "A single host address\n" "Address to match\n") { - return filter_set_cisco (vty, argv[0], argv[1], argv[2], "0.0.0.0", + int idx_acl = 2; + int idx_permit_deny = 3; + int idx_ipv4 = 5; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, "0.0.0.0", NULL, NULL, 0, 0); } DEFUN (no_access_list_standard_any, no_access_list_standard_any_cmd, - "no access-list (<1-99>|<1300-1999>) (deny|permit) any", + "no access-list <(1-99)|(1300-1999)> <deny|permit> any", NO_STR "Add an access list entry\n" "IP standard access list\n" @@ -818,14 +840,16 @@ DEFUN (no_access_list_standard_any, "Specify packets to forward\n" "Any source host\n") { - return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0", + int idx_acl = 2; + int idx_permit_deny = 3; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, "0.0.0.0", "255.255.255.255", NULL, NULL, 0, 0); } /* Extended access-list */ DEFUN (access_list_extended, access_list_extended_cmd, - "access-list (<100-199>|<2000-2699>) (deny|permit) ip A.B.C.D A.B.C.D A.B.C.D A.B.C.D", + "access-list <(100-199)|(2000-2699)> <deny|permit> ip A.B.C.D A.B.C.D A.B.C.D A.B.C.D", "Add an access list entry\n" "IP extended access list\n" "IP extended access list (expanded range)\n" @@ -837,13 +861,19 @@ DEFUN (access_list_extended, "Destination address\n" "Destination Wildcard bits\n") { - return filter_set_cisco (vty, argv[0], argv[1], argv[2], - argv[3], argv[4], argv[5], 1 ,1); + int idx_acl = 1; + int idx_permit_deny = 2; + int idx_ipv4 = 4; + int idx_ipv4_2 = 5; + int idx_ipv4_3 = 6; + int idx_ipv4_4 = 7; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, + argv[idx_ipv4_2]->arg, argv[idx_ipv4_3]->arg, argv[idx_ipv4_4]->arg, 1 ,1); } DEFUN (access_list_extended_mask_any, access_list_extended_mask_any_cmd, - "access-list (<100-199>|<2000-2699>) (deny|permit) ip A.B.C.D A.B.C.D any", + "access-list <(100-199)|(2000-2699)> <deny|permit> ip A.B.C.D A.B.C.D any", "Add an access list entry\n" "IP extended access list\n" "IP extended access list (expanded range)\n" @@ -854,14 +884,18 @@ DEFUN (access_list_extended_mask_any, "Source wildcard bits\n" "Any destination host\n") { - return filter_set_cisco (vty, argv[0], argv[1], argv[2], - argv[3], "0.0.0.0", + int idx_acl = 1; + int idx_permit_deny = 2; + int idx_ipv4 = 4; + int idx_ipv4_2 = 5; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, + argv[idx_ipv4_2]->arg, "0.0.0.0", "255.255.255.255", 1, 1); } DEFUN (access_list_extended_any_mask, access_list_extended_any_mask_cmd, - "access-list (<100-199>|<2000-2699>) (deny|permit) ip any A.B.C.D A.B.C.D", + "access-list <(100-199)|(2000-2699)> <deny|permit> ip any A.B.C.D A.B.C.D", "Add an access list entry\n" "IP extended access list\n" "IP extended access list (expanded range)\n" @@ -872,14 +906,18 @@ DEFUN (access_list_extended_any_mask, "Destination address\n" "Destination Wildcard bits\n") { - return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0", - "255.255.255.255", argv[2], - argv[3], 1, 1); + int idx_acl = 1; + int idx_permit_deny = 2; + int idx_ipv4 = 5; + int idx_ipv4_2 = 6; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, "0.0.0.0", + "255.255.255.255", argv[idx_ipv4]->arg, + argv[idx_ipv4_2]->arg, 1, 1); } DEFUN (access_list_extended_any_any, access_list_extended_any_any_cmd, - "access-list (<100-199>|<2000-2699>) (deny|permit) ip any any", + "access-list <(100-199)|(2000-2699)> <deny|permit> ip any any", "Add an access list entry\n" "IP extended access list\n" "IP extended access list (expanded range)\n" @@ -889,14 +927,16 @@ DEFUN (access_list_extended_any_any, "Any source host\n" "Any destination host\n") { - return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0", + int idx_acl = 1; + int idx_permit_deny = 2; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, "0.0.0.0", "255.255.255.255", "0.0.0.0", "255.255.255.255", 1, 1); } DEFUN (access_list_extended_mask_host, access_list_extended_mask_host_cmd, - "access-list (<100-199>|<2000-2699>) (deny|permit) ip A.B.C.D A.B.C.D host A.B.C.D", + "access-list <(100-199)|(2000-2699)> <deny|permit> ip A.B.C.D A.B.C.D host A.B.C.D", "Add an access list entry\n" "IP extended access list\n" "IP extended access list (expanded range)\n" @@ -908,14 +948,19 @@ DEFUN (access_list_extended_mask_host, "A single destination host\n" "Destination address\n") { - return filter_set_cisco (vty, argv[0], argv[1], argv[2], - argv[3], argv[4], + int idx_acl = 1; + int idx_permit_deny = 2; + int idx_ipv4 = 4; + int idx_ipv4_2 = 5; + int idx_ipv4_3 = 7; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, + argv[idx_ipv4_2]->arg, argv[idx_ipv4_3]->arg, "0.0.0.0", 1, 1); } DEFUN (access_list_extended_host_mask, access_list_extended_host_mask_cmd, - "access-list (<100-199>|<2000-2699>) (deny|permit) ip host A.B.C.D A.B.C.D A.B.C.D", + "access-list <(100-199)|(2000-2699)> <deny|permit> ip host A.B.C.D A.B.C.D A.B.C.D", "Add an access list entry\n" "IP extended access list\n" "IP extended access list (expanded range)\n" @@ -927,14 +972,19 @@ DEFUN (access_list_extended_host_mask, "Destination address\n" "Destination Wildcard bits\n") { - return filter_set_cisco (vty, argv[0], argv[1], argv[2], - "0.0.0.0", argv[3], - argv[4], 1, 1); + int idx_acl = 1; + int idx_permit_deny = 2; + int idx_ipv4 = 5; + int idx_ipv4_2 = 6; + int idx_ipv4_3 = 7; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, + "0.0.0.0", argv[idx_ipv4_2]->arg, + argv[idx_ipv4_3]->arg, 1, 1); } DEFUN (access_list_extended_host_host, access_list_extended_host_host_cmd, - "access-list (<100-199>|<2000-2699>) (deny|permit) ip host A.B.C.D host A.B.C.D", + "access-list <(100-199)|(2000-2699)> <deny|permit> ip host A.B.C.D host A.B.C.D", "Add an access list entry\n" "IP extended access list\n" "IP extended access list (expanded range)\n" @@ -946,14 +996,18 @@ DEFUN (access_list_extended_host_host, "A single destination host\n" "Destination address\n") { - return filter_set_cisco (vty, argv[0], argv[1], argv[2], - "0.0.0.0", argv[3], + int idx_acl = 1; + int idx_permit_deny = 2; + int idx_ipv4 = 5; + int idx_ipv4_2 = 7; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, + "0.0.0.0", argv[idx_ipv4_2]->arg, "0.0.0.0", 1, 1); } DEFUN (access_list_extended_any_host, access_list_extended_any_host_cmd, - "access-list (<100-199>|<2000-2699>) (deny|permit) ip any host A.B.C.D", + "access-list <(100-199)|(2000-2699)> <deny|permit> ip any host A.B.C.D", "Add an access list entry\n" "IP extended access list\n" "IP extended access list (expanded range)\n" @@ -964,14 +1018,17 @@ DEFUN (access_list_extended_any_host, "A single destination host\n" "Destination address\n") { - return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0", - "255.255.255.255", argv[2], + int idx_acl = 1; + int idx_permit_deny = 2; + int idx_ipv4 = 6; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, "0.0.0.0", + "255.255.255.255", argv[idx_ipv4]->arg, "0.0.0.0", 1, 1); } DEFUN (access_list_extended_host_any, access_list_extended_host_any_cmd, - "access-list (<100-199>|<2000-2699>) (deny|permit) ip host A.B.C.D any", + "access-list <(100-199)|(2000-2699)> <deny|permit> ip host A.B.C.D any", "Add an access list entry\n" "IP extended access list\n" "IP extended access list (expanded range)\n" @@ -982,14 +1039,17 @@ DEFUN (access_list_extended_host_any, "Source address\n" "Any destination host\n") { - return filter_set_cisco (vty, argv[0], argv[1], argv[2], + int idx_acl = 1; + int idx_permit_deny = 2; + int idx_ipv4 = 5; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, "0.0.0.0", "0.0.0.0", "255.255.255.255", 1, 1); } DEFUN (no_access_list_extended, no_access_list_extended_cmd, - "no access-list (<100-199>|<2000-2699>) (deny|permit) ip A.B.C.D A.B.C.D A.B.C.D A.B.C.D", + "no access-list <(100-199)|(2000-2699)> <deny|permit> ip A.B.C.D A.B.C.D A.B.C.D A.B.C.D", NO_STR "Add an access list entry\n" "IP extended access list\n" @@ -1002,13 +1062,19 @@ DEFUN (no_access_list_extended, "Destination address\n" "Destination Wildcard bits\n") { - return filter_set_cisco (vty, argv[0], argv[1], argv[2], - argv[3], argv[4], argv[5], 1, 0); + int idx_acl = 2; + int idx_permit_deny = 3; + int idx_ipv4 = 5; + int idx_ipv4_2 = 6; + int idx_ipv4_3 = 7; + int idx_ipv4_4 = 8; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, + argv[idx_ipv4_2]->arg, argv[idx_ipv4_3]->arg, argv[idx_ipv4_4]->arg, 1, 0); } DEFUN (no_access_list_extended_mask_any, no_access_list_extended_mask_any_cmd, - "no access-list (<100-199>|<2000-2699>) (deny|permit) ip A.B.C.D A.B.C.D any", + "no access-list <(100-199)|(2000-2699)> <deny|permit> ip A.B.C.D A.B.C.D any", NO_STR "Add an access list entry\n" "IP extended access list\n" @@ -1020,14 +1086,18 @@ DEFUN (no_access_list_extended_mask_any, "Source wildcard bits\n" "Any destination host\n") { - return filter_set_cisco (vty, argv[0], argv[1], argv[2], - argv[3], "0.0.0.0", + int idx_acl = 2; + int idx_permit_deny = 3; + int idx_ipv4 = 5; + int idx_ipv4_2 = 6; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, + argv[idx_ipv4_2]->arg, "0.0.0.0", "255.255.255.255", 1, 0); } DEFUN (no_access_list_extended_any_mask, no_access_list_extended_any_mask_cmd, - "no access-list (<100-199>|<2000-2699>) (deny|permit) ip any A.B.C.D A.B.C.D", + "no access-list <(100-199)|(2000-2699)> <deny|permit> ip any A.B.C.D A.B.C.D", NO_STR "Add an access list entry\n" "IP extended access list\n" @@ -1039,14 +1109,18 @@ DEFUN (no_access_list_extended_any_mask, "Destination address\n" "Destination Wildcard bits\n") { - return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0", - "255.255.255.255", argv[2], - argv[3], 1, 0); + int idx_acl = 2; + int idx_permit_deny = 3; + int idx_ipv4 = 6; + int idx_ipv4_2 = 7; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, "0.0.0.0", + "255.255.255.255", argv[idx_ipv4]->arg, + argv[idx_ipv4_2]->arg, 1, 0); } DEFUN (no_access_list_extended_any_any, no_access_list_extended_any_any_cmd, - "no access-list (<100-199>|<2000-2699>) (deny|permit) ip any any", + "no access-list <(100-199)|(2000-2699)> <deny|permit> ip any any", NO_STR "Add an access list entry\n" "IP extended access list\n" @@ -1057,14 +1131,16 @@ DEFUN (no_access_list_extended_any_any, "Any source host\n" "Any destination host\n") { - return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0", + int idx_acl = 2; + int idx_permit_deny = 3; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, "0.0.0.0", "255.255.255.255", "0.0.0.0", "255.255.255.255", 1, 0); } DEFUN (no_access_list_extended_mask_host, no_access_list_extended_mask_host_cmd, - "no access-list (<100-199>|<2000-2699>) (deny|permit) ip A.B.C.D A.B.C.D host A.B.C.D", + "no access-list <(100-199)|(2000-2699)> <deny|permit> ip A.B.C.D A.B.C.D host A.B.C.D", NO_STR "Add an access list entry\n" "IP extended access list\n" @@ -1077,14 +1153,19 @@ DEFUN (no_access_list_extended_mask_host, "A single destination host\n" "Destination address\n") { - return filter_set_cisco (vty, argv[0], argv[1], argv[2], - argv[3], argv[4], + int idx_acl = 2; + int idx_permit_deny = 3; + int idx_ipv4 = 5; + int idx_ipv4_2 = 6; + int idx_ipv4_3 = 8; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, + argv[idx_ipv4_2]->arg, argv[idx_ipv4_3]->arg, "0.0.0.0", 1, 0); } DEFUN (no_access_list_extended_host_mask, no_access_list_extended_host_mask_cmd, - "no access-list (<100-199>|<2000-2699>) (deny|permit) ip host A.B.C.D A.B.C.D A.B.C.D", + "no access-list <(100-199)|(2000-2699)> <deny|permit> ip host A.B.C.D A.B.C.D A.B.C.D", NO_STR "Add an access list entry\n" "IP extended access list\n" @@ -1097,14 +1178,19 @@ DEFUN (no_access_list_extended_host_mask, "Destination address\n" "Destination Wildcard bits\n") { - return filter_set_cisco (vty, argv[0], argv[1], argv[2], - "0.0.0.0", argv[3], - argv[4], 1, 0); + int idx_acl = 2; + int idx_permit_deny = 3; + int idx_ipv4 = 6; + int idx_ipv4_2 = 7; + int idx_ipv4_3 = 8; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, + "0.0.0.0", argv[idx_ipv4_2]->arg, + argv[idx_ipv4_3]->arg, 1, 0); } DEFUN (no_access_list_extended_host_host, no_access_list_extended_host_host_cmd, - "no access-list (<100-199>|<2000-2699>) (deny|permit) ip host A.B.C.D host A.B.C.D", + "no access-list <(100-199)|(2000-2699)> <deny|permit> ip host A.B.C.D host A.B.C.D", NO_STR "Add an access list entry\n" "IP extended access list\n" @@ -1117,14 +1203,18 @@ DEFUN (no_access_list_extended_host_host, "A single destination host\n" "Destination address\n") { - return filter_set_cisco (vty, argv[0], argv[1], argv[2], - "0.0.0.0", argv[3], + int idx_acl = 2; + int idx_permit_deny = 3; + int idx_ipv4 = 6; + int idx_ipv4_2 = 8; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, + "0.0.0.0", argv[idx_ipv4_2]->arg, "0.0.0.0", 1, 0); } DEFUN (no_access_list_extended_any_host, no_access_list_extended_any_host_cmd, - "no access-list (<100-199>|<2000-2699>) (deny|permit) ip any host A.B.C.D", + "no access-list <(100-199)|(2000-2699)> <deny|permit> ip any host A.B.C.D", NO_STR "Add an access list entry\n" "IP extended access list\n" @@ -1136,14 +1226,17 @@ DEFUN (no_access_list_extended_any_host, "A single destination host\n" "Destination address\n") { - return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0", - "255.255.255.255", argv[2], + int idx_acl = 2; + int idx_permit_deny = 3; + int idx_ipv4 = 7; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, "0.0.0.0", + "255.255.255.255", argv[idx_ipv4]->arg, "0.0.0.0", 1, 0); } DEFUN (no_access_list_extended_host_any, no_access_list_extended_host_any_cmd, - "no access-list (<100-199>|<2000-2699>) (deny|permit) ip host A.B.C.D any", + "no access-list <(100-199)|(2000-2699)> <deny|permit> ip host A.B.C.D any", NO_STR "Add an access list entry\n" "IP extended access list\n" @@ -1155,7 +1248,10 @@ DEFUN (no_access_list_extended_host_any, "Source address\n" "Any destination host\n") { - return filter_set_cisco (vty, argv[0], argv[1], argv[2], + int idx_acl = 2; + int idx_permit_deny = 3; + int idx_ipv4 = 6; + return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, "0.0.0.0", "0.0.0.0", "255.255.255.255", 1, 0); } @@ -1244,19 +1340,22 @@ filter_set_zebra (struct vty *vty, const char *name_str, const char *type_str, /* Zebra access-list */ DEFUN (access_list, access_list_cmd, - "access-list WORD (deny|permit) A.B.C.D/M", + "access-list WORD <deny|permit> A.B.C.D/M", "Add an access list entry\n" "IP zebra access-list name\n" "Specify packets to reject\n" "Specify packets to forward\n" "Prefix to match. e.g. 10.0.0.0/8\n") { - return filter_set_zebra (vty, argv[0], argv[1], AFI_IP, argv[2], 0, 1); + int idx_word = 1; + int idx_permit_deny = 2; + int idx_ipv4_prefixlen = 3; + return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP, argv[idx_ipv4_prefixlen]->arg, 0, 1); } DEFUN (access_list_exact, access_list_exact_cmd, - "access-list WORD (deny|permit) A.B.C.D/M exact-match", + "access-list WORD <deny|permit> A.B.C.D/M exact-match", "Add an access list entry\n" "IP zebra access-list name\n" "Specify packets to reject\n" @@ -1264,24 +1363,29 @@ DEFUN (access_list_exact, "Prefix to match. e.g. 10.0.0.0/8\n" "Exact match of the prefixes\n") { - return filter_set_zebra (vty, argv[0], argv[1], AFI_IP, argv[2], 1, 1); + int idx_word = 1; + int idx_permit_deny = 2; + int idx_ipv4_prefixlen = 3; + return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP, argv[idx_ipv4_prefixlen]->arg, 1, 1); } DEFUN (access_list_any, access_list_any_cmd, - "access-list WORD (deny|permit) any", + "access-list WORD <deny|permit> any", "Add an access list entry\n" "IP zebra access-list name\n" "Specify packets to reject\n" "Specify packets to forward\n" "Prefix to match. e.g. 10.0.0.0/8\n") { - return filter_set_zebra (vty, argv[0], argv[1], AFI_IP, "0.0.0.0/0", 0, 1); + int idx_word = 1; + int idx_permit_deny = 2; + return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP, "0.0.0.0/0", 0, 1); } DEFUN (no_access_list, no_access_list_cmd, - "no access-list WORD (deny|permit) A.B.C.D/M", + "no access-list WORD <deny|permit> A.B.C.D/M", NO_STR "Add an access list entry\n" "IP zebra access-list name\n" @@ -1289,12 +1393,15 @@ DEFUN (no_access_list, "Specify packets to forward\n" "Prefix to match. e.g. 10.0.0.0/8\n") { - return filter_set_zebra (vty, argv[0], argv[1], AFI_IP, argv[2], 0, 0); + int idx_word = 2; + int idx_permit_deny = 3; + int idx_ipv4_prefixlen = 4; + return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP, argv[idx_ipv4_prefixlen]->arg, 0, 0); } DEFUN (no_access_list_exact, no_access_list_exact_cmd, - "no access-list WORD (deny|permit) A.B.C.D/M exact-match", + "no access-list WORD <deny|permit> A.B.C.D/M exact-match", NO_STR "Add an access list entry\n" "IP zebra access-list name\n" @@ -1303,12 +1410,15 @@ DEFUN (no_access_list_exact, "Prefix to match. e.g. 10.0.0.0/8\n" "Exact match of the prefixes\n") { - return filter_set_zebra (vty, argv[0], argv[1], AFI_IP, argv[2], 1, 0); + int idx_word = 2; + int idx_permit_deny = 3; + int idx_ipv4_prefixlen = 4; + return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP, argv[idx_ipv4_prefixlen]->arg, 1, 0); } DEFUN (no_access_list_any, no_access_list_any_cmd, - "no access-list WORD (deny|permit) any", + "no access-list WORD <deny|permit> any", NO_STR "Add an access list entry\n" "IP zebra access-list name\n" @@ -1316,12 +1426,14 @@ DEFUN (no_access_list_any, "Specify packets to forward\n" "Prefix to match. e.g. 10.0.0.0/8\n") { - return filter_set_zebra (vty, argv[0], argv[1], AFI_IP, "0.0.0.0/0", 0, 0); + int idx_word = 2; + int idx_permit_deny = 3; + return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP, "0.0.0.0/0", 0, 0); } DEFUN (no_access_list_all, no_access_list_all_cmd, - "no access-list (<1-99>|<100-199>|<1300-1999>|<2000-2699>|WORD)", + "no access-list <(1-99)|(100-199)|(1300-1999)|(2000-2699)|WORD>", NO_STR "Add an access list entry\n" "IP standard access list\n" @@ -1330,14 +1442,15 @@ DEFUN (no_access_list_all, "IP extended access list (expanded range)\n" "IP zebra access-list name\n") { + int idx_acl = 2; struct access_list *access; struct access_master *master; /* Looking up access_list. */ - access = access_list_lookup (AFI_IP, argv[0]); + access = access_list_lookup (AFI_IP, argv[idx_acl]->arg); if (access == NULL) { - vty_out (vty, "%% access-list %s doesn't exist%s", argv[0], + vty_out (vty, "%% access-list %s doesn't exist%s", argv[idx_acl]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -1357,7 +1470,7 @@ DEFUN (no_access_list_all, DEFUN (access_list_remark, access_list_remark_cmd, - "access-list (<1-99>|<100-199>|<1300-1999>|<2000-2699>|WORD) remark .LINE", + "access-list <(1-99)|(100-199)|(1300-1999)|(2000-2699)|WORD> remark LINE...", "Add an access list entry\n" "IP standard access list\n" "IP extended access list\n" @@ -1367,23 +1480,25 @@ DEFUN (access_list_remark, "Access list entry comment\n" "Comment up to 100 characters\n") { + int idx_acl = 1; + int idx_remark = 3; struct access_list *access; - access = access_list_get (AFI_IP, argv[0]); + access = access_list_get (AFI_IP, argv[idx_acl]->arg); if (access->remark) { XFREE (MTYPE_TMP, access->remark); access->remark = NULL; } - access->remark = argv_concat(argv, argc, 1); + access->remark = argv_concat(argv, argc, idx_remark); return CMD_SUCCESS; } DEFUN (no_access_list_remark, no_access_list_remark_cmd, - "no access-list (<1-99>|<100-199>|<1300-1999>|<2000-2699>|WORD) remark", + "no access-list <(1-99)|(100-199)|(1300-1999)|(2000-2699)|WORD> remark", NO_STR "Add an access list entry\n" "IP standard access list\n" @@ -1393,12 +1508,14 @@ DEFUN (no_access_list_remark, "IP zebra access-list\n" "Access list entry comment\n") { - return vty_access_list_remark_unset (vty, AFI_IP, argv[0]); + int idx_acl = 2; + return vty_access_list_remark_unset (vty, AFI_IP, argv[idx_acl]->arg); } - -ALIAS (no_access_list_remark, - no_access_list_remark_arg_cmd, - "no access-list (<1-99>|<100-199>|<1300-1999>|<2000-2699>|WORD) remark .LINE", + +/* ALIAS_FIXME */ +DEFUN (no_access_list_remark_comment, + no_access_list_remark_comment_cmd, + "no access-list <(1-99)|(100-199)|(1300-1999)|(2000-2699)|WORD> remark LINE...", NO_STR "Add an access list entry\n" "IP standard access list\n" @@ -1408,11 +1525,15 @@ ALIAS (no_access_list_remark, "IP zebra access-list\n" "Access list entry comment\n" "Comment up to 100 characters\n") +{ + return no_access_list_remark (self, vty, argc, argv); +} + #ifdef HAVE_IPV6 DEFUN (ipv6_access_list, ipv6_access_list_cmd, - "ipv6 access-list WORD (deny|permit) X:X::X:X/M", + "ipv6 access-list WORD <deny|permit> X:X::X:X/M", IPV6_STR "Add an access list entry\n" "IPv6 zebra access-list\n" @@ -1420,12 +1541,15 @@ DEFUN (ipv6_access_list, "Specify packets to forward\n" "Prefix to match. e.g. 3ffe:506::/32\n") { - return filter_set_zebra (vty, argv[0], argv[1], AFI_IP6, argv[2], 0, 1); + int idx_word = 2; + int idx_permit_deny = 3; + int idx_ipv6_prefixlen = 4; + return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP6, argv[idx_ipv6_prefixlen]->arg, 0, 1); } DEFUN (ipv6_access_list_exact, ipv6_access_list_exact_cmd, - "ipv6 access-list WORD (deny|permit) X:X::X:X/M exact-match", + "ipv6 access-list WORD <deny|permit> X:X::X:X/M exact-match", IPV6_STR "Add an access list entry\n" "IPv6 zebra access-list\n" @@ -1434,12 +1558,15 @@ DEFUN (ipv6_access_list_exact, "Prefix to match. e.g. 3ffe:506::/32\n" "Exact match of the prefixes\n") { - return filter_set_zebra (vty, argv[0], argv[1], AFI_IP6, argv[2], 1, 1); + int idx_word = 2; + int idx_permit_deny = 3; + int idx_ipv6_prefixlen = 4; + return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP6, argv[idx_ipv6_prefixlen]->arg, 1, 1); } DEFUN (ipv6_access_list_any, ipv6_access_list_any_cmd, - "ipv6 access-list WORD (deny|permit) any", + "ipv6 access-list WORD <deny|permit> any", IPV6_STR "Add an access list entry\n" "IPv6 zebra access-list\n" @@ -1447,12 +1574,14 @@ DEFUN (ipv6_access_list_any, "Specify packets to forward\n" "Any prefixi to match\n") { - return filter_set_zebra (vty, argv[0], argv[1], AFI_IP6, "::/0", 0, 1); + int idx_word = 2; + int idx_permit_deny = 3; + return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP6, "::/0", 0, 1); } DEFUN (no_ipv6_access_list, no_ipv6_access_list_cmd, - "no ipv6 access-list WORD (deny|permit) X:X::X:X/M", + "no ipv6 access-list WORD <deny|permit> X:X::X:X/M", NO_STR IPV6_STR "Add an access list entry\n" @@ -1461,12 +1590,15 @@ DEFUN (no_ipv6_access_list, "Specify packets to forward\n" "Prefix to match. e.g. 3ffe:506::/32\n") { - return filter_set_zebra (vty, argv[0], argv[1], AFI_IP6, argv[2], 0, 0); + int idx_word = 3; + int idx_permit_deny = 4; + int idx_ipv6_prefixlen = 5; + return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP6, argv[idx_ipv6_prefixlen]->arg, 0, 0); } DEFUN (no_ipv6_access_list_exact, no_ipv6_access_list_exact_cmd, - "no ipv6 access-list WORD (deny|permit) X:X::X:X/M exact-match", + "no ipv6 access-list WORD <deny|permit> X:X::X:X/M exact-match", NO_STR IPV6_STR "Add an access list entry\n" @@ -1476,12 +1608,15 @@ DEFUN (no_ipv6_access_list_exact, "Prefix to match. e.g. 3ffe:506::/32\n" "Exact match of the prefixes\n") { - return filter_set_zebra (vty, argv[0], argv[1], AFI_IP6, argv[2], 1, 0); + int idx_word = 3; + int idx_permit_deny = 4; + int idx_ipv6_prefixlen = 5; + return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP6, argv[idx_ipv6_prefixlen]->arg, 1, 0); } DEFUN (no_ipv6_access_list_any, no_ipv6_access_list_any_cmd, - "no ipv6 access-list WORD (deny|permit) any", + "no ipv6 access-list WORD <deny|permit> any", NO_STR IPV6_STR "Add an access list entry\n" @@ -1490,7 +1625,9 @@ DEFUN (no_ipv6_access_list_any, "Specify packets to forward\n" "Any prefixi to match\n") { - return filter_set_zebra (vty, argv[0], argv[1], AFI_IP6, "::/0", 0, 0); + int idx_word = 3; + int idx_permit_deny = 4; + return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP6, "::/0", 0, 0); } @@ -1502,14 +1639,15 @@ DEFUN (no_ipv6_access_list_all, "Add an access list entry\n" "IPv6 zebra access-list\n") { + int idx_word = 3; struct access_list *access; struct access_master *master; /* Looking up access_list. */ - access = access_list_lookup (AFI_IP6, argv[0]); + access = access_list_lookup (AFI_IP6, argv[idx_word]->arg); if (access == NULL) { - vty_out (vty, "%% access-list %s doesn't exist%s", argv[0], + vty_out (vty, "%% access-list %s doesn't exist%s", argv[idx_word]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -1529,23 +1667,25 @@ DEFUN (no_ipv6_access_list_all, DEFUN (ipv6_access_list_remark, ipv6_access_list_remark_cmd, - "ipv6 access-list WORD remark .LINE", + "ipv6 access-list WORD remark LINE...", IPV6_STR "Add an access list entry\n" "IPv6 zebra access-list\n" "Access list entry comment\n" "Comment up to 100 characters\n") { + int idx_word = 2; + int idx_line = 4; struct access_list *access; - access = access_list_get (AFI_IP6, argv[0]); + access = access_list_get (AFI_IP6, argv[idx_word]->arg); if (access->remark) { XFREE (MTYPE_TMP, access->remark); access->remark = NULL; } - access->remark = argv_concat(argv, argc, 1); + access->remark = argv_concat(argv, argc, idx_line); return CMD_SUCCESS; } @@ -1559,18 +1699,24 @@ DEFUN (no_ipv6_access_list_remark, "IPv6 zebra access-list\n" "Access list entry comment\n") { - return vty_access_list_remark_unset (vty, AFI_IP6, argv[0]); + int idx_word = 3; + return vty_access_list_remark_unset (vty, AFI_IP6, argv[idx_word]->arg); } - -ALIAS (no_ipv6_access_list_remark, - no_ipv6_access_list_remark_arg_cmd, - "no ipv6 access-list WORD remark .LINE", + +/* ALIAS_FIXME */ +DEFUN (no_ipv6_access_list_remark_comment, + no_ipv6_access_list_remark_comment_cmd, + "no ipv6 access-list WORD remark LINE...", NO_STR IPV6_STR "Add an access list entry\n" "IPv6 zebra access-list\n" "Access list entry comment\n" "Comment up to 100 characters\n") +{ + return no_ipv6_access_list_remark (self, vty, argc, argv); +} + #endif /* HAVE_IPV6 */ void config_write_access_zebra (struct vty *, struct filter *); @@ -1695,7 +1841,7 @@ DEFUN (show_ip_access_list, DEFUN (show_ip_access_list_name, show_ip_access_list_name_cmd, - "show ip access-list (<1-99>|<100-199>|<1300-1999>|<2000-2699>|WORD)", + "show ip access-list <(1-99)|(100-199)|(1300-1999)|(2000-2699)|WORD>", SHOW_STR IP_STR "List IP access lists\n" @@ -1705,7 +1851,8 @@ DEFUN (show_ip_access_list_name, "IP extended access list (expanded range)\n" "IP zebra access-list\n") { - return filter_show (vty, argv[0], AFI_IP); + int idx_acl = 3; + return filter_show (vty, argv[idx_acl]->arg, AFI_IP); } #ifdef HAVE_IPV6 @@ -1727,7 +1874,8 @@ DEFUN (show_ipv6_access_list_name, "List IPv6 access lists\n" "IPv6 zebra access-list\n") { - return filter_show (vty, argv[0], AFI_IP6); + int idx_word = 3; + return filter_show (vty, argv[idx_word]->arg, AFI_IP6); } #endif /* HAVE_IPV6 */ @@ -1958,7 +2106,7 @@ access_list_init_ipv4 (void) install_element (CONFIG_NODE, &access_list_remark_cmd); install_element (CONFIG_NODE, &no_access_list_all_cmd); install_element (CONFIG_NODE, &no_access_list_remark_cmd); - install_element (CONFIG_NODE, &no_access_list_remark_arg_cmd); + install_element (CONFIG_NODE, &no_access_list_remark_comment_cmd); } #ifdef HAVE_IPV6 @@ -2022,7 +2170,7 @@ access_list_init_ipv6 (void) install_element (CONFIG_NODE, &no_ipv6_access_list_all_cmd); install_element (CONFIG_NODE, &ipv6_access_list_remark_cmd); install_element (CONFIG_NODE, &no_ipv6_access_list_remark_cmd); - install_element (CONFIG_NODE, &no_ipv6_access_list_remark_arg_cmd); + install_element (CONFIG_NODE, &no_ipv6_access_list_remark_comment_cmd); } #endif /* HAVE_IPV6 */ diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c new file mode 100644 index 0000000000..c4ae2d7d77 --- /dev/null +++ b/lib/grammar_sandbox.c @@ -0,0 +1,386 @@ +/* + * Testing shim and API examples for the new CLI backend. + * + * This unit defines a number of commands in the old engine that can + * be used to test and interact with the new engine. + * + * This shim should be removed upon integration. It is currently hooked in + * vtysh/vtysh.c. It has no header, vtysh.c merely includes this entire unit + * since it clutters up the makefiles less and this is only a temporary shim. + * + * -- + * Copyright (C) 2016 Cumulus Networks, Inc. + * + * This file is part of GNU Zebra. + * + * GNU Zebra is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * GNU Zebra is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Zebra; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include "command.h" +#include "graph.h" +#include "command_parse.h" +#include "command_match.h" + +#define GRAMMAR_STR "CLI grammar sandbox\n" + +/** headers **/ +void +grammar_sandbox_init (void); +void +pretty_print_graph (struct graph_node *, int); +void +init_cmdgraph (struct graph **); +vector +completions_to_vec (struct list *); +int +compare_completions (const void *, const void *); + +/** shim interface commands **/ +struct graph *nodegraph; + +DEFUN (grammar_test, + grammar_test_cmd, + "grammar parse .COMMAND", + GRAMMAR_STR + "command to pass to new parser\n") +{ + int idx_command = 2; + // make a string from tokenized command line + char *command = argv_concat (argv, argc, idx_command); + + // create cmd_element for parser + struct cmd_element *cmd = XCALLOC (MTYPE_CMD_TOKENS, sizeof (struct cmd_element)); + cmd->string = command; + cmd->doc = NULL; + cmd->func = NULL; + cmd->tokens = vector_init (VECTOR_MIN_SIZE); + + // parse the command and install it into the command graph + command_parse_format (nodegraph, cmd); + + return CMD_SUCCESS; +} + +DEFUN (grammar_test_complete, + grammar_test_complete_cmd, + "grammar complete .COMMAND", + GRAMMAR_STR + "attempt to complete input on DFA\n" + "command to complete") +{ + int idx_command = 2; + char *cmdstr = argv_concat (argv, argc, idx_command); + vector command = cmd_make_strvec (cmdstr); + + // generate completions of user input + struct list *completions; + enum matcher_rv result = command_complete (nodegraph, command, &completions); + + // print completions or relevant error message + if (!MATCHER_ERROR(result)) + { + vector comps = completions_to_vec (completions); + struct cmd_token_t *tkn; + + // calculate length of longest tkn->text in completions + unsigned int width = 0, i = 0; + for (i = 0; i < vector_active (comps); i++) { + tkn = vector_slot (comps, i); + unsigned int len = strlen (tkn->text); + width = len > width ? len : width; + } + + // print completions + for (i = 0; i < vector_active (comps); i++) { + tkn = vector_slot (comps, i); + fprintf (stdout, " %-*s %s%s", width, tkn->text, tkn->desc, "\n"); + } + + for (i = 0; i < vector_active (comps); i++) + del_cmd_token ((struct cmd_token_t *) vector_slot (comps, i)); + vector_free (comps); + } + else + fprintf (stdout, "%% No match%s", "\n"); + + // free resources + list_delete (completions); + cmd_free_strvec (command); + free (cmdstr); + + return CMD_SUCCESS; +} + +DEFUN (grammar_test_match, + grammar_test_match_cmd, + "grammar match .COMMAND", + GRAMMAR_STR + "attempt to match input on DFA\n" + "command to match") +{ + int idx_command = 2; + if (argv[0][0] == '#') + return CMD_SUCCESS; + + char *cmdstr = argv_concat(argv, argc, idx_command); + vector command = cmd_make_strvec (cmdstr); + + struct list *argvv = NULL; + struct cmd_element *element = NULL; + enum matcher_rv result = command_match (nodegraph, command, &argvv, &element); + + // print completions or relevant error message + if (element) + { + fprintf (stdout, "Matched: %s%s", element->string, "\n"); + struct listnode *ln; + struct cmd_token_t *token; + for (ALL_LIST_ELEMENTS_RO(argvv,ln,token)) + fprintf (stdout, "%s -- %s%s", token->text, token->arg, "\n"); + + fprintf (stdout, "func: %p%s", element->func, "\n"); + + list_delete (argvv); + del_cmd_element (element); + } + else { + assert(MATCHER_ERROR(result)); + switch (result) { + case MATCHER_NO_MATCH: + fprintf (stdout, "%% Unknown command%s", "\n"); + break; + case MATCHER_INCOMPLETE: + fprintf (stdout, "%% Incomplete command%s", "\n"); + break; + case MATCHER_AMBIGUOUS: + fprintf (stdout, "%% Ambiguous command%s", "\n"); + break; + default: + fprintf (stdout, "%% Unknown error%s", "\n"); + break; + } + } + + // free resources + cmd_free_strvec (command); + free (cmdstr); + + return CMD_SUCCESS; +} + +/** + * Testing shim to test docstrings + */ +DEFUN (grammar_test_doc, + grammar_test_doc_cmd, + "grammar test docstring", + GRAMMAR_STR + "Test function for docstring\n" + "Command end\n") +{ + // create cmd_element with docstring + struct cmd_element *cmd = XCALLOC (MTYPE_CMD_TOKENS, sizeof (struct cmd_element)); + cmd->string = XSTRDUP (MTYPE_CMD_TOKENS, "test docstring <example|selector follow> (1-255) end VARIABLE [OPTION|set lol] . VARARG"); + cmd->doc = XSTRDUP (MTYPE_CMD_TOKENS, + "Test stuff\n" + "docstring thing\n" + "first example\n" + "second example\n" + "follow\n" + "random range\n" + "end thingy\n" + "variable\n" + "optional variable\n" + "optional set\n" + "optional lol\n" + "vararg!\n"); + cmd->func = NULL; + cmd->tokens = vector_init (VECTOR_MIN_SIZE); + + // parse element + command_parse_format (nodegraph, cmd); + + return CMD_SUCCESS; +} + +/** + * Debugging command to print command graph + */ +DEFUN (grammar_test_show, + grammar_test_show_cmd, + "grammar show graph", + GRAMMAR_STR + "print current accumulated DFA\n") +{ + if (!nodegraph) + zlog_info("nodegraph uninitialized"); + else + pretty_print_graph (vector_slot (nodegraph->nodes, 0), 0); + return CMD_SUCCESS; +} + +DEFUN (grammar_init_graph, + grammar_init_graph_cmd, + "grammar init graph", + GRAMMAR_STR + "(re)initialize graph\n") +{ + graph_delete_graph (nodegraph); + init_cmdgraph (&nodegraph); + return CMD_SUCCESS; +} + +/* this is called in vtysh.c to set up the testing shim */ +void grammar_sandbox_init() { + init_cmdgraph (&nodegraph); + + // install all enable elements + install_element (ENABLE_NODE, &grammar_test_cmd); + install_element (ENABLE_NODE, &grammar_test_show_cmd); + install_element (ENABLE_NODE, &grammar_test_match_cmd); + install_element (ENABLE_NODE, &grammar_test_complete_cmd); + install_element (ENABLE_NODE, &grammar_test_doc_cmd); + install_element (ENABLE_NODE, &grammar_init_graph_cmd); +} + + +/** + * Pretty-prints a graph, assuming it is a tree. + * + * @param start the node to take as the root + * @param level indent level for recursive calls, always pass 0 + */ +void +pretty_print_graph (struct graph_node *start, int level) +{ + // print this node + struct cmd_token_t *tok = start->data; + fprintf (stdout, "%s[%d] ", tok->text, tok->type); + + int numto = vector_active (start->to); + if (numto) + { + if (numto > 1) + fprintf (stdout, "\n"); + for (unsigned int i = 0; i < vector_active (start->to); i++) + { + struct graph_node *adj = vector_slot (start->to, i); + // if we're listing multiple children, indent! + if (numto > 1) + for (int j = 0; j < level+1; j++) + fprintf (stdout, " "); + // if this node is a vararg, just print * + if (adj == start) + fprintf (stdout, "*"); + else + pretty_print_graph (adj, numto > 1 ? level+1 : level); + } + } + else + fprintf(stdout, "\n"); +} + +/** stuff that should go in command.c + command.h */ +void +init_cmdgraph (struct graph **graph) +{ + // initialize graph, add start noe + *graph = graph_new (); + struct cmd_token_t *token = new_cmd_token (START_TKN, NULL, NULL); + graph_new_node (*graph, token, (void (*)(void *)) &del_cmd_token); + fprintf (stdout, "initialized graph\n"); +} + +int +compare_completions (const void *fst, const void *snd) +{ + struct cmd_token_t *first = *(struct cmd_token_t **) fst, + *secnd = *(struct cmd_token_t **) snd; + return strcmp (first->text, secnd->text); +} + +vector +completions_to_vec (struct list *completions) +{ + vector comps = vector_init (VECTOR_MIN_SIZE); + + struct listnode *ln; + struct cmd_token_t *token; + unsigned int i, exists; + for (ALL_LIST_ELEMENTS_RO(completions,ln,token)) + { + // linear search for token in completions vector + exists = 0; + for (i = 0; i < vector_active (comps) && !exists; i++) + { + struct cmd_token_t *curr = vector_slot (comps, i); + exists = !strcmp (curr->text, token->text) && + !strcmp (curr->desc, token->desc); + } + + if (!exists) + vector_set (comps, copy_cmd_token (token)); + } + + // sort completions + qsort (comps->index, + vector_active (comps), + sizeof (void *), + &compare_completions); + + return comps; +} + +struct cmd_token_t * +new_cmd_token (enum cmd_token_type_t type, char *text, char *desc) +{ + struct cmd_token_t *token = XMALLOC (MTYPE_CMD_TOKENS, sizeof (struct cmd_token_t)); + token->type = type; + token->text = text; + token->desc = desc; + token->arg = NULL; + + return token; +} + +void +del_cmd_token (struct cmd_token_t *token) +{ + if (!token) return; + + if (token->text) + XFREE (MTYPE_CMD_TOKENS, token->text); + if (token->desc) + XFREE (MTYPE_CMD_TOKENS, token->desc); + if (token->arg) + XFREE (MTYPE_CMD_TOKENS, token->arg); + + XFREE (MTYPE_CMD_TOKENS, token); +} + +struct cmd_token_t * +copy_cmd_token (struct cmd_token_t *token) +{ + struct cmd_token_t *copy = new_cmd_token (token->type, NULL, NULL); + copy->value = token->value; + copy->max = token->max; + copy->min = token->min; + copy->text = token->text ? XSTRDUP (MTYPE_CMD_TOKENS, token->text) : NULL; + copy->desc = token->desc ? XSTRDUP (MTYPE_CMD_TOKENS, token->desc) : NULL; + copy->arg = token->arg ? XSTRDUP (MTYPE_CMD_TOKENS, token->arg) : NULL; + + return copy; +} diff --git a/lib/grammar_sandbox.h b/lib/grammar_sandbox.h new file mode 100644 index 0000000000..6e61ce1b46 --- /dev/null +++ b/lib/grammar_sandbox.h @@ -0,0 +1,65 @@ +#ifndef _GRAMMAR_SANDBOX_H +#define _GRAMMAR_SANDBOX_H + +/** + * Houses functionality for testing shim as well as code that should go into + * command.h and command.c during integration. + */ +#include "memory.h" + +#define CMD_CR_TEXT "<cr>" + +void +grammar_sandbox_init (void); + +/** + * Types for tokens. + * + * The type determines what kind of data the token can match (in the + * matching use case) or hold (in the argv use case). + */ +enum cmd_token_type_t +{ + WORD_TKN, // words + NUMBER_TKN, // integral numbers + VARIABLE_TKN, // almost anything + RANGE_TKN, // integer range + IPV4_TKN, // IPV4 addresses + IPV4_PREFIX_TKN, // IPV4 network prefixes + IPV6_TKN, // IPV6 prefixes + IPV6_PREFIX_TKN, // IPV6 network prefixes + + /* plumbing types */ + SELECTOR_TKN, // marks beginning of selector + OPTION_TKN, // marks beginning of option + NUL_TKN, // dummy token + START_TKN, // first token in line + END_TKN, // last token in line +}; + +/** + * Token struct. + */ +struct cmd_token_t +{ + enum cmd_token_type_t type; // token type + + char *text; // token text + char *desc; // token description + + long long value; // for numeric types + long long min, max; // for ranges + + char *arg; // user input that matches this token +}; + +struct cmd_token_t * +new_cmd_token (enum cmd_token_type_t, char *, char *); + +void +del_cmd_token (struct cmd_token_t *); + +struct cmd_token_t * +copy_cmd_token (struct cmd_token_t *); + +#endif /* _GRAMMAR_SANDBOX_H */ diff --git a/lib/graph.c b/lib/graph.c new file mode 100644 index 0000000000..891ecc33c0 --- /dev/null +++ b/lib/graph.c @@ -0,0 +1,138 @@ +/* + * Graph data structure. + * + * -- + * Copyright (C) 2016 Cumulus Networks, Inc. + * + * This file is part of GNU Zebra. + * + * GNU Zebra is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * GNU Zebra is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Zebra; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ +#include <zebra.h> +#include "graph.h" +#include "memory.h" + +DEFINE_MTYPE_STATIC(LIB, GRAPH, "Graph") +DEFINE_MTYPE_STATIC(LIB, GRAPH_NODE, "Graph Node") +struct graph * +graph_new () +{ + struct graph *graph = XCALLOC (MTYPE_GRAPH, sizeof(struct graph)); + graph->nodes = vector_init (VECTOR_MIN_SIZE); + + return graph; +} + +struct graph_node * +graph_new_node (struct graph *graph, void *data, void (*del) (void*)) +{ + struct graph_node *node = + XCALLOC(MTYPE_GRAPH_NODE, sizeof(struct graph_node)); + + node->from = vector_init (VECTOR_MIN_SIZE); + node->to = vector_init (VECTOR_MIN_SIZE); + node->data = data; + node->del = del; + + vector_set (graph->nodes, node); + + return node; +} + +static void +vector_remove (vector v, unsigned int ix) +{ + vector_unset (v, ix); + if (ix == vector_active (v)) return; + for (; ix < vector_active (v) - 1; ix++) + v->index[ix] = v->index[ix+1]; + v->active--; +} + +void +graph_delete_node (struct graph *graph, struct graph_node *node) +{ + if (!node) return; + + // an adjacent node + struct graph_node *adj; + + // remove all edges from other nodes to us + vector edges = vector_copy (node->from); + for (unsigned int i = 0; i < vector_active (edges); i++) + { + adj = vector_slot (edges, i); + graph_remove_edge (adj, node); + } + vector_free (edges); + + // remove all edges from us to other nodes + edges = vector_copy (node->to); + for (unsigned int i = 0; i < vector_active (edges); i++) + { + adj = vector_slot (edges, i); + graph_remove_edge (node, adj); + } + vector_free (edges); + + // if there is a deletion callback, call it + if (node->del && node->data) + (*node->del) (node->data); + + // free adjacency lists + vector_free (node->to); + vector_free (node->from); + + // remove node from graph->nodes + for (unsigned int i = 0; i < vector_active (graph->nodes); i++) + if (vector_slot (graph->nodes, i) == node) + vector_remove (graph->nodes, i); + + // free the node itself + XFREE (MTYPE_GRAPH_NODE, node); +} + +struct graph_node * +graph_add_edge (struct graph_node *from, struct graph_node *to) +{ + vector_set (from->to, to); + vector_set (to->from, from); + return to; +} + +void +graph_remove_edge (struct graph_node *from, struct graph_node *to) +{ + // remove from from to->from + for (unsigned int i = 0; i < vector_active (to->from); i++) + if (vector_slot (to->from, i) == from) + vector_remove (to->from, i); + // remove to from from->to + for (unsigned int i = 0; i < vector_active (from->to); i++) + if (vector_slot (from->to, i) == to) + vector_remove (from->to, i); +} + +void +graph_delete_graph (struct graph *graph) +{ + // delete each node in the graph + for (unsigned int i = 0; i < vector_active (graph->nodes); i++) + graph_delete_node (graph, vector_slot (graph->nodes, i)); + + vector_free (graph->nodes); + XFREE (MTYPE_GRAPH, graph); +} diff --git a/lib/graph.h b/lib/graph.h new file mode 100644 index 0000000000..8d8aa3823b --- /dev/null +++ b/lib/graph.h @@ -0,0 +1,101 @@ +/* + * Graph data structure. + * + * -- + * Copyright (C) 2016 Cumulus Networks, Inc. + * + * This file is part of GNU Zebra. + * + * GNU Zebra is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * GNU Zebra is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Zebra; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef _ZEBRA_COMMAND_GRAPH_H +#define _ZEBRA_COMMAND_GRAPH_H + +#include "vector.h" + +struct graph +{ + vector nodes; +}; + +struct graph_node +{ + vector from; // nodes which have edges to this node + vector to; // nodes which this node has edges to + + void *data; // node data + void (*del) (void *data); // deletion callback +}; + +struct graph * +graph_new (void); + +/** + * Creates a new node. + * + * @struct graph the graph this node exists in + * @param[in] data this node's data + * @param[in] del data deletion callback + * @return the new node + */ +struct graph_node * +graph_new_node (struct graph *graph, void *data, void (*del) (void*)); + +/** + * Deletes a node. + * + * Before deletion, this function removes all edges to and from this node from + * any neighbor nodes. + * + * If *data and *del are non-null, the following call is made: + * (*node->del) (node->data); + * + * @param[in] graph the graph this node belongs to + * @param[out] node pointer to node to delete + */ +void +graph_delete_node (struct graph *graph, struct graph_node *node); + +/** + * Makes a directed edge between two nodes. + * + * @param[in] from + * @param[in] to + * @return to + */ +struct graph_node * +graph_add_edge (struct graph_node *from, struct graph_node *to); + +/** + * Removes a directed edge between two nodes. + * + * @param[in] from + * @param[in] to + */ +void +graph_remove_edge (struct graph_node *from, struct graph_node *to); + +/** + * Deletes a graph. + * Calls graph_delete_node on each node before freeing the graph struct itself. + * + * @param graph the graph to delete + */ +void +graph_delete_graph (struct graph *graph); + +#endif /* _ZEBRA_COMMAND_GRAPH_H */ @@ -677,25 +677,23 @@ if_dump_all (void) if_dump (p); } -DEFUN (interface_desc, +DEFUN (interface_desc, interface_desc_cmd, - "description .LINE", + "description LINE...", "Interface specific description\n" "Characters describing this interface\n") { + int idx_line = 1; VTY_DECLVAR_CONTEXT (interface, ifp); - if (argc == 0) - return CMD_SUCCESS; - if (ifp->desc) XFREE (MTYPE_TMP, ifp->desc); - ifp->desc = argv_concat(argv, argc, 0); + ifp->desc = argv_concat(argv, argc, idx_line); return CMD_SUCCESS; } -DEFUN (no_interface_desc, +DEFUN (no_interface_desc, no_interface_desc_cmd, "no description", NO_STR @@ -754,36 +752,42 @@ if_sunwzebra_get (const char *name, size_t nlen, vrf_id_t vrf_id) DEFUN (interface, interface_cmd, - "interface IFNAME", + "interface IFNAME [vrf NAME]", "Select an interface to configure\n" - "Interface's name\n") + "Interface's name\n" + VRF_CMD_HELP_STR) { + int idx_ifname = 1; + int idx_vrf = 3; + const char *ifname = argv[idx_ifname]->arg; + const char *vrfname = (argc > 2) ? argv[idx_vrf]->arg : NULL; + struct interface *ifp; size_t sl; vrf_id_t vrf_id = VRF_DEFAULT; - if ((sl = strlen(argv[0])) > INTERFACE_NAMSIZ) + if ((sl = strlen(ifname)) > INTERFACE_NAMSIZ) { vty_out (vty, "%% Interface name %s is invalid: length exceeds " "%d characters%s", - argv[0], INTERFACE_NAMSIZ, VTY_NEWLINE); + ifname, INTERFACE_NAMSIZ, VTY_NEWLINE); return CMD_WARNING; } /*Pending: need proper vrf name based lookup/(possible creation of VRF) Imagine forward reference of a vrf by name in this interface config */ - if (argc > 1) - VRF_GET_ID (vrf_id, argv[1]); + if (vrfname) + VRF_GET_ID (vrf_id, vrfname); #ifdef SUNOS_5 - ifp = if_sunwzebra_get (argv[0], sl, vrf_id); + ifp = if_sunwzebra_get (ifname, sl, vrf_id); #else - ifp = if_get_by_name_len_vrf (argv[0], sl, vrf_id, 1); + ifp = if_get_by_name_len_vrf (ifname, sl, vrf_id, 1); #endif /* SUNOS_5 */ if (!ifp) { - vty_out (vty, "%% interface %s not in %s%s", argv[0], argv[1], VTY_NEWLINE); + vty_out (vty, "%% interface %s not in %s%s", ifname, vrfname, VTY_NEWLINE); return CMD_WARNING; } VTY_PUSH_CONTEXT_COMPAT (INTERFACE_NODE, ifp); @@ -791,32 +795,29 @@ DEFUN (interface, return CMD_SUCCESS; } -ALIAS (interface, - interface_vrf_cmd, - "interface IFNAME " VRF_CMD_STR, - "Select an interface to configure\n" - "Interface's name\n" - VRF_CMD_HELP_STR) - DEFUN_NOSH (no_interface, no_interface_cmd, - "no interface IFNAME", + "no interface IFNAME [vrf NAME]", NO_STR "Delete a pseudo interface's configuration\n" - "Interface's name\n") + "Interface's name\n" + VRF_CMD_HELP_STR) { + const char *ifname = argv[2]->arg; + const char *vrfname = (argc > 3) ? argv[3]->arg : NULL; + // deleting interface struct interface *ifp; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 1) - VRF_GET_ID (vrf_id, argv[1]); + if (argc > 3) + VRF_GET_ID (vrf_id, vrfname); - ifp = if_lookup_by_name_vrf (argv[0], vrf_id); + ifp = if_lookup_by_name_vrf (ifname, vrf_id); if (ifp == NULL) { - vty_out (vty, "%% Interface %s does not exist%s", argv[0], VTY_NEWLINE); + vty_out (vty, "%% Interface %s does not exist%s", ifname, VTY_NEWLINE); return CMD_WARNING; } @@ -832,32 +833,27 @@ DEFUN_NOSH (no_interface, return CMD_SUCCESS; } -ALIAS (no_interface, - no_interface_vrf_cmd, - "no interface IFNAME " VRF_CMD_STR, - NO_STR - "Delete a pseudo interface's configuration\n" - "Interface's name\n" - VRF_CMD_HELP_STR) - DEFUN (vrf, vrf_cmd, "vrf NAME", "Select a VRF to configure\n" "VRF's name\n") { + int idx_name = 1; + const char *vrfname = argv[idx_name]->arg; + struct vrf *vrfp; size_t sl; - if ((sl = strlen(argv[0])) > VRF_NAMSIZ) + if ((sl = strlen(vrfname)) > VRF_NAMSIZ) { vty_out (vty, "%% VRF name %s is invalid: length exceeds " "%d characters%s", - argv[0], VRF_NAMSIZ, VTY_NEWLINE); + vrfname, VRF_NAMSIZ, VTY_NEWLINE); return CMD_WARNING; } - vrfp = vrf_get (VRF_UNKNOWN, argv[0]); + vrfp = vrf_get (VRF_UNKNOWN, vrfname); VTY_PUSH_CONTEXT_COMPAT (VRF_NODE, vrfp); @@ -871,13 +867,15 @@ DEFUN_NOSH (no_vrf, "Delete a pseudo VRF's configuration\n" "VRF's name\n") { + const char *vrfname = argv[2]->arg; + struct vrf *vrfp; - vrfp = vrf_list_lookup_by_name (argv[0]); + vrfp = vrf_list_lookup_by_name (vrfname);; if (vrfp == NULL) { - vty_out (vty, "%% VRF %s does not exist%s", argv[0], VTY_NEWLINE); + vty_out (vty, "%% VRF %s does not exist%s", vrfname, VTY_NEWLINE); return CMD_WARNING; } @@ -897,10 +895,12 @@ DEFUN_NOSH (no_vrf, /* For debug purpose. */ DEFUN (show_address, show_address_cmd, - "show address", + "show address [vrf NAME]", SHOW_STR - "address\n") + "address\n" + VRF_CMD_HELP_STR) { + int idx_vrf = 3; struct listnode *node; struct listnode *node2; struct interface *ifp; @@ -908,8 +908,8 @@ DEFUN (show_address, struct prefix *p; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 0) - VRF_GET_ID (vrf_id, argv[0]); + if (argc > 2) + VRF_GET_ID (vrf_id, argv[idx_vrf]->arg); for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), node, ifp)) { @@ -925,16 +925,9 @@ DEFUN (show_address, return CMD_SUCCESS; } -ALIAS (show_address, - show_address_vrf_cmd, - "show address " VRF_CMD_STR, - SHOW_STR - "address\n" - VRF_CMD_HELP_STR) - DEFUN (show_address_vrf_all, show_address_vrf_all_cmd, - "show address " VRF_ALL_CMD_STR, + "show address vrf all", SHOW_STR "address\n" VRF_ALL_CMD_HELP_STR) diff --git a/lib/if_rmap.c b/lib/if_rmap.c index 736f2e237d..2afb08c7ca 100644 --- a/lib/if_rmap.c +++ b/lib/if_rmap.c @@ -211,18 +211,21 @@ if_rmap_unset (const char *ifname, enum if_rmap_type type, DEFUN (if_rmap, if_rmap_cmd, - "route-map RMAP_NAME (in|out) IFNAME", + "route-map RMAP_NAME <in|out> IFNAME", "Route map set\n" "Route map name\n" "Route map set for input filtering\n" "Route map set for output filtering\n" "Route map interface name\n") { + int idx_rmap_name = 1; + int idx_in_out = 2; + int idx_ifname = 3; enum if_rmap_type type; - if (strncmp (argv[1], "i", 1) == 0) + if (strncmp (argv[idx_in_out]->text, "in", 1) == 0) type = IF_RMAP_IN; - else if (strncmp (argv[1], "o", 1) == 0) + else if (strncmp (argv[idx_in_out]->text, "out", 1) == 0) type = IF_RMAP_OUT; else { @@ -230,23 +233,14 @@ DEFUN (if_rmap, return CMD_WARNING; } - if_rmap_set (argv[2], type, argv[0]); + if_rmap_set (argv[idx_ifname]->arg, type, argv[idx_rmap_name]->arg); return CMD_SUCCESS; -} - -ALIAS (if_rmap, - if_ipv6_rmap_cmd, - "route-map RMAP_NAME (in|out) IFNAME", - "Route map set\n" - "Route map name\n" - "Route map set for input filtering\n" - "Route map set for output filtering\n" - "Route map interface name\n") +} DEFUN (no_if_rmap, no_if_rmap_cmd, - "no route-map ROUTEMAP_NAME (in|out) IFNAME", + "no route-map ROUTEMAP_NAME <in|out> IFNAME", NO_STR "Route map unset\n" "Route map name\n" @@ -254,12 +248,15 @@ DEFUN (no_if_rmap, "Route map for output filtering\n" "Route map interface name\n") { + int idx_routemap_name = 2; + int idx_in_out = 3; + int idx_ifname = 4; int ret; enum if_rmap_type type; - if (strncmp (argv[1], "i", 1) == 0) + if (strncmp (argv[idx_in_out]->arg, "i", 1) == 0) type = IF_RMAP_IN; - else if (strncmp (argv[1], "o", 1) == 0) + else if (strncmp (argv[idx_in_out]->arg, "o", 1) == 0) type = IF_RMAP_OUT; else { @@ -267,24 +264,15 @@ DEFUN (no_if_rmap, return CMD_WARNING; } - ret = if_rmap_unset (argv[2], type, argv[0]); + ret = if_rmap_unset (argv[idx_ifname]->arg, type, argv[idx_routemap_name]->arg); if (! ret) { vty_out (vty, "route-map doesn't exist%s", VTY_NEWLINE); return CMD_WARNING; } return CMD_SUCCESS; -} +} -ALIAS (no_if_rmap, - no_if_ipv6_rmap_cmd, - "no route-map ROUTEMAP_NAME (in|out) IFNAME", - NO_STR - "Route map unset\n" - "Route map name\n" - "Route map for input filtering\n" - "Route map for output filtering\n" - "Route map interface name\n") /* Configuration write function. */ int @@ -333,8 +321,6 @@ if_rmap_init (int node) { ifrmaphash = hash_create (if_rmap_hash_make, if_rmap_hash_cmp); if (node == RIPNG_NODE) { - install_element (RIPNG_NODE, &if_ipv6_rmap_cmd); - install_element (RIPNG_NODE, &no_if_ipv6_rmap_cmd); } else if (node == RIP_NODE) { install_element (RIP_NODE, &if_rmap_cmd); install_element (RIP_NODE, &no_if_rmap_cmd); diff --git a/lib/json.c b/lib/json.c index c49a4f9074..3edd146a8f 100644 --- a/lib/json.c +++ b/lib/json.c @@ -21,6 +21,7 @@ #include <zebra.h> +#include "command.h" #include "lib/json.h" /* @@ -29,12 +30,12 @@ * what. */ int -use_json (const int argc, const char *argv[]) +use_json (const int argc, struct cmd_token *argv[]) { if (argc == 0) return 0; - if (argv[argc-1] && strcmp(argv[argc-1], "json") == 0) + if (argv[argc-1]->arg && strcmp(argv[argc-1]->arg, "json") == 0) return 1; return 0; diff --git a/lib/json.h b/lib/json.h index b217df0a7b..0ceffd4e8e 100644 --- a/lib/json.h +++ b/lib/json.h @@ -34,7 +34,7 @@ #define json_object_to_json_string_ext(A, B) json_object_to_json_string (A) #endif -extern int use_json(const int argc, const char *argv[]); +extern int use_json(const int argc, struct cmd_token *argv[]); extern void json_object_string_add(struct json_object* obj, const char *key, const char *s); extern void json_object_int_add(struct json_object* obj, const char *key, diff --git a/lib/keychain.c b/lib/keychain.c index c090956487..f8a3ffc012 100644 --- a/lib/keychain.c +++ b/lib/keychain.c @@ -247,9 +247,10 @@ DEFUN (key_chain, "Key-chain management\n" "Key-chain name\n") { + int idx_word = 2; struct keychain *keychain; - keychain = keychain_get (argv[0]); + keychain = keychain_get (argv[idx_word]->arg); VTY_PUSH_CONTEXT_COMPAT (KEYCHAIN_NODE, keychain); return CMD_SUCCESS; @@ -263,13 +264,14 @@ DEFUN (no_key_chain, "Key-chain management\n" "Key-chain name\n") { + int idx_word = 3; struct keychain *keychain; - keychain = keychain_lookup (argv[0]); + keychain = keychain_lookup (argv[idx_word]->arg); if (! keychain) { - vty_out (vty, "Can't find keychain %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "Can't find keychain %s%s", argv[idx_word]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -280,33 +282,35 @@ DEFUN (no_key_chain, DEFUN (key, key_cmd, - "key <0-2147483647>", + "key (0-2147483647)", "Configure a key\n" "Key identifier number\n") { + int idx_number = 1; VTY_DECLVAR_CONTEXT (keychain, keychain); struct key *key; u_int32_t index; - VTY_GET_INTEGER ("key identifier", index, argv[0]); + VTY_GET_INTEGER ("key identifier", index, argv[idx_number]->arg); key = key_get (keychain, index); VTY_PUSH_CONTEXT_SUB (KEYCHAIN_KEY_NODE, key); - + return CMD_SUCCESS; } DEFUN (no_key, no_key_cmd, - "no key <0-2147483647>", + "no key (0-2147483647)", NO_STR "Delete a key\n" "Key identifier number\n") { + int idx_number = 2; VTY_DECLVAR_CONTEXT (keychain, keychain); struct key *key; u_int32_t index; - - VTY_GET_INTEGER ("key identifier", index, argv[0]); + + VTY_GET_INTEGER ("key identifier", index, argv[idx_number]->arg); key = key_lookup (keychain, index); if (! key) { @@ -327,11 +331,12 @@ DEFUN (key_string, "Set key string\n" "The key\n") { + int idx_line = 1; VTY_DECLVAR_CONTEXT_SUB (key, key); if (key->string) XFREE(MTYPE_KEY, key->string); - key->string = XSTRDUP(MTYPE_KEY, argv[0]); + key->string = XSTRDUP(MTYPE_KEY, argv[idx_line]->arg); return CMD_SUCCESS; } @@ -541,7 +546,7 @@ key_lifetime_infinite_set (struct vty *vty, struct key_range *krange, DEFUN (accept_lifetime_day_month_day_month, accept_lifetime_day_month_day_month_cmd, - "accept-lifetime HH:MM:SS <1-31> MONTH <1993-2035> HH:MM:SS <1-31> MONTH <1993-2035>", + "accept-lifetime HH:MM:SS (1-31) MONTH (1993-2035) HH:MM:SS (1-31) MONTH (1993-2035)", "Set accept lifetime of the key\n" "Time to start\n" "Day of th month to start\n" @@ -552,15 +557,23 @@ DEFUN (accept_lifetime_day_month_day_month, "Month of the year to expire\n" "Year to expire\n") { + int idx_hhmmss = 1; + int idx_number = 2; + int idx_month = 3; + int idx_number_2 = 4; + int idx_hhmmss_2 = 5; + int idx_number_3 = 6; + int idx_month_2 = 7; + int idx_number_4 = 8; VTY_DECLVAR_CONTEXT_SUB (key, key); - return key_lifetime_set (vty, &key->accept, argv[0], argv[1], argv[2], - argv[3], argv[4], argv[5], argv[6], argv[7]); + return key_lifetime_set (vty, &key->accept, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg, + argv[idx_number_2]->arg, argv[idx_hhmmss_2]->arg, argv[idx_number_3]->arg, argv[idx_month_2]->arg, argv[idx_number_4]->arg); } DEFUN (accept_lifetime_day_month_month_day, accept_lifetime_day_month_month_day_cmd, - "accept-lifetime HH:MM:SS <1-31> MONTH <1993-2035> HH:MM:SS MONTH <1-31> <1993-2035>", + "accept-lifetime HH:MM:SS (1-31) MONTH (1993-2035) HH:MM:SS MONTH (1-31) (1993-2035)", "Set accept lifetime of the key\n" "Time to start\n" "Day of th month to start\n" @@ -571,15 +584,23 @@ DEFUN (accept_lifetime_day_month_month_day, "Day of th month to expire\n" "Year to expire\n") { + int idx_hhmmss = 1; + int idx_number = 2; + int idx_month = 3; + int idx_number_2 = 4; + int idx_hhmmss_2 = 5; + int idx_month_2 = 6; + int idx_number_3 = 7; + int idx_number_4 = 8; VTY_DECLVAR_CONTEXT_SUB (key, key); - return key_lifetime_set (vty, &key->accept, argv[0], argv[1], argv[2], - argv[3], argv[4], argv[6], argv[5], argv[7]); + return key_lifetime_set (vty, &key->accept, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg, + argv[idx_number_2]->arg, argv[idx_hhmmss_2]->arg, argv[idx_number_3]->arg, argv[idx_month_2]->arg, argv[idx_number_4]->arg); } DEFUN (accept_lifetime_month_day_day_month, accept_lifetime_month_day_day_month_cmd, - "accept-lifetime HH:MM:SS MONTH <1-31> <1993-2035> HH:MM:SS <1-31> MONTH <1993-2035>", + "accept-lifetime HH:MM:SS MONTH (1-31) (1993-2035) HH:MM:SS (1-31) MONTH (1993-2035)", "Set accept lifetime of the key\n" "Time to start\n" "Month of the year to start\n" @@ -590,15 +611,23 @@ DEFUN (accept_lifetime_month_day_day_month, "Month of the year to expire\n" "Year to expire\n") { + int idx_hhmmss = 1; + int idx_month = 2; + int idx_number = 3; + int idx_number_2 = 4; + int idx_hhmmss_2 = 5; + int idx_number_3 = 6; + int idx_month_2 = 7; + int idx_number_4 = 8; VTY_DECLVAR_CONTEXT_SUB (key, key); - return key_lifetime_set (vty, &key->accept, argv[0], argv[2], argv[1], - argv[3], argv[4], argv[5], argv[6], argv[7]); + return key_lifetime_set (vty, &key->accept, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg, + argv[idx_number_2]->arg, argv[idx_hhmmss_2]->arg, argv[idx_number_3]->arg, argv[idx_month_2]->arg, argv[idx_number_4]->arg); } DEFUN (accept_lifetime_month_day_month_day, accept_lifetime_month_day_month_day_cmd, - "accept-lifetime HH:MM:SS MONTH <1-31> <1993-2035> HH:MM:SS MONTH <1-31> <1993-2035>", + "accept-lifetime HH:MM:SS MONTH (1-31) (1993-2035) HH:MM:SS MONTH (1-31) (1993-2035)", "Set accept lifetime of the key\n" "Time to start\n" "Month of the year to start\n" @@ -609,15 +638,23 @@ DEFUN (accept_lifetime_month_day_month_day, "Day of th month to expire\n" "Year to expire\n") { + int idx_hhmmss = 1; + int idx_month = 2; + int idx_number = 3; + int idx_number_2 = 4; + int idx_hhmmss_2 = 5; + int idx_month_2 = 6; + int idx_number_3 = 7; + int idx_number_4 = 8; VTY_DECLVAR_CONTEXT_SUB (key, key); - return key_lifetime_set (vty, &key->accept, argv[0], argv[2], argv[1], - argv[3], argv[4], argv[6], argv[5], argv[7]); + return key_lifetime_set (vty, &key->accept, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg, + argv[idx_number_2]->arg, argv[idx_hhmmss_2]->arg, argv[idx_number_3]->arg, argv[idx_month_2]->arg, argv[idx_number_4]->arg); } DEFUN (accept_lifetime_infinite_day_month, accept_lifetime_infinite_day_month_cmd, - "accept-lifetime HH:MM:SS <1-31> MONTH <1993-2035> infinite", + "accept-lifetime HH:MM:SS (1-31) MONTH (1993-2035) infinite", "Set accept lifetime of the key\n" "Time to start\n" "Day of th month to start\n" @@ -625,15 +662,19 @@ DEFUN (accept_lifetime_infinite_day_month, "Year to start\n" "Never expires") { + int idx_hhmmss = 1; + int idx_number = 2; + int idx_month = 3; + int idx_number_2 = 4; VTY_DECLVAR_CONTEXT_SUB (key, key); - return key_lifetime_infinite_set (vty, &key->accept, argv[0], argv[1], - argv[2], argv[3]); + return key_lifetime_infinite_set (vty, &key->accept, argv[idx_hhmmss]->arg, argv[idx_number]->arg, + argv[idx_month]->arg, argv[idx_number_2]->arg); } DEFUN (accept_lifetime_infinite_month_day, accept_lifetime_infinite_month_day_cmd, - "accept-lifetime HH:MM:SS MONTH <1-31> <1993-2035> infinite", + "accept-lifetime HH:MM:SS MONTH (1-31) (1993-2035) infinite", "Set accept lifetime of the key\n" "Time to start\n" "Month of the year to start\n" @@ -641,15 +682,19 @@ DEFUN (accept_lifetime_infinite_month_day, "Year to start\n" "Never expires") { + int idx_hhmmss = 1; + int idx_month = 2; + int idx_number = 3; + int idx_number_2 = 4; VTY_DECLVAR_CONTEXT_SUB (key, key); - return key_lifetime_infinite_set (vty, &key->accept, argv[0], argv[2], - argv[1], argv[3]); + return key_lifetime_infinite_set (vty, &key->accept, argv[idx_hhmmss]->arg, argv[idx_number]->arg, + argv[idx_month]->arg, argv[idx_number_2]->arg); } DEFUN (accept_lifetime_duration_day_month, accept_lifetime_duration_day_month_cmd, - "accept-lifetime HH:MM:SS <1-31> MONTH <1993-2035> duration <1-2147483646>", + "accept-lifetime HH:MM:SS (1-31) MONTH (1993-2035) duration (1-2147483646)", "Set accept lifetime of the key\n" "Time to start\n" "Day of th month to start\n" @@ -658,15 +703,20 @@ DEFUN (accept_lifetime_duration_day_month, "Duration of the key\n" "Duration seconds\n") { + int idx_hhmmss = 1; + int idx_number = 2; + int idx_month = 3; + int idx_number_2 = 4; + int idx_number_3 = 6; VTY_DECLVAR_CONTEXT_SUB (key, key); - return key_lifetime_duration_set (vty, &key->accept, argv[0], argv[1], - argv[2], argv[3], argv[4]); + return key_lifetime_duration_set (vty, &key->accept, argv[idx_hhmmss]->arg, argv[idx_number]->arg, + argv[idx_month]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg); } DEFUN (accept_lifetime_duration_month_day, accept_lifetime_duration_month_day_cmd, - "accept-lifetime HH:MM:SS MONTH <1-31> <1993-2035> duration <1-2147483646>", + "accept-lifetime HH:MM:SS MONTH (1-31) (1993-2035) duration (1-2147483646)", "Set accept lifetime of the key\n" "Time to start\n" "Month of the year to start\n" @@ -675,15 +725,20 @@ DEFUN (accept_lifetime_duration_month_day, "Duration of the key\n" "Duration seconds\n") { + int idx_hhmmss = 1; + int idx_month = 2; + int idx_number = 3; + int idx_number_2 = 4; + int idx_number_3 = 6; VTY_DECLVAR_CONTEXT_SUB (key, key); - return key_lifetime_duration_set (vty, &key->accept, argv[0], argv[2], - argv[1], argv[3], argv[4]); + return key_lifetime_duration_set (vty, &key->accept, argv[idx_hhmmss]->arg, argv[idx_number]->arg, + argv[idx_month]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg); } DEFUN (send_lifetime_day_month_day_month, send_lifetime_day_month_day_month_cmd, - "send-lifetime HH:MM:SS <1-31> MONTH <1993-2035> HH:MM:SS <1-31> MONTH <1993-2035>", + "send-lifetime HH:MM:SS (1-31) MONTH (1993-2035) HH:MM:SS (1-31) MONTH (1993-2035)", "Set send lifetime of the key\n" "Time to start\n" "Day of th month to start\n" @@ -694,15 +749,23 @@ DEFUN (send_lifetime_day_month_day_month, "Month of the year to expire\n" "Year to expire\n") { + int idx_hhmmss = 1; + int idx_number = 2; + int idx_month = 3; + int idx_number_2 = 4; + int idx_hhmmss_2 = 5; + int idx_number_3 = 6; + int idx_month_2 = 7; + int idx_number_4 = 8; VTY_DECLVAR_CONTEXT_SUB (key, key); - return key_lifetime_set (vty, &key->send, argv[0], argv[1], argv[2], argv[3], - argv[4], argv[5], argv[6], argv[7]); + return key_lifetime_set (vty, &key->send, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg, argv[idx_number_2]->arg, + argv[idx_hhmmss_2]->arg, argv[idx_number_3]->arg, argv[idx_month_2]->arg, argv[idx_number_4]->arg); } DEFUN (send_lifetime_day_month_month_day, send_lifetime_day_month_month_day_cmd, - "send-lifetime HH:MM:SS <1-31> MONTH <1993-2035> HH:MM:SS MONTH <1-31> <1993-2035>", + "send-lifetime HH:MM:SS (1-31) MONTH (1993-2035) HH:MM:SS MONTH (1-31) (1993-2035)", "Set send lifetime of the key\n" "Time to start\n" "Day of th month to start\n" @@ -713,15 +776,23 @@ DEFUN (send_lifetime_day_month_month_day, "Day of th month to expire\n" "Year to expire\n") { + int idx_hhmmss = 1; + int idx_number = 2; + int idx_month = 3; + int idx_number_2 = 4; + int idx_hhmmss_2 = 5; + int idx_month_2 = 6; + int idx_number_3 = 7; + int idx_number_4 = 8; VTY_DECLVAR_CONTEXT_SUB (key, key); - return key_lifetime_set (vty, &key->send, argv[0], argv[1], argv[2], argv[3], - argv[4], argv[6], argv[5], argv[7]); + return key_lifetime_set (vty, &key->send, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg, argv[idx_number_2]->arg, + argv[idx_hhmmss_2]->arg, argv[idx_number_3]->arg, argv[idx_month_2]->arg, argv[idx_number_4]->arg); } DEFUN (send_lifetime_month_day_day_month, send_lifetime_month_day_day_month_cmd, - "send-lifetime HH:MM:SS MONTH <1-31> <1993-2035> HH:MM:SS <1-31> MONTH <1993-2035>", + "send-lifetime HH:MM:SS MONTH (1-31) (1993-2035) HH:MM:SS (1-31) MONTH (1993-2035)", "Set send lifetime of the key\n" "Time to start\n" "Month of the year to start\n" @@ -732,15 +803,23 @@ DEFUN (send_lifetime_month_day_day_month, "Month of the year to expire\n" "Year to expire\n") { + int idx_hhmmss = 1; + int idx_month = 2; + int idx_number = 3; + int idx_number_2 = 4; + int idx_hhmmss_2 = 5; + int idx_number_3 = 6; + int idx_month_2 = 7; + int idx_number_4 = 8; VTY_DECLVAR_CONTEXT_SUB (key, key); - return key_lifetime_set (vty, &key->send, argv[0], argv[2], argv[1], argv[3], - argv[4], argv[5], argv[6], argv[7]); + return key_lifetime_set (vty, &key->send, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg, argv[idx_number_2]->arg, + argv[idx_hhmmss_2]->arg, argv[idx_number_3]->arg, argv[idx_month_2]->arg, argv[idx_number_4]->arg); } DEFUN (send_lifetime_month_day_month_day, send_lifetime_month_day_month_day_cmd, - "send-lifetime HH:MM:SS MONTH <1-31> <1993-2035> HH:MM:SS MONTH <1-31> <1993-2035>", + "send-lifetime HH:MM:SS MONTH (1-31) (1993-2035) HH:MM:SS MONTH (1-31) (1993-2035)", "Set send lifetime of the key\n" "Time to start\n" "Month of the year to start\n" @@ -751,15 +830,23 @@ DEFUN (send_lifetime_month_day_month_day, "Day of th month to expire\n" "Year to expire\n") { + int idx_hhmmss = 1; + int idx_month = 2; + int idx_number = 3; + int idx_number_2 = 4; + int idx_hhmmss_2 = 5; + int idx_month_2 = 6; + int idx_number_3 = 7; + int idx_number_4 = 8; VTY_DECLVAR_CONTEXT_SUB (key, key); - return key_lifetime_set (vty, &key->send, argv[0], argv[2], argv[1], argv[3], - argv[4], argv[6], argv[5], argv[7]); + return key_lifetime_set (vty, &key->send, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg, argv[idx_number_2]->arg, + argv[idx_hhmmss_2]->arg, argv[idx_number_3]->arg, argv[idx_month_2]->arg, argv[idx_number_4]->arg); } DEFUN (send_lifetime_infinite_day_month, send_lifetime_infinite_day_month_cmd, - "send-lifetime HH:MM:SS <1-31> MONTH <1993-2035> infinite", + "send-lifetime HH:MM:SS (1-31) MONTH (1993-2035) infinite", "Set send lifetime of the key\n" "Time to start\n" "Day of th month to start\n" @@ -767,15 +854,19 @@ DEFUN (send_lifetime_infinite_day_month, "Year to start\n" "Never expires") { + int idx_hhmmss = 1; + int idx_number = 2; + int idx_month = 3; + int idx_number_2 = 4; VTY_DECLVAR_CONTEXT_SUB (key, key); - return key_lifetime_infinite_set (vty, &key->send, argv[0], argv[1], argv[2], - argv[3]); + return key_lifetime_infinite_set (vty, &key->send, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg, + argv[idx_number_2]->arg); } DEFUN (send_lifetime_infinite_month_day, send_lifetime_infinite_month_day_cmd, - "send-lifetime HH:MM:SS MONTH <1-31> <1993-2035> infinite", + "send-lifetime HH:MM:SS MONTH (1-31) (1993-2035) infinite", "Set send lifetime of the key\n" "Time to start\n" "Month of the year to start\n" @@ -783,15 +874,19 @@ DEFUN (send_lifetime_infinite_month_day, "Year to start\n" "Never expires") { + int idx_hhmmss = 1; + int idx_month = 2; + int idx_number = 3; + int idx_number_2 = 4; VTY_DECLVAR_CONTEXT_SUB (key, key); - return key_lifetime_infinite_set (vty, &key->send, argv[0], argv[2], argv[1], - argv[3]); + return key_lifetime_infinite_set (vty, &key->send, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg, + argv[idx_number_2]->arg); } DEFUN (send_lifetime_duration_day_month, send_lifetime_duration_day_month_cmd, - "send-lifetime HH:MM:SS <1-31> MONTH <1993-2035> duration <1-2147483646>", + "send-lifetime HH:MM:SS (1-31) MONTH (1993-2035) duration (1-2147483646)", "Set send lifetime of the key\n" "Time to start\n" "Day of th month to start\n" @@ -800,15 +895,20 @@ DEFUN (send_lifetime_duration_day_month, "Duration of the key\n" "Duration seconds\n") { + int idx_hhmmss = 1; + int idx_number = 2; + int idx_month = 3; + int idx_number_2 = 4; + int idx_number_3 = 6; VTY_DECLVAR_CONTEXT_SUB (key, key); - return key_lifetime_duration_set (vty, &key->send, argv[0], argv[1], argv[2], - argv[3], argv[4]); + return key_lifetime_duration_set (vty, &key->send, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg, + argv[idx_number_2]->arg, argv[idx_number_3]->arg); } DEFUN (send_lifetime_duration_month_day, send_lifetime_duration_month_day_cmd, - "send-lifetime HH:MM:SS MONTH <1-31> <1993-2035> duration <1-2147483646>", + "send-lifetime HH:MM:SS MONTH (1-31) (1993-2035) duration (1-2147483646)", "Set send lifetime of the key\n" "Time to start\n" "Month of the year to start\n" @@ -817,10 +917,15 @@ DEFUN (send_lifetime_duration_month_day, "Duration of the key\n" "Duration seconds\n") { + int idx_hhmmss = 1; + int idx_month = 2; + int idx_number = 3; + int idx_number_2 = 4; + int idx_number_3 = 6; VTY_DECLVAR_CONTEXT_SUB (key, key); - return key_lifetime_duration_set (vty, &key->send, argv[0], argv[2], argv[1], - argv[3], argv[4]); + return key_lifetime_duration_set (vty, &key->send, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg, + argv[idx_number_2]->arg, argv[idx_number_3]->arg); } static struct cmd_node keychain_node = @@ -205,8 +205,6 @@ struct timestamp_control { /* Defines for use in command construction: */ -#define LOG_LEVELS "(emergencies|alerts|critical|errors|warnings|notifications|informational|debugging)" - #define LOG_LEVEL_DESC \ "System is unusable\n" \ "Immediate action needed\n" \ @@ -217,8 +215,6 @@ struct timestamp_control { "Informational messages\n" \ "Debugging messages\n" -#define LOG_FACILITIES "(kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7)" - #define LOG_FACILITY_DESC \ "Kernel\n" \ "User process\n" \ @@ -551,20 +551,22 @@ ns_netns_pathname (struct vty *vty, const char *name) DEFUN (ns_netns, ns_netns_cmd, - "logical-router <1-65535> ns NAME", + "logical-router (1-65535) ns NAME", "Enable a logical-router\n" "Specify the logical-router indentifier\n" "The Name Space\n" "The file name in " NS_RUN_DIR ", or a full pathname\n") { + int idx_number = 1; + int idx_name = 3; ns_id_t ns_id = NS_DEFAULT; struct ns *ns = NULL; - char *pathname = ns_netns_pathname (vty, argv[1]); + char *pathname = ns_netns_pathname (vty, argv[idx_name]->arg); if (!pathname) return CMD_WARNING; - VTY_GET_INTEGER ("NS ID", ns_id, argv[0]); + VTY_GET_INTEGER ("NS ID", ns_id, argv[idx_number]->arg); ns = ns_get (ns_id); if (ns->name && strcmp (ns->name, pathname) != 0) @@ -589,21 +591,23 @@ DEFUN (ns_netns, DEFUN (no_ns_netns, no_ns_netns_cmd, - "no logical-router <1-65535> ns NAME", + "no logical-router (1-65535) ns NAME", NO_STR "Enable a Logical-Router\n" "Specify the Logical-Router identifier\n" "The Name Space\n" "The file name in " NS_RUN_DIR ", or a full pathname\n") { + int idx_number = 2; + int idx_name = 4; ns_id_t ns_id = NS_DEFAULT; struct ns *ns = NULL; - char *pathname = ns_netns_pathname (vty, argv[1]); + char *pathname = ns_netns_pathname (vty, argv[idx_name]->arg); if (!pathname) return CMD_WARNING; - VTY_GET_INTEGER ("NS ID", ns_id, argv[0]); + VTY_GET_INTEGER ("NS ID", ns_id, argv[idx_number]->arg); ns = ns_lookup (ns_id); if (!ns) diff --git a/lib/plist.c b/lib/plist.c index 2b93d880f6..a854ad52b3 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -20,7 +20,6 @@ */ #include <zebra.h> -#include "lib/json.h" #include "prefix.h" #include "command.h" @@ -31,6 +30,7 @@ #include "stream.h" #include "log.h" #include "routemap.h" +#include "lib/json.h" #include "plist_int.h" @@ -1420,7 +1420,7 @@ vty_clear_prefix_list (struct vty *vty, afi_t afi, const char *name, DEFUN (ip_prefix_list, ip_prefix_list_cmd, - "ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)", + "ip prefix-list WORD <deny|permit> <A.B.C.D/M|any>", IP_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -1429,13 +1429,16 @@ DEFUN (ip_prefix_list, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n") { - return vty_prefix_list_install (vty, AFI_IP, argv[0], NULL, - argv[1], argv[2], NULL, NULL); + int idx_word = 2; + int idx_permit_deny = 3; + int idx_ipv4_any = 4; + return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, NULL, + argv[idx_permit_deny]->arg, argv[idx_ipv4_any]->arg, NULL, NULL); } DEFUN (ip_prefix_list_ge, ip_prefix_list_ge_cmd, - "ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>", + "ip prefix-list WORD <deny|permit> A.B.C.D/M ge (0-32)", IP_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -1445,13 +1448,17 @@ DEFUN (ip_prefix_list_ge, "Minimum prefix length to be matched\n" "Minimum prefix length\n") { - return vty_prefix_list_install (vty, AFI_IP, argv[0], NULL, argv[1], - argv[2], argv[3], NULL); + int idx_word = 2; + int idx_permit_deny = 3; + int idx_ipv4_prefixlen = 4; + int idx_number = 6; + return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, + argv[idx_ipv4_prefixlen]->arg, argv[idx_number]->arg, NULL); } DEFUN (ip_prefix_list_ge_le, ip_prefix_list_ge_le_cmd, - "ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> le <0-32>", + "ip prefix-list WORD <deny|permit> A.B.C.D/M ge (0-32) le (0-32)", IP_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -1463,13 +1470,18 @@ DEFUN (ip_prefix_list_ge_le, "Maximum prefix length to be matched\n" "Maximum prefix length\n") { - return vty_prefix_list_install (vty, AFI_IP, argv[0], NULL, argv[1], - argv[2], argv[3], argv[4]); + int idx_word = 2; + int idx_permit_deny = 3; + int idx_ipv4_prefixlen = 4; + int idx_number = 6; + int idx_number_2 = 8; + return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, + argv[idx_ipv4_prefixlen]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); } DEFUN (ip_prefix_list_le, ip_prefix_list_le_cmd, - "ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32>", + "ip prefix-list WORD <deny|permit> A.B.C.D/M le (0-32)", IP_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -1479,13 +1491,17 @@ DEFUN (ip_prefix_list_le, "Maximum prefix length to be matched\n" "Maximum prefix length\n") { - return vty_prefix_list_install (vty, AFI_IP, argv[0], NULL, argv[1], - argv[2], NULL, argv[3]); + int idx_word = 2; + int idx_permit_deny = 3; + int idx_ipv4_prefixlen = 4; + int idx_number = 6; + return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, + argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_number]->arg); } DEFUN (ip_prefix_list_le_ge, ip_prefix_list_le_ge_cmd, - "ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>", + "ip prefix-list WORD <deny|permit> A.B.C.D/M le (0-32) ge (0-32)", IP_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -1497,13 +1513,18 @@ DEFUN (ip_prefix_list_le_ge, "Minimum prefix length to be matched\n" "Minimum prefix length\n") { - return vty_prefix_list_install (vty, AFI_IP, argv[0], NULL, argv[1], - argv[2], argv[4], argv[3]); + int idx_word = 2; + int idx_permit_deny = 3; + int idx_ipv4_prefixlen = 4; + int idx_number = 6; + int idx_number_2 = 8; + return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, + argv[idx_ipv4_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number]->arg); } DEFUN (ip_prefix_list_seq, ip_prefix_list_seq_cmd, - "ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)", + "ip prefix-list WORD seq (1-4294967295) <deny|permit> <A.B.C.D/M|any>", IP_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -1514,13 +1535,17 @@ DEFUN (ip_prefix_list_seq, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n") { - return vty_prefix_list_install (vty, AFI_IP, argv[0], argv[1], argv[2], - argv[3], NULL, NULL); + int idx_word = 2; + int idx_number = 4; + int idx_permit_deny = 5; + int idx_ipv4_any = 6; + return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv4_any]->arg, NULL, NULL); } DEFUN (ip_prefix_list_seq_ge, ip_prefix_list_seq_ge_cmd, - "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32>", + "ip prefix-list WORD seq (1-4294967295) <deny|permit> A.B.C.D/M ge (0-32)", IP_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -1532,13 +1557,18 @@ DEFUN (ip_prefix_list_seq_ge, "Minimum prefix length to be matched\n" "Minimum prefix length\n") { - return vty_prefix_list_install (vty, AFI_IP, argv[0], argv[1], argv[2], - argv[3], argv[4], NULL); + int idx_word = 2; + int idx_number = 4; + int idx_permit_deny = 5; + int idx_ipv4_prefixlen = 6; + int idx_number_2 = 8; + return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv4_prefixlen]->arg, argv[idx_number_2]->arg, NULL); } DEFUN (ip_prefix_list_seq_ge_le, ip_prefix_list_seq_ge_le_cmd, - "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <0-32>", + "ip prefix-list WORD seq (1-4294967295) <deny|permit> A.B.C.D/M ge (0-32) le (0-32)", IP_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -1552,13 +1582,19 @@ DEFUN (ip_prefix_list_seq_ge_le, "Maximum prefix length to be matched\n" "Maximum prefix length\n") { - return vty_prefix_list_install (vty, AFI_IP, argv[0], argv[1], argv[2], - argv[3], argv[4], argv[5]); + int idx_word = 2; + int idx_number = 4; + int idx_permit_deny = 5; + int idx_ipv4_prefixlen = 6; + int idx_number_2 = 8; + int idx_number_3 = 10; + return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv4_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg); } DEFUN (ip_prefix_list_seq_le, ip_prefix_list_seq_le_cmd, - "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32>", + "ip prefix-list WORD seq (1-4294967295) <deny|permit> A.B.C.D/M le (0-32)", IP_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -1570,13 +1606,18 @@ DEFUN (ip_prefix_list_seq_le, "Maximum prefix length to be matched\n" "Maximum prefix length\n") { - return vty_prefix_list_install (vty, AFI_IP, argv[0], argv[1], argv[2], - argv[3], NULL, argv[4]); + int idx_word = 2; + int idx_number = 4; + int idx_permit_deny = 5; + int idx_ipv4_prefixlen = 6; + int idx_number_2 = 8; + return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_number_2]->arg); } DEFUN (ip_prefix_list_seq_le_ge, ip_prefix_list_seq_le_ge_cmd, - "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32> ge <0-32>", + "ip prefix-list WORD seq (1-4294967295) <deny|permit> A.B.C.D/M le (0-32) ge (0-32)", IP_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -1590,8 +1631,14 @@ DEFUN (ip_prefix_list_seq_le_ge, "Minimum prefix length to be matched\n" "Minimum prefix length\n") { - return vty_prefix_list_install (vty, AFI_IP, argv[0], argv[1], argv[2], - argv[3], argv[5], argv[4]); + int idx_word = 2; + int idx_number = 4; + int idx_permit_deny = 5; + int idx_ipv4_prefixlen = 6; + int idx_number_2 = 8; + int idx_number_3 = 10; + return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv4_prefixlen]->arg, argv[idx_number_3]->arg, argv[idx_number_2]->arg); } DEFUN (no_ip_prefix_list, @@ -1602,13 +1649,14 @@ DEFUN (no_ip_prefix_list, PREFIX_LIST_STR "Name of a prefix list\n") { - return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, NULL, + int idx_word = 3; + return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, NULL, NULL, NULL, NULL, NULL); } DEFUN (no_ip_prefix_list_prefix, no_ip_prefix_list_prefix_cmd, - "no ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)", + "no ip prefix-list WORD <deny|permit> <A.B.C.D/M|any>", NO_STR IP_STR PREFIX_LIST_STR @@ -1618,13 +1666,16 @@ DEFUN (no_ip_prefix_list_prefix, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n") { - return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, argv[1], - argv[2], NULL, NULL); + int idx_word = 3; + int idx_permit_deny = 4; + int idx_ipv4_any = 5; + return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, + argv[idx_ipv4_any]->arg, NULL, NULL); } DEFUN (no_ip_prefix_list_ge, no_ip_prefix_list_ge_cmd, - "no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>", + "no ip prefix-list WORD <deny|permit> A.B.C.D/M ge (0-32)", NO_STR IP_STR PREFIX_LIST_STR @@ -1635,13 +1686,17 @@ DEFUN (no_ip_prefix_list_ge, "Minimum prefix length to be matched\n" "Minimum prefix length\n") { - return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, argv[1], - argv[2], argv[3], NULL); + int idx_word = 3; + int idx_permit_deny = 4; + int idx_ipv4_prefixlen = 5; + int idx_number = 7; + return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, + argv[idx_ipv4_prefixlen]->arg, argv[idx_number]->arg, NULL); } DEFUN (no_ip_prefix_list_ge_le, no_ip_prefix_list_ge_le_cmd, - "no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> le <0-32>", + "no ip prefix-list WORD <deny|permit> A.B.C.D/M ge (0-32) le (0-32)", NO_STR IP_STR PREFIX_LIST_STR @@ -1654,13 +1709,18 @@ DEFUN (no_ip_prefix_list_ge_le, "Maximum prefix length to be matched\n" "Maximum prefix length\n") { - return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, argv[1], - argv[2], argv[3], argv[4]); + int idx_word = 3; + int idx_permit_deny = 4; + int idx_ipv4_prefixlen = 5; + int idx_number = 7; + int idx_number_2 = 9; + return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, + argv[idx_ipv4_prefixlen]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); } DEFUN (no_ip_prefix_list_le, no_ip_prefix_list_le_cmd, - "no ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32>", + "no ip prefix-list WORD <deny|permit> A.B.C.D/M le (0-32)", NO_STR IP_STR PREFIX_LIST_STR @@ -1671,13 +1731,17 @@ DEFUN (no_ip_prefix_list_le, "Maximum prefix length to be matched\n" "Maximum prefix length\n") { - return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, argv[1], - argv[2], NULL, argv[3]); + int idx_word = 3; + int idx_permit_deny = 4; + int idx_ipv4_prefixlen = 5; + int idx_number = 7; + return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, + argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_number]->arg); } DEFUN (no_ip_prefix_list_le_ge, no_ip_prefix_list_le_ge_cmd, - "no ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>", + "no ip prefix-list WORD <deny|permit> A.B.C.D/M le (0-32) ge (0-32)", NO_STR IP_STR PREFIX_LIST_STR @@ -1690,13 +1754,18 @@ DEFUN (no_ip_prefix_list_le_ge, "Minimum prefix length to be matched\n" "Minimum prefix length\n") { - return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, argv[1], - argv[2], argv[4], argv[3]); + int idx_word = 3; + int idx_permit_deny = 4; + int idx_ipv4_prefixlen = 5; + int idx_number = 7; + int idx_number_2 = 9; + return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, + argv[idx_ipv4_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number]->arg); } DEFUN (no_ip_prefix_list_seq, no_ip_prefix_list_seq_cmd, - "no ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)", + "no ip prefix-list WORD seq (1-4294967295) <deny|permit> <A.B.C.D/M|any>", NO_STR IP_STR PREFIX_LIST_STR @@ -1708,13 +1777,17 @@ DEFUN (no_ip_prefix_list_seq, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n") { - return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], argv[1], argv[2], - argv[3], NULL, NULL); + int idx_word = 3; + int idx_number = 5; + int idx_permit_deny = 6; + int idx_ipv4_any = 7; + return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv4_any]->arg, NULL, NULL); } DEFUN (no_ip_prefix_list_seq_ge, no_ip_prefix_list_seq_ge_cmd, - "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32>", + "no ip prefix-list WORD seq (1-4294967295) <deny|permit> A.B.C.D/M ge (0-32)", NO_STR IP_STR PREFIX_LIST_STR @@ -1727,13 +1800,18 @@ DEFUN (no_ip_prefix_list_seq_ge, "Minimum prefix length to be matched\n" "Minimum prefix length\n") { - return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], argv[1], argv[2], - argv[3], argv[4], NULL); + int idx_word = 3; + int idx_number = 5; + int idx_permit_deny = 6; + int idx_ipv4_prefixlen = 7; + int idx_number_2 = 9; + return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv4_prefixlen]->arg, argv[idx_number_2]->arg, NULL); } DEFUN (no_ip_prefix_list_seq_ge_le, no_ip_prefix_list_seq_ge_le_cmd, - "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <0-32>", + "no ip prefix-list WORD seq (1-4294967295) <deny|permit> A.B.C.D/M ge (0-32) le (0-32)", NO_STR IP_STR PREFIX_LIST_STR @@ -1748,13 +1826,19 @@ DEFUN (no_ip_prefix_list_seq_ge_le, "Maximum prefix length to be matched\n" "Maximum prefix length\n") { - return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], argv[1], argv[2], - argv[3], argv[4], argv[5]); + int idx_word = 3; + int idx_number = 5; + int idx_permit_deny = 6; + int idx_ipv4_prefixlen = 7; + int idx_number_2 = 9; + int idx_number_3 = 11; + return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv4_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg); } DEFUN (no_ip_prefix_list_seq_le, no_ip_prefix_list_seq_le_cmd, - "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32>", + "no ip prefix-list WORD seq (1-4294967295) <deny|permit> A.B.C.D/M le (0-32)", NO_STR IP_STR PREFIX_LIST_STR @@ -1767,13 +1851,18 @@ DEFUN (no_ip_prefix_list_seq_le, "Maximum prefix length to be matched\n" "Maximum prefix length\n") { - return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], argv[1], argv[2], - argv[3], NULL, argv[4]); + int idx_word = 3; + int idx_number = 5; + int idx_permit_deny = 6; + int idx_ipv4_prefixlen = 7; + int idx_number_2 = 9; + return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_number_2]->arg); } DEFUN (no_ip_prefix_list_seq_le_ge, no_ip_prefix_list_seq_le_ge_cmd, - "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32> ge <0-32>", + "no ip prefix-list WORD seq (1-4294967295) <deny|permit> A.B.C.D/M le (0-32) ge (0-32)", NO_STR IP_STR PREFIX_LIST_STR @@ -1788,8 +1877,14 @@ DEFUN (no_ip_prefix_list_seq_le_ge, "Minimum prefix length to be matched\n" "Minimum prefix length\n") { - return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], argv[1], argv[2], - argv[3], argv[5], argv[4]); + int idx_word = 3; + int idx_number = 5; + int idx_permit_deny = 6; + int idx_ipv4_prefixlen = 7; + int idx_number_2 = 9; + int idx_number_3 = 11; + return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv4_prefixlen]->arg, argv[idx_number_3]->arg, argv[idx_number_2]->arg); } DEFUN (ip_prefix_list_sequence_number, @@ -1817,26 +1912,28 @@ DEFUN (no_ip_prefix_list_sequence_number, DEFUN (ip_prefix_list_description, ip_prefix_list_description_cmd, - "ip prefix-list WORD description .LINE", + "ip prefix-list WORD description LINE...", IP_STR PREFIX_LIST_STR "Name of a prefix list\n" "Prefix-list specific description\n" "Up to 80 characters describing this prefix-list\n") { + int idx_word = 2; + int idx_line = 4; struct prefix_list *plist; - plist = prefix_list_get (AFI_IP, 0, argv[0]); + plist = prefix_list_get (AFI_IP, 0, argv[idx_word]->arg); if (plist->desc) { XFREE (MTYPE_TMP, plist->desc); plist->desc = NULL; } - plist->desc = argv_concat(argv, argc, 1); + plist->desc = argv_concat(argv, argc, idx_line); return CMD_SUCCESS; -} +} DEFUN (no_ip_prefix_list_description, no_ip_prefix_list_description_cmd, @@ -1847,18 +1944,23 @@ DEFUN (no_ip_prefix_list_description, "Name of a prefix list\n" "Prefix-list specific description\n") { - return vty_prefix_list_desc_unset (vty, AFI_IP, argv[0]); + int idx_word = 3; + return vty_prefix_list_desc_unset (vty, AFI_IP, argv[idx_word]->arg); } -ALIAS (no_ip_prefix_list_description, - no_ip_prefix_list_description_arg_cmd, - "no ip prefix-list WORD description .LINE", +/* ALIAS_FIXME */ +DEFUN (no_ip_prefix_list_description_comment, + no_ip_prefix_list_description_comment_cmd, + "no ip prefix-list WORD description LINE...", NO_STR IP_STR PREFIX_LIST_STR "Name of a prefix list\n" "Prefix-list specific description\n" "Up to 80 characters describing this prefix-list\n") +{ + return no_ip_prefix_list_description (self, vty, argc, argv); +} DEFUN (show_ip_prefix_list, show_ip_prefix_list_cmd, @@ -1878,12 +1980,13 @@ DEFUN (show_ip_prefix_list_name, PREFIX_LIST_STR "Name of a prefix list\n") { - return vty_show_prefix_list (vty, AFI_IP, argv[0], NULL, normal_display); + int idx_word = 3; + return vty_show_prefix_list (vty, AFI_IP, argv[idx_word]->arg, NULL, normal_display); } DEFUN (show_ip_prefix_list_name_seq, show_ip_prefix_list_name_seq_cmd, - "show ip prefix-list WORD seq <1-4294967295>", + "show ip prefix-list WORD seq (1-4294967295)", SHOW_STR IP_STR PREFIX_LIST_STR @@ -1891,7 +1994,9 @@ DEFUN (show_ip_prefix_list_name_seq, "sequence number of an entry\n" "Sequence number\n") { - return vty_show_prefix_list (vty, AFI_IP, argv[0], argv[1], sequential_display); + int idx_word = 3; + int idx_number = 5; + return vty_show_prefix_list (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, sequential_display); } DEFUN (show_ip_prefix_list_prefix, @@ -1903,7 +2008,9 @@ DEFUN (show_ip_prefix_list_prefix, "Name of a prefix list\n" "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") { - return vty_show_prefix_list_prefix (vty, AFI_IP, argv[0], argv[1], normal_display); + int idx_word = 3; + int idx_ipv4_prefixlen = 4; + return vty_show_prefix_list_prefix (vty, AFI_IP, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg, normal_display); } DEFUN (show_ip_prefix_list_prefix_longer, @@ -1916,7 +2023,9 @@ DEFUN (show_ip_prefix_list_prefix_longer, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Lookup longer prefix\n") { - return vty_show_prefix_list_prefix (vty, AFI_IP, argv[0], argv[1], longer_display); + int idx_word = 3; + int idx_ipv4_prefixlen = 4; + return vty_show_prefix_list_prefix (vty, AFI_IP, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg, longer_display); } DEFUN (show_ip_prefix_list_prefix_first_match, @@ -1929,7 +2038,9 @@ DEFUN (show_ip_prefix_list_prefix_first_match, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "First matched prefix\n") { - return vty_show_prefix_list_prefix (vty, AFI_IP, argv[0], argv[1], first_match_display); + int idx_word = 3; + int idx_ipv4_prefixlen = 4; + return vty_show_prefix_list_prefix (vty, AFI_IP, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg, first_match_display); } DEFUN (show_ip_prefix_list_summary, @@ -1952,7 +2063,8 @@ DEFUN (show_ip_prefix_list_summary_name, "Summary of prefix lists\n" "Name of a prefix list\n") { - return vty_show_prefix_list (vty, AFI_IP, argv[0], NULL, summary_display); + int idx_word = 4; + return vty_show_prefix_list (vty, AFI_IP, argv[idx_word]->arg, NULL, summary_display); } @@ -1976,7 +2088,8 @@ DEFUN (show_ip_prefix_list_detail_name, "Detail of prefix lists\n" "Name of a prefix list\n") { - return vty_show_prefix_list (vty, AFI_IP, argv[0], NULL, detail_display); + int idx_word = 4; + return vty_show_prefix_list (vty, AFI_IP, argv[idx_word]->arg, NULL, detail_display); } DEFUN (clear_ip_prefix_list, @@ -1997,7 +2110,8 @@ DEFUN (clear_ip_prefix_list_name, PREFIX_LIST_STR "Name of a prefix list\n") { - return vty_clear_prefix_list (vty, AFI_IP, argv[0], NULL); + int idx_word = 3; + return vty_clear_prefix_list (vty, AFI_IP, argv[idx_word]->arg, NULL); } DEFUN (clear_ip_prefix_list_name_prefix, @@ -2009,13 +2123,15 @@ DEFUN (clear_ip_prefix_list_name_prefix, "Name of a prefix list\n" "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") { - return vty_clear_prefix_list (vty, AFI_IP, argv[0], argv[1]); + int idx_word = 3; + int idx_ipv4_prefixlen = 4; + return vty_clear_prefix_list (vty, AFI_IP, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg); } #ifdef HAVE_IPV6 DEFUN (ipv6_prefix_list, ipv6_prefix_list_cmd, - "ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)", + "ipv6 prefix-list WORD <deny|permit> <X:X::X:X/M|any>", IPV6_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -2024,13 +2140,16 @@ DEFUN (ipv6_prefix_list, "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" "Any prefix match. Same as \"::0/0 le 128\"\n") { - return vty_prefix_list_install (vty, AFI_IP6, argv[0], NULL, - argv[1], argv[2], NULL, NULL); + int idx_word = 2; + int idx_permit_deny = 3; + int idx_ipv6_any = 4; + return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, NULL, + argv[idx_permit_deny]->arg, argv[idx_ipv6_any]->arg, NULL, NULL); } DEFUN (ipv6_prefix_list_ge, ipv6_prefix_list_ge_cmd, - "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>", + "ipv6 prefix-list WORD <deny|permit> X:X::X:X/M ge (0-128)", IPV6_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -2040,13 +2159,17 @@ DEFUN (ipv6_prefix_list_ge, "Minimum prefix length to be matched\n" "Minimum prefix length\n") { - return vty_prefix_list_install (vty, AFI_IP6, argv[0], NULL, argv[1], - argv[2], argv[3], NULL); + int idx_word = 2; + int idx_permit_deny = 3; + int idx_ipv6_prefixlen = 4; + int idx_number = 6; + return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, + argv[idx_ipv6_prefixlen]->arg, argv[idx_number]->arg, NULL); } DEFUN (ipv6_prefix_list_ge_le, ipv6_prefix_list_ge_le_cmd, - "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>", + "ipv6 prefix-list WORD <deny|permit> X:X::X:X/M ge (0-128) le (0-128)", IPV6_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -2059,13 +2182,18 @@ DEFUN (ipv6_prefix_list_ge_le, "Maximum prefix length\n") { - return vty_prefix_list_install (vty, AFI_IP6, argv[0], NULL, argv[1], - argv[2], argv[3], argv[4]); + int idx_word = 2; + int idx_permit_deny = 3; + int idx_ipv6_prefixlen = 4; + int idx_number = 6; + int idx_number_2 = 8; + return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, + argv[idx_ipv6_prefixlen]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); } DEFUN (ipv6_prefix_list_le, ipv6_prefix_list_le_cmd, - "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128>", + "ipv6 prefix-list WORD <deny|permit> X:X::X:X/M le (0-128)", IPV6_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -2075,13 +2203,17 @@ DEFUN (ipv6_prefix_list_le, "Maximum prefix length to be matched\n" "Maximum prefix length\n") { - return vty_prefix_list_install (vty, AFI_IP6, argv[0], NULL, argv[1], - argv[2], NULL, argv[3]); + int idx_word = 2; + int idx_permit_deny = 3; + int idx_ipv6_prefixlen = 4; + int idx_number = 6; + return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, + argv[idx_ipv6_prefixlen]->arg, NULL, argv[idx_number]->arg); } DEFUN (ipv6_prefix_list_le_ge, ipv6_prefix_list_le_ge_cmd, - "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>", + "ipv6 prefix-list WORD <deny|permit> X:X::X:X/M le (0-128) ge (0-128)", IPV6_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -2093,13 +2225,18 @@ DEFUN (ipv6_prefix_list_le_ge, "Minimum prefix length to be matched\n" "Minimum prefix length\n") { - return vty_prefix_list_install (vty, AFI_IP6, argv[0], NULL, argv[1], - argv[2], argv[4], argv[3]); + int idx_word = 2; + int idx_permit_deny = 3; + int idx_ipv6_prefixlen = 4; + int idx_number = 6; + int idx_number_2 = 8; + return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, + argv[idx_ipv6_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number]->arg); } DEFUN (ipv6_prefix_list_seq, ipv6_prefix_list_seq_cmd, - "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)", + "ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> <X:X::X:X/M|any>", IPV6_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -2110,13 +2247,17 @@ DEFUN (ipv6_prefix_list_seq, "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" "Any prefix match. Same as \"::0/0 le 128\"\n") { - return vty_prefix_list_install (vty, AFI_IP6, argv[0], argv[1], argv[2], - argv[3], NULL, NULL); + int idx_word = 2; + int idx_number = 4; + int idx_permit_deny = 5; + int idx_ipv6_any = 6; + return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv6_any]->arg, NULL, NULL); } DEFUN (ipv6_prefix_list_seq_ge, ipv6_prefix_list_seq_ge_cmd, - "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128>", + "ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> X:X::X:X/M ge (0-128)", IPV6_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -2128,13 +2269,18 @@ DEFUN (ipv6_prefix_list_seq_ge, "Minimum prefix length to be matched\n" "Minimum prefix length\n") { - return vty_prefix_list_install (vty, AFI_IP6, argv[0], argv[1], argv[2], - argv[3], argv[4], NULL); + int idx_word = 2; + int idx_number = 4; + int idx_permit_deny = 5; + int idx_ipv6_prefixlen = 6; + int idx_number_2 = 8; + return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv6_prefixlen]->arg, argv[idx_number_2]->arg, NULL); } DEFUN (ipv6_prefix_list_seq_ge_le, ipv6_prefix_list_seq_ge_le_cmd, - "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <0-128>", + "ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> X:X::X:X/M ge (0-128) le (0-128)", IPV6_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -2148,13 +2294,19 @@ DEFUN (ipv6_prefix_list_seq_ge_le, "Maximum prefix length to be matched\n" "Maximum prefix length\n") { - return vty_prefix_list_install (vty, AFI_IP6, argv[0], argv[1], argv[2], - argv[3], argv[4], argv[5]); + int idx_word = 2; + int idx_number = 4; + int idx_permit_deny = 5; + int idx_ipv6_prefixlen = 6; + int idx_number_2 = 8; + int idx_number_3 = 10; + return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv6_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg); } DEFUN (ipv6_prefix_list_seq_le, ipv6_prefix_list_seq_le_cmd, - "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128>", + "ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> X:X::X:X/M le (0-128)", IPV6_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -2166,13 +2318,18 @@ DEFUN (ipv6_prefix_list_seq_le, "Maximum prefix length to be matched\n" "Maximum prefix length\n") { - return vty_prefix_list_install (vty, AFI_IP6, argv[0], argv[1], argv[2], - argv[3], NULL, argv[4]); + int idx_word = 2; + int idx_number = 4; + int idx_permit_deny = 5; + int idx_ipv6_prefixlen = 6; + int idx_number_2 = 8; + return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv6_prefixlen]->arg, NULL, argv[idx_number_2]->arg); } DEFUN (ipv6_prefix_list_seq_le_ge, ipv6_prefix_list_seq_le_ge_cmd, - "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <0-128>", + "ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> X:X::X:X/M le (0-128) ge (0-128)", IPV6_STR PREFIX_LIST_STR "Name of a prefix list\n" @@ -2186,8 +2343,14 @@ DEFUN (ipv6_prefix_list_seq_le_ge, "Minimum prefix length to be matched\n" "Minimum prefix length\n") { - return vty_prefix_list_install (vty, AFI_IP6, argv[0], argv[1], argv[2], - argv[3], argv[5], argv[4]); + int idx_word = 2; + int idx_number = 4; + int idx_permit_deny = 5; + int idx_ipv6_prefixlen = 6; + int idx_number_2 = 8; + int idx_number_3 = 10; + return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv6_prefixlen]->arg, argv[idx_number_3]->arg, argv[idx_number_2]->arg); } DEFUN (no_ipv6_prefix_list, @@ -2198,13 +2361,14 @@ DEFUN (no_ipv6_prefix_list, PREFIX_LIST_STR "Name of a prefix list\n") { - return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], NULL, NULL, + int idx_word = 3; + return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, NULL, NULL, NULL, NULL, NULL); } DEFUN (no_ipv6_prefix_list_prefix, no_ipv6_prefix_list_prefix_cmd, - "no ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)", + "no ipv6 prefix-list WORD <deny|permit> <X:X::X:X/M|any>", NO_STR IPV6_STR PREFIX_LIST_STR @@ -2214,13 +2378,16 @@ DEFUN (no_ipv6_prefix_list_prefix, "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" "Any prefix match. Same as \"::0/0 le 128\"\n") { - return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], NULL, argv[1], - argv[2], NULL, NULL); + int idx_word = 3; + int idx_permit_deny = 4; + int idx_ipv6_any = 5; + return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, + argv[idx_ipv6_any]->arg, NULL, NULL); } DEFUN (no_ipv6_prefix_list_ge, no_ipv6_prefix_list_ge_cmd, - "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>", + "no ipv6 prefix-list WORD <deny|permit> X:X::X:X/M ge (0-128)", NO_STR IPV6_STR PREFIX_LIST_STR @@ -2231,13 +2398,17 @@ DEFUN (no_ipv6_prefix_list_ge, "Minimum prefix length to be matched\n" "Minimum prefix length\n") { - return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], NULL, argv[1], - argv[2], argv[3], NULL); + int idx_word = 3; + int idx_permit_deny = 4; + int idx_ipv6_prefixlen = 5; + int idx_number = 7; + return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, + argv[idx_ipv6_prefixlen]->arg, argv[idx_number]->arg, NULL); } DEFUN (no_ipv6_prefix_list_ge_le, no_ipv6_prefix_list_ge_le_cmd, - "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>", + "no ipv6 prefix-list WORD <deny|permit> X:X::X:X/M ge (0-128) le (0-128)", NO_STR IPV6_STR PREFIX_LIST_STR @@ -2250,13 +2421,18 @@ DEFUN (no_ipv6_prefix_list_ge_le, "Maximum prefix length to be matched\n" "Maximum prefix length\n") { - return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], NULL, argv[1], - argv[2], argv[3], argv[4]); + int idx_word = 3; + int idx_permit_deny = 4; + int idx_ipv6_prefixlen = 5; + int idx_number = 7; + int idx_number_2 = 9; + return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, + argv[idx_ipv6_prefixlen]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); } DEFUN (no_ipv6_prefix_list_le, no_ipv6_prefix_list_le_cmd, - "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128>", + "no ipv6 prefix-list WORD <deny|permit> X:X::X:X/M le (0-128)", NO_STR IPV6_STR PREFIX_LIST_STR @@ -2267,13 +2443,17 @@ DEFUN (no_ipv6_prefix_list_le, "Maximum prefix length to be matched\n" "Maximum prefix length\n") { - return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], NULL, argv[1], - argv[2], NULL, argv[3]); + int idx_word = 3; + int idx_permit_deny = 4; + int idx_ipv6_prefixlen = 5; + int idx_number = 7; + return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, + argv[idx_ipv6_prefixlen]->arg, NULL, argv[idx_number]->arg); } DEFUN (no_ipv6_prefix_list_le_ge, no_ipv6_prefix_list_le_ge_cmd, - "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>", + "no ipv6 prefix-list WORD <deny|permit> X:X::X:X/M le (0-128) ge (0-128)", NO_STR IPV6_STR PREFIX_LIST_STR @@ -2286,13 +2466,18 @@ DEFUN (no_ipv6_prefix_list_le_ge, "Minimum prefix length to be matched\n" "Minimum prefix length\n") { - return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], NULL, argv[1], - argv[2], argv[4], argv[3]); + int idx_word = 3; + int idx_permit_deny = 4; + int idx_ipv6_prefixlen = 5; + int idx_number = 7; + int idx_number_2 = 9; + return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, + argv[idx_ipv6_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number]->arg); } DEFUN (no_ipv6_prefix_list_seq, no_ipv6_prefix_list_seq_cmd, - "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)", + "no ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> <X:X::X:X/M|any>", NO_STR IPV6_STR PREFIX_LIST_STR @@ -2304,13 +2489,17 @@ DEFUN (no_ipv6_prefix_list_seq, "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" "Any prefix match. Same as \"::0/0 le 128\"\n") { - return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], argv[1], argv[2], - argv[3], NULL, NULL); + int idx_word = 3; + int idx_number = 5; + int idx_permit_deny = 6; + int idx_ipv6_any = 7; + return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv6_any]->arg, NULL, NULL); } DEFUN (no_ipv6_prefix_list_seq_ge, no_ipv6_prefix_list_seq_ge_cmd, - "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128>", + "no ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> X:X::X:X/M ge (0-128)", NO_STR IPV6_STR PREFIX_LIST_STR @@ -2323,13 +2512,18 @@ DEFUN (no_ipv6_prefix_list_seq_ge, "Minimum prefix length to be matched\n" "Minimum prefix length\n") { - return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], argv[1], argv[2], - argv[3], argv[4], NULL); + int idx_word = 3; + int idx_number = 5; + int idx_permit_deny = 6; + int idx_ipv6_prefixlen = 7; + int idx_number_2 = 9; + return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv6_prefixlen]->arg, argv[idx_number_2]->arg, NULL); } DEFUN (no_ipv6_prefix_list_seq_ge_le, no_ipv6_prefix_list_seq_ge_le_cmd, - "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <0-128>", + "no ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> X:X::X:X/M ge (0-128) le (0-128)", NO_STR IPV6_STR PREFIX_LIST_STR @@ -2344,13 +2538,19 @@ DEFUN (no_ipv6_prefix_list_seq_ge_le, "Maximum prefix length to be matched\n" "Maximum prefix length\n") { - return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], argv[1], argv[2], - argv[3], argv[4], argv[5]); + int idx_word = 3; + int idx_number = 5; + int idx_permit_deny = 6; + int idx_ipv6_prefixlen = 7; + int idx_number_2 = 9; + int idx_number_3 = 11; + return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv6_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg); } DEFUN (no_ipv6_prefix_list_seq_le, no_ipv6_prefix_list_seq_le_cmd, - "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128>", + "no ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> X:X::X:X/M le (0-128)", NO_STR IPV6_STR PREFIX_LIST_STR @@ -2363,13 +2563,18 @@ DEFUN (no_ipv6_prefix_list_seq_le, "Maximum prefix length to be matched\n" "Maximum prefix length\n") { - return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], argv[1], argv[2], - argv[3], NULL, argv[4]); + int idx_word = 3; + int idx_number = 5; + int idx_permit_deny = 6; + int idx_ipv6_prefixlen = 7; + int idx_number_2 = 9; + return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv6_prefixlen]->arg, NULL, argv[idx_number_2]->arg); } DEFUN (no_ipv6_prefix_list_seq_le_ge, no_ipv6_prefix_list_seq_le_ge_cmd, - "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <0-128>", + "no ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> X:X::X:X/M le (0-128) ge (0-128)", NO_STR IPV6_STR PREFIX_LIST_STR @@ -2384,8 +2589,14 @@ DEFUN (no_ipv6_prefix_list_seq_le_ge, "Minimum prefix length to be matched\n" "Minimum prefix length\n") { - return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], argv[1], argv[2], - argv[3], argv[5], argv[4]); + int idx_word = 3; + int idx_number = 5; + int idx_permit_deny = 6; + int idx_ipv6_prefixlen = 7; + int idx_number_2 = 9; + int idx_number_3 = 11; + return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, + argv[idx_ipv6_prefixlen]->arg, argv[idx_number_3]->arg, argv[idx_number_2]->arg); } DEFUN (ipv6_prefix_list_sequence_number, @@ -2413,26 +2624,28 @@ DEFUN (no_ipv6_prefix_list_sequence_number, DEFUN (ipv6_prefix_list_description, ipv6_prefix_list_description_cmd, - "ipv6 prefix-list WORD description .LINE", + "ipv6 prefix-list WORD description LINE...", IPV6_STR PREFIX_LIST_STR "Name of a prefix list\n" "Prefix-list specific description\n" "Up to 80 characters describing this prefix-list\n") { + int idx_word = 2; + int iddx_line = 4; struct prefix_list *plist; - plist = prefix_list_get (AFI_IP6, 0, argv[0]); + plist = prefix_list_get (AFI_IP6, 0, argv[idx_word]->arg); if (plist->desc) { XFREE (MTYPE_TMP, plist->desc); plist->desc = NULL; } - plist->desc = argv_concat(argv, argc, 1); + plist->desc = argv_concat(argv, argc, iddx_line); return CMD_SUCCESS; -} +} DEFUN (no_ipv6_prefix_list_description, no_ipv6_prefix_list_description_cmd, @@ -2443,18 +2656,24 @@ DEFUN (no_ipv6_prefix_list_description, "Name of a prefix list\n" "Prefix-list specific description\n") { - return vty_prefix_list_desc_unset (vty, AFI_IP6, argv[0]); + int idx_word = 3; + return vty_prefix_list_desc_unset (vty, AFI_IP6, argv[idx_word]->arg); } -ALIAS (no_ipv6_prefix_list_description, - no_ipv6_prefix_list_description_arg_cmd, - "no ipv6 prefix-list WORD description .LINE", +/* ALIAS_FIXME */ +DEFUN (no_ipv6_prefix_list_description_comment, + no_ipv6_prefix_list_description_comment_cmd, + "no ipv6 prefix-list WORD description LINE...", NO_STR IPV6_STR PREFIX_LIST_STR "Name of a prefix list\n" "Prefix-list specific description\n" "Up to 80 characters describing this prefix-list\n") +{ + return no_ipv6_prefix_list_description_comment (self, vty, argc, argv); +} + DEFUN (show_ipv6_prefix_list, show_ipv6_prefix_list_cmd, @@ -2474,12 +2693,13 @@ DEFUN (show_ipv6_prefix_list_name, PREFIX_LIST_STR "Name of a prefix list\n") { - return vty_show_prefix_list (vty, AFI_IP6, argv[0], NULL, normal_display); + int idx_word = 3; + return vty_show_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, NULL, normal_display); } DEFUN (show_ipv6_prefix_list_name_seq, show_ipv6_prefix_list_name_seq_cmd, - "show ipv6 prefix-list WORD seq <1-4294967295>", + "show ipv6 prefix-list WORD seq (1-4294967295)", SHOW_STR IPV6_STR PREFIX_LIST_STR @@ -2487,7 +2707,9 @@ DEFUN (show_ipv6_prefix_list_name_seq, "sequence number of an entry\n" "Sequence number\n") { - return vty_show_prefix_list (vty, AFI_IP6, argv[0], argv[1], sequential_display); + int idx_word = 3; + int idx_number = 5; + return vty_show_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, sequential_display); } DEFUN (show_ipv6_prefix_list_prefix, @@ -2499,7 +2721,9 @@ DEFUN (show_ipv6_prefix_list_prefix, "Name of a prefix list\n" "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") { - return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[0], argv[1], normal_display); + int idx_word = 3; + int idx_ipv6_prefixlen = 4; + return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, normal_display); } DEFUN (show_ipv6_prefix_list_prefix_longer, @@ -2512,7 +2736,9 @@ DEFUN (show_ipv6_prefix_list_prefix_longer, "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" "Lookup longer prefix\n") { - return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[0], argv[1], longer_display); + int idx_word = 3; + int idx_ipv6_prefixlen = 4; + return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, longer_display); } DEFUN (show_ipv6_prefix_list_prefix_first_match, @@ -2525,7 +2751,9 @@ DEFUN (show_ipv6_prefix_list_prefix_first_match, "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" "First matched prefix\n") { - return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[0], argv[1], first_match_display); + int idx_word = 3; + int idx_ipv6_prefixlen = 4; + return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, first_match_display); } DEFUN (show_ipv6_prefix_list_summary, @@ -2548,7 +2776,8 @@ DEFUN (show_ipv6_prefix_list_summary_name, "Summary of prefix lists\n" "Name of a prefix list\n") { - return vty_show_prefix_list (vty, AFI_IP6, argv[0], NULL, summary_display); + int idx_word = 4; + return vty_show_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, NULL, summary_display); } DEFUN (show_ipv6_prefix_list_detail, @@ -2571,7 +2800,8 @@ DEFUN (show_ipv6_prefix_list_detail_name, "Detail of prefix lists\n" "Name of a prefix list\n") { - return vty_show_prefix_list (vty, AFI_IP6, argv[0], NULL, detail_display); + int idx_word = 4; + return vty_show_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, NULL, detail_display); } DEFUN (clear_ipv6_prefix_list, @@ -2592,7 +2822,8 @@ DEFUN (clear_ipv6_prefix_list_name, PREFIX_LIST_STR "Name of a prefix list\n") { - return vty_clear_prefix_list (vty, AFI_IP6, argv[0], NULL); + int idx_word = 3; + return vty_clear_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, NULL); } DEFUN (clear_ipv6_prefix_list_name_prefix, @@ -2604,7 +2835,9 @@ DEFUN (clear_ipv6_prefix_list_name_prefix, "Name of a prefix list\n" "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") { - return vty_clear_prefix_list (vty, AFI_IP6, argv[0], argv[1]); + int idx_word = 3; + int idx_ipv6_prefixlen = 4; + return vty_clear_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg); } #endif /* HAVE_IPV6 */ @@ -2960,7 +3193,7 @@ prefix_list_init_ipv4 (void) install_element (CONFIG_NODE, &ip_prefix_list_description_cmd); install_element (CONFIG_NODE, &no_ip_prefix_list_description_cmd); - install_element (CONFIG_NODE, &no_ip_prefix_list_description_arg_cmd); + install_element (CONFIG_NODE, &no_ip_prefix_list_description_comment_cmd); install_element (CONFIG_NODE, &ip_prefix_list_sequence_number_cmd); install_element (CONFIG_NODE, &no_ip_prefix_list_sequence_number_cmd); @@ -3026,7 +3259,7 @@ prefix_list_init_ipv6 (void) install_element (CONFIG_NODE, &ipv6_prefix_list_description_cmd); install_element (CONFIG_NODE, &no_ipv6_prefix_list_description_cmd); - install_element (CONFIG_NODE, &no_ipv6_prefix_list_description_arg_cmd); + install_element (CONFIG_NODE, &no_ipv6_prefix_list_description_comment_cmd); install_element (CONFIG_NODE, &ipv6_prefix_list_sequence_number_cmd); install_element (CONFIG_NODE, &no_ipv6_prefix_list_sequence_number_cmd); diff --git a/lib/route_types.txt b/lib/route_types.txt index 54572450b5..56e8c14567 100644 --- a/lib/route_types.txt +++ b/lib/route_types.txt @@ -48,7 +48,7 @@ ZEBRA_ROUTE_STATIC, static, zebra, 'S', 1, 1, "static" ZEBRA_ROUTE_RIP, rip, ripd, 'R', 1, 0, "RIP" ZEBRA_ROUTE_RIPNG, ripng, ripngd, 'R', 0, 1, "RIPng" ZEBRA_ROUTE_OSPF, ospf, ospfd, 'O', 1, 0, "OSPF" -ZEBRA_ROUTE_OSPF6, ospf6, ospf6d, 'O', 0, 1, "OSPFv6" +ZEBRA_ROUTE_OSPF6, ospf6, ospf6d, 'O', 0, 1, "OSPFv3" ZEBRA_ROUTE_ISIS, isis, isisd, 'I', 1, 1, "IS-IS" ZEBRA_ROUTE_BGP, bgp, bgpd, 'B', 1, 1, "BGP" ZEBRA_ROUTE_PIM, pim, pimd, 'P', 1, 0, "PIM" diff --git a/lib/routemap.c b/lib/routemap.c index 7b07499533..dc89390a96 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -24,9 +24,9 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "memory.h" #include "vector.h" #include "prefix.h" +#include "vty.h" #include "routemap.h" #include "command.h" -#include "vty.h" #include "log.h" #include "hash.h" @@ -47,6 +47,594 @@ static vector route_match_vec; /* Vector for route set rules. */ static vector route_set_vec; +struct route_map_match_set_hooks +{ + /* match interface */ + int (*match_interface) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match interface */ + int (*no_match_interface) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* match ip address */ + int (*match_ip_address) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match ip address */ + int (*no_match_ip_address) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* match ip address prefix list */ + int (*match_ip_address_prefix_list) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match ip address prefix list */ + int (*no_match_ip_address_prefix_list) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* match ip next hop */ + int (*match_ip_next_hop) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match ip next hop */ + int (*no_match_ip_next_hop) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* match ip next hop prefix list */ + int (*match_ip_next_hop_prefix_list) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match ip next hop prefix list */ + int (*no_match_ip_next_hop_prefix_list) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* match ipv6 address */ + int (*match_ipv6_address) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match ipv6 address */ + int (*no_match_ipv6_address) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + + /* match ipv6 address prefix list */ + int (*match_ipv6_address_prefix_list) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match ipv6 address prefix list */ + int (*no_match_ipv6_address_prefix_list) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* match metric */ + int (*match_metric) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match metric */ + int (*no_match_metric) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* match tag */ + int (*match_tag) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match tag */ + int (*no_match_tag) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* set ip nexthop */ + int (*set_ip_nexthop) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg); + + /* no set ip nexthop */ + int (*no_set_ip_nexthop) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg); + + /* set ipv6 nexthop local */ + int (*set_ipv6_nexthop_local) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg); + + /* no set ipv6 nexthop local */ + int (*no_set_ipv6_nexthop_local) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg); + + /* set metric */ + int (*set_metric) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg); + + /* no set metric */ + int (*no_set_metric) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg); + + /* set tag */ + int (*set_tag) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg); + + /* no set tag */ + int (*no_set_tag) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg); + +}; + +struct route_map_match_set_hooks rmap_match_set_hook; + +/* match interface */ +void +route_map_match_interface_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.match_interface = func; +} + +/* no match interface */ +void +route_map_no_match_interface_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.no_match_interface = func; +} + +/* match ip address */ +void +route_map_match_ip_address_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.match_ip_address = func; +} + +/* no match ip address */ +void +route_map_no_match_ip_address_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.no_match_ip_address = func; +} + +/* match ip address prefix list */ +void +route_map_match_ip_address_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.match_ip_address_prefix_list = func; +} + +/* no match ip address prefix list */ +void +route_map_no_match_ip_address_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.no_match_ip_address_prefix_list = func; +} + +/* match ip next hop */ +void +route_map_match_ip_next_hop_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.match_ip_next_hop = func; +} + +/* no match ip next hop */ +void +route_map_no_match_ip_next_hop_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.no_match_ip_next_hop = func; +} + +/* match ip next hop prefix list */ +void +route_map_match_ip_next_hop_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.match_ip_next_hop_prefix_list = func; +} + +/* no match ip next hop prefix list */ +void +route_map_no_match_ip_next_hop_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.no_match_ip_next_hop_prefix_list = func; +} + +/* match ipv6 address */ +void +route_map_match_ipv6_address_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.match_ipv6_address = func; +} + +/* no match ipv6 address */ +void +route_map_no_match_ipv6_address_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.no_match_ipv6_address = func; +} + + +/* match ipv6 address prefix list */ +void +route_map_match_ipv6_address_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.match_ipv6_address_prefix_list = func; +} + +/* no match ipv6 address prefix list */ +void +route_map_no_match_ipv6_address_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.no_match_ipv6_address_prefix_list = func; +} + +/* match metric */ +void +route_map_match_metric_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.match_metric = func; +} + +/* no match metric */ +void +route_map_no_match_metric_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.no_match_metric = func; +} + +/* match tag */ +void +route_map_match_tag_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.match_tag = func; +} + +/* no match tag */ +void +route_map_no_match_tag_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.no_match_tag = func; +} + +/* set ip nexthop */ +void +route_map_set_ip_nexthop_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)) +{ + rmap_match_set_hook.set_ip_nexthop = func; +} + +/* no set ip nexthop */ +void +route_map_no_set_ip_nexthop_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)) +{ + rmap_match_set_hook.no_set_ip_nexthop = func; +} + +/* set ipv6 nexthop local */ +void +route_map_set_ipv6_nexthop_local_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)) +{ + rmap_match_set_hook.set_ipv6_nexthop_local = func; +} + +/* no set ipv6 nexthop local */ +void +route_map_no_set_ipv6_nexthop_local_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)) +{ + rmap_match_set_hook.no_set_ipv6_nexthop_local = func; +} + +/* set metric */ +void +route_map_set_metric_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)) +{ + rmap_match_set_hook.set_metric = func; +} + +/* no set metric */ +void +route_map_no_set_metric_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)) +{ + rmap_match_set_hook.no_set_metric = func; +} + +/* set tag */ +void +route_map_set_tag_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)) +{ + rmap_match_set_hook.set_tag = func; +} + +/* no set tag */ +void +route_map_no_set_tag_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)) +{ + rmap_match_set_hook.no_set_tag = func; +} + +int +generic_match_add (struct vty *vty, struct route_map_index *index, + const char *command, const char *arg, + route_map_event_t type) +{ + int ret; + + ret = route_map_add_match (index, command, arg); + if (ret) + { + switch (ret) + { + case RMAP_RULE_MISSING: + vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); + return CMD_WARNING; + case RMAP_COMPILE_ERROR: + vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); + return CMD_WARNING; + } + } + + if (type != RMAP_EVENT_MATCH_ADDED) + { + route_map_upd8_dependency (type, arg, index->map->name); + } + return CMD_SUCCESS; +} + +int +generic_match_delete (struct vty *vty, struct route_map_index *index, + const char *command, const char *arg, + route_map_event_t type) +{ + int ret; + char *dep_name = NULL; + const char *tmpstr; + char *rmap_name = NULL; + + if (type != RMAP_EVENT_MATCH_DELETED) + { + /* ignore the mundane, the types without any dependency */ + if (arg == NULL) + { + if ((tmpstr = route_map_get_match_arg(index, command)) != NULL) + dep_name = XSTRDUP(MTYPE_ROUTE_MAP_RULE, tmpstr); + } + else + { + dep_name = XSTRDUP(MTYPE_ROUTE_MAP_RULE, arg); + } + rmap_name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, index->map->name); + } + + ret = route_map_delete_match (index, command, dep_name); + if (ret) + { + switch (ret) + { + case RMAP_RULE_MISSING: + vty_out (vty, "%% BGP Can't find rule.%s", VTY_NEWLINE); + break; + case RMAP_COMPILE_ERROR: + vty_out (vty, "%% BGP Argument is malformed.%s", VTY_NEWLINE); + break; + } + if (dep_name) + XFREE(MTYPE_ROUTE_MAP_RULE, dep_name); + if (rmap_name) + XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name); + return CMD_WARNING; + } + + if (type != RMAP_EVENT_MATCH_DELETED && dep_name) + route_map_upd8_dependency(type, dep_name, rmap_name); + + if (dep_name) + XFREE(MTYPE_ROUTE_MAP_RULE, dep_name); + if (rmap_name) + XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name); + + return CMD_SUCCESS; +} + +int +generic_set_add (struct vty *vty, struct route_map_index *index, + const char *command, const char *arg) +{ + int ret; + + ret = route_map_add_set (index, command, arg); + if (ret) + { + switch (ret) + { + case RMAP_RULE_MISSING: + vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); + return CMD_WARNING; + case RMAP_COMPILE_ERROR: + vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); + return CMD_WARNING; + } + } + return CMD_SUCCESS; +} + +int +generic_set_delete (struct vty *vty, struct route_map_index *index, + const char *command, const char *arg) +{ + int ret; + + ret = route_map_delete_set (index, command, arg); + if (ret) + { + switch (ret) + { + case RMAP_RULE_MISSING: + vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); + return CMD_WARNING; + case RMAP_COMPILE_ERROR: + vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); + return CMD_WARNING; + } + } + return CMD_SUCCESS; +} + + /* Route map rule. This rule has both `match' rule and `set' rule. */ struct route_map_rule { @@ -1386,49 +1974,578 @@ route_map_notify_dependencies (const char *affected_name, route_map_event_t even XFREE (MTYPE_ROUTE_MAP_NAME, name); } + /* VTY related functions. */ -DEFUN (route_map, - route_map_cmd, - "route-map WORD (deny|permit) <1-65535>", - "Create route-map or enter route-map command mode\n" - "Route map tag\n" - "Route map denies set operations\n" - "Route map permits set operations\n" - "Sequence to insert to/delete from existing route-map entry\n") +DEFUN (match_interface, + match_interface_cmd, + "match interface WORD", + MATCH_STR + "match first hop interface of route\n" + "Interface name\n") +{ + int idx_word = 2; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.match_interface) + return rmap_match_set_hook.match_interface (vty, index, "interface", argv[idx_word]->arg, RMAP_EVENT_MATCH_ADDED); + return CMD_SUCCESS; +} + +DEFUN (no_match_interface, + no_match_interface_cmd, + "no match interface [INTERFACE]", + NO_STR + MATCH_STR + "Match first hop interface of route\n" + "Interface name\n") { - int permit; - unsigned long pref; - struct route_map *map; - struct route_map_index *index; - char *endptr = NULL; + char *iface = (argc == 4) ? argv[3]->arg : NULL; + VTY_DECLVAR_CONTEXT (route_map_index, index); - /* Permit check. */ - if (strncmp (argv[1], "permit", strlen (argv[1])) == 0) - permit = RMAP_PERMIT; - else if (strncmp (argv[1], "deny", strlen (argv[1])) == 0) - permit = RMAP_DENY; - else + if (rmap_match_set_hook.no_match_interface) + return rmap_match_set_hook.no_match_interface (vty, index, "interface", iface, RMAP_EVENT_MATCH_DELETED); + return CMD_SUCCESS; +} + + +DEFUN (match_ip_address, + match_ip_address_cmd, + "match ip address <(1-199)|(1300-2699)|WORD>", + MATCH_STR + IP_STR + "Match address of route\n" + "IP access-list number\n" + "IP access-list number (expanded range)\n" + "IP Access-list name\n") +{ + int idx_acl = 3; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.match_ip_address) + return rmap_match_set_hook.match_ip_address (vty, index, "ip address", argv[idx_acl]->arg, + RMAP_EVENT_FILTER_ADDED); + return CMD_SUCCESS; +} + + +DEFUN (no_match_ip_address, + no_match_ip_address_cmd, + "no match ip address [<(1-199)|(1300-2699)|WORD>]", + NO_STR + MATCH_STR + IP_STR + "Match address of route\n" + "IP access-list number\n" + "IP access-list number (expanded range)\n" + "IP Access-list name\n") +{ + int idx_word = 4; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.no_match_ip_address) { - vty_out (vty, "the third field must be [permit|deny]%s", VTY_NEWLINE); + if (argc <= idx_word) + return rmap_match_set_hook.no_match_ip_address (vty, index, "ip address", NULL, + RMAP_EVENT_FILTER_DELETED); + return rmap_match_set_hook.no_match_ip_address (vty, index, "ip address", argv[idx_word]->arg, + RMAP_EVENT_FILTER_DELETED); + } + return CMD_SUCCESS; +} + + +DEFUN (match_ip_address_prefix_list, + match_ip_address_prefix_list_cmd, + "match ip address prefix-list WORD", + MATCH_STR + IP_STR + "Match address of route\n" + "Match entries of prefix-lists\n" + "IP prefix-list name\n") +{ + int idx_word = 4; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.match_ip_address_prefix_list) + return rmap_match_set_hook.match_ip_address_prefix_list (vty, index, "ip address prefix-list", + argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED); + return CMD_SUCCESS; +} + + +DEFUN (no_match_ip_address_prefix_list, + no_match_ip_address_prefix_list_cmd, + "no match ip address prefix-list [WORD]", + NO_STR + MATCH_STR + IP_STR + "Match address of route\n" + "Match entries of prefix-lists\n" + "IP prefix-list name\n") +{ + int idx_word = 5; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.no_match_ip_address_prefix_list) + { + if (argc <= idx_word) + return rmap_match_set_hook.no_match_ip_address_prefix_list (vty, index, "ip address prefix-list", + NULL, RMAP_EVENT_PLIST_DELETED); + return rmap_match_set_hook.no_match_ip_address_prefix_list(vty, index, "ip address prefix-list", + argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED); + } + return CMD_SUCCESS; +} + + +DEFUN (match_ip_next_hop, + match_ip_next_hop_cmd, + "match ip next-hop <(1-199)|(1300-2699)|WORD>", + MATCH_STR + IP_STR + "Match next-hop address of route\n" + "IP access-list number\n" + "IP access-list number (expanded range)\n" + "IP Access-list name\n") +{ + int idx_acl = 3; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.match_ip_next_hop) + return rmap_match_set_hook.match_ip_next_hop (vty, index, "ip next-hop", argv[idx_acl]->arg, + RMAP_EVENT_FILTER_ADDED); + return CMD_SUCCESS; +} + + +DEFUN (no_match_ip_next_hop, + no_match_ip_next_hop_cmd, + "no match ip next-hop [<(1-199)|(1300-2699)|WORD>]", + NO_STR + MATCH_STR + IP_STR + "Match next-hop address of route\n" + "IP access-list number\n" + "IP access-list number (expanded range)\n" + "IP Access-list name\n") +{ + int idx_word = 4; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.no_match_ip_next_hop) + { + if (argc <= idx_word) + return rmap_match_set_hook.no_match_ip_next_hop (vty, index, "ip next-hop", NULL, + RMAP_EVENT_FILTER_DELETED); + return rmap_match_set_hook.no_match_ip_next_hop (vty, index, "ip next-hop", argv[idx_word]->arg, + RMAP_EVENT_FILTER_DELETED); + } + return CMD_SUCCESS; +} + + +DEFUN (match_ip_next_hop_prefix_list, + match_ip_next_hop_prefix_list_cmd, + "match ip next-hop prefix-list WORD", + MATCH_STR + IP_STR + "Match next-hop address of route\n" + "Match entries of prefix-lists\n" + "IP prefix-list name\n") +{ + int idx_word = 4; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.match_ip_next_hop_prefix_list) + return rmap_match_set_hook.match_ip_next_hop_prefix_list (vty, index, "ip next-hop prefix-list", + argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED); + return CMD_SUCCESS; +} + +DEFUN (no_match_ip_next_hop_prefix_list, + no_match_ip_next_hop_prefix_list_cmd, + "no match ip next-hop prefix-list [WORD]", + NO_STR + MATCH_STR + IP_STR + "Match next-hop address of route\n" + "Match entries of prefix-lists\n" + "IP prefix-list name\n") +{ + int idx_word = 5; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.no_match_ip_next_hop) + { + if (argc <= idx_word) + return rmap_match_set_hook.no_match_ip_next_hop (vty, index, "ip next-hop prefix-list", + NULL, RMAP_EVENT_PLIST_DELETED); + return rmap_match_set_hook.no_match_ip_next_hop (vty, index, "ip next-hop prefix-list", + argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED); + } + return CMD_SUCCESS; +} + + +DEFUN (match_ipv6_address, + match_ipv6_address_cmd, + "match ipv6 address WORD", + MATCH_STR + IPV6_STR + "Match IPv6 address of route\n" + "IPv6 access-list name\n") +{ + int idx_word = 3; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.match_ipv6_address) + return rmap_match_set_hook.match_ipv6_address (vty, index, "ipv6 address", argv[idx_word]->arg, + RMAP_EVENT_FILTER_ADDED); + return CMD_SUCCESS; +} + +DEFUN (no_match_ipv6_address, + no_match_ipv6_address_cmd, + "no match ipv6 address WORD", + NO_STR + MATCH_STR + IPV6_STR + "Match IPv6 address of route\n" + "IPv6 access-list name\n") +{ + int idx_word = 4; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.no_match_ipv6_address) + return rmap_match_set_hook.no_match_ipv6_address (vty, index, "ipv6 address", argv[idx_word]->arg, + RMAP_EVENT_FILTER_DELETED); + return CMD_SUCCESS; +} + + +DEFUN (match_ipv6_address_prefix_list, + match_ipv6_address_prefix_list_cmd, + "match ipv6 address prefix-list WORD", + MATCH_STR + IPV6_STR + "Match address of route\n" + "Match entries of prefix-lists\n" + "IP prefix-list name\n") +{ + int idx_word = 4; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.match_ipv6_address_prefix_list) + return rmap_match_set_hook.match_ipv6_address_prefix_list (vty, index, "ipv6 address prefix-list", + argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED); + return CMD_SUCCESS; +} + +DEFUN (no_match_ipv6_address_prefix_list, + no_match_ipv6_address_prefix_list_cmd, + "no match ipv6 address prefix-list WORD", + NO_STR + MATCH_STR + IPV6_STR + "Match address of route\n" + "Match entries of prefix-lists\n" + "IP prefix-list name\n") +{ + int idx_word = 5; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.no_match_ipv6_address_prefix_list) + return rmap_match_set_hook.no_match_ipv6_address_prefix_list(vty, index, "ipv6 address prefix-list", + argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED); + return CMD_SUCCESS; +} + + +DEFUN (match_metric, + match_metric_cmd, + "match metric (0-4294967295)", + MATCH_STR + "Match metric of route\n" + "Metric value\n") +{ + int idx_number = 2; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.match_metric) + return rmap_match_set_hook.match_metric(vty, index, "metric", argv[idx_number]->arg, + RMAP_EVENT_MATCH_ADDED); + return CMD_SUCCESS; +} + + +DEFUN (no_match_metric, + no_match_metric_cmd, + "no match metric [(0-4294967295)]", + NO_STR + MATCH_STR + "Match metric of route\n" + "Metric value\n") +{ + int idx_number = 3; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.no_match_metric) + { + if (argc <= idx_number) + return rmap_match_set_hook.no_match_metric (vty, index, "metric", + NULL, RMAP_EVENT_MATCH_DELETED); + return rmap_match_set_hook.no_match_metric(vty, index, "metric", + argv[idx_number]->arg, + RMAP_EVENT_MATCH_DELETED); + } + return CMD_SUCCESS; +} + + +DEFUN (match_tag, + match_tag_cmd, + "match tag (1-4294967295)", + MATCH_STR + "Match tag of route\n" + "Tag value\n") +{ + int idx_number = 2; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.match_tag) + return rmap_match_set_hook.match_tag(vty, index, "tag", argv[idx_number]->arg, + RMAP_EVENT_MATCH_ADDED); + return CMD_SUCCESS; +} + + +DEFUN (no_match_tag, + no_match_tag_cmd, + "no match tag [(1-4294967295)]", + NO_STR + MATCH_STR + "Match tag of route\n" + "Tag value\n") +{ + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.no_match_tag) + return rmap_match_set_hook.no_match_tag (vty, index, "tag", argv[3]->arg, + RMAP_EVENT_MATCH_DELETED); + return CMD_SUCCESS; +} + + +DEFUN (set_ip_nexthop, + set_ip_nexthop_cmd, + "set ip next-hop A.B.C.D", + SET_STR + IP_STR + "Next hop address\n" + "IP address of next hop\n") +{ + int idx_ipv4 = 3; + union sockunion su; + int ret; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + ret = str2sockunion (argv[idx_ipv4]->arg, &su); + if (ret < 0) + { + vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE); + return CMD_WARNING; + } + if (su.sin.sin_addr.s_addr == 0 || + IPV4_CLASS_DE(su.sin.sin_addr.s_addr)) + { + vty_out (vty, "%% nexthop address cannot be 0.0.0.0, multicast " + "or reserved%s", VTY_NEWLINE); return CMD_WARNING; } - /* Preference check. */ - pref = strtoul (argv[2], &endptr, 10); - if (pref == ULONG_MAX || *endptr != '\0') + if (rmap_match_set_hook.set_ip_nexthop) + return rmap_match_set_hook.set_ip_nexthop(vty, index, "ip next-hop", argv[idx_ipv4]->arg); + return CMD_SUCCESS; +} + + +DEFUN (no_set_ip_nexthop, + no_set_ip_nexthop_cmd, + "no set ip next-hop [<peer-address|A.B.C.D>]", + NO_STR + SET_STR + "Next hop address\n" + "Use peer address (for BGP only)\n" + "IP address of next hop\n") +{ + int idx_peer = 4; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.no_set_ip_nexthop) { - vty_out (vty, "the fourth field must be positive integer%s", - VTY_NEWLINE); + if (argc <= idx_peer) + return rmap_match_set_hook.no_set_ip_nexthop (vty, index, "ip next-hop", NULL); + return rmap_match_set_hook.no_set_ip_nexthop (vty, index, "ip next-hop", argv[idx_peer]->arg); + } + return CMD_SUCCESS; +} + + +DEFUN (set_ipv6_nexthop_local, + set_ipv6_nexthop_local_cmd, + "set ipv6 next-hop local X:X::X:X", + SET_STR + IPV6_STR + "IPv6 next-hop address\n" + "IPv6 local address\n" + "IPv6 address of next hop\n") +{ + int idx_ipv6 = 4; + struct in6_addr addr; + int ret; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + ret = inet_pton (AF_INET6, argv[idx_ipv6]->arg, &addr); + if (!ret) + { + vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE); return CMD_WARNING; } - if (pref == 0 || pref > 65535) + if (!IN6_IS_ADDR_LINKLOCAL(&addr)) { - vty_out (vty, "the fourth field must be <1-65535>%s", VTY_NEWLINE); + vty_out (vty, "%% Invalid link-local nexthop address%s", VTY_NEWLINE); return CMD_WARNING; } + if (rmap_match_set_hook.set_ipv6_nexthop_local) + return rmap_match_set_hook.set_ipv6_nexthop_local (vty, index, "ipv6 next-hop local", argv[idx_ipv6]->arg); + return CMD_SUCCESS; +} + + +DEFUN (no_set_ipv6_nexthop_local, + no_set_ipv6_nexthop_local_cmd, + "no set ipv6 next-hop local [X:X::X:X]", + NO_STR + SET_STR + IPV6_STR + "IPv6 next-hop address\n" + "IPv6 local address\n" + "IPv6 address of next hop\n") +{ + int idx_ipv6 = 5; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.no_set_ipv6_nexthop_local) + { + if (argc <= idx_ipv6) + return rmap_match_set_hook.no_set_ipv6_nexthop_local (vty, index, "ipv6 next-hop local", NULL); + return rmap_match_set_hook.no_set_ipv6_nexthop_local (vty, index, "ipv6 next-hop local", argv[5]->arg); + } + return CMD_SUCCESS; +} + +DEFUN (set_metric, + set_metric_cmd, + "set metric <(0-4294967295)|rtt|+rtt|-rtt|+metric|-metric>", + SET_STR + "Metric value for destination routing protocol\n" + "Metric value\n" + "Assign round trip time\n" + "Add round trip time\n" + "Subtract round trip time\n" + "Add metric\n" + "Subtract metric\n") +{ + int idx_number = 2; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.set_metric) + return rmap_match_set_hook.set_metric (vty, index, "metric", argv[idx_number]->arg); + return CMD_SUCCESS; +} + + +DEFUN (no_set_metric, + no_set_metric_cmd, + "no set metric [(0-4294967295)]", + NO_STR + SET_STR + "Metric value for destination routing protocol\n" + "Metric value\n") +{ + int idx_number = 3; + VTY_DECLVAR_CONTEXT (route_map_index, index); + + if (rmap_match_set_hook.no_set_metric) + { + if (argc <= idx_number) + return rmap_match_set_hook.no_set_metric (vty, index, "metric", NULL); + return rmap_match_set_hook.no_set_metric (vty, index, "metric", argv[idx_number]->arg); + } + return CMD_SUCCESS; +} + + +DEFUN (set_tag, + set_tag_cmd, + "set tag (1-4294967295)", + SET_STR + "Tag value for routing protocol\n" + "Tag value\n") +{ + VTY_DECLVAR_CONTEXT (route_map_index, index); + + int idx_number = 2; + if (rmap_match_set_hook.set_tag) + return rmap_match_set_hook.set_tag (vty, index, "tag", argv[idx_number]->arg); + return CMD_SUCCESS; +} + + +DEFUN (no_set_tag, + no_set_tag_cmd, + "no set tag [(1-4294967295)]", + NO_STR + SET_STR + "Tag value for routing protocol\n" + "Tag value\n") +{ + VTY_DECLVAR_CONTEXT (route_map_index, index); + + int idx_number = 3; + if (rmap_match_set_hook.no_set_tag) + { + if (argc <= idx_number) + return rmap_match_set_hook.no_set_tag (vty, index, "tag", NULL); + return rmap_match_set_hook.no_set_tag (vty, index, "tag", argv[idx_number]->arg); + } + return CMD_SUCCESS; +} + + + +DEFUN (route_map, + route_map_cmd, + "route-map WORD <deny|permit> (1-65535)", + "Create route-map or enter route-map command mode\n" + "Route map tag\n" + "Route map denies set operations\n" + "Route map permits set operations\n" + "Sequence to insert to/delete from existing route-map entry\n") +{ + int idx_word = 1; + int idx_permit_deny = 2; + int idx_number = 3; + struct route_map *map; + struct route_map_index *index; + char *endptr = NULL; + int permit = argv[idx_permit_deny]->arg[0] == 'p' ? RMAP_PERMIT : RMAP_DENY; + unsigned long pref = strtoul (argv[idx_number]->arg, &endptr, 10); + const char *mapname = argv[idx_word]->arg; + /* Get route map. */ - map = route_map_get (argv[0]); + map = route_map_get (mapname); index = route_map_index_get (map, permit, pref); VTY_PUSH_CONTEXT_COMPAT (RMAP_NODE, index); @@ -1442,13 +2559,14 @@ DEFUN (no_route_map_all, "Create route-map or enter route-map command mode\n" "Route map tag\n") { + int idx_word = 2; + const char *mapname = argv[idx_word]->arg; struct route_map *map; - map = route_map_lookup_by_name (argv[0]); + map = route_map_lookup_by_name (mapname); if (map == NULL) { - vty_out (vty, "%% Could not find route-map %s%s", - argv[0], VTY_NEWLINE); + vty_out (vty, "%% Could not find route-map %s%s", mapname, VTY_NEWLINE); return CMD_WARNING; } @@ -1459,7 +2577,7 @@ DEFUN (no_route_map_all, DEFUN (no_route_map, no_route_map_cmd, - "no route-map WORD (deny|permit) <1-65535>", + "no route-map WORD <deny|permit> (1-65535)", NO_STR "Create route-map or enter route-map command mode\n" "Route map tag\n" @@ -1467,43 +2585,22 @@ DEFUN (no_route_map, "Route map permits set operations\n" "Sequence to insert to/delete from existing route-map entry\n") { - int permit; - unsigned long pref; + int idx_word = 2; + int idx_permit_deny = 3; + int idx_number = 4; struct route_map *map; struct route_map_index *index; char *endptr = NULL; - - /* Permit check. */ - if (strncmp (argv[1], "permit", strlen (argv[1])) == 0) - permit = RMAP_PERMIT; - else if (strncmp (argv[1], "deny", strlen (argv[1])) == 0) - permit = RMAP_DENY; - else - { - vty_out (vty, "the third field must be [permit|deny]%s", VTY_NEWLINE); - return CMD_WARNING; - } - - /* Preference. */ - pref = strtoul (argv[2], &endptr, 10); - if (pref == ULONG_MAX || *endptr != '\0') - { - vty_out (vty, "the fourth field must be positive integer%s", - VTY_NEWLINE); - return CMD_WARNING; - } - if (pref == 0 || pref > 65535) - { - vty_out (vty, "the fourth field must be <1-65535>%s", VTY_NEWLINE); - return CMD_WARNING; - } + int permit = argv[idx_permit_deny]->arg[0] == 'p' ? RMAP_PERMIT : RMAP_DENY; + const char *prefstr = argv[idx_number]->arg; + const char *mapname = argv[idx_word]->arg; + unsigned long pref = strtoul (prefstr, &endptr, 10); /* Existence check. */ - map = route_map_lookup_by_name (argv[0]); + map = route_map_lookup_by_name (mapname); if (map == NULL) { - vty_out (vty, "%% Could not find route-map %s%s", - argv[0], VTY_NEWLINE); + vty_out (vty, "%% Could not find route-map %s%s", mapname, VTY_NEWLINE); return CMD_WARNING; } @@ -1512,7 +2609,7 @@ DEFUN (no_route_map, if (index == NULL) { vty_out (vty, "%% Could not find route-map entry %s %s%s", - argv[0], argv[2], VTY_NEWLINE); + mapname, prefstr, VTY_NEWLINE); return CMD_WARNING; } @@ -1556,7 +2653,7 @@ DEFUN (no_rmap_onmatch_next, "Next clause\n") { struct route_map_index *index = VTY_GET_CONTEXT (route_map_index); - + if (index) index->exitpolicy = RMAP_EXIT; @@ -1565,11 +2662,16 @@ DEFUN (no_rmap_onmatch_next, DEFUN (rmap_onmatch_goto, rmap_onmatch_goto_cmd, - "on-match goto <1-65535>", + "on-match goto (1-65535)", "Exit policy on matches\n" "Goto Clause number\n" "Number\n") { + int idx_number = 2; + char *num = NULL; + num = argv[idx_number]->arg; + + struct route_map_index *index = VTY_GET_CONTEXT (route_map_index); int d = 0; @@ -1583,16 +2685,15 @@ DEFUN (rmap_onmatch_goto, return CMD_WARNING; } - if (argc == 1 && argv[0]) - VTY_GET_INTEGER_RANGE("route-map index", d, argv[0], 1, 65535); + if (num) + VTY_GET_INTEGER_RANGE("route-map index", d, num, 1, 65535); else d = index->pref + 1; if (d <= index->pref) { /* Can't allow you to do that, Dave */ - vty_out (vty, "can't jump backwards in route-maps%s", - VTY_NEWLINE); + vty_out (vty, "can't jump backwards in route-maps%s", VTY_NEWLINE); return CMD_WARNING; } else @@ -1619,31 +2720,28 @@ DEFUN (no_rmap_onmatch_goto, return CMD_SUCCESS; } -/* Cisco/GNU Zebra compatible ALIASes for on-match next */ -ALIAS (rmap_onmatch_goto, +/* Cisco/GNU Zebra compatibility aliases */ +/* ALIAS_FIXME */ +DEFUN (rmap_continue, rmap_continue_cmd, - "continue", - "Continue on a different entry within the route-map\n") - -ALIAS (no_rmap_onmatch_goto, - no_rmap_continue_cmd, - "no continue", - NO_STR - "Continue on a different entry within the route-map\n") - -/* GNU Zebra compatible */ -ALIAS (rmap_onmatch_goto, - rmap_continue_seq_cmd, - "continue <1-65535>", + "continue (1-65535)", "Continue on a different entry within the route-map\n" "Route-map entry sequence number\n") +{ + return rmap_onmatch_goto (self, vty, argc, argv); +} -ALIAS (no_rmap_onmatch_goto, - no_rmap_continue_seq, - "no continue <1-65535>", +/* ALIAS_FIXME */ +DEFUN (no_rmap_continue, + no_rmap_continue_cmd, + "no continue [(1-65535)]", NO_STR "Continue on a different entry within the route-map\n" "Route-map entry sequence number\n") +{ + return no_rmap_onmatch_goto (self, vty, argc, argv); +} + DEFUN (rmap_show_name, rmap_show_name_cmd, @@ -1652,25 +2750,20 @@ DEFUN (rmap_show_name, "route-map information\n" "route-map name\n") { - const char *name = NULL; - if (argc) - name = argv[0]; - return vty_show_route_map (vty, name); + int idx_word = 2; + const char *name = (argc == 3) ? argv[idx_word]->arg : NULL; + return vty_show_route_map (vty, name); } -ALIAS (rmap_onmatch_goto, - rmap_continue_index_cmd, - "continue <1-65535>", - "Exit policy on matches\n" - "Goto Clause number\n") - DEFUN (rmap_call, rmap_call_cmd, "call WORD", "Jump to another Route-Map after match+set\n" "Target route-map name\n") { + int idx_word = 1; struct route_map_index *index = VTY_GET_CONTEXT (route_map_index); + const char *rmap = argv[idx_word]->arg; if (index) { @@ -1681,7 +2774,7 @@ DEFUN (rmap_call, index->map->name); XFREE (MTYPE_ROUTE_MAP_NAME, index->nextrm); } - index->nextrm = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[0]); + index->nextrm = XSTRDUP (MTYPE_ROUTE_MAP_NAME, rmap); } /* Execute event hook. */ @@ -1713,17 +2806,18 @@ DEFUN (no_rmap_call, DEFUN (rmap_description, rmap_description_cmd, - "description .LINE", + "description LINE...", "Route-map comment\n" "Comment describing this route-map rule\n") { + int idx_line = 1; struct route_map_index *index = VTY_GET_CONTEXT (route_map_index); if (index) { if (index->description) XFREE (MTYPE_TMP, index->description); - index->description = argv_concat (argv, argc, 0); + index->description = argv_concat (argv, argc, idx_line); } return CMD_SUCCESS; } @@ -1880,11 +2974,10 @@ route_map_init (void) install_element (RMAP_NODE, &no_rmap_onmatch_next_cmd); install_element (RMAP_NODE, &rmap_onmatch_goto_cmd); install_element (RMAP_NODE, &no_rmap_onmatch_goto_cmd); - - /* Install the continue stuff (ALIAS of on-match). */ install_element (RMAP_NODE, &rmap_continue_cmd); install_element (RMAP_NODE, &no_rmap_continue_cmd); - install_element (RMAP_NODE, &rmap_continue_index_cmd); + + /* Install the continue stuff (ALIAS of on-match). */ /* Install the call stuff. */ install_element (RMAP_NODE, &rmap_call_cmd); @@ -1896,4 +2989,44 @@ route_map_init (void) /* Install show command */ install_element (ENABLE_NODE, &rmap_show_name_cmd); + + install_element (RMAP_NODE, &match_interface_cmd); + install_element (RMAP_NODE, &no_match_interface_cmd); + + install_element (RMAP_NODE, &match_ip_address_cmd); + install_element (RMAP_NODE, &no_match_ip_address_cmd); + + install_element (RMAP_NODE, &match_ip_address_prefix_list_cmd); + install_element (RMAP_NODE, &no_match_ip_address_prefix_list_cmd); + + install_element (RMAP_NODE, &match_ip_next_hop_cmd); + install_element (RMAP_NODE, &no_match_ip_next_hop_cmd); + + install_element (RMAP_NODE, &match_ip_next_hop_prefix_list_cmd); + install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd); + + install_element (RMAP_NODE, &match_ipv6_address_cmd); + install_element (RMAP_NODE, &no_match_ipv6_address_cmd); + + install_element (RMAP_NODE, &match_ipv6_address_prefix_list_cmd); + install_element (RMAP_NODE, &no_match_ipv6_address_prefix_list_cmd); + + install_element (RMAP_NODE, &match_metric_cmd); + install_element (RMAP_NODE, &no_match_metric_cmd); + + install_element (RMAP_NODE, &match_tag_cmd); + install_element (RMAP_NODE, &no_match_tag_cmd); + + install_element (RMAP_NODE, &set_ip_nexthop_cmd); + install_element (RMAP_NODE, &no_set_ip_nexthop_cmd); + + install_element (RMAP_NODE, &set_ipv6_nexthop_local_cmd); + install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_cmd); + + install_element (RMAP_NODE, &set_metric_cmd); + install_element (RMAP_NODE, &no_set_metric_cmd); + + install_element (RMAP_NODE, &set_tag_cmd); + install_element (RMAP_NODE, &no_set_tag_cmd); + } diff --git a/lib/routemap.h b/lib/routemap.h index b5cdd27277..b52f7289b0 100644 --- a/lib/routemap.h +++ b/lib/routemap.h @@ -25,6 +25,8 @@ #include "prefix.h" #include "memory.h" #include "qobj.h" +#include "vty.h" + DECLARE_MTYPE(ROUTE_MAP_NAME) DECLARE_MTYPE(ROUTE_MAP_RULE) DECLARE_MTYPE(ROUTE_MAP_COMPILED) @@ -234,6 +236,172 @@ extern void route_map_upd8_dependency (route_map_event_t type, const char *arg, extern void route_map_notify_dependencies (const char *affected_name, route_map_event_t event); +extern int generic_match_add (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + +extern int generic_match_delete (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); +extern int generic_set_add (struct vty *vty, struct route_map_index *index, + const char *command, const char *arg); +extern int generic_set_delete (struct vty *vty, struct route_map_index *index, + const char *command, const char *arg); + + +/* match interface */ +extern void route_map_match_interface_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* no match interface */ +extern void route_map_no_match_interface_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* match ip address */ +extern void route_map_match_ip_address_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* no match ip address */ +extern void route_map_no_match_ip_address_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* match ip address prefix list */ +extern void route_map_match_ip_address_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* no match ip address prefix list */ +extern void route_map_no_match_ip_address_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* match ip next hop */ +extern void route_map_match_ip_next_hop_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* no match ip next hop */ +extern void route_map_no_match_ip_next_hop_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* match ip next hop prefix list */ +extern void route_map_match_ip_next_hop_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* no match ip next hop prefix list */ +extern void route_map_no_match_ip_next_hop_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* match ipv6 address */ +extern void route_map_match_ipv6_address_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* no match ipv6 address */ +extern void route_map_no_match_ipv6_address_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* match ipv6 address prefix list */ +extern void route_map_match_ipv6_address_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* no match ipv6 address prefix list */ +extern void route_map_no_match_ipv6_address_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* match metric */ +extern void route_map_match_metric_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* no match metric */ +extern void route_map_no_match_metric_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* match tag */ +extern void route_map_match_tag_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* no match tag */ +extern void route_map_no_match_tag_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* set ip nexthop */ +extern void route_map_set_ip_nexthop_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)); +/* no set ip nexthop */ +extern void route_map_no_set_ip_nexthop_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)); +/* set ipv6 nexthop local */ +extern void route_map_set_ipv6_nexthop_local_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)); +/* no set ipv6 nexthop local */ +extern void route_map_no_set_ipv6_nexthop_local_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)); +/* set metric */ +extern void route_map_set_metric_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)); +/* no set metric */ +extern void route_map_no_set_metric_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)); +/* set tag */ +extern void route_map_set_tag_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)); +/* no set tag */ +extern void route_map_no_set_tag_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)); + extern void *route_map_rule_tag_compile (const char *arg); extern void route_map_rule_tag_free (void *rule); diff --git a/lib/smux.c b/lib/smux.c index 5012e8d95e..82bf64f1c8 100644 --- a/lib/smux.c +++ b/lib/smux.c @@ -1370,7 +1370,8 @@ DEFUN (smux_peer, "SNMP MUX peer settings\n" "Object ID used in SMUX peering\n") { - if (smux_peer_oid (vty, argv[0], NULL) == 0) + int idx_oid = 2; + if (smux_peer_oid (vty, argv[idx_oid]->arg, NULL) == 0) { smux_start(); return CMD_SUCCESS; @@ -1387,7 +1388,8 @@ DEFUN (smux_peer_password, "SMUX peering object ID\n" "SMUX peering password\n") { - if (smux_peer_oid (vty, argv[0], argv[1]) == 0) + int idx_oid = 2; + if (smux_peer_oid (vty, argv[idx_oid]->arg, argv[3]->rg) == 0) { smux_start(); return CMD_SUCCESS; @@ -1398,32 +1400,17 @@ DEFUN (smux_peer_password, DEFUN (no_smux_peer, no_smux_peer_cmd, - "no smux peer", + "no smux peer [OID [PASSWORD]]", NO_STR "SNMP MUX protocol settings\n" - "SNMP MUX peer settings\n") + "SNMP MUX peer settings\n" + "SMUX peering object ID\n" + "SMUX peering password\n") { smux_stop(); return smux_peer_default (); } -ALIAS (no_smux_peer, - no_smux_peer_oid_cmd, - "no smux peer OID", - NO_STR - "SNMP MUX protocol settings\n" - "SNMP MUX peer settings\n" - "SMUX peering object ID\n") - -ALIAS (no_smux_peer, - no_smux_peer_oid_password_cmd, - "no smux peer OID PASSWORD", - NO_STR - "SNMP MUX protocol settings\n" - "SNMP MUX peer settings\n" - "SMUX peering object ID\n" - "SMUX peering password\n") - static int config_write_smux (struct vty *vty) { @@ -133,3 +133,11 @@ strndup (const char *s, size_t maxlen) return (char *) memcpy (new, s, len); } #endif + +extern int +strmatch (const char *str1, const char *str2) +{ + if (!strcmp(str1, str2)) + return 1; + return 0; +} @@ -29,5 +29,7 @@ extern size_t strnlen(const char *s, size_t maxlen); extern char * strndup (const char *, size_t); #endif +extern int strmatch (const char *, const char *); + #endif /* _ZEBRA_STR_H */ diff --git a/lib/thread.c b/lib/thread.c index 26be17585e..5dc296f2cc 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -278,7 +278,7 @@ cpu_record_print(struct vty *vty, thread_type filter) vty_out(vty, "%21s %18s %18s%s", "", "CPU (user+system):", "Real (wall-clock):", VTY_NEWLINE); #endif - vty_out(vty, " Runtime(ms) Invoked Avg uSec Max uSecs"); + vty_out(vty, "Runtime(ms) Invoked Avg uSec Max uSecs"); #ifdef HAVE_RUSAGE vty_out(vty, " Avg uSec Max uSecs"); #endif @@ -299,15 +299,16 @@ DEFUN (show_thread_cpu, "Thread CPU usage\n" "Display filter (rwtexb)\n") { + int idx_filter = 3; int i = 0; thread_type filter = (thread_type) -1U; - if (argc > 0) + if (argc > 3) { filter = 0; - while (argv[0][i] != '\0') + while (argv[idx_filter]->arg[i] != '\0') { - switch ( argv[0][i] ) + switch ( argv[idx_filter]->arg[i] ) { case 'r': case 'R': @@ -342,7 +343,7 @@ DEFUN (show_thread_cpu, { vty_out(vty, "Invalid filter \"%s\" specified," " must contain at least one of 'RWTEXB'%s", - argv[0], VTY_NEWLINE); + argv[idx_filter]->arg, VTY_NEWLINE); return CMD_WARNING; } } @@ -381,15 +382,16 @@ DEFUN (clear_thread_cpu, "Thread CPU usage\n" "Display filter (rwtexb)\n") { + int idx_filter = 3; int i = 0; thread_type filter = (thread_type) -1U; - if (argc > 0) + if (argc > 3) { filter = 0; - while (argv[0][i] != '\0') + while (argv[idx_filter]->arg[i] != '\0') { - switch ( argv[0][i] ) + switch ( argv[idx_filter]->arg[i] ) { case 'r': case 'R': @@ -424,7 +426,7 @@ DEFUN (clear_thread_cpu, { vty_out(vty, "Invalid filter \"%s\" specified," " must contain at least one of 'RWTEXB'%s", - argv[0], VTY_NEWLINE); + argv[idx_filter]->arg, VTY_NEWLINE); return CMD_WARNING; } } @@ -51,11 +51,7 @@ enum { /* * The command strings */ - -#define VRF_CMD_STR "vrf NAME" #define VRF_CMD_HELP_STR "Specify the VRF\nThe VRF name\n" - -#define VRF_ALL_CMD_STR "vrf all" #define VRF_ALL_CMD_HELP_STR "Specify the VRF\nAll VRFs\n" /* @@ -17,7 +17,7 @@ * You should have received a copy of the GNU General Public License * along with GNU Zebra; see the file COPYING. If not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. + * 02111-1307, USA. */ #include <zebra.h> @@ -45,7 +45,7 @@ DEFINE_MTYPE_STATIC(LIB, VTY_OUT_BUF, "VTY output buffer") DEFINE_MTYPE_STATIC(LIB, VTY_HIST, "VTY history") /* Vty events */ -enum event +enum event { VTY_SERV, VTY_READ, @@ -118,37 +118,37 @@ vty_out (struct vty *vty, const char *format, ...) /* Initial buffer is not enough. */ if (len < 0 || len >= size) - { - while (1) - { - if (len > -1) - size = len + 1; - else - size = size * 2; - - p = XREALLOC (MTYPE_VTY_OUT_BUF, p, size); - if (! p) - return -1; - - va_start (args, format); - len = vsnprintf (p, size, format, args); - va_end (args); - - if (len > -1 && len < size) - break; - } - } + { + while (1) + { + if (len > -1) + size = len + 1; + else + size = size * 2; + + p = XREALLOC (MTYPE_VTY_OUT_BUF, p, size); + if (! p) + return -1; + + va_start (args, format); + len = vsnprintf (p, size, format, args); + va_end (args); + + if (len > -1 && len < size) + break; + } + } /* When initial buffer is enough to store all output. */ if (! p) - p = buf; + p = buf; /* Pointer p must point out buffer. */ buffer_put (vty->obuf, (u_char *) p, len); /* If p is not different with buf, it is allocated buffer. */ if (p != buf) - XFREE (MTYPE_VTY_OUT_BUF, p); + XFREE (MTYPE_VTY_OUT_BUF, p); } return len; @@ -156,7 +156,7 @@ vty_out (struct vty *vty, const char *format, ...) static int vty_log_out (struct vty *vty, const char *level, const char *proto_str, - const char *format, struct timestamp_control *ctl, va_list va) + const char *format, struct timestamp_control *ctl, va_list va) { int ret; int len; @@ -190,13 +190,13 @@ vty_log_out (struct vty *vty, const char *level, const char *proto_str, if (write(vty->wfd, buf, len) < 0) { if (ERRNO_IO_RETRY(errno)) - /* Kernel buffer is full, probably too much debugging output, so just - drop the data and ignore. */ - return -1; + /* Kernel buffer is full, probably too much debugging output, so just + drop the data and ignore. */ + return -1; /* Fatal I/O error. */ vty->monitor = 0; /* disable monitoring to avoid infinite recursion */ zlog_warn("%s: write failed to vty client fd %d, closing: %s", - __func__, vty->fd, safe_strerror(errno)); + __func__, vty->fd, safe_strerror(errno)); buffer_reset(vty->obuf); /* cannot call vty_close, because a parent routine may still try to access the vty struct */ @@ -212,7 +212,7 @@ void vty_time_print (struct vty *vty, int cr) { char buf[QUAGGA_TIMESTAMP_LEN]; - + if (quagga_timestamp(0, buf, sizeof(buf)) == 0) { zlog (NULL, LOG_INFO, "quagga_timestamp error"); @@ -237,20 +237,20 @@ vty_hello (struct vty *vty) f = fopen (host.motdfile, "r"); if (f) - { - while (fgets (buf, sizeof (buf), f)) - { - char *s; - /* work backwards to ignore trailling isspace() */ - for (s = buf + strlen (buf); (s > buf) && isspace ((int)*(s - 1)); - s--); - *s = '\0'; - vty_out (vty, "%s%s", buf, VTY_NEWLINE); - } - fclose (f); - } + { + while (fgets (buf, sizeof (buf), f)) + { + char *s; + /* work backwards to ignore trailling isspace() */ + for (s = buf + strlen (buf); (s > buf) && isspace ((int)*(s - 1)); + s--); + *s = '\0'; + vty_out (vty, "%s%s", buf, VTY_NEWLINE); + } + fclose (f); + } else - vty_out (vty, "MOTD file not found%s", VTY_NEWLINE); + vty_out (vty, "MOTD file not found%s", VTY_NEWLINE); } else if (host.motd) vty_out (vty, "%s", host.motd); @@ -267,10 +267,10 @@ vty_prompt (struct vty *vty) { hostname = host.name; if (!hostname) - { - uname (&names); - hostname = names.nodename; - } + { + uname (&names); + hostname = names.nodename; + } vty_out (vty, cmd_prompt (vty->node), hostname); } } @@ -323,7 +323,7 @@ vty_new () { struct vty *new = XCALLOC (MTYPE_VTY, sizeof (struct vty)); - new->obuf = buffer_new(0); /* Use default buffer size. */ + new->obuf = buffer_new(0); /* Use default buffer size. */ new->buf = XCALLOC (MTYPE_VTY, VTY_BUFSIZ); new->error_buf = XCALLOC (MTYPE_VTY, VTY_BUFSIZ); new->max = VTY_BUFSIZ; @@ -344,19 +344,19 @@ vty_auth (struct vty *vty, char *buf) { case AUTH_NODE: if (host.encrypt) - passwd = host.password_encrypt; + passwd = host.password_encrypt; else - passwd = host.password; + passwd = host.password; if (host.advanced) - next_node = host.enable ? VIEW_NODE : ENABLE_NODE; + next_node = host.enable ? VIEW_NODE : ENABLE_NODE; else - next_node = VIEW_NODE; + next_node = VIEW_NODE; break; case AUTH_ENABLE_NODE: if (host.encrypt) - passwd = host.enable_encrypt; + passwd = host.enable_encrypt; else - passwd = host.enable; + passwd = host.enable; next_node = ENABLE_NODE; break; } @@ -364,9 +364,9 @@ vty_auth (struct vty *vty, char *buf) if (passwd) { if (host.encrypt) - fail = strcmp (crypt(buf, passwd), passwd); + fail = strcmp (crypt(buf, passwd), passwd); else - fail = strcmp (buf, passwd); + fail = strcmp (buf, passwd); } else fail = 1; @@ -374,26 +374,26 @@ vty_auth (struct vty *vty, char *buf) if (! fail) { vty->fail = 0; - vty->node = next_node; /* Success ! */ + vty->node = next_node; /* Success ! */ } else { vty->fail++; if (vty->fail >= 3) - { - if (vty->node == AUTH_NODE) - { - vty_out (vty, "%% Bad passwords, too many failures!%s", VTY_NEWLINE); - vty->status = VTY_CLOSE; - } - else - { - /* AUTH_ENABLE_NODE */ - vty->fail = 0; - vty_out (vty, "%% Bad enable passwords, too many failures!%s", VTY_NEWLINE); + { + if (vty->node == AUTH_NODE) + { + vty_out (vty, "%% Bad passwords, too many failures!%s", VTY_NEWLINE); + vty->status = VTY_CLOSE; + } + else + { + /* AUTH_ENABLE_NODE */ + vty->fail = 0; + vty_out (vty, "%% Bad enable passwords, too many failures!%s", VTY_NEWLINE); vty->status = VTY_CLOSE; - } - } + } + } } } @@ -420,7 +420,7 @@ vty_command (struct vty *vty, char *buf) if (cp != NULL && *cp != '\0') { unsigned i; - char vty_str[VTY_BUFSIZ]; + char vty_str[VTY_BUFSIZ]; char prompt_str[VTY_BUFSIZ]; /* format the base vty info */ @@ -462,14 +462,14 @@ vty_command (struct vty *vty, char *buf) protocolname = zlog_proto_names[zlog_default->protocol]; else protocolname = zlog_proto_names[ZLOG_NONE]; - + #ifdef CONSUMED_TIME_CHECK GETRUSAGE(&after); if ((realtime = thread_consumed_time(&after, &before, &cputime)) > - CONSUMED_TIME_CHECK) + CONSUMED_TIME_CHECK) /* Warn about CPU hog that must be fixed. */ zlog_warn("SLOW COMMAND: command took %lums (cpu time %lums): %s", - realtime/1000, cputime/1000, buf); + realtime/1000, cputime/1000, buf); } #endif /* CONSUMED_TIME_CHECK */ @@ -477,18 +477,18 @@ vty_command (struct vty *vty, char *buf) switch (ret) { case CMD_WARNING: - if (vty->type == VTY_FILE) - vty_out (vty, "Warning...%s", VTY_NEWLINE); - break; + if (vty->type == VTY_FILE) + vty_out (vty, "Warning...%s", VTY_NEWLINE); + break; case CMD_ERR_AMBIGUOUS: - vty_out (vty, "%% Ambiguous command.%s", VTY_NEWLINE); - break; + vty_out (vty, "%% Ambiguous command.%s", VTY_NEWLINE); + break; case CMD_ERR_NO_MATCH: - vty_out (vty, "%% [%s] Unknown command: %s%s", protocolname, buf, VTY_NEWLINE); - break; + vty_out (vty, "%% [%s] Unknown command: %s%s", protocolname, buf, VTY_NEWLINE); + break; case CMD_ERR_INCOMPLETE: - vty_out (vty, "%% Command incomplete.%s", VTY_NEWLINE); - break; + vty_out (vty, "%% Command incomplete.%s", VTY_NEWLINE); + break; } cmd_free_strvec (vline); @@ -686,7 +686,7 @@ vty_forward_word (struct vty *vty) { while (vty->cp != vty->length && vty->buf[vty->cp] != ' ') vty_forward_char (vty); - + while (vty->cp != vty->length && vty->buf[vty->cp] == ' ') vty_forward_char (vty); } @@ -792,14 +792,14 @@ vty_delete_char (struct vty *vty) } if (vty->cp == vty->length) - return; /* completion need here? */ + return; /* completion need here? */ size = vty->length - vty->cp; vty->length--; memmove (&vty->buf[vty->cp], &vty->buf[vty->cp + 1], size - 1); vty->buf[vty->length] = '\0'; - + if (vty->node == AUTH_NODE || vty->node == AUTH_ENABLE_NODE) return; @@ -829,7 +829,7 @@ vty_kill_line (struct vty *vty) int size; size = vty->length - vty->cp; - + if (size == 0) return; @@ -923,8 +923,8 @@ vty_complete_command (struct vty *vty) if (isspace ((int) vty->buf[vty->length - 1])) vector_set (vline, NULL); - matched = cmd_complete_command_lib (vline, vty, &ret, 1); - + matched = cmd_complete_command (vline, vty, &ret); + cmd_free_strvec (vline); vty_out (vty, "%s", VTY_NEWLINE); @@ -959,12 +959,12 @@ vty_complete_command (struct vty *vty) break; case CMD_COMPLETE_LIST_MATCH: for (i = 0; matched[i] != NULL; i++) - { - if (i != 0 && ((i % 6) == 0)) - vty_out (vty, "%s", VTY_NEWLINE); - vty_out (vty, "%-10s ", matched[i]); - XFREE (MTYPE_TMP, matched[i]); - } + { + if (i != 0 && ((i % 6) == 0)) + vty_out (vty, "%s", VTY_NEWLINE); + vty_out (vty, "%-10s ", matched[i]); + XFREE (MTYPE_TMP, matched[i]); + } vty_out (vty, "%s", VTY_NEWLINE); vty_prompt (vty); @@ -983,13 +983,13 @@ vty_complete_command (struct vty *vty) static void vty_describe_fold (struct vty *vty, int cmd_width, - unsigned int desc_width, struct cmd_token *token) + unsigned int desc_width, struct cmd_token *token) { char *buf; const char *cmd, *p; int pos; - cmd = token->cmd[0] == '.' ? token->cmd + 1 : token->cmd; + cmd = token->text; if (desc_width <= 0) { @@ -1038,7 +1038,7 @@ vty_describe_command (struct vty *vty) vline = vector_init (1); vector_set (vline, NULL); } - else + else if (isspace ((int) vty->buf[vty->length - 1])) vector_set (vline, NULL); @@ -1057,24 +1057,22 @@ vty_describe_command (struct vty *vty) vty_out (vty, "%% There is no matched command.%s", VTY_NEWLINE); goto out; break; - } + } /* Get width of command string. */ width = 0; for (i = 0; i < vector_active (describe); i++) if ((token = vector_slot (describe, i)) != NULL) { - unsigned int len; + unsigned int len; - if (token->cmd[0] == '\0') - continue; + if (token->text[0] == '\0') + continue; - len = strlen (token->cmd); - if (token->cmd[0] == '.') - len--; + len = strlen (token->text); - if (width < len) - width = len; + if (width < len) + width = len; } /* Get width of description string. */ @@ -1084,45 +1082,45 @@ vty_describe_command (struct vty *vty) for (i = 0; i < vector_active (describe); i++) if ((token = vector_slot (describe, i)) != NULL) { - if (token->cmd[0] == '\0') - continue; - - if (strcmp (token->cmd, command_cr) == 0) - { - token_cr = token; - continue; - } - - if (!token->desc) - vty_out (vty, " %-s%s", - token->cmd[0] == '.' ? token->cmd + 1 : token->cmd, - VTY_NEWLINE); - else if (desc_width >= strlen (token->desc)) - vty_out (vty, " %-*s %s%s", width, - token->cmd[0] == '.' ? token->cmd + 1 : token->cmd, - token->desc, VTY_NEWLINE); - else - vty_describe_fold (vty, width, desc_width, token); + if (token->text[0] == '\0') + continue; + + if (strcmp (token->text, CMD_CR_TEXT) == 0) + { + token_cr = token; + continue; + } + + if (!token->desc) + vty_out (vty, " %-s%s", + token->text, + VTY_NEWLINE); + else if (desc_width >= strlen (token->desc)) + vty_out (vty, " %-*s %s%s", width, + token->text, + token->desc, VTY_NEWLINE); + else + vty_describe_fold (vty, width, desc_width, token); #if 0 - vty_out (vty, " %-*s %s%s", width - desc->cmd[0] == '.' ? desc->cmd + 1 : desc->cmd, - desc->str ? desc->str : "", VTY_NEWLINE); + vty_out (vty, " %-*s %s%s", width + desc->cmd[0] == '.' ? desc->cmd + 1 : desc->cmd, + desc->str ? desc->str : "", VTY_NEWLINE); #endif /* 0 */ } if ((token = token_cr)) { if (!token->desc) - vty_out (vty, " %-s%s", - token->cmd[0] == '.' ? token->cmd + 1 : token->cmd, - VTY_NEWLINE); + vty_out (vty, " %-s%s", + token->text, + VTY_NEWLINE); else if (desc_width >= strlen (token->desc)) - vty_out (vty, " %-*s %s%s", width, - token->cmd[0] == '.' ? token->cmd + 1 : token->cmd, - token->desc, VTY_NEWLINE); + vty_out (vty, " %-*s %s%s", width, + token->text, + token->desc, VTY_NEWLINE); else - vty_describe_fold (vty, width, desc_width, token); + vty_describe_fold (vty, width, desc_width, token); } out: @@ -1233,41 +1231,41 @@ vty_telnet_option (struct vty *vty, unsigned char *buf, int nbytes) for (i = 0; i < nbytes; i++) { switch (buf[i]) - { - case IAC: - vty_out (vty, "IAC "); - break; - case WILL: - vty_out (vty, "WILL "); - break; - case WONT: - vty_out (vty, "WONT "); - break; - case DO: - vty_out (vty, "DO "); - break; - case DONT: - vty_out (vty, "DONT "); - break; - case SB: - vty_out (vty, "SB "); - break; - case SE: - vty_out (vty, "SE "); - break; - case TELOPT_ECHO: - vty_out (vty, "TELOPT_ECHO %s", VTY_NEWLINE); - break; - case TELOPT_SGA: - vty_out (vty, "TELOPT_SGA %s", VTY_NEWLINE); - break; - case TELOPT_NAWS: - vty_out (vty, "TELOPT_NAWS %s", VTY_NEWLINE); - break; - default: - vty_out (vty, "%x ", buf[i]); - break; - } + { + case IAC: + vty_out (vty, "IAC "); + break; + case WILL: + vty_out (vty, "WILL "); + break; + case WONT: + vty_out (vty, "WONT "); + break; + case DO: + vty_out (vty, "DO "); + break; + case DONT: + vty_out (vty, "DONT "); + break; + case SB: + vty_out (vty, "SB "); + break; + case SE: + vty_out (vty, "SE "); + break; + case TELOPT_ECHO: + vty_out (vty, "TELOPT_ECHO %s", VTY_NEWLINE); + break; + case TELOPT_SGA: + vty_out (vty, "TELOPT_SGA %s", VTY_NEWLINE); + break; + case TELOPT_NAWS: + vty_out (vty, "TELOPT_NAWS %s", VTY_NEWLINE); + break; + default: + vty_out (vty, "%x ", buf[i]); + break; + } } vty_out (vty, "%s", VTY_NEWLINE); @@ -1280,42 +1278,42 @@ vty_telnet_option (struct vty *vty, unsigned char *buf, int nbytes) vty->iac_sb_in_progress = 1; return 0; break; - case SE: + case SE: { - if (!vty->iac_sb_in_progress) - return 0; - - if ((vty->sb_len == 0) || (vty->sb_buf[0] == '\0')) - { - vty->iac_sb_in_progress = 0; - return 0; - } - switch (vty->sb_buf[0]) - { - case TELOPT_NAWS: - if (vty->sb_len != TELNET_NAWS_SB_LEN) - zlog_warn("RFC 1073 violation detected: telnet NAWS option " - "should send %d characters, but we received %lu", - TELNET_NAWS_SB_LEN, (u_long)vty->sb_len); - else if (sizeof(vty->sb_buf) < TELNET_NAWS_SB_LEN) - zlog_err("Bug detected: sizeof(vty->sb_buf) %lu < %d, " - "too small to handle the telnet NAWS option", - (u_long)sizeof(vty->sb_buf), TELNET_NAWS_SB_LEN); - else - { - vty->width = ((vty->sb_buf[1] << 8)|vty->sb_buf[2]); - vty->height = ((vty->sb_buf[3] << 8)|vty->sb_buf[4]); + if (!vty->iac_sb_in_progress) + return 0; + + if ((vty->sb_len == 0) || (vty->sb_buf[0] == '\0')) + { + vty->iac_sb_in_progress = 0; + return 0; + } + switch (vty->sb_buf[0]) + { + case TELOPT_NAWS: + if (vty->sb_len != TELNET_NAWS_SB_LEN) + zlog_warn("RFC 1073 violation detected: telnet NAWS option " + "should send %d characters, but we received %lu", + TELNET_NAWS_SB_LEN, (u_long)vty->sb_len); + else if (sizeof(vty->sb_buf) < TELNET_NAWS_SB_LEN) + zlog_err("Bug detected: sizeof(vty->sb_buf) %lu < %d, " + "too small to handle the telnet NAWS option", + (u_long)sizeof(vty->sb_buf), TELNET_NAWS_SB_LEN); + else + { + vty->width = ((vty->sb_buf[1] << 8)|vty->sb_buf[2]); + vty->height = ((vty->sb_buf[3] << 8)|vty->sb_buf[4]); #ifdef TELNET_OPTION_DEBUG - vty_out(vty, "TELNET NAWS window size negotiation completed: " - "width %d, height %d%s", - vty->width, vty->height, VTY_NEWLINE); + vty_out(vty, "TELNET NAWS window size negotiation completed: " + "width %d, height %d%s", + vty->width, vty->height, VTY_NEWLINE); #endif - } - break; - } - vty->iac_sb_in_progress = 0; - return 0; - break; + } + break; + } + vty->iac_sb_in_progress = 0; + return 0; + break; } default: break; @@ -1340,7 +1338,7 @@ vty_execute (struct vty *vty) default: ret = vty_command (vty, vty->buf); if (vty->type == VTY_TERM) - vty_hist_add (vty); + vty_hist_add (vty); break; } @@ -1410,187 +1408,187 @@ vty_read (struct thread *thread) if ((nbytes = read (vty->fd, buf, VTY_READ_BUFSIZ)) <= 0) { if (nbytes < 0) - { - if (ERRNO_IO_RETRY(errno)) - { - vty_event (VTY_READ, vty_sock, vty); - return 0; - } - vty->monitor = 0; /* disable monitoring to avoid infinite recursion */ - zlog_warn("%s: read error on vty client fd %d, closing: %s", - __func__, vty->fd, safe_strerror(errno)); + { + if (ERRNO_IO_RETRY(errno)) + { + vty_event (VTY_READ, vty_sock, vty); + return 0; + } + vty->monitor = 0; /* disable monitoring to avoid infinite recursion */ + zlog_warn("%s: read error on vty client fd %d, closing: %s", + __func__, vty->fd, safe_strerror(errno)); buffer_reset(vty->obuf); - } + } vty->status = VTY_CLOSE; } - for (i = 0; i < nbytes; i++) + for (i = 0; i < nbytes; i++) { if (buf[i] == IAC) - { - if (!vty->iac) - { - vty->iac = 1; - continue; - } - else - { - vty->iac = 0; - } - } - + { + if (!vty->iac) + { + vty->iac = 1; + continue; + } + else + { + vty->iac = 0; + } + } + if (vty->iac_sb_in_progress && !vty->iac) - { - if (vty->sb_len < sizeof(vty->sb_buf)) - vty->sb_buf[vty->sb_len] = buf[i]; - vty->sb_len++; - continue; - } + { + if (vty->sb_len < sizeof(vty->sb_buf)) + vty->sb_buf[vty->sb_len] = buf[i]; + vty->sb_len++; + continue; + } if (vty->iac) - { - /* In case of telnet command */ - int ret = 0; - ret = vty_telnet_option (vty, buf + i, nbytes - i); - vty->iac = 0; - i += ret; - continue; - } - + { + /* In case of telnet command */ + int ret = 0; + ret = vty_telnet_option (vty, buf + i, nbytes - i); + vty->iac = 0; + i += ret; + continue; + } + if (vty->status == VTY_MORE) - { - switch (buf[i]) - { - case CONTROL('C'): - case 'q': - case 'Q': - vty_buffer_reset (vty); - break; + { + switch (buf[i]) + { + case CONTROL('C'): + case 'q': + case 'Q': + vty_buffer_reset (vty); + break; #if 0 /* More line does not work for "show ip bgp". */ - case '\n': - case '\r': - vty->status = VTY_MORELINE; - break; + case '\n': + case '\r': + vty->status = VTY_MORELINE; + break; #endif - default: - break; - } - continue; - } + default: + break; + } + continue; + } /* Escape character. */ if (vty->escape == VTY_ESCAPE) - { - vty_escape_map (buf[i], vty); - continue; - } + { + vty_escape_map (buf[i], vty); + continue; + } /* Pre-escape status. */ if (vty->escape == VTY_PRE_ESCAPE) - { - switch (buf[i]) - { - case '[': - vty->escape = VTY_ESCAPE; - break; - case 'b': - vty_backward_word (vty); - vty->escape = VTY_NORMAL; - break; - case 'f': - vty_forward_word (vty); - vty->escape = VTY_NORMAL; - break; - case 'd': - vty_forward_kill_word (vty); - vty->escape = VTY_NORMAL; - break; - case CONTROL('H'): - case 0x7f: - vty_backward_kill_word (vty); - vty->escape = VTY_NORMAL; - break; - default: - vty->escape = VTY_NORMAL; - break; - } - continue; - } + { + switch (buf[i]) + { + case '[': + vty->escape = VTY_ESCAPE; + break; + case 'b': + vty_backward_word (vty); + vty->escape = VTY_NORMAL; + break; + case 'f': + vty_forward_word (vty); + vty->escape = VTY_NORMAL; + break; + case 'd': + vty_forward_kill_word (vty); + vty->escape = VTY_NORMAL; + break; + case CONTROL('H'): + case 0x7f: + vty_backward_kill_word (vty); + vty->escape = VTY_NORMAL; + break; + default: + vty->escape = VTY_NORMAL; + break; + } + continue; + } switch (buf[i]) - { - case CONTROL('A'): - vty_beginning_of_line (vty); - break; - case CONTROL('B'): - vty_backward_char (vty); - break; - case CONTROL('C'): - vty_stop_input (vty); - break; - case CONTROL('D'): - vty_delete_char (vty); - break; - case CONTROL('E'): - vty_end_of_line (vty); - break; - case CONTROL('F'): - vty_forward_char (vty); - break; - case CONTROL('H'): - case 0x7f: - vty_delete_backward_char (vty); - break; - case CONTROL('K'): - vty_kill_line (vty); - break; - case CONTROL('N'): - vty_next_line (vty); - break; - case CONTROL('P'): - vty_previous_line (vty); - break; - case CONTROL('T'): - vty_transpose_chars (vty); - break; - case CONTROL('U'): - vty_kill_line_from_beginning (vty); - break; - case CONTROL('W'): - vty_backward_kill_word (vty); - break; - case CONTROL('Z'): - vty_end_config (vty); - break; - case '\n': - case '\r': - vty_out (vty, "%s", VTY_NEWLINE); - vty_execute (vty); - break; - case '\t': - vty_complete_command (vty); - break; - case '?': - if (vty->node == AUTH_NODE || vty->node == AUTH_ENABLE_NODE) - vty_self_insert (vty, buf[i]); - else - vty_describe_command (vty); - break; - case '\033': - if (i + 1 < nbytes && buf[i + 1] == '[') - { - vty->escape = VTY_ESCAPE; - i++; - } - else - vty->escape = VTY_PRE_ESCAPE; - break; - default: - if (buf[i] > 31 && buf[i] < 127) - vty_self_insert (vty, buf[i]); - break; - } + { + case CONTROL('A'): + vty_beginning_of_line (vty); + break; + case CONTROL('B'): + vty_backward_char (vty); + break; + case CONTROL('C'): + vty_stop_input (vty); + break; + case CONTROL('D'): + vty_delete_char (vty); + break; + case CONTROL('E'): + vty_end_of_line (vty); + break; + case CONTROL('F'): + vty_forward_char (vty); + break; + case CONTROL('H'): + case 0x7f: + vty_delete_backward_char (vty); + break; + case CONTROL('K'): + vty_kill_line (vty); + break; + case CONTROL('N'): + vty_next_line (vty); + break; + case CONTROL('P'): + vty_previous_line (vty); + break; + case CONTROL('T'): + vty_transpose_chars (vty); + break; + case CONTROL('U'): + vty_kill_line_from_beginning (vty); + break; + case CONTROL('W'): + vty_backward_kill_word (vty); + break; + case CONTROL('Z'): + vty_end_config (vty); + break; + case '\n': + case '\r': + vty_out (vty, "%s", VTY_NEWLINE); + vty_execute (vty); + break; + case '\t': + vty_complete_command (vty); + break; + case '?': + if (vty->node == AUTH_NODE || vty->node == AUTH_ENABLE_NODE) + vty_self_insert (vty, buf[i]); + else + vty_describe_command (vty); + break; + case '\033': + if (i + 1 < nbytes && buf[i + 1] == '[') + { + vty->escape = VTY_ESCAPE; + i++; + } + else + vty->escape = VTY_PRE_ESCAPE; + break; + default: + if (buf[i] > 31 && buf[i] < 127) + vty_self_insert (vty, buf[i]); + break; + } } /* Check status. */ @@ -1630,36 +1628,36 @@ vty_flush (struct thread *thread) flushrc = buffer_flush_available(vty->obuf, vty_sock); else if (vty->status == VTY_MORELINE) flushrc = buffer_flush_window(vty->obuf, vty_sock, vty->width, - 1, erase, 0); + 1, erase, 0); else flushrc = buffer_flush_window(vty->obuf, vty_sock, vty->width, - vty->lines >= 0 ? vty->lines : - vty->height, - erase, 0); + vty->lines >= 0 ? vty->lines : + vty->height, + erase, 0); switch (flushrc) { case BUFFER_ERROR: vty->monitor = 0; /* disable monitoring to avoid infinite recursion */ zlog_warn("buffer_flush failed on vty client fd %d, closing", - vty->fd); + vty->fd); buffer_reset(vty->obuf); vty_close(vty); return 0; case BUFFER_EMPTY: if (vty->status == VTY_CLOSE) - vty_close (vty); + vty_close (vty); else - { - vty->status = VTY_NORMAL; - if (vty->lines == 0) - vty_event (VTY_READ, vty_sock, vty); - } + { + vty->status = VTY_NORMAL; + if (vty->lines == 0) + vty_event (VTY_READ, vty_sock, vty); + } break; case BUFFER_PENDING: /* There is more data waiting to be written. */ vty->status = VTY_MORE; if (vty->lines == 0) - vty_event (VTY_WRITE, vty_sock, vty); + vty_event (VTY_WRITE, vty_sock, vty); break; } @@ -1712,9 +1710,9 @@ vty_create (int vty_sock, union sockunion *su) if (no_password_check) { if (host.advanced) - vty->node = ENABLE_NODE; + vty->node = ENABLE_NODE; else - vty->node = VIEW_NODE; + vty->node = VIEW_NODE; } if (host.lines >= 0) vty->lines = host.lines; @@ -1723,12 +1721,12 @@ vty_create (int vty_sock, union sockunion *su) { /* Vty is not available if password isn't set. */ if (host.password == NULL && host.password_encrypt == NULL) - { - vty_out (vty, "Vty password is not set.%s", VTY_NEWLINE); - vty->status = VTY_CLOSE; - vty_close (vty); - return NULL; - } + { + vty_out (vty, "Vty password is not set.%s", VTY_NEWLINE); + vty->status = VTY_CLOSE; + vty_close (vty); + return NULL; + } } /* Say hello to the world. */ @@ -1849,17 +1847,17 @@ vty_accept (struct thread *thread) if (p.family == AF_INET && vty_accesslist_name) { if ((acl = access_list_lookup (AFI_IP, vty_accesslist_name)) && - (access_list_apply (acl, &p) == FILTER_DENY)) - { - zlog (NULL, LOG_INFO, "Vty connection refused from %s", - sockunion2str (&su, buf, SU_ADDRSTRLEN)); - close (vty_sock); - - /* continue accepting connections */ - vty_event (VTY_SERV, accept_sock, NULL); - - return 0; - } + (access_list_apply (acl, &p) == FILTER_DENY)) + { + zlog (NULL, LOG_INFO, "Vty connection refused from %s", + sockunion2str (&su, buf, SU_ADDRSTRLEN)); + close (vty_sock); + + /* continue accepting connections */ + vty_event (VTY_SERV, accept_sock, NULL); + + return 0; + } } #ifdef HAVE_IPV6 @@ -1867,29 +1865,29 @@ vty_accept (struct thread *thread) if (p.family == AF_INET6 && vty_ipv6_accesslist_name) { if ((acl = access_list_lookup (AFI_IP6, vty_ipv6_accesslist_name)) && - (access_list_apply (acl, &p) == FILTER_DENY)) - { - zlog (NULL, LOG_INFO, "Vty connection refused from %s", - sockunion2str (&su, buf, SU_ADDRSTRLEN)); - close (vty_sock); - - /* continue accepting connections */ - vty_event (VTY_SERV, accept_sock, NULL); - - return 0; - } + (access_list_apply (acl, &p) == FILTER_DENY)) + { + zlog (NULL, LOG_INFO, "Vty connection refused from %s", + sockunion2str (&su, buf, SU_ADDRSTRLEN)); + close (vty_sock); + + /* continue accepting connections */ + vty_event (VTY_SERV, accept_sock, NULL); + + return 0; + } } #endif /* HAVE_IPV6 */ - + on = 1; - ret = setsockopt (vty_sock, IPPROTO_TCP, TCP_NODELAY, - (char *) &on, sizeof (on)); + ret = setsockopt (vty_sock, IPPROTO_TCP, TCP_NODELAY, + (char *) &on, sizeof (on)); if (ret < 0) - zlog (NULL, LOG_INFO, "can't set sockopt to vty_sock : %s", - safe_strerror (errno)); + zlog (NULL, LOG_INFO, "can't set sockopt to vty_sock : %s", + safe_strerror (errno)); zlog (NULL, LOG_INFO, "Vty connection from %s", - sockunion2str (&su, buf, SU_ADDRSTRLEN)); + sockunion2str (&su, buf, SU_ADDRSTRLEN)); vty_create (vty_sock, &su); @@ -1928,14 +1926,14 @@ vty_serv_sock_addrinfo (const char *hostname, unsigned short port) { if (ainfo->ai_family != AF_INET #ifdef HAVE_IPV6 - && ainfo->ai_family != AF_INET6 + && ainfo->ai_family != AF_INET6 #endif /* HAVE_IPV6 */ - ) - continue; + ) + continue; sock = socket (ainfo->ai_family, ainfo->ai_socktype, ainfo->ai_protocol); if (sock < 0) - continue; + continue; sockopt_v6only (ainfo->ai_family, sock); sockopt_reuseaddr (sock); @@ -1944,17 +1942,17 @@ vty_serv_sock_addrinfo (const char *hostname, unsigned short port) ret = bind (sock, ainfo->ai_addr, ainfo->ai_addrlen); if (ret < 0) - { - close (sock); /* Avoid sd leak. */ - continue; - } + { + close (sock); /* Avoid sd leak. */ + continue; + } ret = listen (sock, 3); - if (ret < 0) - { - close (sock); /* Avoid sd leak. */ - continue; - } + if (ret < 0) + { + close (sock); /* Avoid sd leak. */ + continue; + } vty_event (VTY_SERV, sock, NULL); } @@ -1985,7 +1983,7 @@ vty_serv_sock_family (const char* addr, unsigned short port, int family) case AF_INET6: naddr=&su.sin6.sin6_addr; break; -#endif +#endif } if(naddr) @@ -1993,11 +1991,11 @@ vty_serv_sock_family (const char* addr, unsigned short port, int family) { case -1: zlog_err("bad address %s",addr); - naddr=NULL; - break; + naddr=NULL; + break; case 0: zlog_err("error translating address %s: %s",addr,safe_strerror(errno)); - naddr=NULL; + naddr=NULL; } /* Make new socket. */ @@ -2015,16 +2013,16 @@ vty_serv_sock_family (const char* addr, unsigned short port, int family) if (ret < 0) { zlog_warn("can't bind socket"); - close (accept_sock); /* Avoid sd leak. */ + close (accept_sock); /* Avoid sd leak. */ return; } /* Listen socket under queue 3. */ ret = listen (accept_sock, 3); - if (ret < 0) + if (ret < 0) { zlog (NULL, LOG_WARNING, "can't listen socket"); - close (accept_sock); /* Avoid sd leak. */ + close (accept_sock); /* Avoid sd leak. */ return; } @@ -2046,7 +2044,7 @@ vty_serv_un (const char *path) struct sockaddr_un serv; mode_t old_mask; struct zprivs_ids_t ids; - + /* First of all, unlink existing socket */ unlink (path); @@ -2077,7 +2075,7 @@ vty_serv_un (const char *path) if (ret < 0) { zlog_err("Cannot bind path %s: %s", path, safe_strerror(errno)); - close (sock); /* Avoid sd leak. */ + close (sock); /* Avoid sd leak. */ return; } @@ -2085,14 +2083,14 @@ vty_serv_un (const char *path) if (ret < 0) { zlog_err("listen(fd %d) failed: %s", sock, safe_strerror(errno)); - close (sock); /* Avoid sd leak. */ + close (sock); /* Avoid sd leak. */ return; } umask (old_mask); zprivs_get_ids(&ids); - + if (ids.gid_vty > 0) { /* set group of socket */ @@ -2116,7 +2114,7 @@ vtysh_accept (struct thread *thread) int client_len; struct sockaddr_un client; struct vty *vty; - + accept_sock = THREAD_FD (thread); vty_event (VTYSH_SERV, accept_sock, NULL); @@ -2125,7 +2123,7 @@ vtysh_accept (struct thread *thread) client_len = sizeof (struct sockaddr_un); sock = accept (accept_sock, (struct sockaddr *) &client, - (socklen_t *) &client_len); + (socklen_t *) &client_len); if (sock < 0) { @@ -2196,16 +2194,16 @@ vtysh_read (struct thread *thread) if ((nbytes = read (sock, buf, VTY_READ_BUFSIZ)) <= 0) { if (nbytes < 0) - { - if (ERRNO_IO_RETRY(errno)) - { - vty_event (VTYSH_READ, sock, vty); - return 0; - } - vty->monitor = 0; /* disable monitoring to avoid infinite recursion */ - zlog_warn("%s: read failed on vtysh client fd %d, closing: %s", - __func__, sock, safe_strerror(errno)); - } + { + if (ERRNO_IO_RETRY(errno)) + { + vty_event (VTYSH_READ, sock, vty); + return 0; + } + vty->monitor = 0; /* disable monitoring to avoid infinite recursion */ + zlog_warn("%s: read failed on vtysh client fd %d, closing: %s", + __func__, sock, safe_strerror(errno)); + } buffer_reset(vty->obuf); vty_close (vty); #ifdef VTYSH_DEBUG @@ -2223,16 +2221,16 @@ vtysh_read (struct thread *thread) vty_ensure(vty, vty->length+1); vty->buf[vty->length++] = *p; if (*p == '\0') - { - /* Pass this line to parser. */ - ret = vty_execute (vty); - /* Note that vty_execute clears the command buffer and resets - vty->length to 0. */ + { + /* Pass this line to parser. */ + ret = vty_execute (vty); + /* Note that vty_execute clears the command buffer and resets + vty->length to 0. */ - /* Return result. */ + /* Return result. */ #ifdef VTYSH_DEBUG - printf ("result: %d\n", ret); - printf ("vtysh node: %d\n", vty->node); + printf ("result: %d\n", ret); + printf ("vtysh node: %d\n", vty->node); #endif /* VTYSH_DEBUG */ /* hack for asynchronous "write integrated" @@ -2245,10 +2243,10 @@ vtysh_read (struct thread *thread) header[3] = ret; buffer_put(vty->obuf, header, 4); - if (!vty->t_write && (vtysh_flush(vty) < 0)) - /* Try to flush results; exit if a write error occurs. */ - return 0; - } + if (!vty->t_write && (vtysh_flush(vty) < 0)) + /* Try to flush results; exit if a write error occurs. */ + return 0; + } } vty_event (VTYSH_READ, sock, vty); @@ -2377,26 +2375,31 @@ vty_read_file (FILE *confp) vty->fd = STDIN_FILENO; vty->type = VTY_FILE; vty->node = CONFIG_NODE; - + /* Execute configuration file */ ret = config_from_file (vty, confp, &line_num); /* Flush any previous errors before printing messages below */ buffer_flush_all (vty->obuf, vty->fd); - if ( !((ret == CMD_SUCCESS) || (ret == CMD_ERR_NOTHING_TODO)) ) + if ( !((ret == CMD_SUCCESS) || (ret == CMD_ERR_NOTHING_TODO)) ) { + const char *message = NULL; switch (ret) { case CMD_ERR_AMBIGUOUS: - fprintf (stderr, "*** Error reading config: Ambiguous command.\n"); + message = "*** Error reading config: Ambiguous command."; break; case CMD_ERR_NO_MATCH: - fprintf (stderr, "*** Error reading config: There is no such command.\n"); + message = "*** Error reading config: There is no such command."; break; } - fprintf (stderr, "*** Error occured processing line %u, below:\n%s\n", - line_num, vty->error_buf); + fprintf (stderr, "%s\n", message); + zlog_err ("%s", message); + fprintf (stderr, "*** Error occurred processing line %u, below:\n%s\n", + line_num, vty->error_buf); + zlog_err ("*** Error occurred processing line %u, below:\n%s", + line_num, vty->error_buf); } vty_close (vty); @@ -2411,7 +2414,7 @@ vty_use_backup_config (char *fullpath) int tmp, sav; int c; char buffer[512]; - + fullpath_sav = malloc (strlen (fullpath) + strlen (CONF_BACKUP_EXT) + 1); strcpy (fullpath_sav, fullpath); strcat (fullpath_sav, CONF_BACKUP_EXT); @@ -2423,7 +2426,7 @@ vty_use_backup_config (char *fullpath) fullpath_tmp = malloc (strlen (fullpath) + 8); sprintf (fullpath_tmp, "%s.XXXXXX", fullpath); - + /* Open file to configuration write. */ tmp = mkstemp (fullpath_tmp); if (tmp < 0) @@ -2441,21 +2444,21 @@ vty_use_backup_config (char *fullpath) free (fullpath_tmp); return NULL; } - + while((c = read (sav, buffer, 512)) > 0) { if (write (tmp, buffer, c) <= 0) - { - free (fullpath_sav); - free (fullpath_tmp); - close (sav); - close (tmp); - return NULL; - } + { + free (fullpath_sav); + free (fullpath_tmp); + close (sav); + close (tmp); + return NULL; + } } close (sav); close (tmp); - + if (chmod(fullpath_tmp, CONFIGFILE_MASK) != 0) { unlink (fullpath_tmp); @@ -2463,12 +2466,12 @@ vty_use_backup_config (char *fullpath) free (fullpath_tmp); return NULL; } - + if (link (fullpath_tmp, fullpath) == 0) ret = fopen (fullpath, "r"); unlink (fullpath_tmp); - + free (fullpath_sav); free (fullpath_tmp); return ret; @@ -2490,12 +2493,12 @@ vty_read_config (char *config_file, if (! IS_DIRECTORY_SEP (config_file[0])) { if (getcwd (cwd, MAXPATHLEN) == NULL) - { - fprintf (stderr, "Failure to determine Current Working Directory %d!\n", errno); - exit (1); - } - tmp = XMALLOC (MTYPE_TMP, - strlen (cwd) + strlen (config_file) + 2); + { + fprintf (stderr, "Failure to determine Current Working Directory %d!\n", errno); + exit (1); + } + tmp = XMALLOC (MTYPE_TMP, + strlen (cwd) + strlen (config_file) + 2); sprintf (tmp, "%s/%s", cwd, config_file); fullpath = tmp; } @@ -2508,14 +2511,14 @@ vty_read_config (char *config_file, { fprintf (stderr, "%s: failed to open configuration file %s: %s\n", __func__, fullpath, safe_strerror (errno)); - + confp = vty_use_backup_config (fullpath); if (confp) fprintf (stderr, "WARNING: using backup configuration file!\n"); else { - fprintf (stderr, "can't open configuration file [%s]\n", - config_file); + fprintf (stderr, "can't open configuration file [%s]\n", + config_file); exit(1); } } @@ -2547,7 +2550,7 @@ vty_read_config (char *config_file, { ret = stat (integrate_default, &conf_stat); if (ret >= 0) - goto tmp_free_and_out; + goto tmp_free_and_out; } #endif /* VTYSH */ confp = fopen (config_default_dir, "r"); @@ -2555,7 +2558,7 @@ vty_read_config (char *config_file, { fprintf (stderr, "%s: failed to open configuration file %s: %s\n", __func__, config_default_dir, safe_strerror (errno)); - + confp = vty_use_backup_config (config_default_dir); if (confp) { @@ -2565,10 +2568,10 @@ vty_read_config (char *config_file, else { fprintf (stderr, "can't open configuration file [%s]\n", - config_default_dir); - goto tmp_free_and_out; + config_default_dir); + goto tmp_free_and_out; } - } + } else fullpath = config_default_dir; } @@ -2587,23 +2590,23 @@ tmp_free_and_out: /* Small utility function which output log to the VTY. */ void vty_log (const char *level, const char *proto_str, - const char *format, struct timestamp_control *ctl, va_list va) + const char *format, struct timestamp_control *ctl, va_list va) { unsigned int i; struct vty *vty; - + if (!vtyvec) return; for (i = 0; i < vector_active (vtyvec); i++) if ((vty = vector_slot (vtyvec, i)) != NULL) if (vty->monitor) - { - va_list ac; - va_copy(ac, va); - vty_log_out (vty, level, proto_str, format, ctl, ac); - va_end(ac); - } + { + va_list ac; + va_copy(ac, va); + vty_log_out (vty, level, proto_str, format, ctl, ac); + va_end(ac); + } } /* Async-signal-safe version of vty_log for fixed strings. */ @@ -2617,7 +2620,7 @@ vty_log_fixed (char *buf, size_t len) /* vty may not have been initialised */ if (!vtyvec) return; - + iov[0].iov_base = buf; iov[0].iov_len = len; iov[1].iov_base = crlf; @@ -2627,13 +2630,13 @@ vty_log_fixed (char *buf, size_t len) { struct vty *vty; if (((vty = vector_slot (vtyvec, i)) != NULL) && vty->monitor) - /* N.B. We don't care about the return code, since process is - most likely just about to die anyway. */ - if (writev(vty->wfd, iov, 2) == -1) - { - fprintf(stderr, "Failure to writev: %d\n", errno); - exit(-1); - } + /* N.B. We don't care about the return code, since process is + most likely just about to die anyway. */ + if (writev(vty->wfd, iov, 2) == -1) + { + fprintf(stderr, "Failure to writev: %d\n", errno); + exit(-1); + } } } @@ -2700,28 +2703,28 @@ vty_event (enum event event, int sock, struct vty *vty) /* Time out treatment. */ if (vty->v_timeout) - { - if (vty->t_timeout) - thread_cancel (vty->t_timeout); - vty->t_timeout = - thread_add_timer (vty_master, vty_timeout, vty, vty->v_timeout); - } + { + if (vty->t_timeout) + thread_cancel (vty->t_timeout); + vty->t_timeout = + thread_add_timer (vty_master, vty_timeout, vty, vty->v_timeout); + } break; case VTY_WRITE: if (! vty->t_write) - vty->t_write = thread_add_write (vty_master, vty_flush, vty, sock); + vty->t_write = thread_add_write (vty_master, vty_flush, vty, sock); break; case VTY_TIMEOUT_RESET: if (vty->t_timeout) - { - thread_cancel (vty->t_timeout); - vty->t_timeout = NULL; - } + { + thread_cancel (vty->t_timeout); + vty->t_timeout = NULL; + } if (vty->v_timeout) - { - vty->t_timeout = - thread_add_timer (vty_master, vty_timeout, vty, vty->v_timeout); - } + { + vty->t_timeout = + thread_add_timer (vty_master, vty_timeout, vty, vty->v_timeout); + } break; } } @@ -2737,8 +2740,8 @@ DEFUN (config_who, for (i = 0; i < vector_active (vtyvec); i++) if ((v = vector_slot (vtyvec, i)) != NULL) vty_out (vty, "%svty[%d] connected from %s.%s", - v->config ? "*" : " ", - i, v->address, VTY_NEWLINE); + v->config ? "*" : " ", + i, v->address, VTY_NEWLINE); return CMD_SUCCESS; } @@ -2779,21 +2782,24 @@ exec_timeout (struct vty *vty, const char *min_str, const char *sec_str) DEFUN (exec_timeout_min, exec_timeout_min_cmd, - "exec-timeout <0-35791>", + "exec-timeout (0-35791)", "Set timeout value\n" "Timeout value in minutes\n") { - return exec_timeout (vty, argv[0], NULL); + int idx_number = 1; + return exec_timeout (vty, argv[idx_number]->arg, NULL); } DEFUN (exec_timeout_sec, exec_timeout_sec_cmd, - "exec-timeout <0-35791> <0-2147483>", + "exec-timeout (0-35791) (0-2147483)", "Set the EXEC timeout\n" "Timeout in minutes\n" "Timeout in seconds\n") { - return exec_timeout (vty, argv[0], argv[1]); + int idx_number = 1; + int idx_number_2 = 2; + return exec_timeout (vty, argv[idx_number]->arg, argv[idx_number_2]->arg); } DEFUN (no_exec_timeout, @@ -2812,10 +2818,11 @@ DEFUN (vty_access_class, "Filter connections based on an IP access list\n" "IP access list\n") { + int idx_word = 1; if (vty_accesslist_name) XFREE(MTYPE_VTY, vty_accesslist_name); - vty_accesslist_name = XSTRDUP(MTYPE_VTY, argv[0]); + vty_accesslist_name = XSTRDUP(MTYPE_VTY, argv[idx_word]->arg); return CMD_SUCCESS; } @@ -2828,10 +2835,12 @@ DEFUN (no_vty_access_class, "Filter connections based on an IP access list\n" "IP access list\n") { - if (! vty_accesslist_name || (argc && strcmp(vty_accesslist_name, argv[0]))) + int idx_word = 2; + const char *accesslist = (argc == 3) ? argv[idx_word]->arg : NULL; + if (! vty_accesslist_name || (argc == 3 && strcmp(vty_accesslist_name, accesslist))) { vty_out (vty, "Access-class is not currently applied to vty%s", - VTY_NEWLINE); + VTY_NEWLINE); return CMD_WARNING; } @@ -2851,10 +2860,11 @@ DEFUN (vty_ipv6_access_class, "Filter connections based on an IP access list\n" "IPv6 access list\n") { + int idx_word = 2; if (vty_ipv6_accesslist_name) XFREE(MTYPE_VTY, vty_ipv6_accesslist_name); - vty_ipv6_accesslist_name = XSTRDUP(MTYPE_VTY, argv[0]); + vty_ipv6_accesslist_name = XSTRDUP(MTYPE_VTY, argv[idx_word]->arg); return CMD_SUCCESS; } @@ -2868,11 +2878,14 @@ DEFUN (no_vty_ipv6_access_class, "Filter connections based on an IP access list\n" "IPv6 access list\n") { + int idx_word = 3; + const char *accesslist = (argc == 4) ? argv[idx_word]->arg : NULL; + if (! vty_ipv6_accesslist_name || - (argc && strcmp(vty_ipv6_accesslist_name, argv[0]))) + (argc == 4 && strcmp(vty_ipv6_accesslist_name, accesslist))) { vty_out (vty, "IPv6 access-class is not currently applied to vty%s", - VTY_NEWLINE); + VTY_NEWLINE); return CMD_WARNING; } @@ -2946,12 +2959,16 @@ DEFUN (terminal_no_monitor, return CMD_SUCCESS; } -ALIAS (terminal_no_monitor, +DEFUN (no_terminal_monitor, no_terminal_monitor_cmd, "no terminal monitor", NO_STR "Set terminal line parameters\n" "Copy debug output to the current terminal line\n") +{ + return terminal_no_monitor (self, vty, argc, argv); +} + DEFUN (show_history, show_history_cmd, @@ -2964,13 +2981,13 @@ DEFUN (show_history, for (index = vty->hindex + 1; index != vty->hindex;) { if (index == VTY_MAXHIST) - { - index = 0; - continue; - } + { + index = 0; + continue; + } if (vty->hist[index] != NULL) - vty_out (vty, " %s%s", vty->hist[index], VTY_NEWLINE); + vty_out (vty, " %s%s", vty->hist[index], VTY_NEWLINE); index++; } @@ -2997,17 +3014,17 @@ vty_config_write (struct vty *vty) if (vty_accesslist_name) vty_out (vty, " access-class %s%s", - vty_accesslist_name, VTY_NEWLINE); + vty_accesslist_name, VTY_NEWLINE); if (vty_ipv6_accesslist_name) vty_out (vty, " ipv6 access-class %s%s", - vty_ipv6_accesslist_name, VTY_NEWLINE); + vty_ipv6_accesslist_name, VTY_NEWLINE); /* exec-timeout */ if (vty_timeout_val != VTY_TIMEOUT_DEFAULT) - vty_out (vty, " exec-timeout %ld %ld%s", - vty_timeout_val / 60, - vty_timeout_val % 60, VTY_NEWLINE); + vty_out (vty, " exec-timeout %ld %ld%s", + vty_timeout_val / 60, + vty_timeout_val % 60, VTY_NEWLINE); /* login */ if (no_password_check) @@ -3015,7 +3032,7 @@ vty_config_write (struct vty *vty) if (do_log_commands) vty_out (vty, "log commands%s", VTY_NEWLINE); - + vty_out (vty, "!%s", VTY_NEWLINE); return CMD_SUCCESS; @@ -3039,16 +3056,16 @@ vty_reset () for (i = 0; i < vector_active (vtyvec); i++) if ((vty = vector_slot (vtyvec, i)) != NULL) { - buffer_reset (vty->obuf); - vty->status = VTY_CLOSE; - vty_close (vty); + buffer_reset (vty->obuf); + vty->status = VTY_CLOSE; + vty_close (vty); } for (i = 0; i < vector_active (Vvty_serv_thread); i++) if ((vty_serv_thread = vector_slot (Vvty_serv_thread, i)) != NULL) { - thread_cancel (vty_serv_thread); - vector_slot (Vvty_serv_thread, i) = NULL; + thread_cancel (vty_serv_thread); + vector_slot (Vvty_serv_thread, i) = NULL; close (i); } @@ -3083,15 +3100,15 @@ vty_save_cwd (void) * Hence not worrying about it too much. */ if (!chdir (SYSCONFDIR)) - { - fprintf(stderr, "Failure to chdir to %s, errno: %d\n", SYSCONFDIR, errno); - exit(-1); - } + { + fprintf(stderr, "Failure to chdir to %s, errno: %d\n", SYSCONFDIR, errno); + exit(-1); + } if (getcwd (cwd, MAXPATHLEN) == NULL) - { - fprintf(stderr, "Failure to getcwd, errno: %d\n", errno); - exit(-1); - } + { + fprintf(stderr, "Failure to getcwd, errno: %d\n", errno); + exit(-1); + } } vty_cwd = XMALLOC (MTYPE_TMP, strlen (cwd) + 1); diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c index 685be58324..9ba7287656 100644 --- a/ospf6d/ospf6_area.c +++ b/ospf6d/ospf6_area.c @@ -435,25 +435,32 @@ ospf6_area_show (struct vty *vty, struct ospf6_area *oa) DEFUN (area_range, area_range_cmd, - "area A.B.C.D range X:X::X:X/M", - "OSPF area parameters\n" - OSPF6_AREA_ID_STR + "area <A.B.C.D|(0-4294967295)> range X:X::X:X/M [<advertise|not-advertise|cost (0-16777215)>]", + "OSPF6 area parameters\n" + "OSPF6 area ID in IP address format\n" + "OSPF6 area ID as a decimal value\n" "Configured address range\n" "Specify IPv6 prefix\n" - ) + "Advertise\n" + "Do not advertise\n" + "User specified metric for this range\n" + "Advertised metric for this range\n") { + int idx_ipv4 = 1; + int idx_ipv6_prefixlen = 3; + int idx_type = 4; int ret; struct ospf6_area *oa; struct prefix prefix; struct ospf6_route *range; u_int32_t cost = OSPF_AREA_RANGE_COST_UNSPEC; - OSPF6_CMD_AREA_GET (argv[0], oa); + OSPF6_CMD_AREA_GET (argv[idx_ipv4]->arg, oa); - ret = str2prefix (argv[1], &prefix); + ret = str2prefix (argv[idx_ipv6_prefixlen]->arg, &prefix); if (ret != 1 || prefix.family != AF_INET6) { - vty_out (vty, "Malformed argument: %s%s", argv[1], VNL); + vty_out (vty, "Malformed argument: %s%s", argv[idx_ipv6_prefixlen]->arg, VNL); return CMD_SUCCESS; } @@ -469,26 +476,26 @@ DEFUN (area_range, (u_int32_t) htonl(ospf6_new_range_ls_id (oa->range_table)); } - if (argc > 2) + if (argc > idx_type) { - if (strcmp (argv[2], "not-advertise") == 0) + if (strmatch (argv[idx_type]->text, "not-advertise")) { SET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE); } - else if (strcmp (argv[2], "advertise") == 0) + else if (strmatch (argv[idx_type]->text, "advertise")) { UNSET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE); } else { - VTY_GET_INTEGER_RANGE ("cost", cost, argv[2], 0, OSPF_LS_INFINITY); + VTY_GET_INTEGER_RANGE ("cost", cost, argv[5]->arg, 0, OSPF_LS_INFINITY); UNSET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE); } } range->path.u.cost_config = cost; - zlog_debug ("%s: for prefix %s, flag = %x\n", __func__, argv[1], range->flag); + zlog_debug ("%s: for prefix %s, flag = %x\n", __func__, argv[idx_ipv6_prefixlen]->arg, range->flag); if (range->rnode == NULL) { ospf6_route_add (range, oa->range_table); @@ -503,64 +510,34 @@ DEFUN (area_range, return CMD_SUCCESS; } -ALIAS (area_range, - area_range_advertise_cmd, - "area A.B.C.D range X:X::X:X/M (advertise|not-advertise)", - "OSPF area parameters\n" - OSPF6_AREA_ID_STR - "Configured address range\n" - "Specify IPv6 prefix\n" - ) - -ALIAS (area_range, - area_range_cost_cmd, - "area (A.B.C.D|<0-4294967295>) range X:X::X:X/M cost <0-16777215>", - "OSPF area parameters\n" - OSPF6_AREA_ID_STR - "Summarize routes matching address/mask (border routers only)\n" - "Area range prefix\n" - "User specified metric for this range\n" - "Advertised metric for this range\n") - -ALIAS (area_range, - area_range_advertise_cost_cmd, - "area (A.B.C.D|<0-4294967295>) range X:X::X:X/M advertise cost <0-16777215>", - "OSPF area parameters\n" - OSPF6_AREA_ID_STR - "Summarize routes matching address/mask (border routers only)\n" - "Area range prefix\n" - "User specified metric for this range\n" - "Advertised metric for this range\n") - DEFUN (no_area_range, no_area_range_cmd, - "no area A.B.C.D range X:X::X:X/M", + "no area A.B.C.D range X:X::X:X/M [<advertise|not-advertise>] [cost (0-16777215)]", NO_STR - "OSPF area parameters\n" + "OSPF6 area parameters\n" OSPF6_AREA_ID_STR "Configured address range\n" "Specify IPv6 prefix\n") { + int idx_ipv4 = 2; int ret; struct ospf6_area *oa; struct prefix prefix; struct ospf6_route *range, *route; - OSPF6_CMD_AREA_GET (argv[0], oa); - argc--; - argv++; + OSPF6_CMD_AREA_GET (argv[idx_ipv4]->arg, oa); - ret = str2prefix (argv[0], &prefix); + ret = str2prefix (argv[idx_ipv4]->arg, &prefix); if (ret != 1 || prefix.family != AF_INET6) { - vty_out (vty, "Malformed argument: %s%s", argv[0], VNL); + vty_out (vty, "Malformed argument: %s%s", argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } range = ospf6_route_lookup (&prefix, oa->range_table); if (range == NULL) { - vty_out (vty, "Range %s does not exists.%s", argv[0], VNL); + vty_out (vty, "Range %s does not exists.%s", argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } @@ -584,36 +561,8 @@ DEFUN (no_area_range, return CMD_SUCCESS; } -ALIAS (no_area_range, - no_area_range_advertise_cmd, - "no area A.B.C.D range X:X::X:X/M (advertise|not-advertise)", - NO_STR - "OSPF area parameters\n" - OSPF6_AREA_ID_STR - "Configured address range\n" - "Specify IPv6 prefix\n") -ALIAS (no_area_range, - no_area_range_cost_cmd, - "no area (A.B.C.D|<0-4294967295>) range X:X::X:X/M cost <0-16777215>", - NO_STR - "OSPF area parameters\n" - OSPF6_AREA_ID_STR - "Summarize routes matching address/mask (border routers only)\n" - "Area range prefix\n" - "User specified metric for this range\n" - "Advertised metric for this range\n") -ALIAS (no_area_range, - no_area_range_advertise_cost_cmd, - "no area (A.B.C.D|<0-4294967295>) range X:X::X:X/M advertise cost <0-16777215>", - NO_STR - "OSPF area parameters\n" - OSPF6_AREA_ID_STR - "Summarize routes matching address/mask (border routers only)\n" - "Area range prefix\n" - "User specified metric for this range\n" - "Advertised metric for this range\n") void ospf6_area_config_write (struct vty *vty) @@ -668,30 +617,30 @@ ospf6_area_config_write (struct vty *vty) DEFUN (area_filter_list, area_filter_list_cmd, - "area A.B.C.D filter-list prefix WORD (in|out)", - "OSPFv6 area parameters\n" - "OSPFv6 area ID in IP address format\n" - "Filter networks between OSPFv6 areas\n" - "Filter prefixes between OSPFv6 areas\n" + "area A.B.C.D filter-list prefix WORD <in|out>", + "OSPF6 area parameters\n" + "OSPF6 area ID in IP address format\n" + "Filter networks between OSPF6 areas\n" + "Filter prefixes between OSPF6 areas\n" "Name of an IPv6 prefix-list\n" "Filter networks sent to this area\n" "Filter networks sent from this area\n") { + int idx_ipv4 = 1; + int idx_word = 4; struct ospf6_area *area; struct prefix_list *plist; - OSPF6_CMD_AREA_GET (argv[0], area); - argc--; - argv++; + OSPF6_CMD_AREA_GET (argv[idx_ipv4]->arg, area); - plist = prefix_list_lookup (AFI_IP6, argv[0]); - if (strncmp (argv[1], "in", 2) == 0) + plist = prefix_list_lookup (AFI_IP6, argv[idx_ipv4]->arg); + if (strncmp (argv[idx_word]->arg, "in", 2) == 0) { PREFIX_LIST_IN (area) = plist; if (PREFIX_NAME_IN (area)) free (PREFIX_NAME_IN (area)); - PREFIX_NAME_IN (area) = strdup (argv[0]); + PREFIX_NAME_IN (area) = strdup (argv[idx_ipv4]->arg); ospf6_abr_reimport (area); } else @@ -700,7 +649,7 @@ DEFUN (area_filter_list, if (PREFIX_NAME_OUT (area)) free (PREFIX_NAME_OUT (area)); - PREFIX_NAME_OUT (area) = strdup (argv[0]); + PREFIX_NAME_OUT (area) = strdup (argv[idx_ipv4]->arg); ospf6_abr_enable_area (area); } @@ -709,26 +658,26 @@ DEFUN (area_filter_list, DEFUN (no_area_filter_list, no_area_filter_list_cmd, - "no area A.B.C.D filter-list prefix WORD (in|out)", + "no area A.B.C.D filter-list prefix WORD <in|out>", NO_STR - "OSPFv6 area parameters\n" - "OSPFv6 area ID in IP address format\n" - "Filter networks between OSPFv6 areas\n" - "Filter prefixes between OSPFv6 areas\n" + "OSPF6 area parameters\n" + "OSPF6 area ID in IP address format\n" + "Filter networks between OSPF6 areas\n" + "Filter prefixes between OSPF6 areas\n" "Name of an IPv6 prefix-list\n" "Filter networks sent to this area\n" "Filter networks sent from this area\n") { + int idx_ipv4 = 2; + int idx_word = 5; struct ospf6_area *area; - OSPF6_CMD_AREA_GET (argv[0], area); - argc--; - argv++; + OSPF6_CMD_AREA_GET (argv[idx_ipv4]->arg, area); - if (strncmp (argv[1], "in", 2) == 0) + if (strncmp (argv[idx_word]->arg, "in", 2) == 0) { if (PREFIX_NAME_IN (area)) - if (strcmp (PREFIX_NAME_IN (area), argv[0]) != 0) + if (strcmp (PREFIX_NAME_IN (area), argv[idx_ipv4]->arg) != 0) return CMD_SUCCESS; PREFIX_LIST_IN (area) = NULL; @@ -741,7 +690,7 @@ DEFUN (no_area_filter_list, else { if (PREFIX_NAME_OUT (area)) - if (strcmp (PREFIX_NAME_OUT (area), argv[0]) != 0) + if (strcmp (PREFIX_NAME_OUT (area), argv[idx_ipv4]->arg) != 0) return CMD_SUCCESS; PREFIX_LIST_OUT (area) = NULL; @@ -758,24 +707,26 @@ DEFUN (no_area_filter_list, DEFUN (area_import_list, area_import_list_cmd, "area A.B.C.D import-list NAME", - "OSPFv6 area parameters\n" - "OSPFv6 area ID in IP address format\n" + "OSPF6 area parameters\n" + "OSPF6 area ID in IP address format\n" "Set the filter for networks from other areas announced to the specified one\n" "Name of the acess-list\n") { + int idx_ipv4 = 1; + int idx_name = 3; struct ospf6_area *area; struct access_list *list; - OSPF6_CMD_AREA_GET(argv[0], area); + OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area); - list = access_list_lookup (AFI_IP6, argv[1]); + list = access_list_lookup (AFI_IP6, argv[idx_name]->arg); IMPORT_LIST (area) = list; if (IMPORT_NAME (area)) free (IMPORT_NAME (area)); - IMPORT_NAME (area) = strdup (argv[1]); + IMPORT_NAME (area) = strdup (argv[idx_name]->arg); ospf6_abr_reimport (area); return CMD_SUCCESS; @@ -784,14 +735,16 @@ DEFUN (area_import_list, DEFUN (no_area_import_list, no_area_import_list_cmd, "no area A.B.C.D import-list NAME", - "OSPFv6 area parameters\n" - "OSPFv6 area ID in IP address format\n" + NO_STR + "OSPF6 area parameters\n" + "OSPF6 area ID in IP address format\n" "Unset the filter for networks announced to other areas\n" - "NAme of the access-list\n") + "Name of the access-list\n") { + int idx_ipv4 = 2; struct ospf6_area *area; - OSPF6_CMD_AREA_GET(argv[0], area); + OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area); IMPORT_LIST (area) = 0; @@ -807,24 +760,26 @@ DEFUN (no_area_import_list, DEFUN (area_export_list, area_export_list_cmd, "area A.B.C.D export-list NAME", - "OSPFv6 area parameters\n" - "OSPFv6 area ID in IP address format\n" + "OSPF6 area parameters\n" + "OSPF6 area ID in IP address format\n" "Set the filter for networks announced to other areas\n" "Name of the acess-list\n") { + int idx_ipv4 = 1; + int idx_name = 3; struct ospf6_area *area; struct access_list *list; - OSPF6_CMD_AREA_GET(argv[0], area); + OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area); - list = access_list_lookup (AFI_IP6, argv[1]); + list = access_list_lookup (AFI_IP6, argv[idx_name]->arg); EXPORT_LIST (area) = list; if (EXPORT_NAME (area)) free (EXPORT_NAME (area)); - EXPORT_NAME (area) = strdup (argv[1]); + EXPORT_NAME (area) = strdup (argv[idx_name]->arg); ospf6_abr_enable_area (area); return CMD_SUCCESS; @@ -833,14 +788,16 @@ DEFUN (area_export_list, DEFUN (no_area_export_list, no_area_export_list_cmd, "no area A.B.C.D export-list NAME", - "OSPFv6 area parameters\n" - "OSPFv6 area ID in IP address format\n" + NO_STR + "OSPF6 area parameters\n" + "OSPF6 area ID in IP address format\n" "Unset the filter for networks announced to other areas\n" "Name of the access-list\n") { + int idx_ipv4 = 2; struct ospf6_area *area; - OSPF6_CMD_AREA_GET(argv[0], area); + OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area); EXPORT_LIST (area) = 0; @@ -899,6 +856,7 @@ DEFUN (show_ipv6_ospf6_area_spf_tree, "Shortest Path First caculation\n" "Show SPF tree\n") { + int idx_ipv4 = 4; u_int32_t area_id; struct ospf6_area *oa; struct ospf6_vertex *root; @@ -909,15 +867,15 @@ DEFUN (show_ipv6_ospf6_area_spf_tree, ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix); - if (inet_pton (AF_INET, argv[0], &area_id) != 1) + if (inet_pton (AF_INET, argv[idx_ipv4]->arg, &area_id) != 1) { - vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL); + vty_out (vty, "Malformed Area-ID: %s%s", argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } oa = ospf6_area_lookup (area_id, ospf6); if (oa == NULL) { - vty_out (vty, "No such Area: %s%s", argv[0], VNL); + vty_out (vty, "No such Area: %s%s", argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } @@ -940,10 +898,14 @@ DEFUN (show_ipv6_ospf6_simulate_spf_tree_root, SHOW_STR IP6_STR OSPF6_STR - "Shortest Path First caculation\n" + "Shortest Path First calculation\n" "Show SPF tree\n" - "Specify root's router-id to calculate another router's SPF tree\n") + "Specify root's router-id to calculate another router's SPF tree\n" + "OSPF6 area parameters\n" + OSPF6_AREA_ID_STR) { + int idx_ipv4 = 5; + int idx_ipv4_2 = 7; u_int32_t area_id; struct ospf6_area *oa; struct ospf6_vertex *root; @@ -955,18 +917,18 @@ DEFUN (show_ipv6_ospf6_simulate_spf_tree_root, OSPF6_CMD_CHECK_RUNNING (); - inet_pton (AF_INET, argv[0], &router_id); + inet_pton (AF_INET, argv[idx_ipv4]->arg, &router_id); ospf6_linkstate_prefix (router_id, htonl (0), &prefix); - if (inet_pton (AF_INET, argv[1], &area_id) != 1) + if (inet_pton (AF_INET, argv[idx_ipv4_2]->arg, &area_id) != 1) { - vty_out (vty, "Malformed Area-ID: %s%s", argv[1], VNL); + vty_out (vty, "Malformed Area-ID: %s%s", argv[idx_ipv4_2]->arg, VNL); return CMD_SUCCESS; } oa = ospf6_area_lookup (area_id, ospf6); if (oa == NULL) { - vty_out (vty, "No such Area: %s%s", argv[1], VNL); + vty_out (vty, "No such Area: %s%s", argv[idx_ipv4_2]->arg, VNL); return CMD_SUCCESS; } @@ -996,15 +958,16 @@ DEFUN (show_ipv6_ospf6_simulate_spf_tree_root, DEFUN (ospf6_area_stub, ospf6_area_stub_cmd, - "area (A.B.C.D|<0-4294967295>) stub", + "area <A.B.C.D|(0-4294967295)> stub", "OSPF6 area parameters\n" "OSPF6 area ID in IP address format\n" "OSPF6 area ID as a decimal value\n" "Configure OSPF6 area as stub\n") { + int idx_ipv4_number = 1; struct ospf6_area *area; - OSPF6_CMD_AREA_GET(argv[0], area); + OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area); if (!ospf6_area_stub_set (ospf6, area)) { @@ -1020,16 +983,17 @@ DEFUN (ospf6_area_stub, DEFUN (ospf6_area_stub_no_summary, ospf6_area_stub_no_summary_cmd, - "area (A.B.C.D|<0-4294967295>) stub no-summary", + "area <A.B.C.D|(0-4294967295)> stub no-summary", "OSPF6 stub parameters\n" "OSPF6 area ID in IP address format\n" "OSPF6 area ID as a decimal value\n" "Configure OSPF6 area as stub\n" "Do not inject inter-area routes into stub\n") { + int idx_ipv4_number = 1; struct ospf6_area *area; - OSPF6_CMD_AREA_GET(argv[0], area); + OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area); if (!ospf6_area_stub_set (ospf6, area)) { @@ -1045,16 +1009,17 @@ DEFUN (ospf6_area_stub_no_summary, DEFUN (no_ospf6_area_stub, no_ospf6_area_stub_cmd, - "no area (A.B.C.D|<0-4294967295>) stub", + "no area <A.B.C.D|(0-4294967295)> stub", NO_STR "OSPF6 area parameters\n" "OSPF6 area ID in IP address format\n" "OSPF6 area ID as a decimal value\n" "Configure OSPF6 area as stub\n") { + int idx_ipv4_number = 2; struct ospf6_area *area; - OSPF6_CMD_AREA_GET(argv[0], area); + OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area); ospf6_area_stub_unset (ospf6, area); ospf6_area_no_summary_unset (ospf6, area); @@ -1064,7 +1029,7 @@ DEFUN (no_ospf6_area_stub, DEFUN (no_ospf6_area_stub_no_summary, no_ospf6_area_stub_no_summary_cmd, - "no area (A.B.C.D|<0-4294967295>) stub no-summary", + "no area <A.B.C.D|(0-4294967295)> stub no-summary", NO_STR "OSPF6 area parameters\n" "OSPF6 area ID in IP address format\n" @@ -1072,9 +1037,10 @@ DEFUN (no_ospf6_area_stub_no_summary, "Configure OSPF6 area as stub\n" "Do not inject inter-area routes into area\n") { + int idx_ipv4_number = 2; struct ospf6_area *area; - OSPF6_CMD_AREA_GET(argv[0], area); + OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area); ospf6_area_stub_unset (ospf6, area); ospf6_area_no_summary_unset (ospf6, area); @@ -1090,13 +1056,7 @@ ospf6_area_init (void) install_element (VIEW_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd); install_element (OSPF6_NODE, &area_range_cmd); - install_element (OSPF6_NODE, &area_range_advertise_cmd); - install_element (OSPF6_NODE, &area_range_cost_cmd); - install_element (OSPF6_NODE, &area_range_advertise_cost_cmd); install_element (OSPF6_NODE, &no_area_range_cmd); - install_element (OSPF6_NODE, &no_area_range_advertise_cmd); - install_element (OSPF6_NODE, &no_area_range_cost_cmd); - install_element (OSPF6_NODE, &no_area_range_advertise_cost_cmd); install_element (OSPF6_NODE, &ospf6_area_stub_no_summary_cmd); install_element (OSPF6_NODE, &ospf6_area_stub_cmd); install_element (OSPF6_NODE, &no_ospf6_area_stub_no_summary_cmd); diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index 46ea46305c..c00445e34a 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -96,7 +96,7 @@ ospf6_as_external_lsa_originate (struct ospf6_route *route) if (info->tag) SET_FLAG (as_external_lsa->bits_metric, OSPF6_ASBR_BIT_T); else - UNSET_FLAG (as_external_lsa->bits_metric, OSPF6_ASBR_BIT_T); + UNSET_FLAG (as_external_lsa->bits_metric, OSPF6_ASBR_BIT_T); /* Set metric */ OSPF6_ASBR_METRIC_SET (as_external_lsa, route->path.cost); @@ -686,14 +686,13 @@ ospf6_asbr_redistribute_remove (int type, ifindex_t ifindex, DEFUN (ospf6_redistribute, ospf6_redistribute_cmd, - "redistribute " QUAGGA_REDIST_STR_OSPF6D, + "redistribute <kernel|connected|static|ripng|isis|bgp|table>", "Redistribute\n" - QUAGGA_REDIST_HELP_STR_OSPF6D - ) + QUAGGA_REDIST_HELP_STR_OSPF6D) { int type; - type = proto_redistnum(AFI_IP6, argv[0]); + type = proto_redistnum(AFI_IP6, argv[2]->arg); if (type < 0 || type == ZEBRA_ROUTE_OSPF6) return CMD_WARNING; @@ -704,36 +703,39 @@ DEFUN (ospf6_redistribute, DEFUN (ospf6_redistribute_routemap, ospf6_redistribute_routemap_cmd, - "redistribute " QUAGGA_REDIST_STR_OSPF6D " route-map WORD", + "redistribute <kernel|connected|static|ripng|isis|bgp|table> route-map WORD", "Redistribute\n" QUAGGA_REDIST_HELP_STR_OSPF6D "Route map reference\n" - "Route map name\n" - ) + "Route map name\n") { + int idx_protocol = 1; + int idx_word = 3; int type; - type = proto_redistnum(AFI_IP6, argv[0]); + type = proto_redistnum(AFI_IP6, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_OSPF6) return CMD_WARNING; ospf6_asbr_redistribute_unset (type); - ospf6_asbr_routemap_set (type, argv[1]); + ospf6_asbr_routemap_set (type, argv[idx_word]->arg); ospf6_asbr_redistribute_set (type); return CMD_SUCCESS; } DEFUN (no_ospf6_redistribute, no_ospf6_redistribute_cmd, - "no redistribute " QUAGGA_REDIST_STR_OSPF6D, + "no redistribute <kernel|connected|static|ripng|isis|bgp|table> [route-map WORD]", NO_STR "Redistribute\n" QUAGGA_REDIST_HELP_STR_OSPF6D - ) + "Route map reference\n" + "Route map name\n") { + int idx_protocol = 2; int type; - type = proto_redistnum(AFI_IP6, argv[0]); + type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); if (type < 0 || type == ZEBRA_ROUTE_OSPF6) return CMD_WARNING; @@ -742,14 +744,6 @@ DEFUN (no_ospf6_redistribute, return CMD_SUCCESS; } -ALIAS (no_ospf6_redistribute, - no_ospf6_redistribute_route_map_cmd, - "no redistribute " QUAGGA_REDIST_STR_OSPF6D " route-map WORD", - NO_STR - "Redistribute\n" - QUAGGA_REDIST_HELP_STR_OSPF6D - "Route map reference\n" - "Route map name\n") int ospf6_redistribute_config_write (struct vty *vty) @@ -1109,8 +1103,9 @@ DEFUN (ospf6_routemap_match_address_prefixlist, "Match entries of prefix-lists\n" "IPv6 prefix-list name\n") { + int idx_word = 4; int ret = route_map_add_match ((struct route_map_index *) vty->index, - "ipv6 address prefix-list", argv[0]); + "ipv6 address prefix-list", argv[idx_word]->arg); return route_map_command_status (vty, ret); } @@ -1125,8 +1120,9 @@ DEFUN (ospf6_routemap_no_match_address_prefixlist, "Match entries of prefix-lists\n" "IPv6 prefix-list name\n") { + int idx_word = 5; int ret = route_map_delete_match ((struct route_map_index *) vty->index, - "ipv6 address prefix-list", argv[0]); + "ipv6 address prefix-list", argv[idx_word]->arg); return route_map_command_status (vty, ret); } @@ -1138,134 +1134,63 @@ DEFUN (ospf6_routemap_match_interface, "Match first hop interface of route\n" "Interface name\n") { + int idx_word = 2; return route_map_add_match ((struct route_map_index *) vty->index, - "interface", argv[0]); + "interface", argv[idx_word]->arg); } /* "no match interface WORD" */ DEFUN (ospf6_routemap_no_match_interface, ospf6_routemap_no_match_interface_cmd, - "no match interface", - NO_STR - MATCH_STR - "Match first hop interface of route\n") -{ - int ret = route_map_delete_match ((struct route_map_index *) vty->index, - "interface", (argc == 0) ? NULL : argv[0]); - return route_map_command_status (vty, ret); -} - -ALIAS (ospf6_routemap_no_match_interface, - ospf6_routemap_no_match_interface_val_cmd, - "no match interface WORD", + "no match interface [WORD]", NO_STR MATCH_STR "Match first hop interface of route\n" "Interface name\n") - -/* add "match tag" */ -DEFUN (ospf6_routemap_match_tag, - ospf6_routemap_match_tag_cmd, - "match tag <1-4294967295>", - MATCH_STR - "Tag value for routing protocol\n" - "Tag value\n") { - int ret = route_map_add_match ((struct route_map_index *) vty->index, - "tag", argv[0]); - return route_map_command_status (vty, ret); -} + int idx_word = 3; + int ret; -/* delete "match tag" */ -DEFUN (ospf6_routemap_no_match_tag, - ospf6_routemap_no_match_tag_cmd, - "no match tag", - NO_STR - MATCH_STR - "Tag value for routing protocol\n") -{ - int ret = route_map_delete_match ((struct route_map_index *) vty->index, - "tag", argc ? argv[0] : NULL); + if (argc == 4) + ret = route_map_delete_match ((struct route_map_index *) vty->index, + "interface", argv[idx_word]->arg); + else + ret = route_map_delete_match ((struct route_map_index *) vty->index, + "interface", NULL); return route_map_command_status (vty, ret); } -ALIAS (ospf6_routemap_no_match_tag, - ospf6_routemap_no_match_tag_val_cmd, - "no match tag <1-4294967295>", - NO_STR - MATCH_STR - "Tag value for routing protocol\n" - "Tag value\n") - /* add "set metric-type" */ DEFUN (ospf6_routemap_set_metric_type, ospf6_routemap_set_metric_type_cmd, - "set metric-type (type-1|type-2)", + "set metric-type <type-1|type-2>", "Set value\n" "Type of metric\n" "OSPF6 external type 1 metric\n" "OSPF6 external type 2 metric\n") { + int idx_external = 2; int ret = route_map_add_set ((struct route_map_index *) vty->index, - "metric-type", argv[0]); + "metric-type", argv[idx_external]->arg); return route_map_command_status (vty, ret); } /* delete "set metric-type" */ DEFUN (ospf6_routemap_no_set_metric_type, ospf6_routemap_no_set_metric_type_cmd, - "no set metric-type (type-1|type-2)", + "no set metric-type <type-1|type-2>", NO_STR "Set value\n" "Type of metric\n" "OSPF6 external type 1 metric\n" "OSPF6 external type 2 metric\n") { + int idx_external = 3; int ret = route_map_delete_set ((struct route_map_index *) vty->index, - "metric-type", argv[0]); - return route_map_command_status (vty, ret); -} - -/* add "set metric" */ -DEFUN (set_metric, - set_metric_cmd, - "set metric <0-4294967295>", - "Set value\n" - "Metric value\n" - "Metric value\n") -{ - int ret = route_map_add_set ((struct route_map_index *) vty->index, - "metric", argv[0]); - return route_map_command_status (vty, ret); -} - -/* delete "set metric" */ -DEFUN (no_set_metric, - no_set_metric_cmd, - "no set metric", - NO_STR - SET_STR - "Metric value for destination routing protocol\n") -{ - int ret = 0; - - if (argc == 0) - ret = route_map_delete_set ((struct route_map_index *) vty->index, - "metric", NULL); - else - ret = route_map_delete_set ((struct route_map_index *) vty->index, - "metric", argv[0]); + "metric-type", argv[idx_external]->arg); return route_map_command_status (vty, ret); } -ALIAS (no_set_metric, - no_set_metric_val_cmd, - "no set metric <0-4294967295>", - NO_STR - SET_STR - "Metric value for destination routing protocol\n" - "Metric value\n") - /* add "set forwarding-address" */ DEFUN (ospf6_routemap_set_forwarding, ospf6_routemap_set_forwarding_cmd, @@ -1274,8 +1199,9 @@ DEFUN (ospf6_routemap_set_forwarding, "Forwarding Address\n" "IPv6 Address\n") { + int idx_ipv6 = 2; int ret = route_map_add_set ((struct route_map_index *) vty->index, - "forwarding-address", argv[0]); + "forwarding-address", argv[idx_ipv6]->arg); return route_map_command_status (vty, ret); } @@ -1288,45 +1214,40 @@ DEFUN (ospf6_routemap_no_set_forwarding, "Forwarding Address\n" "IPv6 Address\n") { + int idx_ipv6 = 3; int ret = route_map_delete_set ((struct route_map_index *) vty->index, - "forwarding-address", argv[0]); + "forwarding-address", argv[idx_ipv6]->arg); return route_map_command_status (vty, ret); } /* add "set tag" */ DEFUN (ospf6_routemap_set_tag, ospf6_routemap_set_tag_cmd, - "set tag <1-4294967295>", + "set tag (1-4294967295)", "Set value\n" "Tag value for routing protocol\n" "Tag value\n") { int ret = route_map_add_set ((struct route_map_index *) vty->index, - "tag", argv[0]); + "tag", argv[2]->arg); return route_map_command_status (vty, ret); } /* delete "set tag" */ DEFUN (ospf6_routemap_no_set_tag, ospf6_routemap_no_set_tag_cmd, - "no set tag", + "no set tag [(1-4294967295)]", NO_STR "Set value\n" - "Tag value for routing protocol\n") + "Tag value for routing protocol\n" + "Tag value\n") { - int ret = route_map_delete_set ((struct route_map_index *) vty->index, - "tag", argc ? argv[0] : NULL); + char *tag = (argc == 4) ? argv[3]->arg : NULL; + VTY_DECLVAR_CONTEXT (route_map_index, index); + int ret = route_map_delete_set (index, "tag", tag); return route_map_command_status (vty, ret); } -ALIAS (ospf6_routemap_no_set_tag, - ospf6_routemap_no_set_tag_val_cmd, - "no set tag <1-4294967295>", - NO_STR - "Set value\n" - "Tag value for routing protocol\n" - "Tag value\n") - static void ospf6_routemap_init (void) { @@ -1335,6 +1256,9 @@ ospf6_routemap_init (void) route_map_add_hook (ospf6_asbr_routemap_update); route_map_delete_hook (ospf6_asbr_routemap_update); + route_map_set_metric_hook (generic_set_add); + route_map_no_set_metric_hook (generic_set_delete); + route_map_install_match (&ospf6_routemap_rule_match_address_prefixlist_cmd); route_map_install_match (&ospf6_routemap_rule_match_interface_cmd); route_map_install_match (&ospf6_routemap_rule_match_tag_cmd); @@ -1351,30 +1275,18 @@ ospf6_routemap_init (void) /* Match interface */ install_element (RMAP_NODE, &ospf6_routemap_match_interface_cmd); install_element (RMAP_NODE, &ospf6_routemap_no_match_interface_cmd); - install_element (RMAP_NODE, &ospf6_routemap_no_match_interface_val_cmd); - - /* Match tag */ - install_element (RMAP_NODE, &ospf6_routemap_match_tag_cmd); - install_element (RMAP_NODE, &ospf6_routemap_no_match_tag_cmd); - install_element (RMAP_NODE, &ospf6_routemap_no_match_tag_val_cmd); /* ASE Metric Type (e.g. Type-1/Type-2) */ install_element (RMAP_NODE, &ospf6_routemap_set_metric_type_cmd); install_element (RMAP_NODE, &ospf6_routemap_no_set_metric_type_cmd); /* ASE Metric */ - install_element (RMAP_NODE, &set_metric_cmd); - install_element (RMAP_NODE, &no_set_metric_cmd); - install_element (RMAP_NODE, &no_set_metric_val_cmd); - - /* Forwarding address */ install_element (RMAP_NODE, &ospf6_routemap_set_forwarding_cmd); install_element (RMAP_NODE, &ospf6_routemap_no_set_forwarding_cmd); /* Tag */ install_element (RMAP_NODE, &ospf6_routemap_set_tag_cmd); install_element (RMAP_NODE, &ospf6_routemap_no_set_tag_cmd); - install_element (RMAP_NODE, &ospf6_routemap_no_set_tag_val_cmd); } @@ -1529,7 +1441,6 @@ ospf6_asbr_init (void) install_element (OSPF6_NODE, &ospf6_redistribute_cmd); install_element (OSPF6_NODE, &ospf6_redistribute_routemap_cmd); install_element (OSPF6_NODE, &no_ospf6_redistribute_cmd); - install_element (OSPF6_NODE, &no_ospf6_redistribute_route_map_cmd); } void @@ -1593,5 +1504,3 @@ install_element_ospf6_debug_asbr () install_element (CONFIG_NODE, &debug_ospf6_asbr_cmd); install_element (CONFIG_NODE, &no_debug_ospf6_asbr_cmd); } - - diff --git a/ospf6d/ospf6_bfd.c b/ospf6d/ospf6_bfd.c index f9bb6f0031..ffbefd139d 100644 --- a/ospf6d/ospf6_bfd.c +++ b/ospf6d/ospf6_bfd.c @@ -346,7 +346,7 @@ DEFUN (ipv6_ospf6_bfd, DEFUN (ipv6_ospf6_bfd_param, ipv6_ospf6_bfd_param_cmd, - "ipv6 ospf6 bfd " BFD_CMD_DETECT_MULT_RANGE BFD_CMD_MIN_RX_RANGE BFD_CMD_MIN_TX_RANGE, + "ipv6 ospf6 bfd (2-255) (50-60000) (50-60000)", IP6_STR OSPF6_STR "Enables BFD support\n" @@ -354,6 +354,9 @@ DEFUN (ipv6_ospf6_bfd_param, "Required min receive interval\n" "Desired min transmit interval\n") { + int idx_number = 3; + int idx_number_2 = 4; + int idx_number_3 = 5; struct ospf6_interface *oi; struct interface *ifp; u_int32_t rx_val; @@ -369,7 +372,7 @@ DEFUN (ipv6_ospf6_bfd_param, oi = ospf6_interface_create (ifp); assert (oi); - if ((ret = bfd_validate_param (vty, argv[0], argv[1], argv[2], &dm_val, + if ((ret = bfd_validate_param (vty, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg, &dm_val, &rx_val, &tx_val)) != CMD_SUCCESS) return ret; diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index cd3b171a61..45977c616e 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -988,23 +988,23 @@ ospf6_interface_show (struct vty *vty, struct interface *ifp) /* show interface */ DEFUN (show_ipv6_ospf6_interface, show_ipv6_ospf6_interface_ifname_cmd, - "show ipv6 ospf6 interface IFNAME", + "show ipv6 ospf6 interface [IFNAME]", SHOW_STR IP6_STR OSPF6_STR INTERFACE_STR - IFNAME_STR - ) + IFNAME_STR) { + int idx_ifname = 4; struct interface *ifp; struct listnode *i; - if (argc) + if (argc == 5) { - ifp = if_lookup_by_name (argv[0]); + ifp = if_lookup_by_name (argv[idx_ifname]->arg); if (ifp == NULL) { - vty_out (vty, "No such Interface: %s%s", argv[0], + vty_out (vty, "No such Interface: %s%s", argv[idx_ifname]->arg, VNL); return CMD_WARNING; } @@ -1019,88 +1019,58 @@ DEFUN (show_ipv6_ospf6_interface, return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_interface, - show_ipv6_ospf6_interface_cmd, - "show ipv6 ospf6 interface", - SHOW_STR - IP6_STR - OSPF6_STR - INTERFACE_STR - ) - DEFUN (show_ipv6_ospf6_interface_ifname_prefix, show_ipv6_ospf6_interface_ifname_prefix_cmd, - "show ipv6 ospf6 interface IFNAME prefix", + "show ipv6 ospf6 interface IFNAME prefix [<X:X::X:X|X:X::X:X/M>] [<match|detail>]", SHOW_STR IP6_STR OSPF6_STR INTERFACE_STR IFNAME_STR "Display connected prefixes to advertise\n" - ) + OSPF6_ROUTE_ADDRESS_STR + OSPF6_ROUTE_PREFIX_STR + OSPF6_ROUTE_MATCH_STR + "Display details of the prefixes\n") { + int idx_ifname = 4; + int idx_prefix = 6; struct interface *ifp; struct ospf6_interface *oi; - ifp = if_lookup_by_name (argv[0]); + ifp = if_lookup_by_name (argv[idx_ifname]->arg); if (ifp == NULL) { - vty_out (vty, "No such Interface: %s%s", argv[0], VNL); + vty_out (vty, "No such Interface: %s%s", argv[idx_ifname]->arg, VNL); return CMD_WARNING; } oi = ifp->info; if (oi == NULL) { - vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL); + vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[idx_ifname]->arg, VNL); return CMD_WARNING; } - argc--; - argv++; - ospf6_route_table_show (vty, argc, argv, oi->route_connected); + ospf6_route_table_show (vty, idx_prefix, argc, argv, oi->route_connected); return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_interface_ifname_prefix, - show_ipv6_ospf6_interface_ifname_prefix_detail_cmd, - "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)", +DEFUN (show_ipv6_ospf6_interface_prefix, + show_ipv6_ospf6_interface_prefix_cmd, + "show ipv6 ospf6 interface prefix [<X:X::X:X|X:X::X:X/M>] [<match|detail>]", SHOW_STR IP6_STR OSPF6_STR INTERFACE_STR - IFNAME_STR "Display connected prefixes to advertise\n" OSPF6_ROUTE_ADDRESS_STR OSPF6_ROUTE_PREFIX_STR - "Display details of the prefixes\n" - ) - -ALIAS (show_ipv6_ospf6_interface_ifname_prefix, - show_ipv6_ospf6_interface_ifname_prefix_match_cmd, - "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)", - SHOW_STR - IP6_STR - OSPF6_STR - INTERFACE_STR - IFNAME_STR - "Display connected prefixes to advertise\n" - OSPF6_ROUTE_PREFIX_STR OSPF6_ROUTE_MATCH_STR - "Display details of the prefixes\n" - ) - -DEFUN (show_ipv6_ospf6_interface_prefix, - show_ipv6_ospf6_interface_prefix_cmd, - "show ipv6 ospf6 interface prefix", - SHOW_STR - IP6_STR - OSPF6_STR - INTERFACE_STR - "Display connected prefixes to advertise\n" - ) + "Display details of the prefixes\n") { + int idx_prefix = 5; struct listnode *i; struct ospf6_interface *oi; struct interface *ifp; @@ -1111,49 +1081,23 @@ DEFUN (show_ipv6_ospf6_interface_prefix, if (oi == NULL) continue; - ospf6_route_table_show (vty, argc, argv, oi->route_connected); + ospf6_route_table_show (vty, idx_prefix, argc, argv, oi->route_connected); } return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_interface_prefix, - show_ipv6_ospf6_interface_prefix_detail_cmd, - "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)", - SHOW_STR - IP6_STR - OSPF6_STR - INTERFACE_STR - "Display connected prefixes to advertise\n" - OSPF6_ROUTE_ADDRESS_STR - OSPF6_ROUTE_PREFIX_STR - "Display details of the prefixes\n" - ) - -ALIAS (show_ipv6_ospf6_interface_prefix, - show_ipv6_ospf6_interface_prefix_match_cmd, - "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)", - SHOW_STR - IP6_STR - OSPF6_STR - INTERFACE_STR - "Display connected prefixes to advertise\n" - OSPF6_ROUTE_PREFIX_STR - OSPF6_ROUTE_MATCH_STR - "Display details of the prefixes\n" - ) - - /* interface variable set command */ DEFUN (ipv6_ospf6_ifmtu, ipv6_ospf6_ifmtu_cmd, - "ipv6 ospf6 ifmtu <1-65535>", + "ipv6 ospf6 ifmtu (1-65535)", IP6_STR OSPF6_STR "Interface MTU\n" "OSPFv3 Interface MTU\n" ) { + int idx_number = 3; struct ospf6_interface *oi; struct interface *ifp; unsigned int ifmtu, iobuflen; @@ -1168,7 +1112,7 @@ DEFUN (ipv6_ospf6_ifmtu, oi = ospf6_interface_create (ifp); assert (oi); - ifmtu = strtol (argv[0], NULL, 10); + ifmtu = strtol (argv[idx_number]->arg, NULL, 10); if (oi->ifmtu == ifmtu) return CMD_SUCCESS; @@ -1255,13 +1199,14 @@ DEFUN (no_ipv6_ospf6_ifmtu, DEFUN (ipv6_ospf6_cost, ipv6_ospf6_cost_cmd, - "ipv6 ospf6 cost <1-65535>", + "ipv6 ospf6 cost (1-65535)", IP6_STR OSPF6_STR "Interface cost\n" "Outgoing metric of this interface\n" ) { + int idx_number = 3; struct ospf6_interface *oi; struct interface *ifp; unsigned long int lcost; @@ -1274,7 +1219,7 @@ DEFUN (ipv6_ospf6_cost, oi = ospf6_interface_create (ifp); assert (oi); - lcost = strtol (argv[0], NULL, 10); + lcost = strtol (argv[idx_number]->arg, NULL, 10); if (lcost > UINT32_MAX) { @@ -1322,18 +1267,19 @@ DEFUN (no_ipv6_ospf6_cost, DEFUN (auto_cost_reference_bandwidth, auto_cost_reference_bandwidth_cmd, - "auto-cost reference-bandwidth <1-4294967>", + "auto-cost reference-bandwidth (1-4294967)", "Calculate OSPF interface cost according to bandwidth\n" "Use reference bandwidth method to assign OSPF cost\n" "The reference bandwidth in terms of Mbits per second\n") { + int idx_number = 2; struct ospf6 *o = vty->index; struct ospf6_area *oa; struct ospf6_interface *oi; struct listnode *i, *j; u_int32_t refbw; - refbw = strtol (argv[0], NULL, 10); + refbw = strtol (argv[idx_number]->arg, NULL, 10); if (refbw < 1 || refbw > 4294967) { vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); @@ -1354,10 +1300,11 @@ DEFUN (auto_cost_reference_bandwidth, DEFUN (no_auto_cost_reference_bandwidth, no_auto_cost_reference_bandwidth_cmd, - "no auto-cost reference-bandwidth", + "no auto-cost reference-bandwidth [(1-4294967)]", NO_STR "Calculate OSPF interface cost according to bandwidth\n" - "Use reference bandwidth method to assign OSPF cost\n") + "Use reference bandwidth method to assign OSPF cost\n" + "The reference bandwidth in terms of Mbits per second\n") { struct ospf6 *o = vty->index; struct ospf6_area *oa; @@ -1375,23 +1322,17 @@ DEFUN (no_auto_cost_reference_bandwidth, return CMD_SUCCESS; } -ALIAS (no_auto_cost_reference_bandwidth, - no_auto_cost_reference_bandwidth_val_cmd, - "no auto-cost reference-bandwidth <1-4294967>", - NO_STR - "Calculate OSPF interface cost according to bandwidth\n" - "Use reference bandwidth method to assign OSPF cost\n" - "The reference bandwidth in terms of Mbits per second\n") DEFUN (ipv6_ospf6_hellointerval, ipv6_ospf6_hellointerval_cmd, - "ipv6 ospf6 hello-interval <1-65535>", + "ipv6 ospf6 hello-interval (1-65535)", IP6_STR OSPF6_STR "Interval time of Hello packets\n" SECONDS_STR ) { + int idx_number = 3; struct ospf6_interface *oi; struct interface *ifp; @@ -1403,20 +1344,21 @@ DEFUN (ipv6_ospf6_hellointerval, oi = ospf6_interface_create (ifp); assert (oi); - oi->hello_interval = strtol (argv[0], NULL, 10); + oi->hello_interval = strtol (argv[idx_number]->arg, NULL, 10); return CMD_SUCCESS; } /* interface variable set command */ DEFUN (ipv6_ospf6_deadinterval, ipv6_ospf6_deadinterval_cmd, - "ipv6 ospf6 dead-interval <1-65535>", + "ipv6 ospf6 dead-interval (1-65535)", IP6_STR OSPF6_STR "Interval time after which a neighbor is declared down\n" SECONDS_STR ) { + int idx_number = 3; struct ospf6_interface *oi; struct interface *ifp; @@ -1428,20 +1370,21 @@ DEFUN (ipv6_ospf6_deadinterval, oi = ospf6_interface_create (ifp); assert (oi); - oi->dead_interval = strtol (argv[0], NULL, 10); + oi->dead_interval = strtol (argv[idx_number]->arg, NULL, 10); return CMD_SUCCESS; } /* interface variable set command */ DEFUN (ipv6_ospf6_transmitdelay, ipv6_ospf6_transmitdelay_cmd, - "ipv6 ospf6 transmit-delay <1-3600>", + "ipv6 ospf6 transmit-delay (1-3600)", IP6_STR OSPF6_STR "Transmit delay of this interface\n" SECONDS_STR ) { + int idx_number = 3; struct ospf6_interface *oi; struct interface *ifp; @@ -1453,20 +1396,21 @@ DEFUN (ipv6_ospf6_transmitdelay, oi = ospf6_interface_create (ifp); assert (oi); - oi->transdelay = strtol (argv[0], NULL, 10); + oi->transdelay = strtol (argv[idx_number]->arg, NULL, 10); return CMD_SUCCESS; } /* interface variable set command */ DEFUN (ipv6_ospf6_retransmitinterval, ipv6_ospf6_retransmitinterval_cmd, - "ipv6 ospf6 retransmit-interval <1-65535>", + "ipv6 ospf6 retransmit-interval (1-65535)", IP6_STR OSPF6_STR "Time between retransmitting lost link state advertisements\n" SECONDS_STR ) { + int idx_number = 3; struct ospf6_interface *oi; struct interface *ifp; @@ -1478,20 +1422,21 @@ DEFUN (ipv6_ospf6_retransmitinterval, oi = ospf6_interface_create (ifp); assert (oi); - oi->rxmt_interval = strtol (argv[0], NULL, 10); + oi->rxmt_interval = strtol (argv[idx_number]->arg, NULL, 10); return CMD_SUCCESS; } /* interface variable set command */ DEFUN (ipv6_ospf6_priority, ipv6_ospf6_priority_cmd, - "ipv6 ospf6 priority <0-255>", + "ipv6 ospf6 priority (0-255)", IP6_STR OSPF6_STR "Router priority\n" "Priority value\n" ) { + int idx_number = 3; struct ospf6_interface *oi; struct interface *ifp; @@ -1503,7 +1448,7 @@ DEFUN (ipv6_ospf6_priority, oi = ospf6_interface_create (ifp); assert (oi); - oi->priority = strtol (argv[0], NULL, 10); + oi->priority = strtol (argv[idx_number]->arg, NULL, 10); if (oi->area && (oi->state == OSPF6_INTERFACE_DROTHER || @@ -1516,13 +1461,14 @@ DEFUN (ipv6_ospf6_priority, DEFUN (ipv6_ospf6_instance, ipv6_ospf6_instance_cmd, - "ipv6 ospf6 instance-id <0-255>", + "ipv6 ospf6 instance-id (0-255)", IP6_STR OSPF6_STR "Instance ID for this interface\n" "Instance ID value\n" ) { + int idx_number = 3; struct ospf6_interface *oi; struct interface *ifp; @@ -1534,7 +1480,7 @@ DEFUN (ipv6_ospf6_instance, oi = ospf6_interface_create (ifp); assert (oi); - oi->instance_id = strtol (argv[0], NULL, 10); + oi->instance_id = strtol (argv[idx_number]->arg, NULL, 10); return CMD_SUCCESS; } @@ -1658,6 +1604,7 @@ DEFUN (ipv6_ospf6_advertise_prefix_list, "Prefix list name\n" ) { + int idx_word = 4; struct ospf6_interface *oi; struct interface *ifp; @@ -1671,7 +1618,7 @@ DEFUN (ipv6_ospf6_advertise_prefix_list, if (oi->plist_name) XFREE (MTYPE_CFG_PLIST_NAME, oi->plist_name); - oi->plist_name = XSTRDUP (MTYPE_CFG_PLIST_NAME, argv[0]); + oi->plist_name = XSTRDUP (MTYPE_CFG_PLIST_NAME, argv[idx_word]->arg); ospf6_interface_connected_route_update (oi->interface); @@ -1734,14 +1681,15 @@ DEFUN (no_ipv6_ospf6_advertise_prefix_list, DEFUN (ipv6_ospf6_network, ipv6_ospf6_network_cmd, - "ipv6 ospf6 network (broadcast|point-to-point)", + "ipv6 ospf6 network <broadcast|point-to-point>", IP6_STR OSPF6_STR "Network Type\n" - "Specify OSPFv6 broadcast network\n" + "Specify OSPF6 broadcast network\n" "Specify OSPF6 point-to-point network\n" ) { + int idx_network = 3; struct ospf6_interface *oi; struct interface *ifp; @@ -1754,14 +1702,14 @@ DEFUN (ipv6_ospf6_network, } assert (oi); - if (strncmp (argv[0], "b", 1) == 0) + if (strncmp (argv[idx_network]->arg, "b", 1) == 0) { if (oi->type == OSPF_IFTYPE_BROADCAST) return CMD_SUCCESS; oi->type = OSPF_IFTYPE_BROADCAST; } - else if (strncmp (argv[0], "point-to-p", 10) == 0) + else if (strncmp (argv[idx_network]->arg, "point-to-p", 10) == 0) { if (oi->type == OSPF_IFTYPE_POINTOPOINT) { return CMD_SUCCESS; @@ -1899,14 +1847,9 @@ ospf6_interface_init (void) /* Install interface node. */ install_node (&interface_node, config_write_ospf6_interface); - install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd); install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd); install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd); install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd); install_element (CONFIG_NODE, &interface_cmd); install_default (INTERFACE_NODE); @@ -1938,7 +1881,6 @@ ospf6_interface_init (void) /* reference bandwidth commands */ install_element (OSPF6_NODE, &auto_cost_reference_bandwidth_cmd); install_element (OSPF6_NODE, &no_auto_cost_reference_bandwidth_cmd); - install_element (OSPF6_NODE, &no_auto_cost_reference_bandwidth_val_cmd); } /* Clear the specified interface structure */ @@ -1974,19 +1916,20 @@ DEFUN (clear_ipv6_ospf6_interface, IFNAME_STR ) { + int idx_ifname = 4; struct interface *ifp; struct listnode *node; - if (argc == 0) /* Clear all the ospfv3 interfaces. */ + if (argc == 4) /* Clear all the ospfv3 interfaces. */ { for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) ospf6_interface_clear (vty, ifp); } else /* Interface name is specified. */ { - if ((ifp = if_lookup_by_name (argv[0])) == NULL) + if ((ifp = if_lookup_by_name (argv[idx_ifname]->arg)) == NULL) { - vty_out (vty, "No such Interface: %s%s", argv[0], VNL); + vty_out (vty, "No such Interface: %s%s", argv[idx_ifname]->arg, VNL); return CMD_WARNING; } ospf6_interface_clear (vty, ifp); diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c index 5b92212daa..586bd77f75 100644 --- a/ospf6d/ospf6_intra.c +++ b/ospf6d/ospf6_intra.c @@ -1730,8 +1730,9 @@ DEFUN (debug_ospf6_brouter_router, "Specify border-router's router-id\n" ) { + int idx_ipv4 = 4; u_int32_t router_id; - inet_pton (AF_INET, argv[0], &router_id); + inet_pton (AF_INET, argv[idx_ipv4]->arg, &router_id); OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ON (router_id); return CMD_SUCCESS; } @@ -1760,8 +1761,9 @@ DEFUN (debug_ospf6_brouter_area, "Specify Area-ID\n" ) { + int idx_ipv4 = 4; u_int32_t area_id; - inet_pton (AF_INET, argv[0], &area_id); + inet_pton (AF_INET, argv[idx_ipv4]->arg, &area_id); OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ON (area_id); return CMD_SUCCESS; } diff --git a/ospf6d/ospf6_lsa.c b/ospf6d/ospf6_lsa.c index 35e5a91544..ef56028a3b 100644 --- a/ospf6d/ospf6_lsa.c +++ b/ospf6d/ospf6_lsa.c @@ -818,26 +818,25 @@ ospf6_lsa_handler_name (struct ospf6_lsa_handler *h) DEFUN (debug_ospf6_lsa_type, debug_ospf6_lsa_hex_cmd, - "debug ospf6 lsa (router|network|inter-prefix|inter-router|as-external|link|intra-prefix|unknown)", + "debug ospf6 lsa <router|network|inter-prefix|inter-router|as-external|link|intra-prefix|unknown> [<originate|examine|flooding>]", DEBUG_STR OSPF6_STR "Debug Link State Advertisements (LSAs)\n" - "Specify LS type as Hexadecimal\n" - ) + "Specify LS type as Hexadecimal\n") { + int idx_lsa = 3; + int idx_type = 4; unsigned int i; struct ospf6_lsa_handler *handler = NULL; - assert (argc); - for (i = 0; i < vector_active (ospf6_lsa_handler_vector); i++) { handler = vector_slot (ospf6_lsa_handler_vector, i); if (handler == NULL) continue; - if (strncmp (argv[0], ospf6_lsa_handler_name(handler), strlen(argv[0])) == 0) + if (strncmp (argv[idx_lsa]->arg, ospf6_lsa_handler_name(handler), strlen(argv[idx_lsa]->arg)) == 0) break; - if (! strcasecmp (argv[0], handler->name)) + if (! strcasecmp (argv[idx_lsa]->arg, handler->name)) break; handler = NULL; } @@ -845,13 +844,13 @@ DEFUN (debug_ospf6_lsa_type, if (handler == NULL) handler = &unknown_handler; - if (argc >= 2) + if (argc == 5) { - if (! strcmp (argv[1], "originate")) + if (! strcmp (argv[idx_type]->text, "originate")) SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE); - if (! strcmp (argv[1], "examine")) + else if (! strcmp (argv[idx_type]->text, "examine")) SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN); - if (! strcmp (argv[1], "flooding")) + else if (! strcmp (argv[idx_type]->text, "flooding")) SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD); } else @@ -860,51 +859,49 @@ DEFUN (debug_ospf6_lsa_type, return CMD_SUCCESS; } -ALIAS (debug_ospf6_lsa_type, - debug_ospf6_lsa_hex_detail_cmd, - "debug ospf6 lsa (router|network|inter-prefix|inter-router|as-external|link|intra-prefix|unknown) (originate|examine|flooding)", - DEBUG_STR - OSPF6_STR - "Debug Link State Advertisements (LSAs)\n" - "Specify LS type as Hexadecimal\n" - ) - DEFUN (no_debug_ospf6_lsa_type, no_debug_ospf6_lsa_hex_cmd, - "no debug ospf6 lsa (router|network|inter-prefix|inter-router|as-external|link|intra-prefix|unknown)", + "no debug ospf6 lsa <router|network|inter-prefix|inter-router|as-external|link|intra-prefix|unknown> [<originate|examine|flooding>]", NO_STR DEBUG_STR OSPF6_STR "Debug Link State Advertisements (LSAs)\n" - "Specify LS type as Hexadecimal\n" - ) -{ + "Display Router LSAs\n" + "Display Network LSAs\n" + "Display Inter-Area-Prefix LSAs\n" + "Display As-External LSAs\n" + "Display Link LSAs\n" + "Display Intra-Area-Prefix LSAs\n" + "Display details of LSAs\n" + "Dump LSAs\n" + "Display LSA's internal information\n") +{ + int idx_lsa = 4; + int idx_type = 5; u_int i; struct ospf6_lsa_handler *handler = NULL; - assert (argc); - for (i = 0; i < vector_active (ospf6_lsa_handler_vector); i++) { handler = vector_slot (ospf6_lsa_handler_vector, i); if (handler == NULL) continue; - if (strncmp (argv[0], ospf6_lsa_handler_name(handler), strlen(argv[0])) == 0) + if (strncmp (argv[idx_lsa]->arg, ospf6_lsa_handler_name(handler), strlen(argv[idx_lsa]->arg)) == 0) break; - if (! strcasecmp (argv[0], handler->name)) + if (! strcasecmp (argv[idx_lsa]->arg, handler->name)) break; } if (handler == NULL) return CMD_SUCCESS; - if (argc >= 2) + if (argc == 6) { - if (! strcmp (argv[1], "originate")) + if (! strcmp (argv[idx_type]->text, "originate")) UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE); - if (! strcmp (argv[1], "examine")) + if (! strcmp (argv[idx_type]->text, "examine")) UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN); - if (! strcmp (argv[1], "flooding")) + if (! strcmp (argv[idx_type]->text, "flooding")) UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD); } else @@ -913,27 +910,14 @@ DEFUN (no_debug_ospf6_lsa_type, return CMD_SUCCESS; } -ALIAS (no_debug_ospf6_lsa_type, - no_debug_ospf6_lsa_hex_detail_cmd, - "no debug ospf6 lsa (router|network|inter-prefix|inter-router|as-external|link|intra-prefix) (originate|examine|flooding)", - NO_STR - DEBUG_STR - OSPF6_STR - "Debug Link State Advertisements (LSAs)\n" - "Specify LS type as Hexadecimal\n" - ) void install_element_ospf6_debug_lsa (void) { install_element (ENABLE_NODE, &debug_ospf6_lsa_hex_cmd); - install_element (ENABLE_NODE, &debug_ospf6_lsa_hex_detail_cmd); install_element (ENABLE_NODE, &no_debug_ospf6_lsa_hex_cmd); - install_element (ENABLE_NODE, &no_debug_ospf6_lsa_hex_detail_cmd); install_element (CONFIG_NODE, &debug_ospf6_lsa_hex_cmd); - install_element (CONFIG_NODE, &debug_ospf6_lsa_hex_detail_cmd); install_element (CONFIG_NODE, &no_debug_ospf6_lsa_hex_cmd); - install_element (CONFIG_NODE, &no_debug_ospf6_lsa_hex_detail_cmd); } int diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c index b0e94288b4..e9a25d37e5 100644 --- a/ospf6d/ospf6_message.c +++ b/ospf6d/ospf6_message.c @@ -2340,7 +2340,7 @@ ospf6_lsack_send_interface (struct thread *thread) /* Commands */ DEFUN (debug_ospf6_message, debug_ospf6_message_cmd, - "debug ospf6 message (unknown|hello|dbdesc|lsreq|lsupdate|lsack|all)", + "debug ospf6 message <unknown|hello|dbdesc|lsreq|lsupdate|lsack|all> [<send|recv>]", DEBUG_STR OSPF6_STR "Debug OSPFv3 message\n" @@ -2351,35 +2351,36 @@ DEFUN (debug_ospf6_message, "Debug Link State Update message\n" "Debug Link State Acknowledgement message\n" "Debug All message\n" - ) + "Debug only sending message\n" + "Debug only receiving message\n") { + int idx_packet = 3; + int idx_send_recv = 4; unsigned char level = 0; int type = 0; int i; - assert (argc > 0); - /* check type */ - if (! strncmp (argv[0], "u", 1)) + if (! strncmp (argv[idx_packet]->arg, "u", 1)) type = OSPF6_MESSAGE_TYPE_UNKNOWN; - else if (! strncmp (argv[0], "h", 1)) + else if (! strncmp (argv[idx_packet]->arg, "h", 1)) type = OSPF6_MESSAGE_TYPE_HELLO; - else if (! strncmp (argv[0], "d", 1)) + else if (! strncmp (argv[idx_packet]->arg, "d", 1)) type = OSPF6_MESSAGE_TYPE_DBDESC; - else if (! strncmp (argv[0], "lsr", 3)) + else if (! strncmp (argv[idx_packet]->arg, "lsr", 3)) type = OSPF6_MESSAGE_TYPE_LSREQ; - else if (! strncmp (argv[0], "lsu", 3)) + else if (! strncmp (argv[idx_packet]->arg, "lsu", 3)) type = OSPF6_MESSAGE_TYPE_LSUPDATE; - else if (! strncmp (argv[0], "lsa", 3)) + else if (! strncmp (argv[idx_packet]->arg, "lsa", 3)) type = OSPF6_MESSAGE_TYPE_LSACK; - else if (! strncmp (argv[0], "a", 1)) + else if (! strncmp (argv[idx_packet]->arg, "a", 1)) type = OSPF6_MESSAGE_TYPE_ALL; - if (argc == 1) + if (argc == 4) level = OSPF6_DEBUG_MESSAGE_SEND | OSPF6_DEBUG_MESSAGE_RECV; - else if (! strncmp (argv[1], "s", 1)) + else if (! strncmp (argv[idx_send_recv]->arg, "s", 1)) level = OSPF6_DEBUG_MESSAGE_SEND; - else if (! strncmp (argv[1], "r", 1)) + else if (! strncmp (argv[idx_send_recv]->arg, "r", 1)) level = OSPF6_DEBUG_MESSAGE_RECV; if (type == OSPF6_MESSAGE_TYPE_ALL) @@ -2393,27 +2394,9 @@ DEFUN (debug_ospf6_message, return CMD_SUCCESS; } -ALIAS (debug_ospf6_message, - debug_ospf6_message_sendrecv_cmd, - "debug ospf6 message (unknown|hello|dbdesc|lsreq|lsupdate|lsack|all) (send|recv)", - DEBUG_STR - OSPF6_STR - "Debug OSPFv3 message\n" - "Debug Unknown message\n" - "Debug Hello message\n" - "Debug Database Description message\n" - "Debug Link State Request message\n" - "Debug Link State Update message\n" - "Debug Link State Acknowledgement message\n" - "Debug All message\n" - "Debug only sending message\n" - "Debug only receiving message\n" - ) - - DEFUN (no_debug_ospf6_message, no_debug_ospf6_message_cmd, - "no debug ospf6 message (unknown|hello|dbdesc|lsreq|lsupdate|lsack|all)", + "no debug ospf6 message <unknown|hello|dbdesc|lsreq|lsupdate|lsack|all> [<send|recv>]", NO_STR DEBUG_STR OSPF6_STR @@ -2425,35 +2408,36 @@ DEFUN (no_debug_ospf6_message, "Debug Link State Update message\n" "Debug Link State Acknowledgement message\n" "Debug All message\n" - ) + "Debug only sending message\n" + "Debug only receiving message\n") { + int idx_packet = 4; + int idx_send_recv = 5; unsigned char level = 0; int type = 0; int i; - assert (argc > 0); - /* check type */ - if (! strncmp (argv[0], "u", 1)) + if (! strncmp (argv[idx_packet]->arg, "u", 1)) type = OSPF6_MESSAGE_TYPE_UNKNOWN; - else if (! strncmp (argv[0], "h", 1)) + else if (! strncmp (argv[idx_packet]->arg, "h", 1)) type = OSPF6_MESSAGE_TYPE_HELLO; - else if (! strncmp (argv[0], "d", 1)) + else if (! strncmp (argv[idx_packet]->arg, "d", 1)) type = OSPF6_MESSAGE_TYPE_DBDESC; - else if (! strncmp (argv[0], "lsr", 3)) + else if (! strncmp (argv[idx_packet]->arg, "lsr", 3)) type = OSPF6_MESSAGE_TYPE_LSREQ; - else if (! strncmp (argv[0], "lsu", 3)) + else if (! strncmp (argv[idx_packet]->arg, "lsu", 3)) type = OSPF6_MESSAGE_TYPE_LSUPDATE; - else if (! strncmp (argv[0], "lsa", 3)) + else if (! strncmp (argv[idx_packet]->arg, "lsa", 3)) type = OSPF6_MESSAGE_TYPE_LSACK; - else if (! strncmp (argv[0], "a", 1)) + else if (! strncmp (argv[idx_packet]->arg, "a", 1)) type = OSPF6_MESSAGE_TYPE_ALL; - if (argc == 1) + if (argc == 5) level = OSPF6_DEBUG_MESSAGE_SEND | OSPF6_DEBUG_MESSAGE_RECV; - else if (! strncmp (argv[1], "s", 1)) + else if (! strncmp (argv[idx_send_recv]->arg, "s", 1)) level = OSPF6_DEBUG_MESSAGE_SEND; - else if (! strncmp (argv[1], "r", 1)) + else if (! strncmp (argv[idx_send_recv]->arg, "r", 1)) level = OSPF6_DEBUG_MESSAGE_RECV; if (type == OSPF6_MESSAGE_TYPE_ALL) @@ -2467,24 +2451,6 @@ DEFUN (no_debug_ospf6_message, return CMD_SUCCESS; } -ALIAS (no_debug_ospf6_message, - no_debug_ospf6_message_sendrecv_cmd, - "no debug ospf6 message " - "(unknown|hello|dbdesc|lsreq|lsupdate|lsack|all) (send|recv)", - NO_STR - DEBUG_STR - OSPF6_STR - "Debug OSPFv3 message\n" - "Debug Unknown message\n" - "Debug Hello message\n" - "Debug Database Description message\n" - "Debug Link State Request message\n" - "Debug Link State Update message\n" - "Debug Link State Acknowledgement message\n" - "Debug All message\n" - "Debug only sending message\n" - "Debug only receiving message\n" - ) int config_write_ospf6_debug_message (struct vty *vty) @@ -2549,12 +2515,8 @@ install_element_ospf6_debug_message (void) { install_element (ENABLE_NODE, &debug_ospf6_message_cmd); install_element (ENABLE_NODE, &no_debug_ospf6_message_cmd); - install_element (ENABLE_NODE, &debug_ospf6_message_sendrecv_cmd); - install_element (ENABLE_NODE, &no_debug_ospf6_message_sendrecv_cmd); install_element (CONFIG_NODE, &debug_ospf6_message_cmd); install_element (CONFIG_NODE, &no_debug_ospf6_message_cmd); - install_element (CONFIG_NODE, &debug_ospf6_message_sendrecv_cmd); - install_element (CONFIG_NODE, &no_debug_ospf6_message_sendrecv_cmd); } diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c index bb265274f5..385232f7f8 100644 --- a/ospf6d/ospf6_neighbor.c +++ b/ospf6d/ospf6_neighbor.c @@ -829,13 +829,15 @@ ospf6_neighbor_show_detail (struct vty *vty, struct ospf6_neighbor *on) DEFUN (show_ipv6_ospf6_neighbor, show_ipv6_ospf6_neighbor_cmd, - "show ipv6 ospf6 neighbor", + "show ipv6 ospf6 neighbor [<detail|drchoice>]", SHOW_STR IP6_STR OSPF6_STR "Neighbor list\n" - ) + "Display details\n" + "Display DR choices\n") { + int idx_type = 4; struct ospf6_neighbor *on; struct ospf6_interface *oi; struct ospf6_area *oa; @@ -845,11 +847,11 @@ DEFUN (show_ipv6_ospf6_neighbor, OSPF6_CMD_CHECK_RUNNING (); showfunc = ospf6_neighbor_show; - if (argc) + if (argc == 5) { - if (! strncmp (argv[0], "de", 2)) + if (! strncmp (argv[idx_type]->arg, "de", 2)) showfunc = ospf6_neighbor_show_detail; - else if (! strncmp (argv[0], "dr", 2)) + else if (! strncmp (argv[idx_type]->arg, "dr", 2)) showfunc = ospf6_neighbor_show_drchoice; } @@ -870,16 +872,6 @@ DEFUN (show_ipv6_ospf6_neighbor, return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_neighbor, - show_ipv6_ospf6_neighbor_detail_cmd, - "show ipv6 ospf6 neighbor (detail|drchoice)", - SHOW_STR - IP6_STR - OSPF6_STR - "Neighbor list\n" - "Display details\n" - "Display DR choices\n" - ) DEFUN (show_ipv6_ospf6_neighbor_one, show_ipv6_ospf6_neighbor_one_cmd, @@ -891,6 +883,7 @@ DEFUN (show_ipv6_ospf6_neighbor_one, "Specify Router-ID as IPv4 address notation\n" ) { + int idx_ipv4 = 4; struct ospf6_neighbor *on; struct ospf6_interface *oi; struct ospf6_area *oa; @@ -901,9 +894,9 @@ DEFUN (show_ipv6_ospf6_neighbor_one, OSPF6_CMD_CHECK_RUNNING (); showfunc = ospf6_neighbor_show_detail; - if ((inet_pton (AF_INET, argv[0], &router_id)) != 1) + if ((inet_pton (AF_INET, argv[idx_ipv4]->arg, &router_id)) != 1) { - vty_out (vty, "Router-ID is not parsable: %s%s", argv[0], + vty_out (vty, "Router-ID is not parsable: %s%s", argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } @@ -920,23 +913,25 @@ void ospf6_neighbor_init (void) { install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_detail_cmd); } DEFUN (debug_ospf6_neighbor, debug_ospf6_neighbor_cmd, - "debug ospf6 neighbor", + "debug ospf6 neighbor [<state|event>]", DEBUG_STR OSPF6_STR "Debug OSPFv3 Neighbor\n" - ) + "Debug OSPFv3 Neighbor State Change\n" + "Debug OSPFv3 Neighbor Event\n") { + int idx_type = 3; unsigned char level = 0; - if (argc) + + if (argc == 4) { - if (! strncmp (argv[0], "s", 1)) + if (! strncmp (argv[idx_type]->arg, "s", 1)) level = OSPF6_DEBUG_NEIGHBOR_STATE; - if (! strncmp (argv[0], "e", 1)) + else if (! strncmp (argv[idx_type]->arg, "e", 1)) level = OSPF6_DEBUG_NEIGHBOR_EVENT; } else @@ -946,31 +941,25 @@ DEFUN (debug_ospf6_neighbor, return CMD_SUCCESS; } -ALIAS (debug_ospf6_neighbor, - debug_ospf6_neighbor_detail_cmd, - "debug ospf6 neighbor (state|event)", - DEBUG_STR - OSPF6_STR - "Debug OSPFv3 Neighbor\n" - "Debug OSPFv3 Neighbor State Change\n" - "Debug OSPFv3 Neighbor Event\n" - ) DEFUN (no_debug_ospf6_neighbor, no_debug_ospf6_neighbor_cmd, - "no debug ospf6 neighbor", + "no debug ospf6 neighbor [<state|event>]", NO_STR DEBUG_STR OSPF6_STR "Debug OSPFv3 Neighbor\n" - ) + "Debug OSPFv3 Neighbor State Change\n" + "Debug OSPFv3 Neighbor Event\n") { + int idx_type = 4; unsigned char level = 0; - if (argc) + + if (argc == 5) { - if (! strncmp (argv[0], "s", 1)) + if (! strncmp (argv[idx_type]->arg, "s", 1)) level = OSPF6_DEBUG_NEIGHBOR_STATE; - if (! strncmp (argv[0], "e", 1)) + if (! strncmp (argv[idx_type]->arg, "e", 1)) level = OSPF6_DEBUG_NEIGHBOR_EVENT; } else @@ -980,16 +969,6 @@ DEFUN (no_debug_ospf6_neighbor, return CMD_SUCCESS; } -ALIAS (no_debug_ospf6_neighbor, - no_debug_ospf6_neighbor_detail_cmd, - "no debug ospf6 neighbor (state|event)", - NO_STR - DEBUG_STR - OSPF6_STR - "Debug OSPFv3 Neighbor\n" - "Debug OSPFv3 Neighbor State Change\n" - "Debug OSPFv3 Neighbor Event\n" - ) DEFUN (no_debug_ospf6, no_debug_ospf6_cmd, @@ -1052,14 +1031,10 @@ void install_element_ospf6_debug_neighbor (void) { install_element (ENABLE_NODE, &debug_ospf6_neighbor_cmd); - install_element (ENABLE_NODE, &debug_ospf6_neighbor_detail_cmd); install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_cmd); - install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_detail_cmd); install_element (ENABLE_NODE, &no_debug_ospf6_cmd); install_element (CONFIG_NODE, &debug_ospf6_neighbor_cmd); - install_element (CONFIG_NODE, &debug_ospf6_neighbor_detail_cmd); install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_cmd); - install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_detail_cmd); install_element (CONFIG_NODE, &no_debug_ospf6_cmd); } diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c index 5172eee48d..2f416e2689 100644 --- a/ospf6d/ospf6_route.c +++ b/ospf6d/ospf6_route.c @@ -1298,7 +1298,7 @@ ospf6_route_show_table (struct vty *vty, int detail, } int -ospf6_route_table_show (struct vty *vty, int argc, const char *argv[], +ospf6_route_table_show (struct vty *vty, int argc_start, int argc, struct cmd_token **argv, struct ospf6_route_table *table) { int summary = 0; @@ -1312,60 +1312,60 @@ ospf6_route_table_show (struct vty *vty, int argc, const char *argv[], memset (&prefix, 0, sizeof (struct prefix)); - for (i = 0; i < argc; i++) + for (i = argc_start; i < argc; i++) { - if (! strcmp (argv[i], "summary")) + if (! strcmp (argv[i]->arg, "summary")) { summary++; continue; } - if (! strcmp (argv[i], "intra-area")) + if (! strcmp (argv[i]->arg, "intra-area")) { type = OSPF6_PATH_TYPE_INTRA; continue; } - if (! strcmp (argv[i], "inter-area")) + if (! strcmp (argv[i]->arg, "inter-area")) { type = OSPF6_PATH_TYPE_INTER; continue; } - if (! strcmp (argv[i], "external-1")) + if (! strcmp (argv[i]->arg, "external-1")) { type = OSPF6_PATH_TYPE_EXTERNAL1; continue; } - if (! strcmp (argv[i], "external-2")) + if (! strcmp (argv[i]->arg, "external-2")) { type = OSPF6_PATH_TYPE_EXTERNAL2; continue; } - if (! strcmp (argv[i], "detail")) + if (! strcmp (argv[i]->arg, "detail")) { detail++; continue; } - if (! strcmp (argv[i], "match")) + if (! strcmp (argv[i]->arg, "match")) { match++; continue; } - ret = str2prefix (argv[i], &prefix); + ret = str2prefix (argv[i]->arg, &prefix); if (ret == 1 && prefix.family == AF_INET6) { isprefix++; - if (strchr (argv[i], '/')) + if (strchr (argv[i]->arg, '/')) slash++; continue; } - vty_out (vty, "Malformed argument: %s%s", argv[i], VNL); + vty_out (vty, "Malformed argument: %s%s", argv[i]->arg, VNL); return CMD_SUCCESS; } @@ -1473,7 +1473,8 @@ ospf6_linkstate_show_table (struct vty *vty, int detail, } int -ospf6_linkstate_table_show (struct vty *vty, int argc, const char *argv[], +ospf6_linkstate_table_show (struct vty *vty, int idx_ipv4, int argc, + struct cmd_token **argv, struct ospf6_route_table *table) { int detail = 0; @@ -1486,9 +1487,9 @@ ospf6_linkstate_table_show (struct vty *vty, int argc, const char *argv[], memset (&id, 0, sizeof (struct prefix)); memset (&prefix, 0, sizeof (struct prefix)); - for (i = 0; i < argc; i++) + for (i = idx_ipv4; i < argc; i++) { - if (! strcmp (argv[i], "detail")) + if (! strcmp (argv[i]->arg, "detail")) { detail++; continue; @@ -1496,29 +1497,29 @@ ospf6_linkstate_table_show (struct vty *vty, int argc, const char *argv[], if (! is_router) { - ret = str2prefix (argv[i], &router); + ret = str2prefix (argv[i]->arg, &router); if (ret == 1 && router.family == AF_INET) { is_router++; continue; } - vty_out (vty, "Malformed argument: %s%s", argv[i], VNL); + vty_out (vty, "Malformed argument: %s%s", argv[i]->arg, VNL); return CMD_SUCCESS; } if (! is_id) { - ret = str2prefix (argv[i], &id); + ret = str2prefix (argv[i]->arg, &id); if (ret == 1 && id.family == AF_INET) { is_id++; continue; } - vty_out (vty, "Malformed argument: %s%s", argv[i], VNL); + vty_out (vty, "Malformed argument: %s%s", argv[i]->arg, VNL); return CMD_SUCCESS; } - vty_out (vty, "Malformed argument: %s%s", argv[i], VNL); + vty_out (vty, "Malformed argument: %s%s", argv[i]->arg, VNL); return CMD_SUCCESS; } @@ -1563,25 +1564,26 @@ ospf6_brouter_show (struct vty *vty, struct ospf6_route *route) DEFUN (debug_ospf6_route, debug_ospf6_route_cmd, - "debug ospf6 route (table|intra-area|inter-area|memory)", + "debug ospf6 route <table|intra-area|inter-area|memory>", DEBUG_STR OSPF6_STR + "Debug routes\n" "Debug route table calculation\n" - "Debug detail\n" "Debug intra-area route calculation\n" "Debug inter-area route calculation\n" "Debug route memory use\n" ) { + int idx_type = 3; unsigned char level = 0; - if (! strncmp (argv[0], "table", 5)) + if (! strncmp (argv[idx_type]->arg, "table", 5)) level = OSPF6_DEBUG_ROUTE_TABLE; - else if (! strncmp (argv[0], "intra", 5)) + else if (! strncmp (argv[idx_type]->arg, "intra", 5)) level = OSPF6_DEBUG_ROUTE_INTRA; - else if (! strncmp (argv[0], "inter", 5)) + else if (! strncmp (argv[idx_type]->arg, "inter", 5)) level = OSPF6_DEBUG_ROUTE_INTER; - else if (! strncmp (argv[0], "memor", 5)) + else if (! strncmp (argv[idx_type]->arg, "memor", 5)) level = OSPF6_DEBUG_ROUTE_MEMORY; OSPF6_DEBUG_ROUTE_ON (level); return CMD_SUCCESS; @@ -1589,23 +1591,26 @@ DEFUN (debug_ospf6_route, DEFUN (no_debug_ospf6_route, no_debug_ospf6_route_cmd, - "no debug ospf6 route (table|intra-area|inter-area|memory)", + "no debug ospf6 route <table|intra-area|inter-area|memory>", NO_STR DEBUG_STR OSPF6_STR + "Debug routes\n" "Debug route table calculation\n" "Debug intra-area route calculation\n" + "Debug inter-area route calculation\n" "Debug route memory use\n") { + int idx_type = 4; unsigned char level = 0; - if (! strncmp (argv[0], "table", 5)) + if (! strncmp (argv[idx_type]->arg, "table", 5)) level = OSPF6_DEBUG_ROUTE_TABLE; - else if (! strncmp (argv[0], "intra", 5)) + else if (! strncmp (argv[idx_type]->arg, "intra", 5)) level = OSPF6_DEBUG_ROUTE_INTRA; - else if (! strncmp (argv[0], "inter", 5)) + else if (! strncmp (argv[idx_type]->arg, "inter", 5)) level = OSPF6_DEBUG_ROUTE_INTER; - else if (! strncmp (argv[0], "memor", 5)) + else if (! strncmp (argv[idx_type]->arg, "memor", 5)) level = OSPF6_DEBUG_ROUTE_MEMORY; OSPF6_DEBUG_ROUTE_OFF (level); return CMD_SUCCESS; diff --git a/ospf6d/ospf6_route.h b/ospf6d/ospf6_route.h index 7ecc066602..c7c21a6579 100644 --- a/ospf6d/ospf6_route.h +++ b/ospf6d/ospf6_route.h @@ -329,10 +329,10 @@ extern void ospf6_route_dump (struct ospf6_route_table *table); extern void ospf6_route_show (struct vty *vty, struct ospf6_route *route); extern void ospf6_route_show_detail (struct vty *vty, struct ospf6_route *route); -extern int ospf6_route_table_show (struct vty *, int, const char *[], +extern int ospf6_route_table_show (struct vty *, int, int, struct cmd_token **, struct ospf6_route_table *); -extern int ospf6_linkstate_table_show (struct vty *vty, int argc, - const char *argv[], +extern int ospf6_linkstate_table_show (struct vty *vty, int idx_ipv4, int argc, + struct cmd_token **argv, struct ospf6_route_table *table); extern void ospf6_brouter_show_header (struct vty *vty); diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c index 7e977499cf..df8925c453 100644 --- a/ospf6d/ospf6_spf.c +++ b/ospf6d/ospf6_spf.c @@ -877,7 +877,7 @@ ospf6_timers_spf_set (struct vty *vty, unsigned int delay, DEFUN (ospf6_timers_throttle_spf, ospf6_timers_throttle_spf_cmd, - "timers throttle spf <0-600000> <0-600000> <0-600000>", + "timers throttle spf (0-600000) (0-600000) (0-600000)", "Adjust routing timers\n" "Throttling adaptive timer\n" "OSPF6 SPF timers\n" @@ -885,28 +885,28 @@ DEFUN (ospf6_timers_throttle_spf, "Initial hold time (msec) between consecutive SPF calculations\n" "Maximum hold time (msec)\n") { + int idx_number = 3; + int idx_number_2 = 4; + int idx_number_3 = 5; unsigned int delay, hold, max; - if (argc != 3) - { - vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); - return CMD_WARNING; - } - - VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000); - VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000); - VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000); + VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[idx_number]->arg, 0, 600000); + VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[idx_number_2]->arg, 0, 600000); + VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[idx_number_3]->arg, 0, 600000); return ospf6_timers_spf_set (vty, delay, hold, max); } DEFUN (no_ospf6_timers_throttle_spf, no_ospf6_timers_throttle_spf_cmd, - "no timers throttle spf", + "no timers throttle spf [(0-600000) (0-600000) (0-600000)]", NO_STR "Adjust routing timers\n" "Throttling adaptive timer\n" - "OSPF6 SPF timers\n") + "OSPF6 SPF timers\n" + "Delay (msec) from first change received till SPF calculation\n" + "Initial hold time (msec) between consecutive SPF calculations\n" + "Maximum hold time (msec)\n") { return ospf6_timers_spf_set (vty, OSPF_SPF_DELAY_DEFAULT, @@ -914,16 +914,6 @@ DEFUN (no_ospf6_timers_throttle_spf, OSPF_SPF_MAX_HOLDTIME_DEFAULT); } -ALIAS (no_ospf6_timers_throttle_spf, - no_ospf6_timers_throttle_spf_val_cmd, - "no timers throttle spf <0-600000> <0-600000> <0-600000>", - NO_STR - "Adjust routing timers\n" - "Throttling adaptive timer\n" - "OSPF6 SPF timers\n" - "Delay (msec) from first change received till SPF calculation\n" - "Initial hold time (msec) between consecutive SPF calculations\n" - "Maximum hold time (msec)\n") int config_write_ospf6_debug_spf (struct vty *vty) @@ -972,5 +962,4 @@ ospf6_spf_init (void) { install_element (OSPF6_NODE, &ospf6_timers_throttle_spf_cmd); install_element (OSPF6_NODE, &no_ospf6_timers_throttle_spf_cmd); - install_element (OSPF6_NODE, &no_ospf6_timers_throttle_spf_val_cmd); } diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index 3d632b644e..32ec2731d6 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -305,16 +305,9 @@ DEFUN (no_router_ospf6, no_router_ospf6_cmd, "no router ospf6", NO_STR - OSPF6_ROUTER_STR) + ROUTER_STR + OSPF6_STR) { - if (ospf6 == NULL) - vty_out (vty, "OSPFv3 is not configured%s", VNL); - else - { - ospf6_delete (ospf6); - ospf6 = NULL; - } - /* return to config node . */ vty->node = CONFIG_NODE; vty->index = NULL; @@ -329,16 +322,17 @@ DEFUN (ospf6_router_id, "Configure OSPF Router-ID\n" V4NOTATION_STR) { + int idx_ipv4 = 1; int ret; u_int32_t router_id; struct ospf6 *o; o = (struct ospf6 *) vty->index; - ret = inet_pton (AF_INET, argv[0], &router_id); + ret = inet_pton (AF_INET, argv[idx_ipv4]->arg, &router_id); if (ret == 0) { - vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[0], VNL); + vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } @@ -403,26 +397,20 @@ DEFUN (no_ospf6_log_adjacency_changes_detail, DEFUN (ospf6_timers_lsa, ospf6_timers_lsa_cmd, - "timers lsa min-arrival <0-600000>", + "timers lsa min-arrival (0-600000)", "Adjust routing timers\n" "OSPF6 LSA timers\n" "Minimum delay in receiving new version of a LSA\n" "Delay in milliseconds\n") { + int idx_number = 3; unsigned int minarrival; struct ospf6 *ospf = vty->index; if (!ospf) return CMD_SUCCESS; - if (argc != 1) - { - vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE); - return CMD_WARNING; - } - - VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[0]); - + VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[idx_number]->arg); ospf->lsa_minarrival = minarrival; return CMD_SUCCESS; @@ -430,21 +418,22 @@ DEFUN (ospf6_timers_lsa, DEFUN (no_ospf6_timers_lsa, no_ospf6_timers_lsa_cmd, - "no timers lsa min-arrival", + "no timers lsa min-arrival [(0-600000)]", NO_STR "Adjust routing timers\n" "OSPF6 LSA timers\n" "Minimum delay in receiving new version of a LSA\n") { + int idx_number = 4; unsigned int minarrival; struct ospf6 *ospf = vty->index; if (!ospf) return CMD_SUCCESS; - if (argc) + if (argc == 5) { - VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[0]); + VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[idx_number]->arg); if (ospf->lsa_minarrival != minarrival || minarrival == OSPF_MIN_LS_ARRIVAL) @@ -456,31 +445,23 @@ DEFUN (no_ospf6_timers_lsa, return CMD_SUCCESS; } -ALIAS (no_ospf6_timers_lsa, - no_ospf6_timers_lsa_val_cmd, - "no timers lsa min-arrival <0-600000>", - NO_STR - "Adjust routing timers\n" - "OSPF6 LSA timers\n" - "Minimum delay in receiving new version of a LSA\n" - "Delay in milliseconds\n") DEFUN (ospf6_distance, ospf6_distance_cmd, - "distance <1-255>", + "distance (1-255)", "Administrative distance\n" "OSPF6 Administrative distance\n") { struct ospf6 *o = vty->index; - o->distance_all = atoi (argv[0]); + o->distance_all = atoi (argv[1]->arg); return CMD_SUCCESS; } DEFUN (no_ospf6_distance, no_ospf6_distance_cmd, - "no distance <1-255>", + "no distance (1-255)", NO_STR "Administrative distance\n" "OSPF6 Administrative distance\n") @@ -494,7 +475,7 @@ DEFUN (no_ospf6_distance, DEFUN (ospf6_distance_ospf6, ospf6_distance_ospf6_cmd, - "distance ospf6 {intra-area <1-255>|inter-area <1-255>|external <1-255>}", + "distance ospf6 <intra-area (1-255)|inter-area (1-255)|external (1-255)> <intra-area (1-255)|inter-area (1-255)|external (1-255)> <intra-area (1-255)|inter-area (1-255)|external (1-255)>", "Administrative distance\n" "OSPF6 distance\n" "Intra-area routes\n" @@ -502,35 +483,68 @@ DEFUN (ospf6_distance_ospf6, "Inter-area routes\n" "Distance for inter-area routes\n" "External routes\n" + "Distance for external routes\n" + "Intra-area routes\n" + "Distance for intra-area routes\n" + "Inter-area routes\n" + "Distance for inter-area routes\n" + "External routes\n" + "Distance for external routes\n" + "Intra-area routes\n" + "Distance for intra-area routes\n" + "Inter-area routes\n" + "Distance for inter-area routes\n" + "External routes\n" "Distance for external routes\n") { struct ospf6 *o = vty->index; - if (argc < 3) /* should not happen */ + char *intra, *inter, *external; + intra = inter = external = NULL; + + int idx = 0; + if (argv_find (argv, argc, "intra-area", &idx)) + intra = argv[++idx]->arg; + if (argv_find (argv, argc, "intra-area", &idx)) + { + vty_out (vty, "%% Cannot specify intra-area distance twice%s", VTY_NEWLINE); + return CMD_WARNING; + } + + idx = 0; + if (argv_find (argv, argc, "inter-area", &idx)) + inter = argv[++idx]->arg; + if (argv_find (argv, argc, "inter-area", &idx)) + { + vty_out (vty, "%% Cannot specify inter-area distance twice%s", VTY_NEWLINE); + return CMD_WARNING; + } + + idx = 0; + if (argv_find (argv, argc, "external", &idx)) + external = argv[++idx]->arg; + if (argv_find (argv, argc, "external", &idx)) + { + vty_out (vty, "%% Cannot specify external distance twice%s", VTY_NEWLINE); return CMD_WARNING; + } - if (!argv[0] && !argv[1] && !argv[2]) - { - vty_out(vty, "%% Command incomplete. (Arguments required)%s", - VTY_NEWLINE); - return CMD_WARNING; - } - if (argv[0] != NULL) - o->distance_intra = atoi (argv[0]); + if (intra) + o->distance_intra = atoi (intra); - if (argv[1] != NULL) - o->distance_inter = atoi (argv[1]); + if (inter) + o->distance_inter = atoi (inter); - if (argv[2] != NULL) - o->distance_external = atoi (argv[2]); + if (external) + o->distance_external = atoi (external); return CMD_SUCCESS; } DEFUN (no_ospf6_distance_ospf6, no_ospf6_distance_ospf6_cmd, - "no distance ospf6 {intra-area <1-255>|inter-area <1-255>|external <1-255>}", + "no distance ospf6 [<intra-area (1-255)|inter-area (1-255)|external (1-255)> <intra-area (1-255)|inter-area (1-255)|external (1-255)> <intra-area (1-255)|inter-area (1-255)|external (1-255)>]", NO_STR "Administrative distance\n" "OSPF6 distance\n" @@ -539,51 +553,93 @@ DEFUN (no_ospf6_distance_ospf6, "Inter-area routes\n" "Distance for inter-area routes\n" "External routes\n" + "Distance for external routes\n" + "Intra-area routes\n" + "Distance for intra-area routes\n" + "Inter-area routes\n" + "Distance for inter-area routes\n" + "External routes\n" + "Distance for external routes\n" + "Intra-area routes\n" + "Distance for intra-area routes\n" + "Inter-area routes\n" + "Distance for inter-area routes\n" + "External routes\n" "Distance for external routes\n") { struct ospf6 *o = vty->index; + char *intra, *inter, *external; + intra = inter = external = NULL; + + if (argc == 3) + { + /* If no arguments are given, clear all distance information */ + o->distance_intra = 0; + o->distance_inter = 0; + o->distance_external = 0; + return CMD_SUCCESS; + } + + int idx = 0; + if (argv_find (argv, argc, "intra-area", &idx)) + intra = argv[++idx]->arg; + if (argv_find (argv, argc, "intra-area", &idx)) + { + vty_out (vty, "%% Cannot specify intra-area distance twice%s", VTY_NEWLINE); + return CMD_WARNING; + } + + idx = 0; + if (argv_find (argv, argc, "inter-area", &idx)) + inter = argv[++idx]->arg; + if (argv_find (argv, argc, "inter-area", &idx)) + { + vty_out (vty, "%% Cannot specify inter-area distance twice%s", VTY_NEWLINE); + return CMD_WARNING; + } + + idx = 0; + if (argv_find (argv, argc, "external", &idx)) + external = argv[++idx]->arg; + if (argv_find (argv, argc, "external", &idx)) + { + vty_out (vty, "%% Cannot specify external distance twice%s", VTY_NEWLINE); + return CMD_WARNING; + } if (argc < 3) /* should not happen */ return CMD_WARNING; - if (argv[0] != NULL) + if (intra) o->distance_intra = 0; - if (argv[1] != NULL) + if (inter) o->distance_inter = 0; - if (argv[2] != NULL) + if (external) o->distance_external = 0; - if (argv[0] || argv[1] || argv[2]) - return CMD_SUCCESS; - - /* If no arguments are given, clear all distance information */ - o->distance_intra = 0; - o->distance_inter = 0; - o->distance_external = 0; - return CMD_SUCCESS; } DEFUN (ospf6_distance_source, ospf6_distance_source_cmd, - "distance <1-255> X:X::X:X/M [WORD]", + "distance (1-255) X:X::X:X/M [WORD]", "Administrative distance\n" "Distance value\n" "IP source prefix\n" "Access list name\n") { struct ospf6 *o = vty->index; - - ospf6_distance_set (vty, o, argv[0], argv[1], argc == 3 ? argv[2] : NULL); + char *alname = (argc == 4) ? argv[3]->arg : NULL; + ospf6_distance_set (vty, o, argv[1]->arg, argv[2]->arg, alname); return CMD_SUCCESS; } DEFUN (no_ospf6_distance_source, no_ospf6_distance_source_cmd, - "no distance <1-255> X:X::X:X/M [WORD]", + "no distance (1-255) X:X::X:X/M [WORD]", NO_STR "Administrative distance\n" "Distance value\n" @@ -591,8 +647,8 @@ DEFUN (no_ospf6_distance_source, "Access list name\n") { struct ospf6 *o = vty->index; - - ospf6_distance_unset (vty, o, argv[0], argv[1], argc == 3 ? argv[2] : NULL); + char *alname = (argc == 5) ? argv[4]->arg : NULL; + ospf6_distance_unset (vty, o, argv[2]->arg, argv[3]->arg, alname); return CMD_SUCCESS; } @@ -606,6 +662,8 @@ DEFUN (ospf6_interface_area, "OSPF6 area ID in IPv4 address notation\n" ) { + int idx_ifname = 1; + int idx_ipv4 = 3; struct ospf6 *o; struct ospf6_area *oa; struct ospf6_interface *oi; @@ -615,7 +673,7 @@ DEFUN (ospf6_interface_area, o = (struct ospf6 *) vty->index; /* find/create ospf6 interface */ - ifp = if_get_by_name (argv[0]); + ifp = if_get_by_name (argv[idx_ifname]->arg); oi = (struct ospf6_interface *) ifp->info; if (oi == NULL) oi = ospf6_interface_create (ifp); @@ -627,9 +685,9 @@ DEFUN (ospf6_interface_area, } /* parse Area-ID */ - if (inet_pton (AF_INET, argv[1], &area_id) != 1) + if (inet_pton (AF_INET, argv[idx_ipv4]->arg, &area_id) != 1) { - vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL); + vty_out (vty, "Invalid Area-ID: %s%s", argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } @@ -668,15 +726,17 @@ DEFUN (no_ospf6_interface_area, "OSPF6 area ID in IPv4 address notation\n" ) { + int idx_ifname = 2; + int idx_ipv4 = 4; struct ospf6_interface *oi; struct ospf6_area *oa; struct interface *ifp; u_int32_t area_id; - ifp = if_lookup_by_name (argv[0]); + ifp = if_lookup_by_name (argv[idx_ifname]->arg); if (ifp == NULL) { - vty_out (vty, "No such interface %s%s", argv[0], VNL); + vty_out (vty, "No such interface %s%s", argv[idx_ifname]->arg, VNL); return CMD_SUCCESS; } @@ -688,16 +748,16 @@ DEFUN (no_ospf6_interface_area, } /* parse Area-ID */ - if (inet_pton (AF_INET, argv[1], &area_id) != 1) + if (inet_pton (AF_INET, argv[idx_ipv4]->arg, &area_id) != 1) { - vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL); + vty_out (vty, "Invalid Area-ID: %s%s", argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } /* Verify Area */ if (oi->area == NULL) { - vty_out (vty, "No such Area-ID: %s%s", argv[1], VNL); + vty_out (vty, "No such Area-ID: %s%s", argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } @@ -775,7 +835,7 @@ DEFUN (no_ospf6_stub_router_admin, DEFUN (ospf6_stub_router_startup, ospf6_stub_router_startup_cmd, - "stub-router on-startup <5-86400>", + "stub-router on-startup (5-86400)", "Make router a stub router\n" "Advertise inability to be a transit router\n" "Automatically advertise as stub-router on startup of OSPF6\n" @@ -798,7 +858,7 @@ DEFUN (no_ospf6_stub_router_startup, DEFUN (ospf6_stub_router_shutdown, ospf6_stub_router_shutdown_cmd, - "stub-router on-shutdown <5-86400>", + "stub-router on-shutdown (5-86400)", "Make router a stub router\n" "Advertise inability to be a transit router\n" "Automatically advertise as stub-router before shutdown\n" @@ -913,56 +973,40 @@ DEFUN (show_ipv6_ospf6, DEFUN (show_ipv6_ospf6_route, show_ipv6_ospf6_route_cmd, - "show ipv6 ospf6 route", + "show ipv6 ospf6 route [<intra-area|inter-area|external-1|external-2|X:X::X:X|X:X::X:X/M|detail|summary>]", SHOW_STR IP6_STR OSPF6_STR ROUTE_STR - ) + "Display Intra-Area routes\n" + "Display Inter-Area routes\n" + "Display Type-1 External routes\n" + "Display Type-2 External routes\n" + "Specify IPv6 address\n" + "Specify IPv6 prefix\n" + "Detailed information\n" + "Summary of route table\n") { OSPF6_CMD_CHECK_RUNNING (); - ospf6_route_table_show (vty, argc, argv, ospf6->route_table); + ospf6_route_table_show (vty, 4, argc, argv, ospf6->route_table); return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_route, - show_ipv6_ospf6_route_detail_cmd, - "show ipv6 ospf6 route (X:X::X:X|X:X::X:X/M|detail|summary)", - SHOW_STR - IP6_STR - OSPF6_STR - ROUTE_STR - "Specify IPv6 address\n" - "Specify IPv6 prefix\n" - "Detailed information\n" - "Summary of route table\n" - ) - DEFUN (show_ipv6_ospf6_route_match, show_ipv6_ospf6_route_match_cmd, - "show ipv6 ospf6 route X:X::X:X/M match", + "show ipv6 ospf6 route X:X::X:X/M <match|longer>", SHOW_STR IP6_STR OSPF6_STR ROUTE_STR "Specify IPv6 prefix\n" "Display routes which match the specified route\n" - ) + "Display routes longer than the specified route\n") { - const char *sargv[CMD_ARGC_MAX]; - int i, sargc; - OSPF6_CMD_CHECK_RUNNING (); - /* copy argv to sargv and then append "match" */ - for (i = 0; i < argc; i++) - sargv[i] = argv[i]; - sargc = argc; - sargv[sargc++] = "match"; - sargv[sargc] = NULL; - - ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table); + ospf6_route_table_show (vty, 4, argc, argv, ospf6->route_table); return CMD_SUCCESS; } @@ -978,62 +1022,17 @@ DEFUN (show_ipv6_ospf6_route_match_detail, "Detailed information\n" ) { - const char *sargv[CMD_ARGC_MAX]; - int i, sargc; - - /* copy argv to sargv and then append "match" and "detail" */ - for (i = 0; i < argc; i++) - sargv[i] = argv[i]; - sargc = argc; - sargv[sargc++] = "match"; - sargv[sargc++] = "detail"; - sargv[sargc] = NULL; - OSPF6_CMD_CHECK_RUNNING (); - ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table); + ospf6_route_table_show (vty, 4, argc, argv, ospf6->route_table); return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_route_match, - show_ipv6_ospf6_route_longer_cmd, - "show ipv6 ospf6 route X:X::X:X/M longer", - SHOW_STR - IP6_STR - OSPF6_STR - ROUTE_STR - "Specify IPv6 prefix\n" - "Display routes longer than the specified route\n" - ) - -DEFUN (show_ipv6_ospf6_route_match_detail, - show_ipv6_ospf6_route_longer_detail_cmd, - "show ipv6 ospf6 route X:X::X:X/M longer detail", - SHOW_STR - IP6_STR - OSPF6_STR - ROUTE_STR - "Specify IPv6 prefix\n" - "Display routes longer than the specified route\n" - "Detailed information\n" - ); -ALIAS (show_ipv6_ospf6_route, - show_ipv6_ospf6_route_type_cmd, - "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2)", - SHOW_STR - IP6_STR - OSPF6_STR - ROUTE_STR - "Display Intra-Area routes\n" - "Display Inter-Area routes\n" - "Display Type-1 External routes\n" - "Display Type-2 External routes\n" - ) DEFUN (show_ipv6_ospf6_route_type_detail, show_ipv6_ospf6_route_type_detail_cmd, - "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2) detail", + "show ipv6 ospf6 route <intra-area|inter-area|external-1|external-2> detail", SHOW_STR IP6_STR OSPF6_STR @@ -1045,19 +1044,9 @@ DEFUN (show_ipv6_ospf6_route_type_detail, "Detailed information\n" ) { - const char *sargv[CMD_ARGC_MAX]; - int i, sargc; - - /* copy argv to sargv and then append "detail" */ - for (i = 0; i < argc; i++) - sargv[i] = argv[i]; - sargc = argc; - sargv[sargc++] = "detail"; - sargv[sargc] = NULL; - OSPF6_CMD_CHECK_RUNNING (); - ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table); + ospf6_route_table_show (vty, 4, argc, argv, ospf6->route_table); return CMD_SUCCESS; } @@ -1118,7 +1107,7 @@ config_write_ospf6 (struct vty *vty) struct ospf6_area *oa; struct ospf6_interface *oi; - /* OSPFv6 configuration. */ + /* OSPFv3 configuration. */ if (ospf6 == NULL) return CMD_SUCCESS; @@ -1183,12 +1172,8 @@ ospf6_top_init (void) install_element (CONFIG_NODE, &no_router_ospf6_cmd); install_element (VIEW_NODE, &show_ipv6_ospf6_route_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd); install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd); install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_detail_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_cmd); install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd); install_default (OSPF6_NODE); @@ -1201,7 +1186,6 @@ ospf6_top_init (void) /* LSA timers commands */ install_element (OSPF6_NODE, &ospf6_timers_lsa_cmd); install_element (OSPF6_NODE, &no_ospf6_timers_lsa_cmd); - install_element (OSPF6_NODE, &no_ospf6_timers_lsa_val_cmd); install_element (OSPF6_NODE, &ospf6_interface_area_cmd); install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd); @@ -1223,5 +1207,3 @@ ospf6_top_init (void) install_element (OSPF6_NODE, &no_ospf6_distance_source_cmd); #endif } - - diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index 3e4042d65d..a5303fb1b8 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -325,30 +325,6 @@ DEFUN (show_zebra, return CMD_SUCCESS; } -DEFUN (router_zebra, - router_zebra_cmd, - "router zebra", - "Enable a routing process\n" - "Make connection to zebra daemon\n") -{ - vty->node = ZEBRA_NODE; - zclient->enable = 1; - zclient_start (zclient); - return CMD_SUCCESS; -} - -DEFUN (no_router_zebra, - no_router_zebra_cmd, - "no router zebra", - NO_STR - "Configure routing process\n" - "Disable connection to zebra daemon\n") -{ - zclient->enable = 0; - zclient_stop (zclient); - return CMD_SUCCESS; -} - /* Zebra configuration write function. */ static int config_write_ospf6_zebra (struct vty *vty) @@ -850,9 +826,6 @@ ospf6_zebra_init (struct thread_master *master) /* Install command element for zebra node. */ install_element (VIEW_NODE, &show_zebra_cmd); - install_element (CONFIG_NODE, &router_zebra_cmd); - install_element (CONFIG_NODE, &no_router_zebra_cmd); - install_default (ZEBRA_NODE); install_element (ZEBRA_NODE, &redistribute_ospf6_cmd); install_element (ZEBRA_NODE, &no_redistribute_ospf6_cmd); @@ -864,7 +837,7 @@ ospf6_zebra_init (struct thread_master *master) DEFUN (debug_ospf6_zebra_sendrecv, debug_ospf6_zebra_sendrecv_cmd, - "debug ospf6 zebra (send|recv)", + "debug ospf6 zebra [<send|recv>]", DEBUG_STR OSPF6_STR "Debug connection between zebra\n" @@ -872,13 +845,14 @@ DEFUN (debug_ospf6_zebra_sendrecv, "Debug Receiving zebra\n" ) { + int idx_send_recv = 3; unsigned char level = 0; - if (argc) + if (argc == 4) { - if (! strncmp (argv[0], "s", 1)) + if (strmatch(argv[idx_send_recv]->text, "send")) level = OSPF6_DEBUG_ZEBRA_SEND; - else if (! strncmp (argv[0], "r", 1)) + else if (strmatch(argv[idx_send_recv]->text, "recv")) level = OSPF6_DEBUG_ZEBRA_RECV; } else @@ -888,18 +862,9 @@ DEFUN (debug_ospf6_zebra_sendrecv, return CMD_SUCCESS; } -ALIAS (debug_ospf6_zebra_sendrecv, - debug_ospf6_zebra_cmd, - "debug ospf6 zebra", - DEBUG_STR - OSPF6_STR - "Debug connection between zebra\n" - ) - - DEFUN (no_debug_ospf6_zebra_sendrecv, no_debug_ospf6_zebra_sendrecv_cmd, - "no debug ospf6 zebra (send|recv)", + "no debug ospf6 zebra [<send|recv>]", NO_STR DEBUG_STR OSPF6_STR @@ -908,13 +873,14 @@ DEFUN (no_debug_ospf6_zebra_sendrecv, "Debug Receiving zebra\n" ) { + int idx_send_recv = 4; unsigned char level = 0; - if (argc) + if (argc == 5) { - if (! strncmp (argv[0], "s", 1)) + if (strmatch(argv[idx_send_recv]->text, "send")) level = OSPF6_DEBUG_ZEBRA_SEND; - else if (! strncmp (argv[0], "r", 1)) + else if (strmatch(argv[idx_send_recv]->text, "recv")) level = OSPF6_DEBUG_ZEBRA_RECV; } else @@ -924,14 +890,6 @@ DEFUN (no_debug_ospf6_zebra_sendrecv, return CMD_SUCCESS; } -ALIAS (no_debug_ospf6_zebra_sendrecv, - no_debug_ospf6_zebra_cmd, - "no debug ospf6 zebra", - NO_STR - DEBUG_STR - OSPF6_STR - "Debug connection between zebra\n" - ) int config_write_ospf6_debug_zebra (struct vty *vty) @@ -951,12 +909,8 @@ config_write_ospf6_debug_zebra (struct vty *vty) void install_element_ospf6_debug_zebra (void) { - install_element (ENABLE_NODE, &debug_ospf6_zebra_cmd); - install_element (ENABLE_NODE, &no_debug_ospf6_zebra_cmd); install_element (ENABLE_NODE, &debug_ospf6_zebra_sendrecv_cmd); install_element (ENABLE_NODE, &no_debug_ospf6_zebra_sendrecv_cmd); - install_element (CONFIG_NODE, &debug_ospf6_zebra_cmd); - install_element (CONFIG_NODE, &no_debug_ospf6_zebra_cmd); install_element (CONFIG_NODE, &debug_ospf6_zebra_sendrecv_cmd); install_element (CONFIG_NODE, &no_debug_ospf6_zebra_sendrecv_cmd); } diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c index 76874f6d1d..c3b4005d1d 100644 --- a/ospf6d/ospf6d.c +++ b/ospf6d/ospf6d.c @@ -126,54 +126,61 @@ config_write_ospf6_debug (struct vty *vty) "%s AS Scoped Link State Database%s%s" static int -parse_show_level (int argc, const char *argv[]) +parse_show_level (int idx_level, int argc, struct cmd_token **argv) { - int level = 0; - if (argc) + int level = OSPF6_LSDB_SHOW_LEVEL_NORMAL; + + if (argc > idx_level) { - if (! strncmp (argv[0], "de", 2)) + if (strmatch (argv[idx_level]->text, "detail")) level = OSPF6_LSDB_SHOW_LEVEL_DETAIL; - else if (! strncmp (argv[0], "du", 2)) + else if (strmatch (argv[idx_level]->text, "dump")) level = OSPF6_LSDB_SHOW_LEVEL_DUMP; - else if (! strncmp (argv[0], "in", 2)) + else if (strmatch (argv[idx_level]->text, "internal")) level = OSPF6_LSDB_SHOW_LEVEL_INTERNAL; } - else - level = OSPF6_LSDB_SHOW_LEVEL_NORMAL; + return level; } static u_int16_t -parse_type_spec (int argc, const char *argv[]) +parse_type_spec (int idx_lsa, int argc, struct cmd_token **argv) { u_int16_t type = 0; - assert (argc); - if (! strcmp (argv[0], "router")) - type = htons (OSPF6_LSTYPE_ROUTER); - else if (! strcmp (argv[0], "network")) - type = htons (OSPF6_LSTYPE_NETWORK); - else if (! strcmp (argv[0], "as-external")) - type = htons (OSPF6_LSTYPE_AS_EXTERNAL); - else if (! strcmp (argv[0], "intra-prefix")) - type = htons (OSPF6_LSTYPE_INTRA_PREFIX); - else if (! strcmp (argv[0], "inter-router")) - type = htons (OSPF6_LSTYPE_INTER_ROUTER); - else if (! strcmp (argv[0], "inter-prefix")) - type = htons (OSPF6_LSTYPE_INTER_PREFIX); - else if (! strcmp (argv[0], "link")) - type = htons (OSPF6_LSTYPE_LINK); + + if (argc > idx_lsa) + { + if (strmatch (argv[0]->text, "router")) + type = htons (OSPF6_LSTYPE_ROUTER); + else if (strmatch (argv[0]->text, "network")) + type = htons (OSPF6_LSTYPE_NETWORK); + else if (strmatch (argv[0]->text, "as-external")) + type = htons (OSPF6_LSTYPE_AS_EXTERNAL); + else if (strmatch (argv[0]->text, "intra-prefix")) + type = htons (OSPF6_LSTYPE_INTRA_PREFIX); + else if (strmatch (argv[0]->text, "inter-router")) + type = htons (OSPF6_LSTYPE_INTER_ROUTER); + else if (strmatch (argv[0]->text, "inter-prefix")) + type = htons (OSPF6_LSTYPE_INTER_PREFIX); + else if (strmatch (argv[0]->text, "link")) + type = htons (OSPF6_LSTYPE_LINK); + } + return type; } DEFUN (show_ipv6_ospf6_database, show_ipv6_ospf6_database_cmd, - "show ipv6 ospf6 database", + "show ipv6 ospf6 database [<detail|dump|internal>]", SHOW_STR IPV6_STR OSPF6_STR "Display Link state database\n" - ) + "Display details of LSAs\n" + "Dump LSAs\n" + "Display LSA's internal information\n") { + int idx_level = 4; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -182,7 +189,7 @@ DEFUN (show_ipv6_ospf6_database, OSPF6_CMD_CHECK_RUNNING (); - level = parse_show_level (argc, argv); + level = parse_show_level (idx_level, argc, argv); for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) { @@ -207,23 +214,9 @@ DEFUN (show_ipv6_ospf6_database, return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_database, - show_ipv6_ospf6_database_detail_cmd, - "show ipv6 ospf6 database (detail|dump|internal)", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ) - DEFUN (show_ipv6_ospf6_database_type, show_ipv6_ospf6_database_type_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix)", + "show ipv6 ospf6 database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> [<detail|dump|internal>]", SHOW_STR IPV6_STR OSPF6_STR @@ -237,8 +230,13 @@ DEFUN (show_ipv6_ospf6_database_type, "Display Type-7 LSAs\n" "Display Link LSAs\n" "Display Intra-Area-Prefix LSAs\n" + "Display details of LSAs\n" + "Dump LSAs\n" + "Display LSA's internal information\n" ) { + int idx_lsa = 4; + int idx_level = 5; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -248,10 +246,8 @@ DEFUN (show_ipv6_ospf6_database_type, OSPF6_CMD_CHECK_RUNNING (); - type = parse_type_spec (argc, argv); - argc--; - argv++; - level = parse_show_level (argc, argv); + type = parse_type_spec (idx_lsa, argc, argv); + level = parse_show_level (idx_level, argc, argv); switch (OSPF6_LSA_SCOPE (type)) { @@ -289,41 +285,22 @@ DEFUN (show_ipv6_ospf6_database_type, return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_database_type, - show_ipv6_ospf6_database_type_detail_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix) " - "(detail|dump|internal)", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Display Router LSAs\n" - "Display Network LSAs\n" - "Display Inter-Area-Prefix LSAs\n" - "Display Inter-Area-Router LSAs\n" - "Display As-External LSAs\n" - "Display Group-Membership LSAs\n" - "Display Type-7 LSAs\n" - "Display Link LSAs\n" - "Display Intra-Area-Prefix LSAs\n" - "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ) - DEFUN (show_ipv6_ospf6_database_id, show_ipv6_ospf6_database_id_cmd, - "show ipv6 ospf6 database * A.B.C.D", + "show ipv6 ospf6 database <*|linkstate-id> A.B.C.D [<detail|dump|internal>]", SHOW_STR IPV6_STR OSPF6_STR "Display Link state database\n" "Any Link state Type\n" + "Search by Link state ID\n" "Specify Link state ID as IPv4 address notation\n" - ) + "Display details of LSAs\n" + "Dump LSAs\n" + "Display LSA's internal information\n") { + int idx_ipv4 = 4; + int idx_level = 6; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -333,16 +310,10 @@ DEFUN (show_ipv6_ospf6_database_id, OSPF6_CMD_CHECK_RUNNING (); - if ((inet_pton (AF_INET, argv[0], &id)) != 1) - { - vty_out (vty, "Link State ID is not parsable: %s%s", - argv[0], VNL); - return CMD_SUCCESS; - } + if (argv[idx_ipv4]->type == IPV4_TKN) + inet_pton (AF_INET, argv[idx_ipv4]->arg, &id); - argc--; - argv++; - level = parse_show_level (argc, argv); + level = parse_show_level (idx_level, argc, argv); for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) { @@ -367,59 +338,23 @@ DEFUN (show_ipv6_ospf6_database_id, return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_database_id, - show_ipv6_ospf6_database_id_detail_cmd, - "show ipv6 ospf6 database * A.B.C.D " - "(detail|dump|internal)", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Any Link state Type\n" - "Specify Link state ID as IPv4 address notation\n" - "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ) - -ALIAS (show_ipv6_ospf6_database_id, - show_ipv6_ospf6_database_linkstate_id_cmd, - "show ipv6 ospf6 database linkstate-id A.B.C.D", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Search by Link state ID\n" - "Specify Link state ID as IPv4 address notation\n" - ) - -ALIAS (show_ipv6_ospf6_database_id, - show_ipv6_ospf6_database_linkstate_id_detail_cmd, - "show ipv6 ospf6 database linkstate-id A.B.C.D " - "(detail|dump|internal)", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Search by Link state ID\n" - "Specify Link state ID as IPv4 address notation\n" - "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ) - DEFUN (show_ipv6_ospf6_database_router, show_ipv6_ospf6_database_router_cmd, - "show ipv6 ospf6 database * * A.B.C.D", + "show ipv6 ospf6 database <*|adv-router> * A.B.C.D <detail|dump|internal>", SHOW_STR IPV6_STR OSPF6_STR "Display Link state database\n" "Any Link state Type\n" + "Search by Advertising Router\n" "Any Link state ID\n" "Specify Advertising Router as IPv4 address notation\n" - ) + "Display details of LSAs\n" + "Dump LSAs\n" + "Display LSA's internal information\n") { + int idx_ipv4 = 6; + int idx_level = 7; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -428,17 +363,8 @@ DEFUN (show_ipv6_ospf6_database_router, u_int32_t adv_router = 0; OSPF6_CMD_CHECK_RUNNING (); - - if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1) - { - vty_out (vty, "Advertising Router is not parsable: %s%s", - argv[0], VNL); - return CMD_SUCCESS; - } - - argc--; - argv++; - level = parse_show_level (argc, argv); + inet_pton (AF_INET, argv[idx_ipv4]->arg, &adv_router); + level = parse_show_level (idx_level, argc, argv); for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) { @@ -463,53 +389,9 @@ DEFUN (show_ipv6_ospf6_database_router, return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_database_router, - show_ipv6_ospf6_database_router_detail_cmd, - "show ipv6 ospf6 database * * A.B.C.D " - "(detail|dump|internal)", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Any Link state Type\n" - "Any Link state ID\n" - "Specify Advertising Router as IPv4 address notation\n" - "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ) - -ALIAS (show_ipv6_ospf6_database_router, - show_ipv6_ospf6_database_adv_router_cmd, - "show ipv6 ospf6 database adv-router A.B.C.D", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Search by Advertising Router\n" - "Specify Advertising Router as IPv4 address notation\n" - ) - -ALIAS (show_ipv6_ospf6_database_router, - show_ipv6_ospf6_database_adv_router_detail_cmd, - "show ipv6 ospf6 database adv-router A.B.C.D " - "(detail|dump|internal)", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Search by Advertising Router\n" - "Specify Advertising Router as IPv4 address notation\n" - "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ) - DEFUN (show_ipv6_ospf6_database_type_id, show_ipv6_ospf6_database_type_id_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix) A.B.C.D", + "show ipv6 ospf6 database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> [linkstate-id] A.B.C.D [<detail|dump|internal>]", SHOW_STR IPV6_STR OSPF6_STR @@ -523,9 +405,16 @@ DEFUN (show_ipv6_ospf6_database_type_id, "Display Type-7 LSAs\n" "Display Link LSAs\n" "Display Intra-Area-Prefix LSAs\n" + "Search by Link state ID\n" "Specify Link state ID as IPv4 address notation\n" + "Display details of LSAs\n" + "Dump LSAs\n" + "Display LSA's internal information\n" ) { + int idx_lsa = 4; + int idx_ipv4 = 6; + int idx_level = 7; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -536,20 +425,9 @@ DEFUN (show_ipv6_ospf6_database_type_id, OSPF6_CMD_CHECK_RUNNING (); - type = parse_type_spec (argc, argv); - argc--; - argv++; - - if ((inet_pton (AF_INET, argv[0], &id)) != 1) - { - vty_out (vty, "Link state ID is not parsable: %s%s", - argv[0], VNL); - return CMD_SUCCESS; - } - - argc--; - argv++; - level = parse_show_level (argc, argv); + type = parse_type_spec (idx_lsa, argc, argv); + inet_pton (AF_INET, argv[idx_ipv4]->arg, &id); + level = parse_show_level (idx_level, argc, argv); switch (OSPF6_LSA_SCOPE (type)) { @@ -587,84 +465,9 @@ DEFUN (show_ipv6_ospf6_database_type_id, return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_database_type_id, - show_ipv6_ospf6_database_type_id_detail_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix) A.B.C.D " - "(detail|dump|internal)", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Display Router LSAs\n" - "Display Network LSAs\n" - "Display Inter-Area-Prefix LSAs\n" - "Display Inter-Area-Router LSAs\n" - "Display As-External LSAs\n" - "Display Group-Membership LSAs\n" - "Display Type-7 LSAs\n" - "Display Link LSAs\n" - "Display Intra-Area-Prefix LSAs\n" - "Specify Link state ID as IPv4 address notation\n" - "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ) - -ALIAS (show_ipv6_ospf6_database_type_id, - show_ipv6_ospf6_database_type_linkstate_id_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix) linkstate-id A.B.C.D", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Display Router LSAs\n" - "Display Network LSAs\n" - "Display Inter-Area-Prefix LSAs\n" - "Display Inter-Area-Router LSAs\n" - "Display As-External LSAs\n" - "Display Group-Membership LSAs\n" - "Display Type-7 LSAs\n" - "Display Link LSAs\n" - "Display Intra-Area-Prefix LSAs\n" - "Search by Link state ID\n" - "Specify Link state ID as IPv4 address notation\n" - ) - -ALIAS (show_ipv6_ospf6_database_type_id, - show_ipv6_ospf6_database_type_linkstate_id_detail_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix) linkstate-id A.B.C.D " - "(detail|dump|internal)", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Display Router LSAs\n" - "Display Network LSAs\n" - "Display Inter-Area-Prefix LSAs\n" - "Display Inter-Area-Router LSAs\n" - "Display As-External LSAs\n" - "Display Group-Membership LSAs\n" - "Display Type-7 LSAs\n" - "Display Link LSAs\n" - "Display Intra-Area-Prefix LSAs\n" - "Search by Link state ID\n" - "Specify Link state ID as IPv4 address notation\n" - "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ) - DEFUN (show_ipv6_ospf6_database_type_router, show_ipv6_ospf6_database_type_router_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix) * A.B.C.D", + "show ipv6 ospf6 database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> <*|adv-router> A.B.C.D [<detail|dump|internal>]", SHOW_STR IPV6_STR OSPF6_STR @@ -679,9 +482,16 @@ DEFUN (show_ipv6_ospf6_database_type_router, "Display Link LSAs\n" "Display Intra-Area-Prefix LSAs\n" "Any Link state ID\n" + "Search by Advertising Router\n" "Specify Advertising Router as IPv4 address notation\n" + "Display details of LSAs\n" + "Dump LSAs\n" + "Display LSA's internal information\n" ) { + int idx_lsa = 4; + int idx_ipv4 = 6; + int idx_level = 7; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -692,20 +502,9 @@ DEFUN (show_ipv6_ospf6_database_type_router, OSPF6_CMD_CHECK_RUNNING (); - type = parse_type_spec (argc, argv); - argc--; - argv++; - - if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1) - { - vty_out (vty, "Advertising Router is not parsable: %s%s", - argv[0], VNL); - return CMD_SUCCESS; - } - - argc--; - argv++; - level = parse_show_level (argc, argv); + type = parse_type_spec (idx_lsa, argc, argv); + inet_pton (AF_INET, argv[idx_ipv4]->arg, &adv_router); + level = parse_show_level (idx_level, argc, argv); switch (OSPF6_LSA_SCOPE (type)) { @@ -743,83 +542,10 @@ DEFUN (show_ipv6_ospf6_database_type_router, return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_database_type_router, - show_ipv6_ospf6_database_type_router_detail_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix) * A.B.C.D " - "(detail|dump|internal)", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Display Router LSAs\n" - "Display Network LSAs\n" - "Display Inter-Area-Prefix LSAs\n" - "Display Inter-Area-Router LSAs\n" - "Display As-External LSAs\n" - "Display Group-Membership LSAs\n" - "Display Type-7 LSAs\n" - "Display Link LSAs\n" - "Display Intra-Area-Prefix LSAs\n" - "Any Link state ID\n" - "Specify Advertising Router as IPv4 address notation\n" - "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ) - -ALIAS (show_ipv6_ospf6_database_type_router, - show_ipv6_ospf6_database_type_adv_router_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix) adv-router A.B.C.D", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Display Router LSAs\n" - "Display Network LSAs\n" - "Display Inter-Area-Prefix LSAs\n" - "Display Inter-Area-Router LSAs\n" - "Display As-External LSAs\n" - "Display Group-Membership LSAs\n" - "Display Type-7 LSAs\n" - "Display Link LSAs\n" - "Display Intra-Area-Prefix LSAs\n" - "Search by Advertising Router\n" - "Specify Advertising Router as IPv4 address notation\n" - ) - -ALIAS (show_ipv6_ospf6_database_type_router, - show_ipv6_ospf6_database_type_adv_router_detail_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix) adv-router A.B.C.D " - "(detail|dump|internal)", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Display Router LSAs\n" - "Display Network LSAs\n" - "Display Inter-Area-Prefix LSAs\n" - "Display Inter-Area-Router LSAs\n" - "Display As-External LSAs\n" - "Display Group-Membership LSAs\n" - "Display Type-7 LSAs\n" - "Display Link LSAs\n" - "Display Intra-Area-Prefix LSAs\n" - "Search by Advertising Router\n" - "Specify Advertising Router as IPv4 address notation\n" - "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ) DEFUN (show_ipv6_ospf6_database_id_router, show_ipv6_ospf6_database_id_router_cmd, - "show ipv6 ospf6 database * A.B.C.D A.B.C.D", + "show ipv6 ospf6 database * A.B.C.D A.B.C.D [<detail|dump|internal>]", SHOW_STR IPV6_STR OSPF6_STR @@ -827,8 +553,14 @@ DEFUN (show_ipv6_ospf6_database_id_router, "Any Link state Type\n" "Specify Link state ID as IPv4 address notation\n" "Specify Advertising Router as IPv4 address notation\n" + "Display details of LSAs\n" + "Dump LSAs\n" + "Display LSA's internal information\n" ) { + int idx_ls_id = 5; + int idx_adv_rtr = 6; + int idx_level = 7; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -838,27 +570,9 @@ DEFUN (show_ipv6_ospf6_database_id_router, u_int32_t adv_router = 0; OSPF6_CMD_CHECK_RUNNING (); - - if ((inet_pton (AF_INET, argv[0], &id)) != 1) - { - vty_out (vty, "Link state ID is not parsable: %s%s", - argv[0], VNL); - return CMD_SUCCESS; - } - - argc--; - argv++; - - if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1) - { - vty_out (vty, "Advertising Router is not parsable: %s%s", - argv[0], VNL); - return CMD_SUCCESS; - } - - argc--; - argv++; - level = parse_show_level (argc, argv); + inet_pton (AF_INET, argv[idx_ls_id]->arg, &id); + inet_pton (AF_INET, argv[idx_adv_rtr]->arg, &adv_router); + level = parse_show_level (idx_level, argc, argv); for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) { @@ -883,25 +597,10 @@ DEFUN (show_ipv6_ospf6_database_id_router, return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_database_id_router, - show_ipv6_ospf6_database_id_router_detail_cmd, - "show ipv6 ospf6 database * A.B.C.D A.B.C.D " - "(detail|dump|internal)", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Any Link state Type\n" - "Specify Link state ID as IPv4 address notation\n" - "Specify Advertising Router as IPv4 address notation\n" - "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ) DEFUN (show_ipv6_ospf6_database_adv_router_linkstate_id, show_ipv6_ospf6_database_adv_router_linkstate_id_cmd, - "show ipv6 ospf6 database adv-router A.B.C.D linkstate-id A.B.C.D", + "show ipv6 ospf6 database adv-router A.B.C.D linkstate-id A.B.C.D [<detail|dump|internal>]", SHOW_STR IPV6_STR OSPF6_STR @@ -910,8 +609,13 @@ DEFUN (show_ipv6_ospf6_database_adv_router_linkstate_id, "Specify Advertising Router as IPv4 address notation\n" "Search by Link state ID\n" "Specify Link state ID as IPv4 address notation\n" - ) + "Display details of LSAs\n" + "Dump LSAs\n" + "Display LSA's internal information\n") { + int idx_adv_rtr = 5; + int idx_ls_id = 7; + int idx_level = 8; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -921,27 +625,9 @@ DEFUN (show_ipv6_ospf6_database_adv_router_linkstate_id, u_int32_t adv_router = 0; OSPF6_CMD_CHECK_RUNNING (); - - if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1) - { - vty_out (vty, "Advertising Router is not parsable: %s%s", - argv[0], VNL); - return CMD_SUCCESS; - } - - argc--; - argv++; - - if ((inet_pton (AF_INET, argv[0], &id)) != 1) - { - vty_out (vty, "Link state ID is not parsable: %s%s", - argv[0], VNL); - return CMD_SUCCESS; - } - - argc--; - argv++; - level = parse_show_level (argc, argv); + inet_pton (AF_INET, argv[idx_adv_rtr]->arg, &adv_router); + inet_pton (AF_INET, argv[idx_ls_id]->arg, &id); + level = parse_show_level (idx_level, argc, argv); for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) { @@ -966,28 +652,9 @@ DEFUN (show_ipv6_ospf6_database_adv_router_linkstate_id, return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_database_adv_router_linkstate_id, - show_ipv6_ospf6_database_adv_router_linkstate_id_detail_cmd, - "show ipv6 ospf6 database adv-router A.B.C.D linkstate-id A.B.C.D " - "(detail|dump|internal)", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Search by Advertising Router\n" - "Specify Advertising Router as IPv4 address notation\n" - "Search by Link state ID\n" - "Specify Link state ID as IPv4 address notation\n" - "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ) - DEFUN (show_ipv6_ospf6_database_type_id_router, show_ipv6_ospf6_database_type_id_router_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix) A.B.C.D A.B.C.D", + "show ipv6 ospf6 database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> A.B.C.D A.B.C.D [<dump|internal>]", SHOW_STR IPV6_STR OSPF6_STR @@ -1003,8 +670,13 @@ DEFUN (show_ipv6_ospf6_database_type_id_router, "Display Intra-Area-Prefix LSAs\n" "Specify Link state ID as IPv4 address notation\n" "Specify Advertising Router as IPv4 address notation\n" - ) + "Dump LSAs\n" + "Display LSA's internal information\n") { + int idx_lsa = 4; + int idx_ls_id = 5; + int idx_adv_rtr = 6; + int idx_level = 7; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -1016,30 +688,10 @@ DEFUN (show_ipv6_ospf6_database_type_id_router, OSPF6_CMD_CHECK_RUNNING (); - type = parse_type_spec (argc, argv); - argc--; - argv++; - - if ((inet_pton (AF_INET, argv[0], &id)) != 1) - { - vty_out (vty, "Link state ID is not parsable: %s%s", - argv[0], VNL); - return CMD_SUCCESS; - } - - argc--; - argv++; - - if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1) - { - vty_out (vty, "Advertising Router is not parsable: %s%s", - argv[0], VNL); - return CMD_SUCCESS; - } - - argc--; - argv++; - level = parse_show_level (argc, argv); + type = parse_type_spec (idx_lsa, argc, argv); + inet_pton (AF_INET, argv[idx_ls_id]->arg, &id); + inet_pton (AF_INET, argv[idx_adv_rtr]->arg, &adv_router); + level = parse_show_level (idx_level, argc, argv); switch (OSPF6_LSA_SCOPE (type)) { @@ -1077,37 +729,10 @@ DEFUN (show_ipv6_ospf6_database_type_id_router, return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_database_type_id_router, - show_ipv6_ospf6_database_type_id_router_detail_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix) A.B.C.D A.B.C.D " - "(dump|internal)", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Display Router LSAs\n" - "Display Network LSAs\n" - "Display Inter-Area-Prefix LSAs\n" - "Display Inter-Area-Router LSAs\n" - "Display As-External LSAs\n" - "Display Group-Membership LSAs\n" - "Display Type-7 LSAs\n" - "Display Link LSAs\n" - "Display Intra-Area-Prefix LSAs\n" - "Specify Link state ID as IPv4 address notation\n" - "Specify Advertising Router as IPv4 address notation\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ) DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id, show_ipv6_ospf6_database_type_adv_router_linkstate_id_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix) " - "adv-router A.B.C.D linkstate-id A.B.C.D", + "show ipv6 ospf6 database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> adv-router A.B.C.D linkstate-id A.B.C.D [<dump|internal>]", SHOW_STR IPV6_STR OSPF6_STR @@ -1125,8 +750,13 @@ DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id, "Specify Advertising Router as IPv4 address notation\n" "Search by Link state ID\n" "Specify Link state ID as IPv4 address notation\n" - ) + "Dump LSAs\n" + "Display LSA's internal information\n") { + int idx_lsa = 4; + int idx_adv_rtr = 6; + int idx_ls_id = 8; + int idx_level = 9; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -1138,30 +768,10 @@ DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id, OSPF6_CMD_CHECK_RUNNING (); - type = parse_type_spec (argc, argv); - argc--; - argv++; - - if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1) - { - vty_out (vty, "Advertising Router is not parsable: %s%s", - argv[0], VNL); - return CMD_SUCCESS; - } - - argc--; - argv++; - - if ((inet_pton (AF_INET, argv[0], &id)) != 1) - { - vty_out (vty, "Link state ID is not parsable: %s%s", - argv[0], VNL); - return CMD_SUCCESS; - } - - argc--; - argv++; - level = parse_show_level (argc, argv); + type = parse_type_spec (idx_lsa, argc, argv); + inet_pton (AF_INET, argv[idx_adv_rtr]->arg, &adv_router); + inet_pton (AF_INET, argv[idx_ls_id]->arg, &id); + level = parse_show_level (idx_level, argc, argv); switch (OSPF6_LSA_SCOPE (type)) { @@ -1199,43 +809,19 @@ DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id, return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_database_type_adv_router_linkstate_id, - show_ipv6_ospf6_database_type_adv_router_linkstate_id_detail_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix) " - "adv-router A.B.C.D linkstate-id A.B.C.D " - "(dump|internal)", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Display Router LSAs\n" - "Display Network LSAs\n" - "Display Inter-Area-Prefix LSAs\n" - "Display Inter-Area-Router LSAs\n" - "Display As-External LSAs\n" - "Display Group-Membership LSAs\n" - "Display Type-7 LSAs\n" - "Display Link LSAs\n" - "Display Intra-Area-Prefix LSAs\n" - "Search by Advertising Router\n" - "Specify Advertising Router as IPv4 address notation\n" - "Search by Link state ID\n" - "Specify Link state ID as IPv4 address notation\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ) - DEFUN (show_ipv6_ospf6_database_self_originated, show_ipv6_ospf6_database_self_originated_cmd, - "show ipv6 ospf6 database self-originated", + "show ipv6 ospf6 database self-originated [<detail|dump|internal>]", SHOW_STR IPV6_STR OSPF6_STR + "Display Link state database\n" "Display Self-originated LSAs\n" - ) + "Display details of LSAs\n" + "Dump LSAs\n" + "Display LSA's internal information\n") { + int idx_level = 5; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -1244,9 +830,7 @@ DEFUN (show_ipv6_ospf6_database_self_originated, u_int32_t adv_router = 0; OSPF6_CMD_CHECK_RUNNING (); - - level = parse_show_level (argc, argv); - + level = parse_show_level (idx_level, argc, argv); adv_router = o->router_id; for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) @@ -1272,24 +856,10 @@ DEFUN (show_ipv6_ospf6_database_self_originated, return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_database_self_originated, - show_ipv6_ospf6_database_self_originated_detail_cmd, - "show ipv6 ospf6 database self-originated " - "(detail|dump|internal)", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Self-originated LSAs\n" - "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ) DEFUN (show_ipv6_ospf6_database_type_self_originated, show_ipv6_ospf6_database_type_self_originated_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix) self-originated", + "show ipv6 ospf6 database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> self-originated [<detail|dump|internal>]", SHOW_STR IPV6_STR OSPF6_STR @@ -1304,8 +874,12 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated, "Display Link LSAs\n" "Display Intra-Area-Prefix LSAs\n" "Display Self-originated LSAs\n" - ) + "Display details of LSAs\n" + "Dump LSAs\n" + "Display LSA's internal information\n") { + int idx_lsa = 4; + int idx_level = 6; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -1316,10 +890,8 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated, OSPF6_CMD_CHECK_RUNNING (); - type = parse_type_spec (argc, argv); - argc--; - argv++; - level = parse_show_level (argc, argv); + type = parse_type_spec (idx_lsa, argc, argv); + level = parse_show_level (idx_level, argc, argv); adv_router = o->router_id; @@ -1359,37 +931,9 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated, return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_database_type_self_originated, - show_ipv6_ospf6_database_type_self_originated_detail_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix) self-originated " - "(detail|dump|internal)", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Display Router LSAs\n" - "Display Network LSAs\n" - "Display Inter-Area-Prefix LSAs\n" - "Display Inter-Area-Router LSAs\n" - "Display As-External LSAs\n" - "Display Group-Membership LSAs\n" - "Display Type-7 LSAs\n" - "Display Link LSAs\n" - "Display Intra-Area-Prefix LSAs\n" - "Display Self-originated LSAs\n" - "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ) - DEFUN (show_ipv6_ospf6_database_type_self_originated_linkstate_id, show_ipv6_ospf6_database_type_self_originated_linkstate_id_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix) self-originated " - "linkstate-id A.B.C.D", + "show ipv6 ospf6 database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> self-originated linkstate-id A.B.C.D [<detail|dump|internal>]", SHOW_STR IPV6_STR OSPF6_STR @@ -1406,8 +950,13 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated_linkstate_id, "Display Self-originated LSAs\n" "Search by Link state ID\n" "Specify Link state ID as IPv4 address notation\n" - ) + "Display details of LSAs\n" + "Dump LSAs\n" + "Display LSA's internal information\n") { + int idx_lsa = 4; + int idx_ls_id = 7; + int idx_level = 8; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -1419,21 +968,9 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated_linkstate_id, OSPF6_CMD_CHECK_RUNNING (); - type = parse_type_spec (argc, argv); - argc--; - argv++; - - if ((inet_pton (AF_INET, argv[0], &id)) != 1) - { - vty_out (vty, "Link State ID is not parsable: %s%s", - argv[0], VNL); - return CMD_SUCCESS; - } - - argc--; - argv++; - level = parse_show_level (argc, argv); - + type = parse_type_spec (idx_lsa, argc, argv); + inet_pton (AF_INET, argv[idx_ls_id]->arg, &id); + level = parse_show_level (idx_level, argc, argv); adv_router = o->router_id; switch (OSPF6_LSA_SCOPE (type)) @@ -1472,38 +1009,9 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated_linkstate_id, return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_database_type_self_originated_linkstate_id, - show_ipv6_ospf6_database_type_self_originated_linkstate_id_detail_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix) self-originated " - "linkstate-id A.B.C.D (detail|dump|internal)", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Display Router LSAs\n" - "Display Network LSAs\n" - "Display Inter-Area-Prefix LSAs\n" - "Display Inter-Area-Router LSAs\n" - "Display As-External LSAs\n" - "Display Group-Membership LSAs\n" - "Display Type-7 LSAs\n" - "Display Link LSAs\n" - "Display Intra-Area-Prefix LSAs\n" - "Display Self-originated LSAs\n" - "Search by Link state ID\n" - "Specify Link state ID as IPv4 address notation\n" - "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ) - DEFUN (show_ipv6_ospf6_database_type_id_self_originated, show_ipv6_ospf6_database_type_id_self_originated_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix) A.B.C.D self-originated", + "show ipv6 ospf6 database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> A.B.C.D self-originated [<detail|dump|internal>]", SHOW_STR IPV6_STR OSPF6_STR @@ -1519,8 +1027,13 @@ DEFUN (show_ipv6_ospf6_database_type_id_self_originated, "Display Intra-Area-Prefix LSAs\n" "Specify Link state ID as IPv4 address notation\n" "Display Self-originated LSAs\n" - ) + "Display details of LSAs\n" + "Dump LSAs\n" + "Display LSA's internal information\n") { + int idx_lsa = 4; + int idx_ls_id = 5; + int idx_level = 7; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -1532,21 +1045,9 @@ DEFUN (show_ipv6_ospf6_database_type_id_self_originated, OSPF6_CMD_CHECK_RUNNING (); - type = parse_type_spec (argc, argv); - argc--; - argv++; - - if ((inet_pton (AF_INET, argv[0], &id)) != 1) - { - vty_out (vty, "Link State ID is not parsable: %s%s", - argv[0], VNL); - return CMD_SUCCESS; - } - - argc--; - argv++; - level = parse_show_level (argc, argv); - + type = parse_type_spec (idx_lsa, argc, argv); + inet_pton (AF_INET, argv[idx_ls_id]->arg, &id); + level = parse_show_level (idx_level, argc, argv); adv_router = o->router_id; switch (OSPF6_LSA_SCOPE (type)) @@ -1585,109 +1086,75 @@ DEFUN (show_ipv6_ospf6_database_type_id_self_originated, return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_database_type_id_self_originated, - show_ipv6_ospf6_database_type_id_self_originated_detail_cmd, - "show ipv6 ospf6 database " - "(router|network|inter-prefix|inter-router|as-external|" - "group-membership|type-7|link|intra-prefix) A.B.C.D self-originated " - "(detail|dump|internal)", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - "Display Router LSAs\n" - "Display Network LSAs\n" - "Display Inter-Area-Prefix LSAs\n" - "Display Inter-Area-Router LSAs\n" - "Display As-External LSAs\n" - "Display Group-Membership LSAs\n" - "Display Type-7 LSAs\n" - "Display Link LSAs\n" - "Display Intra-Area-Prefix LSAs\n" - "Display Self-originated LSAs\n" - "Search by Link state ID\n" - "Specify Link state ID as IPv4 address notation\n" - "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ) - - DEFUN (show_ipv6_ospf6_border_routers, show_ipv6_ospf6_border_routers_cmd, - "show ipv6 ospf6 border-routers", + "show ipv6 ospf6 border-routers [<A.B.C.D|detail>]", SHOW_STR IP6_STR OSPF6_STR "Display routing table for ABR and ASBR\n" - ) + "Router ID\n" + "Show detailed output\n") { + int idx_ipv4 = 4; u_int32_t adv_router; - void (*showfunc) (struct vty *, struct ospf6_route *); struct ospf6_route *ro; struct prefix prefix; OSPF6_CMD_CHECK_RUNNING (); - if (argc && ! strcmp ("detail", argv[0])) + if (argc == 5) { - showfunc = ospf6_route_show_detail; - argc--; - argv++; - } - else - showfunc = ospf6_brouter_show; - - if (argc) - { - if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1) + if (strmatch (argv[idx_ipv4]->text, "detail")) { - vty_out (vty, "Router ID is not parsable: %s%s", argv[0], VNL); - return CMD_SUCCESS; + for (ro = ospf6_route_head (ospf6->brouter_table); ro; + ro = ospf6_route_next (ro)) + ospf6_route_show_detail (vty, ro); } - - ospf6_linkstate_prefix (adv_router, 0, &prefix); - ro = ospf6_route_lookup (&prefix, ospf6->brouter_table); - if (!ro) + else { - vty_out (vty, "No Route found for Router ID: %s%s", argv[0], VNL); + inet_pton (AF_INET, argv[idx_ipv4]->arg, &adv_router); + + ospf6_linkstate_prefix (adv_router, 0, &prefix); + ro = ospf6_route_lookup (&prefix, ospf6->brouter_table); + if (!ro) + { + vty_out (vty, "No Route found for Router ID: %s%s", argv[4]->arg, VNL); + return CMD_SUCCESS; + } + + ospf6_route_show_detail (vty, ro); return CMD_SUCCESS; } - - ospf6_route_show_detail (vty, ro); - return CMD_SUCCESS; } + else + { + ospf6_brouter_show_header (vty); - if (showfunc == ospf6_brouter_show) - ospf6_brouter_show_header (vty); - - for (ro = ospf6_route_head (ospf6->brouter_table); ro; - ro = ospf6_route_next (ro)) - (*showfunc) (vty, ro); + for (ro = ospf6_route_head (ospf6->brouter_table); ro; + ro = ospf6_route_next (ro)) + ospf6_brouter_show (vty, ro); + } return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_border_routers, - show_ipv6_ospf6_border_routers_detail_cmd, - "show ipv6 ospf6 border-routers (A.B.C.D|detail)", - SHOW_STR - IP6_STR - OSPF6_STR - "Display routing table for ABR and ASBR\n" - "Specify Router-ID\n" - "Display Detail\n" - ) DEFUN (show_ipv6_ospf6_linkstate, show_ipv6_ospf6_linkstate_cmd, - "show ipv6 ospf6 linkstate", + "show ipv6 ospf6 linkstate <router A.B.C.D|network A.B.C.D A.B.C.D>", SHOW_STR IP6_STR OSPF6_STR "Display linkstate routing table\n" + "Display Router Entry\n" + "Specify Router ID as IPv4 address notation\n" + "Display Network Entry\n" + "Specify Router ID as IPv4 address notation\n" + "Specify Link state ID as IPv4 address notation\n" ) { + int idx_ipv4 = 4; struct listnode *node; struct ospf6_area *oa; @@ -1697,35 +1164,14 @@ DEFUN (show_ipv6_ospf6_linkstate, { vty_out (vty, "%s SPF Result in Area %s%s%s", VNL, oa->name, VNL, VNL); - ospf6_linkstate_table_show (vty, argc, argv, oa->spf_table); + ospf6_linkstate_table_show (vty, idx_ipv4, argc, argv, oa->spf_table); } vty_out (vty, "%s", VNL); return CMD_SUCCESS; } -ALIAS (show_ipv6_ospf6_linkstate, - show_ipv6_ospf6_linkstate_router_cmd, - "show ipv6 ospf6 linkstate router A.B.C.D", - SHOW_STR - IP6_STR - OSPF6_STR - "Display linkstate routing table\n" - "Display Router Entry\n" - "Specify Router ID as IPv4 address notation\n" - ) -ALIAS (show_ipv6_ospf6_linkstate, - show_ipv6_ospf6_linkstate_network_cmd, - "show ipv6 ospf6 linkstate network A.B.C.D A.B.C.D", - SHOW_STR - IP6_STR - OSPF6_STR - "Display linkstate routing table\n" - "Display Network Entry\n" - "Specify Router ID as IPv4 address notation\n" - "Specify Link state ID as IPv4 address notation\n" - ) DEFUN (show_ipv6_ospf6_linkstate_detail, show_ipv6_ospf6_linkstate_detail_cmd, @@ -1736,25 +1182,17 @@ DEFUN (show_ipv6_ospf6_linkstate_detail, "Display linkstate routing table\n" ) { - const char *sargv[CMD_ARGC_MAX]; - int i, sargc; + int idx_detail = 4; struct listnode *node; struct ospf6_area *oa; OSPF6_CMD_CHECK_RUNNING (); - /* copy argv to sargv and then append "detail" */ - for (i = 0; i < argc; i++) - sargv[i] = argv[i]; - sargc = argc; - sargv[sargc++] = "detail"; - sargv[sargc] = NULL; - for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa)) { vty_out (vty, "%s SPF Result in Area %s%s%s", VNL, oa->name, VNL, VNL); - ospf6_linkstate_table_show (vty, sargc, sargv, oa->spf_table); + ospf6_linkstate_table_show (vty, idx_detail, argc, argv, oa->spf_table); } vty_out (vty, "%s", VNL); @@ -1801,52 +1239,27 @@ ospf6_init (void) install_element (VIEW_NODE, &show_version_ospf6_cmd); install_element (VIEW_NODE, &show_ipv6_ospf6_border_routers_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_border_routers_detail_cmd); install_element (VIEW_NODE, &show_ipv6_ospf6_linkstate_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_linkstate_router_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_linkstate_network_cmd); install_element (VIEW_NODE, &show_ipv6_ospf6_linkstate_detail_cmd); #define INSTALL(n,c) \ install_element (n ## _NODE, &show_ipv6_ospf6_ ## c) INSTALL (VIEW, database_cmd); - INSTALL (VIEW, database_detail_cmd); INSTALL (VIEW, database_type_cmd); - INSTALL (VIEW, database_type_detail_cmd); INSTALL (VIEW, database_id_cmd); - INSTALL (VIEW, database_id_detail_cmd); - INSTALL (VIEW, database_linkstate_id_cmd); - INSTALL (VIEW, database_linkstate_id_detail_cmd); INSTALL (VIEW, database_router_cmd); - INSTALL (VIEW, database_router_detail_cmd); - INSTALL (VIEW, database_adv_router_cmd); - INSTALL (VIEW, database_adv_router_detail_cmd); INSTALL (VIEW, database_type_id_cmd); - INSTALL (VIEW, database_type_id_detail_cmd); - INSTALL (VIEW, database_type_linkstate_id_cmd); - INSTALL (VIEW, database_type_linkstate_id_detail_cmd); INSTALL (VIEW, database_type_router_cmd); - INSTALL (VIEW, database_type_router_detail_cmd); - INSTALL (VIEW, database_type_adv_router_cmd); - INSTALL (VIEW, database_type_adv_router_detail_cmd); INSTALL (VIEW, database_adv_router_linkstate_id_cmd); - INSTALL (VIEW, database_adv_router_linkstate_id_detail_cmd); INSTALL (VIEW, database_id_router_cmd); - INSTALL (VIEW, database_id_router_detail_cmd); INSTALL (VIEW, database_type_id_router_cmd); - INSTALL (VIEW, database_type_id_router_detail_cmd); INSTALL (VIEW, database_type_adv_router_linkstate_id_cmd); - INSTALL (VIEW, database_type_adv_router_linkstate_id_detail_cmd); INSTALL (VIEW, database_self_originated_cmd); - INSTALL (VIEW, database_self_originated_detail_cmd); INSTALL (VIEW, database_type_self_originated_cmd); - INSTALL (VIEW, database_type_self_originated_detail_cmd); INSTALL (VIEW, database_type_id_self_originated_cmd); - INSTALL (VIEW, database_type_id_self_originated_detail_cmd); INSTALL (VIEW, database_type_self_originated_linkstate_id_cmd); - INSTALL (VIEW, database_type_self_originated_linkstate_id_detail_cmd); /* Make ospf protocol socket. */ ospf6_serv_sock (); diff --git a/ospfd/ospf_bfd.c b/ospfd/ospf_bfd.c index c87bcb0afb..803dc923ea 100644 --- a/ospfd/ospf_bfd.c +++ b/ospfd/ospf_bfd.c @@ -379,7 +379,7 @@ DEFUN (ip_ospf_bfd, DEFUN (ip_ospf_bfd_param, ip_ospf_bfd_param_cmd, - "ip ospf bfd " BFD_CMD_DETECT_MULT_RANGE BFD_CMD_MIN_RX_RANGE BFD_CMD_MIN_TX_RANGE, + "ip ospf bfd (2-255) (50-60000) (50-60000)", "IP Information\n" "OSPF interface commands\n" "Enables BFD support\n" @@ -387,6 +387,9 @@ DEFUN (ip_ospf_bfd_param, "Required min receive interval\n" "Desired min transmit interval\n") { + int idx_number = 3; + int idx_number_2 = 4; + int idx_number_3 = 5; struct interface *ifp = (struct interface *) vty->index; u_int32_t rx_val; u_int32_t tx_val; @@ -395,7 +398,7 @@ DEFUN (ip_ospf_bfd_param, assert (ifp); - if ((ret = bfd_validate_param (vty, argv[0], argv[1], argv[2], &dm_val, + if ((ret = bfd_validate_param (vty, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg, &dm_val, &rx_val, &tx_val)) != CMD_SUCCESS) return ret; @@ -406,11 +409,14 @@ DEFUN (ip_ospf_bfd_param, DEFUN (no_ip_ospf_bfd, no_ip_ospf_bfd_cmd, - "no ip ospf bfd", + "no ip ospf bfd [(2-255) (50-60000) (50-60000)]", NO_STR "IP Information\n" "OSPF interface commands\n" - "Disables BFD support\n") + "Disables BFD support\n" + "Detect Multiplier\n" + "Required min receive interval\n" + "Desired min transmit interval\n") { struct interface *ifp = (struct interface *)vty->index; struct ospf_if_params *params; @@ -427,17 +433,6 @@ DEFUN (no_ip_ospf_bfd, return CMD_SUCCESS; } -ALIAS (no_ip_ospf_bfd, - no_ip_ospf_bfd_param_cmd, - "no ip ospf bfd " BFD_CMD_DETECT_MULT_RANGE BFD_CMD_MIN_RX_RANGE BFD_CMD_MIN_TX_RANGE, - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Enables BFD support\n" - "Detect Multiplier\n" - "Required min receive interval\n" - "Desired min transmit interval\n") - void ospf_bfd_init(void) { @@ -451,5 +446,4 @@ ospf_bfd_init(void) install_element (INTERFACE_NODE, &ip_ospf_bfd_cmd); install_element (INTERFACE_NODE, &ip_ospf_bfd_param_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_bfd_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_bfd_param_cmd); } diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index 8fa2258f4f..93baac5988 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -753,54 +753,69 @@ ospf_packet_dump (struct stream *s) stream_set_getp (s, gp); } - -/* - [no] debug ospf [<1-65535>] packet (hello|dd|ls-request|ls-update|ls-ack|all) - [send|recv [detail]] -*/ -static int -debug_ospf_packet_common (struct vty *vty, int arg_base, int argc, - const char **argv) +DEFUN (debug_ospf_packet, + debug_ospf_packet_cmd, + "debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]", + DEBUG_STR + OSPF_STR + "Instance ID\n" + "OSPF packets\n" + "OSPF Hello\n" + "OSPF Database Description\n" + "OSPF Link State Request\n" + "OSPF Link State Update\n" + "OSPF Link State Acknowledgment\n" + "OSPF all packets\n" + "Packet sent\n" + "Detail Information\n" + "Packet received\n" + "Detail Information\n" + "Detail Information\n") { + int inst = (argv[2]->type == RANGE_TKN) ? 1 : 0; + int detail = strmatch (argv[argc - 1]->text, "detail"); + int send = strmatch (argv[argc - (1+detail)]->text, "send"); + int recv = strmatch (argv[argc - (1+detail)]->text, "recv"); + char *packet = argv[3 + inst]->text; + + if (inst) // user passed instance ID + { + if (!ospf_lookup_instance (strtoul (argv[2]->arg, NULL, 10))) + return CMD_SUCCESS; + } + int type = 0; int flag = 0; int i; - assert (argc > arg_base + 0); - /* Check packet type. */ - if (strncmp (argv[arg_base + 0], "h", 1) == 0) + if (strmatch (packet, "hello")) type = OSPF_DEBUG_HELLO; - else if (strncmp (argv[arg_base + 0], "d", 1) == 0) + else if (strmatch (packet, "dd")) type = OSPF_DEBUG_DB_DESC; - else if (strncmp (argv[arg_base + 0], "ls-r", 4) == 0) + else if (strmatch (packet, "ls-request")) type = OSPF_DEBUG_LS_REQ; - else if (strncmp (argv[arg_base + 0], "ls-u", 4) == 0) + else if (strmatch (packet, "ls-update")) type = OSPF_DEBUG_LS_UPD; - else if (strncmp (argv[arg_base + 0], "ls-a", 4) == 0) + else if (strmatch (packet, "ls-ack")) type = OSPF_DEBUG_LS_ACK; - else if (strncmp (argv[arg_base + 0], "a", 1) == 0) + else if (strmatch (packet, "all")) type = OSPF_DEBUG_ALL; - /* Default, both send and recv. */ - if (argc == arg_base + 1) - flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV; - - /* send or recv. */ - if (argc >= arg_base + 2) - { - if (strncmp (argv[arg_base + 1], "s", 1) == 0) - flag = OSPF_DEBUG_SEND; - else if (strncmp (argv[arg_base + 1], "r", 1) == 0) - flag = OSPF_DEBUG_RECV; - else if (strncmp (argv[arg_base + 1], "d", 1) == 0) - flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL; - } - - /* detail. */ - if (argc == arg_base + 3) - if (strncmp (argv[arg_base + 2], "d", 1) == 0) - flag |= OSPF_DEBUG_DETAIL; + /* Cases: + * (none) = send + recv + * detail = send + recv + detail + * recv = recv + * send = send + * recv detail = recv + detail + * send detail = send + detail + */ + if (!send && !recv) + send = recv = 1; + + flag |= (send) ? OSPF_DEBUG_SEND : 0; + flag |= (recv) ? OSPF_DEBUG_RECV : 0; + flag |= (detail) ? OSPF_DEBUG_DETAIL : 0; for (i = 0; i < 5; i++) if (type & (0x01 << i)) @@ -814,43 +829,13 @@ debug_ospf_packet_common (struct vty *vty, int arg_base, int argc, return CMD_SUCCESS; } -DEFUN (debug_ospf_packet, - debug_ospf_packet_all_cmd, - "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)", +DEFUN (no_debug_ospf_packet, + no_debug_ospf_packet_cmd, + "no debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]", + NO_STR DEBUG_STR OSPF_STR - "OSPF packets\n" - "OSPF Hello\n" - "OSPF Database Description\n" - "OSPF Link State Request\n" - "OSPF Link State Update\n" - "OSPF Link State Acknowledgment\n" - "OSPF all packets\n") -{ - return (debug_ospf_packet_common(vty, 0, argc, argv)); -} - -ALIAS (debug_ospf_packet, - debug_ospf_packet_send_recv_cmd, - "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)", - "Debugging functions\n" - "OSPF information\n" - "OSPF packets\n" - "OSPF Hello\n" - "OSPF Database Description\n" - "OSPF Link State Request\n" - "OSPF Link State Update\n" - "OSPF Link State Acknowledgment\n" - "OSPF all packets\n" - "Packet sent\n" - "Packet received\n" - "Detail information\n") - -ALIAS (debug_ospf_packet, - debug_ospf_packet_send_recv_detail_cmd, - "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)", - "Debugging functions\n" - "OSPF information\n" + "Instance ID\n" "OSPF packets\n" "OSPF Hello\n" "OSPF Database Description\n" @@ -859,109 +844,55 @@ ALIAS (debug_ospf_packet, "OSPF Link State Acknowledgment\n" "OSPF all packets\n" "Packet sent\n" + "Detail Information\n" "Packet received\n" + "Detail Information\n" "Detail Information\n") - -DEFUN (debug_ospf_instance_packet, - debug_ospf_instance_packet_all_cmd, - "debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all)", - DEBUG_STR - OSPF_STR - "Instance ID\n" - "OSPF packets\n" - "OSPF Hello\n" - "OSPF Database Description\n" - "OSPF Link State Request\n" - "OSPF Link State Update\n" - "OSPF Link State Acknowledgment\n" - "OSPF all packets\n") { - u_short instance = 0; - - VTY_GET_INTEGER ("Instance", instance, argv[0]); - if (!ospf_lookup_instance (instance)) - return CMD_SUCCESS; - - return (debug_ospf_packet_common(vty, 1, argc, argv)); -} + int inst = (argv[3]->type == RANGE_TKN) ? 1 : 0; + int detail = strmatch (argv[argc - 1]->text, "detail"); + int send = strmatch (argv[argc - (1+detail)]->text, "send"); + int recv = strmatch (argv[argc - (1+detail)]->text, "recv"); + char *packet = argv[4 + inst]->text; -ALIAS (debug_ospf_instance_packet, - debug_ospf_instance_packet_send_recv_cmd, - "debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)", - "Debugging functions\n" - "OSPF information\n" - "Instance ID\n" - "OSPF packets\n" - "OSPF Hello\n" - "OSPF Database Description\n" - "OSPF Link State Request\n" - "OSPF Link State Update\n" - "OSPF Link State Acknowledgment\n" - "OSPF all packets\n" - "Packet sent\n" - "Packet received\n" - "Detail information\n") - -ALIAS (debug_ospf_instance_packet, - debug_ospf_instance_packet_send_recv_detail_cmd, - "debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)", - "Debugging functions\n" - "OSPF information\n" - "Instance ID\n" - "OSPF packets\n" - "OSPF Hello\n" - "OSPF Database Description\n" - "OSPF Link State Request\n" - "OSPF Link State Update\n" - "OSPF Link State Acknowledgment\n" - "OSPF all packets\n" - "Packet sent\n" - "Packet received\n" - "Detail Information\n") + if (inst) // user passed instance ID + { + if (!ospf_lookup_instance (strtoul (argv[3]->arg, NULL, 10))) + return CMD_SUCCESS; + } -static int -no_debug_ospf_packet_common (struct vty *vty, int arg_base, int argc, - const char **argv) -{ int type = 0; int flag = 0; int i; - assert (argc > arg_base + 0); - /* Check packet type. */ - if (strncmp (argv[arg_base + 0], "h", 1) == 0) + if (strmatch (packet, "hello")) type = OSPF_DEBUG_HELLO; - else if (strncmp (argv[arg_base + 0], "d", 1) == 0) + else if (strmatch (packet, "dd")) type = OSPF_DEBUG_DB_DESC; - else if (strncmp (argv[arg_base + 0], "ls-r", 4) == 0) + else if (strmatch (packet, "ls-request")) type = OSPF_DEBUG_LS_REQ; - else if (strncmp (argv[arg_base + 0], "ls-u", 4) == 0) + else if (strmatch (packet, "ls-update")) type = OSPF_DEBUG_LS_UPD; - else if (strncmp (argv[arg_base + 0], "ls-a", 4) == 0) + else if (strmatch (packet, "ls-ack")) type = OSPF_DEBUG_LS_ACK; - else if (strncmp (argv[arg_base + 0], "a", 1) == 0) + else if (strmatch (packet, "all")) type = OSPF_DEBUG_ALL; - /* Default, both send and recv. */ - if (argc == arg_base + 1) - flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL ; - - /* send or recv. */ - if (argc == arg_base + 2) - { - if (strncmp (argv[arg_base + 1], "s", 1) == 0) - flag = OSPF_DEBUG_SEND | OSPF_DEBUG_DETAIL; - else if (strncmp (argv[arg_base + 1], "r", 1) == 0) - flag = OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL; - else if (strncmp (argv[arg_base + 1], "d", 1) == 0) - flag = OSPF_DEBUG_DETAIL | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL; - } - - /* detail. */ - if (argc == arg_base + 3) - if (strncmp (argv[arg_base + 2], "d", 1) == 0) - flag = OSPF_DEBUG_DETAIL; + /* Cases: + * (none) = send + recv + * detail = send + recv + detail + * recv = recv + * send = send + * recv detail = recv + detail + * send detail = send + detail + */ + if (!send && !recv) + send = recv = 1; + + flag |= (send) ? OSPF_DEBUG_SEND : 0; + flag |= (recv) ? OSPF_DEBUG_RECV : 0; + flag |= (detail) ? OSPF_DEBUG_DETAIL : 0; for (i = 0; i < 5; i++) if (type & (0x01 << i)) @@ -982,132 +913,37 @@ no_debug_ospf_packet_common (struct vty *vty, int arg_base, int argc, return CMD_SUCCESS; } -DEFUN (no_debug_ospf_packet, - no_debug_ospf_packet_all_cmd, - "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)", - NO_STR - DEBUG_STR - OSPF_STR - "OSPF packets\n" - "OSPF Hello\n" - "OSPF Database Description\n" - "OSPF Link State Request\n" - "OSPF Link State Update\n" - "OSPF Link State Acknowledgment\n" - "OSPF all packets\n") -{ - return no_debug_ospf_packet_common(vty, 0, argc, argv); -} - -ALIAS (no_debug_ospf_packet, - no_debug_ospf_packet_send_recv_cmd, - "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)", - NO_STR - "Debugging functions\n" - "OSPF information\n" - "OSPF packets\n" - "OSPF Hello\n" - "OSPF Database Description\n" - "OSPF Link State Request\n" - "OSPF Link State Update\n" - "OSPF Link State Acknowledgment\n" - "OSPF all packets\n" - "Packet sent\n" - "Packet received\n" - "Detail Information\n") - -ALIAS (no_debug_ospf_packet, - no_debug_ospf_packet_send_recv_detail_cmd, - "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)", - NO_STR - "Debugging functions\n" - "OSPF information\n" - "OSPF packets\n" - "OSPF Hello\n" - "OSPF Database Description\n" - "OSPF Link State Request\n" - "OSPF Link State Update\n" - "OSPF Link State Acknowledgment\n" - "OSPF all packets\n" - "Packet sent\n" - "Packet received\n" - "Detail Information\n") - -DEFUN (no_debug_ospf_instance_packet, - no_debug_ospf_instance_packet_all_cmd, - "no debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all)", - NO_STR +DEFUN (debug_ospf_ism, + debug_ospf_ism_cmd, + "debug ospf [(1-65535)] ism [<status|events|timers>]", DEBUG_STR OSPF_STR "Instance ID\n" - "OSPF packets\n" - "OSPF Hello\n" - "OSPF Database Description\n" - "OSPF Link State Request\n" - "OSPF Link State Update\n" - "OSPF Link State Acknowledgment\n" - "OSPF all packets\n") + "OSPF Interface State Machine\n" + "ISM Status Information\n" + "ISM Event Information\n" + "ISM TImer Information\n") { - u_short instance = 0; - - VTY_GET_INTEGER ("Instance", instance, argv[0]); - if (!ospf_lookup_instance (instance)) - return CMD_SUCCESS; - - return (no_debug_ospf_packet_common(vty, 1, argc, argv)); -} - -ALIAS (no_debug_ospf_instance_packet, - no_debug_ospf_instance_packet_send_recv_cmd, - "no debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)", - NO_STR - "Debugging functions\n" - "OSPF information\n" - "Instance ID\n" - "OSPF packets\n" - "OSPF Hello\n" - "OSPF Database Description\n" - "OSPF Link State Request\n" - "OSPF Link State Update\n" - "OSPF Link State Acknowledgment\n" - "OSPF all packets\n" - "Packet sent\n" - "Packet received\n" - "Detail Information\n") - -ALIAS (no_debug_ospf_instance_packet, - no_debug_ospf_instance_packet_send_recv_detail_cmd, - "no debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)", - NO_STR - "Debugging functions\n" - "OSPF information\n" - "Instance ID\n" - "OSPF packets\n" - "OSPF Hello\n" - "OSPF Database Description\n" - "OSPF Link State Request\n" - "OSPF Link State Update\n" - "OSPF Link State Acknowledgment\n" - "OSPF all packets\n" - "Packet sent\n" - "Packet received\n" - "Detail Information\n") + int inst = (argv[2]->type == RANGE_TKN); + char *dbgparam = (argc == 4 + inst) ? argv[argc - 1]->text : NULL; + if (inst) // user passed instance ID + { + if (!ospf_lookup_instance (strtoul (argv[2]->arg, NULL, 10))) + return CMD_SUCCESS; + } -static int -debug_ospf_ism_common (struct vty *vty, int arg_base, int argc, const char **argv) -{ if (vty->node == CONFIG_NODE) { - if (argc == arg_base + 0) + if (!dbgparam) DEBUG_ON (ism, ISM); - else if (argc == arg_base + 1) + else { - if (strncmp (argv[arg_base + 0], "s", 1) == 0) + if (strmatch (dbgparam, "status")) DEBUG_ON (ism, ISM_STATUS); - else if (strncmp (argv[arg_base + 0], "e", 1) == 0) + else if (strmatch (dbgparam, "events")) DEBUG_ON (ism, ISM_EVENTS); - else if (strncmp (argv[arg_base + 0], "t", 1) == 0) + else if (strmatch (dbgparam, "timers")) DEBUG_ON (ism, ISM_TIMERS); } @@ -1115,159 +951,77 @@ debug_ospf_ism_common (struct vty *vty, int arg_base, int argc, const char **arg } /* ENABLE_NODE. */ - if (argc == arg_base + 0) + if (!dbgparam) TERM_DEBUG_ON (ism, ISM); - else if (argc == arg_base + 1) + else { - if (strncmp (argv[arg_base + 0], "s", 1) == 0) - TERM_DEBUG_ON (ism, ISM_STATUS); - else if (strncmp (argv[arg_base + 0], "e", 1) == 0) - TERM_DEBUG_ON (ism, ISM_EVENTS); - else if (strncmp (argv[arg_base + 0], "t", 1) == 0) - TERM_DEBUG_ON (ism, ISM_TIMERS); + if (strmatch (dbgparam, "status")) + TERM_DEBUG_ON (ism, ISM_STATUS); + else if (strmatch (dbgparam, "events")) + TERM_DEBUG_ON (ism, ISM_EVENTS); + else if (strmatch (dbgparam, "timers")) + TERM_DEBUG_ON (ism, ISM_TIMERS); } return CMD_SUCCESS; } -DEFUN (debug_ospf_ism, - debug_ospf_ism_cmd, - "debug ospf ism", - DEBUG_STR - OSPF_STR - "OSPF Interface State Machine\n") -{ - return debug_ospf_ism_common(vty, 0, argc, argv); -} - -ALIAS (debug_ospf_ism, - debug_ospf_ism_sub_cmd, - "debug ospf ism (status|events|timers)", +DEFUN (no_debug_ospf_ism, + no_debug_ospf_ism_cmd, + "no debug ospf [(1-65535)] ism [<status|events|timers>]", + NO_STR DEBUG_STR OSPF_STR + "Instance ID\n" "OSPF Interface State Machine\n" "ISM Status Information\n" "ISM Event Information\n" "ISM TImer Information\n") - -DEFUN (debug_ospf_instance_ism, - debug_ospf_instance_ism_cmd, - "debug ospf <1-65535> ism", - DEBUG_STR - OSPF_STR - "Instance ID\n" - "OSPF Interface State Machine\n") { - u_short instance = 0; + int inst = (argv[3]->type == RANGE_TKN); + char *dbgparam = (argc == 5 + inst) ? argv[argc - 1]->text : NULL; - VTY_GET_INTEGER ("Instance", instance, argv[0]); - if (!ospf_lookup_instance (instance)) - return CMD_SUCCESS; - - return debug_ospf_ism_common(vty, 1, argc, argv); -} - -ALIAS (debug_ospf_instance_ism, - debug_ospf_instance_ism_sub_cmd, - "debug ospf <1-65535> ism (status|events|timers)", - DEBUG_STR - OSPF_STR - "Instance ID\n" - "OSPF Interface State Machine\n" - "ISM Status Information\n" - "ISM Event Information\n" - "ISM TImer Information\n") + if (inst) // user passed instance ID + { + if (!ospf_lookup_instance (strtoul (argv[3]->arg, NULL, 10))) + return CMD_SUCCESS; + } -static int -no_debug_ospf_ism_common(struct vty *vty, int arg_base, int argc, - const char **argv) -{ if (vty->node == CONFIG_NODE) { - if (argc == arg_base + 0) + if (!dbgparam) DEBUG_OFF (ism, ISM); - else if (argc == arg_base + 1) + else { - if (strncmp (argv[arg_base + 0], "s", 1) == 0) + if (strmatch (dbgparam, "status")) DEBUG_OFF (ism, ISM_STATUS); - else if (strncmp (argv[arg_base + 0], "e", 1) == 0) + else if (strmatch (dbgparam, "events")) DEBUG_OFF (ism, ISM_EVENTS); - else if (strncmp (argv[arg_base + 0], "t", 1) == 0) + else if (strmatch (dbgparam, "timers")) DEBUG_OFF (ism, ISM_TIMERS); } + return CMD_SUCCESS; } /* ENABLE_NODE. */ - if (argc == arg_base + 0) + if (!dbgparam) TERM_DEBUG_OFF (ism, ISM); - else if (argc == arg_base + 1) + else { - if (strncmp (argv[arg_base + 0], "s", 1) == 0) - TERM_DEBUG_OFF (ism, ISM_STATUS); - else if (strncmp (argv[arg_base + 0], "e", 1) == 0) - TERM_DEBUG_OFF (ism, ISM_EVENTS); - else if (strncmp (argv[arg_base + 0], "t", 1) == 0) - TERM_DEBUG_OFF (ism, ISM_TIMERS); + if (strmatch (dbgparam, "status")) + TERM_DEBUG_OFF (ism, ISM_STATUS); + else if (strmatch (dbgparam, "events")) + TERM_DEBUG_OFF (ism, ISM_EVENTS); + else if (strmatch (dbgparam, "timers")) + TERM_DEBUG_OFF (ism, ISM_TIMERS); } return CMD_SUCCESS; } -DEFUN (no_debug_ospf_ism, - no_debug_ospf_ism_cmd, - "no debug ospf ism", - NO_STR - DEBUG_STR - OSPF_STR - "OSPF Interface State Machine") -{ - return no_debug_ospf_ism_common(vty, 0, argc, argv); -} - -ALIAS (no_debug_ospf_ism, - no_debug_ospf_ism_sub_cmd, - "no debug ospf ism (status|events|timers)", - NO_STR - "Debugging functions\n" - "OSPF information\n" - "OSPF Interface State Machine\n" - "ISM Status Information\n" - "ISM Event Information\n" - "ISM Timer Information\n") - -DEFUN (no_debug_ospf_instance_ism, - no_debug_ospf_instance_ism_cmd, - "no debug ospf <1-65535> ism", - NO_STR - DEBUG_STR - OSPF_STR - "Instance ID\n" - "OSPF Interface State Machine") -{ - u_short instance = 0; - - VTY_GET_INTEGER ("Instance", instance, argv[0]); - if (!ospf_lookup_instance (instance)) - return CMD_SUCCESS; - - return no_debug_ospf_ism_common(vty, 1, argc, argv); -} - -ALIAS (no_debug_ospf_instance_ism, - no_debug_ospf_instance_ism_sub_cmd, - "no debug ospf <1-65535> ism (status|events|timers)", - NO_STR - "Debugging functions\n" - "OSPF information\n" - "Instance ID\n" - "OSPF Interface State Machine\n" - "ISM Status Information\n" - "ISM Event Information\n" - "ISM Timer Information\n") - static int -debug_ospf_nsm_common (struct vty *vty, int arg_base, int argc, const char **argv) +debug_ospf_nsm_common (struct vty *vty, int arg_base, int argc, struct cmd_token **argv) { if (vty->node == CONFIG_NODE) { @@ -1275,11 +1029,11 @@ debug_ospf_nsm_common (struct vty *vty, int arg_base, int argc, const char **arg DEBUG_ON (nsm, NSM); else if (argc == arg_base + 1) { - if (strncmp (argv[arg_base + 0], "s", 1) == 0) + if (strmatch(argv[arg_base]->text, "status")) DEBUG_ON (nsm, NSM_STATUS); - else if (strncmp (argv[arg_base + 0], "e", 1) == 0) + else if (strmatch(argv[arg_base]->text, "events")) DEBUG_ON (nsm, NSM_EVENTS); - else if (strncmp (argv[arg_base + 0], "t", 1) == 0) + else if (strmatch(argv[arg_base]->text, "timers")) DEBUG_ON (nsm, NSM_TIMERS); } @@ -1291,11 +1045,11 @@ debug_ospf_nsm_common (struct vty *vty, int arg_base, int argc, const char **arg TERM_DEBUG_ON (nsm, NSM); else if (argc == arg_base + 1) { - if (strncmp (argv[arg_base + 0], "s", 1) == 0) + if (strmatch(argv[arg_base]->text, "status")) TERM_DEBUG_ON (nsm, NSM_STATUS); - else if (strncmp (argv[arg_base + 0], "e", 1) == 0) + else if (strmatch(argv[arg_base]->text, "events")) TERM_DEBUG_ON (nsm, NSM_EVENTS); - else if (strncmp (argv[arg_base + 0], "t", 1) == 0) + else if (strmatch(argv[arg_base]->text, "timers")) TERM_DEBUG_ON (nsm, NSM_TIMERS); } @@ -1304,66 +1058,54 @@ debug_ospf_nsm_common (struct vty *vty, int arg_base, int argc, const char **arg DEFUN (debug_ospf_nsm, debug_ospf_nsm_cmd, - "debug ospf nsm", - DEBUG_STR - OSPF_STR - "OSPF Neighbor State Machine\n") -{ - return debug_ospf_nsm_common (vty, 0, argc, argv); -} - -ALIAS (debug_ospf_nsm, - debug_ospf_nsm_sub_cmd, - "debug ospf nsm (status|events|timers)", + "debug ospf nsm [<status|events|timers>]", DEBUG_STR OSPF_STR "OSPF Neighbor State Machine\n" "NSM Status Information\n" "NSM Event Information\n" "NSM Timer Information\n") +{ + return debug_ospf_nsm_common (vty, 3, argc, argv); +} DEFUN (debug_ospf_instance_nsm, debug_ospf_instance_nsm_cmd, - "debug ospf <1-65535> nsm", + "debug ospf (1-65535) nsm [<status|events|timers>]", DEBUG_STR OSPF_STR "Instance ID\n" - "OSPF Neighbor State Machine\n") + "OSPF Neighbor State Machine\n" + "NSM Status Information\n" + "NSM Event Information\n" + "NSM Timer Information\n") { + int idx_number = 2; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; - return debug_ospf_nsm_common (vty, 1, argc, argv); + return debug_ospf_nsm_common (vty, 4, argc, argv); } -ALIAS (debug_ospf_instance_nsm, - debug_ospf_instance_nsm_sub_cmd, - "debug ospf <1-65535> nsm (status|events|timers)", - DEBUG_STR - OSPF_STR - "Instance ID\n" - "OSPF Neighbor State Machine\n" - "NSM Status Information\n" - "NSM Event Information\n" - "NSM Timer Information\n") static int -no_debug_ospf_nsm_common (struct vty *vty, int arg_base, int argc, const char **argv) +no_debug_ospf_nsm_common (struct vty *vty, int arg_base, int argc, struct cmd_token **argv) { + /* XXX qlyoung */ if (vty->node == CONFIG_NODE) { if (argc == arg_base + 0) DEBUG_OFF (nsm, NSM); else if (argc == arg_base + 1) { - if (strncmp (argv[arg_base + 0], "s", 1) == 0) + if (strmatch(argv[arg_base]->text, "status")) DEBUG_OFF (nsm, NSM_STATUS); - else if (strncmp (argv[arg_base + 0], "e", 1) == 0) + else if (strmatch(argv[arg_base]->text, "events")) DEBUG_OFF (nsm, NSM_EVENTS); - else if (strncmp (argv[arg_base + 0], "t", 1) == 0) + else if (strmatch(argv[arg_base]->text, "timers")) DEBUG_OFF (nsm, NSM_TIMERS); } @@ -1375,11 +1117,11 @@ no_debug_ospf_nsm_common (struct vty *vty, int arg_base, int argc, const char ** TERM_DEBUG_OFF (nsm, NSM); else if (argc == arg_base + 1) { - if (strncmp (argv[arg_base + 0], "s", 1) == 0) + if (strmatch(argv[arg_base]->text, "status")) TERM_DEBUG_OFF (nsm, NSM_STATUS); - else if (strncmp (argv[arg_base + 0], "e", 1) == 0) + else if (strmatch(argv[arg_base]->text, "events")) TERM_DEBUG_OFF (nsm, NSM_EVENTS); - else if (strncmp (argv[arg_base + 0], "t", 1) == 0) + else if (strmatch(argv[arg_base]->text, "timers")) TERM_DEBUG_OFF (nsm, NSM_TIMERS); } @@ -1388,59 +1130,44 @@ no_debug_ospf_nsm_common (struct vty *vty, int arg_base, int argc, const char ** DEFUN (no_debug_ospf_nsm, no_debug_ospf_nsm_cmd, - "no debug ospf nsm", + "no debug ospf nsm [<status|events|timers>]", NO_STR DEBUG_STR OSPF_STR - "OSPF Neighbor State Machine") -{ - return no_debug_ospf_nsm_common(vty, 0, argc, argv); -} - -ALIAS (no_debug_ospf_nsm, - no_debug_ospf_nsm_sub_cmd, - "no debug ospf nsm (status|events|timers)", - NO_STR - "Debugging functions\n" - "OSPF information\n" - "OSPF Interface State Machine\n" + "OSPF Neighbor State Machine\n" "NSM Status Information\n" "NSM Event Information\n" "NSM Timer Information\n") +{ + return no_debug_ospf_nsm_common(vty, 4, argc, argv); +} + DEFUN (no_debug_ospf_instance_nsm, no_debug_ospf_instance_nsm_cmd, - "no debug ospf <1-65535> nsm", + "no debug ospf (1-65535) nsm [<status|events|timers>]", NO_STR DEBUG_STR OSPF_STR "Instance ID\n" - "OSPF Neighbor State Machine") + "OSPF Neighbor State Machine\n" + "NSM Status Information\n" + "NSM Event Information\n" + "NSM Timer Information\n") { + int idx_number = 3; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; - return no_debug_ospf_nsm_common(vty, 1, argc, argv); + return no_debug_ospf_nsm_common(vty, 5, argc, argv); } -ALIAS (no_debug_ospf_instance_nsm, - no_debug_ospf_instance_nsm_sub_cmd, - "no debug ospf <1-65535> nsm (status|events|timers)", - NO_STR - "Debugging functions\n" - "OSPF information\n" - "Instance ID\n" - "OSPF Interface State Machine\n" - "NSM Status Information\n" - "NSM Event Information\n" - "NSM Timer Information\n") - static int -debug_ospf_lsa_common (struct vty *vty, int arg_base, int argc, const char **argv) +debug_ospf_lsa_common (struct vty *vty, int arg_base, int argc, struct cmd_token **argv) { if (vty->node == CONFIG_NODE) { @@ -1448,13 +1175,13 @@ debug_ospf_lsa_common (struct vty *vty, int arg_base, int argc, const char **arg DEBUG_ON (lsa, LSA); else if (argc == arg_base + 1) { - if (strncmp (argv[arg_base + 0], "g", 1) == 0) + if (strmatch(argv[arg_base]->text, "generate")) DEBUG_ON (lsa, LSA_GENERATE); - else if (strncmp (argv[arg_base + 0], "f", 1) == 0) + else if (strmatch(argv[arg_base]->text, "flooding")) DEBUG_ON (lsa, LSA_FLOODING); - else if (strncmp (argv[arg_base + 0], "i", 1) == 0) + else if (strmatch(argv[arg_base]->text, "install")) DEBUG_ON (lsa, LSA_INSTALL); - else if (strncmp (argv[arg_base + 0], "r", 1) == 0) + else if (strmatch(argv[arg_base]->text, "refresh")) DEBUG_ON (lsa, LSA_REFRESH); } @@ -1466,13 +1193,13 @@ debug_ospf_lsa_common (struct vty *vty, int arg_base, int argc, const char **arg TERM_DEBUG_ON (lsa, LSA); else if (argc == arg_base + 1) { - if (strncmp (argv[arg_base + 0], "g", 1) == 0) + if (strmatch(argv[arg_base]->text, "generate")) TERM_DEBUG_ON (lsa, LSA_GENERATE); - else if (strncmp (argv[arg_base + 0], "f", 1) == 0) + else if (strmatch(argv[arg_base]->text, "flooding")) TERM_DEBUG_ON (lsa, LSA_FLOODING); - else if (strncmp (argv[arg_base + 0], "i", 1) == 0) + else if (strmatch(argv[arg_base]->text, "install")) TERM_DEBUG_ON (lsa, LSA_INSTALL); - else if (strncmp (argv[arg_base + 0], "r", 1) == 0) + else if (strmatch(argv[arg_base]->text, "refresh")) TERM_DEBUG_ON (lsa, LSA_REFRESH); } @@ -1481,17 +1208,7 @@ debug_ospf_lsa_common (struct vty *vty, int arg_base, int argc, const char **arg DEFUN (debug_ospf_lsa, debug_ospf_lsa_cmd, - "debug ospf lsa", - DEBUG_STR - OSPF_STR - "OSPF Link State Advertisement\n") -{ - return debug_ospf_lsa_common(vty, 0, argc, argv); -} - -ALIAS (debug_ospf_lsa, - debug_ospf_lsa_sub_cmd, - "debug ospf lsa (generate|flooding|install|refresh)", + "debug ospf lsa [<generate|flooding|install|refresh>]", DEBUG_STR OSPF_STR "OSPF Link State Advertisement\n" @@ -1499,38 +1216,35 @@ ALIAS (debug_ospf_lsa, "LSA Flooding\n" "LSA Install/Delete\n" "LSA Refresh\n") +{ + return debug_ospf_lsa_common(vty, 3, argc, argv); +} DEFUN (debug_ospf_instance_lsa, debug_ospf_instance_lsa_cmd, - "debug ospf <1-65535> lsa", + "debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]", DEBUG_STR OSPF_STR "Instance ID\n" - "OSPF Link State Advertisement\n") + "OSPF Link State Advertisement\n" + "LSA Generation\n" + "LSA Flooding\n" + "LSA Install/Delete\n" + "LSA Refresh\n") { + int idx_number = 2; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; - return debug_ospf_lsa_common(vty, 1, argc, argv); + return debug_ospf_lsa_common(vty, 4, argc, argv); } -ALIAS (debug_ospf_instance_lsa, - debug_ospf_instance_lsa_sub_cmd, - "debug ospf <1-65535> lsa (generate|flooding|install|refresh)", - DEBUG_STR - OSPF_STR - "Instance ID\n" - "OSPF Link State Advertisement\n" - "LSA Generation\n" - "LSA Flooding\n" - "LSA Install/Delete\n" - "LSA Refresh\n") static int -no_debug_ospf_lsa_common (struct vty *vty, int arg_base, int argc, const char **argv) +no_debug_ospf_lsa_common (struct vty *vty, int arg_base, int argc, struct cmd_token **argv) { if (vty->node == CONFIG_NODE) { @@ -1538,13 +1252,13 @@ no_debug_ospf_lsa_common (struct vty *vty, int arg_base, int argc, const char ** DEBUG_OFF (lsa, LSA); else if (argc == arg_base + 1) { - if (strncmp (argv[arg_base + 0], "g", 1) == 0) + if (strmatch(argv[arg_base]->text, "generate")) DEBUG_OFF (lsa, LSA_GENERATE); - else if (strncmp (argv[arg_base + 0], "f", 1) == 0) + else if (strmatch(argv[arg_base]->text, "flooding")) DEBUG_OFF (lsa, LSA_FLOODING); - else if (strncmp (argv[arg_base + 0], "i", 1) == 0) + else if (strmatch(argv[arg_base]->text, "install")) DEBUG_OFF (lsa, LSA_INSTALL); - else if (strncmp (argv[arg_base + 0], "r", 1) == 0) + else if (strmatch(argv[arg_base]->text, "refresh")) DEBUG_OFF (lsa, LSA_REFRESH); } @@ -1556,13 +1270,13 @@ no_debug_ospf_lsa_common (struct vty *vty, int arg_base, int argc, const char ** TERM_DEBUG_OFF (lsa, LSA); else if (argc == arg_base + 1) { - if (strncmp (argv[arg_base + 0], "g", 1) == 0) + if (strmatch(argv[arg_base]->text, "generate")) TERM_DEBUG_OFF (lsa, LSA_GENERATE); - else if (strncmp (argv[arg_base + 0], "f", 1) == 0) + else if (strmatch(argv[arg_base]->text, "flooding")) TERM_DEBUG_OFF (lsa, LSA_FLOODING); - else if (strncmp (argv[arg_base + 0], "i", 1) == 0) + else if (strmatch(argv[arg_base]->text, "install")) TERM_DEBUG_OFF (lsa, LSA_INSTALL); - else if (strncmp (argv[arg_base + 0], "r", 1) == 0) + else if (strmatch(argv[arg_base]->text, "refresh")) TERM_DEBUG_OFF (lsa, LSA_REFRESH); } @@ -1571,18 +1285,7 @@ no_debug_ospf_lsa_common (struct vty *vty, int arg_base, int argc, const char ** DEFUN (no_debug_ospf_lsa, no_debug_ospf_lsa_cmd, - "no debug ospf lsa", - NO_STR - DEBUG_STR - OSPF_STR - "OSPF Link State Advertisement\n") -{ - return no_debug_ospf_lsa_common (vty, 0, argc, argv); -} - -ALIAS (no_debug_ospf_lsa, - no_debug_ospf_lsa_sub_cmd, - "no debug ospf lsa (generate|flooding|install|refresh)", + "no debug ospf lsa [<generate|flooding|install|refresh>]", NO_STR DEBUG_STR OSPF_STR @@ -1591,41 +1294,36 @@ ALIAS (no_debug_ospf_lsa, "LSA Flooding\n" "LSA Install/Delete\n" "LSA Refres\n") +{ + return no_debug_ospf_lsa_common (vty, 4, argc, argv); +} DEFUN (no_debug_ospf_instance_lsa, no_debug_ospf_instance_lsa_cmd, - "no debug ospf <1-65535> lsa", + "no debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]", NO_STR DEBUG_STR OSPF_STR "Instance ID\n" - "OSPF Link State Advertisement\n") + "OSPF Link State Advertisement\n" + "LSA Generation\n" + "LSA Flooding\n" + "LSA Install/Delete\n" + "LSA Refres\n") { + int idx_number = 3; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; - return no_debug_ospf_lsa_common (vty, 1, argc, argv); + return no_debug_ospf_lsa_common (vty, 5, argc, argv); } -ALIAS (no_debug_ospf_instance_lsa, - no_debug_ospf_instance_lsa_sub_cmd, - "no debug ospf <1-65535> lsa (generate|flooding|install|refresh)", - NO_STR - DEBUG_STR - OSPF_STR - "Instance ID\n" - "OSPF Link State Advertisement\n" - "LSA Generation\n" - "LSA Flooding\n" - "LSA Install/Delete\n" - "LSA Refres\n") - static int -debug_ospf_zebra_common (struct vty *vty, int arg_base, int argc, const char **argv) +debug_ospf_zebra_common (struct vty *vty, int arg_base, int argc, struct cmd_token **argv) { if (vty->node == CONFIG_NODE) { @@ -1633,9 +1331,9 @@ debug_ospf_zebra_common (struct vty *vty, int arg_base, int argc, const char **a DEBUG_ON (zebra, ZEBRA); else if (argc == arg_base + 1) { - if (strncmp (argv[arg_base + 0], "i", 1) == 0) + if (strmatch(argv[arg_base]->text, "interface")) DEBUG_ON (zebra, ZEBRA_INTERFACE); - else if (strncmp (argv[arg_base + 0], "r", 1) == 0) + else if (strmatch(argv[arg_base]->text, "redistribute")) DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE); } @@ -1647,9 +1345,9 @@ debug_ospf_zebra_common (struct vty *vty, int arg_base, int argc, const char **a TERM_DEBUG_ON (zebra, ZEBRA); else if (argc == arg_base + 1) { - if (strncmp (argv[arg_base + 0], "i", 1) == 0) + if (strmatch(argv[arg_base]->text, "interface")) TERM_DEBUG_ON (zebra, ZEBRA_INTERFACE); - else if (strncmp (argv[arg_base + 0], "r", 1) == 0) + else if (strmatch(argv[arg_base]->text, "redistribute")) TERM_DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE); } @@ -1658,53 +1356,40 @@ debug_ospf_zebra_common (struct vty *vty, int arg_base, int argc, const char **a DEFUN (debug_ospf_zebra, debug_ospf_zebra_cmd, - "debug ospf zebra", - DEBUG_STR - OSPF_STR - "OSPF Zebra information\n") -{ - return debug_ospf_zebra_common(vty, 0, argc, argv); -} - -ALIAS (debug_ospf_zebra, - debug_ospf_zebra_sub_cmd, - "debug ospf zebra (interface|redistribute)", + "debug ospf zebra [<interface|redistribute>]", DEBUG_STR OSPF_STR "OSPF Zebra information\n" "Zebra interface\n" "Zebra redistribute\n") +{ + return debug_ospf_zebra_common(vty, 3, argc, argv); +} DEFUN (debug_ospf_instance_zebra, debug_ospf_instance_zebra_cmd, - "debug ospf <1-65535> zebra", + "debug ospf (1-65535) zebra [<interface|redistribute>]", DEBUG_STR OSPF_STR "Instance ID\n" - "OSPF Zebra information\n") + "OSPF Zebra information\n" + "Zebra interface\n" + "Zebra redistribute\n") { + int idx_number = 2; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; - return debug_ospf_zebra_common(vty, 1, argc, argv); + return debug_ospf_zebra_common(vty, 4, argc, argv); } -ALIAS (debug_ospf_instance_zebra, - debug_ospf_instance_zebra_sub_cmd, - "debug ospf <1-65535> zebra (interface|redistribute)", - DEBUG_STR - OSPF_STR - "Instance ID\n" - "OSPF Zebra information\n" - "Zebra interface\n" - "Zebra redistribute\n") static int no_debug_ospf_zebra_common(struct vty *vty, int arg_base, int argc, - const char **argv) + struct cmd_token **argv) { if (vty->node == CONFIG_NODE) { @@ -1712,9 +1397,9 @@ no_debug_ospf_zebra_common(struct vty *vty, int arg_base, int argc, DEBUG_OFF (zebra, ZEBRA); else if (argc == arg_base + 1) { - if (strncmp (argv[arg_base + 0], "i", 1) == 0) + if (strmatch(argv[arg_base]->text, "interface")) DEBUG_OFF (zebra, ZEBRA_INTERFACE); - else if (strncmp (argv[arg_base + 0], "r", 1) == 0) + else if (strmatch(argv[arg_base]->text, "redistribute")) DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE); } @@ -1726,9 +1411,9 @@ no_debug_ospf_zebra_common(struct vty *vty, int arg_base, int argc, TERM_DEBUG_OFF (zebra, ZEBRA); else if (argc == arg_base + 1) { - if (strncmp (argv[arg_base + 0], "i", 1) == 0) + if (strmatch(argv[arg_base]->text, "interface")) TERM_DEBUG_OFF (zebra, ZEBRA_INTERFACE); - else if (strncmp (argv[arg_base + 0], "r", 1) == 0) + else if (strmatch(argv[arg_base]->text, "redistribute")) TERM_DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE); } @@ -1737,53 +1422,38 @@ no_debug_ospf_zebra_common(struct vty *vty, int arg_base, int argc, DEFUN (no_debug_ospf_zebra, no_debug_ospf_zebra_cmd, - "no debug ospf zebra", - NO_STR - DEBUG_STR - OSPF_STR - "OSPF Zebra information\n") -{ - return no_debug_ospf_zebra_common(vty, 0, argc, argv); -} - -ALIAS (no_debug_ospf_zebra, - no_debug_ospf_zebra_sub_cmd, - "no debug ospf zebra (interface|redistribute)", + "no debug ospf zebra [<interface|redistribute>]", NO_STR DEBUG_STR OSPF_STR "OSPF Zebra information\n" "Zebra interface\n" "Zebra redistribute\n") +{ + return no_debug_ospf_zebra_common(vty, 4, argc, argv); +} DEFUN (no_debug_ospf_instance_zebra, no_debug_ospf_instance_zebra_cmd, - "no debug ospf <1-65535> zebra", + "no debug ospf (1-65535) zebra [<interface|redistribute>]", NO_STR DEBUG_STR OSPF_STR "Instance ID\n" - "OSPF Zebra information\n") + "OSPF Zebra information\n" + "Zebra interface\n" + "Zebra redistribute\n") { + int idx_number = 3; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; - return no_debug_ospf_zebra_common(vty, 1, argc, argv); + return no_debug_ospf_zebra_common(vty, 5, argc, argv); } -ALIAS (no_debug_ospf_instance_zebra, - no_debug_ospf_instance_zebra_sub_cmd, - "no debug ospf <1-65535> zebra (interface|redistribute)", - NO_STR - DEBUG_STR - OSPF_STR - "Instance ID\n" - "OSPF Zebra information\n" - "Zebra interface\n" - "Zebra redistribute\n") DEFUN (debug_ospf_event, @@ -1815,15 +1485,16 @@ DEFUN (no_debug_ospf_event, DEFUN (debug_ospf_instance_event, debug_ospf_instance_event_cmd, - "debug ospf <1-65535> event", + "debug ospf (1-65535) event", DEBUG_STR OSPF_STR "Instance ID\n" "OSPF event information\n") { + int idx_number = 2; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; @@ -1835,16 +1506,17 @@ DEFUN (debug_ospf_instance_event, DEFUN (no_debug_ospf_instance_event, no_debug_ospf_instance_event_cmd, - "no debug ospf <1-65535> event", + "no debug ospf (1-65535) event", NO_STR DEBUG_STR OSPF_STR "Instance ID\n" "OSPF event information\n") { + int idx_number = 3; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; @@ -1883,15 +1555,16 @@ DEFUN (no_debug_ospf_nssa, DEFUN (debug_ospf_instance_nssa, debug_ospf_instance_nssa_cmd, - "debug ospf <1-65535> nssa", + "debug ospf (1-65535) nssa", DEBUG_STR OSPF_STR "Instance ID\n" "OSPF nssa information\n") { + int idx_number = 2; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; @@ -1903,16 +1576,17 @@ DEFUN (debug_ospf_instance_nssa, DEFUN (no_debug_ospf_instance_nssa, no_debug_ospf_instance_nssa_cmd, - "no debug ospf <1-65535> nssa", + "no debug ospf (1-65535) nssa", NO_STR DEBUG_STR OSPF_STR "Instance ID\n" "OSPF nssa information\n") { + int idx_number = 3; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; @@ -2124,16 +1798,17 @@ DEFUN (show_debugging_ospf, DEFUN (show_debugging_ospf_instance, show_debugging_ospf_instance_cmd, - "show debugging ospf <1-65535>", + "show debugging ospf (1-65535)", SHOW_STR DEBUG_STR OSPF_STR "Instance ID\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL ) return CMD_SUCCESS; @@ -2286,116 +1961,67 @@ debug_init () install_node (&debug_node, config_write_debug); install_element (ENABLE_NODE, &show_debugging_ospf_cmd); - install_element (ENABLE_NODE, &debug_ospf_packet_send_recv_detail_cmd); - install_element (ENABLE_NODE, &debug_ospf_packet_send_recv_cmd); - install_element (ENABLE_NODE, &debug_ospf_packet_all_cmd); - install_element (ENABLE_NODE, &debug_ospf_ism_sub_cmd); install_element (ENABLE_NODE, &debug_ospf_ism_cmd); - install_element (ENABLE_NODE, &debug_ospf_nsm_sub_cmd); install_element (ENABLE_NODE, &debug_ospf_nsm_cmd); - install_element (ENABLE_NODE, &debug_ospf_lsa_sub_cmd); install_element (ENABLE_NODE, &debug_ospf_lsa_cmd); - install_element (ENABLE_NODE, &debug_ospf_zebra_sub_cmd); install_element (ENABLE_NODE, &debug_ospf_zebra_cmd); install_element (ENABLE_NODE, &debug_ospf_event_cmd); install_element (ENABLE_NODE, &debug_ospf_nssa_cmd); install_element (ENABLE_NODE, &debug_ospf_te_cmd); - install_element (ENABLE_NODE, &no_debug_ospf_packet_send_recv_detail_cmd); - install_element (ENABLE_NODE, &no_debug_ospf_packet_send_recv_cmd); - install_element (ENABLE_NODE, &no_debug_ospf_packet_all_cmd); - install_element (ENABLE_NODE, &no_debug_ospf_ism_sub_cmd); install_element (ENABLE_NODE, &no_debug_ospf_ism_cmd); - install_element (ENABLE_NODE, &no_debug_ospf_nsm_sub_cmd); install_element (ENABLE_NODE, &no_debug_ospf_nsm_cmd); - install_element (ENABLE_NODE, &no_debug_ospf_lsa_sub_cmd); install_element (ENABLE_NODE, &no_debug_ospf_lsa_cmd); - install_element (ENABLE_NODE, &no_debug_ospf_zebra_sub_cmd); install_element (ENABLE_NODE, &no_debug_ospf_zebra_cmd); install_element (ENABLE_NODE, &no_debug_ospf_event_cmd); install_element (ENABLE_NODE, &no_debug_ospf_nssa_cmd); install_element (ENABLE_NODE, &no_debug_ospf_te_cmd); install_element (ENABLE_NODE, &show_debugging_ospf_instance_cmd); - install_element (ENABLE_NODE, &debug_ospf_instance_packet_send_recv_detail_cmd); - install_element (ENABLE_NODE, &debug_ospf_instance_packet_send_recv_cmd); - install_element (ENABLE_NODE, &debug_ospf_instance_packet_all_cmd); - install_element (ENABLE_NODE, &debug_ospf_instance_ism_sub_cmd); - install_element (ENABLE_NODE, &debug_ospf_instance_ism_cmd); - install_element (ENABLE_NODE, &debug_ospf_instance_nsm_sub_cmd); + install_element (ENABLE_NODE, &debug_ospf_packet_cmd); + install_element (ENABLE_NODE, &no_debug_ospf_packet_cmd); + install_element (ENABLE_NODE, &debug_ospf_ism_cmd); + install_element (ENABLE_NODE, &no_debug_ospf_ism_cmd); + install_element (ENABLE_NODE, &debug_ospf_instance_nsm_cmd); - install_element (ENABLE_NODE, &debug_ospf_instance_lsa_sub_cmd); install_element (ENABLE_NODE, &debug_ospf_instance_lsa_cmd); - install_element (ENABLE_NODE, &debug_ospf_instance_zebra_sub_cmd); install_element (ENABLE_NODE, &debug_ospf_instance_zebra_cmd); install_element (ENABLE_NODE, &debug_ospf_instance_event_cmd); install_element (ENABLE_NODE, &debug_ospf_instance_nssa_cmd); - install_element (ENABLE_NODE, &no_debug_ospf_instance_packet_send_recv_detail_cmd); - install_element (ENABLE_NODE, &no_debug_ospf_instance_packet_send_recv_cmd); - install_element (ENABLE_NODE, &no_debug_ospf_instance_packet_all_cmd); - install_element (ENABLE_NODE, &no_debug_ospf_instance_ism_sub_cmd); - install_element (ENABLE_NODE, &no_debug_ospf_instance_ism_cmd); - install_element (ENABLE_NODE, &no_debug_ospf_instance_nsm_sub_cmd); install_element (ENABLE_NODE, &no_debug_ospf_instance_nsm_cmd); - install_element (ENABLE_NODE, &no_debug_ospf_instance_lsa_sub_cmd); install_element (ENABLE_NODE, &no_debug_ospf_instance_lsa_cmd); - install_element (ENABLE_NODE, &no_debug_ospf_instance_zebra_sub_cmd); install_element (ENABLE_NODE, &no_debug_ospf_instance_zebra_cmd); install_element (ENABLE_NODE, &no_debug_ospf_instance_event_cmd); install_element (ENABLE_NODE, &no_debug_ospf_instance_nssa_cmd); install_element (ENABLE_NODE, &no_debug_ospf_cmd); - install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_detail_cmd); - install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_cmd); - install_element (CONFIG_NODE, &debug_ospf_packet_all_cmd); - install_element (CONFIG_NODE, &debug_ospf_ism_sub_cmd); + + + install_element (CONFIG_NODE, &debug_ospf_packet_cmd); + install_element (CONFIG_NODE, &no_debug_ospf_packet_cmd); install_element (CONFIG_NODE, &debug_ospf_ism_cmd); - install_element (CONFIG_NODE, &debug_ospf_nsm_sub_cmd); + install_element (CONFIG_NODE, &no_debug_ospf_ism_cmd); + install_element (CONFIG_NODE, &debug_ospf_nsm_cmd); - install_element (CONFIG_NODE, &debug_ospf_lsa_sub_cmd); install_element (CONFIG_NODE, &debug_ospf_lsa_cmd); - install_element (CONFIG_NODE, &debug_ospf_zebra_sub_cmd); install_element (CONFIG_NODE, &debug_ospf_zebra_cmd); install_element (CONFIG_NODE, &debug_ospf_event_cmd); install_element (CONFIG_NODE, &debug_ospf_nssa_cmd); install_element (CONFIG_NODE, &debug_ospf_te_cmd); - install_element (CONFIG_NODE, &no_debug_ospf_packet_send_recv_detail_cmd); - install_element (CONFIG_NODE, &no_debug_ospf_packet_send_recv_cmd); - install_element (CONFIG_NODE, &no_debug_ospf_packet_all_cmd); - install_element (CONFIG_NODE, &no_debug_ospf_ism_sub_cmd); install_element (CONFIG_NODE, &no_debug_ospf_ism_cmd); - install_element (CONFIG_NODE, &no_debug_ospf_nsm_sub_cmd); install_element (CONFIG_NODE, &no_debug_ospf_nsm_cmd); - install_element (CONFIG_NODE, &no_debug_ospf_lsa_sub_cmd); install_element (CONFIG_NODE, &no_debug_ospf_lsa_cmd); - install_element (CONFIG_NODE, &no_debug_ospf_zebra_sub_cmd); install_element (CONFIG_NODE, &no_debug_ospf_zebra_cmd); install_element (CONFIG_NODE, &no_debug_ospf_event_cmd); install_element (CONFIG_NODE, &no_debug_ospf_nssa_cmd); install_element (CONFIG_NODE, &no_debug_ospf_te_cmd); - install_element (CONFIG_NODE, &debug_ospf_instance_packet_send_recv_detail_cmd); - install_element (CONFIG_NODE, &debug_ospf_instance_packet_send_recv_cmd); - install_element (CONFIG_NODE, &debug_ospf_instance_packet_all_cmd); - install_element (CONFIG_NODE, &debug_ospf_instance_ism_sub_cmd); - install_element (CONFIG_NODE, &debug_ospf_instance_ism_cmd); - install_element (CONFIG_NODE, &debug_ospf_instance_nsm_sub_cmd); install_element (CONFIG_NODE, &debug_ospf_instance_nsm_cmd); - install_element (CONFIG_NODE, &debug_ospf_instance_lsa_sub_cmd); install_element (CONFIG_NODE, &debug_ospf_instance_lsa_cmd); - install_element (CONFIG_NODE, &debug_ospf_instance_zebra_sub_cmd); install_element (CONFIG_NODE, &debug_ospf_instance_zebra_cmd); install_element (CONFIG_NODE, &debug_ospf_instance_event_cmd); install_element (CONFIG_NODE, &debug_ospf_instance_nssa_cmd); - install_element (CONFIG_NODE, &no_debug_ospf_instance_packet_send_recv_detail_cmd); - install_element (CONFIG_NODE, &no_debug_ospf_instance_packet_send_recv_cmd); - install_element (CONFIG_NODE, &no_debug_ospf_instance_packet_all_cmd); - install_element (CONFIG_NODE, &no_debug_ospf_instance_ism_sub_cmd); - install_element (CONFIG_NODE, &no_debug_ospf_instance_ism_cmd); - install_element (CONFIG_NODE, &no_debug_ospf_instance_nsm_sub_cmd); install_element (CONFIG_NODE, &no_debug_ospf_instance_nsm_cmd); - install_element (CONFIG_NODE, &no_debug_ospf_instance_lsa_sub_cmd); install_element (CONFIG_NODE, &no_debug_ospf_instance_lsa_cmd); - install_element (CONFIG_NODE, &no_debug_ospf_instance_zebra_sub_cmd); install_element (CONFIG_NODE, &no_debug_ospf_instance_zebra_cmd); install_element (CONFIG_NODE, &no_debug_ospf_instance_event_cmd); install_element (CONFIG_NODE, &no_debug_ospf_instance_nssa_cmd); diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c index c6b55b0746..17cc1f66c2 100644 --- a/ospfd/ospf_nsm.c +++ b/ospfd/ospf_nsm.c @@ -33,6 +33,7 @@ #include "stream.h" #include "table.h" #include "log.h" +#include "command.h" #include "ospfd/ospfd.h" #include "ospfd/ospf_interface.h" diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c index 33980b35c6..a1981be86d 100644 --- a/ospfd/ospf_opaque.c +++ b/ospfd/ospf_opaque.c @@ -786,11 +786,14 @@ DEFUN (capability_opaque, return CMD_SUCCESS; } -ALIAS (capability_opaque, - ospf_opaque_capable_cmd, +DEFUN (ospf_opaque, + ospf_opaque_cmd, "ospf opaque-lsa", "OSPF specific commands\n" "Enable the Opaque-LSA capability (rfc2370)\n") +{ + return capability_opaque (self, vty, argc, argv); +} DEFUN (no_capability_opaque, no_capability_opaque_cmd, @@ -816,20 +819,23 @@ DEFUN (no_capability_opaque, return CMD_SUCCESS; } -ALIAS (no_capability_opaque, - no_ospf_opaque_capable_cmd, +DEFUN (no_ospf_opaque, + no_ospf_opaque_cmd, "no ospf opaque-lsa", NO_STR "OSPF specific commands\n" - "Disable the Opaque-LSA capability (rfc2370)\n") + "Enable the Opaque-LSA capability (rfc2370)\n") +{ + return no_capability_opaque (self, vty, argc, argv); +} static void ospf_opaque_register_vty (void) { install_element (OSPF_NODE, &capability_opaque_cmd); install_element (OSPF_NODE, &no_capability_opaque_cmd); - install_element (OSPF_NODE, &ospf_opaque_capable_cmd); - install_element (OSPF_NODE, &no_ospf_opaque_capable_cmd); + install_element (OSPF_NODE, &ospf_opaque_cmd); + install_element (OSPF_NODE, &no_ospf_opaque_cmd); return; } diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c index 65659709b2..28957e04c6 100644 --- a/ospfd/ospf_ri.c +++ b/ospfd/ospf_ri.c @@ -1176,11 +1176,14 @@ ospf_router_info_config_write_router (struct vty *vty) DEFUN (router_info, router_info_area_cmd, - "router-info area A.B.C.D", + "router-info <as|area A.B.C.D>", OSPF_RI_STR + "Enable the Router Information functionality with AS flooding scope\n" "Enable the Router Information functionality with Area flooding scope\n" "OSPF area ID in IP format") { + int idx_ipv4 = 2; + char *area = (argc == 3) ? argv[idx_ipv4]->arg : NULL; u_int8_t scope; @@ -1188,14 +1191,9 @@ DEFUN (router_info, return CMD_SUCCESS; /* Check and get Area value if present */ - if (argc == 1) + if (area) { - if (!inet_aton (argv[0], &OspfRI.area_id)) - { - vty_out (vty, "Please specify Router Info Area by A.B.C.D%s", - VTY_NEWLINE); - return CMD_WARNING; - } + inet_aton (area, &OspfRI.area_id); scope = OSPF_OPAQUE_AREA_LSA; } else @@ -1236,11 +1234,6 @@ DEFUN (router_info, } -ALIAS (router_info, - router_info_as_cmd, - "router-info as", - OSPF_RI_STR - "Enable the Router Information functionality with AS flooding scope\n") DEFUN (no_router_info, no_router_info_cmd, @@ -1285,13 +1278,14 @@ DEFUN (pce_address, "Stable IP address of the PCE\n" "PCE address in IPv4 address format\n") { + int idx_ipv4 = 2; struct in_addr value; struct ospf_pce_info *pi = &OspfRI.pce_info; if (!ospf_ri_enabled (vty)) return CMD_WARNING; - if (!inet_aton (argv[0], &value)) + if (!inet_aton (argv[idx_ipv4]->arg, &value)) { vty_out (vty, "Please specify PCE Address by A.B.C.D%s", VTY_NEWLINE); return CMD_WARNING; @@ -1313,7 +1307,7 @@ DEFUN (pce_address, DEFUN (no_pce_address, no_pce_address_cmd, - "no pce address {A.B.C.D}", + "no pce address [A.B.C.D]", NO_STR PCE_STR "Disable PCE address\n" @@ -1336,13 +1330,14 @@ DEFUN (pce_path_scope, "Path scope visibilities of the PCE for path computation\n" "32-bit Hexadecimal value\n") { + int idx_bitpattern = 2; uint32_t scope; struct ospf_pce_info *pi = &OspfRI.pce_info; if (!ospf_ri_enabled (vty)) return CMD_WARNING; - if (sscanf (argv[0], "0x%x", &scope) != 1) + if (sscanf (argv[idx_bitpattern]->arg, "0x%x", &scope) != 1) { vty_out (vty, "pce_path_scope: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -1363,7 +1358,7 @@ DEFUN (pce_path_scope, DEFUN (no_pce_path_scope, no_pce_path_scope_cmd, - "no pce scope {BITPATTERN}", + "no pce scope [BITPATTERN]", NO_STR PCE_STR "Disable PCE path scope\n" @@ -1381,12 +1376,13 @@ DEFUN (no_pce_path_scope, DEFUN (pce_domain, pce_domain_cmd, - "pce domain as <0-65535>", + "pce domain as (0-65535)", PCE_STR "Configure PCE domain AS number\n" "AS number where the PCE as visibilities for path computation\n" "AS number in decimal <0-65535>\n") { + int idx_number = 3; uint32_t as; struct ospf_pce_info *pce = &OspfRI.pce_info; @@ -1396,7 +1392,7 @@ DEFUN (pce_domain, if (!ospf_ri_enabled (vty)) return CMD_WARNING; - if (sscanf (argv[0], "%d", &as) != 1) + if (sscanf (argv[idx_number]->arg, "%d", &as) != 1) { vty_out (vty, "pce_domain: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -1422,18 +1418,19 @@ DEFUN (pce_domain, DEFUN (no_pce_domain, no_pce_domain_cmd, - "no pce domain as <0-65535>", + "no pce domain as (0-65535)", NO_STR PCE_STR "Disable PCE domain AS number\n" "AS number where the PCE as visibilities for path computation\n" "AS number in decimal <0-65535>\n") { + int idx_number = 4; uint32_t as; struct ospf_pce_info *pce = &OspfRI.pce_info; - if (sscanf (argv[0], "%d", &as) != 1) + if (sscanf (argv[idx_number]->arg, "%d", &as) != 1) { vty_out (vty, "no_pce_domain: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -1452,12 +1449,13 @@ DEFUN (no_pce_domain, DEFUN (pce_neigbhor, pce_neighbor_cmd, - "pce neighbor as <0-65535>", + "pce neighbor as (0-65535)", PCE_STR "Configure PCE neighbor domain AS number\n" "AS number of PCE neighbors\n" "AS number in decimal <0-65535>\n") { + int idx_number = 3; uint32_t as; struct ospf_pce_info *pce = &OspfRI.pce_info; @@ -1467,7 +1465,7 @@ DEFUN (pce_neigbhor, if (!ospf_ri_enabled (vty)) return CMD_WARNING; - if (sscanf (argv[0], "%d", &as) != 1) + if (sscanf (argv[idx_number]->arg, "%d", &as) != 1) { vty_out (vty, "pce_neighbor: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -1493,18 +1491,19 @@ DEFUN (pce_neigbhor, DEFUN (no_pce_neighbor, no_pce_neighbor_cmd, - "no pce neighbor as <0-65535>", + "no pce neighbor as (0-65535)", NO_STR PCE_STR "Disable PCE neighbor AS number\n" "AS number of PCE neighbor\n" "AS number in decimal <0-65535>\n") { + int idx_number = 4; uint32_t as; struct ospf_pce_info *pce = &OspfRI.pce_info; - if (sscanf (argv[0], "%d", &as) != 1) + if (sscanf (argv[idx_number]->arg, "%d", &as) != 1) { vty_out (vty, "no_pce_neighbor: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -1528,6 +1527,7 @@ DEFUN (pce_cap_flag, "Capabilities of the PCE for path computation\n" "32-bit Hexadecimal value\n") { + int idx_bitpattern = 2; uint32_t cap; struct ospf_pce_info *pce = &OspfRI.pce_info; @@ -1535,7 +1535,7 @@ DEFUN (pce_cap_flag, if (!ospf_ri_enabled (vty)) return CMD_WARNING; - if (sscanf (argv[0], "0x%x", &cap) != 1) + if (sscanf (argv[idx_bitpattern]->arg, "0x%x", &cap) != 1) { vty_out (vty, "pce_cap_flag: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -1652,7 +1652,6 @@ ospf_router_info_register_vty (void) install_element (VIEW_NODE, &show_ip_ospf_router_info_pce_cmd); install_element (OSPF_NODE, &router_info_area_cmd); - install_element (OSPF_NODE, &router_info_as_cmd); install_element (OSPF_NODE, &no_router_info_cmd); install_element (OSPF_NODE, &pce_address_cmd); install_element (OSPF_NODE, &no_pce_address_cmd); diff --git a/ospfd/ospf_routemap.c b/ospfd/ospf_routemap.c index f1483885c0..4166aabe21 100644 --- a/ospfd/ospf_routemap.c +++ b/ospfd/ospf_routemap.c @@ -27,6 +27,7 @@ #include "memory.h" #include "prefix.h" #include "table.h" +#include "vty.h" #include "routemap.h" #include "command.h" #include "log.h" @@ -163,53 +164,6 @@ ospf_route_match_add (struct vty *vty, struct route_map_index *index, return CMD_SUCCESS; } -static int -ospf_route_set_add (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_add_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% OSPF Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% OSPF Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - - return CMD_SUCCESS; -} - -/* Delete rip route map rule. */ -static int -ospf_route_set_delete (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_delete_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% OSPF Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% OSPF Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - - return CMD_SUCCESS; -} - /* `match ip netxthop ' */ /* Match function return 1 if match is success else return zero. */ static route_map_result_t @@ -627,7 +581,7 @@ static struct route_map_rule_cmd route_set_tag_cmd = DEFUN (match_ip_nexthop, match_ip_nexthop_cmd, - "match ip next-hop (<1-199>|<1300-2699>|WORD)", + "match ip next-hop <(1-199)|(1300-2699)|WORD>", MATCH_STR IP_STR "Match next-hop address of route\n" @@ -635,26 +589,13 @@ DEFUN (match_ip_nexthop, "IP access-list number (expanded range)\n" "IP access-list name\n") { - return ospf_route_match_add (vty, vty->index, "ip next-hop", argv[0]); + int idx_acl = 3; + return ospf_route_match_add (vty, vty->index, "ip next-hop", argv[idx_acl]->arg); } DEFUN (no_match_ip_nexthop, no_match_ip_nexthop_cmd, - "no match ip next-hop", - NO_STR - MATCH_STR - IP_STR - "Match next-hop address of route\n") -{ - if (argc == 0) - return ospf_route_match_delete (vty, vty->index, "ip next-hop", NULL); - - return ospf_route_match_delete (vty, vty->index, "ip next-hop", argv[0]); -} - -ALIAS (no_match_ip_nexthop, - no_match_ip_nexthop_val_cmd, - "no match ip next-hop (<1-199>|<1300-2699>|WORD)", + "no match ip next-hop [<(1-199)|(1300-2699)|WORD>]", NO_STR MATCH_STR IP_STR @@ -662,285 +603,36 @@ ALIAS (no_match_ip_nexthop, "IP access-list number\n" "IP access-list number (expanded range)\n" "IP access-list name\n") - -DEFUN (match_ip_next_hop_prefix_list, - match_ip_next_hop_prefix_list_cmd, - "match ip next-hop prefix-list WORD", - MATCH_STR - IP_STR - "Match next-hop address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") { - return ospf_route_match_add (vty, vty->index, "ip next-hop prefix-list", - argv[0]); + char *al = (argc == 5) ? argv[4]->arg : NULL; + return ospf_route_match_delete (vty, vty->index, "ip next-hop", al); } -DEFUN (no_match_ip_next_hop_prefix_list, - no_match_ip_next_hop_prefix_list_cmd, - "no match ip next-hop prefix-list", - NO_STR - MATCH_STR - IP_STR - "Match next-hop address of route\n" - "Match entries of prefix-lists\n") -{ - if (argc == 0) - return ospf_route_match_delete (vty, vty->index, "ip next-hop prefix-list", - NULL); - return ospf_route_match_delete (vty, vty->index, "ip next-hop prefix-list", - argv[0]); -} - -ALIAS (no_match_ip_next_hop_prefix_list, - no_match_ip_next_hop_prefix_list_val_cmd, - "no match ip next-hop prefix-list WORD", - NO_STR - MATCH_STR - IP_STR - "Match next-hop address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") - -DEFUN (match_ip_address, - match_ip_address_cmd, - "match ip address (<1-199>|<1300-2699>|WORD)", - MATCH_STR - IP_STR - "Match address of route\n" - "IP access-list number\n" - "IP access-list number (expanded range)\n" - "IP access-list name\n") -{ - return ospf_route_match_add (vty, vty->index, "ip address", argv[0]); -} - -DEFUN (no_match_ip_address, - no_match_ip_address_cmd, - "no match ip address", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n") -{ - if (argc == 0) - return ospf_route_match_delete (vty, vty->index, "ip address", NULL); - - return ospf_route_match_delete (vty, vty->index, "ip address", argv[0]); -} - -ALIAS (no_match_ip_address, - no_match_ip_address_val_cmd, - "no match ip address (<1-199>|<1300-2699>|WORD)", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n" - "IP access-list number\n" - "IP access-list number (expanded range)\n" - "IP access-list name\n") - -DEFUN (match_ip_address_prefix_list, - match_ip_address_prefix_list_cmd, - "match ip address prefix-list WORD", - MATCH_STR - IP_STR - "Match address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") -{ - return ospf_route_match_add (vty, vty->index, "ip address prefix-list", - argv[0]); -} - -DEFUN (no_match_ip_address_prefix_list, - no_match_ip_address_prefix_list_cmd, - "no match ip address prefix-list", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n" - "Match entries of prefix-lists\n") -{ - if (argc == 0) - return ospf_route_match_delete (vty, vty->index, "ip address prefix-list", - NULL); - return ospf_route_match_delete (vty, vty->index, "ip address prefix-list", - argv[0]); -} - -ALIAS (no_match_ip_address_prefix_list, - no_match_ip_address_prefix_list_val_cmd, - "no match ip address prefix-list WORD", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") - -DEFUN (match_interface, - match_interface_cmd, - "match interface WORD", - MATCH_STR - "Match first hop interface of route\n" - "Interface name\n") -{ - return ospf_route_match_add (vty, vty->index, "interface", argv[0]); -} - -DEFUN (no_match_interface, - no_match_interface_cmd, - "no match interface", - NO_STR - MATCH_STR - "Match first hop interface of route\n") -{ - if (argc == 0) - return ospf_route_match_delete (vty, vty->index, "interface", NULL); - - return ospf_route_match_delete (vty, vty->index, "interface", argv[0]); -} - -ALIAS (no_match_interface, - no_match_interface_val_cmd, - "no match interface WORD", - NO_STR - MATCH_STR - "Match first hop interface of route\n" - "Interface name\n") - -DEFUN (match_tag, - match_tag_cmd, - "match tag <1-4294967295>", - MATCH_STR - "Match tag of route\n" - "Tag value\n") -{ - return ospf_route_match_add (vty, vty->index, "tag", argv[0]); -} - -DEFUN (no_match_tag, - no_match_tag_cmd, - "no match tag", - NO_STR - MATCH_STR - "Match tag of route\n") -{ - if (argc == 0) - return ospf_route_match_delete (vty, vty->index, "tag", NULL); - - return ospf_route_match_delete (vty, vty->index, "tag", argv[0]); -} - -ALIAS (no_match_tag, - no_match_tag_val_cmd, - "no match tag <1-4294967295>", - NO_STR - MATCH_STR - "Match tag of route\n" - "Tag value\n") - -DEFUN (set_metric, - set_metric_cmd, - "set metric <0-4294967295>", - SET_STR - "Metric value for destination routing protocol\n" - "Metric value\n") -{ - return ospf_route_set_add (vty, vty->index, "metric", argv[0]); -} - -DEFUN (no_set_metric, - no_set_metric_cmd, - "no set metric", - NO_STR - SET_STR - "Metric value for destination routing protocol\n") -{ - if (argc == 0) - return ospf_route_set_delete (vty, vty->index, "metric", NULL); - - return ospf_route_set_delete (vty, vty->index, "metric", argv[0]); -} - -ALIAS (no_set_metric, - no_set_metric_val_cmd, - "no set metric <0-4294967295>", - NO_STR - SET_STR - "Metric value for destination routing protocol\n" - "Metric value\n") - DEFUN (set_metric_type, set_metric_type_cmd, - "set metric-type (type-1|type-2)", + "set metric-type <type-1|type-2>", SET_STR "Type of metric for destination routing protocol\n" "OSPF[6] external type 1 metric\n" "OSPF[6] external type 2 metric\n") { - if (strcmp (argv[0], "1") == 0) - return ospf_route_set_add (vty, vty->index, "metric-type", "type-1"); - if (strcmp (argv[0], "2") == 0) - return ospf_route_set_add (vty, vty->index, "metric-type", "type-2"); - - return ospf_route_set_add (vty, vty->index, "metric-type", argv[0]); + char *ext = argv[2]->text; + return generic_set_add (vty, vty->index, "metric-type", ext); } DEFUN (no_set_metric_type, no_set_metric_type_cmd, - "no set metric-type", - NO_STR - SET_STR - "Type of metric for destination routing protocol\n") -{ - if (argc == 0) - return ospf_route_set_delete (vty, vty->index, "metric-type", NULL); - - return ospf_route_set_delete (vty, vty->index, "metric-type", argv[0]); -} - -ALIAS (no_set_metric_type, - no_set_metric_type_val_cmd, - "no set metric-type (type-1|type-2)", + "no set metric-type [<type-1|type-2>]", NO_STR SET_STR "Type of metric for destination routing protocol\n" "OSPF[6] external type 1 metric\n" "OSPF[6] external type 2 metric\n") - -DEFUN (set_tag, - set_tag_cmd, - "set tag <1-4294967295>", - SET_STR - "Tag value for routing protocol\n" - "Tag value\n") -{ - return ospf_route_set_add (vty, vty->index, "tag", argv[0]); -} - -DEFUN (no_set_tag, - no_set_tag_cmd, - "no set tag", - NO_STR - SET_STR - "Tag value for routing protocol\n") { - if (argc == 0) - ospf_route_set_delete(vty, vty->index, "tag", NULL); - - return ospf_route_set_delete (vty, vty->index, "tag", argv[0]); + char *ext = (argc == 4) ? argv[3]->text : NULL; + return generic_set_delete (vty, vty->index, "metric-type", ext); } -ALIAS (no_set_tag, - no_set_tag_val_cmd, - "no set tag <1-4294967295>", - NO_STR - SET_STR - "Tag value for routing protocol\n" - "Tag value\n") - /* Route-map init */ void ospf_route_map_init (void) @@ -950,6 +642,27 @@ ospf_route_map_init (void) route_map_add_hook (ospf_route_map_update); route_map_delete_hook (ospf_route_map_update); route_map_event_hook (ospf_route_map_event); + + route_map_match_interface_hook (generic_match_add); + route_map_no_match_interface_hook (generic_match_delete); + + route_map_match_ip_address_hook (generic_match_add); + route_map_no_match_ip_address_hook (generic_match_delete); + + route_map_match_ip_address_prefix_list_hook (generic_match_add); + route_map_no_match_ip_address_prefix_list_hook (generic_match_delete); + + route_map_match_ip_next_hop_prefix_list_hook (generic_match_add); + route_map_no_match_ip_next_hop_prefix_list_hook (generic_match_delete); + + route_map_match_tag_hook (generic_match_add); + route_map_no_match_tag_hook (generic_match_delete); + + route_map_set_metric_hook (generic_set_add); + route_map_no_set_metric_hook (generic_set_delete); + + route_map_set_tag_hook (generic_set_add); + route_map_no_set_tag_hook (generic_set_delete); route_map_install_match (&route_match_ip_nexthop_cmd); route_map_install_match (&route_match_ip_next_hop_prefix_list_cmd); @@ -964,30 +677,7 @@ ospf_route_map_init (void) install_element (RMAP_NODE, &match_ip_nexthop_cmd); install_element (RMAP_NODE, &no_match_ip_nexthop_cmd); - install_element (RMAP_NODE, &no_match_ip_nexthop_val_cmd); - install_element (RMAP_NODE, &match_ip_next_hop_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_val_cmd); - install_element (RMAP_NODE, &match_ip_address_cmd); - install_element (RMAP_NODE, &no_match_ip_address_cmd); - install_element (RMAP_NODE, &no_match_ip_address_val_cmd); - install_element (RMAP_NODE, &match_ip_address_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ip_address_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ip_address_prefix_list_val_cmd); - install_element (RMAP_NODE, &match_interface_cmd); - install_element (RMAP_NODE, &no_match_interface_cmd); - install_element (RMAP_NODE, &no_match_interface_val_cmd); - install_element (RMAP_NODE, &match_tag_cmd); - install_element (RMAP_NODE, &no_match_tag_cmd); - install_element (RMAP_NODE, &no_match_tag_val_cmd); - - install_element (RMAP_NODE, &set_metric_cmd); - install_element (RMAP_NODE, &no_set_metric_cmd); - install_element (RMAP_NODE, &no_set_metric_val_cmd); + install_element (RMAP_NODE, &set_metric_type_cmd); install_element (RMAP_NODE, &no_set_metric_type_cmd); - install_element (RMAP_NODE, &no_set_metric_type_val_cmd); - install_element (RMAP_NODE, &set_tag_cmd); - install_element (RMAP_NODE, &no_set_tag_cmd); - install_element (RMAP_NODE, &no_set_tag_val_cmd); } diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index 60fb7132cc..80156e81f6 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -2299,7 +2299,7 @@ DEFUN (ospf_mpls_te_on, DEFUN (no_ospf_mpls_te, no_ospf_mpls_te_cmd, - "no mpls-te", + "no mpls-tei [on]", NO_STR "Disable the MPLS-TE functionality\n") { @@ -2325,12 +2325,6 @@ DEFUN (no_ospf_mpls_te, return CMD_SUCCESS; } -ALIAS (no_ospf_mpls_te, - no_ospf_mpls_te_val_cmd, - "no mpls-te on", - NO_STR - MPLS_TE_STR - "Disable the MPLS-TE functionality\n") DEFUN (ospf_mpls_te_router_addr, ospf_mpls_te_router_addr_cmd, @@ -2339,6 +2333,7 @@ DEFUN (ospf_mpls_te_router_addr, "Stable IP address of the advertising router\n" "MPLS-TE router address in IPv4 address format\n") { + int idx_ipv4 = 2; struct te_tlv_router_addr *ra = &OspfMplsTE.router_addr; struct in_addr value; struct ospf *ospf = vty->index; @@ -2346,7 +2341,7 @@ DEFUN (ospf_mpls_te_router_addr, if (!ospf) return CMD_SUCCESS; - if (! inet_aton (argv[0], &value)) + if (! inet_aton (argv[idx_ipv4]->arg, &value)) { vty_out (vty, "Please specify Router-Addr by A.B.C.D%s", VTY_NEWLINE); return CMD_WARNING; @@ -2478,14 +2473,15 @@ DEFUN (ospf_mpls_te_inter_as_as, DEFUN (ospf_mpls_te_inter_as_area, ospf_mpls_te_inter_as_area_cmd, - "mpls-te inter-as area (A.B.C.D|<0-4294967295>)", + "mpls-te inter-as area <A.B.C.D|(0-4294967295)>", MPLS_TE_STR "Configure MPLS-TE Inter-AS support\n" "AREA native mode self originate INTER_AS LSA with Type 10 (area flooding scope)\n" "OSPF area ID in IP format\n" "OSPF area ID as decimal value\n") { - return set_inter_as_mode (vty, "area", argv[0]); + int idx_ipv4_number = 3; + return set_inter_as_mode (vty, "area", argv[idx_ipv4_number]->arg); } DEFUN (no_ospf_mpls_te_inter_as, @@ -2629,11 +2625,12 @@ DEFUN (show_ip_ospf_mpls_te_link, "Interface information\n" "Interface name\n") { + int idx_interface = 5; struct interface *ifp; struct listnode *node, *nnode; /* Show All Interfaces. */ - if (argc == 0) + if (argc == 5) { for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT), node, nnode, ifp)) show_mpls_te_link_sub (vty, ifp); @@ -2641,7 +2638,7 @@ DEFUN (show_ip_ospf_mpls_te_link, /* Interface name is specified. */ else { - if ((ifp = if_lookup_by_name (argv[0])) == NULL) + if ((ifp = if_lookup_by_name (argv[idx_interface]->arg)) == NULL) vty_out (vty, "No such interface name%s", VTY_NEWLINE); else show_mpls_te_link_sub (vty, ifp); @@ -2658,7 +2655,6 @@ ospf_mpls_te_register_vty (void) install_element (OSPF_NODE, &ospf_mpls_te_on_cmd); install_element (OSPF_NODE, &no_ospf_mpls_te_cmd); - install_element (OSPF_NODE, &no_ospf_mpls_te_val_cmd); install_element (OSPF_NODE, &ospf_mpls_te_router_addr_cmd); install_element (OSPF_NODE, &ospf_mpls_te_inter_as_cmd); install_element (OSPF_NODE, &ospf_mpls_te_inter_as_area_cmd); diff --git a/ospfd/ospf_te.h b/ospfd/ospf_te.h index 8bb77c40c5..36f2d8241c 100644 --- a/ospfd/ospf_te.h +++ b/ospfd/ospf_te.h @@ -253,7 +253,7 @@ struct te_link_subtlv_llri /* Inter-RA Export Upward sub-TLV (12) and Inter-RA Export Downward sub-TLV (13) (RFC6827bis) are not yet supported */ /* SUBTLV 14-16 (RFC4203) are not yet supported */ /* Bandwidth Constraints sub-TLV (17) (RFC4124) is not yet supported */ -/* SUBLV 18-20 are for OSPFv6 TE (RFC5329). see ospf6d */ +/* SUBLV 18-20 are for OSPFv3 TE (RFC5329). see ospf6d */ /* For RFC 5392 */ /* Remote AS Number sub-TLV */ diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index b0946600ba..48c0de5f69 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -21,7 +21,6 @@ */ #include <zebra.h> -#include <lib/json.h> #include <string.h> #include "memory.h" @@ -33,6 +32,7 @@ #include "plist.h" #include "log.h" #include "zclient.h" +#include <lib/json.h> #include "ospfd/ospfd.h" #include "ospfd/ospf_asbr.h" @@ -143,12 +143,12 @@ ospf_oi_count (struct interface *ifp) return i; } - DEFUN (router_ospf, router_ospf_cmd, - "router ospf", + "router ospf [(1-65535)]", "Enable a routing process\n" - "Start OSPF configuration\n") + "Start OSPF configuration\n" + "Instance ID\n") { struct ospf *ospf; u_short instance = 0; @@ -162,8 +162,8 @@ DEFUN (router_ospf, vty->node = OSPF_NODE; - if (argc) - VTY_GET_INTEGER ("Instance", instance, argv[0]); + if (argc > 2) + VTY_GET_INTEGER ("Instance", instance, argv[2]->arg); /* The following logic to set the vty->index is in place to be able to ignore the commands which dont belong to this instance. */ @@ -181,25 +181,19 @@ DEFUN (router_ospf, return CMD_SUCCESS; } -ALIAS (router_ospf, - router_ospf_instance_cmd, - "router ospf <1-65535>", - "Enable a routing process\n" - "Start OSPF configuration\n" - "Instance ID\n") - DEFUN (no_router_ospf, no_router_ospf_cmd, - "no router ospf", + "no router ospf [(1-65535)]", NO_STR "Enable a routing process\n" - "Start OSPF configuration\n") + "Start OSPF configuration\n" + "Instance ID\n") { struct ospf *ospf; u_short instance = 0; - if (argc) - VTY_GET_INTEGER ("Instance", instance, argv[0]); + if (argc > 3) + VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL) return CMD_SUCCESS; @@ -209,13 +203,6 @@ DEFUN (no_router_ospf, return CMD_SUCCESS; } -ALIAS (no_router_ospf, - no_router_ospf_instance_cmd, - "no router ospf <1-65535>", - NO_STR - "Enable a routing process\n" - "Start OSPF configuration\n" - "Instance ID\n") DEFUN (ospf_router_id, ospf_router_id_cmd, @@ -224,6 +211,7 @@ DEFUN (ospf_router_id, "router-id for the OSPF process\n" "OSPF router-id in IP address format\n") { + int idx_ipv4 = 2; struct ospf *ospf = vty->index; struct listnode *node; struct ospf_area *area; @@ -233,7 +221,7 @@ DEFUN (ospf_router_id, if (!ospf) return CMD_SUCCESS; - ret = inet_aton (argv[0], &router_id); + ret = inet_aton (argv[idx_ipv4]->arg, &router_id); if (!ret) { vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE); @@ -255,18 +243,51 @@ DEFUN (ospf_router_id, return CMD_SUCCESS; } -ALIAS_HIDDEN (ospf_router_id, +DEFUN_HIDDEN (ospf_router_id_old, ospf_router_id_old_cmd, "router-id A.B.C.D", "router-id for the OSPF process\n" "OSPF router-id in IP address format\n") +{ + int idx_ipv4 = 1; + struct ospf *ospf = vty->index; + struct listnode *node; + struct ospf_area *area; + struct in_addr router_id; + int ret; + + if (!ospf) + return CMD_SUCCESS; + + ret = inet_aton (argv[idx_ipv4]->arg, &router_id); + if (!ret) + { + vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE); + return CMD_WARNING; + } + + ospf->router_id_static = router_id; + + for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) + if (area->full_nbrs) + { + vty_out (vty, "For this router-id change to take effect," + " save config and restart ospfd%s", VTY_NEWLINE); + return CMD_SUCCESS; + } + + ospf_router_id_update (ospf); + + return CMD_SUCCESS; +} DEFUN (no_ospf_router_id, no_ospf_router_id_cmd, - "no ospf router-id", + "no ospf router-id [A.B.C.D]", NO_STR "OSPF specific commands\n" - "router-id for the OSPF process\n") + "router-id for the OSPF process\n" + "OSPF router-id in IP address format\n") { struct ospf *ospf = vty->index; struct listnode *node; @@ -290,13 +311,6 @@ DEFUN (no_ospf_router_id, return CMD_SUCCESS; } -ALIAS (no_ospf_router_id, - no_ospf_router_id_val_cmd, - "no ospf router-id A.B.C.D", - NO_STR - "OSPF specific commands\n" - "router-id for the OSPF process\n" - "OSPF router-id in IP address format\n") static void ospf_passive_interface_default (struct ospf *ospf, u_char newval) @@ -363,10 +377,12 @@ ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp, DEFUN (ospf_passive_interface, ospf_passive_interface_addr_cmd, - "passive-interface IFNAME A.B.C.D", + "passive-interface <IFNAME [A.B.C.D]|default>", "Suppress routing updates on an interface\n" - "Interface's name\n") + "Interface's name\n" + "Suppress routing updates on interfaces by default\n") { + int idx_ipv4 = 2; struct interface *ifp; struct in_addr addr = { .s_addr = INADDR_ANY }; int ret; @@ -377,19 +393,19 @@ DEFUN (ospf_passive_interface, if (!ospf) return CMD_SUCCESS; - if (argc == 0) + if (strcmp (argv[1]->text, "default") == 0) { ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE); return CMD_SUCCESS; } - ifp = if_get_by_name (argv[0]); + ifp = if_get_by_name (argv[1]->arg); params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 3) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -430,25 +446,15 @@ DEFUN (ospf_passive_interface, return CMD_SUCCESS; } -ALIAS (ospf_passive_interface, - ospf_passive_interface_cmd, - "passive-interface IFNAME", - "Suppress routing updates on an interface\n" - "Interface's name\n") - -ALIAS (ospf_passive_interface, - ospf_passive_interface_default_cmd, - "passive-interface default", - "Suppress routing updates on an interface\n" - "Suppress routing updates on interfaces by default\n") - DEFUN (no_ospf_passive_interface, no_ospf_passive_interface_addr_cmd, - "no passive-interface IFNAME A.B.C.D", + "no passive-interface <IFNAME [A.B.C.D]|default>", NO_STR "Allow routing updates on an interface\n" - "Interface's name\n") + "Interface's name\n" + "Allow routing updates on interfaces by default\n") { + int idx_ipv4 = 3; struct interface *ifp; struct in_addr addr = { .s_addr = INADDR_ANY }; struct ospf_if_params *params; @@ -459,19 +465,19 @@ DEFUN (no_ospf_passive_interface, if (!ospf) return CMD_SUCCESS; - if (argc == 0) + if (strcmp (argv[2]->text, "default") == 0) { ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE); return CMD_SUCCESS; } - ifp = if_get_by_name (argv[0]); + ifp = if_get_by_name (argv[2]->arg); params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 4) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -505,29 +511,19 @@ DEFUN (no_ospf_passive_interface, return CMD_SUCCESS; } -ALIAS (no_ospf_passive_interface, - no_ospf_passive_interface_cmd, - "no passive-interface IFNAME", - NO_STR - "Allow routing updates on an interface\n" - "Interface's name\n") -ALIAS (no_ospf_passive_interface, - no_ospf_passive_interface_default_cmd, - "no passive-interface default", - NO_STR - "Allow routing updates on an interface\n" - "Allow routing updates on interfaces by default\n") DEFUN (ospf_network_area, ospf_network_area_cmd, - "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", + "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>", "Enable routing on an IP network\n" "OSPF network prefix\n" "Set the OSPF area ID\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n") { + int idx_ipv4_prefixlen = 1; + int idx_ipv4_number = 3; struct ospf *ospf= vty->index; struct prefix_ipv4 p; struct in_addr area_id; @@ -551,8 +547,8 @@ DEFUN (ospf_network_area, } /* Get network prefix and Area ID. */ - VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); - VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); + VTY_GET_IPV4_PREFIX ("network prefix", p, argv[idx_ipv4_prefixlen]->arg); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); ret = ospf_network_set (ospf, &p, area_id); if (ret == 0) @@ -566,7 +562,7 @@ DEFUN (ospf_network_area, DEFUN (no_ospf_network_area, no_ospf_network_area_cmd, - "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", + "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>", NO_STR "Enable routing on an IP network\n" "OSPF network prefix\n" @@ -574,6 +570,8 @@ DEFUN (no_ospf_network_area, "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n") { + int idx_ipv4_prefixlen = 2; + int idx_ipv4_number = 4; struct ospf *ospf = (struct ospf *) vty->index; struct prefix_ipv4 p; struct in_addr area_id; @@ -590,8 +588,8 @@ DEFUN (no_ospf_network_area, } /* Get network prefix and Area ID. */ - VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); - VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); + VTY_GET_IPV4_PREFIX ("network prefix", p, argv[idx_ipv4_prefixlen]->arg); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); ret = ospf_network_unset (ospf, &p, area_id); if (ret == 0) @@ -604,16 +602,21 @@ DEFUN (no_ospf_network_area, return CMD_SUCCESS; } - DEFUN (ospf_area_range, ospf_area_range_cmd, - "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", + "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]", "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" "Summarize routes matching address/mask (border routers only)\n" - "Area range prefix\n") + "Area range prefix\n" + "Advertise this range (default)\n" + "User specified metric for this range\n" + "Advertised metric for this range\n") { + int idx_ipv4_number = 1; + int idx_ipv4_prefixlen = 3; + int idx_cost = 6; struct ospf *ospf = vty->index; struct prefix_ipv4 p; struct in_addr area_id; @@ -623,32 +626,22 @@ DEFUN (ospf_area_range, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); - VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); + VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); - if (argc > 2) + if (argc > 5) { - VTY_GET_INTEGER ("range cost", cost, argv[2]); + VTY_GET_INTEGER ("range cost", cost, argv[idx_cost]->arg); ospf_area_range_cost_set (ospf, area_id, &p, cost); } return CMD_SUCCESS; } -ALIAS (ospf_area_range, - ospf_area_range_advertise_cmd, - "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise", - "OSPF area parameters\n" - "OSPF area ID in IP address format\n" - "OSPF area ID as a decimal value\n" - "OSPF area range for route advertise (default)\n" - "Area range prefix\n" - "Advertise this range (default)\n") - -ALIAS (ospf_area_range, +DEFUN (ospf_area_range_cost, ospf_area_range_cost_cmd, - "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", + "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)", "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" @@ -656,22 +649,33 @@ ALIAS (ospf_area_range, "Area range prefix\n" "User specified metric for this range\n" "Advertised metric for this range\n") +{ + int idx_ipv4_number = 1; + int idx_ipv4_prefixlen = 3; + int idx_cost = 5; + struct ospf *ospf = vty->index; + struct prefix_ipv4 p; + struct in_addr area_id; + int format; + u_int32_t cost; -ALIAS (ospf_area_range, - ospf_area_range_advertise_cost_cmd, - "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", - "OSPF area parameters\n" - "OSPF area ID in IP address format\n" - "OSPF area ID as a decimal value\n" - "Summarize routes matching address/mask (border routers only)\n" - "Area range prefix\n" - "Advertise this range (default)\n" - "User specified metric for this range\n" - "Advertised metric for this range\n") + if (!ospf) + return CMD_SUCCESS; + + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); + VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); + + ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); + + VTY_GET_INTEGER ("range cost", cost, argv[idx_cost]->arg); + ospf_area_range_cost_set (ospf, area_id, &p, cost); + + return CMD_SUCCESS; +} DEFUN (ospf_area_range_not_advertise, ospf_area_range_not_advertise_cmd, - "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise", + "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise", "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" @@ -679,6 +683,8 @@ DEFUN (ospf_area_range_not_advertise, "Area range prefix\n" "DoNotAdvertise this range\n") { + int idx_ipv4_number = 1; + int idx_ipv4_prefixlen = 3; struct ospf *ospf = vty->index; struct prefix_ipv4 p; struct in_addr area_id; @@ -687,8 +693,8 @@ DEFUN (ospf_area_range_not_advertise, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); - VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); + VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); ospf_area_range_set (ospf, area_id, &p, 0); @@ -697,14 +703,18 @@ DEFUN (ospf_area_range_not_advertise, DEFUN (no_ospf_area_range, no_ospf_area_range_cmd, - "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", + "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)] | not-advertise>]", NO_STR "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" "Summarize routes matching address/mask (border routers only)\n" - "Area range prefix\n") + "Area range prefix\n" + "Advertise this range (default)\n" + "DoNotAdvertise this range\n") { + int idx_ipv4_number = 2; + int idx_ipv4_prefixlen = 4; struct ospf *ospf = vty->index; struct prefix_ipv4 p; struct in_addr area_id; @@ -713,54 +723,17 @@ DEFUN (no_ospf_area_range, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); - VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); + VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); ospf_area_range_unset (ospf, area_id, &p); return CMD_SUCCESS; } -ALIAS (no_ospf_area_range, - no_ospf_area_range_advertise_cmd, - "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)", - NO_STR - "OSPF area parameters\n" - "OSPF area ID in IP address format\n" - "OSPF area ID as a decimal value\n" - "Summarize routes matching address/mask (border routers only)\n" - "Area range prefix\n" - "Advertise this range (default)\n" - "DoNotAdvertise this range\n") - -ALIAS (no_ospf_area_range, - no_ospf_area_range_cost_cmd, - "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", - NO_STR - "OSPF area parameters\n" - "OSPF area ID in IP address format\n" - "OSPF area ID as a decimal value\n" - "Summarize routes matching address/mask (border routers only)\n" - "Area range prefix\n" - "User specified metric for this range\n" - "Advertised metric for this range\n") - -ALIAS (no_ospf_area_range, - no_ospf_area_range_advertise_cost_cmd, - "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", - NO_STR - "OSPF area parameters\n" - "OSPF area ID in IP address format\n" - "OSPF area ID as a decimal value\n" - "Summarize routes matching address/mask (border routers only)\n" - "Area range prefix\n" - "Advertise this range (default)\n" - "User specified metric for this range\n" - "Advertised metric for this range\n") - DEFUN (ospf_area_range_substitute, ospf_area_range_substitute_cmd, - "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", + "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M", "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" @@ -769,6 +742,9 @@ DEFUN (ospf_area_range_substitute, "Announce area range as another prefix\n" "Network prefix to be announced instead of range\n") { + int idx_ipv4_number = 1; + int idx_ipv4_prefixlen = 3; + int idx_ipv4_prefixlen_2 = 5; struct ospf *ospf = vty->index; struct prefix_ipv4 p, s; struct in_addr area_id; @@ -777,9 +753,9 @@ DEFUN (ospf_area_range_substitute, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); - VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); - VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); + VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); + VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[idx_ipv4_prefixlen_2]->arg); ospf_area_range_substitute_set (ospf, area_id, &p, &s); @@ -788,7 +764,7 @@ DEFUN (ospf_area_range_substitute, DEFUN (no_ospf_area_range_substitute, no_ospf_area_range_substitute_cmd, - "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", + "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M", NO_STR "OSPF area parameters\n" "OSPF area ID in IP address format\n" @@ -798,6 +774,9 @@ DEFUN (no_ospf_area_range_substitute, "Announce area range as another prefix\n" "Network prefix to be announced instead of range\n") { + int idx_ipv4_number = 2; + int idx_ipv4_prefixlen = 4; + int idx_ipv4_prefixlen_2 = 6; struct ospf *ospf = vty->index; struct prefix_ipv4 p, s; struct in_addr area_id; @@ -806,9 +785,9 @@ DEFUN (no_ospf_area_range_substitute, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); - VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); - VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); + VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); + VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[idx_ipv4_prefixlen_2]->arg); ospf_area_range_substitute_unset (ospf, area_id, &p); @@ -831,7 +810,6 @@ DEFUN (no_ospf_area_range_substitute, Wed, 21 Feb 2001 15:13:52 +1300 */ - /* Configuration data for virtual links */ struct ospf_vl_config_data { @@ -999,7 +977,6 @@ ospf_vl_set_timers (struct ospf_vl_data *vl_data, } - /* The business end of all of the above */ static int ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) @@ -1071,9 +1048,18 @@ ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) DEFUN (ospf_area_vlink, ospf_area_vlink_cmd, - "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", - VLINK_HELPSTR_IPADDR) + "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D [authentication] [<message-digest|null>] [<message-digest-key (1-255) md5 KEY|authentication-key AUTH_KEY>]", + VLINK_HELPSTR_IPADDR + "Enable authentication on this virtual link\n" \ + "Use null authentication\n" \ + "Use message-digest authentication\n" + "Message digest authentication password (key)\n" \ + "Key ID\n" \ + "Use MD5 algorithm\n" \ + "The OSPF password (key)") { + int idx_ipv4_number = 1; + int idx_ipv4 = 3; struct ospf *ospf = vty->index; struct ospf_vl_config_data vl_config; char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; @@ -1087,14 +1073,14 @@ DEFUN (ospf_area_vlink, ospf_vl_config_data_init(&vl_config, vty); /* Read off first 2 parameters and check them */ - ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format); + ret = ospf_str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id, &vl_config.format); if (ret < 0) { vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); return CMD_WARNING; } - ret = inet_aton (argv[1], &vl_config.vl_peer); + ret = inet_aton (argv[idx_ipv4]->arg, &vl_config.vl_peer); if (! ret) { vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", @@ -1102,7 +1088,7 @@ DEFUN (ospf_area_vlink, return CMD_WARNING; } - if (argc <=2) + if (argc <=4) { /* Thats all folks! - BUGS B. strikes again!!!*/ @@ -1110,40 +1096,40 @@ DEFUN (ospf_area_vlink, } /* Deal with other parameters */ - for (i=2; i < argc; i++) + for (i=5; i < argc; i++) { - /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ + /* vty_out (vty, "argv[%d]->arg - %s%s", i, argv[i]->text, VTY_NEWLINE); */ - switch (argv[i][0]) + switch (argv[i]->arg[0]) { case 'a': - if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) + if (i >5 || strncmp (argv[i]->arg, "authentication-", 15) == 0) { /* authentication-key - this option can occur anywhere on command line. At start of command line must check for authentication option. */ memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); - strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE); + strncpy (auth_key, argv[i+1]->text, OSPF_AUTH_SIMPLE_SIZE); vl_config.auth_key = auth_key; i++; } - else if (strncmp (argv[i], "authentication", 14) == 0) + else if (strncmp (argv[i]->arg, "authentication", 14) == 0) { /* authentication - this option can only occur at start of command line */ vl_config.auth_type = OSPF_AUTH_SIMPLE; if ((i+1) < argc) { - if (strncmp (argv[i+1], "n", 1) == 0) + if (strncmp (argv[i+1]->arg, "n", 1) == 0) { /* "authentication null" */ vl_config.auth_type = OSPF_AUTH_NULL; i++; } - else if (strncmp (argv[i+1], "m", 1) == 0 - && strcmp (argv[i+1], "message-digest-") != 0) + else if (strncmp (argv[i+1]->arg, "m", 1) == 0 + && strcmp (argv[i+1]->arg, "message-digest-") != 0) { /* "authentication message-digest" */ vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; @@ -1156,46 +1142,15 @@ DEFUN (ospf_area_vlink, case 'm': /* message-digest-key */ i++; - vl_config.crypto_key_id = strtol (argv[i], NULL, 10); + vl_config.crypto_key_id = strtol (argv[i]->arg, NULL, 10); if (vl_config.crypto_key_id < 0) return CMD_WARNING; i++; memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); - strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE); + strncpy (md5_key, argv[i]->arg, OSPF_AUTH_MD5_SIZE); vl_config.md5_key = md5_key; break; - case 'h': - /* Hello interval */ - i++; - vl_config.hello_interval = strtol (argv[i], NULL, 10); - if (vl_config.hello_interval < 0) - return CMD_WARNING; - break; - - case 'r': - /* Retransmit Interval */ - i++; - vl_config.retransmit_interval = strtol (argv[i], NULL, 10); - if (vl_config.retransmit_interval < 0) - return CMD_WARNING; - break; - - case 't': - /* Transmit Delay */ - i++; - vl_config.transmit_delay = strtol (argv[i], NULL, 10); - if (vl_config.transmit_delay < 0) - return CMD_WARNING; - break; - - case 'd': - /* Dead Interval */ - i++; - vl_config.dead_interval = strtol (argv[i], NULL, 10); - if (vl_config.dead_interval < 0) - return CMD_WARNING; - break; } } @@ -1206,12 +1161,77 @@ DEFUN (ospf_area_vlink, } +DEFUN (ospf_area_vlink_intervals, + ospf_area_vlink_intervals_cmd, + "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D" + "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" + "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" + "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" + "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" + "]]]", + VLINK_HELPSTR_IPADDR + VLINK_HELPSTR_TIME_PARAM + VLINK_HELPSTR_TIME_PARAM + VLINK_HELPSTR_TIME_PARAM + VLINK_HELPSTR_TIME_PARAM) +{ + struct ospf *ospf = vty->index; + struct ospf_vl_config_data vl_config; + int ret = 0; + + if (!ospf) + return CMD_SUCCESS; + + ospf_vl_config_data_init(&vl_config, vty); + + char *area_id = argv[1]->arg; + char *router_id = argv[3]->arg; + + ret = ospf_str2area_id (area_id, &vl_config.area_id, &vl_config.format); + if (ret < 0) + { + vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } + + ret = inet_aton (router_id, &vl_config.vl_peer); + if (! ret) + { + vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE); + return CMD_WARNING; + } + for (unsigned int i = 0; i < 4; i++) + { + int idx = 0; + if (argv_find (argv, argc, "hello-interval", &idx)) + vl_config.hello_interval = strtol(argv[idx+1]->arg, NULL, 10); + else if (argv_find (argv, argc, "retransmit-interval", &idx)) + vl_config.retransmit_interval = strtol(argv[idx+1]->arg, NULL, 10); + else if (argv_find (argv, argc, "transmit-delay", &idx)) + vl_config.transmit_delay = strtol(argv[idx+1]->arg, NULL, 10); + else if (argv_find (argv, argc, "dead-interval", &idx)) + vl_config.dead_interval = strtol(argv[idx+1]->arg, NULL, 10); + } + + /* Action configuration */ + return ospf_vl_set (ospf, &vl_config); +} + DEFUN (no_ospf_area_vlink, no_ospf_area_vlink_cmd, - "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", + "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D [authentication] [<message-digest|null>] [<message-digest-key (1-255) md5 KEY|authentication-key AUTH_KEY>]", NO_STR - VLINK_HELPSTR_IPADDR) + VLINK_HELPSTR_IPADDR + "Enable authentication on this virtual link\n" \ + "Use null authentication\n" \ + "Use message-digest authentication\n" + "Message digest authentication password (key)\n" \ + "Key ID\n" \ + "Use MD5 algorithm\n" \ + "The OSPF password (key)") { + int idx_ipv4_number = 2; + int idx_ipv4 = 4; struct ospf *ospf = vty->index; struct ospf_area *area; struct ospf_vl_config_data vl_config; @@ -1225,7 +1245,7 @@ DEFUN (no_ospf_area_vlink, ospf_vl_config_data_init(&vl_config, vty); - ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format); + ret = ospf_str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id, &format); if (ret < 0) { vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); @@ -1239,7 +1259,7 @@ DEFUN (no_ospf_area_vlink, return CMD_WARNING; } - ret = inet_aton (argv[1], &vl_config.vl_peer); + ret = inet_aton (argv[idx_ipv4]->arg, &vl_config.vl_peer); if (! ret) { vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", @@ -1247,7 +1267,7 @@ DEFUN (no_ospf_area_vlink, return CMD_WARNING; } - if (argc <=2) + if (argc <=5) { /* Basic VLink no command */ /* Thats all folks! - BUGS B. strikes again!!!*/ @@ -1255,22 +1275,22 @@ DEFUN (no_ospf_area_vlink, ospf_vl_delete (ospf, vl_data); ospf_area_check_free (ospf, vl_config.area_id); - + return CMD_SUCCESS; } /* If we are down here, we are reseting parameters */ /* Deal with other parameters */ - for (i=2; i < argc; i++) + for (i=6; argc; i++) { /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ - switch (argv[i][0]) + switch (argv[i]->arg[0]) { case 'a': - if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) + if (i > 2 || strncmp (argv[i]->text, "authentication-", 15) == 0) { /* authentication-key - this option can occur anywhere on command line. At start of command line @@ -1278,7 +1298,7 @@ DEFUN (no_ospf_area_vlink, memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); vl_config.auth_key = auth_key; } - else if (strncmp (argv[i], "authentication", 14) == 0) + else if (strncmp (argv[i]->text, "authentication", 14) == 0) { /* authentication - this option can only occur at start of command line */ @@ -1290,32 +1310,12 @@ DEFUN (no_ospf_area_vlink, /* message-digest-key */ /* Delete one key */ i++; - vl_config.crypto_key_id = strtol (argv[i], NULL, 10); + vl_config.crypto_key_id = strtol (argv[i]->arg, NULL, 10); if (vl_config.crypto_key_id < 0) return CMD_WARNING; vl_config.md5_key = NULL; break; - case 'h': - /* Hello interval */ - vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; - break; - - case 'r': - /* Retransmit Interval */ - vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; - break; - - case 't': - /* Transmit Delay */ - vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; - break; - - case 'd': - /* Dead Interval */ - i++; - vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; - break; } } @@ -1325,230 +1325,66 @@ DEFUN (no_ospf_area_vlink, return ospf_vl_set (ospf, &vl_config); } -ALIAS (ospf_area_vlink, - ospf_area_vlink_param1_cmd, - "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_TIME_PARAM) - -ALIAS (no_ospf_area_vlink, - no_ospf_area_vlink_param1_cmd, - "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", - NO_STR - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_TIME_PARAM) - -ALIAS (ospf_area_vlink, - ospf_area_vlink_param2_cmd, - "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM) - -ALIAS (no_ospf_area_vlink, - no_ospf_area_vlink_param2_cmd, - "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", - NO_STR - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM) - -ALIAS (ospf_area_vlink, - ospf_area_vlink_param3_cmd, - "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM) - -ALIAS (no_ospf_area_vlink, - no_ospf_area_vlink_param3_cmd, - "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", - NO_STR - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM) - -ALIAS (ospf_area_vlink, - ospf_area_vlink_param4_cmd, - "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM) - -ALIAS (no_ospf_area_vlink, - no_ospf_area_vlink_param4_cmd, - "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " - "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", - NO_STR +DEFUN (no_ospf_area_vlink_intervals, + no_ospf_area_vlink_intervals_cmd, + "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D" + "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" + "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" + "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" + "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" + "]]]", VLINK_HELPSTR_IPADDR VLINK_HELPSTR_TIME_PARAM VLINK_HELPSTR_TIME_PARAM VLINK_HELPSTR_TIME_PARAM VLINK_HELPSTR_TIME_PARAM) +{ + struct ospf *ospf = vty->index; + struct ospf_vl_config_data vl_config; + int ret = 0; -ALIAS (ospf_area_vlink, - ospf_area_vlink_authtype_args_cmd, - "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(authentication|) (message-digest|null)", - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_AUTHTYPE_ALL) - -ALIAS (no_ospf_area_vlink, - no_ospf_area_vlink_authtype_args_cmd, - "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(authentication|) (message-digest|null)", - NO_STR - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_AUTHTYPE_ALL) - -ALIAS (ospf_area_vlink, - ospf_area_vlink_authtype_cmd, - "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(authentication|)", - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_AUTHTYPE_SIMPLE) - -ALIAS (no_ospf_area_vlink, - no_ospf_area_vlink_authtype_cmd, - "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(authentication|)", - NO_STR - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_AUTHTYPE_SIMPLE) + if (!ospf) + return CMD_SUCCESS; -ALIAS (ospf_area_vlink, - ospf_area_vlink_md5_cmd, - "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(message-digest-key|) <1-255> md5 KEY", - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_AUTH_MD5) + ospf_vl_config_data_init(&vl_config, vty); -ALIAS (no_ospf_area_vlink, - no_ospf_area_vlink_md5_cmd, - "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(message-digest-key|) <1-255> md5 KEY", - NO_STR - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_AUTH_MD5) + char *area_id = argv[2]->arg; + char *router_id = argv[4]->arg; -ALIAS (ospf_area_vlink, - ospf_area_vlink_authkey_cmd, - "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(authentication-key|) AUTH_KEY", - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_AUTH_SIMPLE) + ret = ospf_str2area_id (area_id, &vl_config.area_id, &vl_config.format); + if (ret < 0) + { + vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } -ALIAS (no_ospf_area_vlink, - no_ospf_area_vlink_authkey_cmd, - "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(authentication-key|) AUTH_KEY", - NO_STR - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_AUTH_SIMPLE) + ret = inet_aton (router_id, &vl_config.vl_peer); + if (! ret) + { + vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE); + return CMD_WARNING; + } -ALIAS (ospf_area_vlink, - ospf_area_vlink_authtype_args_authkey_cmd, - "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(authentication|) (message-digest|null) " - "(authentication-key|) AUTH_KEY", - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_AUTHTYPE_ALL - VLINK_HELPSTR_AUTH_SIMPLE) - -ALIAS (no_ospf_area_vlink, - no_ospf_area_vlink_authtype_args_authkey_cmd, - "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(authentication|) (message-digest|null) " - "(authentication-key|) AUTH_KEY", - NO_STR - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_AUTHTYPE_ALL - VLINK_HELPSTR_AUTH_SIMPLE) - -ALIAS (ospf_area_vlink, - ospf_area_vlink_authtype_authkey_cmd, - "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(authentication|) " - "(authentication-key|) AUTH_KEY", - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_AUTHTYPE_SIMPLE - VLINK_HELPSTR_AUTH_SIMPLE) - -ALIAS (no_ospf_area_vlink, - no_ospf_area_vlink_authtype_authkey_cmd, - "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(authentication|) " - "(authentication-key|) AUTH_KEY", - NO_STR - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_AUTHTYPE_SIMPLE - VLINK_HELPSTR_AUTH_SIMPLE) - -ALIAS (ospf_area_vlink, - ospf_area_vlink_authtype_args_md5_cmd, - "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(authentication|) (message-digest|null) " - "(message-digest-key|) <1-255> md5 KEY", - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_AUTHTYPE_ALL - VLINK_HELPSTR_AUTH_MD5) - -ALIAS (no_ospf_area_vlink, - no_ospf_area_vlink_authtype_args_md5_cmd, - "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(authentication|) (message-digest|null) " - "(message-digest-key|) <1-255> md5 KEY", - NO_STR - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_AUTHTYPE_ALL - VLINK_HELPSTR_AUTH_MD5) - -ALIAS (ospf_area_vlink, - ospf_area_vlink_authtype_md5_cmd, - "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(authentication|) " - "(message-digest-key|) <1-255> md5 KEY", - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_AUTHTYPE_SIMPLE - VLINK_HELPSTR_AUTH_MD5) - -ALIAS (no_ospf_area_vlink, - no_ospf_area_vlink_authtype_md5_cmd, - "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - "(authentication|) " - "(message-digest-key|) <1-255> md5 KEY", - NO_STR - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_AUTHTYPE_SIMPLE - VLINK_HELPSTR_AUTH_MD5) + for (unsigned int i = 0; i < 4; i++) + { + int idx = 0; + if (argv_find (argv, argc, "hello-interval", &idx)) + vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; + else if (argv_find (argv, argc, "retransmit-interval", &idx)) + vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; + else if (argv_find (argv, argc, "transmit-delay", &idx)) + vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; + else if (argv_find (argv, argc, "dead-interval", &idx)) + vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; + } + /* Action configuration */ + return ospf_vl_set (ospf, &vl_config); +} DEFUN (ospf_area_shortcut, ospf_area_shortcut_cmd, - "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)", + "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>", "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" @@ -1557,6 +1393,8 @@ DEFUN (ospf_area_shortcut, "Enable shortcutting through the area\n" "Disable shortcutting through the area\n") { + int idx_ipv4_number = 1; + int idx_enable_disable = 3; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -1566,15 +1404,15 @@ DEFUN (ospf_area_shortcut, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); + VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); - if (strncmp (argv[1], "de", 2) == 0) + if (strncmp (argv[idx_enable_disable]->arg, "de", 2) == 0) mode = OSPF_SHORTCUT_DEFAULT; - else if (strncmp (argv[1], "di", 2) == 0) + else if (strncmp (argv[idx_enable_disable]->arg, "di", 2) == 0) mode = OSPF_SHORTCUT_DISABLE; - else if (strncmp (argv[1], "e", 1) == 0) + else if (strncmp (argv[idx_enable_disable]->arg, "e", 1) == 0) mode = OSPF_SHORTCUT_ENABLE; else return CMD_WARNING; @@ -1591,7 +1429,7 @@ DEFUN (ospf_area_shortcut, DEFUN (no_ospf_area_shortcut, no_ospf_area_shortcut_cmd, - "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)", + "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>", NO_STR "OSPF area parameters\n" "OSPF area ID in IP address format\n" @@ -1600,6 +1438,7 @@ DEFUN (no_ospf_area_shortcut, "Deconfigure enabled shortcutting through the area\n" "Deconfigure disabled shortcutting through the area\n") { + int idx_ipv4_number = 2; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -1608,7 +1447,7 @@ DEFUN (no_ospf_area_shortcut, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); + VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_lookup_by_area_id (ospf, area_id); if (!area) @@ -1622,12 +1461,13 @@ DEFUN (no_ospf_area_shortcut, DEFUN (ospf_area_stub, ospf_area_stub_cmd, - "area (A.B.C.D|<0-4294967295>) stub", + "area <A.B.C.D|(0-4294967295)> stub", "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" "Configure OSPF area as stub\n") { + int idx_ipv4_number = 1; struct ospf *ospf = vty->index; struct in_addr area_id; int ret, format; @@ -1635,7 +1475,7 @@ DEFUN (ospf_area_stub, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); + VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); ret = ospf_area_stub_set (ospf, area_id); if (ret == 0) @@ -1652,13 +1492,14 @@ DEFUN (ospf_area_stub, DEFUN (ospf_area_stub_no_summary, ospf_area_stub_no_summary_cmd, - "area (A.B.C.D|<0-4294967295>) stub no-summary", + "area <A.B.C.D|(0-4294967295)> stub no-summary", "OSPF stub parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" "Configure OSPF area as stub\n" "Do not inject inter-area routes into stub\n") { + int idx_ipv4_number = 1; struct ospf *ospf = vty->index; struct in_addr area_id; int ret, format; @@ -1666,7 +1507,7 @@ DEFUN (ospf_area_stub_no_summary, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); + VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); ret = ospf_area_stub_set (ospf, area_id); if (ret == 0) @@ -1683,13 +1524,14 @@ DEFUN (ospf_area_stub_no_summary, DEFUN (no_ospf_area_stub, no_ospf_area_stub_cmd, - "no area (A.B.C.D|<0-4294967295>) stub", + "no area <A.B.C.D|(0-4294967295)> stub", NO_STR "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" "Configure OSPF area as stub\n") { + int idx_ipv4_number = 2; struct ospf *ospf = vty->index; struct in_addr area_id; int format; @@ -1697,7 +1539,7 @@ DEFUN (no_ospf_area_stub, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); + VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); ospf_area_stub_unset (ospf, area_id); ospf_area_no_summary_unset (ospf, area_id); @@ -1707,7 +1549,7 @@ DEFUN (no_ospf_area_stub, DEFUN (no_ospf_area_stub_no_summary, no_ospf_area_stub_no_summary_cmd, - "no area (A.B.C.D|<0-4294967295>) stub no-summary", + "no area <A.B.C.D|(0-4294967295)> stub no-summary", NO_STR "OSPF area parameters\n" "OSPF area ID in IP address format\n" @@ -1715,6 +1557,7 @@ DEFUN (no_ospf_area_stub_no_summary, "Configure OSPF area as stub\n" "Do not inject inter-area routes into area\n") { + int idx_ipv4_number = 2; struct ospf *ospf = vty->index; struct in_addr area_id; int format; @@ -1722,14 +1565,14 @@ DEFUN (no_ospf_area_stub_no_summary, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); + VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); ospf_area_no_summary_unset (ospf, area_id); return CMD_SUCCESS; } static int -ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], +ospf_area_nssa_cmd_handler (struct vty *vty, int argc, struct cmd_token **argv, int nosum) { struct ospf *ospf = vty->index; @@ -1739,7 +1582,7 @@ ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); + VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[1]->arg); ret = ospf_area_nssa_set (ospf, area_id); if (ret == 0) @@ -1751,13 +1594,13 @@ ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], if (argc > 1) { - if (strncmp (argv[1], "translate-c", 11) == 0) + if (strncmp (argv[3]->text, "translate-c", 11) == 0) ospf_area_nssa_translator_role_set (ospf, area_id, OSPF_NSSA_ROLE_CANDIDATE); - else if (strncmp (argv[1], "translate-n", 11) == 0) + else if (strncmp (argv[3]->text, "translate-n", 11) == 0) ospf_area_nssa_translator_role_set (ospf, area_id, OSPF_NSSA_ROLE_NEVER); - else if (strncmp (argv[1], "translate-a", 11) == 0) + else if (strncmp (argv[3]->text, "translate-a", 11) == 0) ospf_area_nssa_translator_role_set (ospf, area_id, OSPF_NSSA_ROLE_ALWAYS); } @@ -1779,7 +1622,7 @@ ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], DEFUN (ospf_area_nssa_translate_no_summary, ospf_area_nssa_translate_no_summary_cmd, - "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary", + "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary", "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" @@ -1794,7 +1637,7 @@ DEFUN (ospf_area_nssa_translate_no_summary, DEFUN (ospf_area_nssa_translate, ospf_area_nssa_translate_cmd, - "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)", + "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>", "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" @@ -1808,7 +1651,7 @@ DEFUN (ospf_area_nssa_translate, DEFUN (ospf_area_nssa, ospf_area_nssa_cmd, - "area (A.B.C.D|<0-4294967295>) nssa", + "area <A.B.C.D|(0-4294967295)> nssa", "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" @@ -1819,7 +1662,7 @@ DEFUN (ospf_area_nssa, DEFUN (ospf_area_nssa_no_summary, ospf_area_nssa_no_summary_cmd, - "area (A.B.C.D|<0-4294967295>) nssa no-summary", + "area <A.B.C.D|(0-4294967295)> nssa no-summary", "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" @@ -1831,13 +1674,18 @@ DEFUN (ospf_area_nssa_no_summary, DEFUN (no_ospf_area_nssa, no_ospf_area_nssa_cmd, - "no area (A.B.C.D|<0-4294967295>) nssa", + "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]", NO_STR "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" - "Configure OSPF area as nssa\n") + "Configure OSPF area as nssa\n" + "Configure NSSA-ABR for translate election (default)\n" + "Configure NSSA-ABR to never translate\n" + "Configure NSSA-ABR to always translate\n" + "Do not inject inter-area routes into nssa\n") { + int idx_ipv4_number = 2; struct ospf *ospf = vty->index; struct in_addr area_id; int format; @@ -1845,7 +1693,7 @@ DEFUN (no_ospf_area_nssa, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); + VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[idx_ipv4_number]->arg); ospf_area_nssa_unset (ospf, area_id); ospf_area_no_summary_unset (ospf, area_id); @@ -1855,28 +1703,18 @@ DEFUN (no_ospf_area_nssa, return CMD_SUCCESS; } -ALIAS (no_ospf_area_nssa, - no_ospf_area_nssa_no_summary_cmd, - "no area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always|) {no-summary}", - NO_STR - "OSPF area parameters\n" - "OSPF area ID in IP address format\n" - "OSPF area ID as a decimal value\n" - "Configure OSPF area as nssa\n" - "Configure NSSA-ABR for translate election (default)\n" - "Configure NSSA-ABR to never translate\n" - "Configure NSSA-ABR to always translate\n" - "Do not inject inter-area routes into nssa\n") DEFUN (ospf_area_default_cost, ospf_area_default_cost_cmd, - "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", + "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)", "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" "Set the summary-default cost of a NSSA or stub area\n" "Stub's advertised default summary cost\n") { + int idx_ipv4_number = 1; + int idx_number = 3; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -1887,8 +1725,8 @@ DEFUN (ospf_area_default_cost, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); - VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); + VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[idx_ipv4_number]->arg); + VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[idx_number]->arg, 0, 16777215); area = ospf_area_get (ospf, area_id, format); @@ -1914,7 +1752,7 @@ DEFUN (ospf_area_default_cost, DEFUN (no_ospf_area_default_cost, no_ospf_area_default_cost_cmd, - "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", + "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)", NO_STR "OSPF area parameters\n" "OSPF area ID in IP address format\n" @@ -1922,6 +1760,8 @@ DEFUN (no_ospf_area_default_cost, "Set the summary-default cost of a NSSA or stub area\n" "Stub's advertised default summary cost\n") { + int idx_ipv4_number = 2; + int idx_number = 4; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -1931,8 +1771,8 @@ DEFUN (no_ospf_area_default_cost, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); - VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY); + VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[idx_ipv4_number]->arg); + VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[idx_number]->arg, 0, OSPF_LS_INFINITY); area = ospf_area_lookup_by_area_id (ospf, area_id); if (area == NULL) @@ -1963,13 +1803,14 @@ DEFUN (no_ospf_area_default_cost, DEFUN (ospf_area_export_list, ospf_area_export_list_cmd, - "area (A.B.C.D|<0-4294967295>) export-list NAME", + "area <A.B.C.D|(0-4294967295)> export-list NAME", "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" "Set the filter for networks announced to other areas\n" "Name of the access-list\n") { + int idx_ipv4_number = 1; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -1978,17 +1819,17 @@ DEFUN (ospf_area_export_list, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); - ospf_area_export_list_set (ospf, area, argv[1]); + ospf_area_export_list_set (ospf, area, argv[3]->arg); return CMD_SUCCESS; } DEFUN (no_ospf_area_export_list, no_ospf_area_export_list_cmd, - "no area (A.B.C.D|<0-4294967295>) export-list NAME", + "no area <A.B.C.D|(0-4294967295)> export-list NAME", NO_STR "OSPF area parameters\n" "OSPF area ID in IP address format\n" @@ -1996,6 +1837,7 @@ DEFUN (no_ospf_area_export_list, "Unset the filter for networks announced to other areas\n" "Name of the access-list\n") { + int idx_ipv4_number = 2; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -2004,7 +1846,7 @@ DEFUN (no_ospf_area_export_list, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_lookup_by_area_id (ospf, area_id); if (area == NULL) @@ -2018,13 +1860,14 @@ DEFUN (no_ospf_area_export_list, DEFUN (ospf_area_import_list, ospf_area_import_list_cmd, - "area (A.B.C.D|<0-4294967295>) import-list NAME", + "area <A.B.C.D|(0-4294967295)> import-list NAME", "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" "Set the filter for networks from other areas announced to the specified one\n" "Name of the access-list\n") { + int idx_ipv4_number = 1; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -2033,17 +1876,17 @@ DEFUN (ospf_area_import_list, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); - ospf_area_import_list_set (ospf, area, argv[1]); + ospf_area_import_list_set (ospf, area, argv[3]->arg); return CMD_SUCCESS; } DEFUN (no_ospf_area_import_list, no_ospf_area_import_list_cmd, - "no area (A.B.C.D|<0-4294967295>) import-list NAME", + "no area <A.B.C.D|(0-4294967295)> import-list NAME", NO_STR "OSPF area parameters\n" "OSPF area ID in IP address format\n" @@ -2051,6 +1894,7 @@ DEFUN (no_ospf_area_import_list, "Unset the filter for networks announced to other areas\n" "Name of the access-list\n") { + int idx_ipv4_number = 2; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -2059,7 +1903,7 @@ DEFUN (no_ospf_area_import_list, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_lookup_by_area_id (ospf, area_id); if (area == NULL) @@ -2072,7 +1916,7 @@ DEFUN (no_ospf_area_import_list, DEFUN (ospf_area_filter_list, ospf_area_filter_list_cmd, - "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", + "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>", "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" @@ -2082,6 +1926,9 @@ DEFUN (ospf_area_filter_list, "Filter networks sent to this area\n" "Filter networks sent from this area\n") { + int idx_ipv4_number = 1; + int idx_word = 4; + int idx_in_out = 5; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -2091,17 +1938,17 @@ DEFUN (ospf_area_filter_list, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); - plist = prefix_list_lookup (AFI_IP, argv[1]); - if (strncmp (argv[2], "in", 2) == 0) + plist = prefix_list_lookup (AFI_IP, argv[idx_word]->arg); + if (strncmp (argv[idx_in_out]->arg, "in", 2) == 0) { PREFIX_LIST_IN (area) = plist; if (PREFIX_NAME_IN (area)) free (PREFIX_NAME_IN (area)); - PREFIX_NAME_IN (area) = strdup (argv[1]); + PREFIX_NAME_IN (area) = strdup (argv[idx_word]->arg); ospf_schedule_abr_task (ospf); } else @@ -2110,7 +1957,7 @@ DEFUN (ospf_area_filter_list, if (PREFIX_NAME_OUT (area)) free (PREFIX_NAME_OUT (area)); - PREFIX_NAME_OUT (area) = strdup (argv[1]); + PREFIX_NAME_OUT (area) = strdup (argv[idx_word]->arg); ospf_schedule_abr_task (ospf); } @@ -2119,7 +1966,7 @@ DEFUN (ospf_area_filter_list, DEFUN (no_ospf_area_filter_list, no_ospf_area_filter_list_cmd, - "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", + "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>", NO_STR "OSPF area parameters\n" "OSPF area ID in IP address format\n" @@ -2130,6 +1977,9 @@ DEFUN (no_ospf_area_filter_list, "Filter networks sent to this area\n" "Filter networks sent from this area\n") { + int idx_ipv4_number = 2; + int idx_word = 5; + int idx_in_out = 6; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -2138,15 +1988,15 @@ DEFUN (no_ospf_area_filter_list, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL) return CMD_SUCCESS; - if (strncmp (argv[2], "in", 2) == 0) + if (strncmp (argv[idx_in_out]->arg, "in", 2) == 0) { if (PREFIX_NAME_IN (area)) - if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0) + if (strcmp (PREFIX_NAME_IN (area), argv[idx_word]->arg) != 0) return CMD_SUCCESS; PREFIX_LIST_IN (area) = NULL; @@ -2160,7 +2010,7 @@ DEFUN (no_ospf_area_filter_list, else { if (PREFIX_NAME_OUT (area)) - if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0) + if (strcmp (PREFIX_NAME_OUT (area), argv[idx_word]->arg) != 0) return CMD_SUCCESS; PREFIX_LIST_OUT (area) = NULL; @@ -2178,13 +2028,14 @@ DEFUN (no_ospf_area_filter_list, DEFUN (ospf_area_authentication_message_digest, ospf_area_authentication_message_digest_cmd, - "area (A.B.C.D|<0-4294967295>) authentication message-digest", + "area <A.B.C.D|(0-4294967295)> authentication message-digest", "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" "Enable authentication\n" "Use message-digest authentication\n") { + int idx_ipv4_number = 1; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -2193,7 +2044,7 @@ DEFUN (ospf_area_authentication_message_digest, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; @@ -2203,12 +2054,13 @@ DEFUN (ospf_area_authentication_message_digest, DEFUN (ospf_area_authentication, ospf_area_authentication_cmd, - "area (A.B.C.D|<0-4294967295>) authentication", + "area <A.B.C.D|(0-4294967295)> authentication", "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" "Enable authentication\n") { + int idx_ipv4_number = 1; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -2217,7 +2069,7 @@ DEFUN (ospf_area_authentication, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); area->auth_type = OSPF_AUTH_SIMPLE; @@ -2227,13 +2079,14 @@ DEFUN (ospf_area_authentication, DEFUN (no_ospf_area_authentication, no_ospf_area_authentication_cmd, - "no area (A.B.C.D|<0-4294967295>) authentication", + "no area <A.B.C.D|(0-4294967295)> authentication", NO_STR "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" "Enable authentication\n") { + int idx_ipv4_number = 2; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -2242,7 +2095,7 @@ DEFUN (no_ospf_area_authentication, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_lookup_by_area_id (ospf, area_id); if (area == NULL) @@ -2258,7 +2111,7 @@ DEFUN (no_ospf_area_authentication, DEFUN (ospf_abr_type, ospf_abr_type_cmd, - "ospf abr-type (cisco|ibm|shortcut|standard)", + "ospf abr-type <cisco|ibm|shortcut|standard>", "OSPF specific commands\n" "Set OSPF ABR type\n" "Alternative ABR, cisco implementation\n" @@ -2266,19 +2119,20 @@ DEFUN (ospf_abr_type, "Shortcut ABR\n" "Standard behavior (RFC2328)\n") { + int idx_vendor = 2; struct ospf *ospf = vty->index; u_char abr_type = OSPF_ABR_UNKNOWN; if (!ospf) return CMD_SUCCESS; - if (strncmp (argv[0], "c", 1) == 0) + if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) abr_type = OSPF_ABR_CISCO; - else if (strncmp (argv[0], "i", 1) == 0) + else if (strncmp (argv[idx_vendor]->arg, "i", 1) == 0) abr_type = OSPF_ABR_IBM; - else if (strncmp (argv[0], "sh", 2) == 0) + else if (strncmp (argv[idx_vendor]->arg, "sh", 2) == 0) abr_type = OSPF_ABR_SHORTCUT; - else if (strncmp (argv[0], "st", 2) == 0) + else if (strncmp (argv[idx_vendor]->arg, "st", 2) == 0) abr_type = OSPF_ABR_STAND; else return CMD_WARNING; @@ -2295,7 +2149,7 @@ DEFUN (ospf_abr_type, DEFUN (no_ospf_abr_type, no_ospf_abr_type_cmd, - "no ospf abr-type (cisco|ibm|shortcut|standard)", + "no ospf abr-type <cisco|ibm|shortcut|standard>", NO_STR "OSPF specific commands\n" "Set OSPF ABR type\n" @@ -2303,19 +2157,20 @@ DEFUN (no_ospf_abr_type, "Alternative ABR, IBM implementation\n" "Shortcut ABR\n") { + int idx_vendor = 3; struct ospf *ospf = vty->index; u_char abr_type = OSPF_ABR_UNKNOWN; if (!ospf) return CMD_SUCCESS; - if (strncmp (argv[0], "c", 1) == 0) + if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) abr_type = OSPF_ABR_CISCO; - else if (strncmp (argv[0], "i", 1) == 0) + else if (strncmp (argv[idx_vendor]->arg, "i", 1) == 0) abr_type = OSPF_ABR_IBM; - else if (strncmp (argv[0], "sh", 2) == 0) + else if (strncmp (argv[idx_vendor]->arg, "sh", 2) == 0) abr_type = OSPF_ABR_SHORTCUT; - else if (strncmp (argv[0], "st", 2) == 0) + else if (strncmp (argv[idx_vendor]->arg, "st", 2) == 0) abr_type = OSPF_ABR_STAND; else return CMD_WARNING; @@ -2434,17 +2289,17 @@ DEFUN (no_ospf_compatible_rfc1583, } ALIAS (ospf_compatible_rfc1583, - ospf_rfc1583_flag_cmd, - "ospf rfc1583compatibility", - "OSPF specific commands\n" - "Enable the RFC1583Compatibility flag\n") + ospf_rfc1583_flag_cmd, + "ospf rfc1583compatibility", + "OSPF specific commands\n" + "Enable the RFC1583Compatibility flag\n") ALIAS (no_ospf_compatible_rfc1583, - no_ospf_rfc1583_flag_cmd, - "no ospf rfc1583compatibility", - NO_STR - "OSPF specific commands\n" - "Disable the RFC1583Compatibility flag\n") + no_ospf_rfc1583_flag_cmd, + "no ospf rfc1583compatibility", + NO_STR + "OSPF specific commands\n" + "Disable the RFC1583Compatibility flag\n") static int ospf_timers_spf_set (struct vty *vty, unsigned int delay, @@ -2465,13 +2320,14 @@ ospf_timers_spf_set (struct vty *vty, unsigned int delay, DEFUN (ospf_timers_min_ls_interval, ospf_timers_min_ls_interval_cmd, - "timers throttle lsa all <0-5000>", + "timers throttle lsa all (0-5000)", "Adjust routing timers\n" "Throttling adaptive timer\n" "LSA delay between transmissions\n" "All LSA types\n" "Delay (msec) between sending LSAs\n") { + int idx_number = 4; struct ospf *ospf = vty->index; unsigned int interval; @@ -2484,7 +2340,7 @@ DEFUN (ospf_timers_min_ls_interval, return CMD_WARNING; } - VTY_GET_INTEGER ("LSA interval", interval, argv[0]); + VTY_GET_INTEGER ("LSA interval", interval, argv[idx_number]->arg); ospf->min_ls_interval = interval; @@ -2493,12 +2349,13 @@ DEFUN (ospf_timers_min_ls_interval, DEFUN (no_ospf_timers_min_ls_interval, no_ospf_timers_min_ls_interval_cmd, - "no timers throttle lsa all", + "no timers throttle lsa all [(0-5000)]", NO_STR "Adjust routing timers\n" "Throttling adaptive timer\n" "LSA delay between transmissions\n" - "All LSA types\n") + "All LSA types\n" + "Delay (msec) between sending LSAs\n") { struct ospf *ospf = vty->index; ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL; @@ -2506,24 +2363,16 @@ DEFUN (no_ospf_timers_min_ls_interval, return CMD_SUCCESS; } -ALIAS (no_ospf_timers_min_ls_interval, - no_ospf_timers_min_ls_interval_val_cmd, - "no timers throttle lsa all <0-5000>", - NO_STR - "Adjust routing timers\n" - "Throttling adaptive timer\n" - "LSA delay between transmissions\n" - "All LSA types\n" - "Delay (msec) between sending LSAs\n") DEFUN (ospf_timers_min_ls_arrival, ospf_timers_min_ls_arrival_cmd, - "timers lsa arrival <0-1000>", + "timers lsa arrival (0-1000)", "Adjust routing timers\n" "Throttling link state advertisement delays\n" "OSPF minimum arrival interval delay\n" "Delay (msec) between accepted LSAs\n") { + int idx_number = 3; struct ospf *ospf = vty->index; unsigned int arrival; @@ -2536,7 +2385,7 @@ DEFUN (ospf_timers_min_ls_arrival, return CMD_WARNING; } - VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival, argv[0], 0, 1000); + VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival, argv[idx_number]->arg, 0, 1000); ospf->min_ls_arrival = arrival; @@ -2545,11 +2394,12 @@ DEFUN (ospf_timers_min_ls_arrival, DEFUN (no_ospf_timers_min_ls_arrival, no_ospf_timers_min_ls_arrival_cmd, - "no timers lsa arrival", + "no timers lsa arrival [(0-1000)]", NO_STR "Adjust routing timers\n" "Throttling link state advertisement delays\n" - "OSPF minimum arrival interval delay\n") + "OSPF minimum arrival interval delay\n" + "Delay (msec) between accepted LSAs\n") { struct ospf *ospf = vty->index; @@ -2561,18 +2411,10 @@ DEFUN (no_ospf_timers_min_ls_arrival, return CMD_SUCCESS; } -ALIAS (no_ospf_timers_min_ls_arrival, - no_ospf_timers_min_ls_arrival_val_cmd, - "no timers lsa arrival <0-1000>", - NO_STR - "Adjust routing timers\n" - "Throttling link state advertisement delays\n" - "OSPF minimum arrival interval delay\n" - "Delay (msec) between accepted LSAs\n") DEFUN (ospf_timers_throttle_spf, ospf_timers_throttle_spf_cmd, - "timers throttle spf <0-600000> <0-600000> <0-600000>", + "timers throttle spf (0-600000) (0-600000) (0-600000)", "Adjust routing timers\n" "Throttling adaptive timer\n" "OSPF SPF timers\n" @@ -2580,6 +2422,9 @@ DEFUN (ospf_timers_throttle_spf, "Initial hold time (msec) between consecutive SPF calculations\n" "Maximum hold time (msec)\n") { + int idx_number = 3; + int idx_number_2 = 4; + int idx_number_3 = 5; unsigned int delay, hold, max; if (argc != 3) @@ -2588,20 +2433,23 @@ DEFUN (ospf_timers_throttle_spf, return CMD_WARNING; } - VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000); - VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000); - VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000); + VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[idx_number]->arg, 0, 600000); + VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[idx_number_2]->arg, 0, 600000); + VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[idx_number_3]->arg, 0, 600000); return ospf_timers_spf_set (vty, delay, hold, max); } DEFUN (no_ospf_timers_throttle_spf, no_ospf_timers_throttle_spf_cmd, - "no timers throttle spf", + "no timers throttle spf [(0-600000)(0-600000)(0-600000)]", NO_STR "Adjust routing timers\n" "Throttling adaptive timer\n" - "OSPF SPF timers\n") + "OSPF SPF timers\n" + "Delay (msec) from first change received till SPF calculation\n" + "Initial hold time (msec) between consecutive SPF calculations\n" + "Maximum hold time (msec)\n") { return ospf_timers_spf_set (vty, OSPF_SPF_DELAY_DEFAULT, @@ -2609,25 +2457,16 @@ DEFUN (no_ospf_timers_throttle_spf, OSPF_SPF_MAX_HOLDTIME_DEFAULT); } -ALIAS (no_ospf_timers_throttle_spf, - no_ospf_timers_throttle_spf_val_cmd, - "no timers throttle spf <0-600000> <0-600000> <0-600000>", - NO_STR - "Adjust routing timers\n" - "Throttling adaptive timer\n" - "OSPF SPF timers\n" - "Delay (msec) from first change received till SPF calculation\n" - "Initial hold time (msec) between consecutive SPF calculations\n" - "Maximum hold time (msec)\n") DEFUN (ospf_timers_lsa, ospf_timers_lsa_cmd, - "timers lsa min-arrival <0-600000>", + "timers lsa min-arrival (0-600000)", "Adjust routing timers\n" "OSPF LSA timers\n" "Minimum delay in receiving new version of a LSA\n" "Delay in milliseconds\n") { + int idx_number = 3; unsigned int minarrival; struct ospf *ospf = vty->index; @@ -2640,7 +2479,7 @@ DEFUN (ospf_timers_lsa, return CMD_WARNING; } - VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[0]); + VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[idx_number]->arg); ospf->min_ls_arrival = minarrival; @@ -2649,11 +2488,12 @@ DEFUN (ospf_timers_lsa, DEFUN (no_ospf_timers_lsa, no_ospf_timers_lsa_cmd, - "no timers lsa min-arrival", + "no timers lsa min-arrival [(0-600000)]", NO_STR "Adjust routing timers\n" "OSPF LSA timers\n" - "Minimum delay in receiving new version of a LSA\n") + "Minimum delay in receiving new version of a LSA\n" + "Delay in milliseconds\n") { unsigned int minarrival; struct ospf *ospf = vty->index; @@ -2661,9 +2501,9 @@ DEFUN (no_ospf_timers_lsa, if (!ospf) return CMD_SUCCESS; - if (argc) + if (argc > 4) { - VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[0]); + VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[4]->arg); if (ospf->min_ls_arrival != minarrival || minarrival == OSPF_MIN_LS_ARRIVAL) @@ -2675,22 +2515,19 @@ DEFUN (no_ospf_timers_lsa, return CMD_SUCCESS; } -ALIAS (no_ospf_timers_lsa, - no_ospf_timers_lsa_val_cmd, - "no timers lsa min-arrival <0-600000>", - NO_STR - "Adjust routing timers\n" - "OSPF LSA timers\n" - "Minimum delay in receiving new version of a LSA\n" - "Delay in milliseconds\n") - - DEFUN (ospf_neighbor, ospf_neighbor_cmd, - "neighbor A.B.C.D", + "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]", NEIGHBOR_STR - "Neighbor IP address\n") + "Neighbor IP address\n" + "Neighbor Priority\n" + "Priority\n" + "Dead Neighbor Polling interval\n" + "Seconds\n") { + int idx_ipv4 = 1; + int idx_pri = 3; + int idx_poll = 5; struct ospf *ospf = vty->index; struct in_addr nbr_addr; unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; @@ -2699,49 +2536,38 @@ DEFUN (ospf_neighbor, if (!ospf) return CMD_SUCCESS; - VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); - - if (argc > 1) - VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255); + VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); if (argc > 2) - VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535); + VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[idx_pri]->arg, 0, 255); + + if (argc > 4) + VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[idx_poll]->arg, 1, 65535); ospf_nbr_nbma_set (ospf, nbr_addr); - if (argc > 1) - ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); + if (argc > 2) + ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); + + if (argc > 4) ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); return CMD_SUCCESS; } -ALIAS (ospf_neighbor, - ospf_neighbor_priority_poll_interval_cmd, - "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", - NEIGHBOR_STR - "Neighbor IP address\n" - "Neighbor Priority\n" - "Priority\n" - "Dead Neighbor Polling interval\n" - "Seconds\n") - -ALIAS (ospf_neighbor, - ospf_neighbor_priority_cmd, - "neighbor A.B.C.D priority <0-255>", - NEIGHBOR_STR - "Neighbor IP address\n" - "Neighbor Priority\n" - "Seconds\n") - DEFUN (ospf_neighbor_poll_interval, ospf_neighbor_poll_interval_cmd, - "neighbor A.B.C.D poll-interval <1-65535>", + "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]", NEIGHBOR_STR "Neighbor IP address\n" "Dead Neighbor Polling interval\n" - "Seconds\n") + "Seconds\n" + "OSPF priority of non-broadcast neighbor\n" + "Priority\n") { + int idx_ipv4 = 1; + int idx_poll = 3; + int idx_pri = 5; struct ospf *ospf = vty->index; struct in_addr nbr_addr; unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; @@ -2750,106 +2576,87 @@ DEFUN (ospf_neighbor_poll_interval, if (!ospf) return CMD_SUCCESS; - VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); + VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); - if (argc > 1) - VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535); + VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[idx_poll]->arg, 1, 65535); - if (argc > 2) - VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); + if (argc > 4) + VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[idx_pri]->arg, 0, 255); ospf_nbr_nbma_set (ospf, nbr_addr); - if (argc > 1) - ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); - if (argc > 2) + ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); + + if (argc > 4) ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); return CMD_SUCCESS; } -ALIAS (ospf_neighbor_poll_interval, - ospf_neighbor_poll_interval_priority_cmd, - "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", - NEIGHBOR_STR - "Neighbor address\n" - "OSPF dead-router polling interval\n" - "Seconds\n" - "OSPF priority of non-broadcast neighbor\n" - "Priority\n") - DEFUN (no_ospf_neighbor, no_ospf_neighbor_cmd, - "no neighbor A.B.C.D", + "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]", NO_STR NEIGHBOR_STR - "Neighbor IP address\n") + "Neighbor IP address\n" + "Neighbor Priority\n" + "Priority\n" + "Dead Neighbor Polling interval\n" + "Seconds\n") { + int idx_ipv4 = 2; struct ospf *ospf = vty->index; struct in_addr nbr_addr; if (!ospf) return CMD_SUCCESS; - VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); + VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); (void)ospf_nbr_nbma_unset (ospf, nbr_addr); return CMD_SUCCESS; } -ALIAS (no_ospf_neighbor, - no_ospf_neighbor_priority_cmd, - "no neighbor A.B.C.D priority <0-255>", +DEFUN (no_ospf_neighbor_poll, + no_ospf_neighbor_poll_cmd, + "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]", NO_STR NEIGHBOR_STR "Neighbor IP address\n" + "Dead Neighbor Polling interval\n" + "Seconds\n" "Neighbor Priority\n" "Priority\n") +{ + int idx_ipv4 = 2; + struct ospf *ospf = vty->index; + struct in_addr nbr_addr; -ALIAS (no_ospf_neighbor, - no_ospf_neighbor_poll_interval_cmd, - "no neighbor A.B.C.D poll-interval <1-65535>", - NO_STR - NEIGHBOR_STR - "Neighbor IP address\n" - "Dead Neighbor Polling interval\n" - "Seconds\n") + if (!ospf) + return CMD_SUCCESS; -ALIAS (no_ospf_neighbor, - no_ospf_neighbor_poll_interval_priority_cmd, - "no neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", - NO_STR - NEIGHBOR_STR - "Neighbor IP address\n" - "Dead Neighbor Polling interval\n" - "Seconds\n" - "OSPF priority of non-broadcast neighbor\n" - "Priority\n") + VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); -ALIAS (no_ospf_neighbor, - no_ospf_neighbor_priority_pollinterval_cmd, - "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", - NO_STR - NEIGHBOR_STR - "Neighbor IP address\n" - "Neighbor Priority\n" - "Priority\n" - "Dead Neighbor Polling interval\n" - "Seconds\n") + (void)ospf_nbr_nbma_unset (ospf, nbr_addr); -DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd, - "refresh timer <10-1800>", + return CMD_SUCCESS; +} + +DEFUN (ospf_refresh_timer, + ospf_refresh_timer_cmd, + "refresh timer (10-1800)", "Adjust refresh parameters\n" "Set refresh timer\n" "Timer value in seconds\n") { + int idx_number = 2; struct ospf *ospf = vty->index; unsigned int interval; if (!ospf) return CMD_SUCCESS; - VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); + VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[idx_number]->arg, 10, 1800); interval = (interval / OSPF_LSA_REFRESHER_GRANULARITY) * OSPF_LSA_REFRESHER_GRANULARITY; ospf_timers_refresh_set (ospf, interval); @@ -2857,12 +2664,14 @@ DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd, return CMD_SUCCESS; } -DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd, - "no refresh timer <10-1800>", +DEFUN (no_ospf_refresh_timer, + no_ospf_refresh_timer_val_cmd, + "no refresh timer [(10-1800)]", "Adjust refresh parameters\n" "Unset refresh timer\n" "Timer value in seconds\n") { + int idx_number = 3; struct ospf *ospf = vty->index; unsigned int interval; @@ -2871,7 +2680,7 @@ DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd, if (argc == 1) { - VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); + VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[idx_number]->arg, 10, 1800); if (ospf->lsa_refresh_interval != interval || interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) @@ -2883,19 +2692,15 @@ DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd, return CMD_SUCCESS; } -ALIAS (no_ospf_refresh_timer, - no_ospf_refresh_timer_cmd, - "no refresh timer", - "Adjust refresh parameters\n" - "Unset refresh timer\n") DEFUN (ospf_auto_cost_reference_bandwidth, ospf_auto_cost_reference_bandwidth_cmd, - "auto-cost reference-bandwidth <1-4294967>", + "auto-cost reference-bandwidth (1-4294967)", "Calculate OSPF interface cost according to bandwidth\n" "Use reference bandwidth method to assign OSPF cost\n" "The reference bandwidth in terms of Mbits per second\n") { + int idx_number = 2; struct ospf *ospf = vty->index; u_int32_t refbw; struct listnode *node; @@ -2904,7 +2709,7 @@ DEFUN (ospf_auto_cost_reference_bandwidth, if (!ospf) return CMD_SUCCESS; - refbw = strtol (argv[0], NULL, 10); + refbw = strtol (argv[idx_number]->arg, NULL, 10); if (refbw < 1 || refbw > 4294967) { vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); @@ -2924,10 +2729,11 @@ DEFUN (ospf_auto_cost_reference_bandwidth, DEFUN (no_ospf_auto_cost_reference_bandwidth, no_ospf_auto_cost_reference_bandwidth_cmd, - "no auto-cost reference-bandwidth", + "no auto-cost reference-bandwidth [(1-4294967)]", NO_STR "Calculate OSPF interface cost according to bandwidth\n" - "Use reference bandwidth method to assign OSPF cost\n") + "Use reference bandwidth method to assign OSPF cost\n" + "The reference bandwidth in terms of Mbits per second\n") { struct ospf *ospf = vty->index; struct listnode *node, *nnode; @@ -2949,28 +2755,26 @@ DEFUN (no_ospf_auto_cost_reference_bandwidth, return CMD_SUCCESS; } -ALIAS (no_ospf_auto_cost_reference_bandwidth, - no_ospf_auto_cost_reference_bandwidth_val_cmd, - "no auto-cost reference-bandwidth <1-4294967>", - NO_STR - "Calculate OSPF interface cost according to bandwidth\n" - "Use reference bandwidth method to assign OSPF cost\n" - "The reference bandwidth in terms of Mbits per second\n") - DEFUN (ospf_write_multiplier, ospf_write_multiplier_cmd, - "ospf write-multiplier <1-100>", + "ospf write-multiplier (1-100)", "OSPF specific commands\n" "Write multiplier\n" "Maximum number of interface serviced per write\n") { + int idx_number; struct ospf *ospf = vty->index; u_int32_t write_oi_count; if (!ospf) return CMD_SUCCESS; - write_oi_count = strtol (argv[0], NULL, 10); + if (argc == 3) + idx_number = 2; + else + idx_number = 1; + + write_oi_count = strtol (argv[idx_number]->arg, NULL, 10); if (write_oi_count < 1 || write_oi_count > 100) { vty_out (vty, "write-multiplier value is invalid%s", VTY_NEWLINE); @@ -2982,14 +2786,14 @@ DEFUN (ospf_write_multiplier, } ALIAS (ospf_write_multiplier, - write_multiplier_cmd, - "write-multiplier <1-100>", - "Write multiplier\n" - "Maximum number of interface serviced per write\n") + write_multiplier_cmd, + "write-multiplier (1-100)", + "Write multiplier\n" + "Maximum number of interface serviced per write\n") DEFUN (no_ospf_write_multiplier, no_ospf_write_multiplier_cmd, - "no ospf write-multiplier <1-100>", + "no ospf write-multiplier (1-100)", NO_STR "OSPF specific commands\n" "Write multiplier\n" @@ -3005,17 +2809,11 @@ DEFUN (no_ospf_write_multiplier, } ALIAS (no_ospf_write_multiplier, - no_write_multiplier_cmd, - "no write-multiplier", - NO_STR - "Write multiplier\n") - -ALIAS (no_ospf_write_multiplier, - no_write_multiplier_val_cmd, - "no write-multiplier <1-100>", - NO_STR - "Write multiplier\n" - "Maximum number of interface serviced per write\n") + no_write_multiplier_cmd, + "no write-multiplier (1-100)", + NO_STR + "Write multiplier\n" + "Maximum number of interface serviced per write\n") const char *ospf_abr_type_descr_str[] = { @@ -3586,7 +3384,7 @@ show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) DEFUN (show_ip_ospf, show_ip_ospf_cmd, - "show ip ospf {json}", + "show ip ospf [json]", SHOW_STR IP_STR "OSPF information\n" @@ -3603,18 +3401,19 @@ DEFUN (show_ip_ospf, DEFUN (show_ip_ospf_instance, show_ip_ospf_instance_cmd, - "show ip ospf <1-65535> {json}", + "show ip ospf (1-65535) [json]", SHOW_STR IP_STR "OSPF information\n" "Instance ID\n" "JavaScript Object Notation\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; u_char uj = use_json(argc, argv); - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -3909,7 +3708,7 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface static int show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, - const char **argv, int iface_argv, u_char use_json) + struct cmd_token **argv, int iface_argv, u_char use_json) { struct interface *ifp; struct listnode *node; @@ -3944,7 +3743,7 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, } } } - else if (argv[iface_argv] && strcmp(argv[iface_argv], "json") == 0) + else if (argv[iface_argv] && strcmp(argv[iface_argv]->arg, "json") == 0) { if (!use_json) { @@ -3966,7 +3765,7 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, else { /* Interface name is specified. */ - if ((ifp = if_lookup_by_name (argv[iface_argv])) == NULL) + if ((ifp = if_lookup_by_name (argv[iface_argv]->arg)) == NULL) { if (use_json) json_object_boolean_true_add(json, "noSuchIface"); @@ -3994,7 +3793,7 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, DEFUN (show_ip_ospf_interface, show_ip_ospf_interface_cmd, - "show ip ospf interface [INTERFACE] {json}", + "show ip ospf interface [INTERFACE] [json]", SHOW_STR IP_STR "OSPF information\n" @@ -4013,7 +3812,7 @@ DEFUN (show_ip_ospf_interface, DEFUN (show_ip_ospf_instance_interface, show_ip_ospf_instance_interface_cmd, - "show ip ospf <1-65535> interface [INTERFACE] {json}", + "show ip ospf (1-65535) interface [INTERFACE] [json]", SHOW_STR IP_STR "OSPF information\n" @@ -4022,11 +3821,12 @@ DEFUN (show_ip_ospf_instance_interface, "Interface name\n" "JavaScript Object Notation\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; u_char uj = use_json(argc, argv); - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -4151,7 +3951,7 @@ show_ip_ospf_neighbor_common (struct vty *vty, struct ospf *ospf, u_char use_jso DEFUN (show_ip_ospf_neighbor, show_ip_ospf_neighbor_cmd, - "show ip ospf neighbor {json}", + "show ip ospf neighbor [json]", SHOW_STR IP_STR "OSPF information\n" @@ -4170,7 +3970,7 @@ DEFUN (show_ip_ospf_neighbor, DEFUN (show_ip_ospf_instance_neighbor, show_ip_ospf_instance_neighbor_cmd, - "show ip ospf <1-65535> neighbor {json}", + "show ip ospf (1-65535) neighbor [json]", SHOW_STR IP_STR "OSPF information\n" @@ -4178,11 +3978,12 @@ DEFUN (show_ip_ospf_instance_neighbor, "Neighbor list\n" "JavaScript Object Notation\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; u_char uj = use_json(argc, argv); - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -4262,7 +4063,7 @@ show_ip_ospf_neighbor_all_common (struct vty *vty, struct ospf *ospf, u_char use DEFUN (show_ip_ospf_neighbor_all, show_ip_ospf_neighbor_all_cmd, - "show ip ospf neighbor all {json}", + "show ip ospf neighbor all [json]", SHOW_STR IP_STR "OSPF information\n" @@ -4281,7 +4082,7 @@ DEFUN (show_ip_ospf_neighbor_all, DEFUN (show_ip_ospf_instance_neighbor_all, show_ip_ospf_instance_neighbor_all_cmd, - "show ip ospf <1-65535> neighbor all {json}", + "show ip ospf (1-65535) neighbor all [json]", SHOW_STR IP_STR "OSPF information\n" @@ -4290,11 +4091,12 @@ DEFUN (show_ip_ospf_instance_neighbor_all, "include down status neighbor\n" "JavaScript Object Notation\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; u_char uj = use_json(argc, argv); - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -4303,7 +4105,7 @@ DEFUN (show_ip_ospf_instance_neighbor_all, static int show_ip_ospf_neighbor_int_common (struct vty *vty, struct ospf *ospf, int arg_base, - const char **argv, u_char use_json) + struct cmd_token **argv, u_char use_json) { struct interface *ifp; struct route_node *rn; @@ -4323,7 +4125,7 @@ show_ip_ospf_neighbor_int_common (struct vty *vty, struct ospf *ospf, int arg_ba VTY_NEWLINE, VTY_NEWLINE); } - ifp = if_lookup_by_name (argv[arg_base]); + ifp = if_lookup_by_name (argv[arg_base]->arg); if (!ifp) { if (use_json) @@ -4356,7 +4158,7 @@ show_ip_ospf_neighbor_int_common (struct vty *vty, struct ospf *ospf, int arg_ba DEFUN (show_ip_ospf_neighbor_int, show_ip_ospf_neighbor_int_cmd, - "show ip ospf neighbor IFNAME {json}", + "show ip ospf neighbor IFNAME [json]", SHOW_STR IP_STR "OSPF information\n" @@ -4375,7 +4177,7 @@ DEFUN (show_ip_ospf_neighbor_int, DEFUN (show_ip_ospf_instance_neighbor_int, show_ip_ospf_instance_neighbor_int_cmd, - "show ip ospf <1-65535> neighbor IFNAME {json}", + "show ip ospf (1-65535) neighbor IFNAME [json]", SHOW_STR IP_STR "OSPF information\n" @@ -4384,11 +4186,12 @@ DEFUN (show_ip_ospf_instance_neighbor_int, "Interface name\n" "JavaScript Object Notation\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; u_char uj = use_json(argc, argv); - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -4672,7 +4475,7 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, static int show_ip_ospf_neighbor_id_common (struct vty *vty, struct ospf *ospf, - int arg_base, const char **argv, u_char use_json) + int arg_base, struct cmd_token **argv, u_char use_json) { struct listnode *node; struct ospf_neighbor *nbr; @@ -4693,7 +4496,7 @@ show_ip_ospf_neighbor_id_common (struct vty *vty, struct ospf *ospf, VTY_NEWLINE, VTY_NEWLINE); } - ret = inet_aton (argv[arg_base], &router_id); + ret = inet_aton (argv[arg_base]->arg, &router_id); if (!ret) { if (!use_json) @@ -4722,7 +4525,7 @@ show_ip_ospf_neighbor_id_common (struct vty *vty, struct ospf *ospf, DEFUN (show_ip_ospf_neighbor_id, show_ip_ospf_neighbor_id_cmd, - "show ip ospf neighbor A.B.C.D {json}", + "show ip ospf neighbor A.B.C.D [json]", SHOW_STR IP_STR "OSPF information\n" @@ -4741,7 +4544,7 @@ DEFUN (show_ip_ospf_neighbor_id, DEFUN (show_ip_ospf_instance_neighbor_id, show_ip_ospf_instance_neighbor_id_cmd, - "show ip ospf <1-65535> neighbor A.B.C.D {json}", + "show ip ospf (1-65535) neighbor A.B.C.D [json]", SHOW_STR IP_STR "OSPF information\n" @@ -4750,11 +4553,12 @@ DEFUN (show_ip_ospf_instance_neighbor_id, "Neighbor ID\n" "JavaScript Object Notation\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; u_char uj = use_json(argc, argv); - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -4813,7 +4617,7 @@ show_ip_ospf_neighbor_detail_common (struct vty *vty, struct ospf *ospf, u_char DEFUN (show_ip_ospf_neighbor_detail, show_ip_ospf_neighbor_detail_cmd, - "show ip ospf neighbor detail {json}", + "show ip ospf neighbor detail [json]", SHOW_STR IP_STR "OSPF information\n" @@ -4832,7 +4636,7 @@ DEFUN (show_ip_ospf_neighbor_detail, DEFUN (show_ip_ospf_instance_neighbor_detail, show_ip_ospf_instance_neighbor_detail_cmd, - "show ip ospf <1-65535> neighbor detail {json}", + "show ip ospf (1-65535) neighbor detail [json]", SHOW_STR IP_STR "OSPF information\n" @@ -4841,11 +4645,12 @@ DEFUN (show_ip_ospf_instance_neighbor_detail, "detail of all neighbors\n" "JavaScript Object Notation\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; u_char uj = use_json(argc, argv); - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -4910,7 +4715,7 @@ show_ip_ospf_neighbor_detail_all_common (struct vty *vty, struct ospf *ospf, u_c DEFUN (show_ip_ospf_neighbor_detail_all, show_ip_ospf_neighbor_detail_all_cmd, - "show ip ospf neighbor detail all {json}", + "show ip ospf neighbor detail all [json]", SHOW_STR IP_STR "OSPF information\n" @@ -4930,7 +4735,7 @@ DEFUN (show_ip_ospf_neighbor_detail_all, DEFUN (show_ip_ospf_instance_neighbor_detail_all, show_ip_ospf_instance_neighbor_detail_all_cmd, - "show ip ospf <1-65535> neighbor detail all {json}", + "show ip ospf (1-65535) neighbor detail all [json]", SHOW_STR IP_STR "OSPF information\n" @@ -4940,11 +4745,12 @@ DEFUN (show_ip_ospf_instance_neighbor_detail_all, "include down status neighbor\n" "JavaScript Object Notation\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; u_char uj = use_json(argc, argv); - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -4953,7 +4759,7 @@ DEFUN (show_ip_ospf_instance_neighbor_detail_all, static int show_ip_ospf_neighbor_int_detail_common (struct vty *vty, struct ospf *ospf, - int arg_base, const char **argv, u_char use_json) + int arg_base, struct cmd_token **argv, u_char use_json) { struct ospf_interface *oi; struct interface *ifp; @@ -4973,7 +4779,7 @@ show_ip_ospf_neighbor_int_detail_common (struct vty *vty, struct ospf *ospf, VTY_NEWLINE, VTY_NEWLINE); } - ifp = if_lookup_by_name (argv[arg_base]); + ifp = if_lookup_by_name (argv[arg_base]->arg); if (!ifp) { if (!use_json) @@ -5012,7 +4818,7 @@ show_ip_ospf_neighbor_int_detail_common (struct vty *vty, struct ospf *ospf, DEFUN (show_ip_ospf_neighbor_int_detail, show_ip_ospf_neighbor_int_detail_cmd, - "show ip ospf neighbor IFNAME detail {json}", + "show ip ospf neighbor IFNAME detail [json]", SHOW_STR IP_STR "OSPF information\n" @@ -5032,7 +4838,7 @@ DEFUN (show_ip_ospf_neighbor_int_detail, DEFUN (show_ip_ospf_instance_neighbor_int_detail, show_ip_ospf_instance_neighbor_int_detail_cmd, - "show ip ospf <1-65535> neighbor IFNAME detail {json}", + "show ip ospf (1-65535) neighbor IFNAME detail [json]", SHOW_STR IP_STR "OSPF information\n" @@ -5042,11 +4848,12 @@ DEFUN (show_ip_ospf_instance_neighbor_int_detail, "detail of all neighbors\n" "JavaScript Object Notation\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; u_char uj = use_json(argc, argv); - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -5356,7 +5163,6 @@ show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) return 0; } - #if 0 static int show_as_external_lsa_stdvty (struct ospf_lsa *lsa) @@ -5382,7 +5188,6 @@ show_as_external_lsa_stdvty (struct ospf_lsa *lsa) return 0; } #endif - /* Show AS-NSSA-LSA detail information. */ static int show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) @@ -5669,11 +5474,6 @@ show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" -#define OSPF_LSA_TYPES_CMD_STR \ - "asbr-summary|external|network|router|summary" \ - OSPF_LSA_TYPE_NSSA_CMD_STR \ - OSPF_LSA_TYPE_OPAQUE_CMD_STR - #define OSPF_LSA_TYPES_DESC \ "ASBR summary link states\n" \ "External link states\n" \ @@ -5687,8 +5487,9 @@ show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) static int show_ip_ospf_database_common (struct vty *vty, struct ospf *ospf, - int arg_base, int argc, const char **argv) + int arg_base, int argc, struct cmd_token **argv) { + int idx_type = 4; int type, ret; struct in_addr id, adv_router; @@ -5700,64 +5501,64 @@ show_ip_ospf_database_common (struct vty *vty, struct ospf *ospf, inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); /* Show all LSA. */ - if (argc == arg_base + 0) + if (argc == arg_base + 4) { show_ip_ospf_database_summary (vty, ospf, 0); return CMD_SUCCESS; } /* Set database type to show. */ - if (strncmp (argv[arg_base + 0], "r", 1) == 0) + if (strncmp (argv[arg_base + idx_type]->text, "r", 1) == 0) type = OSPF_ROUTER_LSA; - else if (strncmp (argv[arg_base + 0], "ne", 2) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "ne", 2) == 0) type = OSPF_NETWORK_LSA; - else if (strncmp (argv[arg_base + 0], "ns", 2) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "ns", 2) == 0) type = OSPF_AS_NSSA_LSA; - else if (strncmp (argv[arg_base + 0], "su", 2) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "su", 2) == 0) type = OSPF_SUMMARY_LSA; - else if (strncmp (argv[arg_base + 0], "a", 1) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "a", 1) == 0) type = OSPF_ASBR_SUMMARY_LSA; - else if (strncmp (argv[arg_base + 0], "e", 1) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "e", 1) == 0) type = OSPF_AS_EXTERNAL_LSA; - else if (strncmp (argv[arg_base + 0], "se", 2) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "se", 2) == 0) { show_ip_ospf_database_summary (vty, ospf, 1); return CMD_SUCCESS; } - else if (strncmp (argv[arg_base + 0], "m", 1) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "m", 1) == 0) { show_ip_ospf_database_maxage (vty, ospf); return CMD_SUCCESS; } - else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "opaque-l", 8) == 0) type = OSPF_OPAQUE_LINK_LSA; - else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "opaque-ar", 9) == 0) type = OSPF_OPAQUE_AREA_LSA; - else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "opaque-as", 9) == 0) type = OSPF_OPAQUE_AS_LSA; else return CMD_WARNING; /* `show ip ospf database LSA'. */ - if (argc == arg_base + 1) + if (argc == arg_base + 5) show_lsa_detail (vty, ospf, type, NULL, NULL); - else if (argc >= arg_base + 2) + else if (argc >= arg_base + 6) { - ret = inet_aton (argv[arg_base + 1], &id); + ret = inet_aton (argv[arg_base + 5]->arg, &id); if (!ret) return CMD_WARNING; /* `show ip ospf database LSA ID'. */ - if (argc == arg_base + 2) + if (argc == arg_base + 6) show_lsa_detail (vty, ospf, type, &id, NULL); /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ - else if (argc == arg_base + 3) + else if (argc == arg_base + 7) { - if (strncmp (argv[arg_base + 2], "s", 1) == 0) + if (strncmp (argv[arg_base + 6]->text, "s", 1) == 0) adv_router = ospf->router_id; else { - ret = inet_aton (argv[arg_base + 2], &adv_router); + ret = inet_aton (argv[arg_base + 7]->arg, &adv_router); if (!ret) return CMD_WARNING; } @@ -5770,11 +5571,16 @@ show_ip_ospf_database_common (struct vty *vty, struct ospf *ospf, DEFUN (show_ip_ospf_database, show_ip_ospf_database_cmd, - "show ip ospf database", + "show ip ospf database [<asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> [A.B.C.D [<self-originate|adv-router A.B.C.D>]]]", SHOW_STR IP_STR "OSPF information\n" - "Database summary\n") + "Database summary\n" + OSPF_LSA_TYPES_DESC + "Link State ID (as an IP address)\n" + "Self-originated link states\n" + "Advertising Router link states\n" + "Advertising Router (as an IP address)\n") { struct ospf *ospf; @@ -5784,64 +5590,43 @@ DEFUN (show_ip_ospf_database, return (show_ip_ospf_database_common(vty, ospf, 0, argc, argv)); } -ALIAS (show_ip_ospf_database, - show_ip_ospf_database_type_cmd, - "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", +DEFUN (show_ip_ospf_database_max, + show_ip_ospf_database_max_cmd, + "show ip ospf database <max-age|self-originate>", SHOW_STR IP_STR "OSPF information\n" "Database summary\n" - OSPF_LSA_TYPES_DESC "LSAs in MaxAge list\n" "Self-originated link states\n") +{ + struct ospf *ospf; -ALIAS (show_ip_ospf_database, - show_ip_ospf_database_type_id_cmd, - "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", - SHOW_STR - IP_STR - "OSPF information\n" - "Database summary\n" - OSPF_LSA_TYPES_DESC - "Link State ID (as an IP address)\n") - -ALIAS (show_ip_ospf_database, - show_ip_ospf_database_type_id_adv_router_cmd, - "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", - SHOW_STR - IP_STR - "OSPF information\n" - "Database summary\n" - OSPF_LSA_TYPES_DESC - "Link State ID (as an IP address)\n" - "Advertising Router link states\n" - "Advertising Router (as an IP address)\n") + if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) + return CMD_SUCCESS; -ALIAS (show_ip_ospf_database, - show_ip_ospf_database_type_id_self_cmd, - "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", - SHOW_STR - IP_STR - "OSPF information\n" - "Database summary\n" - OSPF_LSA_TYPES_DESC - "Link State ID (as an IP address)\n" - "Self-originated link states\n" - "\n") + return (show_ip_ospf_database_common(vty, ospf, 0, argc, argv)); +} DEFUN (show_ip_ospf_instance_database, show_ip_ospf_instance_database_cmd, - "show ip ospf <1-65535> database", + "show ip ospf (1-65535) database [<asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> [A.B.C.D [<self-originate|adv-router A.B.C.D>]]]", SHOW_STR IP_STR "OSPF information\n" "Instance ID\n" - "Database summary\n") + "Database summary\n" + OSPF_LSA_TYPES_DESC + "Link State ID (as an IP address)\n" + "Self-originated link states\n" + "Advertising Router link states\n" + "Advertising Router (as an IP address)\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -5849,60 +5634,35 @@ DEFUN (show_ip_ospf_instance_database, return (show_ip_ospf_database_common(vty, ospf, 1, argc, argv)); } -ALIAS (show_ip_ospf_instance_database, - show_ip_ospf_instance_database_type_cmd, - "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", +DEFUN (show_ip_ospf_instance_database_max, + show_ip_ospf_instance_database_max_cmd, + "show ip ospf (1-65535) database <max-age|self-originate>", SHOW_STR IP_STR "OSPF information\n" "Instance ID\n" "Database summary\n" - OSPF_LSA_TYPES_DESC "LSAs in MaxAge list\n" "Self-originated link states\n") +{ + int idx_number = 3; + struct ospf *ospf; + u_short instance = 0; -ALIAS (show_ip_ospf_instance_database, - show_ip_ospf_instance_database_type_id_cmd, - "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", - SHOW_STR - IP_STR - "OSPF information\n" - "Instance ID\n" - "Database summary\n" - OSPF_LSA_TYPES_DESC - "Link State ID (as an IP address)\n") + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); -ALIAS (show_ip_ospf_instance_database, - show_ip_ospf_instance_database_type_id_adv_router_cmd, - "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", - SHOW_STR - IP_STR - "OSPF information\n" - "Instance ID\n" - "Database summary\n" - OSPF_LSA_TYPES_DESC - "Link State ID (as an IP address)\n" - "Advertising Router link states\n" - "Advertising Router (as an IP address)\n") + if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) + return CMD_SUCCESS; -ALIAS (show_ip_ospf_instance_database, - show_ip_ospf_instance_database_type_id_self_cmd, - "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", - SHOW_STR - IP_STR - "OSPF information\n" - "Instance ID\n" - "Database summary\n" - OSPF_LSA_TYPES_DESC - "Link State ID (as an IP address)\n" - "Self-originated link states\n" - "\n") + return (show_ip_ospf_database_common(vty, ospf, 1, argc, argv)); +} static int show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf, - int arg_base, int argc, const char **argv) + int arg_base, int argc, struct cmd_token **argv) { + int idx_type = 4; int type, ret; struct in_addr adv_router; @@ -5913,37 +5673,37 @@ show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); - if (argc != arg_base + 2) + if (argc != arg_base + 7) return CMD_WARNING; /* Set database type to show. */ - if (strncmp (argv[arg_base + 0], "r", 1) == 0) + if (strncmp (argv[arg_base + idx_type]->text, "r", 1) == 0) type = OSPF_ROUTER_LSA; - else if (strncmp (argv[arg_base + 0], "ne", 2) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "ne", 2) == 0) type = OSPF_NETWORK_LSA; - else if (strncmp (argv[arg_base + 0], "ns", 2) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "ns", 2) == 0) type = OSPF_AS_NSSA_LSA; - else if (strncmp (argv[arg_base + 0], "s", 1) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "s", 1) == 0) type = OSPF_SUMMARY_LSA; - else if (strncmp (argv[arg_base + 0], "a", 1) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "a", 1) == 0) type = OSPF_ASBR_SUMMARY_LSA; - else if (strncmp (argv[arg_base + 0], "e", 1) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "e", 1) == 0) type = OSPF_AS_EXTERNAL_LSA; - else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "opaque-l", 8) == 0) type = OSPF_OPAQUE_LINK_LSA; - else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "opaque-ar", 9) == 0) type = OSPF_OPAQUE_AREA_LSA; - else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "opaque-as", 9) == 0) type = OSPF_OPAQUE_AS_LSA; else return CMD_WARNING; /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ - if (strncmp (argv[arg_base + 1], "s", 1) == 0) + if (strncmp (argv[arg_base + 5]->text, "s", 1) == 0) adv_router = ospf->router_id; else { - ret = inet_aton (argv[arg_base + 1], &adv_router); + ret = inet_aton (argv[arg_base + 6]->arg, &adv_router); if (!ret) return CMD_WARNING; } @@ -5955,14 +5715,15 @@ show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf DEFUN (show_ip_ospf_database_type_adv_router, show_ip_ospf_database_type_adv_router_cmd, - "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", + "show ip ospf database <asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> <adv-router A.B.C.D|self-originate>", SHOW_STR IP_STR "OSPF information\n" "Database summary\n" OSPF_LSA_TYPES_DESC "Advertising Router link states\n" - "Advertising Router (as an IP address)\n") + "Advertising Router (as an IP address)\n" + "Self-originated link states\n") { struct ospf *ospf; @@ -5972,19 +5733,9 @@ DEFUN (show_ip_ospf_database_type_adv_router, return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 0, argc, argv)); } -ALIAS (show_ip_ospf_database_type_adv_router, - show_ip_ospf_database_type_self_cmd, - "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", - SHOW_STR - IP_STR - "OSPF information\n" - "Database summary\n" - OSPF_LSA_TYPES_DESC - "Self-originated link states\n") - DEFUN (show_ip_ospf_instance_database_type_adv_router, show_ip_ospf_instance_database_type_adv_router_cmd, - "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", + "show ip ospf (1-65535) database <asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> <adv-router A.B.C.D|self-originate>", SHOW_STR IP_STR "OSPF information\n" @@ -5994,10 +5745,11 @@ DEFUN (show_ip_ospf_instance_database_type_adv_router, "Advertising Router link states\n" "Advertising Router (as an IP address)\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -6005,27 +5757,18 @@ DEFUN (show_ip_ospf_instance_database_type_adv_router, return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 1, argc, argv)); } -ALIAS (show_ip_ospf_instance_database_type_adv_router, - show_ip_ospf_instance_database_type_self_cmd, - "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", - SHOW_STR - IP_STR - "OSPF information\n" - "Instance ID\n" - "Database summary\n" - OSPF_LSA_TYPES_DESC - "Self-originated link states\n") - DEFUN (ip_ospf_authentication_args, ip_ospf_authentication_args_addr_cmd, - "ip ospf authentication (null|message-digest) A.B.C.D", + "ip ospf authentication <null|message-digest> [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Enable authentication on this interface\n" "Use null authentication\n" "Use message-digest authentication\n" - "Address of interface") + "Address of interface\n") { + int idx_encryption = 3; + int idx_ipv4 = 4; struct interface *ifp; struct in_addr addr; int ret; @@ -6034,9 +5777,9 @@ DEFUN (ip_ospf_authentication_args, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 5) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6049,7 +5792,7 @@ DEFUN (ip_ospf_authentication_args, } /* Handle null authentication */ - if ( argv[0][0] == 'n' ) + if ( argv[idx_encryption]->arg[0] == 'n' ) { SET_IF_PARAM (params, auth_type); params->auth_type = OSPF_AUTH_NULL; @@ -6057,7 +5800,7 @@ DEFUN (ip_ospf_authentication_args, } /* Handle message-digest authentication */ - if ( argv[0][0] == 'm' ) + if ( argv[idx_encryption]->arg[0] == 'm' ) { SET_IF_PARAM (params, auth_type); params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; @@ -6068,23 +5811,15 @@ DEFUN (ip_ospf_authentication_args, return CMD_WARNING; } -ALIAS (ip_ospf_authentication_args, - ip_ospf_authentication_args_cmd, - "ip ospf authentication (null|message-digest)", - "IP Information\n" - "OSPF interface commands\n" - "Enable authentication on this interface\n" - "Use null authentication\n" - "Use message-digest authentication\n") - DEFUN (ip_ospf_authentication, ip_ospf_authentication_addr_cmd, - "ip ospf authentication A.B.C.D", + "ip ospf authentication [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Enable authentication on this interface\n" "Address of interface") { + int idx_ipv4 = 3; struct interface *ifp; struct in_addr addr; int ret; @@ -6093,9 +5828,9 @@ DEFUN (ip_ospf_authentication, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 1) + if (argc == 4) { - ret = inet_aton(argv[0], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6113,16 +5848,9 @@ DEFUN (ip_ospf_authentication, return CMD_SUCCESS; } -ALIAS (ip_ospf_authentication, - ip_ospf_authentication_cmd, - "ip ospf authentication", - "IP Information\n" - "OSPF interface commands\n" - "Enable authentication on this interface\n") - DEFUN (no_ip_ospf_authentication_args, no_ip_ospf_authentication_args_addr_cmd, - "no ip ospf authentication (null|message-digest) A.B.C.D", + "no ip ospf authentication <null|message-digest> [A.B.C.D]", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -6131,6 +5859,8 @@ DEFUN (no_ip_ospf_authentication_args, "Use message-digest authentication\n" "Address of interface") { + int idx_encryption = 4; + int idx_ipv4 = 5; struct interface *ifp; struct in_addr addr; int ret; @@ -6141,9 +5871,9 @@ DEFUN (no_ip_ospf_authentication_args, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 6) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6167,11 +5897,11 @@ DEFUN (no_ip_ospf_authentication_args, } else { - if ( argv[0][0] == 'n' ) + if ( argv[idx_encryption]->arg[0] == 'n' ) { auth_type = OSPF_AUTH_NULL; } - else if ( argv[0][0] == 'm' ) + else if ( argv[idx_encryption]->arg[0] == 'm' ) { auth_type = OSPF_AUTH_CRYPTOGRAPHIC; } @@ -6213,25 +5943,16 @@ DEFUN (no_ip_ospf_authentication_args, return CMD_SUCCESS; } -ALIAS (no_ip_ospf_authentication_args, - no_ip_ospf_authentication_args_cmd, - "no ip ospf authentication (null|message-digest)", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Enable authentication on this interface\n" - "Use null authentication\n" - "Use message-digest authentication\n") - DEFUN (no_ip_ospf_authentication, no_ip_ospf_authentication_addr_cmd, - "no ip ospf authentication A.B.C.D", + "no ip ospf authentication [A.B.C.D]", NO_STR "IP Information\n" "OSPF interface commands\n" "Enable authentication on this interface\n" "Address of interface") { + int idx_ipv4 = 4; struct interface *ifp; struct in_addr addr; int ret; @@ -6241,9 +5962,9 @@ DEFUN (no_ip_ospf_authentication, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 1) + if (argc == 5) { - ret = inet_aton(argv[0], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6305,23 +6026,16 @@ DEFUN (no_ip_ospf_authentication, return CMD_SUCCESS; } -ALIAS (no_ip_ospf_authentication, - no_ip_ospf_authentication_cmd, - "no ip ospf authentication", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Enable authentication on this interface\n") - DEFUN (ip_ospf_authentication_key, ip_ospf_authentication_key_addr_cmd, - "ip ospf authentication-key AUTH_KEY A.B.C.D", + "ip ospf authentication-key AUTH_KEY [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Authentication password (key)\n" "The OSPF password (key)\n" "Address of interface") { + int idx_ipv4 = 4; struct interface *ifp; struct in_addr addr; int ret; @@ -6330,9 +6044,9 @@ DEFUN (ip_ospf_authentication_key, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 5) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6345,32 +6059,36 @@ DEFUN (ip_ospf_authentication_key, } memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); - strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE); + strncpy ((char *) params->auth_simple, argv[3]->arg, OSPF_AUTH_SIMPLE_SIZE); SET_IF_PARAM (params, auth_simple); return CMD_SUCCESS; } -ALIAS (ip_ospf_authentication_key, - ip_ospf_authentication_key_cmd, - "ip ospf authentication-key AUTH_KEY", - "IP Information\n" - "OSPF interface commands\n" - "Authentication password (key)\n" - "The OSPF password (key)") -ALIAS_HIDDEN (ip_ospf_authentication_key, +DEFUN_HIDDEN (ospf_authentication_key, ospf_authentication_key_cmd, "ospf authentication-key AUTH_KEY", "OSPF interface commands\n" "Authentication password (key)\n" "The OSPF password (key)") +{ + struct interface *ifp; + struct ospf_if_params *params; -DEFUN (no_ip_ospf_authentication_key, - no_ip_ospf_authentication_key_authkey_addr_cmd, - "no ip ospf authentication-key AUTH_KEY A.B.C.D", + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); + memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); + strncpy ((char *) params->auth_simple, argv[2]->arg, OSPF_AUTH_SIMPLE_SIZE); + SET_IF_PARAM (params, auth_simple); + + return CMD_SUCCESS; +} + +DEFUN (no_ospf_authentication_key, + no_ospf_authentication_key_authkey_addr_cmd, + "no ospf authentication-key [AUTH_KEY [A.B.C.D]]", NO_STR - "IP Information\n" "OSPF interface commands\n" "Authentication password (key)\n" "The OSPF password (key)") @@ -6383,9 +6101,9 @@ DEFUN (no_ip_ospf_authentication_key, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 5) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6410,49 +6128,53 @@ DEFUN (no_ip_ospf_authentication_key, return CMD_SUCCESS; } -ALIAS (no_ip_ospf_authentication_key, - no_ip_ospf_authentication_key_authkey_cmd, - "no ip ospf authentication-key AUTH_KEY", +DEFUN (no_ip_ospf_authentication_key, + no_ip_ospf_authentication_key_authkey_addr_cmd, + "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]", NO_STR "IP Information\n" "OSPF interface commands\n" - "Authentication password (key)\n") + "Authentication password (key)\n" + "The OSPF password (key)") +{ + struct interface *ifp; + struct in_addr addr; + struct ospf_if_params *params; + int ret; -ALIAS (no_ip_ospf_authentication_key, - no_ip_ospf_authentication_key_cmd, - "no ip ospf authentication-key", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Authentication password (key)\n") + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); -ALIAS (no_ip_ospf_authentication_key, - no_ospf_authentication_key_cmd, - "no ospf authentication-key", - NO_STR - "OSPF interface commands\n" - "Authentication password (key)\n") + if (argc == 6) + { + ret = inet_aton(argv[5]->arg, &addr); + if (!ret) + { + vty_out (vty, "Please specify interface address by A.B.C.D%s", + VTY_NEWLINE); + return CMD_WARNING; + } -ALIAS (no_ip_ospf_authentication_key, - no_ospf_authentication_key_authkey_cmd, - "no ospf authentication-key AUTH_KEY", - NO_STR - "OSPF interface commands\n" - "Authentication password (key)\n" - "The OSPF password (key)\n") + params = ospf_lookup_if_params (ifp, addr); + if (params == NULL) + return CMD_SUCCESS; + } -ALIAS (no_ip_ospf_authentication_key, - no_ospf_authentication_key_authkey_ip_cmd, - "no ospf authentication-key AUTH_KEY A.B.C.D", - NO_STR - "OSPF interface commands\n" - "Authentication password (key)\n" - "The OSPF password (key)\n" - "Address of interface") + memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); + UNSET_IF_PARAM (params, auth_simple); + + if (params != IF_DEF_PARAMS (ifp)) + { + ospf_free_if_params (ifp, addr); + ospf_if_update_params (ifp, addr); + } + + return CMD_SUCCESS; +} DEFUN (ip_ospf_message_digest_key, ip_ospf_message_digest_key_addr_cmd, - "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", + "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Message digest authentication password (key)\n" @@ -6461,6 +6183,8 @@ DEFUN (ip_ospf_message_digest_key, "The OSPF password (key)" "Address of interface") { + int idx_number = 3; + int idx_ipv4 = 6; struct interface *ifp; struct crypt_key *ck; u_char key_id; @@ -6471,9 +6195,9 @@ DEFUN (ip_ospf_message_digest_key, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 3) + if (argc == 7) { - ret = inet_aton(argv[2], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6485,7 +6209,7 @@ DEFUN (ip_ospf_message_digest_key, ospf_if_update_params (ifp, addr); } - key_id = strtol (argv[0], NULL, 10); + key_id = strtol (argv[idx_number]->arg, NULL, 10); if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) { vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); @@ -6495,7 +6219,7 @@ DEFUN (ip_ospf_message_digest_key, ck = ospf_crypt_key_new (); ck->key_id = (u_char) key_id; memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); - strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE); + strncpy ((char *) ck->auth_key, argv[idx_ipv4]->arg, OSPF_AUTH_MD5_SIZE); ospf_crypt_key_add (params->auth_crypt, ck); SET_IF_PARAM (params, auth_crypt); @@ -6503,28 +6227,45 @@ DEFUN (ip_ospf_message_digest_key, return CMD_SUCCESS; } -ALIAS (ip_ospf_message_digest_key, - ip_ospf_message_digest_key_cmd, - "ip ospf message-digest-key <1-255> md5 KEY", - "IP Information\n" - "OSPF interface commands\n" - "Message digest authentication password (key)\n" - "Key ID\n" - "Use MD5 algorithm\n" - "The OSPF password (key)") -ALIAS_HIDDEN (ip_ospf_message_digest_key, +DEFUN_HIDDEN (ospf_message_digest_key, ospf_message_digest_key_cmd, - "ospf message-digest-key <1-255> md5 KEY", + "ospf message-digest-key (1-255) md5 KEY", "OSPF interface commands\n" "Message digest authentication password (key)\n" "Key ID\n" "Use MD5 algorithm\n" "The OSPF password (key)") +{ + int idx_number = 2; + struct interface *ifp; + struct crypt_key *ck; + u_char key_id; + struct ospf_if_params *params; + + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); + key_id = strtol (argv[idx_number]->arg, NULL, 10); + if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) + { + vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); + return CMD_WARNING; + } + + ck = ospf_crypt_key_new (); + ck->key_id = (u_char) key_id; + memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); + strncpy ((char *) ck->auth_key, argv[idx_number]->arg, OSPF_AUTH_MD5_SIZE); + + ospf_crypt_key_add (params->auth_crypt, ck); + SET_IF_PARAM (params, auth_crypt); + + return CMD_SUCCESS; +} DEFUN (no_ip_ospf_message_digest_key_md5, no_ip_ospf_message_digest_key_md5_addr_cmd, - "no ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", + "no ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -6534,6 +6275,7 @@ DEFUN (no_ip_ospf_message_digest_key_md5, "The OSPF password (key)" "Address of interface") { + int idx_number = 4; struct interface *ifp; struct crypt_key *ck; int key_id; @@ -6544,9 +6286,9 @@ DEFUN (no_ip_ospf_message_digest_key_md5, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 3) + if (argc == 8) { - ret = inet_aton(argv[2], &addr); + ret = inet_aton(argv[7]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6559,7 +6301,7 @@ DEFUN (no_ip_ospf_message_digest_key_md5, return CMD_SUCCESS; } - key_id = strtol (argv[0], NULL, 10); + key_id = strtol (argv[idx_number]->arg, NULL, 10); ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); if (ck == NULL) { @@ -6578,20 +6320,64 @@ DEFUN (no_ip_ospf_message_digest_key_md5, return CMD_SUCCESS; } -ALIAS (no_ip_ospf_message_digest_key_md5, - no_ip_ospf_message_digest_key_md5_cmd, - "no ip ospf message-digest-key <1-255> md5 KEY", - NO_STR - "IP Information\n" +DEFUN (no_ospf_message_digest_key, + no_ospf_message_digest_key_addr_cmd, + "no ospf message-digest-key (1-255) [A.B.C.D]", + NO_STR "OSPF interface commands\n" "Message digest authentication password (key)\n" "Key ID\n" - "Use MD5 algorithm\n" - "The OSPF password (key)") + "Address of interface") +{ + int idx_number = 3; + int idx_ipv4 = 4; + struct interface *ifp; + struct crypt_key *ck; + int key_id; + struct in_addr addr; + int ret; + struct ospf_if_params *params; + + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); + + if (argc == 5) + { + ret = inet_aton(argv[idx_ipv4]->arg, &addr); + if (!ret) + { + vty_out (vty, "Please specify interface address by A.B.C.D%s", + VTY_NEWLINE); + return CMD_WARNING; + } + + params = ospf_lookup_if_params (ifp, addr); + if (params == NULL) + return CMD_SUCCESS; + } + + key_id = strtol (argv[idx_number]->arg, NULL, 10); + ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); + if (ck == NULL) + { + vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); + return CMD_WARNING; + } + + ospf_crypt_key_delete (params->auth_crypt, key_id); + + if (params != IF_DEF_PARAMS (ifp)) + { + ospf_free_if_params (ifp, addr); + ospf_if_update_params (ifp, addr); + } + + return CMD_SUCCESS; +} DEFUN (no_ip_ospf_message_digest_key, no_ip_ospf_message_digest_key_addr_cmd, - "no ip ospf message-digest-key <1-255> A.B.C.D", + "no ip ospf message-digest-key (1-255) [A.B.C.D]", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -6599,19 +6385,21 @@ DEFUN (no_ip_ospf_message_digest_key, "Key ID\n" "Address of interface") { + int idx_number = 4; + int idx_ipv4 = 5; struct interface *ifp; struct crypt_key *ck; int key_id; struct in_addr addr; int ret; struct ospf_if_params *params; - + ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 6) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6624,7 +6412,7 @@ DEFUN (no_ip_ospf_message_digest_key, return CMD_SUCCESS; } - key_id = strtol (argv[0], NULL, 10); + key_id = strtol (argv[idx_number]->arg, NULL, 10); ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); if (ck == NULL) { @@ -6639,45 +6427,30 @@ DEFUN (no_ip_ospf_message_digest_key, ospf_free_if_params (ifp, addr); ospf_if_update_params (ifp, addr); } - + return CMD_SUCCESS; } -ALIAS (no_ip_ospf_message_digest_key, - no_ip_ospf_message_digest_key_cmd, - "no ip ospf message-digest-key <1-255>", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Message digest authentication password (key)\n" - "Key ID\n") - -ALIAS (no_ip_ospf_message_digest_key, - no_ospf_message_digest_key_cmd, - "no ospf message-digest-key <1-255>", - NO_STR - "OSPF interface commands\n" - "Message digest authentication password (key)\n" - "Key ID\n") - DEFUN (ip_ospf_cost, ip_ospf_cost_u32_inet4_cmd, - "ip ospf cost <1-65535> A.B.C.D", + "ip ospf cost (1-65535) [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Interface cost\n" "Cost\n" "Address of interface") { + int idx_number = 3; + int idx_ipv4 = 4; struct interface *ifp = vty->index; u_int32_t cost; struct in_addr addr; int ret; struct ospf_if_params *params; - + params = IF_DEF_PARAMS (ifp); - cost = strtol (argv[0], NULL, 10); + cost = strtol (argv[idx_number]->arg, NULL, 10); /* cost range is <1-65535>. */ if (cost < 1 || cost > 65535) @@ -6686,9 +6459,9 @@ DEFUN (ip_ospf_cost, return CMD_WARNING; } - if (argc == 2) + if (argc == 5) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6708,49 +6481,75 @@ DEFUN (ip_ospf_cost, return CMD_SUCCESS; } -ALIAS (ip_ospf_cost, - ip_ospf_cost_u32_cmd, - "ip ospf cost <1-65535>", - "IP Information\n" - "OSPF interface commands\n" - "Interface cost\n" - "Cost") - -ALIAS_HIDDEN (ip_ospf_cost, - ospf_cost_u32_cmd, - "ospf cost <1-65535>", - "OSPF interface commands\n" - "Interface cost\n" - "Cost") - -ALIAS_HIDDEN (ip_ospf_cost, +DEFUN_HIDDEN (ospf_cost, ospf_cost_u32_inet4_cmd, - "ospf cost <1-65535> A.B.C.D", + "ospf cost (1-65535) A.B.C.D", "OSPF interface commands\n" "Interface cost\n" "Cost\n" "Address of interface") +{ + int idx_number = 2; + int idx_ipv4 = 3; + struct interface *ifp = vty->index; + u_int32_t cost; + struct in_addr addr; + int ret; + struct ospf_if_params *params; -DEFUN (no_ip_ospf_cost, - no_ip_ospf_cost_inet4_cmd, - "no ip ospf cost A.B.C.D", + params = IF_DEF_PARAMS (ifp); + + cost = strtol (argv[idx_number]->arg, NULL, 10); + + /* cost range is <1-65535>. */ + if (cost < 1 || cost > 65535) + { + vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } + + if (argc == 5) + { + ret = inet_aton(argv[idx_ipv4]->arg, &addr); + if (!ret) + { + vty_out (vty, "Please specify interface address by A.B.C.D%s", + VTY_NEWLINE); + return CMD_WARNING; + } + + params = ospf_get_if_params (ifp, addr); + ospf_if_update_params (ifp, addr); + } + + SET_IF_PARAM (params, output_cost_cmd); + params->output_cost_cmd = cost; + + ospf_if_recalculate_output_cost (ifp); + + return CMD_SUCCESS; +} + +DEFUN (no_ospf_cost, + no_ospf_cost_inet4_cmd, + "no ospf cost [A.B.C.D]", NO_STR - "IP Information\n" "OSPF interface commands\n" "Interface cost\n" "Address of interface") { + int idx_ipv4 = 3; struct interface *ifp = vty->index; struct in_addr addr; int ret; struct ospf_if_params *params; - + ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 1) + if (argc == 4) { - ret = inet_aton(argv[0], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6772,42 +6571,128 @@ DEFUN (no_ip_ospf_cost, } ospf_if_recalculate_output_cost (ifp); - + return CMD_SUCCESS; } -ALIAS (no_ip_ospf_cost, - no_ip_ospf_cost_cmd, - "no ip ospf cost", +DEFUN (no_ip_ospf_cost, + no_ip_ospf_cost_inet4_cmd, + "no ip ospf cost [A.B.C.D]", NO_STR "IP Information\n" "OSPF interface commands\n" - "Interface cost\n") + "Interface cost\n" + "Address of interface") +{ + int idx_ipv4 = 4; + struct interface *ifp = vty->index; + struct in_addr addr; + int ret; + struct ospf_if_params *params; -ALIAS (no_ip_ospf_cost, - no_ospf_cost_cmd, - "no ospf cost", - NO_STR - "OSPF interface commands\n" - "Interface cost\n") + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); -ALIAS (no_ip_ospf_cost, - no_ospf_cost_inet4_cmd, - "no ospf cost A.B.C.D", + if (argc == 5) + { + ret = inet_aton(argv[idx_ipv4]->arg, &addr); + if (!ret) + { + vty_out (vty, "Please specify interface address by A.B.C.D%s", + VTY_NEWLINE); + return CMD_WARNING; + } + + params = ospf_lookup_if_params (ifp, addr); + if (params == NULL) + return CMD_SUCCESS; + } + + UNSET_IF_PARAM (params, output_cost_cmd); + + if (params != IF_DEF_PARAMS (ifp)) + { + ospf_free_if_params (ifp, addr); + ospf_if_update_params (ifp, addr); + } + + ospf_if_recalculate_output_cost (ifp); + + return CMD_SUCCESS; +} + +DEFUN (no_ospf_cost2, + no_ospf_cost_u32_cmd, + "no ospf cost [(1-65535) [A.B.C.D]]", NO_STR "OSPF interface commands\n" "Interface cost\n" - "Address of interface") + "Cost\n" + "Address of interface\n") +{ + int idx_number = 3; + int idx_ipv4 = 4; + struct interface *ifp = vty->index; + struct in_addr addr; + u_int32_t cost; + int ret; + struct ospf_if_params *params; + + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); + + /* According to the semantics we are mimicking "no ip ospf cost N" is + * always treated as "no ip ospf cost" regardless of the actual value + * of N already configured for the interface. Thus the first argument + * is always checked to be a number, but is ignored after that. + */ + cost = strtol (argv[idx_number]->arg, NULL, 10); + if (cost < 1 || cost > 65535) + { + vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } + + if (argc == 5) + { + ret = inet_aton(argv[idx_ipv4]->arg, &addr); + if (!ret) + { + vty_out (vty, "Please specify interface address by A.B.C.D%s", + VTY_NEWLINE); + return CMD_WARNING; + } + + params = ospf_lookup_if_params (ifp, addr); + if (params == NULL) + return CMD_SUCCESS; + } + + UNSET_IF_PARAM (params, output_cost_cmd); + + if (params != IF_DEF_PARAMS (ifp)) + { + ospf_free_if_params (ifp, addr); + ospf_if_update_params (ifp, addr); + } + + ospf_if_recalculate_output_cost (ifp); + + return CMD_SUCCESS; +} DEFUN (no_ip_ospf_cost2, no_ip_ospf_cost_u32_cmd, - "no ip ospf cost <1-65535>", + "no ip ospf cost (1-65535) [A.B.C.D]", NO_STR "IP Information\n" "OSPF interface commands\n" "Interface cost\n" - "Cost") + "Cost\n" + "Address of interface\n") { + int idx_number = 4; + int idx_ipv4 = 5; struct interface *ifp = vty->index; struct in_addr addr; u_int32_t cost; @@ -6822,16 +6707,16 @@ DEFUN (no_ip_ospf_cost2, * of N already configured for the interface. Thus the first argument * is always checked to be a number, but is ignored after that. */ - cost = strtol (argv[0], NULL, 10); + cost = strtol (argv[idx_number]->arg, NULL, 10); if (cost < 1 || cost > 65535) { vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); return CMD_WARNING; } - if (argc == 2) + if (argc == 5) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6857,32 +6742,8 @@ DEFUN (no_ip_ospf_cost2, return CMD_SUCCESS; } -ALIAS (no_ip_ospf_cost2, - no_ospf_cost_u32_cmd, - "no ospf cost <1-65535>", - NO_STR - "OSPF interface commands\n" - "Interface cost\n" - "Cost") -ALIAS (no_ip_ospf_cost2, - no_ip_ospf_cost_u32_inet4_cmd, - "no ip ospf cost <1-65535> A.B.C.D", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Interface cost\n" - "Cost\n" - "Address of interface") -ALIAS (no_ip_ospf_cost2, - no_ospf_cost_u32_inet4_cmd, - "no ospf cost <1-65535> A.B.C.D", - NO_STR - "OSPF interface commands\n" - "Interface cost\n" - "Cost\n" - "Address of interface") static void ospf_nbr_timer_update (struct ospf_interface *oi) @@ -6979,40 +6840,39 @@ ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, return CMD_SUCCESS; } - DEFUN (ip_ospf_dead_interval, ip_ospf_dead_interval_addr_cmd, - "ip ospf dead-interval <1-65535> A.B.C.D", + "ip ospf dead-interval (1-65535) [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Interval after which a neighbor is declared dead\n" "Seconds\n" "Address of interface\n") { - if (argc == 2) - return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL); + int idx_number = 3; + int idx_ipv4 = 4; + if (argc == 5) + return ospf_vty_dead_interval_set (vty, argv[idx_number]->arg, argv[idx_ipv4]->arg, NULL); else - return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL); + return ospf_vty_dead_interval_set (vty, argv[idx_number]->arg, NULL, NULL); } -ALIAS (ip_ospf_dead_interval, - ip_ospf_dead_interval_cmd, - "ip ospf dead-interval <1-65535>", - "IP Information\n" - "OSPF interface commands\n" - "Interval after which a neighbor is declared dead\n" - "Seconds\n") -ALIAS_HIDDEN (ip_ospf_dead_interval, +DEFUN_HIDDEN (ospf_dead_interval, ospf_dead_interval_cmd, - "ospf dead-interval <1-65535>", + "ospf dead-interval (1-65535)", "OSPF interface commands\n" "Interval after which a neighbor is declared dead\n" "Seconds\n") +{ + int idx_number = 2; + + return ospf_vty_dead_interval_set (vty, argv[idx_number]->arg, NULL, NULL); +} DEFUN (ip_ospf_dead_interval_minimal, ip_ospf_dead_interval_minimal_addr_cmd, - "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D", + "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Interval after which a neighbor is declared dead\n" @@ -7021,25 +6881,39 @@ DEFUN (ip_ospf_dead_interval_minimal, "Number of Hellos to send each second\n" "Address of interface\n") { - if (argc == 2) - return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]); + int idx_number = 5; + int idx_ipv4 = 6; + if (argc == 7) + return ospf_vty_dead_interval_set (vty, NULL, argv[idx_ipv4]->arg, argv[idx_number]->arg); else - return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]); + return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[idx_number]->arg); } -ALIAS (ip_ospf_dead_interval_minimal, - ip_ospf_dead_interval_minimal_cmd, - "ip ospf dead-interval minimal hello-multiplier <1-10>", - "IP Information\n" +DEFUN (no_ospf_dead_interval, + no_ospf_dead_interval_cmd, + "no ospf dead-interval", + NO_STR "OSPF interface commands\n" - "Interval after which a neighbor is declared dead\n" - "Minimal 1s dead-interval with fast sub-second hellos\n" - "Hello multiplier factor\n" - "Number of Hellos to send each second\n") + "Interval after which a neighbor is declared dead\n") +{ + struct interface *ifp = vty->index; + struct ospf_if_params *params; + + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); + + UNSET_IF_PARAM (params, v_wait); + params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; + + UNSET_IF_PARAM (params, fast_hello); + params->fast_hello = OSPF_FAST_HELLO_DEFAULT; + + return CMD_SUCCESS; +} DEFUN (no_ip_ospf_dead_interval, no_ip_ospf_dead_interval_addr_cmd, - "no ip ospf dead-interval <1-65535> A.B.C.D", + "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -7047,6 +6921,7 @@ DEFUN (no_ip_ospf_dead_interval, "Seconds\n" "Address of interface") { + int idx_ipv4 = argc - 1; struct interface *ifp = vty->index; struct in_addr addr; int ret; @@ -7057,9 +6932,9 @@ DEFUN (no_ip_ospf_dead_interval, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argv[idx_ipv4]->type == IPV4_TKN) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -7106,62 +6981,17 @@ DEFUN (no_ip_ospf_dead_interval, return CMD_SUCCESS; } -ALIAS (no_ip_ospf_dead_interval, - no_ip_ospf_dead_interval_seconds_cmd, - "no ip ospf dead-interval <1-65535>", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Interval after which a neighbor is declared dead\n" - "Seconds\n") - -ALIAS (no_ip_ospf_dead_interval, - no_ip_ospf_dead_interval_cmd, - "no ip ospf dead-interval", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Interval after which a neighbor is declared dead\n") - -ALIAS (no_ip_ospf_dead_interval, - no_ospf_dead_interval_cmd, - "no ospf dead-interval", - NO_STR - "OSPF interface commands\n" - "Interval after which a neighbor is declared dead\n") - -ALIAS (no_ip_ospf_dead_interval, - no_ip_ospf_dead_interval_minimal_addr_cmd, - "no ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Interval after which a neighbor is declared dead\n" - "Minimal 1s dead-interval with fast sub-second hellos\n" - "Hello multiplier factor\n" - "Number of Hellos to send each second\n" - "Address of interface\n") - -ALIAS (no_ip_ospf_dead_interval, - no_ip_ospf_dead_interval_minimal_cmd, - "no ip ospf dead-interval minimal hello-multiplier <1-10>", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Interval after which a neighbor is declared dead\n" - "Minimal 1s dead-interval with fast sub-second hellos\n" - "Hello multiplier factor\n" - "Number of Hellos to send each second\n") - DEFUN (ip_ospf_hello_interval, ip_ospf_hello_interval_addr_cmd, - "ip ospf hello-interval <1-65535> A.B.C.D", + "ip ospf hello-interval (1-65535) [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Time between HELLO packets\n" "Seconds\n" "Address of interface") { + int idx_number = 3; + int idx_ipv4 = 4; struct interface *ifp = vty->index; u_int32_t seconds; struct in_addr addr; @@ -7170,7 +7000,7 @@ DEFUN (ip_ospf_hello_interval, params = IF_DEF_PARAMS (ifp); - seconds = strtol (argv[0], NULL, 10); + seconds = strtol (argv[idx_number]->arg, NULL, 10); /* HelloInterval range is <1-65535>. */ if (seconds < 1 || seconds > 65535) @@ -7179,9 +7009,9 @@ DEFUN (ip_ospf_hello_interval, return CMD_WARNING; } - if (argc == 2) + if (argc == 5) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -7199,24 +7029,39 @@ DEFUN (ip_ospf_hello_interval, return CMD_SUCCESS; } -ALIAS (ip_ospf_hello_interval, - ip_ospf_hello_interval_cmd, - "ip ospf hello-interval <1-65535>", - "IP Information\n" - "OSPF interface commands\n" - "Time between HELLO packets\n" - "Seconds\n") -ALIAS_HIDDEN (ip_ospf_hello_interval, +DEFUN_HIDDEN (ospf_hello_interval, ospf_hello_interval_cmd, - "ospf hello-interval <1-65535>", + "ospf hello-interval (1-65535)", "OSPF interface commands\n" "Time between HELLO packets\n" "Seconds\n") +{ + int idx_number = 2; + struct interface *ifp = vty->index; + u_int32_t seconds; + struct ospf_if_params *params; + + params = IF_DEF_PARAMS (ifp); + + seconds = strtol (argv[idx_number]->arg, NULL, 10); + + /* HelloInterval range is <1-65535>. */ + if (seconds < 1 || seconds > 65535) + { + vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } + + SET_IF_PARAM (params, v_hello); + params->v_hello = seconds; + + return CMD_SUCCESS; +} DEFUN (no_ip_ospf_hello_interval, no_ip_ospf_hello_interval_addr_cmd, - "no ip ospf hello-interval <1-65535> A.B.C.D", + "no [ip] ospf hello-interval [(1-65535) [A.B.C.D]]", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -7224,6 +7069,7 @@ DEFUN (no_ip_ospf_hello_interval, "Seconds\n" "Address of interface") { + int idx_ipv4 = 5; struct interface *ifp = vty->index; struct in_addr addr; int ret; @@ -7232,9 +7078,12 @@ DEFUN (no_ip_ospf_hello_interval, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (strcmp (argv[1]->arg, "ip") == 0) + idx_ipv4 = 4; + + if (argc == idx_ipv4+1) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -7259,34 +7108,12 @@ DEFUN (no_ip_ospf_hello_interval, return CMD_SUCCESS; } -ALIAS (no_ip_ospf_hello_interval, - no_ip_ospf_hello_interval_seconds_cmd, - "no ip ospf hello-interval <1-65535>", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Time between HELLO packets\n" - "Seconds\n") -ALIAS (no_ip_ospf_hello_interval, - no_ip_ospf_hello_interval_cmd, - "no ip ospf hello-interval", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Time between HELLO packets\n") -ALIAS (no_ip_ospf_hello_interval, - no_ospf_hello_interval_cmd, - "no ospf hello-interval <1-65535>", - NO_STR - "OSPF interface commands\n" - "Time between HELLO packets\n" - "Seconds\n") DEFUN (ip_ospf_network, ip_ospf_network_cmd, - "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", + "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>", "IP Information\n" "OSPF interface commands\n" "Network type\n" @@ -7295,6 +7122,7 @@ DEFUN (ip_ospf_network, "Specify OSPF point-to-multipoint network\n" "Specify OSPF point-to-point network\n") { + int idx_network = 3; struct interface *ifp = vty->index; int old_type = IF_DEF_PARAMS (ifp)->type; struct route_node *rn; @@ -7305,13 +7133,13 @@ DEFUN (ip_ospf_network, return CMD_WARNING; } - if (strncmp (argv[0], "b", 1) == 0) + if (strncmp (argv[idx_network]->arg, "b", 1) == 0) IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; - else if (strncmp (argv[0], "n", 1) == 0) + else if (strncmp (argv[idx_network]->arg, "n", 1) == 0) IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; - else if (strncmp (argv[0], "point-to-m", 10) == 0) + else if (strncmp (argv[idx_network]->arg, "point-to-m", 10) == 0) IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; - else if (strncmp (argv[0], "point-to-p", 10) == 0) + else if (strncmp (argv[idx_network]->arg, "point-to-p", 10) == 0) IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; if (IF_DEF_PARAMS (ifp)->type == old_type) @@ -7338,23 +7166,70 @@ DEFUN (ip_ospf_network, return CMD_SUCCESS; } -ALIAS_HIDDEN (ip_ospf_network, +DEFUN_HIDDEN (ospf_network, ospf_network_cmd, - "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", + "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>", "OSPF interface commands\n" "Network type\n" "Specify OSPF broadcast multi-access network\n" "Specify OSPF NBMA network\n" "Specify OSPF point-to-multipoint network\n" "Specify OSPF point-to-point network\n") +{ + int idx_network = 2; + struct interface *ifp = vty->index; + int old_type = IF_DEF_PARAMS (ifp)->type; + struct route_node *rn; -DEFUN (no_ip_ospf_network, - no_ip_ospf_network_cmd, - "no ip ospf network", + if (old_type == OSPF_IFTYPE_LOOPBACK) + { + vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE); + return CMD_WARNING; + } + + if (strncmp (argv[idx_network]->arg, "b", 1) == 0) + IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; + else if (strncmp (argv[idx_network]->arg, "n", 1) == 0) + IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; + else if (strncmp (argv[idx_network]->arg, "point-to-m", 10) == 0) + IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; + else if (strncmp (argv[idx_network]->arg, "point-to-p", 10) == 0) + IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; + + if (IF_DEF_PARAMS (ifp)->type == old_type) + return CMD_SUCCESS; + + SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); + + for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) + { + struct ospf_interface *oi = rn->info; + + if (!oi) + continue; + + oi->type = IF_DEF_PARAMS (ifp)->type; + + if (oi->state > ISM_Down) + { + OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); + OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); + } + } + + return CMD_SUCCESS; +} + +DEFUN (no_ospf_network, + no_ospf_network_cmd, + "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]", NO_STR - "IP Information\n" "OSPF interface commands\n" - "Network type\n") + "Network type\n" + "Specify OSPF broadcast multi-access network\n" + "Specify OSPF NBMA network\n" + "Specify OSPF point-to-multipoint network\n" + "Specify OSPF point-to-point network\n") { struct interface *ifp = vty->index; int old_type = IF_DEF_PARAMS (ifp)->type; @@ -7371,9 +7246,9 @@ DEFUN (no_ip_ospf_network, if (!oi) continue; - + oi->type = IF_DEF_PARAMS (ifp)->type; - + if (oi->state > ISM_Down) { OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); @@ -7384,9 +7259,9 @@ DEFUN (no_ip_ospf_network, return CMD_SUCCESS; } -ALIAS (no_ip_ospf_network, - no_ip_ospf_network_val_cmd, - "no ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", +DEFUN (no_ip_ospf_network, + no_ip_ospf_network_cmd, + "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -7395,45 +7270,57 @@ ALIAS (no_ip_ospf_network, "Specify OSPF NBMA network\n" "Specify OSPF point-to-multipoint network\n" "Specify OSPF point-to-point network\n") +{ + struct interface *ifp = vty->index; + int old_type = IF_DEF_PARAMS (ifp)->type; + struct route_node *rn; -ALIAS (no_ip_ospf_network, - no_ospf_network_cmd, - "no ospf network", - NO_STR - "OSPF interface commands\n" - "Network type\n") + IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); -ALIAS (no_ip_ospf_network, - no_ospf_network_val_cmd, - "no ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", - NO_STR - "OSPF interface commands\n" - "Network type\n" - "Specify OSPF broadcast multi-access network\n" - "Specify OSPF NBMA network\n" - "Specify OSPF point-to-multipoint network\n" - "Specify OSPF point-to-point network\n") + if (IF_DEF_PARAMS (ifp)->type == old_type) + return CMD_SUCCESS; + + for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) + { + struct ospf_interface *oi = rn->info; + + if (!oi) + continue; + + oi->type = IF_DEF_PARAMS (ifp)->type; + + if (oi->state > ISM_Down) + { + OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); + OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); + } + } + + return CMD_SUCCESS; +} DEFUN (ip_ospf_priority, ip_ospf_priority_addr_cmd, - "ip ospf priority <0-255> A.B.C.D", + "ip ospf priority (0-255) [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Router priority\n" "Priority\n" "Address of interface") { + int idx_number = 3; + int idx_ipv4 = 4; struct interface *ifp = vty->index; long priority; struct route_node *rn; struct in_addr addr; int ret; struct ospf_if_params *params; - + params = IF_DEF_PARAMS (ifp); - priority = strtol (argv[0], NULL, 10); - + priority = strtol (argv[idx_number]->arg, NULL, 10); + /* Router Priority range is <0-255>. */ if (priority < 0 || priority > 255) { @@ -7441,9 +7328,9 @@ DEFUN (ip_ospf_priority, return CMD_WARNING; } - if (argc == 2) + if (argc == 5) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -7454,17 +7341,16 @@ DEFUN (ip_ospf_priority, params = ospf_get_if_params (ifp, addr); ospf_if_update_params (ifp, addr); } - + SET_IF_PARAM (params, priority); params->priority = priority; for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) { struct ospf_interface *oi = rn->info; - + if (!oi) continue; - if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) { @@ -7472,35 +7358,66 @@ DEFUN (ip_ospf_priority, OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); } } - + return CMD_SUCCESS; } -ALIAS (ip_ospf_priority, - ip_ospf_priority_cmd, - "ip ospf priority <0-255>", - "IP Information\n" - "OSPF interface commands\n" - "Router priority\n" - "Priority\n") -ALIAS_HIDDEN (ip_ospf_priority, +DEFUN_HIDDEN (ospf_priority, ospf_priority_cmd, - "ospf priority <0-255>", + "ospf priority (0-255)", "OSPF interface commands\n" "Router priority\n" "Priority\n") +{ + int idx_number = 2; + struct interface *ifp = vty->index; + long priority; + struct route_node *rn; + struct ospf_if_params *params; -DEFUN (no_ip_ospf_priority, - no_ip_ospf_priority_addr_cmd, - "no ip ospf priority <0-255> A.B.C.D", + params = IF_DEF_PARAMS (ifp); + + priority = strtol (argv[idx_number]->arg, NULL, 10); + + /* Router Priority range is <0-255>. */ + if (priority < 0 || priority > 255) + { + vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } + + SET_IF_PARAM (params, priority); + params->priority = priority; + + for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) + { + struct ospf_interface *oi = rn->info; + + if (!oi) + continue; + + + if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) + { + PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); + OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); + } + } + + return CMD_SUCCESS; +} + +DEFUN (no_ospf_priority, + no_ospf_priority_addr_cmd, + "no ospf priority [(0-255) [A.B.C.D]]", NO_STR - "IP Information\n" "OSPF interface commands\n" "Router priority\n" "Priority\n" "Address of interface") { + int idx_ipv4 = 4; struct interface *ifp = vty->index; struct route_node *rn; struct in_addr addr; @@ -7510,9 +7427,9 @@ DEFUN (no_ip_ospf_priority, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 5) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -7541,7 +7458,7 @@ DEFUN (no_ip_ospf_priority, if (!oi) continue; - + if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) { PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); @@ -7552,41 +7469,80 @@ DEFUN (no_ip_ospf_priority, return CMD_SUCCESS; } -ALIAS (no_ip_ospf_priority, - no_ip_ospf_priority_no_param_cmd, - "no ip ospf priority", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Router priority\n"); - -ALIAS (no_ip_ospf_priority, - no_ip_ospf_priority_cmd, - "no ip ospf priority <0-255>", +DEFUN (no_ip_ospf_priority, + no_ip_ospf_priority_addr_cmd, + "no ip ospf priority [(0-255) [A.B.C.D]]", NO_STR "IP Information\n" "OSPF interface commands\n" "Router priority\n" - "Priority\n") + "Priority\n" + "Address of interface") +{ + int idx_ipv4 = 5; + struct interface *ifp = vty->index; + struct route_node *rn; + struct in_addr addr; + int ret; + struct ospf_if_params *params; + + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); -ALIAS (no_ip_ospf_priority, - no_ospf_priority_cmd, - "no ospf priority <0-255>", - NO_STR - "OSPF interface commands\n" - "Router priority\n" - "Priority\n") + if (argc == 6) + { + ret = inet_aton(argv[idx_ipv4]->arg, &addr); + if (!ret) + { + vty_out (vty, "Please specify interface address by A.B.C.D%s", + VTY_NEWLINE); + return CMD_WARNING; + } + + params = ospf_lookup_if_params (ifp, addr); + if (params == NULL) + return CMD_SUCCESS; + } + + UNSET_IF_PARAM (params, priority); + params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; + + if (params != IF_DEF_PARAMS (ifp)) + { + ospf_free_if_params (ifp, addr); + ospf_if_update_params (ifp, addr); + } + + for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) + { + struct ospf_interface *oi = rn->info; + + if (!oi) + continue; + + + if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) + { + PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); + OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); + } + } + + return CMD_SUCCESS; +} DEFUN (ip_ospf_retransmit_interval, ip_ospf_retransmit_interval_addr_cmd, - "ip ospf retransmit-interval <3-65535> A.B.C.D", + "ip ospf retransmit-interval (3-65535) [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Time between retransmitting lost link state advertisements\n" "Seconds\n" "Address of interface") { + int idx_number = 3; + int idx_ipv4 = 4; struct interface *ifp = vty->index; u_int32_t seconds; struct in_addr addr; @@ -7594,7 +7550,7 @@ DEFUN (ip_ospf_retransmit_interval, struct ospf_if_params *params; params = IF_DEF_PARAMS (ifp); - seconds = strtol (argv[0], NULL, 10); + seconds = strtol (argv[idx_number]->arg, NULL, 10); /* Retransmit Interval range is <3-65535>. */ if (seconds < 3 || seconds > 65535) @@ -7604,9 +7560,9 @@ DEFUN (ip_ospf_retransmit_interval, } - if (argc == 2) + if (argc == 5) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -7624,24 +7580,55 @@ DEFUN (ip_ospf_retransmit_interval, return CMD_SUCCESS; } -ALIAS (ip_ospf_retransmit_interval, - ip_ospf_retransmit_interval_cmd, - "ip ospf retransmit-interval <3-65535>", - "IP Information\n" - "OSPF interface commands\n" - "Time between retransmitting lost link state advertisements\n" - "Seconds\n") - -ALIAS_HIDDEN (ip_ospf_retransmit_interval, +DEFUN_HIDDEN (ospf_retransmit_interval, ospf_retransmit_interval_cmd, - "ospf retransmit-interval <3-65535>", + "ospf retransmit-interval (3-65535)", "OSPF interface commands\n" "Time between retransmitting lost link state advertisements\n" "Seconds\n") +{ + int idx_number = 2; + struct interface *ifp = vty->index; + u_int32_t seconds; + struct ospf_if_params *params; + + params = IF_DEF_PARAMS (ifp); + seconds = strtol (argv[idx_number]->arg, NULL, 10); + + /* Retransmit Interval range is <3-65535>. */ + if (seconds < 3 || seconds > 65535) + { + vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } + + SET_IF_PARAM (params, retransmit_interval); + params->retransmit_interval = seconds; + + return CMD_SUCCESS; +} + +DEFUN (no_ospf_retransmit_interval, + no_ospf_retransmit_interval_cmd, + "no ospf retransmit-interval", + NO_STR + "OSPF interface commands\n" + "Time between retransmitting lost link state advertisements\n") +{ + struct interface *ifp = vty->index; + struct ospf_if_params *params; + + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); + UNSET_IF_PARAM (params, retransmit_interval); + params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; + + return CMD_SUCCESS; +} DEFUN (no_ip_ospf_retransmit_interval, no_ip_ospf_retransmit_interval_addr_cmd, - "no ip ospf retransmit-interval A.B.C.D", + "no ip ospf retransmit-interval [<(3-65535) [A.B.C.D]|A.B.C.D>]", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -7657,14 +7644,14 @@ DEFUN (no_ip_ospf_retransmit_interval, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc >= 1) + if (argc >= 5) { - if (argc == 1) - addr_index = 0; + if (argc == 5) + addr_index = 4; else - addr_index = 1; + addr_index = 5; - ret = inet_aton(argv[addr_index], &addr); + ret = inet_aton(argv[addr_index]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -7689,62 +7676,18 @@ DEFUN (no_ip_ospf_retransmit_interval, return CMD_SUCCESS; } -ALIAS (no_ip_ospf_retransmit_interval, - no_ip_ospf_retransmit_interval_sec_addr_cmd, - "no ip ospf retransmit-interval <3-65535> A.B.C.D", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Time between retransmitting lost link state advertisements\n" - "Seconds\n" - "Address of interface") - -ALIAS (no_ip_ospf_retransmit_interval, - no_ip_ospf_retransmit_interval_cmd, - "no ip ospf retransmit-interval", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Time between retransmitting lost link state advertisements\n") - -ALIAS (no_ip_ospf_retransmit_interval, - no_ospf_retransmit_interval_cmd, - "no ospf retransmit-interval", - NO_STR - "OSPF interface commands\n" - "Time between retransmitting lost link state advertisements\n") - -DEFUN (no_ip_ospf_retransmit_interval_sec, - no_ip_ospf_retransmit_interval_sec_cmd, - "no ip ospf retransmit-interval <3-65535>", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Time between retransmitting lost link state advertisements\n" - "Seconds\n") -{ - struct interface *ifp = vty->index; - struct ospf_if_params *params; - - ifp = vty->index; - params = IF_DEF_PARAMS (ifp); - - UNSET_IF_PARAM (params, retransmit_interval); - params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; - - return CMD_SUCCESS; -} - DEFUN (ip_ospf_transmit_delay, ip_ospf_transmit_delay_addr_cmd, - "ip ospf transmit-delay <1-65535> A.B.C.D", + "ip ospf transmit-delay (1-65535) [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Link state transmit delay\n" "Seconds\n" "Address of interface") { + int idx_number = 3; + int idx_ipv4 = 4; struct interface *ifp = vty->index; u_int32_t seconds; struct in_addr addr; @@ -7752,7 +7695,7 @@ DEFUN (ip_ospf_transmit_delay, struct ospf_if_params *params; params = IF_DEF_PARAMS (ifp); - seconds = strtol (argv[0], NULL, 10); + seconds = strtol (argv[idx_number]->arg, NULL, 10); /* Transmit Delay range is <1-65535>. */ if (seconds < 1 || seconds > 65535) @@ -7761,9 +7704,9 @@ DEFUN (ip_ospf_transmit_delay, return CMD_WARNING; } - if (argc == 2) + if (argc == 5) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -7781,24 +7724,38 @@ DEFUN (ip_ospf_transmit_delay, return CMD_SUCCESS; } -ALIAS (ip_ospf_transmit_delay, - ip_ospf_transmit_delay_cmd, - "ip ospf transmit-delay <1-65535>", - "IP Information\n" - "OSPF interface commands\n" - "Link state transmit delay\n" - "Seconds\n") -ALIAS_HIDDEN (ip_ospf_transmit_delay, +DEFUN_HIDDEN (ospf_transmit_delay, ospf_transmit_delay_cmd, - "ospf transmit-delay <1-65535>", + "ospf transmit-delay (1-65535)", "OSPF interface commands\n" "Link state transmit delay\n" "Seconds\n") +{ + int idx_number = 2; + struct interface *ifp = vty->index; + u_int32_t seconds; + struct ospf_if_params *params; + + params = IF_DEF_PARAMS (ifp); + seconds = strtol (argv[idx_number]->arg, NULL, 10); + + /* Transmit Delay range is <1-65535>. */ + if (seconds < 1 || seconds > 65535) + { + vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } + + SET_IF_PARAM (params, transmit_delay); + params->transmit_delay = seconds; + + return CMD_SUCCESS; +} DEFUN (no_ip_ospf_transmit_delay, no_ip_ospf_transmit_delay_addr_cmd, - "no ip ospf transmit-delay A.B.C.D", + "no ip ospf transmit-delay [<A.B.C.D|(1-65535) A.B.C.D>]", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -7814,14 +7771,14 @@ DEFUN (no_ip_ospf_transmit_delay, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc >= 1) + if (argc >= 5) { - if (argc == 1) - addr_index = 0; + if (argc == 5) + addr_index = 4; else - addr_index = 1; + addr_index = 5; - ret = inet_aton(argv[addr_index], &addr); + ret = inet_aton(argv[addr_index]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -7846,34 +7803,29 @@ DEFUN (no_ip_ospf_transmit_delay, return CMD_SUCCESS; } -ALIAS (no_ip_ospf_transmit_delay, - no_ip_ospf_transmit_delay_sec_addr_cmd, - "no ip ospf transmit-delay <1-65535> A.B.C.D", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Link state transmit delay\n" - "Seconds\n" - "Address of interface") -ALIAS (no_ip_ospf_transmit_delay, - no_ip_ospf_transmit_delay_cmd, - "no ip ospf transmit-delay", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Link state transmit delay\n") - -ALIAS (no_ip_ospf_transmit_delay, +DEFUN (no_ospf_transmit_delay, no_ospf_transmit_delay_cmd, "no ospf transmit-delay", NO_STR "OSPF interface commands\n" "Link state transmit delay\n") +{ + struct interface *ifp = vty->index; + struct ospf_if_params *params; + + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); + + UNSET_IF_PARAM (params, transmit_delay); + params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; + + return CMD_SUCCESS; +} DEFUN (no_ip_ospf_transmit_delay_sec, no_ip_ospf_transmit_delay_sec_cmd, - "no ip ospf transmit-delay <1-65535>", + "no ip ospf transmit-delay (1-65535)", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -7895,13 +7847,15 @@ DEFUN (no_ip_ospf_transmit_delay_sec, DEFUN (ip_ospf_area, ip_ospf_area_cmd, - "ip ospf area (A.B.C.D|<0-4294967295>)", + "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>", "IP Information\n" "OSPF interface commands\n" + "Instance ID\n" "Enable OSPF on this interface\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n") { + int idx_ipv4_number = 2; struct interface *ifp = vty->index; int format, ret; struct in_addr area_id; @@ -7910,8 +7864,8 @@ DEFUN (ip_ospf_area, struct route_node *rn; u_short instance = 0; - if (argc == 2) - VTY_GET_INTEGER ("Instance", instance, argv[0]); + if (argc == 5) + VTY_GET_INTEGER ("Instance", instance, argv[idx_ipv4_number]->arg); ospf = ospf_lookup_instance (instance); if (ospf == NULL) @@ -7926,7 +7880,7 @@ DEFUN (ip_ospf_area, return CMD_SUCCESS; } - ret = ospf_str2area_id (argv[instance ? 1 : 0], &area_id, &format); + ret = ospf_str2area_id (argv[instance ? 4 : 3]->arg, &area_id, &format); if (ret < 0) { vty_out (vty, "Please specify area by A.B.C.D|<0-4294967295>%s", @@ -7964,23 +7918,15 @@ DEFUN (ip_ospf_area, return CMD_SUCCESS; } -ALIAS (ip_ospf_area, - ip_ospf_instance_area_cmd, - "ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)", - "IP Information\n" - "OSPF interface commands\n" - "Instance ID\n" - "Enable OSPF on this interface\n" - "OSPF area ID in IP address format\n" - "OSPF area ID as a decimal value\n") - DEFUN (no_ip_ospf_area, no_ip_ospf_area_cmd, - "no ip ospf area", + "no ip ospf area [<A.B.C.D|(0-4294967295)>]", NO_STR "IP Information\n" "OSPF interface commands\n" - "Disable OSPF on this interface\n") + "Disable OSPF on this interface\n" + "OSPF area ID in IP address format\n" + "OSPF area ID as a decimal value\n") { struct interface *ifp = vty->index; struct ospf *ospf; @@ -8002,31 +7948,22 @@ DEFUN (no_ip_ospf_area, return CMD_SUCCESS; } -ALIAS (no_ip_ospf_area, - no_ip_ospf_area_val_cmd, - "no ip ospf area (A.B.C.D|<0-4294967295>)", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Disable OSPF on this interface\n" - "OSPF area ID in IP address format\n" - "OSPF area ID as a decimal value\n") - DEFUN (no_ip_ospf_instance_area, no_ip_ospf_instance_area_cmd, - "no ip ospf <1-65535> area", + "no ip ospf (1-65535) area [<A.B.C.D|(0-4294967295)>]", NO_STR "IP Information\n" "OSPF interface commands\n" "Instance ID\n" "Disable OSPF on this interface\n") { + int idx_number = 3; struct interface *ifp = vty->index; struct ospf *ospf; struct ospf_if_params *params; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL) return CMD_SUCCESS; @@ -8043,21 +7980,9 @@ DEFUN (no_ip_ospf_instance_area, return CMD_SUCCESS; } -ALIAS (no_ip_ospf_instance_area, - no_ip_ospf_instance_area_val_cmd, - "no ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Instance ID\n" - "Disable OSPF on this interface\n" - "OSPF area ID in IP address format\n" - "OSPF area ID as a decimal value\n") - DEFUN (ospf_redistribute_source, ospf_redistribute_source_cmd, - "redistribute " QUAGGA_REDIST_STR_OSPFD - " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", + "redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]", REDIST_STR QUAGGA_REDIST_HELP_STR_OSPFD "Metric for redistributed routes\n" @@ -8068,6 +7993,8 @@ DEFUN (ospf_redistribute_source, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_redist_param = 2; struct ospf *ospf = vty->index; int source; int type = -1; @@ -8084,24 +8011,24 @@ DEFUN (ospf_redistribute_source, return CMD_SUCCESS; /* Get distribute source. */ - source = proto_redistnum(AFI_IP, argv[0]); + source = proto_redistnum(AFI_IP, argv[idx_protocol]->arg); if (source < 0 || source == ZEBRA_ROUTE_OSPF) return CMD_WARNING; /* Get metric value. */ - if (argv[1] != NULL) - if (!str2metric (argv[1], &metric)) + if (strcmp (argv[idx_redist_param]->arg, "metric") == 0) + if (!str2metric (argv[idx_redist_param+1]->arg, &metric)) return CMD_WARNING; /* Get metric type. */ - if (argv[2] != NULL) - if (!str2metric_type (argv[2], &type)) + if (strcmp (argv[idx_redist_param]->arg, "metric-type") == 0) + if (!str2metric_type (argv[idx_redist_param+1]->arg, &type)) return CMD_WARNING; red = ospf_redist_add(ospf, source, 0); - if (argv[3] != NULL) - ospf_routemap_set (red, argv[3]); + if (strcmp (argv[idx_redist_param]->arg, "route-map") == 0) + ospf_routemap_set (red, argv[idx_redist_param+1]->arg); else ospf_routemap_unset (red); @@ -8110,8 +8037,7 @@ DEFUN (ospf_redistribute_source, DEFUN (no_ospf_redistribute_source, no_ospf_redistribute_source_cmd, - "no redistribute " QUAGGA_REDIST_STR_OSPFD - " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", + "no redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]", NO_STR REDIST_STR QUAGGA_REDIST_HELP_STR_OSPFD @@ -8123,13 +8049,14 @@ DEFUN (no_ospf_redistribute_source, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 2; struct ospf *ospf = vty->index; int source; struct ospf_redist *red; if (!ospf) return CMD_SUCCESS; - source = proto_redistnum(AFI_IP, argv[0]); + source = proto_redistnum(AFI_IP, argv[idx_protocol]->arg); if (source < 0 || source == ZEBRA_ROUTE_OSPF) return CMD_WARNING; @@ -8143,8 +8070,7 @@ DEFUN (no_ospf_redistribute_source, DEFUN (ospf_redistribute_instance_source, ospf_redistribute_instance_source_cmd, - "redistribute (ospf|table) <1-65535>" - " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", + "redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]", REDIST_STR "Open Shortest Path First\n" "Non-main Kernel Routing Table\n" @@ -8157,6 +8083,9 @@ DEFUN (ospf_redistribute_instance_source, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_ospf_table = 1; + int idx_number = 2; + int idx_redist_param = 3; struct ospf *ospf = vty->index; int source; int type = -1; @@ -8167,12 +8096,12 @@ DEFUN (ospf_redistribute_instance_source, if (!ospf) return CMD_SUCCESS; - if (strncmp(argv[0], "o", 1) == 0) + if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) source = ZEBRA_ROUTE_OSPF; else source = ZEBRA_ROUTE_TABLE; - VTY_GET_INTEGER ("Instance ID", instance, argv[1]); + VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); if (!ospf) return CMD_SUCCESS; @@ -8192,18 +8121,19 @@ DEFUN (ospf_redistribute_instance_source, } /* Get metric value. */ - if (argv[2] != NULL) - if (!str2metric (argv[2], &metric)) + if (strcmp (argv[idx_redist_param]->arg, "metric") == 0) + if (!str2metric (argv[idx_redist_param+1]->arg, &metric)) return CMD_WARNING; /* Get metric type. */ - if (argv[3] != NULL) - if (!str2metric_type (argv[3], &type)) + if (strcmp (argv[idx_redist_param]->arg, "metric-type") == 0) + if (!str2metric_type (argv[idx_redist_param+1]->arg, &type)) return CMD_WARNING; red = ospf_redist_add(ospf, source, instance); - if (argv[4] != NULL) - ospf_routemap_set (red, argv[4]); + + if (strcmp (argv[idx_redist_param]->arg, "route-map") == 0) + ospf_routemap_set (red, argv[idx_redist_param+1]->arg); else ospf_routemap_unset (red); @@ -8212,8 +8142,7 @@ DEFUN (ospf_redistribute_instance_source, DEFUN (no_ospf_redistribute_instance_source, no_ospf_redistribute_instance_source_cmd, - "no redistribute (ospf|table) <1-65535>" - " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", + "no redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]", NO_STR REDIST_STR "Open Shortest Path First\n" @@ -8227,6 +8156,8 @@ DEFUN (no_ospf_redistribute_instance_source, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_ospf_table = 2; + int idx_number = 3; struct ospf *ospf = vty->index; u_int instance; struct ospf_redist *red; @@ -8235,12 +8166,12 @@ DEFUN (no_ospf_redistribute_instance_source, if (!ospf) return CMD_SUCCESS; - if (strncmp(argv[0], "o", 1) == 0) + if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) source = ZEBRA_ROUTE_OSPF; else source = ZEBRA_ROUTE_TABLE; - VTY_GET_INTEGER ("Instance ID", instance, argv[1]); + VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) { @@ -8266,12 +8197,13 @@ DEFUN (no_ospf_redistribute_instance_source, DEFUN (ospf_distribute_list_out, ospf_distribute_list_out_cmd, - "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, + "distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>", "Filter networks in routing updates\n" "Access-list name\n" OUT_STR QUAGGA_REDIST_HELP_STR_OSPFD) { + int idx_word = 1; struct ospf *ospf = vty->index; int source; @@ -8279,40 +8211,40 @@ DEFUN (ospf_distribute_list_out, return CMD_SUCCESS; /* Get distribute source. */ - source = proto_redistnum(AFI_IP, argv[1]); + source = proto_redistnum(AFI_IP, argv[4]->arg); if (source < 0 || source == ZEBRA_ROUTE_OSPF) return CMD_WARNING; - return ospf_distribute_list_out_set (ospf, source, argv[0]); + return ospf_distribute_list_out_set (ospf, source, argv[idx_word]->arg); } DEFUN (no_ospf_distribute_list_out, no_ospf_distribute_list_out_cmd, - "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, + "no distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>", NO_STR "Filter networks in routing updates\n" "Access-list name\n" OUT_STR QUAGGA_REDIST_HELP_STR_OSPFD) { + int idx_word = 2; struct ospf *ospf = vty->index; int source; if (!ospf) return CMD_SUCCESS; - source = proto_redistnum(AFI_IP, argv[1]); + source = proto_redistnum(AFI_IP, argv[5]->arg); if (source < 0 || source == ZEBRA_ROUTE_OSPF) return CMD_WARNING; - return ospf_distribute_list_out_unset (ospf, source, argv[0]); + return ospf_distribute_list_out_unset (ospf, source, argv[idx_word]->arg); } /* Default information originate. */ DEFUN (ospf_default_information_originate, ospf_default_information_originate_cmd, - "default-information originate " - "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}", + "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]", "Control distribution of default information\n" "Distribute a default route\n" "Always advertise default route\n" @@ -8324,6 +8256,7 @@ DEFUN (ospf_default_information_originate, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_redist_param = 2; struct ospf *ospf = vty->index; int default_originate = DEFAULT_ORIGINATE_ZEBRA; int type = -1; @@ -8337,23 +8270,23 @@ DEFUN (ospf_default_information_originate, return CMD_WARNING; /* this should not happen */ /* Check whether "always" was specified */ - if (argv[0] != NULL) + if (argv[idx_redist_param]->arg != NULL) default_originate = DEFAULT_ORIGINATE_ALWAYS; red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0); /* Get metric value. */ - if (argv[1] != NULL) - if (!str2metric (argv[1], &metric)) + if (strcmp (argv[idx_redist_param]->arg, "metric") == 0) + if (!str2metric (argv[idx_redist_param+1]->arg, &metric)) return CMD_WARNING; /* Get metric type. */ - if (argv[2] != NULL) - if (!str2metric_type (argv[2], &type)) + if (strcmp (argv[idx_redist_param]->arg, "metric-type") == 0) + if (!str2metric_type (argv[idx_redist_param+1]->arg, &type)) return CMD_WARNING; - if (argv[3] != NULL) - ospf_routemap_set (red, argv[3]); + if (strcmp (argv[idx_redist_param]->arg, "route-map") == 0) + ospf_routemap_set (red, argv[idx_redist_param+1]->arg); else ospf_routemap_unset (red); @@ -8363,8 +8296,7 @@ DEFUN (ospf_default_information_originate, DEFUN (no_ospf_default_information_originate, no_ospf_default_information_originate_cmd, - "no default-information originate" - "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}", + "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]", NO_STR "Control distribution of default information\n" "Distribute a default route\n" @@ -8407,17 +8339,18 @@ DEFUN (no_ospf_default_information_originate, DEFUN (ospf_default_metric, ospf_default_metric_cmd, - "default-metric <0-16777214>", + "default-metric (0-16777214)", "Set metric of redistributed routes\n" "Default metric\n") { + int idx_number = 1; struct ospf *ospf = vty->index; int metric = -1; if (!ospf) return CMD_SUCCESS; - if (!str2metric (argv[0], &metric)) + if (!str2metric (argv[idx_number]->arg, &metric)) return CMD_WARNING; ospf->default_metric = metric; @@ -8427,9 +8360,10 @@ DEFUN (ospf_default_metric, DEFUN (no_ospf_default_metric, no_ospf_default_metric_cmd, - "no default-metric", + "no default-metric [(0-16777214)]", NO_STR - "Set metric of redistributed routes\n") + "Set metric of redistributed routes\n" + "Default metric\n") { struct ospf *ospf = vty->index; @@ -8441,32 +8375,27 @@ DEFUN (no_ospf_default_metric, return CMD_SUCCESS; } -ALIAS (no_ospf_default_metric, - no_ospf_default_metric_val_cmd, - "no default-metric <0-16777214>", - NO_STR - "Set metric of redistributed routes\n" - "Default metric\n") DEFUN (ospf_distance, ospf_distance_cmd, - "distance <1-255>", + "distance (1-255)", "Define an administrative distance\n" "OSPF Administrative distance\n") { + int idx_number = 1; struct ospf *ospf = vty->index; if (!ospf) return CMD_SUCCESS; - ospf->distance_all = atoi (argv[0]); + ospf->distance_all = atoi (argv[idx_number]->arg); return CMD_SUCCESS; } DEFUN (no_ospf_distance, no_ospf_distance_cmd, - "no distance <1-255>", + "no distance (1-255)", NO_STR "Define an administrative distance\n" "OSPF Administrative distance\n") @@ -8483,7 +8412,7 @@ DEFUN (no_ospf_distance, DEFUN (no_ospf_distance_ospf, no_ospf_distance_ospf_cmd, - "no distance ospf {intra-area <1-255>|inter-area <1-255>|external <1-255>}", + "no distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]", NO_STR "Define an administrative distance\n" "OSPF Administrative distance\n" @@ -8494,6 +8423,7 @@ DEFUN (no_ospf_distance_ospf, "External routes\n" "Distance for external routes\n") { + int idx_area_distance = 3; struct ospf *ospf = vty->index; if (!ospf) @@ -8505,7 +8435,7 @@ DEFUN (no_ospf_distance_ospf, if (!ospf) return CMD_SUCCESS; - if (argv[0] != NULL) + if (argv[idx_area_distance]->arg != NULL) ospf->distance_intra = 0; if (argv[1] != NULL) @@ -8514,7 +8444,7 @@ DEFUN (no_ospf_distance_ospf, if (argv[2] != NULL) ospf->distance_external = 0; - if (argv[0] || argv[1] || argv[2]) + if (argv[idx_area_distance]->arg || argv[1] || argv[2]) return CMD_SUCCESS; /* If no arguments are given, clear all distance information */ @@ -8527,8 +8457,7 @@ DEFUN (no_ospf_distance_ospf, DEFUN (ospf_distance_ospf, ospf_distance_ospf_cmd, - "distance ospf " - "{intra-area <1-255>|inter-area <1-255>|external <1-255>}", + "distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]", "Define an administrative distance\n" "OSPF Administrative distance\n" "Intra-area routes\n" @@ -8538,6 +8467,7 @@ DEFUN (ospf_distance_ospf, "External routes\n" "Distance for external routes\n") { + int idx_area_distance = 2; struct ospf *ospf = vty->index; if (!ospf) @@ -8546,105 +8476,116 @@ DEFUN (ospf_distance_ospf, if (argc < 3) /* should not happen */ return CMD_WARNING; - if (!argv[0] && !argv[1] && !argv[2]) + if (!argv[idx_area_distance]->arg && !argv[1] && !argv[2]) { vty_out(vty, "%% Command incomplete. (Arguments required)%s", VTY_NEWLINE); return CMD_WARNING; } - if (argv[0] != NULL) - ospf->distance_intra = atoi(argv[0]); + if (strcmp (argv[idx_area_distance]->text, "intra") == 0) + ospf->distance_intra = atoi(argv[idx_area_distance+1]->arg); - if (argv[1] != NULL) - ospf->distance_inter = atoi(argv[1]); + if (strcmp (argv[idx_area_distance]->text, "inter") == 0) + ospf->distance_inter = atoi(argv[idx_area_distance+1]->arg); - if (argv[2] != NULL) - ospf->distance_external = atoi(argv[2]); + if (strcmp (argv[idx_area_distance]->text, "external") == 0) + ospf->distance_external = atoi(argv[idx_area_distance+1]->arg); return CMD_SUCCESS; } DEFUN (ospf_distance_source, ospf_distance_source_cmd, - "distance <1-255> A.B.C.D/M", + "distance (1-255) A.B.C.D/M", "Administrative distance\n" "Distance value\n" "IP source prefix\n") { + int idx_number = 1; + int idx_ipv4_prefixlen = 2; struct ospf *ospf = vty->index; if (!ospf) return CMD_SUCCESS; - ospf_distance_set (vty, ospf, argv[0], argv[1], NULL); + ospf_distance_set (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); return CMD_SUCCESS; } DEFUN (no_ospf_distance_source, no_ospf_distance_source_cmd, - "no distance <1-255> A.B.C.D/M", + "no distance (1-255) A.B.C.D/M", NO_STR "Administrative distance\n" "Distance value\n" "IP source prefix\n") { + int idx_number = 2; + int idx_ipv4_prefixlen = 3; struct ospf *ospf = vty->index; if (!ospf) return CMD_SUCCESS; - ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL); + ospf_distance_unset (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); return CMD_SUCCESS; } DEFUN (ospf_distance_source_access_list, ospf_distance_source_access_list_cmd, - "distance <1-255> A.B.C.D/M WORD", + "distance (1-255) A.B.C.D/M WORD", "Administrative distance\n" "Distance value\n" "IP source prefix\n" "Access list name\n") { + int idx_number = 1; + int idx_ipv4_prefixlen = 2; + int idx_word = 3; struct ospf *ospf = vty->index; if (!ospf) return CMD_SUCCESS; - ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]); + ospf_distance_set (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); return CMD_SUCCESS; } DEFUN (no_ospf_distance_source_access_list, no_ospf_distance_source_access_list_cmd, - "no distance <1-255> A.B.C.D/M WORD", + "no distance (1-255) A.B.C.D/M WORD", NO_STR "Administrative distance\n" "Distance value\n" "IP source prefix\n" "Access list name\n") { + int idx_number = 2; + int idx_ipv4_prefixlen = 3; + int idx_word = 4; struct ospf *ospf = vty->index; if (!ospf) return CMD_SUCCESS; - ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]); + ospf_distance_unset (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); return CMD_SUCCESS; } DEFUN (ip_ospf_mtu_ignore, ip_ospf_mtu_ignore_addr_cmd, - "ip ospf mtu-ignore A.B.C.D", + "ip ospf mtu-ignore [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Disable mtu mismatch detection\n" "Address of interface") { + int idx_ipv4 = 3; struct interface *ifp = vty->index; struct in_addr addr; int ret; @@ -8652,9 +8593,9 @@ DEFUN (ip_ospf_mtu_ignore, struct ospf_if_params *params; params = IF_DEF_PARAMS (ifp); - if (argc == 1) + if (argc == 4) { - ret = inet_aton(argv[0], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -8679,22 +8620,15 @@ DEFUN (ip_ospf_mtu_ignore, return CMD_SUCCESS; } -ALIAS (ip_ospf_mtu_ignore, - ip_ospf_mtu_ignore_cmd, - "ip ospf mtu-ignore", - "IP Information\n" - "OSPF interface commands\n" - "Disable mtu mismatch detection\n") - - DEFUN (no_ip_ospf_mtu_ignore, no_ip_ospf_mtu_ignore_addr_cmd, - "no ip ospf mtu-ignore A.B.C.D", + "no ip ospf mtu-ignore [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Disable mtu mismatch detection\n" "Address of interface") { + int idx_ipv4 = 4; struct interface *ifp = vty->index; struct in_addr addr; int ret; @@ -8702,9 +8636,9 @@ DEFUN (no_ip_ospf_mtu_ignore, struct ospf_if_params *params; params = IF_DEF_PARAMS (ifp); - if (argc == 1) + if (argc == 5) { - ret = inet_aton(argv[0], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -8729,12 +8663,6 @@ DEFUN (no_ip_ospf_mtu_ignore, return CMD_SUCCESS; } -ALIAS (no_ip_ospf_mtu_ignore, - no_ip_ospf_mtu_ignore_cmd, - "no ip ospf mtu-ignore", - "IP Information\n" - "OSPF interface commands\n" - "Disable mtu mismatch detection\n") DEFUN (ospf_max_metric_router_lsa_admin, ospf_max_metric_router_lsa_admin_cmd, @@ -8797,12 +8725,13 @@ DEFUN (no_ospf_max_metric_router_lsa_admin, DEFUN (ospf_max_metric_router_lsa_startup, ospf_max_metric_router_lsa_startup_cmd, - "max-metric router-lsa on-startup <5-86400>", + "max-metric router-lsa on-startup (5-86400)", "OSPF maximum / infinite-distance metric\n" "Advertise own Router-LSA with infinite distance (stub router)\n" "Automatically advertise stub Router-LSA on startup of OSPF\n" "Time (seconds) to advertise self as stub-router\n") { + int idx_number = 3; unsigned int seconds; struct ospf *ospf = vty->index; @@ -8815,7 +8744,7 @@ DEFUN (ospf_max_metric_router_lsa_startup, return CMD_WARNING; } - VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]); + VTY_GET_INTEGER ("stub-router startup period", seconds, argv[idx_number]->arg); ospf->stub_router_startup_time = seconds; @@ -8824,7 +8753,7 @@ DEFUN (ospf_max_metric_router_lsa_startup, DEFUN (no_ospf_max_metric_router_lsa_startup, no_ospf_max_metric_router_lsa_startup_cmd, - "no max-metric router-lsa on-startup <5-86400>", + "no max-metric router-lsa on-startup [(5-86400)]", NO_STR "OSPF maximum / infinite-distance metric\n" "Advertise own Router-LSA with infinite distance (stub router)\n" @@ -8855,22 +8784,16 @@ DEFUN (no_ospf_max_metric_router_lsa_startup, return CMD_SUCCESS; } -ALIAS (no_ospf_max_metric_router_lsa_startup, - no_ospf_max_metric_router_lsa_startup_no_param_cmd, - "no max-metric router-lsa on-startup", - NO_STR - "OSPF maximum / infinite-distance metric\n" - "Advertise own Router-LSA with infinite distance (stub router)\n" - "Automatically advertise stub Router-LSA on startup of OSPF\n"); DEFUN (ospf_max_metric_router_lsa_shutdown, ospf_max_metric_router_lsa_shutdown_cmd, - "max-metric router-lsa on-shutdown <5-100>", + "max-metric router-lsa on-shutdown (5-100)", "OSPF maximum / infinite-distance metric\n" "Advertise own Router-LSA with infinite distance (stub router)\n" "Advertise stub-router prior to full shutdown of OSPF\n" "Time (seconds) to wait till full shutdown\n") { + int idx_number = 3; unsigned int seconds; struct ospf *ospf = vty->index; @@ -8883,7 +8806,7 @@ DEFUN (ospf_max_metric_router_lsa_shutdown, return CMD_WARNING; } - VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]); + VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[idx_number]->arg); ospf->stub_router_shutdown_time = seconds; @@ -8892,7 +8815,7 @@ DEFUN (ospf_max_metric_router_lsa_shutdown, DEFUN (no_ospf_max_metric_router_lsa_shutdown, no_ospf_max_metric_router_lsa_shutdown_cmd, - "no max-metric router-lsa on-shutdown <5-100>", + "no max-metric router-lsa on-shutdown [(5-100)]", NO_STR "OSPF maximum / infinite-distance metric\n" "Advertise own Router-LSA with infinite distance (stub router)\n" @@ -8909,14 +8832,6 @@ DEFUN (no_ospf_max_metric_router_lsa_shutdown, return CMD_SUCCESS; } -ALIAS (no_ospf_max_metric_router_lsa_shutdown, - no_ospf_max_metric_router_lsa_shutdown_no_param_cmd, - "no max-metric router-lsa on-shutdown", - NO_STR - "OSPF maximum / infinite-distance metric\n" - "Advertise own Router-LSA with infinite distance (stub router)\n" - "Advertise stub-router prior to full shutdown of OSPF\n"); - static void config_write_stub_router (struct vty *vty, struct ospf *ospf) { @@ -9136,17 +9051,18 @@ DEFUN (show_ip_ospf_border_routers, DEFUN (show_ip_ospf_instance_border_routers, show_ip_ospf_instance_border_routers_cmd, - "show ip ospf <1-65535> border-routers", + "show ip ospf (1-65535) border-routers", SHOW_STR IP_STR "OSPF information\n" "Instance ID\n" "Show all the ABR's and ASBR's\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -9198,17 +9114,18 @@ DEFUN (show_ip_ospf_route, DEFUN (show_ip_ospf_instance_route, show_ip_ospf_instance_route_cmd, - "show ip ospf <1-65535> route", + "show ip ospf (1-65535) route", SHOW_STR IP_STR "OSPF information\n" "Instance ID\n" "OSPF routing table\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -9980,21 +9897,13 @@ ospf_vty_show_init (void) install_element (VIEW_NODE, &show_ip_ospf_instance_cmd); /* "show ip ospf database" commands. */ - install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd); - install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd); - install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); - install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd); - install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd); install_element (VIEW_NODE, &show_ip_ospf_database_cmd); + install_element (VIEW_NODE, &show_ip_ospf_database_max_cmd); - install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_cmd); - install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_cmd); - install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_adv_router_cmd); install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_adv_router_cmd); - install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_self_cmd); - install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_self_cmd); install_element (VIEW_NODE, &show_ip_ospf_instance_database_cmd); + install_element (VIEW_NODE, &show_ip_ospf_instance_database_max_cmd); /* "show ip ospf interface" commands. */ install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); @@ -10052,121 +9961,75 @@ ospf_vty_if_init (void) /* "ip ospf authentication" commands. */ install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); - install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd); install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); - install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_authentication_args_addr_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_authentication_args_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd); install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); - install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_authkey_addr_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_authkey_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd); + install_element (INTERFACE_NODE, &no_ospf_authentication_key_authkey_addr_cmd); /* "ip ospf message-digest-key" commands. */ install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); - install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_md5_addr_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_md5_cmd); + install_element (INTERFACE_NODE, &no_ospf_message_digest_key_addr_cmd); /* "ip ospf cost" commands. */ install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd); - install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); + install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd); + install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd); /* "ip ospf mtu-ignore" commands. */ install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd); - install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd); /* "ip ospf dead-interval" commands. */ install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd); - install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd); - install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_seconds_cmd); /* "ip ospf hello-interval" commands. */ install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd); - install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_seconds_cmd); /* "ip ospf network" commands. */ install_element (INTERFACE_NODE, &ip_ospf_network_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_network_val_cmd); + install_element (INTERFACE_NODE, &no_ospf_network_cmd); /* "ip ospf priority" commands. */ install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); - install_element (INTERFACE_NODE, &ip_ospf_priority_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_priority_no_param_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); + install_element (INTERFACE_NODE, &no_ospf_priority_addr_cmd); /* "ip ospf retransmit-interval" commands. */ install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); - install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_sec_addr_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_sec_cmd); + install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); /* "ip ospf transmit-delay" commands. */ install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); - install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_sec_addr_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_sec_cmd); + install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); /* "ip ospf area" commands. */ install_element (INTERFACE_NODE, &ip_ospf_area_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_area_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_area_val_cmd); - install_element (INTERFACE_NODE, &ip_ospf_instance_area_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_instance_area_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_instance_area_val_cmd); /* These commands are compatibitliy for previous version. */ install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); - install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd); - install_element (INTERFACE_NODE, &no_ospf_authentication_key_authkey_cmd); - install_element (INTERFACE_NODE, &no_ospf_authentication_key_authkey_ip_cmd); install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); - install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd); - install_element (INTERFACE_NODE, &ospf_cost_u32_cmd); install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd); - install_element (INTERFACE_NODE, &no_ospf_cost_cmd); - install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd); - install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd); - install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd); install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); - install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_minimal_addr_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_minimal_cmd); install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); - install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd); install_element (INTERFACE_NODE, &ospf_network_cmd); - install_element (INTERFACE_NODE, &no_ospf_network_cmd); - install_element (INTERFACE_NODE, &no_ospf_network_val_cmd); install_element (INTERFACE_NODE, &ospf_priority_cmd); - install_element (INTERFACE_NODE, &no_ospf_priority_cmd); install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); - install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); - install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); } static void @@ -10185,7 +10048,6 @@ ospf_vty_zebra_init (void) install_element (OSPF_NODE, &ospf_default_metric_cmd); install_element (OSPF_NODE, &no_ospf_default_metric_cmd); - install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd); install_element (OSPF_NODE, &ospf_distance_cmd); install_element (OSPF_NODE, &no_ospf_distance_cmd); @@ -10226,17 +10088,18 @@ DEFUN (clear_ip_ospf_interface, "Interface information\n" "Interface name\n") { + int idx_ifname = 4; struct interface *ifp; struct listnode *node; - if (argc == 0) /* Clear all the ospfv2 interfaces. */ + if (argc == 4) /* Clear all the ospfv2 interfaces. */ { for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) ospf_interface_clear(ifp); } else /* Interface name is specified. */ { - if ((ifp = if_lookup_by_name (argv[0])) == NULL) + if ((ifp = if_lookup_by_name (argv[idx_ifname]->text)) == NULL) vty_out (vty, "No such interface name%s", VTY_NEWLINE); else ospf_interface_clear(ifp); @@ -10263,8 +10126,6 @@ ospf_vty_init (void) install_element (CONFIG_NODE, &router_ospf_cmd); install_element (CONFIG_NODE, &no_router_ospf_cmd); - install_element (CONFIG_NODE, &router_ospf_instance_cmd); - install_element (CONFIG_NODE, &no_router_ospf_instance_cmd); install_default (OSPF_NODE); @@ -10272,15 +10133,10 @@ ospf_vty_init (void) install_element (OSPF_NODE, &ospf_router_id_cmd); install_element (OSPF_NODE, &ospf_router_id_old_cmd); install_element (OSPF_NODE, &no_ospf_router_id_cmd); - install_element (OSPF_NODE, &no_ospf_router_id_val_cmd); /* "passive-interface" commands. */ install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); - install_element (OSPF_NODE, &ospf_passive_interface_cmd); - install_element (OSPF_NODE, &ospf_passive_interface_default_cmd); install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); - install_element (OSPF_NODE, &no_ospf_passive_interface_cmd); - install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd); /* "ospf abr-type" commands. */ install_element (OSPF_NODE, &ospf_abr_type_cmd); @@ -10293,10 +10149,10 @@ ospf_vty_init (void) install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd); /* "ospf rfc1583-compatible" commands. */ - install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); - install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); + install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); + install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); /* "network area" commands. */ install_element (OSPF_NODE, &ospf_network_area_cmd); @@ -10309,53 +10165,26 @@ ospf_vty_init (void) /* "area range" commands. */ install_element (OSPF_NODE, &ospf_area_range_cmd); - install_element (OSPF_NODE, &ospf_area_range_advertise_cmd); install_element (OSPF_NODE, &ospf_area_range_cost_cmd); - install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd); install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); install_element (OSPF_NODE, &no_ospf_area_range_cmd); - install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd); - install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd); - install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd); install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); /* "area virtual-link" commands. */ install_element (OSPF_NODE, &ospf_area_vlink_cmd); + install_element (OSPF_NODE, &ospf_area_vlink_intervals_cmd); install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); + install_element (OSPF_NODE, &no_ospf_area_vlink_intervals_cmd); - install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd); - install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd); - install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd); - install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd); - install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd); - install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd); - install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd); - install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd); - install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd); - install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_args_cmd); - install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd); - install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd); - install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd); - install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd); - install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd); - install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd); - install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd); - install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_args_authkey_cmd); - install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd); - install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd); - install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd); - install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_args_md5_cmd); - install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd); - install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd); /* "area stub" commands. */ install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); @@ -10369,7 +10198,6 @@ ospf_vty_init (void) install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); - install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd); install_element (OSPF_NODE, &ospf_area_default_cost_cmd); install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); @@ -10389,57 +10217,42 @@ ospf_vty_init (void) /* SPF timer commands */ install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd); install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd); - install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_val_cmd); /* LSA timers commands */ install_element (OSPF_NODE, &ospf_timers_min_ls_interval_cmd); install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_cmd); - install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_val_cmd); install_element (OSPF_NODE, &ospf_timers_min_ls_arrival_cmd); install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_cmd); - install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_val_cmd); install_element (OSPF_NODE, &ospf_timers_lsa_cmd); install_element (OSPF_NODE, &no_ospf_timers_lsa_cmd); - install_element (OSPF_NODE, &no_ospf_timers_lsa_val_cmd); /* refresh timer commands */ install_element (OSPF_NODE, &ospf_refresh_timer_cmd); install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); - install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd); /* max-metric commands */ install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd); install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd); install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd); install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd); - install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_no_param_cmd); install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd); install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd); - install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_no_param_cmd); /* reference bandwidth commands */ install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); - install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_val_cmd); /* "neighbor" commands. */ install_element (OSPF_NODE, &ospf_neighbor_cmd); - install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd); - install_element (OSPF_NODE, &ospf_neighbor_priority_cmd); install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); - install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd); install_element (OSPF_NODE, &no_ospf_neighbor_cmd); - install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd); - install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd); - install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_priority_cmd); - install_element (OSPF_NODE, &no_ospf_neighbor_priority_pollinterval_cmd); + install_element (OSPF_NODE, &no_ospf_neighbor_poll_cmd); /* write multiplier commands */ install_element (OSPF_NODE, &ospf_write_multiplier_cmd); - install_element (OSPF_NODE, &no_ospf_write_multiplier_cmd); install_element (OSPF_NODE, &write_multiplier_cmd); + install_element (OSPF_NODE, &no_ospf_write_multiplier_cmd); install_element (OSPF_NODE, &no_write_multiplier_cmd); - install_element (OSPF_NODE, &no_write_multiplier_val_cmd); /* Init interface related vty commands. */ ospf_vty_if_init (); diff --git a/ospfd/ospf_zebra.h b/ospfd/ospf_zebra.h index 7cfae417e3..8e93ed2691 100644 --- a/ospfd/ospf_zebra.h +++ b/ospfd/ospf_zebra.h @@ -42,8 +42,6 @@ struct ospf_distance }; /* Prototypes */ -extern void ospf_zclient_start (void); - extern void ospf_zebra_add (struct prefix_ipv4 *, struct ospf_route *); extern void ospf_zebra_delete (struct prefix_ipv4 *, struct ospf_route *); diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 430fc738d5..afc42a9561 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -1533,8 +1533,9 @@ DEFUN (pim_interface, "Select an interface to configure\n" "Interface's name\n") { + int idx_ifname = 1; struct interface *ifp; - const char *ifname = argv[0]; + const char *ifname = argv[idx_ifname]->arg; size_t sl; sl = strlen(ifname); @@ -2368,13 +2369,14 @@ DEFUN (show_ip_rib, RIB_STR "Unicast address\n") { + int idx_ipv4 = 3; struct in_addr addr; const char *addr_str; struct pim_nexthop nexthop; char nexthop_addr_str[100]; int result; - addr_str = argv[0]; + addr_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, addr_str, &addr); if (result <= 0) { vty_out(vty, "Bad unicast address %s: errno=%d: %s%s", @@ -2466,16 +2468,17 @@ DEFUN (ip_pim_rp, "Rendevous Point\n" "ip address of RP\n") { + int idx_ipv4 = 3; int result; - result = inet_pton(AF_INET, argv[0], &qpim_rp.rpf_addr.s_addr); + result = inet_pton(AF_INET, argv[idx_ipv4]->arg, &qpim_rp.rpf_addr.s_addr); if (result <= 0) { - vty_out(vty, "%% Bad RP address specified: %s", argv[0]); + vty_out(vty, "%% Bad RP address specified: %s", argv[idx_ipv4]->arg); return CMD_WARNING; } if (pim_nexthop_lookup(&qpim_rp.source_nexthop, qpim_rp.rpf_addr, NULL) != 0) { - vty_out(vty, "%% No Path to RP address specified: %s", argv[0]); + vty_out(vty, "%% No Path to RP address specified: %s", argv[idx_ipv4]->arg); return CMD_WARNING; } @@ -2484,7 +2487,7 @@ DEFUN (ip_pim_rp, DEFUN (no_ip_pim_rp, no_ip_pim_rp_cmd, - "no ip pim rp {A.B.C.D}", + "no ip pim rp [A.B.C.D]", NO_STR IP_STR "pim multicast routing\n" @@ -2498,7 +2501,7 @@ DEFUN (no_ip_pim_rp, DEFUN (ip_multicast_routing, ip_multicast_routing_cmd, - PIM_CMD_IP_MULTICAST_ROUTING, + "ip multicast-routing", IP_STR "Enable IP multicast forwarding\n") { @@ -2511,7 +2514,7 @@ DEFUN (ip_multicast_routing, DEFUN (no_ip_multicast_routing, no_ip_multicast_routing_cmd, - PIM_CMD_NO " " PIM_CMD_IP_MULTICAST_ROUTING, + "no ip multicast-routing", NO_STR IP_STR "Global IP configuration subcommands\n" @@ -2531,9 +2534,10 @@ DEFUN (ip_ssmpingd, CONF_SSMPINGD_STR "Source address\n") { + int idx_ipv4 = 2; int result; struct in_addr source_addr; - const char *source_str = (argc > 0) ? argv[0] : "0.0.0.0"; + const char *source_str = (argc > idx_ipv4) ? argv[idx_ipv4]->arg : "0.0.0.0"; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { @@ -2560,9 +2564,10 @@ DEFUN (no_ip_ssmpingd, CONF_SSMPINGD_STR "Source address\n") { + int idx_ipv4 = 3; int result; struct in_addr source_addr; - const char *source_str = (argc > 0) ? argv[0] : "0.0.0.0"; + const char *source_str = (argc > idx_ipv4) ? argv[idx_ipv4]->arg : "0.0.0.0"; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { @@ -2648,6 +2653,8 @@ DEFUN (interface_ip_igmp_join, "Multicast group address\n" "Source address\n") { + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; struct interface *ifp; const char *group_str; const char *source_str; @@ -2658,7 +2665,7 @@ DEFUN (interface_ip_igmp_join, ifp = vty->index; /* Group address */ - group_str = argv[0]; + group_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, group_str, &group_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -2667,7 +2674,7 @@ DEFUN (interface_ip_igmp_join, } /* Source address */ - source_str = argv[1]; + source_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -2695,6 +2702,8 @@ DEFUN (interface_no_ip_igmp_join, "Multicast group address\n" "Source address\n") { + int idx_ipv4 = 4; + int idx_ipv4_2 = 5; struct interface *ifp; const char *group_str; const char *source_str; @@ -2705,7 +2714,7 @@ DEFUN (interface_no_ip_igmp_join, ifp = vty->index; /* Group address */ - group_str = argv[0]; + group_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, group_str, &group_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -2714,7 +2723,7 @@ DEFUN (interface_no_ip_igmp_join, } /* Source address */ - source_str = argv[1]; + source_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -2865,7 +2874,7 @@ static void change_query_max_response_time(struct pim_interface *pim_ifp, DEFUN (interface_ip_igmp_query_interval, interface_ip_igmp_query_interval_cmd, - PIM_CMD_IP_IGMP_QUERY_INTERVAL " <1-1800>", + "ip igmp query-interval (1-1800)", IP_STR IFACE_IGMP_STR IFACE_IGMP_QUERY_INTERVAL_STR @@ -2887,7 +2896,7 @@ DEFUN (interface_ip_igmp_query_interval, return CMD_WARNING; } - query_interval = atoi(argv[0]); + query_interval = atoi(argv[4]->arg); query_interval_dsec = 10 * query_interval; /* @@ -2924,7 +2933,7 @@ DEFUN (interface_ip_igmp_query_interval, DEFUN (interface_no_ip_igmp_query_interval, interface_no_ip_igmp_query_interval_cmd, - PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_INTERVAL, + "no ip igmp query-interval", NO_STR IP_STR IFACE_IGMP_STR @@ -2960,7 +2969,7 @@ DEFUN (interface_no_ip_igmp_query_interval, DEFUN (interface_ip_igmp_query_max_response_time, interface_ip_igmp_query_max_response_time_cmd, - PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME " <1-25>", + "ip igmp query-max-response-time (1-25)", IP_STR IFACE_IGMP_STR IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR @@ -2981,7 +2990,7 @@ DEFUN (interface_ip_igmp_query_max_response_time, return CMD_WARNING; } - query_max_response_time = atoi(argv[0]); + query_max_response_time = atoi(argv[4]->arg); /* It seems we don't need to check bounds since command.c does it @@ -3017,7 +3026,7 @@ DEFUN (interface_ip_igmp_query_max_response_time, DEFUN (interface_no_ip_igmp_query_max_response_time, interface_no_ip_igmp_query_max_response_time_cmd, - PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME, + "no ip igmp query-max-response-time", NO_STR IP_STR IFACE_IGMP_STR @@ -3053,7 +3062,7 @@ DEFUN (interface_no_ip_igmp_query_max_response_time, DEFUN (interface_ip_igmp_query_max_response_time_dsec, interface_ip_igmp_query_max_response_time_dsec_cmd, - PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC " <10-250>", + "ip igmp query-max-response-time-dsec (10-250)", IP_STR IFACE_IGMP_STR IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR @@ -3075,7 +3084,7 @@ DEFUN (interface_ip_igmp_query_max_response_time_dsec, return CMD_WARNING; } - query_max_response_time_dsec = atoi(argv[0]); + query_max_response_time_dsec = atoi(argv[4]->arg); /* It seems we don't need to check bounds since command.c does it @@ -3113,7 +3122,7 @@ DEFUN (interface_ip_igmp_query_max_response_time_dsec, DEFUN (interface_no_ip_igmp_query_max_response_time_dsec, interface_no_ip_igmp_query_max_response_time_dsec_cmd, - PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, + "no ip igmp query-max-response-time-dsec", NO_STR IP_STR IFACE_IGMP_STR @@ -3146,12 +3155,13 @@ DEFUN (interface_no_ip_igmp_query_max_response_time_dsec, DEFUN (interface_ip_pim_drprio, interface_ip_pim_drprio_cmd, - "ip pim drpriority <1-4294967295>", + "ip pim drpriority (1-4294967295)", IP_STR PIM_STR "Set the Designated Router Election Priority\n" "Value of the new DR Priority\n") { + int idx_number = 3; struct interface *ifp; struct pim_interface *pim_ifp; uint32_t old_dr_prio; @@ -3166,7 +3176,7 @@ DEFUN (interface_ip_pim_drprio, old_dr_prio = pim_ifp->pim_dr_priority; - pim_ifp->pim_dr_priority = strtol(argv[0], NULL, 10); + pim_ifp->pim_dr_priority = strtol(argv[idx_number]->arg, NULL, 10); if (old_dr_prio != pim_ifp->pim_dr_priority) { if (pim_if_dr_election(ifp)) @@ -3178,7 +3188,8 @@ DEFUN (interface_ip_pim_drprio, DEFUN (interface_no_ip_pim_drprio, interface_no_ip_pim_drprio_cmd, - "no ip pim drpriority {<1-4294967295>}", + "no ip pim drpriority [(1-4294967295)]", + NO_STR IP_STR PIM_STR "Revert the Designated Router Priority to default\n" @@ -3345,6 +3356,8 @@ DEFUN (interface_ip_mroute, "Outgoing interface name\n" "Group address\n") { + int idx_interface = 2; + int idx_ipv4 = 3; struct interface *iif; struct interface *oif; const char *oifname; @@ -3355,7 +3368,7 @@ DEFUN (interface_ip_mroute, iif = vty->index; - oifname = argv[0]; + oifname = argv[idx_interface]->arg; oif = if_lookup_by_name(oifname); if (!oif) { vty_out(vty, "No such interface name %s%s", @@ -3363,7 +3376,7 @@ DEFUN (interface_ip_mroute, return CMD_WARNING; } - grp_str = argv[1]; + grp_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, grp_str, &grp_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -3390,6 +3403,9 @@ DEFUN (interface_ip_mroute_source, "Group address\n" "Source address\n") { + int idx_interface = 2; + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; struct interface *iif; struct interface *oif; const char *oifname; @@ -3401,7 +3417,7 @@ DEFUN (interface_ip_mroute_source, iif = vty->index; - oifname = argv[0]; + oifname = argv[idx_interface]->arg; oif = if_lookup_by_name(oifname); if (!oif) { vty_out(vty, "No such interface name %s%s", @@ -3409,7 +3425,7 @@ DEFUN (interface_ip_mroute_source, return CMD_WARNING; } - grp_str = argv[1]; + grp_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, grp_str, &grp_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -3417,7 +3433,7 @@ DEFUN (interface_ip_mroute_source, return CMD_WARNING; } - src_str = argv[2]; + src_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, src_str, &src_addr); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -3442,6 +3458,8 @@ DEFUN (interface_no_ip_mroute, "Outgoing interface name\n" "Group Address\n") { + int idx_interface = 3; + int idx_ipv4 = 4; struct interface *iif; struct interface *oif; const char *oifname; @@ -3452,7 +3470,7 @@ DEFUN (interface_no_ip_mroute, iif = vty->index; - oifname = argv[0]; + oifname = argv[idx_interface]->arg; oif = if_lookup_by_name(oifname); if (!oif) { vty_out(vty, "No such interface name %s%s", @@ -3460,7 +3478,7 @@ DEFUN (interface_no_ip_mroute, return CMD_WARNING; } - grp_str = argv[1]; + grp_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, grp_str, &grp_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -3488,6 +3506,9 @@ DEFUN (interface_no_ip_mroute_source, "Group Address\n" "Source Address\n") { + int idx_interface = 3; + int idx_ipv4 = 4; + int idx_ipv4_2 = 5; struct interface *iif; struct interface *oif; const char *oifname; @@ -3499,7 +3520,7 @@ DEFUN (interface_no_ip_mroute_source, iif = vty->index; - oifname = argv[0]; + oifname = argv[idx_interface]->arg; oif = if_lookup_by_name(oifname); if (!oif) { vty_out(vty, "No such interface name %s%s", @@ -3507,7 +3528,7 @@ DEFUN (interface_no_ip_mroute_source, return CMD_WARNING; } - grp_str = argv[1]; + grp_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, grp_str, &grp_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -3515,7 +3536,7 @@ DEFUN (interface_no_ip_mroute_source, return CMD_WARNING; } - src_str = argv[2]; + src_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, src_str, &src_addr); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -3533,12 +3554,15 @@ DEFUN (interface_no_ip_mroute_source, DEFUN (interface_ip_pim_hello, interface_ip_pim_hello_cmd, - "ip pim hello <1-180>", + "ip pim hello (1-180) [(1-180)]", IP_STR PIM_STR IFACE_PIM_HELLO_STR - IFACE_PIM_HELLO_TIME_STR) + IFACE_PIM_HELLO_TIME_STR + IFACE_PIM_HELLO_HOLD_STR) { + int idx_time = 3; + int idx_hold = 4; struct interface *ifp; struct pim_interface *pim_ifp; @@ -3550,27 +3574,19 @@ DEFUN (interface_ip_pim_hello, return CMD_WARNING; } - pim_ifp->pim_hello_period = strtol(argv[0], NULL, 10); + pim_ifp->pim_hello_period = strtol(argv[idx_time]->arg, NULL, 10); - if (argc == 2) - pim_ifp->pim_default_holdtime = strtol(argv[1], NULL, 10); + if (argc > idx_hold) + pim_ifp->pim_default_holdtime = strtol(argv[idx_hold]->arg, NULL, 10); return CMD_SUCCESS; } -ALIAS (interface_ip_pim_hello, - interface_ip_pim_hello_hold_cmd, - "ip pim hello <1-180> <1-180>", - IP_STR - PIM_STR - IFACE_PIM_HELLO_STR - IFACE_PIM_HELLO_TIME_STR - IFACE_PIM_HELLO_HOLD_STR) DEFUN (interface_no_ip_pim_hello, interface_no_ip_pim_hello_cmd, - "no ip pim hello {<1-180> <1-180>}", + "no ip pim hello [(1-180) (1-180)]", NO_STR IP_STR PIM_STR @@ -3620,11 +3636,6 @@ DEFUN (no_debug_igmp, return CMD_SUCCESS; } -ALIAS (no_debug_igmp, - undebug_igmp_cmd, - "undebug igmp", - UNDEBUG_STR - DEBUG_IGMP_STR) DEFUN (debug_igmp_events, debug_igmp_events_cmd, @@ -3649,12 +3660,6 @@ DEFUN (no_debug_igmp_events, return CMD_SUCCESS; } -ALIAS (no_debug_igmp_events, - undebug_igmp_events_cmd, - "undebug igmp events", - UNDEBUG_STR - DEBUG_IGMP_STR - DEBUG_IGMP_EVENTS_STR) DEFUN (debug_igmp_packets, debug_igmp_packets_cmd, @@ -3679,12 +3684,6 @@ DEFUN (no_debug_igmp_packets, return CMD_SUCCESS; } -ALIAS (no_debug_igmp_packets, - undebug_igmp_packets_cmd, - "undebug igmp packets", - UNDEBUG_STR - DEBUG_IGMP_STR - DEBUG_IGMP_PACKETS_STR) DEFUN (debug_igmp_trace, debug_igmp_trace_cmd, @@ -3709,12 +3708,6 @@ DEFUN (no_debug_igmp_trace, return CMD_SUCCESS; } -ALIAS (no_debug_igmp_trace, - undebug_igmp_trace_cmd, - "undebug igmp trace", - UNDEBUG_STR - DEBUG_IGMP_STR - DEBUG_IGMP_TRACE_STR) DEFUN (debug_mroute, debug_mroute_cmd, @@ -3737,11 +3730,6 @@ DEFUN (no_debug_mroute, return CMD_SUCCESS; } -ALIAS (no_debug_mroute, - undebug_mroute_cmd, - "undebug mroute", - UNDEBUG_STR - DEBUG_MROUTE_STR) DEFUN (debug_static, debug_static_cmd, @@ -3764,11 +3752,6 @@ DEFUN (no_debug_static, return CMD_SUCCESS; } -ALIAS (no_debug_static, - undebug_static_cmd, - "undebug static", - UNDEBUG_STR - DEBUG_STATIC_STR) DEFUN (debug_pim, debug_pim_cmd, @@ -3799,11 +3782,6 @@ DEFUN (no_debug_pim, return CMD_SUCCESS; } -ALIAS (no_debug_pim, - undebug_pim_cmd, - "undebug pim", - UNDEBUG_STR - DEBUG_PIM_STR) DEFUN (debug_pim_events, debug_pim_events_cmd, @@ -3828,12 +3806,6 @@ DEFUN (no_debug_pim_events, return CMD_SUCCESS; } -ALIAS (no_debug_pim_events, - undebug_pim_events_cmd, - "undebug pim events", - UNDEBUG_STR - DEBUG_PIM_STR - DEBUG_PIM_EVENTS_STR) DEFUN (debug_pim_packets, debug_pim_packets_cmd, @@ -3849,19 +3821,20 @@ DEFUN (debug_pim_packets, DEFUN (debug_pim_packets_filter, debug_pim_packets_filter_cmd, - "debug pim packets (hello|joins)", + "debug pim packets <hello|joins>", DEBUG_STR DEBUG_PIM_STR DEBUG_PIM_PACKETS_STR DEBUG_PIM_HELLO_PACKETS_STR DEBUG_PIM_J_P_PACKETS_STR) { - if (strncmp(argv[0],"h",1) == 0) + int idx_hello_join = 3; + if (strncmp(argv[idx_hello_join]->arg,"h",1) == 0) { PIM_DO_DEBUG_PIM_HELLO; vty_out (vty, "PIM Hello debugging is on %s", VTY_NEWLINE); } - else if (strncmp(argv[0],"j",1) == 0) + else if (strncmp(argv[idx_hello_join]->arg,"j",1) == 0) { PIM_DO_DEBUG_PIM_J_P; vty_out (vty, "PIM Join/Prune debugging is on %s", VTY_NEWLINE); @@ -3886,7 +3859,7 @@ DEFUN (no_debug_pim_packets, DEFUN (no_debug_pim_packets_filter, no_debug_pim_packets_filter_cmd, - "no debug pim packets (hello|joins)", + "no debug pim packets <hello|joins>", NO_STR DEBUG_STR DEBUG_PIM_STR @@ -3894,12 +3867,13 @@ DEFUN (no_debug_pim_packets_filter, DEBUG_PIM_HELLO_PACKETS_STR DEBUG_PIM_J_P_PACKETS_STR) { - if (strncmp(argv[0],"h",1) == 0) + int idx_hello_join = 4; + if (strncmp(argv[idx_hello_join]->arg,"h",1) == 0) { PIM_DONT_DEBUG_PIM_HELLO; vty_out (vty, "PIM Hello debugging is off %s", VTY_NEWLINE); } - else if (strncmp(argv[0],"j",1) == 0) + else if (strncmp(argv[idx_hello_join]->arg,"j",1) == 0) { PIM_DONT_DEBUG_PIM_J_P; vty_out (vty, "PIM Join/Prune debugging is off %s", VTY_NEWLINE); @@ -3907,12 +3881,6 @@ DEFUN (no_debug_pim_packets_filter, return CMD_SUCCESS; } -ALIAS (no_debug_pim_packets, - undebug_pim_packets_cmd, - "undebug pim packets", - UNDEBUG_STR - DEBUG_PIM_STR - DEBUG_PIM_PACKETS_STR) DEFUN (debug_pim_packetdump_send, debug_pim_packetdump_send_cmd, @@ -3939,13 +3907,6 @@ DEFUN (no_debug_pim_packetdump_send, return CMD_SUCCESS; } -ALIAS (no_debug_pim_packetdump_send, - undebug_pim_packetdump_send_cmd, - "undebug pim packet-dump send", - UNDEBUG_STR - DEBUG_PIM_STR - DEBUG_PIM_PACKETDUMP_STR - DEBUG_PIM_PACKETDUMP_SEND_STR) DEFUN (debug_pim_packetdump_recv, debug_pim_packetdump_recv_cmd, @@ -3972,13 +3933,6 @@ DEFUN (no_debug_pim_packetdump_recv, return CMD_SUCCESS; } -ALIAS (no_debug_pim_packetdump_recv, - undebug_pim_packetdump_recv_cmd, - "undebug pim packet-dump receive", - UNDEBUG_STR - DEBUG_PIM_STR - DEBUG_PIM_PACKETDUMP_STR - DEBUG_PIM_PACKETDUMP_RECV_STR) DEFUN (debug_pim_trace, debug_pim_trace_cmd, @@ -4003,12 +3957,6 @@ DEFUN (no_debug_pim_trace, return CMD_SUCCESS; } -ALIAS (no_debug_pim_trace, - undebug_pim_trace_cmd, - "undebug pim trace", - UNDEBUG_STR - DEBUG_PIM_STR - DEBUG_PIM_TRACE_STR) DEFUN (debug_ssmpingd, debug_ssmpingd_cmd, @@ -4033,12 +3981,6 @@ DEFUN (no_debug_ssmpingd, return CMD_SUCCESS; } -ALIAS (no_debug_ssmpingd, - undebug_ssmpingd_cmd, - "undebug ssmpingd", - UNDEBUG_STR - DEBUG_PIM_STR - DEBUG_SSMPINGD_STR) DEFUN (debug_pim_zebra, debug_pim_zebra_cmd, @@ -4063,12 +4005,6 @@ DEFUN (no_debug_pim_zebra, return CMD_SUCCESS; } -ALIAS (no_debug_pim_zebra, - undebug_pim_zebra_cmd, - "undebug pim zebra", - UNDEBUG_STR - DEBUG_PIM_STR - DEBUG_PIM_ZEBRA_STR) DEFUN (show_debugging_pim, show_debugging_pim_cmd, @@ -4107,7 +4043,7 @@ static struct igmp_sock *find_igmp_sock_by_fd(int fd) DEFUN (test_igmp_receive_report, test_igmp_receive_report_cmd, - "test igmp receive report <0-65535> A.B.C.D <1-6> .LINE", + "test igmp receive report (0-65535) A.B.C.D (1-6) LINE...", "Test\n" "Test IGMP protocol\n" "Test IGMP message\n" @@ -4117,6 +4053,10 @@ DEFUN (test_igmp_receive_report, "Record type\n" "Sources\n") { + int idx_number = 4; + int idx_ipv4 = 5; + int idx_number_2 = 6; + int idx_line = 7; char buf[1000]; char *igmp_msg; struct ip *ip_hdr; @@ -4138,7 +4078,7 @@ DEFUN (test_igmp_receive_report, struct in_addr *src_addr; int argi; - socket = argv[0]; + socket = argv[idx_number]->arg; socket_fd = atoi(socket); igmp = find_igmp_sock_by_fd(socket_fd); if (!igmp) { @@ -4147,7 +4087,7 @@ DEFUN (test_igmp_receive_report, return CMD_WARNING; } - grp_str = argv[1]; + grp_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, grp_str, &grp_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -4155,7 +4095,7 @@ DEFUN (test_igmp_receive_report, return CMD_WARNING; } - record_type_str = argv[2]; + record_type_str = argv[idx_number_2]->arg; record_type = atoi(record_type_str); /* @@ -4182,8 +4122,8 @@ DEFUN (test_igmp_receive_report, /* Scan LINE sources */ sources = (struct in_addr *) (group_record + IGMP_V3_GROUP_RECORD_SOURCE_OFFSET); src_addr = sources; - for (argi = 3; argi < argc; ++argi,++src_addr) { - src_str = argv[argi]; + for (argi = idx_line; argi < argc; ++argi,++src_addr) { + src_str = argv[argi]->arg; result = inet_pton(AF_INET, src_str, src_addr); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -4220,7 +4160,7 @@ static int hexval(uint8_t ch) DEFUN (test_pim_receive_dump, test_pim_receive_dump_cmd, - "test pim receive dump INTERFACE A.B.C.D .LINE", + "test pim receive dump INTERFACE A.B.C.D LINE...", "Test\n" "Test PIM protocol\n" "Test PIM message reception\n" @@ -4229,6 +4169,9 @@ DEFUN (test_pim_receive_dump, "Neighbor address\n" "Packet dump\n") { + int idx_interface = 4; + int idx_ipv4 = 5; + int idx_line = 6; uint8_t buf[1000]; uint8_t *pim_msg; struct ip *ip_hdr; @@ -4243,7 +4186,7 @@ DEFUN (test_pim_receive_dump, int result; /* Find interface */ - ifname = argv[0]; + ifname = argv[idx_interface]->arg; ifp = if_lookup_by_name(ifname); if (!ifp) { vty_out(vty, "No such interface name %s%s", @@ -4252,7 +4195,7 @@ DEFUN (test_pim_receive_dump, } /* Neighbor address */ - neigh_str = argv[1]; + neigh_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, neigh_str, &neigh_addr); if (result <= 0) { vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s", @@ -4277,8 +4220,8 @@ DEFUN (test_pim_receive_dump, pim_msg_size = 0; /* Scan LINE dump into buffer */ - for (argi = 2; argi < argc; ++argi) { - const char *str = argv[argi]; + for (argi = idx_line; argi < argc; ++argi) { + const char *str = argv[argi]->arg; int str_len = strlen(str); int str_last = str_len - 1; int i; @@ -4332,7 +4275,7 @@ DEFUN (test_pim_receive_dump, DEFUN (test_pim_receive_hello, test_pim_receive_hello_cmd, - "test pim receive hello INTERFACE A.B.C.D <0-65535> <0-65535> <0-65535> <0-32767> <0-65535> <0-1>[LINE]", + "test pim receive hello INTERFACE A.B.C.D (0-65535) (0-65535) (0-65535) (0-32767) (0-65535) (0-1) [LINE]", "Test\n" "Test PIM protocol\n" "Test PIM message reception\n" @@ -4347,6 +4290,15 @@ DEFUN (test_pim_receive_hello, "Neighbor LAN prune delay T-bit\n" "Neighbor secondary addresses\n") { + int idx_interface = 4; + int idx_ipv4 = 5; + int idx_number = 6; + int idx_number_2 = 7; + int idx_number_3 = 8; + int idx_number_4 = 9; + int idx_number_5 = 10; + int idx_number_6 = 11; + int idx_line = 12; uint8_t buf[1000]; uint8_t *pim_msg; struct ip *ip_hdr; @@ -4368,7 +4320,7 @@ DEFUN (test_pim_receive_hello, int result; /* Find interface */ - ifname = argv[0]; + ifname = argv[idx_interface]->arg; ifp = if_lookup_by_name(ifname); if (!ifp) { vty_out(vty, "No such interface name %s%s", @@ -4377,7 +4329,7 @@ DEFUN (test_pim_receive_hello, } /* Neighbor address */ - neigh_str = argv[1]; + neigh_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, neigh_str, &neigh_addr); if (result <= 0) { vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s", @@ -4385,12 +4337,12 @@ DEFUN (test_pim_receive_hello, return CMD_WARNING; } - neigh_holdtime = atoi(argv[2]); - neigh_dr_priority = atoi(argv[3]); - neigh_generation_id = atoi(argv[4]); - neigh_propagation_delay = atoi(argv[5]); - neigh_override_interval = atoi(argv[6]); - neigh_can_disable_join_suppression = atoi(argv[7]); + neigh_holdtime = atoi(argv[idx_number]->arg); + neigh_dr_priority = atoi(argv[idx_number_2]->arg); + neigh_generation_id = atoi(argv[idx_number_3]->arg); + neigh_propagation_delay = atoi(argv[idx_number_4]->arg); + neigh_override_interval = atoi(argv[idx_number_5]->arg); + neigh_can_disable_join_suppression = atoi(argv[idx_number_6]->arg); /* Tweak IP header @@ -4408,8 +4360,8 @@ DEFUN (test_pim_receive_hello, pim_msg = buf + ip_hlen; /* Scan LINE addresses */ - for (argi = 8; argi < argc; ++argi) { - const char *sec_str = argv[argi]; + for (argi = idx_line; argi < argc; ++argi) { + const char *sec_str = argv[argi]->arg; struct in_addr sec_addr; result = inet_pton(AF_INET, sec_str, &sec_addr); if (result <= 0) { @@ -4459,7 +4411,7 @@ DEFUN (test_pim_receive_hello, DEFUN (test_pim_receive_assert, test_pim_receive_assert_cmd, - "test pim receive assert INTERFACE A.B.C.D A.B.C.D A.B.C.D <0-65535> <0-65535> <0-1>", + "test pim receive assert INTERFACE A.B.C.D A.B.C.D A.B.C.D (0-65535) (0-65535) (0-1)", "Test\n" "Test PIM protocol\n" "Test PIM message reception\n" @@ -4472,6 +4424,13 @@ DEFUN (test_pim_receive_assert, "Assert route metric\n" "Assert RPT bit flag\n") { + int idx_interface = 4; + int idx_ipv4 = 5; + int idx_ipv4_2 = 6; + int idx_ipv4_3 = 7; + int idx_number = 8; + int idx_number_2 = 9; + int idx_number_3 = 10; uint8_t buf[1000]; uint8_t *buf_pastend = buf + sizeof(buf); uint8_t *pim_msg; @@ -4494,7 +4453,7 @@ DEFUN (test_pim_receive_assert, int result; /* Find interface */ - ifname = argv[0]; + ifname = argv[idx_interface]->arg; ifp = if_lookup_by_name(ifname); if (!ifp) { vty_out(vty, "No such interface name %s%s", @@ -4503,7 +4462,7 @@ DEFUN (test_pim_receive_assert, } /* Neighbor address */ - neigh_str = argv[1]; + neigh_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, neigh_str, &neigh_addr); if (result <= 0) { vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s", @@ -4512,7 +4471,7 @@ DEFUN (test_pim_receive_assert, } /* Group address */ - group_str = argv[2]; + group_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, group_str, &group_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -4521,7 +4480,7 @@ DEFUN (test_pim_receive_assert, } /* Source address */ - source_str = argv[3]; + source_str = argv[idx_ipv4_3]->arg; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -4529,9 +4488,9 @@ DEFUN (test_pim_receive_assert, return CMD_WARNING; } - assert_metric_preference = atoi(argv[4]); - assert_route_metric = atoi(argv[5]); - assert_rpt_bit_flag = atoi(argv[6]); + assert_metric_preference = atoi(argv[idx_number]->arg); + assert_route_metric = atoi(argv[idx_number_2]->arg); + assert_rpt_bit_flag = atoi(argv[idx_number_3]->arg); remain = buf_pastend - buf; if (remain < (int) sizeof(struct ip)) { @@ -4580,7 +4539,7 @@ DEFUN (test_pim_receive_assert, } static int recv_joinprune(struct vty *vty, - const char *argv[], + struct cmd_token **argv, int src_is_join) { uint8_t buf[1000]; @@ -4608,7 +4567,7 @@ static int recv_joinprune(struct vty *vty, uint16_t num_pruned; /* Find interface */ - ifname = argv[0]; + ifname = argv[0]->arg; ifp = if_lookup_by_name(ifname); if (!ifp) { vty_out(vty, "No such interface name %s%s", @@ -4616,10 +4575,10 @@ static int recv_joinprune(struct vty *vty, return CMD_WARNING; } - neigh_holdtime = atoi(argv[1]); + neigh_holdtime = atoi(argv[1]->arg); /* Neighbor destination address */ - neigh_dst_str = argv[2]; + neigh_dst_str = argv[2]->arg; result = inet_pton(AF_INET, neigh_dst_str, &neigh_dst_addr); if (result <= 0) { vty_out(vty, "Bad neighbor destination address %s: errno=%d: %s%s", @@ -4628,7 +4587,7 @@ static int recv_joinprune(struct vty *vty, } /* Neighbor source address */ - neigh_src_str = argv[3]; + neigh_src_str = argv[3]->arg; result = inet_pton(AF_INET, neigh_src_str, &neigh_src_addr); if (result <= 0) { vty_out(vty, "Bad neighbor source address %s: errno=%d: %s%s", @@ -4637,7 +4596,7 @@ static int recv_joinprune(struct vty *vty, } /* Multicast group address */ - group_str = argv[4]; + group_str = argv[4]->arg; result = inet_pton(AF_INET, group_str, &group_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -4646,7 +4605,7 @@ static int recv_joinprune(struct vty *vty, } /* Multicast source address */ - source_str = argv[5]; + source_str = argv[5]->arg; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -4767,7 +4726,7 @@ static int recv_joinprune(struct vty *vty, DEFUN (test_pim_receive_join, test_pim_receive_join_cmd, - "test pim receive join INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D", + "test pim receive join INTERFACE (0-65535) A.B.C.D A.B.C.D A.B.C.D A.B.C.D", "Test\n" "Test PIM protocol\n" "Test PIM message reception\n" @@ -4784,7 +4743,7 @@ DEFUN (test_pim_receive_join, DEFUN (test_pim_receive_prune, test_pim_receive_prune_cmd, - "test pim receive prune INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D", + "test pim receive prune INTERFACE (0-65535) A.B.C.D A.B.C.D A.B.C.D A.B.C.D", "Test\n" "Test PIM protocol\n" "Test PIM message reception\n" @@ -4801,7 +4760,7 @@ DEFUN (test_pim_receive_prune, DEFUN (test_pim_receive_upcall, test_pim_receive_upcall_cmd, - "test pim receive upcall (nocache|wrongvif|wholepkt) <0-65535> A.B.C.D A.B.C.D", + "test pim receive upcall <nocache|wrongvif|wholepkt> (0-65535) A.B.C.D A.B.C.D", "Test\n" "Test PIM protocol\n" "Test PIM message reception\n" @@ -4813,13 +4772,17 @@ DEFUN (test_pim_receive_upcall, "Multicast group address\n" "Multicast source address\n") { + int idx_type = 4; + int idx_number = 5; + int idx_ipv4 = 6; + int idx_ipv4_2 = 7; struct igmpmsg msg; const char *upcall_type; const char *group_str; const char *source_str; int result; - upcall_type = argv[0]; + upcall_type = argv[idx_type]->arg; if (upcall_type[0] == 'n') msg.im_msgtype = IGMPMSG_NOCACHE; @@ -4833,10 +4796,10 @@ DEFUN (test_pim_receive_upcall, return CMD_WARNING; } - msg.im_vif = atoi(argv[1]); + msg.im_vif = atoi(argv[idx_number]->arg); /* Group address */ - group_str = argv[2]; + group_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, group_str, &msg.im_dst); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -4845,7 +4808,7 @@ DEFUN (test_pim_receive_upcall, } /* Source address */ - source_str = argv[3]; + source_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, source_str, &msg.im_src); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -4901,7 +4864,6 @@ void pim_cmd_init() install_element (INTERFACE_NODE, &interface_ip_pim_drprio_cmd); install_element (INTERFACE_NODE, &interface_no_ip_pim_drprio_cmd); install_element (INTERFACE_NODE, &interface_ip_pim_hello_cmd); - install_element (INTERFACE_NODE, &interface_ip_pim_hello_hold_cmd); install_element (INTERFACE_NODE, &interface_no_ip_pim_hello_cmd); // Static mroutes NEB @@ -4960,81 +4922,59 @@ void pim_cmd_init() install_element (ENABLE_NODE, &debug_igmp_cmd); install_element (ENABLE_NODE, &no_debug_igmp_cmd); - install_element (ENABLE_NODE, &undebug_igmp_cmd); install_element (ENABLE_NODE, &debug_igmp_events_cmd); install_element (ENABLE_NODE, &no_debug_igmp_events_cmd); - install_element (ENABLE_NODE, &undebug_igmp_events_cmd); install_element (ENABLE_NODE, &debug_igmp_packets_cmd); install_element (ENABLE_NODE, &no_debug_igmp_packets_cmd); - install_element (ENABLE_NODE, &undebug_igmp_packets_cmd); install_element (ENABLE_NODE, &debug_igmp_trace_cmd); install_element (ENABLE_NODE, &no_debug_igmp_trace_cmd); - install_element (ENABLE_NODE, &undebug_igmp_trace_cmd); install_element (ENABLE_NODE, &debug_mroute_cmd); install_element (ENABLE_NODE, &no_debug_mroute_cmd); install_element (ENABLE_NODE, &debug_static_cmd); install_element (ENABLE_NODE, &no_debug_static_cmd); install_element (ENABLE_NODE, &debug_pim_cmd); install_element (ENABLE_NODE, &no_debug_pim_cmd); - install_element (ENABLE_NODE, &undebug_pim_cmd); install_element (ENABLE_NODE, &debug_pim_events_cmd); install_element (ENABLE_NODE, &no_debug_pim_events_cmd); - install_element (ENABLE_NODE, &undebug_pim_events_cmd); install_element (ENABLE_NODE, &debug_pim_packets_cmd); install_element (ENABLE_NODE, &debug_pim_packets_filter_cmd); install_element (ENABLE_NODE, &no_debug_pim_packets_cmd); install_element (ENABLE_NODE, &no_debug_pim_packets_filter_cmd); - install_element (ENABLE_NODE, &undebug_pim_packets_cmd); install_element (ENABLE_NODE, &debug_pim_packetdump_send_cmd); install_element (ENABLE_NODE, &no_debug_pim_packetdump_send_cmd); - install_element (ENABLE_NODE, &undebug_pim_packetdump_send_cmd); install_element (ENABLE_NODE, &debug_pim_packetdump_recv_cmd); install_element (ENABLE_NODE, &no_debug_pim_packetdump_recv_cmd); - install_element (ENABLE_NODE, &undebug_pim_packetdump_recv_cmd); install_element (ENABLE_NODE, &debug_pim_trace_cmd); install_element (ENABLE_NODE, &no_debug_pim_trace_cmd); - install_element (ENABLE_NODE, &undebug_pim_trace_cmd); install_element (ENABLE_NODE, &debug_ssmpingd_cmd); install_element (ENABLE_NODE, &no_debug_ssmpingd_cmd); - install_element (ENABLE_NODE, &undebug_ssmpingd_cmd); install_element (ENABLE_NODE, &debug_pim_zebra_cmd); install_element (ENABLE_NODE, &no_debug_pim_zebra_cmd); - install_element (ENABLE_NODE, &undebug_pim_zebra_cmd); install_element (CONFIG_NODE, &debug_igmp_cmd); install_element (CONFIG_NODE, &no_debug_igmp_cmd); - install_element (CONFIG_NODE, &undebug_igmp_cmd); install_element (CONFIG_NODE, &debug_igmp_events_cmd); install_element (CONFIG_NODE, &no_debug_igmp_events_cmd); - install_element (CONFIG_NODE, &undebug_igmp_events_cmd); install_element (CONFIG_NODE, &debug_igmp_packets_cmd); install_element (CONFIG_NODE, &no_debug_igmp_packets_cmd); - install_element (CONFIG_NODE, &undebug_igmp_packets_cmd); install_element (CONFIG_NODE, &debug_igmp_trace_cmd); install_element (CONFIG_NODE, &no_debug_igmp_trace_cmd); - install_element (CONFIG_NODE, &undebug_igmp_trace_cmd); install_element (CONFIG_NODE, &debug_mroute_cmd); install_element (CONFIG_NODE, &no_debug_mroute_cmd); install_element (CONFIG_NODE, &debug_static_cmd); install_element (CONFIG_NODE, &no_debug_static_cmd); install_element (CONFIG_NODE, &debug_pim_cmd); install_element (CONFIG_NODE, &no_debug_pim_cmd); - install_element (CONFIG_NODE, &undebug_pim_cmd); install_element (CONFIG_NODE, &debug_pim_events_cmd); install_element (CONFIG_NODE, &no_debug_pim_events_cmd); - install_element (CONFIG_NODE, &undebug_pim_events_cmd); install_element (CONFIG_NODE, &debug_pim_packets_cmd); install_element (CONFIG_NODE, &debug_pim_packets_filter_cmd); install_element (CONFIG_NODE, &no_debug_pim_packets_cmd); install_element (CONFIG_NODE, &no_debug_pim_packets_filter_cmd); - install_element (CONFIG_NODE, &undebug_pim_packets_cmd); install_element (CONFIG_NODE, &debug_pim_trace_cmd); install_element (CONFIG_NODE, &no_debug_pim_trace_cmd); - install_element (CONFIG_NODE, &undebug_pim_trace_cmd); install_element (CONFIG_NODE, &debug_ssmpingd_cmd); install_element (CONFIG_NODE, &no_debug_ssmpingd_cmd); - install_element (CONFIG_NODE, &undebug_ssmpingd_cmd); install_element (CONFIG_NODE, &debug_pim_zebra_cmd); install_element (CONFIG_NODE, &no_debug_pim_zebra_cmd); - install_element (CONFIG_NODE, &undebug_pim_zebra_cmd); } diff --git a/pimd/pim_cmd.h b/pimd/pim_cmd.h index 26191cd0b6..53df562ab9 100644 --- a/pimd/pim_cmd.h +++ b/pimd/pim_cmd.h @@ -60,12 +60,6 @@ #define MROUTE_STR "IP multicast routing table\n" #define RIB_STR "IP unicast routing table\n" -#define PIM_CMD_NO "no" -#define PIM_CMD_IP_MULTICAST_ROUTING "ip multicast-routing" -#define PIM_CMD_IP_IGMP_QUERY_INTERVAL "ip igmp query-interval" -#define PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME "ip igmp query-max-response-time" -#define PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC "ip igmp query-max-response-time-dsec" - void pim_cmd_init(void); #endif /* PIM_CMD_H */ diff --git a/pimd/pim_routemap.c b/pimd/pim_routemap.c index f65f35ba5e..a8525b690e 100644 --- a/pimd/pim_routemap.c +++ b/pimd/pim_routemap.c @@ -22,6 +22,7 @@ #include <zebra.h> #include "if.h" +#include "vty.h" #include "routemap.h" #include "pimd.h" diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c index f1c8930856..bc0f2c7e58 100644 --- a/pimd/pim_vty.c +++ b/pimd/pim_vty.c @@ -98,7 +98,7 @@ int pim_global_config_write(struct vty *vty) char buffer[32]; if (PIM_MROUTE_IS_ENABLED) { - vty_out(vty, "%s%s", PIM_CMD_IP_MULTICAST_ROUTING, VTY_NEWLINE); + vty_out(vty, "ip multicast-routing%s", VTY_NEWLINE); ++writes; } if (qpim_rp.rpf_addr.s_addr != INADDR_NONE) { @@ -170,8 +170,7 @@ int pim_interface_config_write(struct vty *vty) /* IF ip igmp query-interval */ if (pim_ifp->igmp_default_query_interval != IGMP_GENERAL_QUERY_INTERVAL) { - vty_out(vty, " %s %d%s", - PIM_CMD_IP_IGMP_QUERY_INTERVAL, + vty_out(vty, " ip igmp query-interval %d%s", pim_ifp->igmp_default_query_interval, VTY_NEWLINE); ++writes; @@ -180,8 +179,7 @@ int pim_interface_config_write(struct vty *vty) /* IF ip igmp query-max-response-time */ if (pim_ifp->igmp_query_max_response_time_dsec != IGMP_QUERY_MAX_RESPONSE_TIME_DSEC) { - vty_out(vty, " %s %d%s", - PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, + vty_out(vty, " ip igmp query-max-response-time-dsec %d%s", pim_ifp->igmp_query_max_response_time_dsec, VTY_NEWLINE); ++writes; diff --git a/ripd/rip_debug.c b/ripd/rip_debug.c index a267874ade..fbf2262b8c 100644 --- a/ripd/rip_debug.c +++ b/ripd/rip_debug.c @@ -90,37 +90,18 @@ DEFUN (debug_rip_packet, DEFUN (debug_rip_packet_direct, debug_rip_packet_direct_cmd, - "debug rip packet (recv|send)", + "debug rip packet <recv|send>", DEBUG_STR RIP_STR "RIP packet\n" "RIP receive packet\n" "RIP send packet\n") { + int idx_recv_send = 3; rip_debug_packet |= RIP_DEBUG_PACKET; - if (strncmp ("send", argv[0], strlen (argv[0])) == 0) + if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) rip_debug_packet |= RIP_DEBUG_SEND; - if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) - rip_debug_packet |= RIP_DEBUG_RECV; - return CMD_SUCCESS; -} - -/* N.B. the "detail" modifier is a no-op. we leave this command - for legacy compatibility. */ -DEFUN_DEPRECATED (debug_rip_packet_detail, - debug_rip_packet_detail_cmd, - "debug rip packet (recv|send) detail", - DEBUG_STR - RIP_STR - "RIP packet\n" - "RIP receive packet\n" - "RIP send packet\n" - "Detailed information display\n") -{ - rip_debug_packet |= RIP_DEBUG_PACKET; - if (strncmp ("send", argv[0], strlen (argv[0])) == 0) - rip_debug_packet |= RIP_DEBUG_SEND; - if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) + if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) rip_debug_packet |= RIP_DEBUG_RECV; return CMD_SUCCESS; } @@ -162,7 +143,7 @@ DEFUN (no_debug_rip_packet, DEFUN (no_debug_rip_packet_direct, no_debug_rip_packet_direct_cmd, - "no debug rip packet (recv|send)", + "no debug rip packet <recv|send>", NO_STR DEBUG_STR RIP_STR @@ -170,14 +151,15 @@ DEFUN (no_debug_rip_packet_direct, "RIP option set for receive packet\n" "RIP option set for send packet\n") { - if (strncmp ("send", argv[0], strlen (argv[0])) == 0) + int idx_recv_send = 4; + if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) { if (IS_RIP_DEBUG_RECV) rip_debug_packet &= ~RIP_DEBUG_SEND; else rip_debug_packet = 0; } - else if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) + else if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) { if (IS_RIP_DEBUG_SEND) rip_debug_packet &= ~RIP_DEBUG_RECV; @@ -265,7 +247,6 @@ rip_debug_init (void) install_element (ENABLE_NODE, &debug_rip_events_cmd); install_element (ENABLE_NODE, &debug_rip_packet_cmd); install_element (ENABLE_NODE, &debug_rip_packet_direct_cmd); - install_element (ENABLE_NODE, &debug_rip_packet_detail_cmd); install_element (ENABLE_NODE, &debug_rip_zebra_cmd); install_element (ENABLE_NODE, &no_debug_rip_events_cmd); install_element (ENABLE_NODE, &no_debug_rip_packet_cmd); @@ -275,7 +256,6 @@ rip_debug_init (void) install_element (CONFIG_NODE, &debug_rip_events_cmd); install_element (CONFIG_NODE, &debug_rip_packet_cmd); install_element (CONFIG_NODE, &debug_rip_packet_direct_cmd); - install_element (CONFIG_NODE, &debug_rip_packet_detail_cmd); install_element (CONFIG_NODE, &debug_rip_zebra_cmd); install_element (CONFIG_NODE, &no_debug_rip_events_cmd); install_element (CONFIG_NODE, &no_debug_rip_packet_cmd); diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index 359549ed80..8c5092d787 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -121,9 +121,9 @@ rip_interface_new (void) struct rip_interface *ri; ri = XCALLOC (MTYPE_RIP_INTERFACE, sizeof (struct rip_interface)); - + rip_interface_reset (ri); - + return ri; } @@ -497,17 +497,17 @@ rip_interface_delete (int command, struct zclient *zclient, static void rip_interface_clean (struct rip_interface *ri) -{ - ri->enable_network = 0; - ri->enable_interface = 0; - ri->running = 0; - - if (ri->t_wakeup) { - thread_cancel (ri->t_wakeup); - ri->t_wakeup = NULL; + ri->enable_network = 0; + ri->enable_interface = 0; + ri->running = 0; + + if (ri->t_wakeup) + { + thread_cancel (ri->t_wakeup); + ri->t_wakeup = NULL; + } } -} void rip_interfaces_clean (void) @@ -521,7 +521,7 @@ rip_interfaces_clean (void) static void rip_interface_reset (struct rip_interface *ri) -{ + { /* Default authentication type is simple password for Cisco compatibility. */ ri->auth_type = RIP_NO_AUTH; @@ -534,34 +534,34 @@ rip_interface_reset (struct rip_interface *ri) ri->split_horizon_default = RIP_SPLIT_HORIZON; ri->split_horizon = ri->split_horizon_default; - ri->ri_send = RI_RIP_UNSPEC; - ri->ri_receive = RI_RIP_UNSPEC; - - if (ri->auth_str) - { - free (ri->auth_str); - ri->auth_str = NULL; - } - if (ri->key_chain) - { - free (ri->key_chain); - ri->key_chain = NULL; - } + ri->ri_send = RI_RIP_UNSPEC; + ri->ri_receive = RI_RIP_UNSPEC; - ri->list[RIP_FILTER_IN] = NULL; - ri->list[RIP_FILTER_OUT] = NULL; + if (ri->auth_str) + { + free (ri->auth_str); + ri->auth_str = NULL; + } + if (ri->key_chain) + { + free (ri->key_chain); + ri->key_chain = NULL; + } - ri->prefix[RIP_FILTER_IN] = NULL; - ri->prefix[RIP_FILTER_OUT] = NULL; - - ri->recv_badpackets = 0; - ri->recv_badroutes = 0; - ri->sent_updates = 0; + ri->list[RIP_FILTER_IN] = NULL; + ri->list[RIP_FILTER_OUT] = NULL; - ri->passive = 0; + ri->prefix[RIP_FILTER_IN] = NULL; + ri->prefix[RIP_FILTER_OUT] = NULL; + + ri->recv_badpackets = 0; + ri->recv_badroutes = 0; + ri->sent_updates = 0; + + ri->passive = 0; rip_interface_clean (ri); -} + } void rip_interfaces_reset (void) @@ -1213,24 +1213,25 @@ rip_passive_nondefault_clean (void) /* RIP enable network or interface configuration. */ DEFUN (rip_network, rip_network_cmd, - "network (A.B.C.D/M|WORD)", + "network <A.B.C.D/M|WORD>", "Enable routing on an IP network\n" "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Interface name\n") { + int idx_ipv4_word = 1; int ret; struct prefix_ipv4 p; - ret = str2prefix_ipv4 (argv[0], &p); + ret = str2prefix_ipv4 (argv[idx_ipv4_word]->arg, &p); if (ret) ret = rip_enable_network_add ((struct prefix *) &p); else - ret = rip_enable_if_add (argv[0]); + ret = rip_enable_if_add (argv[idx_ipv4_word]->arg); if (ret < 0) { - vty_out (vty, "There is a same network configuration %s%s", argv[0], + vty_out (vty, "There is a same network configuration %s%s", argv[idx_ipv4_word]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -1241,25 +1242,26 @@ DEFUN (rip_network, /* RIP enable network or interface configuration. */ DEFUN (no_rip_network, no_rip_network_cmd, - "no network (A.B.C.D/M|WORD)", + "no network <A.B.C.D/M|WORD>", NO_STR "Enable routing on an IP network\n" "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Interface name\n") { + int idx_ipv4_word = 2; int ret; struct prefix_ipv4 p; - ret = str2prefix_ipv4 (argv[0], &p); + ret = str2prefix_ipv4 (argv[idx_ipv4_word]->arg, &p); if (ret) ret = rip_enable_network_delete ((struct prefix *) &p); else - ret = rip_enable_if_delete (argv[0]); + ret = rip_enable_if_delete (argv[idx_ipv4_word]->arg); if (ret < 0) { - vty_out (vty, "Can't find network configuration %s%s", argv[0], + vty_out (vty, "Can't find network configuration %s%s", argv[idx_ipv4_word]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -1274,10 +1276,11 @@ DEFUN (rip_neighbor, "Specify a neighbor router\n" "Neighbor address\n") { + int idx_ipv4 = 1; int ret; struct prefix_ipv4 p; - ret = str2prefix_ipv4 (argv[0], &p); + ret = str2prefix_ipv4 (argv[idx_ipv4]->arg, &p); if (ret <= 0) { @@ -1298,10 +1301,11 @@ DEFUN (no_rip_neighbor, "Specify a neighbor router\n" "Neighbor address\n") { + int idx_ipv4 = 2; int ret; struct prefix_ipv4 p; - ret = str2prefix_ipv4 (argv[0], &p); + ret = str2prefix_ipv4 (argv[idx_ipv4]->arg, &p); if (ret <= 0) { @@ -1316,7 +1320,7 @@ DEFUN (no_rip_neighbor, DEFUN (ip_rip_receive_version, ip_rip_receive_version_cmd, - "ip rip receive version (1|2)", + "ip rip receive version (1-2)", IP_STR "Routing Information Protocol\n" "Advertisement reception\n" @@ -1324,6 +1328,7 @@ DEFUN (ip_rip_receive_version, "RIP version 1\n" "RIP version 2\n") { + int idx_type = 4; struct interface *ifp; struct rip_interface *ri; @@ -1331,12 +1336,12 @@ DEFUN (ip_rip_receive_version, ri = ifp->info; /* Version 1. */ - if (atoi (argv[0]) == 1) + if (atoi (argv[idx_type]->arg) == 1) { ri->ri_receive = RI_RIP_VERSION_1; return CMD_SUCCESS; } - if (atoi (argv[0]) == 2) + if (atoi (argv[idx_type]->arg) == 2) { ri->ri_receive = RI_RIP_VERSION_2; return CMD_SUCCESS; @@ -1346,7 +1351,7 @@ DEFUN (ip_rip_receive_version, DEFUN (ip_rip_receive_version_1, ip_rip_receive_version_1_cmd, - "ip rip receive version 1 2", + "ip rip receive version (1-1) (2-2)", IP_STR "Routing Information Protocol\n" "Advertisement reception\n" @@ -1367,7 +1372,7 @@ DEFUN (ip_rip_receive_version_1, DEFUN (ip_rip_receive_version_2, ip_rip_receive_version_2_cmd, - "ip rip receive version 2 1", + "ip rip receive version (2-2) (1-1)", IP_STR "Routing Information Protocol\n" "Advertisement reception\n" @@ -1388,12 +1393,14 @@ DEFUN (ip_rip_receive_version_2, DEFUN (no_ip_rip_receive_version, no_ip_rip_receive_version_cmd, - "no ip rip receive version", + "no ip rip receive version [(1-2)]", NO_STR IP_STR "Routing Information Protocol\n" "Advertisement reception\n" - "Version control\n") + "Version control\n" + "Version 1\n" + "Version 2\n") { struct interface *ifp; struct rip_interface *ri; @@ -1405,20 +1412,10 @@ DEFUN (no_ip_rip_receive_version, return CMD_SUCCESS; } -ALIAS (no_ip_rip_receive_version, - no_ip_rip_receive_version_num_cmd, - "no ip rip receive version (1|2)", - NO_STR - IP_STR - "Routing Information Protocol\n" - "Advertisement reception\n" - "Version control\n" - "Version 1\n" - "Version 2\n") DEFUN (ip_rip_send_version, ip_rip_send_version_cmd, - "ip rip send version (1|2)", + "ip rip send version (1-2)", IP_STR "Routing Information Protocol\n" "Advertisement transmission\n" @@ -1426,6 +1423,7 @@ DEFUN (ip_rip_send_version, "RIP version 1\n" "RIP version 2\n") { + int idx_type = 4; struct interface *ifp; struct rip_interface *ri; @@ -1433,12 +1431,12 @@ DEFUN (ip_rip_send_version, ri = ifp->info; /* Version 1. */ - if (atoi (argv[0]) == 1) + if (atoi (argv[idx_type]->arg) == 1) { ri->ri_send = RI_RIP_VERSION_1; return CMD_SUCCESS; } - if (atoi (argv[0]) == 2) + if (atoi (argv[idx_type]->arg) == 2) { ri->ri_send = RI_RIP_VERSION_2; return CMD_SUCCESS; @@ -1448,7 +1446,7 @@ DEFUN (ip_rip_send_version, DEFUN (ip_rip_send_version_1, ip_rip_send_version_1_cmd, - "ip rip send version 1 2", + "ip rip send version (1-1) (2-2)", IP_STR "Routing Information Protocol\n" "Advertisement transmission\n" @@ -1469,7 +1467,7 @@ DEFUN (ip_rip_send_version_1, DEFUN (ip_rip_send_version_2, ip_rip_send_version_2_cmd, - "ip rip send version 2 1", + "ip rip send version (2-2) (1-1)", IP_STR "Routing Information Protocol\n" "Advertisement transmission\n" @@ -1490,12 +1488,14 @@ DEFUN (ip_rip_send_version_2, DEFUN (no_ip_rip_send_version, no_ip_rip_send_version_cmd, - "no ip rip send version", + "no ip rip send version [(1-2)]", NO_STR IP_STR "Routing Information Protocol\n" "Advertisement transmission\n" - "Version control\n") + "Version control\n" + "Version 1\n" + "Version 2\n") { struct interface *ifp; struct rip_interface *ri; @@ -1507,27 +1507,22 @@ DEFUN (no_ip_rip_send_version, return CMD_SUCCESS; } -ALIAS (no_ip_rip_send_version, - no_ip_rip_send_version_num_cmd, - "no ip rip send version (1|2)", - NO_STR - IP_STR - "Routing Information Protocol\n" - "Advertisement transmission\n" - "Version control\n" - "Version 1\n" - "Version 2\n") DEFUN (ip_rip_authentication_mode, ip_rip_authentication_mode_cmd, - "ip rip authentication mode (md5|text)", + "ip rip authentication mode <md5|text> [auth-length <rfc|old-ripd>]", IP_STR "Routing Information Protocol\n" "Authentication control\n" "Authentication mode\n" "Keyed message digest\n" - "Clear text authentication\n") + "Clear text authentication\n" + "MD5 authentication data length\n" + "RFC compatible\n" + "Old ripd compatible\n") { + char *cryptmode = argv[4]->text; + char *authlen = (argc > 5) ? argv[6]->text : NULL; struct interface *ifp; struct rip_interface *ri; int auth_type; @@ -1535,49 +1530,38 @@ DEFUN (ip_rip_authentication_mode, ifp = (struct interface *)vty->index; ri = ifp->info; - if ( (argc < 1) || (argc > 2) ) - { - vty_out (vty, "incorrect argument count%s", VTY_NEWLINE); - return CMD_WARNING; - } - - if (strncmp ("md5", argv[0], strlen (argv[0])) == 0) + if (strmatch ("md5", cryptmode)) auth_type = RIP_AUTH_MD5; - else if (strncmp ("text", argv[0], strlen (argv[0])) == 0) + else { + assert (strmatch ("text", cryptmode)); auth_type = RIP_AUTH_SIMPLE_PASSWORD; - else - { - vty_out (vty, "mode should be md5 or text%s", VTY_NEWLINE); - return CMD_WARNING; - } + } - if (argc == 1) - { - ri->auth_type = auth_type; - return CMD_SUCCESS; - } + ri->auth_type = auth_type; - if ( (argc == 2) && (auth_type != RIP_AUTH_MD5) ) + if (argc > 5) + { + if (auth_type != RIP_AUTH_MD5) { vty_out (vty, "auth length argument only valid for md5%s", VTY_NEWLINE); return CMD_WARNING; } + if (strmatch ("rfc", authlen)) + ri->md5_auth_len = RIP_AUTH_MD5_SIZE; + else + { + assert (strmatch ("old-ripd", authlen)); + ri->md5_auth_len = RIP_AUTH_MD5_COMPAT_SIZE; + } + } - if (strncmp ("r", argv[1], 1) == 0) - ri->md5_auth_len = RIP_AUTH_MD5_SIZE; - else if (strncmp ("o", argv[1], 1) == 0) - ri->md5_auth_len = RIP_AUTH_MD5_COMPAT_SIZE; - else - return CMD_WARNING; - - ri->auth_type = auth_type; - return CMD_SUCCESS; } -ALIAS (ip_rip_authentication_mode, - ip_rip_authentication_mode_authlen_cmd, - "ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)", +DEFUN (no_ip_rip_authentication_mode, + no_ip_rip_authentication_mode_cmd, + "no ip rip authentication mode [<md5|text> [auth-length <rfc|old-ripd>]]", + NO_STR IP_STR "Routing Information Protocol\n" "Authentication control\n" @@ -1587,15 +1571,6 @@ ALIAS (ip_rip_authentication_mode, "MD5 authentication data length\n" "RFC compatible\n" "Old ripd compatible\n") - -DEFUN (no_ip_rip_authentication_mode, - no_ip_rip_authentication_mode_cmd, - "no ip rip authentication mode", - NO_STR - IP_STR - "Routing Information Protocol\n" - "Authentication control\n" - "Authentication mode\n") { struct interface *ifp; struct rip_interface *ri; @@ -1609,31 +1584,6 @@ DEFUN (no_ip_rip_authentication_mode, return CMD_SUCCESS; } -ALIAS (no_ip_rip_authentication_mode, - no_ip_rip_authentication_mode_type_cmd, - "no ip rip authentication mode (md5|text)", - NO_STR - IP_STR - "Routing Information Protocol\n" - "Authentication control\n" - "Authentication mode\n" - "Keyed message digest\n" - "Clear text authentication\n") - -ALIAS (no_ip_rip_authentication_mode, - no_ip_rip_authentication_mode_type_authlen_cmd, - "no ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)", - NO_STR - IP_STR - "Routing Information Protocol\n" - "Authentication control\n" - "Authentication mode\n" - "Keyed message digest\n" - "Clear text authentication\n" - "MD5 authentication data length\n" - "RFC compatible\n" - "Old ripd compatible\n") - DEFUN (ip_rip_authentication_string, ip_rip_authentication_string_cmd, "ip rip authentication string LINE", @@ -1643,13 +1593,14 @@ DEFUN (ip_rip_authentication_string, "Authentication string\n" "Authentication string\n") { + int idx_line = 4; struct interface *ifp; struct rip_interface *ri; ifp = (struct interface *)vty->index; ri = ifp->info; - if (strlen (argv[0]) > 16) + if (strlen (argv[idx_line]->arg) > 16) { vty_out (vty, "%% RIPv2 authentication string must be shorter than 16%s", VTY_NEWLINE); @@ -1665,18 +1616,19 @@ DEFUN (ip_rip_authentication_string, if (ri->auth_str) free (ri->auth_str); - ri->auth_str = strdup (argv[0]); + ri->auth_str = strdup (argv[idx_line]->arg); return CMD_SUCCESS; } DEFUN (no_ip_rip_authentication_string, no_ip_rip_authentication_string_cmd, - "no ip rip authentication string", + "no ip rip authentication string [LINE]", NO_STR IP_STR "Routing Information Protocol\n" "Authentication control\n" + "Authentication string\n" "Authentication string\n") { struct interface *ifp; @@ -1693,15 +1645,6 @@ DEFUN (no_ip_rip_authentication_string, return CMD_SUCCESS; } -ALIAS (no_ip_rip_authentication_string, - no_ip_rip_authentication_string2_cmd, - "no ip rip authentication string LINE", - NO_STR - IP_STR - "Routing Information Protocol\n" - "Authentication control\n" - "Authentication string\n" - "Authentication string\n") DEFUN (ip_rip_authentication_key_chain, ip_rip_authentication_key_chain_cmd, @@ -1712,6 +1655,7 @@ DEFUN (ip_rip_authentication_key_chain, "Authentication key-chain\n" "name of key-chain\n") { + int idx_line = 4; struct interface *ifp; struct rip_interface *ri; @@ -1728,19 +1672,20 @@ DEFUN (ip_rip_authentication_key_chain, if (ri->key_chain) free (ri->key_chain); - ri->key_chain = strdup (argv[0]); + ri->key_chain = strdup (argv[idx_line]->arg); return CMD_SUCCESS; } DEFUN (no_ip_rip_authentication_key_chain, no_ip_rip_authentication_key_chain_cmd, - "no ip rip authentication key-chain", + "no ip rip authentication key-chain [LINE]", NO_STR IP_STR "Routing Information Protocol\n" "Authentication control\n" - "Authentication key-chain\n") + "Authentication key-chain\n" + "name of key-chain\n") { struct interface *ifp; struct rip_interface *ri; @@ -1756,15 +1701,6 @@ DEFUN (no_ip_rip_authentication_key_chain, return CMD_SUCCESS; } -ALIAS (no_ip_rip_authentication_key_chain, - no_ip_rip_authentication_key_chain2_cmd, - "no ip rip authentication key-chain LINE", - NO_STR - IP_STR - "Routing Information Protocol\n" - "Authentication control\n" - "Authentication key-chain\n" - "name of key-chain\n") /* CHANGED: ip rip split-horizon Cisco and Zebra's command is @@ -1844,10 +1780,10 @@ DEFUN (no_ip_rip_split_horizon_poisoned_reverse, switch( ri->split_horizon ) { - case RIP_SPLIT_HORIZON_POISONED_REVERSE: - ri->split_horizon = RIP_SPLIT_HORIZON; - default: - break; + case RIP_SPLIT_HORIZON_POISONED_REVERSE: + ri->split_horizon = RIP_SPLIT_HORIZON; + default: + break; } return CMD_SUCCESS; @@ -1855,43 +1791,39 @@ DEFUN (no_ip_rip_split_horizon_poisoned_reverse, DEFUN (rip_passive_interface, rip_passive_interface_cmd, - "passive-interface (IFNAME|default)", + "passive-interface <IFNAME|default>", "Suppress routing updates on an interface\n" "Interface name\n" "default for all interfaces\n") { - const char *ifname = argv[0]; - - if (!strcmp(ifname,"default")) { + if (argv[1]->type == WORD_TKN) { // user passed 'default' passive_default = 1; rip_passive_nondefault_clean(); return CMD_SUCCESS; } if (passive_default) - return rip_passive_nondefault_unset (vty, ifname); + return rip_passive_nondefault_unset (vty, argv[1]->arg); else - return rip_passive_nondefault_set (vty, ifname); + return rip_passive_nondefault_set (vty, argv[1]->arg); } DEFUN (no_rip_passive_interface, no_rip_passive_interface_cmd, - "no passive-interface (IFNAME|default)", + "no passive-interface <IFNAME|default>", NO_STR "Suppress routing updates on an interface\n" "Interface name\n" "default for all interfaces\n") { - const char *ifname = argv[0]; - - if (!strcmp(ifname,"default")) { + if (argv[2]->type == WORD_TKN) { passive_default = 0; rip_passive_nondefault_clean(); return CMD_SUCCESS; } if (passive_default) - return rip_passive_nondefault_set (vty, ifname); + return rip_passive_nondefault_set (vty, argv[2]->arg); else - return rip_passive_nondefault_unset (vty, ifname); + return rip_passive_nondefault_unset (vty, argv[2]->arg); } /* Write rip configuration of each interface. */ @@ -2091,27 +2023,20 @@ rip_if_init (void) install_element (INTERFACE_NODE, &ip_rip_send_version_1_cmd); install_element (INTERFACE_NODE, &ip_rip_send_version_2_cmd); install_element (INTERFACE_NODE, &no_ip_rip_send_version_cmd); - install_element (INTERFACE_NODE, &no_ip_rip_send_version_num_cmd); install_element (INTERFACE_NODE, &ip_rip_receive_version_cmd); install_element (INTERFACE_NODE, &ip_rip_receive_version_1_cmd); install_element (INTERFACE_NODE, &ip_rip_receive_version_2_cmd); install_element (INTERFACE_NODE, &no_ip_rip_receive_version_cmd); - install_element (INTERFACE_NODE, &no_ip_rip_receive_version_num_cmd); install_element (INTERFACE_NODE, &ip_rip_authentication_mode_cmd); - install_element (INTERFACE_NODE, &ip_rip_authentication_mode_authlen_cmd); install_element (INTERFACE_NODE, &no_ip_rip_authentication_mode_cmd); - install_element (INTERFACE_NODE, &no_ip_rip_authentication_mode_type_cmd); - install_element (INTERFACE_NODE, &no_ip_rip_authentication_mode_type_authlen_cmd); install_element (INTERFACE_NODE, &ip_rip_authentication_key_chain_cmd); install_element (INTERFACE_NODE, &no_ip_rip_authentication_key_chain_cmd); - install_element (INTERFACE_NODE, &no_ip_rip_authentication_key_chain2_cmd); install_element (INTERFACE_NODE, &ip_rip_authentication_string_cmd); install_element (INTERFACE_NODE, &no_ip_rip_authentication_string_cmd); - install_element (INTERFACE_NODE, &no_ip_rip_authentication_string2_cmd); install_element (INTERFACE_NODE, &ip_rip_split_horizon_cmd); install_element (INTERFACE_NODE, &ip_rip_split_horizon_poisoned_reverse_cmd); diff --git a/ripd/rip_offset.c b/ripd/rip_offset.c index 0155f90ef0..5e0e71579a 100644 --- a/ripd/rip_offset.c +++ b/ripd/rip_offset.c @@ -282,19 +282,22 @@ rip_offset_list_apply_out (struct prefix_ipv4 *p, struct interface *ifp, DEFUN (rip_offset_list, rip_offset_list_cmd, - "offset-list WORD (in|out) <0-16>", + "offset-list WORD <in|out> (0-16)", "Modify RIP metric\n" "Access-list name\n" "For incoming updates\n" "For outgoing updates\n" "Metric value\n") { - return rip_offset_list_set (vty, argv[0], argv[1], argv[2], NULL); + int idx_word = 1; + int idx_in_out = 2; + int idx_number = 3; + return rip_offset_list_set (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, NULL); } DEFUN (rip_offset_list_ifname, rip_offset_list_ifname_cmd, - "offset-list WORD (in|out) <0-16> IFNAME", + "offset-list WORD <in|out> (0-16) IFNAME", "Modify RIP metric\n" "Access-list name\n" "For incoming updates\n" @@ -302,12 +305,16 @@ DEFUN (rip_offset_list_ifname, "Metric value\n" "Interface to match\n") { - return rip_offset_list_set (vty, argv[0], argv[1], argv[2], argv[3]); + int idx_word = 1; + int idx_in_out = 2; + int idx_number = 3; + int idx_ifname = 4; + return rip_offset_list_set (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, argv[idx_ifname]->arg); } DEFUN (no_rip_offset_list, no_rip_offset_list_cmd, - "no offset-list WORD (in|out) <0-16>", + "no offset-list WORD <in|out> (0-16)", NO_STR "Modify RIP metric\n" "Access-list name\n" @@ -315,12 +322,15 @@ DEFUN (no_rip_offset_list, "For outgoing updates\n" "Metric value\n") { - return rip_offset_list_unset (vty, argv[0], argv[1], argv[2], NULL); + int idx_word = 2; + int idx_in_out = 3; + int idx_number = 4; + return rip_offset_list_unset (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, NULL); } DEFUN (no_rip_offset_list_ifname, no_rip_offset_list_ifname_cmd, - "no offset-list WORD (in|out) <0-16> IFNAME", + "no offset-list WORD <in|out> (0-16) IFNAME", NO_STR "Modify RIP metric\n" "Access-list name\n" @@ -329,7 +339,11 @@ DEFUN (no_rip_offset_list_ifname, "Metric value\n" "Interface to match\n") { - return rip_offset_list_unset (vty, argv[0], argv[1], argv[2], argv[3]); + int idx_word = 2; + int idx_in_out = 3; + int idx_number = 4; + int idx_ifname = 5; + return rip_offset_list_unset (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, argv[idx_ifname]->arg); } static int diff --git a/ripd/rip_routemap.c b/ripd/rip_routemap.c index 8b48adfd55..6fd647596c 100644 --- a/ripd/rip_routemap.c +++ b/ripd/rip_routemap.c @@ -24,6 +24,7 @@ #include "memory.h" #include "prefix.h" +#include "vty.h" #include "routemap.h" #include "command.h" #include "filter.h" @@ -45,104 +46,6 @@ struct rip_metric_modifier u_char metric; }; -/* Add rip route map rule. */ -static int -rip_route_match_add (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_add_match (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% RIP Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% RIP Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - -/* Delete rip route map rule. */ -static int -rip_route_match_delete (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_delete_match (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% RIP Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% RIP Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - -/* Add rip route map rule. */ -static int -rip_route_set_add (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_add_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% RIP Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - /* rip, ripng and other protocols share the set metric command - but only values from 0 to 16 are valid for rip and ripng - if metric is out of range for rip and ripng, it is not for - other protocols. Do not return an error */ - if (strcmp(command, "metric")) { - vty_out (vty, "%% RIP Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - } - return CMD_SUCCESS; -} - -/* Delete rip route map rule. */ -static int -rip_route_set_delete (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_delete_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% RIP Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% RIP Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - /* Hook function for updating route_map assignment. */ /* ARGSUSED */ static void @@ -685,394 +588,50 @@ static struct route_map_rule_cmd route_set_tag_cmd = #define MATCH_STR "Match values from routing table\n" #define SET_STR "Set values in destination routing protocol\n" -DEFUN (match_metric, - match_metric_cmd, - "match metric <0-4294967295>", - MATCH_STR - "Match metric of route\n" - "Metric value\n") -{ - return rip_route_match_add (vty, vty->index, "metric", argv[0]); -} - -DEFUN (no_match_metric, - no_match_metric_cmd, - "no match metric", - NO_STR - MATCH_STR - "Match metric of route\n") -{ - if (argc == 0) - return rip_route_match_delete (vty, vty->index, "metric", NULL); - - return rip_route_match_delete (vty, vty->index, "metric", argv[0]); -} - -ALIAS (no_match_metric, - no_match_metric_val_cmd, - "no match metric <0-4294967295>", - NO_STR - MATCH_STR - "Match metric of route\n" - "Metric value\n") - -DEFUN (match_interface, - match_interface_cmd, - "match interface WORD", - MATCH_STR - "Match first hop interface of route\n" - "Interface name\n") -{ - return rip_route_match_add (vty, vty->index, "interface", argv[0]); -} - -DEFUN (no_match_interface, - no_match_interface_cmd, - "no match interface", - NO_STR - MATCH_STR - "Match first hop interface of route\n") -{ - if (argc == 0) - return rip_route_match_delete (vty, vty->index, "interface", NULL); - - return rip_route_match_delete (vty, vty->index, "interface", argv[0]); -} - -ALIAS (no_match_interface, - no_match_interface_val_cmd, - "no match interface WORD", - NO_STR - MATCH_STR - "Match first hop interface of route\n" - "Interface name\n") - -DEFUN (match_ip_next_hop, - match_ip_next_hop_cmd, - "match ip next-hop (<1-199>|<1300-2699>|WORD)", - MATCH_STR - IP_STR - "Match next-hop address of route\n" - "IP access-list number\n" - "IP access-list number (expanded range)\n" - "IP Access-list name\n") -{ - return rip_route_match_add (vty, vty->index, "ip next-hop", argv[0]); -} - -DEFUN (no_match_ip_next_hop, - no_match_ip_next_hop_cmd, - "no match ip next-hop", - NO_STR - MATCH_STR - IP_STR - "Match next-hop address of route\n") -{ - if (argc == 0) - return rip_route_match_delete (vty, vty->index, "ip next-hop", NULL); - - return rip_route_match_delete (vty, vty->index, "ip next-hop", argv[0]); -} - -ALIAS (no_match_ip_next_hop, - no_match_ip_next_hop_val_cmd, - "no match ip next-hop (<1-199>|<1300-2699>|WORD)", - NO_STR - MATCH_STR - IP_STR - "Match next-hop address of route\n" - "IP access-list number\n" - "IP access-list number (expanded range)\n" - "IP Access-list name\n") - -DEFUN (match_ip_next_hop_prefix_list, - match_ip_next_hop_prefix_list_cmd, - "match ip next-hop prefix-list WORD", - MATCH_STR - IP_STR - "Match next-hop address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") -{ - return rip_route_match_add (vty, vty->index, "ip next-hop prefix-list", argv[0]); -} - -DEFUN (no_match_ip_next_hop_prefix_list, - no_match_ip_next_hop_prefix_list_cmd, - "no match ip next-hop prefix-list", - NO_STR - MATCH_STR - IP_STR - "Match next-hop address of route\n" - "Match entries of prefix-lists\n") -{ - if (argc == 0) - return rip_route_match_delete (vty, vty->index, "ip next-hop prefix-list", NULL); - - return rip_route_match_delete (vty, vty->index, "ip next-hop prefix-list", argv[0]); -} - -ALIAS (no_match_ip_next_hop_prefix_list, - no_match_ip_next_hop_prefix_list_val_cmd, - "no match ip next-hop prefix-list WORD", - NO_STR - MATCH_STR - IP_STR - "Match next-hop address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") - -DEFUN (match_ip_address, - match_ip_address_cmd, - "match ip address (<1-199>|<1300-2699>|WORD)", - MATCH_STR - IP_STR - "Match address of route\n" - "IP access-list number\n" - "IP access-list number (expanded range)\n" - "IP Access-list name\n") - -{ - return rip_route_match_add (vty, vty->index, "ip address", argv[0]); -} - -DEFUN (no_match_ip_address, - no_match_ip_address_cmd, - "no match ip address", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n") -{ - if (argc == 0) - return rip_route_match_delete (vty, vty->index, "ip address", NULL); - - return rip_route_match_delete (vty, vty->index, "ip address", argv[0]); -} - -ALIAS (no_match_ip_address, - no_match_ip_address_val_cmd, - "no match ip address (<1-199>|<1300-2699>|WORD)", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n" - "IP access-list number\n" - "IP access-list number (expanded range)\n" - "IP Access-list name\n") - -DEFUN (match_ip_address_prefix_list, - match_ip_address_prefix_list_cmd, - "match ip address prefix-list WORD", - MATCH_STR - IP_STR - "Match address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") -{ - return rip_route_match_add (vty, vty->index, "ip address prefix-list", argv[0]); -} - -DEFUN (no_match_ip_address_prefix_list, - no_match_ip_address_prefix_list_cmd, - "no match ip address prefix-list", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n" - "Match entries of prefix-lists\n") -{ - if (argc == 0) - return rip_route_match_delete (vty, vty->index, "ip address prefix-list", NULL); - - return rip_route_match_delete (vty, vty->index, "ip address prefix-list", argv[0]); -} - -ALIAS (no_match_ip_address_prefix_list, - no_match_ip_address_prefix_list_val_cmd, - "no match ip address prefix-list WORD", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") - -DEFUN (match_tag, - match_tag_cmd, - "match tag <1-4294967295>", - MATCH_STR - "Match tag of route\n" - "Metric value\n") -{ - return rip_route_match_add (vty, vty->index, "tag", argv[0]); -} - -DEFUN (no_match_tag, - no_match_tag_cmd, - "no match tag", - NO_STR - MATCH_STR - "Match tag of route\n") -{ - if (argc == 0) - return rip_route_match_delete (vty, vty->index, "tag", NULL); - - return rip_route_match_delete (vty, vty->index, "tag", argv[0]); -} - -ALIAS (no_match_tag, - no_match_tag_val_cmd, - "no match tag <1-4294967295>", - NO_STR - MATCH_STR - "Match tag of route\n" - "Metric value\n") - -/* set functions */ - -DEFUN (set_metric, - set_metric_cmd, - "set metric <0-4294967295>", - SET_STR - "Metric value for destination routing protocol\n" - "Metric value\n") +void +rip_route_map_reset () { - return rip_route_set_add (vty, vty->index, "metric", argv[0]); + ; } -ALIAS (set_metric, - set_metric_addsub_cmd, - "set metric <+/-metric>", - SET_STR - "Metric value for destination routing protocol\n" - "Add or subtract metric\n") - -DEFUN (no_set_metric, - no_set_metric_cmd, - "no set metric", - NO_STR - SET_STR - "Metric value for destination routing protocol\n") +/* Route-map init */ +void +rip_route_map_init () { - if (argc == 0) - return rip_route_set_delete (vty, vty->index, "metric", NULL); + route_map_init (); - return rip_route_set_delete (vty, vty->index, "metric", argv[0]); -} + route_map_add_hook (rip_route_map_update); + route_map_delete_hook (rip_route_map_update); -ALIAS (no_set_metric, - no_set_metric_val_cmd, - "no set metric <0-4294967295>", - NO_STR - SET_STR - "Metric value for destination routing protocol\n" - "Metric value\n") - -ALIAS (no_set_metric, - no_set_metric_addsub_cmd, - "no set metric <+/-metric>", - NO_STR - SET_STR - "Metric value for destination routing protocol\n" - "Add or subtract metric\n") - -DEFUN (set_ip_nexthop, - set_ip_nexthop_cmd, - "set ip next-hop A.B.C.D", - SET_STR - IP_STR - "Next hop address\n" - "IP address of next hop\n") -{ - union sockunion su; - int ret; + route_map_match_interface_hook (generic_match_add); + route_map_no_match_interface_hook (generic_match_delete); - ret = str2sockunion (argv[0], &su); - if (ret < 0) - { - vty_out (vty, "%% Malformed next-hop address%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (su.sin.sin_addr.s_addr == 0 || - IPV4_CLASS_DE(su.sin.sin_addr.s_addr)) - { - vty_out (vty, "%% nexthop address cannot be 0.0.0.0, multicast " - "or reserved%s", VTY_NEWLINE); - return CMD_WARNING; - } + route_map_match_ip_address_hook (generic_match_add); + route_map_no_match_ip_address_hook (generic_match_delete); - return rip_route_set_add (vty, vty->index, "ip next-hop", argv[0]); -} + route_map_match_ip_address_prefix_list_hook (generic_match_add); + route_map_no_match_ip_address_prefix_list_hook (generic_match_delete); -DEFUN (no_set_ip_nexthop, - no_set_ip_nexthop_cmd, - "no set ip next-hop", - NO_STR - SET_STR - IP_STR - "Next hop address\n") -{ - if (argc == 0) - return rip_route_set_delete (vty, vty->index, "ip next-hop", NULL); - - return rip_route_set_delete (vty, vty->index, "ip next-hop", argv[0]); -} + route_map_match_ip_next_hop_hook (generic_match_add); + route_map_no_match_ip_next_hop_hook (generic_match_delete); -ALIAS (no_set_ip_nexthop, - no_set_ip_nexthop_val_cmd, - "no set ip next-hop A.B.C.D", - NO_STR - SET_STR - IP_STR - "Next hop address\n" - "IP address of next hop\n") - -DEFUN (set_tag, - set_tag_cmd, - "set tag <1-4294967295>", - SET_STR - "Tag value for routing protocol\n" - "Tag value\n") -{ - return rip_route_set_add (vty, vty->index, "tag", argv[0]); -} + route_map_match_ip_next_hop_prefix_list_hook (generic_match_add); + route_map_no_match_ip_next_hop_prefix_list_hook (generic_match_delete); -DEFUN (no_set_tag, - no_set_tag_cmd, - "no set tag", - NO_STR - SET_STR - "Tag value for routing protocol\n") -{ - if (argc == 0) - return rip_route_set_delete (vty, vty->index, "tag", NULL); - - return rip_route_set_delete (vty, vty->index, "tag", argv[0]); -} + route_map_match_metric_hook (generic_match_add); + route_map_no_match_metric_hook (generic_match_delete); -ALIAS (no_set_tag, - no_set_tag_val_cmd, - "no set tag <1-4294967295>", - NO_STR - SET_STR - "Tag value for routing protocol\n" - "Tag value\n") + route_map_match_tag_hook (generic_match_add); + route_map_no_match_tag_hook (generic_match_delete); -void -rip_route_map_reset () -{ - ; -} + route_map_set_ip_nexthop_hook (generic_set_add); + route_map_no_set_ip_nexthop_hook (generic_set_delete); -/* Route-map init */ -void -rip_route_map_init () -{ - route_map_init (); + route_map_set_metric_hook (generic_set_add); + route_map_no_set_metric_hook (generic_set_delete); - route_map_add_hook (rip_route_map_update); - route_map_delete_hook (rip_route_map_update); + route_map_set_tag_hook (generic_set_add); + route_map_no_set_tag_hook (generic_set_delete); route_map_install_match (&route_match_metric_cmd); route_map_install_match (&route_match_interface_cmd); @@ -1085,38 +644,4 @@ rip_route_map_init () route_map_install_set (&route_set_metric_cmd); route_map_install_set (&route_set_ip_nexthop_cmd); route_map_install_set (&route_set_tag_cmd); - - install_element (RMAP_NODE, &match_metric_cmd); - install_element (RMAP_NODE, &no_match_metric_cmd); - install_element (RMAP_NODE, &no_match_metric_val_cmd); - install_element (RMAP_NODE, &match_interface_cmd); - install_element (RMAP_NODE, &no_match_interface_cmd); - install_element (RMAP_NODE, &no_match_interface_val_cmd); - install_element (RMAP_NODE, &match_ip_next_hop_cmd); - install_element (RMAP_NODE, &no_match_ip_next_hop_cmd); - install_element (RMAP_NODE, &no_match_ip_next_hop_val_cmd); - install_element (RMAP_NODE, &match_ip_next_hop_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_val_cmd); - install_element (RMAP_NODE, &match_ip_address_cmd); - install_element (RMAP_NODE, &no_match_ip_address_cmd); - install_element (RMAP_NODE, &no_match_ip_address_val_cmd); - install_element (RMAP_NODE, &match_ip_address_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ip_address_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ip_address_prefix_list_val_cmd); - install_element (RMAP_NODE, &match_tag_cmd); - install_element (RMAP_NODE, &no_match_tag_cmd); - install_element (RMAP_NODE, &no_match_tag_val_cmd); - - install_element (RMAP_NODE, &set_metric_cmd); - install_element (RMAP_NODE, &set_metric_addsub_cmd); - install_element (RMAP_NODE, &no_set_metric_cmd); - install_element (RMAP_NODE, &no_set_metric_val_cmd); - install_element (RMAP_NODE, &no_set_metric_addsub_cmd); - install_element (RMAP_NODE, &set_ip_nexthop_cmd); - install_element (RMAP_NODE, &no_set_ip_nexthop_cmd); - install_element (RMAP_NODE, &no_set_ip_nexthop_val_cmd); - install_element (RMAP_NODE, &set_tag_cmd); - install_element (RMAP_NODE, &no_set_tag_cmd); - install_element (RMAP_NODE, &no_set_tag_val_cmd); } diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c index 3f7c7a3e4d..5aea4f5222 100644 --- a/ripd/rip_zebra.c +++ b/ripd/rip_zebra.c @@ -263,46 +263,6 @@ static struct { {0, 0, NULL} }; -DEFUN (router_zebra, - router_zebra_cmd, - "router zebra", - "Enable a routing process\n" - "Make connection to zebra daemon\n") -{ - vty->node = ZEBRA_NODE; - zclient->enable = 1; - zclient_start (zclient); - return CMD_SUCCESS; -} - -DEFUN (no_router_zebra, - no_router_zebra_cmd, - "no router zebra", - NO_STR - "Enable a routing process\n" - "Make connection to zebra daemon\n") -{ - zclient->enable = 0; - zclient_stop (zclient); - return CMD_SUCCESS; -} - -#if 0 -static int -rip_redistribute_set (int type) -{ - if (vrf_bitmap_check (zclient->redist[AFI_IP][type], VRF_DEFAULT)) - return CMD_SUCCESS; - - vrf_bitmap_set (zclient->redist[AFI_IP][type], VRF_DEFAULT); - - if (zclient->sock > 0) - zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, API_IP, type); - - return CMD_SUCCESS; -} -#endif - static int rip_redistribute_unset (int type) { @@ -371,7 +331,7 @@ DEFUN (no_rip_redistribute_rip, DEFUN (rip_redistribute_type, rip_redistribute_type_cmd, - "redistribute " QUAGGA_REDIST_STR_RIPD, + "redistribute <kernel|connected|static|ospf|isis|bgp|pim|table>", REDIST_STR QUAGGA_REDIST_HELP_STR_RIPD) { @@ -379,7 +339,7 @@ DEFUN (rip_redistribute_type, for(i = 0; redist_type[i].str; i++) { - if (strncmp (redist_type[i].str, argv[0], + if (strncmp (redist_type[i].str, argv[2]->arg, redist_type[i].str_min_len) == 0) { zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, @@ -388,7 +348,7 @@ DEFUN (rip_redistribute_type, } } - vty_out(vty, "Invalid type %s%s", argv[0], + vty_out(vty, "Invalid type %s%s", argv[2]->arg, VTY_NEWLINE); return CMD_WARNING; @@ -396,7 +356,7 @@ DEFUN (rip_redistribute_type, DEFUN (no_rip_redistribute_type, no_rip_redistribute_type_cmd, - "no redistribute " QUAGGA_REDIST_STR_RIPD, + "no redistribute <kernel|connected|static|ospf|isis|bgp|pim|table>", NO_STR REDIST_STR QUAGGA_REDIST_HELP_STR_RIPD) @@ -405,7 +365,7 @@ DEFUN (no_rip_redistribute_type, for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[0], + if (strncmp(redist_type[i].str, argv[3]->arg, redist_type[i].str_min_len) == 0) { rip_metric_unset (redist_type[i].type, DONT_CARE_METRIC_RIP); @@ -415,7 +375,7 @@ DEFUN (no_rip_redistribute_type, } } - vty_out(vty, "Invalid type %s%s", argv[0], + vty_out(vty, "Invalid type %s%s", argv[3]->arg, VTY_NEWLINE); return CMD_WARNING; @@ -423,26 +383,28 @@ DEFUN (no_rip_redistribute_type, DEFUN (rip_redistribute_type_routemap, rip_redistribute_type_routemap_cmd, - "redistribute " QUAGGA_REDIST_STR_RIPD " route-map WORD", + "redistribute <kernel|connected|static|ospf|isis|bgp|pim|table> route-map WORD", REDIST_STR QUAGGA_REDIST_HELP_STR_RIPD "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_word = 3; int i; for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[0], + if (strncmp(redist_type[i].str, argv[idx_protocol]->arg, redist_type[i].str_min_len) == 0) { - rip_routemap_set (redist_type[i].type, argv[1]); + rip_routemap_set (redist_type[i].type, argv[idx_word]->arg); zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, redist_type[i].type, 0, VRF_DEFAULT); return CMD_SUCCESS; } } - vty_out(vty, "Invalid type %s%s", argv[0], + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE); return CMD_WARNING; @@ -450,28 +412,30 @@ DEFUN (rip_redistribute_type_routemap, DEFUN (no_rip_redistribute_type_routemap, no_rip_redistribute_type_routemap_cmd, - "no redistribute " QUAGGA_REDIST_STR_RIPD " route-map WORD", + "no redistribute <kernel|connected|static|ospf|isis|bgp|pim|table> route-map WORD", NO_STR REDIST_STR QUAGGA_REDIST_HELP_STR_RIPD "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 2; + int idx_word = 4; int i; for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[0], + if (strncmp(redist_type[i].str, argv[idx_protocol]->arg, redist_type[i].str_min_len) == 0) { - if (rip_routemap_unset (redist_type[i].type,argv[1])) + if (rip_routemap_unset (redist_type[i].type,argv[idx_word]->arg)) return CMD_WARNING; rip_redistribute_unset (redist_type[i].type); return CMD_SUCCESS; } } - vty_out(vty, "Invalid type %s%s", argv[0], + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE); return CMD_WARNING; @@ -479,19 +443,21 @@ DEFUN (no_rip_redistribute_type_routemap, DEFUN (rip_redistribute_type_metric, rip_redistribute_type_metric_cmd, - "redistribute " QUAGGA_REDIST_STR_RIPD " metric <0-16>", + "redistribute <kernel|connected|static|ospf|isis|bgp|pim|table> metric (0-16)", REDIST_STR QUAGGA_REDIST_HELP_STR_RIPD "Metric\n" "Metric value\n") { + int idx_protocol = 1; + int idx_number = 3; int i; int metric; - metric = atoi (argv[1]); + metric = atoi (argv[idx_number]->arg); for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[0], + if (strncmp(redist_type[i].str, argv[idx_protocol]->arg, redist_type[i].str_min_len) == 0) { rip_redistribute_metric_set (redist_type[i].type, metric); @@ -501,7 +467,7 @@ DEFUN (rip_redistribute_type_metric, } } - vty_out(vty, "Invalid type %s%s", argv[0], + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE); return CMD_WARNING; @@ -509,28 +475,30 @@ DEFUN (rip_redistribute_type_metric, DEFUN (no_rip_redistribute_type_metric, no_rip_redistribute_type_metric_cmd, - "no redistribute " QUAGGA_REDIST_STR_RIPD " metric <0-16>", + "no redistribute <kernel|connected|static|ospf|isis|bgp|pim|table> metric (0-16)", NO_STR REDIST_STR QUAGGA_REDIST_HELP_STR_RIPD "Metric\n" "Metric value\n") { + int idx_protocol = 2; + int idx_number = 4; int i; for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[0], + if (strncmp(redist_type[i].str, argv[idx_protocol]->arg, redist_type[i].str_min_len) == 0) { - if (rip_metric_unset (redist_type[i].type, atoi(argv[1]))) + if (rip_metric_unset (redist_type[i].type, atoi(argv[idx_number]->arg))) return CMD_WARNING; rip_redistribute_unset (redist_type[i].type); return CMD_SUCCESS; } } - vty_out(vty, "Invalid type %s%s", argv[0], + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE); return CMD_WARNING; @@ -538,7 +506,7 @@ DEFUN (no_rip_redistribute_type_metric, DEFUN (rip_redistribute_type_metric_routemap, rip_redistribute_type_metric_routemap_cmd, - "redistribute " QUAGGA_REDIST_STR_RIPD " metric <0-16> route-map WORD", + "redistribute <kernel|connected|static|ospf|isis|bgp|pim|table> metric (0-16) route-map WORD", REDIST_STR QUAGGA_REDIST_HELP_STR_RIPD "Metric\n" @@ -546,24 +514,27 @@ DEFUN (rip_redistribute_type_metric_routemap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_number = 3; + int idx_word = 5; int i; int metric; - metric = atoi (argv[1]); + metric = atoi (argv[idx_number]->arg); for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[0], + if (strncmp(redist_type[i].str, argv[idx_protocol]->arg, redist_type[i].str_min_len) == 0) { rip_redistribute_metric_set (redist_type[i].type, metric); - rip_routemap_set (redist_type[i].type, argv[2]); + rip_routemap_set (redist_type[i].type, argv[idx_word]->arg); zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, redist_type[i].type, 0, VRF_DEFAULT); return CMD_SUCCESS; } } - vty_out(vty, "Invalid type %s%s", argv[0], + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE); return CMD_WARNING; @@ -572,8 +543,7 @@ DEFUN (rip_redistribute_type_metric_routemap, DEFUN (no_rip_redistribute_type_metric_routemap, no_rip_redistribute_type_metric_routemap_cmd, - "no redistribute " QUAGGA_REDIST_STR_RIPD - " metric <0-16> route-map WORD", + "no redistribute <kernel|connected|static|ospf|isis|bgp|pim|table> metric (0-16) route-map WORD", NO_STR REDIST_STR QUAGGA_REDIST_HELP_STR_RIPD @@ -582,18 +552,21 @@ DEFUN (no_rip_redistribute_type_metric_routemap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 2; + int idx_number = 4; + int idx_word = 6; int i; for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[0], + if (strncmp(redist_type[i].str, argv[idx_protocol]->arg, redist_type[i].str_min_len) == 0) { - if (rip_metric_unset (redist_type[i].type, atoi(argv[1]))) + if (rip_metric_unset (redist_type[i].type, atoi(argv[idx_number]->arg))) return CMD_WARNING; - if (rip_routemap_unset (redist_type[i].type, argv[2])) + if (rip_routemap_unset (redist_type[i].type, argv[idx_word]->arg)) { - rip_redistribute_metric_set(redist_type[i].type, atoi(argv[1])); + rip_redistribute_metric_set(redist_type[i].type, atoi(argv[idx_number]->arg)); return CMD_WARNING; } rip_redistribute_unset (redist_type[i].type); @@ -601,7 +574,7 @@ DEFUN (no_rip_redistribute_type_metric_routemap, } } - vty_out(vty, "Invalid type %s%s", argv[0], + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE); return CMD_WARNING; @@ -744,8 +717,6 @@ rip_zclient_init (struct thread_master *master) install_node (&zebra_node, config_write_zebra); /* Install command elements to zebra node. */ - install_element (CONFIG_NODE, &router_zebra_cmd); - install_element (CONFIG_NODE, &no_router_zebra_cmd); install_default (ZEBRA_NODE); install_element (ZEBRA_NODE, &rip_redistribute_rip_cmd); install_element (ZEBRA_NODE, &no_rip_redistribute_rip_cmd); diff --git a/ripd/ripd.c b/ripd/ripd.c index 6124471161..24ba74c73f 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -334,11 +334,11 @@ rip_filter (int rip_distribute, struct prefix_ipv4 *p, struct rip_interface *ri) if (IS_RIP_DEBUG_PACKET) zlog_debug ("%s/%d filtered by distribute %s", inet_ntoa (p->prefix), p->prefixlen, inout); - return -1; - } - } + return -1; + } + } if (ri->prefix[rip_distribute]) - { +{ if (prefix_list_apply (ri->prefix[rip_distribute], (struct prefix *) p) == PREFIX_DENY) { @@ -356,7 +356,7 @@ rip_filter (int rip_distribute, struct prefix_ipv4 *p, struct rip_interface *ri) if (dist->list[distribute]) { alist = access_list_lookup (AFI_IP, dist->list[distribute]); - + if (alist) { if (access_list_apply (alist, (struct prefix *) p) == FILTER_DENY) @@ -371,7 +371,7 @@ rip_filter (int rip_distribute, struct prefix_ipv4 *p, struct rip_interface *ri) if (dist->prefix[distribute]) { plist = prefix_list_lookup (AFI_IP, dist->prefix[distribute]); - + if (plist) { if (prefix_list_apply (plist, @@ -2879,13 +2879,14 @@ DEFUN (no_router_rip, DEFUN (rip_version, rip_version_cmd, - "version <1-2>", + "version (1-2)", "Set routing protocol version\n" "version\n") { + int idx_number = 1; int version; - version = atoi (argv[0]); + version = atoi (argv[idx_number]->arg); if (version != RIPv1 && version != RIPv2) { vty_out (vty, "invalid rip version %d%s", version, @@ -2896,27 +2897,22 @@ DEFUN (rip_version, rip->version_recv = version; return CMD_SUCCESS; -} +} DEFUN (no_rip_version, no_rip_version_cmd, - "no version", + "no version [(1-2)]", NO_STR - "Set routing protocol version\n") + "Set routing protocol version\n" + "Version\n") { /* Set RIP version to the default. */ rip->version_send = RI_RIP_VERSION_2; rip->version_recv = RI_RIP_VERSION_1_AND_2; return CMD_SUCCESS; -} +} -ALIAS (no_rip_version, - no_rip_version_val_cmd, - "no version <1-2>", - NO_STR - "Set routing protocol version\n" - "version\n") DEFUN (rip_route, rip_route_cmd, @@ -2924,11 +2920,12 @@ DEFUN (rip_route, "RIP static route configuration\n" "IP prefix <network>/<length>\n") { + int idx_ipv4_prefixlen = 1; int ret; struct prefix_ipv4 p; struct route_node *node; - ret = str2prefix_ipv4 (argv[0], &p); + ret = str2prefix_ipv4 (argv[idx_ipv4_prefixlen]->arg, &p); if (ret < 0) { vty_out (vty, "Malformed address%s", VTY_NEWLINE); @@ -2960,11 +2957,12 @@ DEFUN (no_rip_route, "RIP static route configuration\n" "IP prefix <network>/<length>\n") { + int idx_ipv4_prefixlen = 2; int ret; struct prefix_ipv4 p; struct route_node *node; - ret = str2prefix_ipv4 (argv[0], &p); + ret = str2prefix_ipv4 (argv[idx_ipv4_prefixlen]->arg, &p); if (ret < 0) { vty_out (vty, "Malformed address%s", VTY_NEWLINE); @@ -2976,7 +2974,7 @@ DEFUN (no_rip_route, node = route_node_lookup (rip->route, (struct prefix *) &p); if (! node) { - vty_out (vty, "Can't find route %s.%s", argv[0], + vty_out (vty, "Can't find route %s.%s", argv[idx_ipv4_prefixlen]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -3009,13 +3007,14 @@ rip_update_default_metric (void) DEFUN (rip_default_metric, rip_default_metric_cmd, - "default-metric <1-16>", + "default-metric (1-16)", "Set a metric of redistribute routes\n" "Default metric\n") { + int idx_number = 1; if (rip) { - rip->default_metric = atoi (argv[0]); + rip->default_metric = atoi (argv[idx_number]->arg); /* rip_update_default_metric (); */ } return CMD_SUCCESS; @@ -3023,7 +3022,7 @@ DEFUN (rip_default_metric, DEFUN (no_rip_default_metric, no_rip_default_metric_cmd, - "no default-metric", + "no default-metric [(1-16)]", NO_STR "Set a metric of redistribute routes\n" "Default metric\n") @@ -3036,22 +3035,19 @@ DEFUN (no_rip_default_metric, return CMD_SUCCESS; } -ALIAS (no_rip_default_metric, - no_rip_default_metric_val_cmd, - "no default-metric <1-16>", - NO_STR - "Set a metric of redistribute routes\n" - "Default metric\n") DEFUN (rip_timers, rip_timers_cmd, - "timers basic <5-2147483647> <5-2147483647> <5-2147483647>", + "timers basic (5-2147483647) (5-2147483647) (5-2147483647)", "Adjust routing timers\n" "Basic routing protocol update timers\n" "Routing table update timer value in second. Default is 30.\n" "Routing information timeout timer. Default is 180.\n" "Garbage collection timer. Default is 120.\n") { + int idx_number = 2; + int idx_number_2 = 3; + int idx_number_3 = 4; unsigned long update; unsigned long timeout; unsigned long garbage; @@ -3059,21 +3055,21 @@ DEFUN (rip_timers, unsigned long RIP_TIMER_MAX = 2147483647; unsigned long RIP_TIMER_MIN = 5; - update = strtoul (argv[0], &endptr, 10); + update = strtoul (argv[idx_number]->arg, &endptr, 10); if (update > RIP_TIMER_MAX || update < RIP_TIMER_MIN || *endptr != '\0') { vty_out (vty, "update timer value error%s", VTY_NEWLINE); return CMD_WARNING; } - timeout = strtoul (argv[1], &endptr, 10); + timeout = strtoul (argv[idx_number_2]->arg, &endptr, 10); if (timeout > RIP_TIMER_MAX || timeout < RIP_TIMER_MIN || *endptr != '\0') { vty_out (vty, "timeout timer value error%s", VTY_NEWLINE); return CMD_WARNING; } - garbage = strtoul (argv[2], &endptr, 10); + garbage = strtoul (argv[idx_number_3]->arg, &endptr, 10); if (garbage > RIP_TIMER_MAX || garbage < RIP_TIMER_MIN || *endptr != '\0') { vty_out (vty, "garbage timer value error%s", VTY_NEWLINE); @@ -3093,10 +3089,13 @@ DEFUN (rip_timers, DEFUN (no_rip_timers, no_rip_timers_cmd, - "no timers basic", + "no timers basic [(0-65535) (0-65535) (0-65535)]", NO_STR "Adjust routing timers\n" - "Basic routing protocol update timers\n") + "Basic routing protocol update timers\n" + "Routing table update timer value in second. Default is 30.\n" + "Routing information timeout timer. Default is 180.\n" + "Garbage collection timer. Default is 120.\n") { /* Set each timer value to the default. */ rip->update_time = RIP_UPDATE_TIMER_DEFAULT; @@ -3109,15 +3108,6 @@ DEFUN (no_rip_timers, return CMD_SUCCESS; } -ALIAS (no_rip_timers, - no_rip_timers_val_cmd, - "no timers basic <0-65535> <0-65535> <0-65535>", - NO_STR - "Adjust routing timers\n" - "Basic routing protocol update timers\n" - "Routing table update timer value in second. Default is 30.\n" - "Routing information timeout timer. Default is 180.\n" - "Garbage collection timer. Default is 120.\n") struct route_table *rip_distance_table; @@ -3318,17 +3308,18 @@ rip_distance_show (struct vty *vty) DEFUN (rip_distance, rip_distance_cmd, - "distance <1-255>", + "distance (1-255)", "Administrative distance\n" "Distance value\n") { - rip->distance = atoi (argv[0]); + int idx_number = 1; + rip->distance = atoi (argv[idx_number]->arg); return CMD_SUCCESS; } DEFUN (no_rip_distance, no_rip_distance_cmd, - "no distance <1-255>", + "no distance (1-255)", NO_STR "Administrative distance\n" "Distance value\n") @@ -3339,49 +3330,59 @@ DEFUN (no_rip_distance, DEFUN (rip_distance_source, rip_distance_source_cmd, - "distance <1-255> A.B.C.D/M", + "distance (1-255) A.B.C.D/M", "Administrative distance\n" "Distance value\n" "IP source prefix\n") { - rip_distance_set (vty, argv[0], argv[1], NULL); + int idx_number = 1; + int idx_ipv4_prefixlen = 2; + rip_distance_set (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); return CMD_SUCCESS; } DEFUN (no_rip_distance_source, no_rip_distance_source_cmd, - "no distance <1-255> A.B.C.D/M", + "no distance (1-255) A.B.C.D/M", NO_STR "Administrative distance\n" "Distance value\n" "IP source prefix\n") { - rip_distance_unset (vty, argv[0], argv[1], NULL); + int idx_number = 2; + int idx_ipv4_prefixlen = 3; + rip_distance_unset (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); return CMD_SUCCESS; } DEFUN (rip_distance_source_access_list, rip_distance_source_access_list_cmd, - "distance <1-255> A.B.C.D/M WORD", + "distance (1-255) A.B.C.D/M WORD", "Administrative distance\n" "Distance value\n" "IP source prefix\n" "Access list name\n") { - rip_distance_set (vty, argv[0], argv[1], argv[2]); + int idx_number = 1; + int idx_ipv4_prefixlen = 2; + int idx_word = 3; + rip_distance_set (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); return CMD_SUCCESS; } DEFUN (no_rip_distance_source_access_list, no_rip_distance_source_access_list_cmd, - "no distance <1-255> A.B.C.D/M WORD", + "no distance (1-255) A.B.C.D/M WORD", NO_STR "Administrative distance\n" "Distance value\n" "IP source prefix\n" "Access list name\n") { - rip_distance_unset (vty, argv[0], argv[1], argv[2]); + int idx_number = 2; + int idx_ipv4_prefixlen = 3; + int idx_word = 4; + rip_distance_unset (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); return CMD_SUCCESS; } @@ -4090,13 +4091,10 @@ rip_init (void) install_default (RIP_NODE); install_element (RIP_NODE, &rip_version_cmd); install_element (RIP_NODE, &no_rip_version_cmd); - install_element (RIP_NODE, &no_rip_version_val_cmd); install_element (RIP_NODE, &rip_default_metric_cmd); install_element (RIP_NODE, &no_rip_default_metric_cmd); - install_element (RIP_NODE, &no_rip_default_metric_val_cmd); install_element (RIP_NODE, &rip_timers_cmd); install_element (RIP_NODE, &no_rip_timers_cmd); - install_element (RIP_NODE, &no_rip_timers_val_cmd); install_element (RIP_NODE, &rip_route_cmd); install_element (RIP_NODE, &no_rip_route_cmd); install_element (RIP_NODE, &rip_distance_cmd); diff --git a/ripd/ripd.h b/ripd/ripd.h index 3de23ec334..1cc46ff310 100644 --- a/ripd/ripd.h +++ b/ripd/ripd.h @@ -392,7 +392,6 @@ extern void rip_route_map_init (void); extern void rip_route_map_reset (void); extern void rip_snmp_init (void); extern void rip_zclient_init(struct thread_master *); -extern void rip_zclient_start (void); extern void rip_zclient_reset (void); extern void rip_offset_init (void); extern int if_check_address (struct in_addr addr); diff --git a/ripngd/ripng_debug.c b/ripngd/ripng_debug.c index eb8ff5dc6d..16c8b3400d 100644 --- a/ripngd/ripng_debug.c +++ b/ripngd/ripng_debug.c @@ -91,38 +91,18 @@ DEFUN (debug_ripng_packet, DEFUN (debug_ripng_packet_direct, debug_ripng_packet_direct_cmd, - "debug ripng packet (recv|send)", + "debug ripng packet <recv|send>", DEBUG_STR "RIPng configuration\n" "Debug option set for ripng packet\n" "Debug option set for receive packet\n" "Debug option set for send packet\n") { + int idx_recv_send = 3; ripng_debug_packet |= RIPNG_DEBUG_PACKET; - if (strncmp ("send", argv[0], strlen (argv[0])) == 0) + if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) ripng_debug_packet |= RIPNG_DEBUG_SEND; - if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) - ripng_debug_packet |= RIPNG_DEBUG_RECV; - - return CMD_SUCCESS; -} - -/* N.B. the "detail" modifier is a no-op. we leave this command - for legacy compatibility. */ -DEFUN_DEPRECATED (debug_ripng_packet_detail, - debug_ripng_packet_detail_cmd, - "debug ripng packet (recv|send) detail", - DEBUG_STR - "RIPng configuration\n" - "Debug option set for ripng packet\n" - "Debug option set for receive packet\n" - "Debug option set for send packet\n" - "Debug option set detaied information\n") -{ - ripng_debug_packet |= RIPNG_DEBUG_PACKET; - if (strncmp ("send", argv[0], strlen (argv[0])) == 0) - ripng_debug_packet |= RIPNG_DEBUG_SEND; - if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) + if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) ripng_debug_packet |= RIPNG_DEBUG_RECV; return CMD_SUCCESS; @@ -165,7 +145,7 @@ DEFUN (no_debug_ripng_packet, DEFUN (no_debug_ripng_packet_direct, no_debug_ripng_packet_direct_cmd, - "no debug ripng packet (recv|send)", + "no debug ripng packet <recv|send>", NO_STR DEBUG_STR "RIPng configuration\n" @@ -173,14 +153,15 @@ DEFUN (no_debug_ripng_packet_direct, "Debug option set for receive packet\n" "Debug option set for send packet\n") { - if (strncmp ("send", argv[0], strlen (argv[0])) == 0) + int idx_recv_send = 4; + if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) { if (IS_RIPNG_DEBUG_RECV) ripng_debug_packet &= ~RIPNG_DEBUG_SEND; else ripng_debug_packet = 0; } - else if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) + else if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) { if (IS_RIPNG_DEBUG_SEND) ripng_debug_packet &= ~RIPNG_DEBUG_RECV; @@ -269,7 +250,6 @@ ripng_debug_init () install_element (ENABLE_NODE, &debug_ripng_events_cmd); install_element (ENABLE_NODE, &debug_ripng_packet_cmd); install_element (ENABLE_NODE, &debug_ripng_packet_direct_cmd); - install_element (ENABLE_NODE, &debug_ripng_packet_detail_cmd); install_element (ENABLE_NODE, &debug_ripng_zebra_cmd); install_element (ENABLE_NODE, &no_debug_ripng_events_cmd); install_element (ENABLE_NODE, &no_debug_ripng_packet_cmd); @@ -279,7 +259,6 @@ ripng_debug_init () install_element (CONFIG_NODE, &debug_ripng_events_cmd); install_element (CONFIG_NODE, &debug_ripng_packet_cmd); install_element (CONFIG_NODE, &debug_ripng_packet_direct_cmd); - install_element (CONFIG_NODE, &debug_ripng_packet_detail_cmd); install_element (CONFIG_NODE, &debug_ripng_zebra_cmd); install_element (CONFIG_NODE, &no_debug_ripng_events_cmd); install_element (CONFIG_NODE, &no_debug_ripng_packet_cmd); diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c index c4dec7e7b1..7bee7625d1 100644 --- a/ripngd/ripng_interface.c +++ b/ripngd/ripng_interface.c @@ -953,20 +953,21 @@ DEFUN (ripng_network, "RIPng enable on specified interface or network.\n" "Interface or address") { + int idx_if_or_addr = 1; int ret; struct prefix p; - ret = str2prefix (argv[0], &p); + ret = str2prefix (argv[idx_if_or_addr]->arg, &p); /* Given string is IPv6 network or interface name. */ if (ret) ret = ripng_enable_network_add (&p); else - ret = ripng_enable_if_add (argv[0]); + ret = ripng_enable_if_add (argv[idx_if_or_addr]->arg); if (ret < 0) { - vty_out (vty, "There is same network configuration %s%s", argv[0], + vty_out (vty, "There is same network configuration %s%s", argv[idx_if_or_addr]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -982,20 +983,21 @@ DEFUN (no_ripng_network, "RIPng enable on specified interface or network.\n" "Interface or address") { + int idx_if_or_addr = 2; int ret; struct prefix p; - ret = str2prefix (argv[0], &p); + ret = str2prefix (argv[idx_if_or_addr]->arg, &p); /* Given string is interface name. */ if (ret) ret = ripng_enable_network_delete (&p); else - ret = ripng_enable_if_delete (argv[0]); + ret = ripng_enable_if_delete (argv[idx_if_or_addr]->arg); if (ret < 0) { - vty_out (vty, "can't find network %s%s", argv[0], + vty_out (vty, "can't find network %s%s", argv[idx_if_or_addr]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -1040,11 +1042,12 @@ DEFUN (ipv6_ripng_split_horizon_poisoned_reverse, DEFUN (no_ipv6_ripng_split_horizon, no_ipv6_ripng_split_horizon_cmd, - "no ipv6 ripng split-horizon", + "no ipv6 ripng split-horizon [poisoned-reverse]", NO_STR IPV6_STR "Routing Information Protocol\n" - "Perform split horizon\n") + "Perform split horizon\n" + "With poisoned-reverse\n") { struct interface *ifp; struct ripng_interface *ri; @@ -1056,22 +1059,14 @@ DEFUN (no_ipv6_ripng_split_horizon, return CMD_SUCCESS; } -ALIAS (no_ipv6_ripng_split_horizon, - no_ipv6_ripng_split_horizon_poisoned_reverse_cmd, - "no ipv6 ripng split-horizon poisoned-reverse", - NO_STR - IPV6_STR - "Routing Information Protocol\n" - "Perform split horizon\n" - "With poisoned-reverse\n") - DEFUN (ripng_passive_interface, ripng_passive_interface_cmd, "passive-interface IFNAME", "Suppress routing updates on an interface\n" "Interface name\n") { - return ripng_passive_interface_set (vty, argv[0]); + int idx_ifname = 1; + return ripng_passive_interface_set (vty, argv[idx_ifname]->arg); } DEFUN (no_ripng_passive_interface, @@ -1081,7 +1076,8 @@ DEFUN (no_ripng_passive_interface, "Suppress routing updates on an interface\n" "Interface name\n") { - return ripng_passive_interface_unset (vty, argv[0]); + int idx_ifname = 2; + return ripng_passive_interface_unset (vty, argv[idx_ifname]->arg); } static struct ripng_interface * @@ -1210,5 +1206,4 @@ ripng_if_init () install_element (INTERFACE_NODE, &ipv6_ripng_split_horizon_cmd); install_element (INTERFACE_NODE, &ipv6_ripng_split_horizon_poisoned_reverse_cmd); install_element (INTERFACE_NODE, &no_ipv6_ripng_split_horizon_cmd); - install_element (INTERFACE_NODE, &no_ipv6_ripng_split_horizon_poisoned_reverse_cmd); } diff --git a/ripngd/ripng_offset.c b/ripngd/ripng_offset.c index 4ed6e9b0c4..dcddf96ebf 100644 --- a/ripngd/ripng_offset.c +++ b/ripngd/ripng_offset.c @@ -290,19 +290,22 @@ ripng_offset_list_apply_out (struct prefix_ipv6 *p, struct interface *ifp, DEFUN (ripng_offset_list, ripng_offset_list_cmd, - "offset-list WORD (in|out) <0-16>", + "offset-list WORD <in|out> (0-16)", "Modify RIPng metric\n" "Access-list name\n" "For incoming updates\n" "For outgoing updates\n" "Metric value\n") { - return ripng_offset_list_set (vty, argv[0], argv[1], argv[2], NULL); + int idx_word = 1; + int idx_in_out = 2; + int idx_number = 3; + return ripng_offset_list_set (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, NULL); } DEFUN (ripng_offset_list_ifname, ripng_offset_list_ifname_cmd, - "offset-list WORD (in|out) <0-16> IFNAME", + "offset-list WORD <in|out> (0-16) IFNAME", "Modify RIPng metric\n" "Access-list name\n" "For incoming updates\n" @@ -310,12 +313,16 @@ DEFUN (ripng_offset_list_ifname, "Metric value\n" "Interface to match\n") { - return ripng_offset_list_set (vty, argv[0], argv[1], argv[2], argv[3]); + int idx_word = 1; + int idx_in_out = 2; + int idx_number = 3; + int idx_ifname = 4; + return ripng_offset_list_set (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, argv[idx_ifname]->arg); } DEFUN (no_ripng_offset_list, no_ripng_offset_list_cmd, - "no offset-list WORD (in|out) <0-16>", + "no offset-list WORD <in|out> (0-16)", NO_STR "Modify RIPng metric\n" "Access-list name\n" @@ -323,12 +330,15 @@ DEFUN (no_ripng_offset_list, "For outgoing updates\n" "Metric value\n") { - return ripng_offset_list_unset (vty, argv[0], argv[1], argv[2], NULL); + int idx_word = 2; + int idx_in_out = 3; + int idx_number = 4; + return ripng_offset_list_unset (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, NULL); } DEFUN (no_ripng_offset_list_ifname, no_ripng_offset_list_ifname_cmd, - "no offset-list WORD (in|out) <0-16> IFNAME", + "no offset-list WORD <in|out> (0-16) IFNAME", NO_STR "Modify RIPng metric\n" "Access-list name\n" @@ -337,7 +347,11 @@ DEFUN (no_ripng_offset_list_ifname, "Metric value\n" "Interface to match\n") { - return ripng_offset_list_unset (vty, argv[0], argv[1], argv[2], argv[3]); + int idx_word = 2; + int idx_in_out = 3; + int idx_number = 4; + int idx_ifname = 5; + return ripng_offset_list_unset (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, argv[idx_ifname]->arg); } static int diff --git a/ripngd/ripng_routemap.c b/ripngd/ripng_routemap.c index 19fa70227d..7cab5861bf 100644 --- a/ripngd/ripng_routemap.c +++ b/ripngd/ripng_routemap.c @@ -24,6 +24,7 @@ #include "if.h" #include "memory.h" #include "prefix.h" +#include "vty.h" #include "routemap.h" #include "command.h" #include "sockunion.h" @@ -42,95 +43,6 @@ struct rip_metric_modifier u_char metric; }; - -static int -ripng_route_match_add (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_add_match (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - -static int -ripng_route_match_delete (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_delete_match (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - -static int -ripng_route_set_add (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_add_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - -static int -ripng_route_set_delete (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_delete_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - /* `match metric METRIC' */ /* Match function return 1 if match is success else return zero. */ static route_map_result_t @@ -442,7 +354,7 @@ route_set_tag (void *rule, struct prefix *prefix, /* Fetch routemap's rule information. */ tag = rule; rinfo = object; - + /* Set next hop value. */ rinfo->tag_out = *tag; } @@ -462,216 +374,6 @@ static struct route_map_rule_cmd route_set_tag_cmd = #define MATCH_STR "Match values from routing table\n" #define SET_STR "Set values in destination routing protocol\n" -DEFUN (match_metric, - match_metric_cmd, - "match metric <0-4294967295>", - MATCH_STR - "Match metric of route\n" - "Metric value\n") -{ - return ripng_route_match_add (vty, vty->index, "metric", argv[0]); -} - -DEFUN (no_match_metric, - no_match_metric_cmd, - "no match metric", - NO_STR - MATCH_STR - "Match metric of route\n") -{ - if (argc == 0) - return ripng_route_match_delete (vty, vty->index, "metric", NULL); - - return ripng_route_match_delete (vty, vty->index, "metric", argv[0]); -} - -ALIAS (no_match_metric, - no_match_metric_val_cmd, - "no match metric <0-4294967295>", - NO_STR - MATCH_STR - "Match metric of route\n" - "Metric value\n") - -DEFUN (match_interface, - match_interface_cmd, - "match interface WORD", - MATCH_STR - "Match first hop interface of route\n" - "Interface name\n") -{ - return ripng_route_match_add (vty, vty->index, "interface", argv[0]); -} - -DEFUN (no_match_interface, - no_match_interface_cmd, - "no match interface", - NO_STR - MATCH_STR - "Match first hop interface of route\n") -{ - if (argc == 0) - return ripng_route_match_delete (vty, vty->index, "interface", NULL); - - return ripng_route_match_delete (vty, vty->index, "interface", argv[0]); -} - -ALIAS (no_match_interface, - no_match_interface_val_cmd, - "no match interface WORD", - NO_STR - MATCH_STR - "Match first hop interface of route\n" - "Interface name\n") - -DEFUN (match_tag, - match_tag_cmd, - "match tag <1-4294967295>", - MATCH_STR - "Match tag of route\n" - "Metric value\n") -{ - return ripng_route_match_add (vty, vty->index, "tag", argv[0]); -} - -DEFUN (no_match_tag, - no_match_tag_cmd, - "no match tag", - NO_STR - MATCH_STR - "Match tag of route\n") -{ - if (argc == 0) - return ripng_route_match_delete (vty, vty->index, "tag", NULL); - - return ripng_route_match_delete (vty, vty->index, "tag", argv[0]); -} - -ALIAS (no_match_tag, - no_match_tag_val_cmd, - "no match tag <1-4294967295>", - NO_STR - MATCH_STR - "Match tag of route\n" - "Metric value\n") - -/* set functions */ - -DEFUN (set_metric, - set_metric_cmd, - "set metric <0-4294967295>", - "Set value\n" - "Metric value for destination routing protocol\n" - "Metric value\n") -{ - return ripng_route_set_add (vty, vty->index, "metric", argv[0]); -} - -DEFUN (no_set_metric, - no_set_metric_cmd, - "no set metric", - NO_STR - SET_STR - "Metric value for destination routing protocol\n") -{ - if (argc == 0) - return ripng_route_set_delete (vty, vty->index, "metric", NULL); - - return ripng_route_set_delete (vty, vty->index, "metric", argv[0]); -} - -ALIAS (no_set_metric, - no_set_metric_val_cmd, - "no set metric <0-4294967295>", - NO_STR - SET_STR - "Metric value for destination routing protocol\n" - "Metric value\n") - -DEFUN (set_ipv6_nexthop_local, - set_ipv6_nexthop_local_cmd, - "set ipv6 next-hop local X:X::X:X", - SET_STR - IPV6_STR - "IPv6 next-hop address\n" - "IPv6 local address\n" - "IPv6 address of next hop\n") -{ - union sockunion su; - int ret; - - ret = str2sockunion (argv[0], &su); - if (ret < 0) - { - vty_out (vty, "%% Malformed next-hop local address%s", VTY_NEWLINE); - return CMD_WARNING; - } - - if (!IN6_IS_ADDR_LINKLOCAL(&su.sin6.sin6_addr)) - { - vty_out (vty, "%% Invalid link-local nexthop address%s", VTY_NEWLINE); - return CMD_WARNING; - } - - return ripng_route_set_add (vty, vty->index, "ipv6 next-hop local", argv[0]); -} - -DEFUN (no_set_ipv6_nexthop_local, - no_set_ipv6_nexthop_local_cmd, - "no set ipv6 next-hop local", - NO_STR - SET_STR - IPV6_STR - "IPv6 next-hop address\n" - "IPv6 local address\n") -{ - if (argc == 0) - return ripng_route_set_delete (vty, vty->index, "ipv6 next-hop local", NULL); - - return ripng_route_set_delete (vty, vty->index, "ipv6 next-hop local", argv[0]); -} - -ALIAS (no_set_ipv6_nexthop_local, - no_set_ipv6_nexthop_local_val_cmd, - "no set ipv6 next-hop local X:X::X:X", - NO_STR - SET_STR - IPV6_STR - "IPv6 next-hop address\n" - "IPv6 local address\n" - "IPv6 address of next hop\n") - -DEFUN (set_tag, - set_tag_cmd, - "set tag <1-4294967295>", - SET_STR - "Tag value for routing protocol\n" - "Tag value\n") -{ - return ripng_route_set_add (vty, vty->index, "tag", argv[0]); -} - -DEFUN (no_set_tag, - no_set_tag_cmd, - "no set tag", - NO_STR - SET_STR - "Tag value for routing protocol\n") -{ - if (argc == 0) - return ripng_route_set_delete (vty, vty->index, "tag", NULL); - - return ripng_route_set_delete (vty, vty->index, "tag", argv[0]); -} - -ALIAS (no_set_tag, - no_set_tag_val_cmd, - "no set tag <1-4294967295>", - NO_STR - SET_STR - "Tag value for routing protocol\n" - "Tag value\n") - void ripng_route_map_reset () { @@ -684,31 +386,28 @@ ripng_route_map_init () { route_map_init (); + route_map_match_interface_hook (generic_match_add); + route_map_no_match_interface_hook (generic_match_delete); + + route_map_match_metric_hook (generic_match_add); + route_map_no_match_metric_hook (generic_match_delete); + + route_map_match_tag_hook (generic_match_add); + route_map_no_match_tag_hook (generic_match_delete); + + route_map_set_ipv6_nexthop_local_hook (generic_set_add); + route_map_no_set_ipv6_nexthop_local_hook (generic_set_delete); + + route_map_set_metric_hook (generic_set_add); + route_map_no_set_metric_hook (generic_set_delete); + + route_map_set_tag_hook (generic_set_add); + route_map_no_set_tag_hook (generic_set_delete); + route_map_install_match (&route_match_metric_cmd); route_map_install_match (&route_match_interface_cmd); route_map_install_match (&route_match_tag_cmd); - route_map_install_set (&route_set_metric_cmd); route_map_install_set (&route_set_ipv6_nexthop_local_cmd); route_map_install_set (&route_set_tag_cmd); - - install_element (RMAP_NODE, &match_metric_cmd); - install_element (RMAP_NODE, &no_match_metric_cmd); - install_element (RMAP_NODE, &no_match_metric_val_cmd); - install_element (RMAP_NODE, &match_interface_cmd); - install_element (RMAP_NODE, &no_match_interface_cmd); - install_element (RMAP_NODE, &no_match_interface_val_cmd); - install_element (RMAP_NODE, &match_tag_cmd); - install_element (RMAP_NODE, &no_match_tag_cmd); - install_element (RMAP_NODE, &no_match_tag_val_cmd); - - install_element (RMAP_NODE, &set_metric_cmd); - install_element (RMAP_NODE, &no_set_metric_cmd); - install_element (RMAP_NODE, &no_set_metric_val_cmd); - install_element (RMAP_NODE, &set_ipv6_nexthop_local_cmd); - install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_cmd); - install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_val_cmd); - install_element (RMAP_NODE, &set_tag_cmd); - install_element (RMAP_NODE, &no_set_tag_cmd); - install_element (RMAP_NODE, &no_set_tag_val_cmd); } diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c index d05b5dbad8..09472683d7 100644 --- a/ripngd/ripng_zebra.c +++ b/ripngd/ripng_zebra.c @@ -292,30 +292,6 @@ ripng_redistribute_clean () } } -DEFUN (router_zebra, - router_zebra_cmd, - "router zebra", - "Enable a routing process\n" - "Make connection to zebra daemon\n") -{ - vty->node = ZEBRA_NODE; - zclient->enable = 1; - zclient_start (zclient); - return CMD_SUCCESS; -} - -DEFUN (no_router_zebra, - no_router_zebra_cmd, - "no router zebra", - NO_STR - "Disable a routing process\n" - "Stop connection to zebra daemon\n") -{ - zclient->enable = 0; - zclient_stop (zclient); - return CMD_SUCCESS; -} - DEFUN (ripng_redistribute_ripng, ripng_redistribute_ripng_cmd, "redistribute ripng", @@ -339,17 +315,17 @@ DEFUN (no_ripng_redistribute_ripng, DEFUN (ripng_redistribute_type, ripng_redistribute_type_cmd, - "redistribute " QUAGGA_REDIST_STR_RIPNGD, + "redistribute <kernel|connected|static|ospf6|isis|bgp|table>", "Redistribute\n" QUAGGA_REDIST_HELP_STR_RIPNGD) { int type; - type = proto_redistnum(AFI_IP6, argv[0]); + type = proto_redistnum(AFI_IP6, argv[2]->arg); if (type < 0) { - vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[2]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -359,18 +335,21 @@ DEFUN (ripng_redistribute_type, DEFUN (no_ripng_redistribute_type, no_ripng_redistribute_type_cmd, - "no redistribute " QUAGGA_REDIST_STR_RIPNGD, + "no redistribute <kernel|connected|static|ospf6|isis|bgp|table> [metric (0-16)] [route-map WORD]", NO_STR "Redistribute\n" - QUAGGA_REDIST_HELP_STR_RIPNGD) + QUAGGA_REDIST_HELP_STR_RIPNGD + "Metric\n" + "Metric value\n" + "Route map reference\n" + "Pointer to route-map entries\n") { int type; - - type = proto_redistnum(AFI_IP6, argv[0]); + type = proto_redistnum(AFI_IP6, argv[2]->text); if (type < 0) { - vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[2]->text, VTY_NEWLINE); return CMD_WARNING; } @@ -382,21 +361,23 @@ DEFUN (no_ripng_redistribute_type, DEFUN (ripng_redistribute_type_metric, ripng_redistribute_type_metric_cmd, - "redistribute " QUAGGA_REDIST_STR_RIPNGD " metric <0-16>", + "redistribute <kernel|connected|static|ospf6|isis|bgp|table> metric (0-16)", "Redistribute\n" QUAGGA_REDIST_HELP_STR_RIPNGD "Metric\n" "Metric value\n") { + int idx_protocol = 1; + int idx_number = 3; int type; int metric; - metric = atoi (argv[1]); - type = proto_redistnum(AFI_IP6, argv[0]); + metric = atoi (argv[idx_number]->arg); + type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); if (type < 0) { - vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE); return CMD_WARNING; } @@ -406,51 +387,37 @@ DEFUN (ripng_redistribute_type_metric, return CMD_SUCCESS; } -ALIAS (no_ripng_redistribute_type, - no_ripng_redistribute_type_metric_cmd, - "no redistribute " QUAGGA_REDIST_STR_RIPNGD " metric <0-16>", - NO_STR - "Redistribute\n" - QUAGGA_REDIST_HELP_STR_RIPNGD - "Metric\n" - "Metric value\n") DEFUN (ripng_redistribute_type_routemap, ripng_redistribute_type_routemap_cmd, - "redistribute " QUAGGA_REDIST_STR_RIPNGD " route-map WORD", + "redistribute <kernel|connected|static|ospf6|isis|bgp|table> route-map WORD", "Redistribute\n" QUAGGA_REDIST_HELP_STR_RIPNGD "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_word = 3; int type; - type = proto_redistnum(AFI_IP6, argv[0]); + type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); if (type < 0) { - vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE); return CMD_WARNING; } - ripng_redistribute_routemap_set (type, argv[1]); + ripng_redistribute_routemap_set (type, argv[idx_word]->text); zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, VRF_DEFAULT); return CMD_SUCCESS; } -ALIAS (no_ripng_redistribute_type, - no_ripng_redistribute_type_routemap_cmd, - "no redistribute " QUAGGA_REDIST_STR_RIPNGD " route-map WORD", - NO_STR - "Redistribute\n" - QUAGGA_REDIST_HELP_STR_RIPNGD - "Route map reference\n" - "Pointer to route-map entries\n") DEFUN (ripng_redistribute_type_metric_routemap, ripng_redistribute_type_metric_routemap_cmd, - "redistribute " QUAGGA_REDIST_STR_RIPNGD " metric <0-16> route-map WORD", + "redistribute <kernel|connected|static|ospf6|isis|bgp|table> metric (0-16) route-map WORD", "Redistribute\n" QUAGGA_REDIST_HELP_STR_RIPNGD "Metric\n" @@ -458,32 +425,27 @@ DEFUN (ripng_redistribute_type_metric_routemap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_number = 3; + int idx_word = 5; int type; int metric; - type = proto_redistnum(AFI_IP6, argv[0]); - metric = atoi (argv[1]); + type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); + metric = atoi (argv[idx_number]->arg); if (type < 0) { - vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE); return CMD_WARNING; } ripng_redistribute_metric_set (type, metric); - ripng_redistribute_routemap_set (type, argv[2]); + ripng_redistribute_routemap_set (type, argv[idx_word]->text); zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, VRF_DEFAULT); return CMD_SUCCESS; } -ALIAS (no_ripng_redistribute_type, - no_ripng_redistribute_type_metric_routemap_cmd, - "no redistribute " QUAGGA_REDIST_STR_RIPNGD " metric <0-16> route-map WORD", - NO_STR - "Redistribute\n" - QUAGGA_REDIST_HELP_STR_RIPNGD - "Route map reference\n" - "Pointer to route-map entries\n") void ripng_redistribute_write (struct vty *vty, int config_mode) @@ -576,8 +538,6 @@ zebra_init (struct thread_master *master) install_node (&zebra_node, zebra_config_write); /* Install command element for zebra node. */ - install_element (CONFIG_NODE, &router_zebra_cmd); - install_element (CONFIG_NODE, &no_router_zebra_cmd); install_default (ZEBRA_NODE); install_element (ZEBRA_NODE, &ripng_redistribute_ripng_cmd); install_element (ZEBRA_NODE, &no_ripng_redistribute_ripng_cmd); @@ -588,7 +548,4 @@ zebra_init (struct thread_master *master) install_element (RIPNG_NODE, &ripng_redistribute_type_metric_cmd); install_element (RIPNG_NODE, &ripng_redistribute_type_metric_routemap_cmd); install_element (RIPNG_NODE, &no_ripng_redistribute_type_cmd); - install_element (RIPNG_NODE, &no_ripng_redistribute_type_routemap_cmd); - install_element (RIPNG_NODE, &no_ripng_redistribute_type_metric_cmd); - install_element (RIPNG_NODE, &no_ripng_redistribute_type_metric_routemap_cmd); } diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index 2a32b934f2..e7db971208 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -629,11 +629,11 @@ ripng_filter (int ripng_distribute, struct prefix_ipv6 *p, if (IS_RIPNG_DEBUG_PACKET) zlog_debug ("%s/%d filtered by distribute %s", inet6_ntoa (p->prefix), p->prefixlen, inout); - return -1; - } - } + return -1; + } + } if (ri->prefix[ripng_distribute]) - { +{ if (prefix_list_apply (ri->prefix[ripng_distribute], (struct prefix *) p) == PREFIX_DENY) { @@ -651,7 +651,7 @@ ripng_filter (int ripng_distribute, struct prefix_ipv6 *p, if (dist->list[distribute]) { alist = access_list_lookup (AFI_IP6, dist->list[distribute]); - + if (alist) { if (access_list_apply (alist, @@ -667,7 +667,7 @@ ripng_filter (int ripng_distribute, struct prefix_ipv6 *p, if (dist->prefix[distribute]) { plist = prefix_list_lookup (AFI_IP6, dist->prefix[distribute]); - + if (plist) { if (prefix_list_apply (plist, @@ -2198,11 +2198,12 @@ DEFUN (ripng_route, "Static route setup\n" "Set static RIPng route announcement\n") { + int idx_ipv6addr = 1; int ret; struct prefix_ipv6 p; struct route_node *rp; - ret = str2prefix_ipv6 (argv[0], (struct prefix_ipv6 *)&p); + ret = str2prefix_ipv6 (argv[idx_ipv6addr]->arg, (struct prefix_ipv6 *)&p); if (ret <= 0) { vty_out (vty, "Malformed address%s", VTY_NEWLINE); @@ -2231,11 +2232,12 @@ DEFUN (no_ripng_route, "Static route setup\n" "Delete static RIPng route announcement\n") { + int idx_ipv6addr = 2; int ret; struct prefix_ipv6 p; struct route_node *rp; - ret = str2prefix_ipv6 (argv[0], (struct prefix_ipv6 *)&p); + ret = str2prefix_ipv6 (argv[idx_ipv6addr]->arg, (struct prefix_ipv6 *)&p); if (ret <= 0) { vty_out (vty, "Malformed address%s", VTY_NEWLINE); @@ -2265,11 +2267,12 @@ DEFUN (ripng_aggregate_address, "Set aggregate RIPng route announcement\n" "Aggregate network\n") { + int idx_ipv6_prefixlen = 1; int ret; struct prefix p; struct route_node *node; - ret = str2prefix_ipv6 (argv[0], (struct prefix_ipv6 *)&p); + ret = str2prefix_ipv6 (argv[idx_ipv6_prefixlen]->arg, (struct prefix_ipv6 *)&p); if (ret <= 0) { vty_out (vty, "Malformed address%s", VTY_NEWLINE); @@ -2298,11 +2301,12 @@ DEFUN (no_ripng_aggregate_address, "Delete aggregate RIPng route announcement\n" "Aggregate network") { + int idx_ipv6_prefixlen = 2; int ret; struct prefix p; struct route_node *rn; - ret = str2prefix_ipv6 (argv[0], (struct prefix_ipv6 *) &p); + ret = str2prefix_ipv6 (argv[idx_ipv6_prefixlen]->arg, (struct prefix_ipv6 *) &p); if (ret <= 0) { vty_out (vty, "Malformed address%s", VTY_NEWLINE); @@ -2326,20 +2330,21 @@ DEFUN (no_ripng_aggregate_address, DEFUN (ripng_default_metric, ripng_default_metric_cmd, - "default-metric <1-16>", + "default-metric (1-16)", "Set a metric of redistribute routes\n" "Default metric\n") { + int idx_number = 1; if (ripng) { - ripng->default_metric = atoi (argv[0]); + ripng->default_metric = atoi (argv[idx_number]->arg); } return CMD_SUCCESS; } DEFUN (no_ripng_default_metric, no_ripng_default_metric_cmd, - "no default-metric", + "no default-metric [(1-16)]", NO_STR "Set a metric of redistribute routes\n" "Default metric\n") @@ -2351,12 +2356,6 @@ DEFUN (no_ripng_default_metric, return CMD_SUCCESS; } -ALIAS (no_ripng_default_metric, - no_ripng_default_metric_val_cmd, - "no default-metric <1-16>", - NO_STR - "Set a metric of redistribute routes\n" - "Default metric\n") #if 0 /* RIPng update timer setup. */ @@ -2463,20 +2462,23 @@ DEFUN (no_ripng_garbage_timer, DEFUN (ripng_timers, ripng_timers_cmd, - "timers basic <0-65535> <0-65535> <0-65535>", + "timers basic (0-65535) (0-65535) (0-65535)", "RIPng timers setup\n" "Basic timer\n" "Routing table update timer value in second. Default is 30.\n" "Routing information timeout timer. Default is 180.\n" "Garbage collection timer. Default is 120.\n") { + int idx_number = 2; + int idx_number_2 = 3; + int idx_number_3 = 4; unsigned long update; unsigned long timeout; unsigned long garbage; - VTY_GET_INTEGER_RANGE("update timer", update, argv[0], 0, 65535); - VTY_GET_INTEGER_RANGE("timeout timer", timeout, argv[1], 0, 65535); - VTY_GET_INTEGER_RANGE("garbage timer", garbage, argv[2], 0, 65535); + VTY_GET_INTEGER_RANGE("update timer", update, argv[idx_number]->arg, 0, 65535); + VTY_GET_INTEGER_RANGE("timeout timer", timeout, argv[idx_number_2]->arg, 0, 65535); + VTY_GET_INTEGER_RANGE("garbage timer", garbage, argv[idx_number_3]->arg, 0, 65535); /* Set each timer value. */ ripng->update_time = update; @@ -2491,10 +2493,13 @@ DEFUN (ripng_timers, DEFUN (no_ripng_timers, no_ripng_timers_cmd, - "no timers basic", + "no timers basic [(0-65535) (0-65535) (0-65535)]", NO_STR "RIPng timers setup\n" - "Basic timer\n") + "Basic timer\n" + "Routing table update timer value in second. Default is 30.\n" + "Routing information timeout timer. Default is 180.\n" + "Garbage collection timer. Default is 120.\n") { /* Set each timer value to the default. */ ripng->update_time = RIPNG_UPDATE_TIMER_DEFAULT; @@ -2507,17 +2512,8 @@ DEFUN (no_ripng_timers, return CMD_SUCCESS; } -ALIAS (no_ripng_timers, - no_ripng_timers_val_cmd, - "no timers basic <0-65535> <0-65535> <0-65535>", - NO_STR - "RIPng timers setup\n" - "Basic timer\n" - "Routing table update timer value in second. Default is 30.\n" - "Routing information timeout timer. Default is 180.\n" - "Garbage collection timer. Default is 120.\n") - -DEFUN (show_ipv6_protocols, show_ipv6_protocols_cmd, +DEFUN (show_ipv6_protocols, + show_ipv6_protocols_cmd, "show ipv6 protocols", SHOW_STR IPV6_STR @@ -3043,11 +3039,9 @@ ripng_init () install_element (RIPNG_NODE, &ripng_default_metric_cmd); install_element (RIPNG_NODE, &no_ripng_default_metric_cmd); - install_element (RIPNG_NODE, &no_ripng_default_metric_val_cmd); install_element (RIPNG_NODE, &ripng_timers_cmd); install_element (RIPNG_NODE, &no_ripng_timers_cmd); - install_element (RIPNG_NODE, &no_ripng_timers_val_cmd); #if 0 install_element (RIPNG_NODE, &ripng_update_timer_cmd); install_element (RIPNG_NODE, &no_ripng_update_timer_cmd); diff --git a/ripngd/ripngd.h b/ripngd/ripngd.h index e340eeecc2..70cba3c680 100644 --- a/ripngd/ripngd.h +++ b/ripngd/ripngd.h @@ -358,7 +358,6 @@ extern void ripng_route_map_reset (void); extern void ripng_terminate (void); /* zclient_init() is done by ripng_zebra.c:zebra_init() */ extern void zebra_init(struct thread_master *); -extern void ripng_zclient_start (void); extern void ripng_zclient_reset (void); extern void ripng_offset_init (void); diff --git a/tests/heavy-thread.c b/tests/heavy-thread.c index c2e71c17d6..c43fa76c0e 100644 --- a/tests/heavy-thread.c +++ b/tests/heavy-thread.c @@ -104,7 +104,7 @@ clear_something (struct thread *thread) DEFUN (clear_foo, clear_foo_cmd, - "clear foo .LINE", + "clear foo LINE...", "clear command\n" "arbitrary string\n") { diff --git a/tests/heavy-wq.c b/tests/heavy-wq.c index 2d15dc37bd..97371face1 100644 --- a/tests/heavy-wq.c +++ b/tests/heavy-wq.c @@ -140,7 +140,7 @@ clear_something (struct vty *vty, const char *str) DEFUN (clear_foo, clear_foo_cmd, - "clear foo .LINE", + "clear foo LINE...", "clear command\n" "arbitrary string\n") { diff --git a/tests/heavy.c b/tests/heavy.c index 9af46c88f7..6ba8d9aa6d 100644 --- a/tests/heavy.c +++ b/tests/heavy.c @@ -82,7 +82,7 @@ clear_something (struct vty *vty, const char *str) DEFUN (clear_foo, clear_foo_cmd, - "clear foo .LINE", + "clear foo LINE...", "clear command\n" "arbitrary string\n") { diff --git a/tools/.gitignore b/tools/.gitignore index dd5bf7c67c..066b0887ae 100644 --- a/tools/.gitignore +++ b/tools/.gitignore @@ -3,4 +3,6 @@ *~ *.loT - +.libs +*.o +permutations diff --git a/tools/Makefile.am b/tools/Makefile.am index 125bfee2c2..c5dbba5a8b 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,3 +1,11 @@ +AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib +DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" +AM_CFLAGS = $(WERROR) + +bin_PROGRAMS = permutations +permutations_SOURCES = permutations.c +permutations_LDADD = ../lib/libzebra.la + sbin_SCRIPTS = quagga-reload.py quagga EXTRA_DIST = quagga.service quagga-reload.py quagga diff --git a/tools/alias_destroyer.py b/tools/alias_destroyer.py new file mode 100755 index 0000000000..0eec78e463 --- /dev/null +++ b/tools/alias_destroyer.py @@ -0,0 +1,273 @@ +#!/usr/bin/env python + +import re +import sys +import os +from pprint import pformat, pprint + + +class DEFUN(object): + + def __init__(self, lines): + # name, name_cmd, command_string, help_strings, guts): + self.name = None + self.name_cmd = None + self.command_string = None + self.help_strings = [] + self.guts = [] + self.aliases = [] + + ''' +DEFUN (no_bgp_maxmed_onstartup, + no_bgp_maxmed_onstartup_cmd, + "no bgp max-med on-startup", + NO_STR + BGP_STR + "Advertise routes with max-med\n" + "Effective on a startup\n") + + ''' + state = 'HEADER' + for (line_number, line) in enumerate(lines): + + if state == 'HEADER': + if line_number == 0: + re_name = re.search('DEFUN \((.*),', line.strip()) + self.name = re_name.group(1) + + elif line_number == 1: + self.name_cmd = line.strip()[0:-1] # chop the trailing comma + + elif line_number == 2: + self.command_string = line + state = 'HELP' + + elif state == 'HELP': + if line.strip() == '{': + self.guts.append(line) + state = 'BODY' + else: + self.help_strings.append(line) + + elif state == 'BODY': + if line.rstrip() == '}': + self.guts.append(line) + state = None + else: + self.guts.append(line) + + else: + raise Exception("invalid state %s" % state) + + # print "%d %7s: %s" % (line_number, state, line.rstrip()) + + assert self.command_string, "No command string for\n%s" % pformat(lines) + + def __str__(self): + return self.name + + def dump(self): + lines = [] + + if self.aliases: + lines.append("/*\n") + lines.append(" * CHECK ME - The following ALIASes need to be implemented in this DEFUN\n") + + for alias in self.aliases: + lines.append(" * %s\n" % alias.command_string.strip()) + for line in alias.help_strings: + lines.append(" * %s\n" % line) + lines.append(" *\n") + + lines.append(" */\n") + + lines.append("DEFUN (%s,\n" % self.name) + lines.append(" %s,\n" % self.name_cmd) + lines.append(self.command_string) + lines.extend(self.help_strings) + lines.extend(self.guts) + return ''.join(lines) + + +class ALIAS(object): + + def __init__(self, lines): + self.name = None + self.name_cmd = None + self.command_string = None + self.help_strings = [] + + ''' +ALIAS (no_bgp_maxmed_onstartup, + no_bgp_maxmed_onstartup_period_cmd, + "no bgp max-med on-startup <5-86400>", + NO_STR + BGP_STR + "Advertise routes with max-med\n" + "Effective on a startup\n" + "Time (seconds) period for max-med\n") + ''' + state = 'HEADER' + for (line_number, line) in enumerate(lines): + + if state == 'HEADER': + if line_number == 0: + re_name = re.search('ALIAS \((.*),', line) + + try: + self.name = re_name.group(1) + except AttributeError: + pprint(lines) + raise + + elif line_number == 1: + self.name_cmd = line.strip()[0:-1] # chop the trailing comma + + elif line_number == 2: + self.command_string = line + state = 'HELP' + + elif state == 'HELP': + if line.strip() == '{': + raise Exception("should not see { in an ALIAS") + else: + line = line.strip() + if line.endswith(')'): + line = line[0:-1] # strip the trailing ) + self.help_strings.append(line) + + else: + raise Exception("invalid state %s" % state) + + assert self.command_string, "No command string for\n%s" % pformat(lines) + + def __str__(self): + return self.name_cmd + + +def alias_destroy(filename): + lines = [] + defuns = {} + aliases = {} + + with open(filename, 'r') as fh: + state = None + defun_lines = [] + alias_lines = [] + + for (line_number, line) in enumerate(fh.readlines()): + + if state is None: + if line.startswith('DEFUN ('): + assert line.count(',') == 1, "%d: Too many commas in\n%s" % (line_number, line) + defun_lines.append(line) + state = 'DEFUN_HEADER' + + elif line.startswith('ALIAS ('): + assert line.count(',') == 1, "%d: Too many commas in\n%s" % (line_number, line) + alias_lines.append(line) + state = 'ALIAS_HEADER' + + elif state == 'DEFUN_HEADER': + defun_lines.append(line) + + if line.startswith('DEFUN'): + raise Exception("ERROR on line %d, found DEFUN inside DEFUN" % line_number) + + elif line.startswith('ALIAS'): + raise Exception("ERROR on line %d, found ALIAS inside DEFUN" % line_number) + + elif line.strip() == '{': + state = 'DEFUN_BODY' + + elif state == 'ALIAS_HEADER': + alias_lines.append(line) + + if line.startswith('ALIAS'): + raise Exception("ERROR on line %d, found ALIAS inside ALIAS" % line_number) + + elif line.startswith('DEFUN'): + raise Exception("ERROR on line %d, found DEFUN inside ALIAS" % line_number) + + if line.rstrip().endswith(')'): + new_alias = ALIAS(alias_lines) + aliases[new_alias.name_cmd] = new_alias + state = None + alias_lines = [] + + elif state == 'DEFUN_BODY': + defun_lines.append(line) + + if line.rstrip() == '}': + new_defun = DEFUN(defun_lines) + defuns[new_defun.name] = new_defun + state = None + defun_lines = [] + + # uncomment to debug state machine + print "%5d %12s: %s" % (line_number, state, line.rstrip()) + + lines.append(line) + + + # At this point we know all of the aliases and all of the tokens + # Assign each ALIAS to its parent DEFUN + for alias in aliases.itervalues(): + defun = defuns.get(alias.name) + assert defun, "Could not find DEFUN for %s" % alias + defun.aliases.append(alias) + + # Now write the file but: + # - do not write any ALIASes + # - do not write the install_element for any ALIASes + # - when you write the DEFUN include a comment that contains the ALIAS command strings it needs to cover + with open(filename, 'w') as fh: + state = None + + for line in lines: + + if state is None: + if line.startswith('DEFUN ('): + state = 'DEFUN_HEADER' + re_name = re.search('DEFUN \((.*),', line.strip()) + name = re_name.group(1) + defun = defuns.get(name) + fh.write(defun.dump()) + + elif line.startswith('ALIAS ('): + state = 'ALIAS_HEADER' + + else: + if 'install_element' in line: + # install_element (CONFIG_NODE, &ip_community_list_name_standard_cmd); + re_install_element = re.search('install_element\s*\(\w+,\s*&(.*)\s*\)', line.strip()) + + if re_install_element: + cmd = re_install_element.group(1) + if cmd not in aliases: + fh.write(line) + else: + fh.write(line) + else: + fh.write(line) + + elif state == 'DEFUN_HEADER': + if line.strip() == '{': + state = 'DEFUN_BODY' + + elif state == 'ALIAS_HEADER': + if line.rstrip().endswith(')'): + state = None + + elif state == 'DEFUN_BODY': + if line.rstrip() == '}': + state = None + + +if __name__ == '__main__': + + filename = sys.argv[1] + if os.path.exists(filename): + alias_destroy(filename) + else: + print "ERROR: could not find file %s" % filename diff --git a/tools/argv_translator.py b/tools/argv_translator.py new file mode 100755 index 0000000000..5325969fdf --- /dev/null +++ b/tools/argv_translator.py @@ -0,0 +1,958 @@ +#!/usr/bin/env python + +""" +Usage: + + argv_translator.py rebuild-defuns [<text>] + +Help: + rebuild-defuns : foo + +""" + +# This script did different things at different times as we migrated code +# to quentin's parse engine. The following were its rebuild-defuns phases: +# +# - originally was used to change all of the argv[2] to argv[4]->arg. This +# calculated the new argv index and added the ->arg. +# - next it was used to replace the 4 in argv[4]->arg with an idx_foo variable +# +# idx-logic +# - used to take a command string and build out an idx_ logic skeleton +# + +import argparse +import re +import sys +import os +import subprocess +from collections import OrderedDict +from copy import deepcopy +from pprint import pformat, pprint +from network_docopt import NetworkDocopt, get_network_docopt_info + + +def token_is_variable(line_number, token): + + if token.isdigit(): + return True + + if token.startswith('('): + assert token.endswith(')') or token.endswith(')...'), "%d: token %s should end with )" % (line_number, token) + return True + + if token.startswith('['): + assert token.endswith(']'), "%d: token %s should end with ]" % (line_number, token) + return True + + if token.startswith('<'): + assert token.endswith('>'), "%d: token %s should end with >" % (line_number, token) + return True + + if token.startswith('{'): + # I don't really care about checking for this I just put + # these asserts in here to bug sharpd + assert token.endswith('}'), "%d: token %s should end with }" % (line_number, token) + return True + + assert '|' not in token, "%d: Weird token %s has a | but does not start with [ or (" % (line_number, token) + + if token in ('WORD', + '.LINE', + '.AA:NN', + 'A.B.C.D', + 'A.B.C.D/M', + 'X:X::X:X', + 'X:X::X:X/M', + 'ASN:nn_or_IP-address:nn'): + return True + + # Anything in all caps in a variable + if token.upper() == token: + return True + + re_number_range = re.search('^<\d+-\d+>$', token) + if re_number_range: + return True + + return False + + +def line_to_tokens(line_number, text): + """ + Most of the time whitespace can be used to split tokens + (set|clear) <interface> clagd-enable (no|yes) + + tokens + - (set|clear) + - <interface> + - clagd-enable + - (no|yes) + + But if we are dealing with multiword keywords, such as "soft in", that approach + does not work. We can only split on whitespaces if we are not inside a () or [] + bgp (<ipv4>|<ipv6>|<interface>|*) [soft in|soft out] + + tokens: + - bgp + - (<ipv4>|<ipv6>|<interface>|*) + - [soft in|soft out] + """ + tokens = [] + token_index = 0 + token_text = [] + parens = 0 + curlys = 0 + brackets = 0 + less_greater = 0 + + for char in text: + if char == ' ': + if parens == 0 and brackets == 0 and curlys == 0 and less_greater == 0: + if token_text: + tokens.append(''.join(token_text)) + token_index += 1 + token_text = [] + else: + token_text.append(char) + else: + if char == '(': + parens += 1 + + elif char == ')': + parens -= 1 + + elif char == '[': + brackets += 1 + + elif char == ']': + brackets -= 1 + + elif char == '{': + curlys += 1 + + elif char == '}': + curlys -= 1 + + elif char == '<': + less_greater += 1 + + elif char == '>': + less_greater -= 1 + + if char: + token_text.append(char) + + if token_text: + tokens.append(''.join(token_text)) + + return tokens + + +''' +# No longer used now that all indexes have been updated +def get_argv_translator(line_number, line): + table = {} + line = line.strip() + assert line.startswith('"'), "%d: line does not start with \"\n%s" % (line_number, line) + assert line.endswith('",'), "%d: line does not end with \",\n%s" % (line_number, line) + + line = line[1:-2] + + funky_chars = ('+', '"') + for char in funky_chars: + if char in line: + raise Exception("%d: Add support for tokens in\n%s\n\nsee BGP_INSTANCE_CMD down below" % (line_number, line)) + + old_style_index = 0 + for (token_index, token) in enumerate(line_to_tokens(line)): + if not token: + continue + + if token_is_variable(line_number, token): + # print "%s is a token" % token + table[old_style_index] = token_index + old_style_index += 1 + else: + # print "%s is NOT a token" % token + pass + + return table +''' + +def get_command_string_variable_indexes(line_number, line): + indexes = {} + + line = line.strip() + assert line.startswith('"'), "%d: line does not start with \"\n%s" % (line_number, line) + assert line.endswith('",'), "%d: line does not end with \",\n%s" % (line_number, line) + line = line[1:-2] + max_index = 0 + + for (token_index, token) in enumerate(line_to_tokens(line_number, line)): + if not token: + raise Exception("%d: empty token" % line_number) + + if token_is_variable(line_number, token): + # print "%s is a token" % token + indexes[token_index] = True + max_index = token_index + + return (max_index, indexes) + + +def get_token_index_variable_name(line_number, token): + + re_range = re.search('\(\d+-\d+\)', token) + + if token.startswith('['): + assert token.endswith(']'), "Token %s should end with ]" % token + token = token[1:-1] + + if token.startswith('<'): + assert token.endswith('>'), "Token %s should end with >" % token + token = token[1:-1] + + if token == 'A.B.C.D': + return 'idx_ipv4' + + elif token == 'A.B.C.D/M': + return 'idx_ipv4_prefixlen' + + elif token == 'X:X::X:X': + return 'idx_ipv6' + + elif token == 'X:X::X:X/M': + return 'idx_ipv6_prefixlen' + + elif token == 'ASN:nn_or_IP-address:nn': + return 'idx_ext_community' + + elif token == '.AA:NN': + return 'idx_community' + + elif token == 'WORD': + return 'idx_word' + + elif token == 'json': + return 'idx_json' + + elif token == '.LINE': + return 'idx_regex' + + elif token == 'A.B.C.D|INTERFACE': + return 'idx_ipv4_ifname' + + elif token == 'A.B.C.D|INTERFACE|null0': + return 'idx_ipv4_ifname_null' + + elif token == 'X:X::X:X|INTERFACE': + return 'idx_ipv6_ifname' + + elif token == 'reject|blackhole': + return 'idx_reject_blackhole' + + elif token == 'route-map NAME': + return 'idx_route_map' + + elif token == 'recv|send|detail': + return 'idx_recv_send' + + elif token == 'recv|send': + return 'idx_recv_send' + + elif token == 'up|down': + return 'idx_up_down' + + elif token == 'off-link': + return 'idx_off_link' + + elif token == 'no-autoconfig': + return 'idx_no_autoconfig' + + elif token == 'router-address': + return 'idx_router_address' + + elif token == 'high|medium|low': + return 'idx_high_medium_low' + + elif token == '(0-4294967295)|infinite': + return 'idx_number_infinite' + + elif token == '(1-199)|(1300-2699)|WORD': + return 'idx_acl' + + elif token == 'A.B.C.D|X:X::X:X': + return 'idx_ip' + + elif token == 'in|out': + return 'idx_in_out' + + elif token == 'deny|permit': + return 'idx_permit_deny' + + elif token == 'view|vrf': + return 'idx_view_vrf' + + elif token == 'unicast|multicast': + return 'idx_safi' + + elif token == 'bestpath|multipath': + return 'idx_bestpath' + + elif token == 'egp|igp|incomplete': + return 'idx_origin' + + elif token == 'cisco|zebra' or token == 'cisco|ibm|shortcut|standard': + return 'idx_vendor' + + elif token == 'as-set|no-as-set': + return 'idx_as_set' + + elif token == 'confed|missing-as-worst': + return 'idx_med_knob' + + elif token == 'both|send|receive' or token == 'send|recv': + return 'idx_send_recv' + + elif token == 'both|extended|standard' or token == '1|2': + return 'idx_type' + + elif token == 'A.B.C.D|WORD' or token == 'A.B.C.D/M|WORD': + return 'idx_ipv4_word' + + elif token == 'advertise-queue|advertised-routes|packet-queue': + return 'idx_type' + + elif token == 'ospf|table': + return 'idx_ospf_table' + + elif token == 'as-path|next-hop|med' or token == 'next-hop|med' or token == 'as-path|med' or token == 'as-path|next-hop': + return 'idx_attribute' + + elif token == '(1-4294967295)|external|internal' or token == '(1-4294967295)|internal|external': + return 'idx_remote_as' + + elif token == '(1-500)|WORD' or token == '(1-99)|(100-500)|WORD': + return 'idx_comm_list' + + elif token == 'ipv4|ipv6' or token == 'ip|ipv6': + return 'idx_afi' + + elif token == 'md5|clear' or token == 'null|message-digest' or token == 'md5|text': + return 'idx_encryption' + + elif token == 'IFNAME|default': + return 'idx_ifname' + + elif token == 'type-1|type-2': + return 'idx_external' + + elif token == 'table|intra-area|inter-area|memory': + return 'idx_type' + + elif token == 'translate-candidate|translate-never|translate-always': + return 'idx_translate' + + elif token == 'intra-area (1-255)|inter-area (1-255)|external (1-255)': + return 'idx_area_distance' + + elif token == 'metric (0-16777214)|metric-type <1|2>|route-map WORD' or token == 'always|metric (0-16777214)|metric-type <1|2>|route-map WORD': + return 'idx_redist_param' + + elif token == 'default|enable|disable' or token == 'enable|disable': + return 'idx_enable_disable' + + elif token == 'unknown|hello|dbdesc|lsreq|lsupdate|lsack|all' or token == 'hello|dd|ls-request|ls-update|ls-ack|all': + return 'idx_packet' + + elif token == 'router|network|inter-prefix|inter-router|as-external|link|intra-prefix|unknown' or token == 'intra-area|inter-area|external-1|external-2' or token == 'router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix' or token == 'asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as': + return 'idx_lsa' + + elif token == 'broadcast|point-to-point' or token == 'broadcast|non-broadcast|point-to-multipoint|point-to-point': + return 'idx_network' + + elif token == 'A.B.C.D|(0-4294967295)': + return 'idx_ipv4_number' + + elif token == 'narrow|transition|wide': + return 'idx_metric_style' + + elif token == 'area-password|domain-password': + return 'idx_password' + + elif token == 'param': + return 'idx_param' + + elif token == 'advertised-routes|received-routes': + return 'idx_adv_rcvd_routes' + + elif token == 'encap|multicast|unicast|vpn' or token == 'unicast|multicast|vpn|encap': + return 'idx_safi' + + elif token == 'AA:NN|local-AS|no-advertise|no-export': + return 'idx_community' + + elif token == 'all|all-et|updates|updates-et|routes-mrt': + return 'idx_dump_routes' + + elif token == 'A.B.C.D|X:X::X:X|WORD': + return 'idx_peer' + + elif token == 'A.B.C.D/M|X:X::X:X/M': + return 'idx_ipv4_ipv6_prefixlen' + + elif token == 'level-1|level-2' or token == 'level-1|level-1-2|level-2-only': + return 'idx_level' + + elif token == 'metric (0-16777215)|route-map WORD' or token == 'always|metric (0-16777215)|route-map WORD': + return 'idx_metric_rmap' + + elif token == 'urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix': + return 'idx_rpf_lookup_mode' + + elif token == 'hello|joins': + return 'idx_hello_join' + + elif token == 'nocache|wrongvif|wholepkt': + return 'idx_type' + + elif token == 'file|memory|terminal': + return 'idx_type' + + elif token == 'prefix': + return 'idx_prefix' + + elif token == 'A.B.C.D/M|any': + return 'idx_ipv4_any' + + elif token == 'X:X::X:X/M|any': + return 'idx_ipv6_any' + + elif token == '(1-99)|(1300-1999)' or token == '(100-199)|(2000-2699)' or token == '(1-99)|(100-199)|(1300-1999)|(2000-2699)|WORD': + return 'idx_acl' + + elif token == 'kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7': + return 'idx_target' + + + elif token in ('kernel|connected|static|rip|ospf|isis|pim|table', + 'kernel|connected|static|ripng|ospf6|isis|table', + 'kernel|connected|static|rip|isis|bgp|pim|table', + 'kernel|connected|static|rip|ospf|isis|bgp|pim|table', + 'kernel|connected|static|rip|ospf|isis|bgp|pim|table', + 'kernel|connected|static|rip|ospf|isis|bgp|pim|table|any', + 'kernel|connected|static|ripng|ospf6|isis|bgp|table|any', + 'kernel|connected|static|ripng|ospf6|isis|bgp|table', + 'kernel|connected|static|ospf6|isis|bgp|table', + 'kernel|connected|static|ospf|isis|bgp|pim|table', + 'kernel|connected|static|ripng|isis|bgp|table', + # '', + 'zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|pimd', + 'zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd', + 'bgp|ospf|rip|ripng|isis|ospf6|connected|system|kernel|static', + 'kernel|connected|static|rip|ripng|ospf|ospf6|bgp|pim|table'): + return 'idx_protocol' + + elif '|' in token: + raise Exception("%d: what variable name for %s" % (line_number, token)) + + elif re_range: + return 'idx_number' + + elif token.upper() == token: + return 'idx_%s' % token.lower() + + else: + raise Exception("%d: what variable name for %s" % (line_number, token)) + + +def get_command_string_index_variable_table(line_number, line): + """ + Return a table that maps an index position to a variable name such as 'idx_ipv4' + """ + indexes = OrderedDict() + + line = line.strip() + assert line.startswith('"'), "line does not start with \"\n%s" % (line) + assert line.endswith('",'), "line does not end with \",\n%s" % (line) + line = line[1:-2] + max_index = 0 + + for (token_index, token) in enumerate(line_to_tokens(line_number, line)): + if not token: + raise Exception("%d: empty token" % line_number) + + if token_is_variable(line_number, token): + # print "%s is a token" % token + idx_variable_name = get_token_index_variable_name(line_number, token) + count = 0 + for tmp in indexes.itervalues(): + if tmp == idx_variable_name: + count += 1 + elif re.search('^%s_\d+' % idx_variable_name, tmp): + count += 1 + if count: + idx_variable_name = "%s_%d" % (idx_variable_name, count + 1) + indexes[token_index] = idx_variable_name + + return indexes + + +def expand_command_string(line): + + # in the middle + line = line.replace('" CMD_AS_RANGE "', '(1-4294967295)') + line = line.replace('" DYNAMIC_NEIGHBOR_LIMIT_RANGE "', '(1-5000)') + line = line.replace('" BGP_INSTANCE_CMD "', '<view|vrf> WORD') + line = line.replace('" BGP_INSTANCE_ALL_CMD "', '<view|vrf> all') + line = line.replace('" CMD_RANGE_STR(1, MULTIPATH_NUM) "', '(1-255)') + line = line.replace('" QUAGGA_IP_REDIST_STR_BGPD "', '<kernel|connected|static|rip|ospf|isis|pim|table>') + line = line.replace('" QUAGGA_IP6_REDIST_STR_BGPD "', '<kernel|connected|static|ripng|ospf6|isis|table>') + line = line.replace('" OSPF_LSA_TYPES_CMD_STR "', 'asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as') + line = line.replace('" QUAGGA_REDIST_STR_OSPFD "', '<kernel|connected|static|rip|isis|bgp|pim|table>') + line = line.replace('" VRF_CMD_STR "', 'vrf NAME') + line = line.replace('" VRF_ALL_CMD_STR "', 'vrf all') + line = line.replace('" QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA "', '<kernel|connected|static|rip|ospf|isis|bgp|pim|table|any>') + line = line.replace('" QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA "', '<kernel|connected|static|ripng|ospf6|isis|bgp|table|any>') + line = line.replace('" QUAGGA_REDIST_STR_RIPNGD "', '<kernel|connected|static|ospf6|isis|bgp|table>') + line = line.replace('" QUAGGA_REDIST_STR_RIPD "', '<kernel|connected|static|ospf|isis|bgp|pim|table>') + line = line.replace('" QUAGGA_REDIST_STR_OSPF6D "', '<kernel|connected|static|ripng|isis|bgp|table>') + line = line.replace('" QUAGGA_REDIST_STR_ISISD "', '<kernel|connected|static|rip|ripng|ospf|ospf6|bgp|pim|table>') + line = line.replace('" LOG_FACILITIES "', '<kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>') + line = line.replace('" LOG_LEVELS "', ' <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>') + + # endswith + line = line.replace('" CMD_AS_RANGE,', ' (1-4294967295)",') + line = line.replace('" DYNAMIC_NEIGHBOR_LIMIT_RANGE,', ' (1-5000)",') + line = line.replace('" BGP_INSTANCE_CMD,', ' <view|vrf> WORD",') + line = line.replace('" BGP_INSTANCE_ALL_CMD,', ' <view|vrf> all",') + line = line.replace('" CMD_RANGE_STR(1, MULTIPATH_NUM),', '(1-255)",') + line = line.replace('" CMD_RANGE_STR(1, MAXTTL),', '(1-255)",') + line = line.replace('" BFD_CMD_DETECT_MULT_RANGE BFD_CMD_MIN_RX_RANGE BFD_CMD_MIN_TX_RANGE,', '(2-255) (50-60000) (50-60000)",') + line = line.replace('" OSPF_LSA_TYPES_CMD_STR,', + ' asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as",') + line = line.replace('" BGP_UPDATE_SOURCE_REQ_STR,', ' <A.B.C.D|X:X::X:X|WORD>",') + line = line.replace('" BGP_UPDATE_SOURCE_OPT_STR,', ' [A.B.C.D|X:X::X:X|WORD]",') + line = line.replace('" QUAGGA_IP_REDIST_STR_BGPD,', ' <kernel|connected|static|rip|ospf|isis|pim|table>",') + line = line.replace('" QUAGGA_IP6_REDIST_STR_BGPD,', ' <kernel|connected|static|ripng|ospf6|isis|table>",') + line = line.replace('" QUAGGA_REDIST_STR_OSPFD,', ' <kernel|connected|static|rip|isis|bgp|pim|table>",') + line = line.replace('" VRF_CMD_STR,', ' vrf NAME",') + line = line.replace('" VRF_ALL_CMD_STR,', ' vrf all",') + line = line.replace('" QUAGGA_IP_REDIST_STR_ZEBRA,', ' <kernel|connected|static|rip|ospf|isis|bgp|pim|table>",') + line = line.replace('" QUAGGA_IP6_REDIST_STR_ZEBRA,', ' <kernel|connected|static|ripng|ospf6|isis|bgp|table>",') + line = line.replace('" QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA,', ' <kernel|connected|static|rip|ospf|isis|bgp|pim|table|any>",') + line = line.replace('" QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA,', ' <kernel|connected|static|ripng|ospf6|isis|bgp|table|any>",') + line = line.replace('" QUAGGA_REDIST_STR_RIPNGD,', ' <kernel|connected|static|ospf6|isis|bgp|table>",') + line = line.replace('" QUAGGA_REDIST_STR_RIPD,', ' <kernel|connected|static|ospf|isis|bgp|pim|table>",') + line = line.replace('" PIM_CMD_IP_MULTICAST_ROUTING,', ' ip multicast-routing",') + line = line.replace('" PIM_CMD_IP_IGMP_QUERY_INTERVAL,', ' ip igmp query-interval",') + line = line.replace('" PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC,', ' ip igmp query-max-response-time-dsec",') + line = line.replace('" PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME,', ' ip igmp query-max-response-time",') + line = line.replace('" QUAGGA_REDIST_STR_OSPF6D,', ' <kernel|connected|static|ripng|isis|bgp|table>",') + line = line.replace('" QUAGGA_REDIST_STR_ISISD,', ' <kernel|connected|static|rip|ripng|ospf|ospf6|bgp|pim|table>",') + line = line.replace('" LOG_FACILITIES,', ' <kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>",') + line = line.replace('" LOG_LEVELS,', ' <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",') + + # startswith + line = line.replace('LISTEN_RANGE_CMD "', '"bgp listen range <A.B.C.D/M|X:X::X:X/M> ') + line = line.replace('NO_NEIGHBOR_CMD2 "', '"no neighbor <A.B.C.D|X:X::X:X|WORD> ') + line = line.replace('NEIGHBOR_CMD2 "', '"neighbor <A.B.C.D|X:X::X:X|WORD> ') + line = line.replace('NO_NEIGHBOR_CMD "', '"no neighbor <A.B.C.D|X:X::X:X> ') + line = line.replace('NEIGHBOR_CMD "', '"neighbor <A.B.C.D|X:X::X:X> ') + line = line.replace('PIM_CMD_NO "', '"no ') + line = line.replace('PIM_CMD_IP_IGMP_QUERY_INTERVAL "', '"ip igmp query-interval ') + line = line.replace('PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME "', '"ip igmp query-max-response-time ') + line = line.replace('PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC "', '"ip igmp query-max-response-time-dsec ') + line = line.replace('LOG_LEVELS "', '"<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging> ') + + # solo + line = line.replace('NO_NEIGHBOR_CMD2,', '"no neighbor <A.B.C.D|X:X::X:X|WORD>",') + line = line.replace('NEIGHBOR_CMD2,', '"neighbor <A.B.C.D|X:X::X:X|WORD>",') + line = line.replace('NO_NEIGHBOR_CMD,', '"no neighbor <A.B.C.D|X:X::X:X>",') + line = line.replace('NEIGHBOR_CMD,', '"neighbor <A.B.C.D|X:X::X:X>",') + line = line.replace('PIM_CMD_IP_MULTICAST_ROUTING,', '"ip multicast-routing",') + + if line.rstrip().endswith('" ,'): + line = line.replace('" ,', '",') + + # compress duplicate white spaces + re_space = re.search('^(\s*).*(\s*)$', line) + line = re_space.group(1) + ' '.join(line.split()) + re_space.group(2) + + return line + + +class DEFUN(object): + + def __init__(self, line_number, command_string_expanded, lines): + # name, name_cmd, command_string, help_strings, guts): + self.line_number = line_number + self.name = None + self.name_cmd = None + self.command_string = None + self.command_string_expanded = command_string_expanded + self.help_strings = [] + self.guts = [] + + ''' +DEFUN (no_bgp_maxmed_onstartup, + no_bgp_maxmed_onstartup_cmd, + "no bgp max-med on-startup", + NO_STR + BGP_STR + "Advertise routes with max-med\n" + "Effective on a startup\n") + + ''' + state = 'HEADER' + for (line_number, line) in enumerate(lines): + + if state == 'HEADER': + if line_number == 0: + re_name = re.search('DEFUN \((.*),', line.strip()) + self.name = re_name.group(1) + + elif line_number == 1: + self.name_cmd = line.strip()[0:-1] # chop the trailing comma + + elif line_number == 2: + self.command_string = line + state = 'HELP' + + elif state == 'HELP': + if line.strip() == '{': + # self.guts.append(line) + state = 'BODY' + else: + self.help_strings.append(line) + + elif state == 'BODY': + if line.rstrip() == '}': + # self.guts.append(line) + state = None + else: + self.guts.append(line) + + else: + raise Exception("invalid state %s" % state) + + # print "%d %7s: %s" % (line_number, state, line.rstrip()) + + assert self.command_string, "No command string for\n%s" % pformat(lines) + + def __str__(self): + return self.name + + def sanity_check(self): + (max_index, variable_indexes) = get_command_string_variable_indexes(self.line_number, self.command_string_expanded) + + # sanity check that each argv index matches a variable in the command string + for line in self.guts: + if 'argv[' in line and '->arg' in line: + tmp_line = deepcopy(line) + re_argv = re.search('^.*?argv\[(\d+)\]->arg(.*)$', tmp_line) + + while re_argv: + index = int(re_argv.group(1)) + if index not in variable_indexes and index <= max_index: + print "%d: index %s is not a variable in the command string" % (self.line_number, index) + tmp_line = re_argv.group(2) + re_argv = re.search('^.*?argv\[(\d+)\]->arg(.*)$', tmp_line) + + def get_new_command_string(self): + line = self.command_string + # Change <1-255> to (1-255) + # Change (foo|bar) to <foo|bar> + # Change {wazzup} to [wazzup]....there shouldn't be many of these + + line = line.replace('(', '<') + line = line.replace(')', '>') + line = line.replace('{', '[') + line = line.replace('}', ']') + re_range = re.search('^(.*?)<(\d+-\d+)>(.*)$', line) + + # A one off to handle "CMD_RANGE_STR(1, MULTIPATH_NUM)" + if 'CMD_RANGE_STR<' in line: + line = line.replace('CMD_RANGE_STR<', 'CMD_RANGE_STR(') + line = line.replace('>', ')') + + while re_range: + line = "%s(%s)%s" % (re_range.group(1), re_range.group(2), re_range.group(3)) + re_range = re.search('^(.*?)<(\d+-\d+)>(.*)$', line) + + if not line.endswith('\n'): + line += '\n' + + if '|<' in line: + print "%d: ERROR |< is illegal in '%s'" % (self.line_number, line) + + if '|[' in line: + print "%d: ERROR |[ is illegal in '%s'" % (self.line_number, line) + + # compress duplicate whitespaces + re_space = re.search('^(\s*).*(\s*)$', line) + line = re_space.group(1) + ' '.join(line.split()) + re_space.group(2) + + ''' + # I ran this once and cleaned them all up...this spews many + # false positives so we don't want to leave this on + for token in line_to_tokens(self.line_number, line): + token = token.strip() + + if token.endswith('",'): + token = token[0:-2] + + if token.startswith('[') and '|' in token: + if not token.startswith('[<') or not token.endswith('>]'): + print "%s: suspend token '%s'" % (self.line_number, token) + ''' + + return line + + def get_used_idx_variables(self, idx_table): + used = {} + + # sanity check that each argv index matches a variable in the command string + for line in self.guts: + if 'argv[' in line and '->arg' in line: + tmp_line = deepcopy(line) + re_argv = re.search('^.*?argv\[(\w+)\]->arg(.*)$', tmp_line) + + while re_argv: + index = re_argv.group(1) + + if index.isdigit(): + index = int(index) + if index in idx_table: + used[index] = idx_table[index] + else: + print "%d: could not find idx variable for %d" % (self.line_number, index) + else: + for (key, value) in idx_table.iteritems(): + if value == index: + used[key] = value + break + + tmp_line = re_argv.group(2) + re_argv = re.search('^.*?argv\[(\w+)\]->arg(.*)$', tmp_line) + + return used + + def uses_argc(self): + for line in self.guts: + if 'CHECK ME argc referenced below' in line: + return False + + if 'use_json (argc, argv)' in line: + continue + + if 'use_json(argc, argv)' in line: + continue + + if 'bgp_get_argv_vrf (argc,)' in line: + continue + + if 'bgp_get_argv_afi_safi (argc,' in line: + continue + + if 'zebra_vty_ip_route_tdv_helper (argc,' in line: + continue + + if 'argc' in line: + return True + return False + + def dump(self): + # new_command_string = self.get_new_command_string() + # new_command_string_expanded = expand_command_string(new_command_string) + new_command_string_expanded = self.get_new_command_string() + lines = [] + + lines.append("DEFUN (%s,\n" % self.name) + lines.append(" %s,\n" % self.name_cmd) + # lines.append(new_command_string) + lines.append(new_command_string_expanded) + lines.extend(self.help_strings) + lines.append('{\n') + + # if self.uses_argc(): + # lines.append(" /* CHECK ME argc referenced below */\n") + lines.extend(self.guts) + + ''' + This is no longer used but was used to do the "- next it was used to + replace the 4 in argv[4]->arg with an idx_foo variable" run mentioned + at the top of this file. + + # only print the variables that will be used else we get a compile error + idx_table = get_command_string_index_variable_table(self.line_number, new_command_string_expanded) + idx_table_used = self.get_used_idx_variables(idx_table) + + for index in sorted(idx_table_used.keys()): + idx_variable = idx_table_used[index] + lines.append(" int %s = %d;\n" % (idx_variable, index)) + + # sanity check that each argv index matches a variable in the command string + for line in self.guts: + if line.startswith(' int idx_'): + pass + elif 'argv[' in line and '->arg' in line: + for (index, idx_variable) in idx_table.iteritems(): + line = line.replace("argv[%d]->arg" % index, "argv[%s]->arg" % idx_variable) + lines.append(line) + else: + lines.append(line) + ''' + + lines.append('}\n') + return ''.join(lines) + + +def update_argvs(filename): + lines = [] + + with open(filename, 'r') as fh: + state = None + defun_line_number = None + cmd_string = None + # argv_translator = {} + # print_translator = False + variable_indexes = {} + max_index = 0 + defun_lines = [] + defuns = {} + command_string = None + + for (line_number, line) in enumerate(fh.readlines()): + # new_line = line + + if state is None: + if line.startswith('DEFUN ('): + assert line.count(',') == 1, "%d: Too many commas in\n%s" % (line_number, line) + state = 'DEFUN_HEADER' + defun_line_number = line_number + defun_lines.append(line) + + elif state == 'DEFUN_HEADER': + defun_lines.append(line) + + if line.startswith('DEFUN'): + raise Exception("ERROR on line %d, found DEFUN inside DEFUN" % line_number) + + elif line.startswith('ALIAS'): + raise Exception("ERROR on line %d, found ALIAS inside DEFUN" % line_number) + + elif line.strip() == '{': + state = 'DEFUN_BODY' + + elif line_number == defun_line_number + 2: + line = expand_command_string(line) + command_string = line + + ''' + # No longer used now that all indexes have been updated + argv_translator = get_argv_translator(line_number, line) + print_translator = True + ''' + + elif state == 'DEFUN_BODY': + defun_lines.append(line) + + if line.rstrip() == '}': + new_defun = DEFUN(defun_line_number, command_string, defun_lines) + defuns[new_defun.name] = new_defun + state = None + command_string = None + defun_lines = [] + + # cmd_string = None + # defun_line_number = None + # argv_translator = {} + + ''' + # No longer used now that all indexes have been updated + elif 'argv[' in new_line and '->arg' not in new_line: + for index in reversed(argv_translator.keys()): + old_argv = "argv[%d]" % index + new_argv = "argv[%d]->arg" % argv_translator[index] + new_line = new_line.replace(old_argv, new_argv) + ''' + + # uncomment to debug state machine + # print "%5d %12s: %s" % (line_number, state, line.rstrip()) + + ''' + # No longer used now that all indexes have been updated + if print_translator: + print "%s\n" % pformat(argv_translator) + print_translator = False + ''' + + lines.append(line) + + for defun in defuns.itervalues(): + defun.sanity_check() + + # Now write the file but allow the DEFUN object to update the contents of the DEFUN () + with open(filename, 'w') as fh: + state = None + + for (line_number, line) in enumerate(lines): + + if state is None: + if 'The following ALIASes need to be implemented in this DEFUN' in line: + state = 'CHANGE ME' + fh.write(line) + + elif line.startswith('DEFUN ('): + state = 'DEFUN_HEADER' + re_name = re.search('DEFUN \((.*),', line.strip()) + name = re_name.group(1) + defun = defuns.get(name) + fh.write(defun.dump()) + else: + fh.write(line) + + elif state == 'CHANGE ME': + if line.strip() == '*/': + state = None + fh.write(line) + elif line.strip().startswith('* ') and not line.strip().startswith('* '): + new_line = expand_command_string(line[3:]) # chop the leading " * " + fh.write(" * %s" % new_line) + else: + fh.write(line) + + elif state == 'DEFUN_HEADER': + if line.strip() == '{': + state = 'DEFUN_BODY' + + elif state == 'DEFUN_BODY': + if line.rstrip() == '}': + state = None + + # uncomment to debug state machine + # print "%5d %12s: %s" % (line_number, state, line.rstrip()) + + +if __name__ == '__main__': + (print_options, ended_with_space, sys.argv) = get_network_docopt_info(sys.argv) + cli = NetworkDocopt(__doc__) + + if print_options: + cli.print_options(ended_with_space) + else: + cli.run() + + if cli.get('rebuild-defuns'): + if cli.get('<text>'): + filename = cli.get('<text>') + update_argvs(filename) + + else: + output = subprocess.check_output("grep -l DEFUN *.c", shell=True).splitlines() + for filename in output: + filename = filename.strip() + print "crunching %s" % filename + update_argvs(filename) diff --git a/tools/permutations.c b/tools/permutations.c new file mode 100644 index 0000000000..49f9416b21 --- /dev/null +++ b/tools/permutations.c @@ -0,0 +1,113 @@ +/* + * Generates all possible matching inputs for a command string. + * -- + * Copyright (C) 2016 Cumulus Networks, Inc. + * + * This file is part of GNU Zebra. + * + * GNU Zebra is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * GNU Zebra is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Zebra; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include "command.h" +#include "graph.h" +#include "command_parse.h" +#include "vector.h" + +#define USAGE "usage: permutations <cmdstr>" + +void +permute (struct graph_node *); +void +pretty_print_graph (struct graph_node *start, int level); + +int main (int argc, char *argv[]) +{ + if (argc < 2) + { + fprintf(stdout, USAGE"\n"); + exit(EXIT_SUCCESS); + } + struct cmd_element *cmd = calloc (1, sizeof (struct cmd_element)); + cmd->string = strdup(argv[1]); + + struct graph *graph = graph_new(); + struct cmd_token *token = new_cmd_token (START_TKN, cmd->attr, NULL, NULL); + graph_new_node (graph, token, NULL); + command_parse_format (graph, cmd); + + permute (vector_slot (graph->nodes, 0)); + pretty_print_graph (vector_slot (graph->nodes, 0), 0); +} + +void +permute (struct graph_node *start) +{ + static struct list *position = NULL; + if (!position) position = list_new (); + + // recursive dfs + listnode_add (position, start); + for (unsigned int i = 0; i < vector_active (start->to); i++) + { + struct graph_node *gn = vector_slot (start->to, i); + struct cmd_token *tok = gn->data; + if (tok->type == END_TKN) + { + struct graph_node *gnn; + struct listnode *ln; + for (ALL_LIST_ELEMENTS_RO (position,ln,gnn)) + { + struct cmd_token *tt = gnn->data; + if (tt->type < SELECTOR_TKN) + fprintf (stdout, "%s ", tt->text); + } + fprintf (stdout, "\n"); + } + else + permute (gn); + } + list_delete_node (position, listtail(position)); +} + +void +pretty_print_graph (struct graph_node *start, int level) +{ + // print this node + struct cmd_token *tok = start->data; + fprintf (stdout, "%s[%d] ", tok->text, tok->type); + + int numto = vector_active (start->to); + if (numto) + { + if (numto > 1) + fprintf (stdout, "\n"); + for (unsigned int i = 0; i < vector_active (start->to); i++) + { + struct graph_node *adj = vector_slot (start->to, i); + // if we're listing multiple children, indent! + if (numto > 1) + for (int j = 0; j < level+1; j++) + fprintf (stdout, " "); + // if this node is a vararg, just print * + if (adj == start) + fprintf (stdout, "*"); + else + pretty_print_graph (adj, numto > 1 ? level+1 : level); + } + } + else + fprintf(stdout, "\n"); +} diff --git a/tools/quagga_parser_to_network_docopt.py b/tools/quagga_parser_to_network_docopt.py new file mode 100755 index 0000000000..89a6fd7985 --- /dev/null +++ b/tools/quagga_parser_to_network_docopt.py @@ -0,0 +1,1327 @@ +#!/usr/bin/env python + +""" +The primary use case of this tool is to print a network-docopt compatible +docstring that covers all bgp and ospf commands in quagga. +""" + +import argparse +import logging +import os +import re +import sys +from pprint import pprint, pformat + +# All of the clear commands in bgp_clear_ignore will be covered by these clear commands: +# quagga clear bgp (<ipv4>|<ipv6>|<interface>|*) +# quagga clear bgp (<ipv4>|<ipv6>|<interface>|*) soft [in|out] +# quagga clear bgp prefix <ipv4/prefixlen> +bgp_clear_ignore = """ quagga clear bgp (<ipv4>|<ipv6>|<interface>) + quagga clear bgp (<ipv4>|<ipv6>|<interface>) in + quagga clear bgp (<ipv4>|<ipv6>|<interface>) in prefix-filter + quagga clear bgp (<ipv4>|<ipv6>|<interface>) out + quagga clear bgp (<ipv4>|<ipv6>|<interface>) soft + quagga clear bgp (<ipv4>|<ipv6>|<interface>) soft in + quagga clear bgp (<ipv4>|<ipv6>|<interface>) soft out + quagga clear bgp * + quagga clear bgp * in + quagga clear bgp * in prefix-filter + quagga clear bgp * out + quagga clear bgp * soft + quagga clear bgp * soft in + quagga clear bgp * soft out + quagga clear bgp <1-4294967295> + quagga clear bgp <1-4294967295> in + quagga clear bgp <1-4294967295> in prefix-filter + quagga clear bgp <1-4294967295> out + quagga clear bgp <1-4294967295> soft + quagga clear bgp <1-4294967295> soft in + quagga clear bgp <1-4294967295> soft out + quagga clear bgp BGP_INSTANCE_CMD * + quagga clear bgp BGP_INSTANCE_CMD * soft + quagga clear bgp BGP_INSTANCE_CMD * soft in + quagga clear bgp BGP_INSTANCE_CMD * soft out + quagga clear bgp external + quagga clear bgp external in + quagga clear bgp external in prefix-filter + quagga clear bgp external out + quagga clear bgp external soft + quagga clear bgp external soft in + quagga clear bgp external soft out + quagga clear bgp ipv6 (<ipv4>|<ipv6>|<interface>) + quagga clear bgp ipv6 (<ipv4>|<ipv6>|<interface>) in + quagga clear bgp ipv6 (<ipv4>|<ipv6>|<interface>) in prefix-filter + quagga clear bgp ipv6 (<ipv4>|<ipv6>|<interface>) out + quagga clear bgp ipv6 (<ipv4>|<ipv6>|<interface>) soft + quagga clear bgp ipv6 (<ipv4>|<ipv6>|<interface>) soft in + quagga clear bgp ipv6 (<ipv4>|<ipv6>|<interface>) soft out + quagga clear bgp ipv6 (unicast|multicast) prefix <ipv6/prefixlen> + quagga clear bgp ipv6 * + quagga clear bgp ipv6 * in + quagga clear bgp ipv6 * in prefix-filter + quagga clear bgp ipv6 * out + quagga clear bgp ipv6 * soft + quagga clear bgp ipv6 * soft in + quagga clear bgp ipv6 * soft out + quagga clear bgp ipv6 <1-4294967295> + quagga clear bgp ipv6 <1-4294967295> in + quagga clear bgp ipv6 <1-4294967295> in prefix-filter + quagga clear bgp ipv6 <1-4294967295> out + quagga clear bgp ipv6 <1-4294967295> soft + quagga clear bgp ipv6 <1-4294967295> soft in + quagga clear bgp ipv6 <1-4294967295> soft out + quagga clear bgp ipv6 external + quagga clear bgp ipv6 external WORD in + quagga clear bgp ipv6 external WORD out + quagga clear bgp ipv6 external in prefix-filter + quagga clear bgp ipv6 external soft + quagga clear bgp ipv6 external soft in + quagga clear bgp ipv6 external soft out + quagga clear bgp ipv6 peer-group WORD + quagga clear bgp ipv6 peer-group WORD in + quagga clear bgp ipv6 peer-group WORD in prefix-filter + quagga clear bgp ipv6 peer-group WORD out + quagga clear bgp ipv6 peer-group WORD soft + quagga clear bgp ipv6 peer-group WORD soft in + quagga clear bgp ipv6 peer-group WORD soft out + quagga clear bgp peer-group WORD + quagga clear bgp peer-group WORD in + quagga clear bgp peer-group WORD in prefix-filter + quagga clear bgp peer-group WORD out + quagga clear bgp peer-group WORD soft + quagga clear bgp peer-group WORD soft in + quagga clear bgp peer-group WORD soft out + quagga clear ip bgp (<ipv4>|<interface>) in + quagga clear ip bgp (<ipv4>|<interface>) in prefix-filter + quagga clear ip bgp (<ipv4>|<interface>) ipv4 (unicast|multicast) in + quagga clear ip bgp (<ipv4>|<interface>) ipv4 (unicast|multicast) in prefix-filter + quagga clear ip bgp (<ipv4>|<interface>) ipv4 (unicast|multicast) out + quagga clear ip bgp (<ipv4>|<interface>) ipv4 (unicast|multicast) soft + quagga clear ip bgp (<ipv4>|<interface>) ipv4 (unicast|multicast) soft in + quagga clear ip bgp (<ipv4>|<interface>) ipv4 (unicast|multicast) soft out + quagga clear ip bgp (<ipv4>|<interface>) out + quagga clear ip bgp (<ipv4>|<interface>) soft + quagga clear ip bgp (<ipv4>|<interface>) soft in + quagga clear ip bgp (<ipv4>|<interface>) soft out + quagga clear ip bgp (<ipv4>|<interface>) vpnv4 unicast in + quagga clear ip bgp (<ipv4>|<interface>) vpnv4 unicast out + quagga clear ip bgp (<ipv4>|<interface>) vpnv4 unicast soft + quagga clear ip bgp (<ipv4>|<interface>) vpnv4 unicast soft in + quagga clear ip bgp (<ipv4>|<interface>) vpnv4 unicast soft out + quagga clear ip bgp (<ipv4>|<ipv6>|<interface>) + quagga clear ip bgp * + quagga clear ip bgp * in + quagga clear ip bgp * in prefix-filter + quagga clear ip bgp * ipv4 (unicast|multicast) in + quagga clear ip bgp * ipv4 (unicast|multicast) in prefix-filter + quagga clear ip bgp * ipv4 (unicast|multicast) out + quagga clear ip bgp * ipv4 (unicast|multicast) soft + quagga clear ip bgp * ipv4 (unicast|multicast) soft in + quagga clear ip bgp * ipv4 (unicast|multicast) soft out + quagga clear ip bgp * out + quagga clear ip bgp * soft + quagga clear ip bgp * soft in + quagga clear ip bgp * soft out + quagga clear ip bgp * vpnv4 unicast in + quagga clear ip bgp * vpnv4 unicast out + quagga clear ip bgp * vpnv4 unicast soft + quagga clear ip bgp * vpnv4 unicast soft in + quagga clear ip bgp * vpnv4 unicast soft out + quagga clear ip bgp <1-4294967295> + quagga clear ip bgp <1-4294967295> in + quagga clear ip bgp <1-4294967295> in prefix-filter + quagga clear ip bgp <1-4294967295> ipv4 (unicast|multicast) in + quagga clear ip bgp <1-4294967295> ipv4 (unicast|multicast) in prefix-filter + quagga clear ip bgp <1-4294967295> ipv4 (unicast|multicast) out + quagga clear ip bgp <1-4294967295> ipv4 (unicast|multicast) soft + quagga clear ip bgp <1-4294967295> ipv4 (unicast|multicast) soft in + quagga clear ip bgp <1-4294967295> ipv4 (unicast|multicast) soft out + quagga clear ip bgp <1-4294967295> out + quagga clear ip bgp <1-4294967295> soft + quagga clear ip bgp <1-4294967295> soft in + quagga clear ip bgp <1-4294967295> soft out + quagga clear ip bgp <1-4294967295> vpnv4 unicast in + quagga clear ip bgp <1-4294967295> vpnv4 unicast out + quagga clear ip bgp <1-4294967295> vpnv4 unicast soft + quagga clear ip bgp <1-4294967295> vpnv4 unicast soft in + quagga clear ip bgp <1-4294967295> vpnv4 unicast soft out + quagga clear ip bgp BGP_INSTANCE_CMD * + quagga clear ip bgp BGP_INSTANCE_CMD * in prefix-filter + quagga clear ip bgp BGP_INSTANCE_CMD * ipv4 (unicast|multicast) in prefix-filter + quagga clear ip bgp BGP_INSTANCE_CMD * ipv4 (unicast|multicast) soft + quagga clear ip bgp BGP_INSTANCE_CMD * ipv4 (unicast|multicast) soft in + quagga clear ip bgp BGP_INSTANCE_CMD * ipv4 (unicast|multicast) soft out + quagga clear ip bgp BGP_INSTANCE_CMD * soft + quagga clear ip bgp BGP_INSTANCE_CMD * soft in + quagga clear ip bgp BGP_INSTANCE_CMD * soft out + quagga clear ip bgp dampening + quagga clear ip bgp dampening <ipv4/prefixlen> + quagga clear ip bgp dampening <ipv4> + quagga clear ip bgp dampening <ipv4> <ipv4> + quagga clear ip bgp external + quagga clear ip bgp external in + quagga clear ip bgp external in prefix-filter + quagga clear ip bgp external ipv4 (unicast|multicast) in + quagga clear ip bgp external ipv4 (unicast|multicast) in prefix-filter + quagga clear ip bgp external ipv4 (unicast|multicast) out + quagga clear ip bgp external ipv4 (unicast|multicast) soft + quagga clear ip bgp external ipv4 (unicast|multicast) soft in + quagga clear ip bgp external ipv4 (unicast|multicast) soft out + quagga clear ip bgp external out + quagga clear ip bgp external soft + quagga clear ip bgp external soft in + quagga clear ip bgp external soft out + quagga clear ip bgp peer-group WORD + quagga clear ip bgp peer-group WORD in + quagga clear ip bgp peer-group WORD in prefix-filter + quagga clear ip bgp peer-group WORD ipv4 (unicast|multicast) in + quagga clear ip bgp peer-group WORD ipv4 (unicast|multicast) in prefix-filter + quagga clear ip bgp peer-group WORD ipv4 (unicast|multicast) out + quagga clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft + quagga clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft in + quagga clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft out + quagga clear ip bgp peer-group WORD out + quagga clear ip bgp peer-group WORD soft + quagga clear ip bgp peer-group WORD soft in + quagga clear ip bgp peer-group WORD soft out + quagga clear ip bgp prefix <ipv4/prefixlen>""".splitlines() + +# All of the debug commands in bgp_debug_ignore will be covered by these debug commands: +# quagga (add|del) debug bgp bestpath <ip/prefixlen> +# quagga (add|del) debug bgp keepalives (<ipv4>|<ipv6>|<interface>) +# quagga (add|del) debug bgp neighbor-events (<ipv4>|<ipv6>|<interface>) +# quagga (add|del) debug bgp nht +# quagga (add|del) debug bgp update-groups +# quagga (add|del) debug bgp updates prefix <ip/prefixlen> +# quagga (add|del) debug bgp zebra prefix <ip/prefixlen> +bgp_debug_ignore = """ quagga debug bgp as4 + quagga debug bgp as4 segment + quagga debug bgp bestpath (<ipv4/prefixlen>|<ipv6/prefixlen>) + quagga debug bgp keepalives + quagga debug bgp keepalives (<ipv4>|<ipv6>|<interface>) + quagga debug bgp neighbor-events + quagga debug bgp neighbor-events (<ipv4>|<ipv6>|<interface>) + quagga debug bgp nht + quagga debug bgp update-groups + quagga debug bgp updates + quagga debug bgp updates (in|out) + quagga debug bgp updates (in|out) (<ipv4>|<ipv6>|<interface>) + quagga debug bgp updates prefix (<ipv4/prefixlen>|<ipv6/prefixlen>) + quagga debug bgp zebra + quagga debug bgp zebra prefix (<ipv4/prefixlen>|<ipv6/prefixlen>)""".splitlines() + + +bgp_show_ignore = """ quagga show bgp (ipv4) (vpnv4) statistics + quagga show bgp (ipv4|ipv6) (unicast|multicast) statistics + quagga show bgp (ipv4|ipv6) (unicast|multicast) update-groups + quagga show bgp (ipv4|ipv6) (unicast|multicast) update-groups (advertise-queue|advertised-routes|packet-queue) + quagga show bgp (ipv4|ipv6) (unicast|multicast) update-groups SUBGROUP-ID + quagga show bgp (ipv4|ipv6) (unicast|multicast) update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue) + quagga show bgp <ipv6/prefixlen> (bestpath|multipath) [json] + quagga show bgp <ipv6/prefixlen> [json] + quagga show bgp <ipv6/prefixlen> longer-prefixes + quagga show bgp <ipv6> (bestpath|multipath) [json] + quagga show bgp <ipv6> [json] + quagga show bgp BGP_INSTANCE_CMD (ipv4) (vpnv4) statistics + quagga show bgp BGP_INSTANCE_CMD (ipv4|ipv6) (unicast|multicast) community + quagga show bgp BGP_INSTANCE_CMD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) + quagga show bgp BGP_INSTANCE_CMD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show bgp BGP_INSTANCE_CMD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show bgp BGP_INSTANCE_CMD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show bgp BGP_INSTANCE_CMD (ipv4|ipv6) (unicast|multicast) neighbors (<ipv4>|<ipv6>|<interface>) (advertised-routes|received-routes) [json] + quagga show bgp BGP_INSTANCE_CMD (ipv4|ipv6) (unicast|multicast) statistics + quagga show bgp BGP_INSTANCE_CMD <ipv6/prefixlen> (bestpath|multipath) [json] + quagga show bgp BGP_INSTANCE_CMD <ipv6/prefixlen> [json] + quagga show bgp BGP_INSTANCE_CMD <ipv6/prefixlen> longer-prefixes + quagga show bgp BGP_INSTANCE_CMD <ipv6> (bestpath|multipath) [json] + quagga show bgp BGP_INSTANCE_CMD <ipv6> [json] + quagga show bgp BGP_INSTANCE_CMD [json] + quagga show bgp BGP_INSTANCE_CMD community-list (<1-500>|WORD) + quagga show bgp BGP_INSTANCE_CMD filter-list WORD + quagga show bgp BGP_INSTANCE_CMD ipv6 (unicast|multicast) summary [json] + quagga show bgp BGP_INSTANCE_CMD ipv6 <ipv6/prefixlen> (bestpath|multipath) [json] + quagga show bgp BGP_INSTANCE_CMD ipv6 <ipv6/prefixlen> [json] + quagga show bgp BGP_INSTANCE_CMD ipv6 <ipv6/prefixlen> longer-prefixes + quagga show bgp BGP_INSTANCE_CMD ipv6 <ipv6> (bestpath|multipath) [json] + quagga show bgp BGP_INSTANCE_CMD ipv6 <ipv6> [json] + quagga show bgp BGP_INSTANCE_CMD ipv6 [json] + quagga show bgp BGP_INSTANCE_CMD ipv6 community-list (<1-500>|WORD) + quagga show bgp BGP_INSTANCE_CMD ipv6 filter-list WORD + quagga show bgp BGP_INSTANCE_CMD ipv6 neighbors (<ipv4>|<ipv6>|<interface>) [json] + quagga show bgp BGP_INSTANCE_CMD ipv6 neighbors (<ipv4>|<ipv6>|<interface>) advertised-routes [json] + quagga show bgp BGP_INSTANCE_CMD ipv6 neighbors (<ipv4>|<ipv6>|<interface>) dampened-routes [json] + quagga show bgp BGP_INSTANCE_CMD ipv6 neighbors (<ipv4>|<ipv6>|<interface>) flap-statistics [json] + quagga show bgp BGP_INSTANCE_CMD ipv6 neighbors (<ipv4>|<ipv6>|<interface>) prefix-counts [json] + quagga show bgp BGP_INSTANCE_CMD ipv6 neighbors (<ipv4>|<ipv6>|<interface>) received prefix-filter [json] + quagga show bgp BGP_INSTANCE_CMD ipv6 neighbors (<ipv4>|<ipv6>|<interface>) received-routes [json] + quagga show bgp BGP_INSTANCE_CMD ipv6 neighbors (<ipv4>|<ipv6>|<interface>) routes [json] + quagga show bgp BGP_INSTANCE_CMD ipv6 neighbors [json] + quagga show bgp BGP_INSTANCE_CMD ipv6 prefix-list WORD + quagga show bgp BGP_INSTANCE_CMD ipv6 route-map WORD + quagga show bgp BGP_INSTANCE_CMD ipv6 summary [json] + quagga show bgp BGP_INSTANCE_CMD neighbors (<ipv4>|<ipv6>|<interface>) [json] + quagga show bgp BGP_INSTANCE_CMD neighbors (<ipv4>|<ipv6>|<interface>) advertised-routes [json] + quagga show bgp BGP_INSTANCE_CMD neighbors (<ipv4>|<ipv6>|<interface>) dampened-routes [json] + quagga show bgp BGP_INSTANCE_CMD neighbors (<ipv4>|<ipv6>|<interface>) flap-statistics [json] + quagga show bgp BGP_INSTANCE_CMD neighbors (<ipv4>|<ipv6>|<interface>) received prefix-filter [json] + quagga show bgp BGP_INSTANCE_CMD neighbors (<ipv4>|<ipv6>|<interface>) received-routes [json] + quagga show bgp BGP_INSTANCE_CMD neighbors (<ipv4>|<ipv6>|<interface>) routes [json] + quagga show bgp BGP_INSTANCE_CMD neighbors [json] + quagga show bgp BGP_INSTANCE_CMD prefix-list WORD + quagga show bgp BGP_INSTANCE_CMD route-map WORD + quagga show bgp BGP_INSTANCE_CMD summary [json] + quagga show bgp BGP_INSTANCE_CMD update-groups + quagga show bgp BGP_INSTANCE_CMD update-groups (advertise-queue|advertised-routes|packet-queue) + quagga show bgp BGP_INSTANCE_CMD update-groups SUBGROUP-ID + quagga show bgp BGP_INSTANCE_CMD update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue) + quagga show bgp [json] + quagga show bgp community + quagga show bgp community (AA:NN|local-AS|no-advertise|no-export) + quagga show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show bgp community-list (<1-500>|WORD) + quagga show bgp community-list (<1-500>|WORD) exact-match + quagga show bgp filter-list WORD + quagga show bgp ipv4 (unicast|multicast) <ipv4/prefixlen> (bestpath|multipath) [json] + quagga show bgp ipv4 (unicast|multicast) <ipv4/prefixlen> [json] + quagga show bgp ipv4 (unicast|multicast) <ipv4> (bestpath|multipath) [json] + quagga show bgp ipv4 (unicast|multicast) <ipv4> [json] + quagga show bgp ipv4 (unicast|multicast) [json] + quagga show bgp ipv4 (unicast|multicast) summary [json] + quagga show bgp ipv6 (unicast|multicast) <ipv6/prefixlen> (bestpath|multipath) [json] + quagga show bgp ipv6 (unicast|multicast) <ipv6/prefixlen> [json] + quagga show bgp ipv6 (unicast|multicast) <ipv6> (bestpath|multipath) [json] + quagga show bgp ipv6 (unicast|multicast) <ipv6> [json] + quagga show bgp ipv6 (unicast|multicast) [json] + quagga show bgp ipv6 (unicast|multicast) summary [json] + quagga show bgp ipv6 <ipv6/prefixlen> (bestpath|multipath) [json] + quagga show bgp ipv6 <ipv6/prefixlen> [json] + quagga show bgp ipv6 <ipv6/prefixlen> longer-prefixes + quagga show bgp ipv6 <ipv6> (bestpath|multipath) [json] + quagga show bgp ipv6 <ipv6> [json] + quagga show bgp ipv6 [json] + quagga show bgp ipv6 community + quagga show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) + quagga show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show bgp ipv6 community-list (<1-500>|WORD) + quagga show bgp ipv6 community-list (<1-500>|WORD) exact-match + quagga show bgp ipv6 filter-list WORD + quagga show bgp ipv6 neighbors (<ipv4>|<ipv6>|<interface>) [json] + quagga show bgp ipv6 neighbors (<ipv4>|<ipv6>|<interface>) advertised-routes [json] + quagga show bgp ipv6 neighbors (<ipv4>|<ipv6>|<interface>) dampened-routes [json] + quagga show bgp ipv6 neighbors (<ipv4>|<ipv6>|<interface>) flap-statistics [json] + quagga show bgp ipv6 neighbors (<ipv4>|<ipv6>|<interface>) prefix-counts [json] + quagga show bgp ipv6 neighbors (<ipv4>|<ipv6>|<interface>) received prefix-filter [json] + quagga show bgp ipv6 neighbors (<ipv4>|<ipv6>|<interface>) received-routes [json] + quagga show bgp ipv6 neighbors (<ipv4>|<ipv6>|<interface>) routes [json] + quagga show bgp ipv6 neighbors [json] + quagga show bgp ipv6 prefix-list WORD + quagga show bgp ipv6 regexp LINE + quagga show bgp ipv6 route-map WORD + quagga show bgp ipv6 summary [json] + quagga show bgp memory + quagga show bgp neighbors (<ipv4>|<ipv6>|<interface>) [json] + quagga show bgp neighbors (<ipv4>|<ipv6>|<interface>) advertised-routes [json] + quagga show bgp neighbors (<ipv4>|<ipv6>|<interface>) dampened-routes [json] + quagga show bgp neighbors (<ipv4>|<ipv6>|<interface>) flap-statistics [json] + quagga show bgp neighbors (<ipv4>|<ipv6>|<interface>) received prefix-filter [json] + quagga show bgp neighbors (<ipv4>|<ipv6>|<interface>) received-routes [json] + quagga show bgp neighbors (<ipv4>|<ipv6>|<interface>) routes [json] + quagga show bgp neighbors [json] + quagga show bgp prefix-list WORD + quagga show bgp regexp LINE + quagga show bgp route-map WORD + quagga show bgp summary [json] + quagga show bgp update-groups + quagga show bgp update-groups (advertise-queue|advertised-routes|packet-queue) + quagga show bgp update-groups SUBGROUP-ID + quagga show bgp update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue) + quagga show bgp view WORD ipv4 (unicast|multicast) summary [json] + quagga show bgp views + quagga show bgp vrfs [json] + quagga show debugging bgp + quagga show ip as-path-access-list + quagga show ip as-path-access-list WORD + quagga show ip bgp <ipv4/prefixlen> (bestpath|multipath) [json] + quagga show ip bgp <ipv4/prefixlen> [json] + quagga show ip bgp <ipv4/prefixlen> longer-prefixes + quagga show ip bgp <ipv4> (bestpath|multipath) [json] + quagga show ip bgp <ipv4> [json] + quagga show ip bgp BGP_INSTANCE_CMD <ipv4/prefixlen> (bestpath|multipath) [json] + quagga show ip bgp BGP_INSTANCE_CMD <ipv4/prefixlen> [json] + quagga show ip bgp BGP_INSTANCE_CMD <ipv4/prefixlen> longer-prefixes + quagga show ip bgp BGP_INSTANCE_CMD <ipv4> (bestpath|multipath) [json] + quagga show ip bgp BGP_INSTANCE_CMD <ipv4> [json] + quagga show ip bgp BGP_INSTANCE_CMD [json] + quagga show ip bgp BGP_INSTANCE_CMD community-list (<1-500>|WORD) + quagga show ip bgp BGP_INSTANCE_CMD filter-list WORD + quagga show ip bgp BGP_INSTANCE_CMD neighbors (<ipv4>|<ipv6>|<interface>) [json] + quagga show ip bgp BGP_INSTANCE_CMD neighbors (<ipv4>|<ipv6>|<interface>) advertised-routes [json] + quagga show ip bgp BGP_INSTANCE_CMD neighbors (<ipv4>|<ipv6>|<interface>) advertised-routes route-map WORD [json] + quagga show ip bgp BGP_INSTANCE_CMD neighbors (<ipv4>|<ipv6>|<interface>) prefix-counts [json] + quagga show ip bgp BGP_INSTANCE_CMD neighbors (<ipv4>|<ipv6>|<interface>) received-routes [json] + quagga show ip bgp BGP_INSTANCE_CMD neighbors (<ipv4>|<ipv6>|<interface>) received-routes route-map WORD [json] + quagga show ip bgp BGP_INSTANCE_CMD neighbors (<ipv4>|<ipv6>|<interface>) routes [json] + quagga show ip bgp BGP_INSTANCE_CMD neighbors [json] + quagga show ip bgp BGP_INSTANCE_CMD nexthop + quagga show ip bgp BGP_INSTANCE_CMD nexthop detail + quagga show ip bgp BGP_INSTANCE_CMD peer-group + quagga show ip bgp BGP_INSTANCE_CMD peer-group WORD + quagga show ip bgp BGP_INSTANCE_CMD prefix-list WORD + quagga show ip bgp BGP_INSTANCE_CMD route-map WORD + quagga show ip bgp BGP_INSTANCE_CMD summary [json] + quagga show ip bgp BGP_INSTANCE_CMD update-groups + quagga show ip bgp BGP_INSTANCE_CMD update-groups (advertise-queue|advertised-routes|packet-queue) + quagga show ip bgp BGP_INSTANCE_CMD update-groups SUBGROUP-ID + quagga show ip bgp BGP_INSTANCE_CMD update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue) + quagga show ip bgp [json] + quagga show ip bgp attribute-info + quagga show ip bgp cidr-only + quagga show ip bgp community + quagga show ip bgp community (AA:NN|local-AS|no-advertise|no-export) + quagga show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show ip bgp community-info + quagga show ip bgp community-list (<1-500>|WORD) + quagga show ip bgp community-list (<1-500>|WORD) exact-match + quagga show ip bgp dampened-paths + quagga show ip bgp filter-list WORD + quagga show ip bgp flap-statistics + quagga show ip bgp flap-statistics <ipv4/prefixlen> + quagga show ip bgp flap-statistics <ipv4/prefixlen> longer-prefixes + quagga show ip bgp flap-statistics <ipv4> + quagga show ip bgp flap-statistics cidr-only + quagga show ip bgp flap-statistics filter-list WORD + quagga show ip bgp flap-statistics prefix-list WORD + quagga show ip bgp flap-statistics regexp LINE + quagga show ip bgp flap-statistics route-map WORD + quagga show ip bgp ipv4 (unicast|multicast) <ipv4/prefixlen> (bestpath|multipath) [json] + quagga show ip bgp ipv4 (unicast|multicast) <ipv4/prefixlen> [json] + quagga show ip bgp ipv4 (unicast|multicast) <ipv4/prefixlen> longer-prefixes + quagga show ip bgp ipv4 (unicast|multicast) <ipv4> [json] + quagga show ip bgp ipv4 (unicast|multicast) [json] + quagga show ip bgp ipv4 (unicast|multicast) cidr-only + quagga show ip bgp ipv4 (unicast|multicast) community + quagga show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) + quagga show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) + quagga show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match + quagga show ip bgp ipv4 (unicast|multicast) filter-list WORD + quagga show ip bgp ipv4 (unicast|multicast) neighbors (<ipv4>|<ipv6>|<interface>) [json] + quagga show ip bgp ipv4 (unicast|multicast) neighbors (<ipv4>|<ipv6>|<interface>) advertised-routes [json] + quagga show ip bgp ipv4 (unicast|multicast) neighbors (<ipv4>|<ipv6>|<interface>) advertised-routes route-map WORD [json] + quagga show ip bgp ipv4 (unicast|multicast) neighbors (<ipv4>|<ipv6>|<interface>) prefix-counts [json] + quagga show ip bgp ipv4 (unicast|multicast) neighbors (<ipv4>|<ipv6>|<interface>) received prefix-filter [json] + quagga show ip bgp ipv4 (unicast|multicast) neighbors (<ipv4>|<ipv6>|<interface>) received-routes [json] + quagga show ip bgp ipv4 (unicast|multicast) neighbors (<ipv4>|<ipv6>|<interface>) received-routes route-map WORD [json] + quagga show ip bgp ipv4 (unicast|multicast) neighbors (<ipv4>|<ipv6>|<interface>) routes [json] + quagga show ip bgp ipv4 (unicast|multicast) neighbors [json] + quagga show ip bgp ipv4 (unicast|multicast) paths + quagga show ip bgp ipv4 (unicast|multicast) prefix-list WORD + quagga show ip bgp ipv4 (unicast|multicast) regexp LINE + quagga show ip bgp ipv4 (unicast|multicast) route-map WORD + quagga show ip bgp ipv4 (unicast|multicast) summary [json] + quagga show ip bgp neighbors (<ipv4>|<ipv6>|<interface>) [json] + quagga show ip bgp neighbors (<ipv4>|<ipv6>|<interface>) advertised-routes [json] + quagga show ip bgp neighbors (<ipv4>|<ipv6>|<interface>) advertised-routes route-map WORD [json] + quagga show ip bgp neighbors (<ipv4>|<ipv6>|<interface>) dampened-routes [json] + quagga show ip bgp neighbors (<ipv4>|<ipv6>|<interface>) flap-statistics [json] + quagga show ip bgp neighbors (<ipv4>|<ipv6>|<interface>) prefix-counts [json] + quagga show ip bgp neighbors (<ipv4>|<ipv6>|<interface>) received prefix-filter [json] + quagga show ip bgp neighbors (<ipv4>|<ipv6>|<interface>) received-routes [json] + quagga show ip bgp neighbors (<ipv4>|<ipv6>|<interface>) received-routes route-map WORD [json] + quagga show ip bgp neighbors (<ipv4>|<ipv6>|<interface>) routes [json] + quagga show ip bgp neighbors [json] + quagga show ip bgp nexthop + quagga show ip bgp nexthop detail + quagga show ip bgp paths + quagga show ip bgp peer-group + quagga show ip bgp peer-group WORD + quagga show ip bgp prefix-list WORD + quagga show ip bgp regexp LINE + quagga show ip bgp route-map WORD + quagga show ip bgp summary [json] + quagga show ip bgp update-groups + quagga show ip bgp update-groups (advertise-queue|advertised-routes|packet-queue) + quagga show ip bgp update-groups SUBGROUP-ID + quagga show ip bgp update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue) + quagga show ip bgp view WORD ipv4 (unicast|multicast) summary [json] + quagga show ip bgp vpnv4 all + quagga show ip bgp vpnv4 all <ipv4/prefixlen> [json] + quagga show ip bgp vpnv4 all <ipv4> [json] + quagga show ip bgp vpnv4 all neighbors (<ipv4>|<ipv6>|<interface>) prefix-counts [json] + quagga show ip bgp vpnv4 all neighbors <ipv4> [json] + quagga show ip bgp vpnv4 all neighbors <ipv4> advertised-routes [json] + quagga show ip bgp vpnv4 all neighbors <ipv4> routes [json] + quagga show ip bgp vpnv4 all neighbors [json] + quagga show ip bgp vpnv4 all summary [json] + quagga show ip bgp vpnv4 all tags + quagga show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn + quagga show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn <ipv4/prefixlen> [json] + quagga show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn <ipv4> [json] + quagga show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors <ipv4> [json] + quagga show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors <ipv4> advertised-routes [json] + quagga show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors <ipv4> routes [json] + quagga show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors [json] + quagga show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary [json] + quagga show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn tags + quagga show ip community-list + quagga show ip community-list (<1-500>|WORD) + quagga show ip extcommunity-list + quagga show ip extcommunity-list (<1-500>|WORD) + quagga show ipv6 bgp <ipv6/prefixlen> [json] + quagga show ipv6 bgp <ipv6/prefixlen> longer-prefixes + quagga show ipv6 bgp <ipv6> [json] + quagga show ipv6 bgp [json] + quagga show ipv6 bgp community + quagga show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) + quagga show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show ipv6 bgp community-list WORD + quagga show ipv6 bgp community-list WORD exact-match + quagga show ipv6 bgp filter-list WORD + quagga show ipv6 bgp neighbors (<ipv4>|<ipv6>|<interface>) advertised-routes [json] + quagga show ipv6 bgp neighbors (<ipv4>|<ipv6>|<interface>) received-routes [json] + quagga show ipv6 bgp neighbors (<ipv4>|<ipv6>|<interface>) routes [json] + quagga show ipv6 bgp prefix-list WORD + quagga show ipv6 bgp regexp LINE + quagga show ipv6 bgp summary [json] + quagga show ipv6 mbgp <ipv6/prefixlen> [json] + quagga show ipv6 mbgp <ipv6/prefixlen> longer-prefixes + quagga show ipv6 mbgp <ipv6> [json] + quagga show ipv6 mbgp [json] + quagga show ipv6 mbgp community + quagga show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) + quagga show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) + quagga show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match + quagga show ipv6 mbgp community-list WORD + quagga show ipv6 mbgp community-list WORD exact-match + quagga show ipv6 mbgp filter-list WORD + quagga show ipv6 mbgp neighbors (<ipv4>|<ipv6>|<interface>) advertised-routes [json] + quagga show ipv6 mbgp neighbors (<ipv4>|<ipv6>|<interface>) received-routes [json] + quagga show ipv6 mbgp neighbors (<ipv4>|<ipv6>|<interface>) routes [json] + quagga show ipv6 mbgp prefix-list WORD + quagga show ipv6 mbgp regexp LINE + quagga show ipv6 mbgp summary [json]""".splitlines() + +bgp_config_ignore = """ quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) activate + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) addpath-tx-all-paths + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) addpath-tx-bestpath-per-AS + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) allowas-in + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) allowas-in <1-10> + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) as-override + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) attribute-unchanged + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) attribute-unchanged (as-path|next-hop|med) + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) attribute-unchanged as-path (next-hop|med) + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) attribute-unchanged as-path med next-hop + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) attribute-unchanged as-path next-hop med + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) attribute-unchanged med (as-path|next-hop) + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) attribute-unchanged med as-path next-hop + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) attribute-unchanged med next-hop as-path + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) attribute-unchanged next-hop (as-path|med) + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) attribute-unchanged next-hop as-path med + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) attribute-unchanged next-hop med as-path + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) capability orf prefix-list (both|send|receive) + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) default-originate + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) default-originate route-map WORD + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) distribute-list (<1-199>|<1300-2699>|WORD) (in|out) + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) filter-list WORD (in|out) + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) maximum-prefix <1-4294967295> + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) maximum-prefix <1-4294967295> <1-100> + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) maximum-prefix <1-4294967295> <1-100> restart <1-65535> + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) maximum-prefix <1-4294967295> <1-100> warning-only + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) maximum-prefix <1-4294967295> restart <1-65535> + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) maximum-prefix <1-4294967295> warning-only + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) next-hop-self + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) next-hop-self force + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) peer-group WORD + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) prefix-list WORD (in|out) + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) remove-private-AS + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) remove-private-AS all + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) remove-private-AS all replace-AS + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) remove-private-AS replace-AS + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) route-map WORD (in|out) + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) route-reflector-client + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) route-server-client + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) send-community + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) send-community (both|extended|standard) + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) soft-reconfiguration inbound + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ipv4>|<ipv6>|<interface>) unsuppress-map WORD + quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] table-map WORD + quagga (add|del) bgp [ipv4|ipv6] unicast maximum-paths <1-255> + quagga (add|del) bgp [ipv4|ipv6] unicast maximum-paths ibgp <1-255> + quagga (add|del) bgp [ipv4|ipv6] unicast maximum-paths ibgp <1-255> equal-cluster-length + quagga (add|del) bgp always-compare-med + quagga (add|del) bgp bestpath as-path confed + quagga (add|del) bgp bestpath as-path ignore + quagga (add|del) bgp bestpath as-path multipath-relax [as-set|no-as-set] + quagga (add|del) bgp bestpath compare-routerid + quagga (add|del) bgp bestpath med (confed|missing-as-worst) + quagga (add|del) bgp bestpath med confed missing-as-worst + quagga (add|del) bgp bestpath med missing-as-worst confed + quagga (add|del) bgp client-to-client reflection + quagga (add|del) bgp cluster-id <1-4294967295> + quagga (add|del) bgp cluster-id <ipv4> + quagga (add|del) bgp confederation identifier <1-4294967295> + quagga (add|del) bgp confederation peers . <1-4294967295> + quagga (add|del) bgp default ipv4-unicast + quagga (add|del) bgp default local-preference <0-4294967295> + quagga (add|del) bgp default show-hostname + quagga (add|del) bgp default subgroup-pkt-queue-max <20-100> + quagga (add|del) bgp deterministic-med + quagga (add|del) bgp disable-ebgp-connected-route-check + quagga (add|del) bgp enforce-first-as + quagga (add|del) bgp fast-external-failover + quagga (add|del) bgp graceful-restart + quagga (add|del) bgp graceful-restart stalepath-time <1-3600> + quagga (add|del) bgp listen limit <1-5000> + quagga (add|del) bgp listen range (<ipv4/prefixlen>|<ipv6/prefixlen>) peer-group WORD + quagga (add|del) bgp log-neighbor-changes + quagga (add|del) bgp max-med administrative + quagga (add|del) bgp max-med administrative <0-4294967294> + quagga (add|del) bgp max-med on-startup <5-86400> + quagga (add|del) bgp max-med on-startup <5-86400> <0-4294967294> + quagga (add|del) bgp network import-check + quagga (add|del) bgp route-map delay-timer <0-600> + quagga (add|del) bgp route-reflector allow-outbound-policy + quagga (add|del) bgp router-id <ipv4> + quagga (add|del) bgp coalesce-time <0-4294967295> + quagga (add|del) bgp distance <1-255> <ipv4/prefixlen> + quagga (add|del) bgp distance <1-255> <ipv4/prefixlen> WORD + quagga (add|del) bgp distance bgp <1-255> <1-255> <1-255> + quagga (add|del) bgp ipv4 [unicast|multicast] aggregate-address <ipv4/prefixlen> + quagga (add|del) bgp ipv4 [unicast|multicast] aggregate-address <ipv4/prefixlen> as-set + quagga (add|del) bgp ipv4 [unicast|multicast] aggregate-address <ipv4/prefixlen> as-set summary-only + quagga (add|del) bgp ipv4 [unicast|multicast] aggregate-address <ipv4/prefixlen> summary-only + quagga (add|del) bgp ipv4 [unicast|multicast] aggregate-address <ipv4/prefixlen> summary-only as-set + quagga (add|del) bgp ipv4 [unicast|multicast] aggregate-address <ipv4> <ipv4> + quagga (add|del) bgp ipv4 [unicast|multicast] aggregate-address <ipv4> <ipv4> as-set + quagga (add|del) bgp ipv4 [unicast|multicast] aggregate-address <ipv4> <ipv4> as-set summary-only + quagga (add|del) bgp ipv4 [unicast|multicast] aggregate-address <ipv4> <ipv4> summary-only + quagga (add|del) bgp ipv4 [unicast|multicast] aggregate-address <ipv4> <ipv4> summary-only as-set + quagga (add|del) bgp ipv4 [unicast|multicast] network <ipv4/prefixlen> + quagga (add|del) bgp ipv4 [unicast|multicast] network <ipv4/prefixlen> route-map WORD + quagga (add|del) bgp ipv4 [unicast|multicast] network <ipv4> + quagga (add|del) bgp ipv4 [unicast|multicast] network <ipv4> prefixlen <ipv4> + quagga (add|del) bgp ipv4 [unicast|multicast] network <ipv4> prefixlen <ipv4> route-map WORD + quagga (add|del) bgp ipv4 [unicast|multicast] network <ipv4> route-map WORD + quagga (add|del) bgp ipv4 unicast bgp dampening + quagga (add|del) bgp ipv4 unicast bgp dampening <1-45> + quagga (add|del) bgp ipv4 unicast bgp dampening <1-45> <1-20000> <1-20000> <1-255> + quagga (add|del) bgp ipv4 unicast redistribute (kernel|connected|static|rip|ospf|isis) + quagga (add|del) bgp ipv4 unicast redistribute (kernel|connected|static|rip|ospf|isis) metric <0-4294967295> + quagga (add|del) bgp ipv4 unicast redistribute (kernel|connected|static|rip|ospf|isis) metric <0-4294967295> route-map WORD + quagga (add|del) bgp ipv4 unicast redistribute (kernel|connected|static|rip|ospf|isis) route-map WORD + quagga (add|del) bgp ipv4 unicast redistribute (kernel|connected|static|rip|ospf|isis) route-map WORD metric <0-4294967295> + quagga (add|del) bgp ipv4 unicast redistribute (ospf|table) <1-65535> + quagga (add|del) bgp ipv4 unicast redistribute (ospf|table) <1-65535> metric <0-4294967295> + quagga (add|del) bgp ipv4 unicast redistribute (ospf|table) <1-65535> metric <0-4294967295> route-map WORD + quagga (add|del) bgp ipv4 unicast redistribute (ospf|table) <1-65535> route-map WORD + quagga (add|del) bgp ipv4 unicast redistribute (ospf|table) <1-65535> route-map WORD metric <0-4294967295> + quagga (add|del) bgp ipv6 [unicast|multicast] network <ipv6/prefixlen> + quagga (add|del) bgp ipv6 bgp aggregate-address <ipv6/prefixlen> + quagga (add|del) bgp ipv6 bgp aggregate-address <ipv6/prefixlen> summary-only + quagga (add|del) bgp ipv6 bgp network <ipv6/prefixlen> + quagga (add|del) bgp ipv6 unicast aggregate-address <ipv6/prefixlen> + quagga (add|del) bgp ipv6 unicast aggregate-address <ipv6/prefixlen> summary-only + quagga (add|del) bgp ipv6 unicast neighbor (<ipv4>|<ipv6>|<interface>) nexthop-local unchanged + quagga (add|del) bgp ipv6 unicast network <ipv6/prefixlen> route-map WORD + quagga (add|del) bgp ipv6 unicast redistribute (kernel|connected|static|ripng|ospf6|isis) + quagga (add|del) bgp ipv6 unicast redistribute (kernel|connected|static|ripng|ospf6|isis) metric <0-4294967295> + quagga (add|del) bgp ipv6 unicast redistribute (kernel|connected|static|ripng|ospf6|isis) metric <0-4294967295> route-map WORD + quagga (add|del) bgp ipv6 unicast redistribute (kernel|connected|static|ripng|ospf6|isis) route-map WORD + quagga (add|del) bgp ipv6 unicast redistribute (kernel|connected|static|ripng|ospf6|isis) route-map WORD metric <0-4294967295> + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>) interface WORD + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>) port <0-65535> + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>) strict-capability-match + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) advertisement-interval <0-600> + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) bfd + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) bfd <2-255> BFD_CMD_MIN_RX_RANGE <50-60000> + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) capability dynamic + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) capability extended-nexthop + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) description LINE + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) disable-connected-check + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) dont-capability-negotiate + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) ebgp-multihop + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) ebgp-multihop <1-255> + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) enforce-multihop + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) local-as <1-4294967295> + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) local-as <1-4294967295> no-prepend + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) local-as <1-4294967295> no-prepend replace-as + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) override-capability + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) passive + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) password LINE + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) remote-as (<1-4294967295>|external|internal) + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) shutdown + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) solo + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) timers <0-65535> <0-65535> + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) timers connect <1-65535> + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) ttl-security hops <1-254> + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) update-source (<ipv4>|<ipv6>|<interface>) + quagga (add|del) bgp neighbor (<ipv4>|<ipv6>|<interface>) weight <0-65535> + quagga (add|del) bgp neighbor WORD interface + quagga (add|del) bgp neighbor WORD interface peer-group WORD + quagga (add|del) bgp neighbor WORD interface v6only + quagga (add|del) bgp neighbor WORD interface v6only peer-group WORD + quagga (add|del) bgp neighbor WORD peer-group + quagga (add|del) bgp network <ipv4/prefixlen> backdoor + quagga (add|del) bgp network <ipv4> backdoor + quagga (add|del) bgp network <ipv4> prefixlen <ipv4> backdoor + quagga (add|del) bgp timers bgp <0-65535> <0-65535> + quagga (add|del) bgp update-delay <0-3600> + quagga (add|del) bgp update-delay <0-3600> <1-3600> + quagga (add|del) bgp write-quanta <1-10000>""".splitlines() + +ospf_clear_ignore = [" quagga clear ip ospf interface [IFNAME]", ] + +ospf_debug_ignore = """ quagga debug ospf <1-65535> event + quagga debug ospf <1-65535> ism + quagga debug ospf <1-65535> ism (status|events|timers) + quagga debug ospf <1-65535> lsa + quagga debug ospf <1-65535> lsa (generate|flooding|install|refresh) + quagga debug ospf <1-65535> nsm + quagga debug ospf <1-65535> nsm (status|events|timers) + quagga debug ospf <1-65535> nssa + quagga debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all) + quagga debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|) + quagga debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail) + quagga debug ospf <1-65535> zebra + quagga debug ospf <1-65535> zebra (interface|redistribute) + quagga debug ospf event + quagga debug ospf ism + quagga debug ospf ism (status|events|timers) + quagga debug ospf lsa + quagga debug ospf lsa (generate|flooding|install|refresh) + quagga debug ospf nsm + quagga debug ospf nsm (status|events|timers) + quagga debug ospf nssa + quagga debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) + quagga debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|) + quagga debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail) + quagga debug ospf zebra + quagga debug ospf zebra (interface|redistribute)""".splitlines() + +ospf_show_ignore = """ quagga show debugging ospf + quagga show debugging ospf <1-65535> + quagga show ip ospf <1-65535> [json] + quagga show ip ospf <1-65535> border-routers + quagga show ip ospf <1-65535> database + quagga show ip ospf <1-65535> database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as) (self-originate|) + quagga show ip ospf <1-65535> database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as) <ipv4> + quagga show ip ospf <1-65535> database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as) <ipv4> (self-originate|) + quagga show ip ospf <1-65535> database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as) <ipv4> adv-router <ipv4> + quagga show ip ospf <1-65535> database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as) adv-router <ipv4> + quagga show ip ospf <1-65535> database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as|max-age|self-originate) + quagga show ip ospf <1-65535> interface [INTERFACE] [json] + quagga show ip ospf <1-65535> neighbor <ipv4> [json] + quagga show ip ospf <1-65535> neighbor IFNAME [json] + quagga show ip ospf <1-65535> neighbor IFNAME detail [json] + quagga show ip ospf <1-65535> neighbor [json] + quagga show ip ospf <1-65535> neighbor all [json] + quagga show ip ospf <1-65535> neighbor detail [json] + quagga show ip ospf <1-65535> neighbor detail all [json] + quagga show ip ospf <1-65535> route + quagga show ip ospf [json] + quagga show ip ospf border-routers + quagga show ip ospf database + quagga show ip ospf database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as) (self-originate|) + quagga show ip ospf database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as) <ipv4> + quagga show ip ospf database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as) <ipv4> (self-originate|) + quagga show ip ospf database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as) <ipv4> adv-router <ipv4> + quagga show ip ospf database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as) adv-router <ipv4> + quagga show ip ospf database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as|max-age|self-originate) + quagga show ip ospf interface [INTERFACE] [json] + quagga show ip ospf neighbor <ipv4> [json] + quagga show ip ospf neighbor IFNAME [json] + quagga show ip ospf neighbor IFNAME detail [json] + quagga show ip ospf neighbor [json] + quagga show ip ospf neighbor all [json] + quagga show ip ospf neighbor detail [json] + quagga show ip ospf neighbor detail all [json] + quagga show ip ospf route + quagga show mpls-te interface [INTERFACE] + quagga show mpls-te router""".splitlines() + +ospf_config_ignore = """ quagga (add|del) <interface> ip ospf <1-65535> area (<ipv4>|<0-4294967295>) + quagga (add|del) <interface> ip ospf area (<ipv4>|<0-4294967295>) + quagga (add|del) <interface> ip ospf authentication + quagga (add|del) <interface> ip ospf authentication (null|message-digest) + quagga (add|del) <interface> ip ospf authentication (null|message-digest) <ipv4> + quagga (add|del) <interface> ip ospf authentication <ipv4> + quagga (add|del) <interface> ip ospf authentication-key AUTH_KEY + quagga (add|del) <interface> ip ospf authentication-key AUTH_KEY <ipv4> + quagga (add|del) <interface> ip ospf bfd + quagga (add|del) <interface> ip ospf bfd <2-255> BFD_CMD_MIN_RX_RANGE <50-60000> + quagga (add|del) <interface> ip ospf cost <1-65535> + quagga (add|del) <interface> ip ospf cost <1-65535> <ipv4> + quagga (add|del) <interface> ip ospf dead-interval <1-65535> + quagga (add|del) <interface> ip ospf dead-interval <1-65535> <ipv4> + quagga (add|del) <interface> ip ospf dead-interval minimal hello-multiplier <1-10> + quagga (add|del) <interface> ip ospf dead-interval minimal hello-multiplier <1-10> <ipv4> + quagga (add|del) <interface> ip ospf hello-interval <1-65535> + quagga (add|del) <interface> ip ospf hello-interval <1-65535> <ipv4> + quagga (add|del) <interface> ip ospf message-digest-key <1-255> md5 KEY + quagga (add|del) <interface> ip ospf message-digest-key <1-255> md5 KEY <ipv4> + quagga (add|del) <interface> ip ospf mtu-ignore + quagga (add|del) <interface> ip ospf mtu-ignore <ipv4> + quagga (add|del) <interface> ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point) + quagga (add|del) <interface> ip ospf priority <0-255> + quagga (add|del) <interface> ip ospf priority <0-255> <ipv4> + quagga (add|del) <interface> ip ospf retransmit-interval <3-65535> + quagga (add|del) <interface> ip ospf retransmit-interval <3-65535> <ipv4> + quagga (add|del) <interface> ip ospf transmit-delay <1-65535> + quagga (add|del) <interface> ip ospf transmit-delay <1-65535> <ipv4> + quagga (add|del) <interface> mpls-te link max-bw BANDWIDTH + quagga (add|del) <interface> mpls-te link max-rsv-bw BANDWIDTH + quagga (add|del) <interface> mpls-te link metric <0-4294967295> + quagga (add|del) <interface> mpls-te link rsc-clsclr BITPATTERN + quagga (add|del) <interface> mpls-te link unrsv-bw <0-7> BANDWIDTH + quagga (add|del) ospf abr-type (cisco|ibm|shortcut|standard) + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) authentication + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) authentication message-digest + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) default-cost <0-16777215> + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) export-list NAME + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) filter-list prefix WORD (in|out) + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) import-list NAME + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) nssa + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) nssa no-summary + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) range <ipv4/prefixlen> + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) range <ipv4/prefixlen> advertise + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) range <ipv4/prefixlen> advertise cost <0-16777215> + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) range <ipv4/prefixlen> cost <0-16777215> + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) range <ipv4/prefixlen> not-advertise + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) range <ipv4/prefixlen> substitute <ipv4/prefixlen> + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) shortcut (default|enable|disable) + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) stub + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) stub no-summary + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) virtual-link <ipv4> + quagga (add|del) ospf area (<ipv4>|<0-4294967295>) virtual-link <ipv4> + quagga (add|del) ospf auto-cost reference-bandwidth <1-4294967> + quagga (add|del) ospf capability opaque + quagga (add|del) ospf compatible rfc1583 + quagga (add|del) ospf default-information originate + quagga (add|del) ospf default-metric <0-16777214> + quagga (add|del) ospf distance <1-255> + quagga (add|del) ospf distance <1-255> <ipv4/prefixlen> + quagga (add|del) ospf distance <1-255> <ipv4/prefixlen> WORD + quagga (add|del) ospf distance ospf + quagga (add|del) ospf distribute-list WORD out QUAGGA_REDIST_STR_OSPFD + quagga (add|del) ospf log-adjacency-changes + quagga (add|del) ospf log-adjacency-changes detail + quagga (add|del) ospf max-metric router-lsa administrative + quagga (add|del) ospf max-metric router-lsa on-shutdown <5-100> + quagga (add|del) ospf max-metric router-lsa on-startup <5-86400> + quagga (add|del) ospf mpls-te + quagga (add|del) ospf mpls-te on + quagga (add|del) ospf mpls-te router-address <ipv4> + quagga (add|del) ospf neighbor <ipv4> + quagga (add|del) ospf neighbor <ipv4> poll-interval <1-65535> + quagga (add|del) ospf neighbor <ipv4> poll-interval <1-65535> priority <0-255> + quagga (add|del) ospf neighbor <ipv4> priority <0-255> + quagga (add|del) ospf neighbor <ipv4> priority <0-255> poll-interval <1-65535> + quagga (add|del) ospf network <ipv4/prefixlen> area (<ipv4>|<0-4294967295>) + quagga (add|del) ospf opaque-lsa + quagga (add|del) ospf passive-interface IFNAME + quagga (add|del) ospf passive-interface IFNAME <ipv4> + quagga (add|del) ospf passive-interface default + quagga (add|del) ospf redistribute (ospf|table) <1-65535> + quagga (add|del) ospf redistribute QUAGGA_REDIST_STR_OSPFD + quagga (add|del) ospf rfc1583compatibility + quagga (add|del) ospf router-id <ipv4> + quagga (add|del) ospf timers lsa arrival <0-1000> + quagga (add|del) ospf timers lsa min-arrival <0-600000> + quagga (add|del) ospf timers throttle lsa all <0-5000> + quagga (add|del) ospf timers throttle spf <0-600000> <0-600000> <0-600000> + quagga (add|del) ospf write-multiplier <1-100> + quagga (add|del) ospf write-multiplier <1-100>""".splitlines() + +def replace_constants(line): + line = line.replace('NO_NEIGHBOR_CMD2', 'no neighbor (A.B.C.D|X:X::X:X|WORD) ') + line = line.replace('NEIGHBOR_CMD2', 'neighbor (A.B.C.D|X:X::X:X|WORD) ') + line = line.replace('NO_NEIGHBOR_CMD', 'no neighbor (A.B.C.D|X:X::X:X) ') + line = line.replace('NEIGHBOR_CMD', 'neighbor (A.B.C.D|X:X::X:X) ') + line = line.replace('CMD_AS_RANGE', '<1-4294967295>') + line = line.replace('LISTEN_RANGE_CMD', 'bgp listen range (A.B.C.D/M|X:X::X:X/M) ') + line = line.replace('DYNAMIC_NEIGHBOR_LIMIT_RANGE', '<1-5000>') + line = line.replace('QUAGGA_IP_REDIST_STR_BGPD', '(kernel|connected|static|rip|ospf|isis)') + line = line.replace('QUAGGA_IP6_REDIST_STR_BGPD', '(kernel|connected|static|ripng|ospf6|isis)') + line = line.replace('QUAGGA_IP6_REDIST_STR_ZEBRA', '(kernel|connected|static|ripng|ospf6|isis|bgp)') + line = line.replace('QUAGGA_IP_REDIST_STR_ZEBRA', '(kernel|connected|static|rip|ospf|isis|bgp)') + line = line.replace('OSPF_LSA_TYPES_CMD_STR', 'asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as') + line = line.replace('CMD_RANGE_STR(1, MULTIPATH_NUM)', '<1-255>') + line = line.replace('CMD_RANGE_STR(1, MAXTTL)', '<1-255>') + line = line.replace('BFD_CMD_DETECT_MULT_RANGE', '<2-255>') + line = line.replace('BFD_CMD_MIN_TX_RANGE', '<50-60000>') + line = line.replace('BGP_UPDATE_SOURCE_REQ_STR', '(A.B.C.D|X:X::X:X|WORD)') + line = line.replace('BGP_UPDATE_SOURCE_OPT_STR', '{A.B.C.D|X:X::X:X|WORD}') + line = line.replace('.LINE', 'LINE') + line = line.replace('.AA:NN', 'AA:NN') + # line = line.replace('', '') + return line + + +ignore = {} +ignore['bgpd'] = [] +ignore['bgpd'].append('address-family ipv4') +ignore['bgpd'].append('address-family ipv4 (unicast|multicast)') +ignore['bgpd'].append('address-family ipv6') +ignore['bgpd'].append('address-family ipv6 (unicast|multicast)') +ignore['bgpd'].append('address-family vpnv4') +ignore['bgpd'].append('address-family vpnv4 unicast') +ignore['bgpd'].append('exit-address-family') + +ignore['ospfd'] = [] + + +class Command(object): + + def __init__(self, defun, text, line_number): + self.defun = defun + self.text = text + self.line_number = line_number + self.context = [] + self.docstring = None + + def __str__(self): + return "%s - %s" % (self.context, self.text) + + def set_docstring(self): + ds = self.text + + if self.text in ignore['bgpd']: + return None + + # For these two WORD means an interface name + ds = ds.replace('A.B.C.D|X:X::X:X|WORD', '<ipv4>|<ipv6>|<interface>') + ds = ds.replace('A.B.C.D|WORD', '<ipv4>|<interface>') + + ds = ds.replace('A.B.C.D/M', '<ipv4/prefixlen>') + ds = ds.replace('A.B.C.D', '<ipv4>') + ds = ds.replace('X:X::X:X/M', '<ipv6/prefixlen>') + ds = ds.replace('X:X::X:X', '<ipv6>') + ds = ds.replace('{json}', '[json]') + ds = ds.replace('{', '[') + ds = ds.replace('}', ']') + ds = ds.replace(' PATH ', ' <text> ') + + afis = [] + safis = [] + + if 'BGP_IPV4_NODE' in self.context: + afis.append('ipv4') + safis.append('unicast') + + if 'BGP_IPV4M_NODE' in self.context: + afis.append('ipv4') + safis.append('multicast') + + if 'BGP_IPV6_NODE' in self.context: + afis.append('ipv6') + safis.append('unicast') + + if 'BGP_IPV6M_NODE' in self.context: + afis.append('ipv6') + safis.append('multicast') + + afis = list(set(afis)) + safis = list(set(safis)) + + # clear, debug, show, etc + if 'ENABLE_NODE' in self.context: + pass + + # config command so need to add (add|del) and maybe afi/safi + else: + if afis: + if len(afis) > 1: + afi_string = "[%s]" % '|'.join(afis) + else: + afi_string = afis[0] + + if len(safis) > 1: + safi_string = "[%s]" % '|'.join(safis) + else: + safi_string = safis[0] + + ds = "(add|del) bgp %s %s " % (afi_string, safi_string) + ds + + elif 'BGP_NODE' in self.context: + if ds.startswith('bgp'): + ds = "(add|del) " + ds + else: + ds = "(add|del) bgp " + ds + + elif 'INTERFACE_NODE' in self.context: + ds = "(add|del) <interface> " + ds + + elif 'OSPF_NODE' in self.context: + if ds.startswith('ospf'): + ds = "(add|del) " + ds + else: + ds = "(add|del) ospf " + ds + + # Ignore the route-map commands, ip community-list, etc for now + else: + ds = None + + if ds: + ds = ds.rstrip() + self.docstring = ' quagga ' + ds + + +if __name__ == '__main__': + + parser = argparse.ArgumentParser(description='Parse the quagga parser') + parser.add_argument('directory', help='quagga directory') + parser.add_argument('daemon', help='bgpd, ospfd, etc') + parser.add_argument('--print-quagga', action='store_true', help='print the raw quagga commands') + parser.add_argument('--print-docstring', action='store_true', help='print a docstring for network-docopt') + parser.add_argument('--print-context', action='store_true', help='print quagga commands with their context') + args = parser.parse_args() + + logging.basicConfig(level=logging.INFO, + format='%(asctime)s %(levelname)7s: %(message)s') + log = logging.getLogger(__name__) + + # Color the errors and warnings in red + logging.addLevelName(logging.ERROR, "\033[91m %s\033[0m" % logging.getLevelName(logging.ERROR)) + logging.addLevelName(logging.WARNING, "\033[91m%s\033[0m" % logging.getLevelName(logging.WARNING)) + + bgpd = os.path.join(args.directory, 'bgpd') + isisd = os.path.join(args.directory, 'isisd') + ospfd = os.path.join(args.directory, 'ospfd') + ospf6d = os.path.join(args.directory, 'ospf6d') + ripd = os.path.join(args.directory, 'ripd') + ripngd = os.path.join(args.directory, 'ripngd') + zebra = os.path.join(args.directory, 'zebra') + parser_files = [] + + for (directory, foo, files) in sorted(os.walk(args.directory)): + + # We do not care about crunching files in these directories + if (directory.endswith('vtysh') or + directory.endswith('quagga-0.99.23.1/') or + directory.endswith('lib') or + directory.endswith('isisd') or + directory.endswith('ripd') or + directory.endswith('ripngd') or + directory.endswith('m4') or + directory.endswith('tests')): + continue + + if args.daemon not in directory: + continue + + for x in sorted(files): + if x.endswith('.c'): + filename = os.path.join(directory, x) + parser_files.append(filename) + + commands = {} + defun_to_context = {} + + for filename in parser_files: + + with open(filename, 'r') as fh: + state = 'LIMBO' + line_number = 1 + + for line in fh.readlines(): + + if state == 'LIMBO': + if (line.startswith('DEFUN ') or line.startswith('ALIAS ')): + state = 'DEFUN_LINE_1' + + elif 'install_element' in line: + # install_element (BGP_NODE, &neighbor_bfd_cmd); + re_line = re.search('install_element\s*\(\s*(\S+)\s*, \&(\S+)\)', line) + + if re_line: + context = re_line.group(1) + defun = re_line.group(2) + + if defun not in defun_to_context: + defun_to_context[defun] = [] + defun_to_context[defun].append(context) + else: + log.warning("regex failed on '%s'" % line.strip()) + + elif state == 'DEFUN_LINE_1': + state = 'DEFUN_LINE_2' + # remove spaces and trailing comma + defun = line.strip()[0:-1] + + elif state == 'DEFUN_LINE_2': + if 'ifdef HAVE_IPV6' in line: + pass + else: + state = 'LIMBO' + + # remove the leading and trailing spaces + # remove the leading and trailing " + # remove the trailing , + line = line.strip() + line = replace_constants(line) + + if line.endswith(','): + line = line.rstrip().lstrip()[:-1] + + if line.startswith('"'): + line = line.rstrip().lstrip()[1:] + + if line.endswith('"'): + line = line.rstrip().lstrip()[:-1] + + line = line.replace(' " ', ' ') + line = line.replace(' "', ' ') + line = line.replace('" ', ' ') + line = line.replace('( ', '(') + line = line.replace(' )', ')') + + line = line.replace('| ', '|') + line = line.replace(' |', '|') + + # compress multiple whitespaces + while ' ' in line: + line = line.replace(' ', ' ') + + commands[line] = Command(defun, line, line_number) + defun = None + line_number += 1 + + # Fill in the context for each Command based on its defun + for cmd in commands.itervalues(): + cmd.context = defun_to_context.get(cmd.defun) + if cmd.context is None: + log.error("%s: could not find defun for %s" % (cmd, cmd.defun)) + continue + cmd.set_docstring() + + normal = [] + expert = [] + + if args.print_docstring: + if args.daemon == 'bgpd': + normal.append(' quagga show bgp [ipv4|ipv6] [unicast|multicast] summary [json]') + normal.append(' quagga show bgp [ipv4|ipv6] [unicast|multicast] [<ip>|<ip/prefixlen>] [bestpath|multipath] [json]') + normal.append(' quagga show bgp neighbor [<ip>|<interface>]') + normal.append(' quagga clear bgp (<ip>|<interface>|*)') + normal.append(' quagga clear bgp (<ip>|<interface>|*) soft [in|out]') + normal.append(' quagga clear bgp prefix <ip/prefixlen>') + normal.append(' quagga (add|del) debug bgp bestpath <ip/prefixlen>') + normal.append(' quagga (add|del) debug bgp keepalives (<ip><interface>)') + normal.append(' quagga (add|del) debug bgp neighbor-events (<ip>|<interface>)') + expert.append(' quagga (add|del) debug bgp nht') + expert.append(' quagga (add|del) debug bgp update-groups') + normal.append(' quagga (add|del) debug bgp updates prefix <ip/prefixlen>') + normal.append(' quagga (add|del) debug bgp zebra prefix <ip/prefixlen>') + + bgp_bgp = ['always-compare-med', + 'bestpath', + 'client-to-client reflection', + 'cluster-id', + 'confederation peers', + 'default ipv4-unicast', + 'default local-preference', + 'default show-hostname', + 'default subgroup-pkt-queue-max', + 'deterministic-med', + 'disable-ebgp-connected-route-check', + 'enforce-first-as', + 'fast-external-failover', + 'graceful-restart', + 'listen', + 'log-neighbor-changes', + 'max-med', + 'network import-check', + 'route-map delay-timer', + 'route-reflector allow-outbound-policy', + 'router-id'] + + # ====== + # global + # ====== + normal.append(' quagga (add|del) bgp always-compare-med') + expert.append(' quagga (add|del) bgp bestpath as-path (confed|ignore)') + normal.append(' quagga (add|del) bgp bestpath as-path multipath-relax [as-set|no-as-set]') + expert.append(' quagga (add|del) bgp bestpath med (confed|missing-as-worst)') + expert.append(' quagga (add|del) bgp client-to-client reflection') + expert.append(' quagga (add|del) bgp cluster-id (<ipv4>|<1-4294967295>)') + expert.append(' quagga (add|del) bgp confederation peers <1-4294967295>') + expert.append(' quagga (add|del) bgp default ipv4-unicast') + expert.append(' quagga (add|del) bgp default local-preference <0-4294967295>') + expert.append(' quagga (add|del) bgp default show-hostname') + expert.append(' quagga (add|del) bgp default subgroup-pkt-queue-max <20-100>') + expert.append(' quagga (add|del) bgp deterministic-med') + expert.append(' quagga (add|del) bgp disable-ebgp-connected-route-check') + expert.append(' quagga (add|del) bgp enforce-first-as') + expert.append(' quagga (add|del) bgp fast-external-failover') + expert.append(' quagga (add|del) bgp graceful-restart') + expert.append(' quagga (add|del) bgp listen limit <1-5000>') + expert.append(' quagga (add|del) bgp listen range (<ipv4/prefixlen>|<ipv6/prefixlen>) peer-group <text>') + expert.append(' quagga (add|del) bgp log-neighbor-changes') + expert.append(' quagga (add|del) bgp max-med administrative <0-4294967294>') + expert.append(' quagga (add|del) bgp max-med on-startup <5-86400> [<0-4294967294>]') + expert.append(' quagga (add|del) bgp network import-check') + expert.append(' quagga (add|del) bgp route-map delay-timer <0-600>') + expert.append(' quagga (add|del) bgp route-reflector allow-outbound-policy') + normal.append(' quagga (add|del) bgp router-id <ipv4>') + expert.append(' quagga (add|del) bgp coalesce-time <0-4294967295>') + expert.append(' quagga (add|del) bgp distance <1-255> <ipv4/prefixlen> <text>') + expert.append(' quagga (add|del) bgp distance bgp <1-255> <1-255> <1-255>') + expert.append(' quagga (add|del) bgp timers bgp <0-65535> <0-65535>') + expert.append(' quagga (add|del) bgp update-delay <0-3600> [<1-3600>]') + expert.append(' quagga (add|del) bgp write-quanta <1-10000>') + + # ==================== + # peer global afi/safi + # ==================== + normal.append(' quagga (add|del) bgp neighbor <interface> interface') + normal.append(' quagga (add|del) bgp neighbor <interface> interface peer-group <text>') + expert.append(' quagga (add|del) bgp neighbor <interface> interface v6only') + expert.append(' quagga (add|del) bgp neighbor <interface> interface v6only peer-group <text>') + normal.append(' quagga (add|del) bgp neighbor <interface> peer-group') + expert.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) advertisement-interval <0-600>') + expert.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) bfd') + expert.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) capability dynamic') + normal.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) capability extended-nexthop') + normal.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) description <text>') + expert.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) disable-connected-check') + expert.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) dont-capability-negotiate') + normal.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) ebgp-multihop [<1-255>]') + expert.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) enforce-multihop') + expert.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) local-as <1-4294967295> [no-prepend] [replace-as]') + expert.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) override-capability') + expert.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) passive') + normal.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) password <text>') + expert.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) port <0-65535>') + normal.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) remote-as (<1-4294967295>|external|internal)') + normal.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) shutdown') + expert.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) solo') + expert.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) strict-capability-match') + normal.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) timers <0-65535> <0-65535>') + normal.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) timers connect <1-65535>') + expert.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) ttl-security hops <1-254>') + normal.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) update-source (<ipv4>|<ipv6>|<interface>)') + expert.append(' quagga (add|del) bgp neighbor (<ip>|<interface>) weight <0-65535>') + + # ================= + # peer per afi/safi + # ================= + expert.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) addpath-tx-all-paths') + expert.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) addpath-tx-bestpath-per-AS') + expert.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) allowas-in [<1-10>]') + expert.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) as-override') + expert.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) attribute-unchanged [as-path] [next-hop] [med]') + expert.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) capability orf prefix-list (both|send|receive)') + normal.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) default-originate [route-map <text>]') + expert.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) distribute-list (<1-199>|<1300-2699>|<text>) (in|out)') + expert.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) filter-list <text> (in|out)') + expert.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) maximum-prefix <1-4294967295>') + normal.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) next-hop-self [force]') + normal.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) peer-group <text>') + expert.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) prefix-list <text> (in|out)') + normal.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) remove-private-AS [all] [replace-AS]') + normal.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) route-map <text> (in|out)') + normal.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) route-reflector-client') + expert.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) route-server-client') + normal.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) send-community [both|extended|standard]') + expert.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) soft-reconfiguration inbound') + expert.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] neighbor (<ip>|<interface>) unsuppress-map <text>') + expert.append(' quagga (add|del) bgp ipv6 unicast neighbor (<ip>|<interface>) nexthop-local unchanged') + + # ============ + # per afi/safi + # ============ + normal.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] maximum-paths [ibgp] <1-255> [equal-cluster-length]') + normal.append(' quagga (add|del) bgp (ipv4|ipv6) [unicast|multicast] aggregate-address <ipv4/prefixlen> [as-set] [summary-only]') + normal.append(' quagga (add|del) bgp (ipv4|ipv6) [unicast|multicast] network (<ipv4/prefixlen>|<ipv6/prefixlen>)') + expert.append(' quagga (add|del) bgp (ipv4|ipv6) [unicast|multicast] network (<ipv4/prefixlen>|<ipv6/prefixlen>) route-map <text>') + expert.append(' quagga (add|del) bgp (ipv4|ipv6) [unicast|multicast] bgp dampening <1-45> <1-20000> <1-20000> <1-255>') + normal.append(' quagga (add|del) bgp (ipv4|ipv6) [unicast|multicast] redistribute (kernel|connected|static|rip|ospf|isis) [metric <0-4294967295>] [route-map <text>]') + expert.append(' quagga (add|del) bgp [ipv4|ipv6] [unicast|multicast] table-map <text>') + + if args.daemon == 'ospfd': + normal.append(' quagga clear ip ospf interface [<interface>]') + normal.append(' quagga (add|del) debug ospf [<1-65535>] ism [status|events|timers]') + normal.append(' quagga (add|del) debug ospf [<1-65535>] lsa [generate|flooding|install|refresh]') + normal.append(' quagga (add|del) debug ospf [<1-65535>] nsm [status|events|timers]') + expert.append(' quagga (add|del) debug ospf [<1-65535>] nssa') + normal.append(' quagga (add|del) debug ospf [<1-65535>] packet [hello|dd|ls-request|ls-update|ls-ack|all] [send|recv|detail]') + normal.append(' quagga (add|del) debug ospf [<1-65535>] zebra [interface|redistribute]') + normal.append(' quagga show ip ospf [<1-65535>]') + expert.append(' quagga show ip ospf [<1-65535>] border-routers') + expert.append(' quagga show ip ospf [<1-65535>] database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as|max-age|self-originate) [self-originate]') + expert.append(' quagga show ip ospf [<1-65535>] database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as|max-age|self-originate) adv-router <ipv4>') + normal.append(' quagga show ip ospf [<1-65535>] interface [<interface>] [json]') + normal.append(' quagga show ip ospf [<1-65535>] neighbor (all|<interface>|<ipv4>) [detail] [json]') + normal.append(' quagga show ip ospf [<1-65535>] route') + + normal.append(' quagga (add|del) <interface> ip ospf [<1-65535>] area (<ipv4>|<0-4294967295>)') + normal.append(' quagga (add|del) <interface> ip ospf dead-interval <1-65535>') + normal.append(' quagga (add|del) <interface> ip ospf hello-interval <1-65535>') + normal.append(' quagga (add|del) <interface> ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)') + normal.append(' quagga (add|del) ospf network <ipv4/prefixlen> area (<ipv4>|<0-4294967295>)') + normal.append(' quagga (add|del) ospf passive-interface IFNAME') + normal.append(' quagga (add|del) ospf router-id <ipv4>') + normal.append(' quagga (add|del) ospf timers throttle spf <0-600000> <0-600000> <0-600000>') + + + + ignore_list = bgp_clear_ignore + bgp_debug_ignore + bgp_show_ignore + bgp_config_ignore + ignore_list += ospf_clear_ignore + ospf_debug_ignore + ospf_show_ignore + ospf_config_ignore + + for cmd in commands.itervalues(): + if not cmd.text.startswith('no ') and cmd.context: + if cmd.docstring: + if cmd.docstring not in ignore_list: + normal.append(cmd.docstring) + + elif args.print_quagga: + for cmd in commands.itervalues(): + if not cmd.text.startswith('no ') and cmd.context: + normal.append(cmd.text) + + elif args.print_context: + for cmd in commands.itervalues(): + if not cmd.text.startswith('no ') and cmd.context: + normal.append("%s - %s" % (cmd.context, cmd.text)) + else: + raise Exception("No print option specified") + + normal = sorted(normal) + print '\n'.join(map(str, normal)) diff --git a/vtysh/extract.pl.in b/vtysh/extract.pl.in index 7c5dec9a54..6709826599 100755 --- a/vtysh/extract.pl.in +++ b/vtysh/extract.pl.in @@ -34,7 +34,7 @@ print <<EOF; EOF $ignore{'"interface IFNAME"'} = "ignore"; -$ignore{'"interface IFNAME " "vrf <0-65535>"'} = "ignore"; +$ignore{'"interface IFNAME " "vrf (0-65535)"'} = "ignore"; $ignore{'"interface IFNAME " "vrf NAME"'} = "ignore"; $ignore{'"link-params"'} = "ignore"; $ignore{'"vrf NAME"'} = "ignore"; @@ -42,25 +42,25 @@ $ignore{'"ip vrf NAME"'} = "ignore"; $ignore{'"router rip"'} = "ignore"; $ignore{'"router ripng"'} = "ignore"; $ignore{'"router ospf"'} = "ignore"; -$ignore{'"router ospf <1-65535>"'} = "ignore"; +$ignore{'"router ospf (1-65535)"'} = "ignore"; $ignore{'"router ospf6"'} = "ignore"; $ignore{'"mpls ldp"'} = "ignore"; $ignore{'"l2vpn WORD type vpls"'} = "ignore"; $ignore{'"member pseudowire IFNAME"'} = "ignore"; $ignore{'"router bgp"'} = "ignore"; -$ignore{'"router bgp " "<1-4294967295>"'} = "ignore"; -$ignore{'"router bgp " "<1-4294967295>" " (view|vrf) WORD"'} = "ignore"; +$ignore{'"router bgp " "(1-4294967295)"'} = "ignore"; +$ignore{'"router bgp " "(1-4294967295)" " <view|vrf> WORD"'} = "ignore"; +$ignore{'"router bgp [(1-4294967295) [<view|vrf> WORD]]"'} = "ignore"; $ignore{'"router isis WORD"'} = "ignore"; $ignore{'"router zebra"'} = "ignore"; $ignore{'"address-family ipv4"'} = "ignore"; -$ignore{'"address-family ipv4 (unicast|multicast)"'} = "ignore"; +$ignore{'"address-family ipv4 <unicast|multicast>"'} = "ignore"; $ignore{'"address-family ipv6"'} = "ignore"; -$ignore{'"address-family ipv6 (unicast|multicast)"'} = "ignore"; +$ignore{'"address-family ipv6 <unicast|multicast>"'} = "ignore"; $ignore{'"address-family vpnv4"'} = "ignore"; $ignore{'"address-family vpnv4 unicast"'} = "ignore"; $ignore{'"address-family ipv4 vrf NAME"'} = "ignore"; -$ignore{'"address-family encap"'} = "ignore"; -$ignore{'"address-family encapv4"'} = "ignore"; +$ignore{'"address-family <encap|encapv4>"'} = "ignore"; $ignore{'"address-family encapv6"'} = "ignore"; $ignore{'"address-family vpnv6"'} = "ignore"; $ignore{'"address-family vpnv6 unicast"'} = "ignore"; @@ -69,14 +69,17 @@ $ignore{'"vnc defaults"'} = "ignore"; $ignore{'"vnc nve-group NAME"'} = "ignore"; $ignore{'"exit-vnc"'} = "ignore"; $ignore{'"key chain WORD"'} = "ignore"; -$ignore{'"key <0-2147483647>"'} = "ignore"; -$ignore{'"route-map WORD (deny|permit) <1-65535>"'} = "ignore"; +$ignore{'"key (0-2147483647)"'} = "ignore"; +$ignore{'"route-map WORD <deny|permit> (1-65535)"'} = "ignore"; $ignore{'"show route-map"'} = "ignore"; $ignore{'"line vty"'} = "ignore"; $ignore{'"who"'} = "ignore"; $ignore{'"terminal monitor"'} = "ignore"; $ignore{'"terminal no monitor"'} = "ignore"; $ignore{'"show history"'} = "ignore"; +$ignore{'"router ospf [(1-65535)]"'} = "ignore"; +$ignore{'"address-family vpnv6 [unicast]"'} = "ignore"; +$ignore{'"address-family vpnv4 [unicast]"'} = "ignore"; my $cli_stomp = 0; @@ -165,7 +168,7 @@ foreach (@ARGV) { elsif ($file =~ /librfp\/.*\.c$/ || $file =~ /rfapi\/.*\.c$/) { $protocol = "VTYSH_BGPD"; } - else { + else { ($protocol) = ($file =~ /^.*\/([a-z0-9]+)\/[a-zA-Z0-9_\-]+\.c$/); $protocol = "VTYSH_" . uc $protocol; } @@ -221,11 +224,6 @@ foreach (@ARGV) { } } -my $bad_cli_stomps = 108; -# Currently we have $bad_cli_stomps. This was determined by -# running this script and counting up the collisions from what -# was returned. -# # When we have cli commands that map to the same function name, we # can introduce subtle bugs due to code not being called when # we think it is. @@ -233,15 +231,9 @@ my $bad_cli_stomps = 108; # If extract.pl fails with a error message and you've been # modifying the cli, then go back and fix your code to # not have cli command function collisions. -# -# If you've removed a cli overwrite, you can safely subtract -# one from $bad_cli_stomps. If you've added to the problem # please fix your code before submittal -if ($cli_stomp != $bad_cli_stomps) { - warn "Expected $bad_cli_stomps command line stomps, but got $cli_stomp instead\n"; - if ($cli_stomp > $bad_cli_stomps) { - exit $cli_stomp; - } +if ($cli_stomp) { + warn "There are $cli_stomp command line stomps\n"; } # Check finaly alive $cmd; diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 17dd58a4a8..85973bdb55 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -271,7 +271,7 @@ vtysh_execute_func (const char *line, int pager) int ret, cmd_stat; u_int i; vector vline; - struct cmd_element *cmd; + const struct cmd_element *cmd; FILE *fp = NULL; int closepager = 0; int tried = 0; @@ -482,7 +482,7 @@ vtysh_mark_file (const char *filename) int ret; vector vline; int tried = 0; - struct cmd_element *cmd; + const struct cmd_element *cmd; int saved_ret, prev_node; int lineno = 0; char *vty_buf_copy = NULL; @@ -650,7 +650,7 @@ int vtysh_config_from_file (struct vty *vty, FILE *fp) { int ret; - struct cmd_element *cmd; + const struct cmd_element *cmd; int lineno = 0; int retcode = CMD_SUCCESS; @@ -767,32 +767,25 @@ vtysh_rl_describe (void) for (i = 0; i < vector_active (describe); i++) if ((token = vector_slot (describe, i)) != NULL) { - int len; - - if (token->cmd[0] == '\0') - continue; + if (token->text[0] == '\0') + continue; - len = strlen (token->cmd); - if (token->cmd[0] == '.') - len--; + int len = strlen (token->text); - if (width < len) - width = len; + if (width < len) + width = len; } for (i = 0; i < vector_active (describe); i++) if ((token = vector_slot (describe, i)) != NULL) { - if (token->cmd[0] == '\0') - continue; - if (! token->desc) fprintf (stdout," %-s\n", - token->cmd[0] == '.' ? token->cmd + 1 : token->cmd); + token->text); else fprintf (stdout," %-*s %s\n", width, - token->cmd[0] == '.' ? token->cmd + 1 : token->cmd, + token->text, token->desc); } @@ -1086,49 +1079,23 @@ DEFUNSH (VTYSH_REALLYALL, DEFUNSH (VTYSH_BGPD, router_bgp, router_bgp_cmd, - "router bgp " CMD_AS_RANGE, + "router bgp [(1-4294967295) [<view|vrf> WORD]]", ROUTER_STR BGP_STR - AS_STR) + AS_STR + "BGP view\nBGP VRF\n" + "View/VRF name\n") { vty->node = BGP_NODE; return CMD_SUCCESS; } -ALIAS_SH (VTYSH_BGPD, - router_bgp, - router_bgp_asn_cmd, - "router bgp", - ROUTER_STR - BGP_STR) - -ALIAS_SH (VTYSH_BGPD, - router_bgp, - router_bgp_view_cmd, - "router bgp " CMD_AS_RANGE " (view|vrf) WORD", - ROUTER_STR - BGP_STR - AS_STR - "BGP view\nBGP VRF\n" - "View/VRF name\n") - DEFUNSH (VTYSH_BGPD, address_family_vpnv4, address_family_vpnv4_cmd, - "address-family vpnv4", - "Enter Address Family command mode\n" - "Address family\n") -{ - vty->node = BGP_VPNV4_NODE; - return CMD_SUCCESS; -} - -DEFUNSH (VTYSH_BGPD, - address_family_vpnv4_unicast, - address_family_vpnv4_unicast_cmd, - "address-family vpnv4 unicast", + "address-family vpnv4 [unicast]", "Enter Address Family command mode\n" - "Address family\n" + "Address Family\n" "Address Family Modifier\n") { vty->node = BGP_VPNV4_NODE; @@ -1138,20 +1105,9 @@ DEFUNSH (VTYSH_BGPD, DEFUNSH (VTYSH_BGPD, address_family_vpnv6, address_family_vpnv6_cmd, - "address-family vpnv6", + "address-family vpnv6 [unicast]", "Enter Address Family command mode\n" - "Address family\n") -{ - vty->node = BGP_VPNV6_NODE; - return CMD_SUCCESS; -} - -DEFUNSH (VTYSH_BGPD, - address_family_vpnv6_unicast, - address_family_vpnv6_unicast_cmd, - "address-family vpnv6 unicast", - "Enter Address Family command mode\n" - "Address family\n" + "Address Family\n" "Address Family Modifier\n") { vty->node = BGP_VPNV6_NODE; @@ -1159,22 +1115,12 @@ DEFUNSH (VTYSH_BGPD, } DEFUNSH (VTYSH_BGPD, - address_family_encap, - address_family_encap_cmd, - "address-family encap", - "Enter Address Family command mode\n" - "Address family\n") -{ - vty->node = BGP_ENCAP_NODE; - return CMD_SUCCESS; -} - -DEFUNSH (VTYSH_BGPD, address_family_encapv4, address_family_encapv4_cmd, - "address-family encapv4", + "address-family <encap|encapv4>", "Enter Address Family command mode\n" - "Address family\n") + "Address Family\n" + "Address Family\n") { vty->node = BGP_ENCAP_NODE; return CMD_SUCCESS; @@ -1185,7 +1131,7 @@ DEFUNSH (VTYSH_BGPD, address_family_encapv6_cmd, "address-family encapv6", "Enter Address Family command mode\n" - "Address family\n") + "Address Family\n") { vty->node = BGP_ENCAPV6_NODE; return CMD_SUCCESS; @@ -1196,7 +1142,7 @@ DEFUNSH (VTYSH_BGPD, address_family_ipv4_unicast_cmd, "address-family ipv4 unicast", "Enter Address Family command mode\n" - "Address family\n" + "Address Family\n" "Address Family Modifier\n") { vty->node = BGP_IPV4_NODE; @@ -1208,7 +1154,7 @@ DEFUNSH (VTYSH_BGPD, address_family_ipv4_multicast_cmd, "address-family ipv4 multicast", "Enter Address Family command mode\n" - "Address family\n" + "Address Family\n" "Address Family Modifier\n") { vty->node = BGP_IPV4M_NODE; @@ -1218,20 +1164,9 @@ DEFUNSH (VTYSH_BGPD, DEFUNSH (VTYSH_BGPD, address_family_ipv6, address_family_ipv6_cmd, - "address-family ipv6", + "address-family ipv6 [unicast]", "Enter Address Family command mode\n" - "Address family\n") -{ - vty->node = BGP_IPV6_NODE; - return CMD_SUCCESS; -} - -DEFUNSH (VTYSH_BGPD, - address_family_ipv6_unicast, - address_family_ipv6_unicast_cmd, - "address-family ipv6 unicast", - "Enter Address Family command mode\n" - "Address family\n" + "Address Family\n" "Address Family Modifier\n") { vty->node = BGP_IPV6_NODE; @@ -1243,7 +1178,7 @@ DEFUNSH (VTYSH_BGPD, address_family_ipv6_multicast_cmd, "address-family ipv6 multicast", "Enter Address Family command mode\n" - "Address family\n" + "Address Family\n" "Address Family Modifier\n") { vty->node = BGP_IPV6M_NODE; @@ -1302,7 +1237,7 @@ DEFUNSH (VTYSH_RIPD, DEFUNSH (VTYSH_RIPD, key, key_cmd, - "key <0-2147483647>", + "key (0-2147483647)", "Configure a key\n" "Key identifier number\n") { @@ -1335,27 +1270,20 @@ DEFUNSH (VTYSH_RIPNGD, DEFUNSH (VTYSH_OSPFD, router_ospf, router_ospf_cmd, - "router ospf", + "router ospf [(1-65535)]", "Enable a routing process\n" - "Start OSPF configuration\n") + "Start OSPF configuration\n" + "Instance ID\n") { vty->node = OSPF_NODE; return CMD_SUCCESS; } -ALIAS_SH (VTYSH_OSPFD, - router_ospf, - router_ospf_instance_cmd, - "router ospf <1-65535>", - "Enable a routing process\n" - "Start OSPF configuration\n" - "Instance ID\n") - DEFUNSH (VTYSH_OSPF6D, router_ospf6, router_ospf6_cmd, "router ospf6", - OSPF6_ROUTER_STR + ROUTER_STR OSPF6_STR) { vty->node = OSPF6_NODE; @@ -1459,7 +1387,7 @@ DEFUNSH (VTYSH_ISISD, DEFUNSH (VTYSH_RMAP, route_map, route_map_cmd, - "route-map WORD (deny|permit) <1-65535>", + "route-map WORD <deny|permit> (1-65535)", "Create route-map or enter route-map command mode\n" "Route map tag\n" "Route map denies set operations\n" @@ -1592,10 +1520,14 @@ DEFUNSH (VTYSH_REALLYALL, return vtysh_exit (vty); } -ALIAS (vtysh_exit_all, - vtysh_quit_all_cmd, - "quit", - "Exit current mode and down to previous mode\n") +DEFUNSH (VTYSH_ALL, + vtysh_quit_all, + vtysh_quit_all_cmd, + "quit", + "Exit current mode and down to previous mode\n") +{ + return vtysh_exit_all (self, vty, argc, argv); +} DEFUNSH (VTYSH_BGPD, exit_address_family, @@ -1637,10 +1569,14 @@ DEFUNSH (VTYSH_ZEBRA, return vtysh_exit (vty); } -ALIAS (vtysh_exit_zebra, - vtysh_quit_zebra_cmd, - "quit", - "Exit current mode and down to previous mode\n") +DEFUNSH (VTYSH_ZEBRA, + vtysh_quit_zebra, + vtysh_quit_zebra_cmd, + "quit", + "Exit current mode and down to previous mode\n") +{ + return vtysh_exit_zebra (self, vty, argc, argv); +} DEFUNSH (VTYSH_RIPD, vtysh_exit_ripd, @@ -1651,10 +1587,14 @@ DEFUNSH (VTYSH_RIPD, return vtysh_exit (vty); } -ALIAS (vtysh_exit_ripd, - vtysh_quit_ripd_cmd, - "quit", - "Exit current mode and down to previous mode\n") +DEFUNSH (VTYSH_RIPD, + vtysh_quit_ripd, + vtysh_quit_ripd_cmd, + "quit", + "Exit current mode and down to previous mode\n") +{ + return vtysh_exit_ripd (self, vty, argc, argv); +} DEFUNSH (VTYSH_RIPNGD, vtysh_exit_ripngd, @@ -1665,10 +1605,14 @@ DEFUNSH (VTYSH_RIPNGD, return vtysh_exit (vty); } -ALIAS (vtysh_exit_ripngd, - vtysh_quit_ripngd_cmd, - "quit", - "Exit current mode and down to previous mode\n") +DEFUNSH (VTYSH_RIPNGD, + vtysh_quit_ripngd, + vtysh_quit_ripngd_cmd, + "quit", + "Exit current mode and down to previous mode\n") +{ + return vtysh_exit_ripngd (self, vty, argc, argv); +} DEFUNSH (VTYSH_RMAP, vtysh_exit_rmap, @@ -1679,10 +1623,14 @@ DEFUNSH (VTYSH_RMAP, return vtysh_exit (vty); } -ALIAS (vtysh_exit_rmap, - vtysh_quit_rmap_cmd, - "quit", - "Exit current mode and down to previous mode\n") +DEFUNSH (VTYSH_RMAP, + vtysh_quit_rmap, + vtysh_quit_rmap_cmd, + "quit", + "Exit current mode and down to previous mode\n") +{ + return vtysh_exit_rmap (self, vty, argc, argv); +} DEFUNSH (VTYSH_BGPD, vtysh_exit_bgpd, @@ -1693,10 +1641,14 @@ DEFUNSH (VTYSH_BGPD, return vtysh_exit (vty); } -ALIAS (vtysh_exit_bgpd, - vtysh_quit_bgpd_cmd, - "quit", - "Exit current mode and down to previous mode\n") +DEFUNSH (VTYSH_BGPD, + vtysh_quit_bgpd, + vtysh_quit_bgpd_cmd, + "quit", + "Exit current mode and down to previous mode\n") +{ + return vtysh_exit_bgpd (self, vty, argc, argv); +} DEFUNSH (VTYSH_OSPFD, vtysh_exit_ospfd, @@ -1707,10 +1659,14 @@ DEFUNSH (VTYSH_OSPFD, return vtysh_exit (vty); } -ALIAS (vtysh_exit_ospfd, - vtysh_quit_ospfd_cmd, - "quit", - "Exit current mode and down to previous mode\n") +DEFUNSH (VTYSH_OSPFD, + vtysh_quit_ospfd, + vtysh_quit_ospfd_cmd, + "quit", + "Exit current mode and down to previous mode\n") +{ + return vtysh_exit_ospfd (self, vty, argc, argv); +} DEFUNSH (VTYSH_OSPF6D, vtysh_exit_ospf6d, @@ -1721,10 +1677,14 @@ DEFUNSH (VTYSH_OSPF6D, return vtysh_exit (vty); } -ALIAS (vtysh_exit_ospf6d, - vtysh_quit_ospf6d_cmd, - "quit", - "Exit current mode and down to previous mode\n") +DEFUNSH (VTYSH_OSPF6D, + vtysh_quit_ospf6d, + vtysh_quit_ospf6d_cmd, + "quit", + "Exit current mode and down to previous mode\n") +{ + return vtysh_exit_ospf6d (self, vty, argc, argv); +} #if defined (HAVE_LDPD) DEFUNSH (VTYSH_LDPD, @@ -1751,10 +1711,14 @@ DEFUNSH (VTYSH_ISISD, return vtysh_exit (vty); } -ALIAS (vtysh_exit_isisd, - vtysh_quit_isisd_cmd, - "quit", - "Exit current mode and down to previous mode\n") +DEFUNSH (VTYSH_ISISD, + vtysh_quit_isisd, + vtysh_quit_isisd_cmd, + "quit", + "Exit current mode and down to previous mode\n") +{ + return vtysh_exit_isisd (self, vty, argc, argv); +} DEFUNSH (VTYSH_ALL, vtysh_exit_line_vty, @@ -1765,30 +1729,27 @@ DEFUNSH (VTYSH_ALL, return vtysh_exit (vty); } -ALIAS (vtysh_exit_line_vty, - vtysh_quit_line_vty_cmd, - "quit", - "Exit current mode and down to previous mode\n") +DEFUNSH (VTYSH_ALL, + vtysh_quit_line_vty, + vtysh_quit_line_vty_cmd, + "quit", + "Exit current mode and down to previous mode\n") +{ + return vtysh_exit_line_vty (self, vty, argc, argv); +} DEFUNSH (VTYSH_INTERFACE, vtysh_interface, vtysh_interface_cmd, - "interface IFNAME", + "interface IFNAME [vrf NAME]", "Select an interface to configure\n" - "Interface's name\n") + "Interface's name\n" + VRF_CMD_HELP_STR) { vty->node = INTERFACE_NODE; return CMD_SUCCESS; } -ALIAS_SH (VTYSH_ZEBRA, - vtysh_interface, - vtysh_interface_vrf_cmd, - "interface IFNAME " VRF_CMD_STR, - "Select an interface to configure\n" - "Interface's name\n" - VRF_CMD_HELP_STR) - /* TODO Implement "no interface command in isisd. */ DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_LDPD, vtysh_no_interface_cmd, @@ -1799,7 +1760,7 @@ DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_LDPD, DEFSH (VTYSH_ZEBRA, vtysh_no_interface_vrf_cmd, - "no interface IFNAME " VRF_CMD_STR, + "no interface IFNAME vrf NAME", NO_STR "Delete a pseudo interface's configuration\n" "Interface's name\n" @@ -1808,7 +1769,7 @@ DEFSH (VTYSH_ZEBRA, DEFUNSH (VTYSH_NS, vtysh_ns, vtysh_ns_cmd, - "logical-router <1-65535 ns NAME", + "logical-router (1-65535) ns NAME", "Enable a logical-router\n" "Specify the logical-router indentifier\n" "The Name Space\n" @@ -1845,10 +1806,14 @@ DEFUNSH (VTYSH_NS, return vtysh_exit (vty); } -ALIAS (vtysh_exit_ns, - vtysh_quit_ns_cmd, - "quit", - "Exit current mode and down to previous mode\n") +DEFUNSH (VTYSH_NS, + vtysh_quit_ns, + vtysh_quit_ns_cmd, + "quit", + "Exit current mode and down to previous mode\n") +{ + return vtysh_quit_ns(self, vty, argc, argv); +} DEFUNSH (VTYSH_VRF, vtysh_exit_vrf, @@ -1859,16 +1824,20 @@ DEFUNSH (VTYSH_VRF, return vtysh_exit (vty); } -ALIAS (vtysh_exit_vrf, - vtysh_quit_vrf_cmd, - "quit", - "Exit current mode and down to previous mode\n") +DEFUNSH (VTYSH_VRF, + vtysh_quit_vrf, + vtysh_quit_vrf_cmd, + "quit", + "Exit current mode and down to previous mode\n") +{ + return vtysh_exit_vrf (self, vty, argc, argv); +} /* TODO Implement interface description commands in ripngd, ospf6d * and isisd. */ DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD|VTYSH_LDPD, interface_desc_cmd, - "description .LINE", + "description LINE...", "Interface specific description\n" "Characters describing this interface\n") @@ -1887,10 +1856,14 @@ DEFUNSH (VTYSH_INTERFACE, return vtysh_exit (vty); } -ALIAS (vtysh_exit_interface, - vtysh_quit_interface_cmd, - "quit", - "Exit current mode and down to previous mode\n") +DEFUNSH (VTYSH_INTERFACE, + vtysh_quit_interface, + vtysh_quit_interface_cmd, + "quit", + "Exit current mode and down to previous mode\n") +{ + return vtysh_exit_interface (self, vty, argc, argv); +} DEFUN (vtysh_show_thread, vtysh_show_thread_cmd, @@ -1900,11 +1873,12 @@ DEFUN (vtysh_show_thread, "Thread CPU usage\n" "Display filter (rwtexb)\n") { + int idx_filter = 3; unsigned int i; int ret = CMD_SUCCESS; char line[100]; - sprintf(line, "show thread cpu %s\n", (argc == 1) ? argv[0] : ""); + sprintf(line, "show thread cpu %s\n", (argc == 4) ? argv[idx_filter]->arg : ""); for (i = 0; i < array_size(vtysh_client); i++) if ( vtysh_client[i].fd >= 0 ) { @@ -1940,7 +1914,7 @@ DEFUN (vtysh_show_work_queues, DEFUN (vtysh_show_work_queues_daemon, vtysh_show_work_queues_daemon_cmd, - "show work-queues (zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd)", + "show work-queues <zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd>", SHOW_STR "Work Queue information\n" "For the zebra daemon\n" @@ -1951,12 +1925,13 @@ DEFUN (vtysh_show_work_queues_daemon, "For the bgp daemon\n" "For the isis daemon\n") { + int idx_protocol = 2; unsigned int i; int ret = CMD_SUCCESS; for (i = 0; i < array_size(vtysh_client); i++) { - if (begins_with(vtysh_client[i].name, argv[0])) + if (begins_with(vtysh_client[i].name, argv[idx_protocol]->arg)) break; } @@ -2035,7 +2010,7 @@ DEFUNSH (VTYSH_ALL, DEFUNSH (VTYSH_ALL, vtysh_log_stdout_level, vtysh_log_stdout_level_cmd, - "log stdout "LOG_LEVELS, + "log stdout <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>", "Logging control\n" "Set stdout logging level\n" LOG_LEVEL_DESC) @@ -2069,7 +2044,7 @@ DEFUNSH (VTYSH_ALL, DEFUNSH (VTYSH_ALL, vtysh_log_file_level, vtysh_log_file_level_cmd, - "log file FILENAME "LOG_LEVELS, + "log file FILENAME <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>", "Logging control\n" "Logging to file\n" "Logging filename\n" @@ -2081,42 +2056,23 @@ DEFUNSH (VTYSH_ALL, DEFUNSH (VTYSH_ALL, no_vtysh_log_file, no_vtysh_log_file_cmd, - "no log file [FILENAME]", + "no log file [FILENAME [LEVEL]]", NO_STR "Logging control\n" "Cancel logging to file\n" - "Logging file name\n") + "Logging file name\n" + "Logging level\n") { return CMD_SUCCESS; } -ALIAS_SH (VTYSH_ALL, - no_vtysh_log_file, - no_vtysh_log_file_level_cmd, - "no log file FILENAME LEVEL", - NO_STR - "Logging control\n" - "Cancel logging to file\n" - "Logging file name\n" - "Logging level\n") - DEFUNSH (VTYSH_ALL, vtysh_log_monitor, vtysh_log_monitor_cmd, - "log monitor", - "Logging control\n" - "Set terminal line (monitor) logging level\n") -{ - return CMD_SUCCESS; -} - -DEFUNSH (VTYSH_ALL, - vtysh_log_monitor_level, - vtysh_log_monitor_level_cmd, - "log monitor "LOG_LEVELS, + "log monitor [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]", "Logging control\n" "Set terminal line (monitor) logging level\n" - LOG_LEVEL_DESC) + LOG_LEVEL_DESC) { return CMD_SUCCESS; } @@ -2136,20 +2092,10 @@ DEFUNSH (VTYSH_ALL, DEFUNSH (VTYSH_ALL, vtysh_log_syslog, vtysh_log_syslog_cmd, - "log syslog", - "Logging control\n" - "Set syslog logging level\n") -{ - return CMD_SUCCESS; -} - -DEFUNSH (VTYSH_ALL, - vtysh_log_syslog_level, - vtysh_log_syslog_level_cmd, - "log syslog "LOG_LEVELS, + "log syslog <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>", "Logging control\n" "Set syslog logging level\n" - LOG_LEVEL_DESC) + LOG_LEVEL_DESC) { return CMD_SUCCESS; } @@ -2169,7 +2115,7 @@ DEFUNSH (VTYSH_ALL, DEFUNSH (VTYSH_ALL, vtysh_log_facility, vtysh_log_facility_cmd, - "log facility "LOG_FACILITIES, + "log facility <kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>", "Logging control\n" "Facility parameter for syslog messages\n" LOG_FACILITY_DESC) @@ -2194,7 +2140,7 @@ DEFUNSH (VTYSH_ALL, DEFUNSH_DEPRECATED (VTYSH_ALL, vtysh_log_trap, vtysh_log_trap_cmd, - "log trap "LOG_LEVELS, + "log trap <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>", "Logging control\n" "(Deprecated) Set logging level and default for all destinations\n" LOG_LEVEL_DESC) @@ -2239,7 +2185,7 @@ DEFUNSH (VTYSH_ALL, DEFUNSH (VTYSH_ALL, vtysh_log_timestamp_precision, vtysh_log_timestamp_precision_cmd, - "log timestamp precision <0-6>", + "log timestamp precision (0-6)", "Logging control\n" "Timestamp configuration\n" "Set the timestamp precision\n" @@ -2284,7 +2230,7 @@ DEFUNSH (VTYSH_ALL, DEFUNSH (VTYSH_ALL, vtysh_config_password, vtysh_password_cmd, - "password (8|) WORD", + "password (8-8) WORD", "Assign the terminal connection password\n" "Specifies a HIDDEN password will follow\n" "dummy string \n" @@ -2306,11 +2252,10 @@ DEFUNSH (VTYSH_ALL, DEFUNSH (VTYSH_ALL, vtysh_config_enable_password, vtysh_enable_password_cmd, - "enable password (8|) WORD", + "enable password (8-8) WORD", "Modify enable password parameters\n" "Assign the privileged level password\n" "Specifies a HIDDEN password will follow\n" - "dummy string \n" "The HIDDEN 'enable' password string\n") { return CMD_SUCCESS; @@ -2340,9 +2285,18 @@ DEFUNSH (VTYSH_ALL, DEFUN (vtysh_write_terminal, vtysh_write_terminal_cmd, - "write terminal", + "write terminal [<zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd>]", "Write running configuration to memory, network, or terminal\n" - "Write to terminal\n") + "Write to terminal\n" + "For the zebra daemon\n" + "For the rip daemon\n" + "For the ripng daemon\n" + "For the ospf daemon\n" + "For the ospfv6 daemon\n" + "For the ldpd daemon\n" + "For the bgp daemon\n" + "For the isis daemon\n" + "For the pim daemon\n") { u_int i; char line[] = "write terminal\n"; @@ -2352,21 +2306,21 @@ DEFUN (vtysh_write_terminal, { fp = popen (vtysh_pager_name, "w"); if (fp == NULL) - { - perror ("popen"); - exit (1); - } + { + perror ("popen"); + exit (1); + } } else fp = stdout; vty_out (vty, "Building configuration...%s", VTY_NEWLINE); vty_out (vty, "%sCurrent configuration:%s", VTY_NEWLINE, - VTY_NEWLINE); + VTY_NEWLINE); vty_out (vty, "!%s", VTY_NEWLINE); for (i = 0; i < array_size(vtysh_client); i++) - if ((argc < 1 ) || (begins_with(vtysh_client[i].name, argv[0]))) + if ((argc < 3 ) || (strmatch (vtysh_client[i].name, argv[2]->text))) vtysh_client_config (&vtysh_client[i], line); /* Integrate vtysh specific configuration. */ @@ -2378,23 +2332,22 @@ DEFUN (vtysh_write_terminal, { fflush (fp); if (pclose (fp) == -1) - { - perror ("pclose"); - exit (1); - } + { + perror ("pclose"); + exit (1); + } fp = NULL; } vty_out (vty, "end%s", VTY_NEWLINE); - return CMD_SUCCESS; } -DEFUN (vtysh_write_terminal_daemon, - vtysh_write_terminal_daemon_cmd, - "write terminal (zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd)", - "Write running configuration to memory, network, or terminal\n" - "Write to terminal\n" +DEFUN (vtysh_show_running_config, + vtysh_show_running_config_cmd, + "show running-config [<zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd>]", + SHOW_STR + "Current operating configuration\n" "For the zebra daemon\n" "For the rip daemon\n" "For the ripng daemon\n" @@ -2405,21 +2358,7 @@ DEFUN (vtysh_write_terminal_daemon, "For the isis daemon\n" "For the pim daemon\n") { - unsigned int i; - int ret = CMD_SUCCESS; - - for (i = 0; i < array_size(vtysh_client); i++) - { - if (begins_with(vtysh_client[i].name, argv[0])) - break; - } - - if (i == array_size(vtysh_client)) - return CMD_ERR_NO_MATCH; - - ret = vtysh_client_execute(&vtysh_client[i], "show running-config\n", stdout); - - return ret; + return vtysh_write_terminal (self, vty, argc, argv); } DEFUN (vtysh_integrated_config, @@ -2566,9 +2505,10 @@ static bool want_config_integrated(void) DEFUN (vtysh_write_memory, vtysh_write_memory_cmd, - "write memory", + "write [<memory|file>]", "Write running configuration to memory, network, or terminal\n" - "Write configuration to the file (same as write file)\n") + "Write configuration to the file (same as write file)\n" + "Write configuration to the file (same as write memory)\n") { int ret = CMD_SUCCESS; char line[] = "write memory\n"; @@ -2604,57 +2544,29 @@ DEFUN (vtysh_write_memory, return ret; } -ALIAS (vtysh_write_memory, - vtysh_copy_runningconfig_startupconfig_cmd, - "copy running-config startup-config", +DEFUN (vtysh_copy_running_config, + vtysh_copy_running_config_cmd, + "copy running-config startup-config", "Copy from one file to another\n" "Copy from current system configuration\n" "Copy to startup configuration\n") - -ALIAS (vtysh_write_memory, - vtysh_write_file_cmd, - "write file", - "Write running configuration to memory, network, or terminal\n" - "Write configuration to the file (same as write memory)\n") - -ALIAS (vtysh_write_memory, - vtysh_write_cmd, - "write", - "Write running configuration to memory, network, or terminal\n") - -ALIAS (vtysh_write_terminal, - vtysh_show_running_config_cmd, - "show running-config", - SHOW_STR - "Current operating configuration\n") - -ALIAS (vtysh_write_terminal, - vtysh_show_running_config_daemon_cmd, - "show running-config (zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd)", - SHOW_STR - "Current operating configuration\n" - "For the zebra daemon\n" - "For the rip daemon\n" - "For the ripng daemon\n" - "For the ospf daemon\n" - "For the ospfv6 daemon\n" - "For the ldp daemon\n" - "For the bgp daemon\n" - "For the isis daemon\n" - "For the pim daemon\n") +{ + return vtysh_write_memory (self, vty, argc, argv); +} DEFUN (vtysh_terminal_length, vtysh_terminal_length_cmd, - "terminal length <0-512>", + "terminal length (0-512)", "Set terminal line parameters\n" "Set number of lines on a screen\n" "Number of lines on screen (0 for no pausing)\n") { + int idx_number = 2; int lines; char *endptr = NULL; char default_pager[10]; - lines = strtol (argv[0], &endptr, 10); + lines = strtol (argv[idx_number]->arg, &endptr, 10); if (lines < 0 || lines > 512 || *endptr != '\0') { vty_out (vty, "length is malformed%s", VTY_NEWLINE); @@ -2711,7 +2623,7 @@ DEFUN (vtysh_show_daemons, /* Execute command in child process. */ static void -execute_command (const char *command, int argc, const char *arg1, +execute_command (const char *command, int argc, struct cmd_token *arg1, const char *arg2) { pid_t pid; @@ -3188,7 +3100,6 @@ vtysh_init_vty (void) /* "exit" command. */ install_element (VIEW_NODE, &vtysh_exit_all_cmd); - install_element (VIEW_NODE, &vtysh_quit_all_cmd); install_element (CONFIG_NODE, &vtysh_exit_all_cmd); /* install_element (CONFIG_NODE, &vtysh_quit_all_cmd); */ install_element (RIP_NODE, &vtysh_exit_ripd_cmd); @@ -3303,7 +3214,6 @@ vtysh_init_vty (void) install_element (CONFIG_NODE, &router_rip_cmd); install_element (CONFIG_NODE, &router_ripng_cmd); install_element (CONFIG_NODE, &router_ospf_cmd); - install_element (CONFIG_NODE, &router_ospf_instance_cmd); install_element (CONFIG_NODE, &router_ospf6_cmd); #if defined (HAVE_LDPD) install_element (CONFIG_NODE, &ldp_mpls_ldp_cmd); @@ -3316,13 +3226,9 @@ vtysh_init_vty (void) #endif install_element (CONFIG_NODE, &router_isis_cmd); install_element (CONFIG_NODE, &router_bgp_cmd); - install_element (CONFIG_NODE, &router_bgp_asn_cmd); - install_element (CONFIG_NODE, &router_bgp_view_cmd); install_element (BGP_NODE, &address_family_vpnv4_cmd); - install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd); install_element (BGP_NODE, &address_family_vpnv6_cmd); - install_element (BGP_NODE, &address_family_vpnv6_unicast_cmd); - install_element (BGP_NODE, &address_family_encap_cmd); + install_element (BGP_NODE, &address_family_encapv4_cmd); install_element (BGP_NODE, &address_family_encapv6_cmd); #if defined(ENABLE_BGP_VNC) install_element (BGP_NODE, &vnc_defaults_cmd); @@ -3330,11 +3236,8 @@ vtysh_init_vty (void) #endif install_element (BGP_NODE, &address_family_ipv4_unicast_cmd); install_element (BGP_NODE, &address_family_ipv4_multicast_cmd); -#ifdef HAVE_IPV6 install_element (BGP_NODE, &address_family_ipv6_cmd); - install_element (BGP_NODE, &address_family_ipv6_unicast_cmd); install_element (BGP_NODE, &address_family_ipv6_multicast_cmd); -#endif install_element (BGP_VPNV4_NODE, &exit_address_family_cmd); install_element (BGP_VPNV6_NODE, &exit_address_family_cmd); install_element (BGP_ENCAP_NODE, &exit_address_family_cmd); @@ -3356,21 +3259,16 @@ vtysh_init_vty (void) install_element (KEYCHAIN_KEY_NODE, &key_chain_cmd); install_element (CONFIG_NODE, &vtysh_interface_cmd); install_element (CONFIG_NODE, &vtysh_no_interface_cmd); - install_element (CONFIG_NODE, &vtysh_interface_vrf_cmd); install_element (CONFIG_NODE, &vtysh_no_interface_vrf_cmd); install_element (INTERFACE_NODE, &vtysh_link_params_cmd); install_element (ENABLE_NODE, &vtysh_show_running_config_cmd); - install_element (ENABLE_NODE, &vtysh_show_running_config_daemon_cmd); - install_element (ENABLE_NODE, &vtysh_copy_runningconfig_startupconfig_cmd); - install_element (ENABLE_NODE, &vtysh_write_file_cmd); - install_element (ENABLE_NODE, &vtysh_write_cmd); + install_element (ENABLE_NODE, &vtysh_copy_running_config_cmd); install_element (CONFIG_NODE, &vtysh_vrf_cmd); install_element (CONFIG_NODE, &vtysh_no_vrf_cmd); /* "write terminal" command. */ install_element (ENABLE_NODE, &vtysh_write_terminal_cmd); - install_element (ENABLE_NODE, &vtysh_write_terminal_daemon_cmd); install_element (CONFIG_NODE, &vtysh_integrated_config_cmd); install_element (CONFIG_NODE, &no_vtysh_integrated_config_cmd); @@ -3414,12 +3312,9 @@ vtysh_init_vty (void) install_element (CONFIG_NODE, &vtysh_log_file_cmd); install_element (CONFIG_NODE, &vtysh_log_file_level_cmd); install_element (CONFIG_NODE, &no_vtysh_log_file_cmd); - install_element (CONFIG_NODE, &no_vtysh_log_file_level_cmd); install_element (CONFIG_NODE, &vtysh_log_monitor_cmd); - install_element (CONFIG_NODE, &vtysh_log_monitor_level_cmd); install_element (CONFIG_NODE, &no_vtysh_log_monitor_cmd); install_element (CONFIG_NODE, &vtysh_log_syslog_cmd); - install_element (CONFIG_NODE, &vtysh_log_syslog_level_cmd); install_element (CONFIG_NODE, &no_vtysh_log_syslog_cmd); install_element (CONFIG_NODE, &vtysh_log_trap_cmd); install_element (CONFIG_NODE, &no_vtysh_log_trap_cmd); @@ -3438,5 +3333,4 @@ vtysh_init_vty (void) install_element (CONFIG_NODE, &vtysh_enable_password_cmd); install_element (CONFIG_NODE, &vtysh_enable_password_text_cmd); install_element (CONFIG_NODE, &no_vtysh_enable_password_cmd); - } diff --git a/vtysh/vtysh_user.c b/vtysh/vtysh_user.c index 1886ba3a67..b1ba1a24ae 100644 --- a/vtysh/vtysh_user.c +++ b/vtysh/vtysh_user.c @@ -173,7 +173,8 @@ DEFUN (banner_motd_file, "Banner from a file\n" "Filename\n") { - return cmd_banner_motd_file (argv[0]); + int idx_file = 3; + return cmd_banner_motd_file (argv[idx_file]->arg); } DEFUN (username_nopassword, @@ -183,8 +184,9 @@ DEFUN (username_nopassword, "\n" "\n") { + int idx_word = 1; struct vtysh_user *user; - user = user_get (argv[0]); + user = user_get (argv[idx_word]->arg); user->nopassword = 1; return CMD_SUCCESS; } diff --git a/ylwrap b/ylwrap new file mode 100755 index 0000000000..8f072a8e97 --- /dev/null +++ b/ylwrap @@ -0,0 +1,247 @@ +#! /bin/sh +# ylwrap - wrapper for lex/yacc invocations. + +scriptversion=2013-01-12.17; # UTC + +# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# +# Written by Tom Tromey <tromey@cygnus.com>. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to <bug-automake@gnu.org> or send patches to +# <automake-patches@gnu.org>. + +get_dirname () +{ + case $1 in + */*|*\\*) printf '%s\n' "$1" | sed -e 's|\([\\/]\)[^\\/]*$|\1|';; + # Otherwise, we want the empty string (not "."). + esac +} + +# guard FILE +# ---------- +# The CPP macro used to guard inclusion of FILE. +guard () +{ + printf '%s\n' "$1" \ + | sed \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ + -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g' \ + -e 's/__*/_/g' +} + +# quote_for_sed [STRING] +# ---------------------- +# Return STRING (or stdin) quoted to be used as a sed pattern. +quote_for_sed () +{ + case $# in + 0) cat;; + 1) printf '%s\n' "$1";; + esac \ + | sed -e 's|[][\\.*]|\\&|g' +} + +case "$1" in + '') + echo "$0: No files given. Try '$0 --help' for more information." 1>&2 + exit 1 + ;; + --basedir) + basedir=$2 + shift 2 + ;; + -h|--h*) + cat <<\EOF +Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... + +Wrapper for lex/yacc invocations, renaming files as desired. + + INPUT is the input file + OUTPUT is one file PROG generates + DESIRED is the file we actually want instead of OUTPUT + PROGRAM is program to run + ARGS are passed to PROG + +Any number of OUTPUT,DESIRED pairs may be used. + +Report bugs to <bug-automake@gnu.org>. +EOF + exit $? + ;; + -v|--v*) + echo "ylwrap $scriptversion" + exit $? + ;; +esac + + +# The input. +input=$1 +shift +# We'll later need for a correct munging of "#line" directives. +input_sub_rx=`get_dirname "$input" | quote_for_sed` +case $input in + [\\/]* | ?:[\\/]*) + # Absolute path; do nothing. + ;; + *) + # Relative path. Make it absolute. + input=`pwd`/$input + ;; +esac +input_rx=`get_dirname "$input" | quote_for_sed` + +# Since DOS filename conventions don't allow two dots, +# the DOS version of Bison writes out y_tab.c instead of y.tab.c +# and y_tab.h instead of y.tab.h. Test to see if this is the case. +y_tab_nodot=false +if test -f y_tab.c || test -f y_tab.h; then + y_tab_nodot=true +fi + +# The parser itself, the first file, is the destination of the .y.c +# rule in the Makefile. +parser=$1 + +# A sed program to s/FROM/TO/g for all the FROM/TO so that, for +# instance, we rename #include "y.tab.h" into #include "parse.h" +# during the conversion from y.tab.c to parse.c. +sed_fix_filenames= + +# Also rename header guards, as Bison 2.7 for instance uses its header +# guard in its implementation file. +sed_fix_header_guards= + +while test $# -ne 0; do + if test x"$1" = x"--"; then + shift + break + fi + from=$1 + # Handle y_tab.c and y_tab.h output by DOS + if $y_tab_nodot; then + case $from in + "y.tab.c") from=y_tab.c;; + "y.tab.h") from=y_tab.h;; + esac + fi + shift + to=$1 + shift + sed_fix_filenames="${sed_fix_filenames}s|"`quote_for_sed "$from"`"|$to|g;" + sed_fix_header_guards="${sed_fix_header_guards}s|"`guard "$from"`"|"`guard "$to"`"|g;" +done + +# The program to run. +prog=$1 +shift +# Make any relative path in $prog absolute. +case $prog in + [\\/]* | ?:[\\/]*) ;; + *[\\/]*) prog=`pwd`/$prog ;; +esac + +dirname=ylwrap$$ +do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret' +trap "ret=129; $do_exit" 1 +trap "ret=130; $do_exit" 2 +trap "ret=141; $do_exit" 13 +trap "ret=143; $do_exit" 15 +mkdir $dirname || exit 1 + +cd $dirname + +case $# in + 0) "$prog" "$input" ;; + *) "$prog" "$@" "$input" ;; +esac +ret=$? + +if test $ret -eq 0; then + for from in * + do + to=`printf '%s\n' "$from" | sed "$sed_fix_filenames"` + if test -f "$from"; then + # If $2 is an absolute path name, then just use that, + # otherwise prepend '../'. + case $to in + [\\/]* | ?:[\\/]*) target=$to;; + *) target=../$to;; + esac + + # Do not overwrite unchanged header files to avoid useless + # recompilations. Always update the parser itself: it is the + # destination of the .y.c rule in the Makefile. Divert the + # output of all other files to a temporary file so we can + # compare them to existing versions. + if test $from != $parser; then + realtarget=$target + target=tmp-`printf '%s\n' "$target" | sed 's|.*[\\/]||g'` + fi + + # Munge "#line" or "#" directives. Don't let the resulting + # debug information point at an absolute srcdir. Use the real + # output file name, not yy.lex.c for instance. Adjust the + # include guards too. + sed -e "/^#/!b" \ + -e "s|$input_rx|$input_sub_rx|" \ + -e "$sed_fix_filenames" \ + -e "$sed_fix_header_guards" \ + "$from" >"$target" || ret=$? + + # Check whether files must be updated. + if test "$from" != "$parser"; then + if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then + echo "$to is unchanged" + rm -f "$target" + else + echo "updating $to" + mv -f "$target" "$realtarget" + fi + fi + else + # A missing file is only an error for the parser. This is a + # blatant hack to let us support using "yacc -d". If -d is not + # specified, don't fail when the header file is "missing". + if test "$from" = "$parser"; then + ret=1 + fi + fi + done +fi + +# Remove the directory. +cd .. +rm -rf $dirname + +exit $ret + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/zebra/connected.c b/zebra/connected.c index 55c3792d4f..bc54aab01c 100644 --- a/zebra/connected.c +++ b/zebra/connected.c @@ -32,6 +32,7 @@ #include "memory.h" #include "zebra_memory.h" +#include "vty.h" #include "zebra/debug.h" #include "zebra/zserv.h" #include "zebra/redistribute.h" diff --git a/zebra/debug.c b/zebra/debug.c index 93cd4dd9c6..2e9fef292b 100644 --- a/zebra/debug.c +++ b/zebra/debug.c @@ -124,52 +124,31 @@ DEFUN (debug_zebra_mpls, DEFUN (debug_zebra_packet, debug_zebra_packet_cmd, - "debug zebra packet", - DEBUG_STR - "Zebra configuration\n" - "Debug option set for zebra packet\n") -{ - zebra_debug_packet = ZEBRA_DEBUG_PACKET; - SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND); - SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV); - return CMD_SUCCESS; -} - -DEFUN (debug_zebra_packet_direct, - debug_zebra_packet_direct_cmd, - "debug zebra packet (recv|send|detail)", + "debug zebra packet [<recv|send>] [detail]", DEBUG_STR "Zebra configuration\n" "Debug option set for zebra packet\n" "Debug option set for receive packet\n" - "Debug option set for send packet\n") + "Debug option set for send packet\n" + "Debug option set for detailed info\n") { + int idx = 0; zebra_debug_packet = ZEBRA_DEBUG_PACKET; - if (strncmp ("send", argv[0], strlen (argv[0])) == 0) + + if (argv_find (argv, argc, "send", &idx)) SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND); - if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) + idx = 0; + if (argv_find (argv, argc, "recv", &idx)) SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV); - if (strncmp ("detail", argv[0], strlen (argv[0])) == 0) + idx = 0; + if (argv_find (argv, argc, "detail", &idx)) SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL); - return CMD_SUCCESS; -} -DEFUN (debug_zebra_packet_detail, - debug_zebra_packet_detail_cmd, - "debug zebra packet (recv|send) detail", - DEBUG_STR - "Zebra configuration\n" - "Debug option set for zebra packet\n" - "Debug option set for receive packet\n" - "Debug option set for send packet\n" - "Debug option set detailed information\n") -{ - zebra_debug_packet = ZEBRA_DEBUG_PACKET; - if (strncmp ("send", argv[0], strlen (argv[0])) == 0) + if (!(zebra_debug_packet & ZEBRA_DEBUG_SEND & ZEBRA_DEBUG_RECV)) + { SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND); - if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV); - SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL); + } return CMD_SUCCESS; } @@ -186,7 +165,7 @@ DEFUN (debug_zebra_kernel, DEFUN (debug_zebra_kernel_msgdump, debug_zebra_kernel_msgdump_cmd, - "debug zebra kernel msgdump {recv|send}", + "debug zebra kernel msgdump [<recv|send>]", DEBUG_STR "Zebra configuration\n" "Debug option set for zebra between kernel interface\n" @@ -194,9 +173,10 @@ DEFUN (debug_zebra_kernel_msgdump, "Dump raw netlink messages received\n" "Dump raw netlink messages sent\n") { - if (!argv[1] || (argv[0] && strncmp(argv[0], "recv", strlen(argv[0])) == 0)) + int idx_recv_send = 4; + if (argv[idx_recv_send]->arg && strncmp(argv[idx_recv_send]->arg, "recv", strlen(argv[idx_recv_send]->arg)) == 0) SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV); - if (!argv[0] || (argv[1] && strncmp(argv[1], "send", strlen(argv[1])) == 0)) + if (!argv[idx_recv_send]->arg || strncmp(argv[idx_recv_send]->arg, "send", strlen(argv[idx_recv_send]->arg)) == 0) SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND); return CMD_SUCCESS; } @@ -273,19 +253,7 @@ DEFUN (no_debug_zebra_mpls, DEFUN (no_debug_zebra_packet, no_debug_zebra_packet_cmd, - "no debug zebra packet", - NO_STR - DEBUG_STR - "Zebra configuration\n" - "Debug option set for zebra packet\n") -{ - zebra_debug_packet = 0; - return CMD_SUCCESS; -} - -DEFUN (no_debug_zebra_packet_direct, - no_debug_zebra_packet_direct_cmd, - "no debug zebra packet (recv|send)", + "no debug zebra packet [<recv|send>]", NO_STR DEBUG_STR "Zebra configuration\n" @@ -293,9 +261,10 @@ DEFUN (no_debug_zebra_packet_direct, "Debug option set for receive packet\n" "Debug option set for send packet\n") { - if (strncmp ("send", argv[0], strlen (argv[0])) == 0) + int idx = 0; + if (argc == 4 || argv_find (argv, argc, "send", &idx)) UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND); - if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) + if (argc == 4 || argv_find (argv, argc, "recv", &idx)) UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV); return CMD_SUCCESS; } @@ -314,7 +283,8 @@ DEFUN (no_debug_zebra_kernel, DEFUN (no_debug_zebra_kernel_msgdump, no_debug_zebra_kernel_msgdump_cmd, - "no debug zebra kernel msgdump {recv|send}", + "no debug zebra kernel msgdump [<recv|send>]", + NO_STR DEBUG_STR "Zebra configuration\n" "Debug option set for zebra between kernel interface\n" @@ -322,10 +292,12 @@ DEFUN (no_debug_zebra_kernel_msgdump, "Dump raw netlink messages received\n" "Dump raw netlink messages sent\n") { - if (!argv[1] || (argv[0] && strncmp(argv[0], "recv", strlen(argv[0])) == 0)) + int idx = 0; + if (argc == 5 || argv_find (argv, argc, "recv", &idx)) UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV); - if (!argv[0] || (argv[1] && strncmp(argv[1], "send", strlen(argv[1])) == 0)) + if (argc == 5 || argv_find (argv, argc, "send", &idx)) UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND); + return CMD_SUCCESS; } @@ -453,8 +425,6 @@ zebra_debug_init (void) install_element (ENABLE_NODE, &debug_zebra_nht_cmd); install_element (ENABLE_NODE, &debug_zebra_mpls_cmd); install_element (ENABLE_NODE, &debug_zebra_packet_cmd); - install_element (ENABLE_NODE, &debug_zebra_packet_direct_cmd); - install_element (ENABLE_NODE, &debug_zebra_packet_detail_cmd); install_element (ENABLE_NODE, &debug_zebra_kernel_cmd); install_element (ENABLE_NODE, &debug_zebra_kernel_msgdump_cmd); install_element (ENABLE_NODE, &debug_zebra_rib_cmd); @@ -474,8 +444,6 @@ zebra_debug_init (void) install_element (CONFIG_NODE, &debug_zebra_nht_cmd); install_element (CONFIG_NODE, &debug_zebra_mpls_cmd); install_element (CONFIG_NODE, &debug_zebra_packet_cmd); - install_element (CONFIG_NODE, &debug_zebra_packet_direct_cmd); - install_element (CONFIG_NODE, &debug_zebra_packet_detail_cmd); install_element (CONFIG_NODE, &debug_zebra_kernel_cmd); install_element (CONFIG_NODE, &debug_zebra_kernel_msgdump_cmd); install_element (CONFIG_NODE, &debug_zebra_rib_cmd); diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index c44219a495..f7f6334a77 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -38,6 +38,7 @@ #include "vrf.h" #include "mpls.h" +#include "vty.h" #include "zebra/zserv.h" #include "zebra/zebra_ns.h" #include "zebra/zebra_vrf.h" diff --git a/zebra/interface.c b/zebra/interface.c index 0f4d2ee9e4..bbe19fbaf4 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -1233,7 +1233,7 @@ DEFUN_NOSH (zebra_interface, "Interface's name\n") { int ret; - + /* Call lib interface() */ if ((ret = interface_cmd.func (self, vty, argc, argv)) != CMD_SUCCESS) return ret; @@ -1248,13 +1248,6 @@ DEFUN_NOSH (zebra_interface, return ret; } -ALIAS (zebra_interface, - zebra_interface_vrf_cmd, - "interface IFNAME " VRF_CMD_STR, - "Select an interface to configure\n" - "Interface's name\n" - VRF_CMD_HELP_STR) - static void interface_update_stats (void) { @@ -1303,10 +1296,12 @@ struct cmd_node vrf_node = }; /* Show all interfaces to vty. */ -DEFUN (show_interface, show_interface_cmd, - "show interface", +DEFUN (show_interface, + show_interface_cmd, + "show interface [vrf NAME]", SHOW_STR - "Interface status and configuration\n") + "Interface status and configuration\n" + VRF_CMD_HELP_STR) { struct listnode *node; struct interface *ifp; @@ -1314,8 +1309,8 @@ DEFUN (show_interface, show_interface_cmd, interface_update_stats (); - if (argc > 0) - VRF_GET_ID (vrf_id, argv[0]); + if (argc > 2) + VRF_GET_ID (vrf_id, argv[3]->arg); /* All interface print. */ for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), node, ifp)) @@ -1324,16 +1319,11 @@ DEFUN (show_interface, show_interface_cmd, return CMD_SUCCESS; } -ALIAS (show_interface, - show_interface_vrf_cmd, - "show interface " VRF_CMD_STR, - SHOW_STR - "Interface status and configuration\n" - VRF_CMD_HELP_STR) /* Show all interfaces to vty. */ -DEFUN (show_interface_vrf_all, show_interface_vrf_all_cmd, - "show interface " VRF_ALL_CMD_STR, +DEFUN (show_interface_vrf_all, + show_interface_vrf_all_cmd, + "show interface vrf all", SHOW_STR "Interface status and configuration\n" VRF_ALL_CMD_HELP_STR) @@ -1356,25 +1346,26 @@ DEFUN (show_interface_vrf_all, show_interface_vrf_all_cmd, DEFUN (show_interface_name_vrf, show_interface_name_vrf_cmd, - "show interface IFNAME " VRF_CMD_STR, + "show interface IFNAME vrf NAME", SHOW_STR "Interface status and configuration\n" "Interface name\n" VRF_CMD_HELP_STR) { + int idx_ifname = 2; + int idx_name = 4; struct interface *ifp; vrf_id_t vrf_id = VRF_DEFAULT; interface_update_stats (); - if (argc > 1) - VRF_GET_ID (vrf_id, argv[1]); + VRF_GET_ID (vrf_id, argv[idx_name]->arg); /* Specified interface print. */ - ifp = if_lookup_by_name_vrf (argv[0], vrf_id); + ifp = if_lookup_by_name_vrf (argv[idx_ifname]->arg, vrf_id); if (ifp == NULL) { - vty_out (vty, "%% Can't find interface %s%s", argv[0], + vty_out (vty, "%% Can't find interface %s%s", argv[idx_ifname]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -1384,13 +1375,15 @@ DEFUN (show_interface_name_vrf, } /* Show specified interface to vty. */ -DEFUN (show_interface_name_vrf_all, show_interface_name_vrf_all_cmd, - "show interface IFNAME " VRF_ALL_CMD_STR, +DEFUN (show_interface_name_vrf_all, + show_interface_name_vrf_all_cmd, + "show interface IFNAME [vrf all]", SHOW_STR "Interface status and configuration\n" "Interface name\n" VRF_ALL_CMD_HELP_STR) { + int idx_ifname = 2; struct interface *ifp; vrf_iter_t iter; int found = 0; @@ -1401,7 +1394,7 @@ DEFUN (show_interface_name_vrf_all, show_interface_name_vrf_all_cmd, for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) { /* Specified interface print. */ - ifp = if_lookup_by_name_vrf (argv[0], vrf_iter2id (iter)); + ifp = if_lookup_by_name_vrf (argv[idx_ifname]->arg, vrf_iter2id (iter)); if (ifp) { if_dump_vty (vty, ifp); @@ -1411,18 +1404,13 @@ DEFUN (show_interface_name_vrf_all, show_interface_name_vrf_all_cmd, if (!found) { - vty_out (vty, "%% Can't find interface %s%s", argv[0], VTY_NEWLINE); + vty_out (vty, "%% Can't find interface %s%s", argv[idx_ifname]->arg, VTY_NEWLINE); return CMD_WARNING; } return CMD_SUCCESS; } -ALIAS (show_interface_name_vrf_all, show_interface_name_cmd, - "show interface IFNAME", - SHOW_STR - "Interface status and configuration\n" - "Interface name\n") static void if_show_description (struct vty *vty, vrf_id_t vrf_id) @@ -1466,32 +1454,26 @@ if_show_description (struct vty *vty, vrf_id_t vrf_id) DEFUN (show_interface_desc, show_interface_desc_cmd, - "show interface description", + "show interface description [vrf NAME]", SHOW_STR "Interface status and configuration\n" - "Interface description\n") + "Interface description\n" + VRF_CMD_HELP_STR) { vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 0) - VRF_GET_ID (vrf_id, argv[0]); + if (argc > 3) + VRF_GET_ID (vrf_id, argv[4]->arg); if_show_description (vty, vrf_id); return CMD_SUCCESS; } -ALIAS (show_interface_desc, - show_interface_desc_vrf_cmd, - "show interface description " VRF_CMD_STR, - SHOW_STR - "Interface status and configuration\n" - "Interface description\n" - VRF_CMD_HELP_STR) DEFUN (show_interface_desc_vrf_all, show_interface_desc_vrf_all_cmd, - "show interface description " VRF_ALL_CMD_STR, + "show interface description vrf all", SHOW_STR "Interface status and configuration\n" "Interface description\n" @@ -1569,7 +1551,7 @@ DEFUN (linkdetect, { VTY_DECLVAR_CONTEXT (interface, ifp); int if_was_operative; - + if_was_operative = if_is_no_ptm_operative(ifp); SET_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION); @@ -1662,14 +1644,15 @@ DEFUN (no_shutdown_if, DEFUN (bandwidth_if, bandwidth_if_cmd, - "bandwidth <1-100000>", + "bandwidth (1-100000)", "Set bandwidth informational parameter\n" "Bandwidth in megabits\n") { + int idx_number = 1; VTY_DECLVAR_CONTEXT (interface, ifp); unsigned int bandwidth; - - bandwidth = strtol(argv[0], NULL, 10); + + bandwidth = strtol(argv[idx_number]->arg, NULL, 10); /* bandwidth range is <1-100000> */ if (bandwidth < 1 || bandwidth > 100000) @@ -1689,9 +1672,10 @@ DEFUN (bandwidth_if, DEFUN (no_bandwidth_if, no_bandwidth_if_cmd, - "no bandwidth", + "no bandwidth [(1-100000)]", NO_STR - "Set bandwidth informational parameter\n") + "Set bandwidth informational parameter\n" + "Bandwidth in megabits\n") { VTY_DECLVAR_CONTEXT (interface, ifp); @@ -1704,12 +1688,6 @@ DEFUN (no_bandwidth_if, return CMD_SUCCESS; } -ALIAS (no_bandwidth_if, - no_bandwidth_if_val_cmd, - "no bandwidth <1-100000>", - NO_STR - "Set bandwidth informational parameter\n" - "Bandwidth in megabits\n") struct cmd_node link_params_node = { @@ -1824,15 +1802,16 @@ DEFUN (no_link_params_enable, /* STANDARD TE metrics */ DEFUN (link_params_metric, link_params_metric_cmd, - "metric <0-4294967295>", + "metric (0-4294967295)", "Link metric for MPLS-TE purpose\n" "Metric value in decimal\n") { + int idx_number = 1; VTY_DECLVAR_CONTEXT (interface, ifp); struct if_link_params *iflp = if_link_params_get (ifp); u_int32_t metric; - VTY_GET_ULONG("metric", metric, argv[0]); + VTY_GET_ULONG("metric", metric, argv[idx_number]->arg); /* Update TE metric if needed */ link_param_cmd_set_uint32 (ifp, &iflp->te_metric, LP_TE, metric); @@ -1860,12 +1839,13 @@ DEFUN (link_params_maxbw, "Maximum bandwidth that can be used\n" "Bytes/second (IEEE floating point format)\n") { + int idx_bandwidth = 1; VTY_DECLVAR_CONTEXT (interface, ifp); struct if_link_params *iflp = if_link_params_get (ifp); float bw; - if (sscanf (argv[0], "%g", &bw) != 1) + if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) { vty_out (vty, "link_params_maxbw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -1904,11 +1884,12 @@ DEFUN (link_params_max_rsv_bw, "Maximum bandwidth that may be reserved\n" "Bytes/second (IEEE floating point format)\n") { + int idx_bandwidth = 1; VTY_DECLVAR_CONTEXT (interface, ifp); struct if_link_params *iflp = if_link_params_get (ifp); float bw; - if (sscanf (argv[0], "%g", &bw) != 1) + if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) { vty_out (vty, "link_params_max_rsv_bw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -1932,25 +1913,27 @@ DEFUN (link_params_max_rsv_bw, DEFUN (link_params_unrsv_bw, link_params_unrsv_bw_cmd, - "unrsv-bw <0-7> BANDWIDTH", + "unrsv-bw (0-7) BANDWIDTH", "Unreserved bandwidth at each priority level\n" "Priority\n" "Bytes/second (IEEE floating point format)\n") { + int idx_number = 1; + int idx_bandwidth = 2; VTY_DECLVAR_CONTEXT (interface, ifp); struct if_link_params *iflp = if_link_params_get (ifp); int priority; float bw; /* We don't have to consider about range check here. */ - if (sscanf (argv[0], "%d", &priority) != 1) + if (sscanf (argv[idx_number]->arg, "%d", &priority) != 1) { vty_out (vty, "link_params_unrsv_bw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); return CMD_WARNING; } - if (sscanf (argv[1], "%g", &bw) != 1) + if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) { vty_out (vty, "link_params_unrsv_bw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -1978,11 +1961,12 @@ DEFUN (link_params_admin_grp, "Administrative group membership\n" "32-bit Hexadecimal value (e.g. 0xa1)\n") { + int idx_bitpattern = 1; VTY_DECLVAR_CONTEXT (interface, ifp); struct if_link_params *iflp = if_link_params_get (ifp); unsigned long value; - if (sscanf (argv[0], "0x%lx", &value) != 1) + if (sscanf (argv[idx_bitpattern]->arg, "0x%lx", &value) != 1) { vty_out (vty, "link_params_admin_grp: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -2012,24 +1996,27 @@ DEFUN (no_link_params_admin_grp, /* RFC5392 & RFC5316: INTER-AS */ DEFUN (link_params_inter_as, link_params_inter_as_cmd, - "neighbor A.B.C.D as <1-4294967295>", + "neighbor A.B.C.D as (1-4294967295)", "Configure remote ASBR information (Neighbor IP address and AS number)\n" "Remote IP address in dot decimal A.B.C.D\n" "Remote AS number\n" "AS number in the range <1-4294967295>\n") { + int idx_ipv4 = 1; + int idx_number = 3; + VTY_DECLVAR_CONTEXT (interface, ifp); struct if_link_params *iflp = if_link_params_get (ifp); struct in_addr addr; u_int32_t as; - if (!inet_aton (argv[0], &addr)) + if (!inet_aton (argv[idx_ipv4]->arg, &addr)) { vty_out (vty, "Please specify Router-Addr by A.B.C.D%s", VTY_NEWLINE); return CMD_WARNING; } - VTY_GET_ULONG("AS number", as, argv[1]); + VTY_GET_ULONG("AS number", as, argv[idx_number]->arg); /* Update Remote IP and Remote AS fields if needed */ if (IS_PARAM_UNSET(iflp, LP_RMT_AS) @@ -2072,78 +2059,77 @@ DEFUN (no_link_params_inter_as, /* RFC7471: OSPF Traffic Engineering (TE) Metric extensions & draft-ietf-isis-metric-extensions-07.txt */ DEFUN (link_params_delay, link_params_delay_cmd, - "delay <0-16777215>", + "delay (0-16777215) [min (0-16777215) max (0-16777215)]", "Unidirectional Average Link Delay\n" - "Average delay in micro-second as decimal (0...16777215)\n") + "Average delay in micro-second as decimal (0...16777215)\n" + "Minimum delay\n" + "Minimum delay in micro-second as decimal (0...16777215)\n" + "Maximum delay\n" + "Maximum delay in micro-second as decimal (0...16777215)\n") { + /* Get and Check new delay values */ + u_int32_t delay = 0, low = 0, high = 0; + VTY_GET_ULONG("delay", delay, argv[1]->arg); + if (argc == 6) + { + VTY_GET_ULONG("minimum delay", low, argv[3]->arg); + VTY_GET_ULONG("maximum delay", high, argv[5]->arg); + } + VTY_DECLVAR_CONTEXT (interface, ifp); struct if_link_params *iflp = if_link_params_get (ifp); - u_int32_t delay = 0, low = 0, high = 0; u_int8_t update = 0; - /* Get and Check new delay values */ - VTY_GET_ULONG("delay", delay, argv[0]); - switch (argc) - { - case 1: - /* Check new delay value against old Min and Max delays if set */ - if (IS_PARAM_SET(iflp, LP_MM_DELAY) - && (delay <= iflp->min_delay || delay >= iflp->max_delay)) - { - vty_out (vty, "Average delay should be comprise between Min (%d) and Max (%d) delay%s", - iflp->min_delay, iflp->max_delay, VTY_NEWLINE); - return CMD_WARNING; - } - /* Update delay if value is not set or change */ - if (IS_PARAM_UNSET(iflp, LP_DELAY)|| iflp->av_delay != delay) - { - iflp->av_delay = delay; - SET_PARAM(iflp, LP_DELAY); - update = 1; - } - /* Unset Min and Max delays if already set */ - if (IS_PARAM_SET(iflp, LP_MM_DELAY)) - { - iflp->min_delay = 0; - iflp->max_delay = 0; - UNSET_PARAM(iflp, LP_MM_DELAY); - update = 1; - } - break; - case 2: - vty_out (vty, "You should specify both Minimum and Maximum delay with Average delay%s", - VTY_NEWLINE); - return CMD_WARNING; - break; - case 3: - VTY_GET_ULONG("minimum delay", low, argv[1]); - VTY_GET_ULONG("maximum delay", high, argv[2]); - /* Check new delays value coherency */ - if (delay <= low || delay >= high) - { - vty_out (vty, "Average delay should be comprise between Min (%d) and Max (%d) delay%s", - low, high, VTY_NEWLINE); - return CMD_WARNING; - } - /* Update Delays if needed */ - if (IS_PARAM_UNSET(iflp, LP_DELAY) - || IS_PARAM_UNSET(iflp, LP_MM_DELAY) - || iflp->av_delay != delay - || iflp->min_delay != low - || iflp->max_delay != high) - { - iflp->av_delay = delay; - SET_PARAM(iflp, LP_DELAY); - iflp->min_delay = low; - iflp->max_delay = high; - SET_PARAM(iflp, LP_MM_DELAY); - update = 1; - } - break; - default: - return CMD_WARNING; - break; - } + if (argc == 2) + { + /* Check new delay value against old Min and Max delays if set */ + if (IS_PARAM_SET(iflp, LP_MM_DELAY) + && (delay <= iflp->min_delay || delay >= iflp->max_delay)) + { + vty_out (vty, "Average delay should be comprise between Min (%d) and Max (%d) delay%s", + iflp->min_delay, iflp->max_delay, VTY_NEWLINE); + return CMD_WARNING; + } + /* Update delay if value is not set or change */ + if (IS_PARAM_UNSET(iflp, LP_DELAY)|| iflp->av_delay != delay) + { + iflp->av_delay = delay; + SET_PARAM(iflp, LP_DELAY); + update = 1; + } + /* Unset Min and Max delays if already set */ + if (IS_PARAM_SET(iflp, LP_MM_DELAY)) + { + iflp->min_delay = 0; + iflp->max_delay = 0; + UNSET_PARAM(iflp, LP_MM_DELAY); + update = 1; + } + } + else + { + /* Check new delays value coherency */ + if (delay <= low || delay >= high) + { + vty_out (vty, "Average delay should be comprise between Min (%d) and Max (%d) delay%s", + low, high, VTY_NEWLINE); + return CMD_WARNING; + } + /* Update Delays if needed */ + if (IS_PARAM_UNSET(iflp, LP_DELAY) + || IS_PARAM_UNSET(iflp, LP_MM_DELAY) + || iflp->av_delay != delay + || iflp->min_delay != low + || iflp->max_delay != high) + { + iflp->av_delay = delay; + SET_PARAM(iflp, LP_DELAY); + iflp->min_delay = low; + iflp->max_delay = high; + SET_PARAM(iflp, LP_MM_DELAY); + update = 1; + } + } /* force protocols to update LINK STATE due to parameters change */ if (update == 1 && if_is_operative (ifp)) @@ -2152,16 +2138,6 @@ DEFUN (link_params_delay, return CMD_SUCCESS; } -ALIAS (link_params_delay, - link_params_delay_mm_cmd, - "delay <0-16777215> min <0-16777215> max <0-16777215>", - "Unidirectional Average Link Delay (optionally Minimum and Maximum delays)\n" - "Average delay in micro-second as decimal (0...16777215)\n" - "Minimum delay\n" - "Minimum delay in micro-second as decimal (0...16777215)\n" - "Maximum delay\n" - "Maximum delay in micro-second as decimal (0...16777215)\n") - DEFUN (no_link_params_delay, no_link_params_delay_cmd, "no delay", @@ -2187,15 +2163,16 @@ DEFUN (no_link_params_delay, DEFUN (link_params_delay_var, link_params_delay_var_cmd, - "delay-variation <0-16777215>", + "delay-variation (0-16777215)", "Unidirectional Link Delay Variation\n" "delay variation in micro-second as decimal (0...16777215)\n") { + int idx_number = 1; VTY_DECLVAR_CONTEXT (interface, ifp); struct if_link_params *iflp = if_link_params_get (ifp); u_int32_t value; - VTY_GET_ULONG("delay variation", value, argv[0]); + VTY_GET_ULONG("delay variation", value, argv[idx_number]->arg); /* Update Delay Variation if needed */ link_param_cmd_set_uint32 (ifp, &iflp->delay_var, LP_DELAY_VAR, value); @@ -2223,11 +2200,12 @@ DEFUN (link_params_pkt_loss, "Unidirectional Link Packet Loss\n" "percentage of total traffic by 0.000003% step and less than 50.331642%\n") { + int idx_percentage = 1; VTY_DECLVAR_CONTEXT (interface, ifp); struct if_link_params *iflp = if_link_params_get (ifp); float fval; - if (sscanf (argv[0], "%g", &fval) != 1) + if (sscanf (argv[idx_percentage]->arg, "%g", &fval) != 1) { vty_out (vty, "link_params_pkt_loss: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -2263,11 +2241,12 @@ DEFUN (link_params_res_bw, "Unidirectional Residual Bandwidth\n" "Bytes/second (IEEE floating point format)\n") { + int idx_bandwidth = 1; VTY_DECLVAR_CONTEXT (interface, ifp); struct if_link_params *iflp = if_link_params_get (ifp); float bw; - if (sscanf (argv[0], "%g", &bw) != 1) + if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) { vty_out (vty, "link_params_res_bw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -2309,11 +2288,12 @@ DEFUN (link_params_ava_bw, "Unidirectional Available Bandwidth\n" "Bytes/second (IEEE floating point format)\n") { + int idx_bandwidth = 1; VTY_DECLVAR_CONTEXT (interface, ifp); struct if_link_params *iflp = if_link_params_get (ifp); float bw; - if (sscanf (argv[0], "%g", &bw) != 1) + if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) { vty_out (vty, "link_params_ava_bw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -2355,11 +2335,12 @@ DEFUN (link_params_use_bw, "Unidirectional Utilised Bandwidth\n" "Bytes/second (IEEE floating point format)\n") { + int idx_bandwidth = 1; VTY_DECLVAR_CONTEXT (interface, ifp); struct if_link_params *iflp = if_link_params_get (ifp); float bw; - if (sscanf (argv[0], "%g", &bw) != 1) + if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) { vty_out (vty, "link_params_use_bw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -2543,8 +2524,9 @@ DEFUN (ip_address, "Set the IP address of an interface\n" "IP address (e.g. 10.0.0.1/8)\n") { + int idx_ipv4_prefixlen = 2; VTY_DECLVAR_CONTEXT (interface, ifp); - return ip_address_install (vty, ifp, argv[0], NULL, NULL); + return ip_address_install (vty, ifp, argv[idx_ipv4_prefixlen]->arg, NULL, NULL); } DEFUN (no_ip_address, @@ -2555,8 +2537,9 @@ DEFUN (no_ip_address, "Set the IP address of an interface\n" "IP Address (e.g. 10.0.0.1/8)") { + int idx_ipv4_prefixlen = 3; VTY_DECLVAR_CONTEXT (interface, ifp); - return ip_address_uninstall (vty, ifp, argv[0], NULL, NULL); + return ip_address_uninstall (vty, ifp, argv[idx_ipv4_prefixlen]->arg, NULL, NULL); } @@ -2570,8 +2553,10 @@ DEFUN (ip_address_label, "Label of this address\n" "Label\n") { + int idx_ipv4_prefixlen = 2; + int idx_line = 4; VTY_DECLVAR_CONTEXT (interface, ifp); - return ip_address_install (vty, ifp, argv[0], NULL, argv[1]); + return ip_address_install (vty, ifp, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_line]->arg); } DEFUN (no_ip_address_label, @@ -2584,8 +2569,10 @@ DEFUN (no_ip_address_label, "Label of this address\n" "Label\n") { + int idx_ipv4_prefixlen = 3; + int idx_line = 5; VTY_DECLVAR_CONTEXT (interface, ifp); - return ip_address_uninstall (vty, ifp, argv[0], NULL, argv[1]); + return ip_address_uninstall (vty, ifp, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_line]->arg); } #endif /* HAVE_NETLINK */ @@ -2748,8 +2735,9 @@ DEFUN (ipv6_address, "Set the IP address of an interface\n" "IPv6 address (e.g. 3ffe:506::1/48)\n") { + int idx_ipv6_prefixlen = 2; VTY_DECLVAR_CONTEXT (interface, ifp); - return ipv6_address_install (vty, ifp, argv[0], NULL, NULL, 0); + return ipv6_address_install (vty, ifp, argv[idx_ipv6_prefixlen]->arg, NULL, NULL, 0); } DEFUN (no_ipv6_address, @@ -2760,8 +2748,9 @@ DEFUN (no_ipv6_address, "Set the IP address of an interface\n" "IPv6 address (e.g. 3ffe:506::1/48)\n") { + int idx_ipv6_prefixlen = 3; VTY_DECLVAR_CONTEXT (interface, ifp); - return ipv6_address_uninstall (vty, ifp, argv[0], NULL, NULL, 0); + return ipv6_address_uninstall (vty, ifp, argv[idx_ipv6_prefixlen]->arg, NULL, NULL, 0); } #endif /* HAVE_IPV6 */ @@ -2935,18 +2924,14 @@ zebra_if_init (void) install_node (&vrf_node, vrf_config_write); install_element (VIEW_NODE, &show_interface_cmd); - install_element (VIEW_NODE, &show_interface_vrf_cmd); install_element (VIEW_NODE, &show_interface_vrf_all_cmd); - install_element (VIEW_NODE, &show_interface_name_cmd); install_element (VIEW_NODE, &show_interface_name_vrf_cmd); install_element (VIEW_NODE, &show_interface_name_vrf_all_cmd); + install_element (ENABLE_NODE, &show_interface_desc_cmd); - install_element (ENABLE_NODE, &show_interface_desc_vrf_cmd); install_element (ENABLE_NODE, &show_interface_desc_vrf_all_cmd); install_element (CONFIG_NODE, &zebra_interface_cmd); - install_element (CONFIG_NODE, &zebra_interface_vrf_cmd); install_element (CONFIG_NODE, &no_interface_cmd); - install_element (CONFIG_NODE, &no_interface_vrf_cmd); install_default (INTERFACE_NODE); install_element (INTERFACE_NODE, &interface_desc_cmd); install_element (INTERFACE_NODE, &no_interface_desc_cmd); @@ -2958,7 +2943,6 @@ zebra_if_init (void) install_element (INTERFACE_NODE, &no_shutdown_if_cmd); install_element (INTERFACE_NODE, &bandwidth_if_cmd); install_element (INTERFACE_NODE, &no_bandwidth_if_cmd); - install_element (INTERFACE_NODE, &no_bandwidth_if_val_cmd); install_element (INTERFACE_NODE, &ip_address_cmd); install_element (INTERFACE_NODE, &no_ip_address_cmd); #ifdef HAVE_IPV6 @@ -2981,7 +2965,6 @@ zebra_if_init (void) install_element(LINK_PARAMS_NODE, &link_params_inter_as_cmd); install_element(LINK_PARAMS_NODE, &no_link_params_inter_as_cmd); install_element(LINK_PARAMS_NODE, &link_params_delay_cmd); - install_element(LINK_PARAMS_NODE, &link_params_delay_mm_cmd); install_element(LINK_PARAMS_NODE, &link_params_delay_var_cmd); install_element(LINK_PARAMS_NODE, &link_params_pkt_loss_cmd); install_element(LINK_PARAMS_NODE, &link_params_ava_bw_cmd); diff --git a/zebra/ioctl.c b/zebra/ioctl.c index f91ee2438d..1835fb3102 100644 --- a/zebra/ioctl.c +++ b/zebra/ioctl.c @@ -29,6 +29,7 @@ #include "log.h" #include "privs.h" +#include "vty.h" #include "zebra/rib.h" #include "zebra/rt.h" #include "zebra/interface.h" diff --git a/zebra/irdp_interface.c b/zebra/irdp_interface.c index 9d8c2e67bf..fde759df98 100644 --- a/zebra/irdp_interface.c +++ b/zebra/irdp_interface.c @@ -18,17 +18,17 @@ * You should have received a copy of the GNU General Public License * along with GNU Zebra; see the file COPYING. If not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. + * 02111-1307, USA. */ -/* +/* * This work includes work with the following copywrite: * * Copyright (C) 1997, 2000 Kunihiro Ishiguro * */ -/* +/* * Thanks to Jens Låås at Swedish University of Agricultural Sciences * for reviewing and tests. */ @@ -36,7 +36,7 @@ #include <zebra.h> -#ifdef HAVE_IRDP +#ifdef HAVE_IRDP #include "if.h" #include "vty.h" @@ -81,7 +81,7 @@ irdp_get_prefix(struct interface *ifp) { struct listnode *node; struct connected *ifc; - + if (ifp->connected) for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc)) return ifc->address; @@ -91,9 +91,9 @@ irdp_get_prefix(struct interface *ifp) /* Join to the add/leave multicast group. */ static int -if_group (struct interface *ifp, - int sock, - u_int32_t group, +if_group (struct interface *ifp, + int sock, + u_int32_t group, int add_leave) { struct ip_mreq m; @@ -116,7 +116,7 @@ if_group (struct interface *ifp, (char *) &m, sizeof (struct ip_mreq)); if (ret < 0) zlog_warn ("IRDP: %s can't setsockopt %s: %s", - add_leave == IP_ADD_MEMBERSHIP? "join group":"leave group", + add_leave == IP_ADD_MEMBERSHIP? "join group":"leave group", inet_2a(group, b1), safe_strerror (errno)); @@ -137,7 +137,7 @@ if_add_group (struct interface *ifp) } if(irdp->flags & IF_DEBUG_MISC ) - zlog_debug("IRDP: Adding group %s for %s", + zlog_debug("IRDP: Adding group %s for %s", inet_2a(htonl(INADDR_ALLRTRS_GROUP), b1), ifp->name); return 0; @@ -156,7 +156,7 @@ if_drop_group (struct interface *ifp) return ret; if(irdp->flags & IF_DEBUG_MISC) - zlog_debug("IRDP: Leaving group %s for %s", + zlog_debug("IRDP: Leaving group %s for %s", inet_2a(htonl(INADDR_ALLRTRS_GROUP), b1), ifp->name); return 0; @@ -206,7 +206,7 @@ irdp_if_start(struct interface *ifp, int multicast, int set_defaults) } irdp->flags |= IF_ACTIVE; - if(!multicast) + if(!multicast) irdp->flags |= IF_BROADCAST; if_add_update(ifp); @@ -219,13 +219,13 @@ irdp_if_start(struct interface *ifp, int multicast, int set_defaults) if( multicast) { if_add_group(ifp); - + if (! (ifp->flags & (IFF_MULTICAST|IFF_ALLMULTI))) { zlog_warn("IRDP: Interface not multicast enabled %s", ifp->name); } } - if(set_defaults) + if(set_defaults) if_set_defaults(ifp); irdp->irdp_sent = 0; @@ -239,9 +239,9 @@ irdp_if_start(struct interface *ifp, int multicast, int set_defaults) seed = ifc->address->u.prefix4.s_addr; break; } - + srandom(seed); - timer = (random () % IRDP_DEFAULT_INTERVAL) + 1; + timer = (random () % IRDP_DEFAULT_INTERVAL) + 1; irdp->AdvPrefList = list_new(); irdp->AdvPrefList->del = (void (*)(void *)) Adv_free; /* Destructor */ @@ -250,18 +250,18 @@ irdp_if_start(struct interface *ifp, int multicast, int set_defaults) /* And this for startup. Speed limit from 1991 :-). But it's OK*/ if(irdp->irdp_sent < MAX_INITIAL_ADVERTISEMENTS && - timer > MAX_INITIAL_ADVERT_INTERVAL ) + timer > MAX_INITIAL_ADVERT_INTERVAL ) timer= MAX_INITIAL_ADVERT_INTERVAL; - + if(irdp->flags & IF_DEBUG_MISC) - zlog_debug("IRDP: Init timer for %s set to %u", - ifp->name, + zlog_debug("IRDP: Init timer for %s set to %u", + ifp->name, timer); - irdp->t_advertise = thread_add_timer(zebrad.master, - irdp_send_thread, - ifp, + irdp->t_advertise = thread_add_timer(zebrad.master, + irdp_send_thread, + ifp, timer); } @@ -270,7 +270,7 @@ irdp_if_stop(struct interface *ifp) { struct zebra_if *zi=ifp->info; struct irdp_interface *irdp=&zi->irdp; - + if (irdp == NULL) { zlog_warn ("Interface %s structure is NULL", ifp->name); return; @@ -281,7 +281,7 @@ irdp_if_stop(struct interface *ifp) return; } - if(! (irdp->flags & IF_BROADCAST)) + if(! (irdp->flags & IF_BROADCAST)) if_drop_group(ifp); irdp_advert_off(ifp); @@ -307,9 +307,9 @@ irdp_if_shutdown(struct interface *ifp) irdp->flags |= IF_SHUTDOWN; irdp->flags &= ~IF_ACTIVE; - if(! (irdp->flags & IF_BROADCAST)) + if(! (irdp->flags & IF_BROADCAST)) if_drop_group(ifp); - + /* Tell the hosts we are out of service */ irdp_advert_off(ifp); } @@ -327,7 +327,7 @@ irdp_if_no_shutdown(struct interface *ifp) irdp->flags &= ~IF_SHUTDOWN; - irdp_if_start(ifp, irdp->flags & IF_BROADCAST? FALSE : TRUE, FALSE); + irdp_if_start(ifp, irdp->flags & IF_BROADCAST? FALSE : TRUE, FALSE); } @@ -344,30 +344,30 @@ void irdp_config_write (struct vty *vty, struct interface *ifp) if(irdp->flags & IF_ACTIVE || irdp->flags & IF_SHUTDOWN) { - if( irdp->flags & IF_SHUTDOWN) + if( irdp->flags & IF_SHUTDOWN) vty_out (vty, " ip irdp shutdown %s", VTY_NEWLINE); - if( irdp->flags & IF_BROADCAST) + if( irdp->flags & IF_BROADCAST) vty_out (vty, " ip irdp broadcast%s", VTY_NEWLINE); - else + else vty_out (vty, " ip irdp multicast%s", VTY_NEWLINE); - vty_out (vty, " ip irdp preference %ld%s", + vty_out (vty, " ip irdp preference %ld%s", irdp->Preference, VTY_NEWLINE); for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv)) vty_out (vty, " ip irdp address %s preference %d%s", inet_2a(adv->ip.s_addr, b1), - adv->pref, + adv->pref, VTY_NEWLINE); - vty_out (vty, " ip irdp holdtime %d%s", + vty_out (vty, " ip irdp holdtime %d%s", irdp->Lifetime, VTY_NEWLINE); - vty_out (vty, " ip irdp minadvertinterval %ld%s", + vty_out (vty, " ip irdp minadvertinterval %ld%s", irdp->MinAdvertInterval, VTY_NEWLINE); - vty_out (vty, " ip irdp maxadvertinterval %ld%s", + vty_out (vty, " ip irdp maxadvertinterval %ld%s", irdp->MaxAdvertInterval, VTY_NEWLINE); } @@ -415,6 +415,7 @@ DEFUN (ip_irdp_shutdown, ip_irdp_shutdown_cmd, "ip irdp shutdown", IP_STR + "ICMP Router discovery on this interface\n" "ICMP Router discovery shutdown on this interface\n") { VTY_DECLVAR_CONTEXT (interface, ifp); @@ -428,6 +429,7 @@ DEFUN (no_ip_irdp_shutdown, "no ip irdp shutdown", NO_STR IP_STR + "ICMP Router discovery on this interface\n" "ICMP Router discovery no shutdown on this interface\n") { VTY_DECLVAR_CONTEXT (interface, ifp); @@ -438,12 +440,13 @@ DEFUN (no_ip_irdp_shutdown, DEFUN (ip_irdp_holdtime, ip_irdp_holdtime_cmd, - "ip irdp holdtime <0-9000>", + "ip irdp holdtime (0-9000)", IP_STR "ICMP Router discovery on this interface\n" "Set holdtime value\n" "Holdtime value in seconds. Default is 1800 seconds\n") { + int idx_number = 3; VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zi; struct irdp_interface *irdp; @@ -451,18 +454,19 @@ DEFUN (ip_irdp_holdtime, zi=ifp->info; irdp=&zi->irdp; - irdp->Lifetime = atoi(argv[0]); + irdp->Lifetime = atoi(argv[idx_number]->arg); return CMD_SUCCESS; } DEFUN (ip_irdp_minadvertinterval, ip_irdp_minadvertinterval_cmd, - "ip irdp minadvertinterval <3-1800>", + "ip irdp minadvertinterval (3-1800)", IP_STR "ICMP Router discovery on this interface\n" "Set minimum time between advertisement\n" "Minimum advertisement interval in seconds\n") { + int idx_number = 3; VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zi; struct irdp_interface *irdp; @@ -470,28 +474,29 @@ DEFUN (ip_irdp_minadvertinterval, zi=ifp->info; irdp=&zi->irdp; - if( (unsigned) atoi(argv[0]) <= irdp->MaxAdvertInterval) { - irdp->MinAdvertInterval = atoi(argv[0]); + if( (unsigned) atoi(argv[idx_number]->arg) <= irdp->MaxAdvertInterval) { + irdp->MinAdvertInterval = atoi(argv[idx_number]->arg); return CMD_SUCCESS; } - vty_out (vty, "ICMP warning maxadvertinterval is greater or equal than minadvertinterval%s", + vty_out (vty, "ICMP warning maxadvertinterval is greater or equal than minadvertinterval%s", VTY_NEWLINE); - vty_out (vty, "Please correct!%s", + vty_out (vty, "Please correct!%s", VTY_NEWLINE); return CMD_WARNING; } DEFUN (ip_irdp_maxadvertinterval, ip_irdp_maxadvertinterval_cmd, - "ip irdp maxadvertinterval <4-1800>", + "ip irdp maxadvertinterval (4-1800)", IP_STR "ICMP Router discovery on this interface\n" "Set maximum time between advertisement\n" "Maximum advertisement interval in seconds\n") { + int idx_number = 3; VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zi; struct irdp_interface *irdp; @@ -500,16 +505,16 @@ DEFUN (ip_irdp_maxadvertinterval, irdp=&zi->irdp; - if( irdp->MinAdvertInterval <= (unsigned) atoi(argv[0]) ) { - irdp->MaxAdvertInterval = atoi(argv[0]); + if( irdp->MinAdvertInterval <= (unsigned) atoi(argv[idx_number]->arg) ) { + irdp->MaxAdvertInterval = atoi(argv[idx_number]->arg); return CMD_SUCCESS; } - vty_out (vty, "ICMP warning maxadvertinterval is greater or equal than minadvertinterval%s", + vty_out (vty, "ICMP warning maxadvertinterval is greater or equal than minadvertinterval%s", VTY_NEWLINE); - vty_out (vty, "Please correct!%s", + vty_out (vty, "Please correct!%s", VTY_NEWLINE); return CMD_WARNING; } @@ -521,12 +526,13 @@ DEFUN (ip_irdp_maxadvertinterval, DEFUN (ip_irdp_preference, ip_irdp_preference_cmd, - "ip irdp preference <0-2147483647>", + "ip irdp preference (0-2147483647)", IP_STR "ICMP Router discovery on this interface\n" "Set default preference level for this interface\n" "Preference level\n") { + int idx_number = 3; VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zi; struct irdp_interface *irdp; @@ -534,22 +540,24 @@ DEFUN (ip_irdp_preference, zi=ifp->info; irdp=&zi->irdp; - irdp->Preference = atoi(argv[0]); + irdp->Preference = atoi(argv[idx_number]->arg); return CMD_SUCCESS; } DEFUN (ip_irdp_address_preference, ip_irdp_address_preference_cmd, - "ip irdp address A.B.C.D preference <0-2147483647>", + "ip irdp address A.B.C.D preference (0-2147483647)", IP_STR "Alter ICMP Router discovery preference this interface\n" "Specify IRDP non-default preference to advertise\n" "Set IRDP address for advertise\n" "Preference level\n") { + int idx_ipv4 = 3; + int idx_number = 5; VTY_DECLVAR_CONTEXT (interface, ifp); struct listnode *node; - struct in_addr ip; + struct in_addr ip; int pref; int ret; struct zebra_if *zi; @@ -559,13 +567,13 @@ DEFUN (ip_irdp_address_preference, zi=ifp->info; irdp=&zi->irdp; - ret = inet_aton(argv[0], &ip); + ret = inet_aton(argv[idx_ipv4]->arg, &ip); if(!ret) return CMD_WARNING; - pref = atoi(argv[1]); + pref = atoi(argv[idx_number]->arg); for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv)) - if(adv->ip.s_addr == ip.s_addr) + if(adv->ip.s_addr == ip.s_addr) return CMD_SUCCESS; adv = Adv_new(); @@ -579,7 +587,7 @@ DEFUN (ip_irdp_address_preference, DEFUN (no_ip_irdp_address_preference, no_ip_irdp_address_preference_cmd, - "no ip irdp address A.B.C.D preference <0-2147483647>", + "no ip irdp address A.B.C.D preference (0-2147483647)", NO_STR IP_STR "Alter ICMP Router discovery preference this interface\n" @@ -587,9 +595,10 @@ DEFUN (no_ip_irdp_address_preference, "Select IRDP address\n" "Old preference level\n") { + int idx_ipv4 = 4; VTY_DECLVAR_CONTEXT (interface, ifp); struct listnode *node, *nnode; - struct in_addr ip; + struct in_addr ip; int ret; struct zebra_if *zi; struct irdp_interface *irdp; @@ -598,8 +607,8 @@ DEFUN (no_ip_irdp_address_preference, zi=ifp->info; irdp=&zi->irdp; - ret = inet_aton(argv[0], &ip); - if (!ret) + ret = inet_aton(argv[idx_ipv4]->arg, &ip); + if (!ret) return CMD_WARNING; for (ALL_LIST_ELEMENTS (irdp->AdvPrefList, node, nnode, adv)) @@ -610,7 +619,7 @@ DEFUN (no_ip_irdp_address_preference, break; } } - + return CMD_SUCCESS; } diff --git a/zebra/kernel_null.c b/zebra/kernel_null.c index d02939882c..a20597882c 100644 --- a/zebra/kernel_null.c +++ b/zebra/kernel_null.c @@ -24,6 +24,7 @@ #include <zebra.h> #include <log.h> +#include "vty.h" #include "zebra/zserv.h" #include "zebra/rt.h" #include "zebra/redistribute.h" diff --git a/zebra/redistribute_null.c b/zebra/redistribute_null.c index 85d3bd2f1b..4446627dd3 100644 --- a/zebra/redistribute_null.c +++ b/zebra/redistribute_null.c @@ -20,6 +20,7 @@ */ #include <zebra.h> +#include "vty.h" #include "zebra/rib.h" #include "zebra/zserv.h" diff --git a/zebra/router-id.c b/zebra/router-id.c index d5d9652c59..23b8cc743c 100644 --- a/zebra/router-id.c +++ b/zebra/router-id.c @@ -216,41 +216,42 @@ router_id_write (struct vty *vty) DEFUN (router_id, router_id_cmd, - "router-id A.B.C.D", + "router-id A.B.C.D [vrf NAME]", "Manually set the router-id\n" - "IP address to use for router-id\n") + "IP address to use for router-id\n" + VRF_CMD_HELP_STR) { + int idx_ipv4 = 1; + int idx_name = 3; + struct prefix rid; vrf_id_t vrf_id = VRF_DEFAULT; - rid.u.prefix4.s_addr = inet_addr (argv[0]); + rid.u.prefix4.s_addr = inet_addr (argv[idx_ipv4]->arg); if (!rid.u.prefix4.s_addr) return CMD_WARNING; rid.prefixlen = 32; rid.family = AF_INET; - if (argc > 1) - VRF_GET_ID (vrf_id, argv[1]); + if (argc > 2) + VRF_GET_ID (vrf_id, argv[idx_name]->arg); router_id_set (&rid, vrf_id); return CMD_SUCCESS; } -ALIAS (router_id, - router_id_vrf_cmd, - "router-id A.B.C.D " VRF_CMD_STR, - "Manually set the router-id\n" - "IP address to use for router-id\n" - VRF_CMD_HELP_STR) - DEFUN (no_router_id, no_router_id_cmd, - "no router-id", + "no router-id [A.B.C.D [vrf NAME]]", NO_STR - "Remove the manually configured router-id\n") + "Remove the manually configured router-id\n" + "IP address to use for router-id\n" + VRF_CMD_HELP_STR) { + int idx_name = 4; + struct prefix rid; vrf_id_t vrf_id = VRF_DEFAULT; @@ -258,28 +259,15 @@ DEFUN (no_router_id, rid.prefixlen = 0; rid.family = AF_INET; - if (argc > 1) - VRF_GET_ID (vrf_id, argv[1]); + if (argc > 3) + VRF_GET_ID (vrf_id, argv[idx_name]->arg); router_id_set (&rid, vrf_id); return CMD_SUCCESS; } -ALIAS (no_router_id, - no_router_id_val_cmd, - "no router-id A.B.C.D", - NO_STR - "Remove the manually configured router-id\n" - "IP address to use for router-id\n") -ALIAS (no_router_id, - no_router_id_vrf_cmd, - "no router-id A.B.C.D " VRF_CMD_STR, - NO_STR - "Remove the manually configured router-id\n" - "IP address to use for router-id\n" - VRF_CMD_HELP_STR) static int router_id_cmp (void *a, void *b) @@ -295,9 +283,6 @@ router_id_cmd_init (void) { install_element (CONFIG_NODE, &router_id_cmd); install_element (CONFIG_NODE, &no_router_id_cmd); - install_element (CONFIG_NODE, &router_id_vrf_cmd); - install_element (CONFIG_NODE, &no_router_id_val_cmd); - install_element (CONFIG_NODE, &no_router_id_vrf_cmd); } void diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index f16fd55c98..90d71e6351 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -16,7 +16,7 @@ * You should have received a copy of the GNU General Public License * along with GNU Zebra; see the file COPYING. If not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. + * 02111-1307, USA. */ #include <zebra.h> @@ -40,6 +40,7 @@ #include "privs.h" #include "nexthop.h" #include "vrf.h" +#include "vty.h" #include "mpls.h" #include "zebra/zserv.h" @@ -313,7 +314,6 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h, u_char zebra_flags = 0; struct prefix p; vrf_id_t vrf_id = VRF_DEFAULT; - char anyaddr[16] = { 0 }; int index; @@ -693,7 +693,7 @@ _netlink_route_build_singlepath( int i, num_labels = 0; u_int32_t bos; char label_buf1[20]; - + for (i = 0; i < nh_label->num_labels; i++) { if (nh_label->label[i] != MPLS_IMP_NULL_LABEL) @@ -1072,7 +1072,7 @@ _netlink_route_debug( prefix2str (p, buf, sizeof(buf)), zvrf->vrf_id, (nexthop) ? nexthop_type_to_str (nexthop->type) : "UNK"); } -} + } static void _netlink_mpls_debug( diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 3e0a198702..dcf31ff450 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -1,4 +1,5 @@ /* Router advertisement + * Copyright (C) 2016 Cumulus Networks * Copyright (C) 2005 6WIND <jean-mickael.guerin@6wind.com> * Copyright (C) 1999 Kunihiro Ishiguro * @@ -911,12 +912,13 @@ DEFUN (no_ipv6_nd_suppress_ra, DEFUN (ipv6_nd_ra_interval_msec, ipv6_nd_ra_interval_msec_cmd, - "ipv6 nd ra-interval msec <70-1800000>", + "ipv6 nd ra-interval msec (70-1800000)", "Interface IPv6 config commands\n" "Neighbor discovery\n" "Router Advertisement interval\n" "Router Advertisement interval in milliseconds\n") { + int idx_number = 4; VTY_DECLVAR_CONTEXT (interface, ifp); unsigned interval; struct zebra_if *zif = ifp->info; @@ -924,7 +926,7 @@ DEFUN (ipv6_nd_ra_interval_msec, struct zebra_ns *zns; zns = zvrf->zns; - VTY_GET_INTEGER_RANGE ("router advertisement interval", interval, argv[0], 70, 1800000); + VTY_GET_INTEGER_RANGE ("router advertisement interval", interval, argv[idx_number]->arg, 70, 1800000); if ((zif->rtadv.AdvDefaultLifetime != -1 && interval > (unsigned)zif->rtadv.AdvDefaultLifetime * 1000)) { vty_out (vty, "This ra-interval would conflict with configured ra-lifetime!%s", VTY_NEWLINE); @@ -946,12 +948,13 @@ DEFUN (ipv6_nd_ra_interval_msec, DEFUN (ipv6_nd_ra_interval, ipv6_nd_ra_interval_cmd, - "ipv6 nd ra-interval <1-1800>", + "ipv6 nd ra-interval (1-1800)", "Interface IPv6 config commands\n" "Neighbor discovery\n" "Router Advertisement interval\n" "Router Advertisement interval in seconds\n") { + int idx_number = 3; VTY_DECLVAR_CONTEXT (interface, ifp); unsigned interval; struct zebra_if *zif = ifp->info; @@ -959,7 +962,7 @@ DEFUN (ipv6_nd_ra_interval, struct zebra_ns *zns; zns = zvrf->zns; - VTY_GET_INTEGER_RANGE ("router advertisement interval", interval, argv[0], 1, 1800); + VTY_GET_INTEGER_RANGE ("router advertisement interval", interval, argv[idx_number]->arg, 1, 1800); if ((zif->rtadv.AdvDefaultLifetime != -1 && interval > (unsigned)zif->rtadv.AdvDefaultLifetime)) { vty_out (vty, "This ra-interval would conflict with configured ra-lifetime!%s", VTY_NEWLINE); @@ -981,11 +984,14 @@ DEFUN (ipv6_nd_ra_interval, DEFUN (no_ipv6_nd_ra_interval, no_ipv6_nd_ra_interval_cmd, - "no ipv6 nd ra-interval", + "no ipv6 nd ra-interval [<(1-1800)|msec (1-1800000)>]", NO_STR "Interface IPv6 config commands\n" "Neighbor discovery\n" - "Router Advertisement interval\n") + "Router Advertisement interval\n" + "Router Advertisement interval in seconds\n" + "Specify millisecond router advertisement interval\n" + "Router Advertisement interval in milliseconds\n") { VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zif = ifp->info; @@ -1005,36 +1011,20 @@ DEFUN (no_ipv6_nd_ra_interval, return CMD_SUCCESS; } -ALIAS (no_ipv6_nd_ra_interval, - no_ipv6_nd_ra_interval_val_cmd, - "no ipv6 nd ra-interval <1-1800>", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Router Advertisement interval\n") - -ALIAS (no_ipv6_nd_ra_interval, - no_ipv6_nd_ra_interval_msec_val_cmd, - "no ipv6 nd ra-interval msec <1-1800000>", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Router Advertisement interval\n" - "Router Advertisement interval in milliseconds\n") - DEFUN (ipv6_nd_ra_lifetime, ipv6_nd_ra_lifetime_cmd, - "ipv6 nd ra-lifetime <0-9000>", + "ipv6 nd ra-lifetime (0-9000)", "Interface IPv6 config commands\n" "Neighbor discovery\n" "Router lifetime\n" "Router lifetime in seconds (0 stands for a non-default gw)\n") { + int idx_number = 3; VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zif = ifp->info; int lifetime; - VTY_GET_INTEGER_RANGE ("router lifetime", lifetime, argv[0], 0, 9000); + VTY_GET_INTEGER_RANGE ("router lifetime", lifetime, argv[idx_number]->arg, 0, 9000); /* The value to be placed in the Router Lifetime field * of Router Advertisements sent from the interface, @@ -1053,11 +1043,12 @@ DEFUN (ipv6_nd_ra_lifetime, DEFUN (no_ipv6_nd_ra_lifetime, no_ipv6_nd_ra_lifetime_cmd, - "no ipv6 nd ra-lifetime", + "no ipv6 nd ra-lifetime [(0-9000)]", NO_STR "Interface IPv6 config commands\n" "Neighbor discovery\n" - "Router lifetime\n") + "Router lifetime\n" + "Router lifetime in seconds (0 stands for a non-default gw)\n") { VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zif = ifp->info; @@ -1067,36 +1058,29 @@ DEFUN (no_ipv6_nd_ra_lifetime, return CMD_SUCCESS; } -ALIAS (no_ipv6_nd_ra_lifetime, - no_ipv6_nd_ra_lifetime_val_cmd, - "no ipv6 nd ra-lifetime <0-9000>", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Router lifetime\n" - "Router lifetime in seconds (0 stands for a non-default gw)\n") - DEFUN (ipv6_nd_reachable_time, ipv6_nd_reachable_time_cmd, - "ipv6 nd reachable-time <1-3600000>", + "ipv6 nd reachable-time (1-3600000)", "Interface IPv6 config commands\n" "Neighbor discovery\n" "Reachable time\n" "Reachable time in milliseconds\n") { + int idx_number = 3; VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zif = ifp->info; - VTY_GET_INTEGER_RANGE ("reachable time", zif->rtadv.AdvReachableTime, argv[0], 1, RTADV_MAX_REACHABLE_TIME); + VTY_GET_INTEGER_RANGE ("reachable time", zif->rtadv.AdvReachableTime, argv[idx_number]->arg, 1, RTADV_MAX_REACHABLE_TIME); return CMD_SUCCESS; } DEFUN (no_ipv6_nd_reachable_time, no_ipv6_nd_reachable_time_cmd, - "no ipv6 nd reachable-time", + "no ipv6 nd reachable-time [(1-3600000)]", NO_STR "Interface IPv6 config commands\n" "Neighbor discovery\n" - "Reachable time\n") + "Reachable time\n" + "Reachable time in milliseconds\n") { VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zif = ifp->info; @@ -1106,36 +1090,29 @@ DEFUN (no_ipv6_nd_reachable_time, return CMD_SUCCESS; } -ALIAS (no_ipv6_nd_reachable_time, - no_ipv6_nd_reachable_time_val_cmd, - "no ipv6 nd reachable-time <1-3600000>", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Reachable time\n" - "Reachable time in milliseconds\n") - DEFUN (ipv6_nd_homeagent_preference, ipv6_nd_homeagent_preference_cmd, - "ipv6 nd home-agent-preference <0-65535>", + "ipv6 nd home-agent-preference (0-65535)", "Interface IPv6 config commands\n" "Neighbor discovery\n" "Home Agent preference\n" "preference value (default is 0, least preferred)\n") { + int idx_number = 3; VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zif = ifp->info; - VTY_GET_INTEGER_RANGE ("home agent preference", zif->rtadv.HomeAgentPreference, argv[0], 0, 65535); + VTY_GET_INTEGER_RANGE ("home agent preference", zif->rtadv.HomeAgentPreference, argv[idx_number]->arg, 0, 65535); return CMD_SUCCESS; } DEFUN (no_ipv6_nd_homeagent_preference, no_ipv6_nd_homeagent_preference_cmd, - "no ipv6 nd home-agent-preference", + "no ipv6 nd home-agent-preference [(0-65535)]", NO_STR "Interface IPv6 config commands\n" "Neighbor discovery\n" - "Home Agent preference\n") + "Home Agent preference\n" + "preference value (default is 0, least preferred)\n") { VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zif = ifp->info; @@ -1145,36 +1122,29 @@ DEFUN (no_ipv6_nd_homeagent_preference, return CMD_SUCCESS; } -ALIAS (no_ipv6_nd_homeagent_preference, - no_ipv6_nd_homeagent_preference_val_cmd, - "no ipv6 nd home-agent-preference <0-65535>", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Home Agent preference\n" - "preference value (default is 0, least preferred)\n") - DEFUN (ipv6_nd_homeagent_lifetime, ipv6_nd_homeagent_lifetime_cmd, - "ipv6 nd home-agent-lifetime <0-65520>", + "ipv6 nd home-agent-lifetime (0-65520)", "Interface IPv6 config commands\n" "Neighbor discovery\n" "Home Agent lifetime\n" "Home Agent lifetime in seconds (0 to track ra-lifetime)\n") { + int idx_number = 3; VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zif = ifp->info; - VTY_GET_INTEGER_RANGE ("home agent lifetime", zif->rtadv.HomeAgentLifetime, argv[0], 0, RTADV_MAX_HALIFETIME); + VTY_GET_INTEGER_RANGE ("home agent lifetime", zif->rtadv.HomeAgentLifetime, argv[idx_number]->arg, 0, RTADV_MAX_HALIFETIME); return CMD_SUCCESS; } DEFUN (no_ipv6_nd_homeagent_lifetime, no_ipv6_nd_homeagent_lifetime_cmd, - "no ipv6 nd home-agent-lifetime", + "no ipv6 nd home-agent-lifetime [(0-65520)]", NO_STR "Interface IPv6 config commands\n" "Neighbor discovery\n" - "Home Agent lifetime\n") + "Home Agent lifetime\n" + "Home Agent lifetime in seconds (0 to track ra-lifetime)\n") { VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zif = ifp->info; @@ -1184,15 +1154,6 @@ DEFUN (no_ipv6_nd_homeagent_lifetime, return CMD_SUCCESS; } -ALIAS (no_ipv6_nd_homeagent_lifetime, - no_ipv6_nd_homeagent_lifetime_val_cmd, - "no ipv6 nd home-agent-lifetime <0-65520>", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Home Agent lifetime\n" - "Home Agent lifetime in seconds (0 to track ra-lifetime)\n") - DEFUN (ipv6_nd_managed_config_flag, ipv6_nd_managed_config_flag_cmd, "ipv6 nd managed-config-flag", @@ -1319,8 +1280,7 @@ DEFUN (no_ipv6_nd_other_config_flag, DEFUN (ipv6_nd_prefix, ipv6_nd_prefix_cmd, - "ipv6 nd prefix X:X::X:X/M (<0-4294967295>|infinite) " - "(<0-4294967295>|infinite) (off-link|) (no-autoconfig|) (router-address|)", + "ipv6 nd prefix X:X::X:X/M [<(0-4294967295)|infinite> <(0-4294967295)|infinite>] [<router-address|off-link [no-autoconfig]|no-autoconfig [off-link]>]", "Interface IPv6 config commands\n" "Neighbor discovery\n" "Prefix information\n" @@ -1329,77 +1289,75 @@ DEFUN (ipv6_nd_prefix, "Infinite valid lifetime\n" "Preferred lifetime in seconds\n" "Infinite preferred lifetime\n" + "Set Router Address flag\n" "Do not use prefix for onlink determination\n" "Do not use prefix for autoconfiguration\n" - "Set Router Address flag\n") + "Do not use prefix for autoconfiguration\n" + "Do not use prefix for onlink determination\n") { + /* prelude */ + char *prefix = argv[3]->arg; + int lifetimes = (argc > 4) && (argv[4]->type == RANGE_TKN || strmatch (argv[4]->text, "infinite")); + int routeropts = lifetimes ? argc > 6 : argc > 4; + + int idx_routeropts = routeropts ? (lifetimes ? 6 : 4) : 0; + + char *lifetime = NULL, *preflifetime = NULL; + int routeraddr = 0, offlink = 0, noautoconf = 0; + if (lifetimes) + { + lifetime = argv[4]->type == RANGE_TKN ? argv[4]->arg : argv[4]->text; + preflifetime = argv[5]->type == RANGE_TKN ? argv[5]->arg : argv[5]->text; + } + if (routeropts) + { + routeraddr = strmatch (argv[idx_routeropts]->text, "router-address"); + if (!routeraddr) + { + offlink = (argc > idx_routeropts + 1 || strmatch (argv[idx_routeropts]->text, "off-link")); + noautoconf = (argc > idx_routeropts + 1 || strmatch (argv[idx_routeropts]->text, "no-autoconfig")); + } + } + + /* business */ VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zebra_if = ifp->info; - int i; int ret; - int cursor = 1; struct rtadv_prefix rp; - ret = str2prefix_ipv6 (argv[0], &rp.prefix); + ret = str2prefix_ipv6 (prefix, &rp.prefix); if (!ret) { vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE); return CMD_WARNING; } apply_mask_ipv6 (&rp.prefix); /* RFC4861 4.6.2 */ - rp.AdvOnLinkFlag = 1; - rp.AdvAutonomousFlag = 1; - rp.AdvRouterAddressFlag = 0; + rp.AdvOnLinkFlag = !offlink; + rp.AdvAutonomousFlag = !noautoconf; + rp.AdvRouterAddressFlag = routeraddr; rp.AdvValidLifetime = RTADV_VALID_LIFETIME; rp.AdvPreferredLifetime = RTADV_PREFERRED_LIFETIME; - if (argc > 1) - { - if ((isdigit((unsigned char)argv[1][0])) - || strncmp (argv[1], "i", 1) == 0) - { - if ( strncmp (argv[1], "i", 1) == 0) - rp.AdvValidLifetime = UINT32_MAX; - else - rp.AdvValidLifetime = (u_int32_t) strtoll (argv[1], - (char **)NULL, 10); - - if ( strncmp (argv[2], "i", 1) == 0) - rp.AdvPreferredLifetime = UINT32_MAX; - else - rp.AdvPreferredLifetime = (u_int32_t) strtoll (argv[2], - (char **)NULL, 10); - - if (rp.AdvPreferredLifetime > rp.AdvValidLifetime) - { - vty_out (vty, "Invalid preferred lifetime%s", VTY_NEWLINE); - return CMD_WARNING; - } - cursor = cursor + 2; - } - if (argc > cursor) - { - for (i = cursor; i < argc; i++) - { - if (strncmp (argv[i], "of", 2) == 0) - rp.AdvOnLinkFlag = 0; - if (strncmp (argv[i], "no", 2) == 0) - rp.AdvAutonomousFlag = 0; - if (strncmp (argv[i], "ro", 2) == 0) - rp.AdvRouterAddressFlag = 1; - } - } - } + if (lifetimes) + { + rp.AdvValidLifetime = strmatch (lifetime, "infinite") ? UINT32_MAX : strtoll (lifetime, NULL, 10); + rp.AdvPreferredLifetime = strmatch (preflifetime, "infinite") ? UINT32_MAX : strtoll (preflifetime, NULL, 10); + if (rp.AdvPreferredLifetime > rp.AdvValidLifetime) + { + vty_out (vty, "Invalid preferred lifetime%s", VTY_NEWLINE); + return CMD_WARNING; + } + } rtadv_prefix_set (zebra_if, &rp); return CMD_SUCCESS; } -ALIAS (ipv6_nd_prefix, - ipv6_nd_prefix_val_nortaddr_cmd, - "ipv6 nd prefix X:X::X:X/M (<0-4294967295>|infinite) " - "(<0-4294967295>|infinite) (off-link|) (no-autoconfig|)", +DEFUN (no_ipv6_nd_prefix, + no_ipv6_nd_prefix_cmd, + "no ipv6 nd prefix X:X::X:X/M [<(0-4294967295)|infinite> <(0-4294967295)|infinite>] [<router-address|off-link [no-autoconfig]|no-autoconfig [off-link]>]", + NO_STR "Interface IPv6 config commands\n" "Neighbor discovery\n" "Prefix information\n" @@ -1408,165 +1366,19 @@ ALIAS (ipv6_nd_prefix, "Infinite valid lifetime\n" "Preferred lifetime in seconds\n" "Infinite preferred lifetime\n" + "Set Router Address flag\n" "Do not use prefix for onlink determination\n" - "Do not use prefix for autoconfiguration\n") - -ALIAS (ipv6_nd_prefix, - ipv6_nd_prefix_val_rev_cmd, - "ipv6 nd prefix X:X::X:X/M (<0-4294967295>|infinite) " - "(<0-4294967295>|infinite) (no-autoconfig|) (off-link|)", - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Valid lifetime in seconds\n" - "Infinite valid lifetime\n" - "Preferred lifetime in seconds\n" - "Infinite preferred lifetime\n" "Do not use prefix for autoconfiguration\n" - "Do not use prefix for onlink determination\n") - -ALIAS (ipv6_nd_prefix, - ipv6_nd_prefix_val_rev_rtaddr_cmd, - "ipv6 nd prefix X:X::X:X/M (<0-4294967295>|infinite) " - "(<0-4294967295>|infinite) (no-autoconfig|) (off-link|) (router-address|)", - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Valid lifetime in seconds\n" - "Infinite valid lifetime\n" - "Preferred lifetime in seconds\n" - "Infinite preferred lifetime\n" "Do not use prefix for autoconfiguration\n" - "Do not use prefix for onlink determination\n" - "Set Router Address flag\n") - -ALIAS (ipv6_nd_prefix, - ipv6_nd_prefix_val_noauto_cmd, - "ipv6 nd prefix X:X::X:X/M (<0-4294967295>|infinite) " - "(<0-4294967295>|infinite) (no-autoconfig|)", - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Valid lifetime in seconds\n" - "Infinite valid lifetime\n" - "Preferred lifetime in seconds\n" - "Infinite preferred lifetime\n" - "Do not use prefix for autoconfiguration") - -ALIAS (ipv6_nd_prefix, - ipv6_nd_prefix_val_offlink_cmd, - "ipv6 nd prefix X:X::X:X/M (<0-4294967295>|infinite) " - "(<0-4294967295>|infinite) (off-link|)", - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Valid lifetime in seconds\n" - "Infinite valid lifetime\n" - "Preferred lifetime in seconds\n" - "Infinite preferred lifetime\n" "Do not use prefix for onlink determination\n") - -ALIAS (ipv6_nd_prefix, - ipv6_nd_prefix_val_rtaddr_cmd, - "ipv6 nd prefix X:X::X:X/M (<0-4294967295>|infinite) " - "(<0-4294967295>|infinite) (router-address|)", - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Valid lifetime in seconds\n" - "Infinite valid lifetime\n" - "Preferred lifetime in seconds\n" - "Infinite preferred lifetime\n" - "Set Router Address flag\n") - -ALIAS (ipv6_nd_prefix, - ipv6_nd_prefix_val_cmd, - "ipv6 nd prefix X:X::X:X/M (<0-4294967295>|infinite) " - "(<0-4294967295>|infinite)", - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Valid lifetime in seconds\n" - "Infinite valid lifetime\n" - "Preferred lifetime in seconds\n" - "Infinite preferred lifetime\n") - -ALIAS (ipv6_nd_prefix, - ipv6_nd_prefix_noval_cmd, - "ipv6 nd prefix X:X::X:X/M (no-autoconfig|) (off-link|)", - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Do not use prefix for autoconfiguration\n" - "Do not use prefix for onlink determination\n") - -ALIAS (ipv6_nd_prefix, - ipv6_nd_prefix_noval_rev_cmd, - "ipv6 nd prefix X:X::X:X/M (off-link|) (no-autoconfig|)", - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Do not use prefix for onlink determination\n" - "Do not use prefix for autoconfiguration\n") - -ALIAS (ipv6_nd_prefix, - ipv6_nd_prefix_noval_noauto_cmd, - "ipv6 nd prefix X:X::X:X/M (no-autoconfig|)", - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Do not use prefix for autoconfiguration\n") - -ALIAS (ipv6_nd_prefix, - ipv6_nd_prefix_noval_offlink_cmd, - "ipv6 nd prefix X:X::X:X/M (off-link|)", - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Do not use prefix for onlink determination\n") - -ALIAS (ipv6_nd_prefix, - ipv6_nd_prefix_noval_rtaddr_cmd, - "ipv6 nd prefix X:X::X:X/M (router-address|)", - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Set Router Address flag\n") - -ALIAS (ipv6_nd_prefix, - ipv6_nd_prefix_prefix_cmd, - "ipv6 nd prefix X:X::X:X/M", - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n") - -DEFUN (no_ipv6_nd_prefix, - no_ipv6_nd_prefix_cmd, - "no ipv6 nd prefix IPV6PREFIX", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n") { VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zebra_if = ifp->info; int ret; struct rtadv_prefix rp; + char *prefix = argv[4]->arg; - ret = str2prefix_ipv6 (argv[0], &rp.prefix); + ret = str2prefix_ipv6 (prefix, &rp.prefix); if (!ret) { vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE); @@ -1577,170 +1389,16 @@ DEFUN (no_ipv6_nd_prefix, ret = rtadv_prefix_reset (zebra_if, &rp); if (!ret) { - vty_out (vty, "Non-exist IPv6 prefix%s", VTY_NEWLINE); + vty_out (vty, "Non-existant IPv6 prefix%s", VTY_NEWLINE); return CMD_WARNING; } return CMD_SUCCESS; } -ALIAS (no_ipv6_nd_prefix, - no_ipv6_nd_prefix_val_nortaddr_cmd, - "no ipv6 nd prefix X:X::X:X/M (<0-4294967295>|infinite) (<0-4294967295>|infinite) (off-link|) (no-autoconfig|) (router-address|)", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Valid lifetime in seconds\n" - "Infinite valid lifetime\n" - "Preferred lifetime in seconds\n" - "Infinite preferred lifetime\n" - "Do not use prefix for onlink determination\n" - "Do not use prefix for autoconfiguration\n" - "Set Router Address flag\n") - -ALIAS (no_ipv6_nd_prefix, - no_ipv6_nd_prefix_val_rev_cmd, - "no ipv6 nd prefix X:X::X:X/M (<0-4294967295>|infinite) (<0-4294967295>|infinite) (no-autoconfig|) (off-link|)", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Valid lifetime in seconds\n" - "Infinite valid lifetime\n" - "Preferred lifetime in seconds\n" - "Infinite preferred lifetime\n" - "Do not use prefix for autoconfiguration\n" - "Do not use prefix for onlink determination\n") - -ALIAS (no_ipv6_nd_prefix, - no_ipv6_nd_prefix_val_rev_rtaddr_cmd, - "no ipv6 nd prefix X:X::X:X/M (<0-4294967295>|infinite) (<0-4294967295>|infinite) (no-autoconfig|) (off-link|) (router-address|)", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Valid lifetime in seconds\n" - "Infinite valid lifetime\n" - "Preferred lifetime in seconds\n" - "Infinite preferred lifetime\n" - "Do not use prefix for autoconfiguration\n" - "Do not use prefix for onlink determination\n" - "Set Router Address flag\n") - -ALIAS (no_ipv6_nd_prefix, - no_ipv6_nd_prefix_val_noauto_cmd, - "no ipv6 nd prefix X:X::X:X/M (<0-4294967295>|infinite) (<0-4294967295>|infinite) (no-autoconfig|)", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Valid lifetime in seconds\n" - "Infinite valid lifetime\n" - "Preferred lifetime in seconds\n" - "Infinite preferred lifetime\n" - "Do not use prefix for autoconfiguration") - -ALIAS (no_ipv6_nd_prefix, - no_ipv6_nd_prefix_val_offlink_cmd, - "no ipv6 nd prefix X:X::X:X/M (<0-4294967295>|infinite) (<0-4294967295>|infinite) (off-link|)", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Valid lifetime in seconds\n" - "Infinite valid lifetime\n" - "Preferred lifetime in seconds\n" - "Infinite preferred lifetime\n" - "Do not use prefix for onlink determination\n") - -ALIAS (no_ipv6_nd_prefix, - no_ipv6_nd_prefix_val_rtaddr_cmd, - "no ipv6 nd prefix X:X::X:X/M (<0-4294967295>|infinite) (<0-4294967295>|infinite) (router-address|)", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Valid lifetime in seconds\n" - "Infinite valid lifetime\n" - "Preferred lifetime in seconds\n" - "Infinite preferred lifetime\n" - "Set Router Address flag\n") - -ALIAS (no_ipv6_nd_prefix, - no_ipv6_nd_prefix_val_cmd, - "no ipv6 nd prefix X:X::X:X/M (<0-4294967295>|infinite) (<0-4294967295>|infinite)", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Valid lifetime in seconds\n" - "Infinite valid lifetime\n" - "Preferred lifetime in seconds\n" - "Infinite preferred lifetime\n") - -ALIAS (no_ipv6_nd_prefix, - no_ipv6_nd_prefix_noval_cmd, - "no ipv6 nd prefix X:X::X:X/M (no-autoconfig|) (off-link|)", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Do not use prefix for autoconfiguration\n" - "Do not use prefix for onlink determination\n") - -ALIAS (no_ipv6_nd_prefix, - no_ipv6_nd_prefix_noval_rev_cmd, - "no ipv6 nd prefix X:X::X:X/M (off-link|) (no-autoconfig|)", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Do not use prefix for onlink determination\n" - "Do not use prefix for autoconfiguration\n") - -ALIAS (no_ipv6_nd_prefix, - no_ipv6_nd_prefix_noval_noauto_cmd, - "no ipv6 nd prefix X:X::X:X/M (no-autoconfig|)", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Do not use prefix for autoconfiguration\n") - -ALIAS (no_ipv6_nd_prefix, - no_ipv6_nd_prefix_noval_offlink_cmd, - "no ipv6 nd prefix X:X::X:X/M (off-link|)", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Do not use prefix for onlink determination\n") - -ALIAS (no_ipv6_nd_prefix, - no_ipv6_nd_prefix_noval_rtaddr_cmd, - "no ipv6 nd prefix X:X::X:X/M (router-address|)", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Prefix information\n" - "IPv6 prefix\n" - "Set Router Address flag\n") - DEFUN (ipv6_nd_router_preference, ipv6_nd_router_preference_cmd, - "ipv6 nd router-preference (high|medium|low)", + "ipv6 nd router-preference <high|medium|low>", "Interface IPv6 config commands\n" "Neighbor discovery\n" "Default router preference\n" @@ -1748,13 +1406,14 @@ DEFUN (ipv6_nd_router_preference, "Low default router preference\n" "Medium default router preference (default)\n") { + int idx_high_medium_low = 3; VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zif = ifp->info; int i = 0; while (0 != rtadv_pref_strs[i]) { - if (strncmp (argv[0], rtadv_pref_strs[i], 1) == 0) + if (strncmp (argv[idx_high_medium_low]->arg, rtadv_pref_strs[i], 1) == 0) { zif->rtadv.DefaultPreference = i; return CMD_SUCCESS; @@ -1767,11 +1426,14 @@ DEFUN (ipv6_nd_router_preference, DEFUN (no_ipv6_nd_router_preference, no_ipv6_nd_router_preference_cmd, - "no ipv6 nd router-preference", + "no ipv6 nd router-preference [<high|medium|low>]", NO_STR "Interface IPv6 config commands\n" "Neighbor discovery\n" - "Default router preference\n") + "Default router preference\n" + "High default router preference\n" + "Medium default router preference (default)\n" + "Low default router preference\n") { VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zif = ifp->info; @@ -1781,38 +1443,29 @@ DEFUN (no_ipv6_nd_router_preference, return CMD_SUCCESS; } -ALIAS (no_ipv6_nd_router_preference, - no_ipv6_nd_router_preference_val_cmd, - "no ipv6 nd router-preference (high|medium|low)", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Default router preference\n" - "High default router preference\n" - "Low default router preference\n" - "Medium default router preference (default)\n") - DEFUN (ipv6_nd_mtu, ipv6_nd_mtu_cmd, - "ipv6 nd mtu <1-65535>", + "ipv6 nd mtu (1-65535)", "Interface IPv6 config commands\n" "Neighbor discovery\n" "Advertised MTU\n" "MTU in bytes\n") { + int idx_number = 3; VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zif = ifp->info; - VTY_GET_INTEGER_RANGE ("MTU", zif->rtadv.AdvLinkMTU, argv[0], 1, 65535); + VTY_GET_INTEGER_RANGE ("MTU", zif->rtadv.AdvLinkMTU, argv[idx_number]->arg, 1, 65535); return CMD_SUCCESS; } DEFUN (no_ipv6_nd_mtu, no_ipv6_nd_mtu_cmd, - "no ipv6 nd mtu", + "no ipv6 nd mtu [(1-65535)]", NO_STR "Interface IPv6 config commands\n" "Neighbor discovery\n" - "Advertised MTU\n") + "Advertised MTU\n" + "MTU in bytes\n") { VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zif = ifp->info; @@ -1820,14 +1473,6 @@ DEFUN (no_ipv6_nd_mtu, return CMD_SUCCESS; } -ALIAS (no_ipv6_nd_mtu, - no_ipv6_nd_mtu_val_cmd, - "no ipv6 nd mtu <1-65535>", - NO_STR - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Advertised MTU\n" - "MTU in bytes\n") /* Write configuration about router advertisement. */ void @@ -1994,14 +1639,10 @@ rtadv_cmd_init (void) install_element (INTERFACE_NODE, &ipv6_nd_ra_interval_cmd); install_element (INTERFACE_NODE, &ipv6_nd_ra_interval_msec_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_ra_interval_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_ra_interval_val_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_ra_interval_msec_val_cmd); install_element (INTERFACE_NODE, &ipv6_nd_ra_lifetime_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_ra_lifetime_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_ra_lifetime_val_cmd); install_element (INTERFACE_NODE, &ipv6_nd_reachable_time_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_reachable_time_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_reachable_time_val_cmd); install_element (INTERFACE_NODE, &ipv6_nd_managed_config_flag_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_managed_config_flag_cmd); install_element (INTERFACE_NODE, &ipv6_nd_other_config_flag_cmd); @@ -2010,45 +1651,16 @@ rtadv_cmd_init (void) install_element (INTERFACE_NODE, &no_ipv6_nd_homeagent_config_flag_cmd); install_element (INTERFACE_NODE, &ipv6_nd_homeagent_preference_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_homeagent_preference_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_homeagent_preference_val_cmd); install_element (INTERFACE_NODE, &ipv6_nd_homeagent_lifetime_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_homeagent_lifetime_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_homeagent_lifetime_val_cmd); install_element (INTERFACE_NODE, &ipv6_nd_adv_interval_config_option_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_adv_interval_config_option_cmd); install_element (INTERFACE_NODE, &ipv6_nd_prefix_cmd); - install_element (INTERFACE_NODE, &ipv6_nd_prefix_val_rev_rtaddr_cmd); - install_element (INTERFACE_NODE, &ipv6_nd_prefix_val_nortaddr_cmd); - install_element (INTERFACE_NODE, &ipv6_nd_prefix_val_rev_cmd); - install_element (INTERFACE_NODE, &ipv6_nd_prefix_val_noauto_cmd); - install_element (INTERFACE_NODE, &ipv6_nd_prefix_val_offlink_cmd); - install_element (INTERFACE_NODE, &ipv6_nd_prefix_val_rtaddr_cmd); - install_element (INTERFACE_NODE, &ipv6_nd_prefix_val_cmd); - install_element (INTERFACE_NODE, &ipv6_nd_prefix_noval_cmd); - install_element (INTERFACE_NODE, &ipv6_nd_prefix_noval_rev_cmd); - install_element (INTERFACE_NODE, &ipv6_nd_prefix_noval_noauto_cmd); - install_element (INTERFACE_NODE, &ipv6_nd_prefix_noval_offlink_cmd); - install_element (INTERFACE_NODE, &ipv6_nd_prefix_noval_rtaddr_cmd); - install_element (INTERFACE_NODE, &ipv6_nd_prefix_prefix_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_prefix_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_prefix_val_rev_rtaddr_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_prefix_val_nortaddr_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_prefix_val_rev_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_prefix_val_noauto_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_prefix_val_offlink_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_prefix_val_rtaddr_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_prefix_val_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_prefix_noval_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_prefix_noval_rev_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_prefix_noval_noauto_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_prefix_noval_offlink_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_prefix_noval_rtaddr_cmd); install_element (INTERFACE_NODE, &ipv6_nd_router_preference_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_router_preference_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_router_preference_val_cmd); install_element (INTERFACE_NODE, &ipv6_nd_mtu_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_mtu_cmd); - install_element (INTERFACE_NODE, &no_ipv6_nd_mtu_val_cmd); } static int diff --git a/zebra/rtread_netlink.c b/zebra/rtread_netlink.c index c27e6e97f1..1d41861bbd 100644 --- a/zebra/rtread_netlink.c +++ b/zebra/rtread_netlink.c @@ -22,6 +22,7 @@ #include <zebra.h> +#include "vty.h" #include "zebra/zserv.h" #include "zebra/rt_netlink.h" diff --git a/zebra/test_main.c b/zebra/test_main.c index 828b61af91..2829328546 100644 --- a/zebra/test_main.c +++ b/zebra/test_main.c @@ -119,15 +119,14 @@ static ifindex_t test_ifindex = 0; /* testrib commands */ DEFUN (test_interface_state, test_interface_state_cmd, - "state (up|down)", + "state <up|down>", "configure interface\n" "up\n" "down\n") { + int idx_up_down = 1; VTY_DECLVAR_CONTEXT (interface, ifp); - if (argc < 1) - return CMD_WARNING; - + if (ifp->ifindex == IFINDEX_INTERNAL) { ifp->ifindex = ++test_ifindex; @@ -135,7 +134,7 @@ DEFUN (test_interface_state, ifp->flags = IFF_BROADCAST|IFF_MULTICAST; } - switch (argv[0][0]) + switch (argv[idx_up_down]->arg[0]) { case 'u': SET_FLAG (ifp->flags, IFF_UP); diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index 343ce1776c..7e8b8682d2 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -1569,9 +1569,9 @@ DEFUN (clear_zebra_fpm_stats, /* * update fpm connection information */ -DEFUN ( fpm_remote_ip, - fpm_remote_ip_cmd, - "fpm connection ip A.B.C.D port <1-65535>", +DEFUN ( fpm_remote_ip, + fpm_remote_ip_cmd, + "fpm connection ip A.B.C.D port (1-65535)", "fpm connection remote ip and port\n" "Remote fpm server ip A.B.C.D\n" "Enter ip ") @@ -1580,11 +1580,11 @@ DEFUN ( fpm_remote_ip, in_addr_t fpm_server; uint32_t port_no; - fpm_server = inet_addr (argv[0]); + fpm_server = inet_addr (argv[3]->arg); if (fpm_server == INADDR_NONE) return CMD_ERR_INCOMPLETE; - port_no = atoi (argv[1]); + port_no = atoi (argv[5]->arg); if (port_no < TCP_MIN_PORT || port_no > TCP_MAX_PORT) return CMD_ERR_INCOMPLETE; @@ -1595,16 +1595,16 @@ DEFUN ( fpm_remote_ip, return CMD_SUCCESS; } -DEFUN ( no_fpm_remote_ip, - no_fpm_remote_ip_cmd, - "no fpm connection ip A.B.C.D port <1-65535>", +DEFUN ( no_fpm_remote_ip, + no_fpm_remote_ip_cmd, + "no fpm connection ip A.B.C.D port (1-65535)", "fpm connection remote ip and port\n" "Connection\n" "Remote fpm server ip A.B.C.D\n" "Enter ip ") { - if (zfpm_g->fpm_server != inet_addr (argv[0]) || - zfpm_g->fpm_port != atoi (argv[1])) + if (zfpm_g->fpm_server != inet_addr (argv[4]->arg) || + zfpm_g->fpm_port != atoi (argv[6]->arg)) return CMD_ERR_NO_MATCH; zfpm_g->fpm_server = FPM_DEFAULT_IP; diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c index 6543298605..f2cba10943 100644 --- a/zebra/zebra_fpm_netlink.c +++ b/zebra/zebra_fpm_netlink.c @@ -27,6 +27,7 @@ #include "log.h" #include "rib.h" +#include "vty.h" #include "zebra/zserv.h" #include "zebra/zebra_ns.h" diff --git a/zebra/zebra_mpls_vty.c b/zebra/zebra_mpls_vty.c index 8b967c3af8..ff84c59432 100644 --- a/zebra/zebra_mpls_vty.c +++ b/zebra/zebra_mpls_vty.c @@ -159,7 +159,7 @@ zebra_mpls_transit_lsp (struct vty *vty, int add_cmd, const char *inlabel_str, DEFUN (mpls_transit_lsp, mpls_transit_lsp_cmd, - "mpls lsp <16-1048575> (A.B.C.D|X:X::X:X) (<16-1048575>|explicit-null|implicit-null)", + "mpls lsp (16-1048575) <A.B.C.D|X:X::X:X> <(16-1048575)|explicit-null|implicit-null>", MPLS_STR "Establish label switched path\n" "Incoming MPLS label\n" @@ -169,12 +169,12 @@ DEFUN (mpls_transit_lsp, "Use Explicit-Null label\n" "Use Implicit-Null label\n") { - return zebra_mpls_transit_lsp (vty, 1, argv[0], argv[1], argv[2], NULL); + return zebra_mpls_transit_lsp (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL); } DEFUN (no_mpls_transit_lsp, no_mpls_transit_lsp_cmd, - "no mpls lsp <16-1048575> (A.B.C.D|X:X::X:X)", + "no mpls lsp (16-1048575) <A.B.C.D|X:X::X:X>", NO_STR MPLS_STR "Establish label switched path\n" @@ -182,12 +182,12 @@ DEFUN (no_mpls_transit_lsp, "IPv4 gateway address\n" "IPv6 gateway address\n") { - return zebra_mpls_transit_lsp (vty, 0, argv[0], argv[1], NULL, NULL); + return zebra_mpls_transit_lsp (vty, 0, argv[3]->arg, argv[4]->arg, NULL, NULL); } ALIAS (no_mpls_transit_lsp, no_mpls_transit_lsp_out_label_cmd, - "no mpls lsp <16-1048575> (A.B.C.D|X:X::X:X) (<16-1048575>|explicit-null|implicit-null)", + "no mpls lsp (16-1048575) <A.B.C.D|X:X::X:X> <(16-1048575)|explicit-null|implicit-null>", NO_STR MPLS_STR "Establish label switched path\n" @@ -200,19 +200,19 @@ ALIAS (no_mpls_transit_lsp, DEFUN (no_mpls_transit_lsp_all, no_mpls_transit_lsp_all_cmd, - "no mpls lsp <16-1048575>", + "no mpls lsp (16-1048575)", NO_STR MPLS_STR "Establish label switched path\n" "Incoming MPLS label\n") { - return zebra_mpls_transit_lsp (vty, 0, argv[0], NULL, NULL, NULL); + return zebra_mpls_transit_lsp (vty, 0, argv[3]->arg, NULL, NULL, NULL); } /* Static route configuration. */ DEFUN (ip_route_label, ip_route_label_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) label WORD", + "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> label WORD", IP_STR "Establish static routes\n" "IP destination prefix (e.g. 10.0.0.0/8)\n" @@ -222,13 +222,13 @@ DEFUN (ip_route_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, NULL, - NULL, NULL, argv[2]); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, NULL, + NULL, NULL, argv[5]->arg); } DEFUN (ip_route_tag_label, ip_route_tag_label_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295> label WORD", + "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD", IP_STR "Establish static routes\n" "IP destination prefix (e.g. 10.0.0.0/8)\n" @@ -240,14 +240,14 @@ DEFUN (ip_route_tag_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, argv[2], - NULL, NULL, argv[3]); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, argv[5]->arg, + NULL, NULL, argv[7]->arg); } /* Mask as A.B.C.D format. */ DEFUN (ip_route_mask_label, ip_route_mask_label_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) label WORD", + "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> label WORD", IP_STR "Establish static routes\n" "IP destination prefix\n" @@ -258,13 +258,13 @@ DEFUN (ip_route_mask_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, NULL, - NULL, NULL, argv[3]); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, NULL, + NULL, NULL, argv[6]->arg); } DEFUN (ip_route_mask_tag_label, ip_route_mask_tag_label_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295> label WORD", + "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD", IP_STR "Establish static routes\n" "IP destination prefix\n" @@ -278,14 +278,14 @@ DEFUN (ip_route_mask_tag_label, "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, argv[3], - NULL, NULL, argv[4]); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg, + NULL, NULL, argv[8]->arg); } /* Distance option value. */ DEFUN (ip_route_distance_label, ip_route_distance_label_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> label WORD", + "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> (1-255) label WORD", IP_STR "Establish static routes\n" "IP destination prefix (e.g. 10.0.0.0/8)\n" @@ -296,13 +296,13 @@ DEFUN (ip_route_distance_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, NULL, - argv[2], NULL, argv[3]); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, NULL, + argv[4]->arg, NULL, argv[6]->arg); } DEFUN (ip_route_tag_distance_label, ip_route_tag_distance_label_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255> label WORD", + "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD", IP_STR "Establish static routes\n" "IP destination prefix (e.g. 10.0.0.0/8)\n" @@ -316,13 +316,13 @@ DEFUN (ip_route_tag_distance_label, "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, argv[2], - argv[3], NULL, argv[4]); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, argv[5]->arg, + argv[6]->arg, NULL, argv[8]->arg); } DEFUN (ip_route_mask_distance_label, ip_route_mask_distance_label_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255> label WORD", + "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> (1-255) label WORD", IP_STR "Establish static routes\n" "IP destination prefix\n" @@ -334,13 +334,13 @@ DEFUN (ip_route_mask_distance_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, NULL, - argv[3], NULL, argv[4]); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, NULL, + argv[5]->arg, NULL, argv[7]->arg); } DEFUN (ip_route_mask_tag_distance_label, ip_route_mask_tag_distance_label_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255> label WORD", + "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD", IP_STR "Establish static routes\n" "IP destination prefix\n" @@ -354,13 +354,13 @@ DEFUN (ip_route_mask_tag_distance_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, argv[3], - argv[4], NULL, argv[5]); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg, + argv[7]->arg, NULL, argv[9]->arg); } DEFUN (no_ip_route_label, no_ip_route_label_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) label WORD", + "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> label WORD", NO_STR IP_STR "Establish static routes\n" @@ -371,13 +371,13 @@ DEFUN (no_ip_route_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, NULL, - NULL, NULL, argv[2]); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, NULL, + NULL, NULL, argv[6]->arg); } DEFUN (no_ip_route_tag_label, no_ip_route_tag_label_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295> label WORD", + "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD", NO_STR IP_STR "Establish static routes\n" @@ -390,13 +390,13 @@ DEFUN (no_ip_route_tag_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, argv[2], - NULL, NULL, argv[3]); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, argv[6]->arg, + NULL, NULL, argv[8]->arg); } DEFUN (no_ip_route_mask_label, no_ip_route_mask_label_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) label WORD", + "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> label WORD", NO_STR IP_STR "Establish static routes\n" @@ -408,13 +408,13 @@ DEFUN (no_ip_route_mask_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, NULL, - NULL, NULL, argv[3]); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, NULL, + NULL, NULL, argv[7]->arg); } DEFUN (no_ip_route_mask_tag_label, no_ip_route_mask_tag_label_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295> label WORD", + "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD", NO_STR IP_STR "Establish static routes\n" @@ -428,13 +428,13 @@ DEFUN (no_ip_route_mask_tag_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, argv[3], - NULL, NULL, argv[4]); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg, + NULL, NULL, argv[9]->arg); } DEFUN (no_ip_route_distance_label, no_ip_route_distance_label_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> label WORD", + "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> (1-255) label WORD", NO_STR IP_STR "Establish static routes\n" @@ -446,13 +446,13 @@ DEFUN (no_ip_route_distance_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, NULL, - argv[2], NULL, argv[3]); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, NULL, + argv[5]->arg, NULL, argv[7]->arg); } DEFUN (no_ip_route_tag_distance_label, no_ip_route_tag_distance_label_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255> label WORD", + "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD", NO_STR IP_STR "Establish static routes\n" @@ -466,13 +466,13 @@ DEFUN (no_ip_route_tag_distance_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, argv[2], - argv[3], NULL, argv[4]); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, argv[6]->arg, + argv[7]->arg, NULL, argv[9]->arg); } DEFUN (no_ip_route_mask_distance_label, no_ip_route_mask_distance_label_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>", + "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> (1-255)", NO_STR IP_STR "Establish static routes\n" @@ -485,13 +485,13 @@ DEFUN (no_ip_route_mask_distance_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, NULL, - argv[3], NULL, argv[5]); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, NULL, + argv[6]->arg, NULL, NULL); } DEFUN (no_ip_route_mask_tag_distance_label, no_ip_route_mask_tag_distance_label_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255> label WORD", + "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD", NO_STR IP_STR "Establish static routes\n" @@ -506,13 +506,13 @@ DEFUN (no_ip_route_mask_tag_distance_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, argv[3], - argv[4], NULL, argv[5]); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg, + argv[8]->arg, NULL, argv[10]->arg); } DEFUN (ipv6_route_label, ipv6_route_label_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) label WORD", + "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> label WORD", IP_STR "Establish static routes\n" "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" @@ -521,12 +521,12 @@ DEFUN (ipv6_route_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, NULL, NULL, argv[2]); + return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, NULL, NULL, NULL, NULL, argv[5]->arg); } DEFUN (ipv6_route_tag_label, ipv6_route_tag_label_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295> label WORD", + "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) label WORD", IP_STR "Establish static routes\n" "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" @@ -537,7 +537,7 @@ DEFUN (ipv6_route_tag_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], NULL, NULL, argv[3]); + return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, NULL, argv[5]->arg, NULL, NULL, argv[7]->arg); } DEFUN (ipv6_route_ifname_label, @@ -551,11 +551,11 @@ DEFUN (ipv6_route_ifname_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, NULL, NULL, argv[3]); + return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, NULL, NULL, NULL, argv[6]->arg); } DEFUN (ipv6_route_ifname_tag_label, ipv6_route_ifname_tag_label_cmd, - "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295> label WORD", + "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) label WORD", IP_STR "Establish static routes\n" "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" @@ -566,12 +566,12 @@ DEFUN (ipv6_route_ifname_tag_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], NULL, NULL, argv[4]); + return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg, NULL, NULL, argv[8]->arg); } DEFUN (ipv6_route_pref_label, ipv6_route_pref_label_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> label WORD", + "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> (1-255) label WORD", IP_STR "Establish static routes\n" "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" @@ -581,12 +581,12 @@ DEFUN (ipv6_route_pref_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, argv[2], NULL, argv[3]); + return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, NULL, NULL, argv[4]->arg, NULL, argv[6]->arg); } DEFUN (ipv6_route_pref_tag_label, ipv6_route_pref_tag_label_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295> <1-255> label WORD", + "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) (1-255) label WORD", IP_STR "Establish static routes\n" "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" @@ -598,12 +598,12 @@ DEFUN (ipv6_route_pref_tag_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], argv[3], NULL, argv[4]); + return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, NULL, argv[5]->arg, argv[6]->arg, NULL, argv[8]->arg); } DEFUN (ipv6_route_ifname_pref_label, ipv6_route_ifname_pref_label_cmd, - "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> label WORD", + "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (1-255) label WORD", IP_STR "Establish static routes\n" "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" @@ -613,12 +613,12 @@ DEFUN (ipv6_route_ifname_pref_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, argv[3], NULL, argv[4]); + return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, NULL, argv[5]->arg, NULL, argv[7]->arg); } DEFUN (ipv6_route_ifname_pref_tag_label, ipv6_route_ifname_pref_tag_label_cmd, - "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295> <1-255> label WORD", + "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) (1-255) label WORD", IP_STR "Establish static routes\n" "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" @@ -630,12 +630,12 @@ DEFUN (ipv6_route_ifname_pref_tag_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], argv[4], NULL, argv[5]); + return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg, argv[7]->arg, NULL, argv[9]->arg); } DEFUN (no_ipv6_route_label, no_ipv6_route_label_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) label WORD", + "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> label WORD", NO_STR IP_STR "Establish static routes\n" @@ -645,12 +645,12 @@ DEFUN (no_ipv6_route_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, NULL, NULL, argv[2]); + return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, NULL, NULL, NULL, NULL, argv[6]->arg); } DEFUN (no_ipv6_route_tag_label, no_ipv6_route_tag_label_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295> label WORD", + "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) label WORD", NO_STR IP_STR "Establish static routes\n" @@ -662,7 +662,7 @@ DEFUN (no_ipv6_route_tag_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], NULL, NULL, argv[3]); + return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, NULL, argv[6]->arg, NULL, NULL, argv[8]->arg); } DEFUN (no_ipv6_route_ifname_label, @@ -677,12 +677,12 @@ DEFUN (no_ipv6_route_ifname_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, NULL, NULL, argv[3]); + return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, NULL, NULL, NULL, argv[7]->arg); } DEFUN (no_ipv6_route_ifname_tag_label, no_ipv6_route_ifname_tag_label_cmd, - "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295> label WORD", + "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) label WORD", NO_STR IP_STR "Establish static routes\n" @@ -694,12 +694,12 @@ DEFUN (no_ipv6_route_ifname_tag_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], NULL, NULL, argv[4]); + return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg, NULL, NULL, argv[9]->arg); } DEFUN (no_ipv6_route_pref_label, no_ipv6_route_pref_label_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> label WORD", + "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> (1-255) label WORD", NO_STR IP_STR "Establish static routes\n" @@ -710,12 +710,12 @@ DEFUN (no_ipv6_route_pref_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, argv[2], NULL, argv[3]); + return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, NULL, NULL, argv[5]->arg, NULL, argv[7]->arg); } DEFUN (no_ipv6_route_pref_tag_label, no_ipv6_route_pref_tag_label_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295> <1-255> label WORD", + "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) (1-255) label WORD", NO_STR IP_STR "Establish static routes\n" @@ -728,12 +728,12 @@ DEFUN (no_ipv6_route_pref_tag_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], argv[3], NULL, argv[4]); + return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, NULL, argv[6]->arg, argv[7]->arg, NULL, argv[9]->arg); } DEFUN (no_ipv6_route_ifname_pref_label, no_ipv6_route_ifname_pref_label_cmd, - "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> label WORD", + "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (1-255) label WORD", NO_STR IP_STR "Establish static routes\n" @@ -744,12 +744,12 @@ DEFUN (no_ipv6_route_ifname_pref_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, argv[3], NULL, argv[4]); + return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, NULL, argv[6]->arg, NULL, argv[8]->arg); } DEFUN (no_ipv6_route_ifname_pref_tag_label, no_ipv6_route_ifname_pref_tag_label_cmd, - "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295> <1-255> label WORD", + "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) (1-255) label WORD", NO_STR IP_STR "Establish static routes\n" @@ -762,7 +762,7 @@ DEFUN (no_ipv6_route_ifname_pref_tag_label, "Specify label(s) for this route\n" "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], argv[4], NULL, argv[5]); + return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg, argv[8]->arg, NULL, argv[10]->arg); } /* MPLS LSP configuration write function. */ @@ -782,14 +782,14 @@ zebra_mpls_config (struct vty *vty) DEFUN (show_mpls_table, show_mpls_table_cmd, - "show mpls table {json}", + "show mpls table [json]", SHOW_STR MPLS_STR "MPLS table\n" "JavaScript Object Notation\n") { struct zebra_vrf *zvrf; - u_char use_json = (argv[0] != NULL); + u_char use_json = (argv[3]->arg != NULL); zvrf = vrf_info_lookup(VRF_DEFAULT); zebra_mpls_print_lsp_table(vty, zvrf, use_json); @@ -798,7 +798,7 @@ DEFUN (show_mpls_table, DEFUN (show_mpls_table_lsp, show_mpls_table_lsp_cmd, - "show mpls table <16-1048575> {json}", + "show mpls table (16-1048575) [json]", SHOW_STR MPLS_STR "MPLS table\n" @@ -807,10 +807,10 @@ DEFUN (show_mpls_table_lsp, { u_int32_t label; struct zebra_vrf *zvrf; - u_char use_json = (argv[1] != NULL); + u_char use_json = (argv[4]->arg != NULL); zvrf = vrf_info_lookup(VRF_DEFAULT); - label = atoi(argv[0]); + label = atoi(argv[3]->arg); zebra_mpls_print_lsp (vty, zvrf, label, use_json); return CMD_SUCCESS; } diff --git a/zebra/zebra_rnh_null.c b/zebra/zebra_rnh_null.c index 3ec8be027d..b7809d3145 100644 --- a/zebra/zebra_rnh_null.c +++ b/zebra/zebra_rnh_null.c @@ -1,4 +1,5 @@ #include <zebra.h> +#include "vty.h" #include "zebra/rib.h" #include "zebra/zserv.h" #include "zebra/zebra_rnh.h" diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index 25091a3eab..af69a9d0e0 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -25,6 +25,7 @@ #include "zebra_memory.h" #include "prefix.h" #include "rib.h" +#include "vty.h" #include "routemap.h" #include "command.h" #include "filter.h" @@ -56,6 +57,8 @@ struct nh_rmap_obj static void zebra_route_map_set_delay_timer(u_int32_t value); + + /* Add zebra route map rule */ static int zebra_route_match_add(struct vty *vty, @@ -138,54 +141,6 @@ zebra_route_match_delete (struct vty *vty, return CMD_SUCCESS; } -/* Add zebra route map rule. */ -static int -zebra_route_set_add (struct vty *vty, - const char *command, const char *arg) -{ - VTY_DECLVAR_CONTEXT (route_map_index, index); - int ret; - - ret = route_map_add_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% Zebra Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% Zebra Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - -/* Delete zebra route map rule. */ -static int -zebra_route_set_delete (struct vty *vty, - const char *command, const char *arg) -{ - VTY_DECLVAR_CONTEXT (route_map_index, index); - int ret; - - ret = route_map_delete_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% Zebra Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% Zebra Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - /* 'match tag TAG' * Match function return 1 if match is success else return 0 */ @@ -210,8 +165,8 @@ route_match_tag (void *rule, struct prefix *prefix, /* Route map commands for tag matching */ static struct route_map_rule_cmd route_match_tag_cmd = { - "tag", - route_match_tag, + "tag", + route_match_tag, route_map_rule_tag_compile, route_map_rule_tag_free, }; @@ -266,240 +221,9 @@ struct route_map_rule_cmd route_match_interface_cmd = route_match_interface_free }; -DEFUN (match_interface, - match_interface_cmd, - "match interface WORD", - MATCH_STR - "match first hop interface of route\n" - "Interface name\n") -{ - return zebra_route_match_add (vty, "interface", argv[0], - RMAP_EVENT_MATCH_ADDED); -} - -DEFUN (no_match_interface, - no_match_interface_cmd, - "no match interface", - NO_STR - MATCH_STR - "Match first hop interface of route\n") -{ - if (argc == 0) - return zebra_route_match_delete (vty, "interface", NULL, RMAP_EVENT_MATCH_DELETED); - - return zebra_route_match_delete (vty, "interface", argv[0], RMAP_EVENT_MATCH_DELETED); -} - -ALIAS (no_match_interface, - no_match_interface_val_cmd, - "no match interface WORD", - NO_STR - MATCH_STR - "Match first hop interface of route\n" - "Interface name\n") - -DEFUN (match_tag, - match_tag_cmd, - "match tag <1-4294967295>", - MATCH_STR - "Match tag of route\n" - "Tag value\n") -{ - return zebra_route_match_add (vty, "tag", argv[0], - RMAP_EVENT_MATCH_ADDED); -} - -DEFUN (no_match_tag, - no_match_tag_cmd, - "no match tag", - NO_STR - MATCH_STR - "Match tag of route\n") -{ - if (argc == 0) - return zebra_route_match_delete (vty, "tag", NULL, - RMAP_EVENT_MATCH_DELETED); - - return zebra_route_match_delete (vty, "tag", argv[0], - RMAP_EVENT_MATCH_DELETED); -} - -ALIAS (no_match_tag, - no_match_tag_val_cmd, - "no match tag <1-4294967295>", - NO_STR - MATCH_STR - "Match tag of route\n") - -DEFUN (match_ip_next_hop, - match_ip_next_hop_cmd, - "match ip next-hop (<1-199>|<1300-2699>|WORD)", - MATCH_STR - IP_STR - "Match next-hop address of route\n" - "IP access-list number\n" - "IP access-list number (expanded range)\n" - "IP Access-list name\n") -{ - return zebra_route_match_add (vty, "ip next-hop", argv[0], RMAP_EVENT_FILTER_ADDED); -} - -DEFUN (no_match_ip_next_hop, - no_match_ip_next_hop_cmd, - "no match ip next-hop", - NO_STR - MATCH_STR - IP_STR - "Match next-hop address of route\n") -{ - if (argc == 0) - return zebra_route_match_delete (vty, "ip next-hop", NULL, - RMAP_EVENT_FILTER_DELETED); - - return zebra_route_match_delete (vty, "ip next-hop", argv[0], - RMAP_EVENT_FILTER_DELETED); -} - -ALIAS (no_match_ip_next_hop, - no_match_ip_next_hop_val_cmd, - "no match ip next-hop (<1-199>|<1300-2699>|WORD)", - NO_STR - MATCH_STR - IP_STR - "Match next-hop address of route\n" - "IP access-list number\n" - "IP access-list number (expanded range)\n" - "IP Access-list name\n") - -DEFUN (match_ip_next_hop_prefix_list, - match_ip_next_hop_prefix_list_cmd, - "match ip next-hop prefix-list WORD", - MATCH_STR - IP_STR - "Match next-hop address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") -{ - return zebra_route_match_add (vty, "ip next-hop prefix-list", - argv[0], RMAP_EVENT_PLIST_ADDED); -} - -DEFUN (no_match_ip_next_hop_prefix_list, - no_match_ip_next_hop_prefix_list_cmd, - "no match ip next-hop prefix-list", - NO_STR - MATCH_STR - IP_STR - "Match next-hop address of route\n" - "Match entries of prefix-lists\n") -{ - if (argc == 0) - return zebra_route_match_delete (vty, - "ip next-hop prefix-list", NULL, - RMAP_EVENT_PLIST_DELETED); - - return zebra_route_match_delete (vty, - "ip next-hop prefix-list", argv[0], - RMAP_EVENT_PLIST_DELETED); -} - -ALIAS (no_match_ip_next_hop_prefix_list, - no_match_ip_next_hop_prefix_list_val_cmd, - "no match ip next-hop prefix-list WORD", - NO_STR - MATCH_STR - IP_STR - "Match next-hop address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") - -DEFUN (match_ip_address, - match_ip_address_cmd, - "match ip address (<1-199>|<1300-2699>|WORD)", - MATCH_STR - IP_STR - "Match address of route\n" - "IP access-list number\n" - "IP access-list number (expanded range)\n" - "IP Access-list name\n") - -{ - return zebra_route_match_add (vty, "ip address", argv[0], - RMAP_EVENT_FILTER_ADDED); -} - -DEFUN (no_match_ip_address, - no_match_ip_address_cmd, - "no match ip address", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n") -{ - if (argc == 0) - return zebra_route_match_delete (vty, "ip address", NULL, - RMAP_EVENT_FILTER_DELETED); - - return zebra_route_match_delete (vty, "ip address", argv[0], - RMAP_EVENT_FILTER_DELETED); -} - -ALIAS (no_match_ip_address, - no_match_ip_address_val_cmd, - "no match ip address (<1-199>|<1300-2699>|WORD)", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n" - "IP access-list number\n" - "IP access-list number (expanded range)\n" - "IP Access-list name\n") - -DEFUN (match_ip_address_prefix_list, - match_ip_address_prefix_list_cmd, - "match ip address prefix-list WORD", - MATCH_STR - IP_STR - "Match address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") -{ - return zebra_route_match_add (vty, "ip address prefix-list", - argv[0], RMAP_EVENT_PLIST_ADDED); -} - -DEFUN (no_match_ip_address_prefix_list, - no_match_ip_address_prefix_list_cmd, - "no match ip address prefix-list", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n" - "Match entries of prefix-lists\n") -{ - if (argc == 0) - return zebra_route_match_delete (vty, - "ip address prefix-list", NULL, - RMAP_EVENT_PLIST_DELETED); - - return zebra_route_match_delete (vty, - "ip address prefix-list", argv[0], - RMAP_EVENT_PLIST_DELETED); -} - -ALIAS (no_match_ip_address_prefix_list, - no_match_ip_address_prefix_list_val_cmd, - "no match ip address prefix-list WORD", - NO_STR - MATCH_STR - IP_STR - "Match address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") - DEFUN (match_ip_address_prefix_len, match_ip_address_prefix_len_cmd, - "match ip address prefix-len NUMBER", + "match ip address prefix-len (0-32)", MATCH_STR IP_STR "Match prefix length of ip address\n" @@ -507,40 +231,29 @@ DEFUN (match_ip_address_prefix_len, "Prefix length\n") { return zebra_route_match_add (vty, "ip address prefix-len", - argv[0], RMAP_EVENT_MATCH_ADDED); + argv[4]->arg, RMAP_EVENT_MATCH_ADDED); } DEFUN (no_match_ip_address_prefix_len, no_match_ip_address_prefix_len_cmd, - "no match ip address prefix-len", + "no match ip address prefix-len [(0-32)]", NO_STR MATCH_STR IP_STR - "Match prefixlen of ip address of route\n" - "prefix length of ip address\n") + "Match prefix length of ip address\n" + "Match prefix length of ip address\n" + "Prefix length\n") { - if (argc == 0) - return zebra_route_match_delete (vty, - "ip address prefix-len", NULL, - RMAP_EVENT_MATCH_DELETED); - + char *plen = (argc == 6) ? argv[5]->arg : NULL; return zebra_route_match_delete (vty, - "ip address prefix-len", argv[0], + "ip address prefix-len", plen, RMAP_EVENT_MATCH_DELETED); } -ALIAS (no_match_ip_address_prefix_len, - no_match_ip_address_prefix_len_val_cmd, - "no match ip address prefix-len NUMBER", - NO_STR - MATCH_STR - IP_STR - "Match prefixlen of ip address of route\n" - "prefix length of ip address\n") DEFUN (match_ip_nexthop_prefix_len, match_ip_nexthop_prefix_len_cmd, - "match ip next-hop prefix-len NUMBER", + "match ip next-hop prefix-len (0-32)", MATCH_STR IP_STR "Match prefixlen of nexthop ip address\n" @@ -548,96 +261,95 @@ DEFUN (match_ip_nexthop_prefix_len, "Prefix length\n") { return zebra_route_match_add (vty, "ip next-hop prefix-len", - argv[0], RMAP_EVENT_MATCH_ADDED); + argv[4]->arg, RMAP_EVENT_MATCH_ADDED); } DEFUN (no_match_ip_nexthop_prefix_len, no_match_ip_nexthop_prefix_len_cmd, - "no match ip next-hop prefix-len", + "no match ip next-hop prefix-len [(0-32)]", NO_STR MATCH_STR IP_STR "Match prefixlen of nexthop ip address\n" - "Match prefix length of nexthop\n") + "Match prefix length of nexthop\n" + "Prefix length\n") { - if (argc == 0) - return zebra_route_match_delete (vty, - "ip next-hop prefix-len", NULL, - RMAP_EVENT_MATCH_DELETED); - + char *plen = (argc == 6) ? argv[5]->arg : NULL; return zebra_route_match_delete (vty, - "ip next-hop prefix-len", argv[0], + "ip next-hop prefix-len", plen, RMAP_EVENT_MATCH_DELETED); } -ALIAS (no_match_ip_nexthop_prefix_len, - no_match_ip_nexthop_prefix_len_val_cmd, - "no match ip next-hop prefix-len NUMBER", - MATCH_STR - "Match prefixlen of ip address of route\n" - "prefix length of ip address\n") DEFUN (match_source_protocol, match_source_protocol_cmd, - "match source-protocol (bgp|ospf|rip|ripng|isis|ospf6|connected|system|kernel|static)", + "match source-protocol <bgp|ospf|rip|ripng|isis|ospf6|connected|system|kernel|static>", MATCH_STR - "Match protocol via which the route was learnt\n") -{ + "Match protocol via which the route was learnt\n" + "BGP protocol\n" + "OSPF protocol\n" + "RIP protocol\n" + "RIPNG protocol\n" + "ISIS protocol\n" + "OSPF6 protocol\n" + "Routes from directly connected peer\n" + "Routes from system configuration\n" + "Routes from kernel\n" + "Statically configured routes\n") +{ + char *proto = argv[2]->text; int i; - i = proto_name2num(argv[0]); + i = proto_name2num(proto); if (i < 0) { - vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "", - VTY_NEWLINE); + vty_out (vty, "invalid protocol name \"%s\"%s", proto, VTY_NEWLINE); return CMD_WARNING; } - return zebra_route_match_add (vty, "source-protocol", - argv[0], RMAP_EVENT_MATCH_ADDED); + return zebra_route_match_add (vty, "source-protocol", proto, RMAP_EVENT_MATCH_ADDED); } DEFUN (no_match_source_protocol, no_match_source_protocol_cmd, - "no match source-protocol (bgp|ospf|rip|ripng|isis|ospf6|connected|system|kernel|static)", + "no match source-protocol [<bgp|ospf|rip|ripng|isis|ospf6|connected|system|kernel|static>]", NO_STR MATCH_STR - "No match protocol via which the route was learnt\n") -{ - int i; - - if (argc >= 1) - { - i = proto_name2num(argv[0]); - if (i < 0) - { - vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "", - VTY_NEWLINE); - return CMD_WARNING; - } - } - return zebra_route_match_delete (vty, - "source-protocol", argv[0] ? argv[0] : NULL, - RMAP_EVENT_MATCH_DELETED); + "No match protocol via which the route was learnt\n" + "BGP protocol\n" + "OSPF protocol\n" + "RIP protocol\n" + "RIPNG protocol\n" + "ISIS protocol\n" + "OSPF6 protocol\n" + "Routes from directly connected peer\n" + "Routes from system configuration\n" + "Routes from kernel\n" + "Statically configured routes\n") +{ + char *proto = (argc == 4) ? argv[3]->text : NULL; + return zebra_route_match_delete (vty, "source-protocol", proto, RMAP_EVENT_MATCH_DELETED); } /* set functions */ DEFUN (set_src, set_src_cmd, - "set src (A.B.C.D|X:X::X:X)", + "set src <A.B.C.D|X:X::X:X>", SET_STR "src address for route\n" - "src address\n") + "IPv4 src address\n" + "IPv6 src address\n") { + int idx_ip = 2; union g_addr src; struct interface *pif = NULL; int family; struct prefix p; vrf_iter_t iter; - if (inet_pton(AF_INET, argv[0], &src.ipv4) != 1) + if (inet_pton(AF_INET, argv[idx_ip]->arg, &src.ipv4) != 1) { - if (inet_pton(AF_INET6, argv[0], &src.ipv6) != 1) + if (inet_pton(AF_INET6, argv[idx_ip]->arg, &src.ipv6) != 1) { vty_out (vty, "%% not a valid IPv4/v6 address%s", VTY_NEWLINE); return CMD_WARNING; @@ -656,8 +368,8 @@ DEFUN (set_src, if (!zebra_check_addr(&p)) { - vty_out (vty, "%% not a valid source IPv4/v6 address%s", VTY_NEWLINE); - return CMD_WARNING; + vty_out (vty, "%% not a valid source IPv4/v6 address%s", VTY_NEWLINE); + return CMD_WARNING; } for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) @@ -678,31 +390,35 @@ DEFUN (set_src, vty_out (vty, "%% not a local address%s", VTY_NEWLINE); return CMD_WARNING; } - return zebra_route_set_add (vty, "src", argv[0]); + + VTY_DECLVAR_CONTEXT (route_map_index, index); + return generic_set_add (vty, index, "src", argv[idx_ip]->arg); } DEFUN (no_set_src, no_set_src_cmd, - "no set src {A.B.C.D|X:X::X:X}", + "no set src [<A.B.C.D|X:X::X:X>]", NO_STR SET_STR "Source address for route\n") { - if (argc == 0) - return zebra_route_set_delete (vty, "src", NULL); - - return zebra_route_set_delete (vty, "src", argv[0]); + char *ip = (argc == 4) ? argv[3]->arg : NULL; + VTY_DECLVAR_CONTEXT (route_map_index, index); + return generic_set_delete (vty, index, "src", ip); } DEFUN (zebra_route_map_timer, zebra_route_map_timer_cmd, - "zebra route-map delay-timer <0-600>", + "zebra route-map delay-timer (0-600)", + "Zebra information\n" + "Set route-map parameters\n" "Time to wait before route-map updates are processed\n" "0 means event-driven updates are disabled\n") { + int idx_number = 3; u_int32_t rmap_delay_timer; - VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[0], 0, 600); + VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[idx_number]->arg, 0, 600); zebra_route_map_set_delay_timer(rmap_delay_timer); return (CMD_SUCCESS); @@ -710,56 +426,53 @@ DEFUN (zebra_route_map_timer, DEFUN (no_zebra_route_map_timer, no_zebra_route_map_timer_cmd, - "no zebra route-map delay-timer", + "no zebra route-map delay-timer [(0-600)]", NO_STR - "Time to wait before route-map updates are processed\n" - "Reset delay-timer to default value, 30 secs\n") + "Zebra information\n" + "Set route-map parameters\n" + "Reset delay-timer to default value, 30 secs\n" + "0 means event-driven updates are disabled\n") { zebra_route_map_set_delay_timer(ZEBRA_RMAP_DEFAULT_UPDATE_TIMER); return (CMD_SUCCESS); } -ALIAS (no_zebra_route_map_timer, - no_zebra_route_map_timer_val_cmd, - "no zebra route-map delay-timer <0-600>", - NO_STR - "Time to wait before route-map updates are processed\n" - "Reset delay-timer to default value, 30 secs\n" - "0 means event-driven updates are disabled\n") DEFUN (ip_protocol, ip_protocol_cmd, - "ip protocol " QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", + "ip protocol <kernel|connected|static|rip|ospf|isis|bgp|pim|table|any> route-map ROUTE-MAP", IP_STR "Filter routing info exchanged between zebra and protocol\n" QUAGGA_IP_PROTOCOL_MAP_HELP_STR_ZEBRA + "Specify route-map\n" "Route map name\n") { + char *proto = argv[2]->text; + char *rmap = argv[4]->arg; int i; - if (strcasecmp(argv[0], "any") == 0) + if (strcasecmp(proto, "any") == 0) i = ZEBRA_ROUTE_MAX; else - i = proto_name2num(argv[0]); + i = proto_name2num(proto); if (i < 0) { - vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "", - VTY_NEWLINE); + vty_out (vty, "invalid protocol name \"%s\"%s", proto, VTY_NEWLINE); return CMD_WARNING; } if (proto_rm[AFI_IP][i]) { - if (strcmp(proto_rm[AFI_IP][i], argv[1]) == 0) + if (strcmp(proto_rm[AFI_IP][i], rmap) == 0) return CMD_SUCCESS; XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]); } - proto_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]); + proto_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, rmap); if (IS_ZEBRA_DEBUG_RIB_DETAILED) zlog_debug ("%u: IPv4 Routemap config for protocol %s, scheduling RIB processing", - VRF_DEFAULT, argv[0]); + VRF_DEFAULT, proto); rib_update(VRF_DEFAULT, RIB_UPDATE_RMAP_CHANGE); return CMD_SUCCESS; @@ -767,50 +480,45 @@ DEFUN (ip_protocol, DEFUN (no_ip_protocol, no_ip_protocol_cmd, - "no ip protocol " QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA, + "no ip protocol <kernel|connected|static|rip|ospf|isis|bgp|pim|table|any> [route-map ROUTE-MAP]", NO_STR IP_STR "Stop filtering routing info between zebra and protocol\n" QUAGGA_IP_PROTOCOL_MAP_HELP_STR_ZEBRA - "Protocol from which to stop filtering routes\n") + "Specify route map\n" + "Route map name\n") { + char *proto = argv[3]->text; + char *rmap = (argc == 6) ? argv[5]->arg : NULL; int i; - if (strcasecmp(argv[0], "any") == 0) + if (strcasecmp(proto, "any") == 0) i = ZEBRA_ROUTE_MAX; else - i = proto_name2num(argv[0]); + i = proto_name2num(proto); + if (i < 0) { - vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "", - VTY_NEWLINE); + vty_out (vty, "invalid protocol name \"%s\"%s", proto, VTY_NEWLINE); return CMD_WARNING; } + if (!proto_rm[AFI_IP][i]) return CMD_SUCCESS; - if ((argc == 2 && strcmp(argv[1], proto_rm[AFI_IP][i]) == 0) || - (argc < 2)) + if (!rmap || strcmp (rmap, proto_rm[AFI_IP][i]) == 0) { XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]); proto_rm[AFI_IP][i] = NULL; if (IS_ZEBRA_DEBUG_RIB_DETAILED) zlog_debug ("%u: IPv4 Routemap unconfig for protocol %s, scheduling RIB processing", - VRF_DEFAULT, argv[0]); + VRF_DEFAULT, proto); rib_update(VRF_DEFAULT, RIB_UPDATE_RMAP_CHANGE); } return CMD_SUCCESS; } -ALIAS (no_ip_protocol, - no_ip_protocol_val_cmd, - "no ip protocol " QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", - NO_STR - IP_STR - "Stop filtering routing info between zebra and protocol\n" - QUAGGA_IP_PROTOCOL_MAP_HELP_STR_ZEBRA - "route map name") DEFUN (show_ip_protocol, show_ip_protocol_cmd, @@ -843,36 +551,38 @@ DEFUN (show_ip_protocol, DEFUN (ipv6_protocol, ipv6_protocol_cmd, - "ipv6 protocol " QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", + "ipv6 protocol <kernel|connected|static|ripng|ospf6|isis|bgp|table|any> route-map ROUTE-MAP", IP6_STR "Filter IPv6 routing info exchanged between zebra and protocol\n" QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA + "Specify route map\n" "Route map name\n") { + char *proto = argv[2]->text; + char *rmap = argv[4]->arg; int i; - if (strcasecmp(argv[0], "any") == 0) + if (strcasecmp(proto, "any") == 0) i = ZEBRA_ROUTE_MAX; else - i = proto_name2num(argv[0]); + i = proto_name2num(proto); if (i < 0) { - vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "", - VTY_NEWLINE); + vty_out (vty, "invalid protocol name \"%s\"%s", proto, VTY_NEWLINE); return CMD_WARNING; } if (proto_rm[AFI_IP6][i]) { - if (strcmp(proto_rm[AFI_IP6][i], argv[1]) == 0) + if (strcmp(proto_rm[AFI_IP6][i], rmap) == 0) return CMD_SUCCESS; XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP6][i]); } - proto_rm[AFI_IP6][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]); + proto_rm[AFI_IP6][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, rmap); if (IS_ZEBRA_DEBUG_RIB_DETAILED) zlog_debug ("%u: IPv6 Routemap config for protocol %s, scheduling RIB processing", - VRF_DEFAULT, argv[0]); + VRF_DEFAULT, proto); rib_update(VRF_DEFAULT, RIB_UPDATE_RMAP_CHANGE); return CMD_SUCCESS; @@ -880,51 +590,44 @@ DEFUN (ipv6_protocol, DEFUN (no_ipv6_protocol, no_ipv6_protocol_cmd, - "no ipv6 protocol " QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA, + "no ipv6 protocol <kernel|connected|static|ripng|ospf6|isis|bgp|table|any> [route-map ROUTE-MAP]", NO_STR IP6_STR "Stop filtering IPv6 routing info between zebra and protocol\n" QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA - "Protocol from which to stop filtering routes\n") + "Specify route map\n" + "Route map name\n") { + const char *proto = argv[3]->text; + const char *rmap = (argc == 6) ? argv[5]->arg : NULL; int i; - if (strcasecmp(argv[0], "any") == 0) + if (strcasecmp(proto, "any") == 0) i = ZEBRA_ROUTE_MAX; else - i = proto_name2num(argv[0]); + i = proto_name2num(proto); if (i < 0) { - vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "", - VTY_NEWLINE); + vty_out (vty, "invalid protocol name \"%s\"%s", proto, VTY_NEWLINE); return CMD_WARNING; } if (!proto_rm[AFI_IP6][i]) return CMD_SUCCESS; - if ((argc == 2 && strcmp(argv[1], proto_rm[AFI_IP6][i]) == 0) || - (argc < 2)) + if (!rmap || strcmp(rmap, proto_rm[AFI_IP6][i]) == 0) { XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP6][i]); proto_rm[AFI_IP6][i] = NULL; if (IS_ZEBRA_DEBUG_RIB_DETAILED) zlog_debug ("%u: IPv6 Routemap unconfig for protocol %s, scheduling RIB processing", - VRF_DEFAULT, argv[0]); + VRF_DEFAULT, proto); rib_update(VRF_DEFAULT, RIB_UPDATE_RMAP_CHANGE); } return CMD_SUCCESS; } -ALIAS (no_ipv6_protocol, - no_ipv6_protocol_val_cmd, - "no ipv6 protocol " QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", - NO_STR - IP6_STR - "Stop filtering IPv6 routing info between zebra and protocol\n" - QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA - "route map name") DEFUN (show_ipv6_protocol, show_ipv6_protocol_cmd, @@ -957,33 +660,35 @@ DEFUN (show_ipv6_protocol, DEFUN (ip_protocol_nht_rmap, ip_protocol_nht_rmap_cmd, - "ip nht " QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", + "ip nht <kernel|connected|static|rip|ospf|isis|bgp|pim|table|any> route-map ROUTE-MAP", IP_STR "Filter Next Hop tracking route resolution\n" QUAGGA_IP_PROTOCOL_MAP_HELP_STR_ZEBRA + "Specify route map\n" "Route map name\n") { + char *proto = argv[2]->text; + char *rmap = argv[4]->arg; int i; - if (strcasecmp(argv[0], "any") == 0) + if (strcasecmp(proto, "any") == 0) i = ZEBRA_ROUTE_MAX; else - i = proto_name2num(argv[0]); + i = proto_name2num(proto); if (i < 0) { - vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "", - VTY_NEWLINE); + vty_out (vty, "invalid protocol name \"%s\"%s", proto, VTY_NEWLINE); return CMD_WARNING; } if (nht_rm[AFI_IP][i]) { - if (strcmp(nht_rm[AFI_IP][i], argv[1]) == 0) + if (strcmp(nht_rm[AFI_IP][i], rmap) == 0) return CMD_SUCCESS; XFREE (MTYPE_ROUTE_MAP_NAME, nht_rm[AFI_IP][i]); } - nht_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]); + nht_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, rmap); zebra_evaluate_rnh(0, AF_INET, 1, RNH_NEXTHOP_TYPE, NULL); return CMD_SUCCESS; @@ -991,29 +696,31 @@ DEFUN (ip_protocol_nht_rmap, DEFUN (no_ip_protocol_nht_rmap, no_ip_protocol_nht_rmap_cmd, - "no ip nht " QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA, + "no ip nht <kernel|connected|static|rip|ospf|isis|bgp|pim|table|any> [route-map ROUTE-MAP]", NO_STR IP_STR "Filter Next Hop tracking route resolution\n" - QUAGGA_IP_PROTOCOL_MAP_HELP_STR_ZEBRA) + QUAGGA_IP_PROTOCOL_MAP_HELP_STR_ZEBRA + "Specify route map\n" + "Route map name\n") { + char *proto = argv[3]->text; + char *rmap = (argc == 6) ? argv[5]->arg : NULL; int i; - if (strcasecmp(argv[0], "any") == 0) + if (strcasecmp(proto, "any") == 0) i = ZEBRA_ROUTE_MAX; else - i = proto_name2num(argv[0]); + i = proto_name2num(proto); if (i < 0) { - vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "", - VTY_NEWLINE); - return CMD_WARNING; + vty_out (vty, "invalid protocol name \"%s\"%s", proto, VTY_NEWLINE); + return CMD_WARNING; } if (!nht_rm[AFI_IP][i]) return CMD_SUCCESS; - if ((argc == 2 && strcmp(argv[1], nht_rm[AFI_IP][i]) == 0) || - (argc < 2)) + if (!rmap && strcmp(rmap, nht_rm[AFI_IP][i]) == 0) { XFREE (MTYPE_ROUTE_MAP_NAME, nht_rm[AFI_IP][i]); nht_rm[AFI_IP][i] = NULL; @@ -1022,13 +729,6 @@ DEFUN (no_ip_protocol_nht_rmap, return CMD_SUCCESS; } -ALIAS (no_ip_protocol_nht_rmap, - no_ip_protocol_nht_rmap_val_cmd, - "no ip nht " QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", - IP_STR - "Filter Next Hop tracking route resolution\n" - QUAGGA_IP_PROTOCOL_MAP_HELP_STR_ZEBRA - "Route map name\n") DEFUN (show_ip_protocol_nht, show_ip_protocol_nht_cmd, @@ -1061,27 +761,29 @@ DEFUN (show_ip_protocol_nht, DEFUN (ipv6_protocol_nht_rmap, ipv6_protocol_nht_rmap_cmd, - "ipv6 nht " QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", + "ipv6 nht <kernel|connected|static|ripng|ospf6|isis|bgp|table|any> route-map ROUTE-MAP", IP6_STR "Filter Next Hop tracking route resolution\n" QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA + "Specify route map\n" "Route map name\n") { + char *proto = argv[2]->text; + char *rmap = argv[4]->arg; int i; - if (strcasecmp(argv[0], "any") == 0) + if (strcasecmp(proto, "any") == 0) i = ZEBRA_ROUTE_MAX; else - i = proto_name2num(argv[0]); + i = proto_name2num(proto); if (i < 0) { - vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "", - VTY_NEWLINE); + vty_out (vty, "invalid protocol name \"%s\"%s", proto, VTY_NEWLINE); return CMD_WARNING; } if (nht_rm[AFI_IP6][i]) XFREE (MTYPE_ROUTE_MAP_NAME, nht_rm[AFI_IP6][i]); - nht_rm[AFI_IP6][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]); + nht_rm[AFI_IP6][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, rmap); zebra_evaluate_rnh(0, AF_INET6, 1, RNH_NEXTHOP_TYPE, NULL); return CMD_SUCCESS; @@ -1089,28 +791,31 @@ DEFUN (ipv6_protocol_nht_rmap, DEFUN (no_ipv6_protocol_nht_rmap, no_ipv6_protocol_nht_rmap_cmd, - "no ipv6 nht " QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA, + "no ipv6 nht <kernel|connected|static|ripng|ospf6|isis|bgp|table|any> [route-map ROUTE-MAP]", NO_STR IP6_STR "Filter Next Hop tracking route resolution\n" - QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA) + QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA + "Specify route map\n" + "Route map name\n") { + char *proto = argv[3]->text; + char *rmap = (argc == 6) ? argv[5]->arg : NULL; int i; - if (strcasecmp(argv[0], "any") == 0) + if (strcasecmp(proto, "any") == 0) i = ZEBRA_ROUTE_MAX; else - i = proto_name2num(argv[0]); + i = proto_name2num(proto); if (i < 0) { - vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "", - VTY_NEWLINE); - return CMD_WARNING; + vty_out (vty, "invalid protocol name \"%s\"%s", proto, VTY_NEWLINE); + return CMD_WARNING; } - if (nht_rm[AFI_IP6][i] && argc == 2 && strcmp(argv[1], nht_rm[AFI_IP6][i])) + if (nht_rm[AFI_IP6][i] && rmap && strcmp(rmap, nht_rm[AFI_IP6][i])) { - vty_out (vty, "invalid route-map \"%s\"%s", argv[1], VTY_NEWLINE); + vty_out (vty, "invalid route-map \"%s\"%s", rmap, VTY_NEWLINE); return CMD_WARNING; } @@ -1125,14 +830,6 @@ DEFUN (no_ipv6_protocol_nht_rmap, return CMD_SUCCESS; } -ALIAS (no_ipv6_protocol_nht_rmap, - no_ipv6_protocol_nht_rmap_val_cmd, - "no ipv6 nht " QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", - NO_STR - IP6_STR - "Filter Next Hop tracking route resolution\n" - QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA - "Route map name\n") DEFUN (show_ipv6_protocol_nht, show_ipv6_protocol_nht_cmd, @@ -1788,23 +1485,18 @@ zebra_route_map_init () { install_element (CONFIG_NODE, &ip_protocol_cmd); install_element (CONFIG_NODE, &no_ip_protocol_cmd); - install_element (CONFIG_NODE, &no_ip_protocol_val_cmd); install_element (VIEW_NODE, &show_ip_protocol_cmd); install_element (CONFIG_NODE, &ipv6_protocol_cmd); install_element (CONFIG_NODE, &no_ipv6_protocol_cmd); - install_element (CONFIG_NODE, &no_ipv6_protocol_val_cmd); install_element (VIEW_NODE, &show_ipv6_protocol_cmd); install_element (CONFIG_NODE, &ip_protocol_nht_rmap_cmd); install_element (CONFIG_NODE, &no_ip_protocol_nht_rmap_cmd); - install_element (CONFIG_NODE, &no_ip_protocol_nht_rmap_val_cmd); install_element (VIEW_NODE, &show_ip_protocol_nht_cmd); install_element (CONFIG_NODE, &ipv6_protocol_nht_rmap_cmd); install_element (CONFIG_NODE, &no_ipv6_protocol_nht_rmap_cmd); - install_element (CONFIG_NODE, &no_ipv6_protocol_nht_rmap_val_cmd); install_element (VIEW_NODE, &show_ipv6_protocol_nht_cmd); install_element (CONFIG_NODE, &zebra_route_map_timer_cmd); install_element (CONFIG_NODE, &no_zebra_route_map_timer_cmd); - install_element (CONFIG_NODE, &no_zebra_route_map_timer_val_cmd); route_map_init (); @@ -1812,6 +1504,24 @@ zebra_route_map_init () route_map_delete_hook (zebra_route_map_delete); route_map_event_hook (zebra_route_map_event); + route_map_match_interface_hook (generic_match_add); + route_map_no_match_interface_hook (generic_match_delete); + + route_map_match_ip_address_hook (generic_match_add); + route_map_no_match_ip_address_hook (generic_match_delete); + + route_map_match_ip_address_prefix_list_hook (generic_match_add); + route_map_no_match_ip_address_prefix_list_hook (generic_match_delete); + + route_map_match_ip_next_hop_hook (generic_match_add); + route_map_no_match_ip_next_hop_hook (generic_match_delete); + + route_map_match_ip_next_hop_prefix_list_hook (generic_match_add); + route_map_no_match_ip_next_hop_prefix_list_hook (generic_match_delete); + + route_map_match_tag_hook (generic_match_add); + route_map_no_match_tag_hook (generic_match_delete); + route_map_install_match (&route_match_tag_cmd); route_map_install_match (&route_match_interface_cmd); route_map_install_match (&route_match_ip_next_hop_cmd); @@ -1824,30 +1534,10 @@ zebra_route_map_init () /* */ route_map_install_set (&route_set_src_cmd); /* */ - install_element (RMAP_NODE, &match_tag_cmd); - install_element (RMAP_NODE, &no_match_tag_cmd); - install_element (RMAP_NODE, &no_match_tag_val_cmd); - install_element (RMAP_NODE, &match_interface_cmd); - install_element (RMAP_NODE, &no_match_interface_cmd); - install_element (RMAP_NODE, &no_match_interface_val_cmd); - install_element (RMAP_NODE, &match_ip_next_hop_cmd); - install_element (RMAP_NODE, &no_match_ip_next_hop_cmd); - install_element (RMAP_NODE, &no_match_ip_next_hop_val_cmd); - install_element (RMAP_NODE, &match_ip_next_hop_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_val_cmd); - install_element (RMAP_NODE, &match_ip_address_cmd); - install_element (RMAP_NODE, &no_match_ip_address_cmd); - install_element (RMAP_NODE, &no_match_ip_address_val_cmd); - install_element (RMAP_NODE, &match_ip_address_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ip_address_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ip_address_prefix_list_val_cmd); install_element (RMAP_NODE, &match_ip_nexthop_prefix_len_cmd); install_element (RMAP_NODE, &no_match_ip_nexthop_prefix_len_cmd); - install_element (RMAP_NODE, &no_match_ip_nexthop_prefix_len_val_cmd); install_element (RMAP_NODE, &match_ip_address_prefix_len_cmd); install_element (RMAP_NODE, &no_match_ip_address_prefix_len_cmd); - install_element (RMAP_NODE, &no_match_ip_address_prefix_len_val_cmd); install_element (RMAP_NODE, &match_source_protocol_cmd); install_element (RMAP_NODE, &no_match_source_protocol_cmd); /* */ diff --git a/zebra/zebra_static.c b/zebra/zebra_static.c index 298fc4e09d..7dc6cbaaa4 100644 --- a/zebra/zebra_static.c +++ b/zebra/zebra_static.c @@ -25,6 +25,7 @@ #include <lib/nexthop.h> #include <lib/memory.h> +#include "vty.h" #include "zebra/debug.h" #include "zebra/rib.h" #include "zebra/zserv.h" @@ -241,7 +242,7 @@ static_nexthop_same (struct nexthop *nexthop, struct static_route *si) gw_match = 1; if (!gw_match) - return 0; + return 0; /* Check match on label(s), if any */ return static_nexthop_label_same (nexthop, &si->snh_label); @@ -322,19 +323,19 @@ static_uninstall_route (afi_t afi, safi_t safi, struct prefix *p, struct static_ { /* Update route in kernel if it's in fib */ if (CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB)) - rib_install_kernel (rn, rib, 1); + rib_install_kernel (rn, rib, 1); /* Update redistribution if it's selected */ if (CHECK_FLAG(rib->flags, ZEBRA_FLAG_SELECTED)) - redistribute_update (&rn->p, rib, NULL); + redistribute_update (&rn->p, rib, NULL); } else { /* Remove from redistribute if selected route becomes inactive */ if (CHECK_FLAG(rib->flags, ZEBRA_FLAG_SELECTED)) - redistribute_delete (&rn->p, rib); + redistribute_delete (&rn->p, rib); /* Remove from kernel if fib route becomes inactive */ if (CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB)) - rib_uninstall_kernel (rn, rib); + rib_uninstall_kernel (rn, rib); } } diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c index ab825281e4..8db89b1e4e 100644 --- a/zebra/zebra_vrf.c +++ b/zebra/zebra_vrf.c @@ -25,6 +25,7 @@ #include "linklist.h" #include "memory.h" +#include "vty.h" #include "zebra/debug.h" #include "zebra/zserv.h" #include "zebra/rib.h" diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 9b0fad93e0..05356b3d0a 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -14,9 +14,9 @@ * General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with GNU Zebra; see the file COPYING. If not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * along with GNU Zebra; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #include <zebra.h> @@ -177,7 +177,7 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd, return CMD_SUCCESS; } - + /* When gateway is A.B.C.D format, gate is treated as nexthop address other case gate is treated as interface name. */ ret = inet_aton (gate_str, &gate); @@ -212,7 +212,7 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd, /* Static unicast routes for multicast RPF lookup. */ DEFUN (ip_mroute_dist, ip_mroute_dist_cmd, - "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>", + "ip mroute A.B.C.D/M <A.B.C.D|INTERFACE> [(1-255)]", IP_STR "Configure static unicast route into MRIB for multicast RPF lookup\n" "IP destination prefix (e.g. 10.0.0.0/8)\n" @@ -220,22 +220,17 @@ DEFUN (ip_mroute_dist, "Nexthop interface name\n" "Distance\n") { - return zebra_static_ipv4 (vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1], - NULL, NULL, argc > 2 ? argv[2] : NULL, NULL, NULL); -} + char *destprefix = argv[2]->arg; + char *nexthop = argv[3]->arg; + char *distance = (argc == 5) ? argv[4]->arg : NULL; -ALIAS (ip_mroute_dist, - ip_mroute_cmd, - "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)", - IP_STR - "Configure static unicast route into MRIB for multicast RPF lookup\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "Nexthop address\n" - "Nexthop interface name\n") + return zebra_static_ipv4 (vty, SAFI_MULTICAST, 1, destprefix, NULL, nexthop, NULL, NULL, distance, NULL, NULL); +} DEFUN (no_ip_mroute_dist, no_ip_mroute_dist_cmd, - "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>", + "no ip mroute A.B.C.D/M <A.B.C.D|INTERFACE> [(1-255)]", + NO_STR IP_STR "Configure static unicast route into MRIB for multicast RPF lookup\n" "IP destination prefix (e.g. 10.0.0.0/8)\n" @@ -243,23 +238,16 @@ DEFUN (no_ip_mroute_dist, "Nexthop interface name\n" "Distance\n") { - return zebra_static_ipv4 (vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1], - NULL, NULL, argc > 2 ? argv[2] : NULL, NULL, NULL); -} + char *destprefix = argv[3]->arg; + char *nexthop = argv[4]->arg; + char *distance = (argc == 6) ? argv[5]->arg : NULL; -ALIAS (no_ip_mroute_dist, - no_ip_mroute_cmd, - "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)", - NO_STR - IP_STR - "Configure static unicast route into MRIB for multicast RPF lookup\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "Nexthop address\n" - "Nexthop interface name\n") + return zebra_static_ipv4 (vty, SAFI_MULTICAST, 0, destprefix, NULL, nexthop, NULL, NULL, distance, NULL, NULL); +} DEFUN (ip_multicast_mode, ip_multicast_mode_cmd, - "ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)", + "ip multicast rpf-lookup-mode <urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix>", IP_STR "Multicast options\n" "RPF lookup behavior\n" @@ -269,16 +257,17 @@ DEFUN (ip_multicast_mode, "Lookup both, use entry with lower distance\n" "Lookup both, use entry with longer prefix\n") { + char *mode = argv[3]->text; - if (!strncmp (argv[0], "u", 1)) + if (strmatch (mode, "urib-only")) multicast_mode_ipv4_set (MCAST_URIB_ONLY); - else if (!strncmp (argv[0], "mrib-o", 6)) + else if (strmatch (mode, "mrib-only")) multicast_mode_ipv4_set (MCAST_MRIB_ONLY); - else if (!strncmp (argv[0], "mrib-t", 6)) + else if (strmatch (mode, "mrib-then-urib")) multicast_mode_ipv4_set (MCAST_MIX_MRIB_FIRST); - else if (!strncmp (argv[0], "low", 3)) + else if (strmatch (mode, "lower-distance")) multicast_mode_ipv4_set (MCAST_MIX_DISTANCE); - else if (!strncmp (argv[0], "lon", 3)) + else if (strmatch (mode, "longer-prefix")) multicast_mode_ipv4_set (MCAST_MIX_PFXLEN); else { @@ -291,7 +280,7 @@ DEFUN (ip_multicast_mode, DEFUN (no_ip_multicast_mode, no_ip_multicast_mode_cmd, - "no ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)", + "no ip multicast rpf-lookup-mode [<urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix>]", NO_STR IP_STR "Multicast options\n" @@ -306,13 +295,6 @@ DEFUN (no_ip_multicast_mode, return CMD_SUCCESS; } -ALIAS (no_ip_multicast_mode, - no_ip_multicast_mode_noarg_cmd, - "no ip multicast rpf-lookup-mode", - NO_STR - IP_STR - "Multicast options\n" - "RPF lookup behavior\n") DEFUN (show_ip_rpf, show_ip_rpf_cmd, @@ -332,12 +314,13 @@ DEFUN (show_ip_rpf_addr, "Display RPF information for multicast source\n" "IP multicast source address (e.g. 10.0.0.0)\n") { + int idx_ipv4 = 3; struct in_addr addr; struct route_node *rn; struct rib *rib; int ret; - ret = inet_aton (argv[0], &addr); + ret = inet_aton (argv[idx_ipv4]->arg, &addr); if (ret == 0) { vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); @@ -354,217 +337,47 @@ DEFUN (show_ip_rpf_addr, return CMD_SUCCESS; } -/* Static route configuration. */ -DEFUN (ip_route, - ip_route_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)", - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, NULL, - NULL, NULL, NULL); -} - -DEFUN (ip_route_tag, - ip_route_tag_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295>", - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - "Set tag for this route\n" - "One or more labels separated by '/'\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, argv[2], - NULL, NULL, NULL); -} - -DEFUN (ip_route_flags, - ip_route_flags_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)", - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], argv[2], NULL, - NULL, NULL, NULL); -} - -DEFUN (ip_route_flags_tag, - ip_route_flags_tag_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295>", - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n") - -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], argv[2], argv[3], - NULL, NULL, NULL); -} - -DEFUN (ip_route_flags2, - ip_route_flags2_cmd, - "ip route A.B.C.D/M (reject|blackhole)", - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, NULL, argv[1], NULL, - NULL, NULL, NULL); -} - -DEFUN (ip_route_flags2_tag, - ip_route_flags2_tag_cmd, - "ip route A.B.C.D/M (reject|blackhole) tag <1-4294967295>", - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n") - -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, NULL, argv[1], argv[2], - NULL, NULL, NULL); -} - -/* Mask as A.B.C.D format. */ -DEFUN (ip_route_mask, - ip_route_mask_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)", - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, NULL, - NULL, NULL, NULL); -} - -DEFUN (ip_route_mask_tag, - ip_route_mask_tag_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295>", - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - "Set tag for this route\n" - "Tag value\n") - -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, argv[3], - NULL, NULL, NULL); -} - -DEFUN (ip_route_mask_flags, - ip_route_mask_flags_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)", - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], argv[3], NULL, - NULL, NULL, NULL); -} - -DEFUN (ip_route_mask_flags_tag, - ip_route_mask_flags_tag_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295>", - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n") - -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], argv[3], argv[4], - NULL, NULL, NULL); -} - -DEFUN (ip_route_mask_flags2, - ip_route_mask_flags2_cmd, - "ip route A.B.C.D A.B.C.D (reject|blackhole)", - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL, argv[2], NULL, - NULL, NULL, NULL); -} - -DEFUN (ip_route_mask_flags2_tag, - ip_route_mask_flags2_tag_cmd, - "ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-4294967295>", - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n") +static void +zebra_vty_ip_route_tdv_helper (int argc, struct cmd_token *argv[], + int idx_curr, char **tag, + char **distance, char **vrf, char **labels) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL, argv[2], argv[3], - NULL, NULL, NULL); -} + *distance = NULL; + while (idx_curr < argc) + { + if (strmatch (argv[idx_curr]->text, "tag")) + { + if (tag) + *tag = argv[idx_curr+1]->arg; + idx_curr += 2; + } + else if (strmatch (argv[idx_curr]->text, "vrf")) + { + if (vrf) + *vrf = argv[idx_curr+1]->arg; + idx_curr += 2; + } + else if (strmatch (argv[idx_curr]->text, "label")) + { + if (labels) + *labels = argv[idx_curr+1]->arg; + idx_curr += 2; + } + else + { + if (distance) + *distance = argv[idx_curr]->arg; + idx_curr++; + } + } -/* Distance option value. */ -DEFUN (ip_route_distance, - ip_route_distance_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>", - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, NULL, - argv[2], NULL, NULL); + return; } -DEFUN (ip_route_tag_distance, - ip_route_tag_distance_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255>", +/* Static route configuration. */ +DEFUN (ip_route, + ip_route_cmd, + "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]", IP_STR "Establish static routes\n" "IP destination prefix (e.g. 10.0.0.0/8)\n" @@ -573,691 +386,94 @@ DEFUN (ip_route_tag_distance, "Null interface\n" "Set tag for this route\n" "Tag value\n" - "Distance value for this route\n") - -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, argv[2], - argv[3], NULL, NULL); -} - -DEFUN (ip_route_flags_distance, - ip_route_flags_distance_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>", - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this route\n") + "Distance value for this route\n" + VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], argv[2], NULL, - argv[3], NULL, NULL); -} + int idx_ipv4_prefixlen = 2; + int idx_ipv4_ifname_null = 3; + int idx_curr = 4; + char *tag, *distance, *vrf; -DEFUN (ip_route_flags_tag_distance, - ip_route_flags_tag_distance_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255>", - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], argv[2], argv[3], - argv[4], NULL, NULL); -} + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); -DEFUN (ip_route_flags_distance2, - ip_route_flags_distance2_cmd, - "ip route A.B.C.D/M (reject|blackhole) <1-255>", - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, NULL, argv[1], NULL, - argv[2], NULL, NULL); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, + argv[idx_ipv4_prefixlen]->arg, + NULL, + argv[idx_ipv4_ifname_null]->arg, + NULL, + tag, distance, vrf, NULL); } -DEFUN (ip_route_flags_tag_distance2, - ip_route_flags_tag_distance2_cmd, - "ip route A.B.C.D/M (reject|blackhole) tag <1-4294967295> <1-255>", +DEFUN (ip_route_flags, + ip_route_flags_cmd, + "ip route A.B.C.D/M <A.B.C.D|INTERFACE> <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]", IP_STR "Establish static routes\n" "IP destination prefix (e.g. 10.0.0.0/8)\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, NULL, argv[1], argv[2], - argv[3], NULL, NULL); -} - -DEFUN (ip_route_mask_distance, - ip_route_mask_distance_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>", - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, NULL, - argv[3], NULL, NULL); -} - -DEFUN (ip_route_mask_tag_distance, - ip_route_mask_tag_distance_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255>", - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - "Set tag for this route\n" - "Tag value\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, argv[3], - argv[4], NULL, NULL); -} - -DEFUN (ip_route_mask_flags_tag_distance, - ip_route_mask_flags_tag_distance_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255>", - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Set tag for this route\n" - "Tag value\n" - "Distance value for this route\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], argv[3], argv[4], - argv[5], NULL, NULL); -} - - -DEFUN (ip_route_mask_flags_distance, - ip_route_mask_flags_distance_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>", - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" "IP gateway address\n" "IP gateway interface name\n" "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], argv[3], NULL, - argv[4], NULL, NULL); -} - -DEFUN (ip_route_mask_flags_distance2, - ip_route_mask_flags_distance2_cmd, - "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>", - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL, argv[2], NULL, - argv[3], NULL, NULL); -} - -DEFUN (ip_route_mask_flags_tag_distance2, - ip_route_mask_flags_tag_distance2_cmd, - "ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-4294967295> <1-255>", - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" "Set tag for this route\n" "Tag value\n" "Distance value for this route\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL, argv[2], argv[3], - argv[4], NULL, NULL); -} - -DEFUN (no_ip_route, - no_ip_route_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, NULL, - NULL, NULL, NULL); -} - -DEFUN (no_ip_route_tag, - no_ip_route_tag_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295>", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - "Tag of this route\n" - "Tag value\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, argv[2], - NULL, NULL, NULL); -} - -ALIAS (no_ip_route, - no_ip_route_flags_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n") - -ALIAS (no_ip_route_tag, - no_ip_route_flags_tag_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295>", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Tag of this route\n" - "Tag value\n") - -DEFUN (no_ip_route_flags2, - no_ip_route_flags2_cmd, - "no ip route A.B.C.D/M (reject|blackhole)", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL, NULL, NULL, - NULL, NULL, NULL); -} - -DEFUN (no_ip_route_flags2_tag, - no_ip_route_flags2_tag_cmd, - "no ip route A.B.C.D/M (reject|blackhole) tag <1-4294967295>", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Tag of this route\n" - "Tag value\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL, NULL, argv[1], - NULL, NULL, NULL); -} - -DEFUN (no_ip_route_mask, - no_ip_route_mask_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, NULL, - NULL, NULL, NULL); -} - -DEFUN (no_ip_route_mask_tag, - no_ip_route_mask_tag_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295>", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - "Tag of this route\n" - "Tag value\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, argv[3], - NULL, NULL, NULL); -} - -ALIAS (no_ip_route_mask, - no_ip_route_mask_flags_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n") - -ALIAS (no_ip_route_mask_tag, - no_ip_route_mask_flags_tag_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295>", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Tag of this route\n" - "Tag value\n") - -DEFUN (no_ip_route_mask_flags2, - no_ip_route_mask_flags2_cmd, - "no ip route A.B.C.D A.B.C.D (reject|blackhole)", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL, NULL, NULL, - NULL, NULL, NULL); -} - -DEFUN (no_ip_route_mask_flags2_tag, - no_ip_route_mask_flags2_tag_cmd, - "no ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-4294967295>", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Tag of this route\n" - "Tag value\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL, NULL, argv[2], - NULL, NULL, NULL); -} - -DEFUN (no_ip_route_distance, - no_ip_route_distance_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, NULL, - argv[2], NULL, NULL); -} - -DEFUN (no_ip_route_tag_distance, - no_ip_route_tag_distance_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - "Tag of this route\n" - "Tag value\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, argv[2], - argv[3], NULL, NULL); -} - -DEFUN (no_ip_route_flags_distance, - no_ip_route_flags_distance_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], argv[2], NULL, - argv[3], NULL, NULL); -} - -DEFUN (no_ip_route_flags_tag_distance, - no_ip_route_flags_tag_distance_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Tag of this route\n" - "Tag value\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], argv[2], argv[3], - argv[4], NULL, NULL); -} - -DEFUN (no_ip_route_flags_distance2, - no_ip_route_flags_distance2_cmd, - "no ip route A.B.C.D/M (reject|blackhole) <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL, argv[1], NULL, - argv[2], NULL, NULL); -} - -DEFUN (no_ip_route_flags_tag_distance2, - no_ip_route_flags_tag_distance2_cmd, - "no ip route A.B.C.D/M (reject|blackhole) tag <1-4294967295> <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Tag of this route\n" - "Tag value\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL, argv[1], argv[2], - argv[3], NULL, NULL); -} - -DEFUN (no_ip_route_mask_distance, - no_ip_route_mask_distance_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, NULL, - argv[3], NULL, NULL); -} - -DEFUN (no_ip_route_mask_tag_distance, - no_ip_route_mask_tag_distance_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - "Tag of this route\n" - "Tag value\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, argv[3], - argv[4], NULL, NULL); -} - -DEFUN (no_ip_route_mask_flags_distance, - no_ip_route_mask_flags_distance_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], argv[3], NULL, - argv[4], NULL, NULL); -} - -DEFUN (no_ip_route_mask_flags_tag_distance, - no_ip_route_mask_flags_tag_distance_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Tag of this route\n" - "Tag value\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], argv[3], argv[4], - argv[5], NULL, NULL); -} - -DEFUN (no_ip_route_mask_flags_distance2, - no_ip_route_mask_flags_distance2_cmd, - "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL, argv[2], NULL, - argv[3], NULL, NULL); -} - -DEFUN (no_ip_route_mask_flags_tag_distance2, - no_ip_route_mask_flags_tag_distance2_cmd, - "no ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-4294967295> <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Tag of this route\n" - "Tag value\n" - "Distance value for this route\n") -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL, argv[2], argv[3], - argv[4], NULL, NULL); -} - -/* Static route configuration. */ -DEFUN (ip_route_vrf, - ip_route_vrf_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - VRF_CMD_HELP_STR) + VRF_CMD_HELP_STR + "Specify labels for this route\n" + "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, - NULL, NULL, argv[2], NULL); -} + int idx_ipv4_prefixlen = 2; + int idx_ipv4_ifname = 3; + int idx_reject_blackhole = 4; + int idx_curr = 5; + char *tag, *distance, *vrf; -DEFUN (ip_route_tag_vrf, - ip_route_tag_vrf_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - "Set tag for this route\n" - "Tag value\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, - argv[2], NULL, argv[3], NULL); -} + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); -DEFUN (ip_route_flags_vrf, - ip_route_flags_vrf_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], - argv[2], NULL, NULL, argv[3], NULL); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, + argv[idx_ipv4_prefixlen]->arg, + NULL, + argv[idx_ipv4_ifname]->arg, + argv[idx_reject_blackhole]->arg, + tag, distance, vrf, NULL); } -DEFUN (ip_route_flags_tag_vrf, - ip_route_flags_tag_vrf_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295> " VRF_CMD_STR, +DEFUN (ip_route_flags2, + ip_route_flags2_cmd, + "ip route A.B.C.D/M <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]", IP_STR "Establish static routes\n" "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n" "Set tag for this route\n" "Tag value\n" - VRF_CMD_HELP_STR) - -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], - argv[2], argv[3], NULL, argv[4], NULL); -} - -DEFUN (ip_route_flags2_vrf, - ip_route_flags2_vrf_cmd, - "ip route A.B.C.D/M (reject|blackhole) " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - VRF_CMD_HELP_STR) + "Distance value for this route\n" + VRF_CMD_HELP_STR + "Specify labels for this route\n" + "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, NULL, argv[1], - NULL, NULL, argv[2], NULL); -} + int idx_ipv4_prefixlen = 2; + int idx_reject_blackhole = 3; + int idx_curr = 4; + char *tag, *distance, *vrf; -DEFUN (ip_route_flags2_tag_vrf, - ip_route_flags2_tag_vrf_cmd, - "ip route A.B.C.D/M (reject|blackhole) tag <1-4294967295> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n" - VRF_CMD_HELP_STR) + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, NULL, argv[1], - argv[2], NULL, argv[3], NULL); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, + argv[idx_ipv4_prefixlen]->arg, + NULL, + NULL, + argv[idx_reject_blackhole]->arg, + tag, distance, vrf, NULL); } /* Mask as A.B.C.D format. */ -DEFUN (ip_route_mask_vrf, - ip_route_mask_vrf_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], - NULL, NULL, NULL, argv[3], NULL); -} - -DEFUN (ip_route_mask_tag_vrf, - ip_route_mask_tag_vrf_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295> " VRF_CMD_STR, +DEFUN (ip_route_mask, + ip_route_mask_cmd, + "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]", IP_STR "Establish static routes\n" "IP destination prefix\n" @@ -1267,141 +483,34 @@ DEFUN (ip_route_mask_tag_vrf, "Null interface\n" "Set tag for this route\n" "Tag value\n" - VRF_CMD_HELP_STR) - + "Distance value for this route\n" + VRF_CMD_HELP_STR + "Specify labels for this route\n" + "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], - NULL, argv[3], NULL, argv[4], NULL); -} + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_ipv4_ifname_null = 4; + int idx_curr = 5; + char *tag, *distance, *vrf; -DEFUN (ip_route_mask_flags_vrf, - ip_route_mask_flags_vrf_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], - argv[3], NULL, NULL, argv[4], NULL); -} + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); -DEFUN (ip_route_mask_flags_tag_vrf, - ip_route_mask_flags_tag_vrf_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n" - VRF_CMD_HELP_STR) - -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], - argv[3], argv[4], NULL, argv[5], NULL); -} - -DEFUN (ip_route_mask_flags2_vrf, - ip_route_mask_flags2_vrf_cmd, - "ip route A.B.C.D A.B.C.D (reject|blackhole) " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL, - argv[2], NULL, NULL, argv[3], NULL); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, + argv[idx_ipv4]->arg, + argv[idx_ipv4_2]->arg, + argv[idx_ipv4_ifname_null]->arg, + NULL, tag, distance, vrf, NULL); } -DEFUN (ip_route_mask_flags2_tag_vrf, - ip_route_mask_flags2_tag_vrf_cmd, - "ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-4294967295> " VRF_CMD_STR, +DEFUN (ip_route_mask_flags, + ip_route_mask_flags_cmd, + "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE> <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]", IP_STR "Establish static routes\n" "IP destination prefix\n" "IP destination prefix mask\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL, - argv[2], argv[3], NULL, argv[4], NULL); -} - -/* Distance option value. */ -DEFUN (ip_route_distance_vrf, - ip_route_distance_vrf_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - "Distance value for this route\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, - NULL, argv[2], argv[3], NULL); -} - -DEFUN (ip_route_tag_distance_vrf, - ip_route_tag_distance_vrf_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - "Set tag for this route\n" - "Tag value\n" - "Distance value for this route\n" - VRF_CMD_HELP_STR) - -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, - argv[2], argv[3], argv[4], NULL); -} - -DEFUN (ip_route_flags_distance_vrf, - ip_route_flags_distance_vrf_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this route\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], - argv[2], NULL, argv[3], argv[4], NULL); -} - -DEFUN (ip_route_flags_tag_distance_vrf, - ip_route_flags_tag_distance_vrf_cmd, - "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" "IP gateway address\n" "IP gateway interface name\n" "Emit an ICMP unreachable when matched\n" @@ -1409,189 +518,65 @@ DEFUN (ip_route_flags_tag_distance_vrf, "Set tag for this route\n" "Tag value\n" "Distance value for this route\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], - argv[2], argv[3], argv[4],argv[5], NULL); -} - -DEFUN (ip_route_flags_distance2_vrf, - ip_route_flags_distance2_vrf_cmd, - "ip route A.B.C.D/M (reject|blackhole) <1-255> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this route\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, NULL, argv[1], - NULL, argv[2], argv[3], NULL); -} - -DEFUN (ip_route_flags_tag_distance2_vrf, - ip_route_flags_tag_distance2_vrf_cmd, - "ip route A.B.C.D/M (reject|blackhole) tag <1-4294967295> <1-255> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n" - "Distance value for this route\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, NULL, argv[1], - argv[2], argv[3], argv[4], NULL); -} - -DEFUN (ip_route_mask_distance_vrf, - ip_route_mask_distance_vrf_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - "Distance value for this route\n" - VRF_CMD_HELP_STR) + VRF_CMD_HELP_STR + "Specify labels for this route\n" + "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], - NULL, NULL, argv[3], argv[4], NULL); -} + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_ipv4_ifname = 4; + int idx_reject_blackhole = 5; + int idx_curr = 6; + char *tag, *distance, *vrf; -DEFUN (ip_route_mask_tag_distance_vrf, - ip_route_mask_tag_distance_vrf_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - "Set tag for this route\n" - "Tag value\n" - "Distance value for this route\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], - NULL, argv[3], argv[4], argv[5], NULL); -} + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); -DEFUN (ip_route_mask_flags_tag_distance_vrf, - ip_route_mask_flags_tag_distance_vrf_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Set tag for this route\n" - "Tag value\n" - "Distance value for this route\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], - argv[3], argv[4], argv[5], argv[6], NULL); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, + argv[idx_ipv4]->arg, + argv[idx_ipv4_2]->arg, + argv[idx_ipv4_ifname]->arg, + argv[idx_reject_blackhole]->arg, + tag, distance, vrf, NULL); } -DEFUN (ip_route_mask_flags_distance_vrf, - ip_route_mask_flags_distance_vrf_cmd, - "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this route\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], - argv[3], NULL, argv[4], argv[5], NULL); -} - -DEFUN (ip_route_mask_flags_distance2_vrf, - ip_route_mask_flags_distance2_vrf_cmd, - "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255> " VRF_CMD_STR, +DEFUN (ip_route_mask_flags2, + ip_route_mask_flags2_cmd, + "ip route A.B.C.D A.B.C.D <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]", IP_STR "Establish static routes\n" "IP destination prefix\n" "IP destination prefix mask\n" "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n" - "Distance value for this route\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL, - argv[2], NULL, argv[3], argv[4], NULL); -} - -DEFUN (ip_route_mask_flags_tag_distance2_vrf, - ip_route_mask_flags_tag_distance2_vrf_cmd, - "ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-4294967295> <1-255> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" "Set tag for this route\n" "Tag value\n" "Distance value for this route\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - VRF_CMD_HELP_STR) + VRF_CMD_HELP_STR + "Specify labels for this route\n" + "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL, - argv[2], argv[3], argv[4], argv[5], NULL); -} + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_reject_blackhole = 4; + int idx_curr = 5; + char *tag, *distance, *vrf; -DEFUN (no_ip_route_vrf, - no_ip_route_vrf_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, - NULL, NULL, argv[2], NULL); -} + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); -DEFUN (no_ip_route_flags_vrf, - no_ip_route_flags_vrf_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], - argv[2], NULL, NULL, argv[3], NULL); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, + argv[idx_ipv4]->arg, + argv[idx_ipv4_2]->arg, + NULL, + argv[idx_reject_blackhole]->arg, + tag, distance, vrf, NULL); } -DEFUN (no_ip_route_tag_vrf, - no_ip_route_tag_vrf_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295> " VRF_CMD_STR, +DEFUN (no_ip_route, + no_ip_route_cmd, + "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]", NO_STR IP_STR "Establish static routes\n" @@ -1601,49 +586,30 @@ DEFUN (no_ip_route_tag_vrf, "Null interface\n" "Tag of this route\n" "Tag value\n" - VRF_CMD_HELP_STR) + "Distance value for this route\n" + VRF_CMD_HELP_STR + "Specify labels for this route\n" + "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, - argv[2], NULL, argv[3], NULL); -} + int idx_ipv4_prefixlen = 3; + int idx_ipv4_ifname_null = 4; + int idx_curr = 5; + char *tag, *distance, *vrf; -DEFUN (no_ip_route_flags_tag_vrf, - no_ip_route_flags_tag_vrf_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Tag of this route\n" - "Tag value\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], - argv[2], argv[3], NULL, argv[4], NULL); -} + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); -DEFUN (no_ip_route_flags2_vrf, - no_ip_route_flags2_vrf_cmd, - "no ip route A.B.C.D/M (reject|blackhole) " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL, argv[1], - NULL, NULL, argv[2], NULL); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, + argv[idx_ipv4_prefixlen]->arg, + NULL, + argv[idx_ipv4_ifname_null]->arg, + NULL, + tag, distance, vrf, NULL); } -DEFUN (no_ip_route_flags2_tag_vrf, - no_ip_route_flags2_tag_vrf_cmd, - "no ip route A.B.C.D/M (reject|blackhole) tag <1-4294967295> " VRF_CMD_STR, +DEFUN (no_ip_route_flags2, + no_ip_route_flags2_cmd, + "no ip route A.B.C.D/M <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]", NO_STR IP_STR "Establish static routes\n" @@ -1652,50 +618,27 @@ DEFUN (no_ip_route_flags2_tag_vrf, "Silently discard pkts when matched\n" "Tag of this route\n" "Tag value\n" - VRF_CMD_HELP_STR) + "Distance value for this route\n" + VRF_CMD_HELP_STR + "Specify labels for this route\n" + "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL, argv[1], - argv[2], NULL, argv[3], NULL); -} + int idx_ipv4_prefixlen = 3; + int idx_curr = 5; + char *tag, *distance, *vrf; -DEFUN (no_ip_route_mask_vrf, - no_ip_route_mask_vrf_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], - NULL, NULL, NULL, argv[3], NULL); -} + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); -DEFUN (no_ip_route_mask_flags_vrf, - no_ip_route_mask_flags_vrf_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], - argv[3], NULL, NULL, argv[4], NULL); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, + argv[idx_ipv4_prefixlen]->arg, + NULL, NULL, NULL, + tag, distance, vrf, NULL); } -DEFUN (no_ip_route_mask_tag_vrf, - no_ip_route_mask_tag_vrf_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295> " VRF_CMD_STR, +DEFUN (no_ip_route_mask, + no_ip_route_mask_cmd, + "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]", NO_STR IP_STR "Establish static routes\n" @@ -1706,51 +649,31 @@ DEFUN (no_ip_route_mask_tag_vrf, "Null interface\n" "Tag of this route\n" "Tag value\n" - VRF_CMD_HELP_STR) + "Distance value for this route\n" + VRF_CMD_HELP_STR + "Specify labels for this route\n" + "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], - NULL, argv[3], NULL, argv[4], NULL); -} + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_ipv4_ifname_null = 5; + int idx_curr = 6; + char *tag, *distance, *vrf; -DEFUN (no_ip_route_mask_flags_tag_vrf, - no_ip_route_mask_flags_tag_vrf_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Tag of this route\n" - "Tag value\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], - argv[3], argv[4], NULL, argv[5], NULL); -} + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); -DEFUN (no_ip_route_mask_flags2_vrf, - no_ip_route_mask_flags2_vrf_cmd, - "no ip route A.B.C.D A.B.C.D (reject|blackhole) " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL, - argv[2], NULL, NULL, argv[3], NULL); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, + argv[idx_ipv4]->arg, + argv[idx_ipv4_2]->arg, + argv[idx_ipv4_ifname_null]->arg, + NULL, + tag, distance, vrf, NULL); } -DEFUN (no_ip_route_mask_flags2_tag_vrf, - no_ip_route_mask_flags2_tag_vrf_cmd, - "no ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-4294967295> " VRF_CMD_STR, +DEFUN (no_ip_route_mask_flags2, + no_ip_route_mask_flags2_cmd, + "no ip route A.B.C.D A.B.C.D <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]", NO_STR IP_STR "Establish static routes\n" @@ -1760,70 +683,29 @@ DEFUN (no_ip_route_mask_flags2_tag_vrf, "Silently discard pkts when matched\n" "Tag of this route\n" "Tag value\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL, - argv[2], argv[3], NULL, argv[4], NULL); -} - - -DEFUN (no_ip_route_distance_vrf, - no_ip_route_distance_vrf_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" "Distance value for this route\n" - VRF_CMD_HELP_STR) + VRF_CMD_HELP_STR + "Specify labels for this route\n" + "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, - NULL, argv[2], argv[3], NULL); -} + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_curr = 6; + char *tag, *distance, *vrf; -DEFUN (no_ip_route_tag_distance_vrf, - no_ip_route_tag_distance_vrf_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - "Tag of this route\n" - "Tag value\n" - "Distance value for this route\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, - argv[2], argv[3], argv[4], NULL); -} + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); -DEFUN (no_ip_route_flags_distance_vrf, - no_ip_route_flags_distance_vrf_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this route\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], - argv[2], NULL, argv[3], argv[4], NULL); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, + argv[idx_ipv4]->arg, + argv[idx_ipv4_2]->arg, + NULL, NULL, + tag, distance, vrf, NULL); } -DEFUN (no_ip_route_flags_tag_distance_vrf, - no_ip_route_flags_tag_distance_vrf_cmd, - "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255> " VRF_CMD_STR, +DEFUN (no_ip_route_flags, + no_ip_route_flags_cmd, + "no ip route A.B.C.D/M <A.B.C.D|INTERFACE> <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]", NO_STR IP_STR "Establish static routes\n" @@ -1835,106 +717,30 @@ DEFUN (no_ip_route_flags_tag_distance_vrf, "Tag of this route\n" "Tag value\n" "Distance value for this route\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], - argv[2], argv[3], argv[4],argv[5], NULL); -} - -DEFUN (no_ip_route_flags_distance2_vrf, - no_ip_route_flags_distance2_vrf_cmd, - "no ip route A.B.C.D/M (reject|blackhole) <1-255> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this route\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL, argv[1], - NULL, argv[2], argv[3], NULL); -} - -DEFUN (no_ip_route_flags_tag_distance2_vrf, - no_ip_route_flags_tag_distance2_vrf_cmd, - "no ip route A.B.C.D/M (reject|blackhole) tag <1-4294967295> <1-255> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix (e.g. 10.0.0.0/8)\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Tag of this route\n" - "Tag value\n" - "Distance value for this route\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL, argv[1], - argv[2] , argv[3], argv[4], NULL); -} - -DEFUN (no_ip_route_mask_distance_vrf, - no_ip_route_mask_distance_vrf_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - "Distance value for this route\n" - VRF_CMD_HELP_STR) + VRF_CMD_HELP_STR + "Specify labels for this route\n" + "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], - NULL, NULL, argv[3], argv[4], NULL); -} + int idx_ipv4_prefixlen = 3; + int idx_ipv4_ifname = 4; + int idx_reject_blackhole = 5; + int idx_curr = 6; + char *tag, *distance, *vrf; -DEFUN (no_ip_route_mask_tag_distance_vrf, - no_ip_route_mask_tag_distance_vrf_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Null interface\n" - "Tag of this route\n" - "Tag value\n" - "Distance value for this route\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], - NULL, argv[3], argv[4], argv[5], NULL); -} + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); -DEFUN (no_ip_route_mask_flags_distance_vrf, - no_ip_route_mask_flags_distance_vrf_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "IP gateway address\n" - "IP gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this route\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], - argv[3], NULL, argv[4], argv[5], NULL); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, + argv[idx_ipv4_prefixlen]->arg, + NULL, + argv[idx_ipv4_ifname]->arg, + argv[idx_reject_blackhole]->arg, + tag, distance, vrf, NULL); } -DEFUN (no_ip_route_mask_flags_tag_distance_vrf, - no_ip_route_mask_flags_tag_distance_vrf_cmd, - "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255> " VRF_CMD_STR, +DEFUN (no_ip_route_mask_flags, + no_ip_route_mask_flags_cmd, + "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE> <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]", NO_STR IP_STR "Establish static routes\n" @@ -1947,46 +753,26 @@ DEFUN (no_ip_route_mask_flags_tag_distance_vrf, "Tag of this route\n" "Tag value\n" "Distance value for this route\n" - VRF_CMD_HELP_STR) + VRF_CMD_HELP_STR + "Specify labels for this route\n" + "One or more labels separated by '/'\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], - argv[3], argv[4], argv[5], argv[6], NULL); -} + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_ipv4_ifname = 5; + int idx_reject_blackhole = 6; + int idx_curr = 7; + char *tag, *distance, *vrf; -DEFUN (no_ip_route_mask_flags_distance2_vrf, - no_ip_route_mask_flags_distance2_vrf_cmd, - "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this route\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL, - argv[2], NULL, argv[3], argv[4], NULL); -} + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); -DEFUN (no_ip_route_mask_flags_tag_distance2_vrf, - no_ip_route_mask_flags_tag_distance2_vrf_cmd, - "no ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-4294967295> <1-255> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IP destination prefix\n" - "IP destination prefix mask\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Tag of this route\n" - "Tag value\n" - "Distance value for this route\n" - VRF_CMD_HELP_STR) -{ - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL, - argv[2], argv[3], argv[4], argv[5], NULL); + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, + argv[idx_ipv4]->arg, + argv[idx_ipv4_2]->arg, + argv[idx_ipv4_ifname]->arg, + argv[idx_reject_blackhole]->arg, + tag, distance, vrf, NULL); } /* New RIB. Detailed information for IPv4 route. */ @@ -2009,7 +795,7 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast) ? " using Multicast RIB" : " using Unicast RIB"; } - + vty_out (vty, "Routing entry for %s%s%s", prefix2str (&rn->p, buf, sizeof(buf)), mcast_info, VTY_NEWLINE); @@ -2019,7 +805,7 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast) vty_out (vty, "\""); vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric); if (rib->tag) - vty_out (vty, ", tag %"ROUTE_TAG_PRI, rib->tag); + vty_out (vty, ", tag %d", rib->tag); if (rib->mtu) vty_out (vty, ", mtu %u", rib->mtu); if (rib->vrf_id != VRF_DEFAULT) @@ -2029,10 +815,6 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast) } if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) vty_out (vty, ", best"); - else if (CHECK_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB)) - vty_out (vty, ", fib"); - if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_FIB_OVERRIDE)) - vty_out (vty, ", fib-override"); if (rib->refcnt) vty_out (vty, ", refcnt %ld", rib->refcnt); if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE)) @@ -2057,13 +839,13 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast) vty_out (vty, " Last update "); if (uptime < ONE_DAY_SECOND) - vty_out (vty, "%02d:%02d:%02d", + vty_out (vty, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec); else if (uptime < ONE_WEEK_SECOND) - vty_out (vty, "%dd%02dh%02dm", + vty_out (vty, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour, tm->tm_min); else - vty_out (vty, "%02dw%dd%02dh", + vty_out (vty, "%02dw%dd%02dh", tm->tm_yday/7, tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour); vty_out (vty, " ago%s", VTY_NEWLINE); @@ -2136,15 +918,6 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast) default: break; } - - /* Label information */ - if (nexthop->nh_label && nexthop->nh_label->num_labels) - { - vty_out (vty, " label %s", - mpls_label2str (nexthop->nh_label->num_labels, - nexthop->nh_label->label, buf, BUFSIZ)); - } - vty_out (vty, "%s", VTY_NEWLINE); } vty_out (vty, "%s", VTY_NEWLINE); @@ -2309,14 +1082,13 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib, len += vty_out (vty, "[%d]", rib->instance); len += vty_out (vty, "%c%c %s", CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED) - ? '>' : CHECK_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB) - ? '!' : ' ', + ? '>' : ' ', CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ', prefix2str (&rn->p, buf, sizeof buf)); /* Distance and metric display. */ - if (rib->type != ZEBRA_ROUTE_CONNECT + if (rib->type != ZEBRA_ROUTE_CONNECT && rib->type != ZEBRA_ROUTE_KERNEL) len += vty_out (vty, " [%d/%d]", rib->distance, rib->metric); @@ -2386,14 +1158,6 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib, break; } - /* Label information */ - if (nexthop->nh_label && nexthop->nh_label->num_labels) - { - vty_out (vty, " label %s", - mpls_label2str (nexthop->nh_label->num_labels, - nexthop->nh_label->label, buf, BUFSIZ)); - } - if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE)) vty_out (vty, ", bh"); if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT)) @@ -2413,13 +1177,13 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib, tm = gmtime (&uptime); if (uptime < ONE_DAY_SECOND) - vty_out (vty, ", %02d:%02d:%02d", + vty_out (vty, ", %02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec); else if (uptime < ONE_WEEK_SECOND) - vty_out (vty, ", %dd%02dh%02dm", + vty_out (vty, ", %dd%02dh%02dm", tm->tm_yday, tm->tm_hour, tm->tm_min); else - vty_out (vty, ", %02dw%dd%02dh", + vty_out (vty, ", %02dw%dd%02dh", tm->tm_yday/7, tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour); } @@ -2429,10 +1193,11 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib, DEFUN (show_ip_route, show_ip_route_cmd, - "show ip route {json}", + "show ip route [json]", SHOW_STR IP_STR - "IP routing table\n") + "IP routing table\n" + "JavaScript Object Notation\n") { return do_show_ip_route (vty, VRF_DEFAULT_NAME, SAFI_UNICAST, use_json(argc, argv)); } @@ -2523,47 +1288,41 @@ do_show_ip_route (struct vty *vty, const char *vrf_name, safi_t safi, DEFUN (show_ip_route_vrf, show_ip_route_vrf_cmd, - "show ip route " VRF_CMD_STR " {json}", + "show ip route vrf NAME [json]", SHOW_STR IP_STR "IP routing table\n" - VRF_CMD_HELP_STR) + VRF_CMD_HELP_STR + "JavaScript Object Notation\n") { + int idx_vrf = 4; u_char uj = use_json(argc, argv); - if (argc == 1 && uj) - return do_show_ip_route (vty, NULL, SAFI_UNICAST, uj); - else - return do_show_ip_route (vty, argv[0], SAFI_UNICAST, uj); + return do_show_ip_route (vty, argv[idx_vrf]->arg, SAFI_UNICAST, uj); } DEFUN (show_ip_nht, show_ip_nht_cmd, - "show ip nht", + "show ip nht [vrf NAME]", SHOW_STR IP_STR - "IP nexthop tracking table\n") + "IP nexthop tracking table\n" + VRF_CMD_HELP_STR) { + int idx_vrf = 4; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc) - VRF_GET_ID (vrf_id, argv[0]); + if (argc == 5) + VRF_GET_ID (vrf_id, argv[idx_vrf]->arg); zebra_print_rnh_table(vrf_id, AF_INET, vty, RNH_NEXTHOP_TYPE); return CMD_SUCCESS; } -ALIAS (show_ip_nht, - show_ip_nht_vrf_cmd, - "show ip nht " VRF_CMD_STR, - SHOW_STR - IP_STR - "IP nexthop tracking table\n" - VRF_CMD_HELP_STR) DEFUN (show_ip_nht_vrf_all, show_ip_nht_vrf_all_cmd, - "show ip nht " VRF_ALL_CMD_STR, + "show ip nht vrf all", SHOW_STR IP_STR "IP nexthop tracking table\n" @@ -2584,31 +1343,26 @@ DEFUN (show_ip_nht_vrf_all, DEFUN (show_ipv6_nht, show_ipv6_nht_cmd, - "show ipv6 nht", + "show ipv6 nht [vrf NAME]", SHOW_STR IPV6_STR - "IPv6 nexthop tracking table\n") + "IPv6 nexthop tracking table\n" + VRF_CMD_HELP_STR) { + int idx_vrf = 4; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc) - VRF_GET_ID (vrf_id, argv[0]); + if (argc == 5) + VRF_GET_ID (vrf_id, argv[idx_vrf]->arg); zebra_print_rnh_table(vrf_id, AF_INET6, vty, RNH_NEXTHOP_TYPE); return CMD_SUCCESS; } -ALIAS (show_ipv6_nht, - show_ipv6_nht_vrf_cmd, - "show ipv6 nht " VRF_CMD_STR, - SHOW_STR - IPV6_STR - "IPv6 nexthop tracking table\n" - VRF_CMD_HELP_STR) DEFUN (show_ipv6_nht_vrf_all, show_ipv6_nht_vrf_all_cmd, - "show ipv6 nht " VRF_ALL_CMD_STR, + "show ipv6 nht vrf all", SHOW_STR IP_STR "IPv6 nexthop tracking table\n" @@ -2691,13 +1445,17 @@ DEFUN (no_ipv6_nht_default_route, DEFUN (show_ip_route_tag, show_ip_route_tag_cmd, - "show ip route tag <1-4294967295>", + "show ip route [vrf NAME] tag (1-4294967295)", SHOW_STR IP_STR "IP routing table\n" + VRF_CMD_HELP_STR "Show only routes with tag\n" "Tag value\n") { + int idx_vrf = 3; + int idx_name = 4; + int idx_tag = 6; struct route_table *table; struct route_node *rn; struct rib *rib; @@ -2705,13 +1463,16 @@ DEFUN (show_ip_route_tag, route_tag_t tag = 0; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 1) + if (strmatch(argv[idx_vrf]->text, "vrf")) { - tag = atol(argv[1]); - VRF_GET_ID (vrf_id, argv[0]); + VRF_GET_ID (vrf_id, argv[idx_name]->arg); + tag = atol(argv[idx_tag]->arg); } else - tag = atol(argv[0]); + { + idx_tag -= 2; + tag = atol(argv[idx_tag]->arg); + } table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id); if (! table) @@ -2734,22 +1495,13 @@ DEFUN (show_ip_route_tag, return CMD_SUCCESS; } -ALIAS (show_ip_route_tag, - show_ip_route_vrf_tag_cmd, - "show ip route " VRF_CMD_STR " tag <1-4294967295>", - SHOW_STR - IP_STR - "IP routing table\n" - VRF_CMD_HELP_STR - "Show only routes with tag\n" - "Tag value\n") - DEFUN (show_ip_route_prefix_longer, show_ip_route_prefix_longer_cmd, - "show ip route A.B.C.D/M longer-prefixes", + "show ip route [vrf NAME] A.B.C.D/M longer-prefixes", SHOW_STR IP_STR "IP routing table\n" + VRF_CMD_HELP_STR "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Show route matching the specified Network/Mask pair only\n") { @@ -2761,13 +1513,15 @@ DEFUN (show_ip_route_prefix_longer, int first = 1; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 1) + if (strmatch(argv[3]->text, "vrf")) { - ret = str2prefix (argv[1], &p); - VRF_GET_ID (vrf_id, argv[0]); + VRF_GET_ID (vrf_id, argv[4]->arg); + ret = str2prefix (argv[5]->arg, &p); } else - ret = str2prefix (argv[0], &p); + { + ret = str2prefix (argv[3]->arg, &p); + } if (! ret) { @@ -2794,22 +1548,13 @@ DEFUN (show_ip_route_prefix_longer, return CMD_SUCCESS; } -ALIAS (show_ip_route_prefix_longer, - show_ip_route_vrf_prefix_longer_cmd, - "show ip route " VRF_CMD_STR " A.B.C.D/M longer-prefixes", - SHOW_STR - IP_STR - "IP routing table\n" - VRF_CMD_HELP_STR - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "Show route matching the specified Network/Mask pair only\n") - DEFUN (show_ip_route_supernets, show_ip_route_supernets_cmd, - "show ip route supernets-only", + "show ip route [vrf NAME] supernets-only", SHOW_STR IP_STR "IP routing table\n" + VRF_CMD_HELP_STR "Show supernet entries only\n") { struct route_table *table; @@ -2819,8 +1564,8 @@ DEFUN (show_ip_route_supernets, int first = 1; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 0) - VRF_GET_ID (vrf_id, argv[0]); + if (strmatch(argv[3]->text, "vrf")) + VRF_GET_ID (vrf_id, argv[4]->arg); table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id); if (! table) @@ -2847,21 +1592,13 @@ DEFUN (show_ip_route_supernets, return CMD_SUCCESS; } -ALIAS (show_ip_route_supernets, - show_ip_route_vrf_supernets_cmd, - "show ip route " VRF_CMD_STR " supernets-only", - SHOW_STR - IP_STR - "IP routing table\n" - VRF_CMD_HELP_STR - "Show supernet entries only\n") - DEFUN (show_ip_route_protocol, show_ip_route_protocol_cmd, - "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA, + "show ip route [vrf NAME] <kernel|connected|static|rip|ospf|isis|bgp|pim|table>", SHOW_STR IP_STR "IP routing table\n" + VRF_CMD_HELP_STR QUAGGA_IP_REDIST_HELP_STR_ZEBRA) { int type; @@ -2871,13 +1608,15 @@ DEFUN (show_ip_route_protocol, int first = 1; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 1) + if (strmatch(argv[3]->text, "vrf")) { - type = proto_redistnum (AFI_IP, argv[1]); - VRF_GET_ID (vrf_id, argv[0]); - } + type = proto_redistnum (AFI_IP, argv[5]->arg); + VRF_GET_ID (vrf_id, argv[4]->arg); + } else - type = proto_redistnum (AFI_IP, argv[0]); + { + type = proto_redistnum (AFI_IP, argv[3]->arg); + } if (type < 0) { @@ -2904,31 +1643,24 @@ DEFUN (show_ip_route_protocol, return CMD_SUCCESS; } -ALIAS (show_ip_route_protocol, - show_ip_route_vrf_protocol_cmd, - "show ip route " VRF_CMD_STR " " QUAGGA_IP_REDIST_STR_ZEBRA, - SHOW_STR - IP_STR - "IP routing table\n" - VRF_CMD_HELP_STR - QUAGGA_IP_REDIST_HELP_STR_ZEBRA) DEFUN (show_ip_route_ospf_instance, show_ip_route_ospf_instance_cmd, - "show ip route ospf <1-65535>", + "show ip route ospf (1-65535)", SHOW_STR IP_STR "IP routing table\n" "Open Shortest Path First (OSPFv2)\n" "Instance ID\n") { + int idx_number = 4; struct route_table *table; struct route_node *rn; struct rib *rib; int first = 1; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[0]); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT); if (! table) @@ -2951,10 +1683,11 @@ DEFUN (show_ip_route_ospf_instance, DEFUN (show_ip_route_addr, show_ip_route_addr_cmd, - "show ip route A.B.C.D", + "show ip route [vrf NAME] A.B.C.D", SHOW_STR IP_STR "IP routing table\n" + VRF_CMD_HELP_STR "Network in the IP routing table to display\n") { int ret; @@ -2963,13 +1696,15 @@ DEFUN (show_ip_route_addr, struct route_node *rn; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 1) + if (strmatch(argv[3]->text, "vrf")) { - VRF_GET_ID (vrf_id, argv[0]); - ret = str2prefix_ipv4 (argv[1], &p); + VRF_GET_ID (vrf_id, argv[4]->arg); + ret = str2prefix_ipv4 (argv[5]->arg, &p); } else - ret = str2prefix_ipv4 (argv[0], &p); + { + ret = str2prefix_ipv4 (argv[3]->arg, &p); + } if (ret <= 0) { @@ -2995,21 +1730,13 @@ DEFUN (show_ip_route_addr, return CMD_SUCCESS; } -ALIAS (show_ip_route_addr, - show_ip_route_vrf_addr_cmd, - "show ip route " VRF_CMD_STR " A.B.C.D", - SHOW_STR - IP_STR - "IP routing table\n" - VRF_CMD_HELP_STR - "Network in the IP routing table to display\n") - DEFUN (show_ip_route_prefix, show_ip_route_prefix_cmd, - "show ip route A.B.C.D/M", + "show ip route [vrf NAME] A.B.C.D/M", SHOW_STR IP_STR "IP routing table\n" + VRF_CMD_HELP_STR "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") { int ret; @@ -3018,13 +1745,15 @@ DEFUN (show_ip_route_prefix, struct route_node *rn; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 1) + if (strmatch(argv[3]->text, "vrf")) { - VRF_GET_ID (vrf_id, argv[0]); - ret = str2prefix_ipv4 (argv[1], &p); + VRF_GET_ID (vrf_id, argv[4]->arg); + ret = str2prefix_ipv4 (argv[5]->arg, &p); } else - ret = str2prefix_ipv4 (argv[0], &p); + { + ret = str2prefix_ipv4 (argv[3]->arg, &p); + } if (ret <= 0) { @@ -3050,14 +1779,6 @@ DEFUN (show_ip_route_prefix, return CMD_SUCCESS; } -ALIAS (show_ip_route_prefix, - show_ip_route_vrf_prefix_cmd, - "show ip route " VRF_CMD_STR " A.B.C.D/M", - SHOW_STR - IP_STR - "IP routing table\n" - VRF_CMD_HELP_STR - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") static void vty_show_ip_route_summary (struct vty *vty, struct route_table *table) @@ -3211,17 +1932,18 @@ vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table) /* Show route summary. */ DEFUN (show_ip_route_summary, show_ip_route_summary_cmd, - "show ip route summary", + "show ip route [vrf NAME] summary", SHOW_STR IP_STR "IP routing table\n" + VRF_CMD_HELP_STR "Summary of all routes\n") { struct route_table *table; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 0) - VRF_GET_ID (vrf_id, argv[0]); + if (strmatch(argv[3]->text, "vrf")) + VRF_GET_ID (vrf_id, argv[4]->arg); table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id); if (! table) @@ -3232,30 +1954,22 @@ DEFUN (show_ip_route_summary, return CMD_SUCCESS; } -ALIAS (show_ip_route_summary, - show_ip_route_vrf_summary_cmd, - "show ip route " VRF_CMD_STR " summary", - SHOW_STR - IP_STR - "IP routing table\n" - VRF_CMD_HELP_STR - "Summary of all routes\n") - /* Show route summary prefix. */ DEFUN (show_ip_route_summary_prefix, show_ip_route_summary_prefix_cmd, - "show ip route summary prefix", + "show ip route [vrf NAME] summary prefix", SHOW_STR IP_STR "IP routing table\n" + VRF_CMD_HELP_STR "Summary of all routes\n" "Prefix routes\n") { struct route_table *table; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 0) - VRF_GET_ID (vrf_id, argv[0]); + if (strmatch(argv[3]->text, "vrf")) + VRF_GET_ID (vrf_id, argv[4]->arg); table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id); if (! table) @@ -3266,19 +1980,10 @@ DEFUN (show_ip_route_summary_prefix, return CMD_SUCCESS; } -ALIAS (show_ip_route_summary_prefix, - show_ip_route_vrf_summary_prefix_cmd, - "show ip route " VRF_CMD_STR " summary prefix", - SHOW_STR - IP_STR - "IP routing table\n" - VRF_CMD_HELP_STR - "Summary of all routes\n" - "Prefix routes\n") DEFUN (show_ip_route_vrf_all, show_ip_route_vrf_all_cmd, - "show ip route " VRF_ALL_CMD_STR, + "show ip route vrf all", SHOW_STR IP_STR "IP routing table\n" @@ -3323,7 +2028,7 @@ DEFUN (show_ip_route_vrf_all, DEFUN (show_ip_route_vrf_all_tag, show_ip_route_vrf_all_tag_cmd, - "show ip route " VRF_ALL_CMD_STR " tag <1-4294967295>", + "show ip route vrf all tag (1-4294967295)", SHOW_STR IP_STR "IP routing table\n" @@ -3331,6 +2036,7 @@ DEFUN (show_ip_route_vrf_all_tag, "Show only routes with tag\n" "Tag value\n") { + int idx_number = 6; struct route_table *table; struct route_node *rn; struct rib *rib; @@ -3340,8 +2046,8 @@ DEFUN (show_ip_route_vrf_all_tag, int vrf_header = 1; route_tag_t tag = 0; - if (argv[0]) - tag = atol(argv[0]); + if (argv[idx_number]->arg) + tag = atol(argv[idx_number]->arg); for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) { @@ -3376,7 +2082,7 @@ DEFUN (show_ip_route_vrf_all_tag, DEFUN (show_ip_route_vrf_all_prefix_longer, show_ip_route_vrf_all_prefix_longer_cmd, - "show ip route " VRF_ALL_CMD_STR " A.B.C.D/M longer-prefixes", + "show ip route vrf all A.B.C.D/M longer-prefixes", SHOW_STR IP_STR "IP routing table\n" @@ -3384,6 +2090,7 @@ DEFUN (show_ip_route_vrf_all_prefix_longer, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Show route matching the specified Network/Mask pair only\n") { + int idx_ipv4_prefixlen = 5; struct route_table *table; struct route_node *rn; struct rib *rib; @@ -3394,7 +2101,7 @@ DEFUN (show_ip_route_vrf_all_prefix_longer, int first = 1; int vrf_header = 1; - ret = str2prefix (argv[0], &p); + ret = str2prefix (argv[idx_ipv4_prefixlen]->arg, &p); if (! ret) { vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); @@ -3433,7 +2140,7 @@ DEFUN (show_ip_route_vrf_all_prefix_longer, DEFUN (show_ip_route_vrf_all_supernets, show_ip_route_vrf_all_supernets_cmd, - "show ip route " VRF_ALL_CMD_STR " supernets-only", + "show ip route vrf all supernets-only", SHOW_STR IP_STR "IP routing table\n" @@ -3470,7 +2177,6 @@ DEFUN (show_ip_route_vrf_all_supernets, vty_out (vty, SHOW_ROUTE_V4_HEADER); first = 0; } - if (vrf_header) { vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE); @@ -3487,7 +2193,7 @@ DEFUN (show_ip_route_vrf_all_supernets, DEFUN (show_ip_route_vrf_all_protocol, show_ip_route_vrf_all_protocol_cmd, - "show ip route " VRF_ALL_CMD_STR " " QUAGGA_IP_REDIST_STR_ZEBRA, + "show ip route vrf all <kernel|connected|static|rip|ospf|isis|bgp|pim|table>", SHOW_STR IP_STR "IP routing table\n" @@ -3503,7 +2209,7 @@ DEFUN (show_ip_route_vrf_all_protocol, int first = 1; int vrf_header = 1; - type = proto_redistnum (AFI_IP, argv[0]); + type = proto_redistnum (AFI_IP, argv[6]->arg); if (type < 0) { vty_out (vty, "Unknown route type%s", VTY_NEWLINE); @@ -3542,13 +2248,14 @@ DEFUN (show_ip_route_vrf_all_protocol, DEFUN (show_ip_route_vrf_all_addr, show_ip_route_vrf_all_addr_cmd, - "show ip route " VRF_ALL_CMD_STR " A.B.C.D", + "show ip route vrf all A.B.C.D", SHOW_STR IP_STR "IP routing table\n" VRF_ALL_CMD_HELP_STR "Network in the IP routing table to display\n") { + int idx_ipv4 = 5; int ret; struct prefix_ipv4 p; struct route_table *table; @@ -3556,7 +2263,7 @@ DEFUN (show_ip_route_vrf_all_addr, struct zebra_vrf *zvrf; vrf_iter_t iter; - ret = str2prefix_ipv4 (argv[0], &p); + ret = str2prefix_ipv4 (argv[idx_ipv4]->arg, &p); if (ret <= 0) { vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE); @@ -3583,13 +2290,14 @@ DEFUN (show_ip_route_vrf_all_addr, DEFUN (show_ip_route_vrf_all_prefix, show_ip_route_vrf_all_prefix_cmd, - "show ip route " VRF_ALL_CMD_STR " A.B.C.D/M", + "show ip route vrf all A.B.C.D/M", SHOW_STR IP_STR "IP routing table\n" VRF_ALL_CMD_HELP_STR "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") { + int idx_ipv4_prefixlen = 5; int ret; struct prefix_ipv4 p; struct route_table *table; @@ -3597,7 +2305,7 @@ DEFUN (show_ip_route_vrf_all_prefix, struct zebra_vrf *zvrf; vrf_iter_t iter; - ret = str2prefix_ipv4 (argv[0], &p); + ret = str2prefix_ipv4 (argv[idx_ipv4_prefixlen]->arg, &p); if (ret <= 0) { vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE); @@ -3629,7 +2337,7 @@ DEFUN (show_ip_route_vrf_all_prefix, DEFUN (show_ip_route_vrf_all_summary, show_ip_route_vrf_all_summary_cmd, - "show ip route " VRF_ALL_CMD_STR " summary ", + "show ip route vrf all summary ", SHOW_STR IP_STR "IP routing table\n" @@ -3648,7 +2356,7 @@ DEFUN (show_ip_route_vrf_all_summary, DEFUN (show_ip_route_vrf_all_summary_prefix, show_ip_route_vrf_all_summary_prefix_cmd, - "show ip route " VRF_ALL_CMD_STR " summary prefix", + "show ip route vrf all summary prefix", SHOW_STR IP_STR "IP routing table\n" @@ -3737,10 +2445,10 @@ static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd) /* General fucntion for IPv6 static route. */ int static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, - const char *gate_str, const char *ifname, - const char *flag_str, const char *tag_str, + const char *gate_str, const char *ifname, + const char *flag_str, const char *tag_str, const char *distance_str, const char *vrf_id_str, - const char *label_str) + const char *label_str) { int ret; u_char distance; @@ -3754,7 +2462,7 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, struct interface *ifp = NULL; struct zebra_vrf *zvrf; struct static_nh_label snh_label; - + ret = str2prefix (dest_str, &p); if (ret <= 0) { @@ -3793,11 +2501,11 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, if (label_str) { if (!mpls_enabled) - { - vty_out (vty, "%% MPLS not turned on in kernel, ignoring command%s", - VTY_NEWLINE); - return CMD_WARNING; - } + { + vty_out (vty, "%% MPLS not turned on in kernel, ignoring command%s", + VTY_NEWLINE); + return CMD_WARNING; + } if (mpls_str2label (label_str, &snh_label.num_labels, snh_label.label)) { @@ -3816,10 +2524,10 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, } if (add_cmd) static_add_route (AFI_IP6, SAFI_UNICAST, type, &p, NULL, ifindex, ifname, - ZEBRA_FLAG_BLACKHOLE, tag, distance, zvrf, &snh_label); + ZEBRA_FLAG_BLACKHOLE, tag, distance, zvrf, &snh_label); else static_delete_route (AFI_IP6, SAFI_UNICAST, type, &p, NULL, ifindex, tag, - distance, zvrf, &snh_label); + distance, zvrf, &snh_label); return CMD_SUCCESS; } @@ -3845,633 +2553,87 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, /* When ifname is specified. It must be come with gateway address. */ if (ret != 1) - { - vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); - return CMD_WARNING; - } + { + vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); + return CMD_WARNING; + } type = STATIC_IPV6_GATEWAY_IFINDEX; gate = &gate_addr; ifp = if_lookup_by_name_vrf (ifname, zvrf->vrf_id); if (!ifp) - { - vty_out (vty, "%% Malformed Interface name %s%s", ifname, VTY_NEWLINE); - return CMD_WARNING; - } + { + vty_out (vty, "%% Malformed Interface name %s%s", ifname, VTY_NEWLINE); + return CMD_WARNING; + } ifindex = ifp->ifindex; } else { if (ret == 1) - { - type = STATIC_IPV6_GATEWAY; - gate = &gate_addr; - } + { + type = STATIC_IPV6_GATEWAY; + gate = &gate_addr; + } else - { - type = STATIC_IFINDEX; - ifp = if_lookup_by_name_vrf (gate_str, zvrf->vrf_id); - if (!ifp) - { - vty_out (vty, "%% Malformed Interface name %s%s", gate_str, VTY_NEWLINE); + { + type = STATIC_IFINDEX; + ifp = if_lookup_by_name_vrf (gate_str, zvrf->vrf_id); + if (!ifp) + { + vty_out (vty, "%% Malformed Interface name %s%s", gate_str, VTY_NEWLINE); ifindex = IFINDEX_DELETED; - } + } else - ifindex = ifp->ifindex; - ifname = gate_str; - } + ifindex = ifp->ifindex; + ifname = gate_str; + } } if (add_cmd) static_add_route (AFI_IP6, SAFI_UNICAST, type, &p, (union g_addr *)gate, - ifindex, ifname, flag, tag, distance, zvrf, &snh_label); + ifindex, ifname, flag, tag, distance, zvrf, &snh_label); else static_delete_route (AFI_IP6, SAFI_UNICAST, type, &p, (union g_addr *)gate, - ifindex, tag, distance, zvrf, &snh_label); + ifindex, tag, distance, zvrf, &snh_label); return CMD_SUCCESS; } DEFUN (ipv6_route, ipv6_route_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0)", - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Null interface\n") -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, NULL, NULL, NULL); -} - -DEFUN (ipv6_route_tag, - ipv6_route_tag_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) tag <1-4294967295>", - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Null interface\n" - "Set tag for this route\n" - "Tag value\n") -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], NULL, NULL, NULL); -} - -DEFUN (ipv6_route_flags, - ipv6_route_flags_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)", - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n") -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, NULL, NULL, NULL); -} - -DEFUN (ipv6_route_flags_tag, - ipv6_route_flags_tag_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-4294967295>", - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n") -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], NULL, NULL, NULL); -} - -DEFUN (ipv6_route_ifname, - ipv6_route_ifname_cmd, - "ipv6 route X:X::X:X/M X:X::X:X INTERFACE", - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n") -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, NULL, NULL, NULL); -} -DEFUN (ipv6_route_ifname_tag, - ipv6_route_ifname_tag_cmd, - "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295>", - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Set tag for this route\n" - "Tag value\n") -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], NULL, NULL, NULL); -} - -DEFUN (ipv6_route_ifname_flags, - ipv6_route_ifname_flags_cmd, - "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)", - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n") -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, NULL, NULL, NULL); -} - -DEFUN (ipv6_route_ifname_flags_tag, - ipv6_route_ifname_flags_tag_cmd, - "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-4294967295>", - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n") -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], NULL, NULL, NULL); -} - -DEFUN (ipv6_route_pref, - ipv6_route_pref_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) <1-255>", + "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]", IP_STR "Establish static routes\n" "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" "IPv6 gateway address\n" "IPv6 gateway interface name\n" "Null interface\n" - "Distance value for this prefix\n") -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, argv[2], NULL, NULL); -} - -DEFUN (ipv6_route_pref_tag, - ipv6_route_pref_tag_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) tag <1-4294967295> <1-255>", - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" "Null interface\n" "Set tag for this route\n" "Tag value\n" - "Distance value for this prefix\n") -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], argv[3], NULL, NULL); -} - -DEFUN (ipv6_route_flags_pref, - ipv6_route_flags_pref_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>", - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this prefix\n") -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, argv[3], NULL, NULL); -} - -DEFUN (ipv6_route_flags_pref_tag, - ipv6_route_flags_pref_tag_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255>", - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n" - "Distance value for this prefix\n") -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], argv[4], NULL, NULL); -} - -DEFUN (ipv6_route_ifname_pref, - ipv6_route_ifname_pref_cmd, - "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>", - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Distance value for this prefix\n") -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, argv[3], NULL, NULL); -} - -DEFUN (ipv6_route_ifname_pref_tag, - ipv6_route_ifname_pref_tag_cmd, - "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295> <1-255>", - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Set tag for this route\n" - "Tag value\n" - "Distance value for this prefix\n") -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], argv[4], NULL, NULL); -} - -DEFUN (ipv6_route_ifname_flags_pref, - ipv6_route_ifname_flags_pref_cmd, - "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>", - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this prefix\n") -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, argv[4], NULL, NULL); -} - -DEFUN (ipv6_route_ifname_flags_pref_tag, - ipv6_route_ifname_flags_pref_tag_cmd, - "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-4294967295> <1-255>", - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n" - "Distance value for this prefix\n") -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], NULL, NULL); -} - -DEFUN (no_ipv6_route, - no_ipv6_route_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0)", - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Null Interface\n") -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, NULL, NULL, NULL); -} - -DEFUN (no_ipv6_route_tag, - no_ipv6_route_tag_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) tag <1-4294967295>", - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Null interface\n" - "Set tag for this route\n" - "Tag value\n") -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], NULL, NULL, NULL); -} - -DEFUN (no_ipv6_route_flags, - no_ipv6_route_flags_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)", - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n") -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], NULL, NULL, NULL, NULL); -} - -DEFUN (no_ipv6_route_flags_tag, - no_ipv6_route_flags_tag_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-4294967295>", - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n") -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3], NULL, NULL, NULL); -} - -DEFUN (no_ipv6_route_ifname, - no_ipv6_route_ifname_cmd, - "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE", - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n") -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, NULL, NULL, NULL); -} - -DEFUN (no_ipv6_route_ifname_tag, - no_ipv6_route_ifname_tag_cmd, - "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295>", - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Set tag for this route\n" - "Tag value\n") -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], NULL, NULL, NULL); -} - -DEFUN (no_ipv6_route_ifname_flags, - no_ipv6_route_ifname_flags_cmd, - "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)", - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n") -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], NULL, NULL, NULL, NULL); -} - -DEFUN (no_ipv6_route_ifname_flags_tag, - no_ipv6_route_ifname_flags_tag_cmd, - "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-4294967295>", - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n") -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4], NULL, NULL, NULL); -} - -DEFUN (no_ipv6_route_pref, - no_ipv6_route_pref_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Null interface\n" - "Distance value for this prefix\n") -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, argv[2], NULL, NULL); -} - -DEFUN (no_ipv6_route_pref_tag, - no_ipv6_route_pref_tag_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) tag <1-4294967295> <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Null interface\n" - "Set tag for this route\n" - "Tag value\n" - "Distance value for this prefix\n") -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], argv[3], NULL, NULL); -} - -DEFUN (no_ipv6_route_flags_pref, - no_ipv6_route_flags_pref_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this prefix\n") -{ - /* We do not care about argv[2] */ - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], NULL, argv[3], NULL, NULL); -} - -DEFUN (no_ipv6_route_flags_pref_tag, - no_ipv6_route_flags_pref_tag_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n" - "Distance value for this prefix\n") -{ - /* We do not care about argv[2] */ - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3], argv[4], NULL, NULL); -} - -DEFUN (no_ipv6_route_ifname_pref, - no_ipv6_route_ifname_pref_cmd, - "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Distance value for this prefix\n") -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, argv[3], NULL, NULL); -} - -DEFUN (no_ipv6_route_ifname_pref_tag, - no_ipv6_route_ifname_pref_tag_cmd, - "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295> <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Set tag for this route\n" - "Tag value\n" - "Distance value for this prefix\n") -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], argv[4], NULL, NULL); -} - -DEFUN (no_ipv6_route_ifname_flags_pref, - no_ipv6_route_ifname_flags_pref_cmd, - "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this prefix\n") -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], NULL, argv[4], NULL, NULL); -} - -DEFUN (no_ipv6_route_ifname_flags_pref_tag, - no_ipv6_route_ifname_flags_pref_tag_cmd, - "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-4294967295> <1-255>", - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n" - "Distance value for this prefix\n") -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], NULL, NULL); -} - -DEFUN (ipv6_route_vrf, - ipv6_route_vrf_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Null interface\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, NULL, argv[2], NULL); -} - -DEFUN (ipv6_route_tag_vrf, - ipv6_route_tag_vrf_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) tag <1-4294967295> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Null interface\n" - "Set tag for this route\n" - "Tag value\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], NULL, argv[3], NULL); -} - -DEFUN (ipv6_route_flags_vrf, - ipv6_route_flags_vrf_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - VRF_CMD_HELP_STR) + "Distance value for this prefix\n" + VRF_CMD_HELP_STR + "Specify labels for this route\n" + "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, NULL, argv[3], NULL); -} + int idx_ipv6_prefixlen = 2; + int idx_ipv6_ifname = 3; + int idx_curr = 4; + char *tag, *distance, *vrf; -DEFUN (ipv6_route_flags_tag_vrf, - ipv6_route_flags_tag_vrf_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-4294967295> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], NULL, argv[4], NULL); -} + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); -DEFUN (ipv6_route_ifname_vrf, - ipv6_route_ifname_vrf_cmd, - "ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, NULL, argv[3], NULL); -} -DEFUN (ipv6_route_ifname_tag_vrf, - ipv6_route_ifname_tag_vrf_cmd, - "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Set tag for this route\n" - "Tag value\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], NULL, argv[4], NULL); + return static_ipv6_func (vty, 1, + argv[idx_ipv6_prefixlen]->arg, + argv[idx_ipv6_ifname]->arg, + NULL, NULL, + tag, distance, vrf, NULL); } -DEFUN (ipv6_route_ifname_flags_vrf, - ipv6_route_ifname_flags_vrf_cmd, - "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR, +DEFUN (ipv6_route_flags, + ipv6_route_flags_cmd, + "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]", IP_STR "Establish static routes\n" "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" @@ -4479,143 +2641,66 @@ DEFUN (ipv6_route_ifname_flags_vrf, "IPv6 gateway interface name\n" "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, NULL, argv[4], NULL); -} - -DEFUN (ipv6_route_ifname_flags_tag_vrf, - ipv6_route_ifname_flags_tag_vrf_cmd, - "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-4294967295> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n" "Set tag for this route\n" "Tag value\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], NULL, argv[5], NULL); -} - -DEFUN (ipv6_route_pref_vrf, - ipv6_route_pref_vrf_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) <1-255> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Null interface\n" "Distance value for this prefix\n" - VRF_CMD_HELP_STR) + VRF_CMD_HELP_STR + "Specify labels for this route\n" + "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, argv[2], argv[3], NULL); -} + int idx_ipv6_prefixlen = 2; + int idx_ipv6_ifname = 3; + int idx_reject_blackhole = 4; + int idx_curr = 5; + char *tag, *distance, *vrf; -DEFUN (ipv6_route_pref_tag_vrf, - ipv6_route_pref_tag_vrf_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) tag <1-4294967295> <1-255> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Null interface\n" - "Set tag for this route\n" - "Tag value\n" - "Distance value for this prefix\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], argv[3], argv[4], NULL); -} + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); -DEFUN (ipv6_route_flags_pref_vrf, - ipv6_route_flags_pref_vrf_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this prefix\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, argv[3], argv[4], NULL); + return static_ipv6_func (vty, 1, + argv[idx_ipv6_prefixlen]->arg, + argv[idx_ipv6_ifname]->arg, + NULL, + argv[idx_reject_blackhole]->arg, + tag, distance, vrf, NULL); } -DEFUN (ipv6_route_flags_pref_tag_vrf, - ipv6_route_flags_pref_tag_vrf_cmd, - "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255> " VRF_CMD_STR, +DEFUN (ipv6_route_ifname, + ipv6_route_ifname_cmd, + "ipv6 route X:X::X:X/M X:X::X:X INTERFACE [tag (1-4294967295)] [(1-255)] [vrf NAME]", IP_STR "Establish static routes\n" "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" "IPv6 gateway address\n" "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" "Set tag for this route\n" "Tag value\n" "Distance value for this prefix\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], argv[4], argv[5], NULL); -} - -DEFUN (ipv6_route_ifname_pref_vrf, - ipv6_route_ifname_pref_vrf_cmd, - "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Distance value for this prefix\n" - VRF_CMD_HELP_STR) + VRF_CMD_HELP_STR + "Specify labels for this route\n" + "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, argv[3], argv[4], NULL); -} + int idx_ipv6_prefixlen = 2; + int idx_ipv6 = 3; + int idx_interface = 4; + int idx_curr = 5; + char *tag, *distance, *vrf; -DEFUN (ipv6_route_ifname_pref_tag_vrf, - ipv6_route_ifname_pref_tag_vrf_cmd, - "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295> <1-255> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Set tag for this route\n" - "Tag value\n" - "Distance value for this prefix\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], argv[4], argv[5], NULL); -} + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); -DEFUN (ipv6_route_ifname_flags_pref_vrf, - ipv6_route_ifname_flags_pref_vrf_cmd, - "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " VRF_CMD_STR, - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this prefix\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, argv[4], argv[5], NULL); + return static_ipv6_func (vty, 1, + argv[idx_ipv6_prefixlen]->arg, + argv[idx_ipv6]->arg, + argv[idx_interface]->arg, + NULL, + tag, distance, vrf, NULL); } -DEFUN (ipv6_route_ifname_flags_pref_tag_vrf, - ipv6_route_ifname_flags_pref_tag_vrf_cmd, - "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-4294967295> <1-255> " VRF_CMD_STR, +DEFUN (ipv6_route_ifname_flags, + ipv6_route_ifname_flags_cmd, + "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]", IP_STR "Establish static routes\n" "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" @@ -4626,29 +2711,31 @@ DEFUN (ipv6_route_ifname_flags_pref_tag_vrf, "Set tag for this route\n" "Tag value\n" "Distance value for this prefix\n" - VRF_CMD_HELP_STR) + VRF_CMD_HELP_STR + "Specify labels for this route\n" + "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], NULL); -} + int idx_ipv6_prefixlen = 2; + int idx_ipv6 = 3; + int idx_interface = 4; + int idx_reject_blackhole = 5; + int idx_curr = 6; + char *tag, *distance, *vrf; -DEFUN (no_ipv6_route_vrf, - no_ipv6_route_vrf_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Null interface\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, NULL, argv[2], NULL); + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); + + return static_ipv6_func (vty, 1, + argv[idx_ipv6_prefixlen]->arg, + argv[idx_ipv6]->arg, + argv[idx_interface]->arg, + argv[idx_reject_blackhole]->arg, + tag, distance, vrf, NULL); } -DEFUN (no_ipv6_route_tag_vrf, - no_ipv6_route_tag_vrf_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) tag <1-4294967295> " VRF_CMD_STR, +DEFUN (no_ipv6_route, + no_ipv6_route_cmd, + "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]", NO_STR IP_STR "Establish static routes\n" @@ -4658,94 +2745,29 @@ DEFUN (no_ipv6_route_tag_vrf, "Null interface\n" "Set tag for this route\n" "Tag value\n" - VRF_CMD_HELP_STR) + "Distance value for this prefix\n" + VRF_CMD_HELP_STR + "Specify labels for this route\n" + "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], NULL, argv[3], NULL); -} + int idx_ipv6_prefixlen = 3; + int idx_ipv6_ifname = 4; + int idx_curr = 5; + char *tag, *distance, *vrf; -DEFUN (no_ipv6_route_flags_vrf, - no_ipv6_route_flags_vrf_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], NULL, NULL, argv[3], NULL); -} + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); -DEFUN (no_ipv6_route_flags_tag_vrf, - no_ipv6_route_flags_tag_vrf_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-4294967295> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Set tag for this route\n" - "Tag value\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3], NULL, argv[4], NULL); -} - -DEFUN (no_ipv6_route_ifname_vrf, - no_ipv6_route_ifname_vrf_cmd, - "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, NULL, argv[3], NULL); + return static_ipv6_func (vty, 0, + argv[idx_ipv6_prefixlen]->arg, + argv[idx_ipv6_ifname]->arg, + NULL, NULL, + tag, distance, vrf, NULL); } -DEFUN (no_ipv6_route_ifname_tag_vrf, - no_ipv6_route_ifname_tag_vrf_cmd, - "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Set tag for this route\n" - "Tag value\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], NULL, argv[4], NULL); -} - -DEFUN (no_ipv6_route_ifname_flags_vrf, - no_ipv6_route_ifname_flags_vrf_cmd, - "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], NULL, NULL, argv[4], NULL); -} - -DEFUN (no_ipv6_route_ifname_flags_tag_vrf, - no_ipv6_route_ifname_flags_tag_vrf_cmd, - "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-4294967295> " VRF_CMD_STR, +DEFUN (no_ipv6_route_flags, + no_ipv6_route_flags_cmd, + "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]", NO_STR IP_STR "Establish static routes\n" @@ -4756,135 +2778,64 @@ DEFUN (no_ipv6_route_ifname_flags_tag_vrf, "Silently discard pkts when matched\n" "Set tag for this route\n" "Tag value\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4], NULL, argv[5], NULL); -} - -DEFUN (no_ipv6_route_pref_vrf, - no_ipv6_route_pref_vrf_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) <1-255> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Null interface\n" "Distance value for this prefix\n" - VRF_CMD_HELP_STR) + VRF_CMD_HELP_STR + "Specify labels for this route\n" + "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, argv[2], argv[3], NULL); -} + int idx_ipv6_prefixlen = 3; + int idx_ipv6_ifname = 4; + int idx_reject_blackhole = 5; + int idx_curr = 5; + char *tag, *distance, *vrf; -DEFUN (no_ipv6_route_pref_tag_vrf, - no_ipv6_route_pref_tag_vrf_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) tag <1-4294967295> <1-255> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Null interface\n" - "Set tag for this route\n" - "Tag value\n" - "Distance value for this prefix\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], argv[3], argv[4], NULL); -} + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); -DEFUN (no_ipv6_route_flags_pref_vrf, - no_ipv6_route_flags_pref_vrf_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this prefix\n" - VRF_CMD_HELP_STR) -{ - /* We do not care about argv[2] */ - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], NULL, argv[3], argv[4], NULL); + return static_ipv6_func (vty, 0, + argv[idx_ipv6_prefixlen]->arg, + argv[idx_ipv6_ifname]->arg, + NULL, + argv[idx_reject_blackhole]->arg, + tag, distance, vrf, NULL); } -DEFUN (no_ipv6_route_flags_pref_tag_vrf, - no_ipv6_route_flags_pref_tag_vrf_cmd, - "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255> " VRF_CMD_STR, +DEFUN (no_ipv6_route_ifname, + no_ipv6_route_ifname_cmd, + "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE [tag (1-4294967295)] [(1-255)] [vrf NAME]", NO_STR IP_STR "Establish static routes\n" "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" "IPv6 gateway address\n" "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" "Set tag for this route\n" "Tag value\n" "Distance value for this prefix\n" - VRF_CMD_HELP_STR) -{ - /* We do not care about argv[2] */ - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3], argv[4], argv[5], NULL); -} - -DEFUN (no_ipv6_route_ifname_pref_vrf, - no_ipv6_route_ifname_pref_vrf_cmd, - "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Distance value for this prefix\n" - VRF_CMD_HELP_STR) + VRF_CMD_HELP_STR + "Specify labels for this route\n" + "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, argv[3], argv[4], NULL); -} + int idx_ipv6_prefixlen = 3; + int idx_ipv6 = 4; + int idx_interface = 5; + int idx_curr = 6; + char *tag, *distance, *vrf; -DEFUN (no_ipv6_route_ifname_pref_tag_vrf, - no_ipv6_route_ifname_pref_tag_vrf_cmd, - "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295> <1-255> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Set tag for this route\n" - "Tag value\n" - "Distance value for this prefix\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], argv[4], argv[5], NULL); -} + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); -DEFUN (no_ipv6_route_ifname_flags_pref_vrf, - no_ipv6_route_ifname_flags_pref_vrf_cmd, - "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " VRF_CMD_STR, - NO_STR - IP_STR - "Establish static routes\n" - "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" - "IPv6 gateway address\n" - "IPv6 gateway interface name\n" - "Emit an ICMP unreachable when matched\n" - "Silently discard pkts when matched\n" - "Distance value for this prefix\n" - VRF_CMD_HELP_STR) -{ - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], NULL, argv[4], argv[5], NULL); + return static_ipv6_func (vty, 0, + argv[idx_ipv6_prefixlen]->arg, + argv[idx_ipv6]->arg, + argv[idx_interface]->arg, + NULL, + tag, distance, vrf, NULL); } -DEFUN (no_ipv6_route_ifname_flags_pref_tag_vrf, - no_ipv6_route_ifname_flags_pref_tag_vrf_cmd, - "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-4294967295> <1-255> " VRF_CMD_STR, +DEFUN (no_ipv6_route_ifname_flags, + no_ipv6_route_ifname_flags_cmd, + "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]", NO_STR IP_STR "Establish static routes\n" @@ -4896,17 +2847,36 @@ DEFUN (no_ipv6_route_ifname_flags_pref_tag_vrf, "Set tag for this route\n" "Tag value\n" "Distance value for this prefix\n" - VRF_CMD_HELP_STR) + VRF_CMD_HELP_STR + "Specify labels for this route\n" + "One or more labels separated by '/'\n") { - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], NULL); + int idx_ipv6_prefixlen = 3; + int idx_ipv6 = 4; + int idx_interface = 5; + int idx_reject_blackhole = 6; + int idx_curr = 7; + char *tag, *distance, *vrf; + + tag = distance = vrf = NULL; + zebra_vty_ip_route_tdv_helper (argc, argv, idx_curr, &tag, &distance, &vrf, NULL); + + return static_ipv6_func (vty, 0, + argv[idx_ipv6_prefixlen]->arg, + argv[idx_ipv6]->arg, + argv[idx_interface]->arg, + argv[idx_reject_blackhole]->arg, + tag, distance, vrf, NULL); } DEFUN (show_ipv6_route, show_ipv6_route_cmd, - "show ipv6 route {json}", + "show ipv6 route [vrf NAME] [json]", SHOW_STR IP_STR - "IPv6 routing table\n") + "IPv6 routing table\n" + VRF_CMD_HELP_STR + "Output JSON\n") { struct route_table *table; struct route_node *rn; @@ -4917,33 +2887,36 @@ DEFUN (show_ipv6_route, char buf[BUFSIZ]; json_object *json = NULL; json_object *json_prefix = NULL; - u_char uj = use_json(argc, argv); - if (argc > 0 && argv[0] && strcmp(argv[0], "json") != 0) - { - if (!(zvrf = zebra_vrf_list_lookup_by_name (argv[0]))) - { - if (uj) - vty_out (vty, "{}%s", VTY_NEWLINE); - else - vty_out (vty, "vrf %s not defined%s", argv[0], VTY_NEWLINE); - return CMD_SUCCESS; - } + int vrf = (argc > 3 && strmatch (argv[3]->text, "vrf")); + int uj = vrf ? argc == 6 : argc == 4; + char *vrfname = vrf ? argv[4]->arg : NULL; - if (zvrf->vrf_id == VRF_UNKNOWN) - { - if (uj) - vty_out (vty, "{}%s", VTY_NEWLINE); - else - vty_out (vty, "vrf %s inactive%s", argv[0], VTY_NEWLINE); - return CMD_SUCCESS; - } - else - vrf_id = zvrf->vrf_id; - } + if (vrf) + { + if (!(zvrf = zebra_vrf_list_lookup_by_name (vrfname))) + { + if (uj) + vty_out (vty, "{}%s", VTY_NEWLINE); + else + vty_out (vty, "vrf %s not defined%s", vrfname, VTY_NEWLINE); + return CMD_SUCCESS; + } + + if (zvrf->vrf_id == VRF_UNKNOWN) + { + if (uj) + vty_out (vty, "{}%s", VTY_NEWLINE); + else + vty_out (vty, "vrf %s inactive%s", vrfname, VTY_NEWLINE); + return CMD_SUCCESS; + } + else + vrf_id = zvrf->vrf_id; + } table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id); - if (! table) + if (!table) { if (uj) vty_out (vty, "{}%s", VTY_NEWLINE); @@ -4995,23 +2968,19 @@ DEFUN (show_ipv6_route, return CMD_SUCCESS; } -ALIAS (show_ipv6_route, - show_ipv6_route_vrf_cmd, - "show ipv6 route " VRF_CMD_STR " {json}", - SHOW_STR - IP_STR - "IPv6 routing table\n" - VRF_CMD_HELP_STR) - DEFUN (show_ipv6_route_tag, show_ipv6_route_tag_cmd, - "show ipv6 route tag <1-4294967295>", + "show ipv6 route [vrf NAME] tag (1-4294967295)", SHOW_STR IP_STR "IPv6 routing table\n" + VRF_CMD_HELP_STR "Show only routes with tag\n" "Tag value\n") { + int idx_vrf = 3; + int idx_name = 4; + int idx_tag = 6; struct route_table *table; struct route_node *rn; struct rib *rib; @@ -5019,13 +2988,16 @@ DEFUN (show_ipv6_route_tag, route_tag_t tag = 0; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 1) + if (strmatch(argv[idx_vrf]->text, "vrf")) { - VRF_GET_ID (vrf_id, argv[0]); - tag = atol(argv[1]); + VRF_GET_ID (vrf_id, argv[idx_name]->arg); + tag = atol(argv[idx_tag]->arg); } else - tag = atol(argv[0]); + { + idx_tag -= 2; + tag = atol(argv[idx_tag]->arg); + } table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id); if (! table) @@ -5048,22 +3020,13 @@ DEFUN (show_ipv6_route_tag, return CMD_SUCCESS; } -ALIAS (show_ipv6_route_tag, - show_ipv6_route_vrf_tag_cmd, - "show ipv6 route " VRF_CMD_STR " tag <1-4294967295>", - SHOW_STR - IP_STR - "IPv6 routing table\n" - VRF_CMD_HELP_STR - "Show only routes with tag\n" - "Tag value\n") - DEFUN (show_ipv6_route_prefix_longer, show_ipv6_route_prefix_longer_cmd, - "show ipv6 route X:X::X:X/M longer-prefixes", + "show ipv6 route [vrf NAME] X:X::X:X/M longer-prefixes", SHOW_STR IP_STR "IPv6 routing table\n" + VRF_CMD_HELP_STR "IPv6 prefix\n" "Show route matching the specified Network/Mask pair only\n") { @@ -5075,13 +3038,15 @@ DEFUN (show_ipv6_route_prefix_longer, int first = 1; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 1) + if (strmatch(argv[3]->text, "vrf")) { - VRF_GET_ID (vrf_id, argv[0]); - ret = str2prefix (argv[1], &p); + VRF_GET_ID (vrf_id, argv[4]->arg); + ret = str2prefix (argv[5]->arg, &p); } else - ret = str2prefix (argv[0], &p); + { + ret = str2prefix (argv[3]->arg, &p); + } if (! ret) { @@ -5108,23 +3073,14 @@ DEFUN (show_ipv6_route_prefix_longer, return CMD_SUCCESS; } -ALIAS (show_ipv6_route_prefix_longer, - show_ipv6_route_vrf_prefix_longer_cmd, - "show ipv6 route " VRF_CMD_STR " X:X::X:X/M longer-prefixes", - SHOW_STR - IP_STR - "IPv6 routing table\n" - VRF_CMD_HELP_STR - "IPv6 prefix\n" - "Show route matching the specified Network/Mask pair only\n") - DEFUN (show_ipv6_route_protocol, show_ipv6_route_protocol_cmd, - "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA, + "show ipv6 route [vrf NAME] <kernel|connected|static|ripng|ospf6|isis|bgp|table>", SHOW_STR IP_STR "IP routing table\n" - QUAGGA_IP6_REDIST_HELP_STR_ZEBRA) + VRF_CMD_HELP_STR + QUAGGA_IP6_REDIST_HELP_STR_ZEBRA) { int type; struct route_table *table; @@ -5133,13 +3089,16 @@ DEFUN (show_ipv6_route_protocol, int first = 1; vrf_id_t vrf_id = VRF_DEFAULT; - if ( argc >1 ) + char *vrfname = (argc == 6) ? argv[4]->arg : NULL; + char *proto = argv[argc - 1]->text; + + if (vrfname) { - VRF_GET_ID (vrf_id, argv[0]); - type = proto_redistnum (AFI_IP6, argv[1]); + VRF_GET_ID (vrf_id, vrfname); + type = proto_redistnum (AFI_IP6, proto); } else - type = proto_redistnum (AFI_IP6, argv[0]); + type = proto_redistnum (AFI_IP6, proto); if (type < 0) { @@ -5166,21 +3125,13 @@ DEFUN (show_ipv6_route_protocol, return CMD_SUCCESS; } -ALIAS (show_ipv6_route_protocol, - show_ipv6_route_vrf_protocol_cmd, - "show ipv6 route " VRF_CMD_STR " " QUAGGA_IP6_REDIST_STR_ZEBRA, - SHOW_STR - IP_STR - "IP routing table\n" - VRF_CMD_HELP_STR - QUAGGA_IP6_REDIST_HELP_STR_ZEBRA) - DEFUN (show_ipv6_route_addr, show_ipv6_route_addr_cmd, - "show ipv6 route X:X::X:X", + "show ipv6 route [vrf NAME] X:X::X:X", SHOW_STR IP_STR "IPv6 routing table\n" + VRF_CMD_HELP_STR "IPv6 Address\n") { int ret; @@ -5189,13 +3140,15 @@ DEFUN (show_ipv6_route_addr, struct route_node *rn; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 1 ) + if (strmatch(argv[3]->text, "vrf")) { - VRF_GET_ID (vrf_id, argv[0]); - ret = str2prefix_ipv6 (argv[1], &p); + VRF_GET_ID (vrf_id, argv[4]->arg); + ret = str2prefix_ipv6 (argv[5]->arg, &p); } else - ret = str2prefix_ipv6 (argv[0], &p); + { + ret = str2prefix_ipv6 (argv[3]->arg, &p); + } if (ret <= 0) { @@ -5221,21 +3174,13 @@ DEFUN (show_ipv6_route_addr, return CMD_SUCCESS; } -ALIAS (show_ipv6_route_addr, - show_ipv6_route_vrf_addr_cmd, - "show ipv6 route " VRF_CMD_STR " X:X::X:X", - SHOW_STR - IP_STR - "IPv6 routing table\n" - VRF_CMD_HELP_STR - "IPv6 Address\n") - DEFUN (show_ipv6_route_prefix, show_ipv6_route_prefix_cmd, - "show ipv6 route X:X::X:X/M", + "show ipv6 route [vrf NAME] X:X::X:X/M", SHOW_STR IP_STR "IPv6 routing table\n" + VRF_CMD_HELP_STR "IPv6 prefix\n") { int ret; @@ -5244,13 +3189,13 @@ DEFUN (show_ipv6_route_prefix, struct route_node *rn; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 1) + if (strmatch(argv[3]->text, "vrf")) { - VRF_GET_ID (vrf_id, argv[0]); - ret = str2prefix_ipv6 (argv[1], &p); + VRF_GET_ID (vrf_id, argv[4]->arg); + ret = str2prefix_ipv6 (argv[5]->arg, &p); } else - ret = str2prefix_ipv6 (argv[0], &p); + ret = str2prefix_ipv6 (argv[3]->arg, &p); if (ret <= 0) { @@ -5276,29 +3221,22 @@ DEFUN (show_ipv6_route_prefix, return CMD_SUCCESS; } -ALIAS (show_ipv6_route_prefix, - show_ipv6_route_vrf_prefix_cmd, - "show ipv6 route " VRF_CMD_STR " X:X::X:X/M ", - SHOW_STR - IP_STR - "IPv6 routing table\n" - VRF_CMD_HELP_STR - "IPv6 prefix\n") /* Show route summary. */ DEFUN (show_ipv6_route_summary, show_ipv6_route_summary_cmd, - "show ipv6 route summary", + "show ipv6 route [vrf NAME] summary", SHOW_STR IP_STR "IPv6 routing table\n" + VRF_CMD_HELP_STR "Summary of all IPv6 routes\n") { struct route_table *table; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 0) - VRF_GET_ID (vrf_id, argv[0]); + if (strmatch(argv[3]->text, "vrf")) + VRF_GET_ID (vrf_id, argv[4]->arg); table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id); if (! table) @@ -5309,30 +3247,23 @@ DEFUN (show_ipv6_route_summary, return CMD_SUCCESS; } -ALIAS (show_ipv6_route_summary, - show_ipv6_route_vrf_summary_cmd, - "show ipv6 route " VRF_CMD_STR " summary", - SHOW_STR - IP_STR - "IPv6 routing table\n" - VRF_CMD_HELP_STR - "Summary of all IPv6 routes\n") /* Show ipv6 route summary prefix. */ DEFUN (show_ipv6_route_summary_prefix, show_ipv6_route_summary_prefix_cmd, - "show ipv6 route summary prefix", + "show ipv6 route [vrf NAME] summary prefix", SHOW_STR IP_STR "IPv6 routing table\n" + VRF_CMD_HELP_STR "Summary of all IPv6 routes\n" "Prefix routes\n") { struct route_table *table; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 0) - VRF_GET_ID (vrf_id, argv[0]); + if (strmatch(argv[3]->text, "vrf")) + VRF_GET_ID (vrf_id, argv[4]->arg); table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id); if (! table) @@ -5343,27 +3274,18 @@ DEFUN (show_ipv6_route_summary_prefix, return CMD_SUCCESS; } -ALIAS (show_ipv6_route_summary_prefix, - show_ipv6_route_vrf_summary_prefix_cmd, - "show ipv6 route " VRF_CMD_STR " summary prefix", - SHOW_STR - IP_STR - "IPv6 routing table\n" - VRF_CMD_HELP_STR - "Summary of all IPv6 routes\n" - "Prefix routes\n") /* * Show IPv6 mroute command.Used to dump * the Multicast routing table. */ - DEFUN (show_ipv6_mroute, show_ipv6_mroute_cmd, - "show ipv6 mroute", + "show ipv6 mroute [vrf NAME]", SHOW_STR IP_STR - "IPv6 Multicast routing table\n") + "IPv6 Multicast routing table\n" + VRF_CMD_HELP_STR) { struct route_table *table; struct route_node *rn; @@ -5371,8 +3293,8 @@ DEFUN (show_ipv6_mroute, int first = 1; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 0) - VRF_GET_ID (vrf_id, argv[0]); + if (strmatch(argv[3]->text, "vrf")) + VRF_GET_ID (vrf_id, argv[4]->arg); table = zebra_vrf_table (AFI_IP6, SAFI_MULTICAST, vrf_id); if (! table) @@ -5392,17 +3314,10 @@ DEFUN (show_ipv6_mroute, return CMD_SUCCESS; } -ALIAS (show_ipv6_mroute, - show_ipv6_mroute_vrf_cmd, - "show ipv6 mroute " VRF_CMD_STR, - SHOW_STR - IP_STR - "IPv6 Multicast routing table\n" - VRF_CMD_HELP_STR) DEFUN (show_ipv6_route_vrf_all, show_ipv6_route_vrf_all_cmd, - "show ipv6 route " VRF_ALL_CMD_STR, + "show ipv6 route vrf all", SHOW_STR IP_STR "IPv6 routing table\n" @@ -5447,7 +3362,7 @@ DEFUN (show_ipv6_route_vrf_all, DEFUN (show_ipv6_route_vrf_all_tag, show_ipv6_route_vrf_all_tag_cmd, - "show ipv6 route " VRF_ALL_CMD_STR " tag <1-4294967295>", + "show ipv6 route vrf all tag (1-4294967295)", SHOW_STR IP_STR "IPv6 routing table\n" @@ -5455,6 +3370,7 @@ DEFUN (show_ipv6_route_vrf_all_tag, "Show only routes with tag\n" "Tag value\n") { + int idx_number = 6; struct route_table *table; struct route_node *rn; struct rib *rib; @@ -5464,8 +3380,8 @@ DEFUN (show_ipv6_route_vrf_all_tag, int vrf_header = 1; route_tag_t tag = 0; - if (argv[0]) - tag = atol(argv[0]); + if (argv[idx_number]->arg) + tag = atol(argv[idx_number]->arg); for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) { @@ -5501,7 +3417,7 @@ DEFUN (show_ipv6_route_vrf_all_tag, DEFUN (show_ipv6_route_vrf_all_prefix_longer, show_ipv6_route_vrf_all_prefix_longer_cmd, - "show ipv6 route " VRF_ALL_CMD_STR " X:X::X:X/M longer-prefixes", + "show ipv6 route vrf all X:X::X:X/M longer-prefixes", SHOW_STR IP_STR "IPv6 routing table\n" @@ -5509,6 +3425,7 @@ DEFUN (show_ipv6_route_vrf_all_prefix_longer, "IPv6 prefix\n" "Show route matching the specified Network/Mask pair only\n") { + int idx_ipv6_prefixlen = 5; struct route_table *table; struct route_node *rn; struct rib *rib; @@ -5519,7 +3436,7 @@ DEFUN (show_ipv6_route_vrf_all_prefix_longer, int first = 1; int vrf_header = 1; - ret = str2prefix (argv[0], &p); + ret = str2prefix (argv[idx_ipv6_prefixlen]->arg, &p); if (! ret) { vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); @@ -5558,13 +3475,14 @@ DEFUN (show_ipv6_route_vrf_all_prefix_longer, DEFUN (show_ipv6_route_vrf_all_protocol, show_ipv6_route_vrf_all_protocol_cmd, - "show ipv6 route " VRF_ALL_CMD_STR " " QUAGGA_IP6_REDIST_STR_ZEBRA, + "show ipv6 route vrf all <kernel|connected|static|ripng|ospf6|isis|bgp|table>", SHOW_STR IP_STR "IP routing table\n" VRF_ALL_CMD_HELP_STR QUAGGA_IP6_REDIST_HELP_STR_ZEBRA) { + int idx_protocol = 5; int type; struct route_table *table; struct route_node *rn; @@ -5574,7 +3492,7 @@ DEFUN (show_ipv6_route_vrf_all_protocol, int first = 1; int vrf_header = 1; - type = proto_redistnum (AFI_IP6, argv[0]); + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); if (type < 0) { vty_out (vty, "Unknown route type%s", VTY_NEWLINE); @@ -5613,13 +3531,14 @@ DEFUN (show_ipv6_route_vrf_all_protocol, DEFUN (show_ipv6_route_vrf_all_addr, show_ipv6_route_vrf_all_addr_cmd, - "show ipv6 route " VRF_ALL_CMD_STR " X:X::X:X", + "show ipv6 route vrf all X:X::X:X", SHOW_STR IP_STR "IPv6 routing table\n" VRF_ALL_CMD_HELP_STR "IPv6 Address\n") { + int idx_ipv6 = 5; int ret; struct prefix_ipv6 p; struct route_table *table; @@ -5627,7 +3546,7 @@ DEFUN (show_ipv6_route_vrf_all_addr, struct zebra_vrf *zvrf; vrf_iter_t iter; - ret = str2prefix_ipv6 (argv[0], &p); + ret = str2prefix_ipv6 (argv[idx_ipv6]->arg, &p); if (ret <= 0) { vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE); @@ -5654,13 +3573,14 @@ DEFUN (show_ipv6_route_vrf_all_addr, DEFUN (show_ipv6_route_vrf_all_prefix, show_ipv6_route_vrf_all_prefix_cmd, - "show ipv6 route " VRF_ALL_CMD_STR " X:X::X:X/M", + "show ipv6 route vrf all X:X::X:X/M", SHOW_STR IP_STR "IPv6 routing table\n" VRF_ALL_CMD_HELP_STR "IPv6 prefix\n") { + int idx_ipv6_prefixlen = 5; int ret; struct prefix_ipv6 p; struct route_table *table; @@ -5668,7 +3588,7 @@ DEFUN (show_ipv6_route_vrf_all_prefix, struct zebra_vrf *zvrf; vrf_iter_t iter; - ret = str2prefix_ipv6 (argv[0], &p); + ret = str2prefix_ipv6 (argv[idx_ipv6_prefixlen]->arg, &p); if (ret <= 0) { vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE); @@ -5700,7 +3620,7 @@ DEFUN (show_ipv6_route_vrf_all_prefix, DEFUN (show_ipv6_route_vrf_all_summary, show_ipv6_route_vrf_all_summary_cmd, - "show ipv6 route " VRF_ALL_CMD_STR " summary", + "show ipv6 route vrf all summary", SHOW_STR IP_STR "IPv6 routing table\n" @@ -5719,7 +3639,7 @@ DEFUN (show_ipv6_route_vrf_all_summary, DEFUN (show_ipv6_mroute_vrf_all, show_ipv6_mroute_vrf_all_cmd, - "show ipv6 mroute " VRF_ALL_CMD_STR, + "show ipv6 mroute vrf all", SHOW_STR IP_STR "IPv6 Multicast routing table\n" @@ -5755,7 +3675,7 @@ DEFUN (show_ipv6_mroute_vrf_all, DEFUN (show_ipv6_route_vrf_all_summary_prefix, show_ipv6_route_vrf_all_summary_prefix_cmd, - "show ipv6 route " VRF_ALL_CMD_STR " summary prefix", + "show ipv6 route vrf all summary prefix", SHOW_STR IP_STR "IPv6 routing table\n" @@ -5902,9 +3822,7 @@ zebra_ip_config (struct vty *vty) write += static_config_ipv4 (vty, SAFI_UNICAST, "ip route"); write += static_config_ipv4 (vty, SAFI_MULTICAST, "ip mroute"); -#ifdef HAVE_IPV6 write += static_config_ipv6 (vty); -#endif /* HAVE_IPV6 */ write += zebra_import_table_config (vty); return write; @@ -5912,49 +3830,7 @@ zebra_ip_config (struct vty *vty) DEFUN (ip_zebra_import_table_distance, ip_zebra_import_table_distance_cmd, - "ip import-table <1-252> distance <1-255>", - IP_STR - "import routes from non-main kernel table\n" - "kernel routing table id\n" - "Distance for imported routes\n" - "Default distance value\n") -{ - u_int32_t table_id = 0; - int distance = ZEBRA_TABLE_DISTANCE_DEFAULT; - - if (argc) - VTY_GET_INTEGER("table", table_id, argv[0]); - - if (!is_zebra_valid_kernel_table(table_id)) - { - vty_out(vty, "Invalid routing table ID, %d. Must be in range 1-252%s", - table_id, VTY_NEWLINE); - return CMD_WARNING; - } - - if (is_zebra_main_routing_table(table_id)) - { - vty_out(vty, "Invalid routing table ID, %d. Must be non-default table%s", - table_id, VTY_NEWLINE); - return CMD_WARNING; - } - - if (argc > 1) - VTY_GET_INTEGER_RANGE("distance", distance, argv[1], 1, 255); - return (zebra_import_table(AFI_IP, table_id, distance, NULL, 1)); - -} - -ALIAS (ip_zebra_import_table_distance, - ip_zebra_import_table_cmd, - "ip import-table <1-252>", - IP_STR - "import routes from non-main kernel table\n" - "kernel routing table id\n") - -DEFUN (ip_zebra_import_table_distance_routemap, - ip_zebra_import_table_distance_routemap_cmd, - "ip import-table <1-252> distance <1-255> route-map WORD", + "ip import-table (1-252) [distance (1-255)] [route-map WORD]", IP_STR "import routes from non-main kernel table\n" "kernel routing table id\n" @@ -5964,11 +3840,13 @@ DEFUN (ip_zebra_import_table_distance_routemap, "route-map name\n") { u_int32_t table_id = 0; - int distance = ZEBRA_TABLE_DISTANCE_DEFAULT; - const char *rmap_name; - if (argc) - VTY_GET_INTEGER("table", table_id, argv[0]); + VTY_GET_INTEGER("table", table_id, argv[2]->arg); + int distance = ZEBRA_TABLE_DISTANCE_DEFAULT; + char *rmap = strmatch (argv[argc - 2]->text, "route-map") ? + XSTRDUP(MTYPE_ROUTE_MAP_NAME, argv[argc - 1]->arg) : NULL; + if (argc == 7 || (argc == 5 && !rmap)) + VTY_GET_INTEGER_RANGE("distance", distance, argv[4]->arg, 1, 255); if (!is_zebra_valid_kernel_table(table_id)) { @@ -5980,42 +3858,23 @@ DEFUN (ip_zebra_import_table_distance_routemap, if (is_zebra_main_routing_table(table_id)) { vty_out(vty, "Invalid routing table ID, %d. Must be non-default table%s", - table_id, VTY_NEWLINE); + table_id, VTY_NEWLINE); return CMD_WARNING; } - if (argc > 2) - { - VTY_GET_INTEGER_RANGE("distance", distance, argv[1], 1, 255); - rmap_name = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[2]); - } - else - rmap_name = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]); - - return (zebra_import_table(AFI_IP, table_id, distance, rmap_name, 1)); + return (zebra_import_table(AFI_IP, table_id, distance, rmap, 1)); } -ALIAS (ip_zebra_import_table_distance_routemap, - ip_zebra_import_table_routemap_cmd, - "ip import-table <1-252> route-map WORD", - IP_STR - "import routes from non-main kernel table\n" - "kernel routing table id\n" - "route-map for filtering\n" - "route-map name\n") - DEFUN (no_ip_zebra_import_table, no_ip_zebra_import_table_cmd, - "no ip import-table <1-252> {route-map NAME}", + "no ip import-table (1-252) [distance (1-255)] [route-map NAME]", NO_STR IP_STR "import routes from non-main kernel table\n" "kernel routing table id\n") { u_int32_t table_id = 0; - - if (argc) - VTY_GET_INTEGER("table", table_id, argv[0]); + VTY_GET_INTEGER("table", table_id, argv[3]->arg); if (!is_zebra_valid_kernel_table(table_id)) { @@ -6037,14 +3896,6 @@ DEFUN (no_ip_zebra_import_table, return (zebra_import_table(AFI_IP, table_id, 0, NULL, 0)); } -ALIAS (no_ip_zebra_import_table, - no_ip_zebra_import_table_distance_cmd, - "no ip import-table <1-252> distance <1-255> {route-map NAME}", - IP_STR - "import routes from non-main kernel table to main table" - "kernel routing table id\n" - "distance to be used\n") - static int config_write_protocol (struct vty *vty) { @@ -6086,77 +3937,30 @@ zebra_vty_init (void) install_element (CONFIG_NODE, &allow_external_route_update_cmd); install_element (CONFIG_NODE, &no_allow_external_route_update_cmd); - install_element (CONFIG_NODE, &ip_mroute_cmd); install_element (CONFIG_NODE, &ip_mroute_dist_cmd); - install_element (CONFIG_NODE, &no_ip_mroute_cmd); install_element (CONFIG_NODE, &no_ip_mroute_dist_cmd); install_element (CONFIG_NODE, &ip_multicast_mode_cmd); install_element (CONFIG_NODE, &no_ip_multicast_mode_cmd); - install_element (CONFIG_NODE, &no_ip_multicast_mode_noarg_cmd); install_element (CONFIG_NODE, &ip_route_cmd); - install_element (CONFIG_NODE, &ip_route_tag_cmd); install_element (CONFIG_NODE, &ip_route_flags_cmd); - install_element (CONFIG_NODE, &ip_route_flags_tag_cmd); install_element (CONFIG_NODE, &ip_route_flags2_cmd); - install_element (CONFIG_NODE, &ip_route_flags2_tag_cmd); install_element (CONFIG_NODE, &ip_route_mask_cmd); - install_element (CONFIG_NODE, &ip_route_mask_tag_cmd); install_element (CONFIG_NODE, &ip_route_mask_flags_cmd); - install_element (CONFIG_NODE, &ip_route_mask_flags_tag_cmd); install_element (CONFIG_NODE, &ip_route_mask_flags2_cmd); - install_element (CONFIG_NODE, &ip_route_mask_flags2_tag_cmd); install_element (CONFIG_NODE, &no_ip_route_cmd); - install_element (CONFIG_NODE, &no_ip_route_tag_cmd); - install_element (CONFIG_NODE, &no_ip_route_flags_cmd); - install_element (CONFIG_NODE, &no_ip_route_flags_tag_cmd); install_element (CONFIG_NODE, &no_ip_route_flags2_cmd); - install_element (CONFIG_NODE, &no_ip_route_flags2_tag_cmd); install_element (CONFIG_NODE, &no_ip_route_mask_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_tag_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_flags_tag_cmd); install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_flags2_tag_cmd); - install_element (CONFIG_NODE, &ip_route_distance_cmd); - install_element (CONFIG_NODE, &ip_route_tag_distance_cmd); - install_element (CONFIG_NODE, &ip_route_flags_distance_cmd); - install_element (CONFIG_NODE, &ip_route_flags_tag_distance_cmd); - install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd); - install_element (CONFIG_NODE, &ip_route_flags_tag_distance2_cmd); - install_element (CONFIG_NODE, &ip_route_mask_distance_cmd); - install_element (CONFIG_NODE, &ip_route_mask_tag_distance_cmd); - install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd); - install_element (CONFIG_NODE, &ip_route_mask_flags_tag_distance_cmd); - install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_cmd); - install_element (CONFIG_NODE, &ip_route_mask_flags_tag_distance2_cmd); - install_element (CONFIG_NODE, &no_ip_route_distance_cmd); - install_element (CONFIG_NODE, &no_ip_route_tag_distance_cmd); - install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd); - install_element (CONFIG_NODE, &no_ip_route_flags_tag_distance_cmd); - install_element (CONFIG_NODE, &no_ip_route_flags_distance2_cmd); - install_element (CONFIG_NODE, &no_ip_route_flags_tag_distance2_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_distance_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_tag_distance_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_flags_tag_distance_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_flags_tag_distance2_cmd); - install_element (CONFIG_NODE, &ip_zebra_import_table_cmd); install_element (CONFIG_NODE, &ip_zebra_import_table_distance_cmd); - install_element (CONFIG_NODE, &ip_zebra_import_table_routemap_cmd); - install_element (CONFIG_NODE, &ip_zebra_import_table_distance_routemap_cmd); install_element (CONFIG_NODE, &no_ip_zebra_import_table_cmd); - install_element (CONFIG_NODE, &no_ip_zebra_import_table_distance_cmd); install_element (VIEW_NODE, &show_vrf_cmd); install_element (VIEW_NODE, &show_ip_route_cmd); install_element (VIEW_NODE, &show_ip_route_ospf_instance_cmd); install_element (VIEW_NODE, &show_ip_route_tag_cmd); install_element (VIEW_NODE, &show_ip_nht_cmd); - install_element (VIEW_NODE, &show_ip_nht_vrf_cmd); install_element (VIEW_NODE, &show_ip_nht_vrf_all_cmd); install_element (VIEW_NODE, &show_ipv6_nht_cmd); - install_element (VIEW_NODE, &show_ipv6_nht_vrf_cmd); install_element (VIEW_NODE, &show_ipv6_nht_vrf_all_cmd); install_element (VIEW_NODE, &show_ip_route_addr_cmd); install_element (VIEW_NODE, &show_ip_route_prefix_cmd); @@ -6171,64 +3975,11 @@ zebra_vty_init (void) /* Commands for VRF */ - install_element (CONFIG_NODE, &ip_route_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_tag_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_flags_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_flags_tag_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_flags2_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_flags2_tag_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_mask_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_mask_tag_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_mask_flags_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_mask_flags_tag_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_mask_flags2_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_mask_flags2_tag_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_tag_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_flags_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_flags_tag_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_flags2_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_flags2_tag_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_tag_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_flags_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_flags_tag_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_flags2_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_flags2_tag_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_distance_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_tag_distance_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_flags_distance_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_flags_tag_distance_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_flags_distance2_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_flags_tag_distance2_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_mask_distance_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_mask_tag_distance_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_mask_flags_distance_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_mask_flags_tag_distance_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_vrf_cmd); - install_element (CONFIG_NODE, &ip_route_mask_flags_tag_distance2_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_distance_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_tag_distance_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_flags_distance_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_flags_tag_distance_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_flags_distance2_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_flags_tag_distance2_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_distance_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_tag_distance_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_flags_tag_distance_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_vrf_cmd); - install_element (CONFIG_NODE, &no_ip_route_mask_flags_tag_distance2_vrf_cmd); + install_element (CONFIG_NODE, &no_ip_route_flags_cmd); + install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd); install_element (VIEW_NODE, &show_ip_route_vrf_cmd); - install_element (VIEW_NODE, &show_ip_route_vrf_addr_cmd); - install_element (VIEW_NODE, &show_ip_route_vrf_tag_cmd); - install_element (VIEW_NODE, &show_ip_route_vrf_prefix_cmd); - install_element (VIEW_NODE, &show_ip_route_vrf_prefix_longer_cmd); - install_element (VIEW_NODE, &show_ip_route_vrf_protocol_cmd); - install_element (VIEW_NODE, &show_ip_route_vrf_supernets_cmd); - install_element (VIEW_NODE, &show_ip_route_vrf_summary_cmd); - install_element (VIEW_NODE, &show_ip_route_vrf_summary_prefix_cmd); + install_element (VIEW_NODE, &show_ip_route_vrf_cmd); install_element (VIEW_NODE, &show_ip_route_vrf_all_cmd); install_element (VIEW_NODE, &show_ip_route_vrf_all_tag_cmd); @@ -6240,7 +3991,6 @@ zebra_vty_init (void) install_element (VIEW_NODE, &show_ip_route_vrf_all_summary_cmd); install_element (VIEW_NODE, &show_ip_route_vrf_all_summary_prefix_cmd); -#ifdef HAVE_IPV6 install_element (CONFIG_NODE, &ipv6_route_cmd); install_element (CONFIG_NODE, &ipv6_route_flags_cmd); install_element (CONFIG_NODE, &ipv6_route_ifname_cmd); @@ -6249,30 +3999,6 @@ zebra_vty_init (void) install_element (CONFIG_NODE, &no_ipv6_route_flags_cmd); install_element (CONFIG_NODE, &no_ipv6_route_ifname_cmd); install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd); - install_element (CONFIG_NODE, &ipv6_route_pref_cmd); - install_element (CONFIG_NODE, &ipv6_route_flags_pref_cmd); - install_element (CONFIG_NODE, &ipv6_route_ifname_pref_cmd); - install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_pref_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_cmd); - install_element (CONFIG_NODE, &ipv6_route_tag_cmd); - install_element (CONFIG_NODE, &ipv6_route_flags_tag_cmd); - install_element (CONFIG_NODE, &ipv6_route_ifname_tag_cmd); - install_element (CONFIG_NODE, &ipv6_route_ifname_flags_tag_cmd); - install_element (CONFIG_NODE, &ipv6_route_pref_tag_cmd); - install_element (CONFIG_NODE, &ipv6_route_flags_pref_tag_cmd); - install_element (CONFIG_NODE, &ipv6_route_ifname_pref_tag_cmd); - install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_tag_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_tag_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_flags_tag_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_ifname_tag_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_tag_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_pref_tag_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_tag_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_tag_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_tag_cmd); install_element (CONFIG_NODE, &ip_nht_default_route_cmd); install_element (CONFIG_NODE, &no_ip_nht_default_route_cmd); install_element (CONFIG_NODE, &ipv6_nht_default_route_cmd); @@ -6289,50 +4015,6 @@ zebra_vty_init (void) install_element (VIEW_NODE, &show_ipv6_mroute_cmd); /* Commands for VRF */ - - install_element (CONFIG_NODE, &ipv6_route_vrf_cmd); - install_element (CONFIG_NODE, &ipv6_route_flags_vrf_cmd); - install_element (CONFIG_NODE, &ipv6_route_ifname_vrf_cmd); - install_element (CONFIG_NODE, &ipv6_route_ifname_flags_vrf_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_vrf_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_flags_vrf_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_ifname_vrf_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_vrf_cmd); - install_element (CONFIG_NODE, &ipv6_route_pref_vrf_cmd); - install_element (CONFIG_NODE, &ipv6_route_flags_pref_vrf_cmd); - install_element (CONFIG_NODE, &ipv6_route_ifname_pref_vrf_cmd); - install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_vrf_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_pref_vrf_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_vrf_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_vrf_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_vrf_cmd); - install_element (CONFIG_NODE, &ipv6_route_tag_vrf_cmd); - install_element (CONFIG_NODE, &ipv6_route_flags_tag_vrf_cmd); - install_element (CONFIG_NODE, &ipv6_route_ifname_tag_vrf_cmd); - install_element (CONFIG_NODE, &ipv6_route_ifname_flags_tag_vrf_cmd); - install_element (CONFIG_NODE, &ipv6_route_pref_tag_vrf_cmd); - install_element (CONFIG_NODE, &ipv6_route_flags_pref_tag_vrf_cmd); - install_element (CONFIG_NODE, &ipv6_route_ifname_pref_tag_vrf_cmd); - install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_tag_vrf_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_tag_vrf_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_flags_tag_vrf_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_ifname_tag_vrf_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_tag_vrf_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_pref_tag_vrf_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_tag_vrf_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_tag_vrf_cmd); - install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_tag_vrf_cmd); - - - install_element (VIEW_NODE, &show_ipv6_route_vrf_cmd); - install_element (VIEW_NODE, &show_ipv6_route_vrf_tag_cmd); - install_element (VIEW_NODE, &show_ipv6_route_vrf_summary_cmd); - install_element (VIEW_NODE, &show_ipv6_route_vrf_summary_prefix_cmd); - install_element (VIEW_NODE, &show_ipv6_route_vrf_protocol_cmd); - install_element (VIEW_NODE, &show_ipv6_route_vrf_addr_cmd); - install_element (VIEW_NODE, &show_ipv6_route_vrf_prefix_cmd); - install_element (VIEW_NODE, &show_ipv6_route_vrf_prefix_longer_cmd); - install_element (VIEW_NODE, &show_ipv6_route_vrf_all_cmd); install_element (VIEW_NODE, &show_ipv6_route_vrf_all_tag_cmd); install_element (VIEW_NODE, &show_ipv6_route_vrf_all_summary_cmd); @@ -6342,8 +4024,5 @@ zebra_vty_init (void) install_element (VIEW_NODE, &show_ipv6_route_vrf_all_prefix_cmd); install_element (VIEW_NODE, &show_ipv6_route_vrf_all_prefix_longer_cmd); - install_element (VIEW_NODE, &show_ipv6_mroute_vrf_cmd); - install_element (VIEW_NODE, &show_ipv6_mroute_vrf_all_cmd); -#endif /* HAVE_IPV6 */ } diff --git a/zebra/zserv.c b/zebra/zserv.c index 0b69af5124..cb396942a1 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -742,28 +742,28 @@ zsend_redistribute_route (int add, struct zserv *client, struct prefix *p, /* ldpd needs all nexthops */ if (client->proto != ZEBRA_ROUTE_LDP) - break; + break; } } /* Distance */ - SET_FLAG (zapi_flags, ZAPI_MESSAGE_DISTANCE); - stream_putc (s, rib->distance); + SET_FLAG (zapi_flags, ZAPI_MESSAGE_DISTANCE); + stream_putc (s, rib->distance); /* Metric */ - SET_FLAG (zapi_flags, ZAPI_MESSAGE_METRIC); - stream_putl (s, rib->metric); + SET_FLAG (zapi_flags, ZAPI_MESSAGE_METRIC); + stream_putl (s, rib->metric); /* Tag */ - if (rib->tag) - { - SET_FLAG(zapi_flags, ZAPI_MESSAGE_TAG); + if (rib->tag) + { + SET_FLAG(zapi_flags, ZAPI_MESSAGE_TAG); stream_putl(s, rib->tag); - } + } /* MTU */ - SET_FLAG (zapi_flags, ZAPI_MESSAGE_MTU); - stream_putl (s, rib->mtu); + SET_FLAG (zapi_flags, ZAPI_MESSAGE_MTU); + stream_putl (s, rib->mtu); /* write real message flags value */ stream_putc_at (s, messmark, zapi_flags); @@ -2366,19 +2366,19 @@ DEFUN (show_table, return CMD_SUCCESS; } -DEFUN (config_table, +DEFUN (config_table, config_table_cmd, "table TABLENO", "Configure target kernel routing table\n" "TABLE integer\n") { - zebrad.rtm_table_default = strtol (argv[0], (char**)0, 10); + zebrad.rtm_table_default = strtol (argv[1]->arg, (char**)0, 10); return CMD_SUCCESS; } DEFUN (no_config_table, no_config_table_cmd, - "no table TABLENO", + "no table [TABLENO]", NO_STR "Configure target kernel routing table\n" "TABLE integer\n") @@ -2435,7 +2435,7 @@ DEFUN (show_zebra_client, show_zebra_client_cmd, "show zebra client", SHOW_STR - "Zebra information" + "Zebra information\n" "Client information") { struct listnode *node; diff --git a/zebra/zserv.h b/zebra/zserv.h index ce243dd6ac..a0434d299b 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -25,10 +25,10 @@ #include "rib.h" #include "if.h" #include "workqueue.h" +#include "vrf.h" #include "routemap.h" #include "vty.h" #include "zclient.h" -#include "vrf.h" #include "zebra/zebra_ns.h" /* Default port information. */ diff --git a/zebra/zserv_null.c b/zebra/zserv_null.c index acab22d96f..4b52abb222 100644 --- a/zebra/zserv_null.c +++ b/zebra/zserv_null.c @@ -23,6 +23,7 @@ #include <zebra.h> #include <vrf.h> +#include <vty.h> #include <zserv.h> #include <zebra_ns.h> |
