From e87d2f9ef8a4a298de5514b30ec2d43d3c90a644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Neira=20Ayuso?= Date: Mon, 6 Jan 2014 00:51:14 +0100 Subject: src: new error reporting approach for XML/JSON parsers I have added a new structure for reporting some errors in parser that we can't cover with errno. In this patch, we have three errors that we can't cover with errno: NFT_PARSE_EBADINPUT : Bad XML/JSON format in the input NFT_PARSE_EMISSINGNODE : Missing node in our input NFT_PARSE_EBADTYPE : Wrong type value in a node Signed-off-by: Alvaro Neira Ayuso Signed-off-by: Pablo Neira Ayuso --- tests/nft-parsing-test.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'tests') diff --git a/tests/nft-parsing-test.c b/tests/nft-parsing-test.c index 6a5ab4d..558c849 100644 --- a/tests/nft-parsing-test.c +++ b/tests/nft-parsing-test.c @@ -167,7 +167,7 @@ static int compare_test(uint32_t type, void *input, const char *filename) } #endif -static int test_json(const char *filename) +static int test_json(const char *filename, struct nft_parse_err *err) { #ifdef JSON_PARSING int ret = -1; @@ -181,17 +181,15 @@ static int test_json(const char *filename) char *json; root = json_load_file(filename, 0, &error); - if (!root) { - printf("Error on the line %d : %s", error.line, error.text); + if (!root) return -1; - } json = json_dumps(root, JSON_INDENT(0)); if (json_object_get(root, "table") != NULL) { t = nft_table_alloc(); if (t != NULL) { - if (nft_table_parse(t, NFT_PARSE_JSON, json) == 0) + if (nft_table_parse(t, NFT_PARSE_JSON, json, err) == 0) ret = compare_test(TEST_JSON_TABLE, t, filename); else goto failparsing; @@ -201,7 +199,7 @@ static int test_json(const char *filename) } else if (json_object_get(root, "chain") != NULL) { c = nft_chain_alloc(); if (c != NULL) { - if (nft_chain_parse(c, NFT_PARSE_JSON, json) == 0) + if (nft_chain_parse(c, NFT_PARSE_JSON, json, err) == 0) ret = compare_test(TEST_JSON_CHAIN, c, filename); else goto failparsing; @@ -211,7 +209,7 @@ static int test_json(const char *filename) } else if (json_object_get(root, "rule") != NULL) { r = nft_rule_alloc(); if (r != NULL) { - if (nft_rule_parse(r, NFT_PARSE_JSON, json) == 0) + if (nft_rule_parse(r, NFT_PARSE_JSON, json, err) == 0) ret = compare_test(TEST_JSON_RULE, r, filename); else goto failparsing; @@ -221,7 +219,7 @@ static int test_json(const char *filename) } else if (json_object_get(root, "set") != NULL) { s = nft_set_alloc(); if (s != NULL) { - if (nft_set_parse(s, NFT_PARSE_JSON, json) == 0) + if (nft_set_parse(s, NFT_PARSE_JSON, json, err) == 0) ret = compare_test(TEST_JSON_SET, s, filename); else goto failparsing; @@ -231,7 +229,7 @@ static int test_json(const char *filename) } else if (json_object_get(root, "nftables") != NULL) { rs = nft_ruleset_alloc(); if (rs != NULL) { - if (nft_ruleset_parse(rs, NFT_PARSE_JSON, json) == 0) + if (nft_ruleset_parse(rs, NFT_PARSE_JSON, json, err) == 0) ret = compare_test(TEST_JSON_RULESET, rs, filename); else goto failparsing; @@ -256,7 +254,7 @@ failparsing: #endif } -static int test_xml(const char *filename) +static int test_xml(const char *filename, struct nft_parse_err *err) { #ifdef XML_PARSING int ret = -1; @@ -290,7 +288,7 @@ static int test_xml(const char *filename) if (strcmp(tree->value.opaque, "table") == 0) { t = nft_table_alloc(); if (t != NULL) { - if (nft_table_parse(t, NFT_PARSE_XML, xml) == 0) + if (nft_table_parse(t, NFT_PARSE_XML, xml, err) == 0) ret = compare_test(TEST_XML_TABLE, t, filename); else goto failparsing; @@ -300,7 +298,7 @@ static int test_xml(const char *filename) } else if (strcmp(tree->value.opaque, "chain") == 0) { c = nft_chain_alloc(); if (c != NULL) { - if (nft_chain_parse(c, NFT_PARSE_XML, xml) == 0) + if (nft_chain_parse(c, NFT_PARSE_XML, xml, err) == 0) ret = compare_test(TEST_XML_CHAIN, c, filename); else goto failparsing; @@ -310,7 +308,7 @@ static int test_xml(const char *filename) } else if (strcmp(tree->value.opaque, "rule") == 0) { r = nft_rule_alloc(); if (r != NULL) { - if (nft_rule_parse(r, NFT_PARSE_XML, xml) == 0) + if (nft_rule_parse(r, NFT_PARSE_XML, xml, err) == 0) ret = compare_test(TEST_XML_RULE, r, filename); else goto failparsing; @@ -320,7 +318,7 @@ static int test_xml(const char *filename) } else if (strcmp(tree->value.opaque, "set") == 0) { s = nft_set_alloc(); if (s != NULL) { - if (nft_set_parse(s, NFT_PARSE_XML, xml) == 0) + if (nft_set_parse(s, NFT_PARSE_XML, xml, err) == 0) ret = compare_test(TEST_XML_SET, s, filename); else goto failparsing; @@ -331,7 +329,7 @@ static int test_xml(const char *filename) rs = nft_ruleset_alloc(); if (rs != NULL) { if (nft_ruleset_parse(rs, NFT_PARSE_XML, - xml) == 0) + xml, err) == 0) ret = compare_test(TEST_XML_RULESET, rs, filename); else @@ -361,6 +359,7 @@ int main(int argc, char *argv[]) struct dirent *dent; char path[PATH_MAX]; int ret = 0, exit_code = 0; + struct nft_parse_err *err; if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); @@ -373,6 +372,12 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } + err = nft_parse_err_alloc(); + if (err == NULL) { + perror("error"); + exit(EXIT_FAILURE); + } + while ((dent = readdir(d)) != NULL) { int len = strlen(dent->d_name); @@ -383,14 +388,14 @@ int main(int argc, char *argv[]) snprintf(path, sizeof(path), "%s/%s", argv[1], dent->d_name); if (strcmp(&dent->d_name[len-4], ".xml") == 0) { - if ((ret = test_xml(path)) == 0) { + if ((ret = test_xml(path, err)) == 0) { printf("parsing and validating %s: ", path); printf("\033[32mOK\e[0m\n"); } exit_code += ret; } if (strcmp(&dent->d_name[len-5], ".json") == 0) { - if ((ret = test_json(path)) == 0) { + if ((ret = test_json(path, err)) == 0) { printf("parsing and validating %s: ", path); printf("\033[32mOK\e[0m\n"); } @@ -399,6 +404,7 @@ int main(int argc, char *argv[]) } closedir(d); + nft_parse_err_free(err); if (exit_code != 0) exit(EXIT_FAILURE); -- cgit v1.2.3 From eaf04163c4a0baeeddf8a449ecb9d47e111ff557 Mon Sep 17 00:00:00 2001 From: Arturo Borrero Date: Thu, 9 Jan 2014 12:19:17 +0100 Subject: tests: nft-parsing-test: use nft_ruleset_parse_file() All testfiles are now enclosed in the corresponding top element, ie. * XML: ... * JSON: {"nftables":[...]} Signed-off-by: Arturo Borrero Gonzalez Signed-off-by: Pablo Neira Ayuso --- tests/jsonfiles/01-table.json | 2 +- tests/jsonfiles/02-table.json | 2 +- tests/jsonfiles/11-chain.json | 2 +- tests/jsonfiles/12-chain.json | 2 +- tests/jsonfiles/13-chain.json | 2 +- tests/jsonfiles/14-chain.json | 2 +- tests/jsonfiles/20-rule-bitwise.json | 2 +- tests/jsonfiles/21-rule-byteorder.json | 2 +- tests/jsonfiles/22-rule-cmp.json | 2 +- tests/jsonfiles/23-rule-counter.json | 2 +- tests/jsonfiles/24-rule-ct.json | 2 +- tests/jsonfiles/25-rule-exthdr.json | 2 +- tests/jsonfiles/26-rule-immediate.json | 2 +- tests/jsonfiles/27-rule-limit.json | 2 +- tests/jsonfiles/28-rule-log.json | 2 +- tests/jsonfiles/29-rule-match.json | 2 +- tests/jsonfiles/30-rule-lookup.json | 2 +- tests/jsonfiles/31-rule-meta.json | 2 +- tests/jsonfiles/32-rule-nat4.json | 2 +- tests/jsonfiles/33-rule-nat6.json | 2 +- tests/jsonfiles/34-rule-payload.json | 2 +- tests/jsonfiles/35-rule-target.json | 2 +- tests/jsonfiles/36-rule-real.json | 2 +- tests/jsonfiles/37-rule-real.json | 2 +- tests/jsonfiles/38-rule-real.json | 2 +- tests/jsonfiles/39-rule-real.json | 2 +- tests/jsonfiles/40-rule-real.json | 2 +- tests/jsonfiles/41-rule-real.json | 2 +- tests/jsonfiles/42-rule-real.json | 2 +- tests/jsonfiles/43-rule-real.json | 2 +- tests/jsonfiles/44-rule-real.json | 2 +- tests/jsonfiles/45-rule-real.json | 2 +- tests/jsonfiles/46-rule-real.json | 2 +- tests/jsonfiles/47-rule-real.json | 2 +- tests/jsonfiles/48-rule-real.json | 2 +- tests/jsonfiles/49-rule-real.json | 2 +- tests/jsonfiles/50-rule-real.json | 2 +- tests/jsonfiles/51-rule-real.json | 2 +- tests/jsonfiles/52-rule-real.json | 2 +- tests/jsonfiles/53-rule-real.json | 2 +- tests/jsonfiles/54-rule-real.json | 2 +- tests/jsonfiles/55-rule-real.json | 2 +- tests/jsonfiles/56-rule-real.json | 2 +- tests/jsonfiles/57-rule-real.json | 2 +- tests/jsonfiles/58-rule-real.json | 2 +- tests/jsonfiles/59-rule-real.json | 2 +- tests/jsonfiles/60-rule-real.json | 2 +- tests/jsonfiles/61-rule-real.json | 2 +- tests/jsonfiles/62-set.json | 2 +- tests/jsonfiles/63-set.json | 2 +- tests/jsonfiles/64-ruleset.json | 1 - tests/nft-parsing-test.c | 261 +++++---------------------------- tests/xmlfiles/01-table.xml | 2 +- tests/xmlfiles/02-table.xml | 2 +- tests/xmlfiles/10-chain.xml | 2 +- tests/xmlfiles/11-chain.xml | 2 +- tests/xmlfiles/12-chain.xml | 2 +- tests/xmlfiles/20-rule-bitwise.xml | 2 +- tests/xmlfiles/21-rule-byteorder.xml | 2 +- tests/xmlfiles/22-rule-cmp.xml | 2 +- tests/xmlfiles/23-rule-counter.xml | 2 +- tests/xmlfiles/24-rule-ct.xml | 2 +- tests/xmlfiles/25-rule-exthdr.xml | 2 +- tests/xmlfiles/26-rule-immediate.xml | 2 +- tests/xmlfiles/27-rule-limit.xml | 2 +- tests/xmlfiles/28-rule-log.xml | 2 +- tests/xmlfiles/29-rule-lookup.xml | 2 +- tests/xmlfiles/30-rule-match.xml | 2 +- tests/xmlfiles/31-rule-meta.xml | 2 +- tests/xmlfiles/32-rule-nat6.xml | 2 +- tests/xmlfiles/33-rule-nat4.xml | 2 +- tests/xmlfiles/34-rule-payload.xml | 2 +- tests/xmlfiles/35-rule-target.xml | 2 +- tests/xmlfiles/36-rule-real.xml | 2 +- tests/xmlfiles/37-rule-real.xml | 2 +- tests/xmlfiles/38-rule-real.xml | 2 +- tests/xmlfiles/39-rule-real.xml | 2 +- tests/xmlfiles/40-rule-real.xml | 2 +- tests/xmlfiles/41-rule-real.xml | 2 +- tests/xmlfiles/42-rule-real.xml | 2 +- tests/xmlfiles/43-rule-real.xml | 2 +- tests/xmlfiles/44-rule-real.xml | 2 +- tests/xmlfiles/45-rule-real.xml | 2 +- tests/xmlfiles/46-rule-real.xml | 2 +- tests/xmlfiles/47-rule-real.xml | 2 +- tests/xmlfiles/48-rule-real.xml | 2 +- tests/xmlfiles/49-rule-real.xml | 2 +- tests/xmlfiles/50-rule-real.xml | 2 +- tests/xmlfiles/51-rule-real.xml | 2 +- tests/xmlfiles/52-rule-real.xml | 2 +- tests/xmlfiles/53-rule-real.xml | 2 +- tests/xmlfiles/54-rule-real.xml | 2 +- tests/xmlfiles/55-rule-real.xml | 2 +- tests/xmlfiles/56-rule-real.xml | 2 +- tests/xmlfiles/57-rule-real.xml | 2 +- tests/xmlfiles/58-rule-real.xml | 2 +- tests/xmlfiles/59-rule-real.xml | 2 +- tests/xmlfiles/60-rule-real.xml | 2 +- tests/xmlfiles/61-rule-real.xml | 2 +- tests/xmlfiles/62-rule-real.xml | 2 +- tests/xmlfiles/63-rule-real.xml | 2 +- tests/xmlfiles/64-rule-real.xml | 2 +- tests/xmlfiles/65-rule-real.xml | 2 +- tests/xmlfiles/66-rule-real.xml | 2 +- tests/xmlfiles/67-rule-real.xml | 2 +- tests/xmlfiles/68-rule-real.xml | 2 +- tests/xmlfiles/69-rule-real.xml | 2 +- tests/xmlfiles/70-rule-real.xml | 2 +- tests/xmlfiles/71-rule-real.xml | 2 +- tests/xmlfiles/72-rule-real.xml | 2 +- tests/xmlfiles/73-set.xml | 2 +- tests/xmlfiles/74-set.xml | 2 +- 112 files changed, 144 insertions(+), 338 deletions(-) (limited to 'tests') diff --git a/tests/jsonfiles/01-table.json b/tests/jsonfiles/01-table.json index cfe7e9d..8668fb79 100644 --- a/tests/jsonfiles/01-table.json +++ b/tests/jsonfiles/01-table.json @@ -1 +1 @@ -{"table":{"name":"filter","family":"ip","flags":0}} +{"nftables":[{"table":{"name":"filter","family":"ip","flags":0}}]} diff --git a/tests/jsonfiles/02-table.json b/tests/jsonfiles/02-table.json index ddd119c..f8f5a1d 100644 --- a/tests/jsonfiles/02-table.json +++ b/tests/jsonfiles/02-table.json @@ -1 +1 @@ -{"table":{"name":"filter2","family":"ip6","flags":0}} +{"nftables":[{"table":{"name":"filter2","family":"ip6","flags":0}}]} diff --git a/tests/jsonfiles/11-chain.json b/tests/jsonfiles/11-chain.json index e1ed07f..2610b79 100644 --- a/tests/jsonfiles/11-chain.json +++ b/tests/jsonfiles/11-chain.json @@ -1 +1 @@ -{"chain":{"name":"input","handle":1,"bytes":1375696,"packets":4136,"family":"ip","table":"filter","use":0,"type":"filter","hooknum":"input","prio":0,"policy":"accept"}} +{"nftables":[{"chain":{"name":"input","handle":1,"bytes":1375696,"packets":4136,"family":"ip","table":"filter","use":0,"type":"filter","hooknum":"input","prio":0,"policy":"accept"}}]} diff --git a/tests/jsonfiles/12-chain.json b/tests/jsonfiles/12-chain.json index b3fa541..3d15982 100644 --- a/tests/jsonfiles/12-chain.json +++ b/tests/jsonfiles/12-chain.json @@ -1 +1 @@ -{"chain":{"name":"forward","handle":2,"bytes":0,"packets":0,"family":"ip","table":"filter","use":0,"type":"filter","hooknum":"forward","prio":0,"policy":"accept"}} +{"nftables":[{"chain":{"name":"forward","handle":2,"bytes":0,"packets":0,"family":"ip","table":"filter","use":0,"type":"filter","hooknum":"forward","prio":0,"policy":"accept"}}]} diff --git a/tests/jsonfiles/13-chain.json b/tests/jsonfiles/13-chain.json index 6d8230d..e3a17f0 100644 --- a/tests/jsonfiles/13-chain.json +++ b/tests/jsonfiles/13-chain.json @@ -1 +1 @@ -{"chain":{"name":"output","handle":3,"bytes":454786,"packets":2681,"family":"ip","table":"filter","use":0,"type":"filter","hooknum":"output","prio":0,"policy":"accept"}} +{"nftables":[{"chain":{"name":"output","handle":3,"bytes":454786,"packets":2681,"family":"ip","table":"filter","use":0,"type":"filter","hooknum":"output","prio":0,"policy":"accept"}}]} diff --git a/tests/jsonfiles/14-chain.json b/tests/jsonfiles/14-chain.json index 44bc106..d98dc94 100644 --- a/tests/jsonfiles/14-chain.json +++ b/tests/jsonfiles/14-chain.json @@ -1 +1 @@ -{"chain":{"name":"chain1","handle":4,"bytes":0,"packets":0,"family":"ip","table":"filter","use":0}} +{"nftables":[{"chain":{"name":"chain1","handle":4,"bytes":0,"packets":0,"family":"ip","table":"filter","use":0}}]} diff --git a/tests/jsonfiles/20-rule-bitwise.json b/tests/jsonfiles/20-rule-bitwise.json index 511ad88..de3d9ec 100644 --- a/tests/jsonfiles/20-rule-bitwise.json +++ b/tests/jsonfiles/20-rule-bitwise.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"input","handle":20,"expr":[{"type":"bitwise","sreg":1,"dreg":1,"len":4,"mask":{"data_reg":{"type":"value","len":4,"data0":"0x0000000a"}},"xor":{"data_reg":{"type":"value","len":4,"data0":"0x00000000"}}}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":20,"expr":[{"type":"bitwise","sreg":1,"dreg":1,"len":4,"mask":{"data_reg":{"type":"value","len":4,"data0":"0x0000000a"}},"xor":{"data_reg":{"type":"value","len":4,"data0":"0x00000000"}}}]}}]} diff --git a/tests/jsonfiles/21-rule-byteorder.json b/tests/jsonfiles/21-rule-byteorder.json index 9c5498e..ae6fb32 100644 --- a/tests/jsonfiles/21-rule-byteorder.json +++ b/tests/jsonfiles/21-rule-byteorder.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"input","handle":21,"expr":[{"type":"byteorder","sreg":3,"dreg":4,"op":"hton","len":4,"size":4}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":21,"expr":[{"type":"byteorder","sreg":3,"dreg":4,"op":"hton","len":4,"size":4}]}}]} diff --git a/tests/jsonfiles/22-rule-cmp.json b/tests/jsonfiles/22-rule-cmp.json index ad1c71a..c32d7ad 100644 --- a/tests/jsonfiles/22-rule-cmp.json +++ b/tests/jsonfiles/22-rule-cmp.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"forward","handle":22,"expr":[{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":16,"data0":"0x00000000","data1":"0x6e6f6200","data2":"0x2e303164","data3":"0x00393331"}}}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"forward","handle":22,"expr":[{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":16,"data0":"0x00000000","data1":"0x6e6f6200","data2":"0x2e303164","data3":"0x00393331"}}}]}}]} diff --git a/tests/jsonfiles/23-rule-counter.json b/tests/jsonfiles/23-rule-counter.json index 331ab2c..95d5072 100644 --- a/tests/jsonfiles/23-rule-counter.json +++ b/tests/jsonfiles/23-rule-counter.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":23,"expr":[{"type":"counter","pkts":135,"bytes":21655}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":23,"expr":[{"type":"counter","pkts":135,"bytes":21655}]}}]} diff --git a/tests/jsonfiles/24-rule-ct.json b/tests/jsonfiles/24-rule-ct.json index 3b161f3..1aa3dd2 100644 --- a/tests/jsonfiles/24-rule-ct.json +++ b/tests/jsonfiles/24-rule-ct.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"input","handle":24,"expr":[{"type":"ct","dreg":1,"key":"state"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x00000008"}}}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":24,"expr":[{"type":"ct","dreg":1,"key":"state"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x00000008"}}}]}}]} diff --git a/tests/jsonfiles/25-rule-exthdr.json b/tests/jsonfiles/25-rule-exthdr.json index 32667a3..c40a074 100644 --- a/tests/jsonfiles/25-rule-exthdr.json +++ b/tests/jsonfiles/25-rule-exthdr.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"input","handle":25,"expr":[{"type":"exthdr","dreg":1,"exthdr_type":"mh","offset":2,"len":16}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":25,"expr":[{"type":"exthdr","dreg":1,"exthdr_type":"mh","offset":2,"len":16}]}}]} diff --git a/tests/jsonfiles/26-rule-immediate.json b/tests/jsonfiles/26-rule-immediate.json index fbe7f8b..3582a39 100644 --- a/tests/jsonfiles/26-rule-immediate.json +++ b/tests/jsonfiles/26-rule-immediate.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"input","handle":26,"expr":[{"type":"immediate","dreg":0,"immediatedata":{"data_reg":{"type":"verdict","verdict":"accept"}}}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":26,"expr":[{"type":"immediate","dreg":0,"immediatedata":{"data_reg":{"type":"verdict","verdict":"accept"}}}]}}]} diff --git a/tests/jsonfiles/27-rule-limit.json b/tests/jsonfiles/27-rule-limit.json index 3ac5118..c268357 100644 --- a/tests/jsonfiles/27-rule-limit.json +++ b/tests/jsonfiles/27-rule-limit.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"input","handle":27,"expr":[{"type":"limit","rate":321321,"unit":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":27,"expr":[{"type":"limit","rate":321321,"unit":0}]}}]} diff --git a/tests/jsonfiles/28-rule-log.json b/tests/jsonfiles/28-rule-log.json index ad0ca8f..1e739f1 100644 --- a/tests/jsonfiles/28-rule-log.json +++ b/tests/jsonfiles/28-rule-log.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"input","handle":28,"expr":[{"type":"log","prefix":"test_chain","group":1,"snaplen":0,"qthreshold":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":28,"expr":[{"type":"log","prefix":"test_chain","group":1,"snaplen":0,"qthreshold":0}]}}]} diff --git a/tests/jsonfiles/29-rule-match.json b/tests/jsonfiles/29-rule-match.json index 78f087d..b533e77 100644 --- a/tests/jsonfiles/29-rule-match.json +++ b/tests/jsonfiles/29-rule-match.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"input","handle":9,"expr":[{"type":"match","name":"state"},{"type":"counter","pkts":0,"bytes":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":9,"expr":[{"type":"match","name":"state"},{"type":"counter","pkts":0,"bytes":0}]}}]} diff --git a/tests/jsonfiles/30-rule-lookup.json b/tests/jsonfiles/30-rule-lookup.json index 5dbf823..05576b0 100644 --- a/tests/jsonfiles/30-rule-lookup.json +++ b/tests/jsonfiles/30-rule-lookup.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"input","handle":8,"expr":[{"type":"payload","dreg":1,"offset":12,"len":4,"base":"network"},{"type":"lookup","set":"set0","sreg":1,"dreg":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":8,"expr":[{"type":"payload","dreg":1,"offset":12,"len":4,"base":"network"},{"type":"lookup","set":"set0","sreg":1,"dreg":0}]}}]} diff --git a/tests/jsonfiles/31-rule-meta.json b/tests/jsonfiles/31-rule-meta.json index b52d29e..96e02e5 100644 --- a/tests/jsonfiles/31-rule-meta.json +++ b/tests/jsonfiles/31-rule-meta.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":8,"expr":[{"type":"meta","dreg":1,"key":"protocol"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x000003e8"}}},{"type":"counter","pkts":0,"bytes":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":8,"expr":[{"type":"meta","dreg":1,"key":"protocol"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x000003e8"}}},{"type":"counter","pkts":0,"bytes":0}]}}]} diff --git a/tests/jsonfiles/32-rule-nat4.json b/tests/jsonfiles/32-rule-nat4.json index eb3ae5b..aa2b50d 100644 --- a/tests/jsonfiles/32-rule-nat4.json +++ b/tests/jsonfiles/32-rule-nat4.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"input","handle":10,"expr":[{"type":"nat","nat_type":"dnat","family":"ip","sreg_addr_min":1,"sreg_addr_max":2,"sreg_proto_min":3,"sreg_proto_max":4}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":10,"expr":[{"type":"nat","nat_type":"dnat","family":"ip","sreg_addr_min":1,"sreg_addr_max":2,"sreg_proto_min":3,"sreg_proto_max":4}]}}]} diff --git a/tests/jsonfiles/33-rule-nat6.json b/tests/jsonfiles/33-rule-nat6.json index fae48d0..e5d8c8f 100644 --- a/tests/jsonfiles/33-rule-nat6.json +++ b/tests/jsonfiles/33-rule-nat6.json @@ -1 +1 @@ -{"rule":{"family":"ip6","table":"nat","chain":"output","handle":33,"expr":[{"type":"nat","nat_type":"snat","family":"ip6","sreg_addr_min":1,"sreg_addr_max":2,"sreg_proto_min":3,"sreg_proto_max":4}]}} +{"nftables":[{"rule":{"family":"ip6","table":"nat","chain":"output","handle":33,"expr":[{"type":"nat","nat_type":"snat","family":"ip6","sreg_addr_min":1,"sreg_addr_max":2,"sreg_proto_min":3,"sreg_proto_max":4}]}}]} diff --git a/tests/jsonfiles/34-rule-payload.json b/tests/jsonfiles/34-rule-payload.json index 3559ca6..7eaff41 100644 --- a/tests/jsonfiles/34-rule-payload.json +++ b/tests/jsonfiles/34-rule-payload.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"input","handle":26,"expr":[{"type":"payload","dreg":1,"offset":9,"len":1,"base":"network"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":1,"data0":"0x00000006"}}},{"type":"payload","dreg":1,"offset":2,"len":2,"base":"transport"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":2,"data0":"0x00001600"}}},{"type":"immediate","dreg":0,"immediatedata":{"data_reg":{"type":"verdict","verdict":"accept"}}}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":26,"expr":[{"type":"payload","dreg":1,"offset":9,"len":1,"base":"network"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":1,"data0":"0x00000006"}}},{"type":"payload","dreg":1,"offset":2,"len":2,"base":"transport"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":2,"data0":"0x00001600"}}},{"type":"immediate","dreg":0,"immediatedata":{"data_reg":{"type":"verdict","verdict":"accept"}}}]}}]} diff --git a/tests/jsonfiles/35-rule-target.json b/tests/jsonfiles/35-rule-target.json index c8ff656..da02921 100644 --- a/tests/jsonfiles/35-rule-target.json +++ b/tests/jsonfiles/35-rule-target.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"INPUT","handle":20,"expr":[{"type":"counter","pkts":17,"bytes":4436},{"type":"target","name":"LOG"}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"INPUT","handle":20,"expr":[{"type":"counter","pkts":17,"bytes":4436},{"type":"target","name":"LOG"}]}}]} diff --git a/tests/jsonfiles/36-rule-real.json b/tests/jsonfiles/36-rule-real.json index c8bfc26..4c5e331 100644 --- a/tests/jsonfiles/36-rule-real.json +++ b/tests/jsonfiles/36-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":36,"expr":[{"type":"payload","dreg":1,"offset":12,"len":8,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":8,"data0":"0x0100a8c0","data1":"0x6400a8c0"}}},{"type":"counter","pkts":0,"bytes":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":36,"expr":[{"type":"payload","dreg":1,"offset":12,"len":8,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":8,"data0":"0x0100a8c0","data1":"0x6400a8c0"}}},{"type":"counter","pkts":0,"bytes":0}]}}]} diff --git a/tests/jsonfiles/37-rule-real.json b/tests/jsonfiles/37-rule-real.json index d9b4580..2645328 100644 --- a/tests/jsonfiles/37-rule-real.json +++ b/tests/jsonfiles/37-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":37,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":37,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}}]}}]} diff --git a/tests/jsonfiles/38-rule-real.json b/tests/jsonfiles/38-rule-real.json index ce37407..2a7640b 100644 --- a/tests/jsonfiles/38-rule-real.json +++ b/tests/jsonfiles/38-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":38,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":38,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}}]}}]} diff --git a/tests/jsonfiles/39-rule-real.json b/tests/jsonfiles/39-rule-real.json index 8529d06..5ab4fae 100644 --- a/tests/jsonfiles/39-rule-real.json +++ b/tests/jsonfiles/39-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":39,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"gte","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}},{"type":"cmp","sreg":1,"op":"lte","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0xfa00a8c0"}}}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":39,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"gte","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}},{"type":"cmp","sreg":1,"op":"lte","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0xfa00a8c0"}}}]}}]} diff --git a/tests/jsonfiles/40-rule-real.json b/tests/jsonfiles/40-rule-real.json index f13c99e..483a1a5 100644 --- a/tests/jsonfiles/40-rule-real.json +++ b/tests/jsonfiles/40-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":40,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}},{"type":"counter","pkts":0,"bytes":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":40,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}},{"type":"counter","pkts":0,"bytes":0}]}}]} diff --git a/tests/jsonfiles/41-rule-real.json b/tests/jsonfiles/41-rule-real.json index ed23fc2..d8ed85c 100644 --- a/tests/jsonfiles/41-rule-real.json +++ b/tests/jsonfiles/41-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":41,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}},{"type":"counter","pkts":0,"bytes":0},{"type":"immediate","dreg":0,"immediatedata":{"data_reg":{"type":"verdict","verdict":"drop"}}}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":41,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}},{"type":"counter","pkts":0,"bytes":0},{"type":"immediate","dreg":0,"immediatedata":{"data_reg":{"type":"verdict","verdict":"drop"}}}]}}]} diff --git a/tests/jsonfiles/42-rule-real.json b/tests/jsonfiles/42-rule-real.json index 6c305e1..49f9b56 100644 --- a/tests/jsonfiles/42-rule-real.json +++ b/tests/jsonfiles/42-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":42,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}},{"type":"counter","pkts":0,"bytes":0},{"type":"log","prefix":"(null)","group":0,"snaplen":0,"qthreshold":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":42,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}},{"type":"counter","pkts":0,"bytes":0},{"type":"log","prefix":"(null)","group":0,"snaplen":0,"qthreshold":0}]}}]} diff --git a/tests/jsonfiles/43-rule-real.json b/tests/jsonfiles/43-rule-real.json index 95d0333..be2c6fb 100644 --- a/tests/jsonfiles/43-rule-real.json +++ b/tests/jsonfiles/43-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":43,"expr":[{"type":"payload","dreg":1,"offset":9,"len":1,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":1,"data0":"0x00000006"}}},{"type":"payload","dreg":1,"offset":2,"len":2,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":2,"data0":"0x00001600"}}},{"type":"counter","pkts":0,"bytes":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":43,"expr":[{"type":"payload","dreg":1,"offset":9,"len":1,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":1,"data0":"0x00000006"}}},{"type":"payload","dreg":1,"offset":2,"len":2,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":2,"data0":"0x00001600"}}},{"type":"counter","pkts":0,"bytes":0}]}}]} diff --git a/tests/jsonfiles/44-rule-real.json b/tests/jsonfiles/44-rule-real.json index a838dbb..890e529 100644 --- a/tests/jsonfiles/44-rule-real.json +++ b/tests/jsonfiles/44-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":44,"expr":[{"type":"payload","dreg":1,"offset":9,"len":1,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":1,"data0":"0x00000006"}}},{"type":"payload","dreg":1,"offset":0,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x16000004"}}},{"type":"counter","pkts":0,"bytes":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":44,"expr":[{"type":"payload","dreg":1,"offset":9,"len":1,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":1,"data0":"0x00000006"}}},{"type":"payload","dreg":1,"offset":0,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x16000004"}}},{"type":"counter","pkts":0,"bytes":0}]}}]} diff --git a/tests/jsonfiles/45-rule-real.json b/tests/jsonfiles/45-rule-real.json index 8b143d6..ed61093 100644 --- a/tests/jsonfiles/45-rule-real.json +++ b/tests/jsonfiles/45-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":45,"expr":[{"type":"payload","dreg":1,"offset":12,"len":8,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":8,"data0":"0x0100a8c0","data1":"0x6400a8c0"}}},{"type":"counter","pkts":0,"bytes":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":45,"expr":[{"type":"payload","dreg":1,"offset":12,"len":8,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":8,"data0":"0x0100a8c0","data1":"0x6400a8c0"}}},{"type":"counter","pkts":0,"bytes":0}]}}]} diff --git a/tests/jsonfiles/46-rule-real.json b/tests/jsonfiles/46-rule-real.json index 28643c8..ed2431e 100644 --- a/tests/jsonfiles/46-rule-real.json +++ b/tests/jsonfiles/46-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":46,"expr":[{"type":"payload","dreg":1,"offset":9,"len":1,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":1,"data0":"0x00000006"}}},{"type":"payload","dreg":1,"offset":0,"len":8,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":8,"data0":"0x16000004","data1":"0x00000000"}}}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":46,"expr":[{"type":"payload","dreg":1,"offset":9,"len":1,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":1,"data0":"0x00000006"}}},{"type":"payload","dreg":1,"offset":0,"len":8,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":8,"data0":"0x16000004","data1":"0x00000000"}}}]}}]} diff --git a/tests/jsonfiles/47-rule-real.json b/tests/jsonfiles/47-rule-real.json index 8f68634..828e3ef 100644 --- a/tests/jsonfiles/47-rule-real.json +++ b/tests/jsonfiles/47-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":47,"expr":[{"type":"payload","dreg":1,"offset":9,"len":1,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":1,"data0":"0x00000006"}}},{"type":"payload","dreg":1,"offset":0,"len":8,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":8,"data0":"0x16000004","data1":"0x00000000"}}}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":47,"expr":[{"type":"payload","dreg":1,"offset":9,"len":1,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":1,"data0":"0x00000006"}}},{"type":"payload","dreg":1,"offset":0,"len":8,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":8,"data0":"0x16000004","data1":"0x00000000"}}}]}}]} diff --git a/tests/jsonfiles/48-rule-real.json b/tests/jsonfiles/48-rule-real.json index 0cd835e..7f08637 100644 --- a/tests/jsonfiles/48-rule-real.json +++ b/tests/jsonfiles/48-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":48,"expr":[{"type":"meta","dreg":1,"key":"len"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x000003e8"}}},{"type":"counter","pkts":0,"bytes":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":48,"expr":[{"type":"meta","dreg":1,"key":"len"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x000003e8"}}},{"type":"counter","pkts":0,"bytes":0}]}}]} diff --git a/tests/jsonfiles/49-rule-real.json b/tests/jsonfiles/49-rule-real.json index 445f46a..26f2672 100644 --- a/tests/jsonfiles/49-rule-real.json +++ b/tests/jsonfiles/49-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":49,"expr":[{"type":"meta","dreg":1,"key":"mark"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x00000000"}}},{"type":"counter","pkts":55,"bytes":11407}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":49,"expr":[{"type":"meta","dreg":1,"key":"mark"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x00000000"}}},{"type":"counter","pkts":55,"bytes":11407}]}}]} diff --git a/tests/jsonfiles/50-rule-real.json b/tests/jsonfiles/50-rule-real.json index 2722236..b63d722 100644 --- a/tests/jsonfiles/50-rule-real.json +++ b/tests/jsonfiles/50-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":50,"expr":[{"type":"meta","dreg":1,"key":"iif"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x00000001"}}},{"type":"counter","pkts":0,"bytes":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":50,"expr":[{"type":"meta","dreg":1,"key":"iif"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x00000001"}}},{"type":"counter","pkts":0,"bytes":0}]}}]} diff --git a/tests/jsonfiles/51-rule-real.json b/tests/jsonfiles/51-rule-real.json index 3161fa4..441716e 100644 --- a/tests/jsonfiles/51-rule-real.json +++ b/tests/jsonfiles/51-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":51,"expr":[{"type":"meta","dreg":1,"key":"iifname"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":16,"data0":"0x00000000","data1":"0x00000000","data2":"0x65000000","data3":"0x00306874"}}},{"type":"counter","pkts":0,"bytes":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":51,"expr":[{"type":"meta","dreg":1,"key":"iifname"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":16,"data0":"0x00000000","data1":"0x00000000","data2":"0x65000000","data3":"0x00306874"}}},{"type":"counter","pkts":0,"bytes":0}]}}]} diff --git a/tests/jsonfiles/52-rule-real.json b/tests/jsonfiles/52-rule-real.json index d4092c6..baec217 100644 --- a/tests/jsonfiles/52-rule-real.json +++ b/tests/jsonfiles/52-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":52,"expr":[{"type":"meta","dreg":1,"key":"oif"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x00000001"}}},{"type":"counter","pkts":0,"bytes":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":52,"expr":[{"type":"meta","dreg":1,"key":"oif"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x00000001"}}},{"type":"counter","pkts":0,"bytes":0}]}}]} diff --git a/tests/jsonfiles/53-rule-real.json b/tests/jsonfiles/53-rule-real.json index 526c9d3..bb28dea 100644 --- a/tests/jsonfiles/53-rule-real.json +++ b/tests/jsonfiles/53-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":53,"expr":[{"type":"meta","dreg":1,"key":"oifname"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":16,"data0":"0x00000000","data1":"0x00000000","data2":"0x65000000","data3":"0x00306874"}}},{"type":"counter","pkts":0,"bytes":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":53,"expr":[{"type":"meta","dreg":1,"key":"oifname"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":16,"data0":"0x00000000","data1":"0x00000000","data2":"0x65000000","data3":"0x00306874"}}},{"type":"counter","pkts":0,"bytes":0}]}}]} diff --git a/tests/jsonfiles/54-rule-real.json b/tests/jsonfiles/54-rule-real.json index edb8c18..ae3b6e8 100644 --- a/tests/jsonfiles/54-rule-real.json +++ b/tests/jsonfiles/54-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":54,"expr":[{"type":"meta","dreg":1,"key":"skuid"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x000003e8"}}},{"type":"counter","pkts":0,"bytes":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":54,"expr":[{"type":"meta","dreg":1,"key":"skuid"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x000003e8"}}},{"type":"counter","pkts":0,"bytes":0}]}}]} diff --git a/tests/jsonfiles/55-rule-real.json b/tests/jsonfiles/55-rule-real.json index a10fc0f..69febc0 100644 --- a/tests/jsonfiles/55-rule-real.json +++ b/tests/jsonfiles/55-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":55,"expr":[{"type":"meta","dreg":1,"key":"skgid"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x000003e8"}}},{"type":"counter","pkts":0,"bytes":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":55,"expr":[{"type":"meta","dreg":1,"key":"skgid"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x000003e8"}}},{"type":"counter","pkts":0,"bytes":0}]}}]} diff --git a/tests/jsonfiles/56-rule-real.json b/tests/jsonfiles/56-rule-real.json index 137e146..6f5f4c5 100644 --- a/tests/jsonfiles/56-rule-real.json +++ b/tests/jsonfiles/56-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":56,"expr":[{"type":"meta","dreg":1,"key":"secmark"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x00000000"}}},{"type":"counter","pkts":55,"bytes":11407}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":56,"expr":[{"type":"meta","dreg":1,"key":"secmark"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x00000000"}}},{"type":"counter","pkts":55,"bytes":11407}]}}]} diff --git a/tests/jsonfiles/57-rule-real.json b/tests/jsonfiles/57-rule-real.json index 8694ea1..da17f64 100644 --- a/tests/jsonfiles/57-rule-real.json +++ b/tests/jsonfiles/57-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":57,"expr":[{"type":"meta","dreg":1,"key":"len"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x000003e8"}}},{"type":"counter","pkts":0,"bytes":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":57,"expr":[{"type":"meta","dreg":1,"key":"len"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x000003e8"}}},{"type":"counter","pkts":0,"bytes":0}]}}]} diff --git a/tests/jsonfiles/58-rule-real.json b/tests/jsonfiles/58-rule-real.json index 59237b6..52532f1 100644 --- a/tests/jsonfiles/58-rule-real.json +++ b/tests/jsonfiles/58-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":58,"expr":[{"type":"meta","dreg":1,"key":"protocol"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":2,"data0":"0x00000008"}}},{"type":"counter","pkts":55,"bytes":11407}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":58,"expr":[{"type":"meta","dreg":1,"key":"protocol"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":2,"data0":"0x00000008"}}},{"type":"counter","pkts":55,"bytes":11407}]}}]} diff --git a/tests/jsonfiles/59-rule-real.json b/tests/jsonfiles/59-rule-real.json index d6245b2..aa632d3 100644 --- a/tests/jsonfiles/59-rule-real.json +++ b/tests/jsonfiles/59-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":59,"expr":[{"type":"meta","dreg":1,"key":"mark"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x00000000"}}},{"type":"counter","pkts":55,"bytes":11407}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":59,"expr":[{"type":"meta","dreg":1,"key":"mark"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x00000000"}}},{"type":"counter","pkts":55,"bytes":11407}]}}]} diff --git a/tests/jsonfiles/60-rule-real.json b/tests/jsonfiles/60-rule-real.json index 54d5288..4b58efd 100644 --- a/tests/jsonfiles/60-rule-real.json +++ b/tests/jsonfiles/60-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":60,"expr":[{"type":"meta","dreg":1,"key":"iif"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x00000001"}}},{"type":"counter","pkts":0,"bytes":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":60,"expr":[{"type":"meta","dreg":1,"key":"iif"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x00000001"}}},{"type":"counter","pkts":0,"bytes":0}]}}]} diff --git a/tests/jsonfiles/61-rule-real.json b/tests/jsonfiles/61-rule-real.json index 3942c3f..c6acf03 100644 --- a/tests/jsonfiles/61-rule-real.json +++ b/tests/jsonfiles/61-rule-real.json @@ -1 +1 @@ -{"rule":{"family":"ip","table":"filter","chain":"output","handle":61,"expr":[{"type":"meta","dreg":1,"key":"iifname"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":16,"data0":"0x00000000","data1":"0x00000000","data2":"0x65000000","data3":"0x00306874"}}},{"type":"counter","pkts":0,"bytes":0}]}} +{"nftables":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":61,"expr":[{"type":"meta","dreg":1,"key":"iifname"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":16,"data0":"0x00000000","data1":"0x00000000","data2":"0x65000000","data3":"0x00306874"}}},{"type":"counter","pkts":0,"bytes":0}]}}]} diff --git a/tests/jsonfiles/62-set.json b/tests/jsonfiles/62-set.json index 0e52f70..8a8d99c 100644 --- a/tests/jsonfiles/62-set.json +++ b/tests/jsonfiles/62-set.json @@ -1 +1 @@ -{"set":{"name":"set0","table":"filter","flags":3,"family":"ip","key_type":12,"key_len":2,"set_elem":[{"flags":0,"key":{"data_reg":{"type":"value","len":2,"data0":"0x00001700"}}},{"flags":0,"key":{"data_reg":{"type":"value","len":2,"data0":"0x00001600"}}}]}} +{"nftables":[{"set":{"name":"set0","table":"filter","flags":3,"family":"ip","key_type":12,"key_len":2,"set_elem":[{"flags":0,"key":{"data_reg":{"type":"value","len":2,"data0":"0x00001700"}}},{"flags":0,"key":{"data_reg":{"type":"value","len":2,"data0":"0x00001600"}}}]}}]} diff --git a/tests/jsonfiles/63-set.json b/tests/jsonfiles/63-set.json index 90afec3..ea2fe3d 100644 --- a/tests/jsonfiles/63-set.json +++ b/tests/jsonfiles/63-set.json @@ -1 +1 @@ -{"set":{"name":"map0","table":"filter","flags":11,"family":"ip","key_type":12,"key_len":2,"data_type":4294967040,"data_len":16,"set_elem":[{"flags":0,"key":{"data_reg":{"type":"value","len":2,"data0":"0x00001700"}},"data":{"data_reg":{"type":"chain","chain":"forward"}}},{"flags":0,"key":{"data_reg":{"type":"value","len":2,"data0":"0x00001600"}},"data":{"data_reg":{"type":"chain","chain":"chain1"}}}]}} +{"nftables":[{"set":{"name":"map0","table":"filter","flags":11,"family":"ip","key_type":12,"key_len":2,"data_type":4294967040,"data_len":16,"set_elem":[{"flags":0,"key":{"data_reg":{"type":"value","len":2,"data0":"0x00001700"}},"data":{"data_reg":{"type":"chain","chain":"forward"}}},{"flags":0,"key":{"data_reg":{"type":"value","len":2,"data0":"0x00001600"}},"data":{"data_reg":{"type":"chain","chain":"chain1"}}}]}}]} diff --git a/tests/jsonfiles/64-ruleset.json b/tests/jsonfiles/64-ruleset.json index 533d7fa..54eb1ff 100644 --- a/tests/jsonfiles/64-ruleset.json +++ b/tests/jsonfiles/64-ruleset.json @@ -1,2 +1 @@ {"nftables":[{"table":{"name":"filter","family":"ip","flags":0}},{"table":{"name":"filter2","family":"ip6","flags":0}},{"chain":{"name":"input","handle":1,"bytes":10681449,"packets":16216,"family":"ip","table":"filter","use":0,"type":"filter","hooknum":"input","prio":0,"policy":"accept"}},{"chain":{"name":"forward","handle":2,"bytes":0,"packets":0,"family":"ip","table":"filter","use":0,"type":"filter","hooknum":"forward","prio":0,"policy":"accept"}},{"chain":{"name":"output","handle":3,"bytes":2375830,"packets":15184,"family":"ip","table":"filter","use":0,"type":"filter","hooknum":"output","prio":0,"policy":"accept"}},{"chain":{"name":"chain1","handle":4,"bytes":0,"packets":0,"family":"ip","table":"filter","use":0}},{"set":{"name":"set0","table":"filter","flags":3,"family":"ip","key_type":12,"key_len":2}},{"rule":{"family":"ip","table":"filter","chain":"output","handle":6,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}},{"type":"counter","pkts":0,"bytes":0},{"type":"immediate","dreg":0,"immediatedata":{"data_reg":{"type":"verdict","verdict":"drop"}}}]}},{"rule":{"family":"ip","table":"filter","chain":"output","handle":9,"expr":[{"type":"payload","dreg":1,"offset":9,"len":1,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":1,"data0":"0x00000006"}}},{"type":"payload","dreg":1,"offset":2,"len":2,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":2,"data0":"0x00001600"}}},{"type":"counter","pkts":0,"bytes":0}]}},{"rule":{"family":"ip","table":"filter","chain":"output","handle":10,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}},{"type":"counter","pkts":0,"bytes":0}]}},{"rule":{"family":"ip","table":"filter","chain":"output","handle":11,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","cmpdata":{"data_reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}},{"type":"counter","pkts":0,"bytes":0},{"type":"immediate","dreg":0,"immediatedata":{"data_reg":{"type":"verdict","verdict":"drop"}}}]}}]} - diff --git a/tests/nft-parsing-test.c b/tests/nft-parsing-test.c index 558c849..b2ad62e 100644 --- a/tests/nft-parsing-test.c +++ b/tests/nft-parsing-test.c @@ -12,28 +12,11 @@ #include #include -#ifdef XML_PARSING -#include -#endif - -#ifdef JSON_PARSING -#include -#endif - enum { - TEST_XML_TABLE = 0, - TEST_XML_CHAIN, - TEST_XML_RULE, - TEST_XML_SET, TEST_XML_RULESET, - TEST_JSON_TABLE, - TEST_JSON_CHAIN, - TEST_JSON_RULE, - TEST_JSON_SET, TEST_JSON_RULESET, }; -#if defined(XML_PARSING) || defined(JSON_PARSING) static void print_detail_error(char *a, char *b) { int i; @@ -73,68 +56,13 @@ static void print_detail_error(char *a, char *b) } } -static int compare_test(uint32_t type, void *input, const char *filename) +static int compare_test(uint32_t type, struct nft_ruleset *rs, + const char *filename, FILE *fp) { - struct nft_table *t = NULL; - struct nft_chain *c = NULL; - struct nft_rule *r = NULL; - struct nft_set *s = NULL; - struct nft_ruleset *rs = NULL; char orig[4096]; char out[4096]; - FILE *fp; switch (type) { - case TEST_XML_TABLE: - case TEST_JSON_TABLE: - t = (struct nft_table *)input; - break; - case TEST_XML_CHAIN: - case TEST_JSON_CHAIN: - c = (struct nft_chain *)input; - break; - case TEST_XML_RULE: - case TEST_JSON_RULE: - r = (struct nft_rule *)input; - break; - case TEST_XML_SET: - case TEST_JSON_SET: - s = (struct nft_set *)input; - break; - case TEST_XML_RULESET: - case TEST_JSON_RULESET: - rs = (struct nft_ruleset *)input; - break; - default: - errno = EINVAL; - return -1; - } - - switch (type) { - case TEST_XML_TABLE: - nft_table_snprintf(out, sizeof(out), t, NFT_OUTPUT_XML, 0); - break; - case TEST_JSON_TABLE: - nft_table_snprintf(out, sizeof(out), t, NFT_OUTPUT_JSON, 0); - break; - case TEST_XML_CHAIN: - nft_chain_snprintf(out, sizeof(out), c, NFT_OUTPUT_XML, 0); - break; - case TEST_JSON_CHAIN: - nft_chain_snprintf(out, sizeof(out), c, NFT_OUTPUT_JSON, 0); - break; - case TEST_XML_RULE: - nft_rule_snprintf(out, sizeof(out), r, NFT_OUTPUT_XML, 0); - break; - case TEST_JSON_RULE: - nft_rule_snprintf(out, sizeof(out), r, NFT_OUTPUT_JSON, 0); - break; - case TEST_XML_SET: - nft_set_snprintf(out, sizeof(out), s, NFT_OUTPUT_XML, 0); - break; - case TEST_JSON_SET: - nft_set_snprintf(out, sizeof(out), s, NFT_OUTPUT_JSON, 0); - break; case TEST_XML_RULESET: nft_ruleset_snprintf(out, sizeof(out), rs, NFT_OUTPUT_XML, 0); @@ -148,14 +76,8 @@ static int compare_test(uint32_t type, void *input, const char *filename) return -1; } - fp = fopen(filename, "r"); - if (fp == NULL) { - perror("open"); - exit(EXIT_FAILURE); - } - + rewind(fp); fgets(orig, sizeof(orig), fp); - fclose(fp); if (strncmp(orig, out, strlen(out)) == 0) return 0; @@ -165,192 +87,77 @@ static int compare_test(uint32_t type, void *input, const char *filename) print_detail_error(orig, out); return -1; } -#endif static int test_json(const char *filename, struct nft_parse_err *err) { -#ifdef JSON_PARSING int ret = -1; - struct nft_table *t; - struct nft_chain *c; - struct nft_rule *r; - struct nft_set *s; struct nft_ruleset *rs; - json_t *root; - json_error_t error; - char *json; + FILE *fp; - root = json_load_file(filename, 0, &error); - if (!root) + fp = fopen(filename, "r"); + if (fp == NULL) { + printf("unable to open file %s: %s\n", filename, + strerror(errno)); return -1; + } - json = json_dumps(root, JSON_INDENT(0)); - - if (json_object_get(root, "table") != NULL) { - t = nft_table_alloc(); - if (t != NULL) { - if (nft_table_parse(t, NFT_PARSE_JSON, json, err) == 0) - ret = compare_test(TEST_JSON_TABLE, t, filename); - else - goto failparsing; - - nft_table_free(t); - } - } else if (json_object_get(root, "chain") != NULL) { - c = nft_chain_alloc(); - if (c != NULL) { - if (nft_chain_parse(c, NFT_PARSE_JSON, json, err) == 0) - ret = compare_test(TEST_JSON_CHAIN, c, filename); - else - goto failparsing; - - nft_chain_free(c); - } - } else if (json_object_get(root, "rule") != NULL) { - r = nft_rule_alloc(); - if (r != NULL) { - if (nft_rule_parse(r, NFT_PARSE_JSON, json, err) == 0) - ret = compare_test(TEST_JSON_RULE, r, filename); - else - goto failparsing; + rs = nft_ruleset_alloc(); + if (rs == NULL) { + perror("nft_ruleset_alloc"); + return -1; + } - nft_rule_free(r); - } - } else if (json_object_get(root, "set") != NULL) { - s = nft_set_alloc(); - if (s != NULL) { - if (nft_set_parse(s, NFT_PARSE_JSON, json, err) == 0) - ret = compare_test(TEST_JSON_SET, s, filename); - else - goto failparsing; + if (nft_ruleset_parse_file(rs, NFT_PARSE_JSON, fp, err) == 0) + ret = compare_test(TEST_JSON_RULESET, rs, filename, fp); + else + goto failparsing; - nft_set_free(s); - } - } else if (json_object_get(root, "nftables") != NULL) { - rs = nft_ruleset_alloc(); - if (rs != NULL) { - if (nft_ruleset_parse(rs, NFT_PARSE_JSON, json, err) == 0) - ret = compare_test(TEST_JSON_RULESET, rs, filename); - else - goto failparsing; - - nft_ruleset_free(rs); - } - } + nft_ruleset_free(rs); + fclose(fp); - free(json); - json_decref(root); return ret; failparsing: + fclose(fp); printf("parsing %s: ", filename); printf("\033[31mFAILED\e[0m (%s)\n", strerror(errno)); - free(json); - json_decref(root); return -1; -#else - printf("Compiled without support for JSON.\n"); - return -1; -#endif } static int test_xml(const char *filename, struct nft_parse_err *err) { -#ifdef XML_PARSING int ret = -1; - struct nft_table *t; - struct nft_chain *c; - struct nft_rule *r; - struct nft_set *s; struct nft_ruleset *rs; FILE *fp; - mxml_node_t *tree; - char *xml; fp = fopen(filename, "r"); - tree = mxmlLoadFile(NULL, fp, MXML_NO_CALLBACK); - fclose(fp); - - if (tree == NULL) { - printf("unable to build XML tree from file " - "%s \033[31mFAILED\e[0m\n", filename); + if (fp == NULL) { + printf("unable to open file %s: %s\n", filename, + strerror(errno)); return -1; } - xml = mxmlSaveAllocString(tree, MXML_NO_CALLBACK); - if (xml == NULL) { - printf("unable to alloc string from XML tree from %s " - "\033[31mFAILED\e[0m\n", filename); + rs = nft_ruleset_alloc(); + if (rs == NULL) { + perror("nft_ruleset_alloc"); return -1; } - /* Check what parsing should be done */ - if (strcmp(tree->value.opaque, "table") == 0) { - t = nft_table_alloc(); - if (t != NULL) { - if (nft_table_parse(t, NFT_PARSE_XML, xml, err) == 0) - ret = compare_test(TEST_XML_TABLE, t, filename); - else - goto failparsing; - - nft_table_free(t); - } - } else if (strcmp(tree->value.opaque, "chain") == 0) { - c = nft_chain_alloc(); - if (c != NULL) { - if (nft_chain_parse(c, NFT_PARSE_XML, xml, err) == 0) - ret = compare_test(TEST_XML_CHAIN, c, filename); - else - goto failparsing; - - nft_chain_free(c); - } - } else if (strcmp(tree->value.opaque, "rule") == 0) { - r = nft_rule_alloc(); - if (r != NULL) { - if (nft_rule_parse(r, NFT_PARSE_XML, xml, err) == 0) - ret = compare_test(TEST_XML_RULE, r, filename); - else - goto failparsing; - - 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_PARSE_XML, xml, err) == 0) - ret = compare_test(TEST_XML_SET, s, filename); - else - goto failparsing; + if (nft_ruleset_parse_file(rs, NFT_PARSE_XML, fp, err) == 0) + ret = compare_test(TEST_XML_RULESET, rs, filename, fp); + else + goto failparsing; - nft_set_free(s); - } - } else if (strcmp(tree->value.opaque, "nftables") == 0) { - rs = nft_ruleset_alloc(); - if (rs != NULL) { - if (nft_ruleset_parse(rs, NFT_PARSE_XML, - xml, err) == 0) - ret = compare_test(TEST_XML_RULESET, rs, - filename); - else - goto failparsing; - - nft_ruleset_free(rs); - } - } + nft_ruleset_free(rs); + fclose(fp); - mxmlDelete(tree); return ret; failparsing: - mxmlDelete(tree); + fclose(fp); printf("parsing %s: ", filename); printf("\033[31mFAILED\e[0m (%s)\n", strerror(errno)); return -1; -#else - printf("Compiled without support for XML.\n"); - return -1; -#endif } int main(int argc, char *argv[]) diff --git a/tests/xmlfiles/01-table.xml b/tests/xmlfiles/01-table.xml index fefcf67..f806334 100644 --- a/tests/xmlfiles/01-table.xml +++ b/tests/xmlfiles/01-table.xml @@ -1 +1 @@ -filterip0
+filterip0
diff --git a/tests/xmlfiles/02-table.xml b/tests/xmlfiles/02-table.xml index d0873ca..ea4e154 100644 --- a/tests/xmlfiles/02-table.xml +++ b/tests/xmlfiles/02-table.xml @@ -1 +1 @@ -natip60
+natip60
diff --git a/tests/xmlfiles/10-chain.xml b/tests/xmlfiles/10-chain.xml index c6aa156..9c00eda 100644 --- a/tests/xmlfiles/10-chain.xml +++ b/tests/xmlfiles/10-chain.xml @@ -1 +1 @@ -test000filter
filterinput0acceptip
+test000filter
filterinput0acceptip
diff --git a/tests/xmlfiles/11-chain.xml b/tests/xmlfiles/11-chain.xml index 3423078..3d9978e 100644 --- a/tests/xmlfiles/11-chain.xml +++ b/tests/xmlfiles/11-chain.xml @@ -1 +1 @@ -test0591filter
filterforward0dropip6
+test0591filter
filterforward0dropip6
diff --git a/tests/xmlfiles/12-chain.xml b/tests/xmlfiles/12-chain.xml index 6afcd00..db0f56c 100644 --- a/tests/xmlfiles/12-chain.xml +++ b/tests/xmlfiles/12-chain.xml @@ -1 +1 @@ -foo100592641549792548796325nat
natpostrouting0acceptip
+foo100592641549792548796325nat
natpostrouting0acceptip
diff --git a/tests/xmlfiles/20-rule-bitwise.xml b/tests/xmlfiles/20-rule-bitwise.xml index 9517db9..8562863 100644 --- a/tests/xmlfiles/20-rule-bitwise.xml +++ b/tests/xmlfiles/20-rule-bitwise.xml @@ -1,2 +1,2 @@ -ipfilter
INPUT10011440x0000000a40x00000000
+ipfilter
INPUT10011440x0000000a40x00000000
diff --git a/tests/xmlfiles/21-rule-byteorder.xml b/tests/xmlfiles/21-rule-byteorder.xml index f8f13b6..fce4ed1 100644 --- a/tests/xmlfiles/21-rule-byteorder.xml +++ b/tests/xmlfiles/21-rule-byteorder.xml @@ -1 +1 @@ -iptest
test100034hton44
+iptest
test100034hton44
diff --git a/tests/xmlfiles/22-rule-cmp.xml b/tests/xmlfiles/22-rule-cmp.xml index 837d0de..ea8ea30 100644 --- a/tests/xmlfiles/22-rule-cmp.xml +++ b/tests/xmlfiles/22-rule-cmp.xml @@ -1,2 +1,2 @@ -ip6filter
test361eq160x000000000x6e6f62000x2e3031640x00393331
+ip6filter
test361eq160x000000000x6e6f62000x2e3031640x00393331
diff --git a/tests/xmlfiles/23-rule-counter.xml b/tests/xmlfiles/23-rule-counter.xml index 77aba7a..82700de 100644 --- a/tests/xmlfiles/23-rule-counter.xml +++ b/tests/xmlfiles/23-rule-counter.xml @@ -1,2 +1,2 @@ -ip6filter
test393177
+ip6filter
test393177
diff --git a/tests/xmlfiles/24-rule-ct.xml b/tests/xmlfiles/24-rule-ct.xml index 814ab52..e8e565d 100644 --- a/tests/xmlfiles/24-rule-ct.xml +++ b/tests/xmlfiles/24-rule-ct.xml @@ -1,2 +1,2 @@ -ipfilter
INPUT1001state0
+ipfilter
INPUT1001state0
diff --git a/tests/xmlfiles/25-rule-exthdr.xml b/tests/xmlfiles/25-rule-exthdr.xml index 6bf139c..9e10a88 100644 --- a/tests/xmlfiles/25-rule-exthdr.xml +++ b/tests/xmlfiles/25-rule-exthdr.xml @@ -1 +1 @@ -ip6filter
INPUT1001mh216
+ip6filter
INPUT1001mh216
diff --git a/tests/xmlfiles/26-rule-immediate.xml b/tests/xmlfiles/26-rule-immediate.xml index 2928142..4d10eb6 100644 --- a/tests/xmlfiles/26-rule-immediate.xml +++ b/tests/xmlfiles/26-rule-immediate.xml @@ -1,2 +1,2 @@ -ipfilter
input320accept
+ipfilter
input320accept
diff --git a/tests/xmlfiles/27-rule-limit.xml b/tests/xmlfiles/27-rule-limit.xml index 6761c9e..a4398e8 100644 --- a/tests/xmlfiles/27-rule-limit.xml +++ b/tests/xmlfiles/27-rule-limit.xml @@ -1 +1 @@ -ipfilter
INPUT100123123321321
+ipfilter
INPUT100123123321321
diff --git a/tests/xmlfiles/28-rule-log.xml b/tests/xmlfiles/28-rule-log.xml index d30e5fb..f24f858 100644 --- a/tests/xmlfiles/28-rule-log.xml +++ b/tests/xmlfiles/28-rule-log.xml @@ -1,2 +1,2 @@ -ip6filter
test96test_chain100
+ip6filter
test96test_chain100
diff --git a/tests/xmlfiles/29-rule-lookup.xml b/tests/xmlfiles/29-rule-lookup.xml index b08ccd3..c77e95c 100644 --- a/tests/xmlfiles/29-rule-lookup.xml +++ b/tests/xmlfiles/29-rule-lookup.xml @@ -1,2 +1,2 @@ -ip6filter
test37set010
+ip6filter
test37set010
diff --git a/tests/xmlfiles/30-rule-match.xml b/tests/xmlfiles/30-rule-match.xml index b4cf72b..4cfe33b 100644 --- a/tests/xmlfiles/30-rule-match.xml +++ b/tests/xmlfiles/30-rule-match.xml @@ -1 +1 @@ -ipfilter
INPUT100state
+ipfilter
INPUT100state
diff --git a/tests/xmlfiles/31-rule-meta.xml b/tests/xmlfiles/31-rule-meta.xml index b38e430..22498e7 100644 --- a/tests/xmlfiles/31-rule-meta.xml +++ b/tests/xmlfiles/31-rule-meta.xml @@ -1,2 +1,2 @@ -ip6filter
test361iifname
+ip6filter
test361iifname
diff --git a/tests/xmlfiles/32-rule-nat6.xml b/tests/xmlfiles/32-rule-nat6.xml index 81566ce..f96b7d8 100644 --- a/tests/xmlfiles/32-rule-nat6.xml +++ b/tests/xmlfiles/32-rule-nat6.xml @@ -1 +1 @@ -ip6nat
OUTPUT100snatip61234
+ip6nat
OUTPUT100snatip61234
diff --git a/tests/xmlfiles/33-rule-nat4.xml b/tests/xmlfiles/33-rule-nat4.xml index 0e495a8..73c5b56 100644 --- a/tests/xmlfiles/33-rule-nat4.xml +++ b/tests/xmlfiles/33-rule-nat4.xml @@ -1 +1 @@ -ipfilter
INPUT100dnatip1234
+ipfilter
INPUT100dnatip1234
diff --git a/tests/xmlfiles/34-rule-payload.xml b/tests/xmlfiles/34-rule-payload.xml index 6c2da6a..833e640 100644 --- a/tests/xmlfiles/34-rule-payload.xml +++ b/tests/xmlfiles/34-rule-payload.xml @@ -1,2 +1,2 @@ -ip6filter
test34122transport
+ip6filter
test34122transport
diff --git a/tests/xmlfiles/35-rule-target.xml b/tests/xmlfiles/35-rule-target.xml index 6925d96..5b46350 100644 --- a/tests/xmlfiles/35-rule-target.xml +++ b/tests/xmlfiles/35-rule-target.xml @@ -1 +1 @@ -ipfilter
INPUT100LOG
+ipfilter
INPUT100LOG
diff --git a/tests/xmlfiles/36-rule-real.xml b/tests/xmlfiles/36-rule-real.xml index 1c953e7..17f1e5f 100644 --- a/tests/xmlfiles/36-rule-real.xml +++ b/tests/xmlfiles/36-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output221128network1eq80x0100a8c00x6400a8c000
+ipfilter
output221128network1eq80x0100a8c00x6400a8c000
diff --git a/tests/xmlfiles/37-rule-real.xml b/tests/xmlfiles/37-rule-real.xml index 3c8ba13..dc45629 100644 --- a/tests/xmlfiles/37-rule-real.xml +++ b/tests/xmlfiles/37-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
INPUT251iifname1eq160x000000000x000000000x650000000x00306874191network1eq10x00000006122transport1eq20x000016001state011440x0000000a40x000000001neq40x0000000000testprefix100
+ipfilter
INPUT251iifname1eq160x000000000x000000000x650000000x00306874191network1eq10x00000006122transport1eq20x000016001state011440x0000000a40x000000001neq40x0000000000testprefix100
diff --git a/tests/xmlfiles/38-rule-real.xml b/tests/xmlfiles/38-rule-real.xml index 6161425..6f41f0e 100644 --- a/tests/xmlfiles/38-rule-real.xml +++ b/tests/xmlfiles/38-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
INPUT301164networkset310191network1eq10x00000006122transport1eq20x0000bb01000accept
+ipfilter
INPUT301164networkset310191network1eq10x00000006122transport1eq20x0000bb01000accept
diff --git a/tests/xmlfiles/39-rule-real.xml b/tests/xmlfiles/39-rule-real.xml index fbf3d61..c823c25 100644 --- a/tests/xmlfiles/39-rule-real.xml +++ b/tests/xmlfiles/39-rule-real.xml @@ -1,2 +1,2 @@ -ip6filter
test311iifname1eq160x000000000x000000000x6f6200000x0030646e1oifname1eq160x000000000x620000000x31646e6f0x0037322e1816network1eq160xc09a002a0x2700cac10x000000000x50010000161network1eq10x00000011122transport1eq20x000035001status01eq40x0000000100dns_drop2000drop
+ip6filter
test311iifname1eq160x000000000x000000000x6f6200000x0030646e1oifname1eq160x000000000x620000000x31646e6f0x0037322e1816network1eq160xc09a002a0x2700cac10x000000000x50010000161network1eq10x00000011122transport1eq20x000035001status01eq40x0000000100dns_drop2000drop
diff --git a/tests/xmlfiles/40-rule-real.xml b/tests/xmlfiles/40-rule-real.xml index 8e1d565..835dcec 100644 --- a/tests/xmlfiles/40-rule-real.xml +++ b/tests/xmlfiles/40-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output21164network1eq40x0100a8c0
+ipfilter
output21164network1eq40x0100a8c0
diff --git a/tests/xmlfiles/41-rule-real.xml b/tests/xmlfiles/41-rule-real.xml index 810267d..001a20e 100644 --- a/tests/xmlfiles/41-rule-real.xml +++ b/tests/xmlfiles/41-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output31164network1gte40x0100a8c01lte40xfa00a8c0
+ipfilter
output31164network1gte40x0100a8c01lte40xfa00a8c0
diff --git a/tests/xmlfiles/42-rule-real.xml b/tests/xmlfiles/42-rule-real.xml index 6aba9eb..6398c48 100644 --- a/tests/xmlfiles/42-rule-real.xml +++ b/tests/xmlfiles/42-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output41164network1eq40x0100a8c000
+ipfilter
output41164network1eq40x0100a8c000
diff --git a/tests/xmlfiles/43-rule-real.xml b/tests/xmlfiles/43-rule-real.xml index 7a2fe6b..38be43e 100644 --- a/tests/xmlfiles/43-rule-real.xml +++ b/tests/xmlfiles/43-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output51164network1eq40x0100a8c0000drop
+ipfilter
output51164network1eq40x0100a8c0000drop
diff --git a/tests/xmlfiles/44-rule-real.xml b/tests/xmlfiles/44-rule-real.xml index 69bdca8..8ab5db9 100644 --- a/tests/xmlfiles/44-rule-real.xml +++ b/tests/xmlfiles/44-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output61164network1eq40x0100a8c000(null)000
+ipfilter
output61164network1eq40x0100a8c000(null)000
diff --git a/tests/xmlfiles/45-rule-real.xml b/tests/xmlfiles/45-rule-real.xml index 36837de..165d581 100644 --- a/tests/xmlfiles/45-rule-real.xml +++ b/tests/xmlfiles/45-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output7191network1eq10x00000006122transport1eq20x0000160000
+ipfilter
output7191network1eq10x00000006122transport1eq20x0000160000
diff --git a/tests/xmlfiles/46-rule-real.xml b/tests/xmlfiles/46-rule-real.xml index 8465d0f..d6f7376 100644 --- a/tests/xmlfiles/46-rule-real.xml +++ b/tests/xmlfiles/46-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output8191network1eq10x00000006104transport1eq40x1600000400
+ipfilter
output8191network1eq10x00000006104transport1eq40x1600000400
diff --git a/tests/xmlfiles/47-rule-real.xml b/tests/xmlfiles/47-rule-real.xml index 39a09a5..815bd61 100644 --- a/tests/xmlfiles/47-rule-real.xml +++ b/tests/xmlfiles/47-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output91128network1eq80x0100a8c00x6400a8c000
+ipfilter
output91128network1eq80x0100a8c00x6400a8c000
diff --git a/tests/xmlfiles/48-rule-real.xml b/tests/xmlfiles/48-rule-real.xml index 89c5088..4b31948 100644 --- a/tests/xmlfiles/48-rule-real.xml +++ b/tests/xmlfiles/48-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output10191network1eq10x00000006108transport1eq80x160000040x00000000
+ipfilter
output10191network1eq10x00000006108transport1eq80x160000040x00000000
diff --git a/tests/xmlfiles/49-rule-real.xml b/tests/xmlfiles/49-rule-real.xml index 0896823..a4db57f 100644 --- a/tests/xmlfiles/49-rule-real.xml +++ b/tests/xmlfiles/49-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output11191network1eq10x00000006108transport1eq80x160000040x00000000
+ipfilter
output11191network1eq10x00000006108transport1eq80x160000040x00000000
diff --git a/tests/xmlfiles/50-rule-real.xml b/tests/xmlfiles/50-rule-real.xml index 1195131..72bddc7 100644 --- a/tests/xmlfiles/50-rule-real.xml +++ b/tests/xmlfiles/50-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output121state011440x0000000a40x000000001neq40x000000005511407
+ipfilter
output121state011440x0000000a40x000000001neq40x000000005511407
diff --git a/tests/xmlfiles/51-rule-real.xml b/tests/xmlfiles/51-rule-real.xml index 4064ffb..72cac29 100644 --- a/tests/xmlfiles/51-rule-real.xml +++ b/tests/xmlfiles/51-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output131direction01eq10x000000005160
+ipfilter
output131direction01eq10x000000005160
diff --git a/tests/xmlfiles/52-rule-real.xml b/tests/xmlfiles/52-rule-real.xml index 6ee7459..ca14eb8 100644 --- a/tests/xmlfiles/52-rule-real.xml +++ b/tests/xmlfiles/52-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output141direction01eq10x000000015011247
+ipfilter
output141direction01eq10x000000015011247
diff --git a/tests/xmlfiles/53-rule-real.xml b/tests/xmlfiles/53-rule-real.xml index ec4ea21..304732b 100644 --- a/tests/xmlfiles/53-rule-real.xml +++ b/tests/xmlfiles/53-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output151status01eq40x0000000100
+ipfilter
output151status01eq40x0000000100
diff --git a/tests/xmlfiles/54-rule-real.xml b/tests/xmlfiles/54-rule-real.xml index c80d43a..5312eca 100644 --- a/tests/xmlfiles/54-rule-real.xml +++ b/tests/xmlfiles/54-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output161mark01eq40x0000006400
+ipfilter
output161mark01eq40x0000006400
diff --git a/tests/xmlfiles/55-rule-real.xml b/tests/xmlfiles/55-rule-real.xml index 47f2e01..757a7a2 100644 --- a/tests/xmlfiles/55-rule-real.xml +++ b/tests/xmlfiles/55-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output171secmark01eq40x000000005511407
+ipfilter
output171secmark01eq40x000000005511407
diff --git a/tests/xmlfiles/56-rule-real.xml b/tests/xmlfiles/56-rule-real.xml index e4965e1..242ddbb 100644 --- a/tests/xmlfiles/56-rule-real.xml +++ b/tests/xmlfiles/56-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output181expiration01eq40x0000001e00
+ipfilter
output181expiration01eq40x0000001e00
diff --git a/tests/xmlfiles/57-rule-real.xml b/tests/xmlfiles/57-rule-real.xml index 985b274..136e5f1 100644 --- a/tests/xmlfiles/57-rule-real.xml +++ b/tests/xmlfiles/57-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output191helper01eq40x0070746600
+ipfilter
output191helper01eq40x0070746600
diff --git a/tests/xmlfiles/58-rule-real.xml b/tests/xmlfiles/58-rule-real.xml index 4b456c1..4474eb2 100644 --- a/tests/xmlfiles/58-rule-real.xml +++ b/tests/xmlfiles/58-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output201len1eq40x000003e800
+ipfilter
output201len1eq40x000003e800
diff --git a/tests/xmlfiles/59-rule-real.xml b/tests/xmlfiles/59-rule-real.xml index 603fe19..4e231a2 100644 --- a/tests/xmlfiles/59-rule-real.xml +++ b/tests/xmlfiles/59-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output211protocol1eq20x000000085511407
+ipfilter
output211protocol1eq20x000000085511407
diff --git a/tests/xmlfiles/60-rule-real.xml b/tests/xmlfiles/60-rule-real.xml index 66a96fe..535ab54 100644 --- a/tests/xmlfiles/60-rule-real.xml +++ b/tests/xmlfiles/60-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output221mark1eq40x000000005511407
+ipfilter
output221mark1eq40x000000005511407
diff --git a/tests/xmlfiles/61-rule-real.xml b/tests/xmlfiles/61-rule-real.xml index 5c1340c..2a5d411 100644 --- a/tests/xmlfiles/61-rule-real.xml +++ b/tests/xmlfiles/61-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output231iif1eq40x0000000100
+ipfilter
output231iif1eq40x0000000100
diff --git a/tests/xmlfiles/62-rule-real.xml b/tests/xmlfiles/62-rule-real.xml index 6a6d381..dfb6e44 100644 --- a/tests/xmlfiles/62-rule-real.xml +++ b/tests/xmlfiles/62-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output241iifname1eq160x000000000x000000000x650000000x0030687400
+ipfilter
output241iifname1eq160x000000000x000000000x650000000x0030687400
diff --git a/tests/xmlfiles/63-rule-real.xml b/tests/xmlfiles/63-rule-real.xml index baa13a7..b144889 100644 --- a/tests/xmlfiles/63-rule-real.xml +++ b/tests/xmlfiles/63-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output251oif1eq40x0000000100
+ipfilter
output251oif1eq40x0000000100
diff --git a/tests/xmlfiles/64-rule-real.xml b/tests/xmlfiles/64-rule-real.xml index 157773f..a83efb9 100644 --- a/tests/xmlfiles/64-rule-real.xml +++ b/tests/xmlfiles/64-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output261oifname1eq160x000000000x000000000x650000000x0030687400
+ipfilter
output261oifname1eq160x000000000x000000000x650000000x0030687400
diff --git a/tests/xmlfiles/65-rule-real.xml b/tests/xmlfiles/65-rule-real.xml index 06c560b..cfec802 100644 --- a/tests/xmlfiles/65-rule-real.xml +++ b/tests/xmlfiles/65-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output271skuid1eq40x000003e800
+ipfilter
output271skuid1eq40x000003e800
diff --git a/tests/xmlfiles/66-rule-real.xml b/tests/xmlfiles/66-rule-real.xml index 9a5b721..57b0d45 100644 --- a/tests/xmlfiles/66-rule-real.xml +++ b/tests/xmlfiles/66-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output281skgid1eq40x000003e800
+ipfilter
output281skgid1eq40x000003e800
diff --git a/tests/xmlfiles/67-rule-real.xml b/tests/xmlfiles/67-rule-real.xml index a3cbc2d..1ee49fc 100644 --- a/tests/xmlfiles/67-rule-real.xml +++ b/tests/xmlfiles/67-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output291secmark1eq40x000000005511407
+ipfilter
output291secmark1eq40x000000005511407
diff --git a/tests/xmlfiles/68-rule-real.xml b/tests/xmlfiles/68-rule-real.xml index 7023e59..70bccd9 100644 --- a/tests/xmlfiles/68-rule-real.xml +++ b/tests/xmlfiles/68-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output32191network1eq10x00000006122transportset01000
+ipfilter
output32191network1eq10x00000006122transportset01000
diff --git a/tests/xmlfiles/69-rule-real.xml b/tests/xmlfiles/69-rule-real.xml index dc2728e..2c61706 100644 --- a/tests/xmlfiles/69-rule-real.xml +++ b/tests/xmlfiles/69-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output331164networkset110
+ipfilter
output331164networkset110
diff --git a/tests/xmlfiles/70-rule-real.xml b/tests/xmlfiles/70-rule-real.xml index 64834d4..0a876e9 100644 --- a/tests/xmlfiles/70-rule-real.xml +++ b/tests/xmlfiles/70-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output34191network1eq10x00000006122transportmap010
+ipfilter
output34191network1eq10x00000006122transportmap010
diff --git a/tests/xmlfiles/71-rule-real.xml b/tests/xmlfiles/71-rule-real.xml index e10437a..143de72 100644 --- a/tests/xmlfiles/71-rule-real.xml +++ b/tests/xmlfiles/71-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output35191network1eq10x00000006122transportmap110
+ipfilter
output35191network1eq10x00000006122transportmap110
diff --git a/tests/xmlfiles/72-rule-real.xml b/tests/xmlfiles/72-rule-real.xml index ccda1fe..fb35523 100644 --- a/tests/xmlfiles/72-rule-real.xml +++ b/tests/xmlfiles/72-rule-real.xml @@ -1,2 +1,2 @@ -ipfilter
output361164networkmap210
+ipfilter
output361164networkmap210
diff --git a/tests/xmlfiles/73-set.xml b/tests/xmlfiles/73-set.xml index 88bf402..37fb2ee 100644 --- a/tests/xmlfiles/73-set.xml +++ b/tests/xmlfiles/73-set.xml @@ -1,2 +1,2 @@ -ipfilter
set000000040x0300a8c0040x0200a8c0040x0100a8c0
+ipfilter
set000000040x0300a8c0040x0200a8c0040x0100a8c0
diff --git a/tests/xmlfiles/74-set.xml b/tests/xmlfiles/74-set.xml index 5b6e8f1..679ee30 100644 --- a/tests/xmlfiles/74-set.xml +++ b/tests/xmlfiles/74-set.xml @@ -1,2 +1,2 @@ -ip6filter
set0000000160xc09a002a0x2700cac10x000000000x700100000160xc09a002a0x2700cac10x000000000x50010000
+ip6filter
set0000000160xc09a002a0x2700cac10x000000000x700100000160xc09a002a0x2700cac10x000000000x50010000
-- cgit v1.2.3 From 5b7ca05aa453f999ec015db671c1665f116e3bb2 Mon Sep 17 00:00:00 2001 From: Arturo Borrero Date: Wed, 15 Jan 2014 12:12:18 +0100 Subject: tests: xml: delete comments When building a XML tree, only one root node can be in place. This is a "feature" added in libmxml 2.7: <<< mxmlLoad... did not error out on XML with multiple root nodes (Bug #403) >>> In libmxml 2.6 the second root node was ignored, not because it was a comment but a bug. Our files had two root nodes, being comments or not. libmxml accept comments, but inside the root node. Signed-off-by: Arturo Borrero Gonzalez Signed-off-by: Pablo Neira Ayuso --- tests/xmlfiles/20-rule-bitwise.xml | 1 - tests/xmlfiles/22-rule-cmp.xml | 1 - tests/xmlfiles/23-rule-counter.xml | 1 - tests/xmlfiles/24-rule-ct.xml | 1 - tests/xmlfiles/26-rule-immediate.xml | 1 - tests/xmlfiles/28-rule-log.xml | 1 - tests/xmlfiles/29-rule-lookup.xml | 1 - tests/xmlfiles/31-rule-meta.xml | 1 - tests/xmlfiles/34-rule-payload.xml | 1 - tests/xmlfiles/36-rule-real.xml | 1 - tests/xmlfiles/37-rule-real.xml | 1 - tests/xmlfiles/38-rule-real.xml | 1 - tests/xmlfiles/39-rule-real.xml | 1 - tests/xmlfiles/40-rule-real.xml | 1 - tests/xmlfiles/41-rule-real.xml | 1 - tests/xmlfiles/42-rule-real.xml | 1 - tests/xmlfiles/43-rule-real.xml | 1 - tests/xmlfiles/44-rule-real.xml | 1 - tests/xmlfiles/45-rule-real.xml | 1 - tests/xmlfiles/46-rule-real.xml | 1 - tests/xmlfiles/47-rule-real.xml | 1 - tests/xmlfiles/48-rule-real.xml | 1 - tests/xmlfiles/49-rule-real.xml | 1 - tests/xmlfiles/50-rule-real.xml | 1 - tests/xmlfiles/51-rule-real.xml | 1 - tests/xmlfiles/52-rule-real.xml | 1 - tests/xmlfiles/53-rule-real.xml | 1 - tests/xmlfiles/54-rule-real.xml | 1 - tests/xmlfiles/55-rule-real.xml | 1 - tests/xmlfiles/56-rule-real.xml | 1 - tests/xmlfiles/57-rule-real.xml | 1 - tests/xmlfiles/58-rule-real.xml | 1 - tests/xmlfiles/59-rule-real.xml | 1 - tests/xmlfiles/60-rule-real.xml | 1 - tests/xmlfiles/61-rule-real.xml | 1 - tests/xmlfiles/62-rule-real.xml | 1 - tests/xmlfiles/63-rule-real.xml | 1 - tests/xmlfiles/64-rule-real.xml | 1 - tests/xmlfiles/65-rule-real.xml | 1 - tests/xmlfiles/66-rule-real.xml | 1 - tests/xmlfiles/67-rule-real.xml | 1 - tests/xmlfiles/68-rule-real.xml | 1 - tests/xmlfiles/69-rule-real.xml | 1 - tests/xmlfiles/70-rule-real.xml | 1 - tests/xmlfiles/71-rule-real.xml | 1 - tests/xmlfiles/72-rule-real.xml | 1 - tests/xmlfiles/73-set.xml | 1 - tests/xmlfiles/74-set.xml | 1 - 48 files changed, 48 deletions(-) (limited to 'tests') diff --git a/tests/xmlfiles/20-rule-bitwise.xml b/tests/xmlfiles/20-rule-bitwise.xml index 8562863..756b22c 100644 --- a/tests/xmlfiles/20-rule-bitwise.xml +++ b/tests/xmlfiles/20-rule-bitwise.xml @@ -1,2 +1 @@ ipfilter
INPUT10011440x0000000a40x00000000
- diff --git a/tests/xmlfiles/22-rule-cmp.xml b/tests/xmlfiles/22-rule-cmp.xml index ea8ea30..308fb9f 100644 --- a/tests/xmlfiles/22-rule-cmp.xml +++ b/tests/xmlfiles/22-rule-cmp.xml @@ -1,2 +1 @@ ip6filter
test361eq160x000000000x6e6f62000x2e3031640x00393331
- diff --git a/tests/xmlfiles/23-rule-counter.xml b/tests/xmlfiles/23-rule-counter.xml index 82700de..6299e84 100644 --- a/tests/xmlfiles/23-rule-counter.xml +++ b/tests/xmlfiles/23-rule-counter.xml @@ -1,2 +1 @@ ip6filter
test393177
- diff --git a/tests/xmlfiles/24-rule-ct.xml b/tests/xmlfiles/24-rule-ct.xml index e8e565d..b3f4ad8 100644 --- a/tests/xmlfiles/24-rule-ct.xml +++ b/tests/xmlfiles/24-rule-ct.xml @@ -1,2 +1 @@ ipfilter
INPUT1001state0
- diff --git a/tests/xmlfiles/26-rule-immediate.xml b/tests/xmlfiles/26-rule-immediate.xml index 4d10eb6..1258c8b 100644 --- a/tests/xmlfiles/26-rule-immediate.xml +++ b/tests/xmlfiles/26-rule-immediate.xml @@ -1,2 +1 @@ ipfilter
input320accept
- diff --git a/tests/xmlfiles/28-rule-log.xml b/tests/xmlfiles/28-rule-log.xml index f24f858..5865bd4 100644 --- a/tests/xmlfiles/28-rule-log.xml +++ b/tests/xmlfiles/28-rule-log.xml @@ -1,2 +1 @@ ip6filter
test96test_chain100
- diff --git a/tests/xmlfiles/29-rule-lookup.xml b/tests/xmlfiles/29-rule-lookup.xml index c77e95c..052b008 100644 --- a/tests/xmlfiles/29-rule-lookup.xml +++ b/tests/xmlfiles/29-rule-lookup.xml @@ -1,2 +1 @@ ip6filter
test37set010
- diff --git a/tests/xmlfiles/31-rule-meta.xml b/tests/xmlfiles/31-rule-meta.xml index 22498e7..a1c9e8c 100644 --- a/tests/xmlfiles/31-rule-meta.xml +++ b/tests/xmlfiles/31-rule-meta.xml @@ -1,2 +1 @@ ip6filter
test361iifname
- diff --git a/tests/xmlfiles/34-rule-payload.xml b/tests/xmlfiles/34-rule-payload.xml index 833e640..a6faca9 100644 --- a/tests/xmlfiles/34-rule-payload.xml +++ b/tests/xmlfiles/34-rule-payload.xml @@ -1,2 +1 @@ ip6filter
test34122transport
- diff --git a/tests/xmlfiles/36-rule-real.xml b/tests/xmlfiles/36-rule-real.xml index 17f1e5f..5c8e075 100644 --- a/tests/xmlfiles/36-rule-real.xml +++ b/tests/xmlfiles/36-rule-real.xml @@ -1,2 +1 @@ ipfilter
output221128network1eq80x0100a8c00x6400a8c000
- diff --git a/tests/xmlfiles/37-rule-real.xml b/tests/xmlfiles/37-rule-real.xml index dc45629..89b06b8 100644 --- a/tests/xmlfiles/37-rule-real.xml +++ b/tests/xmlfiles/37-rule-real.xml @@ -1,2 +1 @@ ipfilter
INPUT251iifname1eq160x000000000x000000000x650000000x00306874191network1eq10x00000006122transport1eq20x000016001state011440x0000000a40x000000001neq40x0000000000testprefix100
- diff --git a/tests/xmlfiles/38-rule-real.xml b/tests/xmlfiles/38-rule-real.xml index 6f41f0e..b8830b0 100644 --- a/tests/xmlfiles/38-rule-real.xml +++ b/tests/xmlfiles/38-rule-real.xml @@ -1,2 +1 @@ ipfilter
INPUT301164networkset310191network1eq10x00000006122transport1eq20x0000bb01000accept
- diff --git a/tests/xmlfiles/39-rule-real.xml b/tests/xmlfiles/39-rule-real.xml index c823c25..a307a2e 100644 --- a/tests/xmlfiles/39-rule-real.xml +++ b/tests/xmlfiles/39-rule-real.xml @@ -1,2 +1 @@ ip6filter
test311iifname1eq160x000000000x000000000x6f6200000x0030646e1oifname1eq160x000000000x620000000x31646e6f0x0037322e1816network1eq160xc09a002a0x2700cac10x000000000x50010000161network1eq10x00000011122transport1eq20x000035001status01eq40x0000000100dns_drop2000drop
- diff --git a/tests/xmlfiles/40-rule-real.xml b/tests/xmlfiles/40-rule-real.xml index 835dcec..0041ebf 100644 --- a/tests/xmlfiles/40-rule-real.xml +++ b/tests/xmlfiles/40-rule-real.xml @@ -1,2 +1 @@ ipfilter
output21164network1eq40x0100a8c0
- diff --git a/tests/xmlfiles/41-rule-real.xml b/tests/xmlfiles/41-rule-real.xml index 001a20e..bd213b0 100644 --- a/tests/xmlfiles/41-rule-real.xml +++ b/tests/xmlfiles/41-rule-real.xml @@ -1,2 +1 @@ ipfilter
output31164network1gte40x0100a8c01lte40xfa00a8c0
- diff --git a/tests/xmlfiles/42-rule-real.xml b/tests/xmlfiles/42-rule-real.xml index 6398c48..b5cc1bd 100644 --- a/tests/xmlfiles/42-rule-real.xml +++ b/tests/xmlfiles/42-rule-real.xml @@ -1,2 +1 @@ ipfilter
output41164network1eq40x0100a8c000
- diff --git a/tests/xmlfiles/43-rule-real.xml b/tests/xmlfiles/43-rule-real.xml index 38be43e..a84f513 100644 --- a/tests/xmlfiles/43-rule-real.xml +++ b/tests/xmlfiles/43-rule-real.xml @@ -1,2 +1 @@ ipfilter
output51164network1eq40x0100a8c0000drop
- diff --git a/tests/xmlfiles/44-rule-real.xml b/tests/xmlfiles/44-rule-real.xml index 8ab5db9..5a99e6f 100644 --- a/tests/xmlfiles/44-rule-real.xml +++ b/tests/xmlfiles/44-rule-real.xml @@ -1,2 +1 @@ ipfilter
output61164network1eq40x0100a8c000(null)000
- diff --git a/tests/xmlfiles/45-rule-real.xml b/tests/xmlfiles/45-rule-real.xml index 165d581..53fa009 100644 --- a/tests/xmlfiles/45-rule-real.xml +++ b/tests/xmlfiles/45-rule-real.xml @@ -1,2 +1 @@ ipfilter
output7191network1eq10x00000006122transport1eq20x0000160000
- diff --git a/tests/xmlfiles/46-rule-real.xml b/tests/xmlfiles/46-rule-real.xml index d6f7376..0ddf6c8 100644 --- a/tests/xmlfiles/46-rule-real.xml +++ b/tests/xmlfiles/46-rule-real.xml @@ -1,2 +1 @@ ipfilter
output8191network1eq10x00000006104transport1eq40x1600000400
- diff --git a/tests/xmlfiles/47-rule-real.xml b/tests/xmlfiles/47-rule-real.xml index 815bd61..fde6d26 100644 --- a/tests/xmlfiles/47-rule-real.xml +++ b/tests/xmlfiles/47-rule-real.xml @@ -1,2 +1 @@ ipfilter
output91128network1eq80x0100a8c00x6400a8c000
- diff --git a/tests/xmlfiles/48-rule-real.xml b/tests/xmlfiles/48-rule-real.xml index 4b31948..547a0f6 100644 --- a/tests/xmlfiles/48-rule-real.xml +++ b/tests/xmlfiles/48-rule-real.xml @@ -1,2 +1 @@ ipfilter
output10191network1eq10x00000006108transport1eq80x160000040x00000000
- diff --git a/tests/xmlfiles/49-rule-real.xml b/tests/xmlfiles/49-rule-real.xml index a4db57f..dc662a3 100644 --- a/tests/xmlfiles/49-rule-real.xml +++ b/tests/xmlfiles/49-rule-real.xml @@ -1,2 +1 @@ ipfilter
output11191network1eq10x00000006108transport1eq80x160000040x00000000
- diff --git a/tests/xmlfiles/50-rule-real.xml b/tests/xmlfiles/50-rule-real.xml index 72bddc7..d15eff4 100644 --- a/tests/xmlfiles/50-rule-real.xml +++ b/tests/xmlfiles/50-rule-real.xml @@ -1,2 +1 @@ ipfilter
output121state011440x0000000a40x000000001neq40x000000005511407
- diff --git a/tests/xmlfiles/51-rule-real.xml b/tests/xmlfiles/51-rule-real.xml index 72cac29..471cd2b 100644 --- a/tests/xmlfiles/51-rule-real.xml +++ b/tests/xmlfiles/51-rule-real.xml @@ -1,2 +1 @@ ipfilter
output131direction01eq10x000000005160
- diff --git a/tests/xmlfiles/52-rule-real.xml b/tests/xmlfiles/52-rule-real.xml index ca14eb8..61a1269 100644 --- a/tests/xmlfiles/52-rule-real.xml +++ b/tests/xmlfiles/52-rule-real.xml @@ -1,2 +1 @@ ipfilter
output141direction01eq10x000000015011247
- diff --git a/tests/xmlfiles/53-rule-real.xml b/tests/xmlfiles/53-rule-real.xml index 304732b..d835639 100644 --- a/tests/xmlfiles/53-rule-real.xml +++ b/tests/xmlfiles/53-rule-real.xml @@ -1,2 +1 @@ ipfilter
output151status01eq40x0000000100
- diff --git a/tests/xmlfiles/54-rule-real.xml b/tests/xmlfiles/54-rule-real.xml index 5312eca..ed27e56 100644 --- a/tests/xmlfiles/54-rule-real.xml +++ b/tests/xmlfiles/54-rule-real.xml @@ -1,2 +1 @@ ipfilter
output161mark01eq40x0000006400
- diff --git a/tests/xmlfiles/55-rule-real.xml b/tests/xmlfiles/55-rule-real.xml index 757a7a2..2d2bf7f 100644 --- a/tests/xmlfiles/55-rule-real.xml +++ b/tests/xmlfiles/55-rule-real.xml @@ -1,2 +1 @@ ipfilter
output171secmark01eq40x000000005511407
- diff --git a/tests/xmlfiles/56-rule-real.xml b/tests/xmlfiles/56-rule-real.xml index 242ddbb..4596689 100644 --- a/tests/xmlfiles/56-rule-real.xml +++ b/tests/xmlfiles/56-rule-real.xml @@ -1,2 +1 @@ ipfilter
output181expiration01eq40x0000001e00
- diff --git a/tests/xmlfiles/57-rule-real.xml b/tests/xmlfiles/57-rule-real.xml index 136e5f1..6a2ad52 100644 --- a/tests/xmlfiles/57-rule-real.xml +++ b/tests/xmlfiles/57-rule-real.xml @@ -1,2 +1 @@ ipfilter
output191helper01eq40x0070746600
- diff --git a/tests/xmlfiles/58-rule-real.xml b/tests/xmlfiles/58-rule-real.xml index 4474eb2..d9bfe3a 100644 --- a/tests/xmlfiles/58-rule-real.xml +++ b/tests/xmlfiles/58-rule-real.xml @@ -1,2 +1 @@ ipfilter
output201len1eq40x000003e800
- diff --git a/tests/xmlfiles/59-rule-real.xml b/tests/xmlfiles/59-rule-real.xml index 4e231a2..6af8aa6 100644 --- a/tests/xmlfiles/59-rule-real.xml +++ b/tests/xmlfiles/59-rule-real.xml @@ -1,2 +1 @@ ipfilter
output211protocol1eq20x000000085511407
- diff --git a/tests/xmlfiles/60-rule-real.xml b/tests/xmlfiles/60-rule-real.xml index 535ab54..24cf057 100644 --- a/tests/xmlfiles/60-rule-real.xml +++ b/tests/xmlfiles/60-rule-real.xml @@ -1,2 +1 @@ ipfilter
output221mark1eq40x000000005511407
- diff --git a/tests/xmlfiles/61-rule-real.xml b/tests/xmlfiles/61-rule-real.xml index 2a5d411..3aaad57 100644 --- a/tests/xmlfiles/61-rule-real.xml +++ b/tests/xmlfiles/61-rule-real.xml @@ -1,2 +1 @@ ipfilter
output231iif1eq40x0000000100
- diff --git a/tests/xmlfiles/62-rule-real.xml b/tests/xmlfiles/62-rule-real.xml index dfb6e44..d7935d1 100644 --- a/tests/xmlfiles/62-rule-real.xml +++ b/tests/xmlfiles/62-rule-real.xml @@ -1,2 +1 @@ ipfilter
output241iifname1eq160x000000000x000000000x650000000x0030687400
- diff --git a/tests/xmlfiles/63-rule-real.xml b/tests/xmlfiles/63-rule-real.xml index b144889..f2a36f4 100644 --- a/tests/xmlfiles/63-rule-real.xml +++ b/tests/xmlfiles/63-rule-real.xml @@ -1,2 +1 @@ ipfilter
output251oif1eq40x0000000100
- diff --git a/tests/xmlfiles/64-rule-real.xml b/tests/xmlfiles/64-rule-real.xml index a83efb9..01a8708 100644 --- a/tests/xmlfiles/64-rule-real.xml +++ b/tests/xmlfiles/64-rule-real.xml @@ -1,2 +1 @@ ipfilter
output261oifname1eq160x000000000x000000000x650000000x0030687400
- diff --git a/tests/xmlfiles/65-rule-real.xml b/tests/xmlfiles/65-rule-real.xml index cfec802..2d59190 100644 --- a/tests/xmlfiles/65-rule-real.xml +++ b/tests/xmlfiles/65-rule-real.xml @@ -1,2 +1 @@ ipfilter
output271skuid1eq40x000003e800
- diff --git a/tests/xmlfiles/66-rule-real.xml b/tests/xmlfiles/66-rule-real.xml index 57b0d45..f9d9c5e 100644 --- a/tests/xmlfiles/66-rule-real.xml +++ b/tests/xmlfiles/66-rule-real.xml @@ -1,2 +1 @@ ipfilter
output281skgid1eq40x000003e800
- diff --git a/tests/xmlfiles/67-rule-real.xml b/tests/xmlfiles/67-rule-real.xml index 1ee49fc..555139c 100644 --- a/tests/xmlfiles/67-rule-real.xml +++ b/tests/xmlfiles/67-rule-real.xml @@ -1,2 +1 @@ ipfilter
output291secmark1eq40x000000005511407
- diff --git a/tests/xmlfiles/68-rule-real.xml b/tests/xmlfiles/68-rule-real.xml index 70bccd9..a0ff9ce 100644 --- a/tests/xmlfiles/68-rule-real.xml +++ b/tests/xmlfiles/68-rule-real.xml @@ -1,2 +1 @@ ipfilter
output32191network1eq10x00000006122transportset01000
- diff --git a/tests/xmlfiles/69-rule-real.xml b/tests/xmlfiles/69-rule-real.xml index 2c61706..e39e2cb 100644 --- a/tests/xmlfiles/69-rule-real.xml +++ b/tests/xmlfiles/69-rule-real.xml @@ -1,2 +1 @@ ipfilter
output331164networkset110
- diff --git a/tests/xmlfiles/70-rule-real.xml b/tests/xmlfiles/70-rule-real.xml index 0a876e9..6edd166 100644 --- a/tests/xmlfiles/70-rule-real.xml +++ b/tests/xmlfiles/70-rule-real.xml @@ -1,2 +1 @@ ipfilter
output34191network1eq10x00000006122transportmap010
- diff --git a/tests/xmlfiles/71-rule-real.xml b/tests/xmlfiles/71-rule-real.xml index 143de72..fba3af9 100644 --- a/tests/xmlfiles/71-rule-real.xml +++ b/tests/xmlfiles/71-rule-real.xml @@ -1,2 +1 @@ ipfilter
output35191network1eq10x00000006122transportmap110
- diff --git a/tests/xmlfiles/72-rule-real.xml b/tests/xmlfiles/72-rule-real.xml index fb35523..aac8b85 100644 --- a/tests/xmlfiles/72-rule-real.xml +++ b/tests/xmlfiles/72-rule-real.xml @@ -1,2 +1 @@ ipfilter
output361164networkmap210
- diff --git a/tests/xmlfiles/73-set.xml b/tests/xmlfiles/73-set.xml index 37fb2ee..6a9323a 100644 --- a/tests/xmlfiles/73-set.xml +++ b/tests/xmlfiles/73-set.xml @@ -1,2 +1 @@ ipfilter
set000000040x0300a8c0040x0200a8c0040x0100a8c0
- diff --git a/tests/xmlfiles/74-set.xml b/tests/xmlfiles/74-set.xml index 679ee30..5f0e7ae 100644 --- a/tests/xmlfiles/74-set.xml +++ b/tests/xmlfiles/74-set.xml @@ -1,2 +1 @@ ip6filter
set0000000160xc09a002a0x2700cac10x000000000x700100000160xc09a002a0x2700cac10x000000000x50010000
- -- cgit v1.2.3 From dec687412e31118a3add7bad8de6ac496f7c1c65 Mon Sep 17 00:00:00 2001 From: Arturo Borrero Date: Sat, 18 Jan 2014 17:56:45 +0100 Subject: data_reg: fix verdict format approach Patrick reports that the XML/JSON formats of the data_reg object are not accuarate. This patch updates these formats, so they are now as follow: * with raw data (this doesn't change). * with a concrete verdict (eg drop accept) and an optional , with destination. In XML: goto output In JSON: "data_reg" : { "type" : "verdict", "verdict" : "goto" "chain" : "output", } The default output format is updated to reflect these changes (minor collateral thing). When parsing set_elems, to know if we need to add the NFT_SET_ELEM_ATTR_CHAIN flag, a basic check for the chain not being NULL is done, instead of evaluating if the result of the parsing was DATA_CHAIN. The DATA_CHAIN symbol is no longer used in the data_reg XML/JSON parsing zone. While at it, I updated the error reporting stuff regarding data_reg/verdict, in order to leave a consistent state in the library. A JSON testfile is updated as well. Reported-by: Patrick McHardy Signed-off-by: Arturo Borrero Gonzalez Signed-off-by: Pablo Neira Ayuso --- tests/jsonfiles/63-set.json | 2 +- tests/nft-parsing-test.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/jsonfiles/63-set.json b/tests/jsonfiles/63-set.json index ea2fe3d..62ccd2f 100644 --- a/tests/jsonfiles/63-set.json +++ b/tests/jsonfiles/63-set.json @@ -1 +1 @@ -{"nftables":[{"set":{"name":"map0","table":"filter","flags":11,"family":"ip","key_type":12,"key_len":2,"data_type":4294967040,"data_len":16,"set_elem":[{"flags":0,"key":{"data_reg":{"type":"value","len":2,"data0":"0x00001700"}},"data":{"data_reg":{"type":"chain","chain":"forward"}}},{"flags":0,"key":{"data_reg":{"type":"value","len":2,"data0":"0x00001600"}},"data":{"data_reg":{"type":"chain","chain":"chain1"}}}]}}]} +{"nftables":[{"set":{"name":"map0","table":"f","flags":11,"family":"ip","key_type":12,"key_len":2,"data_type":4294967040,"data_len":16,"set_elem":[{"flags":0,"key":{"data_reg":{"type":"value","len":2,"data0":"0x00001700"}},"data":{"data_reg":{"type":"verdict","verdict":"goto","chain":"o"}}},{"flags":0,"key":{"data_reg":{"type":"value","len":2,"data0":"0x00001600"}},"data":{"data_reg":{"type":"verdict","verdict":"accept"}}}]}}]} diff --git a/tests/nft-parsing-test.c b/tests/nft-parsing-test.c index b2ad62e..df981ad 100644 --- a/tests/nft-parsing-test.c +++ b/tests/nft-parsing-test.c @@ -121,6 +121,7 @@ failparsing: fclose(fp); printf("parsing %s: ", filename); printf("\033[31mFAILED\e[0m (%s)\n", strerror(errno)); + nft_parse_perror("fail", err); return -1; } -- cgit v1.2.3 From a205a5022259f40aa3ad74017d39e64546d4155c Mon Sep 17 00:00:00 2001 From: Arturo Borrero Date: Sat, 18 Jan 2014 20:01:32 +0100 Subject: ct: use a string with 'dir' attribute This patch implements a string to represent directions in the CT expression: * original (0) * reply (1) Signed-off-by: Arturo Borrero Gonzalez Signed-off-by: Pablo Neira Ayuso --- tests/xmlfiles/24-rule-ct.xml | 2 +- tests/xmlfiles/37-rule-real.xml | 2 +- tests/xmlfiles/39-rule-real.xml | 2 +- tests/xmlfiles/50-rule-real.xml | 2 +- tests/xmlfiles/51-rule-real.xml | 2 +- tests/xmlfiles/52-rule-real.xml | 2 +- tests/xmlfiles/53-rule-real.xml | 2 +- tests/xmlfiles/54-rule-real.xml | 2 +- tests/xmlfiles/55-rule-real.xml | 2 +- tests/xmlfiles/56-rule-real.xml | 2 +- tests/xmlfiles/57-rule-real.xml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/xmlfiles/24-rule-ct.xml b/tests/xmlfiles/24-rule-ct.xml index b3f4ad8..1939e43 100644 --- a/tests/xmlfiles/24-rule-ct.xml +++ b/tests/xmlfiles/24-rule-ct.xml @@ -1 +1 @@ -ipfilter
INPUT1001state0
+ipfilter
INPUT1001stateoriginal
diff --git a/tests/xmlfiles/37-rule-real.xml b/tests/xmlfiles/37-rule-real.xml index 89b06b8..d9293f6 100644 --- a/tests/xmlfiles/37-rule-real.xml +++ b/tests/xmlfiles/37-rule-real.xml @@ -1 +1 @@ -ipfilter
INPUT251iifname1eq160x000000000x000000000x650000000x00306874191network1eq10x00000006122transport1eq20x000016001state011440x0000000a40x000000001neq40x0000000000testprefix100
+ipfilter
INPUT251iifname1eq160x000000000x000000000x650000000x00306874191network1eq10x00000006122transport1eq20x000016001stateoriginal11440x0000000a40x000000001neq40x0000000000testprefix100
diff --git a/tests/xmlfiles/39-rule-real.xml b/tests/xmlfiles/39-rule-real.xml index a307a2e..9a69a61 100644 --- a/tests/xmlfiles/39-rule-real.xml +++ b/tests/xmlfiles/39-rule-real.xml @@ -1 +1 @@ -ip6filter
test311iifname1eq160x000000000x000000000x6f6200000x0030646e1oifname1eq160x000000000x620000000x31646e6f0x0037322e1816network1eq160xc09a002a0x2700cac10x000000000x50010000161network1eq10x00000011122transport1eq20x000035001status01eq40x0000000100dns_drop2000drop
+ip6filter
test311iifname1eq160x000000000x000000000x6f6200000x0030646e1oifname1eq160x000000000x620000000x31646e6f0x0037322e1816network1eq160xc09a002a0x2700cac10x000000000x50010000161network1eq10x00000011122transport1eq20x000035001statusoriginal1eq40x0000000100dns_drop2000drop
diff --git a/tests/xmlfiles/50-rule-real.xml b/tests/xmlfiles/50-rule-real.xml index d15eff4..c52e00e 100644 --- a/tests/xmlfiles/50-rule-real.xml +++ b/tests/xmlfiles/50-rule-real.xml @@ -1 +1 @@ -ipfilter
output121state011440x0000000a40x000000001neq40x000000005511407
+ipfilter
output121stateoriginal11440x0000000a40x000000001neq40x000000005511407
diff --git a/tests/xmlfiles/51-rule-real.xml b/tests/xmlfiles/51-rule-real.xml index 471cd2b..93d6632 100644 --- a/tests/xmlfiles/51-rule-real.xml +++ b/tests/xmlfiles/51-rule-real.xml @@ -1 +1 @@ -ipfilter
output131direction01eq10x000000005160
+ipfilter
output131directionoriginal1eq10x000000005160
diff --git a/tests/xmlfiles/52-rule-real.xml b/tests/xmlfiles/52-rule-real.xml index 61a1269..c6ca9ec 100644 --- a/tests/xmlfiles/52-rule-real.xml +++ b/tests/xmlfiles/52-rule-real.xml @@ -1 +1 @@ -ipfilter
output141direction01eq10x000000015011247
+ipfilter
output141directionoriginal1eq10x000000015011247
diff --git a/tests/xmlfiles/53-rule-real.xml b/tests/xmlfiles/53-rule-real.xml index d835639..8cb0783 100644 --- a/tests/xmlfiles/53-rule-real.xml +++ b/tests/xmlfiles/53-rule-real.xml @@ -1 +1 @@ -ipfilter
output151status01eq40x0000000100
+ipfilter
output151statusoriginal1eq40x0000000100
diff --git a/tests/xmlfiles/54-rule-real.xml b/tests/xmlfiles/54-rule-real.xml index ed27e56..0c0dc9a 100644 --- a/tests/xmlfiles/54-rule-real.xml +++ b/tests/xmlfiles/54-rule-real.xml @@ -1 +1 @@ -ipfilter
output161mark01eq40x0000006400
+ipfilter
output161markoriginal1eq40x0000006400
diff --git a/tests/xmlfiles/55-rule-real.xml b/tests/xmlfiles/55-rule-real.xml index 2d2bf7f..fca8c99 100644 --- a/tests/xmlfiles/55-rule-real.xml +++ b/tests/xmlfiles/55-rule-real.xml @@ -1 +1 @@ -ipfilter
output171secmark01eq40x000000005511407
+ipfilter
output171secmarkoriginal1eq40x000000005511407
diff --git a/tests/xmlfiles/56-rule-real.xml b/tests/xmlfiles/56-rule-real.xml index 4596689..1ea7f0c 100644 --- a/tests/xmlfiles/56-rule-real.xml +++ b/tests/xmlfiles/56-rule-real.xml @@ -1 +1 @@ -ipfilter
output181expiration01eq40x0000001e00
+ipfilter
output181expirationoriginal1eq40x0000001e00
diff --git a/tests/xmlfiles/57-rule-real.xml b/tests/xmlfiles/57-rule-real.xml index 6a2ad52..6036973 100644 --- a/tests/xmlfiles/57-rule-real.xml +++ b/tests/xmlfiles/57-rule-real.xml @@ -1 +1 @@ -ipfilter
output191helper01eq40x0070746600
+ipfilter
output191helperoriginal1eq40x0070746600
-- cgit v1.2.3 From 59e949294f4688bafe44b7def2972987224520c8 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 20 Jan 2014 10:26:57 +0100 Subject: rename library to libnftnl We plan to use this library name for the higher layer library. Signed-off-by: Pablo Neira Ayuso --- tests/Makefile.am | 42 ++++++++++++++++++++--------------------- tests/nft-chain-test.c | 2 +- tests/nft-expr_bitwise-test.c | 4 ++-- tests/nft-expr_byteorder-test.c | 4 ++-- tests/nft-expr_cmp-test.c | 4 ++-- tests/nft-expr_counter-test.c | 4 ++-- tests/nft-expr_ct-test.c | 4 ++-- tests/nft-expr_exthdr-test.c | 4 ++-- tests/nft-expr_immediate-test.c | 4 ++-- tests/nft-expr_limit-test.c | 4 ++-- tests/nft-expr_log-test.c | 4 ++-- tests/nft-expr_lookup-test.c | 4 ++-- tests/nft-expr_match-test.c | 4 ++-- tests/nft-expr_meta-test.c | 4 ++-- tests/nft-expr_nat-test.c | 4 ++-- tests/nft-expr_payload-test.c | 4 ++-- tests/nft-expr_reject-test.c | 4 ++-- tests/nft-expr_target-test.c | 4 ++-- tests/nft-parsing-test.c | 10 +++++----- tests/nft-rule-test.c | 2 +- tests/nft-set-test.c | 2 +- tests/nft-table-test.c | 2 +- 22 files changed, 62 insertions(+), 62 deletions(-) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 362eeac..e82ebf4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -23,64 +23,64 @@ check_PROGRAMS = nft-parsing-test \ nft-expr_target-test nft_parsing_test_SOURCES = nft-parsing-test.c -nft_parsing_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} ${LIBXML_LIBS} ${LIBJSON_LIBS} +nft_parsing_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} ${LIBXML_LIBS} ${LIBJSON_LIBS} nft_table_test_SOURCES = nft-table-test.c -nft_table_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_table_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_chain_test_SOURCES = nft-chain-test.c -nft_chain_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_chain_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_rule_test_SOURCES = nft-rule-test.c -nft_rule_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_rule_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_set_test_SOURCES = nft-set-test.c -nft_set_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_set_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_expr_bitwise_test_SOURCES = nft-expr_bitwise-test.c -nft_expr_bitwise_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_expr_bitwise_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_expr_byteorder_test_SOURCES = nft-expr_byteorder-test.c -nft_expr_byteorder_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_expr_byteorder_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_expr_cmp_test_SOURCES = nft-expr_cmp-test.c -nft_expr_cmp_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_expr_cmp_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_expr_counter_test_SOURCES = nft-expr_counter-test.c -nft_expr_counter_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_expr_counter_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_expr_exthdr_test_SOURCES = nft-expr_exthdr-test.c -nft_expr_exthdr_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_expr_exthdr_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_expr_ct_test_SOURCES = nft-expr_ct-test.c -nft_expr_ct_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_expr_ct_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_expr_immediate_test_SOURCES = nft-expr_counter-test.c -nft_expr_immediate_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_expr_immediate_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_expr_limit_test_SOURCES = nft-expr_limit-test.c -nft_expr_limit_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_expr_limit_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_expr_lookup_test_SOURCES = nft-expr_limit-test.c -nft_expr_lookup_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_expr_lookup_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_expr_log_test_SOURCES = nft-expr_log-test.c -nft_expr_log_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_expr_log_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_expr_match_test_SOURCES = nft-expr_match-test.c -nft_expr_match_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_expr_match_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_expr_meta_test_SOURCES = nft-expr_meta-test.c -nft_expr_meta_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_expr_meta_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_expr_nat_test_SOURCES = nft-expr_nat-test.c -nft_expr_nat_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_expr_nat_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_expr_payload_test_SOURCES = nft-expr_payload-test.c -nft_expr_payload_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_expr_payload_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_expr_reject_test_SOURCES = nft-expr_reject-test.c -nft_expr_reject_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_expr_reject_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_expr_target_test_SOURCES = nft-expr_target-test.c -nft_expr_target_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_expr_target_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} diff --git a/tests/nft-chain-test.c b/tests/nft-chain-test.c index 80c1981..125562a 100644 --- a/tests/nft-chain-test.c +++ b/tests/nft-chain-test.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include static int test_ok = 1; diff --git a/tests/nft-expr_bitwise-test.c b/tests/nft-expr_bitwise-test.c index d755c75..0fe5329 100644 --- a/tests/nft-expr_bitwise-test.c +++ b/tests/nft-expr_bitwise-test.c @@ -16,8 +16,8 @@ #include #include #include -#include -#include +#include +#include static int test_ok = 1; diff --git a/tests/nft-expr_byteorder-test.c b/tests/nft-expr_byteorder-test.c index 5e50da1..456d508 100644 --- a/tests/nft-expr_byteorder-test.c +++ b/tests/nft-expr_byteorder-test.c @@ -16,8 +16,8 @@ #include #include #include -#include -#include +#include +#include static int test_ok = 1; diff --git a/tests/nft-expr_cmp-test.c b/tests/nft-expr_cmp-test.c index f435bbe..f411770 100644 --- a/tests/nft-expr_cmp-test.c +++ b/tests/nft-expr_cmp-test.c @@ -16,8 +16,8 @@ #include #include #include -#include -#include +#include +#include static int test_ok = 1; diff --git a/tests/nft-expr_counter-test.c b/tests/nft-expr_counter-test.c index 70cac2b..e27d20a 100644 --- a/tests/nft-expr_counter-test.c +++ b/tests/nft-expr_counter-test.c @@ -16,8 +16,8 @@ #include #include #include -#include -#include +#include +#include static int test_ok = 1; diff --git a/tests/nft-expr_ct-test.c b/tests/nft-expr_ct-test.c index f8bd13d..341d9e6 100644 --- a/tests/nft-expr_ct-test.c +++ b/tests/nft-expr_ct-test.c @@ -16,8 +16,8 @@ #include #include -#include -#include +#include +#include static int test_ok = 1; static void print_err(const char *msg) diff --git a/tests/nft-expr_exthdr-test.c b/tests/nft-expr_exthdr-test.c index 64c364c..a712903 100644 --- a/tests/nft-expr_exthdr-test.c +++ b/tests/nft-expr_exthdr-test.c @@ -16,8 +16,8 @@ #include #include #include -#include -#include +#include +#include static int test_ok = 1; diff --git a/tests/nft-expr_immediate-test.c b/tests/nft-expr_immediate-test.c index 91e8a3d..c45cefa 100644 --- a/tests/nft-expr_immediate-test.c +++ b/tests/nft-expr_immediate-test.c @@ -16,8 +16,8 @@ #include #include -#include -#include +#include +#include static int test_ok = 1; diff --git a/tests/nft-expr_limit-test.c b/tests/nft-expr_limit-test.c index c5730cc..38c3e5b 100644 --- a/tests/nft-expr_limit-test.c +++ b/tests/nft-expr_limit-test.c @@ -17,8 +17,8 @@ #include #include -#include -#include +#include +#include static int test_ok = 1; diff --git a/tests/nft-expr_log-test.c b/tests/nft-expr_log-test.c index 7590548..7e257ab 100644 --- a/tests/nft-expr_log-test.c +++ b/tests/nft-expr_log-test.c @@ -16,8 +16,8 @@ #include #include -#include -#include +#include +#include static int test_ok = 1; diff --git a/tests/nft-expr_lookup-test.c b/tests/nft-expr_lookup-test.c index 760e69c..38a2a46 100644 --- a/tests/nft-expr_lookup-test.c +++ b/tests/nft-expr_lookup-test.c @@ -16,8 +16,8 @@ #include #include #include -#include -#include +#include +#include static int test_ok = 1; diff --git a/tests/nft-expr_match-test.c b/tests/nft-expr_match-test.c index dcb9f74..96b063a 100644 --- a/tests/nft-expr_match-test.c +++ b/tests/nft-expr_match-test.c @@ -18,8 +18,8 @@ #include #include #include -#include -#include +#include +#include static int test_ok = 1; diff --git a/tests/nft-expr_meta-test.c b/tests/nft-expr_meta-test.c index 879f2e7..9196f9c 100644 --- a/tests/nft-expr_meta-test.c +++ b/tests/nft-expr_meta-test.c @@ -16,8 +16,8 @@ #include #include -#include -#include +#include +#include static int test_ok = 1; diff --git a/tests/nft-expr_nat-test.c b/tests/nft-expr_nat-test.c index 35b6479..64966b2 100644 --- a/tests/nft-expr_nat-test.c +++ b/tests/nft-expr_nat-test.c @@ -17,8 +17,8 @@ #include #include #include -#include -#include +#include +#include static int test_ok = 1; diff --git a/tests/nft-expr_payload-test.c b/tests/nft-expr_payload-test.c index d6f4e05..3ce59f9 100644 --- a/tests/nft-expr_payload-test.c +++ b/tests/nft-expr_payload-test.c @@ -17,8 +17,8 @@ #include #include #include -#include -#include +#include +#include static int test_ok = 1; diff --git a/tests/nft-expr_reject-test.c b/tests/nft-expr_reject-test.c index 23784e9..0678081 100644 --- a/tests/nft-expr_reject-test.c +++ b/tests/nft-expr_reject-test.c @@ -17,8 +17,8 @@ #include #include #include -#include -#include +#include +#include static int test_ok = 1; diff --git a/tests/nft-expr_target-test.c b/tests/nft-expr_target-test.c index 7bde348..9387779 100644 --- a/tests/nft-expr_target-test.c +++ b/tests/nft-expr_target-test.c @@ -18,8 +18,8 @@ #include #include #include -#include -#include +#include +#include static int test_ok = 1; diff --git a/tests/nft-parsing-test.c b/tests/nft-parsing-test.c index df981ad..1786cb6 100644 --- a/tests/nft-parsing-test.c +++ b/tests/nft-parsing-test.c @@ -6,11 +6,11 @@ #include #include /*nlmsghdr*/ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include enum { TEST_XML_RULESET, diff --git a/tests/nft-rule-test.c b/tests/nft-rule-test.c index 5b99003..80338d0 100644 --- a/tests/nft-rule-test.c +++ b/tests/nft-rule-test.c @@ -14,7 +14,7 @@ #include #include -#include +#include static int test_ok = 1; diff --git a/tests/nft-set-test.c b/tests/nft-set-test.c index 5930af3..141dfd3 100644 --- a/tests/nft-set-test.c +++ b/tests/nft-set-test.c @@ -14,7 +14,7 @@ #include #include -#include +#include static int test_ok = 1; diff --git a/tests/nft-table-test.c b/tests/nft-table-test.c index fd85f42..051163b 100644 --- a/tests/nft-table-test.c +++ b/tests/nft-table-test.c @@ -14,7 +14,7 @@ #include #include -#include +#include static int test_ok = 1; -- cgit v1.2.3