Patchwork [libnftables,07/13] src: json: delete unneeded JSON prefixes

login
register
mail settings
Submitter Alvaro Neira
Date Aug. 9, 2013, 11:13 a.m.
Message ID <20130809111314.29819.36371.stgit@Ph0enix>
Download mbox | patch
Permalink /patch/265997/
State Accepted
Headers show

Comments

Alvaro Neira - Aug. 9, 2013, 11:13 a.m.
From: Álvaro Neira Ayuso <alvaroneay@gmail.com>

This patch changes some JSON nodes with prefixes like XML nodes

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
---
 src/rule.c                    |    2 +-
 src/set_elem.c                |    6 +++---
 src/table.c                   |    4 ++--
 tests/jsonfiles/01-table.json |    2 +-
 tests/jsonfiles/02-table.json |    2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)


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

Patch

diff --git a/src/rule.c b/src/rule.c
index 41534bd..8a86f54 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -629,7 +629,7 @@  static int nft_rule_snprintf_json(char *buf, size_t size, struct nft_rule *r,
 				(unsigned long long)r->handle);
 	SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
-	ret = snprintf(buf+offset, len, "\"rule_flags\" : %u, ",
+	ret = snprintf(buf+offset, len, "\"flags\" : %u, ",
 					r->rule_flags);
 	SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
diff --git a/src/set_elem.c b/src/set_elem.c
index 73c100f..c3ac1da 100644
--- a/src/set_elem.c
+++ b/src/set_elem.c
@@ -469,10 +469,10 @@  static int nft_set_elem_snprintf_json(char *buf, size_t size,
 {
 	int ret, len = size, offset = 0, type = -1;
 
-	ret = snprintf(buf, size, "\"set_elem_flags\": %u", e->set_elem_flags);
+	ret = snprintf(buf, size, "\"flags\": %u", e->set_elem_flags);
 	SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
-	ret = snprintf(buf+offset, size, ",\"set_elem_key\": {");
+	ret = snprintf(buf+offset, size, ",\"key\": {");
 	SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
 	ret = nft_data_reg_snprintf(buf+offset, len, &e->key,
@@ -490,7 +490,7 @@  static int nft_set_elem_snprintf_json(char *buf, size_t size,
 		type = DATA_VERDICT;
 
 	if (type != -1) {
-		ret = snprintf(buf+offset, size, ",\"set_elem_data\": {");
+		ret = snprintf(buf+offset, size, ",\"data\": {");
 		SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
 		ret = nft_data_reg_snprintf(buf+offset, len, &e->data,
diff --git a/src/table.c b/src/table.c
index 85993eb..18d9077 100644
--- a/src/table.c
+++ b/src/table.c
@@ -295,7 +295,7 @@  static int nft_table_json_parse(struct nft_table *t, char *json)
 
 	nft_table_attr_set_u32(t, NFT_TABLE_ATTR_FAMILY, family);
 
-	if (nft_jansson_value_parse_val(root, "table_flags",
+	if (nft_jansson_value_parse_val(root, "flags",
 					NFT_TYPE_U32, &table_flag) == -1)
 		goto err;
 
@@ -340,7 +340,7 @@  static int nft_table_snprintf_json(char *buf, size_t size, struct nft_table *t)
 			"{\"table\" : {"
 			"\"name\" : \"%s\","
 			"\"family\" : \"%s\","
-			"\"table_flags\" : %d"
+			"\"flags\" : %d"
 			"}"
 			"}" ,
 			t->name, nft_family2str(t->family), t->table_flags);
diff --git a/tests/jsonfiles/01-table.json b/tests/jsonfiles/01-table.json
index a5ba38b..b4fc91b 100644
--- a/tests/jsonfiles/01-table.json
+++ b/tests/jsonfiles/01-table.json
@@ -1 +1 @@ 
-{"table" : {"name" : "filter","family" : "ip","table_flags" : 0}}
+{"table" : {"name" : "filter","family" : "ip","flags" : 0}}
diff --git a/tests/jsonfiles/02-table.json b/tests/jsonfiles/02-table.json
index f1171a1..01eff74 100644
--- a/tests/jsonfiles/02-table.json
+++ b/tests/jsonfiles/02-table.json
@@ -1 +1 @@ 
-{"table" : {"name" : "filter2","family" : "ip6","table_flags" : 0}}
+{"table" : {"name" : "filter2","family" : "ip6","flags" : 0}}