]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
src: xml: table/chain delete properties
authorArturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Mon, 5 Aug 2013 12:01:28 +0000 (14:01 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 5 Aug 2013 12:29:14 +0000 (14:29 +0200)
This patch deletes the <properties> node in chain and table XML objects.

For this to work, the first tree search with MXML_DESCEND_FIRST flag is moved
to the next node.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/chain.c
src/table.c
tests/xmlfiles/01-table.xml
tests/xmlfiles/02-table.xml
tests/xmlfiles/10-chain.xml
tests/xmlfiles/11-chain.xml
tests/xmlfiles/12-chain.xml

index c24aeb01f271694ee4b520bf9644660ecfaf9abe..1964353b78287806c923651de465424ba4025271 100644 (file)
@@ -648,12 +648,9 @@ static int nft_chain_xml_parse(struct nft_chain *c, char *xml)
        c->packets = utmp;
        c->flags |= (1 << NFT_CHAIN_ATTR_PACKETS);
 
-       /* Ignore <properties> node */
-       node = mxmlFindElement(tree, tree, "properties", NULL, NULL,
-                              MXML_DESCEND_FIRST);
-
        /* Get and set <type> */
-       node = mxmlFindElement(tree, tree, "type", NULL, NULL, MXML_DESCEND);
+       node = mxmlFindElement(tree, tree, "type", NULL, NULL,
+                              MXML_DESCEND_FIRST);
        if (node == NULL) {
                mxmlDelete(tree);
                return -1;
@@ -820,12 +817,8 @@ static int nft_chain_snprintf_xml(char *buf, size_t size, struct nft_chain *c)
        ret = snprintf(buf, size,
                       "<chain name=\"%s\" handle=\"%"PRIu64"\""
                       " bytes=\"%"PRIu64"\" packets=\"%"PRIu64"\">"
-                      "<properties>"
-                               "<type>%s</type>"
-                               "<table>%s</table>"
-                               "<prio>%d</prio>"
-                               "<use>%d</use>"
-                               "<hooknum>%s</hooknum>",
+                      "<type>%s</type><table>%s</table><prio>%d</prio>"
+                      "<use>%d</use><hooknum>%s</hooknum>",
                       c->name, c->handle, c->bytes, c->packets,
                       c->type, c->table,
                       c->prio, c->use, hooknum2str_array[c->hooknum]);
@@ -842,8 +835,7 @@ static int nft_chain_snprintf_xml(char *buf, size_t size, struct nft_chain *c)
                SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
        }
 
-       ret = snprintf(buf+offset, size, "<family>%s</family>"
-                      "</properties></chain>",
+       ret = snprintf(buf+offset, size, "<family>%s</family></chain>",
                       nft_family2str(c->family));
        SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
index 402e8c179c9b395351972ca54d889404cbe60065..76a1b4be647878af8576cefbf2c775df5a7cae24 100644 (file)
@@ -244,12 +244,9 @@ static int nft_table_xml_parse(struct nft_table *t, char *xml)
        t->name = strdup(mxmlElementGetAttr(tree, "name"));
        t->flags |= (1 << NFT_TABLE_ATTR_NAME);
 
-       /* Ignore <properties> node */
-       node = mxmlFindElement(tree, tree, "properties", NULL, NULL,
-                              MXML_DESCEND_FIRST);
-
        /* Get the and set <family> node */
-       node = mxmlFindElement(tree, tree, "family", NULL, NULL, MXML_DESCEND);
+       node = mxmlFindElement(tree, tree, "family", NULL, NULL,
+                              MXML_DESCEND_FIRST);
        if (node == NULL) {
                mxmlDelete(tree);
                return -1;
@@ -363,13 +360,9 @@ static int nft_table_snprintf_json(char *buf, size_t size, struct nft_table *t)
 
 static int nft_table_snprintf_xml(char *buf, size_t size, struct nft_table *t)
 {
-       return snprintf(buf, size, "<table name=\"%s\">"
-                               "<properties>"
-                                       "<family>%s</family>"
-                                       "<table_flags>%d</table_flags>"
-                               "</properties>"
-                               "</table>",
-                      t->name, nft_family2str(t->family), t->table_flags);
+       return snprintf(buf, size, "<table name=\"%s\"><family>%s</family>"
+                       "<table_flags>%d</table_flags></table>",
+                       t->name, nft_family2str(t->family), t->table_flags);
 }
 
 static int nft_table_snprintf_default(char *buf, size_t size, struct nft_table *t)
index 133041d470752a5463a689f2af139888807cafb7..2e333547fd255ecf8b7772737d5148d1d0cdf80a 100644 (file)
@@ -1,6 +1,4 @@
 <table name="filter">
-       <properties>
-               <family>ip</family>
-               <table_flags>0</table_flags>
-       </properties>
+       <family>ip</family>
+       <table_flags>0</table_flags>
 </table>
index 0aef342b1bd48f7a3bd9d1b2d35fa8a0714b8cce..27d02083e255565be7cc014b6ff0d2ce39c9b307 100644 (file)
@@ -1,6 +1,4 @@
 <table name="nat">
-       <properties>
-               <family>ip6</family>
-               <table_flags>0</table_flags>
-       </properties>
+       <family>ip6</family>
+       <table_flags>0</table_flags>
 </table>
index 4de10202781575e6d77560c344d4d5b0e8272874..6d1875e5f7f15ef3d7ca96cf7ca6bb2c59d59a32 100644 (file)
@@ -1,11 +1,9 @@
 <chain name="test" handle="0" bytes="0" packets="0">
-       <properties>
-               <type>filter</type>
-               <table>filter</table>
-               <prio>0</prio>
-               <use>1</use>
-               <hooknum>NF_INET_LOCAL_IN</hooknum>
-               <policy>accept</policy>
-               <family>ip</family>
-       </properties>
+       <type>filter</type>
+       <table>filter</table>
+       <prio>0</prio>
+       <use>1</use>
+       <hooknum>NF_INET_LOCAL_IN</hooknum>
+       <policy>accept</policy>
+       <family>ip</family>
 </chain>
index 310aeaa0c5c707a6a6120853282f1ffffc8b9e50..986cd81379ab421e1f7befb387555df2bfcb5874 100644 (file)
@@ -1,11 +1,9 @@
 <chain name="test" handle="0" bytes="59" packets="1">
-       <properties>
-               <type>filter</type>
-               <table>filter</table>
-               <prio>0</prio>
-               <use>1</use>
-               <hooknum>NF_INET_FORWARD</hooknum>
-               <policy>drop</policy>
-               <family>ip6</family>
-       </properties>
+       <type>filter</type>
+       <table>filter</table>
+       <prio>0</prio>
+       <use>1</use>
+       <hooknum>NF_INET_FORWARD</hooknum>
+       <policy>drop</policy>
+       <family>ip6</family>
 </chain>
index 20ee2a830dd062c4848f9dc1a35bf27e70452b02..23fef8c3e9c25294459eac9d3536565354466f20 100644 (file)
@@ -1,11 +1,9 @@
 <chain name="foo" handle="100" bytes="59264154979" packets="2548796325">
-       <properties>
-               <type>nat</type>
-               <table>nat</table>
-               <prio>0</prio>
-               <use>1</use>
-               <hooknum>NF_INET_POST_ROUTING</hooknum>
-               <policy>accept</policy>
-               <family>ip</family>
-       </properties>
+       <type>nat</type>
+       <table>nat</table>
+       <prio>0</prio>
+       <use>1</use>
+       <hooknum>NF_INET_POST_ROUTING</hooknum>
+       <policy>accept</policy>
+       <family>ip</family>
 </chain>