summaryrefslogtreecommitdiffstats
path: root/src/internal.h
diff options
context:
space:
mode:
authorAlvaro Neira Ayuso <alvaroneay@gmail.com>2015-02-09 21:09:54 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2015-02-10 12:29:31 +0100
commit64279008234c2367e1b6ffa84c6b3dff5a04a779 (patch)
treeeaef66284c0d7fce2f7e5dbaf2ec7c7423e7fb1b /src/internal.h
parent15ad64734a544a9af033e54d232f112971072c15 (diff)
src: add support to import JSON/XML with the new command tag
This patch adds support to parse the new command tag in XML/JSON. This patch adds two new functions: * nft_ruleset_parse_file_cb * nft_ruleset_parse_buffer_cb The idea is to invoke the callback function that is passed as parameter is called for each object that is parsed from the corresponding input. Each callback has access to the nft_parse_ctx structure that provides the necessary context such as the command, the object type and the object itself. This change also adds support to update the content of a set incrementally. {"nftables":[{"add":[{"element":{"name":"blackhole","table":"filter", "family":"ip","key_type":7,"key_len":4,"set_elem":[{"key":{ "reg":{"type":"value","len":4,"data0":"0x0403a8c0"}}}]}}]}]} This also patch consolidates the xml/json ruleset import path. Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/internal.h')
-rw-r--r--src/internal.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/internal.h b/src/internal.h
index 431af11..9ebf7d7 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -139,6 +139,8 @@ int nft_jansson_parse_rule(struct nft_rule *r, json_t *tree,
struct nft_set;
int nft_jansson_parse_set(struct nft_set *s, json_t *tree,
struct nft_parse_err *err);
+int nft_jansson_parse_elem(struct nft_set *s, json_t *tree,
+ struct nft_parse_err *err);
#endif
const char *nft_family2str(uint32_t family);
@@ -149,6 +151,7 @@ int nft_str2verdict(const char *verdict, int *verdict_num);
int nft_get_value(enum nft_type type, void *val, void *out);
enum nft_cmd_type nft_flag2cmd(uint32_t flags);
const char *nft_cmd2tag(enum nft_cmd_type cmd);
+uint32_t nft_str2cmd(const char *cmd);
#include <stdio.h>
int nft_fprintf(FILE *fp, void *obj, uint32_t cmd, uint32_t type,