From 5bf159563c128a4110341949962e5258db3b309c Mon Sep 17 00:00:00 2001 From: Daniel Walton Date: Mon, 26 Sep 2016 04:59:47 +0000 Subject: [PATCH] bgpd: bgp_vty.c compiles now Signed-off-by: Daniel Walton --- bgpd/bgp_bfd.c | 44 +- bgpd/bgp_encap.c | 74 ++- bgpd/bgp_encap_tlv.c | 1 + bgpd/bgp_vty.c | 1097 ++++++++++-------------------------------- 4 files changed, 317 insertions(+), 899 deletions(-) diff --git a/bgpd/bgp_bfd.c b/bgpd/bgp_bfd.c index b2863736ce..7bc902ef92 100644 --- a/bgpd/bgp_bfd.c +++ b/bgpd/bgp_bfd.c @@ -560,10 +560,11 @@ DEFUN (neighbor_bfd, 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; @@ -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; @@ -616,17 +621,19 @@ DEFUN_HIDDEN (neighbor_bfd_type, "Enables BFD support\n" "Session type\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; @@ -638,30 +645,22 @@ DEFUN_HIDDEN (neighbor_bfd_type, return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no neighbor bfd (2-255) (50-60000) (50-60000)", - * 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 (no_neighbor_bfd, no_neighbor_bfd_cmd, - "no neighbor bfd", + "no neighbor 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; @@ -682,10 +681,11 @@ DEFUN_HIDDEN (no_neighbor_bfd_type, "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; diff --git a/bgpd/bgp_encap.c b/bgpd/bgp_encap.c index 0c7657f8bb..f739e81b67 100644 --- a/bgpd/bgp_encap.c +++ b/bgpd/bgp_encap.c @@ -257,7 +257,10 @@ DEFUN (encap_network, "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. */ @@ -272,7 +275,10 @@ DEFUN (no_encap_network, "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 @@ -534,10 +540,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); @@ -557,10 +564,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); @@ -606,10 +614,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); @@ -629,10 +638,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); @@ -653,13 +663,14 @@ 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; - su = sockunion_str2su (argv[0]); + su = sockunion_str2su (argv[idx_peer]->arg); if (su == NULL) { - 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; } @@ -684,13 +695,14 @@ 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; - su = sockunion_str2su (argv[0]); + su = sockunion_str2su (argv[idx_peer]->arg); if (su == NULL) { - 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; } @@ -719,22 +731,24 @@ 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; } - su = sockunion_str2su (argv[1]); + su = sockunion_str2su (argv[idx_peer]->arg); if (su == NULL) { - 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; } @@ -762,22 +776,24 @@ 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; } - su = sockunion_str2su (argv[1]); + su = sockunion_str2su (argv[idx_peer]->arg); if (su == NULL) { - 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; } @@ -803,14 +819,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); @@ -834,14 +851,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); @@ -869,15 +887,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); @@ -887,7 +907,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); @@ -911,15 +931,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); @@ -929,7 +951,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 347b4b3ce7..87aa0ceac5 100644 --- a/bgpd/bgp_encap_tlv.c +++ b/bgpd/bgp_encap_tlv.c @@ -19,6 +19,7 @@ #include +#include "command.h" #include "memory.h" #include "prefix.h" #include "vty.h" diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index ae56fd05d3..2fd75baeff 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -6220,6 +6220,40 @@ bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str, return CMD_SUCCESS; } +static void +bgp_get_argv_afi_safi (struct cmd_token **argv, int idx_afi, int idx_safi, + afi_t *afi, safi_t *safi) +{ + if (strmatch(argv[idx_afi]->text, "ipv4")) + { + *afi = AFI_IP; + + if (strmatch(argv[idx_safi]->text, "unicast")) + *safi = SAFI_UNICAST; + else if (strmatch(argv[idx_safi]->text, "multicast")) + *safi = SAFI_MULTICAST; + } + else if (strmatch(argv[idx_afi]->text, "ipv6")) + { + *afi = AFI_IP6; + + if (strmatch(argv[idx_safi]->text, "unicast")) + *safi = SAFI_UNICAST; + else if (strmatch(argv[idx_safi]->text, "multicast")) + *safi = SAFI_MULTICAST; + } + else if (strmatch(argv[idx_afi]->text, "encap")) + { + *afi = AFI_IP; + *safi = SAFI_ENCAP; + } + else if (strmatch(argv[idx_afi]->text, "vpnv4")) + { + *afi = AFI_IP; + *safi = SAFI_MPLS_VPN; + } +} + /* one clear bgp command to rule them all */ DEFUN (clear_ip_bgp_all, clear_ip_bgp_all_cmd, @@ -6266,7 +6300,7 @@ DEFUN (clear_ip_bgp_all, char *vrf = NULL; afi_t afi; safi_t safi; - enum clear_sort clr_sort; + enum clear_sort clr_sort = clear_peer; enum bgp_clear_type clr_type; char *clr_arg = NULL; @@ -6395,34 +6429,7 @@ DEFUN (clear_ip_bgp_all, } /* afi safi */ - if (strmatch(argv[idx_afi]->text, "ipv4")) - { - afi = AFI_IP; - - if (strmatch(argv[idx_safi]->text, "unicast")) - safi = SAFI_UNICAST; - else if (strmatch(argv[idx_safi]->text, "multicast")) - safi = SAFI_MULTICAST; - } - else if (strmatch(argv[idx_afi]->text, "ipv6")) - { - afi = AFI_IP6; - - if (strmatch(argv[idx_safi]->text, "unicast")) - safi = SAFI_UNICAST; - else if (strmatch(argv[idx_safi]->text, "multicast")) - safi = SAFI_MULTICAST; - } - else if (strmatch(argv[idx_afi]->text, "encap")) - { - afi = AFI_IP; - safi = SAFI_ENCAP; - } - else if (strmatch(argv[idx_afi]->text, "vpnv4")) - { - afi = AFI_IP; - safi = SAFI_MPLS_VPN; - } + bgp_get_argv_afi_safi (argv, idx_afi, idx_safi, &afi, &safi); return bgp_clear_vty (vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); } @@ -7237,34 +7244,7 @@ DEFUN (show_ip_bgp_summary, } /* afi safi */ - if (strmatch(argv[idx_afi]->text, "ipv4")) - { - afi = AFI_IP; - - if (strmatch(argv[idx_safi]->text, "unicast")) - safi = SAFI_UNICAST; - else if (strmatch(argv[idx_safi]->text, "multicast")) - safi = SAFI_MULTICAST; - } - else if (strmatch(argv[idx_afi]->text, "ipv6")) - { - afi = AFI_IP6; - - if (strmatch(argv[idx_safi]->text, "unicast")) - safi = SAFI_UNICAST; - else if (strmatch(argv[idx_safi]->text, "multicast")) - safi = SAFI_MULTICAST; - } - else if (strmatch(argv[idx_afi]->text, "encap")) - { - afi = AFI_IP; - safi = SAFI_ENCAP; - } - else if (strmatch(argv[idx_afi]->text, "vpnv4")) - { - afi = AFI_IP; - safi = SAFI_MPLS_VPN; - } + bgp_get_argv_afi_safi (argv, idx_afi, idx_safi, &afi, &safi); return bgp_show_summary_vty (vty, vrf, afi, safi, uj); } @@ -9009,14 +8989,14 @@ bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type, 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) + enum show_type type, const char *ip_str, u_char use_json) { int ret; struct bgp *bgp; union sockunion su; + json_object *json = NULL; - if (use_json && (json == NULL)) + if (use_json) json = json_object_new_object(); if (name) @@ -9115,184 +9095,61 @@ bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json) } /* "show ip bgp neighbors" commands. */ -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "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" - * - * "show bgp neighbors [json]", - * SHOW_STR - * BGP_STR - * "Detailed information on TCP and BGP neighbor connections\n" - * "JavaScript Object Notation\n" - * - * "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" - * - * "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" - * - * "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" - * - */ 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") -{ - u_char uj = use_json(argc, argv); - - return bgp_show_neighbor_vty (vty, NULL, show_all, NULL, uj, NULL); -} - - - - - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "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" - * - * "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn 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" - * - * "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" - * - * "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) [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" - * "JavaScript Object Notation\n" - * - * "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" - * - */ -DEFUN (show_ip_bgp_neighbors_peer, - show_ip_bgp_neighbors_peer_cmd, - "show ip bgp neighbors [json]", + "show [ip] bgp [ WORD] [] neighbors [] [json]", SHOW_STR IP_STR BGP_STR + 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") { - u_char uj = use_json(argc, argv); - - return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 2], uj, NULL); -} - + int idx_ip = 1; + int idx_view_vrf = 3; + int idx_vrf = 4; + int idx_peer; + char *vrf = NULL; + char *sh_arg = NULL; + enum show_type sh_type; + u_char uj = use_json(argc, argv); + if (!strmatch(argv[idx_ip]->text, "ip")) + { + idx_view_vrf--; + idx_vrf--; + } + if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf")) + vrf = argv[idx_vrf]->arg; + if (uj) + idx_peer = argc - 2; + else + idx_peer = argc - 1; -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp WORD neighbors [json]", - * SHOW_STR - * BGP_STR - * BGP_INSTANCE_HELP_STR - * "Detailed information on TCP and BGP neighbor connections\n" - * "JavaScript Object Notation\n" - * - * "show bgp WORD 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, - show_ip_bgp_instance_neighbors_cmd, - "show ip bgp WORD 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") -{ - int idx_word = 4; - u_char uj = use_json(argc, argv); + if (strmatch(argv[idx_peer]->text, "neighbors")) + { + sh_type = show_all; + } + else + { + sh_type = show_peer; + sh_arg = argv[idx_peer]->arg; + } - return bgp_show_neighbor_vty (vty, argv[idx_word]->arg, show_all, NULL, uj, NULL); + return bgp_show_neighbor_vty (vty, vrf, sh_type, sh_arg, uj); } DEFUN (show_ip_bgp_instance_all_neighbors, show_ip_bgp_instance_all_neighbors_cmd, - "show ip bgp all neighbors [json]", + "show [ip] bgp all neighbors [json]", SHOW_STR IP_STR BGP_STR @@ -9306,54 +9163,6 @@ DEFUN (show_ip_bgp_instance_all_neighbors, return CMD_SUCCESS; } - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp WORD 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 WORD 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" - * - */ -DEFUN (show_ip_bgp_instance_neighbors_peer, - show_ip_bgp_instance_neighbors_peer_cmd, - "show ip bgp WORD neighbors [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") -{ - int idx_word = 4; - int idx_peer = 6; - u_char uj = use_json(argc, argv); - - return bgp_show_neighbor_vty (vty, argv[idx_word]->arg, show_peer, argv[idx_peer]->arg, uj, NULL); -} - - - /* 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.*/ @@ -9464,26 +9273,72 @@ 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") -{ - return (bgp_show_update_groups(vty, NULL, AFI_IP, SAFI_UNICAST, 0)); -} - -DEFUN (show_ip_bgp_instance_updgrps, - show_ip_bgp_instance_updgrps_cmd, - "show ip bgp WORD update-groups", + "show [ip] bgp [ WORD] [] update-groups [SUBGROUP-ID]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "Detailed info about dynamic update groups\n") + "Address family\n" + "Address Family modifier\n" + "Address family\n" + "Address Family modifier\n" + "Address family\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") { - int idx_word = 4; - return (bgp_show_update_groups(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0)); + int idx_ip = 1; + int idx_view_vrf = 3; + int idx_vrf = 4; + int idx_afi; + int idx_safi; + int idx_subgroup_id = argc - 1; + char *vrf = NULL; + afi_t afi; + safi_t safi; + uint64_t subgrp_id = 0; + + /* + * If the user does "show ip bgp" then we default the afi safi to ipv4 unicast. + * If the user does "show bgp" then we default the afi safi to ipv6 unicast. + * This may be over-written later in the command if they explicitly + * specify an afi safi. + */ + if (strmatch(argv[idx_ip]->text, "ip")) + { + afi = AFI_IP; + safi = SAFI_UNICAST; + } + else + { + afi = AFI_IP6; + safi = SAFI_UNICAST; + idx_view_vrf--; + idx_vrf--; + } + + if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf")) + vrf = argv[idx_vrf]->arg; + + if (strmatch(argv[idx_subgroup_id]->text, "update-groups")) + { + idx_afi = idx_subgroup_id - 2; + idx_safi = idx_subgroup_id - 1; + } + else + { + VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); + idx_afi = idx_subgroup_id - 3; + idx_safi = idx_subgroup_id - 2; + } + + bgp_get_argv_afi_safi (argv, idx_afi, idx_safi, &afi, &safi); + + return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); } DEFUN (show_ip_bgp_instance_all_updgrps, @@ -9499,28 +9354,6 @@ DEFUN (show_ip_bgp_instance_all_updgrps, 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 WORD update-groups", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Detailed info about v6 dynamic update groups\n") -{ - int idx_word = 3; - return (bgp_show_update_groups(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, 0)); -} - DEFUN (show_bgp_instance_all_ipv6_updgrps, show_bgp_instance_all_ipv6_updgrps_cmd, "show bgp all update-groups", @@ -9533,116 +9366,9 @@ DEFUN (show_bgp_instance_all_ipv6_updgrps, return CMD_SUCCESS; } -DEFUN (show_bgp_updgrps, - show_bgp_updgrps_cmd, - "show bgp update-groups", - SHOW_STR - BGP_STR - "Address family\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Detailed info about dynamic update groups\n") -{ - int idx_afi = 2; - int idx_safi = 3; - afi_t afi; - safi_t safi; - - 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; - 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 WORD update-groups SUBGROUP-ID", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Detailed info about dynamic update groups\n" - "Specific subgroup to display detailed info for\n") -{ - int idx_word = 4; - uint64_t subgrp_id; - - VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); - return (bgp_show_update_groups(vty, argv[idx_word]->arg, 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)); -} - -DEFUN (show_bgp_instance_ipv6_updgrps_s, - show_bgp_instance_ipv6_updgrps_s_cmd, - "show bgp WORD update-groups SUBGROUP-ID", - SHOW_STR - BGP_STR - "Detailed info about v6 dynamic update groups\n" - "Specific subgroup to display detailed info for\n") -{ - int idx_word = 3; - uint64_t subgrp_id; - - VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); - return(bgp_show_update_groups(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, subgrp_id)); -} - -DEFUN (show_bgp_updgrps_s, - show_bgp_updgrps_s_cmd, - "show bgp update-groups SUBGROUP-ID", - 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") -{ - int idx_afi = 2; - int idx_safi = 3; - afi_t afi; - safi_t safi; - uint64_t subgrp_id; - - 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; - - VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); - return(bgp_show_update_groups(vty, NULL, afi, safi, subgrp_id)); -} - -DEFUN (show_bgp_updgrps_stats, - show_bgp_updgrps_stats_cmd, - "show bgp update-groups statistics", +DEFUN (show_bgp_updgrps_stats, + show_bgp_updgrps_stats_cmd, + "show bgp update-groups statistics", SHOW_STR BGP_STR "BGP update groups\n" @@ -9807,12 +9533,13 @@ DEFUN (show_ip_bgp_updgrps_adj_s, "Packet queue\n") { + int idx_subgroup_id = 4; int idx_type = 5; uint64_t subgrp_id; - VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_type]->arg); + 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; } @@ -9830,13 +9557,14 @@ DEFUN (show_ip_bgp_instance_updgrps_adj_s, "Packet queue\n") { - int idx_word = 4; + 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[idx_type]->arg); + VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); - show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, 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; } @@ -9858,16 +9586,17 @@ DEFUN (show_bgp_updgrps_afi_adj_s, { 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[idx_afi]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6; - safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; - VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_type]->arg); + 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; } @@ -9882,12 +9611,13 @@ DEFUN (show_bgp_updgrps_adj_s, "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[idx_type]->arg); + 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; } @@ -9903,13 +9633,14 @@ DEFUN (show_bgp_instance_updgrps_adj_s, "Announced routes\n" "Packet queue\n") { - int idx_word = 3; + 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[idx_type]->arg); + VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); - show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, 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; } @@ -11785,17 +11516,8 @@ bgp_vty_init (void) /* "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); @@ -11809,17 +11531,8 @@ bgp_vty_init (void) install_element (VIEW_NODE, &show_ip_bgp_instance_all_summary_cmd); install_element (RESTRICTED_NODE, &show_ip_bgp_summary_cmd); install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_cmd); install_element (RESTRICTED_NODE, &show_ip_bgp_instance_all_updgrps_cmd); - install_element (RESTRICTED_NODE, &show_bgp_updgrps_cmd); - install_element (RESTRICTED_NODE, &show_bgp_ipv6_updgrps_cmd); - install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_updgrps_cmd); install_element (RESTRICTED_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_s_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_s_cmd); - install_element (RESTRICTED_NODE, &show_bgp_updgrps_s_cmd); - install_element (RESTRICTED_NODE, &show_bgp_ipv6_updgrps_s_cmd); - install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_updgrps_s_cmd); install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_adj_cmd); install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); install_element (RESTRICTED_NODE, &show_bgp_updgrps_adj_cmd); @@ -11833,17 +11546,8 @@ bgp_vty_init (void) install_element (RESTRICTED_NODE, &show_ip_bgp_instance_all_summary_cmd); install_element (ENABLE_NODE, &show_ip_bgp_summary_cmd); install_element (ENABLE_NODE, &show_ip_bgp_updgrps_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_cmd); install_element (ENABLE_NODE, &show_ip_bgp_instance_all_updgrps_cmd); - install_element (ENABLE_NODE, &show_bgp_updgrps_cmd); - install_element (ENABLE_NODE, &show_bgp_ipv6_updgrps_cmd); - install_element (ENABLE_NODE, &show_bgp_instance_ipv6_updgrps_cmd); install_element (ENABLE_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_updgrps_s_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_s_cmd); - install_element (ENABLE_NODE, &show_bgp_updgrps_s_cmd); - install_element (ENABLE_NODE, &show_bgp_ipv6_updgrps_s_cmd); - install_element (ENABLE_NODE, &show_bgp_instance_ipv6_updgrps_s_cmd); install_element (ENABLE_NODE, &show_ip_bgp_updgrps_adj_cmd); install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); install_element (ENABLE_NODE, &show_bgp_updgrps_adj_cmd); @@ -11858,17 +11562,9 @@ bgp_vty_init (void) /* "show ip bgp neighbors" commands. */ install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd); - install_element (VIEW_NODE, &show_ip_bgp_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); - install_element (RESTRICTED_NODE, &show_ip_bgp_neighbors_peer_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_instance_neighbors_peer_cmd); install_element (ENABLE_NODE, &show_ip_bgp_neighbors_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_neighbors_peer_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_cmd); install_element (ENABLE_NODE, &show_ip_bgp_instance_all_neighbors_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_peer_cmd); /* "show ip bgp peer-group" commands. */ install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd); @@ -11994,43 +11690,55 @@ community_list_perror (struct vty *vty, int ret) } } -/* VTY interface for community_set() function. */ +/* "community-list" keyword help string. */ +#define COMMUNITY_LIST_STR "Add a community list entry\n" + static int -community_list_set_vty (struct vty *vty, int argc, const char **argv, - int style, int reject_all_digit_name) +community_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv, + int style) { - int ret; + int idx_number = 2; + int idx_name = 3; + int idx_permit_deny = 4; + int idx_aa_nn = 5; int direct; + int ret; char *str; + char *name; /* Check the list type. */ - if (strncmp (argv[1], "p", 1) == 0) + if (strmatch(argv[idx_permit_deny]->text, "permit")) direct = COMMUNITY_PERMIT; - else if (strncmp (argv[1], "d", 1) == 0) - direct = COMMUNITY_DENY; else + direct = COMMUNITY_DENY; + + if (argv[idx_number]->type == RANGE_TKN) { - vty_out (vty, "%% Matching condition must be permit or deny%s", - VTY_NEWLINE); - return CMD_WARNING; + name = argv[idx_number]->arg; + idx_permit_deny--; + idx_aa_nn--; } - - /* All digit name check. */ - if (reject_all_digit_name && all_digit (argv[0])) + else { - vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE); - return CMD_WARNING; + name = argv[idx_name]->arg; + + /* All digit name check. */ + if (all_digit (name)) + { + 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); + if (argc > idx_aa_nn) + str = argv_concat (argv, argc, idx_aa_nn); else str = NULL; /* When community_list_set() return nevetive value, it means malformed community string. */ - ret = community_list_set (bgp_clist, argv[0], str, direct, style); + ret = community_list_set (bgp_clist, name, str, direct, style); /* Free temporary community list string allocated by argv_concat(). */ @@ -12047,18 +11755,18 @@ 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) +community_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv, + int style) { + /* CHECK ME dwalton finish this int ret; int direct = 0; char *str = NULL; if (argc > 1) { - /* Check the list direct. */ + // Check the list direct. if (strncmp (argv[1], "p", 1) == 0) direct = COMMUNITY_PERMIT; else if (strncmp (argv[1], "d", 1) == 0) @@ -12070,15 +11778,14 @@ community_list_unset_vty (struct vty *vty, int argc, const char **argv, return CMD_WARNING; } - /* Concat community string argument. */ + // Concat community string argument. str = argv_concat (argv, argc, 2); } - /* Unset community list. */ + // 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(). */ + // Free temporary community list string allocated by argv_concat(). if (str) XFREE (MTYPE_TMP, str); @@ -12087,220 +11794,73 @@ community_list_unset_vty (struct vty *vty, int argc, const char **argv, community_list_perror (vty, ret); return CMD_WARNING; } + * */ return CMD_SUCCESS; } -/* "community-list" keyword help string. */ -#define COMMUNITY_LIST_STR "Add a community list entry\n" - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "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" - * - */ +/* ip community-list standard */ DEFUN (ip_community_list_standard, ip_community_list_standard_cmd, - "ip community-list (1-99) .AA:NN", + "ip community-list <(1-99)|standard WORD> [.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); -} - - -DEFUN (ip_community_list_expanded, - ip_community_list_expanded_cmd, - "ip community-list (100-500) .LINE", - 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); -} - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "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" - * - */ -DEFUN (ip_community_list_name_standard, - ip_community_list_name_standard_cmd, - "ip community-list standard WORD .AA:NN", - IP_STR - COMMUNITY_LIST_STR - "Add a standard community-list entry\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) { - return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1); -} - - -DEFUN (ip_community_list_name_expanded, - ip_community_list_name_expanded_cmd, - "ip community-list expanded WORD .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); + return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD); } 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); -} - -DEFUN (no_ip_community_list_standard_direction, - no_ip_community_list_standard_direction_cmd, - "no ip community-list (1-99) ", - 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); -} - - -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_STR - IP_STR - COMMUNITY_LIST_STR - "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) .AA:NN", + "no ip community-list <(1-99)|standard WORD> [ [.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) { - return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0); + return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD); } -DEFUN (no_ip_community_list_expanded, - no_ip_community_list_expanded_cmd, - "no ip community-list (100-500) .LINE", - NO_STR +/* ip community-list expanded */ +DEFUN (ip_community_list_expanded_all, + ip_community_list_expanded_all_cmd, + "ip community-list <(100-500)|expanded WORD> [ [.LINE]]", 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); -} - -DEFUN (no_ip_community_list_name_standard, - no_ip_community_list_name_standard_cmd, - "no ip community-list standard WORD .AA:NN", - NO_STR - IP_STR - COMMUNITY_LIST_STR - "Specify a standard community-list\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_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0); -} - -DEFUN (no_ip_community_list_name_standard_brief, - no_ip_community_list_name_standard_brief_cmd, - "no ip community-list standard WORD ", - 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); + return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED); } -DEFUN (no_ip_community_list_name_expanded, - no_ip_community_list_name_expanded_cmd, - "no ip community-list expanded WORD .LINE", +DEFUN (no_ip_community_list_expanded_all, + no_ip_community_list_expanded_all_cmd, + "no ip community-list <(100-500)|expanded WORD> [ [.LINE]]", NO_STR IP_STR COMMUNITY_LIST_STR - "Specify an expanded community-list\n" + "Community list number (expanded)\n" + "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") + COMMUNITY_VAL_STR) { - return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0); + return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED); } static void @@ -12384,13 +11944,14 @@ DEFUN (show_ip_community_list_arg, static int extcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv, - int style, int reject_all_digit_name) + int style) { + /* CHECK ME dwalton finish this int ret; int direct; char *str; - /* Check the list type. */ + // Check the list type. if (strncmp (argv[1], "p", 1) == 0) direct = COMMUNITY_PERMIT; else if (strncmp (argv[1], "d", 1) == 0) @@ -12402,14 +11963,14 @@ extcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv, return CMD_WARNING; } - /* All digit name check. */ + // 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. */ + // Concat community string argument. if (argc > 1) str = argv_concat (argv, argc, 2); else @@ -12417,8 +11978,7 @@ extcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv, ret = extcommunity_list_set (bgp_clist, argv[0], str, direct, style); - /* Free temporary community list string allocated by - argv_concat(). */ + // Free temporary community list string allocated by argv_concat(). if (str) XFREE (MTYPE_TMP, str); @@ -12427,20 +11987,22 @@ extcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv, community_list_perror (vty, ret); return CMD_WARNING; } + */ return CMD_SUCCESS; } static int extcommunity_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv, - int style, int delete_all) + int style) { + /* CHECK ME dwalton finish this int ret; int direct = 0; char *str = NULL; if (argc > 1) { - /* Check the list direct. */ + // Check the list direct if (strncmp (argv[1], "p", 1) == 0) direct = COMMUNITY_PERMIT; else if (strncmp (argv[1], "d", 1) == 0) @@ -12452,15 +12014,14 @@ extcommunity_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv, return CMD_WARNING; } - /* Concat community string argument. */ + // 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); + // Unset community list. + ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, EXTCOMMUNITY_LIST_STANDARD, delete_all); - /* Free temporary community list string allocated by - argv_concat(). */ + // Free temporary community list string allocated by argv_concat(). if (str) XFREE (MTYPE_TMP, str); @@ -12470,6 +12031,7 @@ extcommunity_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv, return CMD_WARNING; } + */ return CMD_SUCCESS; } @@ -12477,212 +12039,66 @@ extcommunity_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv, #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" -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "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" - * - */ DEFUN (ip_extcommunity_list_standard, ip_extcommunity_list_standard_cmd, - "ip extcommunity-list (1-99) .AA:NN", + "ip extcommunity-list <(1-99)|standard WORD> [.AA:NN]", IP_STR EXTCOMMUNITY_LIST_STR "Extended Community list number (standard)\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); -} - - -DEFUN (ip_extcommunity_list_expanded, - ip_extcommunity_list_expanded_cmd, - "ip extcommunity-list (100-500) .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); -} - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "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" - * - */ -DEFUN (ip_extcommunity_list_name_standard, - ip_extcommunity_list_name_standard_cmd, - "ip extcommunity-list standard WORD .AA:NN", - IP_STR - EXTCOMMUNITY_LIST_STR "Specify standard extcommunity-list\n" - "Extended Community list name\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, 1); + return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD); } - DEFUN (ip_extcommunity_list_name_expanded, ip_extcommunity_list_name_expanded_cmd, - "ip extcommunity-list expanded WORD .LINE", + "ip extcommunity-list <(100-500)|expanded WORD> [.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); + return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED); } 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); -} - -DEFUN (no_ip_extcommunity_list_standard_direction, - no_ip_extcommunity_list_standard_direction_cmd, - "no ip extcommunity-list (1-99) ", + "no ip extcommunity-list <(1-99)|standard WORD> [.AA:NN]", 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); -} - -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); -} - -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); -} - -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); -} - -DEFUN (no_ip_extcommunity_list_standard, - no_ip_extcommunity_list_standard_cmd, - "no ip extcommunity-list (1-99) .AA:NN", - NO_STR - IP_STR - EXTCOMMUNITY_LIST_STR - "Extended Community list number (standard)\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); + return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED); } -DEFUN (no_ip_extcommunity_list_expanded, - no_ip_extcommunity_list_expanded_cmd, - "no ip extcommunity-list (100-500) .LINE", +DEFUN (no_ip_extcommunity_list_expanded_all, + no_ip_extcommunity_list_expanded_all_cmd, + "no ip extcommunity-list <(100-500)|expanded WORD> [.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); -} - -DEFUN (no_ip_extcommunity_list_name_standard, - no_ip_extcommunity_list_name_standard_cmd, - "no ip extcommunity-list standard WORD .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); -} - -DEFUN (no_ip_extcommunity_list_name_standard_brief, - no_ip_extcommunity_list_name_standard_brief_cmd, - "no ip extcommunity-list standard WORD ", - 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); -} - -DEFUN (no_ip_extcommunity_list_name_expanded, - no_ip_extcommunity_list_name_expanded_cmd, - "no ip extcommunity-list expanded WORD .LINE", - NO_STR - IP_STR - EXTCOMMUNITY_LIST_STR "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); + return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED); } static void @@ -12853,19 +12269,8 @@ community_list_vty (void) /* Community-list. */ install_element (CONFIG_NODE, &ip_community_list_standard_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_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); install_element (ENABLE_NODE, &show_ip_community_list_cmd); @@ -12873,21 +12278,11 @@ community_list_vty (void) /* Extcommunity-list. */ install_element (CONFIG_NODE, &ip_extcommunity_list_standard_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_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); install_element (ENABLE_NODE, &show_ip_extcommunity_list_cmd); install_element (ENABLE_NODE, &show_ip_extcommunity_list_arg_cmd); -T } +} -- 2.39.5