diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-07-04 14:50:22 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-07-04 16:47:38 +0200 |
commit | d844fa06e43bc80487acfe5647cef4d4994c95fd (patch) | |
tree | 2dd70dc1b8889da6f566e467eeebdd13feafeabb /src/expr/limit.c | |
parent | 0dbe80fee352545f51bdc4fd71621223e8b62306 (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/expr/limit.c')
-rw-r--r-- | src/expr/limit.c | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/src/expr/limit.c b/src/expr/limit.c index 1e843ce..fdd76e3 100644 --- a/src/expr/limit.c +++ b/src/expr/limit.c @@ -126,25 +126,14 @@ nft_rule_expr_limit_parse(struct nft_rule_expr *e, struct nlattr *attr) return 0; } -static int nft_rule_expr_limit_xml_parse(struct nft_rule_expr *e, char *xml) +static int nft_rule_expr_limit_xml_parse(struct nft_rule_expr *e, mxml_node_t *tree) { #ifdef XML_PARSING struct nft_expr_limit *limit = (struct nft_expr_limit *)e->data; - mxml_node_t *tree = NULL; mxml_node_t *node = NULL; uint64_t tmp; char *endptr; - tree = mxmlLoadString(NULL, xml, MXML_OPAQUE_CALLBACK); - if (tree == NULL) - return -1; - - if (mxmlElementGetAttr(tree, "type") == NULL) - goto err; - - if (strcmp("limit", mxmlElementGetAttr(tree, "type")) != 0) - goto err; - node = mxmlFindElement(tree, tree, "rate", NULL, NULL, MXML_DESCEND_FIRST); if (node == NULL) @@ -169,11 +158,9 @@ static int nft_rule_expr_limit_xml_parse(struct nft_rule_expr *e, char *xml) limit->depth = tmp; e->flags |= (1 << NFT_EXPR_LIMIT_DEPTH); - mxmlDelete(tree); return 0; err: errno = EINVAL; - mxmlDelete(tree); return -1; #else errno = EOPNOTSUPP; |