/* Static function to display route. */
static void route_vty_out_route(const struct prefix *p, struct vty *vty,
- json_object *json)
+ json_object *json, bool wide)
{
int len = 0;
char buf[BUFSIZ];
}
if (!json) {
- len = 17 - len;
+ len = wide ? (45 - len) : (17 - len);
if (len < 1)
vty_out(vty, "\n%*s", 20, " ");
else
/* called from terminal list command */
void route_vty_out(struct vty *vty, const struct prefix *p,
struct bgp_path_info *path, int display, safi_t safi,
- json_object *json_paths)
+ json_object *json_paths, bool wide)
{
int len;
struct attr *attr = path->attr;
if (!json_paths) {
/* print prefix and mask */
if (!display)
- route_vty_out_route(p, vty, json_path);
+ route_vty_out_route(p, vty, json_path, wide);
else
- vty_out(vty, "%*s", 17, " ");
+ vty_out(vty, "%*s", (wide ? 45 : 17), " ");
} else {
- route_vty_out_route(p, vty, json_path);
+ route_vty_out_route(p, vty, json_path, wide);
}
/*
else
len = vty_out(vty, "%s%s", nexthop, vrf_id_str);
- len = 16 - len;
+ len = wide ? (41 - len) : (16 - len);
if (len < 1)
vty_out(vty, "\n%*s", 36, " ");
else
len = vty_out(vty, "%pI4%s", &attr->nexthop,
vrf_id_str);
- len = 16 - len;
+ len = wide ? (41 - len) : (16 - len);
if (len < 1)
vty_out(vty, "\n%*s", 36, " ");
else
&attr->nexthop,
vrf_id_str);
- len = 16 - len;
+ len = wide ? (41 - len) : (16 - len);
if (len < 1)
vty_out(vty, "\n%*s", 36, " ");
else
len = vty_out(vty, "%pI4%s", &attr->nexthop,
vrf_id_str);
- len = 16 - len;
+ len = wide ? (41 - len) : (16 - len);
if (len < 1)
vty_out(vty, "\n%*s", 36, " ");
else
if (path->peer->conf_if) {
len = vty_out(vty, "%s",
path->peer->conf_if);
- len = 16 - len; /* len of IPv6
- addr + max
- len of def
- ifname */
+ /* len of IPv6 addr + max len of def
+ * ifname */
+ len = wide ? (41 - len) : (16 - len);
if (len < 1)
vty_out(vty, "\n%*s", 36, " ");
&attr->mp_nexthop_local,
vrf_id_str);
- len = 16 - len;
+ len = wide ? (41 - len) : (16 - len);
if (len < 1)
vty_out(vty, "\n%*s", 36, " ");
&attr->mp_nexthop_global,
vrf_id_str);
- len = 16 - len;
+ len = wide ? (41 - len) : (16 - len);
if (len < 1)
vty_out(vty, "\n%*s", 36, " ");
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
if (json_paths)
json_object_int_add(json_path, "metric", attr->med);
+ else if (wide)
+ vty_out(vty, "%7u", attr->med);
else
vty_out(vty, "%10u", attr->med);
- else if (!json_paths)
- vty_out(vty, " ");
+ else if (!json_paths) {
+ if (wide)
+ vty_out(vty, "%*s", 7, " ");
+ else
+ vty_out(vty, "%*s", 10, " ");
+ }
/* Local Pref */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
/* called from terminal list command */
void route_vty_out_tmp(struct vty *vty, const struct prefix *p,
struct attr *attr, safi_t safi, bool use_json,
- json_object *json_ar)
+ json_object *json_ar, bool wide)
{
json_object *json_status = NULL;
json_object *json_net = NULL;
json_object_string_add(json_net, "network", buff);
}
} else
- route_vty_out_route(p, vty, NULL);
+ route_vty_out_route(p, vty, NULL, wide);
/* Print attribute */
if (attr) {
vty_out(vty, "%-16s",
inet_ntoa(
attr->mp_nexthop_global_in));
+ else if (wide)
+ vty_out(vty, "%-41s",
+ inet_ntoa(attr->nexthop));
else
vty_out(vty, "%-16s",
inet_ntoa(attr->nexthop));
inet_ntop(AF_INET6,
&attr->mp_nexthop_global, buf,
BUFSIZ));
- len = 16 - len;
+ len = wide ? (41 - len) : (16 - len);
if (len < 1)
vty_out(vty, "\n%*s", 36, " ");
else
}
if (attr->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
- vty_out(vty, "%10u", attr->med);
+ if (wide)
+ vty_out(vty, "%7u", attr->med);
+ else
+ vty_out(vty, "%10u", attr->med);
+ else if (wide)
+ vty_out(vty, " ");
else
vty_out(vty, " ");
/* print prefix and mask */
if (json == NULL) {
if (!display)
- route_vty_out_route(p, vty, NULL);
+ route_vty_out_route(p, vty, NULL, false);
else
vty_out(vty, "%*s", 17, " ");
}
/* print prefix and mask */
if (!display)
- route_vty_out_route(p, vty, json_path);
+ route_vty_out_route(p, vty, json_path, false);
else
vty_out(vty, "%*s", 17, " ");
/* print prefix and mask */
if (!use_json) {
if (!display)
- route_vty_out_route(p, vty, NULL);
+ route_vty_out_route(p, vty, NULL, false);
else
vty_out(vty, "%*s", 17, " ");
}
/* print prefix and mask */
if (!use_json) {
if (!display)
- route_vty_out_route(p, vty, NULL);
+ route_vty_out_route(p, vty, NULL, false);
else
vty_out(vty, "%*s", 17, " ");
}
void *output_arg, bool use_json, char *rd,
int is_last, unsigned long *output_cum,
unsigned long *total_cum,
- unsigned long *json_header_depth)
+ unsigned long *json_header_depth, bool wide)
{
struct bgp_path_info *pi;
struct bgp_dest *dest;
|| type == bgp_show_type_flap_neighbor)
vty_out(vty, BGP_SHOW_FLAP_HEADER);
else
- vty_out(vty, BGP_SHOW_HEADER);
+ vty_out(vty, (wide ? BGP_SHOW_HEADER_WIDE
+ : BGP_SHOW_HEADER));
header = 0;
}
if (rd != NULL && !display && !output_count) {
json_paths);
else
route_vty_out(vty, dest_p, pi, display, safi,
- json_paths);
+ json_paths, wide);
display++;
}
prefix_rd2str(&prd, rd, sizeof(rd));
bgp_show_table(vty, bgp, safi, itable, type, output_arg,
use_json, rd, next == NULL, &output_cum,
- &total_cum, &json_header_depth);
+ &total_cum, &json_header_depth, false);
if (next == NULL)
show_msg = false;
}
return CMD_SUCCESS;
}
static int bgp_show(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
- enum bgp_show_type type, void *output_arg, bool use_json)
+ enum bgp_show_type type, void *output_arg, bool use_json,
+ bool wide)
{
struct bgp_table *table;
unsigned long json_header_depth = 0;
safi = SAFI_UNICAST;
return bgp_show_table(vty, bgp, safi, table, type, output_arg, use_json,
- NULL, 1, NULL, NULL, &json_header_depth);
+ NULL, 1, NULL, NULL, &json_header_depth, wide);
}
static void bgp_show_all_instances_routes_vty(struct vty *vty, afi_t afi,
- safi_t safi, bool use_json)
+ safi_t safi, bool use_json,
+ bool wide)
{
struct listnode *node, *nnode;
struct bgp *bgp;
: bgp->name);
}
bgp_show(vty, bgp, afi, safi, bgp_show_type_normal, NULL,
- use_json);
+ use_json, wide);
}
if (use_json)
return bgp_show(vty, bgp, afi, safi,
(exact ? bgp_show_type_lcommunity_exact
- : bgp_show_type_lcommunity),
- lcom, uj);
+ : bgp_show_type_lcommunity),
+ lcom, uj, false);
}
static int bgp_show_lcommunity_list(struct vty *vty, struct bgp *bgp,
return bgp_show(vty, bgp, afi, safi,
(exact ? bgp_show_type_lcommunity_list_exact
- : bgp_show_type_lcommunity_list),
- list, uj);
+ : bgp_show_type_lcommunity_list),
+ list, uj, false);
}
DEFUN (show_ip_bgp_large_community_list,
exact_match, afi, safi, uj);
} else
return bgp_show(vty, bgp, afi, safi,
- bgp_show_type_lcommunity_all, NULL, uj);
+ bgp_show_type_lcommunity_all, NULL, uj, false);
}
static int bgp_table_stats_single(struct vty *vty, struct bgp *bgp, afi_t afi,
}
/* BGP route print out function with JSON */
-DEFUN (show_ip_bgp_json,
+DEFPY (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\
|accept-own|accept-own-nexthop|route-filter-v6\
|route-filter-v4|route-filter-translated-v6\
|route-filter-translated-v4] [exact-match]\
- ] [json]",
+ ] [json$uj | wide$wide]",
SHOW_STR
IP_STR
BGP_STR
"RT translated VPNv6 route filtering (well-known community)\n"
"RT translated VPNv4 route filtering (well-known community)\n"
"Exact match of the communities\n"
- JSON_STR)
+ JSON_STR
+ "Increase table width for longer prefixes\n")
{
afi_t afi = AFI_IP6;
safi_t safi = SAFI_UNICAST;
struct bgp *bgp = NULL;
int idx = 0;
int exact_match = 0;
- bool 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);
+ NULL, uj, wide);
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);
+ bgp_show_type_dampend_paths, NULL, uj,
+ wide);
else if (argv_find(argv, argc, "flap-statistics", &idx))
return bgp_show(vty, bgp, afi, safi,
- bgp_show_type_flap_statistics, NULL,
- uj);
+ bgp_show_type_flap_statistics, NULL, uj,
+ wide);
}
if (argv_find(argv, argc, "community", &idx)) {
exact_match, afi, safi, uj);
else
return (bgp_show(vty, bgp, afi, safi,
- bgp_show_type_community_all, NULL,
- uj));
+ bgp_show_type_community_all, NULL, uj,
+ wide));
}
- return bgp_show(vty, bgp, afi, safi, sh_type, NULL, uj);
+ return bgp_show(vty, bgp, afi, safi, sh_type, NULL, uj, wide);
}
DEFUN (show_ip_bgp_route,
bgp_show_type_regexp, uj);
}
-DEFUN (show_ip_bgp_instance_all,
+DEFPY (show_ip_bgp_instance_all,
show_ip_bgp_instance_all_cmd,
- "show [ip] bgp <view|vrf> all ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] [json]",
+ "show [ip] bgp <view|vrf> all ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] [json$uj | wide$wide]",
SHOW_STR
IP_STR
BGP_STR
BGP_INSTANCE_ALL_HELP_STR
BGP_AFI_HELP_STR
BGP_SAFI_WITH_LABEL_HELP_STR
- JSON_STR)
+ JSON_STR
+ "Increase table width for longer prefixes\n")
{
afi_t afi = AFI_IP;
safi_t safi = SAFI_UNICAST;
struct bgp *bgp = NULL;
int idx = 0;
- bool uj = use_json(argc, argv);
if (uj)
argc--;
if (!idx)
return CMD_WARNING;
- bgp_show_all_instances_routes_vty(vty, afi, safi, uj);
+ bgp_show_all_instances_routes_vty(vty, afi, safi, uj, wide);
return CMD_SUCCESS;
}
return CMD_WARNING;
}
- rc = bgp_show(vty, bgp, afi, safi, type, regex, use_json);
+ rc = bgp_show(vty, bgp, afi, safi, type, regex, use_json, false);
bgp_regex_free(regex);
return rc;
}
return CMD_WARNING;
}
- return bgp_show(vty, bgp, afi, safi, type, plist, 0);
+ return bgp_show(vty, bgp, afi, safi, type, plist, 0, false);
}
static int bgp_show_filter_list(struct vty *vty, struct bgp *bgp,
return CMD_WARNING;
}
- return bgp_show(vty, bgp, afi, safi, type, as_list, 0);
+ return bgp_show(vty, bgp, afi, safi, type, as_list, 0, false);
}
static int bgp_show_route_map(struct vty *vty, struct bgp *bgp,
return CMD_WARNING;
}
- return bgp_show(vty, bgp, afi, safi, type, rmap, 0);
+ return bgp_show(vty, bgp, afi, safi, type, rmap, 0, false);
}
static int bgp_show_community(struct vty *vty, struct bgp *bgp,
ret = bgp_show(vty, bgp, afi, safi,
(exact ? bgp_show_type_community_exact
: bgp_show_type_community),
- com, use_json);
+ com, use_json, false);
community_free(&com);
return ret;
return bgp_show(vty, bgp, afi, safi,
(exact ? bgp_show_type_community_list_exact
: bgp_show_type_community_list),
- list, 0);
+ list, 0, false);
}
static int bgp_show_prefix_longer(struct vty *vty, struct bgp *bgp,
return CMD_WARNING;
}
- ret = bgp_show(vty, bgp, afi, safi, type, p, 0);
+ ret = bgp_show(vty, bgp, afi, safi, type, p, 0, false);
prefix_free(&p);
return ret;
}
static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
safi_t safi, enum bgp_show_adj_route_type type,
const char *rmap_name, bool use_json,
- json_object *json)
+ json_object *json, bool wide)
{
struct bgp_table *table;
struct bgp_adj_in *ain;
}
if (header2) {
if (!use_json)
- vty_out(vty, BGP_SHOW_HEADER);
+ vty_out(vty,
+ (wide ? BGP_SHOW_HEADER_WIDE
+ : BGP_SHOW_HEADER));
header2 = 0;
}
filtered_count++;
route_vty_out_tmp(vty, rn_p, &attr, safi,
- use_json, json_ar);
+ use_json, json_ar, wide);
bgp_attr_undup(&attr, ain->attr);
output_count++;
}
if (header2) {
if (!use_json)
vty_out(vty,
- BGP_SHOW_HEADER);
+ (wide ? BGP_SHOW_HEADER_WIDE
+ : BGP_SHOW_HEADER));
header2 = 0;
}
if (ret != RMAP_DENY) {
route_vty_out_tmp(
vty, rn_p, &attr, safi,
- use_json, json_ar);
+ use_json, json_ar,
+ wide);
output_count++;
} else {
filtered_count++;
static int peer_adj_routes(struct vty *vty, struct peer *peer, afi_t afi,
safi_t safi, enum bgp_show_adj_route_type type,
- const char *rmap_name, bool use_json)
+ const char *rmap_name, bool use_json, bool wide)
{
json_object *json = NULL;
return CMD_WARNING;
}
- show_adj_route(vty, peer, afi, safi, type, rmap_name, use_json, json);
+ show_adj_route(vty, peer, afi, safi, type, rmap_name, use_json, json,
+ wide);
return CMD_SUCCESS;
}
-DEFUN (show_ip_bgp_instance_neighbor_advertised_route,
+DEFPY (show_ip_bgp_instance_neighbor_advertised_route,
show_ip_bgp_instance_neighbor_advertised_route_cmd,
- "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] neighbors <A.B.C.D|X:X::X:X|WORD> <advertised-routes|received-routes|filtered-routes> [route-map WORD] [json]",
+ "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] neighbors <A.B.C.D|X:X::X:X|WORD> <advertised-routes|received-routes|filtered-routes> [route-map WORD] [json$uj | wide$wide]",
SHOW_STR
IP_STR
BGP_STR
"Display the filtered routes received from neighbor\n"
"Route-map to modify the attributes\n"
"Name of the route map\n"
- JSON_STR)
+ JSON_STR
+ "Increase table width for longer prefixes\n")
{
afi_t afi = AFI_IP6;
safi_t safi = SAFI_UNICAST;
struct peer *peer;
enum bgp_show_adj_route_type type = bgp_show_adj_route_advertised;
int idx = 0;
- bool uj = use_json(argc, argv);
if (uj)
argc--;
if (argv_find(argv, argc, "route-map", &idx))
rmap_name = argv[++idx]->arg;
- return peer_adj_routes(vty, peer, afi, safi, type, rmap_name, uj);
+ return peer_adj_routes(vty, peer, afi, safi, type, rmap_name, uj, wide);
}
DEFUN (show_ip_bgp_neighbor_received_prefix_filter,
return CMD_WARNING;
}
- return bgp_show(vty, peer->bgp, afi, safi, type, &peer->su, use_json);
+ return bgp_show(vty, peer->bgp, afi, safi, type, &peer->su, use_json,
+ false);
}
DEFUN (show_ip_bgp_flowspec_routes_detailed,
if (!idx)
return CMD_WARNING;
- return bgp_show(vty, bgp, afi, safi, bgp_show_type_detail, NULL, uj);
+ return bgp_show(vty, bgp, afi, safi, bgp_show_type_detail, NULL, uj,
+ false);
}
DEFUN (show_ip_bgp_neighbor_routes,