summaryrefslogtreecommitdiffstats
path: root/src/rule.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2013-07-04 14:50:22 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2013-07-04 16:47:38 +0200
commitd844fa06e43bc80487acfe5647cef4d4994c95fd (patch)
tree2dd70dc1b8889da6f566e467eeebdd13feafeabb /src/rule.c
parent0dbe80fee352545f51bdc4fd71621223e8b62306 (diff)
src: consolidate XML parsing of expressions via nft_mxml_expr_parse
Move common code for XML parsing of expressions to the new nft_mxml_expr_parse function. This patch reduces the XML parsing code in 300 LOC. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/rule.c')
-rw-r--r--src/rule.c23
1 files changed, 2 insertions, 21 deletions
diff --git a/src/rule.c b/src/rule.c
index 5e9b16d..64c34bd 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -483,7 +483,6 @@ static int nft_rule_xml_parse(struct nft_rule *r, char *xml)
mxml_node_t *node = NULL;
mxml_node_t *save = NULL;
struct nft_rule_expr *e;
- struct expr_ops *ops;
char *endptr = NULL;
uint64_t tmp;
int family;
@@ -608,30 +607,12 @@ static int nft_rule_xml_parse(struct nft_rule *r, char *xml)
node = mxmlFindElement(node, tree, "expr", "type",
NULL, MXML_DESCEND)) {
- if (mxmlElementGetAttr(node, "type") == NULL) {
- mxmlDelete(tree);
- return -1;
- }
-
- ops = nft_expr_ops_lookup(mxmlElementGetAttr(node, "type"));
- if (ops == NULL) {
- mxmlDelete(tree);
- return -1;
- }
-
- e = nft_rule_expr_alloc(mxmlElementGetAttr(node, "type"));
- if (e == NULL) {
- mxmlDelete(tree);
- return -1;
- }
-
/* This is a hack for mxml to print just the current node */
save = node->next;
node->next = NULL;
- if (ops->xml_parse(e,
- mxmlSaveAllocString(node,
- MXML_NO_CALLBACK)) != 0) {
+ e = nft_mxml_expr_parse(node);
+ if (e == NULL) {
mxmlDelete(tree);
return -1;
}