set: add xml output
PATCH 1/1 set: add xml output
This patch adds XML output for sets.
Signed-off-by Arturo Borrero Gonzalez <[email protected]>
--- examples/nft-set-elem-get.c | 5 +++ examples/nft-set-get.c | 4 ++- include/libnftables/set.h | 1 + src/internal.h | 1 + src/set.c | 45 ++++++++++++++++++++++++++++- src/set_elem.c | 66 ++++++++++++++++++++++++++++++++++++++++++- 6 files changed, 117 insertions(+), 5 deletions(-)
examples/nft-set-elem-get.c +4 -1
@@ -56,7 +56,8 @@ int main(int argc, char *argv[])int ret;if (argc <4 || argc >5 ) { -fprintf (stderr,"%s <family> <table> <set> [default|json]\n" , argv[0 ]); +fprintf (stderr,"%s <family> <table> <set> [{json|xml}]\n" , + argv[0 ]);return EXIT_FAILURE ; } t =nft_set_alloc ();
@@ -78,6 +79,8 @@ int main(int argc, char *argv[])if (argc ==5 &&strcmp (argv[4 ],"json" ) ==0 ) type =NFT_SET_O_JSON ; +else if (argc ==5 &&strcmp (argv[4 ],"xml" ) ==0 ) + type =NFT_SET_O_XML ; nlh =nft_set_nlmsg_build_hdr (buf,NFT_MSG_GETSETELEM , family,NLM_F_DUMP |NLM_F_ACK , seq);
examples/nft-set-get.c +3 -1
@@ -56,7 +56,7 @@ int main(int argc, char *argv[])int ret;if (argc <3 || argc >4 ) { -fprintf (stderr,"%s <family> <table> [default|json]\n" , argv[0 ]); +fprintf (stderr,"%s <family> <table> [{json|xml}]\n" , argv[0 ]);return EXIT_FAILURE ; } t =nft_set_alloc ();
@@ -78,6 +78,8 @@ int main(int argc, char *argv[])if (argc ==4 &&strcmp (argv[3 ],"json" ) ==0 ) type =NFT_SET_O_JSON ; +else if (argc ==4 &&strcmp (argv[3 ],"xml" ) ==0 ) + type =NFT_SET_O_XML ; nlh =nft_set_nlmsg_build_hdr (buf,NFT_MSG_GETSET , family,NLM_F_DUMP |NLM_F_ACK , seq);
include/libnftables/set.h +1 -0
@@ -64,6 +64,7 @@ enum {enum {NFT_SET_O_DEFAULT =0 , +NFT_SET_O_XML ,NFT_SET_O_JSON , };
src/internal.h +1 -0
@@ -24,6 +24,7 @@ int nft_mxml_data_reg_parse(mxml_node_t *tree, const char *node_name, union nft_#define NFT_TABLE_XML_VERSION 0#define NFT_CHAIN_XML_VERSION 0#define NFT_RULE_XML_VERSION 0 +#define NFT_SET_XML_VERSION 0#define NFT_TABLE_JSON_VERSION 0#define NFT_CHAIN_JSON_VERSION 0#define NFT_RULE_JSON_VERSION 0
src/set.c +43 -2
68 lines not on this page · raw message
src/set_elem.c +65 -1
96 lines not on this page · raw message
Quoted 1 line · Arturo Borrero Gonzalez
This patch adds XML output for sets.
Applied, thanks Arturo.