static int bgp_table_stats(struct vty *vty, struct bgp *bgp, afi_t afi,
safi_t safi);
-/* BGP route print out function. */
+
+/* BGP route print out function without JSON */
DEFUN (show_ip_bgp,
show_ip_bgp_cmd,
"show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]]\
- [<\
- cidr-only\
- |dampening <flap-statistics|dampened-paths|parameters>\
- |route-map WORD\
- |prefix-list WORD\
- |filter-list WORD\
- |statistics\
- |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]",
+ <dampening <parameters>\
+ |route-map WORD\
+ |prefix-list WORD\
+ |filter-list WORD\
+ |statistics\
+ |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\
+ >",
SHOW_STR
IP_STR
BGP_STR
BGP_INSTANCE_HELP_STR
BGP_AFI_HELP_STR
BGP_SAFI_WITH_LABEL_HELP_STR
- "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 detail of configured dampening parameters\n"
"Display routes matching the route-map\n"
"A route-map to match on\n"
"IPv4 prefix\n"
"Display route and more specific routes\n"
"IPv6 prefix\n"
- "Display route and more specific routes\n"
- JSON_STR)
+ "Display route and more specific routes\n")
{
afi_t afi = AFI_IP6;
safi_t safi = SAFI_UNICAST;
int exact_match = 0;
- enum bgp_show_type sh_type = bgp_show_type_normal;
struct bgp *bgp = NULL;
int idx = 0;
if (!idx)
return CMD_WARNING;
- int uj = use_json(argc, argv);
- if (uj)
- argc--;
-
- if (argv_find(argv, argc, "cidr-only", &idx))
- return bgp_show(vty, bgp, afi, safi, bgp_show_type_cidr_only,
- NULL, uj);
-
if (argv_find(argv, argc, "dampening", &idx)) {
- 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))
+ if (argv_find(argv, argc, "parameters", &idx))
return bgp_show_dampening_parameters(vty, afi, safi);
}
return bgp_show_community(vty, bgp, argc, argv,
exact_match, afi, safi);
}
- /* show all communities */
- else
- return bgp_show(vty, bgp, afi, safi,
- bgp_show_type_community_all, NULL, uj);
}
if (argv_find(argv, argc, "community-list", &idx)) {
safi,
bgp_show_type_prefix_longer);
+ return CMD_WARNING;
+}
+
+/* BGP route print out function with JSON */
+DEFUN (show_ip_bgp_json,
+ show_ip_bgp_json_cmd,
+ "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]]\
+ [<\
+ cidr-only\
+ |dampening <flap-statistics|dampened-paths>\
+ |community \
+ >] [json]",
+ SHOW_STR
+ IP_STR
+ BGP_STR
+ BGP_INSTANCE_HELP_STR
+ BGP_AFI_HELP_STR
+ BGP_SAFI_WITH_LABEL_HELP_STR
+ "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 routes matching the communities\n"
+ JSON_STR)
+{
+ afi_t afi = AFI_IP6;
+ safi_t safi = SAFI_UNICAST;
+ enum bgp_show_type sh_type = bgp_show_type_normal;
+ struct bgp *bgp = NULL;
+ int idx = 0;
+
+ bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi,
+ &bgp);
+ if (!idx)
+ return CMD_WARNING;
+
+ int uj = use_json(argc, argv);
+ if (uj)
+ argc--;
+
+ if (argv_find(argv, argc, "cidr-only", &idx))
+ return bgp_show(vty, bgp, afi, safi, bgp_show_type_cidr_only,
+ NULL, uj);
+
+ if (argv_find(argv, argc, "dampening", &idx)) {
+ 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);
+ }
+
+ if (argv_find(argv, argc, "community", &idx)) {
+ /* show all communities */
+ return bgp_show(vty, bgp, afi, safi,
+ bgp_show_type_community_all, NULL, uj);
+ }
+
if (safi == SAFI_MPLS_VPN)
return bgp_show_mpls_vpn(vty, afi, NULL, bgp_show_type_normal,
NULL, 0, uj);
/* IPv4 labeled-unicast configuration. */
install_element(VIEW_NODE, &show_ip_bgp_instance_all_cmd);
install_element(VIEW_NODE, &show_ip_bgp_cmd);
+ install_element(VIEW_NODE, &show_ip_bgp_json_cmd);
install_element(VIEW_NODE, &show_ip_bgp_route_cmd);
install_element(VIEW_NODE, &show_ip_bgp_regexp_cmd);