summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/chain.c7
-rw-r--r--src/internal.h1
-rw-r--r--src/jansson.c3
-rw-r--r--src/libnftables.map6
-rw-r--r--src/mxml.c3
-rw-r--r--src/rule.c7
-rw-r--r--src/ruleset.c7
-rw-r--r--src/set.c13
-rw-r--r--src/set_elem.c7
-rw-r--r--src/table.c7
10 files changed, 59 insertions, 2 deletions
diff --git a/src/chain.c b/src/chain.c
index 8f40ede..18a52da 100644
--- a/src/chain.c
+++ b/src/chain.c
@@ -761,6 +761,13 @@ int nft_chain_parse(struct nft_chain *c, enum nft_parse_type type,
}
EXPORT_SYMBOL(nft_chain_parse);
+int nft_chain_parse_file(struct nft_chain *c, enum nft_parse_type type,
+ FILE *fp, struct nft_parse_err *err)
+{
+ return nft_chain_do_parse(c, type, fp, err, NFT_PARSE_FILE);
+}
+EXPORT_SYMBOL(nft_chain_parse_file);
+
static int nft_chain_snprintf_json(char *buf, size_t size, struct nft_chain *c)
{
int ret, len = size, offset = 0;
diff --git a/src/internal.h b/src/internal.h
index fa092cf..d3c58a2 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -40,6 +40,7 @@ struct nft_parse_err {
enum nft_parse_input {
NFT_PARSE_BUFFER,
+ NFT_PARSE_FILE,
};
#ifdef XML_PARSING
diff --git a/src/jansson.c b/src/jansson.c
index 3428f2f..f446e17 100644
--- a/src/jansson.c
+++ b/src/jansson.c
@@ -98,6 +98,9 @@ json_t *nft_jansson_create_root(const void *json, json_error_t *error,
case NFT_PARSE_BUFFER:
root = json_loadb(json, strlen(json), 0, error);
break;
+ case NFT_PARSE_FILE:
+ root = json_loadf((FILE *)json, 0, error);
+ break;
default:
goto err;
}
diff --git a/src/libnftables.map b/src/libnftables.map
index be5c783..faf0913 100644
--- a/src/libnftables.map
+++ b/src/libnftables.map
@@ -13,6 +13,7 @@ global:
nft_table_attr_get_u32;
nft_table_attr_get_str;
nft_table_parse;
+ nft_table_parse_file;
nft_table_snprintf;
nft_table_fprintf;
nft_table_nlmsg_build_payload;
@@ -45,6 +46,7 @@ global:
nft_chain_attr_get_u64;
nft_chain_attr_get_str;
nft_chain_parse;
+ nft_chain_parse_file;
nft_chain_snprintf;
nft_chain_fprintf;
nft_chain_nlmsg_build_payload;
@@ -74,6 +76,7 @@ global:
nft_rule_attr_get_u64;
nft_rule_attr_get_str;
nft_rule_parse;
+ nft_rule_parse_file;
nft_rule_snprintf;
nft_rule_fprintf;
nft_rule_nlmsg_build_payload;
@@ -128,6 +131,7 @@ global:
nft_set_nlmsg_build_payload;
nft_set_nlmsg_parse;
nft_set_parse;
+ nft_set_parse_file;
nft_set_snprintf;
nft_set_fprintf;
@@ -159,6 +163,7 @@ global:
nft_set_elem_nlmsg_build_payload;
nft_set_elem_nlmsg_parse;
nft_set_elem_parse;
+ nft_set_elem_parse_file;
nft_set_elem_snprintf;
nft_set_elem_fprinf;
@@ -179,6 +184,7 @@ global:
nft_ruleset_attr_set;
nft_ruleset_attr_get;
nft_ruleset_parse;
+ nft_ruleset_parse_file;
nft_ruleset_snprintf;
nft_ruleset_fprintf;
diff --git a/src/mxml.c b/src/mxml.c
index 575383c..ddbd01b 100644
--- a/src/mxml.c
+++ b/src/mxml.c
@@ -31,6 +31,9 @@ mxml_node_t *nft_mxml_build_tree(const void *data, const char *treename,
case NFT_PARSE_BUFFER:
tree = mxmlLoadString(NULL, data, MXML_OPAQUE_CALLBACK);
break;
+ case NFT_PARSE_FILE:
+ tree = mxmlLoadFile(NULL, (FILE *)data, MXML_OPAQUE_CALLBACK);
+ break;
default:
goto err;
}
diff --git a/src/rule.c b/src/rule.c
index 081686c..9b4b01f 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -678,6 +678,13 @@ int nft_rule_parse(struct nft_rule *r, enum nft_parse_type type,
}
EXPORT_SYMBOL(nft_rule_parse);
+int nft_rule_parse_file(struct nft_rule *r, enum nft_parse_type type,
+ FILE *fp, struct nft_parse_err *err)
+{
+ return nft_rule_do_parse(r, type, fp, err, NFT_PARSE_FILE);
+}
+EXPORT_SYMBOL(nft_rule_parse_file);
+
static int nft_rule_snprintf_json(char *buf, size_t size, struct nft_rule *r,
uint32_t type, uint32_t flags)
{
diff --git a/src/ruleset.c b/src/ruleset.c
index c6bcc4b..f5e1157 100644
--- a/src/ruleset.c
+++ b/src/ruleset.c
@@ -597,6 +597,13 @@ int nft_ruleset_parse(struct nft_ruleset *r, enum nft_parse_type type,
}
EXPORT_SYMBOL(nft_ruleset_parse);
+int nft_ruleset_parse_file(struct nft_ruleset *rs, enum nft_parse_type type,
+ FILE *fp, struct nft_parse_err *err)
+{
+ return nft_ruleset_do_parse(rs, type, fp, err, NFT_PARSE_FILE);
+}
+EXPORT_SYMBOL(nft_ruleset_parse_file);
+
static const char *nft_ruleset_o_opentag(uint32_t type)
{
switch (type) {
diff --git a/src/set.c b/src/set.c
index 1c9caf8..822a715 100644
--- a/src/set.c
+++ b/src/set.c
@@ -376,7 +376,8 @@ err:
#endif
static int nft_set_json_parse(struct nft_set *s, const void *json,
- struct nft_parse_err *err, enum nft_parse_input input)
+ struct nft_parse_err *err,
+ enum nft_parse_input input)
{
#ifdef JSON_PARSING
json_t *tree;
@@ -484,7 +485,8 @@ int nft_mxml_set_parse(mxml_node_t *tree, struct nft_set *s,
#endif
static int nft_set_xml_parse(struct nft_set *s, const void *xml,
- struct nft_parse_err *err, enum nft_parse_input input)
+ struct nft_parse_err *err,
+ enum nft_parse_input input)
{
#ifdef XML_PARSING
int ret;
@@ -533,6 +535,13 @@ int nft_set_parse(struct nft_set *s, enum nft_parse_type type,
}
EXPORT_SYMBOL(nft_set_parse);
+int nft_set_parse_file(struct nft_set *s, enum nft_parse_type type,
+ FILE *fp, struct nft_parse_err *err)
+{
+ return nft_set_do_parse(s, type, fp, err, NFT_PARSE_FILE);
+}
+EXPORT_SYMBOL(nft_set_parse_file);
+
static int nft_set_snprintf_json(char *buf, size_t size, struct nft_set *s,
uint32_t type, uint32_t flags)
{
diff --git a/src/set_elem.c b/src/set_elem.c
index 93e8291..2bbfb0e 100644
--- a/src/set_elem.c
+++ b/src/set_elem.c
@@ -463,6 +463,13 @@ int nft_set_elem_parse(struct nft_set_elem *e, enum nft_parse_type type,
}
EXPORT_SYMBOL(nft_set_elem_parse);
+int nft_set_elem_parse_file(struct nft_set_elem *e, enum nft_parse_type type,
+ FILE *fp, struct nft_parse_err *err)
+{
+ return nft_set_elem_do_parse(e, type, fp, err, NFT_PARSE_FILE);
+}
+EXPORT_SYMBOL(nft_set_elem_parse_file);
+
static int nft_set_elem_snprintf_json(char *buf, size_t size,
struct nft_set_elem *e, uint32_t flags)
{
diff --git a/src/table.c b/src/table.c
index 4f2d5d2..ad3570f 100644
--- a/src/table.c
+++ b/src/table.c
@@ -355,6 +355,13 @@ int nft_table_parse(struct nft_table *t, enum nft_parse_type type,
}
EXPORT_SYMBOL(nft_table_parse);
+int nft_table_parse_file(struct nft_table *t, enum nft_parse_type type,
+ FILE *fp, struct nft_parse_err *err)
+{
+ return nft_table_do_parse(t, type, fp, err, NFT_PARSE_FILE);
+}
+EXPORT_SYMBOL(nft_table_parse_file);
+
static int nft_table_snprintf_json(char *buf, size_t size, struct nft_table *t)
{
return snprintf(buf, size,