src: consolidate XML/JSON exportation for rule
PATCH 1/1 src: consolidate XML/JSON exportation for rule
This completes the XML/JSON exportation using the new buffer class for rule.
Signed-off-by Shivani Bhardwaj <[email protected]>
--- include/buffer.h | 5 +++ src/buffer.c | 11 +++++++ src/rule.c | 96 ++++++++++++++++---------------------------------------- 3 files changed, 43 insertions(+), 69 deletions(-)
include/buffer.h +5 -0
@@ -35,12 +35,15 @@ int nftnl_buf_u64(struct nftnl_buf *b, int type, uint64_t value, const char *tagint nftnl_buf_str (struct nftnl_buf *b,int type,const char *str,const char *tag);int nftnl_buf_reg (struct nftnl_buf *b,int type,union nftnl_data_reg *reg,int reg_type,const char *tag); +int nftnl_buf_expr (struct nftnl_buf *b,int type);#define BASE "base"#define BYTES "bytes"#define BURST "burst"#define CHAIN "chain"#define CODE "code" +#define COMPAT_FLAGS "compat_flags" +#define COMPAT_PROTO "compat_proto"#define CONSUMED "consumed"#define DATA "data"#define DEVICE "device"
@@ -64,10 +67,12 @@ int nftnl_buf_reg(struct nftnl_buf *b, int type, union nftnl_data_reg *reg,#define PACKETS "packets"#define PKTS "pkts"#define POLICY "policy" +#define POSITION "position"#define PREFIX "prefix"#define PRIO "prio"#define QTHRESH "qthreshold"#define RATE "rate" +#define RULE "rule"#define SET "set"#define SET_NAME "set_name"#define SIZE "size"
src/buffer.c +11 -0
@@ -171,3 +171,14 @@ int nftnl_buf_reg(struct nftnl_buf *b, int type, union nftnl_data_reg *reg, }return 0 ; } + +int nftnl_buf_expr (struct nftnl_buf *b,int type) +{ +switch (type) { +case NFTNL_OUTPUT_XML : +return 0 ; +case NFTNL_OUTPUT_JSON : +return nftnl_buf_put (b,"\"expr\":[{" ); + } +return 0 ; +}
src/rule.c +27 -69
123 lines not on this page · raw message
Signature · 1 line
2.7.4
Quoted 10 lines · Shivani Bhardwaj
This completes the XML/JSON exportation using the new buffer class for rule.
Signed-off-by Shivani Bhardwaj <[email protected]>--- include/buffer.h | 5 +++ src/buffer.c | 11 +++++++ src/rule.c | 96 ++++++++++++++++---------------------------------------- 3 files changed, 43 insertions(+), 69 deletions(-)
Quoted 2 lines · Shivani Bhardwaj
This completes the XML/JSON exportation using the new buffer class for rule.
Applied, thanks Shivani.
Pablo Neira Ayuso
maintainerQuoted 5 lines · Pablo Neira Ayuso
Quoted 2 lines · Shivani Bhardwaj
This completes the XML/JSON exportation using the new buffer class for rule.
Applied, thanks Shivani.
Hm, there's some problem here, look:
drule.c: In function 'nftnl_rule_export':
rule.c:677:27: warning: passing argument 3 of 'vsnprintf' makes pointer from integer without a cast
vsnprintf(b.buf, b.len, flags, expr);
^
In file included from ../include/utils.h:4:0,
from ../include/internal.h:7,
from rule.c:11:
/usr/include/stdio.h:390:12: note: expected 'const char *
__restrict__' but argument is of type 'uint32_t' extern int vsnprintf (char *__restrict __s, size_t __maxlen,
^
rule.c:677:34: warning: passing argument 4 of 'vsnprintf' from incompatible pointer type vsnprintf(b.buf, b.len, flags, expr);
vsnprintf(b.buf, b.len, flags, expr);
^
In file included from ../include/utils.h:4:0,
from ../include/internal.h:7,
from rule.c:11:
/usr/include/stdio.h:390:12: note: expected 'struct __va_list_tag *' but argument is of type 'struct nftnl_expr *'
extern int vsnprintf (char *__restrict __s, size_t __maxlen,
^