{
int len = 0;
char buf[BUFSIZ];
+ char buf2[BUFSIZ];
if (p->family == AF_INET) {
if (!json) {
&p->u.prefix, buf,
BUFSIZ));
json_object_int_add(json, "prefixLen", p->prefixlen);
+ sprintf(buf2, "%s/%d",
+ inet_ntop(p->family, &p->u.prefix, buf,
+ BUFSIZ), p->prefixlen);
+ json_object_string_add(json, "network", buf2);
}
} else if (p->family == AF_ETHERNET) {
prefix2str(p, buf, PREFIX_STRLEN);
vty, "%s/%d",
inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ),
p->prefixlen);
+ else {
+ json_object_string_add(json, "prefix",
+ inet_ntop(p->family,
+ &p->u.prefix, buf,
+ BUFSIZ));
+ json_object_int_add(json, "prefixLen", p->prefixlen);
+ sprintf(buf2, "%s/%d",
+ inet_ntop(p->family, &p->u.prefix, buf,
+ BUFSIZ), p->prefixlen);
+ json_object_string_add(json, "network", buf2); }
}
if (!json) {
inet_ntoa(attr->nexthop));
json_object_string_add(json_nexthop_global,
"afi", "ipv4");
- json_object_boolean_true_add(json_nexthop_global,
+ json_object_boolean_true_add(
+ json_nexthop_global,
"used");
} else {
vty_out(vty, "%-16s", inet_ntoa(attr->nexthop));
/* MED/Metric */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
- if (json_paths)
+ if (json_paths) {
+
+ /*
+ * Adding "metric" field to match with corresponding
+ * CLI. "med" will be deprecated in future.
+ */
json_object_int_add(json_path, "med", attr->med);
- else
+ json_object_int_add(json_path, "metric", attr->med);
+ } else
vty_out(vty, "%10u", attr->med);
else if (!json_paths)
vty_out(vty, " ");
/* Local Pref */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
- if (json_paths)
+ if (json_paths) {
+
+ /*
+ * Adding "locPrf" field to match with corresponding
+ * CLI. "localPref" will be deprecated in future.
+ */
json_object_int_add(json_path, "localpref",
attr->local_pref);
- else
+ json_object_int_add(json_path, "locPrf",
+ attr->local_pref);
+ } else
vty_out(vty, "%7u", attr->local_pref);
else if (!json_paths)
vty_out(vty, " ");
/* Print aspath */
if (attr->aspath) {
- if (json_paths)
+ if (json_paths) {
+
+ /*
+ * Adding "path" field to match with corresponding
+ * CLI. "aspath" will be deprecated in future.
+ */
json_object_string_add(json_path, "aspath",
attr->aspath->str);
- else
+ json_object_string_add(json_path, "path",
+ attr->aspath->str);
+ } else
aspath_print_vty(vty, "%s", attr->aspath, " ");
}
json_object *json_status = NULL;
json_object *json_net = NULL;
char buff[BUFSIZ];
+ char buf2[BUFSIZ];
/* Route status display. */
if (use_json) {
json_status = json_object_new_object();
}
/* print prefix and mask */
- if (use_json)
+ if (use_json) {
json_object_string_add(
json_net, "addrPrefix",
inet_ntop(p->family, &p->u.prefix, buff, BUFSIZ));
- else
+ json_object_int_add(json_net, "prefixLen", p->prefixlen);
+ sprintf(buf2, "%s/%d",
+ inet_ntop(p->family, &p->u.prefix, buff,
+ BUFSIZ), p->prefixlen);
+ json_object_string_add(json_net, "network", buf2);
+ } else
route_vty_out_route(p, vty, NULL);
/* Print attribute */
json_object_int_add(json_net, "metric",
attr->med);
- if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
+ if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) {
+
+ /*
+ * Adding "locPrf" field to match with
+ * corresponding CLI. "localPref" will be
+ * deprecated in future.
+ */
json_object_int_add(json_net, "localPref",
attr->local_pref);
+ json_object_int_add(json_net, "locPrf",
+ attr->local_pref);
+ }
json_object_int_add(json_net, "weight", attr->weight);
/* Print aspath */
- if (attr->aspath)
+ if (attr->aspath) {
+
+ /*
+ * Adding "path" field to match with
+ * corresponding CLI. "localPref" will be
+ * deprecated in future.
+ */
json_object_string_add(json_net, "asPath",
attr->aspath->str);
+ json_object_string_add(json_net, "path",
+ attr->aspath->str);
+ }
/* Print origin */
json_object_string_add(json_net, "bgpOriginCode",
bgp_origin_long_str[attr->origin]);
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) {
- if (json_paths)
+ if (json_paths) {
+
+ /*
+ * Adding "metric" field to match with
+ * corresponding CLI. "med" will be
+ * deprecated in future.
+ */
json_object_int_add(json_path, "med",
attr->med);
- else
+ json_object_int_add(json_path, "metric",
+ attr->med);
+ } else
vty_out(vty, ", metric %u", attr->med);
}
int pfx_rcd_safi;
json_object *json_peer = NULL;
json_object *json_peers = NULL;
+ struct peer_af *paf;
/* labeled-unicast routes are installed in the unicast table so in order
* to
json_object_int_add(json_peer, "inq", 0);
peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN,
use_json, json_peer);
+
+ /*
+ * Adding "pfxRcd" field to match with the corresponding
+ * CLI. "prefixReceivedCount" will be deprecated in
+ * future.
+ */
json_object_int_add(json_peer, "prefixReceivedCount",
peer->pcount[afi][pfx_rcd_safi]);
+ json_object_int_add(json_peer, "pfxRcd",
+ peer->pcount[afi][pfx_rcd_safi]);
+
+ paf = peer_af_find(peer, afi, pfx_rcd_safi);
+ if (paf && PAF_SUBGRP(paf))
+ json_object_int_add(json_peer,
+ "pfxSnt",
+ (PAF_SUBGRP(paf))->scount);
if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN))
json_object_string_add(json_peer, "state",
/* Receive prefix count */
json_object_int_add(json_addr, "acceptedPrefixCounter",
p->pcount[afi][safi]);
+ if (paf && PAF_SUBGRP(paf))
+ json_object_int_add(json_addr, "sentPrefixCounter",
+ (PAF_SUBGRP(paf))->scount);
/* Maximum prefix */
if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) {