continue;
table = bgp_node_get_bgp_table_info(rn);
- if (table != NULL) {
- if (use_json)
- json_array = json_object_new_array();
- else
- json_array = NULL;
-
- rd_header = 1;
+ if (table == NULL)
+ continue;
- for (rm = bgp_table_top(table); rm;
- rm = bgp_route_next(rm)) {
- path = bgp_node_get_bgp_path_info(rm);
- if (path != NULL) {
- if (header) {
- if (use_json) {
- json_object_int_add(
- json,
- "bgpTableVersion",
- 0);
- json_object_string_add(
- json,
- "bgpLocalRouterId",
- inet_ntoa(
- bgp->router_id));
- json_object_object_add(
- json,
- "bgpStatusCodes",
- json_scode);
- json_object_object_add(
- json,
- "bgpOriginCodes",
- json_ocode);
- } else {
- vty_out(vty,
- "BGP table version is 0, local router ID is %s\n",
- inet_ntoa(
- bgp->router_id));
- vty_out(vty,
- "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal\n");
- vty_out(vty,
- "Origin codes: i - IGP, e - EGP, ? - incomplete\n\n");
- vty_out(vty, V4_HEADER);
- }
- header = 0;
- }
+ if (use_json)
+ json_array = json_object_new_array();
+ else
+ json_array = NULL;
+
+ rd_header = 1;
+
+ for (rm = bgp_table_top(table); rm; rm = bgp_route_next(rm)) {
+ path = bgp_node_get_bgp_path_info(rm);
+ if (path == NULL)
+ continue;
+
+ if (header) {
+ if (use_json) {
+ json_object_int_add(
+ json, "bgpTableVersion", 0);
+ json_object_string_add(
+ json, "bgpLocalRouterId",
+ inet_ntoa(bgp->router_id));
+ json_object_object_add(json,
+ "bgpStatusCodes",
+ json_scode);
+ json_object_object_add(json,
+ "bgpOriginCodes",
+ json_ocode);
+ } else {
+ vty_out(vty,
+ "BGP table version is 0, local router ID is %s\n",
+ inet_ntoa(bgp->router_id));
+ vty_out(vty,
+ "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal\n");
+ vty_out(vty,
+ "Origin codes: i - IGP, e - EGP, ? - incomplete\n\n");
+ vty_out(vty, V4_HEADER);
+ }
+ header = 0;
+ }
- if (rd_header) {
- uint16_t type;
- struct rd_as rd_as = {0};
- struct rd_ip rd_ip = {0};
+ if (rd_header) {
+ uint16_t type;
+ struct rd_as rd_as = {0};
+ struct rd_ip rd_ip = {0};
#if ENABLE_BGP_VNC
- struct rd_vnc_eth rd_vnc_eth = {
- 0};
+ struct rd_vnc_eth rd_vnc_eth = {0};
#endif
- uint8_t *pnt;
-
- pnt = rn->p.u.val;
-
- /* Decode RD type. */
- type = decode_rd_type(pnt);
- /* Decode RD value. */
- if (type == RD_TYPE_AS)
- decode_rd_as(pnt + 2,
- &rd_as);
- else if (type == RD_TYPE_AS4)
- decode_rd_as4(pnt + 2,
- &rd_as);
- else if (type == RD_TYPE_IP)
- decode_rd_ip(pnt + 2,
- &rd_ip);
+ uint8_t *pnt;
+
+ pnt = rn->p.u.val;
+
+ /* Decode RD type. */
+ type = decode_rd_type(pnt);
+ /* Decode RD value. */
+ if (type == RD_TYPE_AS)
+ decode_rd_as(pnt + 2, &rd_as);
+ else if (type == RD_TYPE_AS4)
+ decode_rd_as4(pnt + 2, &rd_as);
+ else if (type == RD_TYPE_IP)
+ decode_rd_ip(pnt + 2, &rd_ip);
#if ENABLE_BGP_VNC
- else if (type
- == RD_TYPE_VNC_ETH)
- decode_rd_vnc_eth(
- pnt,
- &rd_vnc_eth);
+ else if (type == RD_TYPE_VNC_ETH)
+ decode_rd_vnc_eth(pnt, &rd_vnc_eth);
#endif
-
- if (use_json) {
- char buffer[BUFSIZ];
- if (type == RD_TYPE_AS
- || type == RD_TYPE_AS4)
- sprintf(buffer,
- "%u:%d",
- rd_as.as,
- rd_as.val);
- else if (type
- == RD_TYPE_IP)
- sprintf(buffer,
- "%s:%d",
- inet_ntoa(
- rd_ip.ip),
- rd_ip.val);
- json_object_string_add(
- json_routes,
- "routeDistinguisher",
- buffer);
- } else {
- vty_out(vty,
- "Route Distinguisher: ");
-
- if (type == RD_TYPE_AS
- || type == RD_TYPE_AS4)
- 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 (use_json) {
+ char buffer[BUFSIZ];
+ if (type == RD_TYPE_AS
+ || type == RD_TYPE_AS4)
+ sprintf(buffer, "%u:%d",
+ rd_as.as, rd_as.val);
+ else if (type == RD_TYPE_IP)
+ sprintf(buffer, "%s:%d",
+ inet_ntoa(rd_ip.ip),
+ rd_ip.val);
+ json_object_string_add(
+ json_routes,
+ "routeDistinguisher", buffer);
+ } else {
+ vty_out(vty, "Route Distinguisher: ");
+
+ if (type == RD_TYPE_AS
+ || type == RD_TYPE_AS4)
+ 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
- else if (
- type
- == RD_TYPE_VNC_ETH)
- vty_out(vty,
- "%u:%02x:%02x:%02x:%02x:%02x:%02x",
- rd_vnc_eth
- .local_nve_id,
- rd_vnc_eth
- .macaddr
- .octet[0],
- rd_vnc_eth
- .macaddr
- .octet[1],
- rd_vnc_eth
- .macaddr
- .octet[2],
- rd_vnc_eth
- .macaddr
- .octet[3],
- rd_vnc_eth
- .macaddr
- .octet[4],
- rd_vnc_eth
- .macaddr
- .octet[5]);
+ else if (type == RD_TYPE_VNC_ETH)
+ vty_out(vty,
+ "%u:%02x:%02x:%02x:%02x:%02x:%02x",
+ rd_vnc_eth.local_nve_id,
+ rd_vnc_eth.macaddr
+ .octet[0],
+ rd_vnc_eth.macaddr
+ .octet[1],
+ rd_vnc_eth.macaddr
+ .octet[2],
+ rd_vnc_eth.macaddr
+ .octet[3],
+ rd_vnc_eth.macaddr
+ .octet[4],
+ rd_vnc_eth.macaddr
+ .octet[5]);
#endif
- vty_out(vty, "\n");
- }
- rd_header = 0;
- }
- if (use_json) {
- char buf_a[BUFSIZ];
- char buf_b[BUFSIZ];
-
- sprintf(buf_a, "%s/%d",
- inet_ntop(rm->p.family,
- rm->p.u.val,
- buf_b,
- BUFSIZ),
- rm->p.prefixlen);
- json_object_object_add(
- json_routes, buf_a,
- json_array);
- } else {
- route_vty_out_tmp(
- vty, &rm->p, path->attr,
- SAFI_MPLS_VPN, use_json,
- json_array);
- }
+ vty_out(vty, "\n");
}
+ rd_header = 0;
+ }
+ if (use_json) {
+ char buf_a[BUFSIZ];
+ char buf_b[BUFSIZ];
+
+ sprintf(buf_a, "%s/%d",
+ inet_ntop(rm->p.family, rm->p.u.val,
+ buf_b, BUFSIZ),
+ rm->p.prefixlen);
+ json_object_object_add(json_routes, buf_a,
+ json_array);
+ } else {
+ route_vty_out_tmp(vty, &rm->p, path->attr,
+ SAFI_MPLS_VPN, use_json,
+ json_array);
}
}
}