summaryrefslogtreecommitdiffstats
path: root/src/expr/cmp.c
diff options
context:
space:
mode:
authorArturo Borrero <arturo.borrero.glez@gmail.com>2013-07-05 16:28:06 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2013-07-06 00:11:55 +0200
commit1e8e5d4b55efe4f11334a5b55483b802cb704071 (patch)
treec9e948fca996743999917e7a55275432345728d5 /src/expr/cmp.c
parent9e540bd2dd2a53dc017f4ca6bd8b46bd4a3e5c65 (diff)
src: xml: consolidate parsing of data_reg via nft_mxml_data_reg_parse
Move common code for XML parsing of data_reg to the new nft_mxml_data_reg_parse function. Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/expr/cmp.c')
-rw-r--r--src/expr/cmp.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/src/expr/cmp.c b/src/expr/cmp.c
index 2115839..3f795bc 100644
--- a/src/expr/cmp.c
+++ b/src/expr/cmp.c
@@ -173,8 +173,6 @@ static int nft_rule_expr_cmp_xml_parse(struct nft_rule_expr *e, mxml_node_t *tre
#ifdef XML_PARSING
struct nft_expr_cmp *cmp = (struct nft_expr_cmp *)e->data;
mxml_node_t *node = NULL;
- mxml_node_t *save = NULL;
- union nft_data_reg data_regtmp;
int32_t reg;
reg = nft_mxml_reg_parse(tree, "sreg", MXML_DESCEND_FIRST);
@@ -207,22 +205,12 @@ static int nft_rule_expr_cmp_xml_parse(struct nft_rule_expr *e, mxml_node_t *tre
}
/* Get and set <cmpdata>. Is not mandatory */
- node = mxmlFindElement(tree, tree, "cmpdata", NULL, NULL,
- MXML_DESCEND);
+ node = mxmlFindElement(tree, tree, "cmpdata", NULL, NULL, MXML_DESCEND);
if (node != NULL) {
- /* hack for mxmSaveAllocString to print just the current node */
- save = node->next;
- node->next = NULL;
-
- if (nft_data_reg_xml_parse(&data_regtmp,
- mxmlSaveAllocString(node, MXML_NO_CALLBACK)) < 0) {
+ if (nft_mxml_data_reg_parse(tree, "cmpdata",
+ &cmp->data) != DATA_VALUE) {
return -1;
}
-
- node->next = save;
-
- memcpy(&cmp->data.val, data_regtmp.val, data_regtmp.len);
- cmp->data.len = data_regtmp.len;
e->flags |= (1 << NFT_EXPR_CMP_DATA);
}