From 2034d8c60ed91c36b74e86e0c195eb6f2c27f9fa Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 18 Aug 2023 11:40:38 +0200 Subject: src: add input flag NFT_CTX_INPUT_JSON to enable JSON parsing By default, the input is parsed using the nftables grammar. When setting NFT_CTX_OUTPUT_JSON flag, nftables will first try to parse the input as JSON before falling back to the nftables grammar. But NFT_CTX_OUTPUT_JSON flag also turns on JSON for the output. Add a flag NFT_CTX_INPUT_JSON which allows to treat only the input as JSON, but keep the output mode unchanged. Signed-off-by: Thomas Haller Reviewed-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- include/nftables.h | 5 +++++ include/nftables/libnftables.h | 1 + 2 files changed, 6 insertions(+) (limited to 'include') diff --git a/include/nftables.h b/include/nftables.h index 666a17ae..f073fa95 100644 --- a/include/nftables.h +++ b/include/nftables.h @@ -32,6 +32,11 @@ static inline bool nft_input_no_dns(const struct input_ctx *ictx) return ictx->flags & NFT_CTX_INPUT_NO_DNS; } +static inline bool nft_input_json(const struct input_ctx *ictx) +{ + return ictx->flags & NFT_CTX_INPUT_JSON; +} + struct output_ctx { unsigned int flags; union { diff --git a/include/nftables/libnftables.h b/include/nftables/libnftables.h index e109805f..cc059692 100644 --- a/include/nftables/libnftables.h +++ b/include/nftables/libnftables.h @@ -50,6 +50,7 @@ void nft_ctx_set_optimize(struct nft_ctx *ctx, uint32_t flags); enum { NFT_CTX_INPUT_NO_DNS = (1 << 0), + NFT_CTX_INPUT_JSON = (1 << 1), }; unsigned int nft_ctx_input_get_flags(struct nft_ctx *ctx); -- cgit v1.2.3