* [libnftables PATCH 0/2] Series short description @ 2013-06-08 13:35 Alvaro Neira 2013-06-08 13:36 ` [libnftables PATCH 1/2] Add function for exporting chain to JSON Format Alvaro Neira 2013-06-08 13:36 ` [libnftables PATCH 2/2] Implementation for to test the function for exporting chains to JSON format Alvaro Neira 0 siblings, 2 replies; 6+ messages in thread From: Alvaro Neira @ 2013-06-08 13:35 UTC (permalink / raw) To: netfilter-devel Add the implementation for exporting chains to JSON Format and for to test the function. --- Alvaro Neira Ayuso (2): Add function for exporting chain to JSON Format Implementation for to test the function for exporting chains to JSON format examples/nft-chain-get.c | 5 ++++- include/libnftables/chain.h | 1 + src/chain.c | 27 +++++++++++++++++++++++++++ src/internal.h | 1 + 4 files changed, 33 insertions(+), 1 deletion(-) -- Álvaro Neira Ayuso -- 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [libnftables PATCH 1/2] Add function for exporting chain to JSON Format 2013-06-08 13:35 [libnftables PATCH 0/2] Series short description Alvaro Neira @ 2013-06-08 13:36 ` Alvaro Neira 2013-06-08 17:31 ` Pablo Neira Ayuso 2013-06-08 13:36 ` [libnftables PATCH 2/2] Implementation for to test the function for exporting chains to JSON format Alvaro Neira 1 sibling, 1 reply; 6+ messages in thread From: Alvaro Neira @ 2013-06-08 13:36 UTC (permalink / raw) To: netfilter-devel From: Alvaro Neira Ayuso <alvaroneay@gmail.com> --- include/libnftables/chain.h | 1 + src/chain.c | 27 +++++++++++++++++++++++++++ src/internal.h | 1 + 3 files changed, 29 insertions(+) diff --git a/include/libnftables/chain.h b/include/libnftables/chain.h index f06f743..3645eaa 100644 --- a/include/libnftables/chain.h +++ b/include/libnftables/chain.h @@ -44,6 +44,7 @@ void nft_chain_nlmsg_build_payload(struct nlmsghdr *nlh, const struct nft_chain enum { NFT_CHAIN_O_DEFAULT = 0, NFT_CHAIN_O_XML, + NFT_CHAIN_O_JSON, }; enum nft_chain_parse_type { diff --git a/src/chain.c b/src/chain.c index 7775dfc..1c53daa 100644 --- a/src/chain.c +++ b/src/chain.c @@ -688,6 +688,31 @@ int nft_chain_parse(struct nft_chain *c, enum nft_chain_parse_type type, } EXPORT_SYMBOL(nft_chain_parse); +static int nft_chain_snprintf_json(char *buf, size_t size, struct nft_chain *c) +{ + return snprintf(buf, size, + "{ \"chain\": {" + "\"name\": \"%s\"," + "\"handle\": %lu," + "\"bytes\": %lu," + "\"packets\": %lu," + "\"version\": %d," + "\"properties\": {" + "\"type\" : \"%s\"," + "\"table\" : \"%s\"," + "\"prio\" : %d," + "\"use\" : %d," + "\"hooknum\" : %d," + "\"policy\" : %d," + "\"family\" : %d" + "}" + "}" + "}", + c->name, c->handle, c->bytes, c->packets, + NFT_CHAIN_JSON_VERSION, c->type, c->table, + c->prio, c->use, c->hooknum, c->policy, c->family); +} + static int nft_chain_snprintf_xml(char *buf, size_t size, struct nft_chain *c) { return snprintf(buf, size, @@ -721,6 +746,8 @@ int nft_chain_snprintf(char *buf, size_t size, struct nft_chain *c, uint32_t type, uint32_t flags) { switch(type) { + case NFT_CHAIN_O_JSON: + return nft_chain_snprintf_json(buf, size, c); case NFT_CHAIN_O_XML: return nft_chain_snprintf_xml(buf, size, c); case NFT_CHAIN_O_DEFAULT: diff --git a/src/internal.h b/src/internal.h index 0c5de21..769926b 100644 --- a/src/internal.h +++ b/src/internal.h @@ -21,6 +21,7 @@ #define NFT_CHAIN_XML_VERSION 0 #define NFT_RULE_XML_VERSION 0 #define NFT_TABLE_JSON_VERSION 0 +#define NFT_CHAIN_JSON_VERSION 0 struct expr_ops; ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [libnftables PATCH 1/2] Add function for exporting chain to JSON Format 2013-06-08 13:36 ` [libnftables PATCH 1/2] Add function for exporting chain to JSON Format Alvaro Neira @ 2013-06-08 17:31 ` Pablo Neira Ayuso 0 siblings, 0 replies; 6+ messages in thread From: Pablo Neira Ayuso @ 2013-06-08 17:31 UTC (permalink / raw) To: Alvaro Neira; +Cc: netfilter-devel Applied, thanks. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [libnftables PATCH 2/2] Implementation for to test the function for exporting chains to JSON format 2013-06-08 13:35 [libnftables PATCH 0/2] Series short description Alvaro Neira 2013-06-08 13:36 ` [libnftables PATCH 1/2] Add function for exporting chain to JSON Format Alvaro Neira @ 2013-06-08 13:36 ` Alvaro Neira 2013-06-08 17:32 ` Pablo Neira Ayuso 1 sibling, 1 reply; 6+ messages in thread From: Alvaro Neira @ 2013-06-08 13:36 UTC (permalink / raw) To: netfilter-devel From: Alvaro Neira Ayuso <alvaroneay@gmail.com> --- examples/nft-chain-get.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/nft-chain-get.c b/examples/nft-chain-get.c index b815523..459b79e 100644 --- a/examples/nft-chain-get.c +++ b/examples/nft-chain-get.c @@ -90,8 +90,11 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - if (strcmp(argv[argc-1], "xml") == 0) + if (strcmp(argv[argc-1], "xml") == 0){ type = NFT_CHAIN_O_XML; + }else if (strcmp(argv[argc-1], "json") == 0){ + type = NFT_CHAIN_O_JSON; + } nl = mnl_socket_open(NETLINK_NETFILTER); if (nl == NULL) { ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [libnftables PATCH 2/2] Implementation for to test the function for exporting chains to JSON format 2013-06-08 13:36 ` [libnftables PATCH 2/2] Implementation for to test the function for exporting chains to JSON format Alvaro Neira @ 2013-06-08 17:32 ` Pablo Neira Ayuso 0 siblings, 0 replies; 6+ messages in thread From: Pablo Neira Ayuso @ 2013-06-08 17:32 UTC (permalink / raw) To: Alvaro Neira; +Cc: netfilter-devel Applied, thanks Álvaro. -- 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [libnftables PATCH 0/2] Series short description @ 2013-06-07 9:14 Alvaro Neira 0 siblings, 0 replies; 6+ messages in thread From: Alvaro Neira @ 2013-06-07 9:14 UTC (permalink / raw) To: netfilter-devel The following series implements... I collapsed the patches. Now, you can compile libnftables without error if you apply the patch. I hope everything is correct. Thanks for all. --- Alvaro Neira (2): Add functions for exporting tables to JSON format Add implementation for to proof the JSON export function examples/nft-table-get.c | 4 ++++ include/libnftables/table.h | 1 + src/internal.h | 1 + src/table.c | 18 ++++++++++++++++++ 4 files changed, 24 insertions(+) -- Álvaro Neira Ayuso -- 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-06-08 17:32 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-06-08 13:35 [libnftables PATCH 0/2] Series short description Alvaro Neira 2013-06-08 13:36 ` [libnftables PATCH 1/2] Add function for exporting chain to JSON Format Alvaro Neira 2013-06-08 17:31 ` Pablo Neira Ayuso 2013-06-08 13:36 ` [libnftables PATCH 2/2] Implementation for to test the function for exporting chains to JSON format Alvaro Neira 2013-06-08 17:32 ` Pablo Neira Ayuso -- strict thread matches above, loose matches on Subject: below -- 2013-06-07 9:14 [libnftables PATCH 0/2] Series short description 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).