From 44928cd546f00a73797a570dcaee44f0bfe5bea7 Mon Sep 17 00:00:00 2001 From: Arturo Borrero Date: Fri, 26 Jul 2013 14:22:03 +0200 Subject: set: add XML parsing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sets are now parsed, following this previous snprintf pattern: string table int uint32_t uint32_t size_t uint32_t size_t uint32_t [...] Signed-off-by: Arturo Borrero González Signed-off-by: Pablo Neira Ayuso --- tests/nft-parsing-test.c | 10 ++++++++++ tests/xmlfiles/73-set.xml | 39 +++++++++++++++++++++++++++++++++++++++ tests/xmlfiles/74-set.xml | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 tests/xmlfiles/73-set.xml create mode 100644 tests/xmlfiles/74-set.xml (limited to 'tests') diff --git a/tests/nft-parsing-test.c b/tests/nft-parsing-test.c index 83a627c..0734f07 100644 --- a/tests/nft-parsing-test.c +++ b/tests/nft-parsing-test.c @@ -9,6 +9,7 @@ #include #include #include +#include #ifdef XML_PARSING #include @@ -62,6 +63,7 @@ static int test_xml(const char *filename) struct nft_table *t = NULL; struct nft_chain *c = NULL; struct nft_rule *r = NULL; + struct nft_set *s = NULL; FILE *fp; mxml_node_t *tree = NULL;; char *xml = NULL; @@ -102,6 +104,14 @@ static int test_xml(const char *filename) nft_rule_free(r); } + } else if (strcmp(tree->value.opaque, "set") == 0) { + s = nft_set_alloc(); + if (s != NULL) { + if (nft_set_parse(s, NFT_SET_PARSE_XML, xml) == 0) + ret = 0; + + nft_set_free(s); + } } return ret; diff --git a/tests/xmlfiles/73-set.xml b/tests/xmlfiles/73-set.xml new file mode 100644 index 0000000..6807ea7 --- /dev/null +++ b/tests/xmlfiles/73-set.xml @@ -0,0 +1,39 @@ + + set0 + filter + 0 + ip + 0 + 0 + 0 + 0 + 0 + + 0 + + + 4 + 0x0300a8c0 + + + + + 0 + + + 4 + 0x0200a8c0 + + + + + 0 + + + 4 + 0x0100a8c0 + + + + + diff --git a/tests/xmlfiles/74-set.xml b/tests/xmlfiles/74-set.xml new file mode 100644 index 0000000..dd65703 --- /dev/null +++ b/tests/xmlfiles/74-set.xml @@ -0,0 +1,36 @@ + + set0 + filter + 0 + ip6 + 0 + 0 + 0 + 0 + 0 + + 0 + + + 16 + 0xc09a002a + 0x2700cac1 + 0x00000000 + 0x70010000 + + + + + 0 + + + 16 + 0xc09a002a + 0x2700cac1 + 0x00000000 + 0x50010000 + + + + + -- cgit v1.2.3