Skip to contentSkip to conversation

src: Use nftnl_buf to export XML/JSON rules

PATCH Applied Elise Lennion 2 participants 2 messages Mar 2, 2017 – Mar 3, 2017 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 src: Use nftnl_buf to export XML/JSON rules

This completes the use of nftnl_buf and its auxiliary functions to export XML/JSON rules.

Highly based on work from Shivani Bhardwaj <[email protected]>.

---
 include/buffer.h |  11 ++++++
 src/buffer.c     |  46 ++++++++++++++++++++++++
 src/rule.c       | 104 ++++++++++++++++---------------------------------------
 3 files changed, 86 insertions(+), 75 deletions(-)
include/buffer.h +11 -0
index c571657..f556895 100644
@@ -4,6 +4,8 @@
 #include <stdint.h>
 #include <stdbool.h>
 
+struct nftnl_expr;
+
 struct nftnl_buf {
 	char		*buf;
 	size_t		size;
@@ -35,12 +37,18 @@ int nftnl_buf_u64(struct nftnl_buf *b, int type, uint64_t value, const char *tag
 int 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_open(struct nftnl_buf *b, int type);
+int nftnl_buf_expr_close(struct nftnl_buf *b, int type);
+int nftnl_buf_expr(struct nftnl_buf *b, int type, uint32_t flags,
+		   struct nftnl_expr *expr);
 
 #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 +72,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"
@@ -93,5 +103,6 @@ int nftnl_buf_reg(struct nftnl_buf *b, int type, union nftnl_data_reg *reg,
 #define FLUSH			"flush"
 #define MODULUS			"modulus"
 #define SEED			"seed"
+#define ID			"id"
 
 #endif
src/buffer.c +46 -0

49 lines not on this page · raw message

src/rule.c +29 -75

130 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw
Quoted 4 lines · Elise Lennion

This completes the use of nftnl_buf and its auxiliary functions to export XML/JSON rules.

Highly based on work from Shivani Bhardwaj <[email protected]>.

Applied, thanks Elise.