From 5a2a1e0447bc9dc3defe6dca75e6a54312bbb045 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sun, 9 Nov 2014 19:26:48 +0100 Subject: src: consolidate XML/JSON exportation Add new buffer class to consolidate the existing code to export objects in XML/JSON and use it. We save ~700 LOC with this change. The rule and set objects are not yet consolidated. It seems this would require some specific glue code per representation type since lists are arranged differently. This also consolidates the tag names, so we make sure the same are used from XML and JSON by placing them in include/buffer.h. Signed-off-by: Pablo Neira Ayuso --- tests/jsonfiles/11-chain.json | 2 +- tests/jsonfiles/12-chain.json | 2 +- tests/jsonfiles/13-chain.json | 2 +- tests/xmlfiles/10-chain.xml | 2 +- tests/xmlfiles/11-chain.xml | 2 +- tests/xmlfiles/12-chain.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/jsonfiles/11-chain.json b/tests/jsonfiles/11-chain.json index 2610b79..731ed1f 100644 --- a/tests/jsonfiles/11-chain.json +++ b/tests/jsonfiles/11-chain.json @@ -1 +1 @@ -{"nftables":[{"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,"table":"filter","family":"ip","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 3d15982..2d344eb 100644 --- a/tests/jsonfiles/12-chain.json +++ b/tests/jsonfiles/12-chain.json @@ -1 +1 @@ -{"nftables":[{"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,"table":"filter","family":"ip","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 e3a17f0..5a6ddd1 100644 --- a/tests/jsonfiles/13-chain.json +++ b/tests/jsonfiles/13-chain.json @@ -1 +1 @@ -{"nftables":[{"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,"table":"filter","family":"ip","use":0,"type":"filter","hooknum":"output","prio":0,"policy":"accept"}}]} diff --git a/tests/xmlfiles/10-chain.xml b/tests/xmlfiles/10-chain.xml index 9c00eda..6ac54ab 100644 --- a/tests/xmlfiles/10-chain.xml +++ b/tests/xmlfiles/10-chain.xml @@ -1 +1 @@ -test000filter
filterinput0acceptip
+test000filter
ipfilterinput0accept
diff --git a/tests/xmlfiles/11-chain.xml b/tests/xmlfiles/11-chain.xml index 3d9978e..34d99dd 100644 --- a/tests/xmlfiles/11-chain.xml +++ b/tests/xmlfiles/11-chain.xml @@ -1 +1 @@ -test0591filter
filterforward0dropip6
+test0591filter
ip6filterforward0drop
diff --git a/tests/xmlfiles/12-chain.xml b/tests/xmlfiles/12-chain.xml index db0f56c..f53f252 100644 --- a/tests/xmlfiles/12-chain.xml +++ b/tests/xmlfiles/12-chain.xml @@ -1 +1 @@ -foo100592641549792548796325nat
natpostrouting0acceptip
+foo100592641549792548796325nat
ipnatpostrouting0accept
-- cgit v1.2.3