From bb32d8db9a125d9676f87866e48ffbf0221ec16a Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Fri, 26 Oct 2018 15:01:38 +0200 Subject: JSON: Add support for echo option The basic principle is to not return a JSON object freshly created from netlink responses, but just update the existing user-provided one to make sure callers get back exactly what they expect. To achieve that, keep the parsed JSON object around in a global variable ('cur_root') and provide a custom callback to insert handles into it from received netlink messages. The tricky bit here is updating rules since unique identification is problematic. Therefore drop possibly present handles from input and later assume updates are received in order so the first rule not having a handle set is the right one. Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- include/nftables.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/nftables.h') diff --git a/include/nftables.h b/include/nftables.h index 25e78c80..1009e266 100644 --- a/include/nftables.h +++ b/include/nftables.h @@ -53,6 +53,7 @@ struct nft_ctx { uint32_t flags; struct parser_state *state; void *scanner; + void *json_root; }; enum nftables_exit_codes { -- cgit v1.2.3