netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [libnftables PATCH 1/4] Add functions for to export tables to JSON format
@ 2013-06-06 13:17 Alvaro Neira
  2013-06-06 13:17 ` [libnftables PATCH 2/4] Add implementation for to proof the JSON export function Alvaro Neira
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Alvaro Neira @ 2013-06-06 13:17 UTC (permalink / raw)
  To: netfilter-devel; +Cc: julien


---
 0 files changed

diff --git a/src/table.c b/src/table.c
index a868da4..57ea586 100644
--- a/src/table.c
+++ b/src/table.c
@@ -300,6 +300,22 @@ int nft_table_parse(struct nft_table *t, enum nft_table_parse_type type,
 }
 EXPORT_SYMBOL(nft_table_parse);
 
+static int nft_table_snprintf_json(char *buf, size_t size, struct nft_table *t)
+{
+	return snprintf(buf, size,
+			"{\"table\" : {"
+			"\"name\" : \"%s\","
+			"\"version\" : \"%d\","
+			"\"properties\" : {"
+				"\"family\" : %u,"
+				"\"table_flags\" : %d"
+				"}"
+			"}"
+			"}" ,
+			t->name, NFT_TABLE_JSON_VERSION,
+			t->family, t->table_flags);
+}
+
 static int nft_table_snprintf_xml(char *buf, size_t size, struct nft_table *t)
 {
 	return snprintf(buf, size,
@@ -325,6 +341,8 @@ int nft_table_snprintf(char *buf, size_t size, struct nft_table *t,
 	switch(type) {
 	case NFT_TABLE_O_XML:
 		return nft_table_snprintf_xml(buf, size, t);
+	case NFT_TABLE_O_JSON:
+		return nft_table_snprintf_json(buf, size, t);
 	case NFT_TABLE_O_DEFAULT:
 		return nft_table_snprintf_default(buf, size, t);
 	default:


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [libnftables PATCH 2/4] Add implementation for to proof the JSON export function
  2013-06-06 13:17 [libnftables PATCH 1/4] Add functions for to export tables to JSON format Alvaro Neira
@ 2013-06-06 13:17 ` Alvaro Neira
  2013-06-06 13:17 ` [libnftables PATCH 3/4] Add JSON Constant for to use the Json " Alvaro Neira
  2013-06-06 13:17 ` [libnftables PATCH 4/4] Add a constant for to put the JSON Version Alvaro Neira
  2 siblings, 0 replies; 5+ messages in thread
From: Alvaro Neira @ 2013-06-06 13:17 UTC (permalink / raw)
  To: netfilter-devel; +Cc: julien


---
 examples/nft-table-get.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/examples/nft-table-get.c b/examples/nft-table-get.c
index b113636..0d7746c 100644
--- a/examples/nft-table-get.c
+++ b/examples/nft-table-get.c
@@ -59,6 +59,10 @@ int main(int argc, char *argv[])
 		type = NFT_TABLE_O_XML;
 		argv[argc-1] = NULL;
 		argc--;
+	}else if (strcmp(argv[argc-1], "json") == 0) {
+		type = NFT_TABLE_O_JSON;
+		argv[argc-1] = NULL;
+		argc--;
 	} else if (strcmp(argv[argc - 1], "default") == 0) {
 		argc--;
 	}


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [libnftables PATCH 3/4] Add JSON Constant for to use the Json export function
  2013-06-06 13:17 [libnftables PATCH 1/4] Add functions for to export tables to JSON format Alvaro Neira
  2013-06-06 13:17 ` [libnftables PATCH 2/4] Add implementation for to proof the JSON export function Alvaro Neira
@ 2013-06-06 13:17 ` Alvaro Neira
  2013-06-06 16:25   ` Pablo Neira Ayuso
  2013-06-06 13:17 ` [libnftables PATCH 4/4] Add a constant for to put the JSON Version Alvaro Neira
  2 siblings, 1 reply; 5+ messages in thread
From: Alvaro Neira @ 2013-06-06 13:17 UTC (permalink / raw)
  To: netfilter-devel; +Cc: julien


---
 0 files changed

diff --git a/include/libnftables/table.h b/include/libnftables/table.h
index 658230c..19f322c 100644
--- a/include/libnftables/table.h
+++ b/include/libnftables/table.h
@@ -31,6 +31,7 @@ void nft_table_nlmsg_build_payload(struct nlmsghdr *nlh, const struct nft_table
 enum {
 	NFT_TABLE_O_DEFAULT	= 0,
 	NFT_TABLE_O_XML,
+	NFT_TABLE_O_JSON,
 };
 
 enum nft_table_parse_type {


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [libnftables PATCH 4/4] Add a constant for to put the JSON Version
  2013-06-06 13:17 [libnftables PATCH 1/4] Add functions for to export tables to JSON format Alvaro Neira
  2013-06-06 13:17 ` [libnftables PATCH 2/4] Add implementation for to proof the JSON export function Alvaro Neira
  2013-06-06 13:17 ` [libnftables PATCH 3/4] Add JSON Constant for to use the Json " Alvaro Neira
@ 2013-06-06 13:17 ` Alvaro Neira
  2 siblings, 0 replies; 5+ messages in thread
From: Alvaro Neira @ 2013-06-06 13:17 UTC (permalink / raw)
  To: netfilter-devel; +Cc: julien


---
 0 files changed

diff --git a/src/internal.h b/src/internal.h
index 3ad5e89..0c5de21 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -20,6 +20,7 @@
 #define NFT_TABLE_XML_VERSION 0
 #define NFT_CHAIN_XML_VERSION 0
 #define NFT_RULE_XML_VERSION 0
+#define NFT_TABLE_JSON_VERSION 0
 
 struct expr_ops;
 


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [libnftables PATCH 3/4] Add JSON Constant for to use the Json export function
  2013-06-06 13:17 ` [libnftables PATCH 3/4] Add JSON Constant for to use the Json " Alvaro Neira
@ 2013-06-06 16:25   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 5+ messages in thread
From: Pablo Neira Ayuso @ 2013-06-06 16:25 UTC (permalink / raw)
  To: Alvaro Neira; +Cc: netfilter-devel, julien

Hi Alvaro,

On Thu, Jun 06, 2013 at 03:17:25PM +0200, Alvaro Neira wrote:
> 
> ---
>  0 files changed
> 
> diff --git a/include/libnftables/table.h b/include/libnftables/table.h
> index 658230c..19f322c 100644
> --- a/include/libnftables/table.h
> +++ b/include/libnftables/table.h
> @@ -31,6 +31,7 @@ void nft_table_nlmsg_build_payload(struct nlmsghdr *nlh, const struct nft_table
>  enum {
>  	NFT_TABLE_O_DEFAULT	= 0,
>  	NFT_TABLE_O_XML,
> +	NFT_TABLE_O_JSON,

you have to collapse patch 1/4, 3/4 and 4/4. You cannot add the
definition of this constant in a follow-up patch. Note that the
repository has to remain consistent between patches, and after patch
1/4, if I compile libnftables, it would break.

Please, fix it and resubmit. Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-06-06 16:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-06 13:17 [libnftables PATCH 1/4] Add functions for to export tables to JSON format Alvaro Neira
2013-06-06 13:17 ` [libnftables PATCH 2/4] Add implementation for to proof the JSON export function Alvaro Neira
2013-06-06 13:17 ` [libnftables PATCH 3/4] Add JSON Constant for to use the Json " Alvaro Neira
2013-06-06 16:25   ` Pablo Neira Ayuso
2013-06-06 13:17 ` [libnftables PATCH 4/4] Add a constant for to put the JSON Version Alvaro Neira

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).