From 9e88aae28e9f44d010f3ecf7577357f4c0e7d622 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Thu, 11 Oct 2018 17:49:00 +0200 Subject: monitor: Use libnftables JSON output This switches 'nft monitor' JSON output from using libnftnl's to libnftables' implementation. Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- include/json.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'include/json.h') diff --git a/include/json.h b/include/json.h index 66337548..d2dc92d9 100644 --- a/include/json.h +++ b/include/json.h @@ -9,9 +9,11 @@ struct expr; struct netlink_ctx; struct rule; struct set; +struct obj; struct stmt; struct symbol_table; struct table; +struct netlink_mon_handler; #ifdef HAVE_LIBJANSSON @@ -88,6 +90,19 @@ int nft_parse_json_buffer(struct nft_ctx *nft, const char *buf, int nft_parse_json_filename(struct nft_ctx *nft, const char *filename, struct list_head *msgs, struct list_head *cmds); +void monitor_print_table_json(struct netlink_mon_handler *monh, + const char *cmd, struct table *t); +void monitor_print_chain_json(struct netlink_mon_handler *monh, + const char *cmd, struct chain *c); +void monitor_print_set_json(struct netlink_mon_handler *monh, + const char *cmd, struct set *s); +void monitor_print_element_json(struct netlink_mon_handler *monh, + const char *cmd, struct set *s); +void monitor_print_obj_json(struct netlink_mon_handler *monh, + const char *cmd, struct obj *o); +void monitor_print_rule_json(struct netlink_mon_handler *monh, + const char *cmd, struct rule *r); + #else /* ! HAVE_LIBJANSSON */ typedef void json_t; @@ -183,6 +198,42 @@ nft_parse_json_filename(struct nft_ctx *nft, const char *filename, return -EINVAL; } +static inline void monitor_print_table_json(struct netlink_mon_handler *monh, + const char *cmd, struct table *t) +{ + /* empty */ +} + +static inline void monitor_print_chain_json(struct netlink_mon_handler *monh, + const char *cmd, struct chain *c) +{ + /* empty */ +} + +static inline void monitor_print_set_json(struct netlink_mon_handler *monh, + const char *cmd, struct set *s) +{ + /* empty */ +} + +static inline void monitor_print_element_json(struct netlink_mon_handler *monh, + const char *cmd, struct set *s) +{ + /* empty */ +} + +static inline void monitor_print_obj_json(struct netlink_mon_handler *monh, + const char *cmd, struct obj *o) +{ + /* empty */ +} + +static inline void monitor_print_rule_json(struct netlink_mon_handler *monh, + const char *cmd, struct rule *r) +{ + /* empty */ +} + #endif /* HAVE_LIBJANSSON */ #endif /* NFTABLES_JSON_H */ -- cgit v1.2.3