src: delete exporting internal flags in XML
PATCH 1/2 src: delete exporting internal flags in XML
The uint32_t flags attribute is internal, so no need to export/import in XML.
--- src/chain.c | 5 ++--- src/table.c | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-)
src/chain.c +2 -3
@@ -452,7 +452,6 @@ static int nft_chain_snprintf_xml(char *buf, size_t size, struct nft_chain *c)"<chain name=\"%s\" handle=\"%lu\"" " bytes=\"%lu\" packets=\"%lu\">" "<properties>" -"<flags>%d</flags>" "<type>%s</type>" "<table>%s</table>" "<prio>%d</prio>"
@@ -463,8 +462,8 @@ static int nft_chain_snprintf_xml(char *buf, size_t size, struct nft_chain *c)"</properties>" "</chain>" , c->name, c->handle, c->bytes, c->packets, - c->flags, c->type, c->table, c->prio, - c->use, c->hooknum, c->policy, c->family); + c->type, c->table, c->prio, c->use, c->hooknum, + c->policy, c->family); }static int nft_chain_snprintf_default (char *buf,size_t size,struct nft_chain *c)
src/table.c +1 -2
@@ -188,11 +188,10 @@ static int nft_table_snprintf_xml(char *buf, size_t size, struct nft_table *t)"<table name=\"%s\">" "<properties>" "<family>%u</family>" -"<flags>%d</flags>" "<table_flags>%d</table_flags>" "</properties>" "</table>" , - t->name, t->family, t->flags, t->table_flags); + t->name, t->family, t->table_flags); }static int nft_table_snprintf_default (char *buf,size_t size,struct nft_table *t)
--
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 2/2 src: support for XML parsing
This patch adds capabilities for parsing a XML table/chain/rule
Some points to note:
* the XML data is case sensitive (so <chain>asd</chain> != <chain>ASD</chain> != <CHAIN>asd</CHAIN>)
* all exported functions will receive a XML and return an object (aka table|chain|rule)
* XML parsing is done with libmxml (http://minixml.org)
NOTE: expr/target and expr/match binary data are ignored.
Some code examples/test cases will be added to libnftables in a future patch.
--- Make_global.am | 2 configure.ac | 1 include/libnftables/chain.h | 1 include/libnftables/rule.h | 1 include/libnftables/table.h | 1 src/chain.c | 178 ++++++++++++++++++++++++++++++ src/expr/bitwise.c | 115 +++++++++++++++++++ src/expr/cmp.c | 99 +++++++++++++++++ src/expr/counter.c | 63 +++++++++++ src/expr/data_reg.c | 255 ++++++++++++++++++++++++++++++++++++++++++- src/expr/immediate.c | 98 +++++++++++++++++ src/expr/lookup.c | 75 +++++++++++++ src/expr/match.c | 57 ++++++++++ src/expr/meta.c | 64 +++++++++++ src/expr/nat.c | 130 ++++++++++++++++++++++ src/expr/payload.c | 89 +++++++++++++++ src/expr/target.c | 59 ++++++++++ src/expr_ops.h | 1 src/libnftables.map | 3 + src/rule.c | 169 ++++++++++++++++++++++++++++ src/table.c | 78 +++++++++++++ 21 files changed, 1535 insertions(+), 4 deletions(-)
Make_global.am +1 -1
@@ -20,5 +20,5 @@ # LIBVERSION=0:0:0 -AM_CPPFLAGS = ${regular_CPPFLAGS} -I${top_srcdir}/include ${LIBMNL_CFLAGS} +AM_CPPFLAGS = ${regular_CPPFLAGS} -I${top_srcdir}/include ${LIBMNL_CFLAGS} ${LIBMXML_CFLAGS} AM_CFLAGS = ${regular_CFLAGS} ${GCC_FVISIBILITY_HIDDEN}
configure.ac +1 -0
@@ -14,6 +14,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) dnl Dependencies PKG_CHECK_MODULES([LIBMNL], [libmnl >= 1.0.0]) +PKG_CHECK_MODULES([LIBMXML], [mxml >= 2.6]) AC_PROG_CC AM_PROG_CC_C_O
include/libnftables/chain.h +1 -0
@@ -44,6 +44,7 @@ enum { NFT_CHAIN_O_XML, }; +int nft_chain_xml_parse (struct nft_chain *c,char *xml);int nft_chain_snprintf (char *buf,size_t size,struct nft_chain *t,uint32_t type,uint32_t flags);struct nlmsghdr *nft_chain_nlmsg_build_hdr (char *buf,uint16_t cmd,uint16_t family,uint16_t type,uint32_t seq);
include/libnftables/rule.h +1 -0
@@ -43,6 +43,7 @@ enum { NFT_RULE_O_XML, }; +int nft_rule_xml_parse (struct nft_rule *r,char *xml);int nft_rule_snprintf (char *buf,size_t size,struct nft_rule *t,uint32_t type,uint32_t flags);struct nlmsghdr *nft_rule_nlmsg_build_hdr (char *buf,uint16_t cmd,uint16_t family,uint16_t type,uint32_t seq);
include/libnftables/table.h +1 -0
@@ -31,6 +31,7 @@ enum { NFT_TABLE_O_XML, }; +int nft_table_xml_parse (struct nft_table *t,char *xml);int nft_table_snprintf (char *buf,size_t size,struct nft_table *t,uint32_t type,uint32_t flags);struct nlmsghdr *nft_table_nlmsg_build_hdr (char *buf,uint16_t cmd,uint16_t family,uint16_t type,uint32_t seq);
src/chain.c +178 -0
190 lines not on this page · raw message
src/expr/bitwise.c +115 -0
131 lines not on this page · raw message
src/expr/cmp.c +99 -0
115 lines not on this page · raw message
src/expr/counter.c +63 -0
79 lines not on this page · raw message
src/expr/data_reg.c +252 -3
270 lines not on this page · raw message
src/expr/immediate.c +98 -0
114 lines not on this page · raw message
src/expr/lookup.c +75 -0
91 lines not on this page · raw message
src/expr/match.c +57 -0
73 lines not on this page · raw message
src/expr/meta.c +64 -0
80 lines not on this page · raw message
src/expr/nat.c +130 -0
152 lines not on this page · raw message
src/expr/payload.c +89 -0
111 lines not on this page · raw message
src/expr/target.c +59 -0
75 lines not on this page · raw message
src/expr_ops.h +1 -0
@@ -17,6 +17,7 @@ struct expr_ops {int (*parse)(struct nft_rule_expr *e,struct nlattr *attr);void (*build)(struct nlmsghdr *nlh,struct nft_rule_expr *e);int (*snprintf)(char *buf,size_t len,uint32_t type,uint32_t flags,struct nft_rule_expr *e); +int (*xml_parse)(struct nft_rule_expr *e,char *xml); };struct expr_ops *nft_expr_ops_lookup (const char *name);
src/libnftables.map +3 -0
@@ -6,6 +6,7 @@ global: nft_table_attr_get; nft_table_attr_set_u32; nft_table_attr_get_u32; + nft_table_xml_parse; nft_table_snprintf; nft_table_nlmsg_build_hdr; nft_table_nlmsg_build_payload;
@@ -28,6 +29,7 @@ global: nft_chain_attr_get_s32; nft_chain_attr_get_u64; nft_chain_attr_get_str; + nft_chain_xml_parse; nft_chain_snprintf; nft_chain_nlmsg_build_hdr; nft_chain_nlmsg_build_payload;
@@ -51,6 +53,7 @@ global: nft_rule_attr_get_u32; nft_rule_attr_get_u64; nft_rule_attr_get_str; + nft_rule_xml_parse; nft_rule_snprintf; nft_rule_nlmsg_build_hdr; nft_rule_nlmsg_build_payload;
src/rule.c +169 -0
181 lines not on this page · raw message
src/table.c +78 -0
96 lines not on this page · raw message
--
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
Pablo Neira Ayuso
maintainerRe: [libnftables PATCH 2/2] src: support for XML parsing
Quoted 8 lines · Arturo Borrero
This patch adds capabilities for parsing a XML table/chain/rule
Some points to note: * the XML data is case sensitive (so <chain>asd</chain> != <chain>ASD</chain> != <CHAIN>asd</CHAIN>) * all exported functions will receive a XML and return an object (aka table|chain|rule) * XML parsing is done with libmxml
(http://minixml.org)
Quoted 4 lines
NOTE: expr/target and expr/match binary data are ignored.
Some code examples/test cases will be added to libnftables in a future patch.
Please, you have to change this to some --enable-xml-parser option via hen ./configure, so it's not a hard dependency on libmxml.
Re: [libnftables PATCH 2/2] src: support for XML parsing
2013/5/3 Pablo Neira Ayuso <[email protected]>:
Quoted 2 lines
Please, you have to change this to some --enable-xml-parser option via hen ./configure, so it's not a hard dependency on libmxml.
I need some help.
I have conditional package checking, something like this in configure.ac:
[...]
dnl DependenciesPKG_CHECK_MODULES([LIBMNL], [libmnl >= 1.0.0]) AC_ARG_WITH([xml], AS_HELP_STRING([--with-xml-parsing], [Build with XML parsing]))
AS_IF([test "x$with_xml_parsing" = "xyes"], [
PKG_CHECK_MODULES([LIBXML], [mxml >= 2.6])
])
[...]
This way, mxml is only checked if configure was run like this:
$ ./configure --with-xml-parsing
Then, I think I need some way to get makefiles updated, so I could do:
[...]
#ifdef XML_PARSING
#include <mxml.h>
#endif
[...]
I think this could be achieve with
$ gcc: -DXML_PARSING [...]
Running './configure --with-xml-parsing' needs to generate some variable or modify Makefile.am or Make_global.am so I can pass to gcc the -DXML_PARSING option.
Please, consider this a bad explanation or even that my approach is actually wrong.
Any idea?
Regards
--
Arturo Borrero González
--
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
Re: [libnftables PATCH 2/2] src: support for XML parsing
2013/5/8 Arturo Borrero Gonzalez <[email protected]>:
Quoted 4 lines
Running './configure --with-xml-parsing' needs to generate some variable or modify Makefile.am or Make_global.am so I can pass to gcc the -DXML_PARSING option.
Ok, I did this:
[...]
regular_CPPFLAGS="-D_FILE_OFFSET_BITS=64 -D_REENTRANT" AS_IF([test "x$with_xml_parsing" = "xyes"], [
regular_CPPFLAGS="$regular_CPPFLAGS -DXML_PARSING"
])
[...]
that seems to work.
--
Arturo Borrero González
--
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
Quoted 2 lines · Arturo Borrero
The
uint32_tflags attribute is internal, so no need to export/import in XML.
Applied, thanks Arturo.