Patchwork [libnftables] set: xml: change XML attributes to nodes.

login
register
mail settings
Submitter Arturo Borrero
Date July 26, 2013, 12:11 p.m.
Message ID <20130726121107.5396.26597.stgit@nfdev.cica.es>
Download mbox | patch
Permalink /patch/262139/
State Accepted
Headers show

Comments

Arturo Borrero - July 26, 2013, 12:11 p.m.
This patch changes all XML attributes to XML nodes in nft_set.

In order to avoid issues regarding XML nodes with the same name but
different meanings, I've followed this pattern for the new elements:

<set>
	<set_table>string</set_table>
	<set_name>string</set_name>
	<set_xml_version>int</set_xml_version>
	[...]
</set>

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
 src/set.c |   16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/src/set.c b/src/set.c
index ef15527..f525fa8 100644
--- a/src/set.c
+++ b/src/set.c
@@ -386,20 +386,18 @@  static int nft_set_snprintf_xml(char *buf, size_t size, struct nft_set *s,
 	int len = size, offset = 0;
 	struct nft_set_elem *elem;
 
-	ret = snprintf(buf, size,
-		       "<set name=\"%s\" table=\"%s\" version=\"%d\">",
-		       s->name, s->table, NFT_SET_XML_VERSION);
-	SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
-
-	ret = snprintf(buf+offset, size, "<family>%s</family>"
+	ret = snprintf(buf, size, "<set><family>%s</family>"
+					"<set_table>%s</set_table>"
+					"<set_name>%s</set_name>"
+					"<set_xml_version>%d</set_xml_version>"
 					"<set_flags>%u</set_flags>"
 					"<key_type>%u</key_type>"
 					"<key_len>%u</key_len>"
 					"<data_type>%u</data_type>"
 					"<data_len>%u</data_len>",
-			nft_family2str(s->family),
-			s->set_flags, s->key_type, s->key_len,
-			s->data_type, s->data_len);
+			nft_family2str(s->family), s->table, s->name,
+			NFT_SET_XML_VERSION,  s->set_flags, s->key_type,
+			s->key_len, s->data_type, s->data_len);
 	SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
 	if (!list_empty(&s->element_list)) {