Series short description
cover Series short description
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(+)
Signature · 5 lines
Álvaro Neira Ayuso -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/2 Add functions for exporting tables to JSON format
--- include/libnftables/table.h | 1 + src/internal.h | 1 + src/table.c | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+)
include/libnftables/table.h +1 -0
@@ -31,6 +31,7 @@ void nft_table_nlmsg_build_payload(struct nlmsghdr *nlh, const struct nft_tableenum {NFT_TABLE_O_DEFAULT =0 ,NFT_TABLE_O_XML , +NFT_TABLE_O_JSON , };enum nft_table_parse_type {
src/internal.h +1 -0
@@ -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 0struct expr_ops ;
src/table.c +18 -0
@@ -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 :
Re: [libnftables PATCH 1/2] Add functions for exporting tables to JSON format
Applied, thanks Alvaro.
PATCH 2/2 Add implementation for to proof the JSON export function
In reply to Alvaro Neira--- examples/nft-table-get.c | 4 ++++ 1 file changed, 4 insertions(+)
examples/nft-table-get.c +4 -0
@@ -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--; }
Pablo Neira Ayuso
maintainerRe: [libnftables PATCH 2/2] Add implementation for to proof the JSON export function
Also applied, thanks.
Quoted 25 lines · Alvaro Neira
--- examples/nft-table-get.c | 4 ++++ 1 file changed, 4 insertions(+)examples/nft-table-get.c +4
-1@@ -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--; } --To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html