From b58cf8947422ba695df80fe3b012b383fff22f7a Mon Sep 17 00:00:00 2001 From: Arturo Borrero Gonzalez Date: Tue, 6 Aug 2013 10:40:33 +0200 Subject: src: xml: use nodes instead of attributes When working with XML, it's desirable to work with nodes better than attributes. Table/chain/rules had attributes in their XML representation, and this patch transform those to nodes, ie: Before: ip0
After: filterip0
While at it: * There was a lot of redundant code that is now collapsed with the new nft_mxml_family_parse() helper function. * I've added a small fix: additional validation for the name of the current XML object, and also replace raw strtol calls to nft_strtoi. * Also, all XML testfiles are updated to keep passing the parsing tests and mantain the repo in consisten state. Signed-off-by: Arturo Borrero Gonzalez Signed-off-by: Pablo Neira Ayuso --- src/expr/nat.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/expr/nat.c') diff --git a/src/expr/nat.c b/src/expr/nat.c index 7446258..4b7ec27 100644 --- a/src/expr/nat.c +++ b/src/expr/nat.c @@ -188,7 +188,7 @@ static int nft_rule_expr_nat_xml_parse(struct nft_rule_expr *e, mxml_node_t *tre { #ifdef XML_PARSING struct nft_expr_nat *nat = nft_expr_data(e); - const char *nat_type, *family_str; + const char *nat_type; int32_t reg; int family; @@ -205,13 +205,11 @@ static int nft_rule_expr_nat_xml_parse(struct nft_rule_expr *e, mxml_node_t *tre e->flags |= (1 << NFT_EXPR_NAT_TYPE); - family_str = nft_mxml_str_parse(tree, "family", MXML_DESCEND_FIRST); - if (family_str == NULL) - return -1; - - family = nft_str2family(family_str); - if (family < 0) + family = nft_mxml_family_parse(tree, "family", MXML_DESCEND_FIRST); + if (family < 0) { + mxmlDelete(tree); return -1; + } nat->family = family; e->flags |= (1 << NFT_EXPR_NAT_FAMILY); -- cgit v1.2.3