diff options
author | Don Slice <dslice@cumulusnetworks.com> | 2018-08-29 14:19:54 +0200 |
---|---|---|
committer | Don Slice <dslice@cumulusnetworks.com> | 2018-08-30 14:40:18 +0200 |
commit | 9f049418bc2fe2500a4c7dbba11d1eefa9c1408c (patch) | |
tree | f92eaaecf3885a43bb7cd392b7e4b6f546c1570f /lib | |
parent | Merge pull request #2930 from donaldsharp/pim_debug (diff) | |
download | frr-9f049418bc2fe2500a4c7dbba11d1eefa9c1408c.tar.xz frr-9f049418bc2fe2500a4c7dbba11d1eefa9c1408c.zip |
bgpd/ospfd: make bgp and ospf json response a bit more consistent
Problem reported that some bgp and ospf json commands did not return
any json output at all if the bgp/ospf instance did not exist.
Additionally, some bgp and ospf json commands did not return any json
output if the instance existed but no neighbors were defined. This
fix makes these commands more consistent in returning empty braces for
json output and issue a message if not using json output. Additionally,
made the flag "use_json" a bool to make it consistent since previously,
it had been defined as an int, char, u_char, and bool at various places.
Ticket: CM-21040
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bfd.c | 6 | ||||
-rw-r--r-- | lib/bfd.h | 4 | ||||
-rw-r--r-- | lib/json.c | 8 | ||||
-rw-r--r-- | lib/json.h | 2 | ||||
-rw-r--r-- | lib/plist.c | 2 | ||||
-rw-r--r-- | lib/plist.h | 2 |
6 files changed, 12 insertions, 12 deletions
@@ -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; @@ -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 40b6aadaa..4ea20ba17 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 788d1d6ef..d34916230 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 2b666f256..3b25c0677 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 fecbe0e2c..7933b8a92 100644 --- a/lib/plist.h +++ b/lib/plist.h @@ -72,6 +72,6 @@ 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 *, afi_t, char *, bool); #endif /* _QUAGGA_PLIST_H */ |