summaryrefslogtreecommitdiffstats
path: root/src/expr/cmp.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2013-07-04 16:10:24 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2013-07-04 16:47:58 +0200
commit556fb7ee694a0f18cbd3d73ac96b27c74081bd6d (patch)
treea5148ca080d15ea122473186baacc3fd5bd2138c /src/expr/cmp.c
parentd844fa06e43bc80487acfe5647cef4d4994c95fd (diff)
src: consolidate XML parsing of expressions via nft_mxml_reg_parse
This patch reduces the XML code in 100 LOC.
Diffstat (limited to 'src/expr/cmp.c')
-rw-r--r--src/expr/cmp.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/expr/cmp.c b/src/expr/cmp.c
index ca8dd82..f3a363a 100644
--- a/src/expr/cmp.c
+++ b/src/expr/cmp.c
@@ -175,23 +175,14 @@ static int nft_rule_expr_cmp_xml_parse(struct nft_rule_expr *e, mxml_node_t *tre
mxml_node_t *node = NULL;
mxml_node_t *save = NULL;
union nft_data_reg data_regtmp;
- uint64_t tmp;
- char *endptr;
+ int32_t reg;
- /* Get and set <sreg>. Is not mandatory */
- node = mxmlFindElement(tree, tree, "sreg", NULL, NULL,
- MXML_DESCEND_FIRST);
- if (node != NULL) {
- tmp = strtoull(node->child->value.opaque, &endptr, 10);
- if (tmp > UINT8_MAX || tmp < 0 || *endptr)
- return -1;
-
- if (tmp > NFT_REG_MAX)
- return -1;
+ reg = nft_mxml_reg_parse(tree, "sreg", MXML_DESCEND_FIRST);
+ if (reg < 0)
+ return -1;
- cmp->sreg = (uint8_t)tmp;
- e->flags |= (1 << NFT_EXPR_CMP_SREG);
- }
+ cmp->sreg = reg;
+ e->flags |= (1 << NFT_EXPR_CMP_SREG);
/* Get and set <op>. Is not mandatory*/
node = mxmlFindElement(tree, tree, "op", NULL, NULL, MXML_DESCEND);