diff --git a/bgpd/bgp_bfd.c b/bgpd/bgp_bfd.c index 47dffd146a..663bc4894a 100644 --- a/bgpd/bgp_bfd.c +++ b/bgpd/bgp_bfd.c @@ -530,7 +530,7 @@ void bgp_bfd_peer_config_write(struct vty *vty, struct peer *peer, char *addr) /* * bgp_bfd_show_info - Show the peer BFD information. */ -void bgp_bfd_show_info(struct vty *vty, struct peer *peer, uint8_t use_json, +void bgp_bfd_show_info(struct vty *vty, struct peer *peer, bool use_json, json_object *json_neigh) { bfd_show_info(vty, (struct bfd_info *)peer->bfd_info, diff --git a/bgpd/bgp_bfd.h b/bgpd/bgp_bfd.h index a3cfca9c0d..caa5651e3a 100644 --- a/bgpd/bgp_bfd.h +++ b/bgpd/bgp_bfd.h @@ -34,8 +34,8 @@ extern void bgp_bfd_deregister_peer(struct peer *peer); extern void bgp_bfd_peer_config_write(struct vty *vty, struct peer *peer, char *addr); -extern void bgp_bfd_show_info(struct vty *vty, struct peer *peer, - uint8_t use_json, json_object *json_neigh); +extern void bgp_bfd_show_info(struct vty *vty, struct peer *peer, bool use_json, + json_object *json_neigh); extern int bgp_bfd_is_peer_multihop(struct peer *peer); diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index bce6056ded..071ee6b9c6 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -523,7 +523,7 @@ void bgp_config_write_damp(struct vty *vty) } static const char *bgp_get_reuse_time(unsigned int penalty, char *buf, - size_t len, uint8_t use_json, + size_t len, bool use_json, json_object *json) { time_t reuse_time = 0; @@ -641,7 +641,7 @@ void bgp_damp_info_vty(struct vty *vty, struct bgp_info *binfo, } const char *bgp_damp_reuse_time_vty(struct vty *vty, struct bgp_info *binfo, - char *timebuf, size_t len, uint8_t use_json, + char *timebuf, size_t len, bool use_json, json_object *json) { struct bgp_damp_info *bdi; diff --git a/bgpd/bgp_damp.h b/bgpd/bgp_damp.h index d3b0ae42aa..8326bae697 100644 --- a/bgpd/bgp_damp.h +++ b/bgpd/bgp_damp.h @@ -140,9 +140,10 @@ extern int bgp_damp_decay(time_t, int); extern void bgp_config_write_damp(struct vty *); extern void bgp_damp_info_vty(struct vty *, struct bgp_info *, json_object *json_path); -extern const char *bgp_damp_reuse_time_vty(struct vty *, struct bgp_info *, - char *, size_t, uint8_t, - json_object *); +extern const char *bgp_damp_reuse_time_vty(struct vty *vty, + struct bgp_info *binfo, + char *timebuf, size_t len, + bool use_json, json_object *json); extern int bgp_show_dampening_parameters(struct vty *vty, afi_t, safi_t); #endif /* _QUAGGA_BGP_DAMP_H */ diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index b553cb42a5..a6cc2d9b53 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -983,7 +983,7 @@ static void show_vni_entry(struct hash_backet *backet, void *args[]) static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, enum bgp_show_type type, void *output_arg, - int option, uint8_t use_json) + int option, bool use_json) { afi_t afi = AFI_L2VPN; struct bgp *bgp; @@ -1276,7 +1276,7 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_routes, union sockunion su; struct peer *peer; int ret; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); argv_find(argv, argc, "A.B.C.D", &idx_ipv4); @@ -1336,7 +1336,7 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_routes, union sockunion su; struct peer *peer; struct prefix_rd prd; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); argv_find(argv, argc, "ASN:NN_OR_IP-ADDRESS:NN", &idx_ext_community); argv_find(argv, argc, "A.B.C.D", &idx_ipv4); @@ -1409,7 +1409,7 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_advertised_routes, int ret; struct peer *peer; union sockunion su; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); argv_find(argv, argc, "A.B.C.D", &idx_ipv4); @@ -1467,7 +1467,7 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes, struct peer *peer; struct prefix_rd prd; union sockunion su; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); argv_find(argv, argc, "ASN:NN_OR_IP-ADDRESS:NN", &idx_ext_community); argv_find(argv, argc, "A.B.C.D", &idx_ipv4); @@ -3172,7 +3172,7 @@ DEFUN(show_bgp_l2vpn_evpn_vni, struct bgp *bgp_def; vni_t vni; int idx = 0; - uint8_t uj = 0; + bool uj = false; json_object *json = NULL; uint32_t num_l2vnis = 0; uint32_t num_l3vnis = 0; @@ -3255,7 +3255,7 @@ DEFUN(show_bgp_l2vpn_evpn_es, JSON_STR) { int idx = 0; - uint8_t uj = 0; + bool uj = false; esi_t esi; json_object *json = NULL; struct bgp *bgp = NULL; @@ -3312,7 +3312,7 @@ DEFUN(show_bgp_l2vpn_evpn_summary, JSON_STR) { int idx_vrf = 0; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); char *vrf = NULL; if (argv_find(argv, argc, "vrf", &idx_vrf)) @@ -3341,7 +3341,7 @@ DEFUN(show_bgp_l2vpn_evpn_route, struct bgp *bgp; int type_idx = 0; int type = 0; - uint8_t uj = 0; + bool uj = false; json_object *json = NULL; uj = use_json(argc, argv); @@ -3404,7 +3404,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_rd, int type = 0; int rd_idx = 0; int type_idx = 0; - int uj = 0; + bool uj = false; json_object *json = NULL; bgp = bgp_get_default(); @@ -3477,7 +3477,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_rd_macip, int rd_idx = 0; int mac_idx = 0; int ip_idx = 0; - int uj = 0; + bool uj = false; json_object *json = NULL; memset(&mac, 0, sizeof(struct ethaddr)); @@ -3541,7 +3541,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_esi, "ESI ID\n" JSON_STR) { - int uj = 0; + bool uj = false; esi_t esi; struct bgp *bgp = NULL; json_object *json = NULL; @@ -3597,7 +3597,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_vni, show_bgp_l2vpn_evpn_route_vni_cmd, struct in_addr vtep_ip; int type = 0; int idx = 0; - int uj = 0; + bool uj = false; json_object *json = NULL; bgp = bgp_get_default(); @@ -3669,7 +3669,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_vni_macip, struct ethaddr mac; struct ipaddr ip; int idx = 0; - int uj = 0; + bool uj = false; json_object *json = NULL; bgp = bgp_get_default(); @@ -3737,7 +3737,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_vni_multicast, int ret; struct in_addr orig_ip; int idx = 0; - int uj = 0; + bool uj = false; json_object *json = NULL; bgp = bgp_get_default(); @@ -3793,7 +3793,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_vni_all, struct bgp *bgp; struct in_addr vtep_ip; int idx = 0; - int uj = 0; + bool uj = false; json_object *json = NULL; bgp = bgp_get_default(); @@ -3841,7 +3841,7 @@ DEFUN(show_bgp_l2vpn_evpn_vrf_import_rt, "Show vrf import route target\n" JSON_STR) { - uint8_t uj = 0; + bool uj = false; struct bgp *bgp_def = NULL; json_object *json = NULL; @@ -3878,7 +3878,7 @@ DEFUN(show_bgp_l2vpn_evpn_import_rt, JSON_STR) { struct bgp *bgp; - uint8_t uj = 0; + bool uj = false; json_object *json = NULL; bgp = bgp_get_default(); @@ -4359,7 +4359,7 @@ DEFUN (show_bgp_vrf_l3vni_info, json_object *json_vnis = NULL; json_object *json_export_rts = NULL; json_object *json_import_rts = NULL; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (uj) { json = json_object_new_object(); diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index b89edfe459..459775c8ec 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -1775,7 +1775,7 @@ DEFUN (no_vpnv6_network, int bgp_show_mpls_vpn(struct vty *vty, afi_t afi, struct prefix_rd *prd, enum bgp_show_type type, void *output_arg, int tags, - uint8_t use_json) + bool use_json) { struct bgp *bgp; struct bgp_table *table; @@ -1953,7 +1953,7 @@ DEFUN (show_ip_bgp_vpn_all_neighbor_routes, union sockunion su; struct peer *peer; int ret; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); afi_t afi; int idx = 0; @@ -2017,7 +2017,7 @@ DEFUN (show_ip_bgp_vpn_rd_neighbor_routes, union sockunion su; struct peer *peer; struct prefix_rd prd; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); afi_t afi; int idx = 0; @@ -2095,7 +2095,7 @@ DEFUN (show_ip_bgp_vpn_all_neighbor_advertised_routes, int ret; struct peer *peer; union sockunion su; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); afi_t afi; int idx = 0; @@ -2157,7 +2157,7 @@ DEFUN (show_ip_bgp_vpn_rd_neighbor_advertised_routes, struct peer *peer; struct prefix_rd prd; union sockunion su; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); afi_t afi; int idx = 0; diff --git a/bgpd/bgp_mplsvpn.h b/bgpd/bgp_mplsvpn.h index 122ae9e905..61b87392a2 100644 --- a/bgpd/bgp_mplsvpn.h +++ b/bgpd/bgp_mplsvpn.h @@ -50,7 +50,7 @@ extern int argv_find_and_parse_vpnvx(struct cmd_token **argv, int argc, int *index, afi_t *afi); extern int bgp_show_mpls_vpn(struct vty *vty, afi_t afi, struct prefix_rd *prd, enum bgp_show_type type, void *output_arg, - int tags, uint8_t use_json); + int tags, bool use_json); extern void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, struct bgp *bgp_vrf, struct bgp_info *info_vrf); diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index 7fbc030242..5bdee5f512 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -52,8 +52,8 @@ Next, if we send capability to the peer we want to set my capabilty inforation at each peer. */ -void bgp_capability_vty_out(struct vty *vty, struct peer *peer, - uint8_t use_json, json_object *json_neigh) +void bgp_capability_vty_out(struct vty *vty, struct peer *peer, bool use_json, + json_object *json_neigh) { char *pnt; char *end; diff --git a/bgpd/bgp_open.h b/bgpd/bgp_open.h index 42ebe97f2e..0fc321bdf3 100644 --- a/bgpd/bgp_open.h +++ b/bgpd/bgp_open.h @@ -86,8 +86,8 @@ struct graceful_restart_af { extern int bgp_open_option_parse(struct peer *, uint8_t, int *); extern void bgp_open_capability(struct stream *, struct peer *); -extern void bgp_capability_vty_out(struct vty *, struct peer *, uint8_t, - json_object *); +extern void bgp_capability_vty_out(struct vty *vty, struct peer *peer, + bool use_json, json_object *json_neigh); extern as_t peek_for_as4_capability(struct peer *, uint8_t); #endif /* _QUAGGA_BGP_OPEN_H */ diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 50c484d7de..50ffea27bf 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -6755,7 +6755,7 @@ void route_vty_out(struct vty *vty, struct prefix *p, struct bgp_info *binfo, /* called from terminal list command */ void route_vty_out_tmp(struct vty *vty, struct prefix *p, struct attr *attr, - safi_t safi, uint8_t use_json, json_object *json_ar) + safi_t safi, bool use_json, json_object *json_ar) { json_object *json_status = NULL; json_object *json_net = NULL; @@ -7084,7 +7084,7 @@ void route_vty_out_overlay(struct vty *vty, struct prefix *p, /* dampening route */ static void damp_route_vty_out(struct vty *vty, struct prefix *p, struct bgp_info *binfo, int display, safi_t safi, - uint8_t use_json, json_object *json) + bool use_json, json_object *json) { struct attr *attr; int len; @@ -7147,7 +7147,7 @@ static void damp_route_vty_out(struct vty *vty, struct prefix *p, /* flap route */ static void flap_route_vty_out(struct vty *vty, struct prefix *p, struct bgp_info *binfo, int display, safi_t safi, - uint8_t use_json, json_object *json) + bool use_json, json_object *json) { struct attr *attr; struct bgp_damp_info *bdi; @@ -8160,12 +8160,12 @@ static int bgp_show_regexp(struct vty *vty, struct bgp *bgp, const char *regstr, afi_t afi, safi_t safi, enum bgp_show_type type); static int bgp_show_community(struct vty *vty, struct bgp *bgp, const char *comstr, int exact, afi_t afi, - safi_t safi, uint8_t use_json); + safi_t safi, bool use_json); static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, struct bgp_table *table, enum bgp_show_type type, - void *output_arg, uint8_t use_json, char *rd, + void *output_arg, bool use_json, char *rd, int is_last, unsigned long *output_cum, unsigned long *total_cum, unsigned long *json_header_depth) @@ -8452,8 +8452,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi, struct bgp_table *table, struct prefix_rd *prd_match, - enum bgp_show_type type, void *output_arg, - uint8_t use_json) + enum bgp_show_type type, void *output_arg, bool use_json) { struct bgp_node *rn, *next; unsigned long output_cum = 0; @@ -8493,7 +8492,7 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi, 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, uint8_t use_json) + enum bgp_show_type type, void *output_arg, bool use_json) { struct bgp_table *table; unsigned long json_header_depth = 0; @@ -8531,16 +8530,18 @@ static int bgp_show(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, } static void bgp_show_all_instances_routes_vty(struct vty *vty, afi_t afi, - safi_t safi, uint8_t use_json) + safi_t safi, bool use_json) { struct listnode *node, *nnode; struct bgp *bgp; int is_first = 1; + bool route_output = false; if (use_json) vty_out(vty, "{\n"); for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { + route_output = true; if (use_json) { if (!is_first) vty_out(vty, ",\n"); @@ -8563,6 +8564,8 @@ static void bgp_show_all_instances_routes_vty(struct vty *vty, afi_t afi, if (use_json) vty_out(vty, "}\n"); + else if (!route_output) + vty_out(vty, "%% BGP instance not found\n"); } /* Header of detailed BGP route information */ @@ -8748,8 +8751,7 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp, struct bgp_table *rib, const char *ip_str, afi_t afi, safi_t safi, struct prefix_rd *prd, int prefix_check, - enum bgp_path_type pathtype, - uint8_t use_json) + enum bgp_path_type pathtype, bool use_json) { int ret; int header; @@ -8885,7 +8887,7 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp, static int bgp_show_route(struct vty *vty, struct bgp *bgp, const char *ip_str, afi_t afi, safi_t safi, struct prefix_rd *prd, int prefix_check, enum bgp_path_type pathtype, - uint8_t use_json) + bool use_json) { if (!bgp) { bgp = bgp_get_default(); @@ -8994,7 +8996,7 @@ DEFUN (show_ip_bgp_large_community_list, safi = bgp_vty_safi_from_str(argv[idx]->text); } - int uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct bgp *bgp = bgp_lookup_by_name(vrf); if (bgp == NULL) { @@ -9037,7 +9039,7 @@ DEFUN (show_ip_bgp_large_community, safi = bgp_vty_safi_from_str(argv[idx]->text); } - int uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct bgp *bgp = bgp_lookup_by_name(vrf); if (bgp == NULL) { @@ -9121,7 +9123,7 @@ DEFUN (show_ip_bgp, int idx = 0; bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, - &bgp); + &bgp, false); if (!idx) return CMD_WARNING; @@ -9197,16 +9199,16 @@ DEFUN (show_ip_bgp_json, int idx = 0; int idx_community_type = 0; int exact_match = 0; + bool uj = use_json(argc, argv); - 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--; + bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, + &bgp, uj); + if (!idx) + return CMD_WARNING; + if (argv_find(argv, argc, "cidr-only", &idx)) return bgp_show(vty, bgp, afi, safi, bgp_show_type_cidr_only, NULL, uj); @@ -9275,12 +9277,12 @@ DEFUN (show_ip_bgp_route, char *prefix = NULL; struct bgp *bgp = NULL; enum bgp_path_type path_type; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); int idx = 0; bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, - &bgp); + &bgp, uj); if (!idx) return CMD_WARNING; @@ -9343,7 +9345,7 @@ DEFUN (show_ip_bgp_regexp, int idx = 0; bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, - &bgp); + &bgp, false); if (!idx) return CMD_WARNING; @@ -9372,17 +9374,17 @@ DEFUN (show_ip_bgp_instance_all, afi_t afi = AFI_IP; safi_t safi = SAFI_UNICAST; 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; + bool uj = use_json(argc, argv); - int uj = use_json(argc, argv); if (uj) argc--; + bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, + &bgp, uj); + if (!idx) + return CMD_WARNING; + bgp_show_all_instances_routes_vty(vty, afi, safi, uj); return CMD_SUCCESS; } @@ -9453,7 +9455,7 @@ static int bgp_show_route_map(struct vty *vty, struct bgp *bgp, static int bgp_show_community(struct vty *vty, struct bgp *bgp, const char *comstr, int exact, afi_t afi, - safi_t safi, uint8_t use_json) + safi_t safi, bool use_json) { struct community *com; int ret = 0; @@ -9512,7 +9514,7 @@ static int bgp_show_prefix_longer(struct vty *vty, struct bgp *bgp, } static struct peer *peer_lookup_in_view(struct vty *vty, struct bgp *bgp, - const char *ip_str, uint8_t use_json) + const char *ip_str, bool use_json) { int ret; struct peer *peer; @@ -9899,7 +9901,7 @@ static int bgp_peer_count_walker(struct thread *t) } static int bgp_peer_counts(struct vty *vty, struct peer *peer, afi_t afi, - safi_t safi, uint8_t use_json) + safi_t safi, bool use_json) { struct peer_pcounts pcounts = {.peer = peer}; unsigned int i; @@ -10009,16 +10011,16 @@ DEFUN (show_ip_bgp_instance_neighbor_prefix_counts, struct peer *peer; int idx = 0; struct bgp *bgp = NULL; + bool uj = use_json(argc, argv); - 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--; + bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, + &bgp, uj); + if (!idx) + return CMD_WARNING; + argv_find(argv, argc, "neighbors", &idx); peer = peer_lookup_in_view(vty, bgp, argv[idx + 1]->arg, uj); if (!peer) @@ -10045,7 +10047,7 @@ DEFUN (show_ip_bgp_vpn_neighbor_prefix_counts, { int idx_peer = 6; struct peer *peer; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); peer = peer_lookup_in_view(vty, NULL, argv[idx_peer]->arg, uj); if (!peer) @@ -10118,7 +10120,7 @@ DEFUN (show_ip_bgp_l2vpn_evpn_all_route_prefix, 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, uint8_t use_json, + const char *rmap_name, bool use_json, json_object *json) { struct bgp_table *table; @@ -10389,7 +10391,7 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi, 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, uint8_t use_json) + const char *rmap_name, bool use_json) { json_object *json = NULL; @@ -10463,18 +10465,17 @@ DEFUN (show_ip_bgp_instance_neighbor_advertised_route, struct bgp *bgp = NULL; struct peer *peer; enum bgp_show_adj_route_type type = bgp_show_adj_route_advertised; - 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); + bool uj = use_json(argc, argv); if (uj) argc--; + bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, + &bgp, uj); + if (!idx) + return CMD_WARNING; + /* neighbors */ argv_find(argv, argc, "neighbors", &idx); peerstr = argv[++idx]->arg; @@ -10536,7 +10537,7 @@ DEFUN (show_ip_bgp_neighbor_received_prefix_filter, argv_find(argv, argc, "neighbors", &idx); peerstr = argv[++idx]->arg; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); ret = str2sockunion(peerstr, &su); if (ret < 0) { @@ -10580,7 +10581,7 @@ DEFUN (show_ip_bgp_neighbor_received_prefix_filter, static int bgp_show_neighbor_route(struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, - enum bgp_show_type type, uint8_t use_json) + enum bgp_show_type type, bool use_json) { /* labeled-unicast routes live in the unicast table */ if (safi == SAFI_LABELED_UNICAST) @@ -10620,14 +10621,17 @@ DEFUN (show_ip_bgp_flowspec_routes_detailed, safi_t safi = SAFI_UNICAST; struct bgp *bgp = NULL; int idx = 0; + bool uj = use_json(argc, argv); + + if (uj) + argc--; bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, - &bgp); + &bgp, uj); if (!idx) return CMD_WARNING; - return bgp_show(vty, bgp, afi, safi, - bgp_show_type_detail, NULL, use_json(argc, argv)); + return bgp_show(vty, bgp, afi, safi, bgp_show_type_detail, NULL, uj); } DEFUN (show_ip_bgp_neighbor_routes, @@ -10655,18 +10659,17 @@ DEFUN (show_ip_bgp_neighbor_routes, safi_t safi = SAFI_UNICAST; struct peer *peer; enum bgp_show_type sh_type = bgp_show_type_neighbor; - int idx = 0; + bool uj = use_json(argc, argv); - 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--; + bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, + &bgp, uj); + if (!idx) + return CMD_WARNING; + /* neighbors */ argv_find(argv, argc, "neighbors", &idx); peerstr = argv[++idx]->arg; diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index dfef9a8f79..476bb3aa05 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -435,8 +435,9 @@ extern void route_vty_out(struct vty *, struct prefix *, struct bgp_info *, int, safi_t, json_object *); extern void route_vty_out_tag(struct vty *, struct prefix *, struct bgp_info *, int, safi_t, json_object *); -extern void route_vty_out_tmp(struct vty *, struct prefix *, struct attr *, - safi_t, uint8_t, json_object *); +extern void route_vty_out_tmp(struct vty *vty, struct prefix *p, + struct attr *attr, safi_t safi, bool use_json, + json_object *json_ar); extern void route_vty_out_overlay(struct vty *vty, struct prefix *p, struct bgp_info *binfo, int display, json_object *json); @@ -484,5 +485,5 @@ extern void route_vty_out_detail(struct vty *vty, struct bgp *bgp, extern int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi, struct bgp_table *table, struct prefix_rd *prd, enum bgp_show_type type, void *output_arg, - uint8_t use_json); + bool use_json); #endif /* _QUAGGA_BGP_ROUTE_H */ diff --git a/bgpd/bgp_vpn.c b/bgpd/bgp_vpn.c index a771eedf0f..2b4477ddde 100644 --- a/bgpd/bgp_vpn.c +++ b/bgpd/bgp_vpn.c @@ -32,7 +32,7 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer, struct prefix_rd *prd, afi_t afi, safi_t safi, - uint8_t use_json) + bool use_json) { struct bgp *bgp; struct bgp_table *table; diff --git a/bgpd/bgp_vpn.h b/bgpd/bgp_vpn.h index 98b4d9f180..a2e86476a2 100644 --- a/bgpd/bgp_vpn.h +++ b/bgpd/bgp_vpn.h @@ -25,6 +25,6 @@ extern int show_adj_route_vpn(struct vty *vty, struct peer *peer, struct prefix_rd *prd, afi_t afi, safi_t safi, - uint8_t use_json); + bool use_json); #endif /* _QUAGGA_BGP_VPN_H */ diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 99c6f39230..3669ea7736 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -301,7 +301,7 @@ int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, struct cmd_token **argv, int argc, int *idx, afi_t *afi, safi_t *safi, - struct bgp **bgp) + struct bgp **bgp, bool use_json) { char *vrf_name = NULL; @@ -325,9 +325,11 @@ int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, else { *bgp = bgp_lookup_by_name(vrf_name); if (!*bgp) { - vty_out(vty, - "View/Vrf specified is unknown: %s\n", - vrf_name); + if (use_json) + vty_out(vty, "{}\n"); + else + vty_out(vty, "View/Vrf %s is unknown\n", + vrf_name); *idx = 0; return 0; } @@ -335,7 +337,11 @@ int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, } else { *bgp = bgp_get_default(); if (!*bgp) { - vty_out(vty, "Unable to find default BGP instance\n"); + if (use_json) + vty_out(vty, "{}\n"); + else + vty_out(vty, + "Default BGP instance not found\n"); *idx = 0; return 0; } @@ -7343,7 +7349,7 @@ DEFUN (show_bgp_vrfs, struct list *inst = bm->bgp; struct listnode *node; struct bgp *bgp; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); json_object *json = NULL; json_object *json_vrfs = NULL; int count = 0; @@ -7672,7 +7678,7 @@ static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) /* Show BGP peer's summary information. */ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, - uint8_t use_json, json_object *json) + bool use_json, json_object *json) { struct peer *peer; struct listnode *node, *nnode; @@ -8089,14 +8095,14 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, } static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, - int safi, uint8_t use_json, + int safi, bool use_json, json_object *json) { int is_first = 1; int afi_wildcard = (afi == AFI_MAX); int safi_wildcard = (safi == SAFI_MAX); int is_wildcard = (afi_wildcard || safi_wildcard); - bool json_output = false; + bool nbr_output = false; if (use_json && is_wildcard) vty_out(vty, "{\n"); @@ -8107,7 +8113,7 @@ static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, safi = 1; /* SAFI_UNICAST */ while (safi < SAFI_MAX) { if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { - json_output = true; + nbr_output = true; if (is_wildcard) { /* * So limit output to those afi/safi @@ -8146,22 +8152,28 @@ static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, if (use_json && is_wildcard) vty_out(vty, "}\n"); - else if (use_json && !json_output) - vty_out(vty, "{}\n"); + else if (!nbr_output) { + if (use_json) + vty_out(vty, "{}\n"); + else + vty_out(vty, "%% No BGP neighbors found\n"); + } } static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, - safi_t safi, uint8_t use_json) + safi_t safi, bool use_json) { struct listnode *node, *nnode; struct bgp *bgp; json_object *json = NULL; int is_first = 1; + bool nbr_output = false; if (use_json) vty_out(vty, "{\n"); for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { + nbr_output = true; if (use_json) { json = json_object_new_object(); @@ -8185,10 +8197,12 @@ static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, if (use_json) vty_out(vty, "}\n"); + else if (!nbr_output) + vty_out(vty, "%% BGP instance not found\n"); } int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, - safi_t safi, uint8_t use_json) + safi_t safi, bool use_json) { struct bgp *bgp; @@ -8205,7 +8219,7 @@ int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, vty_out(vty, "{}\n"); else vty_out(vty, - "%% No such BGP instance exist\n"); + "%% BGP instance not found\n"); return CMD_WARNING; } @@ -8219,6 +8233,13 @@ int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, if (bgp) bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, NULL); + else { + if (use_json) + vty_out(vty, "{}\n"); + else + vty_out(vty, "%% BGP instance not found\n"); + return CMD_WARNING; + } return CMD_SUCCESS; } @@ -8258,7 +8279,7 @@ DEFUN (show_ip_bgp_summary, argv_find_and_parse_safi(argv, argc, &idx, &safi); } - int uj = use_json(argc, argv); + bool uj = use_json(argc, argv); return bgp_show_summary_vty(vty, vrf, afi, safi, uj); } @@ -8340,7 +8361,7 @@ static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, afi_t afi, safi_t safi, uint16_t adv_smcap, uint16_t adv_rmcap, uint16_t rcv_smcap, uint16_t rcv_rmcap, - uint8_t use_json, json_object *json_pref) + bool use_json, json_object *json_pref) { /* Send-Mode */ if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) @@ -8400,7 +8421,7 @@ static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, } static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, - safi_t safi, uint8_t use_json, + safi_t safi, bool use_json, json_object *json_neigh) { struct bgp_filter *filter; @@ -8975,7 +8996,7 @@ static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, } } -static void bgp_show_peer(struct vty *vty, struct peer *p, uint8_t use_json, +static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, json_object *json) { struct bgp *bgp; @@ -10722,12 +10743,13 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, uint8_t use_json, static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, enum show_type type, union sockunion *su, - const char *conf_if, uint8_t use_json, + const char *conf_if, bool use_json, json_object *json) { struct listnode *node, *nnode; struct peer *peer; int find = 0; + bool nbr_output = false; for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) @@ -10736,6 +10758,7 @@ static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, switch (type) { case show_all: bgp_show_peer(vty, peer, use_json, json); + nbr_output = true; break; case show_peer: if (conf_if) { @@ -10765,6 +10788,9 @@ static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, vty_out(vty, "%% No such neighbor in this view/vrf\n"); } + if (type != show_peer && !nbr_output && !use_json) + vty_out(vty, "%% No BGP neighbors found\n"); + if (use_json) { vty_out(vty, "%s\n", json_object_to_json_string_ext( json, JSON_C_TO_STRING_PRETTY)); @@ -10779,18 +10805,20 @@ static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, static void bgp_show_all_instances_neighbors_vty(struct vty *vty, enum show_type type, const char *ip_str, - uint8_t use_json) + bool use_json) { struct listnode *node, *nnode; struct bgp *bgp; union sockunion su; json_object *json = NULL; int ret, is_first = 1; + bool nbr_output = false; if (use_json) vty_out(vty, "{\n"); for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { + nbr_output = true; if (use_json) { if (!(json = json_object_new_object())) { flog_err( @@ -10843,11 +10871,13 @@ static void bgp_show_all_instances_neighbors_vty(struct vty *vty, if (use_json) vty_out(vty, "}\n"); + else if (!nbr_output) + vty_out(vty, "%% BGP instance not found\n"); } static int bgp_show_neighbor_vty(struct vty *vty, const char *name, enum show_type type, const char *ip_str, - uint8_t use_json) + bool use_json) { int ret; struct bgp *bgp; @@ -10864,8 +10894,6 @@ static int bgp_show_neighbor_vty(struct vty *vty, const char *name, if (!bgp) { if (use_json) { json = json_object_new_object(); - json_object_boolean_true_add( - json, "bgpNoSuchInstance"); vty_out(vty, "%s\n", json_object_to_json_string_ext( json, @@ -10873,7 +10901,7 @@ static int bgp_show_neighbor_vty(struct vty *vty, const char *name, json_object_free(json); } else vty_out(vty, - "%% No such BGP instance exist\n"); + "%% BGP instance not found\n"); return CMD_WARNING; } @@ -10897,6 +10925,11 @@ static int bgp_show_neighbor_vty(struct vty *vty, const char *name, json); } json_object_free(json); + } else { + if (use_json) + vty_out(vty, "{}\n"); + else + vty_out(vty, "%% BGP instance not found\n"); } return CMD_SUCCESS; @@ -10922,7 +10955,7 @@ DEFUN (show_ip_bgp_neighbors, char *sh_arg = NULL; enum show_type sh_type; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); int idx = 0; @@ -11037,8 +11070,8 @@ DEFUN (show_ip_bgp_attr_info, return CMD_SUCCESS; } -static int bgp_show_route_leak_vty(struct vty *vty, const char *name, - afi_t afi, safi_t safi, uint8_t use_json) +static int bgp_show_route_leak_vty(struct vty *vty, const char *name, afi_t afi, + safi_t safi, bool use_json) { struct bgp *bgp; struct listnode *node; @@ -11054,16 +11087,9 @@ static int bgp_show_route_leak_vty(struct vty *vty, const char *name, json = json_object_new_object(); - /* Provide context for the block */ - json_object_string_add(json, "vrf", name ? name : "default"); - json_object_string_add(json, "afiSafi", - afi_safi_print(afi, safi)); - bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); if (!bgp) { - json_object_boolean_true_add(json, - "bgpNoSuchInstance"); vty_out(vty, "%s\n", json_object_to_json_string_ext( json, @@ -11073,6 +11099,11 @@ static int bgp_show_route_leak_vty(struct vty *vty, const char *name, return CMD_WARNING; } + /* Provide context for the block */ + json_object_string_add(json, "vrf", name ? name : "default"); + json_object_string_add(json, "afiSafi", + afi_safi_print(afi, safi)); + if (!CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_VRF_TO_VRF_IMPORT)) { json_object_string_add(json, "importFromVrfs", "none"); @@ -11211,7 +11242,7 @@ DEFUN (show_ip_bgp_route_leak, afi_t afi = AFI_MAX; safi_t safi = SAFI_MAX; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); int idx = 0; /* show [ip] bgp */ @@ -11536,7 +11567,7 @@ static int bgp_show_peer_group_vty(struct vty *vty, const char *name, bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); if (!bgp) { - vty_out(vty, "%% No such BGP instance exists\n"); + vty_out(vty, "%% BGP instance not found\n"); return CMD_WARNING; } diff --git a/bgpd/bgp_vty.h b/bgpd/bgp_vty.h index afb85f112b..d9df2b4cfe 100644 --- a/bgpd/bgp_vty.h +++ b/bgpd/bgp_vty.h @@ -69,9 +69,10 @@ extern int argv_find_and_parse_safi(struct cmd_token **argv, int argc, extern int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, struct cmd_token **argv, int argc, int *idx, afi_t *afi, - safi_t *safi, struct bgp **bgp); + safi_t *safi, struct bgp **bgp, + bool use_json); extern int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, - safi_t safi, uint8_t use_json); + safi_t safi, bool use_json); extern void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, afi_t afi); #endif /* _QUAGGA_BGP_VTY_H */ diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index e6c517a9f9..a9707a7fc7 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -6626,7 +6626,7 @@ int peer_clear_soft(struct peer *peer, afi_t afi, safi_t safi, } /* Display peer uptime.*/ -char *peer_uptime(time_t uptime2, char *buf, size_t len, uint8_t use_json, +char *peer_uptime(time_t uptime2, char *buf, size_t len, bool use_json, json_object *json) { time_t uptime1, epoch_tbuf; diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 06eb86da95..8a99741390 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -1513,7 +1513,8 @@ extern struct peer *peer_create(union sockunion *, const char *, struct bgp *, struct peer_group *); extern struct peer *peer_create_accept(struct bgp *); extern void peer_xfer_config(struct peer *dst, struct peer *src); -extern char *peer_uptime(time_t, char *, size_t, uint8_t, json_object *); +extern char *peer_uptime(time_t uptime2, char *buf, size_t len, bool use_json, + json_object *json); extern int bgp_config_write(struct vty *); diff --git a/lib/bfd.c b/lib/bfd.c index 0eddb47514..1dfe583caf 100644 --- a/lib/bfd.c +++ b/lib/bfd.c @@ -342,7 +342,7 @@ static void bfd_last_update(time_t last_update, char *buf, size_t len) * bfd_show_param - Show the BFD parameter information. */ void bfd_show_param(struct vty *vty, struct bfd_info *bfd_info, int bfd_tag, - int extra_space, uint8_t use_json, json_object *json_obj) + int extra_space, bool use_json, json_object *json_obj) { json_object *json_bfd = NULL; @@ -378,7 +378,7 @@ void bfd_show_param(struct vty *vty, struct bfd_info *bfd_info, int bfd_tag, * bfd_show_status - Show the BFD status information. */ static void bfd_show_status(struct vty *vty, struct bfd_info *bfd_info, - int bfd_tag, int extra_space, uint8_t use_json, + int bfd_tag, int extra_space, bool use_json, json_object *json_bfd) { char time_buf[32]; @@ -402,7 +402,7 @@ static void bfd_show_status(struct vty *vty, struct bfd_info *bfd_info, * bfd_show_info - Show the BFD information. */ void bfd_show_info(struct vty *vty, struct bfd_info *bfd_info, int multihop, - int extra_space, uint8_t use_json, json_object *json_obj) + int extra_space, bool use_json, json_object *json_obj) { json_object *json_bfd = NULL; diff --git a/lib/bfd.h b/lib/bfd.h index f824b0fd9b..b1e490a622 100644 --- a/lib/bfd.h +++ b/lib/bfd.h @@ -91,11 +91,11 @@ extern struct interface *bfd_get_peer_info(struct stream *s, struct prefix *dp, const char *bfd_get_status_str(int status); extern void bfd_show_param(struct vty *vty, struct bfd_info *bfd_info, - int bfd_tag, int extra_space, uint8_t use_json, + int bfd_tag, int extra_space, bool use_json, json_object *json_obj); extern void bfd_show_info(struct vty *vty, struct bfd_info *bfd_info, - int multihop, int extra_space, uint8_t use_json, + int multihop, int extra_space, bool use_json, json_object *json_obj); extern void bfd_client_sendmsg(struct zclient *zclient, int command); diff --git a/lib/json.c b/lib/json.c index 40b6aadaa3..4ea20ba178 100644 --- a/lib/json.c +++ b/lib/json.c @@ -28,15 +28,15 @@ * is the *last* keyword on the line no matter * what. */ -int use_json(const int argc, struct cmd_token *argv[]) +bool use_json(const int argc, struct cmd_token *argv[]) { if (argc == 0) - return 0; + return false; if (argv[argc - 1]->arg && strmatch(argv[argc - 1]->text, "json")) - return 1; + return true; - return 0; + return false; } void json_object_string_add(struct json_object *obj, const char *key, diff --git a/lib/json.h b/lib/json.h index 788d1d6efa..d349162304 100644 --- a/lib/json.h +++ b/lib/json.h @@ -52,7 +52,7 @@ extern int json_object_object_get_ex(struct json_object *obj, const char *key, #include "command.h" -extern int use_json(const int argc, struct cmd_token *argv[]); +extern bool use_json(const int argc, struct cmd_token *argv[]); extern void json_object_string_add(struct json_object *obj, const char *key, const char *s); extern void json_object_int_add(struct json_object *obj, const char *key, diff --git a/lib/plist.c b/lib/plist.c index 37eb6bc49e..5746080127 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -1900,7 +1900,7 @@ void prefix_bgp_orf_remove_all(afi_t afi, char *name) /* return prefix count */ int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name, - uint8_t use_json) + bool use_json) { struct prefix_list *plist; struct prefix_list_entry *pentry; diff --git a/lib/plist.h b/lib/plist.h index fecbe0e2ce..8a4fa8d3ce 100644 --- a/lib/plist.h +++ b/lib/plist.h @@ -72,6 +72,7 @@ extern struct stream *prefix_bgp_orf_entry(struct stream *, uint8_t, uint8_t); extern int prefix_bgp_orf_set(char *, afi_t, struct orf_prefix *, int, int); extern void prefix_bgp_orf_remove_all(afi_t, char *); -extern int prefix_bgp_show_prefix_list(struct vty *, afi_t, char *, uint8_t); +extern int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name, + bool use_json); #endif /* _QUAGGA_PLIST_H */ diff --git a/ospfd/ospf_bfd.c b/ospfd/ospf_bfd.c index df41897660..594735a08f 100644 --- a/ospfd/ospf_bfd.c +++ b/ospfd/ospf_bfd.c @@ -312,7 +312,7 @@ void ospf_bfd_write_config(struct vty *vty, struct ospf_if_params *params) * ospf_bfd_show_info - Show BFD info structure */ void ospf_bfd_show_info(struct vty *vty, void *bfd_info, json_object *json_obj, - uint8_t use_json, int param_only) + bool use_json, int param_only) { if (param_only) bfd_show_param(vty, (struct bfd_info *)bfd_info, 1, 0, use_json, @@ -326,7 +326,7 @@ void ospf_bfd_show_info(struct vty *vty, void *bfd_info, json_object *json_obj, * ospf_bfd_interface_show - Show the interface BFD configuration. */ void ospf_bfd_interface_show(struct vty *vty, struct interface *ifp, - json_object *json_interface_sub, uint8_t use_json) + json_object *json_interface_sub, bool use_json) { struct ospf_if_params *params; diff --git a/ospfd/ospf_bfd.h b/ospfd/ospf_bfd.h index 6d7caf4217..74385d3268 100644 --- a/ospfd/ospf_bfd.h +++ b/ospfd/ospf_bfd.h @@ -35,13 +35,13 @@ extern void ospf_bfd_trigger_event(struct ospf_neighbor *nbr, int old_state, extern void ospf_bfd_interface_show(struct vty *vty, struct interface *ifp, json_object *json_interface_sub, - uint8_t use_json); + bool use_json); extern void ospf_bfd_info_nbr_create(struct ospf_interface *oi, struct ospf_neighbor *nbr); extern void ospf_bfd_show_info(struct vty *vty, void *bfd_info, - json_object *json_obj, uint8_t use_json, + json_object *json_obj, bool use_json, int param_only); extern void ospf_bfd_info_free(void **bfd_info); diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 39f14a00c3..aa877903fc 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -2623,7 +2623,7 @@ const char *ospf_abr_type_descr_str[] = {"Unknown", "Standard (RFC2328)", const char *ospf_shortcut_mode_descr_str[] = {"Default", "Enabled", "Disabled"}; static void show_ip_ospf_area(struct vty *vty, struct ospf_area *area, - json_object *json_areas, uint8_t use_json) + json_object *json_areas, bool use_json) { json_object *json_area = NULL; @@ -3243,7 +3243,7 @@ DEFUN (show_ip_ospf, JSON_STR) { struct ospf *ospf; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct listnode *node = NULL; char *vrf_name = NULL; bool all_vrf = FALSE; @@ -3263,11 +3263,15 @@ DEFUN (show_ip_ospf, /* vrf input is provided could be all or specific vrf*/ if (vrf_name) { + bool ospf_output = FALSE; + use_vrf = 1; + if (all_vrf) { for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { if (!ospf->oi_running) continue; + ospf_output = TRUE; ret = show_ip_ospf_common(vty, ospf, json, use_vrf); } @@ -3276,21 +3280,34 @@ DEFUN (show_ip_ospf, json_object_to_json_string_ext( json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); - } + } else if (!ospf_output) + vty_out(vty, "%% OSPF instance not found\n"); return ret; } ospf = ospf_lookup_by_inst_name(inst, vrf_name); if ((ospf == NULL) || !ospf->oi_running) { - if (uj) + if (uj) { + vty_out(vty, "%s\n", + json_object_to_json_string_ext( + json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); + } else + vty_out(vty, "%% OSPF instance not found\n"); + return CMD_SUCCESS; } } else { ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); /* Display default ospf (instance 0) info */ if (ospf == NULL || !ospf->oi_running) { - if (uj) + if (uj) { + vty_out(vty, "%s\n", + json_object_to_json_string_ext( + json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); + } else + vty_out(vty, "%% OSPF instance not found\n"); + return CMD_SUCCESS; } } @@ -3321,7 +3338,7 @@ DEFUN (show_ip_ospf_instance, int idx_number = 3; struct ospf *ospf; unsigned short instance = 0; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); int ret = CMD_SUCCESS; json_object *json = NULL; @@ -3350,7 +3367,7 @@ DEFUN (show_ip_ospf_instance, static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf, struct interface *ifp, json_object *json_interface_sub, - uint8_t use_json) + bool use_json) { int is_up; struct ospf_neighbor *nbr; @@ -3667,7 +3684,7 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf, static int show_ip_ospf_interface_common(struct vty *vty, struct ospf *ospf, char *intf_name, uint8_t use_vrf, - json_object *json, uint8_t use_json) + json_object *json, bool use_json) { struct interface *ifp; struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id); @@ -3760,7 +3777,7 @@ static int show_ip_ospf_interface_common(struct vty *vty, struct ospf *ospf, static void show_ip_ospf_interface_traffic_sub(struct vty *vty, struct ospf_interface *oi, json_object *json_interface_sub, - uint8_t use_json) + bool use_json) { if (use_json) { json_object_int_add(json_interface_sub, "ifIndex", @@ -3798,7 +3815,7 @@ static void show_ip_ospf_interface_traffic_sub(struct vty *vty, /* OSPFv2 Packet Counters */ static int show_ip_ospf_interface_traffic_common( struct vty *vty, struct ospf *ospf, char *intf_name, json_object *json, - int display_once, uint8_t use_vrf, uint8_t use_json) + int display_once, uint8_t use_vrf, bool use_json) { struct vrf *vrf = NULL; struct interface *ifp = NULL; @@ -3916,7 +3933,7 @@ DEFUN (show_ip_ospf_interface, JSON_STR) { struct ospf *ospf; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct listnode *node = NULL; char *vrf_name = NULL, *intf_name = NULL; bool all_vrf = FALSE; @@ -3951,14 +3968,21 @@ DEFUN (show_ip_ospf_interface, json_object_to_json_string_ext( json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); - } + } else if (!ospf) + vty_out(vty, "%% OSPF instance not found\n"); return ret; } ospf = ospf_lookup_by_inst_name(inst, vrf_name); if (ospf == NULL || !ospf->oi_running) { - if (uj) + if (uj) { + vty_out(vty, "%s\n", + json_object_to_json_string_ext( + json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); + } else + vty_out(vty, "%% OSPF instance not found\n"); + return CMD_SUCCESS; } ret = show_ip_ospf_interface_common(vty, ospf, intf_name, @@ -3968,8 +3992,14 @@ DEFUN (show_ip_ospf_interface, /* Display default ospf (instance 0) info */ ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); if (ospf == NULL || !ospf->oi_running) { - if (uj) + if (uj) { + vty_out(vty, "%s\n", + json_object_to_json_string_ext( + json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); + } else + vty_out(vty, "%% OSPF instance not found\n"); + return CMD_SUCCESS; } ret = show_ip_ospf_interface_common(vty, ospf, intf_name, @@ -4000,7 +4030,7 @@ DEFUN (show_ip_ospf_instance_interface, int idx_intf = 0; struct ospf *ospf; unsigned short instance = 0; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); char *intf_name = NULL; int ret = CMD_SUCCESS; json_object *json = NULL; @@ -4049,7 +4079,7 @@ DEFUN (show_ip_ospf_interface_traffic, bool all_vrf = FALSE; int inst = 0; int idx_vrf = 0, idx_intf = 0; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); json_object *json = NULL; int ret = CMD_SUCCESS; int display_once = 0; @@ -4125,7 +4155,7 @@ static void show_ip_ospf_neighbour_header(struct vty *vty) static void show_ip_ospf_neighbor_sub(struct vty *vty, struct ospf_interface *oi, - json_object *json, uint8_t use_json) + json_object *json, bool use_json) { struct route_node *rn; struct ospf_neighbor *nbr, *prev_nbr = NULL; @@ -4236,7 +4266,7 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty, } static int show_ip_ospf_neighbor_common(struct vty *vty, struct ospf *ospf, - json_object *json, uint8_t use_json, + json_object *json, bool use_json, uint8_t use_vrf) { struct ospf_interface *oi; @@ -4298,7 +4328,7 @@ DEFUN (show_ip_ospf_neighbor, JSON_STR) { struct ospf *ospf; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct listnode *node = NULL; char *vrf_name = NULL; bool all_vrf = FALSE; @@ -4329,23 +4359,36 @@ DEFUN (show_ip_ospf_neighbor, json_object_to_json_string_ext( json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); - } + } else if (!ospf) + vty_out(vty, "OSPF instance not found\n"); return ret; } ospf = ospf_lookup_by_inst_name(inst, vrf_name); if (ospf == NULL || !ospf->oi_running) { - if (uj) + if (uj) { + vty_out(vty, "%s\n", + json_object_to_json_string_ext( + json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); + } else + vty_out(vty, "%% OSPF instance not found\n"); + return CMD_SUCCESS; } } else { /* Display default ospf (instance 0) info */ ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); if (ospf == NULL || !ospf->oi_running) { - if (uj) + if (uj) { + vty_out(vty, "%s\n", + json_object_to_json_string_ext( + json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); + } else + vty_out(vty, "%% OSPF instance not found\n"); + return CMD_SUCCESS; } } @@ -4381,7 +4424,7 @@ DEFUN (show_ip_ospf_instance_neighbor, int idx_number = 3; struct ospf *ospf; unsigned short instance = 0; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); json_object *json = NULL; int ret = CMD_SUCCESS; @@ -4408,7 +4451,7 @@ DEFUN (show_ip_ospf_instance_neighbor, } static int show_ip_ospf_neighbor_all_common(struct vty *vty, struct ospf *ospf, - json_object *json, uint8_t use_json, + json_object *json, bool use_json, uint8_t use_vrf) { struct listnode *node; @@ -4511,7 +4554,7 @@ DEFUN (show_ip_ospf_neighbor_all, JSON_STR) { struct ospf *ospf; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct listnode *node = NULL; char *vrf_name = NULL; bool all_vrf = FALSE; @@ -4593,7 +4636,7 @@ DEFUN (show_ip_ospf_instance_neighbor_all, int idx_number = 3; struct ospf *ospf; unsigned short instance = 0; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); json_object *json = NULL; int ret = CMD_SUCCESS; @@ -4621,7 +4664,7 @@ DEFUN (show_ip_ospf_instance_neighbor_all, static int show_ip_ospf_neighbor_int_common(struct vty *vty, struct ospf *ospf, int arg_base, struct cmd_token **argv, - uint8_t use_json, uint8_t use_vrf) + bool use_json, uint8_t use_vrf) { struct interface *ifp; struct route_node *rn; @@ -4680,7 +4723,7 @@ DEFUN (show_ip_ospf_neighbor_int, { struct ospf *ospf; int idx_ifname = 4; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct listnode *node = NULL; int ret = CMD_SUCCESS; struct interface *ifp = NULL; @@ -4716,7 +4759,7 @@ DEFUN (show_ip_ospf_instance_neighbor_int, int idx_ifname = 5; struct ospf *ospf; unsigned short instance = 0; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (!uj) show_ip_ospf_neighbour_header(vty); @@ -4739,8 +4782,7 @@ DEFUN (show_ip_ospf_instance_neighbor_int, static void show_ip_ospf_nbr_nbma_detail_sub(struct vty *vty, struct ospf_interface *oi, struct ospf_nbr_nbma *nbr_nbma, - uint8_t use_json, - json_object *json) + bool use_json, json_object *json) { char timebuf[OSPF_TIME_DUMP_SIZE]; json_object *json_sub = NULL; @@ -4820,8 +4862,7 @@ static void show_ip_ospf_nbr_nbma_detail_sub(struct vty *vty, static void show_ip_ospf_neighbor_detail_sub(struct vty *vty, struct ospf_interface *oi, struct ospf_neighbor *nbr, - json_object *json, - uint8_t use_json) + json_object *json, bool use_json) { char timebuf[OSPF_TIME_DUMP_SIZE]; json_object *json_sub = NULL; @@ -5037,7 +5078,7 @@ static void show_ip_ospf_neighbor_detail_sub(struct vty *vty, static int show_ip_ospf_neighbor_id_common(struct vty *vty, struct ospf *ospf, int arg_base, struct cmd_token **argv, - uint8_t use_json, uint8_t use_vrf) + bool use_json, uint8_t use_vrf) { struct listnode *node; struct ospf_neighbor *nbr; @@ -5098,7 +5139,7 @@ DEFUN (show_ip_ospf_neighbor_id, JSON_STR) { struct ospf *ospf; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct listnode *node = NULL; int ret = CMD_SUCCESS; @@ -5127,7 +5168,7 @@ DEFUN (show_ip_ospf_instance_neighbor_id, int idx_router_id = 5; struct ospf *ospf; unsigned short instance = 0; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); instance = strtoul(argv[idx_number]->arg, NULL, 10); ospf = ospf_lookup_instance(instance); @@ -5143,8 +5184,7 @@ DEFUN (show_ip_ospf_instance_neighbor_id, static int show_ip_ospf_neighbor_detail_common(struct vty *vty, struct ospf *ospf, - json_object *json, - uint8_t use_json, + json_object *json, bool use_json, uint8_t use_vrf) { struct ospf_interface *oi; @@ -5212,7 +5252,7 @@ DEFUN (show_ip_ospf_neighbor_detail, JSON_STR) { struct ospf *ospf; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct listnode *node = NULL; char *vrf_name = NULL; bool all_vrf = FALSE; @@ -5292,7 +5332,7 @@ DEFUN (show_ip_ospf_instance_neighbor_detail, int idx_number = 3; struct ospf *ospf; unsigned short instance = 0; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); json_object *json = NULL; int ret = CMD_SUCCESS; @@ -5321,7 +5361,7 @@ DEFUN (show_ip_ospf_instance_neighbor_detail, static int show_ip_ospf_neighbor_detail_all_common(struct vty *vty, struct ospf *ospf, json_object *json, - uint8_t use_json, + bool use_json, uint8_t use_vrf) { struct listnode *node; @@ -5401,7 +5441,7 @@ DEFUN (show_ip_ospf_neighbor_detail_all, JSON_STR) { struct ospf *ospf; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct listnode *node = NULL; char *vrf_name = NULL; bool all_vrf = FALSE; @@ -5483,7 +5523,7 @@ DEFUN (show_ip_ospf_instance_neighbor_detail_all, int idx_number = 3; struct ospf *ospf; unsigned short instance = 0; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); json_object *json = NULL; int ret = CMD_SUCCESS; @@ -5513,7 +5553,7 @@ static int show_ip_ospf_neighbor_int_detail_common(struct vty *vty, struct ospf *ospf, int arg_base, struct cmd_token **argv, - uint8_t use_json) + bool use_json) { struct ospf_interface *oi; struct interface *ifp; @@ -5581,17 +5621,22 @@ DEFUN (show_ip_ospf_neighbor_int_detail, JSON_STR) { struct ospf *ospf; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct listnode *node = NULL; int ret = CMD_SUCCESS; + bool ospf_output = FALSE; for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { if (!ospf->oi_running) continue; + ospf_output = TRUE; ret = show_ip_ospf_neighbor_int_detail_common(vty, ospf, 0, argv, uj); } + if (!ospf_output) + vty_out(vty, "%% OSPF instance not found\n"); + return ret; } @@ -5611,7 +5656,7 @@ DEFUN (show_ip_ospf_instance_neighbor_int_detail, int idx_ifname = 5; struct ospf *ospf; unsigned short instance = 0; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); instance = strtoul(argv[idx_number]->arg, NULL, 10); ospf = ospf_lookup_instance(instance); @@ -6296,19 +6341,28 @@ DEFUN (show_ip_ospf_database_max, OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); if (vrf_name) { + bool ospf_output = FALSE; + use_vrf = 1; + if (all_vrf) { for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { if (!ospf->oi_running) continue; + ospf_output = TRUE; ret = show_ip_ospf_database_common( vty, ospf, idx_vrf ? 2 : 0, argc, argv, use_vrf); } + + if (!ospf_output) + vty_out(vty, "%% OSPF instance not found\n"); } else { ospf = ospf_lookup_by_inst_name(inst, vrf_name); - if (ospf == NULL || !ospf->oi_running) + if (ospf == NULL || !ospf->oi_running) { + vty_out(vty, "%% OSPF instance not found\n"); return CMD_SUCCESS; + } ret = (show_ip_ospf_database_common( vty, ospf, idx_vrf ? 2 : 0, argc, argv, use_vrf)); @@ -6316,8 +6370,11 @@ DEFUN (show_ip_ospf_database_max, } else { /* Display default ospf (instance 0) info */ ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); - if (ospf == NULL || !ospf->oi_running) + if (ospf == NULL || !ospf->oi_running) { + vty_out(vty, "%% OSPF instance not found\n"); return CMD_SUCCESS; + } + ret = show_ip_ospf_database_common(vty, ospf, 0, argc, argv, use_vrf); } @@ -6377,16 +6434,22 @@ DEFUN (show_ip_ospf_instance_database, } } else { ospf = ospf_lookup_by_inst_name(inst, vrf_name); - if ((ospf == NULL) || !ospf->oi_running) + if ((ospf == NULL) || !ospf->oi_running) { + vty_out(vty, "%% OSPF instance not found\n"); return CMD_SUCCESS; + } + ret = (show_ip_ospf_database_common( vty, ospf, idx ? 2 : 0, argc, argv, use_vrf)); } } else { /* Display default ospf (instance 0) info */ ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); - if (ospf == NULL || !ospf->oi_running) + if (ospf == NULL || !ospf->oi_running) { + vty_out(vty, "%% OSPF instance not found\n"); return CMD_SUCCESS; + } + ret = (show_ip_ospf_database_common(vty, ospf, 0, argc, argv, use_vrf)); } @@ -6415,8 +6478,10 @@ DEFUN (show_ip_ospf_instance_database_max, if (ospf == NULL) return CMD_NOT_MY_INSTANCE; - if (!ospf->oi_running) + if (!ospf->oi_running) { + vty_out(vty, "%% OSPF instance not found\n"); return CMD_SUCCESS; + } return show_ip_ospf_database_common(vty, ospf, 1, argc, argv, 0); } @@ -6505,8 +6570,11 @@ DEFUN (show_ip_ospf_instance_database_type_adv_router, ospf = ospf_lookup_instance(instance); if (ospf == NULL) return CMD_NOT_MY_INSTANCE; - if (!ospf->oi_running) + if (!ospf->oi_running) { + vty_out(vty, "%% OSPF instance not found\n"); return CMD_SUCCESS; + } + return (show_ip_ospf_database_type_adv_router_common( vty, ospf, idx ? 1 : 0, argc, argv, use_vrf)); } @@ -6514,27 +6582,39 @@ DEFUN (show_ip_ospf_instance_database_type_adv_router, OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); if (vrf_name) { + bool ospf_output = FALSE; + use_vrf = 1; + if (all_vrf) { for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { if (!ospf->oi_running) continue; + ospf_output = TRUE; ret = show_ip_ospf_database_type_adv_router_common( vty, ospf, idx ? 1 : 0, argc, argv, use_vrf); } + if (!ospf_output) + vty_out(vty, "%% OSPF instance not found\n"); } else { ospf = ospf_lookup_by_inst_name(inst, vrf_name); - if ((ospf == NULL) || !ospf->oi_running) + if ((ospf == NULL) || !ospf->oi_running) { + vty_out(vty, "%% OSPF instance not found\n"); return CMD_SUCCESS; + } + ret = show_ip_ospf_database_type_adv_router_common( vty, ospf, idx ? 1 : 0, argc, argv, use_vrf); } } else { /* Display default ospf (instance 0) info */ ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); - if (ospf == NULL || !ospf->oi_running) + if (ospf == NULL || !ospf->oi_running) { + vty_out(vty, "%% OSPF instance not found\n"); return CMD_SUCCESS; + } + ret = show_ip_ospf_database_type_adv_router_common( vty, ospf, idx ? 1 : 0, argc, argv, use_vrf); } @@ -9271,19 +9351,28 @@ DEFUN (show_ip_ospf_border_routers, OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); if (vrf_name) { + bool ospf_output = FALSE; + use_vrf = 1; + if (all_vrf) { for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { if (!ospf->oi_running) continue; + ospf_output = TRUE; ret = show_ip_ospf_border_routers_common( vty, ospf, use_vrf); } + + if (!ospf_output) + vty_out(vty, "%% OSPF instance not found\n"); } else { ospf = ospf_lookup_by_inst_name(inst, vrf_name); - if (ospf == NULL || !ospf->oi_running) + if (ospf == NULL || !ospf->oi_running) { + vty_out(vty, "%% OSPF instance not found\n"); return CMD_SUCCESS; + } ret = show_ip_ospf_border_routers_common(vty, ospf, use_vrf); @@ -9291,8 +9380,11 @@ DEFUN (show_ip_ospf_border_routers, } else { /* Display default ospf (instance 0) info */ ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); - if (ospf == NULL || !ospf->oi_running) + if (ospf == NULL || !ospf->oi_running) { + vty_out(vty, "%% OSPF instance not found\n"); return CMD_SUCCESS; + } + ret = show_ip_ospf_border_routers_common(vty, ospf, use_vrf); } @@ -9393,7 +9485,7 @@ DEFUN (show_ip_ospf_route, int inst = 0; int idx_vrf = 0; uint8_t use_vrf = 0; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); json_object *json = NULL; if (uj) @@ -9403,11 +9495,15 @@ DEFUN (show_ip_ospf_route, /* vrf input is provided could be all or specific vrf*/ if (vrf_name) { + bool ospf_output = FALSE; + use_vrf = 1; + if (all_vrf) { for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { if (!ospf->oi_running) continue; + ospf_output = TRUE; ret = show_ip_ospf_route_common(vty, ospf, json, use_vrf); } @@ -9417,22 +9513,35 @@ DEFUN (show_ip_ospf_route, vty_out(vty, "%s\n", json_object_to_json_string(json)); json_object_free(json); - } + } else if (!ospf_output) + vty_out(vty, "%% OSPF instance not found\n"); return ret; } ospf = ospf_lookup_by_inst_name(inst, vrf_name); if (ospf == NULL || !ospf->oi_running) { - if (uj) + if (uj) { + vty_out(vty, "%s\n", + json_object_to_json_string_ext( + json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); + } else + vty_out(vty, "%% OSPF instance not found\n"); + return CMD_SUCCESS; } } else { /* Display default ospf (instance 0) info */ ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); if (ospf == NULL || !ospf->oi_running) { - if (uj) + if (uj) { + vty_out(vty, "%s\n", + json_object_to_json_string_ext( + json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); + } else + vty_out(vty, "%% OSPF instance not found\n"); + return CMD_SUCCESS; } } @@ -9484,7 +9593,7 @@ DEFUN (show_ip_ospf_vrfs, "Show OSPF VRFs \n" JSON_STR) { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); json_object *json = NULL; json_object *json_vrfs = NULL; struct ospf *ospf = NULL; diff --git a/pimd/pim_bfd.c b/pimd/pim_bfd.c index f7a217b514..466cc60643 100644 --- a/pimd/pim_bfd.c +++ b/pimd/pim_bfd.c @@ -64,7 +64,7 @@ void pim_bfd_write_config(struct vty *vty, struct interface *ifp) * pim_bfd_show_info - Show BFD info structure */ void pim_bfd_show_info(struct vty *vty, void *bfd_info, json_object *json_obj, - uint8_t use_json, int param_only) + bool use_json, int param_only) { if (param_only) bfd_show_param(vty, (struct bfd_info *)bfd_info, 1, 0, use_json, diff --git a/pimd/pim_bfd.h b/pimd/pim_bfd.h index 83def93b66..962b727f88 100644 --- a/pimd/pim_bfd.h +++ b/pimd/pim_bfd.h @@ -28,7 +28,7 @@ void pim_bfd_init(void); void pim_bfd_write_config(struct vty *vty, struct interface *ifp); void pim_bfd_show_info(struct vty *vty, void *bfd_info, json_object *json_obj, - uint8_t use_json, int param_only); + bool use_json, int param_only); void pim_bfd_if_param_set(struct interface *ifp, uint32_t min_rx, uint32_t min_tx, uint8_t detect_mult, int defaults); int pim_bfd_reg_dereg_all_nbr(struct interface *ifp, int command); diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 611d8d3681..918eaf2fdb 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -3373,7 +3373,7 @@ DEFUN (show_ip_igmp_interface, { int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (!vrf) return CMD_WARNING; @@ -3400,7 +3400,7 @@ DEFUN (show_ip_igmp_interface_vrf_all, JSON_STR) { int idx = 2; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct vrf *vrf; bool first = true; @@ -3456,7 +3456,7 @@ DEFUN (show_ip_igmp_join_vrf_all, VRF_CMD_HELP_STR "IGMP static join information\n") { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct vrf *vrf; bool first = true; @@ -3490,7 +3490,7 @@ DEFUN (show_ip_igmp_groups, { int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (!vrf) return CMD_WARNING; @@ -3510,7 +3510,7 @@ DEFUN (show_ip_igmp_groups_vrf_all, IGMP_GROUP_STR JSON_STR) { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct vrf *vrf; bool first = true; @@ -3608,7 +3608,7 @@ DEFUN (show_ip_igmp_statistics, { int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (!vrf) return CMD_WARNING; @@ -3715,7 +3715,7 @@ DEFUN (show_ip_pim_interface, { int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (!vrf) return CMD_WARNING; @@ -3742,7 +3742,7 @@ DEFUN (show_ip_pim_interface_vrf_all, JSON_STR) { int idx = 6; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct vrf *vrf; bool first = true; @@ -3781,7 +3781,7 @@ DEFUN (show_ip_pim_join, { int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (!vrf) return CMD_WARNING; @@ -3801,7 +3801,7 @@ DEFUN (show_ip_pim_join_vrf_all, "PIM interface join information\n" JSON_STR) { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct vrf *vrf; bool first = true; @@ -3835,7 +3835,7 @@ DEFUN (show_ip_pim_local_membership, { int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (!vrf) return CMD_WARNING; @@ -3859,7 +3859,7 @@ DEFUN (show_ip_pim_neighbor, { int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (!vrf) return CMD_WARNING; @@ -3886,7 +3886,7 @@ DEFUN (show_ip_pim_neighbor_vrf_all, JSON_STR) { int idx = 2; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct vrf *vrf; bool first = true; @@ -3949,7 +3949,7 @@ DEFUN (show_ip_pim_state, const char *group = NULL; int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (!vrf) return CMD_WARNING; @@ -3983,7 +3983,7 @@ DEFUN (show_ip_pim_state_vrf_all, const char *src_or_group = NULL; const char *group = NULL; int idx = 2; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct vrf *vrf; bool first = true; @@ -4026,7 +4026,7 @@ DEFUN (show_ip_pim_upstream, { int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (!vrf) return CMD_WARNING; @@ -4046,7 +4046,7 @@ DEFUN (show_ip_pim_upstream_vrf_all, "PIM upstream information\n" JSON_STR) { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct vrf *vrf; bool first = true; @@ -4078,7 +4078,7 @@ DEFUN (show_ip_pim_upstream_join_desired, { int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (!vrf) return CMD_WARNING; @@ -4100,7 +4100,7 @@ DEFUN (show_ip_pim_upstream_rpf, { int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (!vrf) return CMD_WARNING; @@ -4122,7 +4122,7 @@ DEFUN (show_ip_pim_rp, { int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (!vrf) return CMD_WARNING; @@ -4142,7 +4142,7 @@ DEFUN (show_ip_pim_rp_vrf_all, "PIM RP information\n" JSON_STR) { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct vrf *vrf; bool first = true; @@ -4176,7 +4176,7 @@ DEFUN (show_ip_pim_rpf, { int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (!vrf) return CMD_WARNING; @@ -4196,7 +4196,7 @@ DEFUN (show_ip_pim_rpf_vrf_all, "PIM cached source rpf information\n" JSON_STR) { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct vrf *vrf; bool first = true; @@ -4349,7 +4349,7 @@ DEFUN (show_ip_pim_interface_traffic, { int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (!vrf) return CMD_WARNING; @@ -4473,7 +4473,7 @@ DEFUN (show_ip_multicast_vrf_all, VRF_CMD_HELP_STR "Multicast global information\n") { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct vrf *vrf; bool first = true; @@ -4830,7 +4830,7 @@ DEFUN (show_ip_mroute, "Fill in Assumed data\n" JSON_STR) { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); bool fill = false; int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); @@ -4855,7 +4855,7 @@ DEFUN (show_ip_mroute_vrf_all, "Fill in Assumed data\n" JSON_STR) { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); int idx = 4; struct vrf *vrf; bool first = true; @@ -4963,7 +4963,7 @@ DEFUN (show_ip_mroute_count_vrf_all, VRF_CMD_HELP_STR "Route and packet count data\n") { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct vrf *vrf; bool first = true; @@ -5578,7 +5578,7 @@ DEFUN (show_ip_pim_ssm_range, { int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (!vrf) return CMD_WARNING; @@ -5631,7 +5631,7 @@ DEFUN (show_ip_pim_group_type, { int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (!vrf) return CMD_WARNING; @@ -7985,7 +7985,7 @@ DEFUN (show_ip_msdp_mesh_group, "MSDP mesh-group information\n" JSON_STR) { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); @@ -8007,7 +8007,7 @@ DEFUN (show_ip_msdp_mesh_group_vrf_all, "MSDP mesh-group information\n" JSON_STR) { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct vrf *vrf; bool first = true; @@ -8200,7 +8200,7 @@ DEFUN (show_ip_msdp_peer_detail, "peer ip address\n" JSON_STR) { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); @@ -8235,7 +8235,7 @@ DEFUN (show_ip_msdp_peer_detail_vrf_all, JSON_STR) { int idx = 2; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct vrf *vrf; bool first = true; @@ -8441,7 +8441,7 @@ DEFUN (show_ip_msdp_sa_detail, "Detailed output\n" JSON_STR) { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); @@ -8464,7 +8464,7 @@ DEFUN (show_ip_msdp_sa_detail_vrf_all, "Detailed output\n" JSON_STR) { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct vrf *vrf; bool first = true; @@ -8556,7 +8556,7 @@ DEFUN (show_ip_msdp_sa_sg, "group ip\n" JSON_STR) { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct vrf *vrf; int idx = 2; @@ -8593,7 +8593,7 @@ DEFUN (show_ip_msdp_sa_sg_vrf_all, "group ip\n" JSON_STR) { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct vrf *vrf; bool first = true; int idx = 2; diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index f7283aed36..8f48cc5191 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -2698,7 +2698,7 @@ void zebra_mpls_lsp_schedule(struct zebra_vrf *zvrf) * (VTY command handler). */ void zebra_mpls_print_lsp(struct vty *vty, struct zebra_vrf *zvrf, - mpls_label_t label, uint8_t use_json) + mpls_label_t label, bool use_json) { struct hash *lsp_table; zebra_lsp_t *lsp; @@ -2729,7 +2729,7 @@ void zebra_mpls_print_lsp(struct vty *vty, struct zebra_vrf *zvrf, * Display MPLS label forwarding table (VTY command handler). */ void zebra_mpls_print_lsp_table(struct vty *vty, struct zebra_vrf *zvrf, - uint8_t use_json) + bool use_json) { char buf[BUFSIZ]; json_object *json = NULL; diff --git a/zebra/zebra_mpls.h b/zebra/zebra_mpls.h index 65204a67dc..86bee129cf 100644 --- a/zebra/zebra_mpls.h +++ b/zebra/zebra_mpls.h @@ -349,13 +349,13 @@ void zebra_mpls_lsp_schedule(struct zebra_vrf *zvrf); * (VTY command handler). */ void zebra_mpls_print_lsp(struct vty *vty, struct zebra_vrf *zvrf, - mpls_label_t label, uint8_t use_json); + mpls_label_t label, bool use_json); /* * Display MPLS label forwarding table (VTY command handler). */ void zebra_mpls_print_lsp_table(struct vty *vty, struct zebra_vrf *zvrf, - uint8_t use_json); + bool use_json); /* * Display MPLS LSP configuration of all static LSPs (VTY command handler). diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 4f1d5cf6d5..de08e323af 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -55,7 +55,7 @@ extern int allow_delete; static int do_show_ip_route(struct vty *vty, const char *vrf_name, afi_t afi, - safi_t safi, bool use_fib, uint8_t use_json, + safi_t safi, bool use_fib, bool use_json, route_tag_t tag, const struct prefix *longer_prefix_p, bool supernets_only, int type, @@ -135,7 +135,7 @@ DEFUN (show_ip_rpf, "Display RPF information for multicast source\n" JSON_STR) { - int uj = use_json(argc, argv); + bool uj = use_json(argc, argv); return do_show_ip_route(vty, VRF_DEFAULT_NAME, AFI_IP, SAFI_MULTICAST, false, uj, 0, NULL, false, 0, 0); } @@ -760,8 +760,7 @@ static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf, bool use_fib, route_tag_t tag, const struct prefix *longer_prefix_p, bool supernets_only, int type, - unsigned short ospf_instance_id, - uint8_t use_json) + unsigned short ospf_instance_id, bool use_json) { struct route_node *rn; struct route_entry *re; @@ -850,7 +849,7 @@ static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf, } static int do_show_ip_route(struct vty *vty, const char *vrf_name, afi_t afi, - safi_t safi, bool use_fib, uint8_t use_json, + safi_t safi, bool use_fib, bool use_json, route_tag_t tag, const struct prefix *longer_prefix_p, bool supernets_only, int type, @@ -1723,7 +1722,7 @@ DEFUN (show_vrf_vni, struct zebra_vrf *zvrf; json_object *json = NULL; json_object *json_vrfs = NULL; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (uj) { json = json_object_new_object(); @@ -1759,7 +1758,7 @@ DEFUN (show_evpn_global, "EVPN\n" JSON_STR) { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); zebra_vxlan_print_evpn(vty, uj); return CMD_SUCCESS; @@ -1774,7 +1773,7 @@ DEFUN (show_evpn_vni, JSON_STR) { struct zebra_vrf *zvrf; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); zvrf = vrf_info_lookup(VRF_DEFAULT); zebra_vxlan_print_vnis(vty, zvrf, uj); @@ -1792,7 +1791,7 @@ DEFUN (show_evpn_vni_vni, { struct zebra_vrf *zvrf; vni_t vni; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); vni = strtoul(argv[3]->arg, NULL, 10); zvrf = vrf_info_lookup(VRF_DEFAULT); @@ -1814,7 +1813,7 @@ DEFUN (show_evpn_rmac_vni_mac, { vni_t l3vni = 0; struct ethaddr mac; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); l3vni = strtoul(argv[4]->arg, NULL, 10); if (!prefix_str2mac(argv[6]->arg, &mac)) { @@ -1836,7 +1835,7 @@ DEFUN (show_evpn_rmac_vni, JSON_STR) { vni_t l3vni = 0; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); l3vni = strtoul(argv[4]->arg, NULL, 10); zebra_vxlan_print_rmacs_l3vni(vty, l3vni, uj); @@ -1854,7 +1853,7 @@ DEFUN (show_evpn_rmac_vni_all, "All VNIs\n" JSON_STR) { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); zebra_vxlan_print_rmacs_all_l3vni(vty, uj); @@ -1875,7 +1874,7 @@ DEFUN (show_evpn_nh_vni_ip, { vni_t l3vni; struct ipaddr ip; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); l3vni = strtoul(argv[4]->arg, NULL, 10); if (str2ipaddr(argv[6]->arg, &ip) != 0) { @@ -1899,7 +1898,7 @@ DEFUN (show_evpn_nh_vni, JSON_STR) { vni_t l3vni; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); l3vni = strtoul(argv[4]->arg, NULL, 10); zebra_vxlan_print_nh_l3vni(vty, l3vni, uj); @@ -1917,7 +1916,7 @@ DEFUN (show_evpn_nh_vni_all, "All VNIs\n" JSON_STR) { - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); zebra_vxlan_print_nh_all_l3vni(vty, uj); @@ -1936,7 +1935,7 @@ DEFUN (show_evpn_mac_vni, { struct zebra_vrf *zvrf; vni_t vni; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); vni = strtoul(argv[4]->arg, NULL, 10); zvrf = vrf_info_lookup(VRF_DEFAULT); @@ -1955,7 +1954,7 @@ DEFUN (show_evpn_mac_vni_all, JSON_STR) { struct zebra_vrf *zvrf; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); zvrf = vrf_info_lookup(VRF_DEFAULT); zebra_vxlan_print_macs_all_vni(vty, zvrf, uj); @@ -1976,7 +1975,7 @@ DEFUN (show_evpn_mac_vni_all_vtep, { struct zebra_vrf *zvrf; struct in_addr vtep_ip; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (!inet_aton(argv[6]->arg, &vtep_ip)) { if (!uj) @@ -2030,7 +2029,7 @@ DEFUN (show_evpn_mac_vni_vtep, struct zebra_vrf *zvrf; vni_t vni; struct in_addr vtep_ip; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); vni = strtoul(argv[4]->arg, NULL, 10); if (!inet_aton(argv[6]->arg, &vtep_ip)) { @@ -2056,7 +2055,7 @@ DEFUN (show_evpn_neigh_vni, { struct zebra_vrf *zvrf; vni_t vni; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); vni = strtoul(argv[4]->arg, NULL, 10); zvrf = vrf_info_lookup(VRF_DEFAULT); @@ -2075,7 +2074,7 @@ DEFUN (show_evpn_neigh_vni_all, JSON_STR) { struct zebra_vrf *zvrf; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); zvrf = vrf_info_lookup(VRF_DEFAULT); zebra_vxlan_print_neigh_all_vni(vty, zvrf, uj); @@ -2097,7 +2096,7 @@ DEFUN (show_evpn_neigh_vni_neigh, struct zebra_vrf *zvrf; vni_t vni; struct ipaddr ip; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); vni = strtoul(argv[4]->arg, NULL, 10); if (str2ipaddr(argv[6]->arg, &ip) != 0) { @@ -2125,7 +2124,7 @@ DEFUN (show_evpn_neigh_vni_vtep, struct zebra_vrf *zvrf; vni_t vni; struct in_addr vtep_ip; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); vni = strtoul(argv[4]->arg, NULL, 10); if (!inet_aton(argv[6]->arg, &vtep_ip)) { diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index b0fc0a39bd..9aced13a4f 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -4057,8 +4057,7 @@ void zebra_vxlan_evpn_vrf_route_del(vrf_id_t vrf_id, } void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty, vni_t l3vni, - struct ethaddr *rmac, - uint8_t use_json) + struct ethaddr *rmac, bool use_json) { zebra_l3vni_t *zl3vni = NULL; zebra_mac_t *zrmac = NULL; @@ -4102,8 +4101,7 @@ void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty, vni_t l3vni, } } -void zebra_vxlan_print_rmacs_l3vni(struct vty *vty, vni_t l3vni, - uint8_t use_json) +void zebra_vxlan_print_rmacs_l3vni(struct vty *vty, vni_t l3vni, bool use_json) { zebra_l3vni_t *zl3vni; uint32_t num_rmacs; @@ -4147,7 +4145,7 @@ void zebra_vxlan_print_rmacs_l3vni(struct vty *vty, vni_t l3vni, } } -void zebra_vxlan_print_rmacs_all_l3vni(struct vty *vty, uint8_t use_json) +void zebra_vxlan_print_rmacs_all_l3vni(struct vty *vty, bool use_json) { struct zebra_ns *zns = NULL; json_object *json = NULL; @@ -4184,7 +4182,7 @@ void zebra_vxlan_print_rmacs_all_l3vni(struct vty *vty, uint8_t use_json) } void zebra_vxlan_print_specific_nh_l3vni(struct vty *vty, vni_t l3vni, - struct ipaddr *ip, uint8_t use_json) + struct ipaddr *ip, bool use_json) { zebra_l3vni_t *zl3vni = NULL; zebra_neigh_t *n = NULL; @@ -4228,7 +4226,7 @@ void zebra_vxlan_print_specific_nh_l3vni(struct vty *vty, vni_t l3vni, } } -void zebra_vxlan_print_nh_l3vni(struct vty *vty, vni_t l3vni, uint8_t use_json) +void zebra_vxlan_print_nh_l3vni(struct vty *vty, vni_t l3vni, bool use_json) { uint32_t num_nh; struct nh_walk_ctx wctx; @@ -4272,7 +4270,7 @@ void zebra_vxlan_print_nh_l3vni(struct vty *vty, vni_t l3vni, uint8_t use_json) } } -void zebra_vxlan_print_nh_all_l3vni(struct vty *vty, uint8_t use_json) +void zebra_vxlan_print_nh_all_l3vni(struct vty *vty, bool use_json) { struct zebra_ns *zns = NULL; json_object *json = NULL; @@ -4309,7 +4307,7 @@ void zebra_vxlan_print_nh_all_l3vni(struct vty *vty, uint8_t use_json) /* * Display L3 VNI information (VTY command handler). */ -void zebra_vxlan_print_l3vni(struct vty *vty, vni_t vni, uint8_t use_json) +void zebra_vxlan_print_l3vni(struct vty *vty, vni_t vni, bool use_json) { void *args[2]; json_object *json = NULL; @@ -4382,7 +4380,7 @@ void zebra_vxlan_print_vrf_vni(struct vty *vty, struct zebra_vrf *zvrf, * Display Neighbors for a VNI (VTY command handler). */ void zebra_vxlan_print_neigh_vni(struct vty *vty, struct zebra_vrf *zvrf, - vni_t vni, uint8_t use_json) + vni_t vni, bool use_json) { zebra_vni_t *zvni; uint32_t num_neigh; @@ -4438,7 +4436,7 @@ void zebra_vxlan_print_neigh_vni(struct vty *vty, struct zebra_vrf *zvrf, * Display neighbors across all VNIs (VTY command handler). */ void zebra_vxlan_print_neigh_all_vni(struct vty *vty, struct zebra_vrf *zvrf, - uint8_t use_json) + bool use_json) { json_object *json = NULL; void *args[2]; @@ -4467,7 +4465,7 @@ void zebra_vxlan_print_neigh_all_vni(struct vty *vty, struct zebra_vrf *zvrf, */ void zebra_vxlan_print_specific_neigh_vni(struct vty *vty, struct zebra_vrf *zvrf, vni_t vni, - struct ipaddr *ip, uint8_t use_json) + struct ipaddr *ip, bool use_json) { zebra_vni_t *zvni; zebra_neigh_t *n; @@ -4509,7 +4507,7 @@ void zebra_vxlan_print_specific_neigh_vni(struct vty *vty, */ void zebra_vxlan_print_neigh_vni_vtep(struct vty *vty, struct zebra_vrf *zvrf, vni_t vni, struct in_addr vtep_ip, - uint8_t use_json) + bool use_json) { zebra_vni_t *zvni; uint32_t num_neigh; @@ -4551,7 +4549,7 @@ void zebra_vxlan_print_neigh_vni_vtep(struct vty *vty, struct zebra_vrf *zvrf, * Display MACs for a VNI (VTY command handler). */ void zebra_vxlan_print_macs_vni(struct vty *vty, struct zebra_vrf *zvrf, - vni_t vni, uint8_t use_json) + vni_t vni, bool use_json) { zebra_vni_t *zvni; uint32_t num_macs; @@ -4606,7 +4604,7 @@ void zebra_vxlan_print_macs_vni(struct vty *vty, struct zebra_vrf *zvrf, * Display MACs for all VNIs (VTY command handler). */ void zebra_vxlan_print_macs_all_vni(struct vty *vty, struct zebra_vrf *zvrf, - uint8_t use_json) + bool use_json) { struct mac_walk_ctx wctx; json_object *json = NULL; @@ -4636,8 +4634,7 @@ void zebra_vxlan_print_macs_all_vni(struct vty *vty, struct zebra_vrf *zvrf, */ void zebra_vxlan_print_macs_all_vni_vtep(struct vty *vty, struct zebra_vrf *zvrf, - struct in_addr vtep_ip, - uint8_t use_json) + struct in_addr vtep_ip, bool use_json) { struct mac_walk_ctx wctx; json_object *json = NULL; @@ -4693,7 +4690,7 @@ void zebra_vxlan_print_specific_mac_vni(struct vty *vty, struct zebra_vrf *zvrf, */ void zebra_vxlan_print_macs_vni_vtep(struct vty *vty, struct zebra_vrf *zvrf, vni_t vni, struct in_addr vtep_ip, - uint8_t use_json) + bool use_json) { zebra_vni_t *zvni; uint32_t num_macs; @@ -4743,7 +4740,7 @@ void zebra_vxlan_print_macs_vni_vtep(struct vty *vty, struct zebra_vrf *zvrf, * Display VNI information (VTY command handler). */ void zebra_vxlan_print_vni(struct vty *vty, struct zebra_vrf *zvrf, vni_t vni, - uint8_t use_json) + bool use_json) { json_object *json = NULL; void *args[2]; @@ -4831,7 +4828,7 @@ void zebra_vxlan_print_evpn(struct vty *vty, uint8_t uj) * Display VNI hash table (VTY command handler). */ void zebra_vxlan_print_vnis(struct vty *vty, struct zebra_vrf *zvrf, - uint8_t use_json) + bool use_json) { json_object *json = NULL; struct zebra_ns *zns = NULL; diff --git a/zebra/zebra_vxlan.h b/zebra/zebra_vxlan.h index 2732ef72ed..6b2b57371c 100644 --- a/zebra/zebra_vxlan.h +++ b/zebra/zebra_vxlan.h @@ -68,53 +68,51 @@ extern int zebra_vxlan_vrf_enable(struct zebra_vrf *zvrf); extern int zebra_vxlan_vrf_disable(struct zebra_vrf *zvrf); extern int zebra_vxlan_vrf_delete(struct zebra_vrf *zvrf); extern void zebra_vxlan_print_specific_nh_l3vni(struct vty *vty, vni_t l3vni, - struct ipaddr *ip, uint8_t uj); + struct ipaddr *ip, bool uj); extern void zebra_vxlan_print_evpn(struct vty *vty, uint8_t uj); extern void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty, vni_t l3vni, struct ethaddr *rmac, - uint8_t use_json); + bool use_json); extern void zebra_vxlan_print_macs_vni(struct vty *vty, struct zebra_vrf *zvrf, - vni_t vni, uint8_t use_json); + vni_t vni, bool use_json); extern void zebra_vxlan_print_macs_all_vni(struct vty *vty, struct zebra_vrf *zvrf, - uint8_t use_json); + bool use_json); extern void zebra_vxlan_print_macs_all_vni_vtep(struct vty *vty, struct zebra_vrf *zvrf, struct in_addr vtep_ip, - uint8_t use_json); + bool use_json); extern void zebra_vxlan_print_specific_mac_vni(struct vty *vty, struct zebra_vrf *zvrf, vni_t vni, struct ethaddr *mac); extern void zebra_vxlan_print_macs_vni_vtep(struct vty *vty, struct zebra_vrf *zvrf, vni_t vni, struct in_addr vtep_ip, - uint8_t use_json); + bool use_json); extern void zebra_vxlan_print_neigh_vni(struct vty *vty, struct zebra_vrf *zvrf, - vni_t vni, uint8_t use_json); + vni_t vni, bool use_json); extern void zebra_vxlan_print_neigh_all_vni(struct vty *vty, struct zebra_vrf *zvrf, - uint8_t use_json); + bool use_json); extern void zebra_vxlan_print_specific_neigh_vni(struct vty *vty, struct zebra_vrf *zvrf, vni_t vni, struct ipaddr *ip, - uint8_t use_json); + bool use_json); extern void zebra_vxlan_print_neigh_vni_vtep(struct vty *vty, struct zebra_vrf *zvrf, vni_t vni, struct in_addr vtep_ip, - uint8_t use_json); + bool use_json); extern void zebra_vxlan_print_vni(struct vty *vty, struct zebra_vrf *zvrf, - vni_t vni, uint8_t use_json); + vni_t vni, bool use_json); extern void zebra_vxlan_print_vnis(struct vty *vty, struct zebra_vrf *zvrf, - uint8_t use_json); + bool use_json); extern void zebra_vxlan_print_rmacs_l3vni(struct vty *vty, vni_t vni, - uint8_t use_json); -extern void zebra_vxlan_print_rmacs_all_l3vni(struct vty *vty, - uint8_t use_json); + bool use_json); +extern void zebra_vxlan_print_rmacs_all_l3vni(struct vty *vty, bool use_json); extern void zebra_vxlan_print_nh_l3vni(struct vty *vty, vni_t vni, - uint8_t use_json); -extern void zebra_vxlan_print_nh_all_l3vni(struct vty *vty, uint8_t use_json); -extern void zebra_vxlan_print_l3vni(struct vty *vty, vni_t vni, - uint8_t use_json); + bool use_json); +extern void zebra_vxlan_print_nh_all_l3vni(struct vty *vty, bool use_json); +extern void zebra_vxlan_print_l3vni(struct vty *vty, vni_t vni, bool use_json); extern void zebra_vxlan_print_vrf_vni(struct vty *vty, struct zebra_vrf *zvrf, json_object *json_vrfs); extern int zebra_vxlan_add_del_gw_macip(struct interface *ifp, struct prefix *p,