path: root/include/buffer.h
diff options
authorAlvaro Neira Ayuso <>2015-02-09 21:09:53 +0100
committerPablo Neira Ayuso <>2015-02-10 12:23:42 +0100
commit15ad64734a544a9af033e54d232f112971072c15 (patch)
tree151c7529eec0b969287db0492e5abb65aae8e013 /include/buffer.h
parent8875d20e4d9aaa3feee27a164ad2d8b033749a2f (diff)
src: add command tag in JSON/XML export support
Currently, we can't do incremental updates via JSON/XML. This patch enriches the existing output to indicate the kind of update that you want to perform. So, if we have a ruleset like: table ip filter { chain input { type filter hook input priority 0; } } The new output looks like: {"nftables":[{"add":[{"table":{"name":"filter",...}}]}]} ^^^^^ Where we explicitly indicate that we want to add a table. We support all the actions that we can do with nft, they are: - Add, delete and flush tables and chains. - Add, delete, replace and insert rules. - Add and delete sets. - Add and delete set elements. - Flush ruleset. You only need to add the command tag: {"nftables":[{"delete":[{...}, {...},...}]}]} ^^^^^^^^ The possible command tags that you can use are "add", "delete", "insert", "replace" and "flush". - Flush table or chain, eg.: {"nftables":[{"flush":[{"table":{"name":...}}]}]} - Delete table, chain, set or rule: {"nftables":[{"delete":[{"chain":{"name":...}]}]} - Replace a rule (you have to specify the handle): {"nftables":[{"replace":[{"rule":{...}}]}]} - Insert a rule: {"nftables":[{"insert":[{"rule":{...}}]}]} Signed-off-by: Alvaro Neira Ayuso <> Signed-off-by: Pablo Neira Ayuso <>
Diffstat (limited to 'include/buffer.h')
1 files changed, 8 insertions, 0 deletions
diff --git a/include/buffer.h b/include/buffer.h
index 2b497f2..9d1cb8b 100644
--- a/include/buffer.h
+++ b/include/buffer.h
@@ -26,6 +26,9 @@ union nft_data_reg;
int nft_buf_open(struct nft_buf *b, int type, const char *tag);
int nft_buf_close(struct nft_buf *b, int type, const char *tag);
+int nft_buf_open_array(struct nft_buf *b, int type, const char *tag);
+int nft_buf_close_array(struct nft_buf *b, int type, const char *tag);
int nft_buf_u32(struct nft_buf *b, int type, uint32_t value, const char *tag);
int nft_buf_s32(struct nft_buf *b, int type, uint32_t value, const char *tag);
int nft_buf_u64(struct nft_buf *b, int type, uint64_t value, const char *tag);
@@ -76,5 +79,10 @@ int nft_buf_reg(struct nft_buf *b, int type, union nft_data_reg *reg,
#define UNIT "unit"
#define USE "use"
#define XOR "xor"
+#define ADD "add"
+#define INSERT "insert"
+#define DELETE "delete"
+#define REPLACE "replace"
+#define FLUSH "flush"