summaryrefslogtreecommitdiffstats
path: root/include/json.h
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2018-05-08 13:08:38 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2018-05-11 12:17:02 +0200
commit586ad210368b775c94acbad2b105483eaf4ca05a (patch)
tree2d6204f59b8d9f7ed7ebed8492739b5e79ec4e0d /include/json.h
parente70354f53e9f6be4a4be31dbc46c5e23291d3587 (diff)
libnftables: Implement JSON parser
If JSON output setting is active in current context, try parsing any input as JSON. If the initial loading of the buffer or filename by libjansson fails, fall back to regular syntax parser. Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include/json.h')
-rw-r--r--include/json.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/json.h b/include/json.h
index 579bd5df..ae393814 100644
--- a/include/json.h
+++ b/include/json.h
@@ -1,6 +1,8 @@
#ifndef NFTABLES_JSON_H
#define NFTABLES_JSON_H
+#include <errno.h>
+
struct chain;
struct cmd;
struct expr;
@@ -74,6 +76,11 @@ json_t *verdict_stmt_json(const struct stmt *stmt, struct output_ctx *octx);
int do_command_list_json(struct netlink_ctx *ctx, struct cmd *cmd);
+int nft_parse_json_buffer(struct nft_ctx *nft, char *buf, size_t buflen,
+ struct list_head *msgs, struct list_head *cmds);
+int nft_parse_json_filename(struct nft_ctx *nft, const char *filename,
+ struct list_head *msgs, struct list_head *cmds);
+
#else /* ! HAVE_LIBJANSSON */
typedef void json_t;
@@ -156,6 +163,19 @@ static inline int do_command_list_json(struct netlink_ctx *ctx, struct cmd *cmd)
return -1;
}
+static inline int
+nft_parse_json_buffer(struct nft_ctx *nft, char *buf, size_t buflen,
+ struct list_head *msgs, struct list_head *cmds)
+{
+ return -EINVAL;
+}
+static inline int
+nft_parse_json_filename(struct nft_ctx *nft, const char *filename,
+ struct list_head *msgs, struct list_head *cmds)
+{
+ return -EINVAL;
+}
+
#endif /* HAVE_LIBJANSSON */
#endif /* NFTABLES_JSON_H */