#include "command.h"
#include "prefix.h"
#include "lib/json.h"
+#include "lib/printfrr.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_route.h"
{
struct bgp *bgp;
struct bgp_table *table;
- struct bgp_node *rn;
- struct bgp_node *rm;
+ struct bgp_dest *dest;
+ struct bgp_dest *rm;
int rd_header;
int header = 1;
json_object *json = NULL;
json_object_string_add(json_ocode, "incomplete", "?");
}
- for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
- rn = bgp_route_next(rn)) {
- const struct prefix *rn_p = bgp_node_get_prefix(rn);
+ for (dest = bgp_table_top(bgp->rib[afi][safi]); dest;
+ dest = bgp_route_next(dest)) {
+ const struct prefix *dest_p = bgp_dest_get_prefix(dest);
- if (prd && memcmp(rn_p->u.val, prd->val, 8) != 0)
+ if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0)
continue;
- table = bgp_node_get_bgp_table_info(rn);
+ table = bgp_dest_get_bgp_table_info(dest);
if (table == NULL)
continue;
break;
}
- if (bgp_node_get_bgp_path_info(rm) == NULL)
+ if (bgp_dest_get_bgp_path_info(rm) == NULL)
continue;
if (!attr)
if (header) {
if (use_json) {
+ char buf[BUFSIZ] = {0};
+
json_object_int_add(
json, "bgpTableVersion", 0);
json_object_string_add(
json, "bgpLocalRouterId",
- inet_ntoa(bgp->router_id));
+ inet_ntop(AF_INET,
+ &bgp->router_id, buf,
+ sizeof(buf)));
json_object_int_add(
json,
"defaultLocPrf",
json_ocode);
} else {
vty_out(vty,
- "BGP table version is 0, local router ID is %s\n",
- inet_ntoa(bgp->router_id));
+ "BGP table version is 0, local router ID is %pI4\n",
+ &bgp->router_id);
vty_out(vty, "Default local pref %u, ",
bgp->default_local_pref);
vty_out(vty, "local AS %u\n", bgp->as);
uint16_t type;
struct rd_as rd_as = {0};
struct rd_ip rd_ip = {0};
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
struct rd_vnc_eth rd_vnc_eth = {0};
#endif
const uint8_t *pnt;
- pnt = rn_p->u.val;
+ pnt = dest_p->u.val;
/* Decode RD type. */
type = decode_rd_type(pnt);
decode_rd_as4(pnt + 2, &rd_as);
else if (type == RD_TYPE_IP)
decode_rd_ip(pnt + 2, &rd_ip);
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
else if (type == RD_TYPE_VNC_ETH)
decode_rd_vnc_eth(pnt, &rd_vnc_eth);
#endif
if (type == RD_TYPE_AS
|| type == RD_TYPE_AS4)
- sprintf(rd_str, "%u:%d",
- rd_as.as, rd_as.val);
+ snprintf(rd_str, sizeof(rd_str),
+ "%u:%d", rd_as.as,
+ rd_as.val);
else if (type == RD_TYPE_IP)
- sprintf(rd_str, "%s:%d",
- inet_ntoa(rd_ip.ip),
- rd_ip.val);
+ snprintfrr(rd_str,
+ sizeof(rd_str),
+ "%pI4:%d", &rd_ip.ip,
+ rd_ip.val);
json_object_string_add(
json_routes,
"rd", rd_str);
vty_out(vty, "%u:%d", rd_as.as,
rd_as.val);
else if (type == RD_TYPE_IP)
- vty_out(vty, "%s:%d",
- inet_ntoa(rd_ip.ip),
- rd_ip.val);
-#if ENABLE_BGP_VNC
+ vty_out(vty, "%pI4:%d",
+ &rd_ip.ip, rd_ip.val);
+#ifdef ENABLE_BGP_VNC
else if (type == RD_TYPE_VNC_ETH)
vty_out(vty,
"%u:%02x:%02x:%02x:%02x:%02x:%02x",
}
rd_header = 0;
}
- route_vty_out_tmp(vty, bgp_node_get_prefix(rm), attr,
- safi, use_json, json_routes);
+ route_vty_out_tmp(vty, bgp_dest_get_prefix(rm), attr,
+ safi, use_json, json_routes, false);
output_count++;
}