path: root/src/mxml.c
diff options
authorArturo Borrero Gonzalez <>2013-08-06 10:40:33 +0200
committerPablo Neira Ayuso <>2013-08-06 11:44:20 +0200
commitb58cf8947422ba695df80fe3b012b383fff22f7a (patch)
treeed5708d68972c225492771b57397c52bfef1fc4d /src/mxml.c
parentec75831c439ebd3475e0ba6766188d963538129a (diff)
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: <table name="filter"> <family>ip</family> <table_flags>0</table_flags> </table> After: <table> <name>filter</name> <family>ip</family> <table_flags>0</table_flags> </table> 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 <>
Diffstat (limited to 'src/mxml.c')
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mxml.c b/src/mxml.c
index ed1134f..1f0a2df 100644
--- a/src/mxml.c
+++ b/src/mxml.c
@@ -166,6 +166,25 @@ const char *nft_mxml_str_parse(mxml_node_t *tree, const char *node_name,
return strdup(node->child->value.opaque);
+int nft_mxml_family_parse(mxml_node_t *tree, const char *node_name,
+ uint32_t mxml_flags)
+ const char *family_str;
+ int family;
+ family_str = nft_mxml_str_parse(tree, node_name, mxml_flags);
+ if (family_str == NULL)
+ return -1;
+ family = nft_str2family(family_str);
+ xfree(family_str);
+ if (family < 0)
+ return family;
struct nft_set_elem *nft_mxml_set_elem_parse(mxml_node_t *node)
mxml_node_t *save;